Files
MultiRoombaRover/server/public/assets/index-CCaG2_WI.js
T
2026-04-19 01:34:04 -04:00

126 lines
542 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))o(f);new MutationObserver(f=>{for(const d of f)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function i(f){const d={};return f.integrity&&(d.integrity=f.integrity),f.referrerPolicy&&(d.referrerPolicy=f.referrerPolicy),f.crossOrigin==="use-credentials"?d.credentials="include":f.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(f){if(f.ep)return;f.ep=!0;const d=i(f);fetch(f.href,d)}})();function Py(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var zu={exports:{}},ni={};var s0;function Wy(){if(s0)return ni;s0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function i(o,f,d){var h=null;if(d!==void 0&&(h=""+d),f.key!==void 0&&(h=""+f.key),"key"in f){d={};for(var p in f)p!=="key"&&(d[p]=f[p])}else d=f;return f=d.ref,{$$typeof:n,type:o,key:h,ref:f!==void 0?f:null,props:d}}return ni.Fragment=s,ni.jsx=i,ni.jsxs=i,ni}var l0;function eb(){return l0||(l0=1,zu.exports=Wy()),zu.exports}var r=eb(),Uu={exports:{}},Ce={};var i0;function tb(){if(i0)return Ce;i0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),S=Symbol.iterator;function R(q){return q===null||typeof q!="object"?null:(q=S&&q[S]||q["@@iterator"],typeof q=="function"?q:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function w(q,V,P){this.props=q,this.context=V,this.refs=j,this.updater=P||N}w.prototype.isReactComponent={},w.prototype.setState=function(q,V){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,V,"setState")},w.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function E(){}E.prototype=w.prototype;function C(q,V,P){this.props=q,this.context=V,this.refs=j,this.updater=P||N}var M=C.prototype=new E;M.constructor=C,k(M,w.prototype),M.isPureReactComponent=!0;var B=Array.isArray;function H(){}var _={H:null,A:null,T:null,S:null},K=Object.prototype.hasOwnProperty;function L(q,V,P){var ne=P.ref;return{$$typeof:n,type:q,key:V,ref:ne!==void 0?ne:null,props:P}}function U(q,V){return L(q.type,V,q.props)}function F(q){return typeof q=="object"&&q!==null&&q.$$typeof===n}function te(q){var V={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(P){return V[P]})}var fe=/\/+/g;function ce(q,V){return typeof q=="object"&&q!==null&&q.key!=null?te(""+q.key):V.toString(36)}function Y(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(H,H):(q.status="pending",q.then(function(V){q.status==="pending"&&(q.status="fulfilled",q.value=V)},function(V){q.status==="pending"&&(q.status="rejected",q.reason=V)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function T(q,V,P,ne,pe){var ie=typeof q;(ie==="undefined"||ie==="boolean")&&(q=null);var oe=!1;if(q===null)oe=!0;else switch(ie){case"bigint":case"string":case"number":oe=!0;break;case"object":switch(q.$$typeof){case n:case s:oe=!0;break;case y:return oe=q._init,T(oe(q._payload),V,P,ne,pe)}}if(oe)return pe=pe(q),oe=ne===""?"."+ce(q,0):ne,B(pe)?(P="",oe!=null&&(P=oe.replace(fe,"$&/")+"/"),T(pe,V,P,"",function(xe){return xe})):pe!=null&&(F(pe)&&(pe=U(pe,P+(pe.key==null||q&&q.key===pe.key?"":(""+pe.key).replace(fe,"$&/")+"/")+oe)),V.push(pe)),1;oe=0;var ve=ne===""?".":ne+":";if(B(q))for(var ye=0;ye<q.length;ye++)ne=q[ye],ie=ve+ce(ne,ye),oe+=T(ne,V,P,ie,pe);else if(ye=R(q),typeof ye=="function")for(q=ye.call(q),ye=0;!(ne=q.next()).done;)ne=ne.value,ie=ve+ce(ne,ye++),oe+=T(ne,V,P,ie,pe);else if(ie==="object"){if(typeof q.then=="function")return T(Y(q),V,P,ne,pe);throw V=String(q),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return oe}function X(q,V,P){if(q==null)return q;var ne=[],pe=0;return T(q,ne,"","",function(ie){return V.call(P,ie,pe++)}),ne}function J(q){if(q._status===-1){var V=q._result;V=V(),V.then(function(P){(q._status===0||q._status===-1)&&(q._status=1,q._result=P)},function(P){(q._status===0||q._status===-1)&&(q._status=2,q._result=P)}),q._status===-1&&(q._status=0,q._result=V)}if(q._status===1)return q._result.default;throw q._result}var se=typeof reportError=="function"?reportError:function(q){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof q=="object"&&q!==null&&typeof q.message=="string"?String(q.message):String(q),error:q});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",q);return}console.error(q)},de={map:X,forEach:function(q,V,P){X(q,function(){V.apply(this,arguments)},P)},count:function(q){var V=0;return X(q,function(){V++}),V},toArray:function(q){return X(q,function(V){return V})||[]},only:function(q){if(!F(q))throw Error("React.Children.only expected to receive a single React element child.");return q}};return Ce.Activity=b,Ce.Children=de,Ce.Component=w,Ce.Fragment=i,Ce.Profiler=f,Ce.PureComponent=C,Ce.StrictMode=o,Ce.Suspense=x,Ce.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,Ce.__COMPILER_RUNTIME={__proto__:null,c:function(q){return _.H.useMemoCache(q)}},Ce.cache=function(q){return function(){return q.apply(null,arguments)}},Ce.cacheSignal=function(){return null},Ce.cloneElement=function(q,V,P){if(q==null)throw Error("The argument must be a React element, but you passed "+q+".");var ne=k({},q.props),pe=q.key;if(V!=null)for(ie in V.key!==void 0&&(pe=""+V.key),V)!K.call(V,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&V.ref===void 0||(ne[ie]=V[ie]);var ie=arguments.length-2;if(ie===1)ne.children=P;else if(1<ie){for(var oe=Array(ie),ve=0;ve<ie;ve++)oe[ve]=arguments[ve+2];ne.children=oe}return L(q.type,pe,ne)},Ce.createContext=function(q){return q={$$typeof:h,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null},q.Provider=q,q.Consumer={$$typeof:d,_context:q},q},Ce.createElement=function(q,V,P){var ne,pe={},ie=null;if(V!=null)for(ne in V.key!==void 0&&(ie=""+V.key),V)K.call(V,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(pe[ne]=V[ne]);var oe=arguments.length-2;if(oe===1)pe.children=P;else if(1<oe){for(var ve=Array(oe),ye=0;ye<oe;ye++)ve[ye]=arguments[ye+2];pe.children=ve}if(q&&q.defaultProps)for(ne in oe=q.defaultProps,oe)pe[ne]===void 0&&(pe[ne]=oe[ne]);return L(q,ie,pe)},Ce.createRef=function(){return{current:null}},Ce.forwardRef=function(q){return{$$typeof:p,render:q}},Ce.isValidElement=F,Ce.lazy=function(q){return{$$typeof:y,_payload:{_status:-1,_result:q},_init:J}},Ce.memo=function(q,V){return{$$typeof:g,type:q,compare:V===void 0?null:V}},Ce.startTransition=function(q){var V=_.T,P={};_.T=P;try{var ne=q(),pe=_.S;pe!==null&&pe(P,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(H,se)}catch(ie){se(ie)}finally{V!==null&&P.types!==null&&(V.types=P.types),_.T=V}},Ce.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},Ce.use=function(q){return _.H.use(q)},Ce.useActionState=function(q,V,P){return _.H.useActionState(q,V,P)},Ce.useCallback=function(q,V){return _.H.useCallback(q,V)},Ce.useContext=function(q){return _.H.useContext(q)},Ce.useDebugValue=function(){},Ce.useDeferredValue=function(q,V){return _.H.useDeferredValue(q,V)},Ce.useEffect=function(q,V){return _.H.useEffect(q,V)},Ce.useEffectEvent=function(q){return _.H.useEffectEvent(q)},Ce.useId=function(){return _.H.useId()},Ce.useImperativeHandle=function(q,V,P){return _.H.useImperativeHandle(q,V,P)},Ce.useInsertionEffect=function(q,V){return _.H.useInsertionEffect(q,V)},Ce.useLayoutEffect=function(q,V){return _.H.useLayoutEffect(q,V)},Ce.useMemo=function(q,V){return _.H.useMemo(q,V)},Ce.useOptimistic=function(q,V){return _.H.useOptimistic(q,V)},Ce.useReducer=function(q,V,P){return _.H.useReducer(q,V,P)},Ce.useRef=function(q){return _.H.useRef(q)},Ce.useState=function(q){return _.H.useState(q)},Ce.useSyncExternalStore=function(q,V,P){return _.H.useSyncExternalStore(q,V,P)},Ce.useTransition=function(){return _.H.useTransition()},Ce.version="19.2.0",Ce}var r0;function Df(){return r0||(r0=1,Uu.exports=tb()),Uu.exports}var m=Df();const rs=Py(m);var Hu={exports:{}},ai={},Vu={exports:{}},$u={};var o0;function nb(){return o0||(o0=1,(function(n){function s(T,X){var J=T.length;T.push(X);e:for(;0<J;){var se=J-1>>>1,de=T[se];if(0<f(de,X))T[se]=X,T[J]=de,J=se;else break e}}function i(T){return T.length===0?null:T[0]}function o(T){if(T.length===0)return null;var X=T[0],J=T.pop();if(J!==X){T[0]=J;e:for(var se=0,de=T.length,q=de>>>1;se<q;){var V=2*(se+1)-1,P=T[V],ne=V+1,pe=T[ne];if(0>f(P,J))ne<de&&0>f(pe,P)?(T[se]=pe,T[ne]=J,se=ne):(T[se]=P,T[V]=J,se=V);else if(ne<de&&0>f(pe,J))T[se]=pe,T[ne]=J,se=ne;else break e}}return X}function f(T,X){var J=T.sortIndex-X.sortIndex;return J!==0?J:T.id-X.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var h=Date,p=h.now();n.unstable_now=function(){return h.now()-p}}var x=[],g=[],y=1,b=null,S=3,R=!1,N=!1,k=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function M(T){for(var X=i(g);X!==null;){if(X.callback===null)o(g);else if(X.startTime<=T)o(g),X.sortIndex=X.expirationTime,s(x,X);else break;X=i(g)}}function B(T){if(k=!1,M(T),!N)if(i(x)!==null)N=!0,H||(H=!0,te());else{var X=i(g);X!==null&&Y(B,X.startTime-T)}}var H=!1,_=-1,K=5,L=-1;function U(){return j?!0:!(n.unstable_now()-L<K)}function F(){if(j=!1,H){var T=n.unstable_now();L=T;var X=!0;try{e:{N=!1,k&&(k=!1,E(_),_=-1),R=!0;var J=S;try{t:{for(M(T),b=i(x);b!==null&&!(b.expirationTime>T&&U());){var se=b.callback;if(typeof se=="function"){b.callback=null,S=b.priorityLevel;var de=se(b.expirationTime<=T);if(T=n.unstable_now(),typeof de=="function"){b.callback=de,M(T),X=!0;break t}b===i(x)&&o(x),M(T)}else o(x);b=i(x)}if(b!==null)X=!0;else{var q=i(g);q!==null&&Y(B,q.startTime-T),X=!1}}break e}finally{b=null,S=J,R=!1}X=void 0}}finally{X?te():H=!1}}}var te;if(typeof C=="function")te=function(){C(F)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,ce=fe.port2;fe.port1.onmessage=F,te=function(){ce.postMessage(null)}}else te=function(){w(F,0)};function Y(T,X){_=w(function(){T(n.unstable_now())},X)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(T){T.callback=null},n.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<T?Math.floor(1e3/T):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(T){switch(S){case 1:case 2:case 3:var X=3;break;default:X=S}var J=S;S=X;try{return T()}finally{S=J}},n.unstable_requestPaint=function(){j=!0},n.unstable_runWithPriority=function(T,X){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var J=S;S=T;try{return X()}finally{S=J}},n.unstable_scheduleCallback=function(T,X,J){var se=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?se+J:se):J=se,T){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=J+de,T={id:y++,callback:X,priorityLevel:T,startTime:J,expirationTime:de,sortIndex:-1},J>se?(T.sortIndex=J,s(g,T),i(x)===null&&T===i(g)&&(k?(E(_),_=-1):k=!0,Y(B,J-se))):(T.sortIndex=de,s(x,T),N||R||(N=!0,H||(H=!0,te()))),T},n.unstable_shouldYield=U,n.unstable_wrapCallback=function(T){var X=S;return function(){var J=S;S=X;try{return T.apply(this,arguments)}finally{S=J}}}})($u)),$u}var c0;function ab(){return c0||(c0=1,Vu.exports=nb()),Vu.exports}var Gu={exports:{}},Ot={};var u0;function sb(){if(u0)return Ot;u0=1;var n=Df();function s(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)g+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+x+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var o={d:{f:i,r:function(){throw Error(s(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},f=Symbol.for("react.portal");function d(x,g,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:b==null?null:""+b,children:x,containerInfo:g,implementation:y}}var h=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Ot.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Ot.createPortal=function(x,g){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(s(299));return d(x,g,null,y)},Ot.flushSync=function(x){var g=h.T,y=o.p;try{if(h.T=null,o.p=2,x)return x()}finally{h.T=g,o.p=y,o.d.f()}},Ot.preconnect=function(x,g){typeof x=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(x,g))},Ot.prefetchDNS=function(x){typeof x=="string"&&o.d.D(x)},Ot.preinit=function(x,g){if(typeof x=="string"&&g&&typeof g.as=="string"){var y=g.as,b=p(y,g.crossOrigin),S=typeof g.integrity=="string"?g.integrity:void 0,R=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:S,fetchPriority:R}):y==="script"&&o.d.X(x,{crossOrigin:b,integrity:S,fetchPriority:R,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Ot.preinitModule=function(x,g){if(typeof x=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=p(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(x)},Ot.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,b=p(y,g.crossOrigin);o.d.L(x,y,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Ot.preloadModule=function(x,g){if(typeof x=="string")if(g){var y=p(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(x)},Ot.requestFormReset=function(x){o.d.r(x)},Ot.unstable_batchedUpdates=function(x,g){return x(g)},Ot.useFormState=function(x,g,y){return h.H.useFormState(x,g,y)},Ot.useFormStatus=function(){return h.H.useHostTransitionStatus()},Ot.version="19.2.0",Ot}var f0;function lb(){if(f0)return Gu.exports;f0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),Gu.exports=sb(),Gu.exports}var d0;function ib(){if(d0)return ai;d0=1;var n=ab(),s=Df(),i=lb();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(d(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(o(188));return t!==e?null:e}for(var a=e,l=t;;){var c=a.return;if(c===null)break;var u=c.alternate;if(u===null){if(l=c.return,l!==null){a=l;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===a)return x(c),e;if(u===l)return x(c),t;u=u.sibling}throw Error(o(188))}if(a.return!==l.return)a=c,l=u;else{for(var v=!1,A=c.child;A;){if(A===a){v=!0,a=c,l=u;break}if(A===l){v=!0,l=c,a=u;break}A=A.sibling}if(!v){for(A=u.child;A;){if(A===a){v=!0,a=u,l=c;break}if(A===l){v=!0,l=u,a=c;break}A=A.sibling}if(!v)throw Error(o(189))}}if(a.alternate!==l)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?e:t}function y(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=y(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,S=Symbol.for("react.element"),R=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),C=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function te(e){return e===null||typeof e!="object"?null:(e=F&&e[F]||e["@@iterator"],typeof e=="function"?e:null)}var fe=Symbol.for("react.client.reference");function ce(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case w:return"Profiler";case j:return"StrictMode";case B:return"Suspense";case H:return"SuspenseList";case L:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case N:return"Portal";case C:return e.displayName||"Context";case E:return(e._context.displayName||"Context")+".Consumer";case M:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _:return t=e.displayName||null,t!==null?t:ce(e.type)||"Memo";case K:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var Y=Array.isArray,T=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},se=[],de=-1;function q(e){return{current:e}}function V(e){0>de||(e.current=se[de],se[de]=null,de--)}function P(e,t){de++,se[de]=e.current,e.current=t}var ne=q(null),pe=q(null),ie=q(null),oe=q(null);function ve(e,t){switch(P(ie,t),P(pe,e),P(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ep(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ep(t),e=kp(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}V(ne),P(ne,e)}function ye(){V(ne),V(pe),V(ie)}function xe(e){e.memoizedState!==null&&P(oe,e);var t=ne.current,a=kp(t,e.type);t!==a&&(P(pe,e),P(ne,a))}function Ue(e){pe.current===e&&(V(ne),V(pe)),oe.current===e&&(V(oe),Pl._currentValue=J)}var $e,Ne;function ae(e){if($e===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);$e=t&&t[1]||"",Ne=-1<a.stack.indexOf(`
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
`+$e+e+Ne}var ue=!1;function be(e,t){if(!e||ue)return"";ue=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(Z){var Q=Z}Reflect.construct(e,[],ee)}else{try{ee.call()}catch(Z){Q=Z}e.call(ee.prototype)}}else{try{throw Error()}catch(Z){Q=Z}(ee=e())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(Z){if(Z&&Q&&typeof Z.stack=="string")return[Z.stack,Q.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=l.DetermineComponentFrameRoot(),v=u[0],A=u[1];if(v&&A){var D=v.split(`
`),G=A.split(`
`);for(c=l=0;l<D.length&&!D[l].includes("DetermineComponentFrameRoot");)l++;for(;c<G.length&&!G[c].includes("DetermineComponentFrameRoot");)c++;if(l===D.length||c===G.length)for(l=D.length-1,c=G.length-1;1<=l&&0<=c&&D[l]!==G[c];)c--;for(;1<=l&&0<=c;l--,c--)if(D[l]!==G[c]){if(l!==1||c!==1)do if(l--,c--,0>c||D[l]!==G[c]){var I=`
`+D[l].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=l&&0<=c);break}}}finally{ue=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?ae(a):""}function Me(e,t){switch(e.tag){case 26:case 27:case 5:return ae(e.type);case 16:return ae("Lazy");case 13:return e.child!==t&&t!==null?ae("Suspense Fallback"):ae("Suspense");case 19:return ae("SuspenseList");case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return ae("Activity");default:return""}}function le(e){try{var t="",a=null;do t+=Me(e,a),a=e,e=e.return;while(e);return t}catch(l){return`
Error generating stack: `+l.message+`
`+l.stack}}var re=Object.prototype.hasOwnProperty,me=n.unstable_scheduleCallback,we=n.unstable_cancelCallback,et=n.unstable_shouldYield,dt=n.unstable_requestPaint,ze=n.unstable_now,xt=n.unstable_getCurrentPriorityLevel,mt=n.unstable_ImmediatePriority,Tn=n.unstable_UserBlockingPriority,kt=n.unstable_NormalPriority,cs=n.unstable_LowPriority,Gt=n.unstable_IdlePriority,Oa=n.log,Eo=n.unstable_setDisableYieldValue,Dn=null,jt=null;function Yt(e){if(typeof Oa=="function"&&Eo(e),jt&&typeof jt.setStrictMode=="function")try{jt.setStrictMode(Dn,e)}catch{}}var Mt=Math.clz32?Math.clz32:us,ca=Math.log,ko=Math.LN2;function us(e){return e>>>=0,e===0?32:31-(ca(e)/ko|0)|0}var fs=256,Ba=262144,tt=4194304;function _n(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function jn(e,t,a){var l=e.pendingLanes;if(l===0)return 0;var c=0,u=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var A=l&134217727;return A!==0?(l=A&~u,l!==0?c=_n(l):(v&=A,v!==0?c=_n(v):a||(a=A&~e,a!==0&&(c=_n(a))))):(A=l&~u,A!==0?c=_n(A):v!==0?c=_n(v):a||(a=l&~e,a!==0&&(c=_n(a)))),c===0?0:t!==0&&t!==c&&(t&u)===0&&(u=c&-c,a=t&-t,u>=a||u===32&&(a&4194048)!==0)?t:c}function On(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ds(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 ul(){var e=tt;return tt<<=1,(tt&62914560)===0&&(tt=4194304),e}function fl(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function La(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Mo(e,t,a,l,c,u){var v=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var A=e.entanglements,D=e.expirationTimes,G=e.hiddenUpdates;for(a=v&~a;0<a;){var I=31-Mt(a),ee=1<<I;A[I]=0,D[I]=-1;var Q=G[I];if(Q!==null)for(G[I]=null,I=0;I<Q.length;I++){var Z=Q[I];Z!==null&&(Z.lane&=-536870913)}a&=~ee}l!==0&&dl(e,l,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(v&~t))}function dl(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var l=31-Mt(t);e.entangledLanes|=t,e.entanglements[l]=e.entanglements[l]|1073741824|a&261930}function en(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var l=31-Mt(a),c=1<<l;c&t|e[l]&t&&(e[l]|=t),a&=~c}}function Ae(e,t){var a=t&-t;return a=(a&42)!==0?1:Ke(a),(a&(e.suspendedLanes|t))!==0?0:a}function Ke(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Pe(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function qe(){var e=X.p;return e!==0?e:(e=window.event,e===void 0?32:Jp(e.type))}function Ye(e,t){var a=X.p;try{return X.p=e,t()}finally{X.p=a}}var it=Math.random().toString(36).slice(2),rt="__reactFiber$"+it,Nt="__reactProps$"+it,st="__reactContainer$"+it,Bn="__reactEvents$"+it,Vg="__reactListeners$"+it,$g="__reactHandles$"+it,hd="__reactResources$"+it,ml="__reactMarker$"+it;function qo(e){delete e[rt],delete e[Nt],delete e[Bn],delete e[Vg],delete e[$g]}function ms(e){var t=e[rt];if(t)return t;for(var a=e.parentNode;a;){if(t=a[st]||a[rt]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Op(e);e!==null;){if(a=e[rt])return a;e=Op(e)}return t}e=a,a=e.parentNode}return null}function hs(e){if(e=e[rt]||e[st]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function hl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function ps(e){var t=e[hd];return t||(t=e[hd]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ct(e){e[ml]=!0}var pd=new Set,xd={};function za(e,t){xs(e,t),xs(e+"Capture",t)}function xs(e,t){for(xd[e]=t,e=0;e<t.length;e++)pd.add(t[e])}var Gg=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]*$"),gd={},vd={};function Yg(e){return re.call(vd,e)?!0:re.call(gd,e)?!1:Gg.test(e)?vd[e]=!0:(gd[e]=!0,!1)}function Mi(e,t,a){if(Yg(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var l=t.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function qi(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Ln(e,t,a,l){if(l===null)e.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+l)}}function tn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function yd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Fg(e,t,a){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var c=l.get,u=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(v){a=""+v,u.call(this,v)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(v){a=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ro(e){if(!e._valueTracker){var t=yd(e)?"checked":"value";e._valueTracker=Fg(e,t,""+e[t])}}function bd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),l="";return e&&(l=yd(e)?e.checked?"true":"false":e.value),e=l,e!==a?(t.setValue(e),!0):!1}function Ri(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Xg=/[\n"\\]/g;function nn(e){return e.replace(Xg,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function To(e,t,a,l,c,u,v,A){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),t!=null?v==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+tn(t)):e.value!==""+tn(t)&&(e.value=""+tn(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?Do(e,v,tn(t)):a!=null?Do(e,v,tn(a)):l!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+tn(A):e.removeAttribute("name")}function Sd(e,t,a,l,c,u,v,A){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||a!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){Ro(e);return}a=a!=null?""+tn(a):"",t=t!=null?""+tn(t):a,A||t===e.value||(e.value=t),e.defaultValue=t}l=l??c,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=A?e.checked:!!l,e.defaultChecked=!!l,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),Ro(e)}function Do(e,t,a){t==="number"&&Ri(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function gs(e,t,a,l){if(e=e.options,t){t={};for(var c=0;c<a.length;c++)t["$"+a[c]]=!0;for(a=0;a<e.length;a++)c=t.hasOwnProperty("$"+e[a].value),e[a].selected!==c&&(e[a].selected=c),c&&l&&(e[a].defaultSelected=!0)}else{for(a=""+tn(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,l&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Ad(e,t,a){if(t!=null&&(t=""+tn(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+tn(a):""}function jd(e,t,a,l){if(t==null){if(l!=null){if(a!=null)throw Error(o(92));if(Y(l)){if(1<l.length)throw Error(o(93));l=l[0]}a=l}a==null&&(a=""),t=a}a=tn(t),e.defaultValue=a,l=e.textContent,l===a&&l!==""&&l!==null&&(e.value=l),Ro(e)}function vs(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var Qg=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 Nd(e,t,a){var l=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":l?e.setProperty(t,a):typeof a!="number"||a===0||Qg.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function wd(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||t!=null&&t.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var c in t)l=t[c],t.hasOwnProperty(c)&&a[c]!==l&&Nd(e,c,l)}else for(var u in t)t.hasOwnProperty(u)&&Nd(e,u,t[u])}function _o(e){if(e.indexOf("-")===-1)return!1;switch(e){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 Kg=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"]]),Zg=/^[\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 Ti(e){return Zg.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function zn(){}var Oo=null;function Bo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ys=null,bs=null;function Cd(e){var t=hs(e);if(t&&(e=t.stateNode)){var a=e[Nt]||null;e:switch(e=t.stateNode,t.type){case"input":if(To(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+nn(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var l=a[t];if(l!==e&&l.form===e.form){var c=l[Nt]||null;if(!c)throw Error(o(90));To(l,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)l=a[t],l.form===e.form&&bd(l)}break e;case"textarea":Ad(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&gs(e,!!a.multiple,t,!1)}}}var Lo=!1;function Ed(e,t,a){if(Lo)return e(t,a);Lo=!0;try{var l=e(t);return l}finally{if(Lo=!1,(ys!==null||bs!==null)&&(yr(),ys&&(t=ys,e=bs,bs=ys=null,Cd(t),e)))for(t=0;t<e.length;t++)Cd(e[t])}}function pl(e,t){var a=e.stateNode;if(a===null)return null;var l=a[Nt]||null;if(l===null)return null;a=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Un=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zo=!1;if(Un)try{var xl={};Object.defineProperty(xl,"passive",{get:function(){zo=!0}}),window.addEventListener("test",xl,xl),window.removeEventListener("test",xl,xl)}catch{zo=!1}var ua=null,Uo=null,Di=null;function kd(){if(Di)return Di;var e,t=Uo,a=t.length,l,c="value"in ua?ua.value:ua.textContent,u=c.length;for(e=0;e<a&&t[e]===c[e];e++);var v=a-e;for(l=1;l<=v&&t[a-l]===c[u-l];l++);return Di=c.slice(e,1<l?1-l:void 0)}function _i(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Oi(){return!0}function Md(){return!1}function Lt(e){function t(a,l,c,u,v){this._reactName=a,this._targetInst=c,this.type=l,this.nativeEvent=u,this.target=v,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(a=e[A],this[A]=a?a(u):u[A]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Oi:Md,this.isPropagationStopped=Md,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Oi)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Oi)},persist:function(){},isPersistent:Oi}),t}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bi=Lt(Ua),gl=b({},Ua,{view:0,detail:0}),Ig=Lt(gl),Ho,Vo,vl,Li=b({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Go,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==vl&&(vl&&e.type==="mousemove"?(Ho=e.screenX-vl.screenX,Vo=e.screenY-vl.screenY):Vo=Ho=0,vl=e),Ho)},movementY:function(e){return"movementY"in e?e.movementY:Vo}}),qd=Lt(Li),Jg=b({},Li,{dataTransfer:0}),Pg=Lt(Jg),Wg=b({},gl,{relatedTarget:0}),$o=Lt(Wg),ev=b({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),tv=Lt(ev),nv=b({},Ua,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),av=Lt(nv),sv=b({},Ua,{data:0}),Rd=Lt(sv),lv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},iv={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"},rv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ov(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=rv[e])?!!t[e]:!1}function Go(){return ov}var cv=b({},gl,{key:function(e){if(e.key){var t=lv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=_i(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?iv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Go,charCode:function(e){return e.type==="keypress"?_i(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_i(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),uv=Lt(cv),fv=b({},Li,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Td=Lt(fv),dv=b({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Go}),mv=Lt(dv),hv=b({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),pv=Lt(hv),xv=b({},Li,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),gv=Lt(xv),vv=b({},Ua,{newState:0,oldState:0}),yv=Lt(vv),bv=[9,13,27,32],Yo=Un&&"CompositionEvent"in window,yl=null;Un&&"documentMode"in document&&(yl=document.documentMode);var Sv=Un&&"TextEvent"in window&&!yl,Dd=Un&&(!Yo||yl&&8<yl&&11>=yl),_d=" ",Od=!1;function Bd(e,t){switch(e){case"keyup":return bv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ld(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ss=!1;function Av(e,t){switch(e){case"compositionend":return Ld(t);case"keypress":return t.which!==32?null:(Od=!0,_d);case"textInput":return e=t.data,e===_d&&Od?null:e;default:return null}}function jv(e,t){if(Ss)return e==="compositionend"||!Yo&&Bd(e,t)?(e=kd(),Di=Uo=ua=null,Ss=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Dd&&t.locale!=="ko"?null:t.data;default:return null}}var Nv={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 zd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Nv[e.type]:t==="textarea"}function Ud(e,t,a,l){ys?bs?bs.push(l):bs=[l]:ys=l,t=Cr(t,"onChange"),0<t.length&&(a=new Bi("onChange","change",null,a,l),e.push({event:a,listeners:t}))}var bl=null,Sl=null;function wv(e){Sp(e,0)}function zi(e){var t=hl(e);if(bd(t))return e}function Hd(e,t){if(e==="change")return t}var Vd=!1;if(Un){var Fo;if(Un){var Xo="oninput"in document;if(!Xo){var $d=document.createElement("div");$d.setAttribute("oninput","return;"),Xo=typeof $d.oninput=="function"}Fo=Xo}else Fo=!1;Vd=Fo&&(!document.documentMode||9<document.documentMode)}function Gd(){bl&&(bl.detachEvent("onpropertychange",Yd),Sl=bl=null)}function Yd(e){if(e.propertyName==="value"&&zi(Sl)){var t=[];Ud(t,Sl,e,Bo(e)),Ed(wv,t)}}function Cv(e,t,a){e==="focusin"?(Gd(),bl=t,Sl=a,bl.attachEvent("onpropertychange",Yd)):e==="focusout"&&Gd()}function Ev(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return zi(Sl)}function kv(e,t){if(e==="click")return zi(t)}function Mv(e,t){if(e==="input"||e==="change")return zi(t)}function qv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ft=typeof Object.is=="function"?Object.is:qv;function Al(e,t){if(Ft(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),l=Object.keys(t);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var c=a[l];if(!re.call(t,c)||!Ft(e[c],t[c]))return!1}return!0}function Fd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Xd(e,t){var a=Fd(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=t&&l>=t)return{node:a,offset:t-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Fd(a)}}function Qd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Qd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Kd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ri(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=Ri(e.document)}return t}function Qo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Rv=Un&&"documentMode"in document&&11>=document.documentMode,As=null,Ko=null,jl=null,Zo=!1;function Zd(e,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Zo||As==null||As!==Ri(l)||(l=As,"selectionStart"in l&&Qo(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jl&&Al(jl,l)||(jl=l,l=Cr(Ko,"onSelect"),0<l.length&&(t=new Bi("onSelect","select",null,t,a),e.push({event:t,listeners:l}),t.target=As)))}function Ha(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var js={animationend:Ha("Animation","AnimationEnd"),animationiteration:Ha("Animation","AnimationIteration"),animationstart:Ha("Animation","AnimationStart"),transitionrun:Ha("Transition","TransitionRun"),transitionstart:Ha("Transition","TransitionStart"),transitioncancel:Ha("Transition","TransitionCancel"),transitionend:Ha("Transition","TransitionEnd")},Io={},Id={};Un&&(Id=document.createElement("div").style,"AnimationEvent"in window||(delete js.animationend.animation,delete js.animationiteration.animation,delete js.animationstart.animation),"TransitionEvent"in window||delete js.transitionend.transition);function Va(e){if(Io[e])return Io[e];if(!js[e])return e;var t=js[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Id)return Io[e]=t[a];return e}var Jd=Va("animationend"),Pd=Va("animationiteration"),Wd=Va("animationstart"),Tv=Va("transitionrun"),Dv=Va("transitionstart"),_v=Va("transitioncancel"),em=Va("transitionend"),tm=new Map,Jo="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(" ");Jo.push("scrollEnd");function xn(e,t){tm.set(e,t),za(t,[e])}var Ui=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},an=[],Ns=0,Po=0;function Hi(){for(var e=Ns,t=Po=Ns=0;t<e;){var a=an[t];an[t++]=null;var l=an[t];an[t++]=null;var c=an[t];an[t++]=null;var u=an[t];if(an[t++]=null,l!==null&&c!==null){var v=l.pending;v===null?c.next=c:(c.next=v.next,v.next=c),l.pending=c}u!==0&&nm(a,c,u)}}function Vi(e,t,a,l){an[Ns++]=e,an[Ns++]=t,an[Ns++]=a,an[Ns++]=l,Po|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function Wo(e,t,a,l){return Vi(e,t,a,l),$i(e)}function $a(e,t){return Vi(e,null,null,t),$i(e)}function nm(e,t,a){e.lanes|=a;var l=e.alternate;l!==null&&(l.lanes|=a);for(var c=!1,u=e.return;u!==null;)u.childLanes|=a,l=u.alternate,l!==null&&(l.childLanes|=a),u.tag===22&&(e=u.stateNode,e===null||e._visibility&1||(c=!0)),e=u,u=u.return;return e.tag===3?(u=e.stateNode,c&&t!==null&&(c=31-Mt(a),e=u.hiddenUpdates,l=e[c],l===null?e[c]=[t]:l.push(t),t.lane=a|536870912),u):null}function $i(e){if(50<Fl)throw Fl=0,ou=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ws={};function Ov(e,t,a,l){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xt(e,t,a,l){return new Ov(e,t,a,l)}function ec(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hn(e,t){var a=e.alternate;return a===null?(a=Xt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function am(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Gi(e,t,a,l,c,u){var v=0;if(l=e,typeof e=="function")ec(e)&&(v=1);else if(typeof e=="string")v=Hy(e,a,ne.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case L:return e=Xt(31,a,t,c),e.elementType=L,e.lanes=u,e;case k:return Ga(a.children,c,u,t);case j:v=8,c|=24;break;case w:return e=Xt(12,a,t,c|2),e.elementType=w,e.lanes=u,e;case B:return e=Xt(13,a,t,c),e.elementType=B,e.lanes=u,e;case H:return e=Xt(19,a,t,c),e.elementType=H,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case C:v=10;break e;case E:v=9;break e;case M:v=11;break e;case _:v=14;break e;case K:v=16,l=null;break e}v=29,a=Error(o(130,e===null?"null":typeof e,"")),l=null}return t=Xt(v,a,t,c),t.elementType=e,t.type=l,t.lanes=u,t}function Ga(e,t,a,l){return e=Xt(7,e,l,t),e.lanes=a,e}function tc(e,t,a){return e=Xt(6,e,null,t),e.lanes=a,e}function sm(e){var t=Xt(18,null,null,0);return t.stateNode=e,t}function nc(e,t,a){return t=Xt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var lm=new WeakMap;function sn(e,t){if(typeof e=="object"&&e!==null){var a=lm.get(e);return a!==void 0?a:(t={value:e,source:t,stack:le(t)},lm.set(e,t),t)}return{value:e,source:t,stack:le(t)}}var Cs=[],Es=0,Yi=null,Nl=0,ln=[],rn=0,fa=null,Nn=1,wn="";function Vn(e,t){Cs[Es++]=Nl,Cs[Es++]=Yi,Yi=e,Nl=t}function im(e,t,a){ln[rn++]=Nn,ln[rn++]=wn,ln[rn++]=fa,fa=e;var l=Nn;e=wn;var c=32-Mt(l)-1;l&=~(1<<c),a+=1;var u=32-Mt(t)+c;if(30<u){var v=c-c%5;u=(l&(1<<v)-1).toString(32),l>>=v,c-=v,Nn=1<<32-Mt(t)+c|a<<c|l,wn=u+e}else Nn=1<<u|a<<c|l,wn=e}function ac(e){e.return!==null&&(Vn(e,1),im(e,1,0))}function sc(e){for(;e===Yi;)Yi=Cs[--Es],Cs[Es]=null,Nl=Cs[--Es],Cs[Es]=null;for(;e===fa;)fa=ln[--rn],ln[rn]=null,wn=ln[--rn],ln[rn]=null,Nn=ln[--rn],ln[rn]=null}function rm(e,t){ln[rn++]=Nn,ln[rn++]=wn,ln[rn++]=fa,Nn=t.id,wn=t.overflow,fa=e}var qt=null,nt=null,Oe=!1,da=null,on=!1,lc=Error(o(519));function ma(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw wl(sn(t,e)),lc}function om(e){var t=e.stateNode,a=e.type,l=e.memoizedProps;switch(t[rt]=e,t[Nt]=l,a){case"dialog":Te("cancel",t),Te("close",t);break;case"iframe":case"object":case"embed":Te("load",t);break;case"video":case"audio":for(a=0;a<Ql.length;a++)Te(Ql[a],t);break;case"source":Te("error",t);break;case"img":case"image":case"link":Te("error",t),Te("load",t);break;case"details":Te("toggle",t);break;case"input":Te("invalid",t),Sd(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Te("invalid",t);break;case"textarea":Te("invalid",t),jd(t,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||l.suppressHydrationWarning===!0||wp(t.textContent,a)?(l.popover!=null&&(Te("beforetoggle",t),Te("toggle",t)),l.onScroll!=null&&Te("scroll",t),l.onScrollEnd!=null&&Te("scrollend",t),l.onClick!=null&&(t.onclick=zn),t=!0):t=!1,t||ma(e,!0)}function cm(e){for(qt=e.return;qt;)switch(qt.tag){case 5:case 31:case 13:on=!1;return;case 27:case 3:on=!0;return;default:qt=qt.return}}function ks(e){if(e!==qt)return!1;if(!Oe)return cm(e),Oe=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||ju(e.type,e.memoizedProps)),a=!a),a&&nt&&ma(e),cm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=_p(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=_p(e)}else t===27?(t=nt,Ea(e.type)?(e=ku,ku=null,nt=e):nt=t):nt=qt?un(e.stateNode.nextSibling):null;return!0}function Ya(){nt=qt=null,Oe=!1}function ic(){var e=da;return e!==null&&(Vt===null?Vt=e:Vt.push.apply(Vt,e),da=null),e}function wl(e){da===null?da=[e]:da.push(e)}var rc=q(null),Fa=null,$n=null;function ha(e,t,a){P(rc,t._currentValue),t._currentValue=a}function Gn(e){e._currentValue=rc.current,V(rc)}function oc(e,t,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===a)break;e=e.return}}function cc(e,t,a,l){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var u=c.dependencies;if(u!==null){var v=c.child;u=u.firstContext;e:for(;u!==null;){var A=u;u=c;for(var D=0;D<t.length;D++)if(A.context===t[D]){u.lanes|=a,A=u.alternate,A!==null&&(A.lanes|=a),oc(u.return,a,e),l||(v=null);break e}u=A.next}}else if(c.tag===18){if(v=c.return,v===null)throw Error(o(341));v.lanes|=a,u=v.alternate,u!==null&&(u.lanes|=a),oc(v,a,e),v=null}else v=c.child;if(v!==null)v.return=c;else for(v=c;v!==null;){if(v===e){v=null;break}if(c=v.sibling,c!==null){c.return=v.return,v=c;break}v=v.return}c=v}}function Ms(e,t,a,l){e=null;for(var c=t,u=!1;c!==null;){if(!u){if((c.flags&524288)!==0)u=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var v=c.alternate;if(v===null)throw Error(o(387));if(v=v.memoizedProps,v!==null){var A=c.type;Ft(c.pendingProps.value,v.value)||(e!==null?e.push(A):e=[A])}}else if(c===oe.current){if(v=c.alternate,v===null)throw Error(o(387));v.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Pl):e=[Pl])}c=c.return}e!==null&&cc(t,e,a,l),t.flags|=262144}function Fi(e){for(e=e.firstContext;e!==null;){if(!Ft(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xa(e){Fa=e,$n=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Rt(e){return um(Fa,e)}function Xi(e,t){return Fa===null&&Xa(e),um(e,t)}function um(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},$n===null){if(e===null)throw Error(o(308));$n=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $n=$n.next=t;return a}var Bv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,l){e.push(l)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Lv=n.unstable_scheduleCallback,zv=n.unstable_NormalPriority,gt={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function uc(){return{controller:new Bv,data:new Map,refCount:0}}function Cl(e){e.refCount--,e.refCount===0&&Lv(zv,function(){e.controller.abort()})}var El=null,fc=0,qs=0,Rs=null;function Uv(e,t){if(El===null){var a=El=[];fc=0,qs=hu(),Rs={status:"pending",value:void 0,then:function(l){a.push(l)}}}return fc++,t.then(fm,fm),t}function fm(){if(--fc===0&&El!==null){Rs!==null&&(Rs.status="fulfilled");var e=El;El=null,qs=0,Rs=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Hv(e,t){var a=[],l={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){l.status="fulfilled",l.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(l.status="rejected",l.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),l}var dm=T.S;T.S=function(e,t){Zh=ze(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Uv(e,t),dm!==null&&dm(e,t)};var Qa=q(null);function dc(){var e=Qa.current;return e!==null?e:We.pooledCache}function Qi(e,t){t===null?P(Qa,Qa.current):P(Qa,t.pool)}function mm(){var e=dc();return e===null?null:{parent:gt._currentValue,pool:e}}var Ts=Error(o(460)),mc=Error(o(474)),Ki=Error(o(542)),Zi={then:function(){}};function hm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function pm(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(zn,zn),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,gm(e),e;default:if(typeof t.status=="string")t.then(zn,zn);else{if(e=We,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(l){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=l}},function(l){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=l}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,gm(e),e}throw Za=t,Ts}}function Ka(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Za=a,Ts):a}}var Za=null;function xm(){if(Za===null)throw Error(o(459));var e=Za;return Za=null,e}function gm(e){if(e===Ts||e===Ki)throw Error(o(483))}var Ds=null,kl=0;function Ii(e){var t=kl;return kl+=1,Ds===null&&(Ds=[]),pm(Ds,e,t)}function Ml(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ji(e,t){throw t.$$typeof===S?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function vm(e){function t(z,O){if(e){var $=z.deletions;$===null?(z.deletions=[O],z.flags|=16):$.push(O)}}function a(z,O){if(!e)return null;for(;O!==null;)t(z,O),O=O.sibling;return null}function l(z){for(var O=new Map;z!==null;)z.key!==null?O.set(z.key,z):O.set(z.index,z),z=z.sibling;return O}function c(z,O){return z=Hn(z,O),z.index=0,z.sibling=null,z}function u(z,O,$){return z.index=$,e?($=z.alternate,$!==null?($=$.index,$<O?(z.flags|=67108866,O):$):(z.flags|=67108866,O)):(z.flags|=1048576,O)}function v(z){return e&&z.alternate===null&&(z.flags|=67108866),z}function A(z,O,$,W){return O===null||O.tag!==6?(O=tc($,z.mode,W),O.return=z,O):(O=c(O,$),O.return=z,O)}function D(z,O,$,W){var Se=$.type;return Se===k?I(z,O,$.props.children,W,$.key):O!==null&&(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===K&&Ka(Se)===O.type)?(O=c(O,$.props),Ml(O,$),O.return=z,O):(O=Gi($.type,$.key,$.props,null,z.mode,W),Ml(O,$),O.return=z,O)}function G(z,O,$,W){return O===null||O.tag!==4||O.stateNode.containerInfo!==$.containerInfo||O.stateNode.implementation!==$.implementation?(O=nc($,z.mode,W),O.return=z,O):(O=c(O,$.children||[]),O.return=z,O)}function I(z,O,$,W,Se){return O===null||O.tag!==7?(O=Ga($,z.mode,W,Se),O.return=z,O):(O=c(O,$),O.return=z,O)}function ee(z,O,$){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=tc(""+O,z.mode,$),O.return=z,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case R:return $=Gi(O.type,O.key,O.props,null,z.mode,$),Ml($,O),$.return=z,$;case N:return O=nc(O,z.mode,$),O.return=z,O;case K:return O=Ka(O),ee(z,O,$)}if(Y(O)||te(O))return O=Ga(O,z.mode,$,null),O.return=z,O;if(typeof O.then=="function")return ee(z,Ii(O),$);if(O.$$typeof===C)return ee(z,Xi(z,O),$);Ji(z,O)}return null}function Q(z,O,$,W){var Se=O!==null?O.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return Se!==null?null:A(z,O,""+$,W);if(typeof $=="object"&&$!==null){switch($.$$typeof){case R:return $.key===Se?D(z,O,$,W):null;case N:return $.key===Se?G(z,O,$,W):null;case K:return $=Ka($),Q(z,O,$,W)}if(Y($)||te($))return Se!==null?null:I(z,O,$,W,null);if(typeof $.then=="function")return Q(z,O,Ii($),W);if($.$$typeof===C)return Q(z,O,Xi(z,$),W);Ji(z,$)}return null}function Z(z,O,$,W,Se){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return z=z.get($)||null,A(O,z,""+W,Se);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case R:return z=z.get(W.key===null?$:W.key)||null,D(O,z,W,Se);case N:return z=z.get(W.key===null?$:W.key)||null,G(O,z,W,Se);case K:return W=Ka(W),Z(z,O,$,W,Se)}if(Y(W)||te(W))return z=z.get($)||null,I(O,z,W,Se,null);if(typeof W.then=="function")return Z(z,O,$,Ii(W),Se);if(W.$$typeof===C)return Z(z,O,$,Xi(O,W),Se);Ji(O,W)}return null}function he(z,O,$,W){for(var Se=null,He=null,ge=O,ke=O=0,_e=null;ge!==null&&ke<$.length;ke++){ge.index>ke?(_e=ge,ge=null):_e=ge.sibling;var Ve=Q(z,ge,$[ke],W);if(Ve===null){ge===null&&(ge=_e);break}e&&ge&&Ve.alternate===null&&t(z,ge),O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve,ge=_e}if(ke===$.length)return a(z,ge),Oe&&Vn(z,ke),Se;if(ge===null){for(;ke<$.length;ke++)ge=ee(z,$[ke],W),ge!==null&&(O=u(ge,O,ke),He===null?Se=ge:He.sibling=ge,He=ge);return Oe&&Vn(z,ke),Se}for(ge=l(ge);ke<$.length;ke++)_e=Z(ge,z,ke,$[ke],W),_e!==null&&(e&&_e.alternate!==null&&ge.delete(_e.key===null?ke:_e.key),O=u(_e,O,ke),He===null?Se=_e:He.sibling=_e,He=_e);return e&&ge.forEach(function(Ta){return t(z,Ta)}),Oe&&Vn(z,ke),Se}function je(z,O,$,W){if($==null)throw Error(o(151));for(var Se=null,He=null,ge=O,ke=O=0,_e=null,Ve=$.next();ge!==null&&!Ve.done;ke++,Ve=$.next()){ge.index>ke?(_e=ge,ge=null):_e=ge.sibling;var Ta=Q(z,ge,Ve.value,W);if(Ta===null){ge===null&&(ge=_e);break}e&&ge&&Ta.alternate===null&&t(z,ge),O=u(Ta,O,ke),He===null?Se=Ta:He.sibling=Ta,He=Ta,ge=_e}if(Ve.done)return a(z,ge),Oe&&Vn(z,ke),Se;if(ge===null){for(;!Ve.done;ke++,Ve=$.next())Ve=ee(z,Ve.value,W),Ve!==null&&(O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve);return Oe&&Vn(z,ke),Se}for(ge=l(ge);!Ve.done;ke++,Ve=$.next())Ve=Z(ge,z,ke,Ve.value,W),Ve!==null&&(e&&Ve.alternate!==null&&ge.delete(Ve.key===null?ke:Ve.key),O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve);return e&&ge.forEach(function(Jy){return t(z,Jy)}),Oe&&Vn(z,ke),Se}function Je(z,O,$,W){if(typeof $=="object"&&$!==null&&$.type===k&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case R:e:{for(var Se=$.key;O!==null;){if(O.key===Se){if(Se=$.type,Se===k){if(O.tag===7){a(z,O.sibling),W=c(O,$.props.children),W.return=z,z=W;break e}}else if(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===K&&Ka(Se)===O.type){a(z,O.sibling),W=c(O,$.props),Ml(W,$),W.return=z,z=W;break e}a(z,O);break}else t(z,O);O=O.sibling}$.type===k?(W=Ga($.props.children,z.mode,W,$.key),W.return=z,z=W):(W=Gi($.type,$.key,$.props,null,z.mode,W),Ml(W,$),W.return=z,z=W)}return v(z);case N:e:{for(Se=$.key;O!==null;){if(O.key===Se)if(O.tag===4&&O.stateNode.containerInfo===$.containerInfo&&O.stateNode.implementation===$.implementation){a(z,O.sibling),W=c(O,$.children||[]),W.return=z,z=W;break e}else{a(z,O);break}else t(z,O);O=O.sibling}W=nc($,z.mode,W),W.return=z,z=W}return v(z);case K:return $=Ka($),Je(z,O,$,W)}if(Y($))return he(z,O,$,W);if(te($)){if(Se=te($),typeof Se!="function")throw Error(o(150));return $=Se.call($),je(z,O,$,W)}if(typeof $.then=="function")return Je(z,O,Ii($),W);if($.$$typeof===C)return Je(z,O,Xi(z,$),W);Ji(z,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,O!==null&&O.tag===6?(a(z,O.sibling),W=c(O,$),W.return=z,z=W):(a(z,O),W=tc($,z.mode,W),W.return=z,z=W),v(z)):a(z,O)}return function(z,O,$,W){try{kl=0;var Se=Je(z,O,$,W);return Ds=null,Se}catch(ge){if(ge===Ts||ge===Ki)throw ge;var He=Xt(29,ge,null,z.mode);return He.lanes=W,He.return=z,He}finally{}}}var Ia=vm(!0),ym=vm(!1),pa=!1;function hc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function pc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function xa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ga(e,t,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ge&2)!==0){var c=l.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),l.pending=t,t=$i(e),nm(e,null,a),t}return Vi(e,l,t,a),$i(e)}function ql(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,en(e,a)}}function xc(e,t){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var c=null,u=null;if(a=a.firstBaseUpdate,a!==null){do{var v={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};u===null?c=u=v:u=u.next=v,a=a.next}while(a!==null);u===null?c=u=t:u=u.next=t}else c=u=t;a={baseState:l.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:l.shared,callbacks:l.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var gc=!1;function Rl(){if(gc){var e=Rs;if(e!==null)throw e}}function Tl(e,t,a,l){gc=!1;var c=e.updateQueue;pa=!1;var u=c.firstBaseUpdate,v=c.lastBaseUpdate,A=c.shared.pending;if(A!==null){c.shared.pending=null;var D=A,G=D.next;D.next=null,v===null?u=G:v.next=G,v=D;var I=e.alternate;I!==null&&(I=I.updateQueue,A=I.lastBaseUpdate,A!==v&&(A===null?I.firstBaseUpdate=G:A.next=G,I.lastBaseUpdate=D))}if(u!==null){var ee=c.baseState;v=0,I=G=D=null,A=u;do{var Q=A.lane&-536870913,Z=Q!==A.lane;if(Z?(De&Q)===Q:(l&Q)===Q){Q!==0&&Q===qs&&(gc=!0),I!==null&&(I=I.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var he=e,je=A;Q=t;var Je=a;switch(je.tag){case 1:if(he=je.payload,typeof he=="function"){ee=he.call(Je,ee,Q);break e}ee=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=je.payload,Q=typeof he=="function"?he.call(Je,ee,Q):he,Q==null)break e;ee=b({},ee,Q);break e;case 2:pa=!0}}Q=A.callback,Q!==null&&(e.flags|=64,Z&&(e.flags|=8192),Z=c.callbacks,Z===null?c.callbacks=[Q]:Z.push(Q))}else Z={lane:Q,tag:A.tag,payload:A.payload,callback:A.callback,next:null},I===null?(G=I=Z,D=ee):I=I.next=Z,v|=Q;if(A=A.next,A===null){if(A=c.shared.pending,A===null)break;Z=A,A=Z.next,Z.next=null,c.lastBaseUpdate=Z,c.shared.pending=null}}while(!0);I===null&&(D=ee),c.baseState=D,c.firstBaseUpdate=G,c.lastBaseUpdate=I,u===null&&(c.shared.lanes=0),Aa|=v,e.lanes=v,e.memoizedState=ee}}function bm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function Sm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)bm(a[e],t)}var _s=q(null),Pi=q(0);function Am(e,t){e=Pn,P(Pi,e),P(_s,t),Pn=e|t.baseLanes}function vc(){P(Pi,Pn),P(_s,_s.current)}function yc(){Pn=Pi.current,V(_s),V(Pi)}var Qt=q(null),cn=null;function va(e){var t=e.alternate;P(ht,ht.current&1),P(Qt,e),cn===null&&(t===null||_s.current!==null||t.memoizedState!==null)&&(cn=e)}function bc(e){P(ht,ht.current),P(Qt,e),cn===null&&(cn=e)}function jm(e){e.tag===22?(P(ht,ht.current),P(Qt,e),cn===null&&(cn=e)):ya()}function ya(){P(ht,ht.current),P(Qt,Qt.current)}function Kt(e){V(Qt),cn===e&&(cn=null),V(ht)}var ht=q(0);function Wi(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Cu(a)||Eu(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Yn=0,Ee=null,Ze=null,vt=null,er=!1,Os=!1,Ja=!1,tr=0,Dl=0,Bs=null,Vv=0;function ct(){throw Error(o(321))}function Sc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Ft(e[a],t[a]))return!1;return!0}function Ac(e,t,a,l,c,u){return Yn=u,Ee=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?ih:Lc,Ja=!1,u=a(l,c),Ja=!1,Os&&(u=wm(t,a,l,c)),Nm(e),u}function Nm(e){T.H=Bl;var t=Ze!==null&&Ze.next!==null;if(Yn=0,vt=Ze=Ee=null,er=!1,Dl=0,Bs=null,t)throw Error(o(300));e===null||yt||(e=e.dependencies,e!==null&&Fi(e)&&(yt=!0))}function wm(e,t,a,l){Ee=e;var c=0;do{if(Os&&(Bs=null),Dl=0,Os=!1,25<=c)throw Error(o(301));if(c+=1,vt=Ze=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}T.H=rh,u=t(a,l)}while(Os);return u}function $v(){var e=T.H,t=e.useState()[0];return t=typeof t.then=="function"?_l(t):t,e=e.useState()[0],(Ze!==null?Ze.memoizedState:null)!==e&&(Ee.flags|=1024),t}function jc(){var e=tr!==0;return tr=0,e}function Nc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function wc(e){if(er){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}er=!1}Yn=0,vt=Ze=Ee=null,Os=!1,Dl=tr=0,Bs=null}function Bt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vt===null?Ee.memoizedState=vt=e:vt=vt.next=e,vt}function pt(){if(Ze===null){var e=Ee.alternate;e=e!==null?e.memoizedState:null}else e=Ze.next;var t=vt===null?Ee.memoizedState:vt.next;if(t!==null)vt=t,Ze=e;else{if(e===null)throw Ee.alternate===null?Error(o(467)):Error(o(310));Ze=e,e={memoizedState:Ze.memoizedState,baseState:Ze.baseState,baseQueue:Ze.baseQueue,queue:Ze.queue,next:null},vt===null?Ee.memoizedState=vt=e:vt=vt.next=e}return vt}function nr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function _l(e){var t=Dl;return Dl+=1,Bs===null&&(Bs=[]),e=pm(Bs,e,t),t=Ee,(vt===null?t.memoizedState:vt.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?ih:Lc),e}function ar(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return _l(e);if(e.$$typeof===C)return Rt(e)}throw Error(o(438,String(e)))}function Cc(e){var t=null,a=Ee.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var l=Ee.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(t={data:l.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=nr(),Ee.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),l=0;l<e;l++)a[l]=U;return t.index++,a}function Fn(e,t){return typeof t=="function"?t(e):t}function sr(e){var t=pt();return Ec(t,Ze,e)}function Ec(e,t,a){var l=e.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=a;var c=e.baseQueue,u=l.pending;if(u!==null){if(c!==null){var v=c.next;c.next=u.next,u.next=v}t.baseQueue=c=u,l.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var A=v=null,D=null,G=t,I=!1;do{var ee=G.lane&-536870913;if(ee!==G.lane?(De&ee)===ee:(Yn&ee)===ee){var Q=G.revertLane;if(Q===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),ee===qs&&(I=!0);else if((Yn&Q)===Q){G=G.next,Q===qs&&(I=!0);continue}else ee={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(A=D=ee,v=u):D=D.next=ee,Ee.lanes|=Q,Aa|=Q;ee=G.action,Ja&&a(u,ee),u=G.hasEagerState?G.eagerState:a(u,ee)}else Q={lane:ee,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(A=D=Q,v=u):D=D.next=Q,Ee.lanes|=ee,Aa|=ee;G=G.next}while(G!==null&&G!==t);if(D===null?v=u:D.next=A,!Ft(u,e.memoizedState)&&(yt=!0,I&&(a=Rs,a!==null)))throw a;e.memoizedState=u,e.baseState=v,e.baseQueue=D,l.lastRenderedState=u}return c===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function kc(e){var t=pt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var l=a.dispatch,c=a.pending,u=t.memoizedState;if(c!==null){a.pending=null;var v=c=c.next;do u=e(u,v.action),v=v.next;while(v!==c);Ft(u,t.memoizedState)||(yt=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),a.lastRenderedState=u}return[u,l]}function Cm(e,t,a){var l=Ee,c=pt(),u=Oe;if(u){if(a===void 0)throw Error(o(407));a=a()}else a=t();var v=!Ft((Ze||c).memoizedState,a);if(v&&(c.memoizedState=a,yt=!0),c=c.queue,Rc(Mm.bind(null,l,c,e),[e]),c.getSnapshot!==t||v||vt!==null&&vt.memoizedState.tag&1){if(l.flags|=2048,Ls(9,{destroy:void 0},km.bind(null,l,c,a,t),null),We===null)throw Error(o(349));u||(Yn&127)!==0||Em(l,t,a)}return a}function Em(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=Ee.updateQueue,t===null?(t=nr(),Ee.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function km(e,t,a,l){t.value=a,t.getSnapshot=l,qm(t)&&Rm(e)}function Mm(e,t,a){return a(function(){qm(t)&&Rm(e)})}function qm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Ft(e,a)}catch{return!0}}function Rm(e){var t=$a(e,2);t!==null&&$t(t,e,2)}function Mc(e){var t=Bt();if(typeof e=="function"){var a=e;if(e=a(),Ja){Yt(!0);try{a()}finally{Yt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:e},t}function Tm(e,t,a,l){return e.baseState=a,Ec(e,Ze,typeof l=="function"?l:Fn)}function Gv(e,t,a,l,c){if(rr(e))throw Error(o(485));if(e=t.action,e!==null){var u={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){u.listeners.push(v)}};T.T!==null?a(!0):u.isTransition=!1,l(u),a=t.pending,a===null?(u.next=t.pending=u,Dm(t,u)):(u.next=a.next,t.pending=a.next=u)}}function Dm(e,t){var a=t.action,l=t.payload,c=e.state;if(t.isTransition){var u=T.T,v={};T.T=v;try{var A=a(c,l),D=T.S;D!==null&&D(v,A),_m(e,t,A)}catch(G){qc(e,t,G)}finally{u!==null&&v.types!==null&&(u.types=v.types),T.T=u}}else try{u=a(c,l),_m(e,t,u)}catch(G){qc(e,t,G)}}function _m(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Om(e,t,l)},function(l){return qc(e,t,l)}):Om(e,t,a)}function Om(e,t,a){t.status="fulfilled",t.value=a,Bm(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Dm(e,a)))}function qc(e,t,a){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do t.status="rejected",t.reason=a,Bm(t),t=t.next;while(t!==l)}e.action=null}function Bm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Lm(e,t){return t}function zm(e,t){if(Oe){var a=We.formState;if(a!==null){e:{var l=Ee;if(Oe){if(nt){t:{for(var c=nt,u=on;c.nodeType!==8;){if(!u){c=null;break t}if(c=un(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){nt=un(c.nextSibling),l=c.data==="F!";break e}}ma(l)}l=!1}l&&(t=a[0])}}return a=Bt(),a.memoizedState=a.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lm,lastRenderedState:t},a.queue=l,a=ah.bind(null,Ee,l),l.dispatch=a,l=Mc(!1),u=Bc.bind(null,Ee,!1,l.queue),l=Bt(),c={state:t,dispatch:null,action:e,pending:null},l.queue=c,a=Gv.bind(null,Ee,c,u,a),c.dispatch=a,l.memoizedState=e,[t,a,!1]}function Um(e){var t=pt();return Hm(t,Ze,e)}function Hm(e,t,a){if(t=Ec(e,t,Lm)[0],e=sr(Fn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var l=_l(t)}catch(v){throw v===Ts?Ki:v}else l=t;t=pt();var c=t.queue,u=c.dispatch;return a!==t.memoizedState&&(Ee.flags|=2048,Ls(9,{destroy:void 0},Yv.bind(null,c,a),null)),[l,u,e]}function Yv(e,t){e.action=t}function Vm(e){var t=pt(),a=Ze;if(a!==null)return Hm(t,a,e);pt(),t=t.memoizedState,a=pt();var l=a.queue.dispatch;return a.memoizedState=e,[t,l,!1]}function Ls(e,t,a,l){return e={tag:e,create:a,deps:l,inst:t,next:null},t=Ee.updateQueue,t===null&&(t=nr(),Ee.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,t.lastEffect=e),e}function $m(){return pt().memoizedState}function lr(e,t,a,l){var c=Bt();Ee.flags|=e,c.memoizedState=Ls(1|t,{destroy:void 0},a,l===void 0?null:l)}function ir(e,t,a,l){var c=pt();l=l===void 0?null:l;var u=c.memoizedState.inst;Ze!==null&&l!==null&&Sc(l,Ze.memoizedState.deps)?c.memoizedState=Ls(t,u,a,l):(Ee.flags|=e,c.memoizedState=Ls(1|t,u,a,l))}function Gm(e,t){lr(8390656,8,e,t)}function Rc(e,t){ir(2048,8,e,t)}function Fv(e){Ee.flags|=4;var t=Ee.updateQueue;if(t===null)t=nr(),Ee.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function Ym(e){var t=pt().memoizedState;return Fv({ref:t,nextImpl:e}),function(){if((Ge&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Fm(e,t){return ir(4,2,e,t)}function Xm(e,t){return ir(4,4,e,t)}function Qm(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Km(e,t,a){a=a!=null?a.concat([e]):null,ir(4,4,Qm.bind(null,t,e),a)}function Tc(){}function Zm(e,t){var a=pt();t=t===void 0?null:t;var l=a.memoizedState;return t!==null&&Sc(t,l[1])?l[0]:(a.memoizedState=[e,t],e)}function Im(e,t){var a=pt();t=t===void 0?null:t;var l=a.memoizedState;if(t!==null&&Sc(t,l[1]))return l[0];if(l=e(),Ja){Yt(!0);try{e()}finally{Yt(!1)}}return a.memoizedState=[l,t],l}function Dc(e,t,a){return a===void 0||(Yn&1073741824)!==0&&(De&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=Jh(),Ee.lanes|=e,Aa|=e,a)}function Jm(e,t,a,l){return Ft(a,t)?a:_s.current!==null?(e=Dc(e,a,l),Ft(e,t)||(yt=!0),e):(Yn&42)===0||(Yn&1073741824)!==0&&(De&261930)===0?(yt=!0,e.memoizedState=a):(e=Jh(),Ee.lanes|=e,Aa|=e,t)}function Pm(e,t,a,l,c){var u=X.p;X.p=u!==0&&8>u?u:8;var v=T.T,A={};T.T=A,Bc(e,!1,t,a);try{var D=c(),G=T.S;if(G!==null&&G(A,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var I=Hv(D,l);Ol(e,t,I,Jt(e))}else Ol(e,t,l,Jt(e))}catch(ee){Ol(e,t,{then:function(){},status:"rejected",reason:ee},Jt())}finally{X.p=u,v!==null&&A.types!==null&&(v.types=A.types),T.T=v}}function Xv(){}function _c(e,t,a,l){if(e.tag!==5)throw Error(o(476));var c=Wm(e).queue;Pm(e,c,t,J,a===null?Xv:function(){return eh(e),a(l)})}function Wm(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:J},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function eh(e){var t=Wm(e);t.next===null&&(t=e.alternate.memoizedState),Ol(e,t.next.queue,{},Jt())}function Oc(){return Rt(Pl)}function th(){return pt().memoizedState}function nh(){return pt().memoizedState}function Qv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=Jt();e=xa(a);var l=ga(t,e,a);l!==null&&($t(l,t,a),ql(l,t,a)),t={cache:uc()},e.payload=t;return}t=t.return}}function Kv(e,t,a){var l=Jt();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},rr(e)?sh(t,a):(a=Wo(e,t,a,l),a!==null&&($t(a,e,l),lh(a,t,l)))}function ah(e,t,a){var l=Jt();Ol(e,t,a,l)}function Ol(e,t,a,l){var c={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(rr(e))sh(t,c);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var v=t.lastRenderedState,A=u(v,a);if(c.hasEagerState=!0,c.eagerState=A,Ft(A,v))return Vi(e,t,c,0),We===null&&Hi(),!1}catch{}finally{}if(a=Wo(e,t,c,l),a!==null)return $t(a,e,l),lh(a,t,l),!0}return!1}function Bc(e,t,a,l){if(l={lane:2,revertLane:hu(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},rr(e)){if(t)throw Error(o(479))}else t=Wo(e,a,l,2),t!==null&&$t(t,e,2)}function rr(e){var t=e.alternate;return e===Ee||t!==null&&t===Ee}function sh(e,t){Os=er=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function lh(e,t,a){if((a&4194048)!==0){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,en(e,a)}}var Bl={readContext:Rt,use:ar,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};Bl.useEffectEvent=ct;var ih={readContext:Rt,use:ar,useCallback:function(e,t){return Bt().memoizedState=[e,t===void 0?null:t],e},useContext:Rt,useEffect:Gm,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,lr(4194308,4,Qm.bind(null,t,e),a)},useLayoutEffect:function(e,t){return lr(4194308,4,e,t)},useInsertionEffect:function(e,t){lr(4,2,e,t)},useMemo:function(e,t){var a=Bt();t=t===void 0?null:t;var l=e();if(Ja){Yt(!0);try{e()}finally{Yt(!1)}}return a.memoizedState=[l,t],l},useReducer:function(e,t,a){var l=Bt();if(a!==void 0){var c=a(t);if(Ja){Yt(!0);try{a(t)}finally{Yt(!1)}}}else c=t;return l.memoizedState=l.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},l.queue=e,e=e.dispatch=Kv.bind(null,Ee,e),[l.memoizedState,e]},useRef:function(e){var t=Bt();return e={current:e},t.memoizedState=e},useState:function(e){e=Mc(e);var t=e.queue,a=ah.bind(null,Ee,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Tc,useDeferredValue:function(e,t){var a=Bt();return Dc(a,e,t)},useTransition:function(){var e=Mc(!1);return e=Pm.bind(null,Ee,e.queue,!0,!1),Bt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var l=Ee,c=Bt();if(Oe){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),We===null)throw Error(o(349));(De&127)!==0||Em(l,t,a)}c.memoizedState=a;var u={value:a,getSnapshot:t};return c.queue=u,Gm(Mm.bind(null,l,u,e),[e]),l.flags|=2048,Ls(9,{destroy:void 0},km.bind(null,l,u,a,t),null),a},useId:function(){var e=Bt(),t=We.identifierPrefix;if(Oe){var a=wn,l=Nn;a=(l&~(1<<32-Mt(l)-1)).toString(32)+a,t="_"+t+"R_"+a,a=tr++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=Vv++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Oc,useFormState:zm,useActionState:zm,useOptimistic:function(e){var t=Bt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Bc.bind(null,Ee,!0,a),a.dispatch=t,[e,t]},useMemoCache:Cc,useCacheRefresh:function(){return Bt().memoizedState=Qv.bind(null,Ee)},useEffectEvent:function(e){var t=Bt(),a={impl:e};return t.memoizedState=a,function(){if((Ge&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Lc={readContext:Rt,use:ar,useCallback:Zm,useContext:Rt,useEffect:Rc,useImperativeHandle:Km,useInsertionEffect:Fm,useLayoutEffect:Xm,useMemo:Im,useReducer:sr,useRef:$m,useState:function(){return sr(Fn)},useDebugValue:Tc,useDeferredValue:function(e,t){var a=pt();return Jm(a,Ze.memoizedState,e,t)},useTransition:function(){var e=sr(Fn)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:_l(e),t]},useSyncExternalStore:Cm,useId:th,useHostTransitionStatus:Oc,useFormState:Um,useActionState:Um,useOptimistic:function(e,t){var a=pt();return Tm(a,Ze,e,t)},useMemoCache:Cc,useCacheRefresh:nh};Lc.useEffectEvent=Ym;var rh={readContext:Rt,use:ar,useCallback:Zm,useContext:Rt,useEffect:Rc,useImperativeHandle:Km,useInsertionEffect:Fm,useLayoutEffect:Xm,useMemo:Im,useReducer:kc,useRef:$m,useState:function(){return kc(Fn)},useDebugValue:Tc,useDeferredValue:function(e,t){var a=pt();return Ze===null?Dc(a,e,t):Jm(a,Ze.memoizedState,e,t)},useTransition:function(){var e=kc(Fn)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:_l(e),t]},useSyncExternalStore:Cm,useId:th,useHostTransitionStatus:Oc,useFormState:Vm,useActionState:Vm,useOptimistic:function(e,t){var a=pt();return Ze!==null?Tm(a,Ze,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Cc,useCacheRefresh:nh};rh.useEffectEvent=Ym;function zc(e,t,a,l){t=e.memoizedState,a=a(l,t),a=a==null?t:b({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Uc={enqueueSetState:function(e,t,a){e=e._reactInternals;var l=Jt(),c=xa(l);c.payload=t,a!=null&&(c.callback=a),t=ga(e,c,l),t!==null&&($t(t,e,l),ql(t,e,l))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var l=Jt(),c=xa(l);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=ga(e,c,l),t!==null&&($t(t,e,l),ql(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=Jt(),l=xa(a);l.tag=2,t!=null&&(l.callback=t),t=ga(e,l,a),t!==null&&($t(t,e,a),ql(t,e,a))}};function oh(e,t,a,l,c,u,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,u,v):t.prototype&&t.prototype.isPureReactComponent?!Al(a,l)||!Al(c,u):!0}function ch(e,t,a,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,l),t.state!==e&&Uc.enqueueReplaceState(t,t.state,null)}function Pa(e,t){var a=t;if("ref"in t){a={};for(var l in t)l!=="ref"&&(a[l]=t[l])}if(e=e.defaultProps){a===t&&(a=b({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function uh(e){Ui(e)}function fh(e){console.error(e)}function dh(e){Ui(e)}function or(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function mh(e,t,a){try{var l=e.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Hc(e,t,a){return a=xa(a),a.tag=3,a.payload={element:null},a.callback=function(){or(e,t)},a}function hh(e){return e=xa(e),e.tag=3,e}function ph(e,t,a,l){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var u=l.value;e.payload=function(){return c(u)},e.callback=function(){mh(t,a,l)}}var v=a.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){mh(t,a,l),typeof c!="function"&&(ja===null?ja=new Set([this]):ja.add(this));var A=l.stack;this.componentDidCatch(l.value,{componentStack:A!==null?A:""})})}function Zv(e,t,a,l,c){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(t=a.alternate,t!==null&&Ms(t,a,c,!0),a=Qt.current,a!==null){switch(a.tag){case 31:case 13:return cn===null?br():a.alternate===null&&ut===0&&(ut=3),a.flags&=-257,a.flags|=65536,a.lanes=c,l===Zi?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([l]):t.add(l),fu(e,l,c)),!1;case 22:return a.flags|=65536,l===Zi?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([l]):a.add(l)),fu(e,l,c)),!1}throw Error(o(435,a.tag))}return fu(e,l,c),br(),!1}if(Oe)return t=Qt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,l!==lc&&(e=Error(o(422),{cause:l}),wl(sn(e,a)))):(l!==lc&&(t=Error(o(423),{cause:l}),wl(sn(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,l=sn(l,a),c=Hc(e.stateNode,l,c),xc(e,c),ut!==4&&(ut=2)),!1;var u=Error(o(520),{cause:l});if(u=sn(u,a),Yl===null?Yl=[u]:Yl.push(u),ut!==4&&(ut=2),t===null)return!0;l=sn(l,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=Hc(a.stateNode,l,e),xc(a,e),!1;case 1:if(t=a.type,u=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(ja===null||!ja.has(u))))return a.flags|=65536,c&=-c,a.lanes|=c,c=hh(c),ph(c,e,a,l),xc(a,c),!1}a=a.return}while(a!==null);return!1}var Vc=Error(o(461)),yt=!1;function Tt(e,t,a,l){t.child=e===null?ym(t,null,a,l):Ia(t,e.child,a,l)}function xh(e,t,a,l,c){a=a.render;var u=t.ref;if("ref"in l){var v={};for(var A in l)A!=="ref"&&(v[A]=l[A])}else v=l;return Xa(t),l=Ac(e,t,a,v,u,c),A=jc(),e!==null&&!yt?(Nc(e,t,c),Xn(e,t,c)):(Oe&&A&&ac(t),t.flags|=1,Tt(e,t,l,c),t.child)}function gh(e,t,a,l,c){if(e===null){var u=a.type;return typeof u=="function"&&!ec(u)&&u.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=u,vh(e,t,u,l,c)):(e=Gi(a.type,null,l,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!Zc(e,c)){var v=u.memoizedProps;if(a=a.compare,a=a!==null?a:Al,a(v,l)&&e.ref===t.ref)return Xn(e,t,c)}return t.flags|=1,e=Hn(u,l),e.ref=t.ref,e.return=t,t.child=e}function vh(e,t,a,l,c){if(e!==null){var u=e.memoizedProps;if(Al(u,l)&&e.ref===t.ref)if(yt=!1,t.pendingProps=l=u,Zc(e,c))(e.flags&131072)!==0&&(yt=!0);else return t.lanes=e.lanes,Xn(e,t,c)}return $c(e,t,a,l,c)}function yh(e,t,a,l){var c=l.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|a:a,e!==null){for(l=t.child=e.child,c=0;l!==null;)c=c|l.lanes|l.childLanes,l=l.sibling;l=c&~u}else l=0,t.child=null;return bh(e,t,u,a,l)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Qi(t,u!==null?u.cachePool:null),u!==null?Am(t,u):vc(),jm(t);else return l=t.lanes=536870912,bh(e,t,u!==null?u.baseLanes|a:a,a,l)}else u!==null?(Qi(t,u.cachePool),Am(t,u),ya(),t.memoizedState=null):(e!==null&&Qi(t,null),vc(),ya());return Tt(e,t,c,a),t.child}function Ll(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function bh(e,t,a,l,c){var u=dc();return u=u===null?null:{parent:gt._currentValue,pool:u},t.memoizedState={baseLanes:a,cachePool:u},e!==null&&Qi(t,null),vc(),jm(t),e!==null&&Ms(e,t,l,!0),t.childLanes=c,null}function cr(e,t){return t=fr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Sh(e,t,a){return Ia(t,e.child,null,a),e=cr(t,t.pendingProps),e.flags|=2,Kt(t),t.memoizedState=null,e}function Iv(e,t,a){var l=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Oe){if(l.mode==="hidden")return e=cr(t,l),t.lanes=536870912,Ll(null,e);if(bc(t),(e=nt)?(e=Dp(e,on),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:Nn,overflow:wn}:null,retryLane:536870912,hydrationErrors:null},a=sm(e),a.return=t,t.child=a,qt=t,nt=null)):e=null,e===null)throw ma(t);return t.lanes=536870912,null}return cr(t,l)}var u=e.memoizedState;if(u!==null){var v=u.dehydrated;if(bc(t),c)if(t.flags&256)t.flags&=-257,t=Sh(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(yt||Ms(e,t,a,!1),c=(a&e.childLanes)!==0,yt||c){if(l=We,l!==null&&(v=Ae(l,a),v!==0&&v!==u.retryLane))throw u.retryLane=v,$a(e,v),$t(l,e,v),Vc;br(),t=Sh(e,t,a)}else e=u.treeContext,nt=un(v.nextSibling),qt=t,Oe=!0,da=null,on=!1,e!==null&&rm(t,e),t=cr(t,l),t.flags|=4096;return t}return e=Hn(e.child,{mode:l.mode,children:l.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ur(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(o(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function $c(e,t,a,l,c){return Xa(t),a=Ac(e,t,a,l,void 0,c),l=jc(),e!==null&&!yt?(Nc(e,t,c),Xn(e,t,c)):(Oe&&l&&ac(t),t.flags|=1,Tt(e,t,a,c),t.child)}function Ah(e,t,a,l,c,u){return Xa(t),t.updateQueue=null,a=wm(t,l,a,c),Nm(e),l=jc(),e!==null&&!yt?(Nc(e,t,u),Xn(e,t,u)):(Oe&&l&&ac(t),t.flags|=1,Tt(e,t,a,u),t.child)}function jh(e,t,a,l,c){if(Xa(t),t.stateNode===null){var u=ws,v=a.contextType;typeof v=="object"&&v!==null&&(u=Rt(v)),u=new a(l,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Uc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=l,u.state=t.memoizedState,u.refs={},hc(t),v=a.contextType,u.context=typeof v=="object"&&v!==null?Rt(v):ws,u.state=t.memoizedState,v=a.getDerivedStateFromProps,typeof v=="function"&&(zc(t,a,v,l),u.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(v=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),v!==u.state&&Uc.enqueueReplaceState(u,u.state,null),Tl(t,l,u,c),Rl(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),l=!0}else if(e===null){u=t.stateNode;var A=t.memoizedProps,D=Pa(a,A);u.props=D;var G=u.context,I=a.contextType;v=ws,typeof I=="object"&&I!==null&&(v=Rt(I));var ee=a.getDerivedStateFromProps;I=typeof ee=="function"||typeof u.getSnapshotBeforeUpdate=="function",A=t.pendingProps!==A,I||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(A||G!==v)&&ch(t,u,l,v),pa=!1;var Q=t.memoizedState;u.state=Q,Tl(t,l,u,c),Rl(),G=t.memoizedState,A||Q!==G||pa?(typeof ee=="function"&&(zc(t,a,ee,l),G=t.memoizedState),(D=pa||oh(t,a,D,l,Q,G,v))?(I||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=G),u.props=l,u.state=G,u.context=v,l=D):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{u=t.stateNode,pc(e,t),v=t.memoizedProps,I=Pa(a,v),u.props=I,ee=t.pendingProps,Q=u.context,G=a.contextType,D=ws,typeof G=="object"&&G!==null&&(D=Rt(G)),A=a.getDerivedStateFromProps,(G=typeof A=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(v!==ee||Q!==D)&&ch(t,u,l,D),pa=!1,Q=t.memoizedState,u.state=Q,Tl(t,l,u,c),Rl();var Z=t.memoizedState;v!==ee||Q!==Z||pa||e!==null&&e.dependencies!==null&&Fi(e.dependencies)?(typeof A=="function"&&(zc(t,a,A,l),Z=t.memoizedState),(I=pa||oh(t,a,I,l,Q,Z,D)||e!==null&&e.dependencies!==null&&Fi(e.dependencies))?(G||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(l,Z,D),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(l,Z,D)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=Z),u.props=l,u.state=Z,u.context=D,l=I):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),l=!1)}return u=l,ur(e,t),l=(t.flags&128)!==0,u||l?(u=t.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&l?(t.child=Ia(t,e.child,null,c),t.child=Ia(t,null,a,c)):Tt(e,t,a,c),t.memoizedState=u.state,e=t.child):e=Xn(e,t,c),e}function Nh(e,t,a,l){return Ya(),t.flags|=256,Tt(e,t,a,l),t.child}var Gc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Yc(e){return{baseLanes:e,cachePool:mm()}}function Fc(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=It),e}function wh(e,t,a){var l=t.pendingProps,c=!1,u=(t.flags&128)!==0,v;if((v=u)||(v=e!==null&&e.memoizedState===null?!1:(ht.current&2)!==0),v&&(c=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,e===null){if(Oe){if(c?va(t):ya(),(e=nt)?(e=Dp(e,on),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:Nn,overflow:wn}:null,retryLane:536870912,hydrationErrors:null},a=sm(e),a.return=t,t.child=a,qt=t,nt=null)):e=null,e===null)throw ma(t);return Eu(e)?t.lanes=32:t.lanes=536870912,null}var A=l.children;return l=l.fallback,c?(ya(),c=t.mode,A=fr({mode:"hidden",children:A},c),l=Ga(l,c,a,null),A.return=t,l.return=t,A.sibling=l,t.child=A,l=t.child,l.memoizedState=Yc(a),l.childLanes=Fc(e,v,a),t.memoizedState=Gc,Ll(null,l)):(va(t),Xc(t,A))}var D=e.memoizedState;if(D!==null&&(A=D.dehydrated,A!==null)){if(u)t.flags&256?(va(t),t.flags&=-257,t=Qc(e,t,a)):t.memoizedState!==null?(ya(),t.child=e.child,t.flags|=128,t=null):(ya(),A=l.fallback,c=t.mode,l=fr({mode:"visible",children:l.children},c),A=Ga(A,c,a,null),A.flags|=2,l.return=t,A.return=t,l.sibling=A,t.child=l,Ia(t,e.child,null,a),l=t.child,l.memoizedState=Yc(a),l.childLanes=Fc(e,v,a),t.memoizedState=Gc,t=Ll(null,l));else if(va(t),Eu(A)){if(v=A.nextSibling&&A.nextSibling.dataset,v)var G=v.dgst;v=G,l=Error(o(419)),l.stack="",l.digest=v,wl({value:l,source:null,stack:null}),t=Qc(e,t,a)}else if(yt||Ms(e,t,a,!1),v=(a&e.childLanes)!==0,yt||v){if(v=We,v!==null&&(l=Ae(v,a),l!==0&&l!==D.retryLane))throw D.retryLane=l,$a(e,l),$t(v,e,l),Vc;Cu(A)||br(),t=Qc(e,t,a)}else Cu(A)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,nt=un(A.nextSibling),qt=t,Oe=!0,da=null,on=!1,e!==null&&rm(t,e),t=Xc(t,l.children),t.flags|=4096);return t}return c?(ya(),A=l.fallback,c=t.mode,D=e.child,G=D.sibling,l=Hn(D,{mode:"hidden",children:l.children}),l.subtreeFlags=D.subtreeFlags&65011712,G!==null?A=Hn(G,A):(A=Ga(A,c,a,null),A.flags|=2),A.return=t,l.return=t,l.sibling=A,t.child=l,Ll(null,l),l=t.child,A=e.child.memoizedState,A===null?A=Yc(a):(c=A.cachePool,c!==null?(D=gt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=mm(),A={baseLanes:A.baseLanes|a,cachePool:c}),l.memoizedState=A,l.childLanes=Fc(e,v,a),t.memoizedState=Gc,Ll(e.child,l)):(va(t),a=e.child,e=a.sibling,a=Hn(a,{mode:"visible",children:l.children}),a.return=t,a.sibling=null,e!==null&&(v=t.deletions,v===null?(t.deletions=[e],t.flags|=16):v.push(e)),t.child=a,t.memoizedState=null,a)}function Xc(e,t){return t=fr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function fr(e,t){return e=Xt(22,e,null,t),e.lanes=0,e}function Qc(e,t,a){return Ia(t,e.child,null,a),e=Xc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ch(e,t,a){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),oc(e.return,t,a)}function Kc(e,t,a,l,c,u){var v=e.memoizedState;v===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:c,treeForkCount:u}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=l,v.tail=a,v.tailMode=c,v.treeForkCount=u)}function Eh(e,t,a){var l=t.pendingProps,c=l.revealOrder,u=l.tail;l=l.children;var v=ht.current,A=(v&2)!==0;if(A?(v=v&1|2,t.flags|=128):v&=1,P(ht,v),Tt(e,t,l,a),l=Oe?Nl:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ch(e,a,t);else if(e.tag===19)Ch(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(a=t.child,c=null;a!==null;)e=a.alternate,e!==null&&Wi(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),Kc(t,!1,c,a,u,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Wi(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}Kc(t,!0,a,null,u,l);break;case"together":Kc(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function Xn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Aa|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ms(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,a=Hn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Hn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function Zc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Fi(e)))}function Jv(e,t,a){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),ha(t,gt,e.memoizedState.cache),Ya();break;case 27:case 5:xe(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:ha(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,bc(t),null;break;case 13:var l=t.memoizedState;if(l!==null)return l.dehydrated!==null?(va(t),t.flags|=128,null):(a&t.child.childLanes)!==0?wh(e,t,a):(va(t),e=Xn(e,t,a),e!==null?e.sibling:null);va(t);break;case 19:var c=(e.flags&128)!==0;if(l=(a&t.childLanes)!==0,l||(Ms(e,t,a,!1),l=(a&t.childLanes)!==0),c){if(l)return Eh(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),P(ht,ht.current),l)break;return null;case 22:return t.lanes=0,yh(e,t,a,t.pendingProps);case 24:ha(t,gt,e.memoizedState.cache)}return Xn(e,t,a)}function kh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)yt=!0;else{if(!Zc(e,a)&&(t.flags&128)===0)return yt=!1,Jv(e,t,a);yt=(e.flags&131072)!==0}else yt=!1,Oe&&(t.flags&1048576)!==0&&im(t,Nl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var l=t.pendingProps;if(e=Ka(t.elementType),t.type=e,typeof e=="function")ec(e)?(l=Pa(e,l),t.tag=1,t=jh(null,t,e,l,a)):(t.tag=0,t=$c(null,t,e,l,a));else{if(e!=null){var c=e.$$typeof;if(c===M){t.tag=11,t=xh(null,t,e,l,a);break e}else if(c===_){t.tag=14,t=gh(null,t,e,l,a);break e}}throw t=ce(e)||e,Error(o(306,t,""))}}return t;case 0:return $c(e,t,t.type,t.pendingProps,a);case 1:return l=t.type,c=Pa(l,t.pendingProps),jh(e,t,l,c,a);case 3:e:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(o(387));l=t.pendingProps;var u=t.memoizedState;c=u.element,pc(e,t),Tl(t,l,null,a);var v=t.memoizedState;if(l=v.cache,ha(t,gt,l),l!==u.cache&&cc(t,[gt],a,!0),Rl(),l=v.element,u.isDehydrated)if(u={element:l,isDehydrated:!1,cache:v.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=Nh(e,t,l,a);break e}else if(l!==c){c=sn(Error(o(424)),t),wl(c),t=Nh(e,t,l,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(nt=un(e.firstChild),qt=t,Oe=!0,da=null,on=!0,a=ym(t,null,l,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Ya(),l===c){t=Xn(e,t,a);break e}Tt(e,t,l,a)}t=t.child}return t;case 26:return ur(e,t),e===null?(a=Up(t.type,null,t.pendingProps,null))?t.memoizedState=a:Oe||(a=t.type,e=t.pendingProps,l=Er(ie.current).createElement(a),l[rt]=t,l[Nt]=e,Dt(l,a,e),Ct(l),t.stateNode=l):t.memoizedState=Up(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&Oe&&(l=t.stateNode=Bp(t.type,t.pendingProps,ie.current),qt=t,on=!0,c=nt,Ea(t.type)?(ku=c,nt=un(l.firstChild)):nt=c),Tt(e,t,t.pendingProps.children,a),ur(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Oe&&((c=l=nt)&&(l=Ey(l,t.type,t.pendingProps,on),l!==null?(t.stateNode=l,qt=t,nt=un(l.firstChild),on=!1,c=!0):c=!1),c||ma(t)),xe(t),c=t.type,u=t.pendingProps,v=e!==null?e.memoizedProps:null,l=u.children,ju(c,u)?l=null:v!==null&&ju(c,v)&&(t.flags|=32),t.memoizedState!==null&&(c=Ac(e,t,$v,null,null,a),Pl._currentValue=c),ur(e,t),Tt(e,t,l,a),t.child;case 6:return e===null&&Oe&&((e=a=nt)&&(a=ky(a,t.pendingProps,on),a!==null?(t.stateNode=a,qt=t,nt=null,e=!0):e=!1),e||ma(t)),null;case 13:return wh(e,t,a);case 4:return ve(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=Ia(t,null,l,a):Tt(e,t,l,a),t.child;case 11:return xh(e,t,t.type,t.pendingProps,a);case 7:return Tt(e,t,t.pendingProps,a),t.child;case 8:return Tt(e,t,t.pendingProps.children,a),t.child;case 12:return Tt(e,t,t.pendingProps.children,a),t.child;case 10:return l=t.pendingProps,ha(t,t.type,l.value),Tt(e,t,l.children,a),t.child;case 9:return c=t.type._context,l=t.pendingProps.children,Xa(t),c=Rt(c),l=l(c),t.flags|=1,Tt(e,t,l,a),t.child;case 14:return gh(e,t,t.type,t.pendingProps,a);case 15:return vh(e,t,t.type,t.pendingProps,a);case 19:return Eh(e,t,a);case 31:return Iv(e,t,a);case 22:return yh(e,t,a,t.pendingProps);case 24:return Xa(t),l=Rt(gt),e===null?(c=dc(),c===null&&(c=We,u=uc(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=a),c=u),t.memoizedState={parent:l,cache:c},hc(t),ha(t,gt,c)):((e.lanes&a)!==0&&(pc(e,t),Tl(t,null,null,a),Rl()),c=e.memoizedState,u=t.memoizedState,c.parent!==l?(c={parent:l,cache:l},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),ha(t,gt,l)):(l=u.cache,ha(t,gt,l),l!==c.cache&&cc(t,[gt],a,!0))),Tt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Qn(e){e.flags|=4}function Ic(e,t,a,l,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(tp())e.flags|=8192;else throw Za=Zi,mc}else e.flags&=-16777217}function Mh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Yp(t))if(tp())e.flags|=8192;else throw Za=Zi,mc}function dr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?ul():536870912,e.lanes|=t,Vs|=t)}function zl(e,t){if(!Oe)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function at(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(t)for(var c=e.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags&65011712,l|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags,l|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=l,e.childLanes=a,t}function Pv(e,t,a){var l=t.pendingProps;switch(sc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(t),null;case 1:return at(t),null;case 3:return a=t.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Gn(gt),ye(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(ks(t)?Qn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,ic())),at(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Qn(t),u!==null?(at(t),Mh(t,u)):(at(t),Ic(t,c,null,l,a))):u?u!==e.memoizedState?(Qn(t),at(t),Mh(t,u)):(at(t),t.flags&=-16777217):(e=e.memoizedProps,e!==l&&Qn(t),at(t),Ic(t,c,e,l,a)),null;case 27:if(Ue(t),a=ie.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Qn(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return at(t),null}e=ne.current,ks(t)?om(t):(e=Bp(c,l,a),t.stateNode=e,Qn(t))}return at(t),null;case 5:if(Ue(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Qn(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return at(t),null}if(u=ne.current,ks(t))om(t);else{var v=Er(ie.current);switch(u){case 1:u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":u=v.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof l.is=="string"?v.createElement("select",{is:l.is}):v.createElement("select"),l.multiple?u.multiple=!0:l.size&&(u.size=l.size);break;default:u=typeof l.is=="string"?v.createElement(c,{is:l.is}):v.createElement(c)}}u[rt]=t,u[Nt]=l;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)u.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=u;e:switch(Dt(u,c,l),c){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Qn(t)}}return at(t),Ic(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==l&&Qn(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(o(166));if(e=ie.current,ks(t)){if(e=t.stateNode,a=t.memoizedProps,l=null,c=qt,c!==null)switch(c.tag){case 27:case 5:l=c.memoizedProps}e[rt]=t,e=!!(e.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||wp(e.nodeValue,a)),e||ma(t,!0)}else e=Er(e).createTextNode(l),e[rt]=t,t.stateNode=e}return at(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(l=ks(t),a!==null){if(e===null){if(!l)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[rt]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),e=!1}else a=ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Kt(t),t):(Kt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return at(t),null;case 13:if(l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=ks(t),l!==null&&l.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[rt]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),c=!1}else c=ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Kt(t),t):(Kt(t),null)}return Kt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=l!==null,e=e!==null&&e.memoizedState!==null,a&&(l=t.child,c=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(c=l.alternate.memoizedState.cachePool.pool),u=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(u=l.memoizedState.cachePool.pool),u!==c&&(l.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),dr(t,t.updateQueue),at(t),null);case 4:return ye(),e===null&&vu(t.stateNode.containerInfo),at(t),null;case 10:return Gn(t.type),at(t),null;case 19:if(V(ht),l=t.memoizedState,l===null)return at(t),null;if(c=(t.flags&128)!==0,u=l.rendering,u===null)if(c)zl(l,!1);else{if(ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=Wi(e),u!==null){for(t.flags|=128,zl(l,!1),e=u.updateQueue,t.updateQueue=e,dr(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)am(a,e),a=a.sibling;return P(ht,ht.current&1|2),Oe&&Vn(t,l.treeForkCount),t.child}e=e.sibling}l.tail!==null&&ze()>gr&&(t.flags|=128,c=!0,zl(l,!1),t.lanes=4194304)}else{if(!c)if(e=Wi(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,dr(t,e),zl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!u.alternate&&!Oe)return at(t),null}else 2*ze()-l.renderingStartTime>gr&&a!==536870912&&(t.flags|=128,c=!0,zl(l,!1),t.lanes=4194304);l.isBackwards?(u.sibling=t.child,t.child=u):(e=l.last,e!==null?e.sibling=u:t.child=u,l.last=u)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=ze(),e.sibling=null,a=ht.current,P(ht,c?a&1|2:a&1),Oe&&Vn(t,l.treeForkCount),e):(at(t),null);case 22:case 23:return Kt(t),yc(),l=t.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(a&536870912)!==0&&(t.flags&128)===0&&(at(t),t.subtreeFlags&6&&(t.flags|=8192)):at(t),a=t.updateQueue,a!==null&&dr(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==a&&(t.flags|=2048),e!==null&&V(Qa),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Gn(gt),at(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Wv(e,t){switch(sc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gn(gt),ye(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ue(t),null;case 31:if(t.memoizedState!==null){if(Kt(t),t.alternate===null)throw Error(o(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Kt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(ht),null;case 4:return ye(),null;case 10:return Gn(t.type),null;case 22:case 23:return Kt(t),yc(),e!==null&&V(Qa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Gn(gt),null;case 25:return null;default:return null}}function qh(e,t){switch(sc(t),t.tag){case 3:Gn(gt),ye();break;case 26:case 27:case 5:Ue(t);break;case 4:ye();break;case 31:t.memoizedState!==null&&Kt(t);break;case 13:Kt(t);break;case 19:V(ht);break;case 10:Gn(t.type);break;case 22:case 23:Kt(t),yc(),e!==null&&V(Qa);break;case 24:Gn(gt)}}function Ul(e,t){try{var a=t.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var c=l.next;a=c;do{if((a.tag&e)===e){l=void 0;var u=a.create,v=a.inst;l=u(),v.destroy=l}a=a.next}while(a!==c)}}catch(A){Qe(t,t.return,A)}}function ba(e,t,a){try{var l=t.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var u=c.next;l=u;do{if((l.tag&e)===e){var v=l.inst,A=v.destroy;if(A!==void 0){v.destroy=void 0,c=t;var D=a,G=A;try{G()}catch(I){Qe(c,D,I)}}}l=l.next}while(l!==u)}}catch(I){Qe(t,t.return,I)}}function Rh(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{Sm(t,a)}catch(l){Qe(e,e.return,l)}}}function Th(e,t,a){a.props=Pa(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(l){Qe(e,t,l)}}function Hl(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof a=="function"?e.refCleanup=a(l):a.current=l}}catch(c){Qe(e,t,c)}}function Cn(e,t){var a=e.ref,l=e.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(c){Qe(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(c){Qe(e,t,c)}else a.current=null}function Dh(e){var t=e.type,a=e.memoizedProps,l=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(c){Qe(e,e.return,c)}}function Jc(e,t,a){try{var l=e.stateNode;Sy(l,e.type,a,t),l[Nt]=t}catch(c){Qe(e,e.return,c)}}function _h(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ea(e.type)||e.tag===4}function Pc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||_h(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Ea(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Wc(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=zn));else if(l!==4&&(l===27&&Ea(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(Wc(e,t,a),e=e.sibling;e!==null;)Wc(e,t,a),e=e.sibling}function mr(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(l!==4&&(l===27&&Ea(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(mr(e,t,a),e=e.sibling;e!==null;)mr(e,t,a),e=e.sibling}function Oh(e){var t=e.stateNode,a=e.memoizedProps;try{for(var l=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Dt(t,l,a),t[rt]=e,t[Nt]=a}catch(u){Qe(e,e.return,u)}}var Kn=!1,bt=!1,eu=!1,Bh=typeof WeakSet=="function"?WeakSet:Set,Et=null;function ey(e,t){if(e=e.containerInfo,Su=_r,e=Kd(e),Qo(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var c=l.anchorOffset,u=l.focusNode;l=l.focusOffset;try{a.nodeType,u.nodeType}catch{a=null;break e}var v=0,A=-1,D=-1,G=0,I=0,ee=e,Q=null;t:for(;;){for(var Z;ee!==a||c!==0&&ee.nodeType!==3||(A=v+c),ee!==u||l!==0&&ee.nodeType!==3||(D=v+l),ee.nodeType===3&&(v+=ee.nodeValue.length),(Z=ee.firstChild)!==null;)Q=ee,ee=Z;for(;;){if(ee===e)break t;if(Q===a&&++G===c&&(A=v),Q===u&&++I===l&&(D=v),(Z=ee.nextSibling)!==null)break;ee=Q,Q=ee.parentNode}ee=Z}a=A===-1||D===-1?null:{start:A,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(Au={focusedElem:e,selectionRange:a},_r=!1,Et=t;Et!==null;)if(t=Et,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Et=e;else for(;Et!==null;){switch(t=Et,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)c=e[a],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,a=t,c=u.memoizedProps,u=u.memoizedState,l=a.stateNode;try{var he=Pa(a.type,c);e=l.getSnapshotBeforeUpdate(he,u),l.__reactInternalSnapshotBeforeUpdate=e}catch(je){Qe(a,a.return,je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)wu(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":wu(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=t.sibling,e!==null){e.return=t.return,Et=e;break}Et=t.return}}function Lh(e,t,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:In(e,a),l&4&&Ul(5,a);break;case 1:if(In(e,a),l&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(v){Qe(a,a.return,v)}else{var c=Pa(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(v){Qe(a,a.return,v)}}l&64&&Rh(a),l&512&&Hl(a,a.return);break;case 3:if(In(e,a),l&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{Sm(e,t)}catch(v){Qe(a,a.return,v)}}break;case 27:t===null&&l&4&&Oh(a);case 26:case 5:In(e,a),t===null&&l&4&&Dh(a),l&512&&Hl(a,a.return);break;case 12:In(e,a);break;case 31:In(e,a),l&4&&Hh(e,a);break;case 13:In(e,a),l&4&&Vh(e,a),l&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=cy.bind(null,a),My(e,a))));break;case 22:if(l=a.memoizedState!==null||Kn,!l){t=t!==null&&t.memoizedState!==null||bt,c=Kn;var u=bt;Kn=l,(bt=t)&&!u?Jn(e,a,(a.subtreeFlags&8772)!==0):In(e,a),Kn=c,bt=u}break;case 30:break;default:In(e,a)}}function zh(e){var t=e.alternate;t!==null&&(e.alternate=null,zh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&qo(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var lt=null,zt=!1;function Zn(e,t,a){for(a=a.child;a!==null;)Uh(e,t,a),a=a.sibling}function Uh(e,t,a){if(jt&&typeof jt.onCommitFiberUnmount=="function")try{jt.onCommitFiberUnmount(Dn,a)}catch{}switch(a.tag){case 26:bt||Cn(a,t),Zn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:bt||Cn(a,t);var l=lt,c=zt;Ea(a.type)&&(lt=a.stateNode,zt=!1),Zn(e,t,a),Zl(a.stateNode),lt=l,zt=c;break;case 5:bt||Cn(a,t);case 6:if(l=lt,c=zt,lt=null,Zn(e,t,a),lt=l,zt=c,lt!==null)if(zt)try{(lt.nodeType===9?lt.body:lt.nodeName==="HTML"?lt.ownerDocument.body:lt).removeChild(a.stateNode)}catch(u){Qe(a,t,u)}else try{lt.removeChild(a.stateNode)}catch(u){Qe(a,t,u)}break;case 18:lt!==null&&(zt?(e=lt,Rp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Zs(e)):Rp(lt,a.stateNode));break;case 4:l=lt,c=zt,lt=a.stateNode.containerInfo,zt=!0,Zn(e,t,a),lt=l,zt=c;break;case 0:case 11:case 14:case 15:ba(2,a,t),bt||ba(4,a,t),Zn(e,t,a);break;case 1:bt||(Cn(a,t),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Th(a,t,l)),Zn(e,t,a);break;case 21:Zn(e,t,a);break;case 22:bt=(l=bt)||a.memoizedState!==null,Zn(e,t,a),bt=l;break;default:Zn(e,t,a)}}function Hh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Zs(e)}catch(a){Qe(t,t.return,a)}}}function Vh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Zs(e)}catch(a){Qe(t,t.return,a)}}function ty(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Bh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Bh),t;default:throw Error(o(435,e.tag))}}function hr(e,t){var a=ty(e);t.forEach(function(l){if(!a.has(l)){a.add(l);var c=uy.bind(null,e,l);l.then(c,c)}})}function Ut(e,t){var a=t.deletions;if(a!==null)for(var l=0;l<a.length;l++){var c=a[l],u=e,v=t,A=v;e:for(;A!==null;){switch(A.tag){case 27:if(Ea(A.type)){lt=A.stateNode,zt=!1;break e}break;case 5:lt=A.stateNode,zt=!1;break e;case 3:case 4:lt=A.stateNode.containerInfo,zt=!0;break e}A=A.return}if(lt===null)throw Error(o(160));Uh(u,v,c),lt=null,zt=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)$h(t,e),t=t.sibling}var gn=null;function $h(e,t){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ut(t,e),Ht(e),l&4&&(ba(3,e,e.return),Ul(3,e),ba(5,e,e.return));break;case 1:Ut(t,e),Ht(e),l&512&&(bt||a===null||Cn(a,a.return)),l&64&&Kn&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var c=gn;if(Ut(t,e),Ht(e),l&512&&(bt||a===null||Cn(a,a.return)),l&4){var u=a!==null?a.memoizedState:null;if(l=e.memoizedState,a===null)if(l===null)if(e.stateNode===null){e:{l=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(l){case"title":u=c.getElementsByTagName("title")[0],(!u||u[ml]||u[rt]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(l),c.head.insertBefore(u,c.querySelector("head > title"))),Dt(u,l,a),u[rt]=e,Ct(u),l=u;break e;case"link":var v=$p("link","href",c).get(l+(a.href||""));if(v){for(var A=0;A<v.length;A++)if(u=v[A],u.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&u.getAttribute("rel")===(a.rel==null?null:a.rel)&&u.getAttribute("title")===(a.title==null?null:a.title)&&u.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){v.splice(A,1);break t}}u=c.createElement(l),Dt(u,l,a),c.head.appendChild(u);break;case"meta":if(v=$p("meta","content",c).get(l+(a.content||""))){for(A=0;A<v.length;A++)if(u=v[A],u.getAttribute("content")===(a.content==null?null:""+a.content)&&u.getAttribute("name")===(a.name==null?null:a.name)&&u.getAttribute("property")===(a.property==null?null:a.property)&&u.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&u.getAttribute("charset")===(a.charSet==null?null:a.charSet)){v.splice(A,1);break t}}u=c.createElement(l),Dt(u,l,a),c.head.appendChild(u);break;default:throw Error(o(468,l))}u[rt]=e,Ct(u),l=u}e.stateNode=l}else Gp(c,e.type,e.stateNode);else e.stateNode=Vp(c,l,e.memoizedProps);else u!==l?(u===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):u.count--,l===null?Gp(c,e.type,e.stateNode):Vp(c,l,e.memoizedProps)):l===null&&e.stateNode!==null&&Jc(e,e.memoizedProps,a.memoizedProps)}break;case 27:Ut(t,e),Ht(e),l&512&&(bt||a===null||Cn(a,a.return)),a!==null&&l&4&&Jc(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Ut(t,e),Ht(e),l&512&&(bt||a===null||Cn(a,a.return)),e.flags&32){c=e.stateNode;try{vs(c,"")}catch(he){Qe(e,e.return,he)}}l&4&&e.stateNode!=null&&(c=e.memoizedProps,Jc(e,c,a!==null?a.memoizedProps:c)),l&1024&&(eu=!0);break;case 6:if(Ut(t,e),Ht(e),l&4){if(e.stateNode===null)throw Error(o(162));l=e.memoizedProps,a=e.stateNode;try{a.nodeValue=l}catch(he){Qe(e,e.return,he)}}break;case 3:if(qr=null,c=gn,gn=kr(t.containerInfo),Ut(t,e),gn=c,Ht(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Zs(t.containerInfo)}catch(he){Qe(e,e.return,he)}eu&&(eu=!1,Gh(e));break;case 4:l=gn,gn=kr(e.stateNode.containerInfo),Ut(t,e),Ht(e),gn=l;break;case 12:Ut(t,e),Ht(e);break;case 31:Ut(t,e),Ht(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,hr(e,l)));break;case 13:Ut(t,e),Ht(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(xr=ze()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,hr(e,l)));break;case 22:c=e.memoizedState!==null;var D=a!==null&&a.memoizedState!==null,G=Kn,I=bt;if(Kn=G||c,bt=I||D,Ut(t,e),bt=I,Kn=G,Ht(e),l&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||D||Kn||bt||Wa(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){D=a=t;try{if(u=D.stateNode,c)v=u.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{A=D.stateNode;var ee=D.memoizedProps.style,Q=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;A.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(he){Qe(D,D.return,he)}}}else if(t.tag===6){if(a===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(he){Qe(D,D.return,he)}}}else if(t.tag===18){if(a===null){D=t;try{var Z=D.stateNode;c?Tp(Z,!0):Tp(D.stateNode,!1)}catch(he){Qe(D,D.return,he)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}l&4&&(l=e.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,hr(e,a))));break;case 19:Ut(t,e),Ht(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,hr(e,l)));break;case 30:break;case 21:break;default:Ut(t,e),Ht(e)}}function Ht(e){var t=e.flags;if(t&2){try{for(var a,l=e.return;l!==null;){if(_h(l)){a=l;break}l=l.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,u=Pc(e);mr(e,u,c);break;case 5:var v=a.stateNode;a.flags&32&&(vs(v,""),a.flags&=-33);var A=Pc(e);mr(e,A,v);break;case 3:case 4:var D=a.stateNode.containerInfo,G=Pc(e);Wc(e,G,D);break;default:throw Error(o(161))}}catch(I){Qe(e,e.return,I)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Gh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Gh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function In(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Lh(e,t.alternate,t),t=t.sibling}function Wa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ba(4,t,t.return),Wa(t);break;case 1:Cn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Th(t,t.return,a),Wa(t);break;case 27:Zl(t.stateNode);case 26:case 5:Cn(t,t.return),Wa(t);break;case 22:t.memoizedState===null&&Wa(t);break;case 30:Wa(t);break;default:Wa(t)}e=e.sibling}}function Jn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var l=t.alternate,c=e,u=t,v=u.flags;switch(u.tag){case 0:case 11:case 15:Jn(c,u,a),Ul(4,u);break;case 1:if(Jn(c,u,a),l=u,c=l.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(G){Qe(l,l.return,G)}if(l=u,c=l.updateQueue,c!==null){var A=l.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)bm(D[c],A)}catch(G){Qe(l,l.return,G)}}a&&v&64&&Rh(u),Hl(u,u.return);break;case 27:Oh(u);case 26:case 5:Jn(c,u,a),a&&l===null&&v&4&&Dh(u),Hl(u,u.return);break;case 12:Jn(c,u,a);break;case 31:Jn(c,u,a),a&&v&4&&Hh(c,u);break;case 13:Jn(c,u,a),a&&v&4&&Vh(c,u);break;case 22:u.memoizedState===null&&Jn(c,u,a),Hl(u,u.return);break;case 30:break;default:Jn(c,u,a)}t=t.sibling}}function tu(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Cl(a))}function nu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cl(e))}function vn(e,t,a,l){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Yh(e,t,a,l),t=t.sibling}function Yh(e,t,a,l){var c=t.flags;switch(t.tag){case 0:case 11:case 15:vn(e,t,a,l),c&2048&&Ul(9,t);break;case 1:vn(e,t,a,l);break;case 3:vn(e,t,a,l),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cl(e)));break;case 12:if(c&2048){vn(e,t,a,l),e=t.stateNode;try{var u=t.memoizedProps,v=u.id,A=u.onPostCommit;typeof A=="function"&&A(v,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){Qe(t,t.return,D)}}else vn(e,t,a,l);break;case 31:vn(e,t,a,l);break;case 13:vn(e,t,a,l);break;case 23:break;case 22:u=t.stateNode,v=t.alternate,t.memoizedState!==null?u._visibility&2?vn(e,t,a,l):Vl(e,t):u._visibility&2?vn(e,t,a,l):(u._visibility|=2,zs(e,t,a,l,(t.subtreeFlags&10256)!==0||!1)),c&2048&&tu(v,t);break;case 24:vn(e,t,a,l),c&2048&&nu(t.alternate,t);break;default:vn(e,t,a,l)}}function zs(e,t,a,l,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,v=t,A=a,D=l,G=v.flags;switch(v.tag){case 0:case 11:case 15:zs(u,v,A,D,c),Ul(8,v);break;case 23:break;case 22:var I=v.stateNode;v.memoizedState!==null?I._visibility&2?zs(u,v,A,D,c):Vl(u,v):(I._visibility|=2,zs(u,v,A,D,c)),c&&G&2048&&tu(v.alternate,v);break;case 24:zs(u,v,A,D,c),c&&G&2048&&nu(v.alternate,v);break;default:zs(u,v,A,D,c)}t=t.sibling}}function Vl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,l=t,c=l.flags;switch(l.tag){case 22:Vl(a,l),c&2048&&tu(l.alternate,l);break;case 24:Vl(a,l),c&2048&&nu(l.alternate,l);break;default:Vl(a,l)}t=t.sibling}}var $l=8192;function Us(e,t,a){if(e.subtreeFlags&$l)for(e=e.child;e!==null;)Fh(e,t,a),e=e.sibling}function Fh(e,t,a){switch(e.tag){case 26:Us(e,t,a),e.flags&$l&&e.memoizedState!==null&&Vy(a,gn,e.memoizedState,e.memoizedProps);break;case 5:Us(e,t,a);break;case 3:case 4:var l=gn;gn=kr(e.stateNode.containerInfo),Us(e,t,a),gn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=$l,$l=16777216,Us(e,t,a),$l=l):Us(e,t,a));break;default:Us(e,t,a)}}function Xh(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Gl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];Et=l,Kh(l,e)}Xh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Qh(e),e=e.sibling}function Qh(e){switch(e.tag){case 0:case 11:case 15:Gl(e),e.flags&2048&&ba(9,e,e.return);break;case 3:Gl(e);break;case 12:Gl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,pr(e)):Gl(e);break;default:Gl(e)}}function pr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];Et=l,Kh(l,e)}Xh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ba(8,t,t.return),pr(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,pr(t));break;default:pr(t)}e=e.sibling}}function Kh(e,t){for(;Et!==null;){var a=Et;switch(a.tag){case 0:case 11:case 15:ba(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Cl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Et=l;else e:for(a=e;Et!==null;){l=Et;var c=l.sibling,u=l.return;if(zh(l),l===a){Et=null;break e}if(c!==null){c.return=u,Et=c;break e}Et=u}}}var ny={getCacheForType:function(e){var t=Rt(gt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return Rt(gt).controller.signal}},ay=typeof WeakMap=="function"?WeakMap:Map,Ge=0,We=null,Re=null,De=0,Xe=0,Zt=null,Sa=!1,Hs=!1,au=!1,Pn=0,ut=0,Aa=0,es=0,su=0,It=0,Vs=0,Yl=null,Vt=null,lu=!1,xr=0,Zh=0,gr=1/0,vr=null,ja=null,wt=0,Na=null,$s=null,Wn=0,iu=0,ru=null,Ih=null,Fl=0,ou=null;function Jt(){return(Ge&2)!==0&&De!==0?De&-De:T.T!==null?hu():qe()}function Jh(){if(It===0)if((De&536870912)===0||Oe){var e=Ba;Ba<<=1,(Ba&3932160)===0&&(Ba=262144),It=e}else It=536870912;return e=Qt.current,e!==null&&(e.flags|=32),It}function $t(e,t,a){(e===We&&(Xe===2||Xe===9)||e.cancelPendingCommit!==null)&&(Gs(e,0),wa(e,De,It,!1)),La(e,a),((Ge&2)===0||e!==We)&&(e===We&&((Ge&2)===0&&(es|=a),ut===4&&wa(e,De,It,!1)),En(e))}function Ph(e,t,a){if((Ge&6)!==0)throw Error(o(327));var l=!a&&(t&127)===0&&(t&e.expiredLanes)===0||On(e,t),c=l?iy(e,t):uu(e,t,!0),u=l;do{if(c===0){Hs&&!l&&wa(e,t,0,!1);break}else{if(a=e.current.alternate,u&&!sy(a)){c=uu(e,t,!1),u=!1;continue}if(c===2){if(u=t,e.errorRecoveryDisabledLanes&u)var v=0;else v=e.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){t=v;e:{var A=e;c=Yl;var D=A.current.memoizedState.isDehydrated;if(D&&(Gs(A,v).flags|=256),v=uu(A,v,!1),v!==2){if(au&&!D){A.errorRecoveryDisabledLanes|=u,es|=u,c=4;break e}u=Vt,Vt=c,u!==null&&(Vt===null?Vt=u:Vt.push.apply(Vt,u))}c=v}if(u=!1,c!==2)continue}}if(c===1){Gs(e,0),wa(e,t,0,!0);break}e:{switch(l=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:wa(l,t,It,!Sa);break e;case 2:Vt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=xr+300-ze(),10<c)){if(wa(l,t,It,!Sa),jn(l,0,!0)!==0)break e;Wn=t,l.timeoutHandle=Mp(Wh.bind(null,l,a,Vt,vr,lu,t,It,es,Vs,Sa,u,"Throttled",-0,0),c);break e}Wh(l,a,Vt,vr,lu,t,It,es,Vs,Sa,u,null,-0,0)}}break}while(!0);En(e)}function Wh(e,t,a,l,c,u,v,A,D,G,I,ee,Q,Z){if(e.timeoutHandle=-1,ee=t.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zn},Fh(t,u,ee);var he=(u&62914560)===u?xr-ze():(u&4194048)===u?Zh-ze():0;if(he=$y(ee,he),he!==null){Wn=u,e.cancelPendingCommit=he(rp.bind(null,e,t,u,a,l,c,v,A,D,I,ee,null,Q,Z)),wa(e,u,v,!G);return}}rp(e,t,u,a,l,c,v,A,D)}function sy(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var c=a[l],u=c.getSnapshot;c=c.value;try{if(!Ft(u(),c))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function wa(e,t,a,l){t&=~su,t&=~es,e.suspendedLanes|=t,e.pingedLanes&=~t,l&&(e.warmLanes|=t),l=e.expirationTimes;for(var c=t;0<c;){var u=31-Mt(c),v=1<<u;l[u]=-1,c&=~v}a!==0&&dl(e,a,t)}function yr(){return(Ge&6)===0?(Xl(0),!1):!0}function cu(){if(Re!==null){if(Xe===0)var e=Re.return;else e=Re,$n=Fa=null,wc(e),Ds=null,kl=0,e=Re;for(;e!==null;)qh(e.alternate,e),e=e.return;Re=null}}function Gs(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Ny(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),Wn=0,cu(),We=e,Re=a=Hn(e.current,null),De=t,Xe=0,Zt=null,Sa=!1,Hs=On(e,t),au=!1,Vs=It=su=es=Aa=ut=0,Vt=Yl=null,lu=!1,(t&8)!==0&&(t|=t&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=t;0<l;){var c=31-Mt(l),u=1<<c;t|=e[c],l&=~u}return Pn=t,Hi(),a}function ep(e,t){Ee=null,T.H=Bl,t===Ts||t===Ki?(t=xm(),Xe=3):t===mc?(t=xm(),Xe=4):Xe=t===Vc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Zt=t,Re===null&&(ut=1,or(e,sn(t,e.current)))}function tp(){var e=Qt.current;return e===null?!0:(De&4194048)===De?cn===null:(De&62914560)===De||(De&536870912)!==0?e===cn:!1}function np(){var e=T.H;return T.H=Bl,e===null?Bl:e}function ap(){var e=T.A;return T.A=ny,e}function br(){ut=4,Sa||(De&4194048)!==De&&Qt.current!==null||(Hs=!0),(Aa&134217727)===0&&(es&134217727)===0||We===null||wa(We,De,It,!1)}function uu(e,t,a){var l=Ge;Ge|=2;var c=np(),u=ap();(We!==e||De!==t)&&(vr=null,Gs(e,t)),t=!1;var v=ut;e:do try{if(Xe!==0&&Re!==null){var A=Re,D=Zt;switch(Xe){case 8:cu(),v=6;break e;case 3:case 2:case 9:case 6:Qt.current===null&&(t=!0);var G=Xe;if(Xe=0,Zt=null,Ys(e,A,D,G),a&&Hs){v=0;break e}break;default:G=Xe,Xe=0,Zt=null,Ys(e,A,D,G)}}ly(),v=ut;break}catch(I){ep(e,I)}while(!0);return t&&e.shellSuspendCounter++,$n=Fa=null,Ge=l,T.H=c,T.A=u,Re===null&&(We=null,De=0,Hi()),v}function ly(){for(;Re!==null;)sp(Re)}function iy(e,t){var a=Ge;Ge|=2;var l=np(),c=ap();We!==e||De!==t?(vr=null,gr=ze()+500,Gs(e,t)):Hs=On(e,t);e:do try{if(Xe!==0&&Re!==null){t=Re;var u=Zt;t:switch(Xe){case 1:Xe=0,Zt=null,Ys(e,t,u,1);break;case 2:case 9:if(hm(u)){Xe=0,Zt=null,lp(t);break}t=function(){Xe!==2&&Xe!==9||We!==e||(Xe=7),En(e)},u.then(t,t);break e;case 3:Xe=7;break e;case 4:Xe=5;break e;case 7:hm(u)?(Xe=0,Zt=null,lp(t)):(Xe=0,Zt=null,Ys(e,t,u,7));break;case 5:var v=null;switch(Re.tag){case 26:v=Re.memoizedState;case 5:case 27:var A=Re;if(v?Yp(v):A.stateNode.complete){Xe=0,Zt=null;var D=A.sibling;if(D!==null)Re=D;else{var G=A.return;G!==null?(Re=G,Sr(G)):Re=null}break t}}Xe=0,Zt=null,Ys(e,t,u,5);break;case 6:Xe=0,Zt=null,Ys(e,t,u,6);break;case 8:cu(),ut=6;break e;default:throw Error(o(462))}}ry();break}catch(I){ep(e,I)}while(!0);return $n=Fa=null,T.H=l,T.A=c,Ge=a,Re!==null?0:(We=null,De=0,Hi(),ut)}function ry(){for(;Re!==null&&!et();)sp(Re)}function sp(e){var t=kh(e.alternate,e,Pn);e.memoizedProps=e.pendingProps,t===null?Sr(e):Re=t}function lp(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Ah(a,t,t.pendingProps,t.type,void 0,De);break;case 11:t=Ah(a,t,t.pendingProps,t.type.render,t.ref,De);break;case 5:wc(t);default:qh(a,t),t=Re=am(t,Pn),t=kh(a,t,Pn)}e.memoizedProps=e.pendingProps,t===null?Sr(e):Re=t}function Ys(e,t,a,l){$n=Fa=null,wc(t),Ds=null,kl=0;var c=t.return;try{if(Zv(e,c,t,a,De)){ut=1,or(e,sn(a,e.current)),Re=null;return}}catch(u){if(c!==null)throw Re=c,u;ut=1,or(e,sn(a,e.current)),Re=null;return}t.flags&32768?(Oe||l===1?e=!0:Hs||(De&536870912)!==0?e=!1:(Sa=e=!0,(l===2||l===9||l===3||l===6)&&(l=Qt.current,l!==null&&l.tag===13&&(l.flags|=16384))),ip(t,e)):Sr(t)}function Sr(e){var t=e;do{if((t.flags&32768)!==0){ip(t,Sa);return}e=t.return;var a=Pv(t.alternate,t,Pn);if(a!==null){Re=a;return}if(t=t.sibling,t!==null){Re=t;return}Re=t=e}while(t!==null);ut===0&&(ut=5)}function ip(e,t){do{var a=Wv(e.alternate,e);if(a!==null){a.flags&=32767,Re=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Re=e;return}Re=e=a}while(e!==null);ut=6,Re=null}function rp(e,t,a,l,c,u,v,A,D){e.cancelPendingCommit=null;do Ar();while(wt!==0);if((Ge&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=Po,Mo(e,a,u,v,A,D),e===We&&(Re=We=null,De=0),$s=t,Na=e,Wn=a,iu=u,ru=c,Ih=l,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,fy(kt,function(){return dp(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||l){l=T.T,T.T=null,c=X.p,X.p=2,v=Ge,Ge|=4;try{ey(e,t,a)}finally{Ge=v,X.p=c,T.T=l}}wt=1,op(),cp(),up()}}function op(){if(wt===1){wt=0;var e=Na,t=$s,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=T.T,T.T=null;var l=X.p;X.p=2;var c=Ge;Ge|=4;try{$h(t,e);var u=Au,v=Kd(e.containerInfo),A=u.focusedElem,D=u.selectionRange;if(v!==A&&A&&A.ownerDocument&&Qd(A.ownerDocument.documentElement,A)){if(D!==null&&Qo(A)){var G=D.start,I=D.end;if(I===void 0&&(I=G),"selectionStart"in A)A.selectionStart=G,A.selectionEnd=Math.min(I,A.value.length);else{var ee=A.ownerDocument||document,Q=ee&&ee.defaultView||window;if(Q.getSelection){var Z=Q.getSelection(),he=A.textContent.length,je=Math.min(D.start,he),Je=D.end===void 0?je:Math.min(D.end,he);!Z.extend&&je>Je&&(v=Je,Je=je,je=v);var z=Xd(A,je),O=Xd(A,Je);if(z&&O&&(Z.rangeCount!==1||Z.anchorNode!==z.node||Z.anchorOffset!==z.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var $=ee.createRange();$.setStart(z.node,z.offset),Z.removeAllRanges(),je>Je?(Z.addRange($),Z.extend(O.node,O.offset)):($.setEnd(O.node,O.offset),Z.addRange($))}}}}for(ee=[],Z=A;Z=Z.parentNode;)Z.nodeType===1&&ee.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<ee.length;A++){var W=ee[A];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}_r=!!Su,Au=Su=null}finally{Ge=c,X.p=l,T.T=a}}e.current=t,wt=2}}function cp(){if(wt===2){wt=0;var e=Na,t=$s,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=T.T,T.T=null;var l=X.p;X.p=2;var c=Ge;Ge|=4;try{Lh(e,t.alternate,t)}finally{Ge=c,X.p=l,T.T=a}}wt=3}}function up(){if(wt===4||wt===3){wt=0,dt();var e=Na,t=$s,a=Wn,l=Ih;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?wt=5:(wt=0,$s=Na=null,fp(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(ja=null),Pe(a),t=t.stateNode,jt&&typeof jt.onCommitFiberRoot=="function")try{jt.onCommitFiberRoot(Dn,t,void 0,(t.current.flags&128)===128)}catch{}if(l!==null){t=T.T,c=X.p,X.p=2,T.T=null;try{for(var u=e.onRecoverableError,v=0;v<l.length;v++){var A=l[v];u(A.value,{componentStack:A.stack})}}finally{T.T=t,X.p=c}}(Wn&3)!==0&&Ar(),En(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===ou?Fl++:(Fl=0,ou=e):Fl=0,Xl(0)}}function fp(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Cl(t)))}function Ar(){return op(),cp(),up(),dp()}function dp(){if(wt!==5)return!1;var e=Na,t=iu;iu=0;var a=Pe(Wn),l=T.T,c=X.p;try{X.p=32>a?32:a,T.T=null,a=ru,ru=null;var u=Na,v=Wn;if(wt=0,$s=Na=null,Wn=0,(Ge&6)!==0)throw Error(o(331));var A=Ge;if(Ge|=4,Qh(u.current),Yh(u,u.current,v,a),Ge=A,Xl(0,!1),jt&&typeof jt.onPostCommitFiberRoot=="function")try{jt.onPostCommitFiberRoot(Dn,u)}catch{}return!0}finally{X.p=c,T.T=l,fp(e,t)}}function mp(e,t,a){t=sn(a,t),t=Hc(e.stateNode,t,2),e=ga(e,t,2),e!==null&&(La(e,2),En(e))}function Qe(e,t,a){if(e.tag===3)mp(e,e,a);else for(;t!==null;){if(t.tag===3){mp(t,e,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ja===null||!ja.has(l))){e=sn(a,e),a=hh(2),l=ga(t,a,2),l!==null&&(ph(a,l,t,e),La(l,2),En(l));break}}t=t.return}}function fu(e,t,a){var l=e.pingCache;if(l===null){l=e.pingCache=new ay;var c=new Set;l.set(t,c)}else c=l.get(t),c===void 0&&(c=new Set,l.set(t,c));c.has(a)||(au=!0,c.add(a),e=oy.bind(null,e,t,a),t.then(e,e))}function oy(e,t,a){var l=e.pingCache;l!==null&&l.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,We===e&&(De&a)===a&&(ut===4||ut===3&&(De&62914560)===De&&300>ze()-xr?(Ge&2)===0&&Gs(e,0):su|=a,Vs===De&&(Vs=0)),En(e)}function hp(e,t){t===0&&(t=ul()),e=$a(e,t),e!==null&&(La(e,t),En(e))}function cy(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),hp(e,a)}function uy(e,t){var a=0;switch(e.tag){case 31:case 13:var l=e.stateNode,c=e.memoizedState;c!==null&&(a=c.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(o(314))}l!==null&&l.delete(t),hp(e,a)}function fy(e,t){return me(e,t)}var jr=null,Fs=null,du=!1,Nr=!1,mu=!1,Ca=0;function En(e){e!==Fs&&e.next===null&&(Fs===null?jr=Fs=e:Fs=Fs.next=e),Nr=!0,du||(du=!0,my())}function Xl(e,t){if(!mu&&Nr){mu=!0;do for(var a=!1,l=jr;l!==null;){if(e!==0){var c=l.pendingLanes;if(c===0)var u=0;else{var v=l.suspendedLanes,A=l.pingedLanes;u=(1<<31-Mt(42|e)+1)-1,u&=c&~(v&~A),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(a=!0,vp(l,u))}else u=De,u=jn(l,l===We?u:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(u&3)===0||On(l,u)||(a=!0,vp(l,u));l=l.next}while(a);mu=!1}}function dy(){pp()}function pp(){Nr=du=!1;var e=0;Ca!==0&&jy()&&(e=Ca);for(var t=ze(),a=null,l=jr;l!==null;){var c=l.next,u=xp(l,t);u===0?(l.next=null,a===null?jr=c:a.next=c,c===null&&(Fs=a)):(a=l,(e!==0||(u&3)!==0)&&(Nr=!0)),l=c}wt!==0&&wt!==5||Xl(e),Ca!==0&&(Ca=0)}function xp(e,t){for(var a=e.suspendedLanes,l=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var v=31-Mt(u),A=1<<v,D=c[v];D===-1?((A&a)===0||(A&l)!==0)&&(c[v]=ds(A,t)):D<=t&&(e.expiredLanes|=A),u&=~A}if(t=We,a=De,a=jn(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,a===0||e===t&&(Xe===2||Xe===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&we(l),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||On(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(l!==null&&we(l),Pe(a)){case 2:case 8:a=Tn;break;case 32:a=kt;break;case 268435456:a=Gt;break;default:a=kt}return l=gp.bind(null,e),a=me(a,l),e.callbackPriority=t,e.callbackNode=a,t}return l!==null&&l!==null&&we(l),e.callbackPriority=2,e.callbackNode=null,2}function gp(e,t){if(wt!==0&&wt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Ar()&&e.callbackNode!==a)return null;var l=De;return l=jn(e,e===We?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(Ph(e,l,t),xp(e,ze()),e.callbackNode!=null&&e.callbackNode===a?gp.bind(null,e):null)}function vp(e,t){if(Ar())return null;Ph(e,t,!0)}function my(){wy(function(){(Ge&6)!==0?me(mt,dy):pp()})}function hu(){if(Ca===0){var e=qs;e===0&&(e=fs,fs<<=1,(fs&261888)===0&&(fs=256)),Ca=e}return Ca}function yp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ti(""+e)}function bp(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function hy(e,t,a,l,c){if(t==="submit"&&a&&a.stateNode===c){var u=yp((c[Nt]||null).action),v=l.submitter;v&&(t=(t=v[Nt]||null)?yp(t.formAction):v.getAttribute("formAction"),t!==null&&(u=t,v=null));var A=new Bi("action","action",null,l,c);e.push({event:A,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Ca!==0){var D=v?bp(c,v):new FormData(c);_c(a,{pending:!0,data:D,method:c.method,action:u},null,D)}}else typeof u=="function"&&(A.preventDefault(),D=v?bp(c,v):new FormData(c),_c(a,{pending:!0,data:D,method:c.method,action:u},u,D))},currentTarget:c}]})}}for(var pu=0;pu<Jo.length;pu++){var xu=Jo[pu],py=xu.toLowerCase(),xy=xu[0].toUpperCase()+xu.slice(1);xn(py,"on"+xy)}xn(Jd,"onAnimationEnd"),xn(Pd,"onAnimationIteration"),xn(Wd,"onAnimationStart"),xn("dblclick","onDoubleClick"),xn("focusin","onFocus"),xn("focusout","onBlur"),xn(Tv,"onTransitionRun"),xn(Dv,"onTransitionStart"),xn(_v,"onTransitionCancel"),xn(em,"onTransitionEnd"),xs("onMouseEnter",["mouseout","mouseover"]),xs("onMouseLeave",["mouseout","mouseover"]),xs("onPointerEnter",["pointerout","pointerover"]),xs("onPointerLeave",["pointerout","pointerover"]),za("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),za("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),za("onBeforeInput",["compositionend","keypress","textInput","paste"]),za("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),za("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),za("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ql="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(" "),gy=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ql));function Sp(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],c=l.event;l=l.listeners;e:{var u=void 0;if(t)for(var v=l.length-1;0<=v;v--){var A=l[v],D=A.instance,G=A.currentTarget;if(A=A.listener,D!==u&&c.isPropagationStopped())break e;u=A,c.currentTarget=G;try{u(c)}catch(I){Ui(I)}c.currentTarget=null,u=D}else for(v=0;v<l.length;v++){if(A=l[v],D=A.instance,G=A.currentTarget,A=A.listener,D!==u&&c.isPropagationStopped())break e;u=A,c.currentTarget=G;try{u(c)}catch(I){Ui(I)}c.currentTarget=null,u=D}}}}function Te(e,t){var a=t[Bn];a===void 0&&(a=t[Bn]=new Set);var l=e+"__bubble";a.has(l)||(Ap(t,e,2,!1),a.add(l))}function gu(e,t,a){var l=0;t&&(l|=4),Ap(a,e,l,t)}var wr="_reactListening"+Math.random().toString(36).slice(2);function vu(e){if(!e[wr]){e[wr]=!0,pd.forEach(function(a){a!=="selectionchange"&&(gy.has(a)||gu(a,!1,e),gu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wr]||(t[wr]=!0,gu("selectionchange",!1,t))}}function Ap(e,t,a,l){switch(Jp(t)){case 2:var c=Fy;break;case 8:c=Xy;break;default:c=Du}a=c.bind(null,t,a,e),c=void 0,!zo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),l?c!==void 0?e.addEventListener(t,a,{capture:!0,passive:c}):e.addEventListener(t,a,!0):c!==void 0?e.addEventListener(t,a,{passive:c}):e.addEventListener(t,a,!1)}function yu(e,t,a,l,c){var u=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var v=l.tag;if(v===3||v===4){var A=l.stateNode.containerInfo;if(A===c)break;if(v===4)for(v=l.return;v!==null;){var D=v.tag;if((D===3||D===4)&&v.stateNode.containerInfo===c)return;v=v.return}for(;A!==null;){if(v=ms(A),v===null)return;if(D=v.tag,D===5||D===6||D===26||D===27){l=u=v;continue e}A=A.parentNode}}l=l.return}Ed(function(){var G=u,I=Bo(a),ee=[];e:{var Q=tm.get(e);if(Q!==void 0){var Z=Bi,he=e;switch(e){case"keypress":if(_i(a)===0)break e;case"keydown":case"keyup":Z=uv;break;case"focusin":he="focus",Z=$o;break;case"focusout":he="blur",Z=$o;break;case"beforeblur":case"afterblur":Z=$o;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=qd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=Pg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=mv;break;case Jd:case Pd:case Wd:Z=tv;break;case em:Z=pv;break;case"scroll":case"scrollend":Z=Ig;break;case"wheel":Z=gv;break;case"copy":case"cut":case"paste":Z=av;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Td;break;case"toggle":case"beforetoggle":Z=yv}var je=(t&4)!==0,Je=!je&&(e==="scroll"||e==="scrollend"),z=je?Q!==null?Q+"Capture":null:Q;je=[];for(var O=G,$;O!==null;){var W=O;if($=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||$===null||z===null||(W=pl(O,z),W!=null&&je.push(Kl(O,W,$))),Je)break;O=O.return}0<je.length&&(Q=new Z(Q,he,null,a,I),ee.push({event:Q,listeners:je}))}}if((t&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",Z=e==="mouseout"||e==="pointerout",Q&&a!==Oo&&(he=a.relatedTarget||a.fromElement)&&(ms(he)||he[st]))break e;if((Z||Q)&&(Q=I.window===I?I:(Q=I.ownerDocument)?Q.defaultView||Q.parentWindow:window,Z?(he=a.relatedTarget||a.toElement,Z=G,he=he?ms(he):null,he!==null&&(Je=d(he),je=he.tag,he!==Je||je!==5&&je!==27&&je!==6)&&(he=null)):(Z=null,he=G),Z!==he)){if(je=qd,W="onMouseLeave",z="onMouseEnter",O="mouse",(e==="pointerout"||e==="pointerover")&&(je=Td,W="onPointerLeave",z="onPointerEnter",O="pointer"),Je=Z==null?Q:hl(Z),$=he==null?Q:hl(he),Q=new je(W,O+"leave",Z,a,I),Q.target=Je,Q.relatedTarget=$,W=null,ms(I)===G&&(je=new je(z,O+"enter",he,a,I),je.target=$,je.relatedTarget=Je,W=je),Je=W,Z&&he)t:{for(je=vy,z=Z,O=he,$=0,W=z;W;W=je(W))$++;W=0;for(var Se=O;Se;Se=je(Se))W++;for(;0<$-W;)z=je(z),$--;for(;0<W-$;)O=je(O),W--;for(;$--;){if(z===O||O!==null&&z===O.alternate){je=z;break t}z=je(z),O=je(O)}je=null}else je=null;Z!==null&&jp(ee,Q,Z,je,!1),he!==null&&Je!==null&&jp(ee,Je,he,je,!0)}}e:{if(Q=G?hl(G):window,Z=Q.nodeName&&Q.nodeName.toLowerCase(),Z==="select"||Z==="input"&&Q.type==="file")var He=Hd;else if(zd(Q))if(Vd)He=Mv;else{He=Ev;var ge=Cv}else Z=Q.nodeName,!Z||Z.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?G&&_o(G.elementType)&&(He=Hd):He=kv;if(He&&(He=He(e,G))){Ud(ee,He,a,I);break e}ge&&ge(e,Q,G),e==="focusout"&&G&&Q.type==="number"&&G.memoizedProps.value!=null&&Do(Q,"number",Q.value)}switch(ge=G?hl(G):window,e){case"focusin":(zd(ge)||ge.contentEditable==="true")&&(As=ge,Ko=G,jl=null);break;case"focusout":jl=Ko=As=null;break;case"mousedown":Zo=!0;break;case"contextmenu":case"mouseup":case"dragend":Zo=!1,Zd(ee,a,I);break;case"selectionchange":if(Rv)break;case"keydown":case"keyup":Zd(ee,a,I)}var ke;if(Yo)e:{switch(e){case"compositionstart":var _e="onCompositionStart";break e;case"compositionend":_e="onCompositionEnd";break e;case"compositionupdate":_e="onCompositionUpdate";break e}_e=void 0}else Ss?Bd(e,a)&&(_e="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(_e="onCompositionStart");_e&&(Dd&&a.locale!=="ko"&&(Ss||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&Ss&&(ke=kd()):(ua=I,Uo="value"in ua?ua.value:ua.textContent,Ss=!0)),ge=Cr(G,_e),0<ge.length&&(_e=new Rd(_e,e,null,a,I),ee.push({event:_e,listeners:ge}),ke?_e.data=ke:(ke=Ld(a),ke!==null&&(_e.data=ke)))),(ke=Sv?Av(e,a):jv(e,a))&&(_e=Cr(G,"onBeforeInput"),0<_e.length&&(ge=new Rd("onBeforeInput","beforeinput",null,a,I),ee.push({event:ge,listeners:_e}),ge.data=ke)),hy(ee,e,G,a,I)}Sp(ee,t)})}function Kl(e,t,a){return{instance:e,listener:t,currentTarget:a}}function Cr(e,t){for(var a=t+"Capture",l=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=pl(e,a),c!=null&&l.unshift(Kl(e,c,u)),c=pl(e,t),c!=null&&l.push(Kl(e,c,u))),e.tag===3)return l;e=e.return}return[]}function vy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function jp(e,t,a,l,c){for(var u=t._reactName,v=[];a!==null&&a!==l;){var A=a,D=A.alternate,G=A.stateNode;if(A=A.tag,D!==null&&D===l)break;A!==5&&A!==26&&A!==27||G===null||(D=G,c?(G=pl(a,u),G!=null&&v.unshift(Kl(a,G,D))):c||(G=pl(a,u),G!=null&&v.push(Kl(a,G,D)))),a=a.return}v.length!==0&&e.push({event:t,listeners:v})}var yy=/\r\n?/g,by=/\u0000|\uFFFD/g;function Np(e){return(typeof e=="string"?e:""+e).replace(yy,`
`).replace(by,"")}function wp(e,t){return t=Np(t),Np(e)===t}function Ie(e,t,a,l,c,u){switch(a){case"children":typeof l=="string"?t==="body"||t==="textarea"&&l===""||vs(e,l):(typeof l=="number"||typeof l=="bigint")&&t!=="body"&&vs(e,""+l);break;case"className":qi(e,"class",l);break;case"tabIndex":qi(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":qi(e,a,l);break;case"style":wd(e,l,u);break;case"data":if(t!=="object"){qi(e,"data",l);break}case"src":case"href":if(l===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Ti(""+l),e.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(a,"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 u=="function"&&(a==="formAction"?(t!=="input"&&Ie(e,t,"name",c.name,c,null),Ie(e,t,"formEncType",c.formEncType,c,null),Ie(e,t,"formMethod",c.formMethod,c,null),Ie(e,t,"formTarget",c.formTarget,c,null)):(Ie(e,t,"encType",c.encType,c,null),Ie(e,t,"method",c.method,c,null),Ie(e,t,"target",c.target,c,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Ti(""+l),e.setAttribute(a,l);break;case"onClick":l!=null&&(e.onclick=zn);break;case"onScroll":l!=null&&Te("scroll",e);break;case"onScrollEnd":l!=null&&Te("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}a=Ti(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""+l):e.removeAttribute(a);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":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":l===!0?e.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,l):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(a,l):e.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(a):e.setAttribute(a,l);break;case"popover":Te("beforetoggle",e),Te("toggle",e),Mi(e,"popover",l);break;case"xlinkActuate":Ln(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Ln(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Ln(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Ln(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Ln(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Ln(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Mi(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Kg.get(a)||a,Mi(e,a,l))}}function bu(e,t,a,l,c,u){switch(a){case"style":wd(e,l,u);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof l=="string"?vs(e,l):(typeof l=="number"||typeof l=="bigint")&&vs(e,""+l);break;case"onScroll":l!=null&&Te("scroll",e);break;case"onScrollEnd":l!=null&&Te("scrollend",e);break;case"onClick":l!=null&&(e.onclick=zn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!xd.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(c=a.endsWith("Capture"),t=a.slice(2,c?a.length-7:void 0),u=e[Nt]||null,u=u!=null?u[a]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof l=="function")){typeof u!="function"&&u!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,l,c);break e}a in e?e[a]=l:l===!0?e.setAttribute(a,""):Mi(e,a,l)}}}function Dt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Te("error",e),Te("load",e);var l=!1,c=!1,u;for(u in a)if(a.hasOwnProperty(u)){var v=a[u];if(v!=null)switch(u){case"src":l=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ie(e,t,u,v,a,null)}}c&&Ie(e,t,"srcSet",a.srcSet,a,null),l&&Ie(e,t,"src",a.src,a,null);return;case"input":Te("invalid",e);var A=u=v=c=null,D=null,G=null;for(l in a)if(a.hasOwnProperty(l)){var I=a[l];if(I!=null)switch(l){case"name":c=I;break;case"type":v=I;break;case"checked":D=I;break;case"defaultChecked":G=I;break;case"value":u=I;break;case"defaultValue":A=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:Ie(e,t,l,I,a,null)}}Sd(e,u,A,D,G,v,c,!1);return;case"select":Te("invalid",e),l=v=u=null;for(c in a)if(a.hasOwnProperty(c)&&(A=a[c],A!=null))switch(c){case"value":u=A;break;case"defaultValue":v=A;break;case"multiple":l=A;default:Ie(e,t,c,A,a,null)}t=u,a=v,e.multiple=!!l,t!=null?gs(e,!!l,t,!1):a!=null&&gs(e,!!l,a,!0);return;case"textarea":Te("invalid",e),u=c=l=null;for(v in a)if(a.hasOwnProperty(v)&&(A=a[v],A!=null))switch(v){case"value":l=A;break;case"defaultValue":c=A;break;case"children":u=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(o(91));break;default:Ie(e,t,v,A,a,null)}jd(e,l,c,u);return;case"option":for(D in a)if(a.hasOwnProperty(D)&&(l=a[D],l!=null))switch(D){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:Ie(e,t,D,l,a,null)}return;case"dialog":Te("beforetoggle",e),Te("toggle",e),Te("cancel",e),Te("close",e);break;case"iframe":case"object":Te("load",e);break;case"video":case"audio":for(l=0;l<Ql.length;l++)Te(Ql[l],e);break;case"image":Te("error",e),Te("load",e);break;case"details":Te("toggle",e);break;case"embed":case"source":case"link":Te("error",e),Te("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in a)if(a.hasOwnProperty(G)&&(l=a[G],l!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ie(e,t,G,l,a,null)}return;default:if(_o(t)){for(I in a)a.hasOwnProperty(I)&&(l=a[I],l!==void 0&&bu(e,t,I,l,a,void 0));return}}for(A in a)a.hasOwnProperty(A)&&(l=a[A],l!=null&&Ie(e,t,A,l,a,null))}function Sy(e,t,a,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,u=null,v=null,A=null,D=null,G=null,I=null;for(Z in a){var ee=a[Z];if(a.hasOwnProperty(Z)&&ee!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=ee;default:l.hasOwnProperty(Z)||Ie(e,t,Z,null,l,ee)}}for(var Q in l){var Z=l[Q];if(ee=a[Q],l.hasOwnProperty(Q)&&(Z!=null||ee!=null))switch(Q){case"type":u=Z;break;case"name":c=Z;break;case"checked":G=Z;break;case"defaultChecked":I=Z;break;case"value":v=Z;break;case"defaultValue":A=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(o(137,t));break;default:Z!==ee&&Ie(e,t,Q,Z,l,ee)}}To(e,v,A,D,G,I,u,c);return;case"select":Z=v=A=Q=null;for(u in a)if(D=a[u],a.hasOwnProperty(u)&&D!=null)switch(u){case"value":break;case"multiple":Z=D;default:l.hasOwnProperty(u)||Ie(e,t,u,null,l,D)}for(c in l)if(u=l[c],D=a[c],l.hasOwnProperty(c)&&(u!=null||D!=null))switch(c){case"value":Q=u;break;case"defaultValue":A=u;break;case"multiple":v=u;default:u!==D&&Ie(e,t,c,u,l,D)}t=A,a=v,l=Z,Q!=null?gs(e,!!a,Q,!1):!!l!=!!a&&(t!=null?gs(e,!!a,t,!0):gs(e,!!a,a?[]:"",!1));return;case"textarea":Z=Q=null;for(A in a)if(c=a[A],a.hasOwnProperty(A)&&c!=null&&!l.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:Ie(e,t,A,null,l,c)}for(v in l)if(c=l[v],u=a[v],l.hasOwnProperty(v)&&(c!=null||u!=null))switch(v){case"value":Q=c;break;case"defaultValue":Z=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Ie(e,t,v,c,l,u)}Ad(e,Q,Z);return;case"option":for(var he in a)if(Q=a[he],a.hasOwnProperty(he)&&Q!=null&&!l.hasOwnProperty(he))switch(he){case"selected":e.selected=!1;break;default:Ie(e,t,he,null,l,Q)}for(D in l)if(Q=l[D],Z=a[D],l.hasOwnProperty(D)&&Q!==Z&&(Q!=null||Z!=null))switch(D){case"selected":e.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:Ie(e,t,D,Q,l,Z)}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 je in a)Q=a[je],a.hasOwnProperty(je)&&Q!=null&&!l.hasOwnProperty(je)&&Ie(e,t,je,null,l,Q);for(G in l)if(Q=l[G],Z=a[G],l.hasOwnProperty(G)&&Q!==Z&&(Q!=null||Z!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(o(137,t));break;default:Ie(e,t,G,Q,l,Z)}return;default:if(_o(t)){for(var Je in a)Q=a[Je],a.hasOwnProperty(Je)&&Q!==void 0&&!l.hasOwnProperty(Je)&&bu(e,t,Je,void 0,l,Q);for(I in l)Q=l[I],Z=a[I],!l.hasOwnProperty(I)||Q===Z||Q===void 0&&Z===void 0||bu(e,t,I,Q,l,Z);return}}for(var z in a)Q=a[z],a.hasOwnProperty(z)&&Q!=null&&!l.hasOwnProperty(z)&&Ie(e,t,z,null,l,Q);for(ee in l)Q=l[ee],Z=a[ee],!l.hasOwnProperty(ee)||Q===Z||Q==null&&Z==null||Ie(e,t,ee,Q,l,Z)}function Cp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Ay(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var c=a[l],u=c.transferSize,v=c.initiatorType,A=c.duration;if(u&&A&&Cp(v)){for(v=0,A=c.responseEnd,l+=1;l<a.length;l++){var D=a[l],G=D.startTime;if(G>A)break;var I=D.transferSize,ee=D.initiatorType;I&&Cp(ee)&&(D=D.responseEnd,v+=I*(D<A?1:(A-G)/(D-G)))}if(--l,t+=8*(u+v)/(c.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Su=null,Au=null;function Er(e){return e.nodeType===9?e:e.ownerDocument}function Ep(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function kp(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function ju(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Nu=null;function jy(){var e=window.event;return e&&e.type==="popstate"?e===Nu?!1:(Nu=e,!0):(Nu=null,!1)}var Mp=typeof setTimeout=="function"?setTimeout:void 0,Ny=typeof clearTimeout=="function"?clearTimeout:void 0,qp=typeof Promise=="function"?Promise:void 0,wy=typeof queueMicrotask=="function"?queueMicrotask:typeof qp<"u"?function(e){return qp.resolve(null).then(e).catch(Cy)}:Mp;function Cy(e){setTimeout(function(){throw e})}function Ea(e){return e==="head"}function Rp(e,t){var a=t,l=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(l===0){e.removeChild(c),Zs(t);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Zl(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Zl(a);for(var u=a.firstChild;u;){var v=u.nextSibling,A=u.nodeName;u[ml]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&u.rel.toLowerCase()==="stylesheet"||a.removeChild(u),u=v}}else a==="body"&&Zl(e.ownerDocument.body);a=c}while(a);Zs(t)}function Tp(e,t){var a=e;e=0;do{var l=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=l}while(a)}function wu(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":wu(a),qo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Ey(e,t,a,l){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[ml])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(u=e.getAttribute("rel"),u==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(u!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(u=e.getAttribute("src"),(u!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&u&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var u=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===u)return e}else return e;if(e=un(e.nextSibling),e===null)break}return null}function ky(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=un(e.nextSibling),e===null))return null;return e}function Dp(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=un(e.nextSibling),e===null))return null;return e}function Cu(e){return e.data==="$?"||e.data==="$~"}function Eu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function My(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var l=function(){t(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function un(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var ku=null;function _p(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return un(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function Op(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function Bp(e,t,a){switch(t=Er(a),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Zl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);qo(e)}var fn=new Map,Lp=new Set;function kr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ea=X.d;X.d={f:qy,r:Ry,D:Ty,C:Dy,L:_y,m:Oy,X:Ly,S:By,M:zy};function qy(){var e=ea.f(),t=yr();return e||t}function Ry(e){var t=hs(e);t!==null&&t.tag===5&&t.type==="form"?eh(t):ea.r(e)}var Xs=typeof document>"u"?null:document;function zp(e,t,a){var l=Xs;if(l&&typeof t=="string"&&t){var c=nn(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),Lp.has(c)||(Lp.add(c),e={rel:e,crossOrigin:a,href:t},l.querySelector(c)===null&&(t=l.createElement("link"),Dt(t,"link",e),Ct(t),l.head.appendChild(t)))}}function Ty(e){ea.D(e),zp("dns-prefetch",e,null)}function Dy(e,t){ea.C(e,t),zp("preconnect",e,t)}function _y(e,t,a){ea.L(e,t,a);var l=Xs;if(l&&e&&t){var c='link[rel="preload"][as="'+nn(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+nn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+nn(a.imageSizes)+'"]')):c+='[href="'+nn(e)+'"]';var u=c;switch(t){case"style":u=Qs(e);break;case"script":u=Ks(e)}fn.has(u)||(e=b({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),fn.set(u,e),l.querySelector(c)!==null||t==="style"&&l.querySelector(Il(u))||t==="script"&&l.querySelector(Jl(u))||(t=l.createElement("link"),Dt(t,"link",e),Ct(t),l.head.appendChild(t)))}}function Oy(e,t){ea.m(e,t);var a=Xs;if(a&&e){var l=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+nn(l)+'"][href="'+nn(e)+'"]',u=c;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Ks(e)}if(!fn.has(u)&&(e=b({rel:"modulepreload",href:e},t),fn.set(u,e),a.querySelector(c)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Jl(u)))return}l=a.createElement("link"),Dt(l,"link",e),Ct(l),a.head.appendChild(l)}}}function By(e,t,a){ea.S(e,t,a);var l=Xs;if(l&&e){var c=ps(l).hoistableStyles,u=Qs(e);t=t||"default";var v=c.get(u);if(!v){var A={loading:0,preload:null};if(v=l.querySelector(Il(u)))A.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},a),(a=fn.get(u))&&Mu(e,a);var D=v=l.createElement("link");Ct(D),Dt(D,"link",e),D._p=new Promise(function(G,I){D.onload=G,D.onerror=I}),D.addEventListener("load",function(){A.loading|=1}),D.addEventListener("error",function(){A.loading|=2}),A.loading|=4,Mr(v,t,l)}v={type:"stylesheet",instance:v,count:1,state:A},c.set(u,v)}}}function Ly(e,t){ea.X(e,t);var a=Xs;if(a&&e){var l=ps(a).hoistableScripts,c=Ks(e),u=l.get(c);u||(u=a.querySelector(Jl(c)),u||(e=b({src:e,async:!0},t),(t=fn.get(c))&&qu(e,t),u=a.createElement("script"),Ct(u),Dt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},l.set(c,u))}}function zy(e,t){ea.M(e,t);var a=Xs;if(a&&e){var l=ps(a).hoistableScripts,c=Ks(e),u=l.get(c);u||(u=a.querySelector(Jl(c)),u||(e=b({src:e,async:!0,type:"module"},t),(t=fn.get(c))&&qu(e,t),u=a.createElement("script"),Ct(u),Dt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},l.set(c,u))}}function Up(e,t,a,l){var c=(c=ie.current)?kr(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Qs(a.href),a=ps(c).hoistableStyles,l=a.get(t),l||(l={type:"style",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Qs(a.href);var u=ps(c).hoistableStyles,v=u.get(e);if(v||(c=c.ownerDocument||c,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,v),(u=c.querySelector(Il(e)))&&!u._p&&(v.instance=u,v.state.loading=5),fn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},fn.set(e,a),u||Uy(c,e,a,v.state))),t&&l===null)throw Error(o(528,""));return v}if(t&&l!==null)throw Error(o(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ks(a),a=ps(c).hoistableScripts,l=a.get(t),l||(l={type:"script",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Qs(e){return'href="'+nn(e)+'"'}function Il(e){return'link[rel="stylesheet"]['+e+"]"}function Hp(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Uy(e,t,a,l){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=e.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),Dt(t,"link",a),Ct(t),e.head.appendChild(t))}function Ks(e){return'[src="'+nn(e)+'"]'}function Jl(e){return"script[async]"+e}function Vp(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var l=e.querySelector('style[data-href~="'+nn(a.href)+'"]');if(l)return t.instance=l,Ct(l),l;var c=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),Ct(l),Dt(l,"style",c),Mr(l,a.precedence,e),t.instance=l;case"stylesheet":c=Qs(a.href);var u=e.querySelector(Il(c));if(u)return t.state.loading|=4,t.instance=u,Ct(u),u;l=Hp(a),(c=fn.get(c))&&Mu(l,c),u=(e.ownerDocument||e).createElement("link"),Ct(u);var v=u;return v._p=new Promise(function(A,D){v.onload=A,v.onerror=D}),Dt(u,"link",l),t.state.loading|=4,Mr(u,a.precedence,e),t.instance=u;case"script":return u=Ks(a.src),(c=e.querySelector(Jl(u)))?(t.instance=c,Ct(c),c):(l=a,(c=fn.get(u))&&(l=b({},a),qu(l,c)),e=e.ownerDocument||e,c=e.createElement("script"),Ct(c),Dt(c,"link",l),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(l=t.instance,t.state.loading|=4,Mr(l,a.precedence,e));return t.instance}function Mr(e,t,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=l.length?l[l.length-1]:null,u=c,v=0;v<l.length;v++){var A=l[v];if(A.dataset.precedence===t)u=A;else if(u!==c)break}u?u.parentNode.insertBefore(e,u.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function Mu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function qu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var qr=null;function $p(e,t,a){if(qr===null){var l=new Map,c=qr=new Map;c.set(a,l)}else c=qr,l=c.get(a),l||(l=new Map,c.set(a,l));if(l.has(e))return l;for(l.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var u=a[c];if(!(u[ml]||u[rt]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var v=u.getAttribute(t)||"";v=e+v;var A=l.get(v);A?A.push(u):l.set(v,[u])}}return l}function Gp(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function Hy(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Yp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Vy(e,t,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Qs(l.href),u=t.querySelector(Il(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Rr.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=u,Ct(u);return}u=t.ownerDocument||t,l=Hp(l),(c=fn.get(c))&&Mu(l,c),u=u.createElement("link"),Ct(u);var v=u;v._p=new Promise(function(A,D){v.onload=A,v.onerror=D}),Dt(u,"link",l),a.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Rr.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Ru=0;function $y(e,t){return e.stylesheets&&e.count===0&&Dr(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var l=setTimeout(function(){if(e.stylesheets&&Dr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&Ru===0&&(Ru=62500*Ay());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Dr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>Ru?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(c)}}:null}function Rr(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Dr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Tr=null;function Dr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Tr=new Map,t.forEach(Gy,e),Tr=null,Rr.call(e))}function Gy(e,t){if(!(t.state.loading&4)){var a=Tr.get(e);if(a)var l=a.get(null);else{a=new Map,Tr.set(e,a);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<c.length;u++){var v=c[u];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(a.set(v.dataset.precedence,v),l=v)}l&&a.set(null,l)}c=t.instance,v=c.getAttribute("data-precedence"),u=a.get(v)||l,u===l&&a.set(null,c),a.set(v,c),this.count++,l=Rr.bind(this),c.addEventListener("load",l),c.addEventListener("error",l),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Pl={$$typeof:C,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function Yy(e,t,a,l,c,u,v,A,D){this.tag=1,this.containerInfo=e,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=fl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fl(0),this.hiddenUpdates=fl(null),this.identifierPrefix=l,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function Fp(e,t,a,l,c,u,v,A,D,G,I,ee){return e=new Yy(e,t,a,v,D,G,I,ee,A),t=1,u===!0&&(t|=24),u=Xt(3,null,null,t),e.current=u,u.stateNode=e,t=uc(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:l,isDehydrated:a,cache:t},hc(u),e}function Xp(e){return e?(e=ws,e):ws}function Qp(e,t,a,l,c,u){c=Xp(c),l.context===null?l.context=c:l.pendingContext=c,l=xa(t),l.payload={element:a},u=u===void 0?null:u,u!==null&&(l.callback=u),a=ga(e,l,t),a!==null&&($t(a,e,t),ql(a,e,t))}function Kp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Tu(e,t){Kp(e,t),(e=e.alternate)&&Kp(e,t)}function Zp(e){if(e.tag===13||e.tag===31){var t=$a(e,67108864);t!==null&&$t(t,e,67108864),Tu(e,67108864)}}function Ip(e){if(e.tag===13||e.tag===31){var t=Jt();t=Ke(t);var a=$a(e,t);a!==null&&$t(a,e,t),Tu(e,t)}}var _r=!0;function Fy(e,t,a,l){var c=T.T;T.T=null;var u=X.p;try{X.p=2,Du(e,t,a,l)}finally{X.p=u,T.T=c}}function Xy(e,t,a,l){var c=T.T;T.T=null;var u=X.p;try{X.p=8,Du(e,t,a,l)}finally{X.p=u,T.T=c}}function Du(e,t,a,l){if(_r){var c=_u(l);if(c===null)yu(e,t,l,Or,a),Pp(e,l);else if(Ky(c,e,t,a,l))l.stopPropagation();else if(Pp(e,l),t&4&&-1<Qy.indexOf(e)){for(;c!==null;){var u=hs(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var v=_n(u.pendingLanes);if(v!==0){var A=u;for(A.pendingLanes|=2,A.entangledLanes|=2;v;){var D=1<<31-Mt(v);A.entanglements[1]|=D,v&=~D}En(u),(Ge&6)===0&&(gr=ze()+500,Xl(0))}}break;case 31:case 13:A=$a(u,2),A!==null&&$t(A,u,2),yr(),Tu(u,2)}if(u=_u(l),u===null&&yu(e,t,l,Or,a),u===c)break;c=u}c!==null&&l.stopPropagation()}else yu(e,t,l,null,a)}}function _u(e){return e=Bo(e),Ou(e)}var Or=null;function Ou(e){if(Or=null,e=ms(e),e!==null){var t=d(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=h(t),e!==null)return e;e=null}else if(a===31){if(e=p(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Or=e,null}function Jp(e){switch(e){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(xt()){case mt:return 2;case Tn:return 8;case kt:case cs:return 32;case Gt:return 268435456;default:return 32}default:return 32}}var Bu=!1,ka=null,Ma=null,qa=null,Wl=new Map,ei=new Map,Ra=[],Qy="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 Pp(e,t){switch(e){case"focusin":case"focusout":ka=null;break;case"dragenter":case"dragleave":Ma=null;break;case"mouseover":case"mouseout":qa=null;break;case"pointerover":case"pointerout":Wl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ei.delete(t.pointerId)}}function ti(e,t,a,l,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:a,eventSystemFlags:l,nativeEvent:u,targetContainers:[c]},t!==null&&(t=hs(t),t!==null&&Zp(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function Ky(e,t,a,l,c){switch(t){case"focusin":return ka=ti(ka,e,t,a,l,c),!0;case"dragenter":return Ma=ti(Ma,e,t,a,l,c),!0;case"mouseover":return qa=ti(qa,e,t,a,l,c),!0;case"pointerover":var u=c.pointerId;return Wl.set(u,ti(Wl.get(u)||null,e,t,a,l,c)),!0;case"gotpointercapture":return u=c.pointerId,ei.set(u,ti(ei.get(u)||null,e,t,a,l,c)),!0}return!1}function Wp(e){var t=ms(e.target);if(t!==null){var a=d(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){Ip(a)});return}}else if(t===31){if(t=p(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){Ip(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Br(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=_u(e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Oo=l,a.target.dispatchEvent(l),Oo=null}else return t=hs(a),t!==null&&Zp(t),e.blockedOn=a,!1;t.shift()}return!0}function e0(e,t,a){Br(e)&&a.delete(t)}function Zy(){Bu=!1,ka!==null&&Br(ka)&&(ka=null),Ma!==null&&Br(Ma)&&(Ma=null),qa!==null&&Br(qa)&&(qa=null),Wl.forEach(e0),ei.forEach(e0)}function Lr(e,t){e.blockedOn===t&&(e.blockedOn=null,Bu||(Bu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Zy)))}var zr=null;function t0(e){zr!==e&&(zr=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){zr===e&&(zr=null);for(var t=0;t<e.length;t+=3){var a=e[t],l=e[t+1],c=e[t+2];if(typeof l!="function"){if(Ou(l||a)===null)continue;break}var u=hs(a);u!==null&&(e.splice(t,3),t-=3,_c(u,{pending:!0,data:c,method:a.method,action:l},l,c))}}))}function Zs(e){function t(D){return Lr(D,e)}ka!==null&&Lr(ka,e),Ma!==null&&Lr(Ma,e),qa!==null&&Lr(qa,e),Wl.forEach(t),ei.forEach(t);for(var a=0;a<Ra.length;a++){var l=Ra[a];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Ra.length&&(a=Ra[0],a.blockedOn===null);)Wp(a),a.blockedOn===null&&Ra.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var c=a[l],u=a[l+1],v=c[Nt]||null;if(typeof u=="function")v||t0(a);else if(v){var A=null;if(u&&u.hasAttribute("formAction")){if(c=u,v=u[Nt]||null)A=v.formAction;else if(Ou(c)!==null)continue}else A=v.action;typeof A=="function"?a[l+1]=A:(a.splice(l,3),l-=3),t0(a)}}}function n0(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(v){return c=v})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Lu(e){this._internalRoot=e}Ur.prototype.render=Lu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,l=Jt();Qp(a,l,e,t,null,null)},Ur.prototype.unmount=Lu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Qp(e.current,2,null,e,null,null),yr(),t[st]=null}};function Ur(e){this._internalRoot=e}Ur.prototype.unstable_scheduleHydration=function(e){if(e){var t=qe();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Ra.length&&t!==0&&t<Ra[a].priority;a++);Ra.splice(a,0,e),a===0&&Wp(e)}};var a0=s.version;if(a0!=="19.2.0")throw Error(o(527,a0,"19.2.0"));X.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=g(t),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var Iy={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hr.isDisabled&&Hr.supportsFiber)try{Dn=Hr.inject(Iy),jt=Hr}catch{}}return ai.createRoot=function(e,t){if(!f(e))throw Error(o(299));var a=!1,l="",c=uh,u=fh,v=dh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(v=t.onRecoverableError)),t=Fp(e,1,!1,null,null,a,l,null,c,u,v,n0),e[st]=t.current,vu(e),new Lu(t)},ai.hydrateRoot=function(e,t,a){if(!f(e))throw Error(o(299));var l=!1,c="",u=uh,v=fh,A=dh,D=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(u=a.onUncaughtError),a.onCaughtError!==void 0&&(v=a.onCaughtError),a.onRecoverableError!==void 0&&(A=a.onRecoverableError),a.formState!==void 0&&(D=a.formState)),t=Fp(e,1,!0,t,a??null,l,c,D,u,v,A,n0),t.context=Xp(null),a=t.current,l=Jt(),l=Ke(l),c=xa(l),c.callback=null,ga(a,c,l),a=l,t.current.lanes=a,La(t,a),En(t),e[st]=t.current,vu(e),new Ur(t)},ai.version="19.2.0",ai}var m0;function rb(){if(m0)return Hu.exports;m0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),Hu.exports=ib(),Hu.exports}var ob=rb();var h0="popstate";function cb(n={}){function s(o,f){let{pathname:d,search:h,hash:p}=o.location;return xf("",{pathname:d,search:h,hash:p},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function i(o,f){return typeof f=="string"?f:pi(f)}return fb(s,i,null,n)}function ot(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function An(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function ub(){return Math.random().toString(36).substring(2,10)}function p0(n,s){return{usr:n.state,key:n.key,idx:s}}function xf(n,s,i=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?il(s):s,state:i,key:s&&s.key||o||ub()}}function pi({pathname:n="/",search:s="",hash:i=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function il(n){let s={};if(n){let i=n.indexOf("#");i>=0&&(s.hash=n.substring(i),n=n.substring(0,i));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function fb(n,s,i,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,h=f.history,p="POP",x=null,g=y();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function y(){return(h.state||{idx:null}).idx}function b(){p="POP";let j=y(),w=j==null?null:j-g;g=j,x&&x({action:p,location:k.location,delta:w})}function S(j,w){p="PUSH";let E=xf(k.location,j,w);g=y()+1;let C=p0(E,g),M=k.createHref(E);try{h.pushState(C,"",M)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;f.location.assign(M)}d&&x&&x({action:p,location:k.location,delta:1})}function R(j,w){p="REPLACE";let E=xf(k.location,j,w);g=y();let C=p0(E,g),M=k.createHref(E);h.replaceState(C,"",M),d&&x&&x({action:p,location:k.location,delta:0})}function N(j){return db(j)}let k={get action(){return p},get location(){return n(f,h)},listen(j){if(x)throw new Error("A history only accepts one active listener");return f.addEventListener(h0,b),x=j,()=>{f.removeEventListener(h0,b),x=null}},createHref(j){return s(f,j)},createURL:N,encodeLocation(j){let w=N(j);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:S,replace:R,go(j){return h.go(j)}};return k}function db(n,s=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),ot(i,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:pi(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function hx(n,s,i="/"){return mb(n,s,i,!1)}function mb(n,s,i,o){let f=typeof s=="string"?il(s):s,d=ia(f.pathname||"/",i);if(d==null)return null;let h=px(n);hb(h);let p=null;for(let x=0;p==null&&x<h.length;++x){let g=wb(d);p=jb(h[x],g,o)}return p}function px(n,s=[],i=[],o="",f=!1){let d=(h,p,x=f,g)=>{let y={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:p,route:h};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&x)return;ot(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let b=la([o,y.relativePath]),S=i.concat(y);h.children&&h.children.length>0&&(ot(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),px(h.children,s,S,b,x)),!(h.path==null&&!h.index)&&s.push({path:b,score:Sb(b,h.index),routesMeta:S})};return n.forEach((h,p)=>{if(h.path===""||!h.path?.includes("?"))d(h,p);else for(let x of xx(h.path))d(h,p,!0,x)}),s}function xx(n){let s=n.split("/");if(s.length===0)return[];let[i,...o]=s,f=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return f?[d,""]:[d];let h=xx(o.join("/")),p=[];return p.push(...h.map(x=>x===""?d:[d,x].join("/"))),f&&p.push(...h),p.map(x=>n.startsWith("/")&&x===""?"/":x)}function hb(n){n.sort((s,i)=>s.score!==i.score?i.score-s.score:Ab(s.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var pb=/^:[\w-]+$/,xb=3,gb=2,vb=1,yb=10,bb=-2,x0=n=>n==="*";function Sb(n,s){let i=n.split("/"),o=i.length;return i.some(x0)&&(o+=bb),s&&(o+=gb),i.filter(f=>!x0(f)).reduce((f,d)=>f+(pb.test(d)?xb:d===""?vb:yb),o)}function Ab(n,s){return n.length===s.length&&n.slice(0,-1).every((o,f)=>o===s[f])?n[n.length-1]-s[s.length-1]:0}function jb(n,s,i=!1){let{routesMeta:o}=n,f={},d="/",h=[];for(let p=0;p<o.length;++p){let x=o[p],g=p===o.length-1,y=d==="/"?s:s.slice(d.length)||"/",b=so({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},y),S=x.route;if(!b&&g&&i&&!o[o.length-1].route.index&&(b=so({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},y)),!b)return null;Object.assign(f,b.params),h.push({params:f,pathname:la([d,b.pathname]),pathnameBase:qb(la([d,b.pathnameBase])),route:S}),b.pathnameBase!=="/"&&(d=la([d,b.pathnameBase]))}return h}function so(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,o]=Nb(n.path,n.caseSensitive,n.end),f=s.match(i);if(!f)return null;let d=f[0],h=d.replace(/(.)\/+$/,"$1"),p=f.slice(1);return{params:o.reduce((g,{paramName:y,isOptional:b},S)=>{if(y==="*"){let N=p[S]||"";h=d.slice(0,d.length-N.length).replace(/(.)\/+$/,"$1")}const R=p[S];return b&&!R?g[y]=void 0:g[y]=(R||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:n}}function Nb(n,s=!1,i=!0){An(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],f="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,p,x)=>(o.push({paramName:p,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),f+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?f+="\\/*$":n!==""&&n!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,s?void 0:"i"),o]}function wb(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return An(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function ia(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let i=s.endsWith("/")?s.length-1:s.length,o=n.charAt(i);return o&&o!=="/"?null:n.slice(i)||"/"}var Cb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Eb=n=>Cb.test(n);function kb(n,s="/"){let{pathname:i,search:o="",hash:f=""}=typeof n=="string"?il(n):n,d;if(i)if(Eb(i))d=i;else{if(i.includes("//")){let h=i;i=i.replace(/\/\/+/g,"/"),An(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${i}`)}i.startsWith("/")?d=g0(i.substring(1),"/"):d=g0(i,s)}else d=s;return{pathname:d,search:Rb(o),hash:Tb(f)}}function g0(n,s){let i=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(f=>{f===".."?i.length>1&&i.pop():f!=="."&&i.push(f)}),i.length>1?i.join("/"):"/"}function Yu(n,s,i,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Mb(n){return n.filter((s,i)=>i===0||s.route.path&&s.route.path.length>0)}function gx(n){let s=Mb(n);return s.map((i,o)=>o===s.length-1?i.pathname:i.pathnameBase)}function vx(n,s,i,o=!1){let f;typeof n=="string"?f=il(n):(f={...n},ot(!f.pathname||!f.pathname.includes("?"),Yu("?","pathname","search",f)),ot(!f.pathname||!f.pathname.includes("#"),Yu("#","pathname","hash",f)),ot(!f.search||!f.search.includes("#"),Yu("#","search","hash",f)));let d=n===""||f.pathname==="",h=d?"/":f.pathname,p;if(h==null)p=i;else{let b=s.length-1;if(!o&&h.startsWith("..")){let S=h.split("/");for(;S[0]==="..";)S.shift(),b-=1;f.pathname=S.join("/")}p=b>=0?s[b]:"/"}let x=kb(f,p),g=h&&h!=="/"&&h.endsWith("/"),y=(d||h===".")&&i.endsWith("/");return!x.pathname.endsWith("/")&&(g||y)&&(x.pathname+="/"),x}var la=n=>n.join("/").replace(/\/\/+/g,"/"),qb=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Rb=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Tb=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Db(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var yx=["POST","PUT","PATCH","DELETE"];new Set(yx);var _b=["GET",...yx];new Set(_b);var rl=m.createContext(null);rl.displayName="DataRouter";var xo=m.createContext(null);xo.displayName="DataRouterState";m.createContext(!1);var bx=m.createContext({isTransitioning:!1});bx.displayName="ViewTransition";var Ob=m.createContext(new Map);Ob.displayName="Fetchers";var Bb=m.createContext(null);Bb.displayName="Await";var Rn=m.createContext(null);Rn.displayName="Navigation";var Ni=m.createContext(null);Ni.displayName="Location";var oa=m.createContext({outlet:null,matches:[],isDataRoute:!1});oa.displayName="Route";var _f=m.createContext(null);_f.displayName="RouteError";function Lb(n,{relative:s}={}){ot(wi(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=m.useContext(Rn),{hash:f,pathname:d,search:h}=Ci(n,{relative:s}),p=d;return i!=="/"&&(p=d==="/"?i:la([i,d])),o.createHref({pathname:p,search:h,hash:f})}function wi(){return m.useContext(Ni)!=null}function os(){return ot(wi(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Ni).location}var Sx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ax(n){m.useContext(Rn).static||m.useLayoutEffect(n)}function zb(){let{isDataRoute:n}=m.useContext(oa);return n?Jb():Ub()}function Ub(){ot(wi(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(rl),{basename:s,navigator:i}=m.useContext(Rn),{matches:o}=m.useContext(oa),{pathname:f}=os(),d=JSON.stringify(gx(o)),h=m.useRef(!1);return Ax(()=>{h.current=!0}),m.useCallback((x,g={})=>{if(An(h.current,Sx),!h.current)return;if(typeof x=="number"){i.go(x);return}let y=vx(x,JSON.parse(d),f,g.relative==="path");n==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:la([s,y.pathname])),(g.replace?i.replace:i.push)(y,g.state,g)},[s,i,d,f,n])}m.createContext(null);function Ci(n,{relative:s}={}){let{matches:i}=m.useContext(oa),{pathname:o}=os(),f=JSON.stringify(gx(i));return m.useMemo(()=>vx(n,JSON.parse(f),o,s==="path"),[n,f,o,s])}function Hb(n,s){return jx(n,s)}function jx(n,s,i,o,f){ot(wi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(Rn),{matches:h}=m.useContext(oa),p=h[h.length-1],x=p?p.params:{},g=p?p.pathname:"/",y=p?p.pathnameBase:"/",b=p&&p.route;{let E=b&&b.path||"";Nx(g,!b||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let S=os(),R;if(s){let E=typeof s=="string"?il(s):s;ot(y==="/"||E.pathname?.startsWith(y),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${y}" but pathname "${E.pathname}" was given in the \`location\` prop.`),R=E}else R=S;let N=R.pathname||"/",k=N;if(y!=="/"){let E=y.replace(/^\//,"").split("/");k="/"+N.replace(/^\//,"").split("/").slice(E.length).join("/")}let j=hx(n,{pathname:k});An(b||j!=null,`No routes matched location "${R.pathname}${R.search}${R.hash}" `),An(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${R.pathname}${R.search}${R.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=Fb(j&&j.map(E=>Object.assign({},E,{params:Object.assign({},x,E.params),pathname:la([y,d.encodeLocation?d.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?y:la([y,d.encodeLocation?d.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),h,i,o,f);return s&&w?m.createElement(Ni.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...R},navigationType:"POP"}},w):w}function Vb(){let n=Ib(),s=Db(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",n),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:d},"ErrorBoundary")," or"," ",m.createElement("code",{style:d},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},s),i?m.createElement("pre",{style:f},i):null,h)}var $b=m.createElement(Vb,null),Gb=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(oa.Provider,{value:this.props.routeContext},m.createElement(_f.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Yb({routeContext:n,match:s,children:i}){let o=m.useContext(rl);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(oa.Provider,{value:n},i)}function Fb(n,s=[],i=null,o=null,f=null){if(n==null){if(!i)return null;if(i.errors)n=i.matches;else if(s.length===0&&!i.initialized&&i.matches.length>0)n=i.matches;else return null}let d=n,h=i?.errors;if(h!=null){let y=d.findIndex(b=>b.route.id&&h?.[b.route.id]!==void 0);ot(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),d=d.slice(0,Math.min(d.length,y+1))}let p=!1,x=-1;if(i)for(let y=0;y<d.length;y++){let b=d[y];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(x=y),b.route.id){let{loaderData:S,errors:R}=i,N=b.route.loader&&!S.hasOwnProperty(b.route.id)&&(!R||R[b.route.id]===void 0);if(b.route.lazy||N){p=!0,x>=0?d=d.slice(0,x+1):d=[d[0]];break}}}let g=i&&o?(y,b)=>{o(y,{location:i.location,params:i.matches?.[0]?.params??{},errorInfo:b})}:void 0;return d.reduceRight((y,b,S)=>{let R,N=!1,k=null,j=null;i&&(R=h&&b.route.id?h[b.route.id]:void 0,k=b.route.errorElement||$b,p&&(x<0&&S===0?(Nx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,j=null):x===S&&(N=!0,j=b.route.hydrateFallbackElement||null)));let w=s.concat(d.slice(0,S+1)),E=()=>{let C;return R?C=k:N?C=j:b.route.Component?C=m.createElement(b.route.Component,null):b.route.element?C=b.route.element:C=y,m.createElement(Yb,{match:b,routeContext:{outlet:y,matches:w,isDataRoute:i!=null},children:C})};return i&&(b.route.ErrorBoundary||b.route.errorElement||S===0)?m.createElement(Gb,{location:i.location,revalidation:i.revalidation,component:k,error:R,children:E(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:g}):E()},null)}function Of(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xb(n){let s=m.useContext(rl);return ot(s,Of(n)),s}function Qb(n){let s=m.useContext(xo);return ot(s,Of(n)),s}function Kb(n){let s=m.useContext(oa);return ot(s,Of(n)),s}function Bf(n){let s=Kb(n),i=s.matches[s.matches.length-1];return ot(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function Zb(){return Bf("useRouteId")}function Ib(){let n=m.useContext(_f),s=Qb("useRouteError"),i=Bf("useRouteError");return n!==void 0?n:s.errors?.[i]}function Jb(){let{router:n}=Xb("useNavigate"),s=Bf("useNavigate"),i=m.useRef(!1);return Ax(()=>{i.current=!0}),m.useCallback(async(f,d={})=>{An(i.current,Sx),i.current&&(typeof f=="number"?n.navigate(f):await n.navigate(f,{fromRouteId:s,...d}))},[n,s])}var v0={};function Nx(n,s,i){!s&&!v0[n]&&(v0[n]=!0,An(!1,i))}m.memo(Pb);function Pb({routes:n,future:s,state:i,unstable_onError:o}){return jx(n,void 0,i,o,s)}function Qr(n){ot(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Wb({basename:n="/",children:s=null,location:i,navigationType:o="POP",navigator:f,static:d=!1}){ot(!wi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=n.replace(/^\/*/,"/"),p=m.useMemo(()=>({basename:h,navigator:f,static:d,future:{}}),[h,f,d]);typeof i=="string"&&(i=il(i));let{pathname:x="/",search:g="",hash:y="",state:b=null,key:S="default"}=i,R=m.useMemo(()=>{let N=ia(x,h);return N==null?null:{location:{pathname:N,search:g,hash:y,state:b,key:S},navigationType:o}},[h,x,g,y,b,S,o]);return An(R!=null,`<Router basename="${h}"> is not able to match the URL "${x}${g}${y}" because it does not start with the basename, so the <Router> won't render anything.`),R==null?null:m.createElement(Rn.Provider,{value:p},m.createElement(Ni.Provider,{children:s,value:R}))}function e1({children:n,location:s}){return Hb(gf(n),s)}function gf(n,s=[]){let i=[];return m.Children.forEach(n,(o,f)=>{if(!m.isValidElement(o))return;let d=[...s,f];if(o.type===m.Fragment){i.push.apply(i,gf(o.props.children,d));return}ot(o.type===Qr,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ot(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=gf(o.props.children,d)),i.push(h)}),i}var Kr="get",Zr="application/x-www-form-urlencoded";function go(n){return n!=null&&typeof n.tagName=="string"}function t1(n){return go(n)&&n.tagName.toLowerCase()==="button"}function n1(n){return go(n)&&n.tagName.toLowerCase()==="form"}function a1(n){return go(n)&&n.tagName.toLowerCase()==="input"}function s1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function l1(n,s){return n.button===0&&(!s||s==="_self")&&!s1(n)}var Vr=null;function i1(){if(Vr===null)try{new FormData(document.createElement("form"),0),Vr=!1}catch{Vr=!0}return Vr}var r1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fu(n){return n!=null&&!r1.has(n)?(An(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zr}"`),null):n}function o1(n,s){let i,o,f,d,h;if(n1(n)){let p=n.getAttribute("action");o=p?ia(p,s):null,i=n.getAttribute("method")||Kr,f=Fu(n.getAttribute("enctype"))||Zr,d=new FormData(n)}else if(t1(n)||a1(n)&&(n.type==="submit"||n.type==="image")){let p=n.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=n.getAttribute("formaction")||p.getAttribute("action");if(o=x?ia(x,s):null,i=n.getAttribute("formmethod")||p.getAttribute("method")||Kr,f=Fu(n.getAttribute("formenctype"))||Fu(p.getAttribute("enctype"))||Zr,d=new FormData(p,n),!i1()){let{name:g,type:y,value:b}=n;if(y==="image"){let S=g?`${g}.`:"";d.append(`${S}x`,"0"),d.append(`${S}y`,"0")}else g&&d.append(g,b)}}else{if(go(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Kr,o=null,f=Zr,h=n}return d&&f==="text/plain"&&(h=d,d=void 0),{action:o,method:i.toLowerCase(),encType:f,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Lf(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function c1(n,s,i){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${i}`:s&&ia(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${i}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${i}`,o}async function u1(n,s){if(n.id in s)return s[n.id];try{let i=await import(n.module);return s[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function f1(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function d1(n,s,i){let o=await Promise.all(n.map(async f=>{let d=s.routes[f.route.id];if(d){let h=await u1(d,i);return h.links?h.links():[]}return[]}));return x1(o.flat(1).filter(f1).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function y0(n,s,i,o,f,d){let h=(x,g)=>i[g]?x.route.id!==i[g].route.id:!0,p=(x,g)=>i[g].pathname!==x.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==x.params["*"];return d==="assets"?s.filter((x,g)=>h(x,g)||p(x,g)):d==="data"?s.filter((x,g)=>{let y=o.routes[x.route.id];if(!y||!y.hasLoader)return!1;if(h(x,g)||p(x,g))return!0;if(x.route.shouldRevalidate){let b=x.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function m1(n,s,{includeHydrateFallback:i}={}){return h1(n.map(o=>{let f=s.routes[o.route.id];if(!f)return[];let d=[f.module];return f.clientActionModule&&(d=d.concat(f.clientActionModule)),f.clientLoaderModule&&(d=d.concat(f.clientLoaderModule)),i&&f.hydrateFallbackModule&&(d=d.concat(f.hydrateFallbackModule)),f.imports&&(d=d.concat(f.imports)),d}).flat(1))}function h1(n){return[...new Set(n)]}function p1(n){let s={},i=Object.keys(n).sort();for(let o of i)s[o]=n[o];return s}function x1(n,s){let i=new Set;return new Set(s),n.reduce((o,f)=>{let d=JSON.stringify(p1(f));return i.has(d)||(i.add(d),o.push({key:d,link:f})),o},[])}function wx(){let n=m.useContext(rl);return Lf(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function g1(){let n=m.useContext(xo);return Lf(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var zf=m.createContext(void 0);zf.displayName="FrameworkContext";function Cx(){let n=m.useContext(zf);return Lf(n,"You must render this element inside a <HydratedRouter> element"),n}function v1(n,s){let i=m.useContext(zf),[o,f]=m.useState(!1),[d,h]=m.useState(!1),{onFocus:p,onBlur:x,onMouseEnter:g,onMouseLeave:y,onTouchStart:b}=s,S=m.useRef(null);m.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let k=w=>{w.forEach(E=>{h(E.isIntersecting)})},j=new IntersectionObserver(k,{threshold:.5});return S.current&&j.observe(S.current),()=>{j.disconnect()}}},[n]),m.useEffect(()=>{if(o){let k=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(k)}}},[o]);let R=()=>{f(!0)},N=()=>{f(!1),h(!1)};return i?n!=="intent"?[d,S,{}]:[d,S,{onFocus:si(p,R),onBlur:si(x,N),onMouseEnter:si(g,R),onMouseLeave:si(y,N),onTouchStart:si(b,R)}]:[!1,S,{}]}function si(n,s){return i=>{n&&n(i),i.defaultPrevented||s(i)}}function y1({page:n,...s}){let{router:i}=wx(),o=m.useMemo(()=>hx(i.routes,n,i.basename),[i.routes,n,i.basename]);return o?m.createElement(S1,{page:n,matches:o,...s}):null}function b1(n){let{manifest:s,routeModules:i}=Cx(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return d1(n,s,i).then(h=>{d||f(h)}),()=>{d=!0}},[n,s,i]),o}function S1({page:n,matches:s,...i}){let o=os(),{manifest:f,routeModules:d}=Cx(),{basename:h}=wx(),{loaderData:p,matches:x}=g1(),g=m.useMemo(()=>y0(n,s,x,f,o,"data"),[n,s,x,f,o]),y=m.useMemo(()=>y0(n,s,x,f,o,"assets"),[n,s,x,f,o]),b=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let N=new Set,k=!1;if(s.forEach(w=>{let E=f.routes[w.route.id];!E||!E.hasLoader||(!g.some(C=>C.route.id===w.route.id)&&w.route.id in p&&d[w.route.id]?.shouldRevalidate||E.hasClientLoader?k=!0:N.add(w.route.id))}),N.size===0)return[];let j=c1(n,h,"data");return k&&N.size>0&&j.searchParams.set("_routes",s.filter(w=>N.has(w.route.id)).map(w=>w.route.id).join(",")),[j.pathname+j.search]},[h,p,o,f,g,s,n,d]),S=m.useMemo(()=>m1(y,f),[y,f]),R=b1(y);return m.createElement(m.Fragment,null,b.map(N=>m.createElement("link",{key:N,rel:"prefetch",as:"fetch",href:N,...i})),S.map(N=>m.createElement("link",{key:N,rel:"modulepreload",href:N,...i})),R.map(({key:N,link:k})=>m.createElement("link",{key:N,nonce:i.nonce,...k})))}function A1(...n){return s=>{n.forEach(i=>{typeof i=="function"?i(s):i!=null&&(i.current=s)})}}var Ex=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ex&&(window.__reactRouterVersion="7.9.6")}catch{}function j1({basename:n,children:s,window:i}){let o=m.useRef();o.current==null&&(o.current=cb({window:i,v5Compat:!0}));let f=o.current,[d,h]=m.useState({action:f.action,location:f.location}),p=m.useCallback(x=>{m.startTransition(()=>h(x))},[h]);return m.useLayoutEffect(()=>f.listen(p),[f,p]),m.createElement(Wb,{basename:n,children:s,location:d.location,navigationType:d.action,navigator:f})}var kx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Mx=m.forwardRef(function({onClick:s,discover:i="render",prefetch:o="none",relative:f,reloadDocument:d,replace:h,state:p,target:x,to:g,preventScrollReset:y,viewTransition:b,...S},R){let{basename:N}=m.useContext(Rn),k=typeof g=="string"&&kx.test(g),j,w=!1;if(typeof g=="string"&&k&&(j=g,Ex))try{let L=new URL(window.location.href),U=g.startsWith("//")?new URL(L.protocol+g):new URL(g),F=ia(U.pathname,N);U.origin===L.origin&&F!=null?g=F+U.search+U.hash:w=!0}catch{An(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=Lb(g,{relative:f}),[C,M,B]=v1(o,S),H=E1(g,{replace:h,state:p,target:x,preventScrollReset:y,relative:f,viewTransition:b});function _(L){s&&s(L),L.defaultPrevented||H(L)}let K=m.createElement("a",{...S,...B,href:j||E,onClick:w||d?s:_,ref:A1(R,M),target:x,"data-discover":!k&&i==="render"?"true":void 0});return C&&!k?m.createElement(m.Fragment,null,K,m.createElement(y1,{page:E})):K});Mx.displayName="Link";var N1=m.forwardRef(function({"aria-current":s="page",caseSensitive:i=!1,className:o="",end:f=!1,style:d,to:h,viewTransition:p,children:x,...g},y){let b=Ci(h,{relative:g.relative}),S=os(),R=m.useContext(xo),{navigator:N,basename:k}=m.useContext(Rn),j=R!=null&&T1(b)&&p===!0,w=N.encodeLocation?N.encodeLocation(b).pathname:b.pathname,E=S.pathname,C=R&&R.navigation&&R.navigation.location?R.navigation.location.pathname:null;i||(E=E.toLowerCase(),C=C?C.toLowerCase():null,w=w.toLowerCase()),C&&k&&(C=ia(C,k)||C);const M=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let B=E===w||!f&&E.startsWith(w)&&E.charAt(M)==="/",H=C!=null&&(C===w||!f&&C.startsWith(w)&&C.charAt(w.length)==="/"),_={isActive:B,isPending:H,isTransitioning:j},K=B?s:void 0,L;typeof o=="function"?L=o(_):L=[o,B?"active":null,H?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let U=typeof d=="function"?d(_):d;return m.createElement(Mx,{...g,"aria-current":K,className:L,ref:y,style:U,to:h,viewTransition:p},typeof x=="function"?x(_):x)});N1.displayName="NavLink";var w1=m.forwardRef(({discover:n="render",fetcherKey:s,navigate:i,reloadDocument:o,replace:f,state:d,method:h=Kr,action:p,onSubmit:x,relative:g,preventScrollReset:y,viewTransition:b,...S},R)=>{let N=q1(),k=R1(p,{relative:g}),j=h.toLowerCase()==="get"?"get":"post",w=typeof p=="string"&&kx.test(p),E=C=>{if(x&&x(C),C.defaultPrevented)return;C.preventDefault();let M=C.nativeEvent.submitter,B=M?.getAttribute("formmethod")||h;N(M||C.currentTarget,{fetcherKey:s,method:B,navigate:i,replace:f,state:d,relative:g,preventScrollReset:y,viewTransition:b})};return m.createElement("form",{ref:R,method:j,action:k,onSubmit:o?x:E,...S,"data-discover":!w&&n==="render"?"true":void 0})});w1.displayName="Form";function C1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function qx(n){let s=m.useContext(rl);return ot(s,C1(n)),s}function E1(n,{target:s,replace:i,state:o,preventScrollReset:f,relative:d,viewTransition:h}={}){let p=zb(),x=os(),g=Ci(n,{relative:d});return m.useCallback(y=>{if(l1(y,s)){y.preventDefault();let b=i!==void 0?i:pi(x)===pi(g);p(n,{replace:b,state:o,preventScrollReset:f,relative:d,viewTransition:h})}},[x,p,g,i,o,s,n,f,d,h])}var k1=0,M1=()=>`__${String(++k1)}__`;function q1(){let{router:n}=qx("useSubmit"),{basename:s}=m.useContext(Rn),i=Zb();return m.useCallback(async(o,f={})=>{let{action:d,method:h,encType:p,formData:x,body:g}=o1(o,s);if(f.navigate===!1){let y=f.fetcherKey||M1();await n.fetch(y,i,f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,flushSync:f.flushSync})}else await n.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[n,s,i])}function R1(n,{relative:s}={}){let{basename:i}=m.useContext(Rn),o=m.useContext(oa);ot(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...Ci(n||".",{relative:s})},h=os();if(n==null){d.search=h.search;let p=new URLSearchParams(d.search),x=p.getAll("index");if(x.some(y=>y==="")){p.delete("index"),x.filter(b=>b).forEach(b=>p.append("index",b));let y=p.toString();d.search=y?`?${y}`:""}}return(!n||n===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:la([i,d.pathname])),pi(d)}function T1(n,{relative:s}={}){let i=m.useContext(bx);ot(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=qx("useViewTransitionState"),f=Ci(n,{relative:s});if(!i.isTransitioning)return!1;let d=ia(i.currentLocation.pathname,o)||i.currentLocation.pathname,h=ia(i.nextLocation.pathname,o)||i.nextLocation.pathname;return so(f.pathname,h)!=null||so(f.pathname,d)!=null}const qn=Object.create(null);qn.open="0";qn.close="1";qn.ping="2";qn.pong="3";qn.message="4";qn.upgrade="5";qn.noop="6";const Ir=Object.create(null);Object.keys(qn).forEach(n=>{Ir[qn[n]]=n});const vf={type:"error",data:"parser error"},Rx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Tx=typeof ArrayBuffer=="function",Dx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Uf=({type:n,data:s},i,o)=>Rx&&s instanceof Blob?i?o(s):b0(s,o):Tx&&(s instanceof ArrayBuffer||Dx(s))?i?o(s):b0(new Blob([s]),o):o(qn[n]+(s||"")),b0=(n,s)=>{const i=new FileReader;return i.onload=function(){const o=i.result.split(",")[1];s("b"+(o||""))},i.readAsDataURL(n)};function S0(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Xu;function D1(n,s){if(Rx&&n.data instanceof Blob)return n.data.arrayBuffer().then(S0).then(s);if(Tx&&(n.data instanceof ArrayBuffer||Dx(n.data)))return s(S0(n.data));Uf(n,!1,i=>{Xu||(Xu=new TextEncoder),s(Xu.encode(i))})}const A0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ui=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<A0.length;n++)ui[A0.charCodeAt(n)]=n;const _1=n=>{let s=n.length*.75,i=n.length,o,f=0,d,h,p,x;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);const g=new ArrayBuffer(s),y=new Uint8Array(g);for(o=0;o<i;o+=4)d=ui[n.charCodeAt(o)],h=ui[n.charCodeAt(o+1)],p=ui[n.charCodeAt(o+2)],x=ui[n.charCodeAt(o+3)],y[f++]=d<<2|h>>4,y[f++]=(h&15)<<4|p>>2,y[f++]=(p&3)<<6|x&63;return g},O1=typeof ArrayBuffer=="function",Hf=(n,s)=>{if(typeof n!="string")return{type:"message",data:_x(n,s)};const i=n.charAt(0);return i==="b"?{type:"message",data:B1(n.substring(1),s)}:Ir[i]?n.length>1?{type:Ir[i],data:n.substring(1)}:{type:Ir[i]}:vf},B1=(n,s)=>{if(O1){const i=_1(n);return _x(i,s)}else return{base64:!0,data:n}},_x=(n,s)=>{switch(s){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Ox="",L1=(n,s)=>{const i=n.length,o=new Array(i);let f=0;n.forEach((d,h)=>{Uf(d,!1,p=>{o[h]=p,++f===i&&s(o.join(Ox))})})},z1=(n,s)=>{const i=n.split(Ox),o=[];for(let f=0;f<i.length;f++){const d=Hf(i[f],s);if(o.push(d),d.type==="error")break}return o};function U1(){return new TransformStream({transform(n,s){D1(n,i=>{const o=i.length;let f;if(o<126)f=new Uint8Array(1),new DataView(f.buffer).setUint8(0,o);else if(o<65536){f=new Uint8Array(3);const d=new DataView(f.buffer);d.setUint8(0,126),d.setUint16(1,o)}else{f=new Uint8Array(9);const d=new DataView(f.buffer);d.setUint8(0,127),d.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(f[0]|=128),s.enqueue(f),s.enqueue(i)})}})}let Qu;function $r(n){return n.reduce((s,i)=>s+i.length,0)}function Gr(n,s){if(n[0].length===s)return n.shift();const i=new Uint8Array(s);let o=0;for(let f=0;f<s;f++)i[f]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),i}function H1(n,s){Qu||(Qu=new TextDecoder);const i=[];let o=0,f=-1,d=!1;return new TransformStream({transform(h,p){for(i.push(h);;){if(o===0){if($r(i)<1)break;const x=Gr(i,1);d=(x[0]&128)===128,f=x[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if($r(i)<2)break;const x=Gr(i,2);f=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if($r(i)<8)break;const x=Gr(i,8),g=new DataView(x.buffer,x.byteOffset,x.length),y=g.getUint32(0);if(y>Math.pow(2,21)-1){p.enqueue(vf);break}f=y*Math.pow(2,32)+g.getUint32(4),o=3}else{if($r(i)<f)break;const x=Gr(i,f);p.enqueue(Hf(d?x:Qu.decode(x),s)),o=0}if(f===0||f>n){p.enqueue(vf);break}}}})}const Bx=4;function At(n){if(n)return V1(n)}function V1(n){for(var s in At.prototype)n[s]=At.prototype[s];return n}At.prototype.on=At.prototype.addEventListener=function(n,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(s),this};At.prototype.once=function(n,s){function i(){this.off(n,i),s.apply(this,arguments)}return i.fn=s,this.on(n,i),this};At.prototype.off=At.prototype.removeListener=At.prototype.removeAllListeners=At.prototype.removeEventListener=function(n,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,f=0;f<i.length;f++)if(o=i[f],o===s||o.fn===s){i.splice(f,1);break}return i.length===0&&delete this._callbacks["$"+n],this};At.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),i=this._callbacks["$"+n],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,f=i.length;o<f;++o)i[o].apply(this,s)}return this};At.prototype.emitReserved=At.prototype.emit;At.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};At.prototype.hasListeners=function(n){return!!this.listeners(n).length};const vo=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,i)=>i(s,0),hn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),$1="arraybuffer";function Lx(n,...s){return s.reduce((i,o)=>(n.hasOwnProperty(o)&&(i[o]=n[o]),i),{})}const G1=hn.setTimeout,Y1=hn.clearTimeout;function yo(n,s){s.useNativeTimers?(n.setTimeoutFn=G1.bind(hn),n.clearTimeoutFn=Y1.bind(hn)):(n.setTimeoutFn=hn.setTimeout.bind(hn),n.clearTimeoutFn=hn.clearTimeout.bind(hn))}const F1=1.33;function X1(n){return typeof n=="string"?Q1(n):Math.ceil((n.byteLength||n.size)*F1)}function Q1(n){let s=0,i=0;for(let o=0,f=n.length;o<f;o++)s=n.charCodeAt(o),s<128?i+=1:s<2048?i+=2:s<55296||s>=57344?i+=3:(o++,i+=4);return i}function zx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function K1(n){let s="";for(let i in n)n.hasOwnProperty(i)&&(s.length&&(s+="&"),s+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return s}function Z1(n){let s={},i=n.split("&");for(let o=0,f=i.length;o<f;o++){let d=i[o].split("=");s[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return s}class I1 extends Error{constructor(s,i,o){super(s),this.description=i,this.context=o,this.type="TransportError"}}class Vf extends At{constructor(s){super(),this.writable=!1,yo(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,i,o){return super.emitReserved("error",new I1(s,i,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const i=Hf(s,this.socket.binaryType);this.onPacket(i)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,i={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const s=this.opts.hostname;return s.indexOf(":")===-1?s:"["+s+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(s){const i=K1(s);return i.length?"?"+i:""}}class J1 extends Vf{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const i=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||i()})),this.writable||(o++,this.once("drain",function(){--o||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const i=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};z1(s,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const s=()=>{this.write([{type:"close"}])};this.readyState==="open"?s():this.once("open",s)}write(s){this.writable=!1,L1(s,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=zx()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(s,i)}}let Ux=!1;try{Ux=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const P1=Ux;function W1(){}class eS extends J1{constructor(s){if(super(s),typeof location<"u"){const i=location.protocol==="https:";let o=location.port;o||(o=i?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||o!==s.port}}doWrite(s,i){const o=this.request({method:"POST",data:s});o.on("success",i),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(i,o)=>{this.onError("xhr poll error",i,o)}),this.pollXhr=s}}class Mn extends At{constructor(s,i,o){super(),this.createRequest=s,yo(this,o),this._opts=o,this._method=o.method||"GET",this._uri=i,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var s;const i=Lx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(i);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let f in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(f)&&o.setRequestHeader(f,this._opts.extraHeaders[f])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var f;o.readyState===3&&((f=this._opts.cookieJar)===null||f===void 0||f.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(f){this.setTimeoutFn(()=>{this._onError(f)},0);return}typeof document<"u"&&(this._index=Mn.requestsCount++,Mn.requests[this._index]=this)}_onError(s){this.emitReserved("error",s,this._xhr),this._cleanup(!0)}_cleanup(s){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=W1,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Mn.requests[this._index],this._xhr=null}}_onLoad(){const s=this._xhr.responseText;s!==null&&(this.emitReserved("data",s),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Mn.requestsCount=0;Mn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",j0);else if(typeof addEventListener=="function"){const n="onpagehide"in hn?"pagehide":"unload";addEventListener(n,j0,!1)}}function j0(){for(let n in Mn.requests)Mn.requests.hasOwnProperty(n)&&Mn.requests[n].abort()}const tS=(function(){const n=Hx({xdomain:!1});return n&&n.responseType!==null})();class nS extends eS{constructor(s){super(s);const i=s&&s.forceBase64;this.supportsBinary=tS&&!i}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Mn(Hx,this.uri(),s)}}function Hx(n){const s=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||P1))return new XMLHttpRequest}catch{}if(!s)try{return new hn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Vx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class aS extends Vf{get name(){return"websocket"}doOpen(){const s=this.uri(),i=this.opts.protocols,o=Vx?{}:Lx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(s,i,o)}catch(f){return this.emitReserved("error",f)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=s=>this.onClose({description:"websocket connection closed",context:s}),this.ws.onmessage=s=>this.onData(s.data),this.ws.onerror=s=>this.onError("websocket error",s)}write(s){this.writable=!1;for(let i=0;i<s.length;i++){const o=s[i],f=i===s.length-1;Uf(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&vo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const s=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=zx()),this.supportsBinary||(i.b64=1),this.createUri(s,i)}}const Ku=hn.WebSocket||hn.MozWebSocket;class sS extends aS{createSocket(s,i,o){return Vx?new Ku(s,i,o):i?new Ku(s,i):new Ku(s)}doWrite(s,i){this.ws.send(i)}}class lS extends Vf{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const i=H1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=s.readable.pipeThrough(i).getReader(),f=U1();f.readable.pipeTo(s.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:p,value:x})=>{p||(this.onPacket(x),d())}).catch(p=>{})};d();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let i=0;i<s.length;i++){const o=s[i],f=i===s.length-1;this._writer.write(o).then(()=>{f&&vo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const iS={websocket:sS,webtransport:lS,polling:nS},rS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,oS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function yf(n){if(n.length>8e3)throw"URI too long";const s=n,i=n.indexOf("["),o=n.indexOf("]");i!=-1&&o!=-1&&(n=n.substring(0,i)+n.substring(i,o).replace(/:/g,";")+n.substring(o,n.length));let f=rS.exec(n||""),d={},h=14;for(;h--;)d[oS[h]]=f[h]||"";return i!=-1&&o!=-1&&(d.source=s,d.host=d.host.substring(1,d.host.length-1).replace(/;/g,":"),d.authority=d.authority.replace("[","").replace("]","").replace(/;/g,":"),d.ipv6uri=!0),d.pathNames=cS(d,d.path),d.queryKey=uS(d,d.query),d}function cS(n,s){const i=/\/{2,9}/g,o=s.replace(i,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&o.splice(0,1),s.slice(-1)=="/"&&o.splice(o.length-1,1),o}function uS(n,s){const i={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(i[f]=d)}),i}const bf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Jr=[];bf&&addEventListener("offline",()=>{Jr.forEach(n=>n())},!1);class _a extends At{constructor(s,i){if(super(),this.binaryType=$1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(i=s,s=null),s){const o=yf(s);i.hostname=o.host,i.secure=o.protocol==="https"||o.protocol==="wss",i.port=o.port,o.query&&(i.query=o.query)}else i.host&&(i.hostname=yf(i.host).host);yo(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(o=>{const f=o.prototype.name;this.transports.push(f),this._transportsByName[f]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Z1(this.opts.query)),bf&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Jr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const i=Object.assign({},this.opts.query);i.EIO=Bx,i.transport=s,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[s]);return new this._transportsByName[s](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&_a.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(s);i.open(),this.setTransport(i)}setTransport(s){this.transport&&this.transport.removeAllListeners(),this.transport=s,s.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",_a.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=s.data,this._onError(i);break;case"message":this.emitReserved("data",s.data),this.emitReserved("message",s.data);break}}onHandshake(s){this.emitReserved("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this._pingInterval=s.pingInterval,this._pingTimeout=s.pingTimeout,this._maxPayload=s.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const s=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+s,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},s),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const s=this._getWritablePackets();this.transport.send(s),this._prevBufferLen=s.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let o=0;o<this.writeBuffer.length;o++){const f=this.writeBuffer[o].data;if(f&&(i+=X1(f)),o>0&&i>this._maxPayload)return this.writeBuffer.slice(0,o);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,vo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,i,o){return this._sendPacket("message",s,i,o),this}send(s,i,o){return this._sendPacket("message",s,i,o),this}_sendPacket(s,i,o,f){if(typeof i=="function"&&(f=i,i=void 0),typeof o=="function"&&(f=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const d={type:s,data:i,options:o};this.emitReserved("packetCreate",d),this.writeBuffer.push(d),f&&this.once("flush",f),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),s()},o=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():s()}):this.upgrading?o():s()),this}_onError(s){if(_a.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),bf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Jr.indexOf(this._offlineEventListener);o!==-1&&Jr.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,i),this.writeBuffer=[],this._prevBufferLen=0}}}_a.protocol=Bx;class fS extends _a{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let i=this.createTransport(s),o=!1;_a.priorWebsocketSuccess=!1;const f=()=>{o||(i.send([{type:"ping",data:"probe"}]),i.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;_a.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=i.name,this.emitReserved("upgradeError",S)}}))};function d(){o||(o=!0,y(),i.close(),i=null)}const h=b=>{const S=new Error("probe error: "+b);S.transport=i.name,d(),this.emitReserved("upgradeError",S)};function p(){h("transport closed")}function x(){h("socket closed")}function g(b){i&&b.name!==i.name&&d()}const y=()=>{i.removeListener("open",f),i.removeListener("error",h),i.removeListener("close",p),this.off("close",x),this.off("upgrading",g)};i.once("open",f),i.once("error",h),i.once("close",p),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{o||i.open()},200):i.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const i=[];for(let o=0;o<s.length;o++)~this.transports.indexOf(s[o])&&i.push(s[o]);return i}}let dS=class extends fS{constructor(s,i={}){const o=typeof s=="object"?s:i;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(f=>iS[f]).filter(f=>!!f)),super(s,o)}};function mS(n,s="",i){let o=n;i=i||typeof location<"u"&&location,n==null&&(n=i.protocol+"//"+i.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=i.protocol+n:n=i.host+n),/^(https?|wss?):\/\//.test(n)||(typeof i<"u"?n=i.protocol+"//"+n:n="https://"+n),o=yf(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const d=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+d+":"+o.port+s,o.href=o.protocol+"://"+d+(i&&i.port===o.port?"":":"+o.port),o}const hS=typeof ArrayBuffer=="function",pS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,$x=Object.prototype.toString,xS=typeof Blob=="function"||typeof Blob<"u"&&$x.call(Blob)==="[object BlobConstructor]",gS=typeof File=="function"||typeof File<"u"&&$x.call(File)==="[object FileConstructor]";function $f(n){return hS&&(n instanceof ArrayBuffer||pS(n))||xS&&n instanceof Blob||gS&&n instanceof File}function Pr(n,s){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let i=0,o=n.length;i<o;i++)if(Pr(n[i]))return!0;return!1}if($f(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Pr(n.toJSON(),!0);for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&Pr(n[i]))return!0;return!1}function vS(n){const s=[],i=n.data,o=n;return o.data=Sf(i,s),o.attachments=s.length,{packet:o,buffers:s}}function Sf(n,s){if(!n)return n;if($f(n)){const i={_placeholder:!0,num:s.length};return s.push(n),i}else if(Array.isArray(n)){const i=new Array(n.length);for(let o=0;o<n.length;o++)i[o]=Sf(n[o],s);return i}else if(typeof n=="object"&&!(n instanceof Date)){const i={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=Sf(n[o],s));return i}return n}function yS(n,s){return n.data=Af(n.data,s),delete n.attachments,n}function Af(n,s){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<s.length)return s[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let i=0;i<n.length;i++)n[i]=Af(n[i],s);else if(typeof n=="object")for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=Af(n[i],s));return n}const bS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],SS=5;var Be;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Be||(Be={}));class AS{constructor(s){this.replacer=s}encode(s){return(s.type===Be.EVENT||s.type===Be.ACK)&&Pr(s)?this.encodeAsBinary({type:s.type===Be.EVENT?Be.BINARY_EVENT:Be.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let i=""+s.type;return(s.type===Be.BINARY_EVENT||s.type===Be.BINARY_ACK)&&(i+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(i+=s.nsp+","),s.id!=null&&(i+=s.id),s.data!=null&&(i+=JSON.stringify(s.data,this.replacer)),i}encodeAsBinary(s){const i=vS(s),o=this.encodeAsString(i.packet),f=i.buffers;return f.unshift(o),f}}function N0(n){return Object.prototype.toString.call(n)==="[object Object]"}class Gf extends At{constructor(s){super(),this.reviver=s}add(s){let i;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(s);const o=i.type===Be.BINARY_EVENT;o||i.type===Be.BINARY_ACK?(i.type=o?Be.EVENT:Be.ACK,this.reconstructor=new jS(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if($f(s)||s.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(s),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let i=0;const o={type:Number(s.charAt(0))};if(Be[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Be.BINARY_EVENT||o.type===Be.BINARY_ACK){const d=i+1;for(;s.charAt(++i)!=="-"&&i!=s.length;);const h=s.substring(d,i);if(h!=Number(h)||s.charAt(i)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(s.charAt(i+1)==="/"){const d=i+1;for(;++i&&!(s.charAt(i)===","||i===s.length););o.nsp=s.substring(d,i)}else o.nsp="/";const f=s.charAt(i+1);if(f!==""&&Number(f)==f){const d=i+1;for(;++i;){const h=s.charAt(i);if(h==null||Number(h)!=h){--i;break}if(i===s.length)break}o.id=Number(s.substring(d,i+1))}if(s.charAt(++i)){const d=this.tryParse(s.substr(i));if(Gf.isPayloadValid(o.type,d))o.data=d;else throw new Error("invalid payload")}return o}tryParse(s){try{return JSON.parse(s,this.reviver)}catch{return!1}}static isPayloadValid(s,i){switch(s){case Be.CONNECT:return N0(i);case Be.DISCONNECT:return i===void 0;case Be.CONNECT_ERROR:return typeof i=="string"||N0(i);case Be.EVENT:case Be.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&bS.indexOf(i[0])===-1);case Be.ACK:case Be.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class jS{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const i=yS(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const NS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Gf,Encoder:AS,get PacketType(){return Be},protocol:SS},Symbol.toStringTag,{value:"Module"}));function bn(n,s,i){return n.on(s,i),function(){n.off(s,i)}}const wS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Gx extends At{constructor(s,i,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=s,this.nsp=i,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const s=this.io;this.subs=[bn(s,"open",this.onopen.bind(this)),bn(s,"packet",this.onpacket.bind(this)),bn(s,"error",this.onerror.bind(this)),bn(s,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...i){var o,f,d;if(wS.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(i.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const h={type:Be.EVENT,data:i};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const y=this.ids++,b=i.pop();this._registerAckCallback(y,b),h.id=y}const p=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,x=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!p||(x?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(s,i){var o;const f=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(f===void 0){this.acks[s]=i;return}const d=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===s&&this.sendBuffer.splice(p,1);i.call(this,new Error("operation has timed out"))},f),h=(...p)=>{this.io.clearTimeoutFn(d),i.apply(this,p)};h.withError=!0,this.acks[s]=h}emitWithAck(s,...i){return new Promise((o,f)=>{const d=(h,p)=>h?f(h):o(p);d.withError=!0,i.push(d),this.emit(s,...i)})}_addToQueue(s){let i;typeof s[s.length-1]=="function"&&(i=s.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((f,...d)=>o!==this._queue[0]?void 0:(f!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(f)):(this._queue.shift(),i&&i(null,...d)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!s||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:Be.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},s):s})}onerror(s){this.connected||this.emitReserved("connect_error",s)}onclose(s,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(s=>{if(!this.sendBuffer.some(o=>String(o.id)===s)){const o=this.acks[s];delete this.acks[s],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(s){if(s.nsp===this.nsp)switch(s.type){case Be.CONNECT:s.data&&s.data.sid?this.onconnect(s.data.sid,s.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Be.EVENT:case Be.BINARY_EVENT:this.onevent(s);break;case Be.ACK:case Be.BINARY_ACK:this.onack(s);break;case Be.DISCONNECT:this.ondisconnect();break;case Be.CONNECT_ERROR:this.destroy();const o=new Error(s.data.message);o.data=s.data.data,this.emitReserved("connect_error",o);break}}onevent(s){const i=s.data||[];s.id!=null&&i.push(this.ack(s.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const o of i)o.apply(this,s)}super.emit.apply(this,s),this._pid&&s.length&&typeof s[s.length-1]=="string"&&(this._lastOffset=s[s.length-1])}ack(s){const i=this;let o=!1;return function(...f){o||(o=!0,i.packet({type:Be.ACK,id:s,data:f}))}}onack(s){const i=this.acks[s.id];typeof i=="function"&&(delete this.acks[s.id],i.withError&&s.data.unshift(null),i.apply(this,s.data))}onconnect(s,i){this.id=s,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(s=>this.emitEvent(s)),this.receiveBuffer=[],this.sendBuffer.forEach(s=>{this.notifyOutgoingListeners(s),this.packet(s)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(s=>s()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Be.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(s){return this.flags.compress=s,this}get volatile(){return this.flags.volatile=!0,this}timeout(s){return this.flags.timeout=s,this}onAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(s),this}prependAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(s),this}offAny(s){if(!this._anyListeners)return this;if(s){const i=this._anyListeners;for(let o=0;o<i.length;o++)if(s===i[o])return i.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(s),this}prependAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(s),this}offAnyOutgoing(s){if(!this._anyOutgoingListeners)return this;if(s){const i=this._anyOutgoingListeners;for(let o=0;o<i.length;o++)if(s===i[o])return i.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const o of i)o.apply(this,s.data)}}}function ol(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}ol.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),i=Math.floor(s*this.jitter*n);n=(Math.floor(s*10)&1)==0?n-i:n+i}return Math.min(n,this.max)|0};ol.prototype.reset=function(){this.attempts=0};ol.prototype.setMin=function(n){this.ms=n};ol.prototype.setMax=function(n){this.max=n};ol.prototype.setJitter=function(n){this.jitter=n};class jf extends At{constructor(s,i){var o;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(i=s,s=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,yo(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((o=i.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new ol({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=s;const f=i.parser||NS;this.encoder=new f.Encoder,this.decoder=new f.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(s){return arguments.length?(this._reconnection=!!s,s||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(s){return s===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=s,this)}reconnectionDelay(s){var i;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(i=this.backoff)===null||i===void 0||i.setMin(s),this)}randomizationFactor(s){var i;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(i=this.backoff)===null||i===void 0||i.setJitter(s),this)}reconnectionDelayMax(s){var i;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(i=this.backoff)===null||i===void 0||i.setMax(s),this)}timeout(s){return arguments.length?(this._timeout=s,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(s){if(~this._readyState.indexOf("open"))return this;this.engine=new dS(this.uri,this.opts);const i=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=bn(i,"open",function(){o.onopen(),s&&s()}),d=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),s?s(p):this.maybeReconnectOnOpen()},h=bn(i,"error",d);if(this._timeout!==!1){const p=this._timeout,x=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),i.close()},p);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(f),this.subs.push(h),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(bn(s,"ping",this.onping.bind(this)),bn(s,"data",this.ondata.bind(this)),bn(s,"error",this.onerror.bind(this)),bn(s,"close",this.onclose.bind(this)),bn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(i){this.onclose("parse error",i)}}ondecoded(s){vo(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,i){let o=this.nsps[s];return o?this._autoConnect&&!o.active&&o.connect():(o=new Gx(this,s,i),this.nsps[s]=o),o}_destroy(s){const i=Object.keys(this.nsps);for(const o of i)if(this.nsps[o].active)return;this._close()}_packet(s){const i=this.encoder.encode(s);for(let o=0;o<i.length;o++)this.engine.write(i[o],s.options)}cleanup(){this.subs.forEach(s=>s()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,i){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(f=>{f?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",f)):s.onreconnect()}))},i);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const li={};function Wr(n,s){typeof n=="object"&&(s=n,n=void 0),s=s||{};const i=mS(n,s.path||"/socket.io"),o=i.source,f=i.id,d=i.path,h=li[f]&&d in li[f].nsps,p=s.forceNew||s["force new connection"]||s.multiplex===!1||h;let x;return p?x=new jf(o,s):(li[f]||(li[f]=new jf(o,s)),x=li[f]),i.query&&!s.query&&(s.query=i.queryKey),x.socket(i.path,s)}Object.assign(Wr,{Manager:jf,Socket:Gx,io:Wr,connect:Wr});const Yx="roverSettings",CS=3600*24*365;function ES(n){try{const s=decodeURIComponent(n??"");return JSON.parse(s)}catch(s){return console.warn("Failed to parse settings cookie",s),null}}function Nf(){if(typeof document>"u")return{};const n=`${Yx}=`,s=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!s)return{};const i=s.substring(n.length);return ES(i)??{}}function w0(n){if(typeof document>"u")return!1;try{const s=encodeURIComponent(JSON.stringify(n??{})),i=`${Yx}=${s}; path=/; max-age=${CS}; samesite=strict`;return document.cookie=i,!0}catch(s){return console.warn("Failed to write settings cookie",s),!1}}const Fx=window.location.origin;console.info("[socket] connecting to",Fx);const kS=Nf(),MS=kS?.page?.connectionTransport||"websocket",qS=MS==="polling"?["polling"]:["websocket","polling"],Yf=Wr(Fx,{transports:qS,timeout:15e3});Yf.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const Xx=m.createContext(Yf),RS=({children:n})=>r.jsx(Xx.Provider,{value:Yf,children:n}),pn=()=>m.useContext(Xx),Qx=m.createContext({connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,identifySession:async()=>{},login:async()=>{},setRole:async()=>{},requestControl:async()=>{},releaseControl:async()=>{},subscribeAll:async()=>{},homeAssistantToggle:async()=>{},homeAssistantSetState:async()=>{},homeAssistantSetLightColor:async()=>{},setNickname:async()=>{},requestVerification:async()=>{},requestPrivateRoverAccess:async()=>{},triggerReplay:async()=>{},setCommunityGoal:async()=>{},setAdminReason:async()=>{},rebootRover:async()=>{},rebootServer:async()=>{},playUploadedAudio:async()=>{},stopUploadedAudio:async()=>{},startMicWhip:async()=>{},readyMicWhip:async()=>{},stopMicWhip:async()=>{},setAudioLevels:async()=>{},setPrivateSafety:async()=>{},llmControl:async()=>{}});function TS(n){return m.useCallback((s,i={})=>new Promise((o,f)=>{n.emit(s,i,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[n])}function DS({children:n}){const s=pn(),i=TS(s),[o,f]=m.useState(null),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,y]=m.useState(null),[b,S]=m.useState(null),[R,N]=m.useState([]),[k,j]=m.useState(s.connected);m.useEffect(()=>{const C=()=>j(!0),M=()=>j(!1);return s.on("connect",C),s.on("disconnect",M),()=>{s.off("connect",C),s.off("disconnect",M)}},[s]),m.useEffect(()=>{function C(L){f(L)}function M(L=[]){h(L)}function B(L){h(U=>[...U.slice(-199),L])}function H(L=[]){x(L)}function _(L){x(U=>[...U.slice(-199),L])}function K(L=null){const U=L&&typeof L=="object"?L:null,F=U?.debug?.status&&typeof U.debug.status=="object"?U.debug.status:null;y(U),S(F)}return s.on("session:sync",C),s.on("log:init",M),s.on("log:entry",B),s.on("adminlog:init",H),s.on("adminlog:entry",_),s.on("llm:state",K),s.on("alert:new",(L={})=>{N(U=>[...U.slice(-49),{...L,receivedAt:Date.now()}])}),()=>{s.off("session:sync",C),s.off("log:init",M),s.off("log:entry",B),s.off("adminlog:init",H),s.off("adminlog:entry",_),s.off("llm:state",K),s.off("alert:new")}},[s]);const w=m.useMemo(()=>({login:(C,M)=>i("auth:login",{username:C,password:M}),identifySession:({cookieUserId:C,nickname:M}={})=>i("session:identify",{cookieUserId:C,nickname:M}),setRole:C=>i("session:setRole",{role:C}),requestControl:(C,M={})=>i("session:requestControl",{roverId:C,...M}),releaseControl:C=>i("session:releaseControl",{roverId:C}),subscribeAll:()=>i("session:subscribeAll"),lockRover:(C,M)=>i("session:lockRover",{roverId:C,locked:M}),setMode:C=>i("setMode",{mode:C}),homeAssistantToggle:C=>i("homeAssistant:toggle",{entityId:C}),homeAssistantSetState:(C,M)=>i("homeAssistant:setState",{entityId:C,state:M}),homeAssistantSetLightColor:(C,M)=>i("homeAssistant:lightColor",{entityId:C,rgbColor:M}),setNickname:C=>i("nickname:set",{nickname:C}),requestVerification:()=>i("verification:request"),requestPrivateRoverAccess:C=>i("session:privateRover:requestAccess",{roverId:C}),triggerReplay:(C=[])=>i("replay:trigger",{sources:C}),setCommunityGoal:C=>i("communityGoal:set",{text:C}),setAdminReason:C=>i("adminReason:set",{text:C}),rebootRover:C=>i("command",{roverId:C,type:"reboot",data:{reboot:{}}}),rebootServer:()=>i("server:reboot"),playUploadedAudio:({roverId:C,name:M,mime:B,dataBase64:H})=>i("audio:uploadPlay",{roverId:C,name:M,mime:B,dataBase64:H}),stopUploadedAudio:C=>i("audio:uploadStop",{roverId:C}),startMicWhip:C=>i("audio:micWhipStart",{roverId:C}),readyMicWhip:C=>i("audio:micWhipReady",{roverId:C}),stopMicWhip:C=>i("audio:micWhipStop",{roverId:C}),setAudioLevels:(C={})=>i("audioLevels:set",C),setPrivateSafety:(C,M={})=>i("session:privateSafety:set",{roverId:C,safety:M}),llmControl:(C,M={})=>i("llm:control",{controls:{action:C,...M}}),pushAlert:C=>N(M=>[...M.slice(-49),{...C,receivedAt:Date.now(),id:C.id||Math.random().toString(36).slice(2)}])}),[i]),E=m.useMemo(()=>({connected:k,session:o,logs:d,adminLogs:p,llmCommentaryState:g,llmCommentaryStatus:b,alerts:R,...w}),[w,p,R,k,g,b,d,o]);return r.jsx(Qx.Provider,{value:E,children:n})}function Le(){return m.useContext(Qx)}const Kx=m.createContext({frames:{}});function _S({children:n}){const s=pn(),[i,o]=m.useState({});m.useEffect(()=>{function d({roverId:h,sensors:p={},frame:x={}}){h&&o(g=>({...g,[h]:{roverId:h,sensors:p,raw:x?.data||null,receivedAt:Date.now()}}))}return s.on("sensorFrame",d),()=>{s.off("sensorFrame",d)}},[s]);const f=m.useMemo(()=>({frames:i}),[i]);return r.jsx(Kx.Provider,{value:f,children:n})}function Ff(){return m.useContext(Kx).frames}function cl(n){const s=Ff();return n?s[n]??null:null}const OS=650,BS={161:{red:!0},164:{green:!0},165:{force:!0},168:{red:!0,green:!0},169:{red:!0,force:!0},172:{green:!0,force:!0},173:{red:!0,green:!0,force:!0}};function Zu(n){if(typeof n!="number"||n<=0)return null;const s=BS[n];return s?{code:n,...s}:null}function LS(n,s={}){const i=s.holdMs||OS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,h]=m.useState(0);return m.useEffect(()=>{const p=setInterval(()=>h(Date.now()),Math.max(i/2,100));return()=>clearInterval(p)},[i]),m.useEffect(()=>{const p=Date.now(),x=Zu(n?.infraredCharacterLeft),g=Zu(n?.infraredCharacterRight),y=Zu(n?.infraredCharacterOmni);!x&&!g&&!y||f(b=>({left:x?{...x,ts:p}:b.left,right:g?{...g,ts:p}:b.right,omni:y?{...y,ts:p}:b.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useEffect(()=>{const{left:p,right:x,omni:g}=o;if(!(p?.ts||x?.ts||g?.ts))return;const b=new Date().toISOString();console.debug("[DockIR]",b,{left:p?.code??0,omni:g?.code??0,right:x?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const p=Date.now(),x=j=>{if(!j)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const w=p-j.ts,E=w<=i;return{active:E,age:w,code:j.code,red:!!(j.red&&E),green:!!(j.green&&E),force:!!(j.force&&E)}},g=x(o.left),y=x(o.right),b=x(o.omni),S=g.force||y.force||b.force,R=g.active||y.active||b.active,N=g.active&&!y.active?"right":y.active&&!g.active?"left":"center",k=(y.active?1:0)-(g.active?1:0);return{visible:R,forceDetected:S,left:g,right:y,omni:b,bias:N,balance:Math.max(-1,Math.min(1,k))}},[o.left,o.right,o.omni,i,d])}function zS(){const{connected:n,session:s}=Le(),i=s?.assignment?.roverId,o=cl(i),f=o?.sensors||{},d=LS(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,p=f.currentMa!=null?`${f.currentMa} mA`:null,x=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,g=f.batteryChargeMah,y=f.batteryCapacityMah;o?.receivedAt&&new Date(o.receivedAt).toLocaleTimeString();const b=o?.raw?o.raw:null,S=i?s?.activeDrivers?.[i]:null;return m.useMemo(()=>i?S?S===s?.socketId?"You":(s?.users||[]).find(N=>N.socketId===S)?.nickname||S.slice(0,6):"Available":"n/a",[S,i,s?.socketId,s?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[i?o?r.jsxs(r.Fragment,{children:[r.jsx(US,{sensors:f,voltage:h,current:p,batteryTemp:x,charge:g,capacity:y}),r.jsx(HS,{sensors:f,dockState:d})]}):r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):r.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),b&&r.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:b})]})}function US({sensors:n,voltage:s,current:i,batteryTemp:o,charge:f,capacity:d}){const h=f!=null&&d?`${Math.round(f/d*100)}`:"--",p=n?.oiMode?.label||"--",x=n?.chargingSources?.homeBase?"Yes":"No",g=n?.chargingState?.label||"--";return r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[r.jsx(ta,{label:"Voltage",value:s??"--"}),r.jsx(ta,{label:"Current",value:i??"--"}),r.jsx(ta,{label:"Battery temp",value:o??"--"}),r.jsx(ta,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(ta,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(ta,{label:"Charge",value:h}),r.jsx(ta,{label:"OI mode",value:p}),r.jsx(ta,{label:"Docked",value:x}),r.jsx(ta,{label:"Charging state",value:g})]})}function ta({label:n,value:s}){return r.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[r.jsx("span",{className:"text-slate-400",children:n}),r.jsx("span",{className:"text-slate-100",children:s})]})}function HS({sensors:n,dockState:s}){const i=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},f=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],d=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],h=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs(Is,{title:"Dock IR",children:[r.jsx(VS,{sensors:n}),r.jsx($S,{state:s})]}),r.jsxs(Is,{title:"Bumps & drops",children:[r.jsx(na,{label:"Bump L",value:r.jsx(ii,{active:i.bumpLeft})}),r.jsx(na,{label:"Bump R",value:r.jsx(ii,{active:i.bumpRight})}),r.jsx(na,{label:"Wheel drop L",value:r.jsx(ii,{active:i.wheelDropLeft,tone:"amber"})}),r.jsx(na,{label:"Wheel drop R",value:r.jsx(ii,{active:i.wheelDropRight,tone:"amber"})})]}),r.jsx(Is,{title:"Light bumps (raw)",children:f.map(p=>r.jsx(na,{label:p.label,value:ri(p.value)},p.label))}),r.jsx(Is,{title:"Cliff sensors",children:d.map(p=>r.jsx(na,{label:p.label,value:`${ri(p.value)} · ${p.active?"bool: true":"bool: false"}`},p.label))}),r.jsx(Is,{title:"Currents",children:h.map(p=>r.jsx(na,{label:p.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:ri(p.value,"mA")}),p.over?r.jsx(ii,{active:!0,tone:"red",label:"over"}):null]})},p.label))}),r.jsxs(Is,{title:"Dirt detect",children:[r.jsx(na,{label:"Left",value:ri(n?.dirtDetectLeft)}),r.jsx(na,{label:"Right",value:ri(n?.dirtDetect)})]})]})}function Is({title:n,children:s}){return r.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[r.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:n}),r.jsx("div",{className:"space-y-0.5",children:s})]})}function na({label:n,value:s}){return r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-300",children:n}),r.jsx("span",{className:"text-slate-100",children:s})]})}function ii({active:n,tone:s="green",label:i}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=s==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":s==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:i||(n?"true":"false")})}function ri(n,s){return n==null||Number.isNaN(n)?"--":s?`${n} ${s}`:n}function VS({sensors:n}){const s=n?.infraredCharacterLeft,i=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,f=d=>r.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${d?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:d||"--"});return r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"L"}),f(s)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"O"}),f(o)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"R"}),f(i)]})]})}function $S({state:n}){if(!n)return null;const s=o=>{const f=[];return o?.red&&f.push("R"),o?.green&&f.push("G"),o?.force&&f.push("F"),f.length?f.join(""):"none"},i=o=>o?.age!=null?`${o.age}ms`:"--";return r.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Left: ${n.left.code??"--"} (${s(n.left)}) · age ${i(n.left)}`}),r.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${s(n.omni)}) · age ${i(n.omni)}`}),r.jsx("div",{children:`Right: ${n.right.code??"--"} (${s(n.right)}) · age ${i(n.right)}`})]})}const Zx=m.createContext(null);function GS({children:n}){const[s,i]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const p=Nf();i({status:"ready",data:p??{}})},[]);const o=m.useCallback(()=>{const p=Nf();i({status:"ready",data:p??{}})},[]),f=m.useCallback(p=>{const x=w0(p??{});return i(x?{status:"ready",data:p??{}}:g=>({...g,status:"error"})),x},[]),d=m.useCallback((p,x)=>{i(g=>{const y=g.data[p]||{},b=typeof x=="function"?x(y):{...y,...x??{}},S={...g.data,[p]:b};return w0(S)?{status:"ready",data:S}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:s.data,status:s.status,reload:o,saveAll:f,setNamespace:d}),[s,o,f,d]);return r.jsx(Zx.Provider,{value:h,children:n})}function YS(){const n=m.useContext(Zx);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Fe(n,s={}){const{data:i,status:o,setNamespace:f}=YS(),d=i[n]??s??{},h=m.useCallback(g=>{f(n,y=>{const b=y??{};return typeof g=="function"?g(b):{...b,...g??{}}})},[n,f]),p=m.useCallback(g=>{f(n,()=>g??{})},[n,f]),x=m.useCallback(()=>{const g=typeof s=="object"?{...s}:s;f(n,()=>g??{})},[s,n,f]);return{value:d,status:o,save:h,replace:p,reset:x}}const FS=/^#[0-9A-Fa-f]{6}$/;function Xf(n){const s=typeof n=="string"?n.trim():"";return!s||!FS.test(s)?null:s.toUpperCase()}function ra(n,s=.2){const i=Xf(n);if(!i)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=Ix(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.65)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function XS(n,s=.2){const i=Xf(n);if(!i)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=Ix(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.55)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function Ix(n){const s=Xf(n);return s?{r:parseInt(s.slice(1,3),16),g:parseInt(s.slice(3,5),16),b:parseInt(s.slice(5,7),16)}:null}function QS(n=[]){return n.map(s=>!s?.type||!s?.id?null:{type:s.type,id:String(s.id),label:s.label||String(s.id),color:s.color||null,key:`${s.type}:${s.id}`}).filter(Boolean)}function Qf({panelId:n="replay-sources",fillHeight:s=!1}){const{session:i,triggerReplay:o}=Le(),f=QS(i?.replaySources||[]),{value:d,save:h}=Fe("replaySources",{}),[p,x]=m.useState([]),[g,y]=m.useState(!1),[b,S]=m.useState(null),[R,N]=m.useState(null),k=i?.replay||null,[j,w]=m.useState(0),E=m.useMemo(()=>{const L=i?.assignment?.roverId;return L?[`rover:${L}`]:[]},[i?.assignment?.roverId]);m.useEffect(()=>{const L=d?.[n];if(Array.isArray(L)&&L.length){x(L);return}x(E)},[d?.[n],E,n]),m.useEffect(()=>{const L=new Set(f.map(U=>U.key));x(U=>U.filter(F=>L.has(F)))},[f]);const C=m.useMemo(()=>({rovers:f.filter(L=>L.type==="rover"),rooms:f.filter(L=>L.type==="room")}),[f]);m.useEffect(()=>{if(!k?.lastTriggeredAt||!k?.cooldownMs){w(0);return}const L=()=>{const F=k.lastTriggeredAt+k.cooldownMs-Date.now();w(Math.max(0,F))};L();const U=setInterval(L,250);return()=>clearInterval(U)},[k?.lastTriggeredAt,k?.cooldownMs,k?.remainingMs]);const M=g||i?.mode==="lockdown"||j>0||!p.length,B=L=>{x(U=>{const F=U.includes(L)?U.filter(te=>te!==L):[...U,L];return h(te=>({...te||{},[n]:F})),F}),N(null)},H=async()=>{if(!M){y(!0),S(null),N(null);try{const L=p.map(U=>{const[F,te]=U.split(":");return{type:F,id:te}});await o(L),N("Replay sent. Check the Discord replay channel.")}catch(L){S(L.message)}finally{y(!1)}}},_=s?"h-full flex flex-col":"",K=s?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${_}`,children:[r.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[r.jsx("span",{children:"Replay Sources"}),r.jsx("span",{children:f.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${K}`,children:[r.jsx(C0,{title:"Rovers",items:C.rovers,selected:p,onToggle:B}),r.jsx(C0,{title:"Room Cams",items:C.rooms,selected:p,onToggle:B})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:H,disabled:M,children:j>0?`Replay (${Math.ceil(j/1e3)}s)`:g?"Replay…":"Replay"}),b?r.jsx("div",{className:"text-xs text-amber-400",children:b}):null,R?r.jsx("div",{className:"text-xs text-emerald-300",children:R}):null]})]})}function C0({title:n,items:s,selected:i,onToggle:o}){return s.length?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs",children:n}),r.jsx("div",{className:"space-y-0.5",children:s.map(f=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:i.includes(f.key),onChange:()=>o(f.key),className:"accent-emerald-400"}),r.jsx("span",{className:`truncate ${f.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:f.type==="rover"?ra(f.color,.16):void 0,children:f.label})]},f.key))})]}):null}var Jx={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},E0=rs.createContext&&rs.createContext(Jx),KS=["attr","size","title"];function ZS(n,s){if(n==null)return{};var i=IS(n,s),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(n);for(f=0;f<d.length;f++)o=d[f],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(i[o]=n[o])}return i}function IS(n,s){if(n==null)return{};var i={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(s.indexOf(o)>=0)continue;i[o]=n[o]}return i}function lo(){return lo=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])}return n},lo.apply(this,arguments)}function k0(n,s){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);s&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(n,f).enumerable})),i.push.apply(i,o)}return i}function io(n){for(var s=1;s<arguments.length;s++){var i=arguments[s]!=null?arguments[s]:{};s%2?k0(Object(i),!0).forEach(function(o){JS(n,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):k0(Object(i)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(i,o))})}return n}function JS(n,s,i){return s=PS(s),s in n?Object.defineProperty(n,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[s]=i,n}function PS(n){var s=WS(n,"string");return typeof s=="symbol"?s:s+""}function WS(n,s){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var o=i.call(n,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function Px(n){return n&&n.map((s,i)=>rs.createElement(s.tag,io({key:i},s.attr),Px(s.child)))}function Ei(n){return s=>rs.createElement(eA,lo({attr:io({},n.attr)},s),Px(n.child))}function eA(n){var s=i=>{var{attr:o,size:f,title:d}=n,h=ZS(n,KS),p=f||i.size||"1em",x;return i.className&&(x=i.className),n.className&&(x=(x?x+" ":"")+n.className),rs.createElement("svg",lo({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,o,h,{className:x,style:io(io({color:n.color||i.color},i.style),n.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),d&&rs.createElement("title",null,d),n.children)};return E0!==void 0?rs.createElement(E0.Consumer,null,i=>s(i)):s(Jx)}function Wx(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(n)}function tA(n){return Ei({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(n)}function M0(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(n)}function nA(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(n)}function aA(n){return Ei({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(n)}function sA(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function Kf(n){return!!n?.system}function lA(n){const s=new Date(n);return`${s.getHours().toString().padStart(2,"0")}:${s.getMinutes().toString().padStart(2,"0")}`}function q0(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function iA({guildIconUrl:n,userAvatarUrl:s,label:i}){return!n&&!s?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:i,children:[r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${n?"bg-cover":""}`,style:n?{backgroundImage:`url(${n})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${s?"bg-cover":""}`,style:s?{backgroundImage:`url(${s})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function eg({message:n}){const s=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${q0(n)}`:null,i=Kf(n),o=i?"text-emerald-300":sA(n.role);return r.jsxs(r.Fragment,{children:[n.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(Wx,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(iA,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:s})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:q0(n)}),i?r.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,n.roverId&&r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",style:XS(n.roverColor,.14),children:n.roverId})]})}function tg(n){return Kf(n)?"surface-muted relative flex flex-wrap items-start gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted relative flex flex-wrap items-start gap-0.5 text-sm ${n.role==="admin"||n.role==="lockdown"||n.role==="lockdown-admin"?"border border-amber-400/30":n.fromDiscord?"border border-indigo-400/30 bg-indigo-900/20":""}`}function Zf({message:n}){const s=Kf(n);return r.jsxs("div",{className:tg(n),children:[r.jsx(eg,{message:n}),r.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${s?"text-emerald-100":"text-slate-100"}`,children:n.text}),r.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:lA(n.ts)})]})}function ng({message:n}){return r.jsxs("div",{className:`${tg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(eg,{message:n}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function ag({buttonId:n,count:s,goal:i,rewardNumber:o,rewardName:f,className:d=""}){return r.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",d].filter(Boolean).join(" "),children:[r.jsxs("p",{className:"text-xs text-slate-400",children:["Button ",n]}),r.jsxs("p",{className:"text-sm font-semibold text-white",children:[s," / ",i]}),r.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",f]})]})}const rA=3e3,oA=3500,cA="#2196f3";function uA(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function If({scale:n=1}){const{alerts:s,session:i,pushAlert:o}=Le(),f=pn(),[d,h]=m.useState(()=>Date.now());m.useEffect(()=>{function S(R={}){const N=Number(R.buttonId);if(!Number.isFinite(N)||N<1||N>4)return;const j=(Array.isArray(i?.buttonBox?.buttons)?i.buttonBox.buttons:[]).find(B=>Number(B?.id)===N)||{},w=Number.isFinite(R.count)?R.count:Number(j.count)||0,E=Number.isFinite(j.goal)?j.goal:0,C=Number.isFinite(j.rewardNumber)?j.rewardNumber:"?",M=typeof j.rewardName=="string"&&j.rewardName.trim()?j.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${N}`,kind:"buttonbox-active",lifetimeMs:oA,payload:{buttonId:N,count:w,goal:E,rewardNumber:C,rewardName:M}})}return f.on("buttonBox:increment",S),()=>{f.off("buttonBox:increment",S)}},[o,i?.buttonBox?.buttons,f]);const p=m.useMemo(()=>s.slice(-12).map(S=>({alert:S,key:uA(S)})),[s]);m.useEffect(()=>{if(!p.length)return;const S=setInterval(()=>h(Date.now()),200);return()=>clearInterval(S)},[p.length]);const x=new Map;p.forEach(S=>{const R=d-(S.alert.receivedAt??S.alert.timestamp??0),N=Number.isFinite(S.alert.lifetimeMs)?S.alert.lifetimeMs:rA;R<=N&&x.set(S.key,{...S,age:R})});const g=Array.from(x.values()).slice(-3);if(!g.length)return null;const y=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},b=n===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return r.jsx("div",{className:b,style:y,children:g.map(S=>r.jsx(fA,{alert:S.alert},S.key))})}function R0(n){const s=typeof n=="string"?n.trim():"",i=/^#?([0-9a-fA-F]{6})$/.exec(s);if(!i)return null;const o=i[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function fA({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const f=n.payload;return r.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:r.jsx(ag,{buttonId:f.buttonId,count:f.count,goal:f.goal,rewardNumber:f.rewardNumber,rewardName:f.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return r.jsx(Zf,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return r.jsx(ng,{message:n.payload});const s=R0(n.color)||R0(cA),i=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return r.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:i,border:`1px solid ${o}`},children:r.jsxs("p",{className:"truncate text-slate-100",children:[r.jsx("span",{className:"text-slate-300",children:n.title||"Alert"}),r.jsx("span",{className:"text-slate-500",children:" · "}),r.jsx("span",{className:"text-white",children:n.message})]})})}const Js={main:[-127,127],side:[-127,127],vacuum:[0,127]},Iu={maxSpeed:500,baseSpeed:250,boostSpeed:400},wf=100,Jf=[31,127],al=60,Cf=8,dA=250,mA=4e3,Ju=.4,hA=.8,pA={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},di={driveForward:["w"],driveBackward:["s"],driveLeft:["a"],driveRight:["d"],boostModifier:["\\"],slowModifier:["shift"],auxMainForward:["i"],auxMainReverse:["k"],auxSideForward:["o"],auxSideReverse:["l"],auxVacuumFast:["p"],auxVacuumSlow:[";"],auxAllForward:[","],cameraUp:["u"],cameraDown:["j"],nightVisionToggle:["e"],hornHonk:["h"],micPtt:["m"],driveMacro:["f"],dockMacro:["g"],chatFocus:["enter"],songNoteUp:["ArrowUp"],songNoteDown:["ArrowDown"],homeAssistantOn:["ArrowRight"],homeAssistantOff:["ArrowLeft"]},sg=[{id:"drive-sequence",label:"Drive",description:"Start, undock, and full command sequence used by the drive button.",steps:[{type:"servo",angle:0},{type:"oi",command:"start"},{type:"pause",duration:wf},{type:"oi",command:"dock"},{type:"pause",duration:wf},{type:"oi",command:"full"},{type:"pause",duration:300},{type:"drive",speeds:{left:-300,right:-300}},{type:"pause",duration:600},{type:"drive",speeds:{left:0,right:0}}]},{id:"seek-dock",label:"Dock",description:"Send the seek dock command.",steps:[{type:"oi",command:"dock"}]}];function Ef(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function kf(){return{main:0,side:0,vacuum:0}}function xA(){return{enabled:!1,angle:null,config:null}}function eo(){return{note:al}}function fi(){return{active:!1,heat:0,overheated:!1}}function to(){return{pttActive:!1}}const T0={roverId:null,mode:"drive",drive:Ef(),aux:kf(),camera:xA(),song:eo(),horn:fi(),mic:to(),lastControlIntentAt:0,macros:sg,keymap:di,inputs:{}};function gA(n,s){switch(s.type){case"control/set-rover":return{...n,roverId:s.payload??null,drive:s.payload?n.drive:Ef(),aux:s.payload?n.aux:kf(),song:s.payload?n.song:eo(),horn:s.payload?n.horn:fi(),mic:s.payload?n.mic:to(),lastControlIntentAt:s.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===s.payload?n:{...n,mode:s.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:i,speeds:o,source:f}=s.payload;return{...n,drive:{vector:i??n.drive.vector,speeds:o??n.drive.speeds,source:f??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...s.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!s.payload?.config,config:s.payload?.config??null,angle:typeof s.payload?.angle=="number"?s.payload.angle:s.payload?.config?s.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:s.payload}};case"control/register-input-state":{const i=s.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[i]:{...n.inputs[i]??{},...s.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...s.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(s.payload)?s.payload:n.macros};case"control/reset":return{...n,drive:Ef(),aux:kf(),song:eo(),horn:fi(),mic:to(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||fi(),active:!!s.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||fi(),heat:typeof s.payload?.heat=="number"?s.payload.heat:0,overheated:!!s.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||eo(),note:s.payload??al}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||to(),pttActive:!!s.payload}};default:return n}}function sl(n,s,i){return typeof n!="number"||Number.isNaN(n)?s:Math.max(s,Math.min(i,n))}function ll(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function dn(n,s){return!Array.isArray(s)||s.length!==2?n:sl(n,s[0],s[1])}function vA(n={}){const s=ll(n.x??0),i=ll(n.y??0);return{x:s,y:i,boost:!!n.boost}}function yA(n={},s={}){const i=vA(n),o=typeof s.maxSpeed=="number"?s.maxSpeed:Iu.maxSpeed,f=typeof s.baseSpeed=="number"?s.baseSpeed:Iu.baseSpeed,d=typeof s.boostSpeed=="number"?s.boostSpeed:Iu.boostSpeed,h=i.boost?d:f,p=i.y*h,x=i.x*h;return{vector:i,speeds:{left:sl(Math.round(p+x),-o,o),right:sl(Math.round(p-x),-o,o)}}}function bA(n){const s=Array.isArray(n)?n:[],i=String.fromCharCode(...s);if(typeof btoa=="function")return btoa(i);if(typeof Buffer<"u")return Buffer.from(s).toString("base64");throw new Error("No base64 encoder available")}function D0(n){return new Promise(s=>setTimeout(s,n))}function SA(n={}){const{driveTransform:s,auxTransform:i}=n,o=pn(),{session:f}=Le(),d=f?.assignment?.roverId,h=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(B=>String(B.id)===String(d))||null,[d,f?.roster]),p=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),x=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),y=m.useMemo(()=>h?.nightVision?.state??null,[h]),b=m.useCallback((B,H)=>{d&&o.emit("command",{roverId:d,...B},H)},[o,d]),S=m.useCallback(()=>{d&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,d]),R=m.useCallback(B=>{if(!d)return null;const H={left:dn(B?.left??0,[-500,500]),right:dn(B?.right??0,[-500,500])},_=s?s(H):H,K={left:dn(_?.left??0,[-500,500]),right:dn(_?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:K}}),K},[s,b,d]),N=m.useCallback(({main:B=0,side:H=0,vacuum:_=0}={})=>{if(!d)return null;const K={main:dn(B,Js.main),side:dn(H,Js.side),vacuum:dn(_,Js.vacuum)},L=i?i(K):K,U={main:dn(L?.main??0,Js.main),side:dn(L?.side??0,Js.side),vacuum:dn(L?.vacuum??0,Js.vacuum)};return b({type:"motors",data:{motorPwm:U}}),U},[i,b,d]),k=m.useCallback(B=>!d||!p?null:(b({type:"servo",data:{servo:{angle:B}}}),B),[b,d,p]),j=m.useCallback(B=>{if(!d)return!1;const H=Array.isArray(B)?B:typeof B=="string"?pA[B]:null;return H?(b({type:"raw",data:{raw:bA(H)}}),S(),!0):!1},[b,S,d]),w=m.useCallback(async B=>{if(!(!B||!Array.isArray(B.steps)||!d))for(const H of B.steps){if(!d)break;switch(H.type){case"oi":j(H.command);break;case"drive":R(H.speeds??{left:0,right:0});break;case"motors":N(H.values??{});break;case"servo":k(H.angle);break;case"pause":await D0(H.duration??wf);break}if(H.delay||H.delayMs){const _=H.delayMs??H.delay;typeof _=="number"&&_>0&&await D0(_)}}},[d,j,R,N,k]),E=m.useCallback((B="toggle")=>!d||!x?null:(b({type:"nightVision",data:{nightVision:{action:B}}}),B),[b,x,d]),C=m.useCallback(B=>d?(b({type:"horn",data:{horn:B}}),B):null,[b,d]),M=m.useCallback((B=[],H={})=>{if(!d)return null;const K=(Array.isArray(B)&&B.length>0?B:[{note:al,duration:Cf}]).slice(0,16).map(L=>({note:dn(Math.round(L?.note??al),Jf),duration:dn(Math.round(L?.duration??Cf),[1,255])}));return b({type:"song",data:{song:{notes:K,slot:H.slot,loop:H.loop}}}),K},[b,d]);return m.useMemo(()=>({roverId:d,rosterEntry:h,servoConfig:p,nightVision:x,nightVisionState:y,horn:g,emitCommand:b,enableSensorStream:S,sendDriveDirect:R,sendAuxMotors:N,sendServoAngle:k,sendOiCommand:j,sendNightVision:E,sendHorn:C,sendSong:M,runMacroSteps:w}),[d,h,p,x,y,g,b,S,R,N,k,j,E,C,w])}const AA={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},_0={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function ki(n){if(typeof n!="string")return"";const s=n.toLowerCase();return AA[s]??s}function jA(n){const s=ki(n);if(!s)return null;if(_0[s])return _0[s];if(s.length===1){if(/[a-z]/.test(s))return`Key${s.toUpperCase()}`;if(/[0-9]/.test(s))return`Digit${s}`}return null}function lg(n){const s=ki(n);return s?`key:${s}`:null}function NA(n){const s=jA(n);return s?`code:${s}`:null}function O0(n){const s=new Set,i=lg(n?.key??"");i&&s.add(i);const o=n?.code?`code:${n.code}`:null;return o&&s.add(o),Array.from(s)}function wA(n={}){return Object.fromEntries(Object.entries(n).map(([s,i])=>{const o=Array.isArray(i)?i:[i],f=new Set;return o.forEach(d=>{const h=lg(String(d));h&&f.add(h);const p=NA(String(d));p&&f.add(p)}),[s,f]}))}function Sn(n){const s=ki(n);return s?s===" "?"Space":s==="\\"?"Backslash":s==="`"?"Backtick":s==="["?"[ or {":s==="]"?"] or }":s===";"?"; or :":s==="'"?`' or "`:s===","?", or <":s==="."?". or >":s==="/"?"/ or ?":s==="-"?"- or _":s==="="?"= or +":s==="arrowup"?"Arrow Up":s==="arrowdown"?"Arrow Down":s==="arrowleft"?"Arrow Left":s==="arrowright"?"Arrow Right":s.length===1?s.toUpperCase():s:"—"}const kn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},sa={label:"Default",calibration:{driveDeadzone:.18,cameraDeadzone:.08,auxDeadzone:.05,driveCurve:"linear",cameraCurve:"linear",auxCurve:"linear",cameraMode:"absolute",cameraSensitivity:60,auxSideScale:.55},bindings:{drive:{kind:"axisPair",sources:[{kind:"axisPair",x:0,y:1,invertX:!1,invertY:!0}]},cameraTilt:{kind:"axis",sources:[{kind:"axis",index:3,invert:!0},{kind:"axis",index:1,invert:!0}]},mainBrush:{kind:"axis",sources:[{kind:"buttonAxis",index:6},{kind:"axis",index:2,invert:!1}]},sideBrush:{kind:"axis",sources:[{kind:"buttonAxis",index:7},{kind:"axis",index:5,invert:!1}]},vacuum:{kind:"button",sources:[{kind:"button",index:0}]},allAux:{kind:"button",sources:[{kind:"button",index:1}]},mainReverse:{kind:"button",sources:[{kind:"button",index:4}]},sideReverse:{kind:"button",sources:[{kind:"button",index:5}]},driveMacro:{kind:"button",sources:[{kind:"button",index:2}]},dockMacro:{kind:"button",sources:[{kind:"button",index:3}]},nightVisionToggle:{kind:"button",sources:[{kind:"button",index:9}]}}},Da={activeSignature:null,profiles:{},defaults:{profile:sa}},is={waveform:"saw",freqs:[440,550,660,0]},St={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},tl=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],CA={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function B0(){return tl.reduce((n,s)=>(n[s.key]={cap:1,clearSec:0},n),{})}function L0(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function EA(n,s={}){const{session:i}=Le(),d=(cl(n)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...CA,...s.config||{}}),[s.config]),[p,x]=m.useState(()=>B0()),g=m.useRef(typeof performance<"u"?performance.now():Date.now()),y=m.useRef(d);m.useEffect(()=>{y.current=d||{}},[d]),m.useEffect(()=>{x(B0())},[n]),m.useEffect(()=>{const N=setInterval(()=>{const k=typeof performance<"u"?performance.now():Date.now(),j=Math.max(0,k-g.current);g.current=k;const w=j/1e3;w<=0||x(E=>{let C=!1;const M={},B=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,H=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,_=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return tl.forEach(K=>{const L=E[K.key]||{cap:1,clearSec:0},U=Number.isFinite(L.cap)?L.cap:1,F=Number.isFinite(L.clearSec)?L.clearSec:0,te=K.motors.some(T=>!!y.current?.[T]),fe=te?0:F+w,ce=!te&&fe>=_,Y=L0(te?U-B*w:ce?U+H*w:U);(Math.abs(Y-U)>1e-4||Math.abs(fe-F)>1e-4)&&(C=!0),M[K.key]={cap:Y,clearSec:fe}}),C?M:E})},100);return()=>clearInterval(N)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec]);const b=m.useMemo(()=>{const N=tl.reduce((k,j)=>{const w=p?.[j.key],E=Number.isFinite(w?.cap)?w.cap:1;return k[j.key]=L0(E),k},{});return{perGroup:N,drive:{left:N.drive??1,right:N.drive??1},aux:{main:N.aux??1,side:N.aux??1,vacuum:1}}},[p]),S=m.useMemo(()=>{const N={};tl.forEach(j=>{j.motors.forEach(w=>{N[w]=!!d?.[w]})});const k=tl.reduce((j,w)=>(j[w.key]=w.motors.some(E=>!!d?.[E]),j),{});return{motors:N,groups:k}},[d]),R=i?.role==="admin"||i?.role==="lockdown"||i?.role==="lockdown-admin";return m.useMemo(()=>({caps:p,overcurrent:S,scales:b,isActive:(b?.drive?.left??1)<1||(b?.drive?.right??1)<1||(b?.aux?.main??1)<1||(b?.aux?.side??1)<1,config:h,adminImmune:R}),[p,S,b,h,R])}function kA(n={},s,i=!1){if(i||!s?.drive)return n;const o=typeof s.drive.left=="number"?s.drive.left:1,f=typeof s.drive.right=="number"?s.drive.right:1;return o>=.999&&f>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*f)}}function MA(n={},s,i=!1){if(i||!s?.aux)return n;const o=typeof s.aux.main=="number"?s.aux.main:1,f=typeof s.aux.side=="number"?s.aux.side:1,d=typeof s.aux.vacuum=="number"?s.aux.vacuum:1;return o>=.999&&f>=.999&&d>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*f),vacuum:Math.round((n.vacuum??0)*d)}}const ig=m.createContext(null);function z0(n){return Object.fromEntries(Object.entries(n||{}).map(([s,i])=>[s,Array.isArray(i)?[...i]:[]]))}function qA(n,s){if(!n)return s;const i=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return sl(s,i,o)}function RA(n=[]){if(!Array.isArray(n)||n.length<3)return n;const s=n.slice(-3),[i,o,f]=s,d=i?.type==="drive"&&Number(i?.speeds?.left)===-300&&Number(i?.speeds?.right)===-300,h=o?.type==="pause"&&Number(o?.duration)===600,p=f?.type==="drive"&&Number(f?.speeds?.left)===0&&Number(f?.speeds?.right)===0;return!d||!h||!p?n:n.slice(0,-3)}function TA({children:n}){const[s,i]=m.useReducer(gA,T0),o=m.useRef(null),f=m.useRef(!1),d=m.useRef(T0.camera.angle),h=m.useRef(null),p=m.useRef(0),x=m.useRef(0),{value:g,save:y}=Fe("controls",{keymap:di,macros:sg}),{value:b}=Fe("page",{driveMacroBackoffEnabled:!0}),{value:S}=Fe("horn",is),R=typeof b?.driveMacroBackoffEnabled=="boolean"?b.driveMacroBackoffEnabled:!0,{session:N,homeAssistantSetState:k}=Le(),j=N?.assignment?.roverId??null,w=EA(j),E=m.useCallback(ae=>kA(ae,w.scales,w.adminImmune),[w.adminImmune,w.scales]),C=m.useCallback(ae=>MA(ae,w.scales,w.adminImmune),[w.adminImmune,w.scales]),M=SA({driveTransform:E,auxTransform:C}),B=m.useCallback(()=>{const ue=(N?.homeAssistant?.entities||[]).filter(be=>(be.type==="light"||be.type==="switch")&&be.available!==!1&&be.state!=="on");if(ue.length===0){f.current=!1;return}f.current=!0,ue.forEach(be=>{k(be.id,"on").catch(()=>{})}),f.current=!1},[N?.homeAssistant?.entities,k]);m.useEffect(()=>{i({type:"control/set-rover",payload:M.roverId})},[M.roverId]),m.useEffect(()=>{const ae=o.current;o.current=s.mode,ae!=="drive"&&s.mode==="drive"&&N?.homeAssistant?.entities?B():ae!=="drive"&&s.mode==="drive"&&(f.current=!0)},[s.mode,N?.homeAssistant?.entities,B]),m.useEffect(()=>{f.current&&N?.homeAssistant?.entities&&B()},[N?.homeAssistant?.entities,B]),m.useEffect(()=>{const ae={...di,...g?.keymap||{}};i({type:"control/set-keymap",payload:ae}),g?.macros&&i({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const ae=M.servoConfig;if(!ae){i({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const ue=typeof ae.minAngle=="number"?ae.minAngle:-45,be=typeof ae.maxAngle=="number"?ae.maxAngle:45,Me=typeof ae.homeAngle=="number"?ae.homeAngle:(ue+be)/2,le=typeof d.current=="number"?sl(d.current,ue,be):null,re=le??sl(Me,ue,be);i({type:"control/set-camera-config",payload:{config:ae,angle:re}}),d.current=re},[M.servoConfig]),m.useEffect(()=>{d.current=typeof s.camera.angle=="number"?s.camera.angle:d.current},[s.camera.angle]),m.useEffect(()=>{M.roverId&&M.enableSensorStream()},[M.roverId,M.enableSensorStream]);const H=m.useCallback(ae=>{i({type:"control/set-mode",payload:ae})},[]),_=m.useCallback(()=>{i({type:"control/record-intent"})},[]),K=m.useRef(s.drive.speeds),L=m.useRef(s.aux),U=m.useMemo(()=>JSON.stringify(w.scales),[w.scales]),F=m.useRef(0),te=m.useRef(0);m.useEffect(()=>{K.current=s.drive.speeds},[s.drive.speeds]),m.useEffect(()=>{L.current=s.aux},[s.aux]),m.useEffect(()=>{if(!M.roverId||w.adminImmune||!w.isActive)return;const ae=Math.max(0,Number(w?.config?.outputRateMs)||0),ue=typeof performance<"u"?performance.now():Date.now(),be=K.current||{left:0,right:0},Me=L.current||{main:0,side:0,vacuum:0},le=!!(be.left||be.right),re=!!(Me.main||Me.side||Me.vacuum);!le&&!re||(le&&ue-F.current>=ae&&(F.current=ue,M.sendDriveDirect(be)),re&&ue-te.current>=ae&&(te.current=ue,M.sendAuxMotors(Me)))},[U,w.adminImmune,w.config,w.isActive,M]);const fe=m.useCallback((ae,ue={})=>{const be=yA(ae,ue.speedOptions);i({type:"control/update-drive",payload:{...be,source:ue.source??null}}),_(),M.sendDriveDirect(be.speeds)},[M,_]),ce=m.useCallback((ae={})=>{const ue=M.sendAuxMotors(ae)??ae;i({type:"control/set-aux-motors",payload:ue}),_()},[M,_]),Y=m.useCallback((ae,ue)=>{if(!ae)return!1;const be=ki(ue);if(!be)return!1;const Me=z0(s.keymap);return Me[ae]=[be],i({type:"control/set-keymap",payload:Me}),y(le=>({...le??{},keymap:Me})),!0},[s.keymap,y]),T=m.useCallback(()=>{const ae=z0(di);i({type:"control/set-keymap",payload:ae}),y(ue=>({...ue??{},keymap:ae}))},[y]),X=m.useCallback(ae=>{if(!M.servoConfig)return;const ue=qA(M.servoConfig,ae);i({type:"control/set-camera-angle",payload:ue}),M.sendServoAngle(ue),d.current=ue,_()},[M,_]),J=m.useCallback((ae=0)=>{const ue=M.servoConfig;if(!ue)return;const be=typeof ae=="number"&&ae!==0?ae:ue.nudgeDegrees||1,Me=typeof d.current=="number"?d.current:typeof ue.homeAngle=="number"?ue.homeAngle:0;X(Me+be)},[M.servoConfig,X]),se=m.useCallback(()=>{const ae=M.servoConfig;if(!ae)return;const ue=typeof ae.homeAngle=="number"?ae.homeAngle:typeof ae.minAngle=="number"&&typeof ae.maxAngle=="number"?(ae.minAngle+ae.maxAngle)/2:0;X(ue)},[M.servoConfig,X]),de=m.useCallback(async ae=>{const ue=s.macros.find(Me=>Me.id===ae)||null;if(!ue)return;let be=ue;ae==="drive-sequence"?(B(),N?.homeAssistant?.entities||(f.current=!0),_(),R||(be={...ue,steps:RA(ue.steps)})):ae==="seek-dock"&&_(),await M.runMacroSteps(be)},[R,M,_,N?.homeAssistant?.entities,s.macros,B]),q=m.useCallback(()=>{i({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),M.sendDriveDirect({left:0,right:0}),M.sendAuxMotors({main:0,side:0,vacuum:0})},[M]),V=m.useCallback(ae=>{M.sendOiCommand(ae)},[M]),P=m.useCallback(ae=>{M.roverId&&M.emitCommand({type:"sensorStream",data:{sensorStream:{enable:ae}}})},[M]),ne=m.useCallback(ae=>{if(M.nightVision){if(typeof ae=="boolean"){const ue=ae?"off":"on";M.sendNightVision(ue)}else M.sendNightVision("toggle");_()}},[M,_]),pe=m.useCallback(()=>{ne()},[ne]),ie=m.useCallback(ae=>{const ue=typeof ae=="number"?ae:al;return i({type:"control/set-song-note",payload:ue}),ue},[]),oe=m.useCallback((ae,ue)=>M.sendSong(ae,ue),[M]),ve=m.useMemo(()=>{const ae=S??is,ue=ae.waveform==="sine"?"sine":"saw",Me=[...Array.isArray(ae.freqs)?ae.freqs:is.freqs,0,0,0,0].slice(0,4).map(le=>{const re=Number(le);return Number.isFinite(re)?re<=0?0:Math.min(5e3,Math.round(re)):0});return{waveform:ue,freqs:Me}},[S]),ye=m.useCallback(()=>{if(!M.horn)return;if(s.horn?.overheated||(s.horn?.heat??0)>=1||s.horn?.active)return!1;const ae=Date.now();return M.sendHorn({action:"start",...ve}),i({type:"control/set-horn-active",payload:!0}),p.current=ae,x.current=ae,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{xe()},mA),_(),!0},[i,ve,M,_,s.horn?.active,s.horn?.heat,s.horn?.overheated]),xe=m.useCallback(()=>{if(!M.horn)return;M.sendHorn({action:"stop"}),i({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const ae=Date.now(),ue=p.current||ae,be=Math.max(0,ae-ue);if(p.current=0,be>0){const Me=s.horn?.heat??0,le=be/1e3*Ju;let re=Math.max(0,Math.min(1,Me+le)),me=s.horn?.overheated??!1;re>=1&&(re=1,me=!0),i({type:"control/set-horn-heat",payload:{heat:re,overheated:me}})}},[i,M,s.horn?.heat,s.horn?.overheated,Ju]);m.useEffect(()=>{const ue=setInterval(()=>{const be=Date.now(),Me=x.current||be;x.current=be;const le=Math.min(1e3,Math.max(0,be-Me))/1e3,re=s.horn?.heat??0,me=!!s.horn?.active,we=!!s.horn?.overheated,et=le*(me?Ju:-.2);let dt=Math.max(0,Math.min(1,re+et)),ze=we;dt>=1?(dt=1,ze=!0,me&&xe()):ze&&dt<=hA&&(ze=!1),(dt!==re||ze!==we)&&i({type:"control/set-horn-heat",payload:{heat:dt,overheated:ze}})},100);return()=>clearInterval(ue)},[i,s.horn?.active,s.horn?.heat,s.horn?.overheated,xe]);const Ue=m.useCallback((ae,ue)=>{i({type:"control/register-input-state",payload:{source:ae,state:ue}})},[]),$e=m.useCallback(ae=>{i({type:"control/set-mic-ptt",payload:!!ae})},[]),Ne=m.useMemo(()=>({state:s,dispatch:i,pipeline:M,overcurrentLimiter:w,actions:{setMode:H,setDriveVector:fe,setAuxMotors:ce,setServoAngle:X,nudgeServo:J,goServoHome:se,runMacro:de,stopAllMotion:q,sendOiCommand:V,setSensorStream:P,setNightVision:ne,toggleNightVision:pe,updateKeyBinding:Y,resetKeyBindings:T,registerInputState:Ue,setSongNote:ie,sendSong:oe,startHorn:ye,stopHorn:xe,setMicPttActive:$e}}),[s,M,w,H,fe,ce,X,J,se,de,q,V,P,ne,pe,Y,T,Ue,ie,oe,ye,xe,$e]);return r.jsx(ig.Provider,{value:Ne,children:n})}function _t(){const n=m.useContext(ig);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const DA="data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAANAAAIpQBKSkpKSkpKXFxcXFxcXFxra2tra2tra3p6enp6enqJiYmJiYmJiZiYmJiYmJiYpqampqamprW1tbW1tbW1xMTExMTExMTT09PT09PT4uLi4uLi4uLx8fHx8fHx8f////////8AAABQTEFNRTMuMTAwBLkAAAAAAAAAABUgJAUYQQAB4AAACKVpqtMZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//ugxAAAwqQPR8CIwCh0BCj5jDwlIAAjW87wAACcOsAKPMk8ARj8w9OAWwNlV/gCgQMHEhAOVnFaNzWWAPI2zyjHjd8FAoKqyAa88AAAAABNjEd9CQOglIY9dtC+a51bGZrZgTewD3c+AAYx5hxIMheIcudKAyaykG1/h5EsPB0iTEFNRTMuMTAwqqqqqqrIBZqvAAAAAC9JXFIAHrCgAp0D0hUYOInIluqg1TNdKCzMeAAFQCKKsxUmVfireKILLBgSVgb4qBVtPWpMQU1FMy4xMDCqqqqqqqqqqqqqqqqpApm/AAAAAC7QYaHPHoCjkCysmc+QY9NNWRbKE+mqowNobwAAoSQQMLGChDlOrKMqVMC/6xy/CXbFaL7AZUxBTUUzLjEwMFVVVVVVVVVVVacDqZ8AAAAAMgzaYFBPNgIOnVCQfFfwmBBhLVNJQSdxdQRofwAGxF9xAAYs4AZDuE87li0YCASIBwaCiXUj+2BqTEFNRTMuMTAwqqqqqqqqlwOonwAAAAAtkABQSEZ1INNDgx8HeaaLCXiu5dqSciylQNXjv8GdmACQ5ogYKbnsmxkoChog+w9IhU6GsgzCIQBSxFpMQQAAMBiHjgAAAAv6FQQILmJmGLltnax9HszIVEAoEq1p8olpcPLlGpXFastuWosKNFlmlqADJbwAEFRI4iJJy0oDumUW//sgxOEAw5wfU8fnAGBvg6n5nDxUh7QuwcEzkK5Ztz7AZUxBTUUzLjEwMFVVVVVVVZUAhd8AAAAALZAAamQMWKtC7Avib0WLplt2IAp0SKV0pFFxCADLX6AIPFrWJIBQqPGW/x0QDTRLGaQYCRAZzKeoU6uqTEFN6AB3n/7wAAAxq//7EMT0AMPUHU/MawJgc4PpuYy8VQZjocBw2OgQQyQyECnbABEUC/ZoM0J56Jm0tqzNJaq8KospqUAQ5/QBghnCqQAhR4Mz1D1gJPstYsI1sYIg079I5cYjY6pMQU1FMy4xMDCqqqqq//sQxPUAw+AdT8zvAih6hCk5nWBFqqqWAFOf4AAAAEAIQZPkMcwUzFVE51cSBjIHpJRIEIjWgGar9VhgCUvwAFAUMk0RCpMkwXjPQDcoLBU+n5RuR4ZrPQLPckxBTUUzLjEwMKqqqqr/+xDE9oDEAB1NzG8CKIGEKPmd5EWqxgBWn9AAAAAKIiC5GcLJIczCEvNbWsF31jo4Bw0rXktvJF5YRyABlj+ABIQ2RGsHgdc0XsPntoEDUzaQOjTBqblFPUE1TEFNRckAt68AAAAALv/7EMT4AMQIHU3M7wIojwUo+Y2MZfAgKcwITAQIYN1TosJeLtDA0ubWNrFSADJoln4AC0hVaLiIIUChs+4HST4BgCpQHITPMBQkEnj73ORZfylh+sRLEGUiNIpMQU1FMy4xMDCqqqqq//sQxP6AxlgtK+13Yih3hCj5neBNqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrIkT7UNAZ7NS7yMqcihSKLMn8DlKYq8ZdPCVEoJBuWqkxBTUUzLjEwMKqqqqr/+xDE+ADEXCVHzGjDIIQEqLm9PIWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT+AMWoL0XNcwJoiASoeY3gVaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxPgAxHAnRcxvAmiBBKj5jehEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xDE+IDEmCVDzPMCKH6EqLmNYE2qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT9gEPgI0vMZwQgvYWlPY5gFaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxOYDw+gpIIfgwWgAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=",rg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function _A({children:n}){const s=pn(),{session:i,pushAlert:o}=Le(),{value:f}=Fe("audio",St),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,y]=m.useState(!1),b=m.useRef(null),S=m.useRef(null),R=m.useRef(null),N=m.useRef(new Map),k=m.useRef(new Map),j=m.useRef({isTyping:!1,lastSent:0}),w=Number.isFinite(f?.masterVolume)?f.masterVolume:St.masterVolume,E=Number.isFinite(f?.alertVolume)?f.alertVolume:St.alertVolume,C=Math.max(0,Math.min(1,w*E)),M=m.useCallback(()=>{const Y=Array.from(N.current.values()).sort((T,X)=>T.lastUpdate-X.lastUpdate).map(T=>T.payload);x(Y)},[]),B=m.useCallback(Y=>!Y||typeof Y!="object"?null:Y.typingId?Y.typingId:Y.fromDiscord?`discord:${Y.discordUserId||Y.discordUserName||Y.nickname||"unknown"}`:`socket:${Y.socketId||Y.nickname||"unknown"}`,[]);m.useEffect(()=>{R.current=new Audio(DA),R.current.volume=C,R.current.load()},[C]);const H=m.useCallback(()=>{const Y=R.current;Y&&(Y.volume=C,Y.currentTime=0,Y.play().catch(()=>{}))},[C]);m.useEffect(()=>{function Y(T={}){h(X=>[...X.slice(-99),T]),!(T?.socketId&&i?.socketId&&T.socketId===i.socketId)&&(H(),o?.({kind:"chat",payload:T,id:`chat-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return s.on("chat:message",Y),()=>{s.off("chat:message",Y)}},[H,i?.socketId,s]),m.useEffect(()=>{function Y(T={}){const X=B(T);if(!X)return;const J=Date.now();if(T?.socketId&&i?.socketId&&T.socketId===i.socketId){T.isTyping||(N.current.delete(X),M());return}if(T.isTyping){N.current.set(X,{payload:T,expiresAt:J+6e3,lastUpdate:J});const se=k.current.get(X)||0;J-se>=2500&&(k.current.set(X,J),o?.({kind:"chat-typing",payload:T,id:`chat-typing-${X}-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:J}))}else N.current.delete(X);M()}return s.on("chat:typing",Y),()=>{s.off("chat:typing",Y)}},[o,M,B,i?.socketId,s]),m.useEffect(()=>{const Y=setInterval(()=>{const T=Date.now();let X=!1;N.current.forEach((J,se)=>{J.expiresAt<=T&&(N.current.delete(se),X=!0)}),X&&M()},2e3);return()=>clearInterval(Y)},[M]),m.useEffect(()=>{function Y(T=[]){Array.isArray(T)&&h(X=>{if(X.length===0)return T.slice(-100);const J=new Set(T.map(de=>de?.id));return[...T,...X.filter(de=>de?.id&&!J.has(de.id))].slice(-100)})}return s.on("chat:init",Y),()=>{s.off("chat:init",Y)}},[s]);const _=m.useCallback(Y=>{const T=!!Y,X=Date.now(),J=j.current,se=!T&&J.isTyping;!(T&&(!J.isTyping||X-J.lastSent>=3500))&&!se||(j.current={isTyping:T,lastSent:X},s.emit("chat:typing",{isTyping:T}))},[s]),K=m.useCallback((Y,T=null)=>new Promise((X,J)=>{s.emit("chat:send",{text:Y,tts:T},(se={})=>{se.error?J(new Error(se.error)):X(se)})}),[s]),L=m.useCallback((Y,T={})=>{(T?.target==="hud"?"hud":"panel")==="hud"?S.current=Y:b.current=Y},[]),U=m.useCallback(()=>{y(!0),(S.current||b.current)?.focus()},[]),F=m.useCallback(()=>{y(!1),S.current?.blur(),b.current?.blur()},[]),te=m.useCallback(()=>y(!0),[]),fe=m.useCallback(()=>y(!1),[]),ce=m.useMemo(()=>({messages:d,sendMessage:K,focusChat:U,blurChat:F,registerInputRef:L,onInputFocus:te,onInputBlur:fe,setTypingActive:_,typing:p,isChatFocused:g,selfSocketId:i?.socketId||null}),[F,U,g,d,fe,te,L,K,i?.socketId,_,p]);return r.jsx(rg.Provider,{value:ce,children:n})}function Pf(){const n=m.useContext(rg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let og=!1;function Pu(n){og=!!n}function U0(){return og}const OA=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function cg(n){if(!n||n.nodeType!==1)return!1;const s=n.tagName;if(s==="TEXTAREA"||n.isContentEditable)return!0;if(s!=="INPUT")return!1;const i=n.type?n.type.toLowerCase():"";return OA.has(i)}function BA(){return typeof document>"u"?!1:cg(document.activeElement)}const Wu="keyboard",ef={x:0,y:0,boost:!1},tf={main:0,side:0,vacuum:0},H0=Jf[0],V0=Jf[1],Wf=5,xi=500,gi=1,ed=100;function nf(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):s}function LA(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(Wf,Math.min(xi,i)):s}function ug(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(gi,Math.min(ed,i)):s}function zA(n){const i=(ug(n,n)-gi)/(ed-gi),o=xi-i*(xi-Wf);return Math.round(o)}function UA(n){const s=LA(n,n),i=(xi-s)/(xi-Wf),o=gi+i*(ed-gi);return Math.round(o)}function HA(n){return cg(n?.target)}function ft(n,s){if(!n||n.size===0)return!1;for(const i of s)if(n.has(i))return!0;return!1}function VA(n,s){const i=ft(s.driveForward,n),o=ft(s.driveBackward,n),f=ft(s.driveLeft,n),d=ft(s.driveRight,n),h=ft(s.boostModifier,n),p=ft(s.slowModifier,n);let x=0;i&&!o?x=1:o&&!i&&(x=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const y=p?.4:1;return{x:g*y,y:x*y,boost:h&&!p}}function $A(n,s){if(ft(s.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=ft(s.auxMainForward,n)?127:ft(s.auxMainReverse,n)?-127:0,f=ft(s.auxSideForward,n)?127:ft(s.auxSideReverse,n)?-70:0,d=ft(s.auxVacuumFast,n)?127:ft(s.auxVacuumSlow,n)?50:0;return{main:o,side:f,vacuum:d}}function GA(){const{state:n,actions:{setMode:s,setDriveVector:i,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:h,registerInputState:p,toggleNightVision:x,startHorn:g,stopHorn:y,setMicPttActive:b,setSongNote:S,sendSong:R}}=_t(),{session:N,homeAssistantSetState:k}=Le(),{focusChat:j,blurChat:w,isChatFocused:E}=Pf(),{value:C}=Fe("inputs",kn),M=m.useMemo(()=>wA(n.keymap),[n.keymap]),B=m.useMemo(()=>{const ie=new Set;return Object.values(M).forEach(oe=>{oe&&oe.forEach(ve=>ie.add(ve))}),ie},[M]),H=m.useMemo(()=>{const ie=kn.keyboard,oe=C?.keyboard??{};return{baseSpeed:nf(oe.baseSpeed,ie.baseSpeed),turboSpeed:nf(oe.turboSpeed,ie.turboSpeed),precisionSpeed:nf(oe.precisionSpeed,ie.precisionSpeed)}},[C?.keyboard]),_=m.useMemo(()=>{const ie=kn.keyboard,oe=C?.keyboard??{},ve=ug(typeof oe.tiltSpeed=="number"?oe.tiltSpeed:typeof oe.tiltIntervalMs=="number"?UA(oe.tiltIntervalMs):ie.tiltSpeed,ie.tiltSpeed);return zA(ve)},[C?.keyboard]),K=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),L=m.useRef(new Set),U=m.useRef(ef),F=m.useRef(tf),te=m.useRef(null),fe=m.useRef(null),ce=m.useRef(!1),Y=m.useCallback(()=>{const ie=new Set(L.current);ft(M.boostModifier,ie);const ve=ft(M.slowModifier,ie)?{baseSpeed:H.precisionSpeed,boostSpeed:H.precisionSpeed}:{baseSpeed:H.baseSpeed,boostSpeed:H.turboSpeed},ye=VA(ie,M),xe=$A(ie,M);(ye.x!==U.current.x||ye.y!==U.current.y||ye.boost!==U.current.boost)&&(U.current=ye,i(ye,{source:Wu,speedOptions:ve})),(xe.main!==F.current.main||xe.side!==F.current.side||xe.vacuum!==F.current.vacuum)&&(F.current=xe,o(xe)),p(Wu,{keys:Array.from(ie),vector:ye,aux:xe})},[M,H,p,o,i]),T=m.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=null)},[]),X=m.useCallback(()=>{const ie=new Set(L.current),oe=ft(M.cameraUp,ie),ve=ft(M.cameraDown,ie);return(oe?1:0)-(ve?1:0)},[M]),J=m.useCallback(()=>{if(X()===0){T();return}if(te.current)return;const oe=()=>{const ve=X();if(ve===0){T();return}f(ve*K),te.current=setTimeout(oe,_)};te.current=setTimeout(oe,0)},[X,f,_,K,T]),se=m.useCallback(()=>{fe.current&&(clearTimeout(fe.current),fe.current=null)},[]),de=m.useCallback(()=>{const ie=new Set(L.current),oe=ft(M.songNoteUp,ie),ve=ft(M.songNoteDown,ie);return(oe?1:0)-(ve?1:0)},[M]),q=m.useCallback(ie=>{if(ie===0)return;let ve=(typeof n.song?.note=="number"?n.song.note:al)+ie;ve>V0?ve=H0:ve<H0&&(ve=V0);const ye=S(ve);R([{note:ye,duration:Cf}],{slot:0})},[R,S,n.song?.note]),V=m.useCallback(()=>{if(de()===0){se();return}if(fe.current)return;const oe=()=>{const ve=de();if(ve===0){se();return}q(ve),fe.current=setTimeout(oe,dA)};fe.current=setTimeout(oe,0)},[de,se,q]),P=m.useCallback(()=>{L.current.clear(),U.current=ef,F.current=tf,T(),se(),ce.current&&(ce.current=!1,y()),b(!1),h(),p(Wu,{keys:[],vector:ef,aux:tf})},[p,b,h,y,T,se]),ne=m.useCallback(ie=>{const oe=N?.homeAssistant;if(!oe?.enabled||!oe?.connected||oe?.lightPolicy?.locked||oe?.lightPolicy?.lockedOn)return;const ye=(oe.entities||[]).filter(xe=>(xe.type==="light"||xe.type==="switch")&&xe.available!==!1&&xe.state!=="unavailable");if(ye.length!==0){if(ie==="on"){const xe=ye.find(Ue=>Ue.state!=="on");xe&&k(xe.id,"on").catch(()=>{});return}if(ie==="off")for(let xe=ye.length-1;xe>=0;xe-=1){const Ue=ye[xe];if(Ue.state==="on"){k(Ue.id,"off").catch(()=>{});break}}}},[k,N?.homeAssistant]);m.useEffect(()=>{function ie(ye){if(U0()||HA(ye))return;const xe=O0(ye);if(xe.length===0)return;const Ue=new Set(xe);if(ft(M.chatFocus,Ue)){ye.preventDefault(),P(),E||j();return}xe.some(Ne=>B.has(Ne))&&ye.preventDefault();const $e=xe.filter(Ne=>!L.current.has(Ne));if($e.forEach(Ne=>L.current.add(Ne)),$e.length>0)if($e.some(Ne=>M.driveMacro?.has(Ne)))s("drive"),d("drive-sequence");else if($e.some(Ne=>M.dockMacro?.has(Ne)))s("dock"),d("seek-dock");else if($e.some(Ne=>M.nightVisionToggle?.has(Ne)))x();else if($e.some(Ne=>M.hornHonk?.has(Ne))){if(!ce.current){const Ne=g();ce.current=!!Ne}}else $e.some(Ne=>M.micPtt?.has(Ne))?b(!0):$e.some(Ne=>M.homeAssistantOn?.has(Ne))?ne("on"):$e.some(Ne=>M.homeAssistantOff?.has(Ne))&&ne("off");J(),V(),Y()}function oe(ye){if(U0())return;O0(ye).forEach(Ue=>L.current.delete(Ue)),ce.current&&!ft(M.hornHonk,L.current)&&(ce.current=!1,y()),ft(M.micPtt,L.current)||b(!1),J(),V(),Y()}function ve(){P()}return window.addEventListener("keydown",ie,{capture:!0}),window.addEventListener("keyup",oe,{capture:!0}),window.addEventListener("blur",ve),()=>{window.removeEventListener("keydown",ie,{capture:!0}),window.removeEventListener("keyup",oe,{capture:!0}),window.removeEventListener("blur",ve)}},[B,w,Y,J,V,j,E,M.chatFocus,M.dockMacro,M.driveMacro,M.hornHonk,M.micPtt,P,d,b,s,h,se,g,y,ne]);const pe=m.useRef(P);return m.useEffect(()=>{pe.current=P},[P]),m.useEffect(()=>{pe.current()},[n.roverId]),m.useEffect(()=>{ce.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{T(),se()},[T,se]),null}const YA=1.6;function fg(n){if(!n)return"unknown::none::0::0";const s=n.id||"unknown",i=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,f=Array.isArray(n.buttons)?n.buttons.length:0;return`${s}::${i}::${o}::${f}`}function FA(n){return JSON.parse(JSON.stringify(n??{}))}function dg(n,s){const i=FA(s);return i.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},i}function ls(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function oi(n,s){if(!n)return 0;const i=Math.abs(n);return s==="expo"?Math.sign(n)*Math.pow(i,YA):n}function af(n,s){const i=Math.abs(n);if(i<=s)return 0;const o=(i-s)/(1-s);return Math.sign(n)*o}function XA(n,s,i){const o=Math.hypot(n,s);if(o<=i)return{x:0,y:0};const d=(o-i)/(1-i)/o;return{x:n*d,y:s*d}}function ro(n,s){if(!n||!Array.isArray(n.axes))return null;const i=n.axes[s];return Number.isFinite(i)?ls(i):null}function Mf(n,s){if(!n||!Array.isArray(n.buttons))return null;const i=n.buttons[s];if(!i)return null;const o=typeof i.value=="number"?i.value:i.pressed?1:0;return{pressed:!!(i.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function sf(n,s=[]){for(const i of s)if(i){if(i.kind==="axis"){const o=ro(n,i.index);if(o===null)continue;return{value:i.invert?-o:o,source:i}}if(i.kind==="buttonAxis"){const o=Mf(n,i.index);if(!o)continue;return{value:ls(o.value),source:i}}}return{value:0,source:null}}function QA(n,s=[]){for(const i of s){if(!i||i.kind!=="axisPair")continue;const o=ro(n,i.x),f=ro(n,i.y);if(o===null||f===null)continue;const d=i.invertX?-o:o,h=i.invertY?-f:f;return{x:d,y:h,source:i}}return{x:0,y:0,source:null}}function ts(n,s=[]){for(const i of s)if(i){if(i.kind==="button"){const o=Mf(n,i.index);if(!o)continue;return{pressed:o.pressed,source:i}}if(i.kind==="axisButton"){const o=ro(n,i.index);if(o===null)continue;const f=i.direction||1,d=typeof i.threshold=="number"?i.threshold:.6;return{pressed:o*f>d,source:i}}if(i.kind==="buttonAxis"){const o=Mf(n,i.index);if(!o)continue;return{pressed:o.value>.5,source:i}}}return{pressed:!1,source:null}}function mg(n,s){const i=s?.bindings??{},o=s?.calibration??{},f=i.drive??{},d=QA(n,f.sources);let h=ls(d.x),p=ls(d.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=XA(h,p,x);h=oi(g.x,o.driveCurve),p=oi(g.y,o.driveCurve);const y=i.cameraTilt??{},b=sf(n,y.sources),S=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let R=af(ls(b.value),S);R=oi(R,o.cameraCurve);const N=Math.min(Math.max(o.auxDeadzone??.05,0),.6),k=i.mainBrush??{},j=sf(n,k.sources);let w=af(ls(j.value),N);w=oi(w,o.auxCurve);const E=i.sideBrush??{},C=sf(n,E.sources);let M=af(ls(C.value),N);M=oi(M,o.auxCurve);const B=ts(n,i.vacuum?.sources),H=ts(n,i.allAux?.sources),_=ts(n,i.mainReverse?.sources),K=ts(n,i.sideReverse?.sources),L=ts(n,i.driveMacro?.sources),U=ts(n,i.dockMacro?.sources),F=ts(n,i.nightVisionToggle?.sources);return{driveVector:{x:h,y:p,boost:!1},cameraAxis:R,auxAxis:{main:w,side:M},buttons:{vacuum:B.pressed,allAux:H.pressed,mainReverse:_.pressed,sideReverse:K.pressed,driveMacro:L.pressed,dockMacro:U.pressed,nightVisionToggle:F.pressed},sources:{drive:d.source,cameraTilt:b.source,mainBrush:j.source,sideBrush:C.source,vacuum:B.source,allAux:H.source,mainReverse:_.source,sideReverse:K.source,driveMacro:L.source,dockMacro:U.source,nightVisionToggle:F.source}}}const no=new Set;let nl=null,oo={pads:[],timestamp:0};function KA(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function ZA(n){return{index:n.index,id:n.id,mapping:n.mapping,connected:n.connected!==!1,timestamp:n.timestamp,axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0})),signature:fg(n)}}function IA(){oo={pads:KA().map(ZA),timestamp:typeof performance<"u"?performance.now():Date.now()},no.forEach(s=>s(oo))}function hg(){IA(),nl=requestAnimationFrame(hg)}function JA(){nl||(nl=requestAnimationFrame(hg))}function PA(){nl&&(cancelAnimationFrame(nl),nl=null)}function pg(n){return no.add(n),JA(),n(oo),()=>{no.delete(n),no.size===0&&PA()}}function WA(){const[n,s]=m.useState(oo);return m.useEffect(()=>pg(s),[]),n}const Ps="gamepad",ns={x:0,y:0,boost:!1},as={main:0,side:0,vacuum:0},ej=100,tj=100;function lf(n,s){return n&&s&&n.x===s.x&&n.y===s.y&&n.boost===s.boost}function rf(n,s){return n&&s&&n.main===s.main&&n.side===s.side&&n.vacuum===s.vacuum}function nj(n){return n?Math.hypot(n.x||0,n.y||0):0}function aj(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function sj(n,s){if(!n||n.length===0)return null;if(s){const i=n.find(o=>o.signature===s);if(i)return i}return n[0]}function lj(){const{state:n,actions:{setMode:s,setDriveVector:i,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:h,registerInputState:p}}=_t(),{value:x,save:g}=Fe("gamepad",Da),y=m.useRef(new Set),b=m.useRef(ns),S=m.useRef(as),R=m.useRef({main:!1,side:!1}),N=m.useRef(new Map),k=m.useRef(0),j=m.useRef(0),w=m.useRef(0),E=m.useRef(null),C=m.useCallback(_=>{const K=_.signature??fg(_);x?.profiles?.[K]||y.current.has(K)||(y.current.add(K),g(L=>{const U=L??Da;if(U.profiles?.[K])return U;const F=U?.defaults?.profile??sa,te=dg(_,F);return{...U,profiles:{...U.profiles??{},[K]:te}}}))},[x?.profiles,g]),M=m.useCallback((_,K)=>{const L=N.current.get(_)||!1;return N.current.set(_,K),K&&!L},[]),B=m.useCallback((_,K)=>{const L=n.camera?.config;if(!L)return;const U=typeof performance<"u"?performance.now():Date.now(),F=K?.cameraMode??"absolute",te=Math.max(1,Math.min(180,K?.cameraSensitivity??60));if(F==="velocity"){const X=Math.min(50,U-w.current||16),J=_*te*(X/1e3);if(Math.abs(J)<.01)return;const de=(typeof E.current=="number"?E.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof L.homeAngle=="number"?L.homeAngle:0)+J;f(de),E.current=de,w.current=U;return}const fe=typeof L.minAngle=="number"?L.minAngle:-45,ce=typeof L.maxAngle=="number"?L.maxAngle:45,Y=typeof L.homeAngle=="number"?L.homeAngle:(fe+ce)/2,T=_<0?Y+_*(Y-fe):Y+_*(ce-Y);typeof E.current=="number"&&Math.abs(E.current-T)<.35&&U-w.current<80||(w.current=U,E.current=T,f(T))},[f,n.camera?.angle,n.camera?.config]),H=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>pg(_=>{const K=sj(_.pads,H);if(!K){lf(b.current,ns)||(b.current=ns,i(ns,{source:Ps})),rf(S.current,as)||(S.current=as,o(as)),N.current=new Map,R.current={main:!1,side:!1},k.current=0,j.current=0,p(Ps,{connected:!1});return}if(BA()){lf(b.current,ns)||(b.current=ns,i(ns,{source:Ps})),rf(S.current,as)||(S.current=as,o(as)),N.current=new Map,R.current={main:!1,side:!1},p(Ps,{connected:!0,blocked:!0});return}C(K);const L=K.signature,U=x?.profiles?.[L]??x?.defaults?.profile??sa,F=mg(K,U);if(!lf(F.driveVector,b.current)){const J=typeof performance<"u"?performance.now():Date.now();(nj(F.driveVector)<.02||J-k.current>=ej)&&(b.current=F.driveVector,k.current=J,i(F.driveVector,{source:Ps}))}const te=U.calibration?.auxSideScale??.55,fe=Math.round(Math.min(Math.abs(F.auxAxis.main),1)*127),ce=Math.round(Math.min(Math.abs(F.auxAxis.side),1)*127),Y=R.current.main?-fe:fe,T=R.current.side?-Math.round(ce*te):Math.round(ce*te);let X={main:F.auxAxis.main!==0?Y:0,side:F.auxAxis.side!==0?T:0,vacuum:F.buttons.vacuum?127:0};if(F.buttons.allAux&&(X={main:127,side:127,vacuum:127}),!rf(X,S.current)){const J=typeof performance<"u"?performance.now():Date.now();(aj(X)||J-j.current>=tj)&&(S.current=X,j.current=J,o(X))}F.buttons.mainReverse&&M("mainReverse",!0)?R.current.main=!R.current.main:F.buttons.mainReverse||M("mainReverse",!1),F.buttons.sideReverse&&M("sideReverse",!0)?R.current.side=!R.current.side:F.buttons.sideReverse||M("sideReverse",!1),F.buttons.driveMacro&&M("driveMacro",!0)?(s("drive"),d("drive-sequence")):F.buttons.driveMacro||M("driveMacro",!1),F.buttons.dockMacro&&M("dockMacro",!0)?(s("dock"),d("seek-dock")):F.buttons.dockMacro||M("dockMacro",!1),F.buttons.nightVisionToggle&&M("nightVisionToggle",!0)?h():F.buttons.nightVisionToggle||M("nightVisionToggle",!1),Math.abs(F.cameraAxis)>.001&&B(F.cameraAxis,U.calibration),p(Ps,{connected:!0,signature:L,id:K.id,index:K.index,axes:K.axes,buttons:K.buttons,drive:F.driveVector,aux:X,cameraAxis:F.cameraAxis,bindings:F.sources})}),[H,C,x?.defaults?.profile,x?.profiles,M,B,p,d,o,i,s,h]),null}function xg(n){const s=n?.sensors||{},i=s.oiMode?.label||"Unknown",o=i.toLowerCase(),f=s.chargingState?.label||"",d=!!s.chargingSources?.homeBase,h=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:h,dockedNotCharging:d&&!h,dockingInProgress:!d&&!h&&o==="passive",oiLabel:i,chargingLabel:f}}function gg(n){const s=cl(n);return m.useMemo(()=>xg(s),[s])}function Ws({label:n,value:s,tone:i="neutral"}){const o=i==="good"?"border-emerald-200 bg-emerald-600 text-white":i==="warn"?"border-amber-200 bg-amber-600 text-white":i==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return r.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:r.jsx("span",{className:"text-base font-semibold md:text-lg",children:s})})}function $0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function of({label:n,tone:s}){const i=s==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":s==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return r.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${i}`,children:n})}function ij({instructions:n,onConfirm:s,onCancel:i,pending:o}){return r.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),r.jsx("p",{className:"text-sm text-slate-200",children:n.summary}),r.jsx(qf,{steps:n.steps,tone:"indigo"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[r.jsx("button",{type:"button",onClick:i,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),r.jsx("button",{type:"button",disabled:o,onClick:s,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Docking…":"Confirm Dock"})]})]})})}function vg({layout:n="desktop",expand:s=!1,fill:i=!1,driveDockState:o,compactHeightClass:f=""}){const d=n==="mobile",{state:{roverId:h,keymap:p},actions:x}=_t(),g=cl(h),y=o??xg(g),{driving:b,docked:S,charging:R,dockingInProgress:N}=y,[k,j]=m.useState(null),[w,E]=m.useState(!1),[C,M]=m.useState(!1),B=!h||k!==null,H=!h||k!==null,_=Sn(p?.driveMacro?.[0]),K=Sn(p?.dockMacro?.[0]),L={summary:"You are about to trigger an automatic docking attempt! To have a successful dock:",steps:["Line up the rover straight in front of the dock","Make sure the rover is about one foot or half a meter away from the dock","Press Confirm Dock to begin the docking process"]},U="Click this button to initate auto-dock.",F={summary:"You must enable driving mode before you can move the rover.",steps:["Press the keybind or tap this button to enable driving mode","Once ready (should be instant), this dialog will change, and you will be able to move"]},te=S?"Docked":"Undocked",fe=S?"good":"bad",ce=R?"Charging":S?"Charging in 5s":"—",Y=R?"good":S?"warn":"bad",T=async()=>{if(!(!h||k)){j("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(ue){alert(ue.message)}finally{j(null)}}},X=async()=>{if(!(!h||k)){E(!1),M(!1),j("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(ue){alert(ue.message)}finally{j(null)}}},J=async()=>{if(!(!h||k)){j("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch(ue){alert(ue.message)}finally{j(null),E(!1),M(!1)}}},se=()=>{H||(M(!0),E(!0))},de="flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-0.75 py-0.75 text-slate-100 shadow-md transition hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 select-none no-touch-select",q="text-center",V="items-center justify-between",P="items-center justify-center",ne=d?"text-sm font-semibold":"",pe="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",ie="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",oe="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",ve="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",xe=s||N,Ue=xe?"h-full flex-1":i?"flex-1":"",$e=d&&!xe?f:"",Ne=d&&!xe?P:V,ae=d&&!xe&&b&&S;if(!b&&!N)return r.jsxs("button",{type:"button",onClick:X,onContextMenu:ue=>ue.preventDefault(),disabled:B,className:`${de} ${Ue} ${$e} ${q} ${Ne} ${ne} ${pe}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[_?r.jsx($0,{label:_}):null,r.jsx(of,{label:"Click to start",tone:"emerald"})]}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:F.summary}),r.jsx(qf,{steps:F.steps,tone:"emerald"})]}):null]}),xe?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Ws,{label:"Dock",value:te,tone:fe}),r.jsx(Ws,{label:"Charge",value:ce,tone:Y})]}):null]});if(N){const ue={summary:"If the rover is failing to dock, click to drive and try again.",steps:["The rover should be slowly wiggling towards the dock","If it is obviously not working, press this button to enter driving mode and try again"]};return r.jsxs("button",{type:"button",disabled:B,onClick:T,onContextMenu:be=>be.preventDefault(),className:`${de} ${Ue} ${$e} ${q} ${Ne} ${ne} ${ie}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),xe?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(of,{label:"Return to driving mode",tone:"emerald"})}):null]}),xe?r.jsx("p",{className:"text-sm text-amber-50/90",children:ue.summary}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Ws,{label:"Dock",value:te,tone:fe}),r.jsx(Ws,{label:"Charge",value:ce,tone:Y})]}),d?null:r.jsx(qf,{steps:ue.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:H,onClick:se,onContextMenu:ue=>ue.preventDefault(),className:d?`flex w-full ${de} ${$e} ${q} ${Ne} ${ne} ${ae?ve:oe}`:`${de} ${Ue} ${q} ${V} ${ne} ${oe}`,children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:ae?"Docked!":"Dock and Charge"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[K?r.jsx($0,{label:K}):null,r.jsx(of,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!d&&xe&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:U}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Ws,{label:"Dock",value:te,tone:fe}),r.jsx(Ws,{label:"Charge",value:ce,tone:Y})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),C||!d&&w?r.jsx(ij,{instructions:L,pending:k==="dock",onCancel:()=>{M(!1),E(!1)},onConfirm:J}):null]})}function qf({steps:n,tone:s="emerald"}){const i=s==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":s==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=s==="emerald"?"text-emerald-200":s==="amber"?"text-amber-200":"text-indigo-200";return r.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${i}`,children:n.map((f,d)=>r.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[r.jsxs("div",{className:"flex items-start",children:[r.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[d+1,"."]}),r.jsx("span",{className:"align-top",children:f})]}),d<n.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},f))})}function cf(n){return typeof n=="boolean"}function yg({nightVisionOn:n,disabled:s,onToggle:i,keyLabel:o,className:f="",heightClass:d=""}){const[h,p]=m.useState(cf(n)?n:null);m.useEffect(()=>{cf(n)&&p(n)},[n]);const x=cf(h),g=x?h:!1,y=x?g?"On":"Off":"—",b=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",S=()=>{if(s)return;const N=x?!g:!0;p(N),i?.(N)},R=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",g?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",d,f].filter(Boolean).join(" "),[f,g,d]);return r.jsxs("button",{type:"button",onClick:S,onContextMenu:N=>N.preventDefault(),disabled:s,"aria-pressed":g,className:R,children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?r.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:y})]})}function uf(n){const s=Number(n);return!Number.isFinite(s)||s<=0?0:Math.min(5e3,Math.round(s))}function bg({disabled:n,onStart:s,onStop:i,keyLabel:o,active:f,heat:d=0,className:h="",defaultShowSettings:p=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[y,b]=m.useState(!1),[S,R]=m.useState(p),{value:N,save:k}=Fe("horn",is),[j,w]=m.useState(N?.waveform||is.waveform),[E,C]=m.useState(()=>[...Array.isArray(N?.freqs)?N.freqs:is.freqs,0,0,0,0].slice(0,4).map(T=>uf(T)));m.useEffect(()=>{w(N?.waveform||is.waveform),Array.isArray(N?.freqs)&&C([...N.freqs,0,0,0,0].slice(0,4).map(Y=>uf(Y)))},[N?.freqs,N?.waveform]);const M=!!f,B=Math.max(0,Math.min(1,Number(d)||0)),H=m.useMemo(()=>["group relative flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-1 py-1.5 text-xs font-semibold select-none no-touch-select",M?"border-fuchsia-300/70 bg-fuchsia-700 text-fuchsia-50":"border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800","disabled:opacity-50",h].filter(Boolean).join(" "),[h,M]),_=()=>{n||y||(b(!0),s?.())},K=()=>{y&&(b(!1),i?.())};m.useEffect(()=>{!M&&y&&b(!1)},[M,y]);const L=j==="sine"?"sine":"saw",U=m.useCallback(Y=>{const T=Y.target.value==="sine"?"sine":"saw";w(T),k(X=>({...X??{},waveform:T}))},[k]),F=m.useCallback((Y,T)=>{C(X=>{const J=[...X];return J[Y]=uf(T),k(se=>({...se??{},freqs:J})),J})},[k]),te=Y=>{if(n)return;const T=Y.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(Y.preventDefault(),_())},fe=Y=>{const T=Y.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(Y.preventDefault(),K())},ce=x?r.jsx("button",{type:"button",onClick:Y=>{Y.preventDefault(),R(T=>!T)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:S?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":y,onPointerDown:te,onPointerUp:fe,onPointerLeave:K,onPointerCancel:K,onContextMenu:Y=>Y.preventDefault(),onBlur:K,className:H,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${B*100}%, rgba(0,0,0,0) ${B*100}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${M?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),r.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[r.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[r.jsx("span",{children:"Horn"}),o?r.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),ce,r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${M?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:M?"Honk":"Hold"})]}),S?g?r.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:L,onChange:U,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:E.map((Y,T)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:Y,onChange:X=>F(T,X.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))})]}):r.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:L,onChange:U,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),E.map((Y,T)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:Y,onChange:X=>F(T,X.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))]}):null]})}function Yr(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function G0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Sg({value:n,min:s,max:i,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:h,onCommit:p,throttleMs:x=0,disabled:g=!1,keyDownLabel:y,keyUpLabel:b,className:S="",labelRowClass:R="",labelClass:N="",valueClass:k="",sliderClass:j="",endpointClass:w="",endpointLabelClass:E="",accentClass:C="",showValue:M=!0,showEndpoints:B}){const H=d==="vertical",K=typeof B=="boolean"?B:!H,[L,U]=m.useState(n),F=m.useRef(!1),te=m.useRef(null);m.useEffect(()=>{F.current||U(n)},[n]),m.useEffect(()=>()=>{te.current&&clearTimeout(te.current)},[]);const fe=J=>{if(h){if(x>0){te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{h(J)},x);return}h(J)}},ce=J=>{const se=Number.parseFloat(J.target.value);Number.isNaN(se)||(F.current=!0,U(se),fe(se))},Y=()=>{F.current=!1,te.current&&(clearTimeout(te.current),te.current=null),p?p(L):x>0&&h?.(L)};if(typeof s!="number"||typeof i!="number")return null;const T=[H?"h-28 w-5":"w-full",C,j].filter(Boolean).join(" "),X=r.jsx("input",{type:"range",orient:H?"vertical":void 0,min:s,max:i,step:o,value:Number.isFinite(L)?L:s,onChange:ce,onMouseUp:Y,onTouchEnd:Y,onPointerUp:Y,disabled:g,className:T,style:H?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return H?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${S}`.trim(),children:[M?r.jsx("div",{className:`flex flex-col items-center ${R}`.trim(),children:r.jsx("span",{className:k,children:Yr(n)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:N,children:f}),X]})]}):r.jsxs("div",{className:`space-y-0.5 ${S}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${R}`.trim(),children:[r.jsx("span",{className:N,children:f}),M?r.jsx("span",{className:k,children:Yr(n)}):null]}),r.jsxs("div",{children:[X,K?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${w}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${E}`.trim(),children:[y?r.jsx(G0,{label:y}):null,Yr(s)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${E}`.trim(),children:[Yr(i),b?r.jsx(G0,{label:b}):null]})]}):null]})]})}const Fr="mobile-joystick",rj=80,oj=.15,cj={main:0,side:0,vacuum:0},uj={main:127,side:127,vacuum:127},fj={main:-127,side:-127,vacuum:-127};function dj({disabled:n,layout:s,radius:i,onMove:o,onStop:f}){const d=m.useRef(null),h=m.useRef(null),p=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),y=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),b=m.useCallback(k=>{if(n||h.current!==null)return;k.preventDefault();const j=d.current;if(!j)return;const w=j.getBoundingClientRect(),E=k.clientX-w.left,C=k.clientY-w.top;p.current={x:E,y:C},h.current=k.pointerId,j.setPointerCapture?.(k.pointerId),g({active:!0,base:{x:E,y:C},knob:{x:0,y:0}})},[n]),S=m.useCallback(k=>{if(n||h.current!==k.pointerId)return;k.preventDefault();const j=d.current;if(!j)return;const w=j.getBoundingClientRect(),E=k.clientX-w.left,C=k.clientY-w.top,M=E-p.current.x,B=C-p.current.y,H=Math.min(Math.hypot(M,B),i),_=Math.atan2(B,M),K=Math.cos(_)*H,L=Math.sin(_)*H,U={x:ll(K/i),y:ll(-L/i),boost:!1};g(F=>({...F,knob:{x:K,y:L}})),o?.(U)},[n,o]),R=m.useCallback(k=>{if(h.current!==k.pointerId)return;k.preventDefault(),d.current?.releasePointerCapture?.(k.pointerId),y()},[y]);return m.useEffect(()=>{n&&y()},[n,y]),r.jsxs("div",{ref:d,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:S,onPointerUp:R,onPointerLeave:R,onPointerCancel:R,onContextMenu:k=>k.preventDefault(),children:[!x.active&&r.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[r.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),r.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),x.active&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:x.base.x,top:x.base.y}}),r.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:x.base.x+x.knob.x,top:x.base.y+x.knob.y}})]})]})}function mj({layout:n}){const{state:{roverId:s},actions:{setDriveVector:i,registerInputState:o}}=_t(),f=gg(s),d=f.docked&&!f.driving,h=d||f.dockingInProgress,p=!s,x=rj,g=oj,y=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{p&&(y.current={x:0,y:0,boost:!1})},[p]);const b=m.useCallback((k={})=>{if(p)return;const j={x:ll(k.x??0),y:ll(k.y??0),boost:!!k.boost},w={x:y.current.x+(j.x-y.current.x)*(1-g),y:y.current.y+(j.y-y.current.y)*(1-g),boost:j.boost};y.current=w,i(w,{source:Fr}),o(Fr,{vector:w,lastEvent:"move"})},[p,o,i,g]),S=m.useCallback(()=>{if(p)return;const k={x:0,y:0,boost:!1};y.current=k,i(k,{source:Fr}),o(Fr,{vector:k,lastEvent:"stop"})},[p,o,i]),N=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:N,children:[r.jsx(vg,{layout:"mobile",expand:h,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),h?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(dj,{disabled:p,layout:n,radius:x,onMove:b,onStop:S})})]})}function Y0({id:n,label:s,values:i,color:o,disabled:f,onPress:d,onRelease:h}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:p=>{p.preventDefault(),d(n,i)},onPointerUp:()=>h(n),onPointerLeave:()=>h(n),onPointerCancel:()=>h(n),onContextMenu:p=>p.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:s})}function hj({layout:n}){const{state:{roverId:s,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,setAuxMotors:p,startHorn:x,stopHorn:g}}=_t(),y=!s,b=m.useRef(null),S=i?.config,R=!!(s&&i?.enabled&&S),N=!!(s&&f?.nightVision),k=f?.nightVisionState,j=!!(s&&f?.horn),w=o?.overheated,E=typeof S?.minAngle=="number"?S.minAngle:-45,C=typeof S?.maxAngle=="number"?S.maxAngle:45,M=typeof i?.angle=="number"?i.angle:typeof S?.homeAngle=="number"?S.homeAngle:(E+C)/2,B=m.useCallback(K=>{N&&h(K)},[N,h]),H=m.useCallback((K,L)=>{y||(b.current=K,p(L))},[y,p]),_=m.useCallback(K=>{y||b.current===K&&(b.current=null,p(cj))},[y,p]);return r.jsxs("div",{className:"grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-0.5 text-slate-100",children:[r.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[r.jsx(Y0,{id:"aux-vac-forward",label:"Vacuum Forward",values:uj,color:"bg-fuchsia-600",disabled:y,onPress:H,onRelease:_}),r.jsx(Y0,{id:"aux-vac-backward",label:"Vacuum Backward",values:fj,color:"bg-fuchsia-800",disabled:y,onPress:H,onRelease:_})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[R?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(Sg,{value:M,min:E,max:C,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,N?r.jsx(yg,{nightVisionOn:k?.nightVisionOn,disabled:y,onToggle:B,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:j?r.jsx(bg,{disabled:y||w,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function co({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(hj,{layout:n})})}function uo({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(mj,{layout:n==="landscape"?"landscape":"portrait"})})}function pj({swapColumns:n=!1}){const s="h-[min(60svh,24rem)]",i=n?r.jsx(uo,{layout:"portrait",className:s}):r.jsx(co,{layout:"portrait",className:s}),o=n?r.jsx(co,{layout:"portrait",className:s}):r.jsx(uo,{layout:"portrait",className:s});return r.jsx("section",{className:"panel",children:r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[i,o]})})}function xj(n=[],s={}){const i=pn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id),[n]),g=m.useMemo(()=>{const N=x.join("|");return f?`${N}|v:${f}`:N},[x,f]),y=m.useRef([]),[b,S]=m.useState(0),R=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const N=()=>S(k=>k+1);return i.on("connect",N),()=>i.off("connect",N)},[i]),m.useEffect(()=>{y.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({});return}if(!y.current.length||!i)return;let N=!1;const k=y.current,j=(E={},C)=>{if(N||!E.id||!C)return;const M=C.byteLength??C.length??0,B=Date.now(),H=R.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:H.count+1,totalBytes:H.totalBytes+M,lastLogAt:H.lastLogAt};if(!_.lastLogAt||B-_.lastLogAt>=1e4){const F=_.count?_.totalBytes/_.count:0;console.log("[roomCamera]",E.id,`frame=${M}B`,`avg=${Math.round(F)}B`,`count=${_.count}`),_.lastLogAt=B}R.current.set(E.id,_);const K=new Blob([C],{type:"image/jpeg"}),L=URL.createObjectURL(K),U=p.current.get(E.id);U&&URL.revokeObjectURL(U),p.current.set(E.id,L),h(F=>({...F,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:L}}))},w=(E={})=>{N||!E.id||h(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return i.on("roomCamera:frame",j),i.on("roomCamera:status",w),i.emit("roomCamera:subscribe",{ids:k},(E={})=>{E.error}),()=>{N=!0,i.emit("roomCamera:unsubscribe",{ids:k}),i.off("roomCamera:frame",j),i.off("roomCamera:status",w),p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear()}},[i,g,o,b]),d}function gj({feed:n,label:s}){const[i,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(d=>!d))},[n?.ts,n?.objectUrl]);const f=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return r.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?r.jsx("img",{src:n.objectUrl,alt:s,className:"h-full w-full object-cover"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:s}),r.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[r.jsx("span",{className:`h-2 w-2 rounded-full ${i?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:f})]})]})}function vj(){return r.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),r.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const Ag=["horizontal","vertical"];function ff(n,s){return Ag.includes(n)?n:s}function td({defaultOrientation:n="horizontal",orientation:s,hideLayoutToggle:i=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=Le(),h=d?.roomCameras||[],p=xj(h.map(j=>({id:j.id}))),{value:x,save:g}=Fe("roomCameraPanels",{}),[y,b]=m.useState(()=>ff(f?x?.[f]:n,"horizontal"));m.useEffect(()=>{if(!f)return;const j=x?.[f];j&&b(ff(j,"horizontal"))},[f,x?.[f]]);const S=s?ff(s,"horizontal"):y,R=S==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",N=!i&&!s&&h.length>0,k=j=>{b(j),f&&g(w=>({...w||{},[f]:j}))};return h.length===0?r.jsx(vj,{}):r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&r.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room cameras"}),r.jsx("span",{className:"text-xs text-slate-500",children:h.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:N&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-500",children:"Layout:"}),r.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:Ag.map(j=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${S===j?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>k(j),children:j==="vertical"?"Vertical":"Grid"},j))})]})})]}),r.jsx("div",{className:R,children:h.map(j=>{const w=p[j.id]||null;return r.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:r.jsx(gj,{feed:w,label:j.name||j.id})},j.id)})})]})}function nd(){const{logs:n}=Le();return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Server logs"}),r.jsx("span",{children:n.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?r.jsx("p",{children:"No logs yet."}):n.slice().reverse().map(s=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:s.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",s.level,"]"]})," ",s.label&&r.jsxs("span",{className:"text-teal-400",children:["[",s.label,"]"]})," ",r.jsx("span",{children:s.message})]},s.id))})]})}function yj(n){if(!n)return null;if(typeof n=="string"){const s=String(n).trim();return s?{type:"rover",id:s,key:s}:null}if(typeof n=="object"){if(n.type&&n.id){const s=String(n.id);let i=n.key;return i||(i=n.type==="room"?`room:${s}`:s),{type:n.type,id:s,key:i}}if(n.roverId){const s=String(n.roverId);return{type:"rover",id:s,key:n.key||s}}if(n.roomCameraId){const s=String(n.roomCameraId);return{type:"room",id:s,key:n.key||`room:${s}`}}}return null}function bj(n=[]){const s=new Set,i=[];return n.forEach(o=>{!o?.key||s.has(o.key)||(s.add(o.key),i.push(o))}),i.sort((o,f)=>o.key.localeCompare(f.key))}function vi(n=[],s={}){const i=pn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useMemo(()=>Array.isArray(n)?bj(n.map(yj).filter(Boolean)):[],[n]),x=m.useMemo(()=>{const R=p.map(N=>`${N.type}:${N.id}:${N.key}`).join("|");return f?`${R}|v:${f}`:R},[p,f]),g=m.useRef([]),[y,b]=m.useState(0);return m.useEffect(()=>{if(!i)return;const R=()=>b(N=>N+1);return i.on("connect",R),()=>{i.off("connect",R)}},[i]),m.useEffect(()=>{g.current=p},[p]),m.useEffect(()=>{if(!x||!o){h({});return}const R=g.current;let N=!1;function k(j){const w=j.type==="room"?{roomCameraId:j.id}:{roverId:j.id};i.emit("video:request",w,(E={})=>{N||h(C=>({...C,[j.key]:E}))})}return R.forEach(j=>{k(j)}),()=>{N=!0}},[i,x,o,y]),m.useMemo(()=>{if(!x||!o)return{};const R={};return p.forEach(N=>{d[N.key]&&(R[N.key]=d[N.key])}),R},[x,d,p])}function ad(n=[],s={}){const i=pn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id).filter(Boolean),[n]),g=m.useMemo(()=>{const N=x.join("|");return f?`${N}|v:${f}`:N},[x,f]),y=m.useRef([]),[b,S]=m.useState(0),R=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const N=()=>S(k=>k+1);return i.on("connect",N),()=>i.off("connect",N)},[i]),m.useEffect(()=>{y.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({});return}if(!y.current.length||!i)return;let N=!1;const k=y.current,j=(E={},C)=>{if(N||!E.id||!C)return;const M=C.byteLength??C.length??0,B=Date.now(),H=R.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:H.count+1,totalBytes:H.totalBytes+M,lastLogAt:H.lastLogAt};if(!_.lastLogAt||B-_.lastLogAt>=1e4){const F=_.count?_.totalBytes/_.count:0;console.log("[roverSnapshot]",E.id,`frame=${M}B`,`avg=${Math.round(F)}B`,`count=${_.count}`),_.lastLogAt=B}R.current.set(E.id,_);const K=new Blob([C],{type:"image/jpeg"}),L=URL.createObjectURL(K),U=p.current.get(E.id);U&&URL.revokeObjectURL(U),p.current.set(E.id,L),h(F=>({...F,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:L}}))},w=(E={})=>{N||!E.id||h(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return i.on("roverSnapshot:frame",j),i.on("roverSnapshot:status",w),i.emit("roverSnapshot:subscribe",{ids:k},(E={})=>{E.error}),()=>{N=!0,i.emit("roverSnapshot:unsubscribe",{ids:k}),i.off("roverSnapshot:frame",j),i.off("roverSnapshot:status",w),p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear()}},[i,g,o,b]),d}const Sj={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function Aj(n){if(typeof btoa=="function")return btoa(n);if(typeof Buffer<"u")return Buffer.from(n).toString("base64");throw new Error("No base64 encoder available")}function jj(n){if(!n)return{};const s=`${n}:${n}`;return{Authorization:`Basic ${Aj(s)}`}}class F0{constructor({url:s,token:i,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:h=!0}){this.url=s,this.token=i,this.video=o,this.audioOnly=d,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=f}notify(s,i){typeof this.onStatus=="function"&&this.onStatus(s,i)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const s=new RTCPeerConnection(Sj);this.pc=s;const i=new MediaStream;s.ontrack=o=>{o.streams[0]?.getTracks().forEach(f=>i.addTrack(f)),this.video.srcObject=i,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?s.addTransceiver("audio",{direction:"recvonly"}):(s.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&s.addTransceiver("audio",{direction:"recvonly"})),s.onconnectionstatechange=()=>{this.notify(s.connectionState)},s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await s.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await s.setLocalDescription(o);const f=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...jj(this.token)},body:o.sdp,signal:this.abortController.signal});if(!f.ok)throw new Error(`WHEP request failed: ${f.status}`);const d=await f.text();await s.setRemoteDescription({type:"answer",sdp:d}),s.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(s=>s.track?.stop()),this.pc.getReceivers().forEach(s=>s.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function Rf({sensors:n={},variant:s="full",size:i,overlay:o=!1}){const f=i||(s==="mini"?190:260),d=f/2,h=f*.07,p=d,x=d+h,g=d*.8,y=g-4,b=g+4,S=g-14,R=g-6,N=g*.65,k=n?.bumpsAndWheelDrops||{},j=n?.wheelOvercurrents||{},w=n?.wheelLeftCurrentMa??0,E=n?.wheelRightCurrentMa??0,C=n?.sideBrushCurrentMa??0,M=n?.mainBrushCurrentMa??0,B=6,H=k.bumpLeft?B:0,_=k.bumpRight?B:0,K=qj({count:6,totalSpan:140,gap:6,startAngle:-70}),L=["L","FL","CL","CR","FR","R"],U=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],F=K.map((Y,T)=>({label:L[T],start:Y.start,end:Y.end,value:U[T]})),te=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],fe=U.filter(Y=>Y!=null),ce=fe.length?Math.max(...fe,1200):1200;return r.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${f}px`,height:`${f}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),r.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0",ce]})]}),r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${f}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:p,cy:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(X0,{cx:p-N,cy:x,current:w,drop:k.wheelDropLeft,overcurrent:j.leftWheel,label:"L"}),r.jsx(X0,{cx:p+N,cy:x,current:E,drop:k.wheelDropRight,overcurrent:j.rightWheel,label:"R"}),r.jsx(Cj,{cx:p+g*.65,cy:x-g*.55,current:C,overcurrent:j.sideBrush}),r.jsx(Ej,{cx:p,cy:x,current:M,overcurrent:j.mainBrush,variant:s,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),F.map(Y=>{const T=kj(Y.value,ce),X=b+4,J=X+28;return r.jsx(Nj,{cx:p,cy:x,rBase:J,rTip:X,startDeg:Y.start,endDeg:Y.end,color:T,value:Y.value,max:ce},Y.label)}),te.map(Y=>{const T=Mj(Y.value,Y.active);return r.jsx(df,{cx:p,cy:x,rInner:S,rOuter:R,startDeg:Y.start,endDeg:Y.end,color:T,opacity:1,pulse:!!Y.active},Y.label)}),r.jsx(df,{cx:p,cy:x,rInner:y-H,rOuter:b-H,startDeg:-70,endDeg:-6,color:k.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!k.bumpLeft}),r.jsx(df,{cx:p,cy:x,rInner:y-_,rOuter:b-_,startDeg:6,endDeg:70,color:k.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!k.bumpRight})]})]})}function df({cx:n,cy:s,rInner:i,rOuter:o,startDeg:f,endDeg:d,color:h,pulse:p=!1,opacity:x=1}){const g=(i+o)/2,y=o-i,b=wj(n,s,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:b,stroke:h,strokeWidth:y,strokeLinecap:"round",fill:"none",opacity:x}),p?r.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:y,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function Nj({cx:n,cy:s,rBase:i,rTip:o,startDeg:f,endDeg:d,color:h,value:p,max:x}){const g=(f+d)/2,y=mi(n,s,o,g),b=bo(p!=null?p/(x||1):0),S=Math.pow(b,.35),R=i-(i-o)*S,N=mi(n,s,R,f),k=mi(n,s,R,d),j=`M ${y.x} ${y.y} L ${N.x} ${N.y} L ${k.x} ${k.y} Z`;return r.jsx("path",{d:j,fill:h,opacity:1,stroke:"none"})}function wj(n,s,i,o,f){let d=o,h=f;h<=d&&(h+=360);const p=mi(n,s,i,d),x=mi(n,s,i,h);return["M",p.x,p.y,"A",i,i,0,0,1,x.x,x.y].join(" ")}function mi(n,s,i,o){const f=jg(o);return{x:n+i*Math.cos(f),y:s+i*Math.sin(f)}}function jg(n){return(n-90)*Math.PI/180}function sd(n,s){if(s)return"#ef4444";const i=Math.abs(n);return i>900?"#f59e0b":i>300?"#22c55e":"#64748b"}function bo(n){return Math.max(0,Math.min(1,n))}function X0({cx:n,cy:s,current:i,drop:o,overcurrent:f,label:d}){const h=Math.abs(i),p=bo(h/1200),x=sd(i,f),g=56,y=14,b=9,S=3,R=g*p,N=d==="L"?-1:1,k=N*(-b/2-S/2),j=N*(y/2+S/2),w=y+b+S+2,E=g+4;return r.jsxs("g",{transform:`translate(${n},${s})`,children:[r.jsx("rect",{x:-w/2,y:-E/2,width:w,height:E,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:k-y/2,y:-g/2,width:y,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:k-y/2,y:g/2-R,width:y,height:R,fill:x,className:f?"animate-pulse":""}),r.jsx("rect",{x:j-b/2,y:-g/2,width:b,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),r.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:d})]})}function Cj({cx:n,cy:s,current:i,overcurrent:o}){var f=Math.abs(i);f<10&&(f=0);const d=sd(i*3,o),h=43,p=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${n}px ${s}px`,animation:p?`spin ${p}s linear infinite`:"none",animationDirection:p?"reverse":"normal"},children:[r.jsx("circle",{cx:n,cy:s,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const y=jg(g),b=n+h*Math.cos(y),S=s+h*Math.sin(y);return r.jsx("line",{x1:n,y1:s,x2:b,y2:S,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:n,cy:s,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function Ej({cx:n,cy:s,current:i,overcurrent:o,variant:f,dirtLeft:d,dirtRight:h}){const p=Math.abs(i),x=sd(i,o),g=1,y=96,b=12,S=`main-brush-pattern-a-${f}`,R=`main-brush-pattern-b-${f}`,N=p>0?.6:null,k=i>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[S,R].map((j,w)=>r.jsxs("pattern",{id:j,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:x,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),N?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${k*(w===0?6:-6)}`,dur:`${N}s`,repeatCount:"indefinite"}):null]},j))}),r.jsx("rect",{x:n-y/2,y:s-14,width:y,height:b,rx:"3",fill:`url(#${S})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:n-y/2,y:s+4,width:y,height:b,rx:"3",fill:`url(#${R})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:n-y/4,cy:s-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:n+y/4,cy:s+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:n-y/2-4,y:s-16,width:y+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function kj(n,s){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=bo(n/(s||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function Mj(n,s){if(s)return"#ef4444";const i=bo(n==null?0:n/4095),o=[47,55,69],f=[245,158,11],[d,h,p]=o.map((x,g)=>Math.round(x+(f[g]-x)*i));return`rgb(${d}, ${h}, ${p})`}function qj({count:n,totalSpan:s,gap:i,startAngle:o}){const d=(s-i*(n-1))/n,h=[];let p=o;for(let x=0;x<n;x+=1){const g=p+d;h.push({start:p,end:g}),p=g+i}return h}function Ng(){const{value:n,save:s}=Fe("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,f=>{s({hudMapDesktop:!!f})}]}const Rj={discord:Wx,kofi:M0,"ko-fi":M0,wiki:tA,throne:nA},Tj={discord:{backgroundImage:"linear-gradient(270deg,#5865F2,#404EED,#5865F2)",backgroundSize:"600% 600%",animation:"socialGradient 180s ease infinite"},kofi:{backgroundImage:"linear-gradient(270deg,#FF6433,#E04822,#FF6433)",backgroundSize:"600% 600%",animation:"socialGradient 170s ease infinite"},"ko-fi":{backgroundImage:"linear-gradient(270deg,#FF6433,#E04822,#FF6433)",backgroundSize:"600% 600%",animation:"socialGradient 170s ease infinite"},wiki:{backgroundImage:"linear-gradient(270deg,#EE8019,#C65C08,#EE8019)",backgroundSize:"600% 600%",animation:"socialGradient 180s ease infinite"},throne:{backgroundImage:"linear-gradient(270deg,#7C3AED,#5B21B6,#7C3AED)",backgroundSize:"600% 600%",animation:"socialGradient 180s ease infinite"}};function Dj(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const s=document.createElement("style");s.id=n,s.textContent=`
@keyframes socialGradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
`,document.head.appendChild(s)},[])}function _j(n,s){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof s=="string"&&s.trim()?s.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function ld({id:n,label:s,url:i,className:o=""}){if(!i)return null;Dj();const f=_j(n,s),d=Rj[f]||aA,h=Tj[f]||null,p=s||n||"Link";return r.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","aria-label":p,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${h?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:h||void 0,children:[r.jsx(d,{className:"mr-0"}),p]})}const yi=10;function wg({batteryState:n=null,charge:s=null,config:i=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,f=n?.warnActive??null,d=n?.urgentActive??null,h=i?.Full??null,p=i?.Warn??null,x=i?.Urgent??null,g=s??n?.charge??null;let y=o;if(y==null&&(y=Oj({charge:g,full:h,warn:p,urgent:x})),y==null)return{available:!1};const b=Math.max(0,Math.min(1,y/100)),S=f??(p!=null&&g!=null&&g<=p),R=d??(x!=null&&g!=null&&g<=x);return{available:!0,percent:b,percentDisplay:y,warnActive:S,urgentActive:R,warnDisplayPercent:yi}}function Oj({charge:n,full:s,warn:i,urgent:o}){if(n!=null&&s!=null&&i!=null&&o!=null&&s>i&&i>o){const f=yi/100,d=1-f;if(n<=o)return 0;if(n<=i){const p=(n-o)/(i-o);return Math.round(Math.max(0,Math.min(1,p))*yi)}if(n>=s)return 100;const h=(n-i)/(s-i);return Math.round((f+Math.max(0,Math.min(1,h))*d)*100)}return null}const Bj=1600,Lj=800;function yn(...n){return n.filter(Boolean).join(" ")}function Tf({visual:n,orientation:s="horizontal",variant:i="inline",compact:o=!1,showLabel:f,className:d=""}){const h=i==="background",p=s==="vertical",x=f??!h;if(!n?.available){if(h){const te=yi,fe=yn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!S&&"battery-tick-warn"),ce=p?{bottom:`${te}%`}:{left:`${te}%`},Y=yn("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:Y,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:fe,style:ce})]})}return p?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,y=Math.max(0,Math.min(100,g)),b=n.warnDisplayPercent??yi,S=!!n.urgentActive,R=!!n.warnActive,N=S?`${Lj}ms`:R?`${Bj}ms`:void 0,j=h?S||R?"bg-red-500/45":"bg-emerald-500/45":S||R?"bg-red-500":"bg-emerald-500",w=S||R?"bg-red-900/35":"bg-slate-900/35",E=S||R?"bg-red-900/45":"bg-slate-900/35",C=yn(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",p&&!h?"flex flex-col items-center justify-center":"w-full",d);if(h){const te=p?{height:`${y}%`}:{width:`${y}%`},fe=yn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",S&&"battery-urgent-flash"),ce=yn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!S&&"battery-tick-warn"),Y=p?{bottom:`${b}%`}:{left:`${b}%`};return r.jsxs("div",{className:C,children:[r.jsx("div",{className:yn("absolute inset-0",w,S&&"battery-urgent-flash")}),r.jsx("div",{className:fe,style:{...te,animationDuration:N}}),r.jsx("div",{className:ce,style:Y})]})}const M=yn("relative overflow-hidden rounded-sm border border-slate-800",S||R?E:"bg-zinc-900/90",S&&"battery-urgent-flash",p?"w-full flex-1":o?"h-4":"h-5"),B=p?{height:`${y}%`}:{width:`${y}%`},H=yn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",S&&"battery-urgent-flash"),_=yn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!S&&"battery-tick-warn"),K=p?{bottom:`${b}%`}:{left:`${b}%`},L=`Battery ${g}%`,U=yn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",p?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),F=yn("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:C,children:[r.jsxs("div",{className:M,children:[r.jsx("div",{className:H,style:{...B,animationDuration:N}}),r.jsx("div",{className:_,style:K})]}),x&&!p?r.jsx("div",{className:U,children:r.jsx("span",{className:F,children:L})}):null,x&&p?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:F,children:[g,"%"]})}):null]})}const Q0=2e3,zj=3e3,Uj=3e3,Hj=40,Vj=1e3;function bi({sessionInfo:n,audioSessionInfo:s,videoMode:i="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,roverColor:h=null,forceMute:p=!1,telemetryFrame:x,batteryConfig:g,layoutFormat:y="desktop",hudVariant:b="default",driverLabel:S=null,hudForceMap:R=!1,hudMapPosition:N="top-center",hudLabelScale:k=1,fitParent:j=!1,overcurrentLimiter:w=null,showTurnCue:E=!1,turnTimerText:C=null,turnSeconds:M=null,isActiveDriver:B=!1,idleSkipSeconds:H=null}){const{session:_}=Le(),K=m.useRef(null),L=m.useRef(null),U=m.useRef(null),F=m.useRef(null),te=m.useRef(null),fe=m.useRef(null),ce=m.useRef(null),Y=m.useRef(null),[T,X]=m.useState("idle"),[J,se]=m.useState(null),[de,q]=m.useState("idle"),[V,P]=m.useState(null),[ne,pe]=m.useState(0),[ie,oe]=m.useState(0),[ve,ye]=m.useState(!0),xe=!!s?.url,Ue=i==="snapshot",$e=x?.sensors,{value:Ne}=Fe("audio",St),ae=Number.isFinite(Ne?.masterVolume)?Ne.masterVolume:St.masterVolume,ue=Number.isFinite(Ne?.roverVolume)?Ne.roverVolume:St.roverVolume,be=typeof Ne?.mainBrushDuckEnabled=="boolean"?Ne.mainBrushDuckEnabled:typeof Ne?.autoLevelEnabled=="boolean"?Ne.autoLevelEnabled:St.mainBrushDuckEnabled,Me=Number.isFinite(Ne?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Ne.mainBrushDuckAmount)):St.mainBrushDuckAmount,le=Math.max(0,Math.min(1,ae*ue)),re=$e?.batteryChargeMah??null,me=y==="desktop",we=!me,et=we?"top-right":N,[dt]=Ng(),ze=R||we?!0:dt,xt=wg({charge:re,config:g}),mt=$e?.wheelOvercurrents||null,Tn=mt==null?[]:Object.entries(mt).filter(([,Ae])=>!!Ae).map(([Ae])=>Ae),kt=w?.caps||null,cs=w?.overcurrent?.groups||null,Gt=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),Oa=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),Eo=m.useMemo(()=>{if(!kt)return null;const Ae=Number.isFinite(kt?.drive?.cap)?kt.drive.cap:1,Ke=Number.isFinite(kt?.aux?.cap)?kt.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(Ae,Ke)))},[kt]),Dn=!!w?.isActive,jt=Tn.length?Tn:Dn?["limiter"]:[],Yt=Eo??(Tn.length?1:0),Mt=!!jt.length,ca=!!((Number($e?.mainBrushCurrentMa)||0)>Hj||$e?.wheelOvercurrents?.mainBrush),ko=be&&ca?1-Me:1,us=Math.max(0,Math.min(1,le*ko)),fs=be&&ca&&Me>0?`Volume decreased ${Math.round(Me*1e3)/10}%`:null,Ba=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Ba.current={hasDedicatedAudio:xe,audioUrl:s?.url||null,mainBrushDuckEnabled:be,mainBrushDuckAmount:Me,mainBrushActive:ca,baseRoverGain:le,effectiveRoverGain:us}},[xe,s?.url,be,Me,ca,le,us]);const tt=m.useCallback((Ae,Ke={})=>{if(!Gt)return;const Pe=L.current,qe=Ba.current,Ye={event:Ae,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:qe.hasDedicatedAudio,audioUrl:qe.audioUrl,mainBrushDuckEnabled:qe.mainBrushDuckEnabled,mainBrushDuckAmount:qe.mainBrushDuckAmount,mainBrushActive:qe.mainBrushActive,baseRoverGain:qe.baseRoverGain,effectiveRoverGain:qe.effectiveRoverGain,element:Pe?{muted:Pe.muted,volume:Pe.volume,paused:Pe.paused,ended:Pe.ended,readyState:Pe.readyState,networkState:Pe.networkState}:null,...Ke};try{console.log(`[AudioDebug] ${Ae} ${JSON.stringify(Ye)}`)}catch{console.log("[AudioDebug]",Ae,Ye)}},[Gt,d]),_n=_?.socials?.find(Ae=>String(Ae?.id||Ae?.label||"").toLowerCase()==="discord")?.url||_?.discord?.invite||null;m.useEffect(()=>{Oa&&console.log("[OvercurrentHUD]",{overlayVisible:Mt,overlayMotors:jt,overlayFill:Yt,limiterActive:Dn,limiterCaps:kt,limiterGroups:cs,wheelOvercurrents:mt})},[Oa,Yt,jt,Mt,Dn,kt,cs,mt]),m.useEffect(()=>{tt("settings/update")},[tt]);const jn=m.useCallback(()=>{clearTimeout(U.current),U.current=setTimeout(()=>pe(Date.now()),Q0)},[]),On=m.useCallback(()=>{clearTimeout(F.current),F.current=setTimeout(()=>oe(Date.now()),Q0)},[]),ds=m.useCallback(async()=>{const Ae=K.current;if(Ae)try{Ae.muted=!0,await Ae.play()}catch{}},[]),ul=m.useCallback((Ae=0)=>{if(p||xe)return;clearTimeout(fe.current);const Ke=()=>{clearTimeout(fe.current),fe.current=setTimeout(()=>{p||Pe()},zj)},Pe=async()=>{const qe=K.current;if(qe)try{await ds(),qe.muted=!1,await qe.play(),ye(!1)}catch{qe.muted=!0,ye(!0),Ke()}};fe.current=setTimeout(Pe,Ae)},[ds,p,xe]);m.useEffect(()=>()=>{clearTimeout(U.current),clearTimeout(F.current),clearTimeout(fe.current),clearInterval(te.current),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)},[]),m.useEffect(()=>{T==="playing"&&ul(0)},[T,ul]),m.useEffect(()=>{Ue&&(X("snapshot"),se(null))},[Ue]),m.useEffect(()=>{if(Ue||!n?.url||!K.current)return;let Ae=!0,Ke;const Pe=setTimeout(()=>ye(!0),0),qe=(Ye,it)=>{Ae&&(tt("video/status",{nextStatus:Ye,info:it||null}),X(Ye),se(it||null),Ye==="playing"&&ds(),["error","failed","disconnected","closed"].includes(Ye)&&jn())};return Ke=new F0({url:n.url,token:n.token,video:K.current,receiveAudio:!xe,onStatus:qe}),Ke.start().catch(Ye=>{Ae&&(X("error"),se(Ye.message),jn())}),()=>{Ae=!1,clearTimeout(Pe),Ke?.stop()}},[Ue,n?.url,n?.token,ne,jn,ds,xe,tt]),m.useEffect(()=>{T==="stopped"&&n?.url&&jn()},[T,n?.url,jn]),m.useEffect(()=>{const Ae=L.current;if(!Ae||!s?.url){tt("route/no-audio-url"),Y.current=null;return}const Ke=Math.max(0,Math.min(1,us)),Pe=Y.current==null?Math.max(0,Math.min(1,Ae.volume)):Y.current;if(ce.current&&(cancelAnimationFrame(ce.current),ce.current=null),Ke>Pe){const qe=performance.now(),Ye=Pe,it=Ke-Ye,rt=Nt=>{const st=Math.min(1,(Nt-qe)/Vj),Bn=Ye+it*st;Ae.volume=Bn,Y.current=Bn,st<1?ce.current=requestAnimationFrame(rt):ce.current=null};ce.current=requestAnimationFrame(rt)}else Ae.volume=Ke,Y.current=Ke;tt("route/direct",{elementVolume:Ke,duckEnabled:be,mainBrushActive:ca,duckAmount:Me})},[s?.url,us,be,ca,Me,tt]),m.useEffect(()=>{if(!s?.url||!L.current)return;let Ae=!0,Ke;const Pe=(qe,Ye)=>{Ae&&(tt("audio/status",{nextStatus:qe,info:Ye||null}),P(Ye||(qe==="connected"?"connected":null)),q(it=>qe==="connected"&&(it==="playing"||it==="connecting")||qe==="new"?it:qe),["error","failed"].includes(qe)&&On())};return Ke=new F0({url:s.url,token:s.token,video:L.current,audioOnly:!0,onStatus:Pe}),Ke.start().catch(qe=>{Ae&&(q("error"),P(qe.message),On())}),()=>{Ae=!1,Ke?.stop()}},[s?.url,s?.token,ie,On,tt]),m.useEffect(()=>{const Ae=L.current;if(!s?.url||!Ae){clearInterval(te.current);return}if(!["connecting","connected","playing","paused"].includes(de)){clearInterval(te.current);return}const Pe=async()=>{const qe=L.current;qe&&(qe.muted=!1,!(!qe.paused&&!qe.ended)&&(tt("retry/play-attempt"),qe.play().then(()=>{tt("retry/play-ok"),q(Ye=>Ye==="connected"?"playing":Ye),P(Ye=>Ye==="paused"?null:Ye)}).catch(Ye=>{tt("retry/play-fail",{error:Ye?.message}),P(it=>it||Ye?.message||"autoplay blocked")})))};return Pe(),te.current=setInterval(Pe,Uj),()=>clearInterval(te.current)},[s?.url,de,tt]),m.useEffect(()=>{const Ae=L.current;if(!Ae)return;const Ke=()=>{tt("element/play"),q(st=>st==="error"?st:"playing"),P(null)},Pe=()=>{tt("element/pause"),q(st=>["error","failed","disconnected","closed","stopped"].includes(st)?st:"paused"),P(st=>st||"paused")},qe=()=>{tt("element/ended"),q(st=>st==="error"?st:"stopped"),P(st=>st||"ended")},Ye=()=>{const{error:st}=Ae,Bn=st?.message||"audio error";tt("element/error",{error:Bn}),q("error"),P(Bn)},it=()=>tt("element/waiting"),rt=()=>tt("element/canplay"),Nt=()=>tt("element/stalled");return Ae.addEventListener("play",Ke),Ae.addEventListener("pause",Pe),Ae.addEventListener("ended",qe),Ae.addEventListener("error",Ye),Ae.addEventListener("waiting",it),Ae.addEventListener("canplay",rt),Ae.addEventListener("stalled",Nt),()=>{Ae.removeEventListener("play",Ke),Ae.removeEventListener("pause",Pe),Ae.removeEventListener("ended",qe),Ae.removeEventListener("error",Ye),Ae.removeEventListener("waiting",it),Ae.removeEventListener("canplay",rt),Ae.removeEventListener("stalled",Nt)}},[s?.url,tt]);const fl=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",La=Ue?fl:n?.url?T==="error"?`Error: ${J||"unknown"}`:J?`${T} (${J})`:T:"waiting",Mo=s?.error?`Error: ${s.error}`:s?.url?de==="error"?`Error: ${V||"unknown"}`:V?`${de} (${V})`:de:null,dl=b==="spectator",en=b==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${j?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${j?"h-full flex-1":"aspect-[4/3]"}`,children:[Ue?o?.objectUrl?r.jsx("img",{src:o.objectUrl,alt:d,className:"h-full w-full object-contain",draggable:!1}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):r.jsx("video",{ref:K,muted:p||ve||xe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:L,autoPlay:!0,hidden:!0}),!en&&E?r.jsx(Yj,{mobileHud:we,turnSeconds:M,isActiveDriver:B,idleSkipSeconds:H}):null,en?null:r.jsx(Gj,{frame:x,sensors:$e,label:d,roverColor:h,status:La,audioStatus:Mo,levelStatus:fs,desktopLayout:me,layoutFormat:y,variant:b,driverLabel:S,battery:xt,showTopDown:ze,mobileHud:we,mapPosition:et,turnTimerText:C,labelScale:k}),en?null:r.jsx(Kj,{compact:we}),!en&&Oa?r.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-40 rounded bg-black/80 px-1 py-0.5 text-[0.6rem] text-lime-200",children:`OC vis:${Mt?1:0} motors:${jt.length} fill:${Math.round(Yt*100)}%`}):null,en?null:r.jsx(Xj,{motors:jt,fill:Yt,compact:we}),en?null:r.jsx(Qj,{battery:xt,compact:we}),!en&&dl&&xt.available?r.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:r.jsx(Tf,{visual:xt,orientation:"vertical",variant:"inline",compact:we,className:"h-full w-4"})}):null,!en&&f?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2",children:r.jsxs("div",{className:`mx-auto w-fit rounded border border-amber-300/80 bg-black/75 text-amber-200 ${we?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[r.jsx("div",{className:"text-center",children:f}),r.jsx("div",{className:"pointer-events-auto mt-0",children:r.jsx(ld,{id:"discord",label:"Join our Discord server while you wait!",url:_n})})]})}):null]}),!en&&!dl&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx($j,{sensors:$e}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(Tf,{visual:xt,compact:we})})]})]})}function $j({sensors:n}){const s=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],i=s.filter(p=>p!=null).reduce((p,x)=>Math.max(p,x),1200),o=p=>Math.pow(Math.max(0,Math.min(1,(p??0)/i)),.35),f=p=>p==null||p<=0?"hsl(200 60% 18%)":`hsl(${(200+o(p)*360)%360} 100% 60%)`,d=6,h=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:s.map((p,x)=>{const g=o(p),y=x<d/2?-1:1,b=`${g*100}%`,S=f(p);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${h}px`},children:r.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:r.jsx("div",{className:"h-full",style:{width:b,background:S,float:y===-1?"right":"left"}})})},x)})})}function Gj({frame:n,sensors:s,label:i,roverColor:o=null,status:f,audioStatus:d,levelStatus:h,desktopLayout:p=!0,layoutFormat:x="desktop",variant:g="default",driverLabel:y=null,battery:b,showTopDown:S=!1,mobileHud:R=!1,mapPosition:N="top-center",turnTimerText:k=null,labelScale:j=1}){s?.bumpsAndWheelDrops;const[w,E]=m.useState(()=>Date.now());m.useEffect(()=>{const se=setInterval(()=>E(Date.now()),150);return()=>clearInterval(se)},[]),n?.receivedAt&&w-n.receivedAt<200;const C=R,M=x==="mobile-portrait",B=C?"text-[0.45rem]":"text-[0.65rem]",H=C?"px-0.25 py-0.25":"px-1 py-0.5",_=C?"px-0.25 py-0.25":"px-0.5 py-0.5",K=C?"text-[0.55rem]":"text-[0.8rem]",L=C?"left-0.5 top-0.5":"left-1 top-1",U=C?"text-[0.5rem]":"text-[0.7rem]",F=C?"px-0.5 py-0.25":"px-1 py-0.5",te=C?"left-0.5 top-1/2":"left-1 top-1/2",fe="bottom-0.5",ce={transform:`translateX(-50%) scale(${j})`,transformOrigin:"center bottom"},Y="240px",T=M?.3:C?.33:.7,J={width:Y,height:Y,opacity:C?.6:.7,transform:N==="top-center"?`translateX(-50%) scale(${T})`:`scale(${T})`,transformOrigin:N==="bottom-left"?"bottom left":N==="top-center"?"top center":"top right",...N==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:N==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(g==="none")return null;if(g==="spectator"){const se=[["Voltage",s?.voltageMv!=null?`${(s.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",s?.currentMa!=null?`${s.currentMa} mA`:"--"],["Charge",s?.batteryChargeMah!=null?`${s.batteryChargeMah}`:"--"],["OI",s?.oiMode?.label||"--"]],de=!!s?.chargingSources?.homeBase,q=s?.chargingState?.label||"",V=!!(q&&q.toLowerCase()!=="not charging"),P=s?.oiMode?.label||"Unknown",ne=P.toLowerCase(),pe=ne==="full"?"bg-emerald-500/80 text-emerald-50":ne==="safe"?"bg-amber-400/80 text-amber-950":ne==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",ie=de?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",oe=V?"bg-emerald-500/80 text-emerald-50":de?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${L} font-medium text-slate-100 ${B}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,h?r.jsx("span",{className:"text-cyan-300",children:h}):null]})}),r.jsx("div",{className:`absolute ${te} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${B} ${H}`,children:r.jsxs("div",{className:"space-y-0.5 leading-tight",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[r.jsx("span",{className:`rounded px-1.5 py-0.5 ${ie}`,children:de?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${oe}`,children:V?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${pe}`,children:["OI: ",P]})]}),se.map(([ve,ye])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:ve}),r.jsx("span",{className:"font-semibold text-white",children:ye})]},ve))]})}),r.jsx("div",{className:`absolute ${fe} left-1/2`,style:ce,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${_} ${K}`,children:[r.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ra(o,.18),children:i||"Unnamed Rover"}),y?r.jsxs("span",{className:"text-slate-300",children:["• ",y]}):null]})})]}),S?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:r.jsx(Rf,{sensors:s,size:240,overlay:!0})}):null]})}return r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${L} font-medium text-slate-100 ${B}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,h?r.jsx("span",{className:"text-cyan-300",children:h}):null]})}),k?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${F} ${U}`,children:k}):null,r.jsx("div",{className:`absolute ${fe} left-1/2`,style:ce,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${_} ${K}`,children:r.jsxs("span",{children:["Rover:"," ",r.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(o,.18),children:['"',i||"Unnamed Rover",'"']})]})})}),S&&g!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:r.jsx(Rf,{sensors:s,size:240,overlay:!0})}):null]})}function Yj({mobileHud:n=!1,turnSeconds:s=null,isActiveDriver:i=!1,idleSkipSeconds:o=null}){const f=n?"text-3xl":"text-5xl",d=n?"text-xs":"text-sm",h=n?"text-[0.55rem]":"text-[0.75rem]",p=n?"px-4 py-3":"px-6 py-4",x=i&&typeof o=="number";return r.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:r.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${p}`,children:[r.jsx("div",{className:`font-semibold text-amber-200 ${f}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${d}`,children:"Start driving!"}),x?r.jsxs("div",{className:`text-red-100/90 ${h}`,children:["Idle skip in ",o,"s"]}):null]})})}const Fj={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function Xj({motors:n,fill:s=0,compact:i=!1}){if(!n?.length)return null;const o=n.map(y=>Fj[y]||y),f=i?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=i?"px-2 py-1":"px-4 py-2",h=i?"text-lg":"text-4xl",p=i?"text-xs":"text-xl",x=Math.max(0,Math.min(1,s)),g=`${Math.round(x*100)}%`;return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${f}`,children:r.jsxs("div",{className:"relative h-full w-full",children:[r.jsx("div",{className:"absolute inset-0 overflow-hidden",children:r.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),r.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${h} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${p}`,children:o.join(", ")})]})]})})}function Qj({battery:n,compact:s=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const i=n.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=s?"p-2 top-6":"p-4 top-10",f=s?"text-sm":"text-2xl";return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${o}`,children:r.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${f}`,children:r.jsx("div",{children:i})})})}function Kj({compact:n=!1}){const{session:s}=Le(),{sendMessage:i,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:h,setTypingActive:p}=Pf(),{value:x}=Fe("tts",{engine:"flite",voice:"rms",pitch:50}),[g,y]=m.useState(""),[b,S]=m.useState(!1),R=s?.role!=="spectator",N=s?.role==="spectator",k=s?.assignment?.roverId||null,w=!!m.useMemo(()=>s?.roster?.find(_=>String(_.id)===String(k))||null,[k,s?.roster])?.audio?.ttsEnabled,E=m.useMemo(()=>{if(!w)return null;const _=x?.engine==="espeak"?"espeak":"flite";if(_==="espeak"){let L=Number.isFinite(x?.pitch)?Math.round(x.pitch):void 0;return typeof L=="number"&&(L=Math.max(0,Math.min(99,L))),{speak:!0,engine:_,pitch:L}}const K=typeof x?.voice=="string"?x.voice:void 0;return{speak:!0,engine:_,voice:K}},[x?.engine,x?.pitch,x?.voice,w]),C=n?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",M=n?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",B=n?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function H(_){if(_.preventDefault(),!R)return;const K=g.trim();if(K){S(!0);try{await i(K,E),y(""),d(),p(!1)}catch(L){alert(L.message)}finally{S(!1)}}}return N?null:r.jsxs("form",{onSubmit:H,className:C,children:[r.jsx("input",{className:M,value:g,onChange:_=>{const K=_.target.value;y(K),p(!!K.trim())},onFocus:_=>{o(_),p(!!g.trim())},onBlur:_=>{f(_),p(!1)},onKeyDown:_=>{_.key==="Enter"&&!g.trim()&&(_.preventDefault(),d(),p(!1))},ref:_=>h(_,{target:"hud"}),placeholder:R?"Chat (TTS)":"Spectator",disabled:!R}),r.jsx("button",{type:"submit",disabled:!R||b,className:B,children:"Speak"})]})}function id({layoutFormat:n="desktop"}){const{session:s}=Le(),{state:{song:i,lastControlIntentAt:o},overcurrentLimiter:f}=_t(),[d,h]=m.useState(()=>Date.now()),[p,x]=m.useState(!1),[g,y]=m.useState(null),b=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(s?.mode!=="turns")return;const ne=setInterval(()=>h(Date.now()),250);return()=>clearInterval(ne)},[s?.mode]);const S=s?.assignment?.roverId,N=!!(S&&s?.roster?s.roster.find(ne=>String(ne.id)===String(S)):null)?.media?.audioPublishUrl,k=S?s?.turnQueues?.[S]:null,j=s?.socketId||null,w=S?s?.activeDrivers?.[S]:null,E=!!(j&&w===j),C=m.useMemo(()=>{const ne=k?.queue||[];if(!ne.length||!k?.current||ne.length<=1)return null;const pe=ne.findIndex(ie=>ie===k.current);return pe===-1?ne[0]||null:ne[(pe+1)%ne.length]||null},[k?.queue,k?.current]),M=!!(j&&C===j),B=k?.deadline||null,H=k?.idleDeadline||null,_=B?B-d:null,K=H?H-d:null,L=s?.mode==="turns"&&M&&_!=null&&_<=5e3&&_>0,U=s?.mode!=="turns"||E||L,F=_!=null&&Number.isFinite(_)?Math.max(0,Math.ceil(_/1e3)):null,te=K!=null&&Number.isFinite(K)?Math.max(0,Math.ceil(K/1e3)):null,fe=E?F!=null?`${F}s left`:null:M&&F!=null?`Your turn in ${F}s`:null,ce=S?[...U?[{type:"rover",id:S,key:S}]:[],...N?[{type:"rover",id:`${S}-audio`,key:`${S}-audio`}]:[]]:[],Y=vi(ce),T=S&&U?Y[S]:null,X=S&&N?Y[`${S}-audio`]:null,J=ad(S?[S]:[],{enabled:!!S,version:s?.mode}),se=S&&J[S]||null,de=cl(S),q=S&&s?.roster?s.roster.find(ne=>String(ne.id)===String(S)):null,V=q?.battery??null,P=q?.name||(S?`Rover ${S}`:"");return m.useEffect(()=>{if(s?.mode!=="turns"){x(!1),y(null),b.current={active:!1,roverId:null};return}const ne=b.current,pe=E&&!ne.active,ie=E&&S&&S!==ne.roverId;pe||ie?(x(!0),y(Date.now())):!E&&ne.active&&(x(!1),y(null)),b.current={active:E,roverId:S}},[E,S,s?.mode]),m.useEffect(()=>{!p||!g||o>g&&x(!1)},[o,g,p]),r.jsx("section",{className:"panel",children:S?r.jsx(bi,{sessionInfo:T,videoMode:U?"whep":"snapshot",snapshotFeed:se,audioSessionInfo:X,label:P,roverColor:q?.color||null,telemetryFrame:de,batteryConfig:V,layoutFormat:n,overcurrentLimiter:f,songNote:i?.note,qualityNotice:U?null:"Preview feed (low FPS) until your turn.",showTurnCue:p,turnTimerText:fe,turnSeconds:F,isActiveDriver:E,idleSkipSeconds:te}):r.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[r.jsx("p",{children:"You are not assigned to a rover."}),r.jsx("p",{className:"mt-0",children:r.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function fo({label:n,tone:s="muted"}){const i=s==="success"?"bg-emerald-900 text-emerald-100":s==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return r.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${i}`,children:n})}function So(n){if(!Number.isFinite(n))return 0;const s=n%360;return s<0?s+360:s}function Zj(n){if(!Array.isArray(n)||n.length<3)return 0;const[s,i,o]=n,f=Math.max(0,Math.min(255,Number(s)))/255,d=Math.max(0,Math.min(255,Number(i)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,p=Math.max(f,d,h),x=Math.min(f,d,h),g=p-x;if(g===0)return 0;let y=0;return p===f?y=(d-h)/g%6:p===d?y=(h-f)/g+2:y=(f-d)/g+4,So(Math.round(y*60))}function K0(n){const s=So(n),i=1,o=1-Math.abs(s/60%2-1);let f=0,d=0,h=0;return s<60?(f=i,d=o):s<120?(f=o,d=i):s<180?(d=i,h=o):s<240?(d=o,h=i):s<300?(f=o,h=i):(f=i,h=o),[Math.round(f*255),Math.round(d*255),Math.round(h*255)]}function Z0(n){return n?Array.isArray(n.hsColor)?So(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?Zj(n.rgbColor):0:0}function Ij({entity:n,connected:s,controlsLocked:i,onToggle:o,onSetColor:f}){const d=n.state==="unavailable"||!n.available,h=n.state==="on",p=n.type==="light"&&n.supportsColor,x=d?"warn":h?"success":"muted",g=d?"Unavailable":h?"On":"Off",y=i||!s||d,b=y||!p,[S,R]=m.useState(()=>Z0(n)),N=m.useRef(S),k=m.useRef(!1),j=d?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":i?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":h?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!p||k.current)return;const H=Z0(n);N.current=H,R(H)},[n.rgbColor,n.hsColor,p]);const w=H=>{const _=So(Number(H.target.value));N.current=_,R(_)},E=()=>{b||!f||f(n.id,K0(N.current))},C=H=>{H.stopPropagation()},B=`rgb(${(p?K0(N.current):[255,255,255]).join(",")})`;return r.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:y,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${j} disabled:opacity-60 disabled:hover:bg-inherit`,children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[r.jsx("span",{className:"truncate font-semibold text-white",children:n.name||n.id}),p&&r.jsxs(r.Fragment,{children:[r.jsx(fo,{label:g,tone:x}),!s&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),p?r.jsx("div",{className:"-mt-0.5 w-full",onClick:C,onPointerDown:H=>{C(H),k.current=!0},onPointerUp:H=>{C(H),k.current=!1,E()},onPointerCancel:H=>{C(H),k.current=!1,E()},onKeyUp:H=>{C(H),E()},onBlur:E,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:S,onChange:w,disabled:b,"aria-label":`Set color for ${n.name||n.id}`,className:"ha-hue-slider w-full"})})}):r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsx(fo,{label:g,tone:x}),!s&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),p&&r.jsx("span",{className:"pointer-events-none absolute right-1 top-1 h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:B}}),!p&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:h?"Turn off":"Turn on"})]})}function Cg(){const{state:{keymap:n}}=_t(),{session:s,homeAssistantToggle:i,homeAssistantSetLightColor:o}=Le(),f=s?.homeAssistant,d=m.useMemo(()=>f?.entities||[],[f?.entities]),h=f?.lightPolicy||null,p=!!(h?.locked||h?.lockedOn),x=h?.lockState||(h?.lockedOn?"on":null),g=Sn(n?.homeAssistantOn?.[0]),y=Sn(n?.homeAssistantOff?.[0]);if(!f?.enabled)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(d.length===0)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const b=!!f?.connected;return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room Controls"}),r.jsx("span",{className:"text-xs text-slate-500",children:d.length}),p?r.jsx(fo,{label:x==="off"?"Locked Off":"Locked On",tone:"warn"}):null,r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"On"}),g?r.jsx(I0,{label:g}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),y?r.jsx(I0,{label:y}):null]})]})]}),r.jsx(fo,{label:b?"Connected":"Offline",tone:b?"success":"warn"})]}),p?r.jsx("p",{className:"rounded border border-amber-600/60 bg-amber-900/40 px-1 py-0.5 text-xs text-amber-100",children:x==="off"?"Lights are locked off. Room controls are disabled.":"Lights are locked on. Room controls are disabled."}):null,r.jsx("div",{className:"flex flex-wrap gap-0.5",children:d.map(S=>r.jsx(Ij,{entity:S,connected:b,controlsLocked:p,onToggle:i,onSetColor:o},S.id))})]})}function I0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Eg(){const{login:n,setRole:s}=Le(),[i,o]=m.useState(""),[f,d]=m.useState(""),[h,p]=m.useState(!1);async function x(g){g.preventDefault(),p(!0);try{await n(i,f),o(""),d("")}catch(y){alert(y.message)}finally{p(!1)}}return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),r.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:x,children:[r.jsx("input",{className:"field-input",placeholder:"Username",value:i,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:f,onChange:g=>d(g.target.value)}),r.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function J0(...n){return n.filter(Boolean).join(" ")}function Jj(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function Pj(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Wj({title:n,roster:s=[],emptyText:i="No roster data.",renderActions:o=null}){return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),s.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:i}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:s.map(f=>{const d=!!(f?.private?.enabled&&f?.private?.open),h=!!f?.locked;return r.jsxs("li",{className:J0("surface flex flex-wrap items-center justify-between gap-0.5",h?"bg-red-900/40":d?"bg-amber-700/35 border border-amber-200/30":null),children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-slate-200",children:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(f.color,.16),children:f.name})}),r.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[r.jsx("span",{children:f.locked?"locked":"free"}),f.lockReason&&r.jsx("span",{className:"rounded bg-black/30 px-1",children:f.lockReason}),r.jsxs("span",{className:J0("font-semibold",Pj(f)),children:["Battery ",Jj(f)]})]})]}),o?o(f):null]},f.id)})})]})}const eN=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function tN(){const{session:n,lockRover:s,setMode:i,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:h,rebootServer:p,setAudioLevels:x,setPrivateSafety:g,llmControl:y,adminLogs:b,llmCommentaryState:S}=Le(),R=m.useMemo(()=>n?.roster??[],[n?.roster]),[N,k]=m.useState({}),[j,w]=m.useState({}),[E,C]=m.useState(!1),[M,B]=m.useState(!1),H=n?.health||null,_=n?.communityGoal?.text||"",K=n?.communityGoal?.updatedAt||null,[L,U]=m.useState(_),F=n?.adminReason?.text||"",te=n?.adminReason?.updatedAt||null,[fe,ce]=m.useState(F),Y=n?.audioLevels||{},[T,X]=m.useState({hornGain:Number.isFinite(Y.hornGain)?Y.hornGain:1,ttsGain:Number.isFinite(Y.ttsGain)?Y.ttsGain:1,forwardGain:Number.isFinite(Y.forwardGain)?Y.forwardGain:1}),[J,se]=m.useState({}),de=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",q=n?.role==="lockdown"||n?.role==="lockdown-admin",V=n?.mode??"open",P=async(le,re)=>{try{await s(le,re),k(me=>({...me,[le]:re}))}catch(me){alert(me.message)}},ne=async le=>{const re=le.target.value;try{await i(re)}catch(me){alert(me.message)}},pe=async le=>{try{await o(le,{force:!0})}catch(re){alert(re.message)}},ie=async le=>{if(!(!le?.id||!window.confirm(`Reboot rover "${le.name||le.id}" now?`))){w(me=>({...me,[le.id]:!0}));try{await h(le.id)}catch(me){alert(me.message)}finally{w(me=>({...me,[le.id]:!1}))}}},oe=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){C(!0);try{await p()}catch(re){alert(re.message),C(!1)}}},ve=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){B(!0);try{await y("clearHistory")}catch(re){alert(re.message)}finally{B(!1)}}},ye=async()=>{try{await f(L)}catch(le){alert(le.message)}},xe=async()=>{try{await f(null)}catch(le){alert(le.message)}},Ue=async()=>{try{await d(fe)}catch(le){alert(le.message)}},$e=async()=>{try{await d(null)}catch(le){alert(le.message)}},Ne=le=>re=>{const me=Number(re.target.value);X(we=>({...we||{},[le]:Number.isFinite(me)?me:1}))},ae=async()=>{try{await x(T)}catch(le){alert(le.message)}};m.useEffect(()=>{U(_)},[_]),m.useEffect(()=>{ce(F)},[F]),m.useEffect(()=>{X({hornGain:Number.isFinite(Y.hornGain)?Y.hornGain:1,ttsGain:Number.isFinite(Y.ttsGain)?Y.ttsGain:1,forwardGain:Number.isFinite(Y.forwardGain)?Y.forwardGain:1})},[Y.forwardGain,Y.hornGain,Y.ttsGain]),m.useEffect(()=>{const le={};(R||[]).forEach(re=>{re?.private?.enabled&&(le[re.id]={speedLimitEnabled:!!re?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(re?.private?.safety?.speedLimitMaxWheelSpeed)?re.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!re?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(re?.private?.safety?.overcurrentStopMs)?re.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!re?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(re?.private?.safety?.bumpBackoffSpeed)?re.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(re?.private?.safety?.bumpBackoffMs)?re.private.safety.bumpBackoffMs:350,cliffEnabled:!!re?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(re?.private?.safety?.cliffBackoffSpeed)?re.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(re?.private?.safety?.cliffBackoffMs)?re.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(re?.private?.safety?.triggerCooldownMs)?re.private.safety.triggerCooldownMs:800})}),se(le)},[R]);const ue=m.useMemo(()=>{const le={};return R.forEach(re=>{le[re.id]=N[re.id]??re.locked}),le},[R,N]),be=(le,re={})=>{se(me=>({...me||{},[le]:{...me?.[le]||{},...re||{}}}))},Me=async le=>{try{const re=J?.[le];if(!re)return;await g(le,re)}catch(re){alert(re.message)}};return de?r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[r.jsx("span",{children:"Admin controls"}),r.jsx("select",{value:V,onChange:ne,className:"field-input text-sm",children:eN.map(le=>r.jsx("option",{value:le.key,children:le.label},le.key))})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:oe,disabled:E,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:E?"Server rebooting...":"Reboot Server"})}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Global audio levels"}),n?.audioLevels?.updatedAt?r.jsxs("span",{children:["Updated ",new Date(n.audioLevels.updatedAt).toLocaleString()]}):null]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Horn gain"}),r.jsxs("span",{children:[T.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.hornGain,onChange:Ne("hornGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"TTS gain"}),r.jsxs("span",{children:[T.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.ttsGain,onChange:Ne("ttsGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Forward gain"}),r.jsxs("span",{children:[T.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.forwardGain,onChange:Ne("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ae,className:"button-dark",children:"Apply audio levels"})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Community goal"}),K?r.jsxs("span",{children:["Updated ",new Date(K).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:L,onChange:le=>U(le.target.value),placeholder:"Set a community goal",className:"field-input text-sm"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:ye,className:"button-dark",children:"Set goal"}),r.jsx("button",{type:"button",onClick:xe,className:"button-danger",children:"Clear"})]})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Admin mode reason"}),te?r.jsxs("span",{children:["Updated ",new Date(te).toLocaleString()]}):null]}),r.jsx("textarea",{value:fe,onChange:le=>ce(le.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:Ue,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:$e,className:"button-danger",children:"Clear"})]})]}),r.jsx(Wj,{roster:R,renderActions:le=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>P(le.id,!ue[le.id]),className:"button-dark",children:ue[le.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>pe(le.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>ie(le),disabled:!!j[le.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:j[le.id]?"Rebooting...":"Reboot"}),le?.private?.enabled?r.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[r.jsx("div",{className:"text-slate-300",children:"Private safety"}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.speedLimitEnabled,disabled:!q,onChange:re=>be(le.id,{speedLimitEnabled:!!re.target.checked})}),r.jsx("span",{children:"Speed limit"})]}),r.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!q,value:J?.[le.id]?.speedLimitMaxWheelSpeed??250,onChange:re=>be(le.id,{speedLimitMaxWheelSpeed:Number(re.target.value)||250})}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.hardOvercurrentEnabled,disabled:!q,onChange:re=>be(le.id,{hardOvercurrentEnabled:!!re.target.checked})}),r.jsx("span",{children:"Hard overcurrent"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.hardBumpEnabled,disabled:!q,onChange:re=>be(le.id,{hardBumpEnabled:!!re.target.checked})}),r.jsx("span",{children:"Hard bump"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.cliffEnabled,disabled:!q,onChange:re=>be(le.id,{cliffEnabled:!!re.target.checked})}),r.jsx("span",{children:"Cliff safety"})]}),r.jsx("button",{type:"button",disabled:!q,onClick:()=>Me(le.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),r.jsx(lN,{health:H,roster:R}),r.jsx(nN,{state:S,onClearHistory:ve,clearingHistory:M}),r.jsx(iN,{entries:b})]}):null}function nN({state:n,onClearHistory:s,clearingHistory:i}){const[o,f]=m.useState(null);if(!n)return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const d=n.runtime||{},h=n.counters||{},p=n.timings||{},x=n.input||{},g=n.output||{},y=n.errors||{},b=Array.isArray(n.history)?n.history:[],S=b.find(j=>j.runId===o)||(b.length?b[b.length-1]:null),R=aN(n),N=sN(x.modelMessages,g.raw),k=[{label:"running",value:d.running?"yes":"no"},{label:"in flight",value:d.inFlight?"yes":"no"},{label:"phase",value:d.phase||"--"},{label:"run id",value:d.currentRunId??"--"},{label:"tick count",value:d.tickCount??0},{label:"last tick",value:d.lastTickAt?new Date(d.lastTickAt).toLocaleString():"never"},{label:"next run",value:d.nextRunAt?new Date(d.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:d.outcome||"--"},{label:"reason",value:d.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:p.lastGenerationMs!=null?`${p.lastGenerationMs} ms`:"--"},{label:"avg gen",value:p.avgGenerationMs!=null?`${p.avgGenerationMs} ms`:"--"},{label:"gen count",value:p.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:s,disabled:!!i,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:i?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${R.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:R.label}),r.jsx("div",{className:"text-xs text-slate-200",children:R.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:k.map(j=>r.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[j.label,": ",j.value]},j.label))}),y.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",y.message]}):null,y.details?r.jsxs("details",{className:"surface text-xs text-red-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(y.details,null,2)})]}):null,g.generated?r.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?r.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),r.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:N.length?N.map(j=>r.jsx(Zf,{message:j.message},j.id)):r.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),r.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),r.jsxs("div",{children:["Output at:"," ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),r.jsxs("div",{children:["Failed at: ",y.failedAt?new Date(y.failedAt).toLocaleString():"n/a"]})]})]})]}),r.jsxs("details",{className:"surface text-xs text-slate-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),r.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(j=>r.jsxs("button",{type:"button",onClick:()=>f(j.runId),className:`w-full text-left surface ${S?.runId===j.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",j.runId]})," ",r.jsx("span",{className:"text-slate-200",children:j.outcome||j.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:j.durationMs!=null?`${j.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:j.reason||""})]},j.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),S?r.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[r.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",S.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(S,null,2)})]}):null]})}function aN(n){const s=n?.runtime||{},i=n?.output||{},o=n?.errors||{};return s.inFlight?{label:"IN FLIGHT",detail:s.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:s.outcome==="posted"?{label:"POSTED",detail:i.posted?`Last: ${i.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:s.outcome==="skipped"?{label:"SKIPPED",detail:s.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:s.outcome==="failed"?{label:"FAILED",detail:o.message||s.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:s.running?"IDLE":"STOPPED",detail:s.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function sN(n,s){const i=Date.now(),f=(Array.isArray(n)?n:[]).map((d,h)=>{const p=String(d?.role||"").toLowerCase(),x=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=p==="system"?"LLM System":p==="assistant"?"LLM Context":p==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:i+h,nickname:g,text:x,role:"spectator",system:p==="system"}}});if(s!=null){const d=String(s);f.push({id:"llm-output",message:{ts:i+f.length+1,nickname:"LLM Output",text:d.trim()?d:"<empty>",role:"spectator",system:!0}})}return f}function lN({health:n,roster:s=[]}){if(!n)return null;const i=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},f=x=>s.find(g=>String(g.id)===String(x))?.color||null,d=`${i.readyCount}/${i.totalCount} sources ready`,h=o.rovers.filter(x=>x.stale).length,p=o.rooms.filter(x=>x.stale).length;return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Replay segments"}),r.jsx("span",{className:"text-slate-400",children:d})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rovers.length-h,"/",o.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rooms.length-p,"/",o.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.sources.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:`${x.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:x.type==="rover"?ra(f(x.id),.16):void 0,children:x.label}),r.jsxs("span",{className:x.ready?"text-emerald-300":"text-amber-300",children:[x.recentCount,"/",x.neededCount]})]},`${x.type}:${x.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(f(x.id),.16),children:x.name}),r.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.stale?"stale":"ok"})]},`rover:${x.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:x.name}),r.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.error?"error":x.stale?"stale":"ok"})]},`room:${x.id}`))})]})}function iN({entries:n}){const s=n||[];return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Admin IP log"}),r.jsx("span",{children:s.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No admin log entries yet."}):s.slice().reverse().map(i=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:i.ts?new Date(i.ts).toLocaleTimeString():"--"})," ",i.label&&r.jsxs("span",{className:"text-teal-400",children:["[",i.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:i.message})," ",i.ip&&r.jsx("span",{className:"text-cyan-300",children:i.ip})," ",i.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(i.meta)})]},i.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const rN=[{id:"driveForward",label:"Drive Forward",group:"Driving"},{id:"driveBackward",label:"Drive Backward",group:"Driving"},{id:"driveLeft",label:"Turn Left",group:"Driving"},{id:"driveRight",label:"Turn Right",group:"Driving"},{id:"boostModifier",label:"Boost Modifier",group:"Driving"},{id:"slowModifier",label:"Slow Modifier",group:"Driving"},{id:"auxMainForward",label:"Main Brush Forward",group:"Aux Motors"},{id:"auxMainReverse",label:"Main Brush Reverse",group:"Aux Motors"},{id:"auxSideForward",label:"Side Brush Forward",group:"Aux Motors"},{id:"auxSideReverse",label:"Side Brush Reverse",group:"Aux Motors"},{id:"auxVacuumFast",label:"Vacuum Max",group:"Aux Motors"},{id:"auxVacuumSlow",label:"Vacuum Low",group:"Aux Motors"},{id:"auxAllForward",label:"All Aux Forward",group:"Aux Motors"},{id:"cameraUp",label:"Camera Up",group:"Camera"},{id:"cameraDown",label:"Camera Down",group:"Camera"},{id:"nightVisionToggle",label:"Toggle Night Vision",group:"Camera"},{id:"hornHonk",label:"Horn (Hold)",group:"Audio"},{id:"micPtt",label:"Mic Push To Talk",group:"Audio"},{id:"driveMacro",label:"Drive Macro",group:"Macros"},{id:"dockMacro",label:"Dock Macro",group:"Macros"},{id:"chatFocus",label:"Toggle Chat",group:"Chat"},{id:"songNoteUp",label:"Song Note Up",group:"Audio"},{id:"songNoteDown",label:"Song Note Down",group:"Audio"},{id:"homeAssistantOn",label:"Room Controls On (Cycle)",group:"Room Controls"},{id:"homeAssistantOff",label:"Room Controls Off (Cycle)",group:"Room Controls"}];function oN(n){return n.reduce((s,i)=>((s[i.group]||(s[i.group]=[])).push(i),s),{})}function cN(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):s}const rd=5,Si=500,Ai=1,od=100;function uN(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(rd,Math.min(Si,i)):s}function ao(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(Ai,Math.min(od,i)):s}function fN(n){const i=(ao(n,n)-Ai)/(od-Ai),o=Si-i*(Si-rd);return Math.round(o)}function dN(n){const s=uN(n,n),i=(Si-s)/(Si-rd),o=Ai+i*(od-Ai);return Math.round(o)}function mN(n){const[s,i]=m.useState(null),o=m.useCallback(h=>{Pu(!0),i(h)},[]),f=m.useCallback(()=>{Pu(!1),i(null)},[]),d=m.useCallback((h,p)=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){f();return}const x=ki(p.key??"");x&&(n(h,x,p),f())},[f,n]);return m.useEffect(()=>()=>Pu(!1),[]),{active:s,startCapture:o,cancel:f,captureFromEvent:d}}function Xr({label:n,description:s,value:i,onChange:o,min:f=0,max:d=500,step:h=5}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("input",{type:"number",min:f,max:d,value:i,onChange:p=>o(p.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[r.jsx("input",{type:"range",min:f,max:d,step:h,value:i,onChange:p=>o(p.target.value),className:"h-2 flex-1 accent-emerald-400"}),r.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:i})]})]})}function hN(){const{state:{keymap:n},actions:{updateKeyBinding:s,resetKeyBindings:i}}=_t(),{value:o,save:f}=Fe("inputs",kn),d={...kn.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof d.tiltSpeed=="number"?ao(d.tiltSpeed,kn.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?ao(dN(d.tiltIntervalMs),kn.keyboard.tiltSpeed):kn.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),p=m.useMemo(()=>oN(rN),[]),{active:x,startCapture:g,cancel:y,captureFromEvent:b}=mN((k,j)=>{s(k,j)}),S=m.useCallback(k=>n?.[k]?.[0]||di[k]?.[0]||"",[n]),R=m.useCallback((k,j)=>{const w=kn.keyboard,E=cN(j,w[k]);f(C=>({...C??{},keyboard:{...C?.keyboard??w,[k]:E}}))},[f]),N=m.useCallback(k=>{const j=kn.keyboard,w=ao(k,j.tiltSpeed),E=fN(w);f(C=>({...C??{},keyboard:{...C?.keyboard??j,tiltSpeed:w,tiltIntervalMs:E}}))},[f]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),r.jsx("button",{type:"button",onClick:()=>i(),className:"button-dark text-xs",children:"Reset defaults"})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Xr,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:k=>R("baseSpeed",k)}),r.jsx(Xr,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:k=>R("turboSpeed",k)}),r.jsx(Xr,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:k=>R("precisionSpeed",k)})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),r.jsx(Xr,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:h,onChange:N,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([k,j])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:k}),r.jsx("div",{className:"space-y-0.5",children:j.map(w=>{const E=S(w.id),C=x===w.id;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:w.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Sn(E)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[C&&r.jsx("button",{type:"button",onClick:()=>y(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(w.id),onKeyDown:C?M=>b(w.id,M):void 0,autoFocus:C,className:`${C?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium transition-colors`,children:C?"Press a key…":"Change"})]})]},w.id)})})]},k))})]})}const aa=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),pN=[{id:"drive",label:"Drive stick",kind:"axisPair",section:"Driving",invertDefaults:{invertX:!1,invertY:!0}},{id:"cameraTilt",label:"Camera tilt",kind:"axis",section:"Camera",invertDefaults:{invert:!0}},{id:"mainBrush",label:"Main brush",kind:"axis",section:"Brushes",invertDefaults:{invert:!1}},{id:"sideBrush",label:"Side brush",kind:"axis",section:"Brushes",invertDefaults:{invert:!1}},{id:"vacuum",label:"Vacuum",kind:"button",section:"Aux buttons"},{id:"allAux",label:"All aux",kind:"button",section:"Aux buttons"},{id:"mainReverse",label:"Main reverse toggle",kind:"button",section:"Brush toggles"},{id:"sideReverse",label:"Side reverse toggle",kind:"button",section:"Brush toggles"},{id:"driveMacro",label:"Drive macro",kind:"button",section:"Mode macros"},{id:"dockMacro",label:"Dock macro",kind:"button",section:"Mode macros"},{id:"nightVisionToggle",label:"Night vision toggle",kind:"button",section:"Camera"}],P0=.45,xN=.6;function ci({label:n,description:s,min:i,max:o,step:f,value:d,onChange:h}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("span",{className:"font-mono text-slate-400",children:aa.format(d)})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsx("input",{type:"range",min:i,max:o,step:f,value:d,onChange:p=>h(Number(p.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function gN(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const s=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${s?` (${s})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const s=n.direction<0?"<":">";return`Axis ${n.index} ${s} ${aa.format(n.threshold??.6)}`}return"Unassigned"}function vN(n){return n.reduce((s,i)=>((s[i.section]||(s[i.section]=[])).push(i),s),{})}function yN(n,s){if(!n||n.length===0)return null;if(s){const i=n.find(o=>o.signature===s);if(i)return i}return n[0]}function bN(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0}))}}function SN(n,s,i){const o=(n.axes??[]).map((d,h)=>({index:h,delta:Math.abs((d??0)-(s.axes?.[h]??0)),value:d}));if(o.sort((d,h)=>h.delta-d.delta),i.kind==="axisPair"){const d=o.filter(h=>h.delta>P0).slice(0,2);return d.length<2?null:{kind:"axisPair",x:d[0].index,y:d[1].index,...i.invertDefaults??{}}}const f=o.find(d=>d.delta>P0);return f?{kind:"axis",index:f.index,...i.invertDefaults??{}}:null}function AN(n,s,i){const o=n.buttons??[];for(let d=0;d<o.length;d+=1){const h=o[d],p=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||p>xN)return i.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=n.axes??[];for(let d=0;d<f.length;d+=1){const h=f[d]??0,p=Math.abs(h-(s.axes?.[d]??0));if(Math.abs(h)>.7&&p>.5)return i.kind==="axis"?{kind:"axis",index:d,...i.invertDefaults??{}}:{kind:"axisButton",index:d,direction:h>=0?1:-1,threshold:.6}}return null}function jN(n,s,i){if(!n)return null;if(i.kind==="axis"||i.kind==="axisPair"){const o=SN(n,s,i);if(o)return o}return AN(n,s,i)}function NN(){const n=WA(),{value:s,save:i}=Fe("gamepad",Da),[o,f]=m.useState(null),d=m.useRef(null),h=m.useMemo(()=>vN(pN),[]),p=m.useMemo(()=>yN(n.pads,s.activeSignature),[n.pads,s.activeSignature]),x=p?.signature??null,g=m.useMemo(()=>x?s?.profiles?.[x]??s?.defaults?.profile??sa:s?.defaults?.profile??sa,[x,s?.defaults?.profile,s?.profiles]);m.useEffect(()=>{!p||!x||s?.profiles?.[x]||i(j=>{const w=j??Da;if(w.profiles?.[x])return w;const E=w?.defaults?.profile??sa,C=dg(p,E);return{...w,profiles:{...w.profiles??{},[x]:C}}})},[p,x,s?.profiles,i]),m.useEffect(()=>{d.current=null},[o,x]),m.useEffect(()=>{if(!o||!p)return;if(!d.current){d.current=bN(p);return}const j=jN(p,d.current,o);j&&(i(w=>{const E=w??Da,C=E.profiles?.[x]??E?.defaults?.profile??sa,M={...C,bindings:{...C.bindings??{},[o.id]:{...C.bindings?.[o.id]??{},kind:o.kind,sources:[j]}}};return{...E,profiles:{...E.profiles??{},[x]:M}}}),f(null))},[p,x,o,i]);const y=m.useCallback(j=>{i(w=>({...w??Da,activeSignature:j||null}))},[i]),b=m.useCallback(j=>{i(w=>{const E=w??Da,C=(x&&E.profiles?.[x])??E?.defaults?.profile??sa,M={...C,calibration:{...C.calibration??{},...j}};return x?{...E,profiles:{...E.profiles??{},[x]:M}}:{...E,defaults:{...E.defaults??{},profile:M}}})},[x,i]),S=m.useCallback((j,w)=>{i(E=>{const C=E??Da,M=(x&&C.profiles?.[x])??C?.defaults?.profile??sa,B=w(M.bindings?.[j]??{}),H={...M,bindings:{...M.bindings??{},[j]:B}};return x?{...C,profiles:{...C.profiles??{},[x]:H}}:{...C,defaults:{...C.defaults??{},profile:H}}})},[x,i]),R=m.useCallback(j=>{S(j.id,w=>({...w,sources:[]}))},[S]),N=m.useCallback((j,w)=>{S(j.id,E=>{const C=Array.isArray(E.sources)?[...E.sources]:[];if(!C[0])return E;const M={...C[0]};return w==="invertX"?M.invertX=!M.invertX:w==="invertY"?M.invertY=!M.invertY:M.invert=!M.invert,C[0]=M,{...E,sources:C}})},[S]),k=m.useMemo(()=>p?{outputs:mg(p,g)}:null,[p,g]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:p?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&r.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),n.pads.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[r.jsx("select",{value:x??"",onChange:j=>y(j.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(j=>r.jsx("option",{value:j.signature,children:j.id||"Unknown controller"},j.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:p?.mapping??"unknown"})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ci,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:j=>b({driveDeadzone:j})}),r.jsx(ci,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:j=>b({cameraDeadzone:j})}),r.jsx(ci,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:j=>b({auxDeadzone:j})}),r.jsx(ci,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:j=>b({auxSideScale:j})}),r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),r.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:j=>b({cameraMode:j.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[r.jsx("option",{value:"absolute",children:"Absolute"}),r.jsx("option",{value:"velocity",children:"Velocity"})]})]}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),r.jsx(ci,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:j=>b({cameraSensitivity:j})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([j,w])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:j}),r.jsx("div",{className:"space-y-0.5",children:w.map(E=>{const M=g.bindings?.[E.id]?.sources?.[0]??null;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:E.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:gN(M)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[E.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),E.kind==="axis"&&r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>R(E),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(E),className:`${o?.id===E.id?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium`,children:o?.id===E.id?"Waiting…":"Capture"})]})]},E.id)})})]},j))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),p?r.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[r.jsx("p",{className:"text-slate-400",children:"Raw axes"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.axes.map((j,w)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",w,": ",aa.format(j)]},`axis-${w}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.buttons.map((j,w)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",w,": ",aa.format(j.value)," ",j.pressed?"●":""]},`btn-${w}`))}),k?.outputs&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",aa.format(k.outputs.driveVector.x),","," ",aa.format(k.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",aa.format(k.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",aa.format(k.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",aa.format(k.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const wN={drive:"Drive wheels",aux:"Aux motors"};function W0(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function CN({value:n,color:s="bg-emerald-500"}){const i=`${Math.round(Math.max(0,Math.min(1,n))*100)}%`;return r.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:r.jsx("div",{className:`h-full ${s}`,style:{width:i}})})}function EN(){const{state:{roverId:n},overcurrentLimiter:s}=_t(),i=m.useMemo(()=>tl.map(o=>o.key),[]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Overcurrent limiter"}),r.jsx("span",{children:s?.adminImmune?"Admin immune":"Active"})]}),n?r.jsxs("div",{className:"space-y-0.5",children:[i.map(o=>{const f=s?.caps?.[o]?.cap??0,d=s?.overcurrent?.groups?.[o]??!1,h=s?.scales?.perGroup?.[o]??1;return r.jsxs("div",{className:"surface space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-slate-200",children:wN[o]||o}),r.jsx("span",{className:d?"text-red-300":"text-slate-400",children:d?"overcurrent":"ok"})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Cap"}),r.jsx("span",{children:W0(f)})]}),r.jsx(CN,{value:f,color:"bg-amber-500"}),r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Scale"}),r.jsx("span",{children:W0(h)})]})]})]},o)}),r.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Down rate ${s?.config?.downRatePerSec}/s · Up rate ${s?.config?.upRatePerSec}/s`}),r.jsx("div",{children:`Release delay ${s?.config?.releaseDelaySec}s`}),r.jsx("div",{children:`Output rate ${s?.config?.outputRateMs}ms`})]})]}):r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const kg=m.createContext(null);function Mg(){const n=m.useContext(kg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const ex={primary:{base:"flex-1 px-0.5 py-0.5 text-sm font-medium focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-slate-500 rounded-md border border-slate-800",active:"bg-sky-600 text-white border-white",inactive:"bg-zinc-900 text-slate-300 hover:bg-sky-500 hover:text-white"}},tx={none:"",pink:"bg-pink-500 text-white border-pink-200 hover:bg-pink-400",green:"bg-emerald-500 text-white border-emerald-200 hover:bg-emerald-400"},qg="primary";function cd(...n){return n.filter(Boolean).join(" ")}function ud({children:n,defaultTab:s,currentTab:i,onTabChange:o,variant:f=qg}){const[d,h]=m.useState(s??null),[p,x]=m.useState([]),g=m.useCallback(R=>R?(x(N=>N.includes(R)?N:[...N,R]),()=>x(N=>N.includes(R)?N.filter(k=>k!==R):N)):()=>{},[]),y=i??d??p[0]??null;m.useEffect(()=>{s&&i===void 0&&h(s)},[s,i]);const b=m.useCallback(R=>{R&&(i===void 0&&h(R),o&&o(R))},[i,o]),S=m.useMemo(()=>({activeTab:y,setActiveTab:b,registerTab:g,variant:f}),[y,b,g,f]);return r.jsx(kg.Provider,{value:S,children:n})}function fd({children:n,className:s=""}){return r.jsx("div",{className:cd("flex gap-0.5",s),children:n})}function Pt({id:n,children:s,className:i="",disabled:o=!1,highlight:f="none"}){const{activeTab:d,setActiveTab:h,registerTab:p,variant:x}=Mg();m.useEffect(()=>p(n),[n,p]);const g=ex[x]??ex[qg],y=d===n,b=tx[f]||tx.none,S=cd(g.base,b||(y?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",i);return r.jsx("button",{type:"button",className:S,onClick:()=>!o&&h(n),"aria-pressed":y,"aria-disabled":o,children:s})}function dd({children:n,className:s=""}){return r.jsx("div",{className:cd("mt-0 space-y-0.5",s),children:n})}function Wt({id:n,children:s,keepMounted:i=!1}){const{activeTab:o}=Mg(),f=o===n;return!f&&!i?null:!f&&i?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:s}):r.jsx(r.Fragment,{children:s})}function kN(){const{session:n}=Le(),s=m.useMemo(()=>JSON.stringify(n??{},null,2),[n]);return r.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),r.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:s})]})}const nx=300,ax=240;function MN(n,s){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(s||(s=new WeakSet),typeof n=="object"){if(s.has(n))return"[Circular]";s.add(n)}try{return JSON.stringify(n,(i,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function qN(n){const i=n.map(o=>MN(o)).join(" ");return i.length>ax?`${i.slice(0,ax)}…`:i}function RN(){const n=pn(),[s,i]=m.useState([]),o=m.useMemo(()=>s.reduce((f,d)=>(d.direction==="in"&&(f.in+=1),d.direction==="out"&&(f.out+=1),f),{in:0,out:0}),[s]);return m.useEffect(()=>{const f=(x,g,y)=>{i(b=>{const S=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:qN(y),timestamp:new Date().toLocaleTimeString()}];return S.length>nx?S.slice(-nx):S})},d=(x,...g)=>f("in",x,g),h=(x,...g)=>f("out",x,g);n.onAny(d);let p=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(h),p=()=>n.offAnyOutgoing(h);else{const x=n.emit.bind(n);n.emit=(g,...y)=>(h(g,...y),x(g,...y)),p=()=>{n.emit=x}}return()=>{n.offAny(d),p&&p()}},[n]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Socket activity"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),r.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),r.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>i([]),children:"Clear"})]})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No socket activity yet."}):s.slice().reverse().map(f=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-slate-400",children:f.timestamp})," ",r.jsxs("span",{className:f.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",f.direction.toUpperCase(),"]"]})," ",r.jsx("span",{className:"text-cyan-300",children:f.event})," ",r.jsx("span",{className:"text-slate-200",children:f.payload})]},f.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const TN=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Rg(){const{state:{roverId:n},actions:{sendOiCommand:s,setSensorStream:i}}=_t(),o=!!n,[f,d]=Ng(),h=pn(),{value:p,save:x}=Fe("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:y}=Fe("audio",St),b=p?.connectionTransport||"websocket",S=!!p?.swapMobileControlColumns,R=typeof p?.driveMacroBackoffEnabled=="boolean"?p.driveMacroBackoffEnabled:!0,N=Number.isFinite(g?.masterVolume)?g.masterVolume:St.masterVolume,k=Number.isFinite(g?.alertVolume)?g.alertVolume:St.alertVolume,j=Number.isFinite(g?.roverVolume)?g.roverVolume:St.roverVolume,w=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:St.mainBrushDuckEnabled,E=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):St.mainBrushDuckAmount,C=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),M=U=>{n&&i(U)},B=U=>{const F=U.target.value;x(te=>({...te??{},connectionTransport:F})),h?.io?.opts&&(h.io.opts.transports=F==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},H=U=>F=>{const te=Number(F.target.value),fe=Number.isFinite(te)?Math.max(0,Math.min(1,te)):0;y(ce=>({...ce??{},[U]:fe}))},_=U=>{const F=!!U.target.checked;y(te=>({...te??{},mainBrushDuckEnabled:F}))},K=U=>{const F=!!U.target.checked;x(te=>({...te??{},swapMobileControlColumns:F}))},L=U=>{const F=!!U.target.checked;x(te=>({...te??{},driveMacroBackoffEnabled:F}))};return r.jsxs(ud,{defaultTab:"keybindings",children:[r.jsxs(fd,{children:[r.jsx(Pt,{id:"keybindings",children:"Keybindings"}),r.jsx(Pt,{id:"controller",children:"Controller"}),r.jsx(Pt,{id:"page",children:"Page settings"}),r.jsx(Pt,{id:"admin",children:"Admin"})]}),r.jsxs(dd,{children:[r.jsx(Wt,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(hN,{})})}),r.jsx(Wt,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(NN,{})})}),r.jsx(Wt,{id:"page",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"HUD"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:f,onChange:U=>d(U.target.checked)}),r.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:S,onChange:K}),r.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Macros"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:R,onChange:L}),r.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Audio"}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Master volume"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:H("masterVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Alert/page sounds"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(k*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:k,onChange:H("alertVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Rover audio"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(j*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:j,onChange:H("roverVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Main brush ducking"}),r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:w,onChange:_})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Main brush duck amount"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(E*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:H("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!w})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Connection"}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Transport"}),r.jsxs("select",{value:b,onChange:B,className:"field-input text-sm",children:[r.jsx("option",{value:"websocket",children:"WebSocket"}),r.jsx("option",{value:"polling",children:"Polling"})]})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),r.jsx(Wt,{id:"admin",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:TN.map(U=>r.jsx("button",{type:"button",onClick:()=>s(U.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:U.label},U.key))})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),r.jsx("div",{className:"surface flex gap-0.5",children:C.map(U=>r.jsx("button",{type:"button",onClick:()=>M(U.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:U.label},U.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(Eg,{}),r.jsx(EN,{}),r.jsx(tN,{}),r.jsx(kN,{}),r.jsx(RN,{})]})})]})]})}const sx={desktop:{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel, on the bottom left of the page below the rover video.",{segments:["Toggle chat focus with ",{action:"chatFocus"},". Press ",{action:"chatFocus"}," again to send."]}]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen, or press ',{action:"driveMacro"}," on your keyboard to put the rover into driving mode."]},"Refer to the controls for the controls for the rover."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen, or press ',{action:"dockMacro"}," on your keyboard to start docking."]},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}],aside:[{type:"keyboard",title:"Keyboard controls",footnote:"Per-browser; adjust bindings and speeds in Settings → Keybindings.",groups:[{id:"movement",title:"Movement",items:[{action:"driveForward",label:"Forward"},{action:"driveBackward",label:"Backward"},{action:"driveLeft",label:"Turn left"},{action:"driveRight",label:"Turn right"},{action:"boostModifier",label:"Boost speed"},{action:"slowModifier",label:"Precision speed"}]},{id:"macros",title:"Rover modes & chat",items:[{action:"driveMacro",label:"Drive macro"},{action:"dockMacro",label:"Dock macro"},{action:"chatFocus",label:"Chat focus"}]},{id:"camera",title:"Camera",items:[{action:"cameraUp",label:"Tilt up"},{action:"cameraDown",label:"Tilt down"},{action:"nightVisionToggle",label:"Toggle night vision"}]},{id:"motors",title:"Rover Aux Motors",items:[{action:"auxMainForward",label:"Main brush forward"},{action:"auxMainReverse",label:"Main brush reverse"},{action:"auxSideForward",label:"Side brush forward"},{action:"auxSideReverse",label:"Side brush reverse"},{action:"auxVacuumFast",label:"Vacuum max"},{action:"auxVacuumSlow",label:"Vacuum low"},{action:"auxAllForward",label:"All motors forward"}]},{id:"audio",title:"Audio / Song",items:[{action:"songNoteUp",label:"Song note up"},{action:"songNoteDown",label:"Song note down"}]},{id:"room-controls",title:"Room Controls",items:[{action:"homeAssistantOn",label:"Next room control on"},{action:"homeAssistantOff",label:"Next room control off (reverse)"}]}]},{type:"gamepad",title:"Gamepad / joystick",items:["Gamepad controls are fully configurable to handle inconsistent browser mappings.","Use Settings → Controller to bind inputs, calibrate deadzones, and view diagnostics.","If inputs behave oddly, the diagnostics panel will show raw axis/button values."]}]},"mobile-portrait":{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen to put the rover into driving mode.']},"Look below the rover video. Use the joystick column to move the rover, and hold the aux buttons in the other control column."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]},"mobile-landscape":{main:[{type:"list",title:"Chat and nicknames",items:["Scroll down to see more of the page.","Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button, or the "Drive" button to put the rover into driving mode.']},"Use the joystick column beside the video feed to move the rover, and hold the aux buttons in the other control column."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" or the "Dock" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]}};function DN(n){return sx[n]||sx.desktop}function Tg({actionId:n,keymap:s}){const i=s?.[n]?.[0]??"";return r.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:Sn(i)})}function lx(n,s){return n.map((i,o)=>typeof i=="string"?r.jsx("span",{children:i},`text-${o}`):i?.action?r.jsx(Tg,{actionId:i.action,keymap:s},`pill-${i.action}-${o}`):i?.text?r.jsx("span",{children:i.text},`span-${o}`):null)}function Ao(n,s,i){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return lx(n.segments,s);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return lx(n,s)}return String(n??"")}function _N({hero:n,keymap:s}){return n?r.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-white",children:n.title}),n.subtitle&&r.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&r.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(i=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:i},i))})]}),n.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((i,o)=>{const f=Array.isArray(i?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Ao(i,s)},f)})})]}):null}function ON({block:n,keymap:s}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items.map((i,o)=>{const f=`item-${o}`;return r.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:Ao(i,s)},f)})})]})}function BN({block:n}){const s=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return r.jsxs("div",{className:`surface space-y-0.5 border ${s} px-0.5 py-0.5`,children:[r.jsx("p",{className:"text-xs font-semibold text-slate-100",children:n.title}),n.body&&r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((i,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Ao(i,{})},`callout-${o}`))})]})}function LN({group:n,keymap:s}){return r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:n.title}),r.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.items.map(i=>r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[r.jsx("span",{className:"text-slate-200",children:i.label}),r.jsx(Tg,{actionId:i.action,keymap:s})]},i.action))})]})}function zN({block:n,keymap:s}){return n?r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:n.title}),n.footnote&&r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(i=>r.jsx(LN,{group:i,keymap:s},i.id))})]}):null}function UN({block:n}){return n?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((s,i)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Ao(s,{})},`gamepad-${i}`))})]}):null}function ix({block:n,keymap:s}){if(!n)return null;switch(n.type){case"list":return r.jsx(ON,{block:n,keymap:s});case"callout":return r.jsx(BN,{block:n});case"keyboard":return r.jsx(zN,{block:n,keymap:s});case"gamepad":return r.jsx(UN,{block:n});default:return null}}function Dg({layout:n,keymap:s}){const i=m.useMemo(()=>DN(n),[n]),o=s||{},f=i.main||[],d=i.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(_N,{hero:i.hero,keymap:o}),r.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[r.jsx("div",{className:"space-y-0.5",children:f.map((h,p)=>r.jsx(ix,{block:h,keymap:o},h.title||p))}),r.jsx("div",{className:"space-y-0.5",children:d.map((h,p)=>r.jsx(ix,{block:h,keymap:o},h.title||p))})]})]})}function _g({layout:n,onOpenOverlay:s}){const{state:i}=_t();return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Help"}),r.jsx("button",{type:"button",onClick:s,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),r.jsx(Dg,{layout:n,keymap:i?.keymap||{}})]})}const HN=["kal","rms","slt","ksp","bdl"],VN=Array.from({length:10},(n,s)=>s*10);function jo({hideInput:n=!1,hideSpectatorNotice:s=!1,fillHeight:i=!1,allowSpectatorInput:o=!1}){const{session:f}=Le(),{messages:d,typing:h,sendMessage:p,registerInputRef:x,onInputFocus:g,onInputBlur:y,blurChat:b,setTypingActive:S}=Pf(),{value:R,save:N}=Fe("tts",{engine:"flite",voice:"rms",pitch:50}),[k,j]=m.useState(""),[w,E]=m.useState(!1),[C,M]=m.useState(!1),[B,H]=m.useState(()=>R?.engine||"flite"),[_,K]=m.useState(()=>R?.voice||"rms"),[L,U]=m.useState(()=>Number.isFinite(R?.pitch)?R.pitch:50),F=f?.role!=="spectator"||o,te=m.useRef(null),fe=f?.assignment?.roverId||null,Y=!!m.useMemo(()=>f?.roster?.find(q=>String(q.id)===String(fe))||null,[fe,f?.roster])?.audio?.ttsEnabled,T=m.useMemo(()=>d.slice(-200),[d]),X=m.useMemo(()=>h||[],[h]);m.useEffect(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[T,X]),m.useEffect(()=>{const q=R?.engine||"flite",V=R?.voice||"rms",P=Number.isFinite(R?.pitch)?R.pitch:50;B!==q&&H(q),_!==V&&K(V),L!==P&&U(P)},[B,L,R?.engine,R?.pitch,R?.voice,_]),m.useEffect(()=>{M(!!Y)},[Y]);const J=m.useMemo(()=>!Y||!C?null:B==="espeak"?{speak:!0,engine:B,pitch:L}:{speak:!0,engine:B,voice:_},[B,L,C,Y,_]);async function se(q){if(q.preventDefault(),!F||n)return;const P=k.replace(/\\n/g,`
`).trim();if(P){E(!0);try{await p(P,J),j(""),b(),S(!1)}catch(ne){alert(ne.message)}finally{E(!1)}}}const de=i?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${i?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${de}`,ref:te,children:[T.length===0&&X.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):T.map(q=>r.jsx(Zf,{message:q},q.id)),X.map(q=>r.jsx(ng,{message:q},`typing-${q.typingId||q.id}`))]}),!n&&r.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:se,children:[r.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:k,onChange:q=>{const V=q.target.value;j(V),S(!!V.trim())},onFocus:q=>{g(q),S(!!k.trim())},onBlur:q=>{y(q),S(!1)},onKeyDown:q=>{q.key==="Enter"&&!k.trim()&&(q.preventDefault(),b(),S(!1))},ref:q=>x(q,{target:"panel"}),placeholder:F?"Type a message…":s?"":"Spectators cannot chat",disabled:!F}),Y&&r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:C,onChange:q=>M(q.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:B,onChange:q=>{const V=q.target.value;H(V),N(P=>({...P||{},engine:V}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),B==="flite"?r.jsx("select",{value:_,onChange:q=>{const V=q.target.value;K(V),N(P=>({...P||{},voice:V}))},className:"field-input text-xs",children:HN.map(q=>r.jsx("option",{value:q,children:q},q))}):r.jsx("select",{value:L,onChange:q=>{const V=Number(q.target.value);U(V),N(P=>({...P||{},pitch:V}))},className:"field-input text-xs",children:VN.map(q=>r.jsxs("option",{value:q,children:["pitch ",q]},q))})]}),r.jsx("button",{type:"submit",disabled:!F||w,className:"button-dark h-full disabled:opacity-50 self-stretch",children:w?"...":"Send"})]})]})}function No({compact:n=!1}){const{session:s,setNickname:i}=Le(),{value:o,save:f}=Fe("profile",{nickname:""}),[d,h]=m.useState(o.nickname||""),[p,x]=m.useState(!1),g=s?.role!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function y(b){if(b.preventDefault(),!g)return;const S=(d||"").trim().slice(0,32);if(S){x(!0);try{await i(S),f({nickname:S})}catch(R){alert(R.message)}finally{x(!1)}}}return r.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:y,children:[r.jsx("input",{className:"field-input flex-1 min-w-0",value:d,onChange:b=>h(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||p,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:p?"Saving…":n?"Set":"Save"})]})}function $N(n){const s=Array.isArray(n?.socials)?n.socials:null;if(s&&s.length)return s;const i=[];return n?.discord?.invite&&i.push({id:"discord",label:"Discord",url:n.discord.invite}),n?.kofi?.link&&i.push({id:"kofi",label:"Ko-fi",url:n.kofi.link}),i}function GN(n){if(!n||typeof n!="object")return null;const s=n.id||n.service||n.key||n.name||null,i=n.label||n.title||n.name||s||"Link",o=n.url||n.link||n.href||null;return o?{id:s,label:i,url:o}:null}function Og({className:n=""}){const{session:s}=Le(),i=$N(s).map(GN).filter(Boolean).slice(0,4);return i.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:i.map(o=>r.jsx(ld,{...o},`${o.id||o.label}-${o.url}`))}):null}function YN({compact:n=!1}){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(No,{compact:n})})})}function FN(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Og,{className:"flex-1 min-h-0"})})}function mf(...n){return n.filter(Boolean).join(" ")}function XN(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function QN(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function KN(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function ZN(n,s){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${i} (you)`:i}function wo({title:n="Rovers"}){const{session:s,requestControl:i}=Le(),[o,f]=m.useState({}),[d,h]=m.useState(()=>Date.now()),p=m.useMemo(()=>s?.role&&s.role!=="spectator",[s?.role]),x=m.useMemo(()=>s?.role==="admin"||s?.role==="lockdown"||s?.role==="lockdown-admin",[s?.role]),g=s?.roster??[],y=s?.turnQueues??{},b=s?.users??[],S=s?.socketId||null,R=m.useMemo(()=>Object.values(y||{}).some(w=>w?.deadline||w?.idleDeadline),[y]);m.useEffect(()=>{if(!R)return;const w=setInterval(()=>{h(Date.now())},1e3);return()=>clearInterval(w)},[R]);const N=m.useMemo(()=>{const w=new Set(g.map(C=>String(C.id))),E=Object.keys(y||{}).filter(C=>!w.has(String(C))).map(C=>({id:C,name:C,locked:!1,batteryState:null}));return[...g,...E]},[g,y]);async function k(w){if(w){f(E=>({...E,[w]:!0}));try{await i(w)}catch(E){alert(E.message)}finally{f(E=>({...E,[w]:!1}))}}}const j=w=>b.find(E=>E.socketId===w)||{socketId:w,nickname:null,role:null};return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),N.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:N.map(w=>{const E=String(w.id),C=y?.[E]||null,M=C?.queue||[],B=C?.idleDeadline||C?.deadline||null,H=B&&B>d?Math.ceil((B-d)/1e3):B?0:null,_=C?.current||null,K=_?M.findIndex(se=>se===_):-1,L=M.length>1?K>=0?M[(K+1)%M.length]:M[0]:null,U=!!(S&&_&&_===S),F=!!(S&&L&&L===S),te=H!=null&&(U||F),fe=!!w.locked,ce=fe&&!x,Y=!!(w?.private?.enabled&&w?.private?.open),T=w.lockReason?`locked: ${w.lockReason}`:"locked",X=fe?T:o[E]?"...":"request",J=p&&!ce&&!o[E];return r.jsxs("li",{className:mf("surface flex flex-wrap items-start justify-between gap-0.5",J&&"cursor-pointer",fe?"bg-red-900/40":Y?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{J&&k(w.id)},children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{className:"text-slate-200",children:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(w.color,.16),children:w.name})}),te?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:U?`${H}s left`:`Your turn in ${H}s`}):null]}),r.jsx("span",{className:mf("text-[0.75rem] font-semibold",QN(w)),children:XN(w)})]}),M.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):r.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:M.map((se,de)=>{const q=j(se),V=se===_,P=!!(L&&se===L&&!V),ne=V?"bg-sky-600 text-white ring-2 ring-amber-300":P?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return r.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${ne}`,children:[r.jsx("span",{className:`${KN(q.role)} font-semibold`,children:ZN(q,S)}),V&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),P&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${E}-${se}-${de}`)})})]}),p?r.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),k(w.id)},disabled:o[E]||ce,className:mf("button-dark disabled:opacity-40",fe&&"bg-red-600/70 text-white hover:bg-red-600"),children:X}):null]},w.id)})})]})}function IN(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function JN(n,s){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${i} (you)`:i}function mo({hideNicknameForm:n=!1,hideHeader:s=!1,className:i="",fillHeight:o=!1,compact:f=!1}){const{session:d}=Le(),h=d?.role!=="spectator",p=d?.users??[],x=d?.socketId||null,g=m.useMemo(()=>[...p].sort((b,S)=>b.socketId===x?-1:S.socketId===x?1:(b.nickname||"").localeCompare(S.nickname||"")),[x,p]),y=o?"flex-1 min-h-0 overflow-y-auto":f?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${i}`,children:[!n&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(No,{compact:f})})}),r.jsx(Og,{})]}),!h&&r.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),r.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!s&&r.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${f?"text-xs":""}`,children:[r.jsx("span",{children:"Users"}),r.jsx("span",{className:"text-xs text-slate-500",children:g.length})]}),r.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${y} ${f?"text-[0.8rem]":""}`,children:g.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(b=>r.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${IN(b.role)}`,children:JN(b,x)},b.socketId))})]})]})}const PN=/^cu_[a-f0-9]{32}$/,ji="field-input w-full max-w-sm text-left focus:ring-emerald-500",Co="mx-auto w-full max-w-xl flex justify-center",hi="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function WN(n){const s=String(n||"").trim();return s?s.length<=10?`${s.slice(0,2)}***${s.slice(-2)}`:`${s.slice(0,6)}...${s.slice(-6)}`:""}const rx=8*1024*1024,ss=16e3,ew={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function ox(n){let s="";for(let o=0;o<n.length;o+=32768){const f=n.subarray(o,o+32768);s+=String.fromCharCode(...f)}return btoa(s)}function tw(n){return typeof btoa=="function"?btoa(n):""}function nw(n){if(!n)return{};const s=tw(`${n}:${n}`);return s?{Authorization:`Basic ${s}`}:{}}function aw(n,s=1500){return new Promise(i=>{if(!n||n.iceGatheringState==="complete"){i();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",f),i()},s);function f(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",f),i())}n.addEventListener("icegatheringstatechange",f)})}function cx(n){if(!n)return!1;const s=n.connectionState,i=n.iceConnectionState;return s==="connected"||i==="connected"||i==="completed"}function sw(n,s=1e4){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(cx(n)){i();return}const f=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},s),d=()=>{cx(n)?(h(),i()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(h(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function h(){clearTimeout(f),n.removeEventListener("connectionstatechange",d),n.removeEventListener("iceconnectionstatechange",d)}n.addEventListener("connectionstatechange",d),n.addEventListener("iceconnectionstatechange",d)})}async function lw(n){if(!n?.getParameters||!n?.setParameters)return;const s=n.getParameters()||{},i=s.encodings&&s.encodings[0]||{};s.encodings=[{...i,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(s)}catch{}}function iw(n,s=6e3){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}const f=Date.now();let d=-1;const h=setInterval(async()=>{if(Date.now()-f>s){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const p=n.getSenders().filter(x=>x.track?.kind==="audio");for(const x of p){const g=await x.getStats();for(const y of g.values()){if(y.type!=="outbound-rtp"||y.kind!=="audio")continue;const b=Number(y.bytesSent||0),S=Number(y.packetsSent||0);if(d<0)d=b;else if(b>d+200||S>5){clearInterval(h),i();return}}}}catch{}},250)})}function mn({label:n,active:s,detail:i=""}){return r.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${s?"bg-emerald-500":"bg-slate-700"}`,children:[r.jsx("div",{className:"text-center font-medium",children:n}),r.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:i||(s?"active":"idle")})]})}function ux({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function rw(n){const s=n.reduce((f,d)=>f+d.length,0),i=new Float32Array(s);let o=0;for(const f of n)i.set(f,o),o+=f.length;return i}function ow(n){const s=new Int16Array(n.length);for(let i=0;i<n.length;i+=1){const o=Math.max(-1,Math.min(1,n[i]));s[i]=o<0?o*32768:o*32767}return s}function cw(n,s){const i=ow(n),o=i.length*2,f=new ArrayBuffer(44+o),d=new DataView(f),h=(x,g)=>{for(let y=0;y<g.length;y+=1)d.setUint8(x+y,g.charCodeAt(y))};h(0,"RIFF"),d.setUint32(4,36+o,!0),h(8,"WAVE"),h(12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,1,!0),d.setUint32(24,s,!0),d.setUint32(28,s*2,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),h(36,"data"),d.setUint32(40,o,!0);let p=44;for(let x=0;x<i.length;x+=1,p+=2)d.setInt16(p,i[x],!0);return new Uint8Array(f)}function uw({ownRoverId:n="",audioForwardByRover:s={},playUploadedAudio:i,stopUploadedAudio:o,startMicWhip:f,readyMicWhip:d,stopMicWhip:h}){const{state:p}=_t(),{value:x,save:g}=Fe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),y=String(n||"").trim(),[b,S]=m.useState(null),[R,N]=m.useState(!1),k=!!x?.openMicEnabled,w=(x?.pttMode==="clip"?"clip":"live")==="clip",[E,C]=m.useState("idle"),[M,B]=m.useState("idle"),[H,_]=m.useState(""),K=m.useRef(null),L=m.useRef(null),U=m.useRef(null),F=m.useRef(!1),te=m.useRef(""),fe=m.useRef(null),ce=m.useRef(null),Y=m.useRef(null),T=m.useRef(null),X=m.useRef(null),J=m.useRef([]),se=m.useRef(!1),de=m.useRef(ss),q=!!p?.mic?.pttActive,V=m.useMemo(()=>y&&s?.[y]||null,[s,y]),P=!!(V&&V.state!=="offline"&&!V.error),ne=V?.source==="upload"&&V?.state==="playing",pe=V?.source==="mic-whip"&&(V?.state==="starting"||V?.state==="playing"),ie=!!(!w&&L.current&&(k||q)),oe=!w&&(E==="live"||E==="starting"),ve=w&&M==="recording",ye=w&&M==="sending",xe=Sn(p?.keymap?.micPtt?.[0])||"M",Ue=m.useCallback(me=>{const we=me==="clip"?"clip":"live";g(et=>({...et||{},pttMode:we}))},[g]),$e=async()=>{if(!y){_("Take control of your rover first.");return}if(!b){_("Select an audio file first.");return}if(b.size>rx){_(`File too large (max ${rx} bytes).`);return}N(!0),_("");try{const me=await b.arrayBuffer(),we=ox(new Uint8Array(me));await i?.({roverId:y,name:b.name,mime:b.type||"",dataBase64:we}),_("Upload playback started.")}catch(me){_(me?.message||"Failed to play upload.")}finally{N(!1)}},Ne=async()=>{if(!y){_("Take control of your rover first.");return}N(!0),_("");try{await o?.(y),_("Upload playback stopped.")}catch(me){_(me?.message||"Failed to stop upload.")}finally{N(!1)}},ae=m.useCallback(async me=>{const we=String(me||te.current||"").trim();if(F.current=!1,C("idle"),U.current){try{U.current.getSenders().forEach(et=>et.track?.stop())}catch{}try{U.current.close()}catch{}}if(U.current=null,K.current)try{K.current.getTracks().forEach(et=>et.stop())}catch{}if(K.current=null,L.current=null,we)try{await h?.(we)}catch{}te.current=""},[h]),ue=m.useCallback(async me=>{const we=await f?.(me),et=String(we?.whipUrl||"").trim(),dt=String(we?.token||"").trim();if(!et||!dt)throw new Error("WHIP endpoint unavailable");const ze=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});K.current=ze;const xt=ze.getAudioTracks()?.[0];if(L.current=xt||null,xt&&(xt.enabled=!!(k||q)),xt?.applyConstraints)try{await xt.applyConstraints({channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const mt=new RTCPeerConnection(ew);U.current=mt,mt.onconnectionstatechange=()=>{if(!F.current)return;const Gt=mt.connectionState;if(Gt==="connected"){C("live");return}(Gt==="failed"||Gt==="disconnected"||Gt==="closed")&&(C("error"),_(`WHIP transport ${Gt}.`))},ze.getAudioTracks().forEach(Gt=>{const Oa=mt.addTrack(Gt,ze);lw(Oa)});const Tn=await mt.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await mt.setLocalDescription(Tn),await aw(mt,1800);const kt=await fetch(et,{method:"POST",headers:{"Content-Type":"application/sdp",...nw(dt)},body:mt.localDescription?.sdp||Tn.sdp});if(!kt.ok)throw new Error(`WHIP request failed: ${kt.status}`);const cs=await kt.text();await mt.setRemoteDescription({type:"answer",sdp:cs}),await sw(mt,1e4),await iw(mt,6e3),await d?.(me)},[k,q,d,f]),be=m.useCallback(async()=>{if(se.current=!1,T.current){try{T.current.disconnect()}catch{}T.current.onaudioprocess=null}if(Y.current)try{Y.current.disconnect()}catch{}if(X.current)try{X.current.disconnect()}catch{}if(fe.current)try{fe.current.getTracks().forEach(me=>me.stop())}catch{}if(ce.current)try{await ce.current.close()}catch{}J.current=[],T.current=null,Y.current=null,X.current=null,fe.current=null,ce.current=null,de.current=ss},[]),Me=m.useCallback(async()=>{if(fe.current&&ce.current&&T.current)return;B(xt=>xt==="recording"?xt:"arming");const me=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),we=new AudioContext({latencyHint:"interactive"}),et=we.createMediaStreamSource(me),dt=we.createScriptProcessor(1024,1,1),ze=we.createGain();ze.gain.value=0,dt.onaudioprocess=xt=>{if(!se.current)return;const mt=xt.inputBuffer.getChannelData(0);J.current.push(new Float32Array(mt))},et.connect(dt),dt.connect(ze),ze.connect(we.destination),fe.current=me,ce.current=we,Y.current=et,T.current=dt,X.current=ze,de.current=we.sampleRate||ss},[]),le=m.useCallback(async({send:me})=>{const we=se.current;if(se.current=!1,!we){me||B("idle");return}const et=J.current;if(J.current=[],!me){B("idle");return}if(!y){B("idle");return}if(!et.length){B("idle");return}B("sending");try{const dt=rw(et),ze=cw(dt,de.current||ss),xt=ox(ze);await i?.({roverId:y,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:xt}),B("idle")}catch(dt){B("error"),_(dt?.message||"Failed to send PTT clip.")}},[i,y]),re=m.useCallback(async()=>{if(!y){_("Take control of your rover first.");return}await Me(),J.current=[],se.current=!0,B("recording")},[Me,y]);return m.useEffect(()=>{let me=!1;async function we(){if(w){await ae(te.current||y);return}if(!y){await ae(te.current);return}if(!(F.current&&te.current===y)&&!(!k&&!q))try{C("starting"),_(""),F.current=!0,te.current=y,await ue(y),me||C("live")}catch(et){me||(C("error"),_(et?.message||"Failed to start mic forwarding.")),await ae(y)}}return we(),()=>{me=!0}},[w,k,q,y,ue,ae]),m.useEffect(()=>{const me=L.current;me&&(me.enabled=!!(!w&&(k||q)))},[w,k,q]),m.useEffect(()=>{let me=!1;async function we(){if(!w||!y){se.current&&await le({send:!1}),B("idle");return}try{await Me(),!me&&!se.current&&B("idle")}catch(et){me||(B("error"),_(et?.message||"Microphone access failed for clip mode."))}}return we(),()=>{me=!0}},[w,Me,le,y]),m.useEffect(()=>{let me=!1;async function we(){if(w){if(!y){se.current&&await le({send:!1});return}if(q){if(!se.current)try{_(""),await re()}catch(et){me||(B("error"),_(et?.message||"Failed to start clip recording."))}}else se.current&&await le({send:!0})}}return we(),()=>{me=!0}},[w,le,q,y,re]),m.useEffect(()=>()=>{ae(te.current||y),be()},[y,ae,be]),r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[r.jsx("span",{children:"Push-to-Talk Key"}),r.jsx(ux,{label:xe})]})}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),r.jsx("p",{className:"text-xs text-slate-400 text-center",children:"Choose how holding your PTT key behaves: live mic stream, or record-and-send clip. If the live stream doesn't work, switch to clip mode."}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${w?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Ue("live"),children:"Live Mic (WHIP)"}),r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${w?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Ue("clip"),children:"Record Clip"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(mn,{label:"Mode",active:w,detail:w?"record clip":"live mic"}),r.jsx(mn,{label:"PTT hold",active:q,detail:q?"held":"released"}),r.jsx(mn,{label:"Recording",active:ve,detail:ve?"capturing":"idle"}),r.jsx(mn,{label:"Playback",active:w&&ne,detail:w&&ne?"playing":"idle"})]})]})})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),r.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),r.jsx("input",{className:`${ji} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:R||!y,onChange:me=>S(me.target.files?.[0]||null)})]}),r.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:b?r.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[b.name," (",b.size," bytes)"]}):r.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:R||!y,onClick:$e,children:R?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:R||!y,onClick:Ne,children:"Stop"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),r.jsxs("label",{className:"surface-muted mx-auto flex w-full max-w-sm items-center justify-center gap-0.5 px-0.5 py-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:k,disabled:!y||w,onChange:me=>g(we=>({...we||{},openMicEnabled:!!me.target.checked}))}),r.jsx("span",{children:w?"Open mic (live mode only)":"Open mic"})]}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(mn,{label:"WHIP link",active:oe,detail:E}),r.jsx(mn,{label:"Mic hot",active:ie,detail:ie?"transmitting":"muted"}),r.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",r.jsx(ux,{label:xe})," to talk"]})]})]})})]}),r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[r.jsx(mn,{label:"Forward pipe",active:P,detail:P?"connected":"offline"}),r.jsx(mn,{label:"Upload playback",active:ne,detail:ne?"playing":"idle"}),r.jsx(mn,{label:"Mic relay",active:pe,detail:pe?"active":"idle"}),r.jsx(mn,{label:"WHIP transport",active:oe,detail:E}),r.jsx(mn,{label:"Clip recording",active:ve,detail:ve?"recording":"idle"}),r.jsx(mn,{label:"Clip sending",active:ye,detail:ye?"sending":"idle"})]}),H?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:H}):null]})})]})}function fw({pendingRequestId:n,currentStoredKey:s,nickname:i,requestVerification:o,applyIdentityKey:f,onMessage:d,fullWidth:h=!1}){const[p,x]=m.useState(0),[g,y]=m.useState(""),[b,S]=m.useState(!1),[R,N]=m.useState(!1),k=()=>{x(1),y(s),S(!1),d?.("")},j=()=>{x(0),S(!1)},w=async C=>{if(C.preventDefault(),!b){d?.("Please confirm your nickname agreement before sending.");return}if(p<3){d?.("Complete all request steps before sending.");return}N(!0),d?.("");try{const M=await f(g);await o?.(),y(M),x(0),S(!1),d?.("Verification request sent to lockdown admins.")}catch(M){d?.(M.message||"Failed to submit request.")}finally{N(!1)}},E=h?"w-full":Co;return n?r.jsx("section",{className:`surface text-sm text-slate-300 ${E}`,children:r.jsxs("div",{className:hi,children:["Verification request pending: ",n]})}):p===0?r.jsx("section",{className:`surface ${E}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:k,disabled:R,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${E}`,onSubmit:w,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",p," of 3"]}),p===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),r.jsx("div",{className:"mx-auto w-full max-w-sm",children:r.jsx(No,{compact:!0})}),r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",r.jsx("span",{className:"font-semibold",children:i||"(not set)"})]}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:C=>S(C.target.checked)}),r.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!i||!b,onClick:()=>x(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:j,children:"Cancel"})]})]}):null,p===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:ji,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:C=>y(C.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>navigator.clipboard?.writeText(g),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>x(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(1),children:"Back"})]})]}):null,p===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:ji,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:C=>y(C.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:R||!g,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function dw({currentStoredKey:n,applyIdentityKey:s,onMessage:i,fullWidth:o=!1}){const[f,d]=m.useState(0),[h,p]=m.useState(""),[x,g]=m.useState(!1),y=()=>{d(1),p(""),i?.("")},b=()=>{d(0),p("")},S=async N=>{if(N.preventDefault(),!(f<2)){g(!0),i?.("");try{await s(h),d(0),p(""),i?.("Identity key restored.")}catch(k){i?.(k.message||"Failed to restore key.")}finally{g(!1)}}},R=o?"w-full":Co;return r.jsx("section",{className:`surface ${R}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",WN(n)||"not set yet"]}),r.jsx("input",{className:ji,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),f===0?r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,disabled:x,children:"Restore Key"})]}):null,f===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,f===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:S,children:[r.jsx("input",{className:ji,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:h,onChange:N=>p(N.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:x||!h,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(1),children:"Back"})]})]}):null]})})}function mw({requestableRovers:n=[],pendingRequests:s=[],requestPrivateRoverAccess:i,onMessage:o,fullWidth:f=!1}){const[d,h]=m.useState({}),p=m.useMemo(()=>{const y=new Map;return(s||[]).forEach(b=>{b?.roverId&&y.set(String(b.roverId),b)}),y},[s]),x=f?"w-full":Co,g=async y=>{if(y){h(b=>({...b,[y]:!0})),o?.("");try{(await i?.(y))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(b){o?.(b.message||"Failed to send request.")}finally{h(b=>({...b,[y]:!1}))}}};return r.jsx("section",{className:`surface text-sm text-slate-300 ${x}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?r.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):r.jsx("div",{className:"w-full space-y-0.5",children:n.map(y=>{const b=String(y.id),S=!!d[b],R=p.get(b);return r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[r.jsxs("div",{className:"min-w-0 text-left",children:[r.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:y.name||b}),r.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:b})]}),R?r.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):r.jsx("button",{type:"button",onClick:()=>g(b),disabled:S,className:"button-dark text-xs disabled:opacity-50",children:S?"Sending...":"Request"})]},b)})})]})})}function Bg(){const{session:n,identifySession:s,requestVerification:i,requestPrivateRoverAccess:o,playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:p,stopMicWhip:x}=Le(),{value:g,save:y}=Fe("identity",{cookieUserId:""}),{value:b}=Fe("profile",{nickname:""}),S=m.useMemo(()=>(g?.cookieUserId||"").trim(),[g?.cookieUserId]),R=(b?.nickname||"").trim(),N=!!n?.isVerified,k=n?.verification?.pendingRequestId||null,j=n?.privateRoverAccess?.requestableRovers||[],w=n?.privateRoverAccess?.pendingRequests||[],E=String(n?.assignment?.roverId||"").trim(),[C,M]=m.useState(""),B=async H=>{const _=String(H||"").trim().toLowerCase();if(!_)throw new Error("Identity key required.");if(!PN.test(_))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return y(K=>({...K||{},cookieUserId:_})),await s({cookieUserId:_,nickname:R}),_};return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[r.jsx("div",{className:"lg:col-span-2",children:N?r.jsx("section",{className:"surface w-full",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center",children:[r.jsx("p",{className:"text-sm text-emerald-300",children:"Verification complete"}),r.jsx("p",{className:"text-xs text-slate-400",children:"VIP controls are unlocked for your assigned rover."})]})}):r.jsx(fw,{pendingRequestId:k,currentStoredKey:S,nickname:R,requestVerification:i,applyIdentityKey:B,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:N?r.jsx(uw,{ownRoverId:E,audioForwardByRover:n?.audioForward||{},playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:p,stopMicWhip:x}):r.jsx("section",{className:"surface h-full",children:r.jsx("div",{className:"flex h-full flex-col items-center justify-center text-center text-xs text-slate-400",children:"Verify your account to unlock VIP controls."})})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(mw,{requestableRovers:j,pendingRequests:w,requestPrivateRoverAccess:o,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(dw,{currentStoredKey:S,applyIdentityKey:B,onMessage:M,fullWidth:!0})})]}),C?r.jsx("div",{className:Co,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:C})}):null]})}const hw=420,pw=1200,xw={1:262,2:330,3:392,4:523};function ho(){const{session:n}=Le(),s=pn(),{value:i}=Fe("audio",St),o=Number.isFinite(i?.masterVolume)?i.masterVolume:St.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:St.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=m.useMemo(()=>{const k=Array.isArray(n?.buttonBox?.buttons)?n.buttonBox.buttons:[];return k.length===4?k:[1,2,3,4].map(j=>k.find(w=>Number(w?.id)===j)||{id:j,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n?.buttonBox?.buttons]),[p,x]=m.useState({}),[g,y]=m.useState({}),b=m.useRef(new Map),S=m.useRef(new Map),R=m.useRef({}),N=m.useRef(null);return m.useEffect(()=>{const k={};h.forEach(w=>{k[w.id]=Number(w.lastRewardAt||0)});const j=R.current||{};h.forEach(w=>{const E=Number(w.id),C=k[E]||0,M=Number(j[E]||0);if(C>0&&C!==M){y(_=>({..._,[E]:!0}));const B=S.current.get(E);B&&clearTimeout(B);const H=setTimeout(()=>{y(_=>({..._,[E]:!1})),S.current.delete(E)},pw);S.current.set(E,H)}}),R.current=k},[h]),m.useEffect(()=>{function k(w){const E=xw[w];if(!E||d<=0)return;let C=N.current;if(!C){const _=window.AudioContext||window.webkitAudioContext;if(!_)return;C=new _,N.current=C}const M=C.createOscillator(),B=C.createGain();M.type="square",M.frequency.value=E;const H=.14*d;B.gain.setValueAtTime(1e-4,C.currentTime),B.gain.exponentialRampToValueAtTime(Math.max(1e-4,H),C.currentTime+.01),B.gain.exponentialRampToValueAtTime(1e-4,C.currentTime+.2),M.connect(B),B.connect(C.destination),M.start(),M.stop(C.currentTime+.21)}function j(w={}){const E=Number(w.buttonId);if(!Number.isFinite(E)||E<1||E>4)return;x(B=>({...B,[E]:!0}));const C=b.current.get(E);C&&clearTimeout(C);const M=setTimeout(()=>{x(B=>({...B,[E]:!1})),b.current.delete(E)},hw);b.current.set(E,M),k(E)}return s.on("buttonBox:increment",j),()=>{s.off("buttonBox:increment",j)}},[d,s]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("header",{className:"panel-muted text-center text-sm",children:r.jsx("p",{children:"Button Box"})}),r.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:h.map(k=>{const j=Number(k.id),w=Number.isFinite(k.count)?k.count:0,E=Number.isFinite(k.goal)?k.goal:0,C=typeof k.rewardName=="string"&&k.rewardName.trim()?k.rewardName.trim():"Unassigned",M=Number.isFinite(k.rewardNumber)?k.rewardNumber:"?",B=!!p[j],H=!!g[j];return r.jsx(ag,{buttonId:j,count:w,goal:E,rewardNumber:M,rewardName:C,className:[B?"bg-cyan-900/45":"",H?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},j)})})]})}function gw(){const{state:{roverId:n}}=_t(),i=cl(n)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(Rf,{sensors:i})})})}function vw(){const{state:{roverId:n,keymap:s,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,startHorn:p,stopHorn:x}}=_t(),g=gg(n),y=g.docked&&!g.driving,b=i?.config,S=!!(n&&i?.enabled&&b),R=!!(n&&f?.nightVision),N=f?.nightVisionState,k=!!(n&&f?.horn),j=o?.overheated,w=typeof b?.minAngle=="number"?b.minAngle:-30,E=typeof b?.maxAngle=="number"?b.maxAngle:30,C=typeof i?.angle=="number"?i.angle:typeof b?.homeAngle=="number"?b.homeAngle:(w+E)/2,M=Sn(s?.nightVisionToggle?.[0]),B=Sn(s?.hornHonk?.[0]),H=Sn(s?.cameraUp?.[0]),_=Sn(s?.cameraDown?.[0]);return r.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[r.jsx(vg,{layout:"desktop",expand:!0,driveDockState:g}),y?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[R&&r.jsx(yg,{nightVisionOn:N?.nightVisionOn,disabled:!n,onToggle:h,keyLabel:M}),k&&r.jsx(bg,{disabled:!n||j,onStart:p,onStop:x,keyLabel:B,active:o?.active,heat:o?.heat}),S&&r.jsx(Sg,{value:C,min:w,max:E,onChange:d,keyDownLabel:_,keyUpLabel:H,className:"space-y-0.5 px-1 py-1",labelRowClass:"text-xs text-slate-300",labelClass:"",valueClass:"font-mono text-slate-100",sliderClass:"w-full",accentClass:"accent-emerald-400",endpointClass:"text-[0.7rem] text-slate-400"})]})]})}function yw({layout:n,onOpenHelpOverlay:s}){const{session:i}=Le(),{state:o}=_t(),{value:f}=Fe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),d=i?.isVerified?"bg-emerald-400":"bg-red-600",h=String(i?.assignment?.roverId||"").trim(),p=h?i?.audioForward?.[h]:null,x=!!o?.mic?.pttActive,g=!!f?.openMicEnabled,y=f?.pttMode==="clip"?"clip":"live",b=!!(h&&i?.isVerified&&(y==="clip"?x:g||x)),S=!!(h&&i?.isVerified&&y==="clip"&&p?.source==="upload"&&p?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(ud,{defaultTab:"telemetry",children:[r.jsxs(fd,{children:[r.jsx(Pt,{id:"telemetry",children:"Controls"}),r.jsx(Pt,{id:"vip",highlight:S?"green":b?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${d}`,"aria-hidden":"true",title:i?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Pt,{id:"help",children:"Help"}),r.jsx(Pt,{id:"settings",children:"Settings"})]}),r.jsxs(dd,{children:[r.jsx(Wt,{id:"telemetry",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[r.jsx(gw,{}),r.jsx(vw,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(wo,{}),r.jsx(Qf,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx(FN,{})]}),r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[r.jsx(jo,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(mo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(YN,{compact:!0})]})]}),r.jsx(Cg,{}),r.jsx(ho,{}),r.jsx(td,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(Wt,{id:"vip",keepMounted:!0,children:r.jsx(Bg,{})}),r.jsx(Wt,{id:"help",children:r.jsx(_g,{layout:n,onOpenOverlay:s})}),r.jsx(Wt,{id:"settings",children:r.jsx(Rg,{})})]})]})})}const bw=new Set(["admin","lockdown","lockdown-admin"]),Sw=new Set(["lockdown","lockdown-admin"]),Aw=new Set(["admin","lockdown"]);function jw(n="admin"){return n==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function Nw(){const{session:n}=Le(),s=n?.mode,i=n?.role,o=n?.adminReason?.text||"";n?.adminReason?.updatedAt;const f=n?.timezone||"UTC",d=n?.socials?.find(S=>String(S?.id||S?.label||"").toLowerCase()==="discord")?.url||n?.discord?.invite||null,h=Aw.has(s),p=s==="lockdown"?Sw.has(i):bw.has(i),[x,g]=m.useState(()=>new Date),y=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:f,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(x)}catch{return x.toLocaleTimeString()}},[x,f]);if(m.useEffect(()=>{const S=setInterval(()=>g(new Date),1e3);return()=>clearInterval(S)},[]),!h||p)return null;const b=jw(s);return r.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black/85 px-0.5 py-0.5",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold",children:b.title}),r.jsx("p",{className:"text-sm text-slate-300",children:b.description})]}),r.jsxs("div",{className:"surface-muted space-y-0.5",children:[r.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),r.jsx("p",{className:"text-lg font-semibold text-slate-100",children:o||"No reason set."}),r.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",y]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx(Eg,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(ld,{id:"discord",label:"Join our Discord server for updates!",url:d})}),"You can still use the chat while the server is locked:",r.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[r.jsx(jo,{}),r.jsx(No,{})]})]})})}const ww="/assets/turn_alert-DVO8EZJa.mp3";function Cw(n,s=1){const i=m.useRef(null);return m.useEffect(()=>{i.current=new Audio(n),i.current.volume=s,i.current.load()},[n,s]),()=>{i.current&&(i.current.volume=s,i.current.currentTime=0,i.current.play().catch(()=>{}))}}function Ew(){const{session:n,pushAlert:s}=Le(),{value:i}=Fe("audio",St),o=Number.isFinite(i?.masterVolume)?i.masterVolume:St.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:St.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=Cw(ww,d),p=m.useRef(new Set),x=m.useMemo(()=>n?.turnQueues||{},[n?.turnQueues]),g=n?.socketId||null;return m.useEffect(()=>{if(!g)return;const y=[];Object.entries(x).forEach(([b,S])=>{!S||!S.current||S.current!==g||p.current.has(b)||(y.push(b),p.current.add(b))}),Object.keys(x).forEach(b=>{(!x[b]||x[b].current!==g)&&p.current.delete(b)}),y.length!==0&&(y.forEach(b=>{const S=n?.roster?.find(R=>String(R.id)===String(b))?.name||b;s({title:"Your turn!",message:`You now control ${S}.`,color:"#ff5722"})}),h())},[x,h,s,n?.roster,g]),null}function kw({visible:n,mode:s,onEnterFullscreen:i,onDismiss:o}){if(!n)return null;const f=s==="pwa-hint";return r.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center p-2 pointer-events-none sm:items-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-sm rounded-lg border border-cyan-500/40 bg-zinc-950/95 shadow-xl",children:r.jsxs("div",{className:"space-y-0.5 p-4 text-sm text-slate-100",children:[r.jsx("h2",{className:"text-base font-semibold text-white",children:"Better in fullscreen"}),f?r.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",r.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen removes the browser chrome."]}):r.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),r.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[r.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:f?"Got it":"Not now"}),!f&&r.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:i,children:"Enter fullscreen"})]})]})})})}function Mw({side:n="right",onClick:s}){const i=n==="left"?"left-2":"right-2";return r.jsx("button",{type:"button",onClick:s,className:`fixed bottom-2 ${i} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-cyan-200/50 bg-slate-900/70 text-cyan-100 shadow-lg backdrop-blur-sm transition hover:bg-slate-800/80 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:r.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:r.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const Lg="fullscreenPromptDismissed",qw=new Set(["mobile-portrait","mobile-landscape"]),zg=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},Rw=()=>{const n=zg();if(!n)return!1;try{return n.getItem(Lg)==="1"}catch{return!1}},fx=()=>{const n=zg();if(n)try{n.setItem(Lg,"1")}catch{}},Tw=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},dx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function Dw(n){const s=qw.has(n),[i,o]=m.useState(!1),[f,d]=m.useState("native"),[h,p]=m.useState(!1),x=m.useMemo(()=>Tw(),[]),g=m.useMemo(()=>dx(),[]),y=m.useCallback(()=>{if(!s){o(!1),p(!1);return}if(!h&&Rw()){o(!1);return}if(x){d("pwa-hint"),o(!0);return}if(!dx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[h,x,s]);m.useEffect(()=>{y()},[y]),m.useEffect(()=>{if(typeof document>"u")return;const N=()=>{if(document.fullscreenElement){p(!1),o(!1);return}y()};return document.addEventListener("fullscreenchange",N),document.addEventListener("webkitfullscreenchange",N),()=>{document.removeEventListener("fullscreenchange",N),document.removeEventListener("webkitfullscreenchange",N)}},[y]);const b=m.useCallback(()=>{fx(),p(!1),o(!1)},[]),S=m.useCallback(async()=>{if(!s||x||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const N=document.documentElement;if(!N)return!1;const k=N.requestFullscreen||N.webkitRequestFullscreen||N.mozRequestFullScreen||N.msRequestFullscreen;if(!k)return!1;try{const j=k.call(N);return j&&typeof j.then=="function"&&await j,fx(),p(!1),o(!1),!0}catch(j){return console.warn("Failed to enter fullscreen",j),!1}},[x,s]),R=m.useCallback(()=>{s&&(p(!0),d(x?"pwa-hint":"native"),o(!0))},[x,s]);return m.useEffect(()=>{s||(p(!1),o(!1))},[s]),{visible:i,mode:f,isIOS:x,nativeSupported:g,enterFullscreen:S,dismiss:b,showPrompt:R}}function _w({visible:n,layout:s,onClose:i,showOnLoad:o,onToggleShowOnLoad:f}){if(!n)return null;const{state:d}=_t(),h=p=>{const x=!p.target.checked;f?.(x)};return r.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:r.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:"Help & controls"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:i,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),r.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:r.jsx(Dg,{layout:s,keymap:d?.keymap||{}})})]})})}const Ow=`aroma
bagel
batter
beans
beer
biscuit
bread
broth
burger
burrito
butter
cake
candy
caramel
caviar
cheese
chili
chimichanga
chocolate
cider
cobbler
cocoa
coffee
cookie
cream
croissant
crumble
cuisine
curd
dessert
dish
drink
eggs
empanada
enchilada
entree
filet
fish
flour
foie gras
food
glaze
grill
hamburger
ice
juice
ketchup
kitchen
lard
liquor
margarine
marinade
mayo
mayonnaise
meat
milk
mousse
muffin
mushroom
noodle
nut
oil
olive
omelette
pan
pasta
paste
pastry
pie
pizza
plate
pot
poutine
pudding
queso
raclette
recipe
rice
salad
salsa
sandwich
sauce
seasoning
skillet
soda
sopapillas
soup
soy
spice
steak
stew
syrup
taco
taquito
tartar
taste
tea
toast
tostada
vinegar
waffle
water
wheat
wine
wok
yeast
yogurt
`;function Bw(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function Lw(){const n=String(Ow).split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function md(){const{setNickname:n}=Le(),{value:s,status:i,save:o}=Fe("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(i!=="ready"||f.current||(s.nickname||"").trim())return;f.current=!0;const h=Bw(Lw()).slice(0,32);if(!h)return;(async()=>{try{await n(h)}catch{}finally{o({nickname:h})}})()},[o,n,i,s.nickname])}function zw(){const n=pn(),{connected:s,identifySession:i}=Le(),{value:o,status:f,save:d}=Fe("identity",{cookieUserId:""}),{value:h,status:p}=Fe("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),b=f==="ready"&&p==="ready",S=(o?.cookieUserId||"").trim(),R=(h?.nickname||"").trim(),N=m.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),k=m.useCallback(async()=>{if(!(!b||!s||!n?.id||x.current)){x.current=!0;try{const w=((await i({cookieUserId:S,nickname:R}))?.cookieUserId||"").trim();w&&w!==S&&d(E=>({...E||{},cookieUserId:w})),g.current=n.id,N()}catch{N(),y.current=setTimeout(()=>{k()},2e3)}finally{x.current=!1}}},[N,s,S,i,R,b,d,n?.id]);m.useEffect(()=>{!b||!s||!n?.id||g.current!==n.id&&k()},[s,b,k,n?.id]),m.useEffect(()=>{!b||!s||!n?.id||k()},[b,s,n?.id,S,R,k]),m.useEffect(()=>{const j=()=>{n?.connected&&k()},w=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&k()};return window.addEventListener("online",j),document.addEventListener("visibilitychange",w),()=>{window.removeEventListener("online",j),document.removeEventListener("visibilitychange",w)}},[k,n?.connected]),m.useEffect(()=>()=>N(),[N])}const hf=1e4,pf=28,Uw=14;function po({layout:n="desktop",className:s="",dismissable:i=!0}){const{session:o}=Le(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[h,p]=m.useState(!1),[x,g]=m.useState(pf),[y,b]=m.useState(0),S=m.useRef(null),R=m.useRef(null),N=m.useRef(null);m.useEffect(()=>{if(!f){p(!1);return}if(p(!0),!d||!i)return;const E=Date.now();b(hf);const C=setTimeout(()=>p(!1),hf),M=setInterval(()=>{const B=Date.now()-E;b(Math.max(0,hf-B))},250);return()=>{clearTimeout(C),clearInterval(M)}},[f,d]),m.useEffect(()=>{if(!f)return;g(pf);let E=0;const C=()=>{const B=N.current,H=R.current;if(!B||!H)return;const _=B.clientWidth;if(!_)return;const K=H.scrollWidth;if(!K)return;const L=Math.min(1,_/K),U=Math.max(Uw,Math.floor(pf*L));g(U)};E=window.requestAnimationFrame(C);const M=new ResizeObserver(()=>{window.cancelAnimationFrame(E),E=window.requestAnimationFrame(C)});return S.current&&M.observe(S.current),()=>{window.cancelAnimationFrame(E),M.disconnect()}},[f]);const k=m.useMemo(()=>["panel-section flex w-full items-center justify-center",d?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",s].filter(Boolean).join(" "),[s,d]);if(!f||!h)return null;const j=d?Math.ceil(y/1e3):null,w=i?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:S,className:k,style:{fontSize:`${x}px`,lineHeight:1.1},...w,children:r.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[r.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[r.jsx("span",{children:"Community"}),r.jsx("span",{children:"Goal"})]}),r.jsx("span",{ref:N,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:R,className:"block",children:f})}),d?r.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[j,"s"]}):null]})})}function Hw(){const[n,s]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function i(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:f}=window;o>=1024?s("desktop"):o>f?s("mobile-landscape"):s("mobile-portrait")}return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),n}function Vw({layout:n,onOpenHelpOverlay:s}){return r.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[r.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[r.jsx(id,{}),r.jsx(zS,{}),r.jsx(nd,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(po,{layout:n}),r.jsx(yw,{layout:n,onOpenHelpOverlay:s})]})]})}function Ug({layout:n,onOpenHelpOverlay:s,roomPanelId:i,showTelemetry:o=!0}){const{session:f}=Le(),{state:d}=_t(),{value:h}=Fe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),p=f?.isVerified?"bg-emerald-400":"bg-amber-400",x=String(f?.assignment?.roverId||"").trim(),g=x?f?.audioForward?.[x]:null,y=!!d?.mic?.pttActive,b=!!h?.openMicEnabled,S=h?.pttMode==="clip"?"clip":"live",R=!!(x&&f?.isVerified&&(S==="clip"?y:b||y)),N=!!(x&&f?.isVerified&&S==="clip"&&g?.source==="upload"&&g?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(ud,{defaultTab:"chat",children:[r.jsxs(fd,{children:[r.jsx(Pt,{id:"chat",children:"Chat"}),r.jsx(Pt,{id:"vip",highlight:N?"green":R?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${p}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Pt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Pt,{id:"help",children:"Help"}),r.jsx(Pt,{id:"settings",children:"Settings"})]}),r.jsxs(dd,{children:[r.jsx(Wt,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(jo,{}),r.jsx(mo,{})]})}),r.jsx(Wt,{id:"vip",keepMounted:!0,children:r.jsx(Bg,{})}),r.jsx(Wt,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Cg,{}),r.jsx(ho,{}),r.jsx(td,{panelId:i})]})}),r.jsx(Wt,{id:"help",children:r.jsx(_g,{layout:n,onOpenOverlay:s})}),r.jsx(Wt,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Rg,{}),r.jsx(nd,{})]})})]})]})})}function $w({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(id,{layoutFormat:"mobile-portrait"}),r.jsx(pj,{swapColumns:s}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Qf,{panelId:"replay-sources-mobile-portrait"}),r.jsx(wo,{})]}),r.jsx(Ug,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function Gw({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){const i="self-start h-[min(100svh,32rem)]",o=s?r.jsx(uo,{layout:"landscape",className:i}):r.jsx(co,{layout:"landscape",className:i}),f=s?r.jsx(co,{layout:"landscape",className:i}):r.jsx(uo,{layout:"landscape",className:i});return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[o,r.jsxs("div",{children:[r.jsx(id,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Qf,{panelId:"replay-sources-mobile-landscape"}),r.jsx(wo,{})]})]}),f]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(Ug,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function Yw(){const n=Hw(),s=n==="desktop",i=Dw(n);return r.jsx("div",{className:`bg-black text-slate-100 ${s?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(Fw,{layout:n,isDesktop:s,fullscreen:i})})}function Fw({layout:n,isDesktop:s,fullscreen:i}){md(),zw();const{visible:o,mode:f,isIOS:d,nativeSupported:h,enterFullscreen:p,dismiss:x,showPrompt:g}=i,{value:y,status:b,save:S}=Fe("help",{showOnLoad:!0}),{value:R}=Fe("page",{swapMobileControlColumns:!1}),N=!!R?.swapMobileControlColumns,k=N?"left":"right",j=!s&&(d||h),[w,E]=m.useState(!1);m.useEffect(()=>{b==="ready"&&E(y?.showOnLoad!==!1)},[b,y?.showOnLoad]);const C=m.useCallback(()=>E(!0),[]),M=m.useCallback(()=>E(!1),[]),B=m.useCallback(async()=>{if(d){g();return}await p()||g()},[p,d,g]),H=m.useCallback(K=>{const L=!!K;S(U=>({...U??{},showOnLoad:L})),L||E(!1)},[S]),_=m.useMemo(()=>s?r.jsx(Vw,{layout:n,onOpenHelpOverlay:C}):n==="mobile-landscape"?r.jsx(Gw,{onOpenHelpOverlay:C,swapMobileControlColumns:N}):r.jsx($w,{onOpenHelpOverlay:C,swapMobileControlColumns:N}),[s,n,C,N]);return r.jsxs(TA,{children:[r.jsx(GA,{}),r.jsx(lj,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${s?"h-full overflow-hidden":""}`,children:[s?null:r.jsx(po,{layout:n}),_]}),r.jsx(If,{}),r.jsx(Ew,{}),r.jsx(Nw,{}),r.jsx(_w,{visible:w,layout:n,onClose:M,showOnLoad:y?.showOnLoad!==!1,onToggleShowOnLoad:H}),r.jsx(kw,{visible:o,mode:f,onEnterFullscreen:p,onDismiss:x}),j?r.jsx(Mw,{side:k,onClick:B}):null]})}function Hg(){const{session:n,setRole:s,subscribeAll:i,connected:o}=Le(),[f,d]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function p(){if(n?.mode==="lockdown"){d(!1);return}try{n?.role!=="spectator"&&await s("spectator"),await i(),h||d(!0)}catch(x){console.error("Failed to enter spectator mode",x),h||d(!1)}}return p(),()=>{h=!0}},[o,n?.mode,n?.role,s,i]),f}function Xw(){const[n,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(max-aspect-ratio: 4/3)"),o=f=>s(f.matches);return i.addEventListener?i.addEventListener("change",o):i.addListener(o),()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener(o)}},[]),n}function Qw({roverId:n,session:s}){const i=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(x=>x.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f} (turns)`:f}function Kw({rover:n,frame:s,sessionInfo:i,videoMode:o,snapshotFeed:f,audioInfo:d,session:h}){const p=Qw({roverId:n.id,session:h});return r.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:r.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:r.jsx(bi,{sessionInfo:i,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:n.name,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:p,hudForceMap:!0,hudMapPosition:"top-center"})})})}function Zw({roster:n,frames:s,videoSources:i,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:h}){return n.length===0?r.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):r.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:n.map(p=>r.jsx(Kw,{rover:p,frame:s[p.id],sessionInfo:h&&i[p.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[p.id],audioInfo:f[`${p.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},p.id))})}function Iw(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(td,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function Jw({className:n=""}){return r.jsx("div",{className:`panel ${n}`,children:r.jsx(nd,{})})}function Pw(){const{session:n}=Le(),s=n?.mode==="lockdown",i=!!n?.isLocalNetwork;md(),Hg();const o=Xw(),f=Ff(),d=n?.roster??[],h=ad(d.map(j=>j.id),{enabled:!s&&!i,version:n?.mode}),p=i?d.map(j=>({type:"rover",id:j.id,key:j.id})):[],x=vi(p,{enabled:!s&&i,version:n?.mode}),g=d.flatMap(j=>j.media?.audioPublishUrl?[{type:"rover",id:`${j.id}-audio`,key:`${j.id}-audio`}]:[]),y=vi(g,{enabled:!s,version:n?.mode});if(s)return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),r.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const b=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",S=o?"order-2 flex min-h-0 min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto":"order-1 flex min-h-0 min-w-0 flex-col gap-0.5 md:overflow-y-auto",R=o?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",N="",k=o?"h-64":"";return r.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[r.jsxs("main",{className:b,children:[r.jsxs("section",{className:R,children:[o?r.jsxs("div",{className:`${N} ${k} flex flex-col gap-0.5`,children:[r.jsx(po,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(ho,{}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(mo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsxs("div",{className:N,children:[r.jsx(po,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(ho,{})]}),r.jsx("div",{className:`${N} ${o?`${k} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(wo,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${N} flex-1 min-h-0`,children:r.jsx(mo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${N} ${o?k:"flex-[1.1] min-h-0"}`,children:r.jsx(jo,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${N} ${o?k:""}`,children:r.jsx(Jw,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:S,children:[r.jsx(Zw,{roster:d,frames:f,videoSources:x,snapshotFeeds:h,audioSources:y,session:n,canSpectateVideo:i}),r.jsx(Iw,{})]})]}),r.jsx(If,{})]})}function Ww(){return r.jsx(Pw,{})}const e2=2e4,t2=3600*1e3;function n2({roverId:n,session:s}){const i=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(p=>p.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f}`:f}function a2({rover:n,frame:s}){const i=s?.sensors?.batteryChargeMah??null,o=n?.battery??null;return wg({batteryState:n?.batteryState??null,charge:i,config:o})}function mx({rover:n,frame:s,driverLabel:i,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:h=!1,showPreview:p=!0,variant:x="stacked"}){const g=a2({rover:n,frame:s}),y=g?.available?g.percentDisplay:null,b=x==="active";return r.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[r.jsx(Tf,{visual:g,orientation:b?"vertical":"horizontal",variant:"background"}),b?r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ra(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):r.jsx("div",{}),r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:y==null?"--%":`${y}%`})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ra(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):null,r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:y==null?"--%":`${y}%`})})})]}),r.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:r.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:p?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(bi,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}function el({children:n,className:s="",maxSize:i=1e3,minSize:o=14,style:f=void 0}){const d=m.useRef(null),h=m.useRef(null),[p,x]=m.useState(i);return m.useLayoutEffect(()=>{const g=d.current,y=h.current;if(!g||!y)return;let b=null;const S=()=>{const k=g.clientWidth;if(!k){R();return}let j=o,w=i,E=o;for(;j<=w;){const C=Math.floor((j+w)/2);y.style.fontSize=`${C}px`,y.scrollWidth<=k?(E=C,j=C+1):w=C-1}x(E)},R=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(S)};R();const N=new ResizeObserver(R);return N.observe(g),()=>{b&&cancelAnimationFrame(b),N.disconnect()}},[n,i,o]),r.jsx("div",{ref:d,className:"w-full min-w-0",children:r.jsx("div",{ref:h,className:`whitespace-nowrap ${s}`,style:{fontSize:`${p}px`,lineHeight:1.1,...f||{}},children:n})})}function s2(){const{session:n}=Le(),s=Hg();md();const i=n?.mode==="lockdown",o=!!n?.isLocalNetwork,f=Ff(),d=n?.roster??[],[h,p]=m.useState(0),x=n?.activeDrivers||{},g=m.useMemo(()=>d.filter(U=>x[U.id]),[d,x]),y=g.length?g:d,b=ad(y.map(U=>U.id),{enabled:!i&&!o,version:n?.mode}),S=m.useMemo(()=>o?y.map(U=>({type:"rover",id:U.id,key:U.id})):[],[o,y]),R=vi(S,{enabled:!i&&o,version:n?.mode}),N=m.useMemo(()=>g.flatMap(U=>{if(!U?.id||!U.media?.audioPublishUrl)return[];const F=String(U.id);return[{type:"rover",id:`${F}-audio`,key:`${F}-audio`}]}),[g]),k=vi(N,{enabled:!i,version:n?.mode}),j=m.useMemo(()=>{if(!g.length)return[];if(!o){const F=g.filter(te=>b[te.id]?.objectUrl);return F.length?F:g}const U=g.filter(F=>{const te=R[F.id];return te?.url&&!te?.error});return U.length?U:g},[g,b,R,o]),w=m.useMemo(()=>j.map(U=>({type:"rover",rover:U})),[j]),E=m.useMemo(()=>w.map(U=>`r:${U.rover.id}`).join("|"),[w]);m.useEffect(()=>{p(0)},[E]),m.useEffect(()=>{if(!w.length)return;const U=setInterval(()=>{p(F=>(F+1)%w.length)},e2);return()=>clearInterval(U)},[w.length,E]);const C=w.length?w[h%w.length]:null,M=C?.type==="rover"?C.rover:null,B=!o&&M&&b[M.id]||null,H=o&&M&&R[M.id]||null,_=M&&k[`${M.id}-audio`]||null,K=M&&f[M.id]||null,L=M?n2({roverId:M.id,session:n}):null;return i?r.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),r.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):g.length?r.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[r.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:s?M?r.jsx(i2,{children:o?r.jsx("div",{className:"relative h-full w-full",children:w.map(U=>{const F=U.rover,te=M?.id===F.id;return r.jsx("div",{className:`absolute inset-0 ${te?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(bi,{sessionInfo:R[F.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:te?_:null,forceMute:!te,label:F.name||F.id,roverColor:F.color||null,telemetryFrame:f[F.id]||null,batteryConfig:F.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},F.id)})}):r.jsx(bi,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:B,audioSessionInfo:_,label:M.name||M.id,roverColor:M.color||null,telemetryFrame:K,batteryConfig:M.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:g.length?"No sources available.":"No active drivers."}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),r.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:M?r.jsx(mx,{rover:M,frame:K,driverLabel:L,sessionInfo:o?H:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[M.id]||null,showPreview:!1,variant:"active"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):r.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:r.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:d.length?d.map((U,F)=>r.jsx(mx,{rover:U,frame:f[U.id]||null,driverLabel:null,sessionInfo:o&&R[U.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[U.id]||null,showPreview:!0,withDivider:!1},U.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function l2(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const s=new URL(window.location.href);s.searchParams.set("refresh",Date.now().toString()),window.location.replace(s.toString())},t2);return()=>clearTimeout(n)},[]),r.jsxs(r.Fragment,{children:[r.jsx(s2,{}),r.jsx(If,{scale:3})]})}function i2({children:n}){return r.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:r.jsx("div",{className:"relative flex items-center justify-center overflow-hidden bg-black",style:{width:"min(100%, calc(100vh * 4 / 3))",height:"min(100%, calc(100vw * 3 / 4))",maxWidth:"100%",maxHeight:"100%",aspectRatio:"4 / 3"},children:r.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:n})})})}ob.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(RS,{children:r.jsx(DS,{children:r.jsx(_S,{children:r.jsx(GS,{children:r.jsx(_A,{children:r.jsx(j1,{children:r.jsxs(e1,{children:[r.jsx(Qr,{path:"/",element:r.jsx(Yw,{})}),r.jsx(Qr,{path:"/spectate",element:r.jsx(Ww,{})}),r.jsx(Qr,{path:"/mini",element:r.jsx(l2,{})})]})})})})})})})}));