Files
MultiRoombaRover/server/public/assets/index-CduNi74O.js
T
2026-05-02 15:39:38 -04:00

127 lines
564 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 d of document.querySelectorAll('link[rel="modulepreload"]'))o(d);new MutationObserver(d=>{for(const f of d)if(f.type==="childList")for(const p of f.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&o(p)}).observe(document,{childList:!0,subtree:!0});function l(d){const f={};return d.integrity&&(f.integrity=d.integrity),d.referrerPolicy&&(f.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?f.credentials="include":d.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function o(d){if(d.ep)return;d.ep=!0;const f=l(d);fetch(d.href,f)}})();function py(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Qu={exports:{}},ii={};var pp;function xy(){if(pp)return ii;pp=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(o,d,f){var p=null;if(f!==void 0&&(p=""+f),d.key!==void 0&&(p=""+d.key),"key"in d){f={};for(var h in d)h!=="key"&&(f[h]=d[h])}else f=d;return d=f.ref,{$$typeof:n,type:o,key:p,ref:d!==void 0?d:null,props:f}}return ii.Fragment=s,ii.jsx=l,ii.jsxs=l,ii}var xp;function gy(){return xp||(xp=1,Qu.exports=xy()),Qu.exports}var r=gy(),Ku={exports:{}},Ae={};var gp;function by(){if(gp)return Ae;gp=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),p=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),S=Symbol.iterator;function M(T){return T===null||typeof T!="object"?null:(T=S&&T[S]||T["@@iterator"],typeof T=="function"?T:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,N={};function C(T,V,te){this.props=T,this.context=V,this.refs=N,this.updater=te||j}C.prototype.isReactComponent={},C.prototype.setState=function(T,V){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,V,"setState")},C.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function A(){}A.prototype=C.prototype;function R(T,V,te){this.props=T,this.context=V,this.refs=N,this.updater=te||j}var k=R.prototype=new A;k.constructor=R,E(k,C.prototype),k.isPureReactComponent=!0;var O=Array.isArray;function X(){}var D={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function K(T,V,te){var ae=te.ref;return{$$typeof:n,type:T,key:V,ref:ae!==void 0?ae:null,props:te}}function $(T,V){return K(T.type,V,T.props)}function Y(T){return typeof T=="object"&&T!==null&&T.$$typeof===n}function ee(T){var V={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(te){return V[te]})}var oe=/\/+/g;function ce(T,V){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):V.toString(36)}function z(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(X,X):(T.status="pending",T.then(function(V){T.status==="pending"&&(T.status="fulfilled",T.value=V)},function(V){T.status==="pending"&&(T.status="rejected",T.reason=V)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,V,te,ae,he){var re=typeof T;(re==="undefined"||re==="boolean")&&(T=null);var de=!1;if(T===null)de=!0;else switch(re){case"bigint":case"string":case"number":de=!0;break;case"object":switch(T.$$typeof){case n:case s:de=!0;break;case b:return de=T._init,q(de(T._payload),V,te,ae,he)}}if(de)return he=he(T),de=ae===""?"."+ce(T,0):ae,O(he)?(te="",de!=null&&(te=de.replace(oe,"$&/")+"/"),q(he,V,te,"",function(pe){return pe})):he!=null&&(Y(he)&&(he=$(he,te+(he.key==null||T&&T.key===he.key?"":(""+he.key).replace(oe,"$&/")+"/")+de)),V.push(he)),1;de=0;var ve=ae===""?".":ae+":";if(O(T))for(var fe=0;fe<T.length;fe++)ae=T[fe],re=ve+ce(ae,fe),de+=q(ae,V,te,re,he);else if(fe=M(T),typeof fe=="function")for(T=fe.call(T),fe=0;!(ae=T.next()).done;)ae=ae.value,re=ve+ce(ae,fe++),de+=q(ae,V,te,re,he);else if(re==="object"){if(typeof T.then=="function")return q(z(T),V,te,ae,he);throw V=String(T),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return de}function L(T,V,te){if(T==null)return T;var ae=[],he=0;return q(T,ae,"","",function(re){return V.call(te,re,he++)}),ae}function Z(T){if(T._status===-1){var V=T._result;V=V(),V.then(function(te){(T._status===0||T._status===-1)&&(T._status=1,T._result=te)},function(te){(T._status===0||T._status===-1)&&(T._status=2,T._result=te)}),T._status===-1&&(T._status=0,T._result=V)}if(T._status===1)return T._result.default;throw T._result}var se=typeof reportError=="function"?reportError:function(T){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof T=="object"&&T!==null&&typeof T.message=="string"?String(T.message):String(T),error:T});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",T);return}console.error(T)},ue={map:L,forEach:function(T,V,te){L(T,function(){V.apply(this,arguments)},te)},count:function(T){var V=0;return L(T,function(){V++}),V},toArray:function(T){return L(T,function(V){return V})||[]},only:function(T){if(!Y(T))throw Error("React.Children.only expected to receive a single React element child.");return T}};return Ae.Activity=y,Ae.Children=ue,Ae.Component=C,Ae.Fragment=l,Ae.Profiler=d,Ae.PureComponent=R,Ae.StrictMode=o,Ae.Suspense=x,Ae.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,Ae.__COMPILER_RUNTIME={__proto__:null,c:function(T){return D.H.useMemoCache(T)}},Ae.cache=function(T){return function(){return T.apply(null,arguments)}},Ae.cacheSignal=function(){return null},Ae.cloneElement=function(T,V,te){if(T==null)throw Error("The argument must be a React element, but you passed "+T+".");var ae=E({},T.props),he=T.key;if(V!=null)for(re in V.key!==void 0&&(he=""+V.key),V)!H.call(V,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&V.ref===void 0||(ae[re]=V[re]);var re=arguments.length-2;if(re===1)ae.children=te;else if(1<re){for(var de=Array(re),ve=0;ve<re;ve++)de[ve]=arguments[ve+2];ae.children=de}return K(T.type,he,ae)},Ae.createContext=function(T){return T={$$typeof:p,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null},T.Provider=T,T.Consumer={$$typeof:f,_context:T},T},Ae.createElement=function(T,V,te){var ae,he={},re=null;if(V!=null)for(ae in V.key!==void 0&&(re=""+V.key),V)H.call(V,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(he[ae]=V[ae]);var de=arguments.length-2;if(de===1)he.children=te;else if(1<de){for(var ve=Array(de),fe=0;fe<de;fe++)ve[fe]=arguments[fe+2];he.children=ve}if(T&&T.defaultProps)for(ae in de=T.defaultProps,de)he[ae]===void 0&&(he[ae]=de[ae]);return K(T,re,he)},Ae.createRef=function(){return{current:null}},Ae.forwardRef=function(T){return{$$typeof:h,render:T}},Ae.isValidElement=Y,Ae.lazy=function(T){return{$$typeof:b,_payload:{_status:-1,_result:T},_init:Z}},Ae.memo=function(T,V){return{$$typeof:g,type:T,compare:V===void 0?null:V}},Ae.startTransition=function(T){var V=D.T,te={};D.T=te;try{var ae=T(),he=D.S;he!==null&&he(te,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(X,se)}catch(re){se(re)}finally{V!==null&&te.types!==null&&(V.types=te.types),D.T=V}},Ae.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},Ae.use=function(T){return D.H.use(T)},Ae.useActionState=function(T,V,te){return D.H.useActionState(T,V,te)},Ae.useCallback=function(T,V){return D.H.useCallback(T,V)},Ae.useContext=function(T){return D.H.useContext(T)},Ae.useDebugValue=function(){},Ae.useDeferredValue=function(T,V){return D.H.useDeferredValue(T,V)},Ae.useEffect=function(T,V){return D.H.useEffect(T,V)},Ae.useEffectEvent=function(T){return D.H.useEffectEvent(T)},Ae.useId=function(){return D.H.useId()},Ae.useImperativeHandle=function(T,V,te){return D.H.useImperativeHandle(T,V,te)},Ae.useInsertionEffect=function(T,V){return D.H.useInsertionEffect(T,V)},Ae.useLayoutEffect=function(T,V){return D.H.useLayoutEffect(T,V)},Ae.useMemo=function(T,V){return D.H.useMemo(T,V)},Ae.useOptimistic=function(T,V){return D.H.useOptimistic(T,V)},Ae.useReducer=function(T,V,te){return D.H.useReducer(T,V,te)},Ae.useRef=function(T){return D.H.useRef(T)},Ae.useState=function(T){return D.H.useState(T)},Ae.useSyncExternalStore=function(T,V,te){return D.H.useSyncExternalStore(T,V,te)},Ae.useTransition=function(){return D.H.useTransition()},Ae.version="19.2.0",Ae}var bp;function $d(){return bp||(bp=1,Ku.exports=by()),Ku.exports}var m=$d();const qn=py(m);var Zu={exports:{}},ri={},Iu={exports:{}},Ju={};var vp;function vy(){return vp||(vp=1,(function(n){function s(q,L){var Z=q.length;q.push(L);e:for(;0<Z;){var se=Z-1>>>1,ue=q[se];if(0<d(ue,L))q[se]=L,q[Z]=ue,Z=se;else break e}}function l(q){return q.length===0?null:q[0]}function o(q){if(q.length===0)return null;var L=q[0],Z=q.pop();if(Z!==L){q[0]=Z;e:for(var se=0,ue=q.length,T=ue>>>1;se<T;){var V=2*(se+1)-1,te=q[V],ae=V+1,he=q[ae];if(0>d(te,Z))ae<ue&&0>d(he,te)?(q[se]=he,q[ae]=Z,se=ae):(q[se]=te,q[V]=Z,se=V);else if(ae<ue&&0>d(he,Z))q[se]=he,q[ae]=Z,se=ae;else break e}}return L}function d(q,L){var Z=q.sortIndex-L.sortIndex;return Z!==0?Z:q.id-L.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;n.unstable_now=function(){return f.now()}}else{var p=Date,h=p.now();n.unstable_now=function(){return p.now()-h}}var x=[],g=[],b=1,y=null,S=3,M=!1,j=!1,E=!1,N=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function k(q){for(var L=l(g);L!==null;){if(L.callback===null)o(g);else if(L.startTime<=q)o(g),L.sortIndex=L.expirationTime,s(x,L);else break;L=l(g)}}function O(q){if(E=!1,k(q),!j)if(l(x)!==null)j=!0,X||(X=!0,ee());else{var L=l(g);L!==null&&z(O,L.startTime-q)}}var X=!1,D=-1,H=5,K=-1;function $(){return N?!0:!(n.unstable_now()-K<H)}function Y(){if(N=!1,X){var q=n.unstable_now();K=q;var L=!0;try{e:{j=!1,E&&(E=!1,A(D),D=-1),M=!0;var Z=S;try{t:{for(k(q),y=l(x);y!==null&&!(y.expirationTime>q&&$());){var se=y.callback;if(typeof se=="function"){y.callback=null,S=y.priorityLevel;var ue=se(y.expirationTime<=q);if(q=n.unstable_now(),typeof ue=="function"){y.callback=ue,k(q),L=!0;break t}y===l(x)&&o(x),k(q)}else o(x);y=l(x)}if(y!==null)L=!0;else{var T=l(g);T!==null&&z(O,T.startTime-q),L=!1}}break e}finally{y=null,S=Z,M=!1}L=void 0}}finally{L?ee():X=!1}}}var ee;if(typeof R=="function")ee=function(){R(Y)};else if(typeof MessageChannel<"u"){var oe=new MessageChannel,ce=oe.port2;oe.port1.onmessage=Y,ee=function(){ce.postMessage(null)}}else ee=function(){C(Y,0)};function z(q,L){D=C(function(){q(n.unstable_now())},L)}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(q){q.callback=null},n.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<q?Math.floor(1e3/q):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(q){switch(S){case 1:case 2:case 3:var L=3;break;default:L=S}var Z=S;S=L;try{return q()}finally{S=Z}},n.unstable_requestPaint=function(){N=!0},n.unstable_runWithPriority=function(q,L){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var Z=S;S=q;try{return L()}finally{S=Z}},n.unstable_scheduleCallback=function(q,L,Z){var se=n.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?se+Z:se):Z=se,q){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=Z+ue,q={id:b++,callback:L,priorityLevel:q,startTime:Z,expirationTime:ue,sortIndex:-1},Z>se?(q.sortIndex=Z,s(g,q),l(x)===null&&q===l(g)&&(E?(A(D),D=-1):E=!0,z(O,Z-se))):(q.sortIndex=ue,s(x,q),j||M||(j=!0,X||(X=!0,ee()))),q},n.unstable_shouldYield=$,n.unstable_wrapCallback=function(q){var L=S;return function(){var Z=S;S=L;try{return q.apply(this,arguments)}finally{S=Z}}}})(Ju)),Ju}var yp;function yy(){return yp||(yp=1,Iu.exports=vy()),Iu.exports}var Pu={exports:{}},Ot={};var Sp;function Sy(){if(Sp)return Ot;Sp=1;var n=$d();function s(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)g+="&args[]="+encodeURIComponent(arguments[b])}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 l(){}var o={d:{f:l,r:function(){throw Error(s(522))},D:l,C:l,L:l,m:l,X:l,S:l,M:l},p:0,findDOMNode:null},d=Symbol.for("react.portal");function f(x,g,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:d,key:y==null?null:""+y,children:x,containerInfo:g,implementation:b}}var p=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(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 b=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 f(x,g,null,b)},Ot.flushSync=function(x){var g=p.T,b=o.p;try{if(p.T=null,o.p=2,x)return x()}finally{p.T=g,o.p=b,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 b=g.as,y=h(b,g.crossOrigin),S=typeof g.integrity=="string"?g.integrity:void 0,M=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;b==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:M}):b==="script"&&o.d.X(x,{crossOrigin:y,integrity:S,fetchPriority:M,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 b=h(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:b,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 b=g.as,y=h(b,g.crossOrigin);o.d.L(x,b,{crossOrigin:y,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 b=h(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:b,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,b){return p.H.useFormState(x,g,b)},Ot.useFormStatus=function(){return p.H.useHostTransitionStatus()},Ot.version="19.2.0",Ot}var jp;function jy(){if(jp)return Pu.exports;jp=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(),Pu.exports=Sy(),Pu.exports}var Np;function Ny(){if(Np)return ri;Np=1;var n=yy(),s=$d(),l=jy();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 d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(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 p(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 h(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(f(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(o(188));return t!==e?null:e}for(var a=e,i=t;;){var c=a.return;if(c===null)break;var u=c.alternate;if(u===null){if(i=c.return,i!==null){a=i;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===a)return x(c),e;if(u===i)return x(c),t;u=u.sibling}throw Error(o(188))}if(a.return!==i.return)a=c,i=u;else{for(var v=!1,w=c.child;w;){if(w===a){v=!0,a=c,i=u;break}if(w===i){v=!0,i=c,a=u;break}w=w.sibling}if(!v){for(w=u.child;w;){if(w===a){v=!0,a=u,i=c;break}if(w===i){v=!0,i=u,a=c;break}w=w.sibling}if(!v)throw Error(o(189))}}if(a.alternate!==i)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?e:t}function b(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=b(e),t!==null)return t;e=e.sibling}return null}var y=Object.assign,S=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),R=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function ee(e){return e===null||typeof e!="object"?null:(e=Y&&e[Y]||e["@@iterator"],typeof e=="function"?e:null)}var oe=Symbol.for("react.client.reference");function ce(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case C:return"Profiler";case N:return"StrictMode";case O:return"Suspense";case X:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case R:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case k:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case D:return t=e.displayName||null,t!==null?t:ce(e.type)||"Memo";case H:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var z=Array.isArray,q=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},se=[],ue=-1;function T(e){return{current:e}}function V(e){0>ue||(e.current=se[ue],se[ue]=null,ue--)}function te(e,t){ue++,se[ue]=e.current,e.current=t}var ae=T(null),he=T(null),re=T(null),de=T(null);function ve(e,t){switch(te(re,t),te(he,e),te(ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?z0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=z0(t),e=U0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}V(ae),te(ae,e)}function fe(){V(ae),V(he),V(re)}function pe(e){e.memoizedState!==null&&te(de,e);var t=ae.current,a=U0(t,e.type);t!==a&&(te(he,e),te(ae,a))}function Le(e){he.current===e&&(V(ae),V(he)),de.current===e&&(V(de),ni._currentValue=Z)}var ke,Ce;function _e(e){if(ke===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);ke=t&&t[1]||"",Ce=-1<a.stack.indexOf(`
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
`+ke+e+Ce}var ze=!1;function ht(e,t){if(!e||ze)return"";ze=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var ne=function(){throw Error()};if(Object.defineProperty(ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ne,[])}catch(I){var Q=I}Reflect.construct(e,[],ne)}else{try{ne.call()}catch(I){Q=I}e.call(ne.prototype)}}else{try{throw Error()}catch(I){Q=I}(ne=e())&&typeof ne.catch=="function"&&ne.catch(function(){})}}catch(I){if(I&&Q&&typeof I.stack=="string")return[I.stack,Q.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=i.DetermineComponentFrameRoot(),v=u[0],w=u[1];if(v&&w){var _=v.split(`
`),F=w.split(`
`);for(c=i=0;i<_.length&&!_[i].includes("DetermineComponentFrameRoot");)i++;for(;c<F.length&&!F[c].includes("DetermineComponentFrameRoot");)c++;if(i===_.length||c===F.length)for(i=_.length-1,c=F.length-1;1<=i&&0<=c&&_[i]!==F[c];)c--;for(;1<=i&&0<=c;i--,c--)if(_[i]!==F[c]){if(i!==1||c!==1)do if(i--,c--,0>c||_[i]!==F[c]){var P=`
`+_[i].replace(" at new "," at ");return e.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",e.displayName)),P}while(1<=i&&0<=c);break}}}finally{ze=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?_e(a):""}function ie(e,t){switch(e.tag){case 26:case 27:case 5:return _e(e.type);case 16:return _e("Lazy");case 13:return e.child!==t&&t!==null?_e("Suspense Fallback"):_e("Suspense");case 19:return _e("SuspenseList");case 0:case 15:return ht(e.type,!1);case 11:return ht(e.type.render,!1);case 1:return ht(e.type,!0);case 31:return _e("Activity");default:return""}}function xe(e){try{var t="",a=null;do t+=ie(e,a),a=e,e=e.return;while(e);return t}catch(i){return`
Error generating stack: `+i.message+`
`+i.stack}}var le=Object.prototype.hasOwnProperty,J=n.unstable_scheduleCallback,ge=n.unstable_cancelCallback,Ne=n.unstable_shouldYield,pt=n.unstable_requestPaint,Ue=n.unstable_now,ct=n.unstable_getCurrentPriorityLevel,ut=n.unstable_ImmediatePriority,bt=n.unstable_UserBlockingPriority,Mt=n.unstable_NormalPriority,fs=n.unstable_LowPriority,Yt=n.unstable_IdlePriority,za=n.log,Oo=n.unstable_setDisableYieldValue,Bn=null,At=null;function Ft(e){if(typeof za=="function"&&Oo(e),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Bn,e)}catch{}}var Rt=Math.clz32?Math.clz32:ms,fa=Math.log,Lo=Math.LN2;function ms(e){return e>>>=0,e===0?32:31-(fa(e)/Lo|0)|0}var hs=256,Ua=262144,et=4194304;function On(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 wn(e,t,a){var i=e.pendingLanes;if(i===0)return 0;var c=0,u=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var w=i&134217727;return w!==0?(i=w&~u,i!==0?c=On(i):(v&=w,v!==0?c=On(v):a||(a=w&~e,a!==0&&(c=On(a))))):(w=i&~u,w!==0?c=On(w):v!==0?c=On(v):a||(a=i&~e,a!==0&&(c=On(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 Ln(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ps(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 hl(){var e=et;return et<<=1,(et&62914560)===0&&(et=4194304),e}function pl(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function Ha(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function zo(e,t,a,i,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 w=e.entanglements,_=e.expirationTimes,F=e.hiddenUpdates;for(a=v&~a;0<a;){var P=31-Rt(a),ne=1<<P;w[P]=0,_[P]=-1;var Q=F[P];if(Q!==null)for(F[P]=null,P=0;P<Q.length;P++){var I=Q[P];I!==null&&(I.lane&=-536870913)}a&=~ne}i!==0&&xl(e,i,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(v&~t))}function xl(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-Rt(t);e.entangledLanes|=t,e.entanglements[i]=e.entanglements[i]|1073741824|a&261930}function nn(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var i=31-Rt(a),c=1<<i;c&t|e[i]&t&&(e[i]|=t),a&=~c}}function ye(e,t){var a=t&-t;return a=(a&42)!==0?1:Qe(a),(a&(e.suspendedLanes|t))!==0?0:a}function Qe(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 Me(){var e=L.p;return e!==0?e:(e=window.event,e===void 0?32:op(e.type))}function Ye(e,t){var a=L.p;try{return L.p=e,t()}finally{L.p=a}}var lt=Math.random().toString(36).slice(2),it="__reactFiber$"+lt,wt="__reactProps$"+lt,at="__reactContainer$"+lt,zn="__reactEvents$"+lt,sb="__reactListeners$"+lt,lb="__reactHandles$"+lt,wf="__reactResources$"+lt,gl="__reactMarker$"+lt;function Uo(e){delete e[it],delete e[wt],delete e[zn],delete e[sb],delete e[lb]}function xs(e){var t=e[it];if(t)return t;for(var a=e.parentNode;a;){if(t=a[at]||a[it]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=X0(e);e!==null;){if(a=e[it])return a;e=X0(e)}return t}e=a,a=e.parentNode}return null}function gs(e){if(e=e[it]||e[at]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function bl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function bs(e){var t=e[wf];return t||(t=e[wf]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Et(e){e[gl]=!0}var Cf=new Set,Ef={};function Va(e,t){vs(e,t),vs(e+"Capture",t)}function vs(e,t){for(Ef[e]=t,e=0;e<t.length;e++)Cf.add(t[e])}var ib=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]*$"),kf={},Mf={};function rb(e){return le.call(Mf,e)?!0:le.call(kf,e)?!1:ib.test(e)?Mf[e]=!0:(kf[e]=!0,!1)}function _i(e,t,a){if(rb(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function Bi(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 Un(e,t,a,i){if(i===null)e.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+i)}}function an(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Rf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ob(e,t,a){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,u=i.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:i.enumerable}),{getValue:function(){return a},setValue:function(v){a=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ho(e){if(!e._valueTracker){var t=Rf(e)?"checked":"value";e._valueTracker=ob(e,t,""+e[t])}}function qf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),i="";return e&&(i=Rf(e)?e.checked?"true":"false":e.value),e=i,e!==a?(t.setValue(e),!0):!1}function Oi(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 cb=/[\n"\\]/g;function sn(e){return e.replace(cb,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Vo(e,t,a,i,c,u,v,w){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=""+an(t)):e.value!==""+an(t)&&(e.value=""+an(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?$o(e,v,an(t)):a!=null?$o(e,v,an(a)):i!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?e.name=""+an(w):e.removeAttribute("name")}function Tf(e,t,a,i,c,u,v,w){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)){Ho(e);return}a=a!=null?""+an(a):"",t=t!=null?""+an(t):a,w||t===e.value||(e.value=t),e.defaultValue=t}i=i??c,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=w?e.checked:!!i,e.defaultChecked=!!i,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),Ho(e)}function $o(e,t,a){t==="number"&&Oi(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function ys(e,t,a,i){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&&i&&(e[a].defaultSelected=!0)}else{for(a=""+an(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,i&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Df(e,t,a){if(t!=null&&(t=""+an(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+an(a):""}function _f(e,t,a,i){if(t==null){if(i!=null){if(a!=null)throw Error(o(92));if(z(i)){if(1<i.length)throw Error(o(93));i=i[0]}a=i}a==null&&(a=""),t=a}a=an(t),e.defaultValue=a,i=e.textContent,i===a&&i!==""&&i!==null&&(e.value=i),Ho(e)}function Ss(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var ub=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 Bf(e,t,a){var i=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?i?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":i?e.setProperty(t,a):typeof a!="number"||a===0||ub.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Of(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var i in a)!a.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var c in t)i=t[c],t.hasOwnProperty(c)&&a[c]!==i&&Bf(e,c,i)}else for(var u in t)t.hasOwnProperty(u)&&Bf(e,u,t[u])}function Go(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 db=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"]]),fb=/^[\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 Li(e){return fb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Hn(){}var Yo=null;function Fo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var js=null,Ns=null;function Lf(e){var t=gs(e);if(t&&(e=t.stateNode)){var a=e[wt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Vo(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="'+sn(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var i=a[t];if(i!==e&&i.form===e.form){var c=i[wt]||null;if(!c)throw Error(o(90));Vo(i,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)i=a[t],i.form===e.form&&qf(i)}break e;case"textarea":Df(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&ys(e,!!a.multiple,t,!1)}}}var Xo=!1;function zf(e,t,a){if(Xo)return e(t,a);Xo=!0;try{var i=e(t);return i}finally{if(Xo=!1,(js!==null||Ns!==null)&&(Ar(),js&&(t=js,e=Ns,Ns=js=null,Lf(t),e)))for(t=0;t<e.length;t++)Lf(e[t])}}function vl(e,t){var a=e.stateNode;if(a===null)return null;var i=a[wt]||null;if(i===null)return null;a=i[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":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Vn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Qo=!1;if(Vn)try{var yl={};Object.defineProperty(yl,"passive",{get:function(){Qo=!0}}),window.addEventListener("test",yl,yl),window.removeEventListener("test",yl,yl)}catch{Qo=!1}var ma=null,Ko=null,zi=null;function Uf(){if(zi)return zi;var e,t=Ko,a=t.length,i,c="value"in ma?ma.value:ma.textContent,u=c.length;for(e=0;e<a&&t[e]===c[e];e++);var v=a-e;for(i=1;i<=v&&t[a-i]===c[u-i];i++);return zi=c.slice(e,1<i?1-i:void 0)}function Ui(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 Hi(){return!0}function Hf(){return!1}function zt(e){function t(a,i,c,u,v){this._reactName=a,this._targetInst=c,this.type=i,this.nativeEvent=u,this.target=v,this.currentTarget=null;for(var w in e)e.hasOwnProperty(w)&&(a=e[w],this[w]=a?a(u):u[w]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Hi:Hf,this.isPropagationStopped=Hf,this}return y(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=Hi)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Hi)},persist:function(){},isPersistent:Hi}),t}var $a={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vi=zt($a),Sl=y({},$a,{view:0,detail:0}),mb=zt(Sl),Zo,Io,jl,$i=y({},Sl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Po,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!==jl&&(jl&&e.type==="mousemove"?(Zo=e.screenX-jl.screenX,Io=e.screenY-jl.screenY):Io=Zo=0,jl=e),Zo)},movementY:function(e){return"movementY"in e?e.movementY:Io}}),Vf=zt($i),hb=y({},$i,{dataTransfer:0}),pb=zt(hb),xb=y({},Sl,{relatedTarget:0}),Jo=zt(xb),gb=y({},$a,{animationName:0,elapsedTime:0,pseudoElement:0}),bb=zt(gb),vb=y({},$a,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),yb=zt(vb),Sb=y({},$a,{data:0}),$f=zt(Sb),jb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nb={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"},Ab={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wb(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Ab[e])?!!t[e]:!1}function Po(){return wb}var Cb=y({},Sl,{key:function(e){if(e.key){var t=jb[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Nb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Po,charCode:function(e){return e.type==="keypress"?Ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Eb=zt(Cb),kb=y({},$i,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gf=zt(kb),Mb=y({},Sl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Po}),Rb=zt(Mb),qb=y({},$a,{propertyName:0,elapsedTime:0,pseudoElement:0}),Tb=zt(qb),Db=y({},$i,{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}),_b=zt(Db),Bb=y({},$a,{newState:0,oldState:0}),Ob=zt(Bb),Lb=[9,13,27,32],Wo=Vn&&"CompositionEvent"in window,Nl=null;Vn&&"documentMode"in document&&(Nl=document.documentMode);var zb=Vn&&"TextEvent"in window&&!Nl,Yf=Vn&&(!Wo||Nl&&8<Nl&&11>=Nl),Ff=" ",Xf=!1;function Qf(e,t){switch(e){case"keyup":return Lb.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var As=!1;function Ub(e,t){switch(e){case"compositionend":return Kf(t);case"keypress":return t.which!==32?null:(Xf=!0,Ff);case"textInput":return e=t.data,e===Ff&&Xf?null:e;default:return null}}function Hb(e,t){if(As)return e==="compositionend"||!Wo&&Qf(e,t)?(e=Uf(),zi=Ko=ma=null,As=!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 Yf&&t.locale!=="ko"?null:t.data;default:return null}}var Vb={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 Zf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Vb[e.type]:t==="textarea"}function If(e,t,a,i){js?Ns?Ns.push(i):Ns=[i]:js=i,t=qr(t,"onChange"),0<t.length&&(a=new Vi("onChange","change",null,a,i),e.push({event:a,listeners:t}))}var Al=null,wl=null;function $b(e){T0(e,0)}function Gi(e){var t=bl(e);if(qf(t))return e}function Jf(e,t){if(e==="change")return t}var Pf=!1;if(Vn){var ec;if(Vn){var tc="oninput"in document;if(!tc){var Wf=document.createElement("div");Wf.setAttribute("oninput","return;"),tc=typeof Wf.oninput=="function"}ec=tc}else ec=!1;Pf=ec&&(!document.documentMode||9<document.documentMode)}function em(){Al&&(Al.detachEvent("onpropertychange",tm),wl=Al=null)}function tm(e){if(e.propertyName==="value"&&Gi(wl)){var t=[];If(t,wl,e,Fo(e)),zf($b,t)}}function Gb(e,t,a){e==="focusin"?(em(),Al=t,wl=a,Al.attachEvent("onpropertychange",tm)):e==="focusout"&&em()}function Yb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Gi(wl)}function Fb(e,t){if(e==="click")return Gi(t)}function Xb(e,t){if(e==="input"||e==="change")return Gi(t)}function Qb(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xt=typeof Object.is=="function"?Object.is:Qb;function Cl(e,t){if(Xt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),i=Object.keys(t);if(a.length!==i.length)return!1;for(i=0;i<a.length;i++){var c=a[i];if(!le.call(t,c)||!Xt(e[c],t[c]))return!1}return!0}function nm(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function am(e,t){var a=nm(e);e=0;for(var i;a;){if(a.nodeType===3){if(i=e+a.textContent.length,e<=t&&i>=t)return{node:a,offset:t-e};e=i}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=nm(a)}}function sm(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?sm(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function lm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Oi(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=Oi(e.document)}return t}function nc(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 Kb=Vn&&"documentMode"in document&&11>=document.documentMode,ws=null,ac=null,El=null,sc=!1;function im(e,t,a){var i=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;sc||ws==null||ws!==Oi(i)||(i=ws,"selectionStart"in i&&nc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),El&&Cl(El,i)||(El=i,i=qr(ac,"onSelect"),0<i.length&&(t=new Vi("onSelect","select",null,t,a),e.push({event:t,listeners:i}),t.target=ws)))}function Ga(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Cs={animationend:Ga("Animation","AnimationEnd"),animationiteration:Ga("Animation","AnimationIteration"),animationstart:Ga("Animation","AnimationStart"),transitionrun:Ga("Transition","TransitionRun"),transitionstart:Ga("Transition","TransitionStart"),transitioncancel:Ga("Transition","TransitionCancel"),transitionend:Ga("Transition","TransitionEnd")},lc={},rm={};Vn&&(rm=document.createElement("div").style,"AnimationEvent"in window||(delete Cs.animationend.animation,delete Cs.animationiteration.animation,delete Cs.animationstart.animation),"TransitionEvent"in window||delete Cs.transitionend.transition);function Ya(e){if(lc[e])return lc[e];if(!Cs[e])return e;var t=Cs[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in rm)return lc[e]=t[a];return e}var om=Ya("animationend"),cm=Ya("animationiteration"),um=Ya("animationstart"),Zb=Ya("transitionrun"),Ib=Ya("transitionstart"),Jb=Ya("transitioncancel"),dm=Ya("transitionend"),fm=new Map,ic="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(" ");ic.push("scrollEnd");function bn(e,t){fm.set(e,t),Va(t,[e])}var Yi=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)},ln=[],Es=0,rc=0;function Fi(){for(var e=Es,t=rc=Es=0;t<e;){var a=ln[t];ln[t++]=null;var i=ln[t];ln[t++]=null;var c=ln[t];ln[t++]=null;var u=ln[t];if(ln[t++]=null,i!==null&&c!==null){var v=i.pending;v===null?c.next=c:(c.next=v.next,v.next=c),i.pending=c}u!==0&&mm(a,c,u)}}function Xi(e,t,a,i){ln[Es++]=e,ln[Es++]=t,ln[Es++]=a,ln[Es++]=i,rc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function oc(e,t,a,i){return Xi(e,t,a,i),Qi(e)}function Fa(e,t){return Xi(e,null,null,t),Qi(e)}function mm(e,t,a){e.lanes|=a;var i=e.alternate;i!==null&&(i.lanes|=a);for(var c=!1,u=e.return;u!==null;)u.childLanes|=a,i=u.alternate,i!==null&&(i.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-Rt(a),e=u.hiddenUpdates,i=e[c],i===null?e[c]=[t]:i.push(t),t.lane=a|536870912),u):null}function Qi(e){if(50<Zl)throw Zl=0,gu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ks={};function Pb(e,t,a,i){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=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qt(e,t,a,i){return new Pb(e,t,a,i)}function cc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $n(e,t){var a=e.alternate;return a===null?(a=Qt(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 hm(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 Ki(e,t,a,i,c,u){var v=0;if(i=e,typeof e=="function")cc(e)&&(v=1);else if(typeof e=="string")v=ay(e,a,ae.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case K:return e=Qt(31,a,t,c),e.elementType=K,e.lanes=u,e;case E:return Xa(a.children,c,u,t);case N:v=8,c|=24;break;case C:return e=Qt(12,a,t,c|2),e.elementType=C,e.lanes=u,e;case O:return e=Qt(13,a,t,c),e.elementType=O,e.lanes=u,e;case X:return e=Qt(19,a,t,c),e.elementType=X,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:v=10;break e;case A:v=9;break e;case k:v=11;break e;case D:v=14;break e;case H:v=16,i=null;break e}v=29,a=Error(o(130,e===null?"null":typeof e,"")),i=null}return t=Qt(v,a,t,c),t.elementType=e,t.type=i,t.lanes=u,t}function Xa(e,t,a,i){return e=Qt(7,e,i,t),e.lanes=a,e}function uc(e,t,a){return e=Qt(6,e,null,t),e.lanes=a,e}function pm(e){var t=Qt(18,null,null,0);return t.stateNode=e,t}function dc(e,t,a){return t=Qt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var xm=new WeakMap;function rn(e,t){if(typeof e=="object"&&e!==null){var a=xm.get(e);return a!==void 0?a:(t={value:e,source:t,stack:xe(t)},xm.set(e,t),t)}return{value:e,source:t,stack:xe(t)}}var Ms=[],Rs=0,Zi=null,kl=0,on=[],cn=0,ha=null,Cn=1,En="";function Gn(e,t){Ms[Rs++]=kl,Ms[Rs++]=Zi,Zi=e,kl=t}function gm(e,t,a){on[cn++]=Cn,on[cn++]=En,on[cn++]=ha,ha=e;var i=Cn;e=En;var c=32-Rt(i)-1;i&=~(1<<c),a+=1;var u=32-Rt(t)+c;if(30<u){var v=c-c%5;u=(i&(1<<v)-1).toString(32),i>>=v,c-=v,Cn=1<<32-Rt(t)+c|a<<c|i,En=u+e}else Cn=1<<u|a<<c|i,En=e}function fc(e){e.return!==null&&(Gn(e,1),gm(e,1,0))}function mc(e){for(;e===Zi;)Zi=Ms[--Rs],Ms[Rs]=null,kl=Ms[--Rs],Ms[Rs]=null;for(;e===ha;)ha=on[--cn],on[cn]=null,En=on[--cn],on[cn]=null,Cn=on[--cn],on[cn]=null}function bm(e,t){on[cn++]=Cn,on[cn++]=En,on[cn++]=ha,Cn=t.id,En=t.overflow,ha=e}var qt=null,tt=null,Be=!1,pa=null,un=!1,hc=Error(o(519));function xa(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ml(rn(t,e)),hc}function vm(e){var t=e.stateNode,a=e.type,i=e.memoizedProps;switch(t[it]=e,t[wt]=i,a){case"dialog":qe("cancel",t),qe("close",t);break;case"iframe":case"object":case"embed":qe("load",t);break;case"video":case"audio":for(a=0;a<Jl.length;a++)qe(Jl[a],t);break;case"source":qe("error",t);break;case"img":case"image":case"link":qe("error",t),qe("load",t);break;case"details":qe("toggle",t);break;case"input":qe("invalid",t),Tf(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":qe("invalid",t);break;case"textarea":qe("invalid",t),_f(t,i.value,i.defaultValue,i.children)}a=i.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||i.suppressHydrationWarning===!0||O0(t.textContent,a)?(i.popover!=null&&(qe("beforetoggle",t),qe("toggle",t)),i.onScroll!=null&&qe("scroll",t),i.onScrollEnd!=null&&qe("scrollend",t),i.onClick!=null&&(t.onclick=Hn),t=!0):t=!1,t||xa(e,!0)}function ym(e){for(qt=e.return;qt;)switch(qt.tag){case 5:case 31:case 13:un=!1;return;case 27:case 3:un=!0;return;default:qt=qt.return}}function qs(e){if(e!==qt)return!1;if(!Be)return ym(e),Be=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Tu(e.type,e.memoizedProps)),a=!a),a&&tt&&xa(e),ym(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));tt=F0(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));tt=F0(e)}else t===27?(t=tt,Ra(e.type)?(e=Lu,Lu=null,tt=e):tt=t):tt=qt?fn(e.stateNode.nextSibling):null;return!0}function Qa(){tt=qt=null,Be=!1}function pc(){var e=pa;return e!==null&&($t===null?$t=e:$t.push.apply($t,e),pa=null),e}function Ml(e){pa===null?pa=[e]:pa.push(e)}var xc=T(null),Ka=null,Yn=null;function ga(e,t,a){te(xc,t._currentValue),t._currentValue=a}function Fn(e){e._currentValue=xc.current,V(xc)}function gc(e,t,a){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===a)break;e=e.return}}function bc(e,t,a,i){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 w=u;u=c;for(var _=0;_<t.length;_++)if(w.context===t[_]){u.lanes|=a,w=u.alternate,w!==null&&(w.lanes|=a),gc(u.return,a,e),i||(v=null);break e}u=w.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),gc(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 Ts(e,t,a,i){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 w=c.type;Xt(c.pendingProps.value,v.value)||(e!==null?e.push(w):e=[w])}}else if(c===de.current){if(v=c.alternate,v===null)throw Error(o(387));v.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(ni):e=[ni])}c=c.return}e!==null&&bc(t,e,a,i),t.flags|=262144}function Ii(e){for(e=e.firstContext;e!==null;){if(!Xt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Za(e){Ka=e,Yn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Tt(e){return Sm(Ka,e)}function Ji(e,t){return Ka===null&&Za(e),Sm(e,t)}function Sm(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Yn===null){if(e===null)throw Error(o(308));Yn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Yn=Yn.next=t;return a}var Wb=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,i){e.push(i)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},ev=n.unstable_scheduleCallback,tv=n.unstable_NormalPriority,vt={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function vc(){return{controller:new Wb,data:new Map,refCount:0}}function Rl(e){e.refCount--,e.refCount===0&&ev(tv,function(){e.controller.abort()})}var ql=null,yc=0,Ds=0,_s=null;function nv(e,t){if(ql===null){var a=ql=[];yc=0,Ds=Nu(),_s={status:"pending",value:void 0,then:function(i){a.push(i)}}}return yc++,t.then(jm,jm),t}function jm(){if(--yc===0&&ql!==null){_s!==null&&(_s.status="fulfilled");var e=ql;ql=null,Ds=0,_s=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function av(e,t){var a=[],i={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){i.status="fulfilled",i.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(i.status="rejected",i.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),i}var Nm=q.S;q.S=function(e,t){i0=Ue(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&nv(e,t),Nm!==null&&Nm(e,t)};var Ia=T(null);function Sc(){var e=Ia.current;return e!==null?e:We.pooledCache}function Pi(e,t){t===null?te(Ia,Ia.current):te(Ia,t.pool)}function Am(){var e=Sc();return e===null?null:{parent:vt._currentValue,pool:e}}var Bs=Error(o(460)),jc=Error(o(474)),Wi=Error(o(542)),er={then:function(){}};function wm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Cm(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(Hn,Hn),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,km(e),e;default:if(typeof t.status=="string")t.then(Hn,Hn);else{if(e=We,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(i){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=i}},function(i){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=i}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,km(e),e}throw Pa=t,Bs}}function Ja(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Pa=a,Bs):a}}var Pa=null;function Em(){if(Pa===null)throw Error(o(459));var e=Pa;return Pa=null,e}function km(e){if(e===Bs||e===Wi)throw Error(o(483))}var Os=null,Tl=0;function tr(e){var t=Tl;return Tl+=1,Os===null&&(Os=[]),Cm(Os,e,t)}function Dl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function nr(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 Mm(e){function t(U,B){if(e){var G=U.deletions;G===null?(U.deletions=[B],U.flags|=16):G.push(B)}}function a(U,B){if(!e)return null;for(;B!==null;)t(U,B),B=B.sibling;return null}function i(U){for(var B=new Map;U!==null;)U.key!==null?B.set(U.key,U):B.set(U.index,U),U=U.sibling;return B}function c(U,B){return U=$n(U,B),U.index=0,U.sibling=null,U}function u(U,B,G){return U.index=G,e?(G=U.alternate,G!==null?(G=G.index,G<B?(U.flags|=67108866,B):G):(U.flags|=67108866,B)):(U.flags|=1048576,B)}function v(U){return e&&U.alternate===null&&(U.flags|=67108866),U}function w(U,B,G,W){return B===null||B.tag!==6?(B=uc(G,U.mode,W),B.return=U,B):(B=c(B,G),B.return=U,B)}function _(U,B,G,W){var Se=G.type;return Se===E?P(U,B,G.props.children,W,G.key):B!==null&&(B.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===H&&Ja(Se)===B.type)?(B=c(B,G.props),Dl(B,G),B.return=U,B):(B=Ki(G.type,G.key,G.props,null,U.mode,W),Dl(B,G),B.return=U,B)}function F(U,B,G,W){return B===null||B.tag!==4||B.stateNode.containerInfo!==G.containerInfo||B.stateNode.implementation!==G.implementation?(B=dc(G,U.mode,W),B.return=U,B):(B=c(B,G.children||[]),B.return=U,B)}function P(U,B,G,W,Se){return B===null||B.tag!==7?(B=Xa(G,U.mode,W,Se),B.return=U,B):(B=c(B,G),B.return=U,B)}function ne(U,B,G){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=uc(""+B,U.mode,G),B.return=U,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case M:return G=Ki(B.type,B.key,B.props,null,U.mode,G),Dl(G,B),G.return=U,G;case j:return B=dc(B,U.mode,G),B.return=U,B;case H:return B=Ja(B),ne(U,B,G)}if(z(B)||ee(B))return B=Xa(B,U.mode,G,null),B.return=U,B;if(typeof B.then=="function")return ne(U,tr(B),G);if(B.$$typeof===R)return ne(U,Ji(U,B),G);nr(U,B)}return null}function Q(U,B,G,W){var Se=B!==null?B.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Se!==null?null:w(U,B,""+G,W);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case M:return G.key===Se?_(U,B,G,W):null;case j:return G.key===Se?F(U,B,G,W):null;case H:return G=Ja(G),Q(U,B,G,W)}if(z(G)||ee(G))return Se!==null?null:P(U,B,G,W,null);if(typeof G.then=="function")return Q(U,B,tr(G),W);if(G.$$typeof===R)return Q(U,B,Ji(U,G),W);nr(U,G)}return null}function I(U,B,G,W,Se){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return U=U.get(G)||null,w(B,U,""+W,Se);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case M:return U=U.get(W.key===null?G:W.key)||null,_(B,U,W,Se);case j:return U=U.get(W.key===null?G:W.key)||null,F(B,U,W,Se);case H:return W=Ja(W),I(U,B,G,W,Se)}if(z(W)||ee(W))return U=U.get(G)||null,P(B,U,W,Se,null);if(typeof W.then=="function")return I(U,B,G,tr(W),Se);if(W.$$typeof===R)return I(U,B,G,Ji(B,W),Se);nr(B,W)}return null}function me(U,B,G,W){for(var Se=null,He=null,be=B,Ee=B=0,De=null;be!==null&&Ee<G.length;Ee++){be.index>Ee?(De=be,be=null):De=be.sibling;var Ve=Q(U,be,G[Ee],W);if(Ve===null){be===null&&(be=De);break}e&&be&&Ve.alternate===null&&t(U,be),B=u(Ve,B,Ee),He===null?Se=Ve:He.sibling=Ve,He=Ve,be=De}if(Ee===G.length)return a(U,be),Be&&Gn(U,Ee),Se;if(be===null){for(;Ee<G.length;Ee++)be=ne(U,G[Ee],W),be!==null&&(B=u(be,B,Ee),He===null?Se=be:He.sibling=be,He=be);return Be&&Gn(U,Ee),Se}for(be=i(be);Ee<G.length;Ee++)De=I(be,U,Ee,G[Ee],W),De!==null&&(e&&De.alternate!==null&&be.delete(De.key===null?Ee:De.key),B=u(De,B,Ee),He===null?Se=De:He.sibling=De,He=De);return e&&be.forEach(function(Ba){return t(U,Ba)}),Be&&Gn(U,Ee),Se}function je(U,B,G,W){if(G==null)throw Error(o(151));for(var Se=null,He=null,be=B,Ee=B=0,De=null,Ve=G.next();be!==null&&!Ve.done;Ee++,Ve=G.next()){be.index>Ee?(De=be,be=null):De=be.sibling;var Ba=Q(U,be,Ve.value,W);if(Ba===null){be===null&&(be=De);break}e&&be&&Ba.alternate===null&&t(U,be),B=u(Ba,B,Ee),He===null?Se=Ba:He.sibling=Ba,He=Ba,be=De}if(Ve.done)return a(U,be),Be&&Gn(U,Ee),Se;if(be===null){for(;!Ve.done;Ee++,Ve=G.next())Ve=ne(U,Ve.value,W),Ve!==null&&(B=u(Ve,B,Ee),He===null?Se=Ve:He.sibling=Ve,He=Ve);return Be&&Gn(U,Ee),Se}for(be=i(be);!Ve.done;Ee++,Ve=G.next())Ve=I(be,U,Ee,Ve.value,W),Ve!==null&&(e&&Ve.alternate!==null&&be.delete(Ve.key===null?Ee:Ve.key),B=u(Ve,B,Ee),He===null?Se=Ve:He.sibling=Ve,He=Ve);return e&&be.forEach(function(hy){return t(U,hy)}),Be&&Gn(U,Ee),Se}function Ie(U,B,G,W){if(typeof G=="object"&&G!==null&&G.type===E&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case M:e:{for(var Se=G.key;B!==null;){if(B.key===Se){if(Se=G.type,Se===E){if(B.tag===7){a(U,B.sibling),W=c(B,G.props.children),W.return=U,U=W;break e}}else if(B.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===H&&Ja(Se)===B.type){a(U,B.sibling),W=c(B,G.props),Dl(W,G),W.return=U,U=W;break e}a(U,B);break}else t(U,B);B=B.sibling}G.type===E?(W=Xa(G.props.children,U.mode,W,G.key),W.return=U,U=W):(W=Ki(G.type,G.key,G.props,null,U.mode,W),Dl(W,G),W.return=U,U=W)}return v(U);case j:e:{for(Se=G.key;B!==null;){if(B.key===Se)if(B.tag===4&&B.stateNode.containerInfo===G.containerInfo&&B.stateNode.implementation===G.implementation){a(U,B.sibling),W=c(B,G.children||[]),W.return=U,U=W;break e}else{a(U,B);break}else t(U,B);B=B.sibling}W=dc(G,U.mode,W),W.return=U,U=W}return v(U);case H:return G=Ja(G),Ie(U,B,G,W)}if(z(G))return me(U,B,G,W);if(ee(G)){if(Se=ee(G),typeof Se!="function")throw Error(o(150));return G=Se.call(G),je(U,B,G,W)}if(typeof G.then=="function")return Ie(U,B,tr(G),W);if(G.$$typeof===R)return Ie(U,B,Ji(U,G),W);nr(U,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,B!==null&&B.tag===6?(a(U,B.sibling),W=c(B,G),W.return=U,U=W):(a(U,B),W=uc(G,U.mode,W),W.return=U,U=W),v(U)):a(U,B)}return function(U,B,G,W){try{Tl=0;var Se=Ie(U,B,G,W);return Os=null,Se}catch(be){if(be===Bs||be===Wi)throw be;var He=Qt(29,be,null,U.mode);return He.lanes=W,He.return=U,He}finally{}}}var Wa=Mm(!0),Rm=Mm(!1),ba=!1;function Nc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ac(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 va(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ya(e,t,a){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,($e&2)!==0){var c=i.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),i.pending=t,t=Qi(e),mm(e,null,a),t}return Xi(e,i,t,a),Qi(e)}function _l(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,nn(e,a)}}function wc(e,t){var a=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,a===i)){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:i.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:i.shared,callbacks:i.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var Cc=!1;function Bl(){if(Cc){var e=_s;if(e!==null)throw e}}function Ol(e,t,a,i){Cc=!1;var c=e.updateQueue;ba=!1;var u=c.firstBaseUpdate,v=c.lastBaseUpdate,w=c.shared.pending;if(w!==null){c.shared.pending=null;var _=w,F=_.next;_.next=null,v===null?u=F:v.next=F,v=_;var P=e.alternate;P!==null&&(P=P.updateQueue,w=P.lastBaseUpdate,w!==v&&(w===null?P.firstBaseUpdate=F:w.next=F,P.lastBaseUpdate=_))}if(u!==null){var ne=c.baseState;v=0,P=F=_=null,w=u;do{var Q=w.lane&-536870913,I=Q!==w.lane;if(I?(Te&Q)===Q:(i&Q)===Q){Q!==0&&Q===Ds&&(Cc=!0),P!==null&&(P=P.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var me=e,je=w;Q=t;var Ie=a;switch(je.tag){case 1:if(me=je.payload,typeof me=="function"){ne=me.call(Ie,ne,Q);break e}ne=me;break e;case 3:me.flags=me.flags&-65537|128;case 0:if(me=je.payload,Q=typeof me=="function"?me.call(Ie,ne,Q):me,Q==null)break e;ne=y({},ne,Q);break e;case 2:ba=!0}}Q=w.callback,Q!==null&&(e.flags|=64,I&&(e.flags|=8192),I=c.callbacks,I===null?c.callbacks=[Q]:I.push(Q))}else I={lane:Q,tag:w.tag,payload:w.payload,callback:w.callback,next:null},P===null?(F=P=I,_=ne):P=P.next=I,v|=Q;if(w=w.next,w===null){if(w=c.shared.pending,w===null)break;I=w,w=I.next,I.next=null,c.lastBaseUpdate=I,c.shared.pending=null}}while(!0);P===null&&(_=ne),c.baseState=_,c.firstBaseUpdate=F,c.lastBaseUpdate=P,u===null&&(c.shared.lanes=0),wa|=v,e.lanes=v,e.memoizedState=ne}}function qm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function Tm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)qm(a[e],t)}var Ls=T(null),ar=T(0);function Dm(e,t){e=ea,te(ar,e),te(Ls,t),ea=e|t.baseLanes}function Ec(){te(ar,ea),te(Ls,Ls.current)}function kc(){ea=ar.current,V(Ls),V(ar)}var Kt=T(null),dn=null;function Sa(e){var t=e.alternate;te(xt,xt.current&1),te(Kt,e),dn===null&&(t===null||Ls.current!==null||t.memoizedState!==null)&&(dn=e)}function Mc(e){te(xt,xt.current),te(Kt,e),dn===null&&(dn=e)}function _m(e){e.tag===22?(te(xt,xt.current),te(Kt,e),dn===null&&(dn=e)):ja()}function ja(){te(xt,xt.current),te(Kt,Kt.current)}function Zt(e){V(Kt),dn===e&&(dn=null),V(xt)}var xt=T(0);function sr(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Bu(a)||Ou(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 Xn=0,we=null,Ke=null,yt=null,lr=!1,zs=!1,es=!1,ir=0,Ll=0,Us=null,sv=0;function dt(){throw Error(o(321))}function Rc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Xt(e[a],t[a]))return!1;return!0}function qc(e,t,a,i,c,u){return Xn=u,we=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,q.H=e===null||e.memoizedState===null?gh:Xc,es=!1,u=a(i,c),es=!1,zs&&(u=Om(t,a,i,c)),Bm(e),u}function Bm(e){q.H=Hl;var t=Ke!==null&&Ke.next!==null;if(Xn=0,yt=Ke=we=null,lr=!1,Ll=0,Us=null,t)throw Error(o(300));e===null||St||(e=e.dependencies,e!==null&&Ii(e)&&(St=!0))}function Om(e,t,a,i){we=e;var c=0;do{if(zs&&(Us=null),Ll=0,zs=!1,25<=c)throw Error(o(301));if(c+=1,yt=Ke=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}q.H=bh,u=t(a,i)}while(zs);return u}function lv(){var e=q.H,t=e.useState()[0];return t=typeof t.then=="function"?zl(t):t,e=e.useState()[0],(Ke!==null?Ke.memoizedState:null)!==e&&(we.flags|=1024),t}function Tc(){var e=ir!==0;return ir=0,e}function Dc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function _c(e){if(lr){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}lr=!1}Xn=0,yt=Ke=we=null,zs=!1,Ll=ir=0,Us=null}function Lt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yt===null?we.memoizedState=yt=e:yt=yt.next=e,yt}function gt(){if(Ke===null){var e=we.alternate;e=e!==null?e.memoizedState:null}else e=Ke.next;var t=yt===null?we.memoizedState:yt.next;if(t!==null)yt=t,Ke=e;else{if(e===null)throw we.alternate===null?Error(o(467)):Error(o(310));Ke=e,e={memoizedState:Ke.memoizedState,baseState:Ke.baseState,baseQueue:Ke.baseQueue,queue:Ke.queue,next:null},yt===null?we.memoizedState=yt=e:yt=yt.next=e}return yt}function rr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function zl(e){var t=Ll;return Ll+=1,Us===null&&(Us=[]),e=Cm(Us,e,t),t=we,(yt===null?t.memoizedState:yt.next)===null&&(t=t.alternate,q.H=t===null||t.memoizedState===null?gh:Xc),e}function or(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return zl(e);if(e.$$typeof===R)return Tt(e)}throw Error(o(438,String(e)))}function Bc(e){var t=null,a=we.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var i=we.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=rr(),we.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),i=0;i<e;i++)a[i]=$;return t.index++,a}function Qn(e,t){return typeof t=="function"?t(e):t}function cr(e){var t=gt();return Oc(t,Ke,e)}function Oc(e,t,a){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=a;var c=e.baseQueue,u=i.pending;if(u!==null){if(c!==null){var v=c.next;c.next=u.next,u.next=v}t.baseQueue=c=u,i.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var w=v=null,_=null,F=t,P=!1;do{var ne=F.lane&-536870913;if(ne!==F.lane?(Te&ne)===ne:(Xn&ne)===ne){var Q=F.revertLane;if(Q===0)_!==null&&(_=_.next={lane:0,revertLane:0,gesture:null,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null}),ne===Ds&&(P=!0);else if((Xn&Q)===Q){F=F.next,Q===Ds&&(P=!0);continue}else ne={lane:0,revertLane:F.revertLane,gesture:null,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null},_===null?(w=_=ne,v=u):_=_.next=ne,we.lanes|=Q,wa|=Q;ne=F.action,es&&a(u,ne),u=F.hasEagerState?F.eagerState:a(u,ne)}else Q={lane:ne,revertLane:F.revertLane,gesture:F.gesture,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null},_===null?(w=_=Q,v=u):_=_.next=Q,we.lanes|=ne,wa|=ne;F=F.next}while(F!==null&&F!==t);if(_===null?v=u:_.next=w,!Xt(u,e.memoizedState)&&(St=!0,P&&(a=_s,a!==null)))throw a;e.memoizedState=u,e.baseState=v,e.baseQueue=_,i.lastRenderedState=u}return c===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Lc(e){var t=gt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var i=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);Xt(u,t.memoizedState)||(St=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),a.lastRenderedState=u}return[u,i]}function Lm(e,t,a){var i=we,c=gt(),u=Be;if(u){if(a===void 0)throw Error(o(407));a=a()}else a=t();var v=!Xt((Ke||c).memoizedState,a);if(v&&(c.memoizedState=a,St=!0),c=c.queue,Hc(Hm.bind(null,i,c,e),[e]),c.getSnapshot!==t||v||yt!==null&&yt.memoizedState.tag&1){if(i.flags|=2048,Hs(9,{destroy:void 0},Um.bind(null,i,c,a,t),null),We===null)throw Error(o(349));u||(Xn&127)!==0||zm(i,t,a)}return a}function zm(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=we.updateQueue,t===null?(t=rr(),we.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Um(e,t,a,i){t.value=a,t.getSnapshot=i,Vm(t)&&$m(e)}function Hm(e,t,a){return a(function(){Vm(t)&&$m(e)})}function Vm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Xt(e,a)}catch{return!0}}function $m(e){var t=Fa(e,2);t!==null&&Gt(t,e,2)}function zc(e){var t=Lt();if(typeof e=="function"){var a=e;if(e=a(),es){Ft(!0);try{a()}finally{Ft(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:e},t}function Gm(e,t,a,i){return e.baseState=a,Oc(e,Ke,typeof i=="function"?i:Qn)}function iv(e,t,a,i,c){if(fr(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)}};q.T!==null?a(!0):u.isTransition=!1,i(u),a=t.pending,a===null?(u.next=t.pending=u,Ym(t,u)):(u.next=a.next,t.pending=a.next=u)}}function Ym(e,t){var a=t.action,i=t.payload,c=e.state;if(t.isTransition){var u=q.T,v={};q.T=v;try{var w=a(c,i),_=q.S;_!==null&&_(v,w),Fm(e,t,w)}catch(F){Uc(e,t,F)}finally{u!==null&&v.types!==null&&(u.types=v.types),q.T=u}}else try{u=a(c,i),Fm(e,t,u)}catch(F){Uc(e,t,F)}}function Fm(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(i){Xm(e,t,i)},function(i){return Uc(e,t,i)}):Xm(e,t,a)}function Xm(e,t,a){t.status="fulfilled",t.value=a,Qm(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Ym(e,a)))}function Uc(e,t,a){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=a,Qm(t),t=t.next;while(t!==i)}e.action=null}function Qm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Km(e,t){return t}function Zm(e,t){if(Be){var a=We.formState;if(a!==null){e:{var i=we;if(Be){if(tt){t:{for(var c=tt,u=un;c.nodeType!==8;){if(!u){c=null;break t}if(c=fn(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){tt=fn(c.nextSibling),i=c.data==="F!";break e}}xa(i)}i=!1}i&&(t=a[0])}}return a=Lt(),a.memoizedState=a.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Km,lastRenderedState:t},a.queue=i,a=hh.bind(null,we,i),i.dispatch=a,i=zc(!1),u=Fc.bind(null,we,!1,i.queue),i=Lt(),c={state:t,dispatch:null,action:e,pending:null},i.queue=c,a=iv.bind(null,we,c,u,a),c.dispatch=a,i.memoizedState=e,[t,a,!1]}function Im(e){var t=gt();return Jm(t,Ke,e)}function Jm(e,t,a){if(t=Oc(e,t,Km)[0],e=cr(Qn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=zl(t)}catch(v){throw v===Bs?Wi:v}else i=t;t=gt();var c=t.queue,u=c.dispatch;return a!==t.memoizedState&&(we.flags|=2048,Hs(9,{destroy:void 0},rv.bind(null,c,a),null)),[i,u,e]}function rv(e,t){e.action=t}function Pm(e){var t=gt(),a=Ke;if(a!==null)return Jm(t,a,e);gt(),t=t.memoizedState,a=gt();var i=a.queue.dispatch;return a.memoizedState=e,[t,i,!1]}function Hs(e,t,a,i){return e={tag:e,create:a,deps:i,inst:t,next:null},t=we.updateQueue,t===null&&(t=rr(),we.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(i=a.next,a.next=e,e.next=i,t.lastEffect=e),e}function Wm(){return gt().memoizedState}function ur(e,t,a,i){var c=Lt();we.flags|=e,c.memoizedState=Hs(1|t,{destroy:void 0},a,i===void 0?null:i)}function dr(e,t,a,i){var c=gt();i=i===void 0?null:i;var u=c.memoizedState.inst;Ke!==null&&i!==null&&Rc(i,Ke.memoizedState.deps)?c.memoizedState=Hs(t,u,a,i):(we.flags|=e,c.memoizedState=Hs(1|t,u,a,i))}function eh(e,t){ur(8390656,8,e,t)}function Hc(e,t){dr(2048,8,e,t)}function ov(e){we.flags|=4;var t=we.updateQueue;if(t===null)t=rr(),we.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function th(e){var t=gt().memoizedState;return ov({ref:t,nextImpl:e}),function(){if(($e&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function nh(e,t){return dr(4,2,e,t)}function ah(e,t){return dr(4,4,e,t)}function sh(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 lh(e,t,a){a=a!=null?a.concat([e]):null,dr(4,4,sh.bind(null,t,e),a)}function Vc(){}function ih(e,t){var a=gt();t=t===void 0?null:t;var i=a.memoizedState;return t!==null&&Rc(t,i[1])?i[0]:(a.memoizedState=[e,t],e)}function rh(e,t){var a=gt();t=t===void 0?null:t;var i=a.memoizedState;if(t!==null&&Rc(t,i[1]))return i[0];if(i=e(),es){Ft(!0);try{e()}finally{Ft(!1)}}return a.memoizedState=[i,t],i}function $c(e,t,a){return a===void 0||(Xn&1073741824)!==0&&(Te&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=o0(),we.lanes|=e,wa|=e,a)}function oh(e,t,a,i){return Xt(a,t)?a:Ls.current!==null?(e=$c(e,a,i),Xt(e,t)||(St=!0),e):(Xn&42)===0||(Xn&1073741824)!==0&&(Te&261930)===0?(St=!0,e.memoizedState=a):(e=o0(),we.lanes|=e,wa|=e,t)}function ch(e,t,a,i,c){var u=L.p;L.p=u!==0&&8>u?u:8;var v=q.T,w={};q.T=w,Fc(e,!1,t,a);try{var _=c(),F=q.S;if(F!==null&&F(w,_),_!==null&&typeof _=="object"&&typeof _.then=="function"){var P=av(_,i);Ul(e,t,P,Pt(e))}else Ul(e,t,i,Pt(e))}catch(ne){Ul(e,t,{then:function(){},status:"rejected",reason:ne},Pt())}finally{L.p=u,v!==null&&w.types!==null&&(v.types=w.types),q.T=v}}function cv(){}function Gc(e,t,a,i){if(e.tag!==5)throw Error(o(476));var c=uh(e).queue;ch(e,c,t,Z,a===null?cv:function(){return dh(e),a(i)})}function uh(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:Z},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function dh(e){var t=uh(e);t.next===null&&(t=e.alternate.memoizedState),Ul(e,t.next.queue,{},Pt())}function Yc(){return Tt(ni)}function fh(){return gt().memoizedState}function mh(){return gt().memoizedState}function uv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=Pt();e=va(a);var i=ya(t,e,a);i!==null&&(Gt(i,t,a),_l(i,t,a)),t={cache:vc()},e.payload=t;return}t=t.return}}function dv(e,t,a){var i=Pt();a={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},fr(e)?ph(t,a):(a=oc(e,t,a,i),a!==null&&(Gt(a,e,i),xh(a,t,i)))}function hh(e,t,a){var i=Pt();Ul(e,t,a,i)}function Ul(e,t,a,i){var c={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(fr(e))ph(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,w=u(v,a);if(c.hasEagerState=!0,c.eagerState=w,Xt(w,v))return Xi(e,t,c,0),We===null&&Fi(),!1}catch{}finally{}if(a=oc(e,t,c,i),a!==null)return Gt(a,e,i),xh(a,t,i),!0}return!1}function Fc(e,t,a,i){if(i={lane:2,revertLane:Nu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},fr(e)){if(t)throw Error(o(479))}else t=oc(e,a,i,2),t!==null&&Gt(t,e,2)}function fr(e){var t=e.alternate;return e===we||t!==null&&t===we}function ph(e,t){zs=lr=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function xh(e,t,a){if((a&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,nn(e,a)}}var Hl={readContext:Tt,use:or,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useLayoutEffect:dt,useInsertionEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useSyncExternalStore:dt,useId:dt,useHostTransitionStatus:dt,useFormState:dt,useActionState:dt,useOptimistic:dt,useMemoCache:dt,useCacheRefresh:dt};Hl.useEffectEvent=dt;var gh={readContext:Tt,use:or,useCallback:function(e,t){return Lt().memoizedState=[e,t===void 0?null:t],e},useContext:Tt,useEffect:eh,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,ur(4194308,4,sh.bind(null,t,e),a)},useLayoutEffect:function(e,t){return ur(4194308,4,e,t)},useInsertionEffect:function(e,t){ur(4,2,e,t)},useMemo:function(e,t){var a=Lt();t=t===void 0?null:t;var i=e();if(es){Ft(!0);try{e()}finally{Ft(!1)}}return a.memoizedState=[i,t],i},useReducer:function(e,t,a){var i=Lt();if(a!==void 0){var c=a(t);if(es){Ft(!0);try{a(t)}finally{Ft(!1)}}}else c=t;return i.memoizedState=i.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},i.queue=e,e=e.dispatch=dv.bind(null,we,e),[i.memoizedState,e]},useRef:function(e){var t=Lt();return e={current:e},t.memoizedState=e},useState:function(e){e=zc(e);var t=e.queue,a=hh.bind(null,we,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Vc,useDeferredValue:function(e,t){var a=Lt();return $c(a,e,t)},useTransition:function(){var e=zc(!1);return e=ch.bind(null,we,e.queue,!0,!1),Lt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var i=we,c=Lt();if(Be){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),We===null)throw Error(o(349));(Te&127)!==0||zm(i,t,a)}c.memoizedState=a;var u={value:a,getSnapshot:t};return c.queue=u,eh(Hm.bind(null,i,u,e),[e]),i.flags|=2048,Hs(9,{destroy:void 0},Um.bind(null,i,u,a,t),null),a},useId:function(){var e=Lt(),t=We.identifierPrefix;if(Be){var a=En,i=Cn;a=(i&~(1<<32-Rt(i)-1)).toString(32)+a,t="_"+t+"R_"+a,a=ir++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=sv++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Yc,useFormState:Zm,useActionState:Zm,useOptimistic:function(e){var t=Lt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Fc.bind(null,we,!0,a),a.dispatch=t,[e,t]},useMemoCache:Bc,useCacheRefresh:function(){return Lt().memoizedState=uv.bind(null,we)},useEffectEvent:function(e){var t=Lt(),a={impl:e};return t.memoizedState=a,function(){if(($e&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Xc={readContext:Tt,use:or,useCallback:ih,useContext:Tt,useEffect:Hc,useImperativeHandle:lh,useInsertionEffect:nh,useLayoutEffect:ah,useMemo:rh,useReducer:cr,useRef:Wm,useState:function(){return cr(Qn)},useDebugValue:Vc,useDeferredValue:function(e,t){var a=gt();return oh(a,Ke.memoizedState,e,t)},useTransition:function(){var e=cr(Qn)[0],t=gt().memoizedState;return[typeof e=="boolean"?e:zl(e),t]},useSyncExternalStore:Lm,useId:fh,useHostTransitionStatus:Yc,useFormState:Im,useActionState:Im,useOptimistic:function(e,t){var a=gt();return Gm(a,Ke,e,t)},useMemoCache:Bc,useCacheRefresh:mh};Xc.useEffectEvent=th;var bh={readContext:Tt,use:or,useCallback:ih,useContext:Tt,useEffect:Hc,useImperativeHandle:lh,useInsertionEffect:nh,useLayoutEffect:ah,useMemo:rh,useReducer:Lc,useRef:Wm,useState:function(){return Lc(Qn)},useDebugValue:Vc,useDeferredValue:function(e,t){var a=gt();return Ke===null?$c(a,e,t):oh(a,Ke.memoizedState,e,t)},useTransition:function(){var e=Lc(Qn)[0],t=gt().memoizedState;return[typeof e=="boolean"?e:zl(e),t]},useSyncExternalStore:Lm,useId:fh,useHostTransitionStatus:Yc,useFormState:Pm,useActionState:Pm,useOptimistic:function(e,t){var a=gt();return Ke!==null?Gm(a,Ke,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Bc,useCacheRefresh:mh};bh.useEffectEvent=th;function Qc(e,t,a,i){t=e.memoizedState,a=a(i,t),a=a==null?t:y({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Kc={enqueueSetState:function(e,t,a){e=e._reactInternals;var i=Pt(),c=va(i);c.payload=t,a!=null&&(c.callback=a),t=ya(e,c,i),t!==null&&(Gt(t,e,i),_l(t,e,i))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var i=Pt(),c=va(i);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=ya(e,c,i),t!==null&&(Gt(t,e,i),_l(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=Pt(),i=va(a);i.tag=2,t!=null&&(i.callback=t),t=ya(e,i,a),t!==null&&(Gt(t,e,a),_l(t,e,a))}};function vh(e,t,a,i,c,u,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,u,v):t.prototype&&t.prototype.isPureReactComponent?!Cl(a,i)||!Cl(c,u):!0}function yh(e,t,a,i){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,i),t.state!==e&&Kc.enqueueReplaceState(t,t.state,null)}function ts(e,t){var a=t;if("ref"in t){a={};for(var i in t)i!=="ref"&&(a[i]=t[i])}if(e=e.defaultProps){a===t&&(a=y({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function Sh(e){Yi(e)}function jh(e){console.error(e)}function Nh(e){Yi(e)}function mr(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function Ah(e,t,a){try{var i=e.onCaughtError;i(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Zc(e,t,a){return a=va(a),a.tag=3,a.payload={element:null},a.callback=function(){mr(e,t)},a}function wh(e){return e=va(e),e.tag=3,e}function Ch(e,t,a,i){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var u=i.value;e.payload=function(){return c(u)},e.callback=function(){Ah(t,a,i)}}var v=a.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){Ah(t,a,i),typeof c!="function"&&(Ca===null?Ca=new Set([this]):Ca.add(this));var w=i.stack;this.componentDidCatch(i.value,{componentStack:w!==null?w:""})})}function fv(e,t,a,i,c){if(a.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=a.alternate,t!==null&&Ts(t,a,c,!0),a=Kt.current,a!==null){switch(a.tag){case 31:case 13:return dn===null?wr():a.alternate===null&&ft===0&&(ft=3),a.flags&=-257,a.flags|=65536,a.lanes=c,i===er?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([i]):t.add(i),yu(e,i,c)),!1;case 22:return a.flags|=65536,i===er?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([i]):a.add(i)),yu(e,i,c)),!1}throw Error(o(435,a.tag))}return yu(e,i,c),wr(),!1}if(Be)return t=Kt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,i!==hc&&(e=Error(o(422),{cause:i}),Ml(rn(e,a)))):(i!==hc&&(t=Error(o(423),{cause:i}),Ml(rn(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,i=rn(i,a),c=Zc(e.stateNode,i,c),wc(e,c),ft!==4&&(ft=2)),!1;var u=Error(o(520),{cause:i});if(u=rn(u,a),Kl===null?Kl=[u]:Kl.push(u),ft!==4&&(ft=2),t===null)return!0;i=rn(i,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=Zc(a.stateNode,i,e),wc(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"&&(Ca===null||!Ca.has(u))))return a.flags|=65536,c&=-c,a.lanes|=c,c=wh(c),Ch(c,e,a,i),wc(a,c),!1}a=a.return}while(a!==null);return!1}var Ic=Error(o(461)),St=!1;function Dt(e,t,a,i){t.child=e===null?Rm(t,null,a,i):Wa(t,e.child,a,i)}function Eh(e,t,a,i,c){a=a.render;var u=t.ref;if("ref"in i){var v={};for(var w in i)w!=="ref"&&(v[w]=i[w])}else v=i;return Za(t),i=qc(e,t,a,v,u,c),w=Tc(),e!==null&&!St?(Dc(e,t,c),Kn(e,t,c)):(Be&&w&&fc(t),t.flags|=1,Dt(e,t,i,c),t.child)}function kh(e,t,a,i,c){if(e===null){var u=a.type;return typeof u=="function"&&!cc(u)&&u.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=u,Mh(e,t,u,i,c)):(e=Ki(a.type,null,i,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!su(e,c)){var v=u.memoizedProps;if(a=a.compare,a=a!==null?a:Cl,a(v,i)&&e.ref===t.ref)return Kn(e,t,c)}return t.flags|=1,e=$n(u,i),e.ref=t.ref,e.return=t,t.child=e}function Mh(e,t,a,i,c){if(e!==null){var u=e.memoizedProps;if(Cl(u,i)&&e.ref===t.ref)if(St=!1,t.pendingProps=i=u,su(e,c))(e.flags&131072)!==0&&(St=!0);else return t.lanes=e.lanes,Kn(e,t,c)}return Jc(e,t,a,i,c)}function Rh(e,t,a,i){var c=i.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|a:a,e!==null){for(i=t.child=e.child,c=0;i!==null;)c=c|i.lanes|i.childLanes,i=i.sibling;i=c&~u}else i=0,t.child=null;return qh(e,t,u,a,i)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Pi(t,u!==null?u.cachePool:null),u!==null?Dm(t,u):Ec(),_m(t);else return i=t.lanes=536870912,qh(e,t,u!==null?u.baseLanes|a:a,a,i)}else u!==null?(Pi(t,u.cachePool),Dm(t,u),ja(),t.memoizedState=null):(e!==null&&Pi(t,null),Ec(),ja());return Dt(e,t,c,a),t.child}function Vl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function qh(e,t,a,i,c){var u=Sc();return u=u===null?null:{parent:vt._currentValue,pool:u},t.memoizedState={baseLanes:a,cachePool:u},e!==null&&Pi(t,null),Ec(),_m(t),e!==null&&Ts(e,t,i,!0),t.childLanes=c,null}function hr(e,t){return t=xr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Th(e,t,a){return Wa(t,e.child,null,a),e=hr(t,t.pendingProps),e.flags|=2,Zt(t),t.memoizedState=null,e}function mv(e,t,a){var i=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Be){if(i.mode==="hidden")return e=hr(t,i),t.lanes=536870912,Vl(null,e);if(Mc(t),(e=tt)?(e=Y0(e,un),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ha!==null?{id:Cn,overflow:En}:null,retryLane:536870912,hydrationErrors:null},a=pm(e),a.return=t,t.child=a,qt=t,tt=null)):e=null,e===null)throw xa(t);return t.lanes=536870912,null}return hr(t,i)}var u=e.memoizedState;if(u!==null){var v=u.dehydrated;if(Mc(t),c)if(t.flags&256)t.flags&=-257,t=Th(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(St||Ts(e,t,a,!1),c=(a&e.childLanes)!==0,St||c){if(i=We,i!==null&&(v=ye(i,a),v!==0&&v!==u.retryLane))throw u.retryLane=v,Fa(e,v),Gt(i,e,v),Ic;wr(),t=Th(e,t,a)}else e=u.treeContext,tt=fn(v.nextSibling),qt=t,Be=!0,pa=null,un=!1,e!==null&&bm(t,e),t=hr(t,i),t.flags|=4096;return t}return e=$n(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pr(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 Jc(e,t,a,i,c){return Za(t),a=qc(e,t,a,i,void 0,c),i=Tc(),e!==null&&!St?(Dc(e,t,c),Kn(e,t,c)):(Be&&i&&fc(t),t.flags|=1,Dt(e,t,a,c),t.child)}function Dh(e,t,a,i,c,u){return Za(t),t.updateQueue=null,a=Om(t,i,a,c),Bm(e),i=Tc(),e!==null&&!St?(Dc(e,t,u),Kn(e,t,u)):(Be&&i&&fc(t),t.flags|=1,Dt(e,t,a,u),t.child)}function _h(e,t,a,i,c){if(Za(t),t.stateNode===null){var u=ks,v=a.contextType;typeof v=="object"&&v!==null&&(u=Tt(v)),u=new a(i,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Kc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=i,u.state=t.memoizedState,u.refs={},Nc(t),v=a.contextType,u.context=typeof v=="object"&&v!==null?Tt(v):ks,u.state=t.memoizedState,v=a.getDerivedStateFromProps,typeof v=="function"&&(Qc(t,a,v,i),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&&Kc.enqueueReplaceState(u,u.state,null),Ol(t,i,u,c),Bl(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(e===null){u=t.stateNode;var w=t.memoizedProps,_=ts(a,w);u.props=_;var F=u.context,P=a.contextType;v=ks,typeof P=="object"&&P!==null&&(v=Tt(P));var ne=a.getDerivedStateFromProps;P=typeof ne=="function"||typeof u.getSnapshotBeforeUpdate=="function",w=t.pendingProps!==w,P||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(w||F!==v)&&yh(t,u,i,v),ba=!1;var Q=t.memoizedState;u.state=Q,Ol(t,i,u,c),Bl(),F=t.memoizedState,w||Q!==F||ba?(typeof ne=="function"&&(Qc(t,a,ne,i),F=t.memoizedState),(_=ba||vh(t,a,_,i,Q,F,v))?(P||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=i,t.memoizedState=F),u.props=i,u.state=F,u.context=v,i=_):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),i=!1)}else{u=t.stateNode,Ac(e,t),v=t.memoizedProps,P=ts(a,v),u.props=P,ne=t.pendingProps,Q=u.context,F=a.contextType,_=ks,typeof F=="object"&&F!==null&&(_=Tt(F)),w=a.getDerivedStateFromProps,(F=typeof w=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(v!==ne||Q!==_)&&yh(t,u,i,_),ba=!1,Q=t.memoizedState,u.state=Q,Ol(t,i,u,c),Bl();var I=t.memoizedState;v!==ne||Q!==I||ba||e!==null&&e.dependencies!==null&&Ii(e.dependencies)?(typeof w=="function"&&(Qc(t,a,w,i),I=t.memoizedState),(P=ba||vh(t,a,P,i,Q,I,_)||e!==null&&e.dependencies!==null&&Ii(e.dependencies))?(F||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(i,I,_),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(i,I,_)),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=i,t.memoizedState=I),u.props=i,u.state=I,u.context=_,i=P):(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),i=!1)}return u=i,pr(e,t),i=(t.flags&128)!==0,u||i?(u=t.stateNode,a=i&&typeof a.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&i?(t.child=Wa(t,e.child,null,c),t.child=Wa(t,null,a,c)):Dt(e,t,a,c),t.memoizedState=u.state,e=t.child):e=Kn(e,t,c),e}function Bh(e,t,a,i){return Qa(),t.flags|=256,Dt(e,t,a,i),t.child}var Pc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Wc(e){return{baseLanes:e,cachePool:Am()}}function eu(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=Jt),e}function Oh(e,t,a){var i=t.pendingProps,c=!1,u=(t.flags&128)!==0,v;if((v=u)||(v=e!==null&&e.memoizedState===null?!1:(xt.current&2)!==0),v&&(c=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,e===null){if(Be){if(c?Sa(t):ja(),(e=tt)?(e=Y0(e,un),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ha!==null?{id:Cn,overflow:En}:null,retryLane:536870912,hydrationErrors:null},a=pm(e),a.return=t,t.child=a,qt=t,tt=null)):e=null,e===null)throw xa(t);return Ou(e)?t.lanes=32:t.lanes=536870912,null}var w=i.children;return i=i.fallback,c?(ja(),c=t.mode,w=xr({mode:"hidden",children:w},c),i=Xa(i,c,a,null),w.return=t,i.return=t,w.sibling=i,t.child=w,i=t.child,i.memoizedState=Wc(a),i.childLanes=eu(e,v,a),t.memoizedState=Pc,Vl(null,i)):(Sa(t),tu(t,w))}var _=e.memoizedState;if(_!==null&&(w=_.dehydrated,w!==null)){if(u)t.flags&256?(Sa(t),t.flags&=-257,t=nu(e,t,a)):t.memoizedState!==null?(ja(),t.child=e.child,t.flags|=128,t=null):(ja(),w=i.fallback,c=t.mode,i=xr({mode:"visible",children:i.children},c),w=Xa(w,c,a,null),w.flags|=2,i.return=t,w.return=t,i.sibling=w,t.child=i,Wa(t,e.child,null,a),i=t.child,i.memoizedState=Wc(a),i.childLanes=eu(e,v,a),t.memoizedState=Pc,t=Vl(null,i));else if(Sa(t),Ou(w)){if(v=w.nextSibling&&w.nextSibling.dataset,v)var F=v.dgst;v=F,i=Error(o(419)),i.stack="",i.digest=v,Ml({value:i,source:null,stack:null}),t=nu(e,t,a)}else if(St||Ts(e,t,a,!1),v=(a&e.childLanes)!==0,St||v){if(v=We,v!==null&&(i=ye(v,a),i!==0&&i!==_.retryLane))throw _.retryLane=i,Fa(e,i),Gt(v,e,i),Ic;Bu(w)||wr(),t=nu(e,t,a)}else Bu(w)?(t.flags|=192,t.child=e.child,t=null):(e=_.treeContext,tt=fn(w.nextSibling),qt=t,Be=!0,pa=null,un=!1,e!==null&&bm(t,e),t=tu(t,i.children),t.flags|=4096);return t}return c?(ja(),w=i.fallback,c=t.mode,_=e.child,F=_.sibling,i=$n(_,{mode:"hidden",children:i.children}),i.subtreeFlags=_.subtreeFlags&65011712,F!==null?w=$n(F,w):(w=Xa(w,c,a,null),w.flags|=2),w.return=t,i.return=t,i.sibling=w,t.child=i,Vl(null,i),i=t.child,w=e.child.memoizedState,w===null?w=Wc(a):(c=w.cachePool,c!==null?(_=vt._currentValue,c=c.parent!==_?{parent:_,pool:_}:c):c=Am(),w={baseLanes:w.baseLanes|a,cachePool:c}),i.memoizedState=w,i.childLanes=eu(e,v,a),t.memoizedState=Pc,Vl(e.child,i)):(Sa(t),a=e.child,e=a.sibling,a=$n(a,{mode:"visible",children:i.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 tu(e,t){return t=xr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function xr(e,t){return e=Qt(22,e,null,t),e.lanes=0,e}function nu(e,t,a){return Wa(t,e.child,null,a),e=tu(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Lh(e,t,a){e.lanes|=t;var i=e.alternate;i!==null&&(i.lanes|=t),gc(e.return,t,a)}function au(e,t,a,i,c,u){var v=e.memoizedState;v===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:a,tailMode:c,treeForkCount:u}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=i,v.tail=a,v.tailMode=c,v.treeForkCount=u)}function zh(e,t,a){var i=t.pendingProps,c=i.revealOrder,u=i.tail;i=i.children;var v=xt.current,w=(v&2)!==0;if(w?(v=v&1|2,t.flags|=128):v&=1,te(xt,v),Dt(e,t,i,a),i=Be?kl:0,!w&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Lh(e,a,t);else if(e.tag===19)Lh(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&&sr(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),au(t,!1,c,a,u,i);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&sr(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}au(t,!0,a,null,u,i);break;case"together":au(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Kn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),wa|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ts(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=$n(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=$n(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function su(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Ii(e)))}function hv(e,t,a){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),ga(t,vt,e.memoizedState.cache),Qa();break;case 27:case 5:pe(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:ga(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Mc(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(Sa(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Oh(e,t,a):(Sa(t),e=Kn(e,t,a),e!==null?e.sibling:null);Sa(t);break;case 19:var c=(e.flags&128)!==0;if(i=(a&t.childLanes)!==0,i||(Ts(e,t,a,!1),i=(a&t.childLanes)!==0),c){if(i)return zh(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),te(xt,xt.current),i)break;return null;case 22:return t.lanes=0,Rh(e,t,a,t.pendingProps);case 24:ga(t,vt,e.memoizedState.cache)}return Kn(e,t,a)}function Uh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)St=!0;else{if(!su(e,a)&&(t.flags&128)===0)return St=!1,hv(e,t,a);St=(e.flags&131072)!==0}else St=!1,Be&&(t.flags&1048576)!==0&&gm(t,kl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=Ja(t.elementType),t.type=e,typeof e=="function")cc(e)?(i=ts(e,i),t.tag=1,t=_h(null,t,e,i,a)):(t.tag=0,t=Jc(null,t,e,i,a));else{if(e!=null){var c=e.$$typeof;if(c===k){t.tag=11,t=Eh(null,t,e,i,a);break e}else if(c===D){t.tag=14,t=kh(null,t,e,i,a);break e}}throw t=ce(e)||e,Error(o(306,t,""))}}return t;case 0:return Jc(e,t,t.type,t.pendingProps,a);case 1:return i=t.type,c=ts(i,t.pendingProps),_h(e,t,i,c,a);case 3:e:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(o(387));i=t.pendingProps;var u=t.memoizedState;c=u.element,Ac(e,t),Ol(t,i,null,a);var v=t.memoizedState;if(i=v.cache,ga(t,vt,i),i!==u.cache&&bc(t,[vt],a,!0),Bl(),i=v.element,u.isDehydrated)if(u={element:i,isDehydrated:!1,cache:v.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=Bh(e,t,i,a);break e}else if(i!==c){c=rn(Error(o(424)),t),Ml(c),t=Bh(e,t,i,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(tt=fn(e.firstChild),qt=t,Be=!0,pa=null,un=!0,a=Rm(t,null,i,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Qa(),i===c){t=Kn(e,t,a);break e}Dt(e,t,i,a)}t=t.child}return t;case 26:return pr(e,t),e===null?(a=I0(t.type,null,t.pendingProps,null))?t.memoizedState=a:Be||(a=t.type,e=t.pendingProps,i=Tr(re.current).createElement(a),i[it]=t,i[wt]=e,_t(i,a,e),Et(i),t.stateNode=i):t.memoizedState=I0(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return pe(t),e===null&&Be&&(i=t.stateNode=Q0(t.type,t.pendingProps,re.current),qt=t,un=!0,c=tt,Ra(t.type)?(Lu=c,tt=fn(i.firstChild)):tt=c),Dt(e,t,t.pendingProps.children,a),pr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Be&&((c=i=tt)&&(i=Yv(i,t.type,t.pendingProps,un),i!==null?(t.stateNode=i,qt=t,tt=fn(i.firstChild),un=!1,c=!0):c=!1),c||xa(t)),pe(t),c=t.type,u=t.pendingProps,v=e!==null?e.memoizedProps:null,i=u.children,Tu(c,u)?i=null:v!==null&&Tu(c,v)&&(t.flags|=32),t.memoizedState!==null&&(c=qc(e,t,lv,null,null,a),ni._currentValue=c),pr(e,t),Dt(e,t,i,a),t.child;case 6:return e===null&&Be&&((e=a=tt)&&(a=Fv(a,t.pendingProps,un),a!==null?(t.stateNode=a,qt=t,tt=null,e=!0):e=!1),e||xa(t)),null;case 13:return Oh(e,t,a);case 4:return ve(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Wa(t,null,i,a):Dt(e,t,i,a),t.child;case 11:return Eh(e,t,t.type,t.pendingProps,a);case 7:return Dt(e,t,t.pendingProps,a),t.child;case 8:return Dt(e,t,t.pendingProps.children,a),t.child;case 12:return Dt(e,t,t.pendingProps.children,a),t.child;case 10:return i=t.pendingProps,ga(t,t.type,i.value),Dt(e,t,i.children,a),t.child;case 9:return c=t.type._context,i=t.pendingProps.children,Za(t),c=Tt(c),i=i(c),t.flags|=1,Dt(e,t,i,a),t.child;case 14:return kh(e,t,t.type,t.pendingProps,a);case 15:return Mh(e,t,t.type,t.pendingProps,a);case 19:return zh(e,t,a);case 31:return mv(e,t,a);case 22:return Rh(e,t,a,t.pendingProps);case 24:return Za(t),i=Tt(vt),e===null?(c=Sc(),c===null&&(c=We,u=vc(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=a),c=u),t.memoizedState={parent:i,cache:c},Nc(t),ga(t,vt,c)):((e.lanes&a)!==0&&(Ac(e,t),Ol(t,null,null,a),Bl()),c=e.memoizedState,u=t.memoizedState,c.parent!==i?(c={parent:i,cache:i},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),ga(t,vt,i)):(i=u.cache,ga(t,vt,i),i!==c.cache&&bc(t,[vt],a,!0))),Dt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Zn(e){e.flags|=4}function lu(e,t,a,i,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(f0())e.flags|=8192;else throw Pa=er,jc}else e.flags&=-16777217}function Hh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!tp(t))if(f0())e.flags|=8192;else throw Pa=er,jc}function gr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?hl():536870912,e.lanes|=t,Ys|=t)}function $l(e,t){if(!Be)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 i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function nt(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,i=0;if(t)for(var c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags&65011712,i|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags,i|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=i,e.childLanes=a,t}function pv(e,t,a){var i=t.pendingProps;switch(mc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nt(t),null;case 1:return nt(t),null;case 3:return a=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Fn(vt),fe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(qs(t)?Zn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,pc())),nt(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Zn(t),u!==null?(nt(t),Hh(t,u)):(nt(t),lu(t,c,null,i,a))):u?u!==e.memoizedState?(Zn(t),nt(t),Hh(t,u)):(nt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==i&&Zn(t),nt(t),lu(t,c,e,i,a)),null;case 27:if(Le(t),a=re.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Zn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return nt(t),null}e=ae.current,qs(t)?vm(t):(e=Q0(c,i,a),t.stateNode=e,Zn(t))}return nt(t),null;case 5:if(Le(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Zn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return nt(t),null}if(u=ae.current,qs(t))vm(t);else{var v=Tr(re.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 i.is=="string"?v.createElement("select",{is:i.is}):v.createElement("select"),i.multiple?u.multiple=!0:i.size&&(u.size=i.size);break;default:u=typeof i.is=="string"?v.createElement(c,{is:i.is}):v.createElement(c)}}u[it]=t,u[wt]=i;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(_t(u,c,i),c){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Zn(t)}}return nt(t),lu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&Zn(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(o(166));if(e=re.current,qs(t)){if(e=t.stateNode,a=t.memoizedProps,i=null,c=qt,c!==null)switch(c.tag){case 27:case 5:i=c.memoizedProps}e[it]=t,e=!!(e.nodeValue===a||i!==null&&i.suppressHydrationWarning===!0||O0(e.nodeValue,a)),e||xa(t,!0)}else e=Tr(e).createTextNode(i),e[it]=t,t.stateNode=e}return nt(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(i=qs(t),a!==null){if(e===null){if(!i)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[it]=t}else Qa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;nt(t),e=!1}else a=pc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Zt(t),t):(Zt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return nt(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=qs(t),i!==null&&i.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[it]=t}else Qa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;nt(t),c=!1}else c=pc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Zt(t),t):(Zt(t),null)}return Zt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=i!==null,e=e!==null&&e.memoizedState!==null,a&&(i=t.child,c=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(c=i.alternate.memoizedState.cachePool.pool),u=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),u!==c&&(i.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),gr(t,t.updateQueue),nt(t),null);case 4:return fe(),e===null&&Eu(t.stateNode.containerInfo),nt(t),null;case 10:return Fn(t.type),nt(t),null;case 19:if(V(xt),i=t.memoizedState,i===null)return nt(t),null;if(c=(t.flags&128)!==0,u=i.rendering,u===null)if(c)$l(i,!1);else{if(ft!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=sr(e),u!==null){for(t.flags|=128,$l(i,!1),e=u.updateQueue,t.updateQueue=e,gr(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)hm(a,e),a=a.sibling;return te(xt,xt.current&1|2),Be&&Gn(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Ue()>jr&&(t.flags|=128,c=!0,$l(i,!1),t.lanes=4194304)}else{if(!c)if(e=sr(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,gr(t,e),$l(i,!0),i.tail===null&&i.tailMode==="hidden"&&!u.alternate&&!Be)return nt(t),null}else 2*Ue()-i.renderingStartTime>jr&&a!==536870912&&(t.flags|=128,c=!0,$l(i,!1),t.lanes=4194304);i.isBackwards?(u.sibling=t.child,t.child=u):(e=i.last,e!==null?e.sibling=u:t.child=u,i.last=u)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Ue(),e.sibling=null,a=xt.current,te(xt,c?a&1|2:a&1),Be&&Gn(t,i.treeForkCount),e):(nt(t),null);case 22:case 23:return Zt(t),kc(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(a&536870912)!==0&&(t.flags&128)===0&&(nt(t),t.subtreeFlags&6&&(t.flags|=8192)):nt(t),a=t.updateQueue,a!==null&&gr(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==a&&(t.flags|=2048),e!==null&&V(Ia),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Fn(vt),nt(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function xv(e,t){switch(mc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fn(vt),fe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Le(t),null;case 31:if(t.memoizedState!==null){if(Zt(t),t.alternate===null)throw Error(o(340));Qa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Zt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Qa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(xt),null;case 4:return fe(),null;case 10:return Fn(t.type),null;case 22:case 23:return Zt(t),kc(),e!==null&&V(Ia),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Fn(vt),null;case 25:return null;default:return null}}function Vh(e,t){switch(mc(t),t.tag){case 3:Fn(vt),fe();break;case 26:case 27:case 5:Le(t);break;case 4:fe();break;case 31:t.memoizedState!==null&&Zt(t);break;case 13:Zt(t);break;case 19:V(xt);break;case 10:Fn(t.type);break;case 22:case 23:Zt(t),kc(),e!==null&&V(Ia);break;case 24:Fn(vt)}}function Gl(e,t){try{var a=t.updateQueue,i=a!==null?a.lastEffect:null;if(i!==null){var c=i.next;a=c;do{if((a.tag&e)===e){i=void 0;var u=a.create,v=a.inst;i=u(),v.destroy=i}a=a.next}while(a!==c)}}catch(w){Xe(t,t.return,w)}}function Na(e,t,a){try{var i=t.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var u=c.next;i=u;do{if((i.tag&e)===e){var v=i.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,c=t;var _=a,F=w;try{F()}catch(P){Xe(c,_,P)}}}i=i.next}while(i!==u)}}catch(P){Xe(t,t.return,P)}}function $h(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{Tm(t,a)}catch(i){Xe(e,e.return,i)}}}function Gh(e,t,a){a.props=ts(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(i){Xe(e,t,i)}}function Yl(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof a=="function"?e.refCleanup=a(i):a.current=i}}catch(c){Xe(e,t,c)}}function kn(e,t){var a=e.ref,i=e.refCleanup;if(a!==null)if(typeof i=="function")try{i()}catch(c){Xe(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){Xe(e,t,c)}else a.current=null}function Yh(e){var t=e.type,a=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&i.focus();break e;case"img":a.src?i.src=a.src:a.srcSet&&(i.srcset=a.srcSet)}}catch(c){Xe(e,e.return,c)}}function iu(e,t,a){try{var i=e.stateNode;zv(i,e.type,a,t),i[wt]=t}catch(c){Xe(e,e.return,c)}}function Fh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ra(e.type)||e.tag===4}function ru(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Fh(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&&Ra(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 ou(e,t,a){var i=e.tag;if(i===5||i===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=Hn));else if(i!==4&&(i===27&&Ra(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(ou(e,t,a),e=e.sibling;e!==null;)ou(e,t,a),e=e.sibling}function br(e,t,a){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(i!==4&&(i===27&&Ra(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(br(e,t,a),e=e.sibling;e!==null;)br(e,t,a),e=e.sibling}function Xh(e){var t=e.stateNode,a=e.memoizedProps;try{for(var i=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);_t(t,i,a),t[it]=e,t[wt]=a}catch(u){Xe(e,e.return,u)}}var In=!1,jt=!1,cu=!1,Qh=typeof WeakSet=="function"?WeakSet:Set,kt=null;function gv(e,t){if(e=e.containerInfo,Ru=Ur,e=lm(e),nc(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var i=a.getSelection&&a.getSelection();if(i&&i.rangeCount!==0){a=i.anchorNode;var c=i.anchorOffset,u=i.focusNode;i=i.focusOffset;try{a.nodeType,u.nodeType}catch{a=null;break e}var v=0,w=-1,_=-1,F=0,P=0,ne=e,Q=null;t:for(;;){for(var I;ne!==a||c!==0&&ne.nodeType!==3||(w=v+c),ne!==u||i!==0&&ne.nodeType!==3||(_=v+i),ne.nodeType===3&&(v+=ne.nodeValue.length),(I=ne.firstChild)!==null;)Q=ne,ne=I;for(;;){if(ne===e)break t;if(Q===a&&++F===c&&(w=v),Q===u&&++P===i&&(_=v),(I=ne.nextSibling)!==null)break;ne=Q,Q=ne.parentNode}ne=I}a=w===-1||_===-1?null:{start:w,end:_}}else a=null}a=a||{start:0,end:0}}else a=null;for(qu={focusedElem:e,selectionRange:a},Ur=!1,kt=t;kt!==null;)if(t=kt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,kt=e;else for(;kt!==null;){switch(t=kt,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,i=a.stateNode;try{var me=ts(a.type,c);e=i.getSnapshotBeforeUpdate(me,u),i.__reactInternalSnapshotBeforeUpdate=e}catch(je){Xe(a,a.return,je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)_u(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":_u(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,kt=e;break}kt=t.return}}function Kh(e,t,a){var i=a.flags;switch(a.tag){case 0:case 11:case 15:Pn(e,a),i&4&&Gl(5,a);break;case 1:if(Pn(e,a),i&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(v){Xe(a,a.return,v)}else{var c=ts(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(v){Xe(a,a.return,v)}}i&64&&$h(a),i&512&&Yl(a,a.return);break;case 3:if(Pn(e,a),i&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{Tm(e,t)}catch(v){Xe(a,a.return,v)}}break;case 27:t===null&&i&4&&Xh(a);case 26:case 5:Pn(e,a),t===null&&i&4&&Yh(a),i&512&&Yl(a,a.return);break;case 12:Pn(e,a);break;case 31:Pn(e,a),i&4&&Jh(e,a);break;case 13:Pn(e,a),i&4&&Ph(e,a),i&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=Cv.bind(null,a),Xv(e,a))));break;case 22:if(i=a.memoizedState!==null||In,!i){t=t!==null&&t.memoizedState!==null||jt,c=In;var u=jt;In=i,(jt=t)&&!u?Wn(e,a,(a.subtreeFlags&8772)!==0):Pn(e,a),In=c,jt=u}break;case 30:break;default:Pn(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&&Uo(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 st=null,Ut=!1;function Jn(e,t,a){for(a=a.child;a!==null;)Ih(e,t,a),a=a.sibling}function Ih(e,t,a){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(Bn,a)}catch{}switch(a.tag){case 26:jt||kn(a,t),Jn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:jt||kn(a,t);var i=st,c=Ut;Ra(a.type)&&(st=a.stateNode,Ut=!1),Jn(e,t,a),Wl(a.stateNode),st=i,Ut=c;break;case 5:jt||kn(a,t);case 6:if(i=st,c=Ut,st=null,Jn(e,t,a),st=i,Ut=c,st!==null)if(Ut)try{(st.nodeType===9?st.body:st.nodeName==="HTML"?st.ownerDocument.body:st).removeChild(a.stateNode)}catch(u){Xe(a,t,u)}else try{st.removeChild(a.stateNode)}catch(u){Xe(a,t,u)}break;case 18:st!==null&&(Ut?(e=st,$0(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Ps(e)):$0(st,a.stateNode));break;case 4:i=st,c=Ut,st=a.stateNode.containerInfo,Ut=!0,Jn(e,t,a),st=i,Ut=c;break;case 0:case 11:case 14:case 15:Na(2,a,t),jt||Na(4,a,t),Jn(e,t,a);break;case 1:jt||(kn(a,t),i=a.stateNode,typeof i.componentWillUnmount=="function"&&Gh(a,t,i)),Jn(e,t,a);break;case 21:Jn(e,t,a);break;case 22:jt=(i=jt)||a.memoizedState!==null,Jn(e,t,a),jt=i;break;default:Jn(e,t,a)}}function Jh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ps(e)}catch(a){Xe(t,t.return,a)}}}function Ph(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ps(e)}catch(a){Xe(t,t.return,a)}}function bv(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Qh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Qh),t;default:throw Error(o(435,e.tag))}}function vr(e,t){var a=bv(e);t.forEach(function(i){if(!a.has(i)){a.add(i);var c=Ev.bind(null,e,i);i.then(c,c)}})}function Ht(e,t){var a=t.deletions;if(a!==null)for(var i=0;i<a.length;i++){var c=a[i],u=e,v=t,w=v;e:for(;w!==null;){switch(w.tag){case 27:if(Ra(w.type)){st=w.stateNode,Ut=!1;break e}break;case 5:st=w.stateNode,Ut=!1;break e;case 3:case 4:st=w.stateNode.containerInfo,Ut=!0;break e}w=w.return}if(st===null)throw Error(o(160));Ih(u,v,c),st=null,Ut=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Wh(t,e),t=t.sibling}var vn=null;function Wh(e,t){var a=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ht(t,e),Vt(e),i&4&&(Na(3,e,e.return),Gl(3,e),Na(5,e,e.return));break;case 1:Ht(t,e),Vt(e),i&512&&(jt||a===null||kn(a,a.return)),i&64&&In&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?i:a.concat(i))));break;case 26:var c=vn;if(Ht(t,e),Vt(e),i&512&&(jt||a===null||kn(a,a.return)),i&4){var u=a!==null?a.memoizedState:null;if(i=e.memoizedState,a===null)if(i===null)if(e.stateNode===null){e:{i=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(i){case"title":u=c.getElementsByTagName("title")[0],(!u||u[gl]||u[it]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(i),c.head.insertBefore(u,c.querySelector("head > title"))),_t(u,i,a),u[it]=e,Et(u),i=u;break e;case"link":var v=W0("link","href",c).get(i+(a.href||""));if(v){for(var w=0;w<v.length;w++)if(u=v[w],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(w,1);break t}}u=c.createElement(i),_t(u,i,a),c.head.appendChild(u);break;case"meta":if(v=W0("meta","content",c).get(i+(a.content||""))){for(w=0;w<v.length;w++)if(u=v[w],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(w,1);break t}}u=c.createElement(i),_t(u,i,a),c.head.appendChild(u);break;default:throw Error(o(468,i))}u[it]=e,Et(u),i=u}e.stateNode=i}else ep(c,e.type,e.stateNode);else e.stateNode=P0(c,i,e.memoizedProps);else u!==i?(u===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):u.count--,i===null?ep(c,e.type,e.stateNode):P0(c,i,e.memoizedProps)):i===null&&e.stateNode!==null&&iu(e,e.memoizedProps,a.memoizedProps)}break;case 27:Ht(t,e),Vt(e),i&512&&(jt||a===null||kn(a,a.return)),a!==null&&i&4&&iu(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Ht(t,e),Vt(e),i&512&&(jt||a===null||kn(a,a.return)),e.flags&32){c=e.stateNode;try{Ss(c,"")}catch(me){Xe(e,e.return,me)}}i&4&&e.stateNode!=null&&(c=e.memoizedProps,iu(e,c,a!==null?a.memoizedProps:c)),i&1024&&(cu=!0);break;case 6:if(Ht(t,e),Vt(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,a=e.stateNode;try{a.nodeValue=i}catch(me){Xe(e,e.return,me)}}break;case 3:if(Br=null,c=vn,vn=Dr(t.containerInfo),Ht(t,e),vn=c,Vt(e),i&4&&a!==null&&a.memoizedState.isDehydrated)try{Ps(t.containerInfo)}catch(me){Xe(e,e.return,me)}cu&&(cu=!1,e0(e));break;case 4:i=vn,vn=Dr(e.stateNode.containerInfo),Ht(t,e),Vt(e),vn=i;break;case 12:Ht(t,e),Vt(e);break;case 31:Ht(t,e),Vt(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,vr(e,i)));break;case 13:Ht(t,e),Vt(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Sr=Ue()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,vr(e,i)));break;case 22:c=e.memoizedState!==null;var _=a!==null&&a.memoizedState!==null,F=In,P=jt;if(In=F||c,jt=P||_,Ht(t,e),jt=P,In=F,Vt(e),i&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||_||In||jt||ns(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){_=a=t;try{if(u=_.stateNode,c)v=u.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{w=_.stateNode;var ne=_.memoizedProps.style,Q=ne!=null&&ne.hasOwnProperty("display")?ne.display:null;w.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(me){Xe(_,_.return,me)}}}else if(t.tag===6){if(a===null){_=t;try{_.stateNode.nodeValue=c?"":_.memoizedProps}catch(me){Xe(_,_.return,me)}}}else if(t.tag===18){if(a===null){_=t;try{var I=_.stateNode;c?G0(I,!0):G0(_.stateNode,!1)}catch(me){Xe(_,_.return,me)}}}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}i&4&&(i=e.updateQueue,i!==null&&(a=i.retryQueue,a!==null&&(i.retryQueue=null,vr(e,a))));break;case 19:Ht(t,e),Vt(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,vr(e,i)));break;case 30:break;case 21:break;default:Ht(t,e),Vt(e)}}function Vt(e){var t=e.flags;if(t&2){try{for(var a,i=e.return;i!==null;){if(Fh(i)){a=i;break}i=i.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,u=ru(e);br(e,u,c);break;case 5:var v=a.stateNode;a.flags&32&&(Ss(v,""),a.flags&=-33);var w=ru(e);br(e,w,v);break;case 3:case 4:var _=a.stateNode.containerInfo,F=ru(e);ou(e,F,_);break;default:throw Error(o(161))}}catch(P){Xe(e,e.return,P)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function e0(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;e0(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Pn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Kh(e,t.alternate,t),t=t.sibling}function ns(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Na(4,t,t.return),ns(t);break;case 1:kn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Gh(t,t.return,a),ns(t);break;case 27:Wl(t.stateNode);case 26:case 5:kn(t,t.return),ns(t);break;case 22:t.memoizedState===null&&ns(t);break;case 30:ns(t);break;default:ns(t)}e=e.sibling}}function Wn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var i=t.alternate,c=e,u=t,v=u.flags;switch(u.tag){case 0:case 11:case 15:Wn(c,u,a),Gl(4,u);break;case 1:if(Wn(c,u,a),i=u,c=i.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(F){Xe(i,i.return,F)}if(i=u,c=i.updateQueue,c!==null){var w=i.stateNode;try{var _=c.shared.hiddenCallbacks;if(_!==null)for(c.shared.hiddenCallbacks=null,c=0;c<_.length;c++)qm(_[c],w)}catch(F){Xe(i,i.return,F)}}a&&v&64&&$h(u),Yl(u,u.return);break;case 27:Xh(u);case 26:case 5:Wn(c,u,a),a&&i===null&&v&4&&Yh(u),Yl(u,u.return);break;case 12:Wn(c,u,a);break;case 31:Wn(c,u,a),a&&v&4&&Jh(c,u);break;case 13:Wn(c,u,a),a&&v&4&&Ph(c,u);break;case 22:u.memoizedState===null&&Wn(c,u,a),Yl(u,u.return);break;case 30:break;default:Wn(c,u,a)}t=t.sibling}}function uu(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&&Rl(a))}function du(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Rl(e))}function yn(e,t,a,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)t0(e,t,a,i),t=t.sibling}function t0(e,t,a,i){var c=t.flags;switch(t.tag){case 0:case 11:case 15:yn(e,t,a,i),c&2048&&Gl(9,t);break;case 1:yn(e,t,a,i);break;case 3:yn(e,t,a,i),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Rl(e)));break;case 12:if(c&2048){yn(e,t,a,i),e=t.stateNode;try{var u=t.memoizedProps,v=u.id,w=u.onPostCommit;typeof w=="function"&&w(v,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(_){Xe(t,t.return,_)}}else yn(e,t,a,i);break;case 31:yn(e,t,a,i);break;case 13:yn(e,t,a,i);break;case 23:break;case 22:u=t.stateNode,v=t.alternate,t.memoizedState!==null?u._visibility&2?yn(e,t,a,i):Fl(e,t):u._visibility&2?yn(e,t,a,i):(u._visibility|=2,Vs(e,t,a,i,(t.subtreeFlags&10256)!==0||!1)),c&2048&&uu(v,t);break;case 24:yn(e,t,a,i),c&2048&&du(t.alternate,t);break;default:yn(e,t,a,i)}}function Vs(e,t,a,i,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,v=t,w=a,_=i,F=v.flags;switch(v.tag){case 0:case 11:case 15:Vs(u,v,w,_,c),Gl(8,v);break;case 23:break;case 22:var P=v.stateNode;v.memoizedState!==null?P._visibility&2?Vs(u,v,w,_,c):Fl(u,v):(P._visibility|=2,Vs(u,v,w,_,c)),c&&F&2048&&uu(v.alternate,v);break;case 24:Vs(u,v,w,_,c),c&&F&2048&&du(v.alternate,v);break;default:Vs(u,v,w,_,c)}t=t.sibling}}function Fl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,i=t,c=i.flags;switch(i.tag){case 22:Fl(a,i),c&2048&&uu(i.alternate,i);break;case 24:Fl(a,i),c&2048&&du(i.alternate,i);break;default:Fl(a,i)}t=t.sibling}}var Xl=8192;function $s(e,t,a){if(e.subtreeFlags&Xl)for(e=e.child;e!==null;)n0(e,t,a),e=e.sibling}function n0(e,t,a){switch(e.tag){case 26:$s(e,t,a),e.flags&Xl&&e.memoizedState!==null&&sy(a,vn,e.memoizedState,e.memoizedProps);break;case 5:$s(e,t,a);break;case 3:case 4:var i=vn;vn=Dr(e.stateNode.containerInfo),$s(e,t,a),vn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=Xl,Xl=16777216,$s(e,t,a),Xl=i):$s(e,t,a));break;default:$s(e,t,a)}}function a0(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 Ql(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];kt=i,l0(i,e)}a0(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)s0(e),e=e.sibling}function s0(e){switch(e.tag){case 0:case 11:case 15:Ql(e),e.flags&2048&&Na(9,e,e.return);break;case 3:Ql(e);break;case 12:Ql(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,yr(e)):Ql(e);break;default:Ql(e)}}function yr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];kt=i,l0(i,e)}a0(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Na(8,t,t.return),yr(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,yr(t));break;default:yr(t)}e=e.sibling}}function l0(e,t){for(;kt!==null;){var a=kt;switch(a.tag){case 0:case 11:case 15:Na(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var i=a.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:Rl(a.memoizedState.cache)}if(i=a.child,i!==null)i.return=a,kt=i;else e:for(a=e;kt!==null;){i=kt;var c=i.sibling,u=i.return;if(Zh(i),i===a){kt=null;break e}if(c!==null){c.return=u,kt=c;break e}kt=u}}}var vv={getCacheForType:function(e){var t=Tt(vt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return Tt(vt).controller.signal}},yv=typeof WeakMap=="function"?WeakMap:Map,$e=0,We=null,Re=null,Te=0,Fe=0,It=null,Aa=!1,Gs=!1,fu=!1,ea=0,ft=0,wa=0,as=0,mu=0,Jt=0,Ys=0,Kl=null,$t=null,hu=!1,Sr=0,i0=0,jr=1/0,Nr=null,Ca=null,Ct=0,Ea=null,Fs=null,ta=0,pu=0,xu=null,r0=null,Zl=0,gu=null;function Pt(){return($e&2)!==0&&Te!==0?Te&-Te:q.T!==null?Nu():Me()}function o0(){if(Jt===0)if((Te&536870912)===0||Be){var e=Ua;Ua<<=1,(Ua&3932160)===0&&(Ua=262144),Jt=e}else Jt=536870912;return e=Kt.current,e!==null&&(e.flags|=32),Jt}function Gt(e,t,a){(e===We&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)&&(Xs(e,0),ka(e,Te,Jt,!1)),Ha(e,a),(($e&2)===0||e!==We)&&(e===We&&(($e&2)===0&&(as|=a),ft===4&&ka(e,Te,Jt,!1)),Mn(e))}function c0(e,t,a){if(($e&6)!==0)throw Error(o(327));var i=!a&&(t&127)===0&&(t&e.expiredLanes)===0||Ln(e,t),c=i?Nv(e,t):vu(e,t,!0),u=i;do{if(c===0){Gs&&!i&&ka(e,t,0,!1);break}else{if(a=e.current.alternate,u&&!Sv(a)){c=vu(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 w=e;c=Kl;var _=w.current.memoizedState.isDehydrated;if(_&&(Xs(w,v).flags|=256),v=vu(w,v,!1),v!==2){if(fu&&!_){w.errorRecoveryDisabledLanes|=u,as|=u,c=4;break e}u=$t,$t=c,u!==null&&($t===null?$t=u:$t.push.apply($t,u))}c=v}if(u=!1,c!==2)continue}}if(c===1){Xs(e,0),ka(e,t,0,!0);break}e:{switch(i=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:ka(i,t,Jt,!Aa);break e;case 2:$t=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=Sr+300-Ue(),10<c)){if(ka(i,t,Jt,!Aa),wn(i,0,!0)!==0)break e;ta=t,i.timeoutHandle=H0(u0.bind(null,i,a,$t,Nr,hu,t,Jt,as,Ys,Aa,u,"Throttled",-0,0),c);break e}u0(i,a,$t,Nr,hu,t,Jt,as,Ys,Aa,u,null,-0,0)}}break}while(!0);Mn(e)}function u0(e,t,a,i,c,u,v,w,_,F,P,ne,Q,I){if(e.timeoutHandle=-1,ne=t.subtreeFlags,ne&8192||(ne&16785408)===16785408){ne={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Hn},n0(t,u,ne);var me=(u&62914560)===u?Sr-Ue():(u&4194048)===u?i0-Ue():0;if(me=ly(ne,me),me!==null){ta=u,e.cancelPendingCommit=me(b0.bind(null,e,t,u,a,i,c,v,w,_,P,ne,null,Q,I)),ka(e,u,v,!F);return}}b0(e,t,u,a,i,c,v,w,_)}function Sv(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 i=0;i<a.length;i++){var c=a[i],u=c.getSnapshot;c=c.value;try{if(!Xt(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 ka(e,t,a,i){t&=~mu,t&=~as,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var c=t;0<c;){var u=31-Rt(c),v=1<<u;i[u]=-1,c&=~v}a!==0&&xl(e,a,t)}function Ar(){return($e&6)===0?(Il(0),!1):!0}function bu(){if(Re!==null){if(Fe===0)var e=Re.return;else e=Re,Yn=Ka=null,_c(e),Os=null,Tl=0,e=Re;for(;e!==null;)Vh(e.alternate,e),e=e.return;Re=null}}function Xs(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Vv(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),ta=0,bu(),We=e,Re=a=$n(e.current,null),Te=t,Fe=0,It=null,Aa=!1,Gs=Ln(e,t),fu=!1,Ys=Jt=mu=as=wa=ft=0,$t=Kl=null,hu=!1,(t&8)!==0&&(t|=t&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=t;0<i;){var c=31-Rt(i),u=1<<c;t|=e[c],i&=~u}return ea=t,Fi(),a}function d0(e,t){we=null,q.H=Hl,t===Bs||t===Wi?(t=Em(),Fe=3):t===jc?(t=Em(),Fe=4):Fe=t===Ic?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,It=t,Re===null&&(ft=1,mr(e,rn(t,e.current)))}function f0(){var e=Kt.current;return e===null?!0:(Te&4194048)===Te?dn===null:(Te&62914560)===Te||(Te&536870912)!==0?e===dn:!1}function m0(){var e=q.H;return q.H=Hl,e===null?Hl:e}function h0(){var e=q.A;return q.A=vv,e}function wr(){ft=4,Aa||(Te&4194048)!==Te&&Kt.current!==null||(Gs=!0),(wa&134217727)===0&&(as&134217727)===0||We===null||ka(We,Te,Jt,!1)}function vu(e,t,a){var i=$e;$e|=2;var c=m0(),u=h0();(We!==e||Te!==t)&&(Nr=null,Xs(e,t)),t=!1;var v=ft;e:do try{if(Fe!==0&&Re!==null){var w=Re,_=It;switch(Fe){case 8:bu(),v=6;break e;case 3:case 2:case 9:case 6:Kt.current===null&&(t=!0);var F=Fe;if(Fe=0,It=null,Qs(e,w,_,F),a&&Gs){v=0;break e}break;default:F=Fe,Fe=0,It=null,Qs(e,w,_,F)}}jv(),v=ft;break}catch(P){d0(e,P)}while(!0);return t&&e.shellSuspendCounter++,Yn=Ka=null,$e=i,q.H=c,q.A=u,Re===null&&(We=null,Te=0,Fi()),v}function jv(){for(;Re!==null;)p0(Re)}function Nv(e,t){var a=$e;$e|=2;var i=m0(),c=h0();We!==e||Te!==t?(Nr=null,jr=Ue()+500,Xs(e,t)):Gs=Ln(e,t);e:do try{if(Fe!==0&&Re!==null){t=Re;var u=It;t:switch(Fe){case 1:Fe=0,It=null,Qs(e,t,u,1);break;case 2:case 9:if(wm(u)){Fe=0,It=null,x0(t);break}t=function(){Fe!==2&&Fe!==9||We!==e||(Fe=7),Mn(e)},u.then(t,t);break e;case 3:Fe=7;break e;case 4:Fe=5;break e;case 7:wm(u)?(Fe=0,It=null,x0(t)):(Fe=0,It=null,Qs(e,t,u,7));break;case 5:var v=null;switch(Re.tag){case 26:v=Re.memoizedState;case 5:case 27:var w=Re;if(v?tp(v):w.stateNode.complete){Fe=0,It=null;var _=w.sibling;if(_!==null)Re=_;else{var F=w.return;F!==null?(Re=F,Cr(F)):Re=null}break t}}Fe=0,It=null,Qs(e,t,u,5);break;case 6:Fe=0,It=null,Qs(e,t,u,6);break;case 8:bu(),ft=6;break e;default:throw Error(o(462))}}Av();break}catch(P){d0(e,P)}while(!0);return Yn=Ka=null,q.H=i,q.A=c,$e=a,Re!==null?0:(We=null,Te=0,Fi(),ft)}function Av(){for(;Re!==null&&!Ne();)p0(Re)}function p0(e){var t=Uh(e.alternate,e,ea);e.memoizedProps=e.pendingProps,t===null?Cr(e):Re=t}function x0(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Dh(a,t,t.pendingProps,t.type,void 0,Te);break;case 11:t=Dh(a,t,t.pendingProps,t.type.render,t.ref,Te);break;case 5:_c(t);default:Vh(a,t),t=Re=hm(t,ea),t=Uh(a,t,ea)}e.memoizedProps=e.pendingProps,t===null?Cr(e):Re=t}function Qs(e,t,a,i){Yn=Ka=null,_c(t),Os=null,Tl=0;var c=t.return;try{if(fv(e,c,t,a,Te)){ft=1,mr(e,rn(a,e.current)),Re=null;return}}catch(u){if(c!==null)throw Re=c,u;ft=1,mr(e,rn(a,e.current)),Re=null;return}t.flags&32768?(Be||i===1?e=!0:Gs||(Te&536870912)!==0?e=!1:(Aa=e=!0,(i===2||i===9||i===3||i===6)&&(i=Kt.current,i!==null&&i.tag===13&&(i.flags|=16384))),g0(t,e)):Cr(t)}function Cr(e){var t=e;do{if((t.flags&32768)!==0){g0(t,Aa);return}e=t.return;var a=pv(t.alternate,t,ea);if(a!==null){Re=a;return}if(t=t.sibling,t!==null){Re=t;return}Re=t=e}while(t!==null);ft===0&&(ft=5)}function g0(e,t){do{var a=xv(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);ft=6,Re=null}function b0(e,t,a,i,c,u,v,w,_){e.cancelPendingCommit=null;do Er();while(Ct!==0);if(($e&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=rc,zo(e,a,u,v,w,_),e===We&&(Re=We=null,Te=0),Fs=t,Ea=e,ta=a,pu=u,xu=c,r0=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,kv(Mt,function(){return N0(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||i){i=q.T,q.T=null,c=L.p,L.p=2,v=$e,$e|=4;try{gv(e,t,a)}finally{$e=v,L.p=c,q.T=i}}Ct=1,v0(),y0(),S0()}}function v0(){if(Ct===1){Ct=0;var e=Ea,t=Fs,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=q.T,q.T=null;var i=L.p;L.p=2;var c=$e;$e|=4;try{Wh(t,e);var u=qu,v=lm(e.containerInfo),w=u.focusedElem,_=u.selectionRange;if(v!==w&&w&&w.ownerDocument&&sm(w.ownerDocument.documentElement,w)){if(_!==null&&nc(w)){var F=_.start,P=_.end;if(P===void 0&&(P=F),"selectionStart"in w)w.selectionStart=F,w.selectionEnd=Math.min(P,w.value.length);else{var ne=w.ownerDocument||document,Q=ne&&ne.defaultView||window;if(Q.getSelection){var I=Q.getSelection(),me=w.textContent.length,je=Math.min(_.start,me),Ie=_.end===void 0?je:Math.min(_.end,me);!I.extend&&je>Ie&&(v=Ie,Ie=je,je=v);var U=am(w,je),B=am(w,Ie);if(U&&B&&(I.rangeCount!==1||I.anchorNode!==U.node||I.anchorOffset!==U.offset||I.focusNode!==B.node||I.focusOffset!==B.offset)){var G=ne.createRange();G.setStart(U.node,U.offset),I.removeAllRanges(),je>Ie?(I.addRange(G),I.extend(B.node,B.offset)):(G.setEnd(B.node,B.offset),I.addRange(G))}}}}for(ne=[],I=w;I=I.parentNode;)I.nodeType===1&&ne.push({element:I,left:I.scrollLeft,top:I.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;w<ne.length;w++){var W=ne[w];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}Ur=!!Ru,qu=Ru=null}finally{$e=c,L.p=i,q.T=a}}e.current=t,Ct=2}}function y0(){if(Ct===2){Ct=0;var e=Ea,t=Fs,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=q.T,q.T=null;var i=L.p;L.p=2;var c=$e;$e|=4;try{Kh(e,t.alternate,t)}finally{$e=c,L.p=i,q.T=a}}Ct=3}}function S0(){if(Ct===4||Ct===3){Ct=0,pt();var e=Ea,t=Fs,a=ta,i=r0;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Ct=5:(Ct=0,Fs=Ea=null,j0(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(Ca=null),Pe(a),t=t.stateNode,At&&typeof At.onCommitFiberRoot=="function")try{At.onCommitFiberRoot(Bn,t,void 0,(t.current.flags&128)===128)}catch{}if(i!==null){t=q.T,c=L.p,L.p=2,q.T=null;try{for(var u=e.onRecoverableError,v=0;v<i.length;v++){var w=i[v];u(w.value,{componentStack:w.stack})}}finally{q.T=t,L.p=c}}(ta&3)!==0&&Er(),Mn(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===gu?Zl++:(Zl=0,gu=e):Zl=0,Il(0)}}function j0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Rl(t)))}function Er(){return v0(),y0(),S0(),N0()}function N0(){if(Ct!==5)return!1;var e=Ea,t=pu;pu=0;var a=Pe(ta),i=q.T,c=L.p;try{L.p=32>a?32:a,q.T=null,a=xu,xu=null;var u=Ea,v=ta;if(Ct=0,Fs=Ea=null,ta=0,($e&6)!==0)throw Error(o(331));var w=$e;if($e|=4,s0(u.current),t0(u,u.current,v,a),$e=w,Il(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Bn,u)}catch{}return!0}finally{L.p=c,q.T=i,j0(e,t)}}function A0(e,t,a){t=rn(a,t),t=Zc(e.stateNode,t,2),e=ya(e,t,2),e!==null&&(Ha(e,2),Mn(e))}function Xe(e,t,a){if(e.tag===3)A0(e,e,a);else for(;t!==null;){if(t.tag===3){A0(t,e,a);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Ca===null||!Ca.has(i))){e=rn(a,e),a=wh(2),i=ya(t,a,2),i!==null&&(Ch(a,i,t,e),Ha(i,2),Mn(i));break}}t=t.return}}function yu(e,t,a){var i=e.pingCache;if(i===null){i=e.pingCache=new yv;var c=new Set;i.set(t,c)}else c=i.get(t),c===void 0&&(c=new Set,i.set(t,c));c.has(a)||(fu=!0,c.add(a),e=wv.bind(null,e,t,a),t.then(e,e))}function wv(e,t,a){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,We===e&&(Te&a)===a&&(ft===4||ft===3&&(Te&62914560)===Te&&300>Ue()-Sr?($e&2)===0&&Xs(e,0):mu|=a,Ys===Te&&(Ys=0)),Mn(e)}function w0(e,t){t===0&&(t=hl()),e=Fa(e,t),e!==null&&(Ha(e,t),Mn(e))}function Cv(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),w0(e,a)}function Ev(e,t){var a=0;switch(e.tag){case 31:case 13:var i=e.stateNode,c=e.memoizedState;c!==null&&(a=c.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(t),w0(e,a)}function kv(e,t){return J(e,t)}var kr=null,Ks=null,Su=!1,Mr=!1,ju=!1,Ma=0;function Mn(e){e!==Ks&&e.next===null&&(Ks===null?kr=Ks=e:Ks=Ks.next=e),Mr=!0,Su||(Su=!0,Rv())}function Il(e,t){if(!ju&&Mr){ju=!0;do for(var a=!1,i=kr;i!==null;){if(e!==0){var c=i.pendingLanes;if(c===0)var u=0;else{var v=i.suspendedLanes,w=i.pingedLanes;u=(1<<31-Rt(42|e)+1)-1,u&=c&~(v&~w),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(a=!0,M0(i,u))}else u=Te,u=wn(i,i===We?u:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(u&3)===0||Ln(i,u)||(a=!0,M0(i,u));i=i.next}while(a);ju=!1}}function Mv(){C0()}function C0(){Mr=Su=!1;var e=0;Ma!==0&&Hv()&&(e=Ma);for(var t=Ue(),a=null,i=kr;i!==null;){var c=i.next,u=E0(i,t);u===0?(i.next=null,a===null?kr=c:a.next=c,c===null&&(Ks=a)):(a=i,(e!==0||(u&3)!==0)&&(Mr=!0)),i=c}Ct!==0&&Ct!==5||Il(e),Ma!==0&&(Ma=0)}function E0(e,t){for(var a=e.suspendedLanes,i=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var v=31-Rt(u),w=1<<v,_=c[v];_===-1?((w&a)===0||(w&i)!==0)&&(c[v]=ps(w,t)):_<=t&&(e.expiredLanes|=w),u&=~w}if(t=We,a=Te,a=wn(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,a===0||e===t&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&ge(i),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||Ln(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(i!==null&&ge(i),Pe(a)){case 2:case 8:a=bt;break;case 32:a=Mt;break;case 268435456:a=Yt;break;default:a=Mt}return i=k0.bind(null,e),a=J(a,i),e.callbackPriority=t,e.callbackNode=a,t}return i!==null&&i!==null&&ge(i),e.callbackPriority=2,e.callbackNode=null,2}function k0(e,t){if(Ct!==0&&Ct!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Er()&&e.callbackNode!==a)return null;var i=Te;return i=wn(e,e===We?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(c0(e,i,t),E0(e,Ue()),e.callbackNode!=null&&e.callbackNode===a?k0.bind(null,e):null)}function M0(e,t){if(Er())return null;c0(e,t,!0)}function Rv(){$v(function(){($e&6)!==0?J(ut,Mv):C0()})}function Nu(){if(Ma===0){var e=Ds;e===0&&(e=hs,hs<<=1,(hs&261888)===0&&(hs=256)),Ma=e}return Ma}function R0(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Li(""+e)}function q0(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 qv(e,t,a,i,c){if(t==="submit"&&a&&a.stateNode===c){var u=R0((c[wt]||null).action),v=i.submitter;v&&(t=(t=v[wt]||null)?R0(t.formAction):v.getAttribute("formAction"),t!==null&&(u=t,v=null));var w=new Vi("action","action",null,i,c);e.push({event:w,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Ma!==0){var _=v?q0(c,v):new FormData(c);Gc(a,{pending:!0,data:_,method:c.method,action:u},null,_)}}else typeof u=="function"&&(w.preventDefault(),_=v?q0(c,v):new FormData(c),Gc(a,{pending:!0,data:_,method:c.method,action:u},u,_))},currentTarget:c}]})}}for(var Au=0;Au<ic.length;Au++){var wu=ic[Au],Tv=wu.toLowerCase(),Dv=wu[0].toUpperCase()+wu.slice(1);bn(Tv,"on"+Dv)}bn(om,"onAnimationEnd"),bn(cm,"onAnimationIteration"),bn(um,"onAnimationStart"),bn("dblclick","onDoubleClick"),bn("focusin","onFocus"),bn("focusout","onBlur"),bn(Zb,"onTransitionRun"),bn(Ib,"onTransitionStart"),bn(Jb,"onTransitionCancel"),bn(dm,"onTransitionEnd"),vs("onMouseEnter",["mouseout","mouseover"]),vs("onMouseLeave",["mouseout","mouseover"]),vs("onPointerEnter",["pointerout","pointerover"]),vs("onPointerLeave",["pointerout","pointerover"]),Va("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Va("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Va("onBeforeInput",["compositionend","keypress","textInput","paste"]),Va("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Va("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Va("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Jl="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(" "),_v=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Jl));function T0(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var i=e[a],c=i.event;i=i.listeners;e:{var u=void 0;if(t)for(var v=i.length-1;0<=v;v--){var w=i[v],_=w.instance,F=w.currentTarget;if(w=w.listener,_!==u&&c.isPropagationStopped())break e;u=w,c.currentTarget=F;try{u(c)}catch(P){Yi(P)}c.currentTarget=null,u=_}else for(v=0;v<i.length;v++){if(w=i[v],_=w.instance,F=w.currentTarget,w=w.listener,_!==u&&c.isPropagationStopped())break e;u=w,c.currentTarget=F;try{u(c)}catch(P){Yi(P)}c.currentTarget=null,u=_}}}}function qe(e,t){var a=t[zn];a===void 0&&(a=t[zn]=new Set);var i=e+"__bubble";a.has(i)||(D0(t,e,2,!1),a.add(i))}function Cu(e,t,a){var i=0;t&&(i|=4),D0(a,e,i,t)}var Rr="_reactListening"+Math.random().toString(36).slice(2);function Eu(e){if(!e[Rr]){e[Rr]=!0,Cf.forEach(function(a){a!=="selectionchange"&&(_v.has(a)||Cu(a,!1,e),Cu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Rr]||(t[Rr]=!0,Cu("selectionchange",!1,t))}}function D0(e,t,a,i){switch(op(t)){case 2:var c=oy;break;case 8:c=cy;break;default:c=$u}a=c.bind(null,t,a,e),c=void 0,!Qo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),i?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 ku(e,t,a,i,c){var u=i;if((t&1)===0&&(t&2)===0&&i!==null)e:for(;;){if(i===null)return;var v=i.tag;if(v===3||v===4){var w=i.stateNode.containerInfo;if(w===c)break;if(v===4)for(v=i.return;v!==null;){var _=v.tag;if((_===3||_===4)&&v.stateNode.containerInfo===c)return;v=v.return}for(;w!==null;){if(v=xs(w),v===null)return;if(_=v.tag,_===5||_===6||_===26||_===27){i=u=v;continue e}w=w.parentNode}}i=i.return}zf(function(){var F=u,P=Fo(a),ne=[];e:{var Q=fm.get(e);if(Q!==void 0){var I=Vi,me=e;switch(e){case"keypress":if(Ui(a)===0)break e;case"keydown":case"keyup":I=Eb;break;case"focusin":me="focus",I=Jo;break;case"focusout":me="blur",I=Jo;break;case"beforeblur":case"afterblur":I=Jo;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":I=Vf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":I=pb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":I=Rb;break;case om:case cm:case um:I=bb;break;case dm:I=Tb;break;case"scroll":case"scrollend":I=mb;break;case"wheel":I=_b;break;case"copy":case"cut":case"paste":I=yb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":I=Gf;break;case"toggle":case"beforetoggle":I=Ob}var je=(t&4)!==0,Ie=!je&&(e==="scroll"||e==="scrollend"),U=je?Q!==null?Q+"Capture":null:Q;je=[];for(var B=F,G;B!==null;){var W=B;if(G=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||G===null||U===null||(W=vl(B,U),W!=null&&je.push(Pl(B,W,G))),Ie)break;B=B.return}0<je.length&&(Q=new I(Q,me,null,a,P),ne.push({event:Q,listeners:je}))}}if((t&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",I=e==="mouseout"||e==="pointerout",Q&&a!==Yo&&(me=a.relatedTarget||a.fromElement)&&(xs(me)||me[at]))break e;if((I||Q)&&(Q=P.window===P?P:(Q=P.ownerDocument)?Q.defaultView||Q.parentWindow:window,I?(me=a.relatedTarget||a.toElement,I=F,me=me?xs(me):null,me!==null&&(Ie=f(me),je=me.tag,me!==Ie||je!==5&&je!==27&&je!==6)&&(me=null)):(I=null,me=F),I!==me)){if(je=Vf,W="onMouseLeave",U="onMouseEnter",B="mouse",(e==="pointerout"||e==="pointerover")&&(je=Gf,W="onPointerLeave",U="onPointerEnter",B="pointer"),Ie=I==null?Q:bl(I),G=me==null?Q:bl(me),Q=new je(W,B+"leave",I,a,P),Q.target=Ie,Q.relatedTarget=G,W=null,xs(P)===F&&(je=new je(U,B+"enter",me,a,P),je.target=G,je.relatedTarget=Ie,W=je),Ie=W,I&&me)t:{for(je=Bv,U=I,B=me,G=0,W=U;W;W=je(W))G++;W=0;for(var Se=B;Se;Se=je(Se))W++;for(;0<G-W;)U=je(U),G--;for(;0<W-G;)B=je(B),W--;for(;G--;){if(U===B||B!==null&&U===B.alternate){je=U;break t}U=je(U),B=je(B)}je=null}else je=null;I!==null&&_0(ne,Q,I,je,!1),me!==null&&Ie!==null&&_0(ne,Ie,me,je,!0)}}e:{if(Q=F?bl(F):window,I=Q.nodeName&&Q.nodeName.toLowerCase(),I==="select"||I==="input"&&Q.type==="file")var He=Jf;else if(Zf(Q))if(Pf)He=Xb;else{He=Yb;var be=Gb}else I=Q.nodeName,!I||I.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?F&&Go(F.elementType)&&(He=Jf):He=Fb;if(He&&(He=He(e,F))){If(ne,He,a,P);break e}be&&be(e,Q,F),e==="focusout"&&F&&Q.type==="number"&&F.memoizedProps.value!=null&&$o(Q,"number",Q.value)}switch(be=F?bl(F):window,e){case"focusin":(Zf(be)||be.contentEditable==="true")&&(ws=be,ac=F,El=null);break;case"focusout":El=ac=ws=null;break;case"mousedown":sc=!0;break;case"contextmenu":case"mouseup":case"dragend":sc=!1,im(ne,a,P);break;case"selectionchange":if(Kb)break;case"keydown":case"keyup":im(ne,a,P)}var Ee;if(Wo)e:{switch(e){case"compositionstart":var De="onCompositionStart";break e;case"compositionend":De="onCompositionEnd";break e;case"compositionupdate":De="onCompositionUpdate";break e}De=void 0}else As?Qf(e,a)&&(De="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(De="onCompositionStart");De&&(Yf&&a.locale!=="ko"&&(As||De!=="onCompositionStart"?De==="onCompositionEnd"&&As&&(Ee=Uf()):(ma=P,Ko="value"in ma?ma.value:ma.textContent,As=!0)),be=qr(F,De),0<be.length&&(De=new $f(De,e,null,a,P),ne.push({event:De,listeners:be}),Ee?De.data=Ee:(Ee=Kf(a),Ee!==null&&(De.data=Ee)))),(Ee=zb?Ub(e,a):Hb(e,a))&&(De=qr(F,"onBeforeInput"),0<De.length&&(be=new $f("onBeforeInput","beforeinput",null,a,P),ne.push({event:be,listeners:De}),be.data=Ee)),qv(ne,e,F,a,P)}T0(ne,t)})}function Pl(e,t,a){return{instance:e,listener:t,currentTarget:a}}function qr(e,t){for(var a=t+"Capture",i=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=vl(e,a),c!=null&&i.unshift(Pl(e,c,u)),c=vl(e,t),c!=null&&i.push(Pl(e,c,u))),e.tag===3)return i;e=e.return}return[]}function Bv(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function _0(e,t,a,i,c){for(var u=t._reactName,v=[];a!==null&&a!==i;){var w=a,_=w.alternate,F=w.stateNode;if(w=w.tag,_!==null&&_===i)break;w!==5&&w!==26&&w!==27||F===null||(_=F,c?(F=vl(a,u),F!=null&&v.unshift(Pl(a,F,_))):c||(F=vl(a,u),F!=null&&v.push(Pl(a,F,_)))),a=a.return}v.length!==0&&e.push({event:t,listeners:v})}var Ov=/\r\n?/g,Lv=/\u0000|\uFFFD/g;function B0(e){return(typeof e=="string"?e:""+e).replace(Ov,`
`).replace(Lv,"")}function O0(e,t){return t=B0(t),B0(e)===t}function Ze(e,t,a,i,c,u){switch(a){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||Ss(e,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&Ss(e,""+i);break;case"className":Bi(e,"class",i);break;case"tabIndex":Bi(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Bi(e,a,i);break;case"style":Of(e,i,u);break;case"data":if(t!=="object"){Bi(e,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(a);break}i=Li(""+i),e.setAttribute(a,i);break;case"action":case"formAction":if(typeof i=="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"&&Ze(e,t,"name",c.name,c,null),Ze(e,t,"formEncType",c.formEncType,c,null),Ze(e,t,"formMethod",c.formMethod,c,null),Ze(e,t,"formTarget",c.formTarget,c,null)):(Ze(e,t,"encType",c.encType,c,null),Ze(e,t,"method",c.method,c,null),Ze(e,t,"target",c.target,c,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(a);break}i=Li(""+i),e.setAttribute(a,i);break;case"onClick":i!=null&&(e.onclick=Hn);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}a=Li(""+i),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":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""+i):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":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":i===!0?e.setAttribute(a,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,i):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(a,i):e.removeAttribute(a);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(a):e.setAttribute(a,i);break;case"popover":qe("beforetoggle",e),qe("toggle",e),_i(e,"popover",i);break;case"xlinkActuate":Un(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":Un(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":Un(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":Un(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":Un(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":Un(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":Un(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":Un(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":Un(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":_i(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=db.get(a)||a,_i(e,a,i))}}function Mu(e,t,a,i,c,u){switch(a){case"style":Of(e,i,u);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof i=="string"?Ss(e,i):(typeof i=="number"||typeof i=="bigint")&&Ss(e,""+i);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("scrollend",e);break;case"onClick":i!=null&&(e.onclick=Hn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ef.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[wt]||null,u=u!=null?u[a]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof i=="function")){typeof u!="function"&&u!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,i,c);break e}a in e?e[a]=i:i===!0?e.setAttribute(a,""):_i(e,a,i)}}}function _t(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":qe("error",e),qe("load",e);var i=!1,c=!1,u;for(u in a)if(a.hasOwnProperty(u)){var v=a[u];if(v!=null)switch(u){case"src":i=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ze(e,t,u,v,a,null)}}c&&Ze(e,t,"srcSet",a.srcSet,a,null),i&&Ze(e,t,"src",a.src,a,null);return;case"input":qe("invalid",e);var w=u=v=c=null,_=null,F=null;for(i in a)if(a.hasOwnProperty(i)){var P=a[i];if(P!=null)switch(i){case"name":c=P;break;case"type":v=P;break;case"checked":_=P;break;case"defaultChecked":F=P;break;case"value":u=P;break;case"defaultValue":w=P;break;case"children":case"dangerouslySetInnerHTML":if(P!=null)throw Error(o(137,t));break;default:Ze(e,t,i,P,a,null)}}Tf(e,u,w,_,F,v,c,!1);return;case"select":qe("invalid",e),i=v=u=null;for(c in a)if(a.hasOwnProperty(c)&&(w=a[c],w!=null))switch(c){case"value":u=w;break;case"defaultValue":v=w;break;case"multiple":i=w;default:Ze(e,t,c,w,a,null)}t=u,a=v,e.multiple=!!i,t!=null?ys(e,!!i,t,!1):a!=null&&ys(e,!!i,a,!0);return;case"textarea":qe("invalid",e),u=c=i=null;for(v in a)if(a.hasOwnProperty(v)&&(w=a[v],w!=null))switch(v){case"value":i=w;break;case"defaultValue":c=w;break;case"children":u=w;break;case"dangerouslySetInnerHTML":if(w!=null)throw Error(o(91));break;default:Ze(e,t,v,w,a,null)}_f(e,i,c,u);return;case"option":for(_ in a)if(a.hasOwnProperty(_)&&(i=a[_],i!=null))switch(_){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Ze(e,t,_,i,a,null)}return;case"dialog":qe("beforetoggle",e),qe("toggle",e),qe("cancel",e),qe("close",e);break;case"iframe":case"object":qe("load",e);break;case"video":case"audio":for(i=0;i<Jl.length;i++)qe(Jl[i],e);break;case"image":qe("error",e),qe("load",e);break;case"details":qe("toggle",e);break;case"embed":case"source":case"link":qe("error",e),qe("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(F in a)if(a.hasOwnProperty(F)&&(i=a[F],i!=null))switch(F){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ze(e,t,F,i,a,null)}return;default:if(Go(t)){for(P in a)a.hasOwnProperty(P)&&(i=a[P],i!==void 0&&Mu(e,t,P,i,a,void 0));return}}for(w in a)a.hasOwnProperty(w)&&(i=a[w],i!=null&&Ze(e,t,w,i,a,null))}function zv(e,t,a,i){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,w=null,_=null,F=null,P=null;for(I in a){var ne=a[I];if(a.hasOwnProperty(I)&&ne!=null)switch(I){case"checked":break;case"value":break;case"defaultValue":_=ne;default:i.hasOwnProperty(I)||Ze(e,t,I,null,i,ne)}}for(var Q in i){var I=i[Q];if(ne=a[Q],i.hasOwnProperty(Q)&&(I!=null||ne!=null))switch(Q){case"type":u=I;break;case"name":c=I;break;case"checked":F=I;break;case"defaultChecked":P=I;break;case"value":v=I;break;case"defaultValue":w=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:I!==ne&&Ze(e,t,Q,I,i,ne)}}Vo(e,v,w,_,F,P,u,c);return;case"select":I=v=w=Q=null;for(u in a)if(_=a[u],a.hasOwnProperty(u)&&_!=null)switch(u){case"value":break;case"multiple":I=_;default:i.hasOwnProperty(u)||Ze(e,t,u,null,i,_)}for(c in i)if(u=i[c],_=a[c],i.hasOwnProperty(c)&&(u!=null||_!=null))switch(c){case"value":Q=u;break;case"defaultValue":w=u;break;case"multiple":v=u;default:u!==_&&Ze(e,t,c,u,i,_)}t=w,a=v,i=I,Q!=null?ys(e,!!a,Q,!1):!!i!=!!a&&(t!=null?ys(e,!!a,t,!0):ys(e,!!a,a?[]:"",!1));return;case"textarea":I=Q=null;for(w in a)if(c=a[w],a.hasOwnProperty(w)&&c!=null&&!i.hasOwnProperty(w))switch(w){case"value":break;case"children":break;default:Ze(e,t,w,null,i,c)}for(v in i)if(c=i[v],u=a[v],i.hasOwnProperty(v)&&(c!=null||u!=null))switch(v){case"value":Q=c;break;case"defaultValue":I=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Ze(e,t,v,c,i,u)}Df(e,Q,I);return;case"option":for(var me in a)if(Q=a[me],a.hasOwnProperty(me)&&Q!=null&&!i.hasOwnProperty(me))switch(me){case"selected":e.selected=!1;break;default:Ze(e,t,me,null,i,Q)}for(_ in i)if(Q=i[_],I=a[_],i.hasOwnProperty(_)&&Q!==I&&(Q!=null||I!=null))switch(_){case"selected":e.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:Ze(e,t,_,Q,i,I)}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&&!i.hasOwnProperty(je)&&Ze(e,t,je,null,i,Q);for(F in i)if(Q=i[F],I=a[F],i.hasOwnProperty(F)&&Q!==I&&(Q!=null||I!=null))switch(F){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(o(137,t));break;default:Ze(e,t,F,Q,i,I)}return;default:if(Go(t)){for(var Ie in a)Q=a[Ie],a.hasOwnProperty(Ie)&&Q!==void 0&&!i.hasOwnProperty(Ie)&&Mu(e,t,Ie,void 0,i,Q);for(P in i)Q=i[P],I=a[P],!i.hasOwnProperty(P)||Q===I||Q===void 0&&I===void 0||Mu(e,t,P,Q,i,I);return}}for(var U in a)Q=a[U],a.hasOwnProperty(U)&&Q!=null&&!i.hasOwnProperty(U)&&Ze(e,t,U,null,i,Q);for(ne in i)Q=i[ne],I=a[ne],!i.hasOwnProperty(ne)||Q===I||Q==null&&I==null||Ze(e,t,ne,Q,i,I)}function L0(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Uv(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),i=0;i<a.length;i++){var c=a[i],u=c.transferSize,v=c.initiatorType,w=c.duration;if(u&&w&&L0(v)){for(v=0,w=c.responseEnd,i+=1;i<a.length;i++){var _=a[i],F=_.startTime;if(F>w)break;var P=_.transferSize,ne=_.initiatorType;P&&L0(ne)&&(_=_.responseEnd,v+=P*(_<w?1:(w-F)/(_-F)))}if(--i,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 Ru=null,qu=null;function Tr(e){return e.nodeType===9?e:e.ownerDocument}function z0(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 U0(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 Tu(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 Du=null;function Hv(){var e=window.event;return e&&e.type==="popstate"?e===Du?!1:(Du=e,!0):(Du=null,!1)}var H0=typeof setTimeout=="function"?setTimeout:void 0,Vv=typeof clearTimeout=="function"?clearTimeout:void 0,V0=typeof Promise=="function"?Promise:void 0,$v=typeof queueMicrotask=="function"?queueMicrotask:typeof V0<"u"?function(e){return V0.resolve(null).then(e).catch(Gv)}:H0;function Gv(e){setTimeout(function(){throw e})}function Ra(e){return e==="head"}function $0(e,t){var a=t,i=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(i===0){e.removeChild(c),Ps(t);return}i--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")i++;else if(a==="html")Wl(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Wl(a);for(var u=a.firstChild;u;){var v=u.nextSibling,w=u.nodeName;u[gl]||w==="SCRIPT"||w==="STYLE"||w==="LINK"&&u.rel.toLowerCase()==="stylesheet"||a.removeChild(u),u=v}}else a==="body"&&Wl(e.ownerDocument.body);a=c}while(a);Ps(t)}function G0(e,t){var a=e;e=0;do{var i=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||""),i&&i.nodeType===8)if(a=i.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=i}while(a)}function _u(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":_u(a),Uo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Yv(e,t,a,i){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[gl])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=fn(e.nextSibling),e===null)break}return null}function Fv(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=fn(e.nextSibling),e===null))return null;return e}function Y0(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=fn(e.nextSibling),e===null))return null;return e}function Bu(e){return e.data==="$?"||e.data==="$~"}function Ou(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Xv(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var i=function(){t(),a.removeEventListener("DOMContentLoaded",i)};a.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function fn(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 Lu=null;function F0(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return fn(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function X0(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 Q0(e,t,a){switch(t=Tr(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 Wl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Uo(e)}var mn=new Map,K0=new Set;function Dr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var na=L.d;L.d={f:Qv,r:Kv,D:Zv,C:Iv,L:Jv,m:Pv,X:ey,S:Wv,M:ty};function Qv(){var e=na.f(),t=Ar();return e||t}function Kv(e){var t=gs(e);t!==null&&t.tag===5&&t.type==="form"?dh(t):na.r(e)}var Zs=typeof document>"u"?null:document;function Z0(e,t,a){var i=Zs;if(i&&typeof t=="string"&&t){var c=sn(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),K0.has(c)||(K0.add(c),e={rel:e,crossOrigin:a,href:t},i.querySelector(c)===null&&(t=i.createElement("link"),_t(t,"link",e),Et(t),i.head.appendChild(t)))}}function Zv(e){na.D(e),Z0("dns-prefetch",e,null)}function Iv(e,t){na.C(e,t),Z0("preconnect",e,t)}function Jv(e,t,a){na.L(e,t,a);var i=Zs;if(i&&e&&t){var c='link[rel="preload"][as="'+sn(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+sn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+sn(a.imageSizes)+'"]')):c+='[href="'+sn(e)+'"]';var u=c;switch(t){case"style":u=Is(e);break;case"script":u=Js(e)}mn.has(u)||(e=y({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),mn.set(u,e),i.querySelector(c)!==null||t==="style"&&i.querySelector(ei(u))||t==="script"&&i.querySelector(ti(u))||(t=i.createElement("link"),_t(t,"link",e),Et(t),i.head.appendChild(t)))}}function Pv(e,t){na.m(e,t);var a=Zs;if(a&&e){var i=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+sn(i)+'"][href="'+sn(e)+'"]',u=c;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Js(e)}if(!mn.has(u)&&(e=y({rel:"modulepreload",href:e},t),mn.set(u,e),a.querySelector(c)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(ti(u)))return}i=a.createElement("link"),_t(i,"link",e),Et(i),a.head.appendChild(i)}}}function Wv(e,t,a){na.S(e,t,a);var i=Zs;if(i&&e){var c=bs(i).hoistableStyles,u=Is(e);t=t||"default";var v=c.get(u);if(!v){var w={loading:0,preload:null};if(v=i.querySelector(ei(u)))w.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},a),(a=mn.get(u))&&zu(e,a);var _=v=i.createElement("link");Et(_),_t(_,"link",e),_._p=new Promise(function(F,P){_.onload=F,_.onerror=P}),_.addEventListener("load",function(){w.loading|=1}),_.addEventListener("error",function(){w.loading|=2}),w.loading|=4,_r(v,t,i)}v={type:"stylesheet",instance:v,count:1,state:w},c.set(u,v)}}}function ey(e,t){na.X(e,t);var a=Zs;if(a&&e){var i=bs(a).hoistableScripts,c=Js(e),u=i.get(c);u||(u=a.querySelector(ti(c)),u||(e=y({src:e,async:!0},t),(t=mn.get(c))&&Uu(e,t),u=a.createElement("script"),Et(u),_t(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},i.set(c,u))}}function ty(e,t){na.M(e,t);var a=Zs;if(a&&e){var i=bs(a).hoistableScripts,c=Js(e),u=i.get(c);u||(u=a.querySelector(ti(c)),u||(e=y({src:e,async:!0,type:"module"},t),(t=mn.get(c))&&Uu(e,t),u=a.createElement("script"),Et(u),_t(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},i.set(c,u))}}function I0(e,t,a,i){var c=(c=re.current)?Dr(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=Is(a.href),a=bs(c).hoistableStyles,i=a.get(t),i||(i={type:"style",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Is(a.href);var u=bs(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(ei(e)))&&!u._p&&(v.instance=u,v.state.loading=5),mn.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},mn.set(e,a),u||ny(c,e,a,v.state))),t&&i===null)throw Error(o(528,""));return v}if(t&&i!==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=Js(a),a=bs(c).hoistableScripts,i=a.get(t),i||(i={type:"script",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Is(e){return'href="'+sn(e)+'"'}function ei(e){return'link[rel="stylesheet"]['+e+"]"}function J0(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function ny(e,t,a,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),_t(t,"link",a),Et(t),e.head.appendChild(t))}function Js(e){return'[src="'+sn(e)+'"]'}function ti(e){return"script[async]"+e}function P0(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+sn(a.href)+'"]');if(i)return t.instance=i,Et(i),i;var c=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Et(i),_t(i,"style",c),_r(i,a.precedence,e),t.instance=i;case"stylesheet":c=Is(a.href);var u=e.querySelector(ei(c));if(u)return t.state.loading|=4,t.instance=u,Et(u),u;i=J0(a),(c=mn.get(c))&&zu(i,c),u=(e.ownerDocument||e).createElement("link"),Et(u);var v=u;return v._p=new Promise(function(w,_){v.onload=w,v.onerror=_}),_t(u,"link",i),t.state.loading|=4,_r(u,a.precedence,e),t.instance=u;case"script":return u=Js(a.src),(c=e.querySelector(ti(u)))?(t.instance=c,Et(c),c):(i=a,(c=mn.get(u))&&(i=y({},a),Uu(i,c)),e=e.ownerDocument||e,c=e.createElement("script"),Et(c),_t(c,"link",i),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&&(i=t.instance,t.state.loading|=4,_r(i,a.precedence,e));return t.instance}function _r(e,t,a){for(var i=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=i.length?i[i.length-1]:null,u=c,v=0;v<i.length;v++){var w=i[v];if(w.dataset.precedence===t)u=w;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 zu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Uu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Br=null;function W0(e,t,a){if(Br===null){var i=new Map,c=Br=new Map;c.set(a,i)}else c=Br,i=c.get(a),i||(i=new Map,c.set(a,i));if(i.has(e))return i;for(i.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var u=a[c];if(!(u[gl]||u[it]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var v=u.getAttribute(t)||"";v=e+v;var w=i.get(v);w?w.push(u):i.set(v,[u])}}return i}function ep(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ay(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 tp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function sy(e,t,a,i){if(a.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Is(i.href),u=t.querySelector(ei(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Or.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=u,Et(u);return}u=t.ownerDocument||t,i=J0(i),(c=mn.get(c))&&zu(i,c),u=u.createElement("link"),Et(u);var v=u;v._p=new Promise(function(w,_){v.onload=w,v.onerror=_}),_t(u,"link",i),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=Or.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Hu=0;function ly(e,t){return e.stylesheets&&e.count===0&&zr(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var i=setTimeout(function(){if(e.stylesheets&&zr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&Hu===0&&(Hu=62500*Uv());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&zr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>Hu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(c)}}:null}function Or(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Lr=null;function zr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Lr=new Map,t.forEach(iy,e),Lr=null,Or.call(e))}function iy(e,t){if(!(t.state.loading&4)){var a=Lr.get(e);if(a)var i=a.get(null);else{a=new Map,Lr.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),i=v)}i&&a.set(null,i)}c=t.instance,v=c.getAttribute("data-precedence"),u=a.get(v)||i,u===i&&a.set(null,c),a.set(v,c),this.count++,i=Or.bind(this),c.addEventListener("load",i),c.addEventListener("error",i),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var ni={$$typeof:R,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function ry(e,t,a,i,c,u,v,w,_){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=pl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pl(0),this.hiddenUpdates=pl(null),this.identifierPrefix=i,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=_,this.incompleteTransitions=new Map}function np(e,t,a,i,c,u,v,w,_,F,P,ne){return e=new ry(e,t,a,v,_,F,P,ne,w),t=1,u===!0&&(t|=24),u=Qt(3,null,null,t),e.current=u,u.stateNode=e,t=vc(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:i,isDehydrated:a,cache:t},Nc(u),e}function ap(e){return e?(e=ks,e):ks}function sp(e,t,a,i,c,u){c=ap(c),i.context===null?i.context=c:i.pendingContext=c,i=va(t),i.payload={element:a},u=u===void 0?null:u,u!==null&&(i.callback=u),a=ya(e,i,t),a!==null&&(Gt(a,e,t),_l(a,e,t))}function lp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Vu(e,t){lp(e,t),(e=e.alternate)&&lp(e,t)}function ip(e){if(e.tag===13||e.tag===31){var t=Fa(e,67108864);t!==null&&Gt(t,e,67108864),Vu(e,67108864)}}function rp(e){if(e.tag===13||e.tag===31){var t=Pt();t=Qe(t);var a=Fa(e,t);a!==null&&Gt(a,e,t),Vu(e,t)}}var Ur=!0;function oy(e,t,a,i){var c=q.T;q.T=null;var u=L.p;try{L.p=2,$u(e,t,a,i)}finally{L.p=u,q.T=c}}function cy(e,t,a,i){var c=q.T;q.T=null;var u=L.p;try{L.p=8,$u(e,t,a,i)}finally{L.p=u,q.T=c}}function $u(e,t,a,i){if(Ur){var c=Gu(i);if(c===null)ku(e,t,i,Hr,a),cp(e,i);else if(dy(c,e,t,a,i))i.stopPropagation();else if(cp(e,i),t&4&&-1<uy.indexOf(e)){for(;c!==null;){var u=gs(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var v=On(u.pendingLanes);if(v!==0){var w=u;for(w.pendingLanes|=2,w.entangledLanes|=2;v;){var _=1<<31-Rt(v);w.entanglements[1]|=_,v&=~_}Mn(u),($e&6)===0&&(jr=Ue()+500,Il(0))}}break;case 31:case 13:w=Fa(u,2),w!==null&&Gt(w,u,2),Ar(),Vu(u,2)}if(u=Gu(i),u===null&&ku(e,t,i,Hr,a),u===c)break;c=u}c!==null&&i.stopPropagation()}else ku(e,t,i,null,a)}}function Gu(e){return e=Fo(e),Yu(e)}var Hr=null;function Yu(e){if(Hr=null,e=xs(e),e!==null){var t=f(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=p(t),e!==null)return e;e=null}else if(a===31){if(e=h(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 Hr=e,null}function op(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(ct()){case ut:return 2;case bt:return 8;case Mt:case fs:return 32;case Yt:return 268435456;default:return 32}default:return 32}}var Fu=!1,qa=null,Ta=null,Da=null,ai=new Map,si=new Map,_a=[],uy="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 cp(e,t){switch(e){case"focusin":case"focusout":qa=null;break;case"dragenter":case"dragleave":Ta=null;break;case"mouseover":case"mouseout":Da=null;break;case"pointerover":case"pointerout":ai.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":si.delete(t.pointerId)}}function li(e,t,a,i,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:a,eventSystemFlags:i,nativeEvent:u,targetContainers:[c]},t!==null&&(t=gs(t),t!==null&&ip(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function dy(e,t,a,i,c){switch(t){case"focusin":return qa=li(qa,e,t,a,i,c),!0;case"dragenter":return Ta=li(Ta,e,t,a,i,c),!0;case"mouseover":return Da=li(Da,e,t,a,i,c),!0;case"pointerover":var u=c.pointerId;return ai.set(u,li(ai.get(u)||null,e,t,a,i,c)),!0;case"gotpointercapture":return u=c.pointerId,si.set(u,li(si.get(u)||null,e,t,a,i,c)),!0}return!1}function up(e){var t=xs(e.target);if(t!==null){var a=f(t);if(a!==null){if(t=a.tag,t===13){if(t=p(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){rp(a)});return}}else if(t===31){if(t=h(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){rp(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 Vr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Gu(e.nativeEvent);if(a===null){a=e.nativeEvent;var i=new a.constructor(a.type,a);Yo=i,a.target.dispatchEvent(i),Yo=null}else return t=gs(a),t!==null&&ip(t),e.blockedOn=a,!1;t.shift()}return!0}function dp(e,t,a){Vr(e)&&a.delete(t)}function fy(){Fu=!1,qa!==null&&Vr(qa)&&(qa=null),Ta!==null&&Vr(Ta)&&(Ta=null),Da!==null&&Vr(Da)&&(Da=null),ai.forEach(dp),si.forEach(dp)}function $r(e,t){e.blockedOn===t&&(e.blockedOn=null,Fu||(Fu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,fy)))}var Gr=null;function fp(e){Gr!==e&&(Gr=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Gr===e&&(Gr=null);for(var t=0;t<e.length;t+=3){var a=e[t],i=e[t+1],c=e[t+2];if(typeof i!="function"){if(Yu(i||a)===null)continue;break}var u=gs(a);u!==null&&(e.splice(t,3),t-=3,Gc(u,{pending:!0,data:c,method:a.method,action:i},i,c))}}))}function Ps(e){function t(_){return $r(_,e)}qa!==null&&$r(qa,e),Ta!==null&&$r(Ta,e),Da!==null&&$r(Da,e),ai.forEach(t),si.forEach(t);for(var a=0;a<_a.length;a++){var i=_a[a];i.blockedOn===e&&(i.blockedOn=null)}for(;0<_a.length&&(a=_a[0],a.blockedOn===null);)up(a),a.blockedOn===null&&_a.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(i=0;i<a.length;i+=3){var c=a[i],u=a[i+1],v=c[wt]||null;if(typeof u=="function")v||fp(a);else if(v){var w=null;if(u&&u.hasAttribute("formAction")){if(c=u,v=u[wt]||null)w=v.formAction;else if(Yu(c)!==null)continue}else w=v.action;typeof w=="function"?a[i+1]=w:(a.splice(i,3),i-=3),fp(a)}}}function mp(){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),i||setTimeout(a,20)}function a(){if(!i&&!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 i=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Xu(e){this._internalRoot=e}Yr.prototype.render=Xu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,i=Pt();sp(a,i,e,t,null,null)},Yr.prototype.unmount=Xu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;sp(e.current,2,null,e,null,null),Ar(),t[at]=null}};function Yr(e){this._internalRoot=e}Yr.prototype.unstable_scheduleHydration=function(e){if(e){var t=Me();e={blockedOn:null,target:e,priority:t};for(var a=0;a<_a.length&&t!==0&&t<_a[a].priority;a++);_a.splice(a,0,e),a===0&&up(e)}};var hp=s.version;if(hp!=="19.2.0")throw Error(o(527,hp,"19.2.0"));L.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?b(e):null,e=e===null?null:e.stateNode,e};var my={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Fr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fr.isDisabled&&Fr.supportsFiber)try{Bn=Fr.inject(my),At=Fr}catch{}}return ri.createRoot=function(e,t){if(!d(e))throw Error(o(299));var a=!1,i="",c=Sh,u=jh,v=Nh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(v=t.onRecoverableError)),t=np(e,1,!1,null,null,a,i,null,c,u,v,mp),e[at]=t.current,Eu(e),new Xu(t)},ri.hydrateRoot=function(e,t,a){if(!d(e))throw Error(o(299));var i=!1,c="",u=Sh,v=jh,w=Nh,_=null;return a!=null&&(a.unstable_strictMode===!0&&(i=!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&&(w=a.onRecoverableError),a.formState!==void 0&&(_=a.formState)),t=np(e,1,!0,t,a??null,i,c,_,u,v,w,mp),t.context=ap(null),a=t.current,i=Pt(),i=Qe(i),c=va(i),c.callback=null,ya(a,c,i),a=i,t.current.lanes=a,Ha(t,a),Mn(t),e[at]=t.current,Eu(e),new Yr(t)},ri.version="19.2.0",ri}var Ap;function Ay(){if(Ap)return Zu.exports;Ap=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(),Zu.exports=Ny(),Zu.exports}var wy=Ay();var wp="popstate";function Cy(n={}){function s(o,d){let{pathname:f,search:p,hash:h}=o.location;return Nd("",{pathname:f,search:p,hash:h},d.state&&d.state.usr||null,d.state&&d.state.key||"default")}function l(o,d){return typeof d=="string"?d:yi(d)}return ky(s,l,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 Ey(){return Math.random().toString(36).substring(2,10)}function Cp(n,s){return{usr:n.state,key:n.key,idx:s}}function Nd(n,s,l=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?ul(s):s,state:l,key:s&&s.key||o||Ey()}}function yi({pathname:n="/",search:s="",hash:l=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),l&&l!=="#"&&(n+=l.charAt(0)==="#"?l:"#"+l),n}function ul(n){let s={};if(n){let l=n.indexOf("#");l>=0&&(s.hash=n.substring(l),n=n.substring(0,l));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function ky(n,s,l,o={}){let{window:d=document.defaultView,v5Compat:f=!1}=o,p=d.history,h="POP",x=null,g=b();g==null&&(g=0,p.replaceState({...p.state,idx:g},""));function b(){return(p.state||{idx:null}).idx}function y(){h="POP";let N=b(),C=N==null?null:N-g;g=N,x&&x({action:h,location:E.location,delta:C})}function S(N,C){h="PUSH";let A=Nd(E.location,N,C);g=b()+1;let R=Cp(A,g),k=E.createHref(A);try{p.pushState(R,"",k)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;d.location.assign(k)}f&&x&&x({action:h,location:E.location,delta:1})}function M(N,C){h="REPLACE";let A=Nd(E.location,N,C);g=b();let R=Cp(A,g),k=E.createHref(A);p.replaceState(R,"",k),f&&x&&x({action:h,location:E.location,delta:0})}function j(N){return My(N)}let E={get action(){return h},get location(){return n(d,p)},listen(N){if(x)throw new Error("A history only accepts one active listener");return d.addEventListener(wp,y),x=N,()=>{d.removeEventListener(wp,y),x=null}},createHref(N){return s(d,N)},createURL:j,encodeLocation(N){let C=j(N);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:S,replace:M,go(N){return p.go(N)}};return E}function My(n,s=!1){let l="http://localhost";typeof window<"u"&&(l=window.location.origin!=="null"?window.location.origin:window.location.href),ot(l,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:yi(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=l+o),new URL(o,l)}function Mx(n,s,l="/"){return Ry(n,s,l,!1)}function Ry(n,s,l,o){let d=typeof s=="string"?ul(s):s,f=oa(d.pathname||"/",l);if(f==null)return null;let p=Rx(n);qy(p);let h=null;for(let x=0;h==null&&x<p.length;++x){let g=$y(f);h=Hy(p[x],g,o)}return h}function Rx(n,s=[],l=[],o="",d=!1){let f=(p,h,x=d,g)=>{let b={relativePath:g===void 0?p.path||"":g,caseSensitive:p.caseSensitive===!0,childrenIndex:h,route:p};if(b.relativePath.startsWith("/")){if(!b.relativePath.startsWith(o)&&x)return;ot(b.relativePath.startsWith(o),`Absolute route path "${b.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),b.relativePath=b.relativePath.slice(o.length)}let y=ra([o,b.relativePath]),S=l.concat(b);p.children&&p.children.length>0&&(ot(p.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Rx(p.children,s,S,y,x)),!(p.path==null&&!p.index)&&s.push({path:y,score:zy(y,p.index),routesMeta:S})};return n.forEach((p,h)=>{if(p.path===""||!p.path?.includes("?"))f(p,h);else for(let x of qx(p.path))f(p,h,!0,x)}),s}function qx(n){let s=n.split("/");if(s.length===0)return[];let[l,...o]=s,d=l.endsWith("?"),f=l.replace(/\?$/,"");if(o.length===0)return d?[f,""]:[f];let p=qx(o.join("/")),h=[];return h.push(...p.map(x=>x===""?f:[f,x].join("/"))),d&&h.push(...p),h.map(x=>n.startsWith("/")&&x===""?"/":x)}function qy(n){n.sort((s,l)=>s.score!==l.score?l.score-s.score:Uy(s.routesMeta.map(o=>o.childrenIndex),l.routesMeta.map(o=>o.childrenIndex)))}var Ty=/^:[\w-]+$/,Dy=3,_y=2,By=1,Oy=10,Ly=-2,Ep=n=>n==="*";function zy(n,s){let l=n.split("/"),o=l.length;return l.some(Ep)&&(o+=Ly),s&&(o+=_y),l.filter(d=>!Ep(d)).reduce((d,f)=>d+(Ty.test(f)?Dy:f===""?By:Oy),o)}function Uy(n,s){return n.length===s.length&&n.slice(0,-1).every((o,d)=>o===s[d])?n[n.length-1]-s[s.length-1]:0}function Hy(n,s,l=!1){let{routesMeta:o}=n,d={},f="/",p=[];for(let h=0;h<o.length;++h){let x=o[h],g=h===o.length-1,b=f==="/"?s:s.slice(f.length)||"/",y=ho({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},b),S=x.route;if(!y&&g&&l&&!o[o.length-1].route.index&&(y=ho({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},b)),!y)return null;Object.assign(d,y.params),p.push({params:d,pathname:ra([f,y.pathname]),pathnameBase:Qy(ra([f,y.pathnameBase])),route:S}),y.pathnameBase!=="/"&&(f=ra([f,y.pathnameBase]))}return p}function ho(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[l,o]=Vy(n.path,n.caseSensitive,n.end),d=s.match(l);if(!d)return null;let f=d[0],p=f.replace(/(.)\/+$/,"$1"),h=d.slice(1);return{params:o.reduce((g,{paramName:b,isOptional:y},S)=>{if(b==="*"){let j=h[S]||"";p=f.slice(0,f.length-j.length).replace(/(.)\/+$/,"$1")}const M=h[S];return y&&!M?g[b]=void 0:g[b]=(M||"").replace(/%2F/g,"/"),g},{}),pathname:f,pathnameBase:p,pattern:n}}function Vy(n,s=!1,l=!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=[],d="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(p,h,x)=>(o.push({paramName:h,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),d+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):l?d+="\\/*$":n!==""&&n!=="/"&&(d+="(?:(?=\\/|$))"),[new RegExp(d,s?void 0:"i"),o]}function $y(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 oa(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let l=s.endsWith("/")?s.length-1:s.length,o=n.charAt(l);return o&&o!=="/"?null:n.slice(l)||"/"}var Gy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yy=n=>Gy.test(n);function Fy(n,s="/"){let{pathname:l,search:o="",hash:d=""}=typeof n=="string"?ul(n):n,f;if(l)if(Yy(l))f=l;else{if(l.includes("//")){let p=l;l=l.replace(/\/\/+/g,"/"),An(!1,`Pathnames cannot have embedded double slashes - normalizing ${p} -> ${l}`)}l.startsWith("/")?f=kp(l.substring(1),"/"):f=kp(l,s)}else f=s;return{pathname:f,search:Ky(o),hash:Zy(d)}}function kp(n,s){let l=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(d=>{d===".."?l.length>1&&l.pop():d!=="."&&l.push(d)}),l.length>1?l.join("/"):"/"}function Wu(n,s,l,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${l}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Xy(n){return n.filter((s,l)=>l===0||s.route.path&&s.route.path.length>0)}function Tx(n){let s=Xy(n);return s.map((l,o)=>o===s.length-1?l.pathname:l.pathnameBase)}function Dx(n,s,l,o=!1){let d;typeof n=="string"?d=ul(n):(d={...n},ot(!d.pathname||!d.pathname.includes("?"),Wu("?","pathname","search",d)),ot(!d.pathname||!d.pathname.includes("#"),Wu("#","pathname","hash",d)),ot(!d.search||!d.search.includes("#"),Wu("#","search","hash",d)));let f=n===""||d.pathname==="",p=f?"/":d.pathname,h;if(p==null)h=l;else{let y=s.length-1;if(!o&&p.startsWith("..")){let S=p.split("/");for(;S[0]==="..";)S.shift(),y-=1;d.pathname=S.join("/")}h=y>=0?s[y]:"/"}let x=Fy(d,h),g=p&&p!=="/"&&p.endsWith("/"),b=(f||p===".")&&l.endsWith("/");return!x.pathname.endsWith("/")&&(g||b)&&(x.pathname+="/"),x}var ra=n=>n.join("/").replace(/\/\/+/g,"/"),Qy=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Ky=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Zy=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Iy(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 _x=["POST","PUT","PATCH","DELETE"];new Set(_x);var Jy=["GET",..._x];new Set(Jy);var dl=m.createContext(null);dl.displayName="DataRouter";var wo=m.createContext(null);wo.displayName="DataRouterState";m.createContext(!1);var Bx=m.createContext({isTransitioning:!1});Bx.displayName="ViewTransition";var Py=m.createContext(new Map);Py.displayName="Fetchers";var Wy=m.createContext(null);Wy.displayName="Await";var _n=m.createContext(null);_n.displayName="Navigation";var Mi=m.createContext(null);Mi.displayName="Location";var ua=m.createContext({outlet:null,matches:[],isDataRoute:!1});ua.displayName="Route";var Gd=m.createContext(null);Gd.displayName="RouteError";function e1(n,{relative:s}={}){ot(Ri(),"useHref() may be used only in the context of a <Router> component.");let{basename:l,navigator:o}=m.useContext(_n),{hash:d,pathname:f,search:p}=qi(n,{relative:s}),h=f;return l!=="/"&&(h=f==="/"?l:ra([l,f])),o.createHref({pathname:h,search:p,hash:d})}function Ri(){return m.useContext(Mi)!=null}function ds(){return ot(Ri(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Mi).location}var Ox="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Lx(n){m.useContext(_n).static||m.useLayoutEffect(n)}function t1(){let{isDataRoute:n}=m.useContext(ua);return n?h1():n1()}function n1(){ot(Ri(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(dl),{basename:s,navigator:l}=m.useContext(_n),{matches:o}=m.useContext(ua),{pathname:d}=ds(),f=JSON.stringify(Tx(o)),p=m.useRef(!1);return Lx(()=>{p.current=!0}),m.useCallback((x,g={})=>{if(An(p.current,Ox),!p.current)return;if(typeof x=="number"){l.go(x);return}let b=Dx(x,JSON.parse(f),d,g.relative==="path");n==null&&s!=="/"&&(b.pathname=b.pathname==="/"?s:ra([s,b.pathname])),(g.replace?l.replace:l.push)(b,g.state,g)},[s,l,f,d,n])}m.createContext(null);function qi(n,{relative:s}={}){let{matches:l}=m.useContext(ua),{pathname:o}=ds(),d=JSON.stringify(Tx(l));return m.useMemo(()=>Dx(n,JSON.parse(d),o,s==="path"),[n,d,o,s])}function a1(n,s){return zx(n,s)}function zx(n,s,l,o,d){ot(Ri(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:f}=m.useContext(_n),{matches:p}=m.useContext(ua),h=p[p.length-1],x=h?h.params:{},g=h?h.pathname:"/",b=h?h.pathnameBase:"/",y=h&&h.route;{let A=y&&y.path||"";Ux(g,!y||A.endsWith("*")||A.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${A}">) 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="${A}"> to <Route path="${A==="/"?"*":`${A}/*`}">.`)}let S=ds(),M;if(s){let A=typeof s=="string"?ul(s):s;ot(b==="/"||A.pathname?.startsWith(b),`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 "${b}" but pathname "${A.pathname}" was given in the \`location\` prop.`),M=A}else M=S;let j=M.pathname||"/",E=j;if(b!=="/"){let A=b.replace(/^\//,"").split("/");E="/"+j.replace(/^\//,"").split("/").slice(A.length).join("/")}let N=Mx(n,{pathname:E});An(y||N!=null,`No routes matched location "${M.pathname}${M.search}${M.hash}" `),An(N==null||N[N.length-1].route.element!==void 0||N[N.length-1].route.Component!==void 0||N[N.length-1].route.lazy!==void 0,`Matched leaf route at location "${M.pathname}${M.search}${M.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 C=o1(N&&N.map(A=>Object.assign({},A,{params:Object.assign({},x,A.params),pathname:ra([b,f.encodeLocation?f.encodeLocation(A.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathname]),pathnameBase:A.pathnameBase==="/"?b:ra([b,f.encodeLocation?f.encodeLocation(A.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathnameBase])})),p,l,o,d);return s&&C?m.createElement(Mi.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...M},navigationType:"POP"}},C):C}function s1(){let n=m1(),s=Iy(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),l=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",d={padding:"0.5rem",backgroundColor:o},f={padding:"2px 4px",backgroundColor:o},p=null;return console.error("Error handled by React Router default ErrorBoundary:",n),p=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:f},"ErrorBoundary")," or"," ",m.createElement("code",{style:f},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},s),l?m.createElement("pre",{style:d},l):null,p)}var l1=m.createElement(s1,null),i1=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(ua.Provider,{value:this.props.routeContext},m.createElement(Gd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function r1({routeContext:n,match:s,children:l}){let o=m.useContext(dl);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(ua.Provider,{value:n},l)}function o1(n,s=[],l=null,o=null,d=null){if(n==null){if(!l)return null;if(l.errors)n=l.matches;else if(s.length===0&&!l.initialized&&l.matches.length>0)n=l.matches;else return null}let f=n,p=l?.errors;if(p!=null){let b=f.findIndex(y=>y.route.id&&p?.[y.route.id]!==void 0);ot(b>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(p).join(",")}`),f=f.slice(0,Math.min(f.length,b+1))}let h=!1,x=-1;if(l)for(let b=0;b<f.length;b++){let y=f[b];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(x=b),y.route.id){let{loaderData:S,errors:M}=l,j=y.route.loader&&!S.hasOwnProperty(y.route.id)&&(!M||M[y.route.id]===void 0);if(y.route.lazy||j){h=!0,x>=0?f=f.slice(0,x+1):f=[f[0]];break}}}let g=l&&o?(b,y)=>{o(b,{location:l.location,params:l.matches?.[0]?.params??{},errorInfo:y})}:void 0;return f.reduceRight((b,y,S)=>{let M,j=!1,E=null,N=null;l&&(M=p&&y.route.id?p[y.route.id]:void 0,E=y.route.errorElement||l1,h&&(x<0&&S===0?(Ux("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),j=!0,N=null):x===S&&(j=!0,N=y.route.hydrateFallbackElement||null)));let C=s.concat(f.slice(0,S+1)),A=()=>{let R;return M?R=E:j?R=N:y.route.Component?R=m.createElement(y.route.Component,null):y.route.element?R=y.route.element:R=b,m.createElement(r1,{match:y,routeContext:{outlet:b,matches:C,isDataRoute:l!=null},children:R})};return l&&(y.route.ErrorBoundary||y.route.errorElement||S===0)?m.createElement(i1,{location:l.location,revalidation:l.revalidation,component:E,error:M,children:A(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:g}):A()},null)}function Yd(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function c1(n){let s=m.useContext(dl);return ot(s,Yd(n)),s}function u1(n){let s=m.useContext(wo);return ot(s,Yd(n)),s}function d1(n){let s=m.useContext(ua);return ot(s,Yd(n)),s}function Fd(n){let s=d1(n),l=s.matches[s.matches.length-1];return ot(l.route.id,`${n} can only be used on routes that contain a unique "id"`),l.route.id}function f1(){return Fd("useRouteId")}function m1(){let n=m.useContext(Gd),s=u1("useRouteError"),l=Fd("useRouteError");return n!==void 0?n:s.errors?.[l]}function h1(){let{router:n}=c1("useNavigate"),s=Fd("useNavigate"),l=m.useRef(!1);return Lx(()=>{l.current=!0}),m.useCallback(async(d,f={})=>{An(l.current,Ox),l.current&&(typeof d=="number"?n.navigate(d):await n.navigate(d,{fromRouteId:s,...f}))},[n,s])}var Mp={};function Ux(n,s,l){!s&&!Mp[n]&&(Mp[n]=!0,An(!1,l))}m.memo(p1);function p1({routes:n,future:s,state:l,unstable_onError:o}){return zx(n,void 0,l,o,s)}function ao(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 x1({basename:n="/",children:s=null,location:l,navigationType:o="POP",navigator:d,static:f=!1}){ot(!Ri(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=n.replace(/^\/*/,"/"),h=m.useMemo(()=>({basename:p,navigator:d,static:f,future:{}}),[p,d,f]);typeof l=="string"&&(l=ul(l));let{pathname:x="/",search:g="",hash:b="",state:y=null,key:S="default"}=l,M=m.useMemo(()=>{let j=oa(x,p);return j==null?null:{location:{pathname:j,search:g,hash:b,state:y,key:S},navigationType:o}},[p,x,g,b,y,S,o]);return An(M!=null,`<Router basename="${p}"> is not able to match the URL "${x}${g}${b}" because it does not start with the basename, so the <Router> won't render anything.`),M==null?null:m.createElement(_n.Provider,{value:h},m.createElement(Mi.Provider,{children:s,value:M}))}function g1({children:n,location:s}){return a1(Ad(n),s)}function Ad(n,s=[]){let l=[];return m.Children.forEach(n,(o,d)=>{if(!m.isValidElement(o))return;let f=[...s,d];if(o.type===m.Fragment){l.push.apply(l,Ad(o.props.children,f));return}ot(o.type===ao,`[${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 p={id:o.props.id||f.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&&(p.children=Ad(o.props.children,f)),l.push(p)}),l}var so="get",lo="application/x-www-form-urlencoded";function Co(n){return n!=null&&typeof n.tagName=="string"}function b1(n){return Co(n)&&n.tagName.toLowerCase()==="button"}function v1(n){return Co(n)&&n.tagName.toLowerCase()==="form"}function y1(n){return Co(n)&&n.tagName.toLowerCase()==="input"}function S1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function j1(n,s){return n.button===0&&(!s||s==="_self")&&!S1(n)}var Xr=null;function N1(){if(Xr===null)try{new FormData(document.createElement("form"),0),Xr=!1}catch{Xr=!0}return Xr}var A1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ed(n){return n!=null&&!A1.has(n)?(An(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${lo}"`),null):n}function w1(n,s){let l,o,d,f,p;if(v1(n)){let h=n.getAttribute("action");o=h?oa(h,s):null,l=n.getAttribute("method")||so,d=ed(n.getAttribute("enctype"))||lo,f=new FormData(n)}else if(b1(n)||y1(n)&&(n.type==="submit"||n.type==="image")){let h=n.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=n.getAttribute("formaction")||h.getAttribute("action");if(o=x?oa(x,s):null,l=n.getAttribute("formmethod")||h.getAttribute("method")||so,d=ed(n.getAttribute("formenctype"))||ed(h.getAttribute("enctype"))||lo,f=new FormData(h,n),!N1()){let{name:g,type:b,value:y}=n;if(b==="image"){let S=g?`${g}.`:"";f.append(`${S}x`,"0"),f.append(`${S}y`,"0")}else g&&f.append(g,y)}}else{if(Co(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');l=so,o=null,d=lo,p=n}return f&&d==="text/plain"&&(p=f,f=void 0),{action:o,method:l.toLowerCase(),encType:d,formData:f,body:p}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xd(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function C1(n,s,l){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${l}`:s&&oa(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${l}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${l}`,o}async function E1(n,s){if(n.id in s)return s[n.id];try{let l=await import(n.module);return s[n.id]=l,l}catch(l){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(l),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function k1(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 M1(n,s,l){let o=await Promise.all(n.map(async d=>{let f=s.routes[d.route.id];if(f){let p=await E1(f,l);return p.links?p.links():[]}return[]}));return D1(o.flat(1).filter(k1).filter(d=>d.rel==="stylesheet"||d.rel==="preload").map(d=>d.rel==="stylesheet"?{...d,rel:"prefetch",as:"style"}:{...d,rel:"prefetch"}))}function Rp(n,s,l,o,d,f){let p=(x,g)=>l[g]?x.route.id!==l[g].route.id:!0,h=(x,g)=>l[g].pathname!==x.pathname||l[g].route.path?.endsWith("*")&&l[g].params["*"]!==x.params["*"];return f==="assets"?s.filter((x,g)=>p(x,g)||h(x,g)):f==="data"?s.filter((x,g)=>{let b=o.routes[x.route.id];if(!b||!b.hasLoader)return!1;if(p(x,g)||h(x,g))return!0;if(x.route.shouldRevalidate){let y=x.route.shouldRevalidate({currentUrl:new URL(d.pathname+d.search+d.hash,window.origin),currentParams:l[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function R1(n,s,{includeHydrateFallback:l}={}){return q1(n.map(o=>{let d=s.routes[o.route.id];if(!d)return[];let f=[d.module];return d.clientActionModule&&(f=f.concat(d.clientActionModule)),d.clientLoaderModule&&(f=f.concat(d.clientLoaderModule)),l&&d.hydrateFallbackModule&&(f=f.concat(d.hydrateFallbackModule)),d.imports&&(f=f.concat(d.imports)),f}).flat(1))}function q1(n){return[...new Set(n)]}function T1(n){let s={},l=Object.keys(n).sort();for(let o of l)s[o]=n[o];return s}function D1(n,s){let l=new Set;return new Set(s),n.reduce((o,d)=>{let f=JSON.stringify(T1(d));return l.has(f)||(l.add(f),o.push({key:f,link:d})),o},[])}function Hx(){let n=m.useContext(dl);return Xd(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function _1(){let n=m.useContext(wo);return Xd(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Qd=m.createContext(void 0);Qd.displayName="FrameworkContext";function Vx(){let n=m.useContext(Qd);return Xd(n,"You must render this element inside a <HydratedRouter> element"),n}function B1(n,s){let l=m.useContext(Qd),[o,d]=m.useState(!1),[f,p]=m.useState(!1),{onFocus:h,onBlur:x,onMouseEnter:g,onMouseLeave:b,onTouchStart:y}=s,S=m.useRef(null);m.useEffect(()=>{if(n==="render"&&p(!0),n==="viewport"){let E=C=>{C.forEach(A=>{p(A.isIntersecting)})},N=new IntersectionObserver(E,{threshold:.5});return S.current&&N.observe(S.current),()=>{N.disconnect()}}},[n]),m.useEffect(()=>{if(o){let E=setTimeout(()=>{p(!0)},100);return()=>{clearTimeout(E)}}},[o]);let M=()=>{d(!0)},j=()=>{d(!1),p(!1)};return l?n!=="intent"?[f,S,{}]:[f,S,{onFocus:oi(h,M),onBlur:oi(x,j),onMouseEnter:oi(g,M),onMouseLeave:oi(b,j),onTouchStart:oi(y,M)}]:[!1,S,{}]}function oi(n,s){return l=>{n&&n(l),l.defaultPrevented||s(l)}}function O1({page:n,...s}){let{router:l}=Hx(),o=m.useMemo(()=>Mx(l.routes,n,l.basename),[l.routes,n,l.basename]);return o?m.createElement(z1,{page:n,matches:o,...s}):null}function L1(n){let{manifest:s,routeModules:l}=Vx(),[o,d]=m.useState([]);return m.useEffect(()=>{let f=!1;return M1(n,s,l).then(p=>{f||d(p)}),()=>{f=!0}},[n,s,l]),o}function z1({page:n,matches:s,...l}){let o=ds(),{manifest:d,routeModules:f}=Vx(),{basename:p}=Hx(),{loaderData:h,matches:x}=_1(),g=m.useMemo(()=>Rp(n,s,x,d,o,"data"),[n,s,x,d,o]),b=m.useMemo(()=>Rp(n,s,x,d,o,"assets"),[n,s,x,d,o]),y=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let j=new Set,E=!1;if(s.forEach(C=>{let A=d.routes[C.route.id];!A||!A.hasLoader||(!g.some(R=>R.route.id===C.route.id)&&C.route.id in h&&f[C.route.id]?.shouldRevalidate||A.hasClientLoader?E=!0:j.add(C.route.id))}),j.size===0)return[];let N=C1(n,p,"data");return E&&j.size>0&&N.searchParams.set("_routes",s.filter(C=>j.has(C.route.id)).map(C=>C.route.id).join(",")),[N.pathname+N.search]},[p,h,o,d,g,s,n,f]),S=m.useMemo(()=>R1(b,d),[b,d]),M=L1(b);return m.createElement(m.Fragment,null,y.map(j=>m.createElement("link",{key:j,rel:"prefetch",as:"fetch",href:j,...l})),S.map(j=>m.createElement("link",{key:j,rel:"modulepreload",href:j,...l})),M.map(({key:j,link:E})=>m.createElement("link",{key:j,nonce:l.nonce,...E})))}function U1(...n){return s=>{n.forEach(l=>{typeof l=="function"?l(s):l!=null&&(l.current=s)})}}var $x=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{$x&&(window.__reactRouterVersion="7.9.6")}catch{}function H1({basename:n,children:s,window:l}){let o=m.useRef();o.current==null&&(o.current=Cy({window:l,v5Compat:!0}));let d=o.current,[f,p]=m.useState({action:d.action,location:d.location}),h=m.useCallback(x=>{m.startTransition(()=>p(x))},[p]);return m.useLayoutEffect(()=>d.listen(h),[d,h]),m.createElement(x1,{basename:n,children:s,location:f.location,navigationType:f.action,navigator:d})}var Gx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yx=m.forwardRef(function({onClick:s,discover:l="render",prefetch:o="none",relative:d,reloadDocument:f,replace:p,state:h,target:x,to:g,preventScrollReset:b,viewTransition:y,...S},M){let{basename:j}=m.useContext(_n),E=typeof g=="string"&&Gx.test(g),N,C=!1;if(typeof g=="string"&&E&&(N=g,$x))try{let K=new URL(window.location.href),$=g.startsWith("//")?new URL(K.protocol+g):new URL(g),Y=oa($.pathname,j);$.origin===K.origin&&Y!=null?g=Y+$.search+$.hash:C=!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 A=e1(g,{relative:d}),[R,k,O]=B1(o,S),X=Y1(g,{replace:p,state:h,target:x,preventScrollReset:b,relative:d,viewTransition:y});function D(K){s&&s(K),K.defaultPrevented||X(K)}let H=m.createElement("a",{...S,...O,href:N||A,onClick:C||f?s:D,ref:U1(M,k),target:x,"data-discover":!E&&l==="render"?"true":void 0});return R&&!E?m.createElement(m.Fragment,null,H,m.createElement(O1,{page:A})):H});Yx.displayName="Link";var V1=m.forwardRef(function({"aria-current":s="page",caseSensitive:l=!1,className:o="",end:d=!1,style:f,to:p,viewTransition:h,children:x,...g},b){let y=qi(p,{relative:g.relative}),S=ds(),M=m.useContext(wo),{navigator:j,basename:E}=m.useContext(_n),N=M!=null&&Z1(y)&&h===!0,C=j.encodeLocation?j.encodeLocation(y).pathname:y.pathname,A=S.pathname,R=M&&M.navigation&&M.navigation.location?M.navigation.location.pathname:null;l||(A=A.toLowerCase(),R=R?R.toLowerCase():null,C=C.toLowerCase()),R&&E&&(R=oa(R,E)||R);const k=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let O=A===C||!d&&A.startsWith(C)&&A.charAt(k)==="/",X=R!=null&&(R===C||!d&&R.startsWith(C)&&R.charAt(C.length)==="/"),D={isActive:O,isPending:X,isTransitioning:N},H=O?s:void 0,K;typeof o=="function"?K=o(D):K=[o,O?"active":null,X?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let $=typeof f=="function"?f(D):f;return m.createElement(Yx,{...g,"aria-current":H,className:K,ref:b,style:$,to:p,viewTransition:h},typeof x=="function"?x(D):x)});V1.displayName="NavLink";var $1=m.forwardRef(({discover:n="render",fetcherKey:s,navigate:l,reloadDocument:o,replace:d,state:f,method:p=so,action:h,onSubmit:x,relative:g,preventScrollReset:b,viewTransition:y,...S},M)=>{let j=Q1(),E=K1(h,{relative:g}),N=p.toLowerCase()==="get"?"get":"post",C=typeof h=="string"&&Gx.test(h),A=R=>{if(x&&x(R),R.defaultPrevented)return;R.preventDefault();let k=R.nativeEvent.submitter,O=k?.getAttribute("formmethod")||p;j(k||R.currentTarget,{fetcherKey:s,method:O,navigate:l,replace:d,state:f,relative:g,preventScrollReset:b,viewTransition:y})};return m.createElement("form",{ref:M,method:N,action:E,onSubmit:o?x:A,...S,"data-discover":!C&&n==="render"?"true":void 0})});$1.displayName="Form";function G1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Fx(n){let s=m.useContext(dl);return ot(s,G1(n)),s}function Y1(n,{target:s,replace:l,state:o,preventScrollReset:d,relative:f,viewTransition:p}={}){let h=t1(),x=ds(),g=qi(n,{relative:f});return m.useCallback(b=>{if(j1(b,s)){b.preventDefault();let y=l!==void 0?l:yi(x)===yi(g);h(n,{replace:y,state:o,preventScrollReset:d,relative:f,viewTransition:p})}},[x,h,g,l,o,s,n,d,f,p])}var F1=0,X1=()=>`__${String(++F1)}__`;function Q1(){let{router:n}=Fx("useSubmit"),{basename:s}=m.useContext(_n),l=f1();return m.useCallback(async(o,d={})=>{let{action:f,method:p,encType:h,formData:x,body:g}=w1(o,s);if(d.navigate===!1){let b=d.fetcherKey||X1();await n.fetch(b,l,d.action||f,{preventScrollReset:d.preventScrollReset,formData:x,body:g,formMethod:d.method||p,formEncType:d.encType||h,flushSync:d.flushSync})}else await n.navigate(d.action||f,{preventScrollReset:d.preventScrollReset,formData:x,body:g,formMethod:d.method||p,formEncType:d.encType||h,replace:d.replace,state:d.state,fromRouteId:l,flushSync:d.flushSync,viewTransition:d.viewTransition})},[n,s,l])}function K1(n,{relative:s}={}){let{basename:l}=m.useContext(_n),o=m.useContext(ua);ot(o,"useFormAction must be used inside a RouteContext");let[d]=o.matches.slice(-1),f={...qi(n||".",{relative:s})},p=ds();if(n==null){f.search=p.search;let h=new URLSearchParams(f.search),x=h.getAll("index");if(x.some(b=>b==="")){h.delete("index"),x.filter(y=>y).forEach(y=>h.append("index",y));let b=h.toString();f.search=b?`?${b}`:""}}return(!n||n===".")&&d.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),l!=="/"&&(f.pathname=f.pathname==="/"?l:ra([l,f.pathname])),yi(f)}function Z1(n,{relative:s}={}){let l=m.useContext(Bx);ot(l!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Fx("useViewTransitionState"),d=qi(n,{relative:s});if(!l.isTransitioning)return!1;let f=oa(l.currentLocation.pathname,o)||l.currentLocation.pathname,p=oa(l.nextLocation.pathname,o)||l.nextLocation.pathname;return ho(d.pathname,p)!=null||ho(d.pathname,f)!=null}const Dn=Object.create(null);Dn.open="0";Dn.close="1";Dn.ping="2";Dn.pong="3";Dn.message="4";Dn.upgrade="5";Dn.noop="6";const io=Object.create(null);Object.keys(Dn).forEach(n=>{io[Dn[n]]=n});const wd={type:"error",data:"parser error"},Xx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Qx=typeof ArrayBuffer=="function",Kx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Kd=({type:n,data:s},l,o)=>Xx&&s instanceof Blob?l?o(s):qp(s,o):Qx&&(s instanceof ArrayBuffer||Kx(s))?l?o(s):qp(new Blob([s]),o):o(Dn[n]+(s||"")),qp=(n,s)=>{const l=new FileReader;return l.onload=function(){const o=l.result.split(",")[1];s("b"+(o||""))},l.readAsDataURL(n)};function Tp(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let td;function I1(n,s){if(Xx&&n.data instanceof Blob)return n.data.arrayBuffer().then(Tp).then(s);if(Qx&&(n.data instanceof ArrayBuffer||Kx(n.data)))return s(Tp(n.data));Kd(n,!1,l=>{td||(td=new TextEncoder),s(td.encode(l))})}const Dp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",hi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Dp.length;n++)hi[Dp.charCodeAt(n)]=n;const J1=n=>{let s=n.length*.75,l=n.length,o,d=0,f,p,h,x;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);const g=new ArrayBuffer(s),b=new Uint8Array(g);for(o=0;o<l;o+=4)f=hi[n.charCodeAt(o)],p=hi[n.charCodeAt(o+1)],h=hi[n.charCodeAt(o+2)],x=hi[n.charCodeAt(o+3)],b[d++]=f<<2|p>>4,b[d++]=(p&15)<<4|h>>2,b[d++]=(h&3)<<6|x&63;return g},P1=typeof ArrayBuffer=="function",Zd=(n,s)=>{if(typeof n!="string")return{type:"message",data:Zx(n,s)};const l=n.charAt(0);return l==="b"?{type:"message",data:W1(n.substring(1),s)}:io[l]?n.length>1?{type:io[l],data:n.substring(1)}:{type:io[l]}:wd},W1=(n,s)=>{if(P1){const l=J1(n);return Zx(l,s)}else return{base64:!0,data:n}},Zx=(n,s)=>{switch(s){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Ix="",eS=(n,s)=>{const l=n.length,o=new Array(l);let d=0;n.forEach((f,p)=>{Kd(f,!1,h=>{o[p]=h,++d===l&&s(o.join(Ix))})})},tS=(n,s)=>{const l=n.split(Ix),o=[];for(let d=0;d<l.length;d++){const f=Zd(l[d],s);if(o.push(f),f.type==="error")break}return o};function nS(){return new TransformStream({transform(n,s){I1(n,l=>{const o=l.length;let d;if(o<126)d=new Uint8Array(1),new DataView(d.buffer).setUint8(0,o);else if(o<65536){d=new Uint8Array(3);const f=new DataView(d.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{d=new Uint8Array(9);const f=new DataView(d.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(d[0]|=128),s.enqueue(d),s.enqueue(l)})}})}let nd;function Qr(n){return n.reduce((s,l)=>s+l.length,0)}function Kr(n,s){if(n[0].length===s)return n.shift();const l=new Uint8Array(s);let o=0;for(let d=0;d<s;d++)l[d]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),l}function aS(n,s){nd||(nd=new TextDecoder);const l=[];let o=0,d=-1,f=!1;return new TransformStream({transform(p,h){for(l.push(p);;){if(o===0){if(Qr(l)<1)break;const x=Kr(l,1);f=(x[0]&128)===128,d=x[0]&127,d<126?o=3:d===126?o=1:o=2}else if(o===1){if(Qr(l)<2)break;const x=Kr(l,2);d=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if(Qr(l)<8)break;const x=Kr(l,8),g=new DataView(x.buffer,x.byteOffset,x.length),b=g.getUint32(0);if(b>Math.pow(2,21)-1){h.enqueue(wd);break}d=b*Math.pow(2,32)+g.getUint32(4),o=3}else{if(Qr(l)<d)break;const x=Kr(l,d);h.enqueue(Zd(f?x:nd.decode(x),s)),o=0}if(d===0||d>n){h.enqueue(wd);break}}}})}const Jx=4;function Nt(n){if(n)return sS(n)}function sS(n){for(var s in Nt.prototype)n[s]=Nt.prototype[s];return n}Nt.prototype.on=Nt.prototype.addEventListener=function(n,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(s),this};Nt.prototype.once=function(n,s){function l(){this.off(n,l),s.apply(this,arguments)}return l.fn=s,this.on(n,l),this};Nt.prototype.off=Nt.prototype.removeListener=Nt.prototype.removeAllListeners=Nt.prototype.removeEventListener=function(n,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var l=this._callbacks["$"+n];if(!l)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,d=0;d<l.length;d++)if(o=l[d],o===s||o.fn===s){l.splice(d,1);break}return l.length===0&&delete this._callbacks["$"+n],this};Nt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),l=this._callbacks["$"+n],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(l){l=l.slice(0);for(var o=0,d=l.length;o<d;++o)l[o].apply(this,s)}return this};Nt.prototype.emitReserved=Nt.prototype.emit;Nt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Nt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Eo=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,l)=>l(s,0),xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),lS="arraybuffer";function Px(n,...s){return s.reduce((l,o)=>(n.hasOwnProperty(o)&&(l[o]=n[o]),l),{})}const iS=xn.setTimeout,rS=xn.clearTimeout;function ko(n,s){s.useNativeTimers?(n.setTimeoutFn=iS.bind(xn),n.clearTimeoutFn=rS.bind(xn)):(n.setTimeoutFn=xn.setTimeout.bind(xn),n.clearTimeoutFn=xn.clearTimeout.bind(xn))}const oS=1.33;function cS(n){return typeof n=="string"?uS(n):Math.ceil((n.byteLength||n.size)*oS)}function uS(n){let s=0,l=0;for(let o=0,d=n.length;o<d;o++)s=n.charCodeAt(o),s<128?l+=1:s<2048?l+=2:s<55296||s>=57344?l+=3:(o++,l+=4);return l}function Wx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function dS(n){let s="";for(let l in n)n.hasOwnProperty(l)&&(s.length&&(s+="&"),s+=encodeURIComponent(l)+"="+encodeURIComponent(n[l]));return s}function fS(n){let s={},l=n.split("&");for(let o=0,d=l.length;o<d;o++){let f=l[o].split("=");s[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return s}class mS extends Error{constructor(s,l,o){super(s),this.description=l,this.context=o,this.type="TransportError"}}class Id extends Nt{constructor(s){super(),this.writable=!1,ko(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,l,o){return super.emitReserved("error",new mS(s,l,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 l=Zd(s,this.socket.binaryType);this.onPacket(l)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,l={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(l)}_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 l=dS(s);return l.length?"?"+l:""}}class hS extends Id{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const l=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||l()})),this.writable||(o++,this.once("drain",function(){--o||l()}))}else l()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const l=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)};tS(s,this.socket.binaryType).forEach(l),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,eS(s,l=>{this.doWrite(l,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",l=this.query||{};return this.opts.timestampRequests!==!1&&(l[this.opts.timestampParam]=Wx()),!this.supportsBinary&&!l.sid&&(l.b64=1),this.createUri(s,l)}}let eg=!1;try{eg=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const pS=eg;function xS(){}class gS extends hS{constructor(s){if(super(s),typeof location<"u"){const l=location.protocol==="https:";let o=location.port;o||(o=l?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||o!==s.port}}doWrite(s,l){const o=this.request({method:"POST",data:s});o.on("success",l),o.on("error",(d,f)=>{this.onError("xhr post error",d,f)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(l,o)=>{this.onError("xhr poll error",l,o)}),this.pollXhr=s}}class Tn extends Nt{constructor(s,l,o){super(),this.createRequest=s,ko(this,o),this._opts=o,this._method=o.method||"GET",this._uri=l,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var s;const l=Px(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");l.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(l);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let d in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(d)&&o.setRequestHeader(d,this._opts.extraHeaders[d])}}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 d;o.readyState===3&&((d=this._opts.cookieJar)===null||d===void 0||d.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(d){this.setTimeoutFn(()=>{this._onError(d)},0);return}typeof document<"u"&&(this._index=Tn.requestsCount++,Tn.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=xS,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Tn.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()}}Tn.requestsCount=0;Tn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",_p);else if(typeof addEventListener=="function"){const n="onpagehide"in xn?"pagehide":"unload";addEventListener(n,_p,!1)}}function _p(){for(let n in Tn.requests)Tn.requests.hasOwnProperty(n)&&Tn.requests[n].abort()}const bS=(function(){const n=tg({xdomain:!1});return n&&n.responseType!==null})();class vS extends gS{constructor(s){super(s);const l=s&&s.forceBase64;this.supportsBinary=bS&&!l}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Tn(tg,this.uri(),s)}}function tg(n){const s=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||pS))return new XMLHttpRequest}catch{}if(!s)try{return new xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ng=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class yS extends Id{get name(){return"websocket"}doOpen(){const s=this.uri(),l=this.opts.protocols,o=ng?{}:Px(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,l,o)}catch(d){return this.emitReserved("error",d)}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 l=0;l<s.length;l++){const o=s[l],d=l===s.length-1;Kd(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}d&&Eo(()=>{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",l=this.query||{};return this.opts.timestampRequests&&(l[this.opts.timestampParam]=Wx()),this.supportsBinary||(l.b64=1),this.createUri(s,l)}}const ad=xn.WebSocket||xn.MozWebSocket;class SS extends yS{createSocket(s,l,o){return ng?new ad(s,l,o):l?new ad(s,l):new ad(s)}doWrite(s,l){this.ws.send(l)}}class jS extends Id{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 l=aS(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=s.readable.pipeThrough(l).getReader(),d=nS();d.readable.pipeTo(s.writable),this._writer=d.writable.getWriter();const f=()=>{o.read().then(({done:h,value:x})=>{h||(this.onPacket(x),f())}).catch(h=>{})};f();const p={type:"open"};this.query.sid&&(p.data=`{"sid":"${this.query.sid}"}`),this._writer.write(p).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let l=0;l<s.length;l++){const o=s[l],d=l===s.length-1;this._writer.write(o).then(()=>{d&&Eo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const NS={websocket:SS,webtransport:jS,polling:vS},AS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,wS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Cd(n){if(n.length>8e3)throw"URI too long";const s=n,l=n.indexOf("["),o=n.indexOf("]");l!=-1&&o!=-1&&(n=n.substring(0,l)+n.substring(l,o).replace(/:/g,";")+n.substring(o,n.length));let d=AS.exec(n||""),f={},p=14;for(;p--;)f[wS[p]]=d[p]||"";return l!=-1&&o!=-1&&(f.source=s,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=CS(f,f.path),f.queryKey=ES(f,f.query),f}function CS(n,s){const l=/\/{2,9}/g,o=s.replace(l,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&o.splice(0,1),s.slice(-1)=="/"&&o.splice(o.length-1,1),o}function ES(n,s){const l={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,d,f){d&&(l[d]=f)}),l}const Ed=typeof addEventListener=="function"&&typeof removeEventListener=="function",ro=[];Ed&&addEventListener("offline",()=>{ro.forEach(n=>n())},!1);class La extends Nt{constructor(s,l){if(super(),this.binaryType=lS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(l=s,s=null),s){const o=Cd(s);l.hostname=o.host,l.secure=o.protocol==="https"||o.protocol==="wss",l.port=o.port,o.query&&(l.query=o.query)}else l.host&&(l.hostname=Cd(l.host).host);ko(this,l),this.secure=l.secure!=null?l.secure:typeof location<"u"&&location.protocol==="https:",l.hostname&&!l.port&&(l.port=this.secure?"443":"80"),this.hostname=l.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=l.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},l.transports.forEach(o=>{const d=o.prototype.name;this.transports.push(d),this._transportsByName[d]=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},l),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=fS(this.opts.query)),Ed&&(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"})},ro.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const l=Object.assign({},this.opts.query);l.EIO=Jx,l.transport=s,this.id&&(l.sid=this.id);const o=Object.assign({},this.opts,{query:l,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&&La.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const l=this.createTransport(s);l.open(),this.setTransport(l)}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",l=>this._onClose("transport close",l))}onOpen(){this.readyState="open",La.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 l=new Error("server error");l.code=s.data,this._onError(l);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 l=1;for(let o=0;o<this.writeBuffer.length;o++){const d=this.writeBuffer[o].data;if(d&&(l+=cS(d)),o>0&&l>this._maxPayload)return this.writeBuffer.slice(0,o);l+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,Eo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,l,o){return this._sendPacket("message",s,l,o),this}send(s,l,o){return this._sendPacket("message",s,l,o),this}_sendPacket(s,l,o,d){if(typeof l=="function"&&(d=l,l=void 0),typeof o=="function"&&(d=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:s,data:l,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),d&&this.once("flush",d),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},l=()=>{this.off("upgrade",l),this.off("upgradeError",l),s()},o=()=>{this.once("upgrade",l),this.once("upgradeError",l)};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(La.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,l){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(),Ed&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=ro.indexOf(this._offlineEventListener);o!==-1&&ro.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,l),this.writeBuffer=[],this._prevBufferLen=0}}}La.protocol=Jx;class kS extends La{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 l=this.createTransport(s),o=!1;La.priorWebsocketSuccess=!1;const d=()=>{o||(l.send([{type:"ping",data:"probe"}]),l.once("packet",y=>{if(!o)if(y.type==="pong"&&y.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",l),!l)return;La.priorWebsocketSuccess=l.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(b(),this.setTransport(l),l.send([{type:"upgrade"}]),this.emitReserved("upgrade",l),l=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=l.name,this.emitReserved("upgradeError",S)}}))};function f(){o||(o=!0,b(),l.close(),l=null)}const p=y=>{const S=new Error("probe error: "+y);S.transport=l.name,f(),this.emitReserved("upgradeError",S)};function h(){p("transport closed")}function x(){p("socket closed")}function g(y){l&&y.name!==l.name&&f()}const b=()=>{l.removeListener("open",d),l.removeListener("error",p),l.removeListener("close",h),this.off("close",x),this.off("upgrading",g)};l.once("open",d),l.once("error",p),l.once("close",h),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{o||l.open()},200):l.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const l=[];for(let o=0;o<s.length;o++)~this.transports.indexOf(s[o])&&l.push(s[o]);return l}}let MS=class extends kS{constructor(s,l={}){const o=typeof s=="object"?s:l;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(d=>NS[d]).filter(d=>!!d)),super(s,o)}};function RS(n,s="",l){let o=n;l=l||typeof location<"u"&&location,n==null&&(n=l.protocol+"//"+l.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=l.protocol+n:n=l.host+n),/^(https?|wss?):\/\//.test(n)||(typeof l<"u"?n=l.protocol+"//"+n:n="https://"+n),o=Cd(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 f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+s,o.href=o.protocol+"://"+f+(l&&l.port===o.port?"":":"+o.port),o}const qS=typeof ArrayBuffer=="function",TS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ag=Object.prototype.toString,DS=typeof Blob=="function"||typeof Blob<"u"&&ag.call(Blob)==="[object BlobConstructor]",_S=typeof File=="function"||typeof File<"u"&&ag.call(File)==="[object FileConstructor]";function Jd(n){return qS&&(n instanceof ArrayBuffer||TS(n))||DS&&n instanceof Blob||_S&&n instanceof File}function oo(n,s){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let l=0,o=n.length;l<o;l++)if(oo(n[l]))return!0;return!1}if(Jd(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return oo(n.toJSON(),!0);for(const l in n)if(Object.prototype.hasOwnProperty.call(n,l)&&oo(n[l]))return!0;return!1}function BS(n){const s=[],l=n.data,o=n;return o.data=kd(l,s),o.attachments=s.length,{packet:o,buffers:s}}function kd(n,s){if(!n)return n;if(Jd(n)){const l={_placeholder:!0,num:s.length};return s.push(n),l}else if(Array.isArray(n)){const l=new Array(n.length);for(let o=0;o<n.length;o++)l[o]=kd(n[o],s);return l}else if(typeof n=="object"&&!(n instanceof Date)){const l={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(l[o]=kd(n[o],s));return l}return n}function OS(n,s){return n.data=Md(n.data,s),delete n.attachments,n}function Md(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 l=0;l<n.length;l++)n[l]=Md(n[l],s);else if(typeof n=="object")for(const l in n)Object.prototype.hasOwnProperty.call(n,l)&&(n[l]=Md(n[l],s));return n}const LS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],zS=5;var Oe;(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"})(Oe||(Oe={}));class US{constructor(s){this.replacer=s}encode(s){return(s.type===Oe.EVENT||s.type===Oe.ACK)&&oo(s)?this.encodeAsBinary({type:s.type===Oe.EVENT?Oe.BINARY_EVENT:Oe.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let l=""+s.type;return(s.type===Oe.BINARY_EVENT||s.type===Oe.BINARY_ACK)&&(l+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(l+=s.nsp+","),s.id!=null&&(l+=s.id),s.data!=null&&(l+=JSON.stringify(s.data,this.replacer)),l}encodeAsBinary(s){const l=BS(s),o=this.encodeAsString(l.packet),d=l.buffers;return d.unshift(o),d}}function Bp(n){return Object.prototype.toString.call(n)==="[object Object]"}class Pd extends Nt{constructor(s){super(),this.reviver=s}add(s){let l;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");l=this.decodeString(s);const o=l.type===Oe.BINARY_EVENT;o||l.type===Oe.BINARY_ACK?(l.type=o?Oe.EVENT:Oe.ACK,this.reconstructor=new HS(l),l.attachments===0&&super.emitReserved("decoded",l)):super.emitReserved("decoded",l)}else if(Jd(s)||s.base64)if(this.reconstructor)l=this.reconstructor.takeBinaryData(s),l&&(this.reconstructor=null,super.emitReserved("decoded",l));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let l=0;const o={type:Number(s.charAt(0))};if(Oe[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Oe.BINARY_EVENT||o.type===Oe.BINARY_ACK){const f=l+1;for(;s.charAt(++l)!=="-"&&l!=s.length;);const p=s.substring(f,l);if(p!=Number(p)||s.charAt(l)!=="-")throw new Error("Illegal attachments");o.attachments=Number(p)}if(s.charAt(l+1)==="/"){const f=l+1;for(;++l&&!(s.charAt(l)===","||l===s.length););o.nsp=s.substring(f,l)}else o.nsp="/";const d=s.charAt(l+1);if(d!==""&&Number(d)==d){const f=l+1;for(;++l;){const p=s.charAt(l);if(p==null||Number(p)!=p){--l;break}if(l===s.length)break}o.id=Number(s.substring(f,l+1))}if(s.charAt(++l)){const f=this.tryParse(s.substr(l));if(Pd.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(s){try{return JSON.parse(s,this.reviver)}catch{return!1}}static isPayloadValid(s,l){switch(s){case Oe.CONNECT:return Bp(l);case Oe.DISCONNECT:return l===void 0;case Oe.CONNECT_ERROR:return typeof l=="string"||Bp(l);case Oe.EVENT:case Oe.BINARY_EVENT:return Array.isArray(l)&&(typeof l[0]=="number"||typeof l[0]=="string"&&LS.indexOf(l[0])===-1);case Oe.ACK:case Oe.BINARY_ACK:return Array.isArray(l)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class HS{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const l=OS(this.reconPack,this.buffers);return this.finishedReconstruction(),l}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const VS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Pd,Encoder:US,get PacketType(){return Oe},protocol:zS},Symbol.toStringTag,{value:"Module"}));function jn(n,s,l){return n.on(s,l),function(){n.off(s,l)}}const $S=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class sg extends Nt{constructor(s,l,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=l,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=[jn(s,"open",this.onopen.bind(this)),jn(s,"packet",this.onpacket.bind(this)),jn(s,"error",this.onerror.bind(this)),jn(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,...l){var o,d,f;if($S.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(l.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(l),this;const p={type:Oe.EVENT,data:l};if(p.options={},p.options.compress=this.flags.compress!==!1,typeof l[l.length-1]=="function"){const b=this.ids++,y=l.pop();this._registerAckCallback(b,y),p.id=b}const h=(d=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||d===void 0?void 0:d.writable,x=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!h||(x?(this.notifyOutgoingListeners(p),this.packet(p)):this.sendBuffer.push(p)),this.flags={},this}_registerAckCallback(s,l){var o;const d=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(d===void 0){this.acks[s]=l;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===s&&this.sendBuffer.splice(h,1);l.call(this,new Error("operation has timed out"))},d),p=(...h)=>{this.io.clearTimeoutFn(f),l.apply(this,h)};p.withError=!0,this.acks[s]=p}emitWithAck(s,...l){return new Promise((o,d)=>{const f=(p,h)=>p?d(p):o(h);f.withError=!0,l.push(f),this.emit(s,...l)})}_addToQueue(s){let l;typeof s[s.length-1]=="function"&&(l=s.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((d,...f)=>o!==this._queue[0]?void 0:(d!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),l&&l(d)):(this._queue.shift(),l&&l(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const l=this._queue[0];l.pending&&!s||(l.pending=!0,l.tryCount++,this.flags=l.flags,this.emit.apply(this,l.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:Oe.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,l){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,l),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 Oe.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 Oe.EVENT:case Oe.BINARY_EVENT:this.onevent(s);break;case Oe.ACK:case Oe.BINARY_ACK:this.onack(s);break;case Oe.DISCONNECT:this.ondisconnect();break;case Oe.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 l=s.data||[];s.id!=null&&l.push(this.ack(s.id)),this.connected?this.emitEvent(l):this.receiveBuffer.push(Object.freeze(l))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const l=this._anyListeners.slice();for(const o of l)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 l=this;let o=!1;return function(...d){o||(o=!0,l.packet({type:Oe.ACK,id:s,data:d}))}}onack(s){const l=this.acks[s.id];typeof l=="function"&&(delete this.acks[s.id],l.withError&&s.data.unshift(null),l.apply(this,s.data))}onconnect(s,l){this.id=s,this.recovered=l&&this._pid===l,this._pid=l,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:Oe.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 l=this._anyListeners;for(let o=0;o<l.length;o++)if(s===l[o])return l.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 l=this._anyOutgoingListeners;for(let o=0;o<l.length;o++)if(s===l[o])return l.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const l=this._anyOutgoingListeners.slice();for(const o of l)o.apply(this,s.data)}}}function fl(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}fl.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),l=Math.floor(s*this.jitter*n);n=(Math.floor(s*10)&1)==0?n-l:n+l}return Math.min(n,this.max)|0};fl.prototype.reset=function(){this.attempts=0};fl.prototype.setMin=function(n){this.ms=n};fl.prototype.setMax=function(n){this.max=n};fl.prototype.setJitter=function(n){this.jitter=n};class Rd extends Nt{constructor(s,l){var o;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(l=s,s=void 0),l=l||{},l.path=l.path||"/socket.io",this.opts=l,ko(this,l),this.reconnection(l.reconnection!==!1),this.reconnectionAttempts(l.reconnectionAttempts||1/0),this.reconnectionDelay(l.reconnectionDelay||1e3),this.reconnectionDelayMax(l.reconnectionDelayMax||5e3),this.randomizationFactor((o=l.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new fl({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(l.timeout==null?2e4:l.timeout),this._readyState="closed",this.uri=s;const d=l.parser||VS;this.encoder=new d.Encoder,this.decoder=new d.Decoder,this._autoConnect=l.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 l;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(l=this.backoff)===null||l===void 0||l.setMin(s),this)}randomizationFactor(s){var l;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(l=this.backoff)===null||l===void 0||l.setJitter(s),this)}reconnectionDelayMax(s){var l;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(l=this.backoff)===null||l===void 0||l.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 MS(this.uri,this.opts);const l=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const d=jn(l,"open",function(){o.onopen(),s&&s()}),f=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),s?s(h):this.maybeReconnectOnOpen()},p=jn(l,"error",f);if(this._timeout!==!1){const h=this._timeout,x=this.setTimeoutFn(()=>{d(),f(new Error("timeout")),l.close()},h);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(d),this.subs.push(p),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(jn(s,"ping",this.onping.bind(this)),jn(s,"data",this.ondata.bind(this)),jn(s,"error",this.onerror.bind(this)),jn(s,"close",this.onclose.bind(this)),jn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(l){this.onclose("parse error",l)}}ondecoded(s){Eo(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,l){let o=this.nsps[s];return o?this._autoConnect&&!o.active&&o.connect():(o=new sg(this,s,l),this.nsps[s]=o),o}_destroy(s){const l=Object.keys(this.nsps);for(const o of l)if(this.nsps[o].active)return;this._close()}_packet(s){const l=this.encoder.encode(s);for(let o=0;o<l.length;o++)this.engine.write(l[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,l){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,l),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 l=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(d=>{d?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",d)):s.onreconnect()}))},l);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 ci={};function co(n,s){typeof n=="object"&&(s=n,n=void 0),s=s||{};const l=RS(n,s.path||"/socket.io"),o=l.source,d=l.id,f=l.path,p=ci[d]&&f in ci[d].nsps,h=s.forceNew||s["force new connection"]||s.multiplex===!1||p;let x;return h?x=new Rd(o,s):(ci[d]||(ci[d]=new Rd(o,s)),x=ci[d]),l.query&&!s.query&&(s.query=l.queryKey),x.socket(l.path,s)}Object.assign(co,{Manager:Rd,Socket:sg,io:co,connect:co});const lg="roverSettings",GS=3600*24*365;function YS(n){try{const s=decodeURIComponent(n??"");return JSON.parse(s)}catch(s){return console.warn("Failed to parse settings cookie",s),null}}function qd(){if(typeof document>"u")return{};const n=`${lg}=`,s=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!s)return{};const l=s.substring(n.length);return YS(l)??{}}function Op(n){if(typeof document>"u")return!1;try{const s=encodeURIComponent(JSON.stringify(n??{})),l=`${lg}=${s}; path=/; max-age=${GS}; samesite=strict`;return document.cookie=l,!0}catch(s){return console.warn("Failed to write settings cookie",s),!1}}const ig=window.location.origin;console.info("[socket] connecting to",ig);const FS=qd(),XS=FS?.page?.connectionTransport||"websocket",QS=XS==="polling"?["polling"]:["websocket","polling"],Wd=co(ig,{transports:QS,timeout:15e3});Wd.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const rg=m.createContext(Wd),KS=({children:n})=>r.jsx(rg.Provider,{value:Wd,children:n}),tn=()=>m.useContext(rg),ZS={connected:!1,session:null,neatoLidar:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,alerts:[]},ef=m.createContext(null);function IS(n){return m.useCallback((s,l={})=>new Promise((o,d)=>{n.emit(s,l,(f={})=>{f.error?d(new Error(f.error)):o(f)})}),[n])}function JS(n){return typeof n=="function"?n:s=>s}function PS({children:n}){const s=tn(),l=IS(s),o=m.useRef({...ZS,connected:s.connected}),d=m.useRef(new Set),f=m.useCallback(()=>o.current,[]),p=m.useCallback(b=>{const y=o.current,S=typeof b=="function"?b(y):{...y,...b||{}};S!==y&&(o.current=S,d.current.forEach(M=>{const j=M.selector(S);M.equalityFn(M.current,j)||(M.current=j,M.listener(j))}))},[]),h=m.useCallback((b,y,S=Object.is)=>{const M=JS(b),j={selector:M,equalityFn:S,listener:y,current:M(o.current)};return d.current.add(j),()=>{d.current.delete(j)}},[]);m.useEffect(()=>{const b=()=>{p(S=>S.connected?S:{...S,connected:!0})},y=()=>{p(S=>S.connected?{...S,connected:!1}:S)};return s.on("connect",b),s.on("disconnect",y),()=>{s.off("connect",b),s.off("disconnect",y)}},[p,s]),m.useEffect(()=>{function b(A){p(R=>({...R,session:A}))}function y(A=[]){p(R=>({...R,logs:A}))}function S(A){p(R=>({...R,logs:[...R.logs.slice(-199),A]}))}function M(A=[]){p(R=>({...R,adminLogs:A}))}function j(A){p(R=>({...R,adminLogs:[...R.adminLogs.slice(-199),A]}))}function E(A=null){const R=A&&typeof A=="object"?A:null,k=R?.debug?.status&&typeof R.debug.status=="object"?R.debug.status:null;p(O=>({...O,llmCommentaryState:R,llmCommentaryStatus:k}))}function N(A={}){p(R=>({...R,alerts:[...R.alerts.slice(-49),{...A,receivedAt:Date.now()}]}))}function C(A=null){const R=A&&typeof A=="object"?A:null;p(k=>({...k,neatoLidar:R}))}return s.on("session:sync",b),s.on("neato:lidar",C),s.on("log:init",y),s.on("log:entry",S),s.on("adminlog:init",M),s.on("adminlog:entry",j),s.on("llm:state",E),s.on("alert:new",N),()=>{s.off("session:sync",b),s.off("neato:lidar",C),s.off("log:init",y),s.off("log:entry",S),s.off("adminlog:init",M),s.off("adminlog:entry",j),s.off("llm:state",E),s.off("alert:new",N)}},[p,s]);const x=m.useMemo(()=>({login:(b,y)=>l("auth:login",{username:b,password:y}),identifySession:({cookieUserId:b,nickname:y}={})=>l("session:identify",{cookieUserId:b,nickname:y}),setRole:b=>l("session:setRole",{role:b}),requestControl:(b,y={})=>l("session:requestControl",{roverId:b,...y}),releaseControl:b=>l("session:releaseControl",{roverId:b}),subscribeAll:()=>l("session:subscribeAll"),lockRover:(b,y)=>l("session:lockRover",{roverId:b,locked:y}),setMode:b=>l("setMode",{mode:b}),homeAssistantToggle:b=>l("homeAssistant:toggle",{entityId:b}),homeAssistantSetState:(b,y)=>l("homeAssistant:setState",{entityId:b,state:y}),homeAssistantSetLightColor:(b,y)=>l("homeAssistant:lightColor",{entityId:b,rgbColor:y}),homeAssistantSetLightWhite:b=>l("homeAssistant:lightWhite",{entityId:b}),neatoStart:()=>l("neato:start"),neatoSendHome:()=>l("neato:sendHome"),neatoLocate:()=>l("neato:locate"),neatoClearErrors:()=>l("neato:clearErrors"),neatoPowerCycle:()=>l("neato:powerCycle"),liftUp:()=>l("lift:up"),liftDown:()=>l("lift:down"),setNickname:b=>l("nickname:set",{nickname:b}),requestVerification:()=>l("verification:request"),requestPrivateRoverAccess:b=>l("session:privateRover:requestAccess",{roverId:b}),triggerReplay:(b=[],y="")=>b&&typeof b=="object"&&!Array.isArray(b)?l("replay:trigger",b):l("replay:trigger",{sources:b,title:y}),setGlobalObjective:b=>l("globalObjective:set",{text:b}),setAdminReason:b=>l("adminReason:set",{text:b}),rebootRover:b=>l("command",{roverId:b,type:"reboot",data:{reboot:{}}}),rebootServer:()=>l("server:reboot"),playUploadedAudio:({roverId:b,name:y,mime:S,dataBase64:M})=>l("audio:uploadPlay",{roverId:b,name:y,mime:S,dataBase64:M}),stopUploadedAudio:b=>l("audio:uploadStop",{roverId:b}),startMicWhip:b=>l("audio:micWhipStart",{roverId:b}),readyMicWhip:b=>l("audio:micWhipReady",{roverId:b}),stopMicWhip:b=>l("audio:micWhipStop",{roverId:b}),setAudioLevels:(b={})=>l("audioLevels:set",b),setPrivateSafety:(b,y={})=>l("session:privateSafety:set",{roverId:b,safety:y}),llmControl:(b,y={})=>l("llm:control",{controls:{action:b,...y}}),pushAlert:b=>p(y=>({...y,alerts:[...y.alerts.slice(-49),{...b,receivedAt:Date.now(),id:b.id||Math.random().toString(36).slice(2)}]}))}),[l,p]),g=m.useMemo(()=>({getState:f,subscribe:h,actions:x}),[x,f,h]);return r.jsx(ef.Provider,{value:g,children:n})}function Je(n,s=Object.is){const l=m.useContext(ef);if(!l)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const d=m.useRef(s);d.current=s;const[f,p]=m.useState(()=>n(l.getState()));return m.useEffect(()=>(p(h=>{const x=o.current(l.getState());return d.current(h,x)?h:x}),l.subscribe(h=>o.current(h),h=>{p(x=>d.current(x,h)?x:h)},(h,x)=>d.current(h,x))),[l]),f}function gn(){const n=m.useContext(ef);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function da(){const n=Je(l=>l),s=gn();return m.useMemo(()=>({...n,...s}),[s,n])}const WS=Object.freeze({}),Td=null,tf=m.createContext(null);function ej({children:n}){const s=tn(),l=m.useRef({}),o=m.useRef(new Map),d=m.useRef(new Set),f=h=>{const x=o.current.get(h);x&&x.forEach(g=>g()),d.current.forEach(g=>g())},p=m.useMemo(()=>({getFrames:()=>l.current,getFrame:h=>h?l.current[h]??Td:Td,subscribeAll:h=>(d.current.add(h),()=>{d.current.delete(h)}),subscribeRover:(h,x)=>{if(!h)return()=>{};let g=o.current.get(h);return g||(g=new Set,o.current.set(h,g)),g.add(x),()=>{const b=o.current.get(h);b&&(b.delete(x),b.size||o.current.delete(h))}}}),[]);return m.useEffect(()=>{function h({roverId:x,sensors:g={},frame:b={}}){x&&(l.current={...l.current,[x]:{roverId:x,sensors:g,raw:b?.data||null,receivedAt:Date.now()}},f(x))}return s.on("sensorFrame",h),()=>{s.off("sensorFrame",h)}},[s]),r.jsx(tf.Provider,{value:p,children:n})}function og(){const n=m.useContext(tf);if(!n)throw new Error("useTelemetryFrames must be used within TelemetryProvider");return m.useSyncExternalStore(n.subscribeAll,n.getFrames,()=>WS)}function ml(n){const s=m.useContext(tf);if(!s)throw new Error("useTelemetryFrame must be used within TelemetryProvider");return m.useSyncExternalStore(l=>s.subscribeRover(n,l),()=>s.getFrame(n),()=>Td)}const tj=650,nj={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 sd(n){if(typeof n!="number"||n<=0)return null;const s=nj[n];return s?{code:n,...s}:null}function aj(n,s={}){const l=s.holdMs||tj,[o,d]=m.useState({left:null,right:null,omni:null}),[f,p]=m.useState(0);return m.useEffect(()=>{const h=setInterval(()=>p(Date.now()),Math.max(l/2,100));return()=>clearInterval(h)},[l]),m.useEffect(()=>{const h=Date.now(),x=sd(n?.infraredCharacterLeft),g=sd(n?.infraredCharacterRight),b=sd(n?.infraredCharacterOmni);!x&&!g&&!b||d(y=>({left:x?{...x,ts:h}:y.left,right:g?{...g,ts:h}:y.right,omni:b?{...b,ts:h}:y.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useMemo(()=>{const h=Date.now(),x=N=>{if(!N)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const C=h-N.ts,A=C<=l;return{active:A,age:C,code:N.code,red:!!(N.red&&A),green:!!(N.green&&A),force:!!(N.force&&A)}},g=x(o.left),b=x(o.right),y=x(o.omni),S=g.force||b.force||y.force,M=g.active||b.active||y.active,j=g.active&&!b.active?"right":b.active&&!g.active?"left":"center",E=(b.active?1:0)-(g.active?1:0);return{visible:M,forceDetected:S,left:g,right:b,omni:y,bias:j,balance:Math.max(-1,Math.min(1,E))}},[o.left,o.right,o.omni,l,f])}function sj(){Je(S=>S.connected);const n=Je(S=>S.session),s=n?.assignment?.roverId,l=ml(s),o=l?.sensors||{},d=aj(o),f=o.voltageMv!=null?`${(o.voltageMv/1e3).toFixed(2)} V`:null,p=o.currentMa!=null?`${o.currentMa} mA`:null,h=o.batteryTemperatureC!=null?`${o.batteryTemperatureC} °C`:null,x=o.batteryChargeMah,g=o.batteryCapacityMah;l?.receivedAt&&new Date(l.receivedAt).toLocaleTimeString();const b=l?.raw?l.raw:null,y=s?n?.activeDrivers?.[s]:null;return m.useMemo(()=>s?y?y===n?.socketId?"You":(n?.users||[]).find(M=>M.socketId===y)?.nickname||y.slice(0,6):"Available":"n/a",[y,s,n?.socketId,n?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[s?l?r.jsxs(r.Fragment,{children:[r.jsx(lj,{sensors:o,voltage:f,current:p,batteryTemp:h,charge:x,capacity:g}),r.jsx(ij,{sensors:o,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 lj({sensors:n,voltage:s,current:l,batteryTemp:o,charge:d,capacity:f}){const p=d!=null&&f?`${Math.round(d/f*100)}`:"--",h=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(aa,{label:"Voltage",value:s??"--"}),r.jsx(aa,{label:"Current",value:l??"--"}),r.jsx(aa,{label:"Battery temp",value:o??"--"}),r.jsx(aa,{label:"Charge",value:d!=null?`${d} mAh`:"--"}),r.jsx(aa,{label:"Capacity",value:f!=null?`${f} mAh`:"--"}),r.jsx(aa,{label:"Charge",value:p}),r.jsx(aa,{label:"OI mode",value:h}),r.jsx(aa,{label:"Docked",value:x}),r.jsx(aa,{label:"Charging state",value:g})]})}function aa({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 ij({sensors:n,dockState:s}){const l=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},d=[{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}],f=[{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}],p=[{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(Ws,{title:"Dock IR",children:[r.jsx(rj,{sensors:n}),r.jsx(oj,{state:s})]}),r.jsxs(Ws,{title:"Bumps & drops",children:[r.jsx(sa,{label:"Bump L",value:r.jsx(ui,{active:l.bumpLeft})}),r.jsx(sa,{label:"Bump R",value:r.jsx(ui,{active:l.bumpRight})}),r.jsx(sa,{label:"Wheel drop L",value:r.jsx(ui,{active:l.wheelDropLeft,tone:"amber"})}),r.jsx(sa,{label:"Wheel drop R",value:r.jsx(ui,{active:l.wheelDropRight,tone:"amber"})})]}),r.jsx(Ws,{title:"Light bumps (raw)",children:d.map(h=>r.jsx(sa,{label:h.label,value:di(h.value)},h.label))}),r.jsx(Ws,{title:"Cliff sensors",children:f.map(h=>r.jsx(sa,{label:h.label,value:`${di(h.value)} · ${h.active?"bool: true":"bool: false"}`},h.label))}),r.jsx(Ws,{title:"Currents",children:p.map(h=>r.jsx(sa,{label:h.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:di(h.value,"mA")}),h.over?r.jsx(ui,{active:!0,tone:"red",label:"over"}):null]})},h.label))}),r.jsxs(Ws,{title:"Dirt detect",children:[r.jsx(sa,{label:"Left",value:di(n?.dirtDetectLeft)}),r.jsx(sa,{label:"Right",value:di(n?.dirtDetect)})]})]})}function Ws({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 sa({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 ui({active:n,tone:s="green",label:l}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",d=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} ${d}`,children:l||(n?"true":"false")})}function di(n,s){return n==null||Number.isNaN(n)?"--":s?`${n} ${s}`:n}function rj({sensors:n}){const s=n?.infraredCharacterLeft,l=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,d=f=>r.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${f?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:f||"--"});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"}),d(s)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"O"}),d(o)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"R"}),d(l)]})]})}function oj({state:n}){if(!n)return null;const s=o=>{const d=[];return o?.red&&d.push("R"),o?.green&&d.push("G"),o?.force&&d.push("F"),d.length?d.join(""):"none"},l=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 ${l(n.left)}`}),r.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${s(n.omni)}) · age ${l(n.omni)}`}),r.jsx("div",{children:`Right: ${n.right.code??"--"} (${s(n.right)}) · age ${l(n.right)}`})]})}const cg=m.createContext(null);function cj({children:n}){const[s,l]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const h=qd();l({status:"ready",data:h??{}})},[]);const o=m.useCallback(()=>{const h=qd();l({status:"ready",data:h??{}})},[]),d=m.useCallback(h=>{const x=Op(h??{});return l(x?{status:"ready",data:h??{}}:g=>({...g,status:"error"})),x},[]),f=m.useCallback((h,x)=>{l(g=>{const b=g.data[h]||{},y=typeof x=="function"?x(b):{...b,...x??{}},S={...g.data,[h]:y};return Op(S)?{status:"ready",data:S}:{...g,status:"error"}})},[]),p=m.useMemo(()=>({data:s.data,status:s.status,reload:o,saveAll:d,setNamespace:f}),[s,o,d,f]);return r.jsx(cg.Provider,{value:p,children:n})}function uj(){const n=m.useContext(cg);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Ge(n,s={}){const{data:l,status:o,setNamespace:d}=uj(),f=l[n]??s??{},p=m.useCallback(g=>{d(n,b=>{const y=b??{};return typeof g=="function"?g(y):{...y,...g??{}}})},[n,d]),h=m.useCallback(g=>{d(n,()=>g??{})},[n,d]),x=m.useCallback(()=>{const g=typeof s=="object"?{...s}:s;d(n,()=>g??{})},[s,n,d]);return{value:f,status:o,save:p,replace:h,reset:x}}const dj=/^#[0-9A-Fa-f]{6}$/;function nf(n){const s=typeof n=="string"?n.trim():"";return!s||!dj.test(s)?null:s.toUpperCase()}function ca(n,s=.2){const l=nf(n);if(!l)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,d=ug(l);if(d)return{borderColor:`rgba(${d.r}, ${d.g}, ${d.b}, 0.65)`,backgroundColor:`rgba(${d.r}, ${d.g}, ${d.b}, ${o})`}}function fj(n,s=.2){const l=nf(n);if(!l)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,d=ug(l);if(d)return{borderColor:`rgba(${d.r}, ${d.g}, ${d.b}, 0.55)`,backgroundColor:`rgba(${d.r}, ${d.g}, ${d.b}, ${o})`}}function ug(n){const s=nf(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 mj(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 af({panelId:n="replay-sources",fillHeight:s=!1}){const{session:l,triggerReplay:o}=da(),d=mj(l?.replaySources||[]),{value:f,save:p}=Ge("replaySources",{}),[h,x]=m.useState([]),[g,b]=m.useState(!1),[y,S]=m.useState(null),[M,j]=m.useState(null),[E,N]=m.useState(""),[C,A]=m.useState(!1),[R,k]=m.useState(!0),O=l?.replay||null,[X,D]=m.useState(0),H=m.useMemo(()=>{const q=l?.assignment?.roverId;return q?[`rover:${q}`]:[]},[l?.assignment?.roverId]),K=m.useMemo(()=>{const L=((Array.isArray(l?.users)?l.users.find(ue=>ue?.socketId===l?.socketId):null)?.nickname||"Someone").trim()||"Someone",Z=l?.assignment?.roverId||null,se=Z&&Array.isArray(l?.roster)?l.roster.find(ue=>String(ue?.id)===String(Z))?.name||Z:"a rover";return`${L} driving ${se}`},[l?.users,l?.socketId,l?.assignment?.roverId,l?.roster]);m.useEffect(()=>{const q=f?.[n];if(Array.isArray(q)&&q.length){x(q);return}x(H)},[f?.[n],H,n]),m.useEffect(()=>{const q=f?.[`${n}:includeSidebar`];if(typeof q=="boolean"){k(q);return}k(!0)},[f?.[`${n}:includeSidebar`],n]),m.useEffect(()=>{C||N(K)},[K,C]),m.useEffect(()=>{const q=new Set(d.map(L=>L.key));x(L=>L.filter(Z=>q.has(Z)))},[d]);const $=m.useMemo(()=>({rovers:d.filter(q=>q.type==="rover"),rooms:d.filter(q=>q.type==="room")}),[d]);m.useEffect(()=>{if(!O?.lastTriggeredAt||!O?.cooldownMs){D(0);return}const q=()=>{const Z=O.lastTriggeredAt+O.cooldownMs-Date.now();D(Math.max(0,Z))};q();const L=setInterval(q,250);return()=>clearInterval(L)},[O?.lastTriggeredAt,O?.cooldownMs,O?.remainingMs]);const Y=g||l?.mode==="lockdown"||X>0||!h.length,ee=q=>{x(L=>{const Z=L.includes(q)?L.filter(se=>se!==q):[...L,q];return p(se=>({...se||{},[n]:Z})),Z}),j(null)},oe=async()=>{if(!Y){b(!0),S(null),j(null);try{const q=h.map(Z=>{const[se,ue]=Z.split(":");return{type:se,id:ue}}),L=String(E||"").trim()||K;await o({sources:q,title:L,includeSidebar:R}),j("Replay sent. Check the Discord replay channel.")}catch(q){S(q.message)}finally{b(!1)}}},ce=s?"h-full flex flex-col":"",z=s?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${ce}`,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:d.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${z}`,children:[r.jsx(Lp,{title:"Rovers",items:$.rovers,selected:h,onToggle:ee}),r.jsx(Lp,{title:"Room Cams",items:$.rooms,selected:h,onToggle:ee})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("label",{className:"panel-muted block text-xs",htmlFor:`${n}-title`,children:"Replay title"}),r.jsx("input",{id:`${n}-title`,type:"text",className:"field-input w-full text-xs",value:E,onChange:q=>{N(q.target.value),A(!0)},placeholder:K,maxLength:120}),r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:R,onChange:q=>{const L=!!q.target.checked;k(L),p(Z=>({...Z||{},[`${n}:includeSidebar`]:L}))},className:"accent-emerald-400"}),r.jsx("span",{children:"Include replay sidebar"})]}),r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:oe,disabled:Y,children:X>0?`Replay (${Math.ceil(X/1e3)}s)`:g?"Replay…":"Replay"}),y?r.jsx("div",{className:"text-xs text-amber-400",children:y}):null,M?r.jsx("div",{className:"text-xs text-emerald-300",children:M}):null]})]})}function Lp({title:n,items:s,selected:l,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(d=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:l.includes(d.key),onChange:()=>o(d.key),className:"accent-emerald-400"}),r.jsx("span",{className:`truncate ${d.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:d.type==="rover"?ca(d.color,.16):void 0,children:d.label})]},d.key))})]}):null}var dg={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},zp=qn.createContext&&qn.createContext(dg),hj=["attr","size","title"];function pj(n,s){if(n==null)return{};var l=xj(n,s),o,d;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(n);for(d=0;d<f.length;d++)o=f[d],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(l[o]=n[o])}return l}function xj(n,s){if(n==null)return{};var l={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(s.indexOf(o)>=0)continue;l[o]=n[o]}return l}function po(){return po=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var l=arguments[s];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(n[o]=l[o])}return n},po.apply(this,arguments)}function Up(n,s){var l=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);s&&(o=o.filter(function(d){return Object.getOwnPropertyDescriptor(n,d).enumerable})),l.push.apply(l,o)}return l}function xo(n){for(var s=1;s<arguments.length;s++){var l=arguments[s]!=null?arguments[s]:{};s%2?Up(Object(l),!0).forEach(function(o){gj(n,o,l[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(l)):Up(Object(l)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(l,o))})}return n}function gj(n,s,l){return s=bj(s),s in n?Object.defineProperty(n,s,{value:l,enumerable:!0,configurable:!0,writable:!0}):n[s]=l,n}function bj(n){var s=vj(n,"string");return typeof s=="symbol"?s:s+""}function vj(n,s){if(typeof n!="object"||!n)return n;var l=n[Symbol.toPrimitive];if(l!==void 0){var o=l.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 fg(n){return n&&n.map((s,l)=>qn.createElement(s.tag,xo({key:l},s.attr),fg(s.child)))}function Ti(n){return s=>qn.createElement(yj,po({attr:xo({},n.attr)},s),fg(n.child))}function yj(n){var s=l=>{var{attr:o,size:d,title:f}=n,p=pj(n,hj),h=d||l.size||"1em",x;return l.className&&(x=l.className),n.className&&(x=(x?x+" ":"")+n.className),qn.createElement("svg",po({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},l.attr,o,p,{className:x,style:xo(xo({color:n.color||l.color},l.style),n.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),f&&qn.createElement("title",null,f),n.children)};return zp!==void 0?qn.createElement(zp.Consumer,null,l=>s(l)):s(dg)}function mg(n){return Ti({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 Sj(n){return Ti({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 Hp(n){return Ti({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 jj(n){return Ti({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 Nj(n){return Ti({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 Aj(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 sf(n){return!!n?.system}function wj(n){const s=new Date(n);return`${s.getHours().toString().padStart(2,"0")}:${s.getMinutes().toString().padStart(2,"0")}`}function Vp(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function Cj({guildIconUrl:n,userAvatarUrl:s,label:l}){return!n&&!s?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:l,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 hg({message:n}){const s=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${Vp(n)}`:null,l=sf(n),o=l?"text-emerald-300":Aj(n.role);return r.jsxs(r.Fragment,{children:[n.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(mg,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(Cj,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:s})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:Vp(n)}),l?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:fj(n.roverColor,.14),children:n.roverId})]})}function pg(n){return sf(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 lf({message:n}){const s=sf(n);return r.jsxs("div",{className:pg(n),children:[r.jsx(hg,{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:wj(n.ts)})]})}function xg({message:n}){return r.jsxs("div",{className:`${pg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(hg,{message:n}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function gg({buttonId:n,count:s,goal:l,rewardNumber:o,rewardName:d,className:f=""}){return r.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",f].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," / ",l]}),r.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",d]})]})}const Ej=3e3,kj=3500,Mj="#2196f3";function Rj(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function rf({scale:n=1}){const s=Je(S=>S.alerts),l=Je(S=>S.session),{pushAlert:o}=gn(),d=tn(),[f,p]=m.useState(()=>Date.now());m.useEffect(()=>{function S(M={}){const j=Number(M.buttonId);if(!Number.isFinite(j)||j<1||j>4)return;const N=(Array.isArray(l?.buttonBox?.buttons)?l.buttonBox.buttons:[]).find(O=>Number(O?.id)===j)||{},C=Number.isFinite(M.count)?M.count:Number(N.count)||0,A=Number.isFinite(N.goal)?N.goal:0,R=Number.isFinite(N.rewardNumber)?N.rewardNumber:"?",k=typeof N.rewardName=="string"&&N.rewardName.trim()?N.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${j}`,kind:"buttonbox-active",lifetimeMs:kj,payload:{buttonId:j,count:C,goal:A,rewardNumber:R,rewardName:k}})}return d.on("buttonBox:increment",S),()=>{d.off("buttonBox:increment",S)}},[o,l?.buttonBox?.buttons,d]);const h=m.useMemo(()=>s.slice(-12).map(S=>({alert:S,key:Rj(S)})),[s]);m.useEffect(()=>{if(!h.length)return;const S=setInterval(()=>p(Date.now()),200);return()=>clearInterval(S)},[h.length]);const x=new Map;h.forEach(S=>{const M=f-(S.alert.receivedAt??S.alert.timestamp??0),j=Number.isFinite(S.alert.lifetimeMs)?S.alert.lifetimeMs:Ej;M<=j&&x.set(S.key,{...S,age:M})});const g=Array.from(x.values()).slice(-3);if(!g.length)return null;const b=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},y=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:y,style:b,children:g.map(S=>r.jsx(qj,{alert:S.alert},S.key))})}function $p(n){const s=typeof n=="string"?n.trim():"",l=/^#?([0-9a-fA-F]{6})$/.exec(s);if(!l)return null;const o=l[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function qj({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const d=n.payload;return r.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:r.jsx(gg,{buttonId:d.buttonId,count:d.count,goal:d.goal,rewardNumber:d.rewardNumber,rewardName:d.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return r.jsx(lf,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return r.jsx(xg,{message:n.payload});const s=$p(n.color)||$p(Mj),l=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:l,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 el={main:[-127,127],side:[-127,127],vacuum:[0,127]},ld={maxSpeed:500,baseSpeed:250,boostSpeed:400},Dd=100,of=[31,127],il=60,_d=8,Tj=250,Dj=4e3,Zr=.4,Gp=.2,Yp=.8,_j={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},gi={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"]},bg=[{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:Dd},{type:"oi",command:"dock"},{type:"pause",duration:Dd},{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 Bd(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Od(){return{main:0,side:0,vacuum:0}}function Bj(){return{enabled:!1,angle:null,config:null}}function uo(){return{note:il}}function pi(){return{active:!1,heat:0,overheated:!1}}function fo(){return{pttActive:!1}}const Fp={roverId:null,mode:"drive",drive:Bd(),aux:Od(),camera:Bj(),song:uo(),horn:pi(),mic:fo(),lastControlIntentAt:0,macros:bg,keymap:gi,inputs:{}};function Oj(n,s){switch(s.type){case"control/set-rover":return{...n,roverId:s.payload??null,drive:s.payload?n.drive:Bd(),aux:s.payload?n.aux:Od(),song:s.payload?n.song:uo(),horn:s.payload?n.horn:pi(),mic:s.payload?n.mic:fo(),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:l,speeds:o,source:d}=s.payload;return{...n,drive:{vector:l??n.drive.vector,speeds:o??n.drive.speeds,source:d??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 l=s.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[l]:{...n.inputs[l]??{},...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:Bd(),aux:Od(),song:uo(),horn:pi(),mic:fo(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||pi(),active:!!s.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||pi(),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||uo(),note:s.payload??il}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||fo(),pttActive:!!s.payload}};default:return n}}function rl(n,s,l){return typeof n!="number"||Number.isNaN(n)?s:Math.max(s,Math.min(l,n))}function ol(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function hn(n,s){return!Array.isArray(s)||s.length!==2?n:rl(n,s[0],s[1])}function Lj(n={}){const s=ol(n.x??0),l=ol(n.y??0);return{x:s,y:l,boost:!!n.boost}}function zj(n={},s={}){const l=Lj(n),o=typeof s.maxSpeed=="number"?s.maxSpeed:ld.maxSpeed,d=typeof s.baseSpeed=="number"?s.baseSpeed:ld.baseSpeed,f=typeof s.boostSpeed=="number"?s.boostSpeed:ld.boostSpeed,p=l.boost?f:d,h=l.y*p,x=l.x*p;return{vector:l,speeds:{left:rl(Math.round(h+x),-o,o),right:rl(Math.round(h-x),-o,o)}}}function Uj(n){const s=Array.isArray(n)?n:[],l=String.fromCharCode(...s);if(typeof btoa=="function")return btoa(l);if(typeof Buffer<"u")return Buffer.from(s).toString("base64");throw new Error("No base64 encoder available")}function Xp(n){return new Promise(s=>setTimeout(s,n))}function Hj(n={}){const{driveTransform:s,auxTransform:l}=n,o=tn(),d=Je(O=>O.session),f=d?.assignment?.roverId,p=m.useMemo(()=>!f||!Array.isArray(d?.roster)?null:d.roster.find(O=>String(O.id)===String(f))||null,[f,d?.roster]),h=m.useMemo(()=>!p?.cameraServo||!p.cameraServo.enabled?null:p.cameraServo,[p]),x=m.useMemo(()=>!p?.nightVision||!p.nightVision.enabled?null:p.nightVision,[p]),g=m.useMemo(()=>!p?.horn||!p.horn.enabled?null:p.horn,[p]),b=m.useMemo(()=>p?.nightVision?.state??null,[p]),y=m.useCallback((O,X)=>{f&&o.emit("command",{roverId:f,...O},X)},[o,f]),S=m.useCallback(()=>{f&&y({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[y,f]),M=m.useCallback(O=>{if(!f)return null;const X={left:hn(O?.left??0,[-500,500]),right:hn(O?.right??0,[-500,500])},D=s?s(X):X,H={left:hn(D?.left??0,[-500,500]),right:hn(D?.right??0,[-500,500])};return y({type:"drive",data:{driveDirect:H}}),H},[s,y,f]),j=m.useCallback(({main:O=0,side:X=0,vacuum:D=0}={})=>{if(!f)return null;const H={main:hn(O,el.main),side:hn(X,el.side),vacuum:hn(D,el.vacuum)},K=l?l(H):H,$={main:hn(K?.main??0,el.main),side:hn(K?.side??0,el.side),vacuum:hn(K?.vacuum??0,el.vacuum)};return y({type:"motors",data:{motorPwm:$}}),$},[l,y,f]),E=m.useCallback(O=>!f||!h?null:(y({type:"servo",data:{servo:{angle:O}}}),O),[y,f,h]),N=m.useCallback(O=>{if(!f)return!1;const X=Array.isArray(O)?O:typeof O=="string"?_j[O]:null;return X?(y({type:"raw",data:{raw:Uj(X)}}),S(),!0):!1},[y,S,f]),C=m.useCallback(async O=>{if(!(!O||!Array.isArray(O.steps)||!f))for(const X of O.steps){if(!f)break;switch(X.type){case"oi":N(X.command);break;case"drive":M(X.speeds??{left:0,right:0});break;case"motors":j(X.values??{});break;case"servo":E(X.angle);break;case"pause":await Xp(X.duration??Dd);break}if(X.delay||X.delayMs){const D=X.delayMs??X.delay;typeof D=="number"&&D>0&&await Xp(D)}}},[f,N,M,j,E]),A=m.useCallback((O="toggle")=>!f||!x?null:(y({type:"nightVision",data:{nightVision:{action:O}}}),O),[y,x,f]),R=m.useCallback(O=>f?(y({type:"horn",data:{horn:O}}),O):null,[y,f]),k=m.useCallback((O=[],X={})=>{if(!f)return null;const H=(Array.isArray(O)&&O.length>0?O:[{note:il,duration:_d}]).slice(0,16).map(K=>({note:hn(Math.round(K?.note??il),of),duration:hn(Math.round(K?.duration??_d),[1,255])}));return y({type:"song",data:{song:{notes:H,slot:X.slot,loop:X.loop}}}),H},[y,f]);return m.useMemo(()=>({roverId:f,rosterEntry:p,servoConfig:h,nightVision:x,nightVisionState:b,horn:g,emitCommand:y,enableSensorStream:S,sendDriveDirect:M,sendAuxMotors:j,sendServoAngle:E,sendOiCommand:N,sendNightVision:A,sendHorn:R,sendSong:k,runMacroSteps:C}),[f,p,h,x,b,g,y,S,M,j,E,N,A,R,C])}const Vj={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Qp={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function Di(n){if(typeof n!="string")return"";const s=n.toLowerCase();return Vj[s]??s}function $j(n){const s=Di(n);if(!s)return null;if(Qp[s])return Qp[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 vg(n){const s=Di(n);return s?`key:${s}`:null}function Gj(n){const s=$j(n);return s?`code:${s}`:null}function Kp(n){const s=new Set,l=vg(n?.key??"");l&&s.add(l);const o=n?.code?`code:${n.code}`:null;return o&&s.add(o),Array.from(s)}function Yj(n={}){return Object.fromEntries(Object.entries(n).map(([s,l])=>{const o=Array.isArray(l)?l:[l],d=new Set;return o.forEach(f=>{const p=vg(String(f));p&&d.add(p);const h=Gj(String(f));h&&d.add(h)}),[s,d]}))}function Nn(n){const s=Di(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 Rn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:100,tiltIntervalMs:110}},ia={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}]}}},Oa={activeSignature:null,profiles:{},defaults:{profile:ia}},us={waveform:"saw",freqs:[440,550,660,0]},rt={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},os=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],Fj={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function Zp(){return os.reduce((n,s)=>(n[s.key]={cap:1,clearSec:0},n),{})}function Ip(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function Xj(n,s={}){const l=Je(C=>C.session),f=(ml(n)?.sensors||{})?.wheelOvercurrents||{},p=m.useMemo(()=>({...Fj,...s.config||{}}),[s.config]),[h,x]=m.useState(()=>Zp()),g=m.useRef(0),b=m.useRef(f);m.useEffect(()=>{b.current=f||{}},[f]),m.useEffect(()=>{x(Zp()),g.current=0},[n]);const y=m.useMemo(()=>os.some(C=>C.motors.some(A=>!!f?.[A])),[f]),S=m.useMemo(()=>Object.values(h||{}).some(C=>(Number.isFinite(C?.cap)?C.cap:1)<.999),[h]),M=!!n&&(y||S);m.useEffect(()=>{if(!M)return;g.current=typeof performance<"u"?performance.now():Date.now();const C=setInterval(()=>{const A=typeof performance<"u"?performance.now():Date.now(),R=Math.max(0,A-g.current);g.current=A;const k=Math.min(.25,R/1e3);k<=0||x(O=>{let X=!1;const D={},H=Number.isFinite(p.downRatePerSec)?Math.max(0,p.downRatePerSec):0,K=Number.isFinite(p.upRatePerSec)?Math.max(0,p.upRatePerSec):0,$=Number.isFinite(p.releaseDelaySec)?Math.max(0,p.releaseDelaySec):0;return os.forEach(Y=>{const ee=O[Y.key]||{cap:1,clearSec:0},oe=Number.isFinite(ee.cap)?ee.cap:1,ce=Number.isFinite(ee.clearSec)?ee.clearSec:0,z=Y.motors.some(se=>!!b.current?.[se]),q=z?0:ce+k,L=!z&&q>=$,Z=Ip(z?oe-H*k:L?oe+K*k:oe);(Math.abs(Z-oe)>1e-4||Math.abs(q-ce)>1e-4)&&(X=!0),D[Y.key]={cap:Z,clearSec:q}}),X?D:O})},100);return()=>clearInterval(C)},[p.downRatePerSec,p.releaseDelaySec,p.upRatePerSec,n,M]);const j=m.useMemo(()=>{const C=os.reduce((A,R)=>{const k=h?.[R.key],O=Number.isFinite(k?.cap)?k.cap:1;return A[R.key]=Ip(O),A},{});return{perGroup:C,drive:{left:C.drive??1,right:C.drive??1},aux:{main:C.aux??1,side:C.aux??1,vacuum:1}}},[h]),E=m.useMemo(()=>{const C={};os.forEach(R=>{R.motors.forEach(k=>{C[k]=!!f?.[k]})});const A=os.reduce((R,k)=>(R[k.key]=k.motors.some(O=>!!f?.[O]),R),{});return{motors:C,groups:A}},[f]),N=l?.role==="admin"||l?.role==="lockdown"||l?.role==="lockdown-admin";return m.useMemo(()=>({caps:h,overcurrent:E,scales:j,isActive:(j?.drive?.left??1)<1||(j?.drive?.right??1)<1||(j?.aux?.main??1)<1||(j?.aux?.side??1)<1,config:p,adminImmune:N}),[h,E,j,p,N])}function Qj(n={},s,l=!1){if(l||!s?.drive)return n;const o=typeof s.drive.left=="number"?s.drive.left:1,d=typeof s.drive.right=="number"?s.drive.right:1;return o>=.999&&d>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*d)}}function Kj(n={},s,l=!1){if(l||!s?.aux)return n;const o=typeof s.aux.main=="number"?s.aux.main:1,d=typeof s.aux.side=="number"?s.aux.side:1,f=typeof s.aux.vacuum=="number"?s.aux.vacuum:1;return o>=.999&&d>=.999&&f>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*d),vacuum:Math.round((n.vacuum??0)*f)}}const yg=m.createContext(null);function Jp(n){return Object.fromEntries(Object.entries(n||{}).map(([s,l])=>[s,Array.isArray(l)?[...l]:[]]))}function Zj(n,s){if(!n)return s;const l=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return rl(s,l,o)}function Ij(n=[]){if(!Array.isArray(n)||n.length<3)return n;const s=n.slice(-3),[l,o,d]=s,f=l?.type==="drive"&&Number(l?.speeds?.left)===-300&&Number(l?.speeds?.right)===-300,p=o?.type==="pause"&&Number(o?.duration)===600,h=d?.type==="drive"&&Number(d?.speeds?.left)===0&&Number(d?.speeds?.right)===0;return!f||!p||!h?n:n.slice(0,-3)}function Jj({children:n}){const[s,l]=m.useReducer(Oj,Fp),o=m.useRef(null),d=m.useRef(!1),f=m.useRef(Fp.camera.angle),p=m.useRef(null),h=m.useRef(0),x=m.useRef(0),{value:g,save:b}=Ge("controls",{keymap:gi,macros:bg}),{value:y}=Ge("page",{driveMacroBackoffEnabled:!0}),{value:S}=Ge("horn",us),M=typeof y?.driveMacroBackoffEnabled=="boolean"?y.driveMacroBackoffEnabled:!0,j=Je(ie=>ie.session),{homeAssistantSetState:E}=gn(),N=j?.assignment?.roverId??null,C=Xj(N),A=m.useCallback(ie=>Qj(ie,C.scales,C.adminImmune),[C.adminImmune,C.scales]),R=m.useCallback(ie=>Kj(ie,C.scales,C.adminImmune),[C.adminImmune,C.scales]),k=Hj({driveTransform:A,auxTransform:R}),O=m.useCallback(()=>{const xe=(j?.homeAssistant?.entities||[]).filter(le=>(le.type==="light"||le.type==="switch")&&le.available!==!1&&le.state!=="on");if(xe.length===0){d.current=!1;return}d.current=!0,xe.forEach(le=>{E(le.id,"on").catch(()=>{})}),d.current=!1},[j?.homeAssistant?.entities,E]);m.useEffect(()=>{l({type:"control/set-rover",payload:k.roverId})},[k.roverId]),m.useEffect(()=>{const ie=o.current;o.current=s.mode,ie!=="drive"&&s.mode==="drive"&&j?.homeAssistant?.entities?O():ie!=="drive"&&s.mode==="drive"&&(d.current=!0)},[s.mode,j?.homeAssistant?.entities,O]),m.useEffect(()=>{d.current&&j?.homeAssistant?.entities&&O()},[j?.homeAssistant?.entities,O]),m.useEffect(()=>{const ie={...gi,...g?.keymap||{}};l({type:"control/set-keymap",payload:ie}),g?.macros&&l({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const ie=k.servoConfig;if(!ie){l({type:"control/set-camera-config",payload:{config:null}}),f.current=null;return}const xe=typeof ie.minAngle=="number"?ie.minAngle:-45,le=typeof ie.maxAngle=="number"?ie.maxAngle:45,J=typeof ie.homeAngle=="number"?ie.homeAngle:(xe+le)/2,ge=typeof f.current=="number"?rl(f.current,xe,le):null,Ne=ge??rl(J,xe,le);l({type:"control/set-camera-config",payload:{config:ie,angle:Ne}}),f.current=Ne},[k.servoConfig]),m.useEffect(()=>{f.current=typeof s.camera.angle=="number"?s.camera.angle:f.current},[s.camera.angle]),m.useEffect(()=>{k.roverId&&k.enableSensorStream()},[k.roverId,k.enableSensorStream]);const X=m.useCallback(ie=>{l({type:"control/set-mode",payload:ie})},[]),D=m.useCallback(()=>{l({type:"control/record-intent"})},[]),H=m.useRef(s.drive.speeds),K=m.useRef(s.aux),$=m.useMemo(()=>JSON.stringify(C.scales),[C.scales]),Y=m.useRef(0),ee=m.useRef(0);m.useEffect(()=>{H.current=s.drive.speeds},[s.drive.speeds]),m.useEffect(()=>{K.current=s.aux},[s.aux]),m.useEffect(()=>{if(!k.roverId||C.adminImmune||!C.isActive)return;const ie=Math.max(0,Number(C?.config?.outputRateMs)||0),xe=typeof performance<"u"?performance.now():Date.now(),le=H.current||{left:0,right:0},J=K.current||{main:0,side:0,vacuum:0},ge=!!(le.left||le.right),Ne=!!(J.main||J.side||J.vacuum);!ge&&!Ne||(ge&&xe-Y.current>=ie&&(Y.current=xe,k.sendDriveDirect(le)),Ne&&xe-ee.current>=ie&&(ee.current=xe,k.sendAuxMotors(J)))},[$,C.adminImmune,C.config,C.isActive,k]);const oe=m.useCallback((ie,xe={})=>{const le=zj(ie,xe.speedOptions);l({type:"control/update-drive",payload:{...le,source:xe.source??null}}),D(),k.sendDriveDirect(le.speeds)},[k,D]),ce=m.useCallback((ie={})=>{const xe=k.sendAuxMotors(ie)??ie;l({type:"control/set-aux-motors",payload:xe}),D()},[k,D]),z=m.useCallback((ie,xe)=>{if(!ie)return!1;const le=Di(xe);if(!le)return!1;const J=Jp(s.keymap);return J[ie]=[le],l({type:"control/set-keymap",payload:J}),b(ge=>({...ge??{},keymap:J})),!0},[s.keymap,b]),q=m.useCallback(()=>{const ie=Jp(gi);l({type:"control/set-keymap",payload:ie}),b(xe=>({...xe??{},keymap:ie}))},[b]),L=m.useCallback(ie=>{if(!k.servoConfig)return;const xe=Zj(k.servoConfig,ie);l({type:"control/set-camera-angle",payload:xe}),k.sendServoAngle(xe),f.current=xe,D()},[k,D]),Z=m.useCallback((ie=0)=>{const xe=k.servoConfig;if(!xe)return;const le=typeof ie=="number"&&ie!==0?ie:xe.nudgeDegrees||1,J=typeof f.current=="number"?f.current:typeof xe.homeAngle=="number"?xe.homeAngle:0;L(J+le)},[k.servoConfig,L]),se=m.useCallback(()=>{const ie=k.servoConfig;if(!ie)return;const xe=typeof ie.homeAngle=="number"?ie.homeAngle:typeof ie.minAngle=="number"&&typeof ie.maxAngle=="number"?(ie.minAngle+ie.maxAngle)/2:0;L(xe)},[k.servoConfig,L]),ue=m.useCallback(async ie=>{const xe=s.macros.find(J=>J.id===ie)||null;if(!xe)return;let le=xe;ie==="drive-sequence"?(O(),j?.homeAssistant?.entities||(d.current=!0),D(),M||(le={...xe,steps:Ij(xe.steps)})):ie==="seek-dock"&&D(),await k.runMacroSteps(le)},[M,k,D,j?.homeAssistant?.entities,s.macros,O]),T=m.useCallback(()=>{l({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),k.sendDriveDirect({left:0,right:0}),k.sendAuxMotors({main:0,side:0,vacuum:0})},[k]),V=m.useCallback(ie=>{k.sendOiCommand(ie)},[k]),te=m.useCallback(ie=>{k.roverId&&k.emitCommand({type:"sensorStream",data:{sensorStream:{enable:ie}}})},[k]),ae=m.useCallback(ie=>{if(k.nightVision){if(typeof ie=="boolean"){const xe=ie?"off":"on";k.sendNightVision(xe)}else k.sendNightVision("toggle");D()}},[k,D]),he=m.useCallback(()=>{ae()},[ae]),re=m.useCallback(ie=>{const xe=typeof ie=="number"?ie:il;return l({type:"control/set-song-note",payload:xe}),xe},[]),de=m.useCallback((ie,xe)=>k.sendSong(ie,xe),[k]),ve=m.useMemo(()=>{const ie=S??us,xe=ie.waveform==="sine"?"sine":"saw",J=[...Array.isArray(ie.freqs)?ie.freqs:us.freqs,0,0,0,0].slice(0,4).map(ge=>{const Ne=Number(ge);return Number.isFinite(Ne)?Ne<=0?0:Math.min(5e3,Math.round(Ne)):0});return{waveform:xe,freqs:J}},[S]),fe=m.useCallback(()=>{if(!k.horn)return;if(s.horn?.overheated||(s.horn?.heat??0)>=1||s.horn?.active)return!1;const ie=Date.now();return k.sendHorn({action:"start",...ve}),l({type:"control/set-horn-active",payload:!0}),h.current=ie,x.current=ie,p.current&&(clearTimeout(p.current),p.current=null),p.current=setTimeout(()=>{pe()},Dj),D(),!0},[l,ve,k,D,s.horn?.active,s.horn?.heat,s.horn?.overheated]),pe=m.useCallback(()=>{if(!k.horn)return;k.sendHorn({action:"stop"}),l({type:"control/set-horn-active",payload:!1}),p.current&&(clearTimeout(p.current),p.current=null);const ie=Date.now(),xe=h.current||ie,le=Math.max(0,ie-xe);if(h.current=0,le>0){const J=s.horn?.heat??0,ge=le/1e3*Zr;let Ne=Math.max(0,Math.min(1,J+ge)),pt=s.horn?.overheated??!1;Ne>=1&&(Ne=1,pt=!0),l({type:"control/set-horn-heat",payload:{heat:Ne,overheated:pt}})}},[l,k,s.horn?.heat,s.horn?.overheated,Zr]),Le=m.useRef({active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}),ke=m.useRef(pe);m.useEffect(()=>{Le.current={active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}},[s.horn?.active,s.horn?.heat,s.horn?.overheated]),m.useEffect(()=>{ke.current=pe},[pe]);const Ce=!!s.horn?.active||(s.horn?.heat??0)>0||!!s.horn?.overheated;m.useEffect(()=>{if(!Ce)return;const xe=setInterval(()=>{const le=Date.now(),J=x.current||le;x.current=le;const ge=Math.min(1e3,Math.max(0,le-J))/1e3,Ne=Le.current,pt=Ne.heat??0,Ue=!!Ne.active,ct=!!Ne.overheated,ut=ge*(Ue?Zr:-Gp);let bt=Math.max(0,Math.min(1,pt+ut)),Mt=ct;bt>=1?(bt=1,Mt=!0,Ue&&ke.current()):Mt&&bt<=Yp&&(Mt=!1),(bt!==pt||Mt!==ct)&&l({type:"control/set-horn-heat",payload:{heat:bt,overheated:Mt}})},100);return()=>clearInterval(xe)},[l,Ce,Gp,Yp,Zr]);const _e=m.useCallback((ie,xe)=>{l({type:"control/register-input-state",payload:{source:ie,state:xe}})},[]),ze=m.useCallback(ie=>{l({type:"control/set-mic-ptt",payload:!!ie})},[]),ht=m.useMemo(()=>({state:s,dispatch:l,pipeline:k,overcurrentLimiter:C,actions:{setMode:X,setDriveVector:oe,setAuxMotors:ce,setServoAngle:L,nudgeServo:Z,goServoHome:se,runMacro:ue,stopAllMotion:T,sendOiCommand:V,setSensorStream:te,setNightVision:ae,toggleNightVision:he,updateKeyBinding:z,resetKeyBindings:q,registerInputState:_e,setSongNote:re,sendSong:de,startHorn:fe,stopHorn:pe,setMicPttActive:ze}}),[s,k,C,X,oe,ce,L,Z,se,ue,T,V,te,ae,he,z,q,_e,re,de,fe,pe,ze]);return r.jsx(yg.Provider,{value:ht,children:n})}function Bt(){const n=m.useContext(yg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const Pj="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=",Sg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function Wj({children:n}){const s=tn(),l=Je(z=>z.session),{pushAlert:o}=gn(),{value:d}=Ge("audio",rt),[f,p]=m.useState([]),[h,x]=m.useState([]),[g,b]=m.useState(!1),y=m.useRef(null),S=m.useRef(null),M=m.useRef(null),j=m.useRef(new Map),E=m.useRef(new Map),N=m.useRef({isTyping:!1,lastSent:0}),C=Number.isFinite(d?.masterVolume)?d.masterVolume:rt.masterVolume,A=Number.isFinite(d?.alertVolume)?d.alertVolume:rt.alertVolume,R=Math.max(0,Math.min(1,C*A)),k=m.useCallback(()=>{const z=Array.from(j.current.values()).sort((q,L)=>q.lastUpdate-L.lastUpdate).map(q=>q.payload);x(z)},[]),O=m.useCallback(z=>!z||typeof z!="object"?null:z.typingId?z.typingId:z.fromDiscord?`discord:${z.discordUserId||z.discordUserName||z.nickname||"unknown"}`:`socket:${z.socketId||z.nickname||"unknown"}`,[]);m.useEffect(()=>{M.current=new Audio(Pj),M.current.volume=R,M.current.load()},[R]);const X=m.useCallback(()=>{const z=M.current;z&&(z.volume=R,z.currentTime=0,z.play().catch(()=>{}))},[R]);m.useEffect(()=>{function z(q={}){p(L=>[...L.slice(-99),q]),!(q?.socketId&&l?.socketId&&q.socketId===l.socketId)&&(X(),o?.({kind:"chat",payload:q,id:`chat-${q.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return s.on("chat:message",z),()=>{s.off("chat:message",z)}},[X,l?.socketId,s]),m.useEffect(()=>{function z(q={}){const L=O(q);if(!L)return;const Z=Date.now();if(q?.socketId&&l?.socketId&&q.socketId===l.socketId){q.isTyping||(j.current.delete(L),k());return}if(q.isTyping){j.current.set(L,{payload:q,expiresAt:Z+6e3,lastUpdate:Z});const se=E.current.get(L)||0;Z-se>=2500&&(E.current.set(L,Z),o?.({kind:"chat-typing",payload:q,id:`chat-typing-${L}-${q.id||Math.random().toString(36).slice(2)}`,receivedAt:Z}))}else j.current.delete(L);k()}return s.on("chat:typing",z),()=>{s.off("chat:typing",z)}},[o,k,O,l?.socketId,s]),m.useEffect(()=>{const z=setInterval(()=>{const q=Date.now();let L=!1;j.current.forEach((Z,se)=>{Z.expiresAt<=q&&(j.current.delete(se),L=!0)}),L&&k()},2e3);return()=>clearInterval(z)},[k]),m.useEffect(()=>{function z(q=[]){Array.isArray(q)&&p(L=>{if(L.length===0)return q.slice(-100);const Z=new Set(q.map(ue=>ue?.id));return[...q,...L.filter(ue=>ue?.id&&!Z.has(ue.id))].slice(-100)})}return s.on("chat:init",z),()=>{s.off("chat:init",z)}},[s]);const D=m.useCallback(z=>{const q=!!z,L=Date.now(),Z=N.current,se=!q&&Z.isTyping;!(q&&(!Z.isTyping||L-Z.lastSent>=3500))&&!se||(N.current={isTyping:q,lastSent:L},s.emit("chat:typing",{isTyping:q}))},[s]),H=m.useCallback((z,q=null)=>new Promise((L,Z)=>{s.emit("chat:send",{text:z,tts:q},(se={})=>{se.error?Z(new Error(se.error)):L(se)})}),[s]),K=m.useCallback((z,q={})=>{(q?.target==="hud"?"hud":"panel")==="hud"?S.current=z:y.current=z},[]),$=m.useCallback(()=>{b(!0),(S.current||y.current)?.focus()},[]),Y=m.useCallback(()=>{b(!1),S.current?.blur(),y.current?.blur()},[]),ee=m.useCallback(()=>b(!0),[]),oe=m.useCallback(()=>b(!1),[]),ce=m.useMemo(()=>({messages:f,sendMessage:H,focusChat:$,blurChat:Y,registerInputRef:K,onInputFocus:ee,onInputBlur:oe,setTypingActive:D,typing:h,isChatFocused:g,selfSocketId:l?.socketId||null}),[Y,$,g,f,oe,ee,K,H,l?.socketId,D,h]);return r.jsx(Sg.Provider,{value:ce,children:n})}function cf(){const n=m.useContext(Sg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let jg=!1;function id(n){jg=!!n}function Pp(){return jg}const eN=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function Ng(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 l=n.type?n.type.toLowerCase():"";return eN.has(l)}function tN(){return typeof document>"u"?!1:Ng(document.activeElement)}const rd="keyboard",od={x:0,y:0,boost:!1},cd={main:0,side:0,vacuum:0},Wp=of[0],ex=of[1],uf=5,Si=500,ji=1,df=100;function ud(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(0,Math.min(500,l)):s}function nN(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(uf,Math.min(Si,l)):s}function Ag(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(ji,Math.min(df,l)):s}function aN(n){const l=(Ag(n,n)-ji)/(df-ji),o=Si-l*(Si-uf);return Math.round(o)}function sN(n){const s=nN(n,n),l=(Si-s)/(Si-uf),o=ji+l*(df-ji);return Math.round(o)}function lN(n){return Ng(n?.target)}function mt(n,s){if(!n||n.size===0)return!1;for(const l of s)if(n.has(l))return!0;return!1}function iN(n,s){const l=mt(s.driveForward,n),o=mt(s.driveBackward,n),d=mt(s.driveLeft,n),f=mt(s.driveRight,n),p=mt(s.boostModifier,n),h=mt(s.slowModifier,n);let x=0;l&&!o?x=1:o&&!l&&(x=-1);let g=0;d&&!f?g=-1:f&&!d&&(g=1);const b=h?.4:1;return{x:g*b,y:x*b,boost:p&&!h}}function rN(n,s){if(mt(s.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=mt(s.auxMainForward,n)?127:mt(s.auxMainReverse,n)?-127:0,d=mt(s.auxSideForward,n)?127:mt(s.auxSideReverse,n)?-70:0,f=mt(s.auxVacuumFast,n)?127:mt(s.auxVacuumSlow,n)?50:0;return{main:o,side:d,vacuum:f}}function oN(){const{state:n,actions:{setMode:s,setDriveVector:l,setAuxMotors:o,nudgeServo:d,runMacro:f,stopAllMotion:p,registerInputState:h,toggleNightVision:x,startHorn:g,stopHorn:b,setMicPttActive:y,setSongNote:S,sendSong:M}}=Bt(),j=Je(re=>re.session),{homeAssistantSetState:E}=gn(),{focusChat:N,blurChat:C,isChatFocused:A}=cf(),{value:R}=Ge("inputs",Rn),k=m.useMemo(()=>Yj(n.keymap),[n.keymap]),O=m.useMemo(()=>{const re=new Set;return Object.values(k).forEach(de=>{de&&de.forEach(ve=>re.add(ve))}),re},[k]),X=m.useMemo(()=>{const re=Rn.keyboard,de=R?.keyboard??{};return{baseSpeed:ud(de.baseSpeed,re.baseSpeed),turboSpeed:ud(de.turboSpeed,re.turboSpeed),precisionSpeed:ud(de.precisionSpeed,re.precisionSpeed)}},[R?.keyboard]),D=m.useMemo(()=>{const re=Rn.keyboard,de=R?.keyboard??{},ve=Ag(typeof de.tiltSpeed=="number"?de.tiltSpeed:typeof de.tiltIntervalMs=="number"?sN(de.tiltIntervalMs):re.tiltSpeed,re.tiltSpeed);return aN(ve)},[R?.keyboard]),H=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),K=m.useRef(new Set),$=m.useRef(od),Y=m.useRef(cd),ee=m.useRef(null),oe=m.useRef(null),ce=m.useRef(!1),z=m.useCallback(()=>{const re=new Set(K.current);mt(k.boostModifier,re);const ve=mt(k.slowModifier,re)?{baseSpeed:X.precisionSpeed,boostSpeed:X.precisionSpeed}:{baseSpeed:X.baseSpeed,boostSpeed:X.turboSpeed},fe=iN(re,k),pe=rN(re,k);(fe.x!==$.current.x||fe.y!==$.current.y||fe.boost!==$.current.boost)&&($.current=fe,l(fe,{source:rd,speedOptions:ve})),(pe.main!==Y.current.main||pe.side!==Y.current.side||pe.vacuum!==Y.current.vacuum)&&(Y.current=pe,o(pe)),h(rd,{keys:Array.from(re),vector:fe,aux:pe})},[k,X,h,o,l]),q=m.useCallback(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),L=m.useCallback(()=>{const re=new Set(K.current),de=mt(k.cameraUp,re),ve=mt(k.cameraDown,re);return(de?1:0)-(ve?1:0)},[k]),Z=m.useCallback(()=>{if(L()===0){q();return}if(ee.current)return;const de=()=>{const ve=L();if(ve===0){q();return}d(ve*H),ee.current=setTimeout(de,D)};ee.current=setTimeout(de,0)},[L,d,D,H,q]),se=m.useCallback(()=>{oe.current&&(clearTimeout(oe.current),oe.current=null)},[]),ue=m.useCallback(()=>{const re=new Set(K.current),de=mt(k.songNoteUp,re),ve=mt(k.songNoteDown,re);return(de?1:0)-(ve?1:0)},[k]),T=m.useCallback(re=>{if(re===0)return;let ve=(typeof n.song?.note=="number"?n.song.note:il)+re;ve>ex?ve=Wp:ve<Wp&&(ve=ex);const fe=S(ve);M([{note:fe,duration:_d}],{slot:0})},[M,S,n.song?.note]),V=m.useCallback(()=>{if(ue()===0){se();return}if(oe.current)return;const de=()=>{const ve=ue();if(ve===0){se();return}T(ve),oe.current=setTimeout(de,Tj)};oe.current=setTimeout(de,0)},[ue,se,T]),te=m.useCallback(()=>{K.current.clear(),$.current=od,Y.current=cd,q(),se(),ce.current&&(ce.current=!1,b()),y(!1),p(),h(rd,{keys:[],vector:od,aux:cd})},[h,y,p,b,q,se]),ae=m.useCallback(re=>{const de=j?.homeAssistant;if(!de?.enabled||!de?.connected||de?.lightPolicy?.locked||de?.lightPolicy?.lockedOn)return;const fe=(de.entities||[]).filter(pe=>(pe.type==="light"||pe.type==="switch")&&pe.available!==!1&&pe.state!=="unavailable");if(fe.length!==0){if(re==="on"){const pe=fe.find(Le=>Le.state!=="on");pe&&E(pe.id,"on").catch(()=>{});return}if(re==="off")for(let pe=fe.length-1;pe>=0;pe-=1){const Le=fe[pe];if(Le.state==="on"){E(Le.id,"off").catch(()=>{});break}}}},[E,j?.homeAssistant]);m.useEffect(()=>{function re(fe){if(Pp()||lN(fe))return;const pe=Kp(fe);if(pe.length===0)return;const Le=new Set(pe);if(mt(k.chatFocus,Le)){fe.preventDefault(),te(),A||N();return}pe.some(Ce=>O.has(Ce))&&fe.preventDefault();const ke=pe.filter(Ce=>!K.current.has(Ce));if(ke.forEach(Ce=>K.current.add(Ce)),ke.length>0)if(ke.some(Ce=>k.driveMacro?.has(Ce)))s("drive"),f("drive-sequence");else if(ke.some(Ce=>k.dockMacro?.has(Ce)))s("dock"),f("seek-dock");else if(ke.some(Ce=>k.nightVisionToggle?.has(Ce)))x();else if(ke.some(Ce=>k.hornHonk?.has(Ce))){if(!ce.current){const Ce=g();ce.current=!!Ce}}else ke.some(Ce=>k.micPtt?.has(Ce))?y(!0):ke.some(Ce=>k.homeAssistantOn?.has(Ce))?ae("on"):ke.some(Ce=>k.homeAssistantOff?.has(Ce))&&ae("off");Z(),V(),z()}function de(fe){if(Pp())return;Kp(fe).forEach(Le=>K.current.delete(Le)),ce.current&&!mt(k.hornHonk,K.current)&&(ce.current=!1,b()),mt(k.micPtt,K.current)||y(!1),Z(),V(),z()}function ve(){te()}return window.addEventListener("keydown",re,{capture:!0}),window.addEventListener("keyup",de,{capture:!0}),window.addEventListener("blur",ve),()=>{window.removeEventListener("keydown",re,{capture:!0}),window.removeEventListener("keyup",de,{capture:!0}),window.removeEventListener("blur",ve)}},[O,C,z,Z,V,N,A,k.chatFocus,k.dockMacro,k.driveMacro,k.hornHonk,k.micPtt,te,f,y,s,p,se,g,b,ae]);const he=m.useRef(te);return m.useEffect(()=>{he.current=te},[te]),m.useEffect(()=>{he.current()},[n.roverId]),m.useEffect(()=>{ce.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{q(),se()},[q,se]),null}const cN=1.6;function wg(n){if(!n)return"unknown::none::0::0";const s=n.id||"unknown",l=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,d=Array.isArray(n.buttons)?n.buttons.length:0;return`${s}::${l}::${o}::${d}`}function uN(n){return JSON.parse(JSON.stringify(n??{}))}function Cg(n,s){const l=uN(s);return l.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},l}function cs(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function fi(n,s){if(!n)return 0;const l=Math.abs(n);return s==="expo"?Math.sign(n)*Math.pow(l,cN):n}function dd(n,s){const l=Math.abs(n);if(l<=s)return 0;const o=(l-s)/(1-s);return Math.sign(n)*o}function dN(n,s,l){const o=Math.hypot(n,s);if(o<=l)return{x:0,y:0};const f=(o-l)/(1-l)/o;return{x:n*f,y:s*f}}function go(n,s){if(!n||!Array.isArray(n.axes))return null;const l=n.axes[s];return Number.isFinite(l)?cs(l):null}function Ld(n,s){if(!n||!Array.isArray(n.buttons))return null;const l=n.buttons[s];if(!l)return null;const o=typeof l.value=="number"?l.value:l.pressed?1:0;return{pressed:!!(l.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function fd(n,s=[]){for(const l of s)if(l){if(l.kind==="axis"){const o=go(n,l.index);if(o===null)continue;return{value:l.invert?-o:o,source:l}}if(l.kind==="buttonAxis"){const o=Ld(n,l.index);if(!o)continue;return{value:cs(o.value),source:l}}}return{value:0,source:null}}function fN(n,s=[]){for(const l of s){if(!l||l.kind!=="axisPair")continue;const o=go(n,l.x),d=go(n,l.y);if(o===null||d===null)continue;const f=l.invertX?-o:o,p=l.invertY?-d:d;return{x:f,y:p,source:l}}return{x:0,y:0,source:null}}function ss(n,s=[]){for(const l of s)if(l){if(l.kind==="button"){const o=Ld(n,l.index);if(!o)continue;return{pressed:o.pressed,source:l}}if(l.kind==="axisButton"){const o=go(n,l.index);if(o===null)continue;const d=l.direction||1,f=typeof l.threshold=="number"?l.threshold:.6;return{pressed:o*d>f,source:l}}if(l.kind==="buttonAxis"){const o=Ld(n,l.index);if(!o)continue;return{pressed:o.value>.5,source:l}}}return{pressed:!1,source:null}}function Eg(n,s){const l=s?.bindings??{},o=s?.calibration??{},d=l.drive??{},f=fN(n,d.sources);let p=cs(f.x),h=cs(f.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=dN(p,h,x);p=fi(g.x,o.driveCurve),h=fi(g.y,o.driveCurve);const b=l.cameraTilt??{},y=fd(n,b.sources),S=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let M=dd(cs(y.value),S);M=fi(M,o.cameraCurve);const j=Math.min(Math.max(o.auxDeadzone??.05,0),.6),E=l.mainBrush??{},N=fd(n,E.sources);let C=dd(cs(N.value),j);C=fi(C,o.auxCurve);const A=l.sideBrush??{},R=fd(n,A.sources);let k=dd(cs(R.value),j);k=fi(k,o.auxCurve);const O=ss(n,l.vacuum?.sources),X=ss(n,l.allAux?.sources),D=ss(n,l.mainReverse?.sources),H=ss(n,l.sideReverse?.sources),K=ss(n,l.driveMacro?.sources),$=ss(n,l.dockMacro?.sources),Y=ss(n,l.nightVisionToggle?.sources);return{driveVector:{x:p,y:h,boost:!1},cameraAxis:M,auxAxis:{main:C,side:k},buttons:{vacuum:O.pressed,allAux:X.pressed,mainReverse:D.pressed,sideReverse:H.pressed,driveMacro:K.pressed,dockMacro:$.pressed,nightVisionToggle:Y.pressed},sources:{drive:f.source,cameraTilt:y.source,mainBrush:N.source,sideBrush:R.source,vacuum:O.source,allAux:X.source,mainReverse:D.source,sideReverse:H.source,driveMacro:K.source,dockMacro:$.source,nightVisionToggle:Y.source}}}const xi=new Set;let ll=null,cl={pads:[],timestamp:0},Ir=!1,Jr=null;function tx(){return kg().some(n=>n?.connected!==!1)}function kg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function mN(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:wg(n)}}function bo(){cl={pads:kg().map(mN),timestamp:typeof performance<"u"?performance.now():Date.now()},xi.forEach(s=>s(cl))}function Mg(){if(bo(),cl.pads.length===0){zd();return}ll=requestAnimationFrame(Mg)}function nx(){ll||(bo(),cl.pads.length!==0&&(ll=requestAnimationFrame(Mg)))}function zd(){ll&&(cancelAnimationFrame(ll),ll=null)}function Rg(n){if(xi.add(n),!Ir&&typeof window<"u"){const s=()=>{bo(),xi.size!==0&&(tx()?nx():zd())};window.addEventListener("gamepadconnected",s),window.addEventListener("gamepaddisconnected",s),Jr=s,Ir=!0}return tx()?nx():bo(),n(cl),()=>{xi.delete(n),xi.size===0&&(zd(),Ir&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",Jr),window.removeEventListener("gamepaddisconnected",Jr),Jr=null,Ir=!1))}}function hN(){const[n,s]=m.useState(cl);return m.useEffect(()=>Rg(s),[]),n}const tl="gamepad",ls={x:0,y:0,boost:!1},is={main:0,side:0,vacuum:0},pN=100,xN=100;function md(n,s){return n&&s&&n.x===s.x&&n.y===s.y&&n.boost===s.boost}function hd(n,s){return n&&s&&n.main===s.main&&n.side===s.side&&n.vacuum===s.vacuum}function gN(n){return n?Math.hypot(n.x||0,n.y||0):0}function bN(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function vN(n,s){if(!n||n.length===0)return null;if(s){const l=n.find(o=>o.signature===s);if(l)return l}return n[0]}function yN(){const{state:n,actions:{setMode:s,setDriveVector:l,setAuxMotors:o,setServoAngle:d,runMacro:f,toggleNightVision:p,registerInputState:h}}=Bt(),{value:x,save:g}=Ge("gamepad",Oa),b=m.useRef(new Set),y=m.useRef(ls),S=m.useRef(is),M=m.useRef({main:!1,side:!1}),j=m.useRef(new Map),E=m.useRef(0),N=m.useRef(0),C=m.useRef(0),A=m.useRef(null),R=m.useCallback(D=>{const H=D.signature??wg(D);x?.profiles?.[H]||b.current.has(H)||(b.current.add(H),g(K=>{const $=K??Oa;if($.profiles?.[H])return $;const Y=$?.defaults?.profile??ia,ee=Cg(D,Y);return{...$,profiles:{...$.profiles??{},[H]:ee}}}))},[x?.profiles,g]),k=m.useCallback((D,H)=>{const K=j.current.get(D)||!1;return j.current.set(D,H),H&&!K},[]),O=m.useCallback((D,H)=>{const K=n.camera?.config;if(!K)return;const $=typeof performance<"u"?performance.now():Date.now(),Y=H?.cameraMode??"absolute",ee=Math.max(1,Math.min(180,H?.cameraSensitivity??60));if(Y==="velocity"){const L=Math.min(50,$-C.current||16),Z=D*ee*(L/1e3);if(Math.abs(Z)<.01)return;const ue=(typeof A.current=="number"?A.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof K.homeAngle=="number"?K.homeAngle:0)+Z;d(ue),A.current=ue,C.current=$;return}const oe=typeof K.minAngle=="number"?K.minAngle:-45,ce=typeof K.maxAngle=="number"?K.maxAngle:45,z=typeof K.homeAngle=="number"?K.homeAngle:(oe+ce)/2,q=D<0?z+D*(z-oe):z+D*(ce-z);typeof A.current=="number"&&Math.abs(A.current-q)<.35&&$-C.current<80||(C.current=$,A.current=q,d(q))},[d,n.camera?.angle,n.camera?.config]),X=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>Rg(D=>{const H=vN(D.pads,X);if(!H){md(y.current,ls)||(y.current=ls,l(ls,{source:tl})),hd(S.current,is)||(S.current=is,o(is)),j.current=new Map,M.current={main:!1,side:!1},E.current=0,N.current=0,h(tl,{connected:!1});return}if(tN()){md(y.current,ls)||(y.current=ls,l(ls,{source:tl})),hd(S.current,is)||(S.current=is,o(is)),j.current=new Map,M.current={main:!1,side:!1},h(tl,{connected:!0,blocked:!0});return}R(H);const K=H.signature,$=x?.profiles?.[K]??x?.defaults?.profile??ia,Y=Eg(H,$);if(!md(Y.driveVector,y.current)){const Z=typeof performance<"u"?performance.now():Date.now();(gN(Y.driveVector)<.02||Z-E.current>=pN)&&(y.current=Y.driveVector,E.current=Z,l(Y.driveVector,{source:tl}))}const ee=$.calibration?.auxSideScale??.55,oe=Math.round(Math.min(Math.abs(Y.auxAxis.main),1)*127),ce=Math.round(Math.min(Math.abs(Y.auxAxis.side),1)*127),z=M.current.main?-oe:oe,q=M.current.side?-Math.round(ce*ee):Math.round(ce*ee);let L={main:Y.auxAxis.main!==0?z:0,side:Y.auxAxis.side!==0?q:0,vacuum:Y.buttons.vacuum?127:0};if(Y.buttons.allAux&&(L={main:127,side:127,vacuum:127}),!hd(L,S.current)){const Z=typeof performance<"u"?performance.now():Date.now();(bN(L)||Z-N.current>=xN)&&(S.current=L,N.current=Z,o(L))}Y.buttons.mainReverse&&k("mainReverse",!0)?M.current.main=!M.current.main:Y.buttons.mainReverse||k("mainReverse",!1),Y.buttons.sideReverse&&k("sideReverse",!0)?M.current.side=!M.current.side:Y.buttons.sideReverse||k("sideReverse",!1),Y.buttons.driveMacro&&k("driveMacro",!0)?(s("drive"),f("drive-sequence")):Y.buttons.driveMacro||k("driveMacro",!1),Y.buttons.dockMacro&&k("dockMacro",!0)?(s("dock"),f("seek-dock")):Y.buttons.dockMacro||k("dockMacro",!1),Y.buttons.nightVisionToggle&&k("nightVisionToggle",!0)?p():Y.buttons.nightVisionToggle||k("nightVisionToggle",!1),Math.abs(Y.cameraAxis)>.001&&O(Y.cameraAxis,$.calibration),h(tl,{connected:!0,signature:K,id:H.id,index:H.index,axes:H.axes,buttons:H.buttons,drive:Y.driveVector,aux:L,cameraAxis:Y.cameraAxis,bindings:Y.sources})}),[X,R,x?.defaults?.profile,x?.profiles,k,O,h,f,o,l,s,p]),null}function qg(n){const s=n?.sensors||{},l=s.oiMode?.label||"Unknown",o=l.toLowerCase(),d=s.chargingState?.label||"",f=!!s.chargingSources?.homeBase,p=f&&d.toLowerCase()!=="not charging"&&d!=="";return{driving:o==="full",docked:f,charging:p,dockedNotCharging:f&&!p,dockingInProgress:!f&&!p&&o==="passive",oiLabel:l,chargingLabel:d}}function Tg(n){const s=ml(n);return m.useMemo(()=>qg(s),[s])}function nl({label:n,value:s,tone:l="neutral"}){const o=l==="good"?"border-emerald-200 bg-emerald-600 text-white":l==="warn"?"border-amber-200 bg-amber-600 text-white":l==="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 ax({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function pd({label:n,tone:s}){const l=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 ${l}`,children:n})}function SN({instructions:n,onConfirm:s,onCancel:l,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(Ud,{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:l,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 Dg({layout:n="desktop",expand:s=!1,fill:l=!1,driveDockState:o,compactHeightClass:d=""}){const f=n==="mobile",{state:{roverId:p,keymap:h},actions:x}=Bt(),g=ml(p),b=o??qg(g),{driving:y,docked:S,charging:M,dockingInProgress:j}=b,[E,N]=m.useState(null),[C,A]=m.useState(!1),[R,k]=m.useState(!1),O=!p||E!==null,X=!p||E!==null,D=Nn(h?.driveMacro?.[0]),H=Nn(h?.dockMacro?.[0]),K={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"]},$="Click this button to initate auto-dock.",Y={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"]},ee=S?"Docked":"Undocked",oe=S?"good":"bad",ce=M?"Charging":S?"Charging in 5s":"—",z=M?"good":S?"warn":"bad",q=async()=>{if(!(!p||E)){N("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(ze){alert(ze.message)}finally{N(null)}}},L=async()=>{if(!(!p||E)){A(!1),k(!1),N("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(ze){alert(ze.message)}finally{N(null)}}},Z=async()=>{if(!(!p||E)){N("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch(ze){alert(ze.message)}finally{N(null),A(!1),k(!1)}}},se=()=>{X||(k(!0),A(!0))},ue="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",T="text-center",V="items-center justify-between",te="items-center justify-center",ae=f?"text-sm font-semibold":"",he="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",re="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",de="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",pe=s||j,Le=pe?"h-full flex-1":l?"flex-1":"",ke=f&&!pe?d:"",Ce=f&&!pe?te:V,_e=f&&!pe&&y&&S;if(!y&&!j)return r.jsxs("button",{type:"button",onClick:L,onContextMenu:ze=>ze.preventDefault(),disabled:O,className:`${ue} ${Le} ${ke} ${T} ${Ce} ${ae} ${he}`,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"}),!f&&pe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[D?r.jsx(ax,{label:D}):null,r.jsx(pd,{label:"Click to start",tone:"emerald"})]}):null]}),pe?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:Y.summary}),r.jsx(Ud,{steps:Y.steps,tone:"emerald"})]}):null]}),pe?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(nl,{label:"Dock",value:ee,tone:oe}),r.jsx(nl,{label:"Charge",value:ce,tone:z})]}):null]});if(j){const ze={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:O,onClick:q,onContextMenu:ht=>ht.preventDefault(),className:`${ue} ${Le} ${ke} ${T} ${Ce} ${ae} ${re}`,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"}),pe?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(pd,{label:"Return to driving mode",tone:"emerald"})}):null]}),pe?r.jsx("p",{className:"text-sm text-amber-50/90",children:ze.summary}):null]}),pe?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(nl,{label:"Dock",value:ee,tone:oe}),r.jsx(nl,{label:"Charge",value:ce,tone:z})]}),f?null:r.jsx(Ud,{steps:ze.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:X,onClick:se,onContextMenu:ze=>ze.preventDefault(),className:f?`flex w-full ${ue} ${ke} ${T} ${Ce} ${ae} ${_e?ve:de}`:`${ue} ${Le} ${T} ${V} ${ae} ${de}`,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:_e?"Docked!":"Dock and Charge"}),!f&&pe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[H?r.jsx(ax,{label:H}):null,r.jsx(pd,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!f&&pe&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:$}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(nl,{label:"Dock",value:ee,tone:oe}),r.jsx(nl,{label:"Charge",value:ce,tone:z})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),R||!f&&C?r.jsx(SN,{instructions:K,pending:E==="dock",onCancel:()=>{k(!1),A(!1)},onConfirm:Z}):null]})}function Ud({steps:n,tone:s="emerald"}){const l=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 ${l}`,children:n.map((d,f)=>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:[f+1,"."]}),r.jsx("span",{className:"align-top",children:d})]}),f<n.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},d))})}function xd(n){return typeof n=="boolean"}function _g({nightVisionOn:n,disabled:s,onToggle:l,keyLabel:o,className:d="",heightClass:f=""}){const[p,h]=m.useState(xd(n)?n:null);m.useEffect(()=>{xd(n)&&h(n)},[n]);const x=xd(p),g=x?p:!1,b=x?g?"On":"Off":"—",y=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",S=()=>{if(s)return;const j=x?!g:!0;h(j),l?.(j)},M=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",f,d].filter(Boolean).join(" "),[d,g,f]);return r.jsxs("button",{type:"button",onClick:S,onContextMenu:j=>j.preventDefault(),disabled:s,"aria-pressed":g,className:M,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 ${y}`,children:b})]})}function gd(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:l,keyLabel:o,active:d,heat:f=0,className:p="",defaultShowSettings:h=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[b,y]=m.useState(!1),[S,M]=m.useState(h),{value:j,save:E}=Ge("horn",us),[N,C]=m.useState(j?.waveform||us.waveform),[A,R]=m.useState(()=>[...Array.isArray(j?.freqs)?j.freqs:us.freqs,0,0,0,0].slice(0,4).map(q=>gd(q)));m.useEffect(()=>{C(j?.waveform||us.waveform),Array.isArray(j?.freqs)&&R([...j.freqs,0,0,0,0].slice(0,4).map(z=>gd(z)))},[j?.freqs,j?.waveform]);const k=!!d,O=Math.max(0,Math.min(1,Number(f)||0)),X=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",k?"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",p].filter(Boolean).join(" "),[p,k]),D=()=>{n||b||(y(!0),s?.())},H=()=>{b&&(y(!1),l?.())};m.useEffect(()=>{!k&&b&&y(!1)},[k,b]);const K=N==="sine"?"sine":"saw",$=m.useCallback(z=>{const q=z.target.value==="sine"?"sine":"saw";C(q),E(L=>({...L??{},waveform:q}))},[E]),Y=m.useCallback((z,q)=>{R(L=>{const Z=[...L];return Z[z]=gd(q),E(se=>({...se??{},freqs:Z})),Z})},[E]),ee=z=>{if(n)return;const q=z.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||(z.preventDefault(),D())},oe=z=>{const q=z.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||(z.preventDefault(),H())},ce=x?r.jsx("button",{type:"button",onClick:z=>{z.preventDefault(),M(q=>!q)},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":b,onPointerDown:ee,onPointerUp:oe,onPointerLeave:H,onPointerCancel:H,onContextMenu:z=>z.preventDefault(),onBlur:H,className:X,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${O*100}%, rgba(0,0,0,0) ${O*100}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${k?"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 ${k?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:k?"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:K,onChange:$,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:A.map((z,q)=>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:q+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:z,onChange:L=>Y(q,L.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-${q}`))})]}):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:K,onChange:$,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"})]})]}),A.map((z,q)=>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:q+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:z,onChange:L=>Y(q,L.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-${q}`))]}):null]})}function Pr(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function sx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Og({value:n,min:s,max:l,step:o=.5,label:d="Camera Tilt",orientation:f="horizontal",onChange:p,onCommit:h,throttleMs:x=0,disabled:g=!1,keyDownLabel:b,keyUpLabel:y,className:S="",labelRowClass:M="",labelClass:j="",valueClass:E="",sliderClass:N="",endpointClass:C="",endpointLabelClass:A="",accentClass:R="",showValue:k=!0,showEndpoints:O}){const X=f==="vertical",H=typeof O=="boolean"?O:!X,[K,$]=m.useState(n),Y=m.useRef(!1),ee=m.useRef(null);m.useEffect(()=>{Y.current||$(n)},[n]),m.useEffect(()=>()=>{ee.current&&clearTimeout(ee.current)},[]);const oe=Z=>{if(p){if(x>0){ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{p(Z)},x);return}p(Z)}},ce=Z=>{const se=Number.parseFloat(Z.target.value);Number.isNaN(se)||(Y.current=!0,$(se),oe(se))},z=()=>{Y.current=!1,ee.current&&(clearTimeout(ee.current),ee.current=null),h?h(K):x>0&&p?.(K)};if(typeof s!="number"||typeof l!="number")return null;const q=[X?"h-28 w-5":"w-full",R,N].filter(Boolean).join(" "),L=r.jsx("input",{type:"range",orient:X?"vertical":void 0,min:s,max:l,step:o,value:Number.isFinite(K)?K:s,onChange:ce,onMouseUp:z,onTouchEnd:z,onPointerUp:z,disabled:g,className:q,style:X?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return X?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${S}`.trim(),children:[k?r.jsx("div",{className:`flex flex-col items-center ${M}`.trim(),children:r.jsx("span",{className:E,children:Pr(n)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:j,children:d}),L]})]}):r.jsxs("div",{className:`space-y-0.5 ${S}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${M}`.trim(),children:[r.jsx("span",{className:j,children:d}),k?r.jsx("span",{className:E,children:Pr(n)}):null]}),r.jsxs("div",{children:[L,H?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${C}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${A}`.trim(),children:[b?r.jsx(sx,{label:b}):null,Pr(s)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${A}`.trim(),children:[Pr(l),y?r.jsx(sx,{label:y}):null]})]}):null]})]})}function jN({disabled:n,layout:s,radius:l,onMove:o,onStop:d}){const f=m.useRef(null),p=m.useRef(null),h=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),b=m.useCallback(()=>{p.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),d?.()},[d]),y=m.useCallback(E=>{if(n||p.current!==null)return;E.preventDefault();const N=f.current;if(!N)return;const C=N.getBoundingClientRect(),A=E.clientX-C.left,R=E.clientY-C.top;h.current={x:A,y:R},p.current=E.pointerId,N.setPointerCapture?.(E.pointerId),g({active:!0,base:{x:A,y:R},knob:{x:0,y:0}})},[n]),S=m.useCallback(E=>{if(n||p.current!==E.pointerId)return;E.preventDefault();const N=f.current;if(!N)return;const C=N.getBoundingClientRect(),A=E.clientX-C.left,R=E.clientY-C.top,k=A-h.current.x,O=R-h.current.y,X=Math.min(Math.hypot(k,O),l),D=Math.atan2(O,k),H=Math.cos(D)*X,K=Math.sin(D)*X,$={x:ol(H/l),y:ol(-K/l),boost:!1};g(Y=>({...Y,knob:{x:H,y:K}})),o?.($)},[n,o,l]),M=m.useCallback(E=>{if(p.current!==E.pointerId)return;E.preventDefault(),f.current?.releasePointerCapture?.(E.pointerId),b()},[b]);return m.useEffect(()=>{n&&b()},[n,b]),r.jsxs("div",{ref:f,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:y,onPointerMove:S,onPointerUp:M,onPointerLeave:M,onPointerCancel:M,onContextMenu:E=>E.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 lx({id:n,label:s,values:l,color:o,disabled:d,onPress:f,onRelease:p}){return r.jsx("button",{type:"button",disabled:d,onPointerDown:h=>{h.preventDefault(),f(n,l)},onPointerUp:()=>p(n),onPointerLeave:()=>p(n),onPointerCancel:()=>p(n),onContextMenu:h=>h.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})}const Wr="mobile-joystick",NN=80,AN=.15,wN={main:0,side:0,vacuum:0},CN={main:127,side:127,vacuum:127},EN={main:-127,side:-127,vacuum:-127};function kN({layout:n}){const{state:{roverId:s},actions:{setDriveVector:l,registerInputState:o}}=Bt(),d=Tg(s),f=d.docked&&!d.driving,p=f||d.dockingInProgress,h=!s,x=NN,g=AN,b=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{h&&(b.current={x:0,y:0,boost:!1})},[h]);const y=m.useCallback((E={})=>{if(h)return;const N={x:ol(E.x??0),y:ol(E.y??0),boost:!!E.boost},C={x:b.current.x+(N.x-b.current.x)*(1-g),y:b.current.y+(N.y-b.current.y)*(1-g),boost:N.boost};b.current=C,l(C,{source:Wr}),o(Wr,{vector:C,lastEvent:"move"})},[h,o,l,g]),S=m.useCallback(()=>{if(h)return;const E={x:0,y:0,boost:!1};b.current=E,l(E,{source:Wr}),o(Wr,{vector:E,lastEvent:"stop"})},[h,o,l]),j=`flex h-full flex-col gap-0.5 text-slate-100 ${f?"max-h-screen self-start":""}`;return r.jsxs("div",{className:j,children:[r.jsx(Dg,{layout:"mobile",expand:p,driveDockState:d,compactHeightClass:"min-h-[5rem]"}),p?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(jN,{disabled:h,layout:n,radius:x,onMove:y,onStop:S})})]})}function MN({layout:n}){const{state:{roverId:s,camera:l,horn:o},pipeline:d,actions:{setServoAngle:f,setNightVision:p,setAuxMotors:h,startHorn:x,stopHorn:g}}=Bt(),b=!s,y=m.useRef(null),S=l?.config,M=!!(s&&l?.enabled&&S),j=!!(s&&d?.nightVision),E=d?.nightVisionState,N=!!(s&&d?.horn),C=o?.overheated,A=typeof S?.minAngle=="number"?S.minAngle:-45,R=typeof S?.maxAngle=="number"?S.maxAngle:45,k=typeof l?.angle=="number"?l.angle:typeof S?.homeAngle=="number"?S.homeAngle:(A+R)/2,O=m.useCallback(H=>{j&&p(H)},[j,p]),X=m.useCallback((H,K)=>{b||(y.current=H,h(K))},[b,h]),D=m.useCallback(H=>{b||y.current===H&&(y.current=null,h(wN))},[b,h]);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(lx,{id:"aux-vac-forward",label:"Vacuum Forward",values:CN,color:"bg-fuchsia-600",disabled:b,onPress:X,onRelease:D}),r.jsx(lx,{id:"aux-vac-backward",label:"Vacuum Backward",values:EN,color:"bg-fuchsia-800",disabled:b,onPress:X,onRelease:D})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[M?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(Og,{value:k,min:A,max:R,step:.5,onChange:f,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,j?r.jsx(_g,{nightVisionOn:E?.nightVisionOn,disabled:b,onToggle:O,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:N?r.jsx(Bg,{disabled:b||C,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function vo({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(MN,{layout:n})})}function yo({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(kN,{layout:n==="landscape"?"landscape":"portrait"})})}function RN({swapColumns:n=!1}){const s="h-[min(60svh,24rem)]",l=n?r.jsx(yo,{layout:"portrait",className:s}):r.jsx(vo,{layout:"portrait",className:s}),o=n?r.jsx(vo,{layout:"portrait",className:s}):r.jsx(yo,{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:[l,o]})})}function qN(n=[],s={}){const l=tn(),{enabled:o=!0,version:d=null}=s,[f,p]=m.useState({}),h=m.useRef(new Map),x=m.useMemo(()=>n.map(j=>typeof j=="string"?j:j.id),[n]),g=m.useMemo(()=>{const j=x.join("|");return d?`${j}|v:${d}`:j},[x,d]),b=m.useRef([]),[y,S]=m.useState(0),M=m.useRef(new Map);return m.useEffect(()=>{if(!l)return;const j=()=>S(E=>E+1);return l.on("connect",j),()=>l.off("connect",j)},[l]),m.useEffect(()=>{b.current=x},[g,x]),m.useEffect(()=>{h.current.forEach(j=>URL.revokeObjectURL(j)),h.current.clear(),p({})},[g]),m.useEffect(()=>{if(!o){h.current.forEach(A=>URL.revokeObjectURL(A)),h.current.clear(),p({});return}if(!b.current.length||!l)return;let j=!1;const E=b.current,N=(A={},R)=>{if(j||!A.id||!R)return;const k=R.byteLength??R.length??0,O=Date.now(),X=M.current.get(A.id)||{count:0,totalBytes:0,lastLogAt:0},D={count:X.count+1,totalBytes:X.totalBytes+k,lastLogAt:X.lastLogAt};if(!D.lastLogAt||O-D.lastLogAt>=1e4){const Y=D.count?D.totalBytes/D.count:0;console.log("[roomCamera]",A.id,`frame=${k}B`,`avg=${Math.round(Y)}B`,`count=${D.count}`),D.lastLogAt=O}M.current.set(A.id,D);const H=new Blob([R],{type:"image/jpeg"}),K=URL.createObjectURL(H),$=h.current.get(A.id);$&&URL.revokeObjectURL($),h.current.set(A.id,K),p(Y=>({...Y,[A.id]:{status:"playing",ts:A.ts||Date.now(),error:null,objectUrl:K}}))},C=(A={})=>{j||!A.id||p(R=>({...R,[A.id]:{...R[A.id]||{},status:A.error?"error":R[A.id]?.status||"connecting",error:A.error||null,ts:A.ts||R[A.id]?.ts||null,objectUrl:R[A.id]?.objectUrl||null}}))};return l.on("roomCamera:frame",N),l.on("roomCamera:status",C),l.emit("roomCamera:subscribe",{ids:E},(A={})=>{A.error}),()=>{j=!0,l.emit("roomCamera:unsubscribe",{ids:E}),l.off("roomCamera:frame",N),l.off("roomCamera:status",C),h.current.forEach(A=>URL.revokeObjectURL(A)),h.current.clear()}},[l,g,o,y]),f}function TN({feed:n,label:s}){const[l,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(f=>!f))},[n?.ts,n?.objectUrl]);const d=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 ${l?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:d})]})]})}function DN(){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 Lg=["horizontal","vertical"];function bd(n,s){return Lg.includes(n)?n:s}function ff({defaultOrientation:n="horizontal",orientation:s,hideLayoutToggle:l=!1,hideHeader:o=!1,panelId:d=null}){const p=Je(N=>N.session)?.roomCameras||[],h=qN(p.map(N=>({id:N.id}))),{value:x,save:g}=Ge("roomCameraPanels",{}),[b,y]=m.useState(()=>bd(d?x?.[d]:n,"horizontal"));m.useEffect(()=>{if(!d)return;const N=x?.[d];N&&y(bd(N,"horizontal"))},[d,x?.[d]]);const S=s?bd(s,"horizontal"):b,M=S==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",j=!l&&!s&&p.length>0,E=N=>{y(N),d&&g(C=>({...C||{},[d]:N}))};return p.length===0?r.jsx(DN,{}):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:p.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:j&&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:Lg.map(N=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${S===N?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>E(N),children:N==="vertical"?"Vertical":"Grid"},N))})]})})]}),r.jsx("div",{className:M,children:p.map(N=>{const C=h[N.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(TN,{feed:C,label:N.name||N.id})},N.id)})})]})}function mf(){const n=Je(l=>l.logs),s=m.useMemo(()=>n.slice().reverse(),[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:"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."}):s.map(l=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:l.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",l.level,"]"]})," ",l.label&&r.jsxs("span",{className:"text-teal-400",children:["[",l.label,"]"]})," ",r.jsx("span",{children:l.message})]},l.id))})]})}function _N(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 l=n.key;return l||(l=n.type==="room"?`room:${s}`:s),{type:n.type,id:s,key:l}}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 BN(n=[]){const s=new Set,l=[];return n.forEach(o=>{!o?.key||s.has(o.key)||(s.add(o.key),l.push(o))}),l.sort((o,d)=>o.key.localeCompare(d.key))}function Ni(n=[],s={}){const l=tn(),{enabled:o=!0,version:d=null}=s,[f,p]=m.useState({}),h=m.useMemo(()=>Array.isArray(n)?BN(n.map(_N).filter(Boolean)):[],[n]),x=m.useMemo(()=>{const M=h.map(j=>`${j.type}:${j.id}:${j.key}`).join("|");return d?`${M}|v:${d}`:M},[h,d]),g=m.useRef([]),[b,y]=m.useState(0);return m.useEffect(()=>{if(!l)return;const M=()=>y(j=>j+1);return l.on("connect",M),()=>{l.off("connect",M)}},[l]),m.useEffect(()=>{g.current=h},[h]),m.useEffect(()=>{if(!x||!o){p({});return}const M=g.current;let j=!1;function E(N){const C=N.type==="room"?{roomCameraId:N.id}:{roverId:N.id};l.emit("video:request",C,(A={})=>{j||p(R=>({...R,[N.key]:A}))})}return M.forEach(N=>{E(N)}),()=>{j=!0}},[l,x,o,b]),m.useMemo(()=>{if(!x||!o)return{};const M={};return h.forEach(j=>{f[j.key]&&(M[j.key]=f[j.key])}),M},[x,f,h])}function hf(n=[],s={}){const l=tn(),{enabled:o=!0,version:d=null}=s,[f,p]=m.useState({}),h=m.useRef(new Map),x=m.useMemo(()=>n.map(j=>typeof j=="string"?j:j.id).filter(Boolean),[n]),g=m.useMemo(()=>{const j=x.join("|");return d?`${j}|v:${d}`:j},[x,d]),b=m.useRef([]),[y,S]=m.useState(0),M=m.useRef(new Map);return m.useEffect(()=>{if(!l)return;const j=()=>S(E=>E+1);return l.on("connect",j),()=>l.off("connect",j)},[l]),m.useEffect(()=>{b.current=x},[g,x]),m.useEffect(()=>{h.current.forEach(j=>URL.revokeObjectURL(j)),h.current.clear(),p({})},[g]),m.useEffect(()=>{if(!o){h.current.forEach(A=>URL.revokeObjectURL(A)),h.current.clear(),p({});return}if(!b.current.length||!l)return;let j=!1;const E=b.current,N=(A={},R)=>{if(j||!A.id||!R)return;const k=R.byteLength??R.length??0,O=Date.now(),X=M.current.get(A.id)||{count:0,totalBytes:0,lastLogAt:0},D={count:X.count+1,totalBytes:X.totalBytes+k,lastLogAt:X.lastLogAt};if(!D.lastLogAt||O-D.lastLogAt>=1e4){const Y=D.count?D.totalBytes/D.count:0;console.log("[roverSnapshot]",A.id,`frame=${k}B`,`avg=${Math.round(Y)}B`,`count=${D.count}`),D.lastLogAt=O}M.current.set(A.id,D);const H=new Blob([R],{type:"image/jpeg"}),K=URL.createObjectURL(H),$=h.current.get(A.id);$&&URL.revokeObjectURL($),h.current.set(A.id,K),p(Y=>({...Y,[A.id]:{status:"playing",ts:A.ts||Date.now(),error:null,objectUrl:K}}))},C=(A={})=>{j||!A.id||p(R=>({...R,[A.id]:{...R[A.id]||{},status:A.error?"error":R[A.id]?.status||"connecting",error:A.error||null,ts:A.ts||R[A.id]?.ts||null,objectUrl:R[A.id]?.objectUrl||null}}))};return l.on("roverSnapshot:frame",N),l.on("roverSnapshot:status",C),l.emit("roverSnapshot:subscribe",{ids:E},(A={})=>{A.error}),()=>{j=!0,l.emit("roverSnapshot:unsubscribe",{ids:E}),l.off("roverSnapshot:frame",N),l.off("roverSnapshot:status",C),h.current.forEach(A=>URL.revokeObjectURL(A)),h.current.clear()}},[l,g,o,y]),f}const ON={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function LN(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 zN(n){if(!n)return{};const s=`${n}:${n}`;return{Authorization:`Basic ${LN(s)}`}}class ix{constructor({url:s,token:l,video:o,onStatus:d,audioOnly:f=!1,receiveAudio:p=!0}){this.url=s,this.token=l,this.video=o,this.audioOnly=f,this.receiveAudio=p,this.pc=null,this.abortController=null,this.onStatus=d}notify(s,l){typeof this.onStatus=="function"&&this.onStatus(s,l)}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(ON);this.pc=s;const l=new MediaStream;s.ontrack=o=>{o.streams[0]?.getTracks().forEach(d=>l.addTrack(d)),this.video.srcObject=l,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 d=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...zN(this.token)},body:o.sdp,signal:this.abortController.signal});if(!d.ok)throw new Error(`WHEP request failed: ${d.status}`);const f=await d.text();await s.setRemoteDescription({type:"answer",sdp:f}),s.getReceivers().forEach(p=>{"playoutDelayHint"in p&&(p.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 zg(){const{value:n,save:s}=Ge("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,d=>{s({hudMapDesktop:!!d})}]}const UN={discord:mg,kofi:Hp,"ko-fi":Hp,wiki:Sj,throne:jj},HN={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 VN(){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 $N(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 pf({id:n,label:s,url:l,className:o=""}){if(!l)return null;VN();const d=$N(n,s),f=UN[d]||Nj,p=HN[d]||null,h=s||n||"Link";return r.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer","aria-label":h,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 ${p?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:p||void 0,children:[r.jsx(f,{className:"mr-0"}),h]})}const Ai=10;function Ug({batteryState:n=null,charge:s=null,config:l=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,d=n?.warnActive??null,f=n?.urgentActive??null,p=l?.Full??null,h=l?.Warn??null,x=l?.Urgent??null,g=s??n?.charge??null;let b=o;if(b==null&&(b=GN({charge:g,full:p,warn:h,urgent:x})),b==null)return{available:!1};const y=Math.max(0,Math.min(1,b/100)),S=d??(h!=null&&g!=null&&g<=h),M=f??(x!=null&&g!=null&&g<=x);return{available:!0,percent:y,percentDisplay:b,warnActive:S,urgentActive:M,warnDisplayPercent:Ai}}function GN({charge:n,full:s,warn:l,urgent:o}){if(n!=null&&s!=null&&l!=null&&o!=null&&s>l&&l>o){const d=Ai/100,f=1-d;if(n<=o)return 0;if(n<=l){const h=(n-o)/(l-o);return Math.round(Math.max(0,Math.min(1,h))*Ai)}if(n>=s)return 100;const p=(n-l)/(s-l);return Math.round((d+Math.max(0,Math.min(1,p))*f)*100)}return null}const YN=1600,FN=800;function Sn(...n){return n.filter(Boolean).join(" ")}function Hd({visual:n,orientation:s="horizontal",variant:l="inline",compact:o=!1,showLabel:d,className:f=""}){const p=l==="background",h=s==="vertical",x=d??!p;if(!n?.available){if(p){const ee=Ai,oe=Sn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!S&&"battery-tick-warn"),ce=h?{bottom:`${ee}%`}:{left:`${ee}%`},z=Sn("absolute inset-0 pointer-events-none",f);return r.jsxs("div",{className:z,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:oe,style:ce})]})}return h?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,b=Math.max(0,Math.min(100,g)),y=n.warnDisplayPercent??Ai,S=!!n.urgentActive,M=!!n.warnActive,j=S?`${FN}ms`:M?`${YN}ms`:void 0,N=p?S||M?"bg-red-500/45":"bg-emerald-500/45":S||M?"bg-red-500":"bg-emerald-500",C=S||M?"bg-red-900/35":"bg-slate-900/35",A=S||M?"bg-red-900/45":"bg-slate-900/35",R=Sn(p?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",h&&!p?"flex flex-col items-center justify-center":"w-full",f);if(p){const ee=h?{height:`${b}%`}:{width:`${b}%`},oe=Sn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",N,"transition-[width,height]",S&&"battery-urgent-flash"),ce=Sn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!S&&"battery-tick-warn"),z=h?{bottom:`${y}%`}:{left:`${y}%`};return r.jsxs("div",{className:R,children:[r.jsx("div",{className:Sn("absolute inset-0",C,S&&"battery-urgent-flash")}),r.jsx("div",{className:oe,style:{...ee,animationDuration:j}}),r.jsx("div",{className:ce,style:z})]})}const k=Sn("relative overflow-hidden rounded-sm border border-slate-800",S||M?A:"bg-zinc-900/90",S&&"battery-urgent-flash",h?"w-full flex-1":o?"h-4":"h-5"),O=h?{height:`${b}%`}:{width:`${b}%`},X=Sn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",N,"transition-[width,height]",S&&"battery-urgent-flash"),D=Sn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!S&&"battery-tick-warn"),H=h?{bottom:`${y}%`}:{left:`${y}%`},K=`Battery ${g}%`,$=Sn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",h?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),Y=Sn("rounded px-1.5 py-0.5",p?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:R,children:[r.jsxs("div",{className:k,children:[r.jsx("div",{className:X,style:{...O,animationDuration:j}}),r.jsx("div",{className:D,style:H})]}),x&&!h?r.jsx("div",{className:$,children:r.jsx("span",{className:Y,children:K})}):null,x&&h?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:Y,children:[g,"%"]})}):null]})}function XN({mobileHud:n=!1,isActiveDriver:s=!1,idleSkipSeconds:l=null}){const o=n?"text-3xl":"text-5xl",d=n?"text-xs":"text-sm",f=n?"text-[0.55rem]":"text-[0.75rem]",p=n?"px-4 py-3":"px-6 py-4",h=s&&typeof l=="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 ${o}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${d}`,children:"Start driving!"}),h?r.jsxs("div",{className:`text-red-100/90 ${f}`,children:["Idle skip in ",l,"s"]}):null]})})}function Mo(n){return Math.max(0,Math.min(1,n))}function Hg(n){return(n-90)*Math.PI/180}function bi(n,s,l,o){const d=Hg(o);return{x:n+l*Math.cos(d),y:s+l*Math.sin(d)}}function QN(n,s,l,o,d){let f=o,p=d;p<=f&&(p+=360);const h=bi(n,s,l,f),x=bi(n,s,l,p);return["M",h.x,h.y,"A",l,l,0,0,1,x.x,x.y].join(" ")}function xf(n,s){if(s)return"#ef4444";const l=Math.abs(n);return l>900?"#f59e0b":l>300?"#22c55e":"#64748b"}function KN(n,s){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=Mo(n/(s||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function ZN(n,s){if(s)return"#ef4444";const l=Mo(n==null?0:n/4095),o=[47,55,69],d=[245,158,11],[f,p,h]=o.map((x,g)=>Math.round(x+(d[g]-x)*l));return`rgb(${f}, ${p}, ${h})`}function IN({count:n,totalSpan:s,gap:l,startAngle:o}){const f=(s-l*(n-1))/n,p=[];let h=o;for(let x=0;x<n;x+=1){const g=h+f;p.push({start:h,end:g}),h=g+l}return p}function vd({cx:n,cy:s,rInner:l,rOuter:o,startDeg:d,endDeg:f,color:p,pulse:h=!1,opacity:x=1}){const g=(l+o)/2,b=o-l,y=QN(n,s,g,d,f);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:y,stroke:p,strokeWidth:b,strokeLinecap:"round",fill:"none",opacity:x}),h?r.jsx("path",{d:y,stroke:"#ef4444",strokeWidth:b,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function JN({cx:n,cy:s,rBase:l,rTip:o,startDeg:d,endDeg:f,color:p,value:h,max:x}){const g=(d+f)/2,b=bi(n,s,o,g),y=Mo(h!=null?h/(x||1):0),S=Math.pow(y,.35),M=l-(l-o)*S,j=Math.max(o,Math.min(M,l)),E=bi(n,s,j,d),N=bi(n,s,j,f),C=`M ${b.x} ${b.y} L ${E.x} ${E.y} L ${N.x} ${N.y} Z`;return r.jsx("path",{d:C,fill:p,opacity:1,stroke:"none"})}function rx({cx:n,cy:s,current:l,drop:o,overcurrent:d,label:f}){const p=Math.abs(l),h=Mo(p/1200),x=xf(l,d),g=56,b=14,y=9,S=3,M=g*h,j=f==="L"?-1:1,E=j*(-y/2-S/2),N=j*(b/2+S/2),C=b+y+S+2,A=g+4;return r.jsxs("g",{transform:`translate(${n},${s})`,children:[r.jsx("rect",{x:-C/2,y:-A/2,width:C,height:A,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:E-b/2,y:-g/2,width:b,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:E-b/2,y:g/2-M,width:b,height:M,fill:x,className:d?"animate-pulse":""}),r.jsx("rect",{x:N-y/2,y:-g/2,width:y,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:f})]})}function PN({cx:n,cy:s,current:l,overcurrent:o}){let d=Math.abs(l);d<10&&(d=0);const f=xf(l*3,o),p=43,h=d>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${n}px ${s}px`,animation:h?`spin ${h}s linear infinite`:"none",animationDirection:h?"reverse":"normal"},children:[r.jsx("circle",{cx:n,cy:s,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const b=Hg(g),y=n+p*Math.cos(b),S=s+p*Math.sin(b);return r.jsx("line",{x1:n,y1:s,x2:y,y2:S,stroke:f,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:n,cy:s,r:p+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function WN({cx:n,cy:s,current:l,overcurrent:o,variant:d,dirtLeft:f,dirtRight:p}){const h=Math.abs(l),x=xf(l,o),g=1,b=96,y=12,S=`main-brush-pattern-a-${d}`,M=`main-brush-pattern-b-${d}`,j=h>0?.6:null,E=l>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[S,M].map((N,C)=>r.jsxs("pattern",{id:N,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"}),j?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${E*(C===0?6:-6)}`,dur:`${j}s`,repeatCount:"indefinite"}):null]},N))}),r.jsx("rect",{x:n-b/2,y:s-14,width:b,height:y,rx:"3",fill:`url(#${S})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:n-b/2,y:s+4,width:b,height:y,rx:"3",fill:`url(#${M})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:n-b/4,cy:s-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:n+b/4,cy:s+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:n-b/2-4,y:s-16,width:b+8,height:y*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function eA({sensors:n={},variant:s="full",size:l,overlay:o=!1}){const d=l||(s==="mini"?190:260),f=d/2,p=d*.07,h=f,x=f+p,g=f*.8,b=g-4,y=g+4,S=g-14,M=g-6,j=g*.65,E=n?.bumpsAndWheelDrops||{},N=n?.wheelOvercurrents||{},C=n?.wheelLeftCurrentMa??0,A=n?.wheelRightCurrentMa??0,R=n?.sideBrushCurrentMa??0,k=n?.mainBrushCurrentMa??0,O=6,X=E.bumpLeft?O:0,D=E.bumpRight?O:0,H=IN({count:6,totalSpan:140,gap:6,startAngle:-70}),K=["L","FL","CL","CR","FR","R"],$=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],Y=H.map((z,q)=>({label:K[q],start:z.start,end:z.end,value:$[q]})),ee=[{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}],oe=$.filter(z=>z!=null),ce=oe.length?Math.max(...oe,1200):1200;return r.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${d}px`,height:`${d}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 ${d} ${d}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:h,cy:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(rx,{cx:h-j,cy:x,current:C,drop:E.wheelDropLeft,overcurrent:N.leftWheel,label:"L"}),r.jsx(rx,{cx:h+j,cy:x,current:A,drop:E.wheelDropRight,overcurrent:N.rightWheel,label:"R"}),r.jsx(PN,{cx:h+g*.65,cy:x-g*.55,current:R,overcurrent:N.sideBrush}),r.jsx(WN,{cx:h,cy:x,current:k,overcurrent:N.mainBrush,variant:s,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),Y.map(z=>{const q=KN(z.value,ce),L=y+4,Z=L+28;return r.jsx(JN,{cx:h,cy:x,rBase:Z,rTip:L,startDeg:z.start,endDeg:z.end,color:q,value:z.value,max:ce},z.label)}),ee.map(z=>r.jsx(vd,{cx:h,cy:x,rInner:S,rOuter:M,startDeg:z.start,endDeg:z.end,color:ZN(z.value,z.active),opacity:1,pulse:!!z.active},z.label)),r.jsx(vd,{cx:h,cy:x,rInner:b-X,rOuter:y-X,startDeg:-70,endDeg:-6,color:E.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!E.bumpLeft}),r.jsx(vd,{cx:h,cy:x,rInner:b-D,rOuter:y-D,startDeg:6,endDeg:70,color:E.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!E.bumpRight})]})]})}const Vd=qn.memo(eA);function tA({sensors:n,label:s,roverColor:l=null,status:o,audioStatus:d,levelStatus:f,layoutFormat:p="desktop",variant:h="default",driverLabel:x=null,showTopDown:g=!1,mobileHud:b=!1,mapPosition:y="top-center",turnTimerText:S=null,labelScale:M=1}){const j=b,E=p==="mobile-portrait",N=j?"text-[0.45rem]":"text-[0.65rem]",C=j?"px-0.25 py-0.25":"px-1 py-0.5",A=j?"px-0.25 py-0.25":"px-0.5 py-0.5",R=j?"text-[0.55rem]":"text-[0.8rem]",k=j?"left-0.5 top-0.5":"left-1 top-1",O=j?"text-[0.5rem]":"text-[0.7rem]",X=j?"px-0.5 py-0.25":"px-1 py-0.5",D=j?"left-0.5 top-1/2":"left-1 top-1/2",H="bottom-0.5",K={transform:`translateX(-50%) scale(${M})`,transformOrigin:"center bottom"},$="240px",Y=E?.3:j?.33:.7,oe={width:$,height:$,opacity:j?.6:.7,transform:y==="top-center"?`translateX(-50%) scale(${Y})`:`scale(${Y})`,transformOrigin:y==="bottom-left"?"bottom left":y==="top-center"?"top center":"top right",...y==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:y==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(h==="none")return null;if(h==="spectator"){const ce=[["Voltage",n?.voltageMv!=null?`${(n.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",n?.currentMa!=null?`${n.currentMa} mA`:"--"],["Charge",n?.batteryChargeMah!=null?`${n.batteryChargeMah}`:"--"],["OI",n?.oiMode?.label||"--"]],z=!!n?.chargingSources?.homeBase,q=n?.chargingState?.label||"",L=!!(q&&q.toLowerCase()!=="not charging"),Z=n?.oiMode?.label||"Unknown",se=Z.toLowerCase(),ue=se==="full"?"bg-emerald-500/80 text-emerald-50":se==="safe"?"bg-amber-400/80 text-amber-950":se==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",T=z?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",V=L?"bg-emerald-500/80 text-emerald-50":z?"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 ${k} font-medium text-slate-100 ${N}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,f?r.jsx("span",{className:"text-cyan-300",children:f}):null]})}),r.jsx("div",{className:`absolute ${D} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${N} ${C}`,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 ${T}`,children:z?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${V}`,children:L?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${ue}`,children:["OI: ",Z]})]}),ce.map(([te,ae])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:te}),r.jsx("span",{className:"font-semibold text-white",children:ae})]},te))]})}),r.jsx("div",{className:`absolute ${H} left-1/2`,style:K,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${A} ${R}`,children:[r.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ca(l,.18),children:s||"Unnamed Rover"}),x?r.jsxs("span",{className:"text-slate-300",children:["• ",x]}):null]})})]}),g?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...oe},children:r.jsx(Vd,{sensors:n,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 ${k} font-medium text-slate-100 ${N}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,f?r.jsx("span",{className:"text-cyan-300",children:f}):null]})}),S?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${X} ${O}`,children:S}):null,r.jsx("div",{className:`absolute ${H} left-1/2`,style:K,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${A} ${R}`,children:r.jsxs("span",{children:["Rover:"," ",r.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ca(l,.18),children:['"',s||"Unnamed Rover",'"']})]})})}),g&&h!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...oe},children:r.jsx(Vd,{sensors:n,size:240,overlay:!0})}):null]})}const nA=qn.memo(tA),ox=2e3,aA=3e3,sA=3e3,lA=40,iA=1e3,rA={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function oA({motors:n,fill:s=0,compact:l=!1}){if(!n?.length)return null;const o=n.map(b=>rA[b]||b),d=l?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",f=l?"px-2 py-1":"px-4 py-2",p=l?"text-lg":"text-4xl",h=l?"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 ${d}`,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 ${p} ${f}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${h}`,children:o.join(", ")})]})]})})}function cA({battery:n,compact:s=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const l=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",d=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 ${d}`,children:r.jsx("div",{children:l})})})}function uA({sensors:n}){const s=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],l=s.filter(h=>h!=null).reduce((h,x)=>Math.max(h,x),1200),o=h=>Math.pow(Math.max(0,Math.min(1,(h??0)/l)),.35),d=h=>h==null||h<=0?"hsl(200 60% 18%)":`hsl(${(200+o(h)*360)%360} 100% 60%)`,f=6,p=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:s.map((h,x)=>{const g=o(h),b=x<f/2?-1:1,y=`${g*100}%`,S=d(h);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${p}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:y,background:S,float:b===-1?"right":"left"}})})},x)})})}const dA=qn.memo(uA);function fA({compact:n=!1}){const s=Je(D=>D.session),{sendMessage:l,onInputFocus:o,onInputBlur:d,blurChat:f,registerInputRef:p,setTypingActive:h}=cf(),{value:x}=Ge("tts",{engine:"flite",voice:"rms",pitch:50}),[g,b]=m.useState(""),[y,S]=m.useState(!1),M=s?.role!=="spectator",j=s?.role==="spectator",E=s?.assignment?.roverId||null,C=!!m.useMemo(()=>s?.roster?.find(D=>String(D.id)===String(E))||null,[E,s?.roster])?.audio?.ttsEnabled,A=m.useMemo(()=>{if(!C)return null;const D=x?.engine==="espeak"?"espeak":"flite";if(D==="espeak"){let K=Number.isFinite(x?.pitch)?Math.round(x.pitch):void 0;return typeof K=="number"&&(K=Math.max(0,Math.min(99,K))),{speak:!0,engine:D,pitch:K}}const H=typeof x?.voice=="string"?x.voice:void 0;return{speak:!0,engine:D,voice:H}},[x?.engine,x?.pitch,x?.voice,C]),R=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",k=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",O=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 X(D){if(D.preventDefault(),!M)return;const H=g.trim();if(H){S(!0);try{await l(H,A),b(""),f(),h(!1)}catch(K){alert(K.message)}finally{S(!1)}}}return j?null:r.jsxs("form",{onSubmit:X,className:R,children:[r.jsx("input",{className:k,value:g,onChange:D=>{const H=D.target.value;b(H),h(!!H.trim())},onFocus:D=>{o(D),h(!!g.trim())},onBlur:D=>{d(D),h(!1)},onKeyDown:D=>{D.key==="Enter"&&!g.trim()&&(D.preventDefault(),f(),h(!1))},ref:D=>p(D,{target:"hud"}),placeholder:M?"Chat (TTS)":"Spectator",disabled:!M}),r.jsx("button",{type:"submit",disabled:!M||y,className:O,children:"Speak"})]})}function wi({sessionInfo:n,audioSessionInfo:s,videoMode:l="whep",snapshotFeed:o=null,qualityNotice:d=null,label:f,roverColor:p=null,forceMute:h=!1,telemetryFrame:x,batteryConfig:g,layoutFormat:b="desktop",hudVariant:y="default",driverLabel:S=null,hudForceMap:M=!1,hudMapPosition:j="top-center",hudLabelScale:E=1,fitParent:N=!1,overcurrentLimiter:C=null,showTurnCue:A=!1,turnTimerText:R=null,isActiveDriver:k=!1,idleSkipSeconds:O=null}){const X=Je(ye=>ye.session),D=m.useRef(null),H=m.useRef(null),K=m.useRef(null),$=m.useRef(null),Y=m.useRef(null),ee=m.useRef(null),oe=m.useRef(null),ce=m.useRef(null),[z,q]=m.useState("idle"),[L,Z]=m.useState(null),[se,ue]=m.useState("idle"),[T,V]=m.useState(null),[te,ae]=m.useState(0),[he,re]=m.useState(0),[de,ve]=m.useState(!0),fe=!!s?.url,pe=l==="snapshot",Le=x?.sensors,{value:ke}=Ge("audio",rt),Ce=Number.isFinite(ke?.masterVolume)?ke.masterVolume:rt.masterVolume,_e=Number.isFinite(ke?.roverVolume)?ke.roverVolume:rt.roverVolume,ze=typeof ke?.mainBrushDuckEnabled=="boolean"?ke.mainBrushDuckEnabled:typeof ke?.autoLevelEnabled=="boolean"?ke.autoLevelEnabled:rt.mainBrushDuckEnabled,ht=Number.isFinite(ke?.mainBrushDuckAmount)?Math.max(0,Math.min(1,ke.mainBrushDuckAmount)):rt.mainBrushDuckAmount,ie=Math.max(0,Math.min(1,Ce*_e)),xe=Le?.batteryChargeMah??null,J=!(b==="desktop"),ge=J?"top-right":j,[Ne]=zg(),pt=M||J?!0:Ne,Ue=Ug({charge:xe,config:g}),ct=Le?.wheelOvercurrents||null,ut=ct==null?[]:Object.entries(ct).filter(([,ye])=>!!ye).map(([ye])=>ye),bt=C?.caps||null,Mt=C?.overcurrent?.groups||null,fs=m.useMemo(()=>{if(typeof window>"u")return{debugAudio:!1,debugHud:!1};const ye=new URLSearchParams(window.location.search);return{debugAudio:ye.has("debugAudio"),debugHud:ye.has("debugHud")}},[]),Yt=fs.debugAudio,za=fs.debugHud,Oo=m.useMemo(()=>{if(!bt)return null;const ye=Number.isFinite(bt?.drive?.cap)?bt.drive.cap:1,Qe=Number.isFinite(bt?.aux?.cap)?bt.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(ye,Qe)))},[bt]),Bn=!!C?.isActive,At=ut.length?ut:Bn?["limiter"]:[],Ft=Oo??(ut.length?1:0),Rt=!!At.length,fa=!!((Number(Le?.mainBrushCurrentMa)||0)>lA||Le?.wheelOvercurrents?.mainBrush),Lo=ze&&fa?1-ht:1,ms=Math.max(0,Math.min(1,ie*Lo)),hs=ze&&fa&&ht>0?`Volume decreased ${Math.round(ht*1e3)/10}%`:null,Ua=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Ua.current={hasDedicatedAudio:fe,audioUrl:s?.url||null,mainBrushDuckEnabled:ze,mainBrushDuckAmount:ht,mainBrushActive:fa,baseRoverGain:ie,effectiveRoverGain:ms}},[fe,s?.url,ze,ht,fa,ie,ms]);const et=m.useCallback((ye,Qe={})=>{if(!Yt)return;const Pe=H.current,Me=Ua.current,Ye={event:ye,ts:Date.now(),roverLabel:f||null,hasDedicatedAudio:Me.hasDedicatedAudio,audioUrl:Me.audioUrl,mainBrushDuckEnabled:Me.mainBrushDuckEnabled,mainBrushDuckAmount:Me.mainBrushDuckAmount,mainBrushActive:Me.mainBrushActive,baseRoverGain:Me.baseRoverGain,effectiveRoverGain:Me.effectiveRoverGain,element:Pe?{muted:Pe.muted,volume:Pe.volume,paused:Pe.paused,ended:Pe.ended,readyState:Pe.readyState,networkState:Pe.networkState}:null,...Qe};try{console.log(`[AudioDebug] ${ye} ${JSON.stringify(Ye)}`)}catch{console.log("[AudioDebug]",ye,Ye)}},[Yt,f]),On=X?.socials?.find(ye=>String(ye?.id||ye?.label||"").toLowerCase()==="discord")?.url||X?.discord?.invite||null;m.useEffect(()=>{za&&console.log("[OvercurrentHUD]",{overlayVisible:Rt,overlayMotors:At,overlayFill:Ft,limiterActive:Bn,limiterCaps:bt,limiterGroups:Mt,wheelOvercurrents:ct})},[za,Ft,At,Rt,Bn,bt,Mt,ct]),m.useEffect(()=>{et("settings/update")},[et]);const wn=m.useCallback(()=>{clearTimeout(K.current),K.current=setTimeout(()=>ae(Date.now()),ox)},[]),Ln=m.useCallback(()=>{clearTimeout($.current),$.current=setTimeout(()=>re(Date.now()),ox)},[]),ps=m.useCallback(async()=>{const ye=D.current;if(ye)try{ye.muted=!0,await ye.play()}catch{}},[]),hl=m.useCallback((ye=0)=>{if(h||fe)return;clearTimeout(ee.current);const Qe=()=>{clearTimeout(ee.current),ee.current=setTimeout(()=>{h||Pe()},aA)},Pe=async()=>{const Me=D.current;if(Me)try{await ps(),Me.muted=!1,await Me.play(),ve(!1)}catch{Me.muted=!0,ve(!0),Qe()}};ee.current=setTimeout(Pe,ye)},[ps,h,fe]);m.useEffect(()=>()=>{clearTimeout(K.current),clearTimeout($.current),clearTimeout(ee.current),clearInterval(Y.current),oe.current&&(cancelAnimationFrame(oe.current),oe.current=null)},[]),m.useEffect(()=>{z==="playing"&&hl(0)},[z,hl]),m.useEffect(()=>{pe&&(q("snapshot"),Z(null))},[pe]),m.useEffect(()=>{if(pe||!n?.url||!D.current)return;let ye=!0,Qe;const Pe=setTimeout(()=>ve(!0),0),Me=(Ye,lt)=>{ye&&(et("video/status",{nextStatus:Ye,info:lt||null}),q(Ye),Z(lt||null),Ye==="playing"&&ps(),["error","failed","disconnected","closed"].includes(Ye)&&wn())};return Qe=new ix({url:n.url,token:n.token,video:D.current,receiveAudio:!fe,onStatus:Me}),Qe.start().catch(Ye=>{ye&&(q("error"),Z(Ye.message),wn())}),()=>{ye=!1,clearTimeout(Pe),Qe?.stop()}},[pe,n?.url,n?.token,te,wn,ps,fe,et]),m.useEffect(()=>{z==="stopped"&&n?.url&&wn()},[z,n?.url,wn]),m.useEffect(()=>{const ye=H.current;if(!ye||!s?.url){et("route/no-audio-url"),ce.current=null;return}const Qe=Math.max(0,Math.min(1,ms)),Pe=ce.current==null?Math.max(0,Math.min(1,ye.volume)):ce.current;if(oe.current&&(cancelAnimationFrame(oe.current),oe.current=null),Qe>Pe){const Me=performance.now(),Ye=Pe,lt=Qe-Ye,it=wt=>{const at=Math.min(1,(wt-Me)/iA),zn=Ye+lt*at;ye.volume=zn,ce.current=zn,at<1?oe.current=requestAnimationFrame(it):oe.current=null};oe.current=requestAnimationFrame(it)}else ye.volume=Qe,ce.current=Qe;et("route/direct",{elementVolume:Qe,duckEnabled:ze,mainBrushActive:fa,duckAmount:ht})},[s?.url,ms,ze,fa,ht,et]),m.useEffect(()=>{if(!s?.url||!H.current)return;let ye=!0,Qe;const Pe=(Me,Ye)=>{ye&&(et("audio/status",{nextStatus:Me,info:Ye||null}),V(Ye||(Me==="connected"?"connected":null)),ue(lt=>Me==="connected"&&(lt==="playing"||lt==="connecting")||Me==="new"?lt:Me),["error","failed"].includes(Me)&&Ln())};return Qe=new ix({url:s.url,token:s.token,video:H.current,audioOnly:!0,onStatus:Pe}),Qe.start().catch(Me=>{ye&&(ue("error"),V(Me.message),Ln())}),()=>{ye=!1,Qe?.stop()}},[s?.url,s?.token,he,Ln,et]),m.useEffect(()=>{const ye=H.current;if(!s?.url||!ye){clearInterval(Y.current);return}if(!["connecting","connected","playing","paused"].includes(se)){clearInterval(Y.current);return}const Pe=async()=>{const Me=H.current;Me&&(Me.muted=!1,!(!Me.paused&&!Me.ended)&&(et("retry/play-attempt"),Me.play().then(()=>{et("retry/play-ok"),ue(Ye=>Ye==="connected"?"playing":Ye),V(Ye=>Ye==="paused"?null:Ye)}).catch(Ye=>{et("retry/play-fail",{error:Ye?.message}),V(lt=>lt||Ye?.message||"autoplay blocked")})))};return Pe(),Y.current=setInterval(Pe,sA),()=>clearInterval(Y.current)},[s?.url,se,et]),m.useEffect(()=>{const ye=H.current;if(!ye)return;const Qe=()=>{et("element/play"),ue(at=>at==="error"?at:"playing"),V(null)},Pe=()=>{et("element/pause"),ue(at=>["error","failed","disconnected","closed","stopped"].includes(at)?at:"paused"),V(at=>at||"paused")},Me=()=>{et("element/ended"),ue(at=>at==="error"?at:"stopped"),V(at=>at||"ended")},Ye=()=>{const{error:at}=ye,zn=at?.message||"audio error";et("element/error",{error:zn}),ue("error"),V(zn)},lt=()=>et("element/waiting"),it=()=>et("element/canplay"),wt=()=>et("element/stalled");return ye.addEventListener("play",Qe),ye.addEventListener("pause",Pe),ye.addEventListener("ended",Me),ye.addEventListener("error",Ye),ye.addEventListener("waiting",lt),ye.addEventListener("canplay",it),ye.addEventListener("stalled",wt),()=>{ye.removeEventListener("play",Qe),ye.removeEventListener("pause",Pe),ye.removeEventListener("ended",Me),ye.removeEventListener("error",Ye),ye.removeEventListener("waiting",lt),ye.removeEventListener("canplay",it),ye.removeEventListener("stalled",wt)}},[s?.url,et]);const pl=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",Ha=pe?pl:n?.url?z==="error"?`Error: ${L||"unknown"}`:L?`${z} (${L})`:z:"waiting",zo=s?.error?`Error: ${s.error}`:s?.url?se==="error"?`Error: ${T||"unknown"}`:T?`${se} (${T})`:se:null,xl=y==="spectator",nn=y==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${N?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${N?"h-full flex-1":"aspect-[4/3]"}`,children:[pe?o?.objectUrl?r.jsx("img",{src:o.objectUrl,alt:f,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:D,muted:h||de||fe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:H,autoPlay:!0,hidden:!0}),!nn&&A?r.jsx(XN,{mobileHud:J,isActiveDriver:k,idleSkipSeconds:O}):null,nn?null:r.jsx(nA,{sensors:Le,label:f,roverColor:p,status:Ha,audioStatus:zo,levelStatus:hs,layoutFormat:b,variant:y,driverLabel:S,showTopDown:pt,mobileHud:J,mapPosition:ge,turnTimerText:R,labelScale:E}),nn?null:r.jsx(fA,{compact:J}),!nn&&za?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:${Rt?1:0} motors:${At.length} fill:${Math.round(Ft*100)}%`}):null,nn?null:r.jsx(oA,{motors:At,fill:Ft,compact:J}),nn?null:r.jsx(cA,{battery:Ue,compact:J}),!nn&&xl&&Ue.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(Hd,{visual:Ue,orientation:"vertical",variant:"inline",compact:J,className:"h-full w-4"})}):null,!nn&&d?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 ${J?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[r.jsx("div",{className:"text-center",children:d}),r.jsx("div",{className:"pointer-events-auto mt-0",children:r.jsx(pf,{id:"discord",label:"Join our Discord server while you wait!",url:On})})]})}):null]}),!nn&&!xl&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(dA,{sensors:Le}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(Hd,{visual:Ue,compact:J})})]})]})}function gf({layoutFormat:n="desktop"}){const s=Je(ae=>ae.session),{state:{song:l,lastControlIntentAt:o},overcurrentLimiter:d}=Bt(),[f,p]=m.useState(()=>Date.now()),[h,x]=m.useState(!1),[g,b]=m.useState(null),y=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(s?.mode!=="turns")return;const ae=setInterval(()=>p(Date.now()),250);return()=>clearInterval(ae)},[s?.mode]);const S=s?.assignment?.roverId,j=!!(S&&s?.roster?s.roster.find(ae=>String(ae.id)===String(S)):null)?.media?.audioPublishUrl,E=S?s?.turnQueues?.[S]:null,N=s?.socketId||null,C=S?s?.activeDrivers?.[S]:null,A=!!(N&&C===N),R=m.useMemo(()=>{const ae=E?.queue||[];if(!ae.length||!E?.current||ae.length<=1)return null;const he=ae.findIndex(re=>re===E.current);return he===-1?ae[0]||null:ae[(he+1)%ae.length]||null},[E?.queue,E?.current]),k=!!(N&&R===N),O=E?.deadline||null,X=E?.idleDeadline||null,D=O?O-f:null,H=X?X-f:null,K=s?.mode==="turns"&&k&&D!=null&&D<=5e3&&D>0,$=s?.mode!=="turns"||A||K,Y=D!=null&&Number.isFinite(D)?Math.max(0,Math.ceil(D/1e3)):null,ee=H!=null&&Number.isFinite(H)?Math.max(0,Math.ceil(H/1e3)):null,oe=A?Y!=null?`${Y}s left`:null:k&&Y!=null?`Your turn in ${Y}s`:null,ce=S?[...$?[{type:"rover",id:S,key:S}]:[],...j?[{type:"rover",id:`${S}-audio`,key:`${S}-audio`}]:[]]:[],z=Ni(ce),q=S&&$?z[S]:null,L=S&&j?z[`${S}-audio`]:null,Z=hf(S?[S]:[],{enabled:!!S,version:s?.mode}),se=S&&Z[S]||null,ue=ml(S),T=S&&s?.roster?s.roster.find(ae=>String(ae.id)===String(S)):null,V=T?.battery??null,te=T?.name||(S?`Rover ${S}`:"");return m.useEffect(()=>{if(s?.mode!=="turns"){x(!1),b(null),y.current={active:!1,roverId:null};return}const ae=y.current,he=A&&!ae.active,re=A&&S&&S!==ae.roverId;he||re?(x(!0),b(Date.now())):!A&&ae.active&&(x(!1),b(null)),y.current={active:A,roverId:S}},[A,S,s?.mode]),m.useEffect(()=>{!h||!g||o>g&&x(!1)},[o,g,h]),r.jsx("section",{className:"panel",children:S?r.jsx(wi,{sessionInfo:q,videoMode:$?"whep":"snapshot",snapshotFeed:se,audioSessionInfo:L,label:te,roverColor:T?.color||null,telemetryFrame:ue,batteryConfig:V,layoutFormat:n,overcurrentLimiter:d,songNote:l?.note,qualityNotice:$?null:"Preview feed (low FPS) until your turn.",showTurnCue:h,turnTimerText:oe,turnSeconds:Y,isActiveDriver:A,idleSkipSeconds:ee}):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 So({label:n,tone:s="muted"}){const l=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 ${l}`,children:n})}function Ro(n){if(!Number.isFinite(n))return 0;const s=n%360;return s<0?s+360:s}function mA(n){if(!Array.isArray(n)||n.length<3)return 0;const[s,l,o]=n,d=Math.max(0,Math.min(255,Number(s)))/255,f=Math.max(0,Math.min(255,Number(l)))/255,p=Math.max(0,Math.min(255,Number(o)))/255,h=Math.max(d,f,p),x=Math.min(d,f,p),g=h-x;if(g===0)return 0;let b=0;return h===d?b=(f-p)/g%6:h===f?b=(p-d)/g+2:b=(d-f)/g+4,Ro(Math.round(b*60))}function cx(n){const s=Ro(n),l=1,o=1-Math.abs(s/60%2-1);let d=0,f=0,p=0;return s<60?(d=l,f=o):s<120?(d=o,f=l):s<180?(f=l,p=o):s<240?(f=o,p=l):s<300?(d=o,p=l):(d=l,p=o),[Math.round(d*255),Math.round(f*255),Math.round(p*255)]}function ux(n){return n?Array.isArray(n.hsColor)?Ro(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?mA(n.rgbColor):0:0}function hA({entity:n,connected:s,controlsLocked:l,onToggle:o,onSetColor:d,onSetWhite:f}){const p=n.state==="unavailable"||!n.available,h=n.state==="on",x=n.type==="light"&&n.supportsColor,g=p?"warn":h?"success":"muted",b=p?"Unavailable":h?"On":"Off",y=l||!s||p,S=y||!x,[M,j]=m.useState(()=>ux(n)),E=m.useRef(M),N=m.useRef(!1),C=p?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":l?"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(!x||N.current)return;const H=ux(n);E.current=H,j(H)},[n.rgbColor,n.hsColor,x]);const A=H=>{const K=Ro(Number(H.target.value));E.current=K,j(K)},R=()=>{S||!d||d(n.id,cx(E.current))},k=H=>{H.stopPropagation()},O=H=>{k(H),!(S||!f)&&f(n.id)},D=`rgb(${(x?cx(E.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 ${C} 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}),x&&r.jsxs(r.Fragment,{children:[r.jsx(So,{label:b,tone:g}),!s&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),x?r.jsx("div",{className:"-mt-0.5 w-full",onClick:k,onPointerDown:H=>{k(H),N.current=!0},onPointerUp:H=>{k(H),N.current=!1,R()},onPointerCancel:H=>{k(H),N.current=!1,R()},onKeyUp:H=>{k(H),R()},onBlur:R,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:M,onChange:A,disabled:S,"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(So,{label:b,tone:g}),!s&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),x&&r.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[r.jsx("span",{role:"button",tabIndex:S?-1:0,onClick:O,onPointerDown:k,onKeyDown:H=>{S||(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),O(H))},title:"Set white color temperature","aria-label":`Set ${n.name||n.id} to white`,"aria-disabled":S,className:`inline-flex items-center justify-center rounded border border-slate-200 bg-white px-1 py-0.5 text-xs font-semibold leading-none text-slate-900 ${S?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-slate-100"}`,children:"white"}),r.jsx("span",{className:"pointer-events-none h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:D}})]}),!x&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:h?"Turn off":"Turn on"})]})}function Vg(){const{state:{keymap:n}}=Bt(),s=Je(M=>M.session),{homeAssistantToggle:l,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:d}=gn(),f=s?.homeAssistant,p=m.useMemo(()=>f?.entities||[],[f?.entities]),h=f?.lightPolicy||null,x=!!(h?.locked||h?.lockedOn),g=h?.lockState||(h?.lockedOn?"on":null),b=Nn(n?.homeAssistantOn?.[0]),y=Nn(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(p.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 S=!!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:p.length}),x?r.jsx(So,{label:g==="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"}),b?r.jsx(dx,{label:b}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),y?r.jsx(dx,{label:y}):null]})]})]}),r.jsx(So,{label:S?"Connected":"Offline",tone:S?"success":"warn"})]}),x?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:g==="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:p.map(M=>r.jsx(hA,{entity:M,connected:S,controlsLocked:x,onToggle:l,onSetColor:o,onSetWhite:d},M.id))})]})}function dx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function $g(){const{login:n,setRole:s}=gn(),[l,o]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1);async function x(g){g.preventDefault(),h(!0);try{await n(l,d),o(""),f("")}catch(b){alert(b.message)}finally{h(!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:l,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:d,onChange:g=>f(g.target.value)}),r.jsx("button",{type:"submit",disabled:p,className:"button-dark w-full disabled:opacity-50",children:p?"Logging in…":"Login"})]})]})}function fx(...n){return n.filter(Boolean).join(" ")}function pA(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function xA(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function gA({title:n,roster:s=[],emptyText:l="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:l}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:s.map(d=>{const f=!!(d?.private?.enabled&&d?.private?.open),p=!!d?.locked;return r.jsxs("li",{className:fx("surface flex flex-wrap items-center justify-between gap-0.5",p?"bg-red-900/40":f?"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:ca(d.color,.16),children:d.name})}),r.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[r.jsx("span",{children:d.locked?"locked":"free"}),d.lockReason&&r.jsx("span",{className:"rounded bg-black/30 px-1",children:d.lockReason}),r.jsxs("span",{className:fx("font-semibold",xA(d)),children:["Battery ",pA(d)]})]})]}),o?o(d):null]},d.id)})})]})}function bA(n){const s=n?.runtime||{},l=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:l.posted?`Last: ${l.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 vA(n,s){const l=Date.now(),d=(Array.isArray(n)?n:[]).map((f,p)=>{const h=String(f?.role||"").toLowerCase(),x=typeof f?.content=="string"?f.content:JSON.stringify(f?.content??null,null,2),g=h==="system"?"LLM System":h==="assistant"?"LLM Context":h==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${p}`,message:{ts:l+p,nickname:g,text:x,role:"spectator",system:h==="system"}}});if(s!=null){const f=String(s);d.push({id:"llm-output",message:{ts:l+d.length+1,nickname:"LLM Output",text:f.trim()?f:"<empty>",role:"spectator",system:!0}})}return d}function yA({state:n,onClearHistory:s,clearingHistory:l}){const[o,d]=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 f=n.runtime||{},p=n.counters||{},h=n.timings||{},x=n.input||{},g=n.output||{},b=n.errors||{},y=Array.isArray(n.history)?n.history:[],S=y.find(N=>N.runId===o)||(y.length?y[y.length-1]:null),M=bA(n),j=vA(x.modelMessages,g.raw),E=[{label:"running",value:f.running?"yes":"no"},{label:"in flight",value:f.inFlight?"yes":"no"},{label:"phase",value:f.phase||"--"},{label:"run id",value:f.currentRunId??"--"},{label:"tick count",value:f.tickCount??0},{label:"last tick",value:f.lastTickAt?new Date(f.lastTickAt).toLocaleString():"never"},{label:"next run",value:f.nextRunAt?new Date(f.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:f.outcome||"--"},{label:"reason",value:f.reason||"--"},{label:"skip streak",value:p.skipStreak??0},{label:"clear count",value:p.clearCount??0},{label:"last gen",value:h.lastGenerationMs!=null?`${h.lastGenerationMs} ms`:"--"},{label:"avg gen",value:h.avgGenerationMs!=null?`${h.avgGenerationMs} ms`:"--"},{label:"gen count",value:h.generationCount??0},{label:"prompt chars",value:p.promptChars??0},{label:"active drivers",value:p.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:p.snapshotSummary?.rovers??0},{label:"snapshot chat",value:p.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:!!l,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:l?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${M.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:M.label}),r.jsx("div",{className:"text-xs text-slate-200",children:M.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:E.map(N=>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:[N.label,": ",N.value]},N.label))}),b.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",b.message]}):null,b.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(b.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:j.length?j.map(N=>r.jsx(lf,{message:N.message},N.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: ",b.failedAt?new Date(b.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:y.length?y.slice().reverse().map(N=>r.jsxs("button",{type:"button",onClick:()=>d(N.runId),className:`w-full text-left surface ${S?.runId===N.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",N.runId]})," ",r.jsx("span",{className:"text-slate-200",children:N.outcome||N.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:N.durationMs!=null?`${N.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:N.reason||""})]},N.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 SA({health:n,roster:s=[]}){if(!n)return null;const l=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},d=x=>s.find(g=>String(g.id)===String(x))?.color||null,f=`${l.readyCount}/${l.totalCount} sources ready`,p=o.rovers.filter(x=>x.stale).length,h=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:f})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rovers.length-p,"/",o.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rooms.length-h,"/",o.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:l.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"?ca(d(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:ca(d(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 jA({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(l=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:l.ts?new Date(l.ts).toLocaleTimeString():"--"})," ",l.label&&r.jsxs("span",{className:"text-teal-400",children:["[",l.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:l.message})," ",l.ip&&r.jsx("span",{className:"text-cyan-300",children:l.ip})," ",l.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(l.meta)})]},l.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const NA=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function AA(){const{session:n,lockRover:s,setMode:l,requestControl:o,setGlobalObjective:d,setAdminReason:f,rebootRover:p,rebootServer:h,setAudioLevels:x,setPrivateSafety:g,llmControl:b,adminLogs:y,llmCommentaryState:S}=da(),M=m.useMemo(()=>n?.roster??[],[n?.roster]),[j,E]=m.useState({}),[N,C]=m.useState({}),[A,R]=m.useState(!1),[k,O]=m.useState(!1),X=n?.health||null,D=n?.globalObjective?.text||"",H=n?.globalObjective?.updatedAt||null,[K,$]=m.useState(D),Y=n?.adminReason?.text||"",ee=n?.adminReason?.updatedAt||null,[oe,ce]=m.useState(Y),z=n?.audioLevels||{},[q,L]=m.useState({hornGain:Number.isFinite(z.hornGain)?z.hornGain:1,ttsGain:Number.isFinite(z.ttsGain)?z.ttsGain:1,forwardGain:Number.isFinite(z.forwardGain)?z.forwardGain:1}),[Z,se]=m.useState({}),ue=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",T=n?.role==="lockdown"||n?.role==="lockdown-admin",V=n?.mode??"open",te=async(le,J)=>{try{await s(le,J),E(ge=>({...ge,[le]:J}))}catch(ge){alert(ge.message)}},ae=async le=>{const J=le.target.value;try{await l(J)}catch(ge){alert(ge.message)}},he=async le=>{try{await o(le,{force:!0})}catch(J){alert(J.message)}},re=async le=>{if(!(!le?.id||!window.confirm(`Reboot rover "${le.name||le.id}" now?`))){C(ge=>({...ge,[le.id]:!0}));try{await p(le.id)}catch(ge){alert(ge.message)}finally{C(ge=>({...ge,[le.id]:!1}))}}},de=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){R(!0);try{await h()}catch(J){alert(J.message),R(!1)}}},ve=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){O(!0);try{await b("clearHistory")}catch(J){alert(J.message)}finally{O(!1)}}},fe=async()=>{try{await d(K)}catch(le){alert(le.message)}},pe=async()=>{try{await d(null)}catch(le){alert(le.message)}},Le=async()=>{try{await f(oe)}catch(le){alert(le.message)}},ke=async()=>{try{await f(null)}catch(le){alert(le.message)}},Ce=le=>J=>{const ge=Number(J.target.value);L(Ne=>({...Ne||{},[le]:Number.isFinite(ge)?ge:1}))},_e=async()=>{try{await x(q)}catch(le){alert(le.message)}},ze=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{$(D)},[D]),m.useEffect(()=>{ce(Y)},[Y]),m.useEffect(()=>{L({hornGain:Number.isFinite(z.hornGain)?z.hornGain:1,ttsGain:Number.isFinite(z.ttsGain)?z.ttsGain:1,forwardGain:Number.isFinite(z.forwardGain)?z.forwardGain:1})},[z.forwardGain,z.hornGain,z.ttsGain]),m.useEffect(()=>{const le={};(M||[]).forEach(J=>{J?.private?.enabled&&(le[J.id]={speedLimitEnabled:!!J?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(J?.private?.safety?.speedLimitMaxWheelSpeed)?J.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!J?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(J?.private?.safety?.overcurrentStopMs)?J.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!J?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(J?.private?.safety?.bumpBackoffSpeed)?J.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(J?.private?.safety?.bumpBackoffMs)?J.private.safety.bumpBackoffMs:350,cliffEnabled:!!J?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(J?.private?.safety?.cliffBackoffSpeed)?J.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(J?.private?.safety?.cliffBackoffMs)?J.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(J?.private?.safety?.triggerCooldownMs)?J.private.safety.triggerCooldownMs:800})}),se(le)},[M]);const ht=m.useMemo(()=>{const le={};return M.forEach(J=>{le[J.id]=j[J.id]??J.locked}),le},[M,j]),ie=(le,J={})=>{se(ge=>({...ge||{},[le]:{...ge?.[le]||{},...J||{}}}))},xe=async le=>{try{const J=Z?.[le];if(!J)return;await g(le,J)}catch(J){alert(J.message)}};return ue?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:ae,className:"field-input text-sm",children:NA.map(le=>r.jsx("option",{value:le.key,children:le.label},le.key))})]}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:de,disabled:A,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:A?"Server rebooting...":"Reboot Server"}),r.jsx("button",{type:"button",onClick:ze,className:"button-dark",children:"Test Reward Popup"})]}),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:[q.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:q.hornGain,onChange:Ce("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:[q.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:q.ttsGain,onChange:Ce("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:[q.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:q.forwardGain,onChange:Ce("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:_e,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:"Global objective"}),H?r.jsxs("span",{children:["Updated ",new Date(H).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:K,onChange:le=>$(le.target.value),placeholder:"Set a global objective",className:"field-input text-sm"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:fe,className:"button-dark",children:"Set objective"}),r.jsx("button",{type:"button",onClick:pe,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"}),ee?r.jsxs("span",{children:["Updated ",new Date(ee).toLocaleString()]}):null]}),r.jsx("textarea",{value:oe,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:Le,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:ke,className:"button-danger",children:"Clear"})]})]}),r.jsx(gA,{roster:M,renderActions:le=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>te(le.id,!ht[le.id]),className:"button-dark",children:ht[le.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>he(le.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>re(le),disabled:!!N[le.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:N[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:!!Z?.[le.id]?.speedLimitEnabled,disabled:!T,onChange:J=>ie(le.id,{speedLimitEnabled:!!J.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:!T,value:Z?.[le.id]?.speedLimitMaxWheelSpeed??250,onChange:J=>ie(le.id,{speedLimitMaxWheelSpeed:Number(J.target.value)||250})}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!Z?.[le.id]?.hardOvercurrentEnabled,disabled:!T,onChange:J=>ie(le.id,{hardOvercurrentEnabled:!!J.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:!!Z?.[le.id]?.hardBumpEnabled,disabled:!T,onChange:J=>ie(le.id,{hardBumpEnabled:!!J.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:!!Z?.[le.id]?.cliffEnabled,disabled:!T,onChange:J=>ie(le.id,{cliffEnabled:!!J.target.checked})}),r.jsx("span",{children:"Cliff safety"})]}),r.jsx("button",{type:"button",disabled:!T,onClick:()=>xe(le.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),r.jsx(SA,{health:X,roster:M}),r.jsx(yA,{state:S,onClearHistory:ve,clearingHistory:k}),r.jsx(jA,{entries:y})]}):null}const wA=[{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 CA(n){return n.reduce((s,l)=>((s[l.group]||(s[l.group]=[])).push(l),s),{})}function EA(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(0,Math.min(500,l)):s}const bf=5,Ci=500,Ei=1,vf=100;function kA(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(bf,Math.min(Ci,l)):s}function mo(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(Ei,Math.min(vf,l)):s}function MA(n){const l=(mo(n,n)-Ei)/(vf-Ei),o=Ci-l*(Ci-bf);return Math.round(o)}function RA(n){const s=kA(n,n),l=(Ci-s)/(Ci-bf),o=Ei+l*(vf-Ei);return Math.round(o)}function qA(n){const[s,l]=m.useState(null),o=m.useCallback(p=>{id(!0),l(p)},[]),d=m.useCallback(()=>{id(!1),l(null)},[]),f=m.useCallback((p,h)=>{if(h.preventDefault(),h.stopPropagation(),h.key==="Escape"){d();return}const x=Di(h.key??"");x&&(n(p,x,h),d())},[d,n]);return m.useEffect(()=>()=>id(!1),[]),{active:s,startCapture:o,cancel:d,captureFromEvent:f}}function eo({label:n,description:s,value:l,onChange:o,min:d=0,max:f=500,step:p=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:d,max:f,value:l,onChange:h=>o(h.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:d,max:f,step:p,value:l,onChange:h=>o(h.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:l})]})]})}function TA(){const{state:{keymap:n},actions:{updateKeyBinding:s,resetKeyBindings:l}}=Bt(),{value:o,save:d}=Ge("inputs",Rn),f={...Rn.keyboard,...o.keyboard??{}},p=m.useMemo(()=>typeof f.tiltSpeed=="number"?mo(f.tiltSpeed,Rn.keyboard.tiltSpeed):typeof f.tiltIntervalMs=="number"?mo(RA(f.tiltIntervalMs),Rn.keyboard.tiltSpeed):Rn.keyboard.tiltSpeed,[f.tiltIntervalMs,f.tiltSpeed]),h=m.useMemo(()=>CA(wA),[]),{active:x,startCapture:g,cancel:b,captureFromEvent:y}=qA((E,N)=>{s(E,N)}),S=m.useCallback(E=>n?.[E]?.[0]||gi[E]?.[0]||"",[n]),M=m.useCallback((E,N)=>{const C=Rn.keyboard,A=EA(N,C[E]);d(R=>({...R??{},keyboard:{...R?.keyboard??C,[E]:A}}))},[d]),j=m.useCallback(E=>{const N=Rn.keyboard,C=mo(E,N.tiltSpeed),A=MA(C);d(R=>({...R??{},keyboard:{...R?.keyboard??N,tiltSpeed:C,tiltIntervalMs:A}}))},[d]);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:()=>l(),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(eo,{label:"Base speed",description:"Normal driving speed",value:f.baseSpeed,onChange:E=>M("baseSpeed",E)}),r.jsx(eo,{label:"Turbo speed",description:"Used when holding the boost modifier",value:f.turboSpeed,onChange:E=>M("turboSpeed",E)}),r.jsx(eo,{label:"Precision speed",description:"Used when holding the precision modifier",value:f.precisionSpeed,onChange:E=>M("precisionSpeed",E)})]})]}),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(eo,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:p,onChange:j,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([E,N])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:E}),r.jsx("div",{className:"space-y-0.5",children:N.map(C=>{const A=S(C.id),R=x===C.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:C.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Nn(A)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[R&&r.jsx("button",{type:"button",onClick:()=>b(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(C.id),onKeyDown:R?k=>y(C.id,k):void 0,autoFocus:R,className:`${R?"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:R?"Press a key…":"Change"})]})]},C.id)})})]},E))})]})}const la=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),DA=[{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"}],mx=.45,_A=.6;function mi({label:n,description:s,min:l,max:o,step:d,value:f,onChange:p}){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:la.format(f)})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsx("input",{type:"range",min:l,max:o,step:d,value:f,onChange:h=>p(Number(h.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function BA(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} ${la.format(n.threshold??.6)}`}return"Unassigned"}function OA(n){return n.reduce((s,l)=>((s[l.section]||(s[l.section]=[])).push(l),s),{})}function LA(n,s){if(!n||n.length===0)return null;if(s){const l=n.find(o=>o.signature===s);if(l)return l}return n[0]}function zA(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 UA(n,s,l){const o=(n.axes??[]).map((f,p)=>({index:p,delta:Math.abs((f??0)-(s.axes?.[p]??0)),value:f}));if(o.sort((f,p)=>p.delta-f.delta),l.kind==="axisPair"){const f=o.filter(p=>p.delta>mx).slice(0,2);return f.length<2?null:{kind:"axisPair",x:f[0].index,y:f[1].index,...l.invertDefaults??{}}}const d=o.find(f=>f.delta>mx);return d?{kind:"axis",index:d.index,...l.invertDefaults??{}}:null}function HA(n,s,l){const o=n.buttons??[];for(let f=0;f<o.length;f+=1){const p=o[f],h=typeof p?.value=="number"?p.value:p?.pressed?1:0;if(p?.pressed||h>_A)return l.kind==="axis"?{kind:"buttonAxis",index:f}:{kind:"button",index:f}}const d=n.axes??[];for(let f=0;f<d.length;f+=1){const p=d[f]??0,h=Math.abs(p-(s.axes?.[f]??0));if(Math.abs(p)>.7&&h>.5)return l.kind==="axis"?{kind:"axis",index:f,...l.invertDefaults??{}}:{kind:"axisButton",index:f,direction:p>=0?1:-1,threshold:.6}}return null}function VA(n,s,l){if(!n)return null;if(l.kind==="axis"||l.kind==="axisPair"){const o=UA(n,s,l);if(o)return o}return HA(n,s,l)}function $A(){const n=hN(),{value:s,save:l}=Ge("gamepad",Oa),[o,d]=m.useState(null),f=m.useRef(null),p=m.useMemo(()=>OA(DA),[]),h=m.useMemo(()=>LA(n.pads,s.activeSignature),[n.pads,s.activeSignature]),x=h?.signature??null,g=m.useMemo(()=>x?s?.profiles?.[x]??s?.defaults?.profile??ia:s?.defaults?.profile??ia,[x,s?.defaults?.profile,s?.profiles]);m.useEffect(()=>{!h||!x||s?.profiles?.[x]||l(N=>{const C=N??Oa;if(C.profiles?.[x])return C;const A=C?.defaults?.profile??ia,R=Cg(h,A);return{...C,profiles:{...C.profiles??{},[x]:R}}})},[h,x,s?.profiles,l]),m.useEffect(()=>{f.current=null},[o,x]),m.useEffect(()=>{if(!o||!h)return;if(!f.current){f.current=zA(h);return}const N=VA(h,f.current,o);N&&(l(C=>{const A=C??Oa,R=A.profiles?.[x]??A?.defaults?.profile??ia,k={...R,bindings:{...R.bindings??{},[o.id]:{...R.bindings?.[o.id]??{},kind:o.kind,sources:[N]}}};return{...A,profiles:{...A.profiles??{},[x]:k}}}),d(null))},[h,x,o,l]);const b=m.useCallback(N=>{l(C=>({...C??Oa,activeSignature:N||null}))},[l]),y=m.useCallback(N=>{l(C=>{const A=C??Oa,R=(x&&A.profiles?.[x])??A?.defaults?.profile??ia,k={...R,calibration:{...R.calibration??{},...N}};return x?{...A,profiles:{...A.profiles??{},[x]:k}}:{...A,defaults:{...A.defaults??{},profile:k}}})},[x,l]),S=m.useCallback((N,C)=>{l(A=>{const R=A??Oa,k=(x&&R.profiles?.[x])??R?.defaults?.profile??ia,O=C(k.bindings?.[N]??{}),X={...k,bindings:{...k.bindings??{},[N]:O}};return x?{...R,profiles:{...R.profiles??{},[x]:X}}:{...R,defaults:{...R.defaults??{},profile:X}}})},[x,l]),M=m.useCallback(N=>{S(N.id,C=>({...C,sources:[]}))},[S]),j=m.useCallback((N,C)=>{S(N.id,A=>{const R=Array.isArray(A.sources)?[...A.sources]:[];if(!R[0])return A;const k={...R[0]};return C==="invertX"?k.invertX=!k.invertX:C==="invertY"?k.invertY=!k.invertY:k.invert=!k.invert,R[0]=k,{...A,sources:R}})},[S]),E=m.useMemo(()=>h?{outputs:Eg(h,g)}:null,[h,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:h?"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:N=>b(N.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(N=>r.jsx("option",{value:N.signature,children:N.id||"Unknown controller"},N.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:h?.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(mi,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:N=>y({driveDeadzone:N})}),r.jsx(mi,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:N=>y({cameraDeadzone:N})}),r.jsx(mi,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:N=>y({auxDeadzone:N})}),r.jsx(mi,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:N=>y({auxSideScale:N})}),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:N=>y({cameraMode:N.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(mi,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:N=>y({cameraSensitivity:N})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([N,C])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:N}),r.jsx("div",{className:"space-y-0.5",children:C.map(A=>{const k=g.bindings?.[A.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:A.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:BA(k)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[A.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!k,onClick:()=>j(A,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!k,onClick:()=>j(A,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),A.kind==="axis"&&r.jsx("button",{type:"button",disabled:!k,onClick:()=>j(A),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>M(A),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>d(A),className:`${o?.id===A.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===A.id?"Waiting…":"Capture"})]})]},A.id)})})]},N))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),h?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:h.axes.map((N,C)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",C,": ",la.format(N)]},`axis-${C}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.buttons.map((N,C)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",C,": ",la.format(N.value)," ",N.pressed?"●":""]},`btn-${C}`))}),E?.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: ",la.format(E.outputs.driveVector.x),","," ",la.format(E.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",la.format(E.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",la.format(E.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",la.format(E.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const GA={drive:"Drive wheels",aux:"Aux motors"};function hx(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function YA({value:n,color:s="bg-emerald-500"}){const l=`${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:l}})})}function FA(){const{state:{roverId:n},overcurrentLimiter:s}=Bt(),l=m.useMemo(()=>os.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:[l.map(o=>{const d=s?.caps?.[o]?.cap??0,f=s?.overcurrent?.groups?.[o]??!1,p=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:GA[o]||o}),r.jsx("span",{className:f?"text-red-300":"text-slate-400",children:f?"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:hx(d)})]}),r.jsx(YA,{value:d,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:hx(p)})]})]})]},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 Gg=m.createContext(null);function Yg(){const n=m.useContext(Gg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const px={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"}},xx={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"},Fg="primary";function yf(...n){return n.filter(Boolean).join(" ")}function Sf({children:n,defaultTab:s,currentTab:l,onTabChange:o,variant:d=Fg}){const[f,p]=m.useState(s??null),[h,x]=m.useState([]),g=m.useCallback(M=>M?(x(j=>j.includes(M)?j:[...j,M]),()=>x(j=>j.includes(M)?j.filter(E=>E!==M):j)):()=>{},[]),b=l??f??h[0]??null;m.useEffect(()=>{s&&l===void 0&&p(s)},[s,l]);const y=m.useCallback(M=>{M&&(l===void 0&&p(M),o&&o(M))},[l,o]),S=m.useMemo(()=>({activeTab:b,setActiveTab:y,registerTab:g,variant:d}),[b,y,g,d]);return r.jsx(Gg.Provider,{value:S,children:n})}function jf({children:n,className:s=""}){return r.jsx("div",{className:yf("flex gap-0.5",s),children:n})}function Wt({id:n,children:s,className:l="",disabled:o=!1,highlight:d="none"}){const{activeTab:f,setActiveTab:p,registerTab:h,variant:x}=Yg();m.useEffect(()=>h(n),[n,h]);const g=px[x]??px[Fg],b=f===n,y=xx[d]||xx.none,S=yf(g.base,y||(b?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",l);return r.jsx("button",{type:"button",className:S,onClick:()=>!o&&p(n),"aria-pressed":b,"aria-disabled":o,children:s})}function Nf({children:n,className:s=""}){return r.jsx("div",{className:yf("mt-0 space-y-0.5",s),children:n})}function en({id:n,children:s,keepMounted:l=!1}){const{activeTab:o}=Yg(),d=o===n;return!d&&!l?null:!d&&l?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:s}):r.jsx(r.Fragment,{children:s})}function XA(){const{session:n}=da(),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 gx=300,bx=240;function QA(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,(l,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function KA(n){const l=n.map(o=>QA(o)).join(" ");return l.length>bx?`${l.slice(0,bx)}…`:l}function ZA(){const n=tn(),[s,l]=m.useState([]),o=m.useMemo(()=>s.reduce((d,f)=>(f.direction==="in"&&(d.in+=1),f.direction==="out"&&(d.out+=1),d),{in:0,out:0}),[s]);return m.useEffect(()=>{const d=(x,g,b)=>{l(y=>{const S=[...y,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:KA(b),timestamp:new Date().toLocaleTimeString()}];return S.length>gx?S.slice(-gx):S})},f=(x,...g)=>d("in",x,g),p=(x,...g)=>d("out",x,g);n.onAny(f);let h=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(p),h=()=>n.offAnyOutgoing(p);else{const x=n.emit.bind(n);n.emit=(g,...b)=>(p(g,...b),x(g,...b)),h=()=>{n.emit=x}}return()=>{n.offAny(f),h&&h()}},[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:()=>l([]),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(d=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-slate-400",children:d.timestamp})," ",r.jsxs("span",{className:d.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",d.direction.toUpperCase(),"]"]})," ",r.jsx("span",{className:"text-cyan-300",children:d.event})," ",r.jsx("span",{className:"text-slate-200",children:d.payload})]},d.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const IA=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Xg(){const{state:{roverId:n},actions:{sendOiCommand:s,setSensorStream:l}}=Bt(),o=!!n,[d,f]=zg(),p=tn(),{value:h,save:x}=Ge("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:b}=Ge("audio",rt),y=h?.connectionTransport||"websocket",S=!!h?.swapMobileControlColumns,M=typeof h?.driveMacroBackoffEnabled=="boolean"?h.driveMacroBackoffEnabled:!0,j=Number.isFinite(g?.masterVolume)?g.masterVolume:rt.masterVolume,E=Number.isFinite(g?.alertVolume)?g.alertVolume:rt.alertVolume,N=Number.isFinite(g?.roverVolume)?g.roverVolume:rt.roverVolume,C=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:rt.mainBrushDuckEnabled,A=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):rt.mainBrushDuckAmount,R=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),k=$=>{n&&l($)},O=$=>{const Y=$.target.value;x(ee=>({...ee??{},connectionTransport:Y})),p?.io?.opts&&(p.io.opts.transports=Y==="polling"?["polling"]:["websocket","polling"],p.disconnect(),p.connect())},X=$=>Y=>{const ee=Number(Y.target.value),oe=Number.isFinite(ee)?Math.max(0,Math.min(1,ee)):0;b(ce=>({...ce??{},[$]:oe}))},D=$=>{const Y=!!$.target.checked;b(ee=>({...ee??{},mainBrushDuckEnabled:Y}))},H=$=>{const Y=!!$.target.checked;x(ee=>({...ee??{},swapMobileControlColumns:Y}))},K=$=>{const Y=!!$.target.checked;x(ee=>({...ee??{},driveMacroBackoffEnabled:Y}))};return r.jsxs(Sf,{defaultTab:"keybindings",children:[r.jsxs(jf,{children:[r.jsx(Wt,{id:"keybindings",children:"Keybindings"}),r.jsx(Wt,{id:"controller",children:"Controller"}),r.jsx(Wt,{id:"page",children:"Page settings"}),r.jsx(Wt,{id:"admin",children:"Admin"})]}),r.jsxs(Nf,{children:[r.jsx(en,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(TA,{})})}),r.jsx(en,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx($A,{})})}),r.jsx(en,{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:d,onChange:$=>f($.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:H}),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:M,onChange:K}),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(j*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:j,onChange:X("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(E*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:X("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(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:X("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:C,onChange:D})]}),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(A*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:A,onChange:X("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!C})]}),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:y,onChange:O,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(en,{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:IA.map($=>r.jsx("button",{type:"button",onClick:()=>s($.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:$.label},$.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:R.map($=>r.jsx("button",{type:"button",onClick:()=>k($.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:$.label},$.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx($g,{}),r.jsx(FA,{}),r.jsx(AA,{}),r.jsx(XA,{}),r.jsx(ZA,{})]})})]})]})}const vx={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 JA(n){return vx[n]||vx.desktop}function Qg({actionId:n,keymap:s}){const l=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:Nn(l)})}function yx(n,s){return n.map((l,o)=>typeof l=="string"?r.jsx("span",{children:l},`text-${o}`):l?.action?r.jsx(Qg,{actionId:l.action,keymap:s},`pill-${l.action}-${o}`):l?.text?r.jsx("span",{children:l.text},`span-${o}`):null)}function qo(n,s,l){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return yx(n.segments,s);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return yx(n,s)}return String(n??"")}function PA({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(l=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:l},l))})]}),n.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((l,o)=>{const d=Array.isArray(l?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(l,s)},d)})})]}):null}function WA({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((l,o)=>{const d=`item-${o}`;return r.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:qo(l,s)},d)})})]})}function ew({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((l,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(l,{})},`callout-${o}`))})]})}function tw({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(l=>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:l.label}),r.jsx(Qg,{actionId:l.action,keymap:s})]},l.action))})]})}function nw({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(l=>r.jsx(tw,{group:l,keymap:s},l.id))})]}):null}function aw({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,l)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(s,{})},`gamepad-${l}`))})]}):null}function Sx({block:n,keymap:s}){if(!n)return null;switch(n.type){case"list":return r.jsx(WA,{block:n,keymap:s});case"callout":return r.jsx(ew,{block:n});case"keyboard":return r.jsx(nw,{block:n,keymap:s});case"gamepad":return r.jsx(aw,{block:n});default:return null}}function Kg({layout:n,keymap:s}){const l=m.useMemo(()=>JA(n),[n]),o=s||{},d=l.main||[],f=l.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(PA,{hero:l.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:d.map((p,h)=>r.jsx(Sx,{block:p,keymap:o},p.title||h))}),r.jsx("div",{className:"space-y-0.5",children:f.map((p,h)=>r.jsx(Sx,{block:p,keymap:o},p.title||h))})]})]})}function Zg({layout:n,onOpenOverlay:s}){const{state:l}=Bt();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(Kg,{layout:n,keymap:l?.keymap||{}})]})}const sw=["kal","rms","slt","ksp","bdl"],lw=Array.from({length:10},(n,s)=>s*10);function To({hideInput:n=!1,hideSpectatorNotice:s=!1,fillHeight:l=!1,allowSpectatorInput:o=!1}){const d=Je(T=>T.session),{messages:f,typing:p,sendMessage:h,registerInputRef:x,onInputFocus:g,onInputBlur:b,blurChat:y,setTypingActive:S}=cf(),{value:M,save:j}=Ge("tts",{engine:"flite",voice:"rms",pitch:50}),[E,N]=m.useState(""),[C,A]=m.useState(!1),[R,k]=m.useState(!1),[O,X]=m.useState(()=>M?.engine||"flite"),[D,H]=m.useState(()=>M?.voice||"rms"),[K,$]=m.useState(()=>Number.isFinite(M?.pitch)?M.pitch:50),Y=d?.role!=="spectator"||o,ee=m.useRef(null),oe=d?.assignment?.roverId||null,z=!!m.useMemo(()=>d?.roster?.find(T=>String(T.id)===String(oe))||null,[oe,d?.roster])?.audio?.ttsEnabled,q=m.useMemo(()=>f.slice(-200),[f]),L=m.useMemo(()=>p||[],[p]);m.useEffect(()=>{ee.current&&(ee.current.scrollTop=ee.current.scrollHeight)},[q,L]),m.useEffect(()=>{const T=M?.engine||"flite",V=M?.voice||"rms",te=Number.isFinite(M?.pitch)?M.pitch:50;O!==T&&X(T),D!==V&&H(V),K!==te&&$(te)},[O,K,M?.engine,M?.pitch,M?.voice,D]),m.useEffect(()=>{k(!!z)},[z]);const Z=m.useMemo(()=>!z||!R?null:O==="espeak"?{speak:!0,engine:O,pitch:K}:{speak:!0,engine:O,voice:D},[O,K,R,z,D]);async function se(T){if(T.preventDefault(),!Y||n)return;const te=E.replace(/\\n/g,`
`).trim();if(te){A(!0);try{await h(te,Z),N(""),y(),S(!1)}catch(ae){alert(ae.message)}finally{A(!1)}}}const ue=l?"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 ${l?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${ue}`,ref:ee,children:[q.length===0&&L.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):q.map(T=>r.jsx(lf,{message:T},T.id)),L.map(T=>r.jsx(xg,{message:T},`typing-${T.typingId||T.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:E,onChange:T=>{const V=T.target.value;N(V),S(!!V.trim())},onFocus:T=>{g(T),S(!!E.trim())},onBlur:T=>{b(T),S(!1)},onKeyDown:T=>{T.key==="Enter"&&!E.trim()&&(T.preventDefault(),y(),S(!1))},ref:T=>x(T,{target:"panel"}),placeholder:Y?"Type a message…":s?"":"Spectators cannot chat",disabled:!Y}),z&&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:R,onChange:T=>k(T.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:O,onChange:T=>{const V=T.target.value;X(V),j(te=>({...te||{},engine:V}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),O==="flite"?r.jsx("select",{value:D,onChange:T=>{const V=T.target.value;H(V),j(te=>({...te||{},voice:V}))},className:"field-input text-xs",children:sw.map(T=>r.jsx("option",{value:T,children:T},T))}):r.jsx("select",{value:K,onChange:T=>{const V=Number(T.target.value);$(V),j(te=>({...te||{},pitch:V}))},className:"field-input text-xs",children:lw.map(T=>r.jsxs("option",{value:T,children:["pitch ",T]},T))})]}),r.jsx("button",{type:"submit",disabled:!Y||C,className:"button-dark h-full disabled:opacity-50 self-stretch",children:C?"...":"Send"})]})]})}function Do({compact:n=!1}){const{session:s,setNickname:l}=da(),{value:o,save:d}=Ge("profile",{nickname:""}),[f,p]=m.useState(o.nickname||""),[h,x]=m.useState(!1),g=s?.role!=="spectator";m.useEffect(()=>{p(o.nickname||"")},[o.nickname]);async function b(y){if(y.preventDefault(),!g)return;const S=(f||"").trim().slice(0,32);if(S){x(!0);try{await l(S),d({nickname:S})}catch(M){alert(M.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:b,children:[r.jsx("input",{className:"field-input flex-1 min-w-0",value:f,onChange:y=>p(y.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||h,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:h?"Saving…":n?"Set":"Save"})]})}function iw(n){const s=Array.isArray(n?.socials)?n.socials:null;if(s&&s.length)return s;const l=[];return n?.discord?.invite&&l.push({id:"discord",label:"Discord",url:n.discord.invite}),n?.kofi?.link&&l.push({id:"kofi",label:"Ko-fi",url:n.kofi.link}),l}function rw(n){if(!n||typeof n!="object")return null;const s=n.id||n.service||n.key||n.name||null,l=n.label||n.title||n.name||s||"Link",o=n.url||n.link||n.href||null;return o?{id:s,label:l,url:o}:null}function Ig({className:n=""}){const{session:s}=da(),l=iw(s).map(rw).filter(Boolean).slice(0,4);return l.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:l.map(o=>r.jsx(pf,{...o},`${o.id||o.label}-${o.url}`))}):null}function ow({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(Do,{compact:n})})})}function cw(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Ig,{className:"flex-1 min-h-0"})})}function yd(...n){return n.filter(Boolean).join(" ")}function uw(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function dw(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function fw(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 mw(n,s){if(!n)return"";const l=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${l} (you)`:l}function _o({title:n="Rovers"}){const s=Je(C=>C.session),{requestControl:l}=gn(),[o,d]=m.useState({}),[f,p]=m.useState(()=>Date.now()),h=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??[],b=s?.turnQueues??{},y=s?.users??[],S=s?.socketId||null,M=m.useMemo(()=>Object.values(b||{}).some(C=>C?.deadline||C?.idleDeadline),[b]);m.useEffect(()=>{if(!M)return;const C=setInterval(()=>{p(Date.now())},1e3);return()=>clearInterval(C)},[M]);const j=m.useMemo(()=>{const C=new Set(g.map(R=>String(R.id))),A=Object.keys(b||{}).filter(R=>!C.has(String(R))).map(R=>({id:R,name:R,locked:!1,batteryState:null}));return[...g,...A]},[g,b]);async function E(C){if(C){d(A=>({...A,[C]:!0}));try{await l(C)}catch(A){alert(A.message)}finally{d(A=>({...A,[C]:!1}))}}}const N=C=>y.find(A=>A.socketId===C)||{socketId:C,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}),j.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:j.map(C=>{const A=String(C.id),R=b?.[A]||null,k=R?.queue||[],O=R?.idleDeadline||R?.deadline||null,X=O&&O>f?Math.ceil((O-f)/1e3):O?0:null,D=R?.current||null,H=D?k.findIndex(se=>se===D):-1,K=k.length>1?H>=0?k[(H+1)%k.length]:k[0]:null,$=!!(S&&D&&D===S),Y=!!(S&&K&&K===S),ee=X!=null&&($||Y),oe=!!C.locked,ce=oe&&!x,z=!!(C?.private?.enabled&&C?.private?.open),q=C.lockReason?`locked: ${C.lockReason}`:"locked",L=oe?q:o[A]?"...":"request",Z=h&&!ce&&!o[A];return r.jsxs("li",{className:yd("surface flex flex-wrap items-start justify-between gap-0.5",Z&&"cursor-pointer",oe?"bg-red-900/40":z?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{Z&&E(C.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:ca(C.color,.16),children:C.name})}),ee?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:$?`${X}s left`:`Your turn in ${X}s`}):null]}),r.jsx("span",{className:yd("text-[0.75rem] font-semibold",dw(C)),children:uw(C)})]}),k.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:k.map((se,ue)=>{const T=N(se),V=se===D,te=!!(K&&se===K&&!V),ae=V?"bg-sky-600 text-white ring-2 ring-amber-300":te?"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] ${ae}`,children:[r.jsx("span",{className:`${fw(T.role)} font-semibold`,children:mw(T,S)}),V&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),te&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${A}-${se}-${ue}`)})})]}),h?r.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),E(C.id)},disabled:o[A]||ce,className:yd("button-dark disabled:opacity-40",oe&&"bg-red-600/70 text-white hover:bg-red-600"),children:L}):null]},C.id)})})]})}function hw(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 pw(n,s){if(!n)return"";const l=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${l} (you)`:l}function jo({hideNicknameForm:n=!1,hideHeader:s=!1,className:l="",fillHeight:o=!1,compact:d=!1}){const f=Je(y=>y.session),p=f?.role!=="spectator",h=f?.users??[],x=f?.socketId||null,g=m.useMemo(()=>[...h].sort((y,S)=>y.socketId===x?-1:S.socketId===x?1:(y.nickname||"").localeCompare(S.nickname||"")),[x,h]),b=o?"flex-1 min-h-0 overflow-y-auto":d?"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":""} ${l}`,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(Do,{compact:d})})}),r.jsx(Ig,{})]}),!p&&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 ${d?"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 ${b} ${d?"text-[0.8rem]":""}`,children:g.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(y=>r.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${hw(y.role)}`,children:pw(y,x)},y.socketId))})]})]})}const xw=/^cu_[a-f0-9]{32}$/,ki="field-input w-full max-w-sm text-left focus:ring-emerald-500",Bo="mx-auto w-full max-w-xl flex justify-center",vi="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function gw(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 jx=8*1024*1024,rs=16e3,bw={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function Nx(n){let s="";for(let o=0;o<n.length;o+=32768){const d=n.subarray(o,o+32768);s+=String.fromCharCode(...d)}return btoa(s)}function vw(n){return typeof btoa=="function"?btoa(n):""}function yw(n){if(!n)return{};const s=vw(`${n}:${n}`);return s?{Authorization:`Basic ${s}`}:{}}function Sw(n,s=1500){return new Promise(l=>{if(!n||n.iceGatheringState==="complete"){l();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",d),l()},s);function d(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",d),l())}n.addEventListener("icegatheringstatechange",d)})}function Ax(n){if(!n)return!1;const s=n.connectionState,l=n.iceConnectionState;return s==="connected"||l==="connected"||l==="completed"}function jw(n,s=1e4){return new Promise((l,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(Ax(n)){l();return}const d=setTimeout(()=>{p(),o(new Error("Peer connection timeout"))},s),f=()=>{Ax(n)?(p(),l()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(p(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function p(){clearTimeout(d),n.removeEventListener("connectionstatechange",f),n.removeEventListener("iceconnectionstatechange",f)}n.addEventListener("connectionstatechange",f),n.addEventListener("iceconnectionstatechange",f)})}async function Nw(n){if(!n?.getParameters||!n?.setParameters)return;const s=n.getParameters()||{},l=s.encodings&&s.encodings[0]||{};s.encodings=[{...l,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(s)}catch{}}function Aw(n,s=6e3){return new Promise((l,o)=>{if(!n){o(new Error("Peer connection missing"));return}const d=Date.now();let f=-1;const p=setInterval(async()=>{if(Date.now()-d>s){clearInterval(p),o(new Error("WHIP connected but no outbound audio flow"));return}try{const h=n.getSenders().filter(x=>x.track?.kind==="audio");for(const x of h){const g=await x.getStats();for(const b of g.values()){if(b.type!=="outbound-rtp"||b.kind!=="audio")continue;const y=Number(b.bytesSent||0),S=Number(b.packetsSent||0);if(f<0)f=y;else if(y>f+200||S>5){clearInterval(p),l();return}}}}catch{}},250)})}function ww(n){const s=n.reduce((d,f)=>d+f.length,0),l=new Float32Array(s);let o=0;for(const d of n)l.set(d,o),o+=d.length;return l}function Cw(n){const s=new Int16Array(n.length);for(let l=0;l<n.length;l+=1){const o=Math.max(-1,Math.min(1,n[l]));s[l]=o<0?o*32768:o*32767}return s}function Ew(n,s){const l=Cw(n),o=l.length*2,d=new ArrayBuffer(44+o),f=new DataView(d),p=(x,g)=>{for(let b=0;b<g.length;b+=1)f.setUint8(x+b,g.charCodeAt(b))};p(0,"RIFF"),f.setUint32(4,36+o,!0),p(8,"WAVE"),p(12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,1,!0),f.setUint16(22,1,!0),f.setUint32(24,s,!0),f.setUint32(28,s*2,!0),f.setUint16(32,2,!0),f.setUint16(34,16,!0),p(36,"data"),f.setUint32(40,o,!0);let h=44;for(let x=0;x<l.length;x+=1,h+=2)f.setInt16(h,l[x],!0);return new Uint8Array(d)}function pn({label:n,active:s,detail:l=""}){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:l||(s?"active":"idle")})]})}function wx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function kw({ownRoverId:n="",audioForwardByRover:s={},playUploadedAudio:l,stopUploadedAudio:o,startMicWhip:d,readyMicWhip:f,stopMicWhip:p}){const{state:h}=Bt(),{value:x,save:g}=Ge("vipAudio",{openMicEnabled:!1,pttMode:"live"}),b=String(n||"").trim(),[y,S]=m.useState(null),[M,j]=m.useState(!1),E=!!x?.openMicEnabled,C=(x?.pttMode==="clip"?"clip":"live")==="clip",[A,R]=m.useState("idle"),[k,O]=m.useState("idle"),[X,D]=m.useState(""),H=m.useRef(null),K=m.useRef(null),$=m.useRef(null),Y=m.useRef(!1),ee=m.useRef(""),oe=m.useRef(null),ce=m.useRef(null),z=m.useRef(null),q=m.useRef(null),L=m.useRef(null),Z=m.useRef([]),se=m.useRef(!1),ue=m.useRef(rs),T=!!h?.mic?.pttActive,V=m.useMemo(()=>b&&s?.[b]||null,[s,b]),te=!!(V&&V.state!=="offline"&&!V.error),ae=V?.source==="upload"&&V?.state==="playing",he=V?.source==="mic-whip"&&(V?.state==="starting"||V?.state==="playing"),re=!!(!C&&K.current&&(E||T)),de=!C&&(A==="live"||A==="starting"),ve=C&&k==="recording",fe=C&&k==="sending",pe=Nn(h?.keymap?.micPtt?.[0])||"M",Le=m.useCallback(J=>{const ge=J==="clip"?"clip":"live";g(Ne=>({...Ne||{},pttMode:ge}))},[g]),ke=async()=>{if(!b){D("Take control of your rover first.");return}if(!y){D("Select an audio file first.");return}if(y.size>jx){D(`File too large (max ${jx} bytes).`);return}j(!0),D("");try{const J=await y.arrayBuffer(),ge=Nx(new Uint8Array(J));await l?.({roverId:b,name:y.name,mime:y.type||"",dataBase64:ge}),D("Upload playback started.")}catch(J){D(J?.message||"Failed to play upload.")}finally{j(!1)}},Ce=async()=>{if(!b){D("Take control of your rover first.");return}j(!0),D("");try{await o?.(b),D("Upload playback stopped.")}catch(J){D(J?.message||"Failed to stop upload.")}finally{j(!1)}},_e=m.useCallback(async J=>{const ge=String(J||ee.current||"").trim();if(Y.current=!1,R("idle"),$.current){try{$.current.getSenders().forEach(Ne=>Ne.track?.stop())}catch{}try{$.current.close()}catch{}}if($.current=null,H.current)try{H.current.getTracks().forEach(Ne=>Ne.stop())}catch{}if(H.current=null,K.current=null,ge)try{await p?.(ge)}catch{}ee.current=""},[p]),ze=m.useCallback(async J=>{const ge=await d?.(J),Ne=String(ge?.whipUrl||"").trim(),pt=String(ge?.token||"").trim();if(!Ne||!pt)throw new Error("WHIP endpoint unavailable");const Ue=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:rs,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});H.current=Ue;const ct=Ue.getAudioTracks()?.[0];if(K.current=ct||null,ct&&(ct.enabled=!!(E||T)),ct?.applyConstraints)try{await ct.applyConstraints({channelCount:1,sampleRate:rs,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const ut=new RTCPeerConnection(bw);$.current=ut,ut.onconnectionstatechange=()=>{if(!Y.current)return;const Yt=ut.connectionState;if(Yt==="connected"){R("live");return}(Yt==="failed"||Yt==="disconnected"||Yt==="closed")&&(R("error"),D(`WHIP transport ${Yt}.`))},Ue.getAudioTracks().forEach(Yt=>{const za=ut.addTrack(Yt,Ue);Nw(za)});const bt=await ut.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await ut.setLocalDescription(bt),await Sw(ut,1800);const Mt=await fetch(Ne,{method:"POST",headers:{"Content-Type":"application/sdp",...yw(pt)},body:ut.localDescription?.sdp||bt.sdp});if(!Mt.ok)throw new Error(`WHIP request failed: ${Mt.status}`);const fs=await Mt.text();await ut.setRemoteDescription({type:"answer",sdp:fs}),await jw(ut,1e4),await Aw(ut,6e3),await f?.(J)},[E,T,f,d]),ht=m.useCallback(async()=>{if(se.current=!1,q.current){try{q.current.disconnect()}catch{}q.current.onaudioprocess=null}if(z.current)try{z.current.disconnect()}catch{}if(L.current)try{L.current.disconnect()}catch{}if(oe.current)try{oe.current.getTracks().forEach(J=>J.stop())}catch{}if(ce.current)try{await ce.current.close()}catch{}Z.current=[],q.current=null,z.current=null,L.current=null,oe.current=null,ce.current=null,ue.current=rs},[]),ie=m.useCallback(async()=>{if(oe.current&&ce.current&&q.current)return;O(ct=>ct==="recording"?ct:"arming");const J=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:rs,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),ge=new AudioContext({latencyHint:"interactive"}),Ne=ge.createMediaStreamSource(J),pt=ge.createScriptProcessor(1024,1,1),Ue=ge.createGain();Ue.gain.value=0,pt.onaudioprocess=ct=>{if(!se.current)return;const ut=ct.inputBuffer.getChannelData(0);Z.current.push(new Float32Array(ut))},Ne.connect(pt),pt.connect(Ue),Ue.connect(ge.destination),oe.current=J,ce.current=ge,z.current=Ne,q.current=pt,L.current=Ue,ue.current=ge.sampleRate||rs},[]),xe=m.useCallback(async({send:J})=>{const ge=se.current;if(se.current=!1,!ge){J||O("idle");return}const Ne=Z.current;if(Z.current=[],!J){O("idle");return}if(!b){O("idle");return}if(!Ne.length){O("idle");return}O("sending");try{const pt=ww(Ne),Ue=Ew(pt,ue.current||rs),ct=Nx(Ue);await l?.({roverId:b,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:ct}),O("idle")}catch(pt){O("error"),D(pt?.message||"Failed to send PTT clip.")}},[l,b]),le=m.useCallback(async()=>{if(!b){D("Take control of your rover first.");return}await ie(),Z.current=[],se.current=!0,O("recording")},[ie,b]);return m.useEffect(()=>{let J=!1;async function ge(){if(C){await _e(ee.current||b);return}if(!b){await _e(ee.current);return}if(!(Y.current&&ee.current===b)&&!(!E&&!T))try{R("starting"),D(""),Y.current=!0,ee.current=b,await ze(b),J||R("live")}catch(Ne){J||(R("error"),D(Ne?.message||"Failed to start mic forwarding.")),await _e(b)}}return ge(),()=>{J=!0}},[C,E,T,b,ze,_e]),m.useEffect(()=>{const J=K.current;J&&(J.enabled=!!(!C&&(E||T)))},[C,E,T]),m.useEffect(()=>{let J=!1;async function ge(){if(!C||!b){se.current&&await xe({send:!1}),O("idle");return}try{await ie(),!J&&!se.current&&O("idle")}catch(Ne){J||(O("error"),D(Ne?.message||"Microphone access failed for clip mode."))}}return ge(),()=>{J=!0}},[C,ie,xe,b]),m.useEffect(()=>{let J=!1;async function ge(){if(C){if(!b){se.current&&await xe({send:!1});return}if(T){if(!se.current)try{D(""),await le()}catch(Ne){J||(O("error"),D(Ne?.message||"Failed to start clip recording."))}}else se.current&&await xe({send:!0})}}return ge(),()=>{J=!0}},[C,xe,T,b,le]),m.useEffect(()=>()=>{_e(ee.current||b),ht()},[b,_e,ht]),r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"grid gap-1",children:[r.jsx("p",{className:"text-sm text-slate-100 text-center",children:"Audio Controls"}),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(wx,{label:pe})]})}),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 ${C?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Le("live"),children:"Live Mic (WHIP)"}),r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${C?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Le("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(pn,{label:"Mode",active:C,detail:C?"record clip":"live mic"}),r.jsx(pn,{label:"PTT hold",active:T,detail:T?"held":"released"}),r.jsx(pn,{label:"Recording",active:ve,detail:ve?"capturing":"idle"}),r.jsx(pn,{label:"Playback",active:C&&ae,detail:C&&ae?"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:`${ki} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:M||!b,onChange:J=>S(J.target.files?.[0]||null)})]}),r.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:y?r.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[y.name," (",y.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:M||!b,onClick:ke,children:M?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:M||!b,onClick:Ce,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:E,disabled:!b||C,onChange:J=>g(ge=>({...ge||{},openMicEnabled:!!J.target.checked}))}),r.jsx("span",{children:C?"Open mic (live mode only)":"Open mic"})]}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(pn,{label:"WHIP link",active:de,detail:A}),r.jsx(pn,{label:"Mic hot",active:re,detail:re?"transmitting":"muted"}),r.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",r.jsx(wx,{label:pe})," 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(pn,{label:"Forward pipe",active:te,detail:te?"connected":"offline"}),r.jsx(pn,{label:"Upload playback",active:ae,detail:ae?"playing":"idle"}),r.jsx(pn,{label:"Mic relay",active:he,detail:he?"active":"idle"}),r.jsx(pn,{label:"WHIP transport",active:de,detail:A}),r.jsx(pn,{label:"Clip recording",active:ve,detail:ve?"recording":"idle"}),r.jsx(pn,{label:"Clip sending",active:fe,detail:fe?"sending":"idle"})]}),X?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:X}):null]})})]})})}function Mw({pendingRequestId:n,currentStoredKey:s,nickname:l,requestVerification:o,applyIdentityKey:d,onMessage:f,fullWidth:p=!1}){const[h,x]=m.useState(0),[g,b]=m.useState(""),[y,S]=m.useState(!1),[M,j]=m.useState(!1),E=()=>{x(1),b(s),S(!1),f?.("")},N=()=>{x(0),S(!1)},C=async R=>{if(R.preventDefault(),!y){f?.("Please confirm your nickname agreement before sending.");return}if(h<3){f?.("Complete all request steps before sending.");return}j(!0),f?.("");try{const k=await d(g);await o?.(),b(k),x(0),S(!1),f?.("Verification request sent to lockdown admins.")}catch(k){f?.(k.message||"Failed to submit request.")}finally{j(!1)}},A=p?"w-full":Bo;return n?r.jsx("section",{className:`surface text-sm text-slate-300 ${A}`,children:r.jsxs("div",{className:vi,children:["Verification request pending: ",n]})}):h===0?r.jsx("section",{className:`surface ${A}`,children:r.jsxs("div",{className:vi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:E,disabled:M,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${A}`,onSubmit:C,children:r.jsxs("div",{className:vi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",h," of 3"]}),h===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(Do,{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:l||"(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:y,onChange:R=>S(R.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:!l||!y,onClick:()=>x(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:N,children:"Cancel"})]})]}):null,h===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:ki,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:R=>b(R.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,h===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:ki,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:R=>b(R.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:M||!g,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function Rw({currentStoredKey:n,applyIdentityKey:s,onMessage:l,fullWidth:o=!1}){const[d,f]=m.useState(0),[p,h]=m.useState(""),[x,g]=m.useState(!1),b=()=>{f(1),h(""),l?.("")},y=()=>{f(0),h("")},S=async j=>{if(j.preventDefault(),!(d<2)){g(!0),l?.("");try{await s(p),f(0),h(""),l?.("Identity key restored.")}catch(E){l?.(E.message||"Failed to restore key.")}finally{g(!1)}}},M=o?"w-full":Bo;return r.jsx("section",{className:`surface ${M}`,children:r.jsxs("div",{className:vi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",gw(n)||"not set yet"]}),r.jsx("input",{className:ki,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),d===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:b,disabled:x,children:"Restore Key"})]}):null,d===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:()=>f(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,children:"Cancel"})]})]}):null,d===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:S,children:[r.jsx("input",{className:ki,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:p,onChange:j=>h(j.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||!p,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function qw({requestableRovers:n=[],pendingRequests:s=[],requestPrivateRoverAccess:l,onMessage:o,fullWidth:d=!1}){const[f,p]=m.useState({}),h=m.useMemo(()=>{const b=new Map;return(s||[]).forEach(y=>{y?.roverId&&b.set(String(y.roverId),y)}),b},[s]),x=d?"w-full":Bo,g=async b=>{if(b){p(y=>({...y,[b]:!0})),o?.("");try{(await l?.(b))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(y){o?.(y.message||"Failed to send request.")}finally{p(y=>({...y,[b]:!1}))}}};return r.jsx("section",{className:`surface text-sm text-slate-300 ${x}`,children:r.jsxs("div",{className:vi,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(b=>{const y=String(b.id),S=!!f[y],M=h.get(y);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:b.name||y}),r.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:y})]}),M?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(y),disabled:S,className:"button-dark text-xs disabled:opacity-50",children:S?"Sending...":"Request"})]},y)})})]})})}function sl(n){return String(n||"").trim()}function Tw(n){const s=sl(n);return s?s.includes("DOCKINGRUNNING")?"Returning":s.includes("PAUSED")?"Paused":s.includes("HOUSECLEANINGRUNNING")?"Cleaning":s.includes("SPOTCLEANINGRUNNING")?"Spot cleaning":s.includes("STATE_START")?"Starting":s.includes("STATE_IDLE")||s.includes("STATE_STANDBY")?"Idle":s:"--"}function Jg(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function to({label:n,value:s,tone:l="muted",valueClass:o="",hideLabel:d=!1}){return r.jsxs("div",{className:`rounded-md px-1 py-0.75 text-center ${Jg(l)}`,children:[d?null:r.jsx("div",{className:"text-[0.72rem] opacity-90",children:n}),r.jsx("div",{className:`text-sm font-semibold ${o}`,title:String(s||""),children:s})]})}function Dw(n=[]){const d=[...n.filter(j=>j&&j.valid&&Number.isFinite(j.angleDeg)&&Number.isFinite(j.distanceMm))].sort((j,E)=>Number(j.angleDeg)-Number(E.angleDeg)),f=[];let p=[];for(const j of d){if(!p.length){p.push(j);continue}const E=p[p.length-1],N=Math.abs(Number(j.angleDeg)-Number(E.angleDeg)),C=Math.max(0,Number(E.distanceMm)),A=Math.max(0,Number(j.distanceMm)),R=Math.abs(A-C);if(N<=2&&R<=900){p.push(j);continue}f.push(p),p=[j]}p.length&&f.push(p);const h=f.map(j=>{const E=j.map(C=>Math.max(0,Number(C.distanceMm))),N=E.reduce((C,A)=>C+A,0)/Math.max(1,E.length);return{points:j,size:j.length,avgDistanceMm:N}}),g=h.reduce((j,E)=>E.size>(j?.size||0)?E:j,null)?.avgDistanceMm||1e3,b=h.filter(j=>{const E=j.size<=3,N=j.avgDistanceMm>g*1.8&&j.avgDistanceMm-g>1400;return!(E&&N)}).flatMap(j=>j.points),y=b.map(j=>Math.max(0,Number(j.distanceMm))).sort((j,E)=>j-E),S=Math.max(0,Math.floor((y.length-1)*.95)),M=Math.max(1e3,y[S]||1e3);return b.map(j=>{const E=(Number(j.angleDeg)-90)*Math.PI/180,N=Math.max(0,Number(j.distanceMm)),A=Math.max(0,Math.min(1,N/M))*102,R=110+Math.cos(E)*A,k=110+Math.sin(E)*A,X=38+Math.max(0,Math.min(255,Number(j.intensity)||0))/255*38;return{key:`${j.angleDeg}-${j.distanceMm}-${j.intensity}`,x:R,y:k,fill:`hsl(198 100% ${X}%)`}})}function _w({neato:n,lidar:s,lidarActive:l=!0,onStart:o,onSendHome:d,onLocate:f,onClearErrors:p,onPowerCycle:h,fullWidth:x=!1}){const[g,b]=m.useState(""),[y,S]=m.useState(!1),[M,j]=m.useState(!1),E=x?"w-full":"w-full max-w-xl",N=!!n?.configured,C=!!(n?.enabled&&n?.connected),A=!!n?.telemetry?.extPowerPresent,R=!!n?.telemetry?.chargingActive,k=Tw(n?.telemetry?.uiState),O=sl(n?.telemetry?.robotState)||"--",X=n?.telemetry?.batteryPercent,D=Number.isFinite(X)?`${X}%`:"--",H=n?.telemetry?.batteryVoltage,K=Number.isFinite(H)?`${H.toFixed(2)} V`:"--",$=sl(n?.telemetry?.robotError)||"--",Y=sl(n?.telemetry?.robotAlert)||"--",ee=Array.isArray(s?.points)?s.points:[],oe=m.useMemo(()=>l?Dw(ee):[],[l,ee]),ce=sl(s?.status)||"--",z=s?.debug&&typeof s.debug=="object"?s.debug:null,q=sl(z?.reason)||"--",L=z?.stats&&typeof z.stats=="object"?z.stats:null,Z=n?.controls||{},se=!!Z?.start?.available,ue=!!Z?.sendHome?.available,T=!!Z?.locate?.available,V=!!Z?.clearErrors?.available,te=!!Z?.powerCycle?.available,ae=N&&C&&se,he=N&&C&&ue,re=N&&C&&T,de=N&&C&&V,ve=N&&C&&te,fe=async(_e,ze)=>{if(ze){b(_e);try{await ze()}catch{}finally{b("")}}},pe=N?C?"Online":"Offline":"Not configured",Le=N?C?"good":"danger":"warn",ke=X==null?"muted":X>=60?"good":X>=25?"warn":"danger",Ce=A?"Docked":k!=="--"?k:"Away from dock";return m.useEffect(()=>{if(!l||!s||!Array.isArray(s.points))return;S(!0);const _e=setTimeout(()=>{S(!1)},120);return()=>clearTimeout(_e)},[s,l]),r.jsx("section",{className:`surface text-sm text-slate-200 ${E}`,children:r.jsxs("div",{className:"grid gap-0.5",children:[r.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-sm text-slate-100",children:"Neato Controls"}),r.jsx("p",{className:"text-xs text-slate-400",children:"Control the autonomous Neato robovac. Be nice to him."})]}),r.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${Jg(Le)}`,children:pe})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,0.95fr)_minmax(0,1.05fr)] gap-0.5",children:[r.jsxs("div",{className:"surface-muted grid gap-0.5",children:[r.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Controls"}),r.jsx("button",{type:"button",disabled:!ae||!!g,onClick:()=>fe("start",o),className:"rounded-md border border-sky-300 bg-emerald-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-emerald-500 disabled:opacity-50",children:g==="start"?"Starting...":"Start cleaning"}),r.jsx("button",{type:"button",disabled:!he||!!g,onClick:()=>fe("sendHome",d),className:"rounded-md border border-sky-300 bg-sky-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-sky-500 disabled:opacity-50",children:g==="sendHome"?"Sending...":"Send to dock"}),r.jsxs("div",{className:"grid grid-cols-3 gap-0.5",children:[r.jsx("button",{type:"button",disabled:!re||!!g,onClick:()=>fe("locate",f),className:"w-full rounded-md border border-sky-300 bg-fuchsia-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-sky-500 hover:bg-fuchsia-500 disabled:opacity-50",children:g==="locate"?"Playing...":"Play sound"}),r.jsx("button",{type:"button",disabled:!de||!!g,onClick:()=>fe("clearErrors",p),className:"w-full rounded-md border border-sky-300 bg-amber-500 px-1 py-0.5 text-xs font-semibold text-slate-900 transition hover:border-sky-500 hover:bg-amber-400 disabled:opacity-50",children:g==="clearErrors"?"Clearing...":"Clear errors"}),r.jsx("button",{type:"button",disabled:!ve||!!g,onClick:()=>fe("powerCycle",h),className:"w-full rounded-md border border-rose-300 bg-rose-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-rose-500 hover:bg-rose-500 disabled:opacity-50",children:g==="powerCycle"?"Cycling...":"Power cycle"})]}),r.jsxs("div",{className:"surface-muted grid gap-0.5 pt-0.25",children:[r.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Power status"}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsx(to,{label:"Battery",value:D,tone:ke}),r.jsx(to,{label:"Voltage",value:K,tone:"muted"}),r.jsx(to,{label:"Docked",value:A?"Docked":"Not docked",tone:A?"good":"muted",hideLabel:!0}),r.jsx(to,{label:"Charging",value:R?"charging":"not charging",tone:R?"good":"muted",hideLabel:!0})]})]})]}),r.jsx("div",{className:"grid gap-0.5",children:r.jsxs("div",{className:"surface-muted grid gap-0.5",children:[r.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Robot Status"}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_minmax(13rem,15rem)] gap-0.5 items-start",children:[r.jsxs("div",{className:"grid gap-0.5",children:[r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[r.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot state (raw)"}),r.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:O})]}),r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[r.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Basic state"}),r.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:Ce})]}),r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[r.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"UI state"}),r.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:k})]}),r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[r.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot error"}),r.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:$})]}),r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[r.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot alert"}),r.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:Y})]})]}),r.jsxs("div",{className:`rounded-md px-1 py-0.5 ${y?"bg-emerald-900":"bg-slate-800"}`,children:[r.jsx("button",{type:"button",onClick:()=>j(_e=>!_e),className:"w-full text-left text-[0.72rem] text-slate-300",children:"Lidar"}),r.jsx("div",{className:"mt-0.25 text-center text-[0.68rem] text-slate-400",children:"Front of robot"}),r.jsx("div",{className:"mt-0.25 aspect-square rounded-md bg-slate-800 p-0",children:oe.length?r.jsxs("svg",{viewBox:"0 0 220 220",className:"h-full w-full",children:[r.jsx("rect",{x:"0",y:"0",width:"220",height:"220",fill:"#1e293b"}),r.jsx("rect",{x:"7",y:"7",width:"206",height:"206",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:"33",y:"33",width:"154",height:"154",fill:"none",stroke:"#475569",strokeWidth:"1"}),r.jsx("rect",{x:"59",y:"59",width:"102",height:"102",fill:"none",stroke:"#475569",strokeWidth:"1"}),r.jsx("rect",{x:"85",y:"85",width:"50",height:"50",fill:"none",stroke:"#334155",strokeWidth:"1"}),r.jsx("line",{x1:"110",y1:"7",x2:"110",y2:"213",stroke:"#475569",strokeWidth:"1"}),r.jsx("line",{x1:"7",y1:"110",x2:"213",y2:"110",stroke:"#475569",strokeWidth:"1"}),r.jsx("circle",{cx:"110",cy:"110",r:"4",fill:"#e2e8f0"}),oe.map(_e=>r.jsx("circle",{cx:_e.x,cy:_e.y,r:"1.8",fill:_e.fill},_e.key))]}):r.jsx("div",{className:"flex h-full items-center justify-center text-center text-xs text-slate-400",children:"Waiting for scan"})}),M?r.jsxs("div",{className:"mt-0.5 rounded-md bg-slate-900 px-0.75 py-0.5 font-mono text-[0.68rem] text-slate-300",children:[r.jsxs("div",{children:["Status: ",ce]}),r.jsxs("div",{children:["Reason: ",q]}),r.jsxs("div",{children:["Points: ",ee.length]}),r.jsxs("div",{children:["Rotation: ",Number.isFinite(s?.rotationSpeed)?s.rotationSpeed.toFixed(2):"--"]}),r.jsxs("div",{children:["Request in flight: ",z?.requestInFlight?"yes":"no"]}),r.jsxs("div",{children:["Started at: ",z?.requestStartedAt||"--"]}),r.jsxs("div",{children:["Headers: ",L?.headersSeen??"--"]}),r.jsxs("div",{children:["Rotations: ",L?.rotationsSeen??"--"]}),r.jsxs("div",{children:["Scans ok: ",L?.scansOk??"--"]}),r.jsxs("div",{children:["Timeouts: ",L?.scansTimedOut??"--"]}),r.jsxs("div",{children:["Restarts: ",L?.scansRestarted??"--"]}),r.jsxs("div",{children:["Rotation no scan: ",L?.rotationsWithoutScan??"--"]}),r.jsxs("div",{children:["Parseable payloads: ",L?.parseablePayloads??"--"]}),r.jsxs("div",{children:["Point payloads: ",L?.pointPayloads??"--"]})]}):null]})]})]})})]}),!N||!C||!se||!ue||!T||!V||!te?r.jsx("p",{className:"text-xs text-slate-400 text-center",children:N?C?"Waiting for required Neato entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.neato.device in server config to enable Neato controls."}):null]})})}function Bw(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function Ow(n){return n==="up"?"Up":n==="down"?"Down":n==="stopped"?"Transitioning...":n==="conflict"?"Conflict":"--"}function Lw({lift:n,onUp:s,onDown:l,fullWidth:o=!1}){const[d,f]=m.useState(""),[p,h]=m.useState(()=>Date.now()),x=o?"w-full":"w-full max-w-xl",g=!!n?.configured,b=!!(n?.enabled&&n?.connected),y=!!n?.busy,S=String(n?.target||"").toLowerCase(),M=String(n?.position||"").toLowerCase(),j=!!n?.availability?.upSwitch,E=!!n?.availability?.downSwitch,N=Number(n?.lastActionAt||0),C=Math.max(0,Number(n?.commandCooldownMs||0)),A=Math.max(0,N+C-p),R=!y&&A>0,k=y||R;m.useEffect(()=>{if(!k)return;const $=setInterval(()=>{h(Date.now())},100);return()=>clearInterval($)},[k]),m.useEffect(()=>{h(Date.now())},[N,C,y]);const O=g?b?k?"Busy":"Ready":"Offline":"Not configured",X=g?b?k?"warn":"good":"danger":"warn",D=g&&b&&!k&&!d&&j&&E,H=m.useMemo(()=>Math.ceil(A/1e3),[A]),K=async($,Y)=>{if(Y){f($);try{await Y()}catch{}finally{f("")}}};return r.jsxs("section",{className:`surface relative text-sm text-slate-200 ${x}`,children:[k?r.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center rounded-md bg-slate-950/80 px-1.5 text-center",children:r.jsxs("div",{className:"space-y-0.25",children:[r.jsx("p",{className:"text-sm font-semibold text-slate-100",children:y?"Motion in progress":"Motion cooldown active"}),r.jsx("p",{className:"text-xs text-slate-300",children:"Controls are disabled while the lift is moving, otherwise it's tiny brain would get confused."}),!y&&R?r.jsxs("p",{className:"text-xs text-slate-400",children:["About ",H,"s remaining."]}):null]})}):null,r.jsxs("div",{className:"grid gap-0.5",children:[r.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-sm text-slate-100",children:"Lift Controls"}),r.jsx("p",{className:"text-xs text-slate-400",children:"Move the lift up and down. Please don't break anything..."})]}),r.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${Bw(X)}`,children:O})]}),r.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-0.5",children:[r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.75 text-center",children:[r.jsx("div",{className:"text-xs text-slate-300",children:"Position"}),r.jsx("div",{className:"text-base font-semibold text-slate-100",children:Ow(M)})]}),r.jsx("button",{type:"button",disabled:!D,onClick:()=>K("down",l),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="down"||S==="down"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:d==="down"||S==="down"?"Lowering...":"Down"}),r.jsx("button",{type:"button",disabled:!D,onClick:()=>K("up",s),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="up"||S==="up"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:d==="up"||S==="up"?"Raising...":"Up"})]})}),!g||!b||!j||!E?r.jsx("p",{className:"text-xs text-slate-400 text-center",children:g?b?"Waiting for required lift switch entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.lift.upSwitch and homeAssistant.lift.downSwitch in server config."}):null,n?.lastError?r.jsxs("p",{className:"text-xs text-rose-300 text-center",children:["Last error: ",n.lastError]}):null]})]})}function Pg({isActive:n=!0}){const s=Je(z=>z.session),l=Je(z=>z.neatoLidar),{identifySession:o,requestVerification:d,requestPrivateRoverAccess:f,playUploadedAudio:p,stopUploadedAudio:h,startMicWhip:x,readyMicWhip:g,stopMicWhip:b,neatoStart:y,neatoSendHome:S,neatoLocate:M,neatoClearErrors:j,neatoPowerCycle:E,liftUp:N,liftDown:C}=gn(),{value:A,save:R}=Ge("identity",{cookieUserId:""}),{value:k}=Ge("profile",{nickname:""}),O=m.useMemo(()=>(A?.cookieUserId||"").trim(),[A?.cookieUserId]),X=(k?.nickname||"").trim(),D=!!s?.isVerified,H=s?.verification?.pendingRequestId||null,K=s?.privateRoverAccess?.requestableRovers||[],$=s?.privateRoverAccess?.pendingRequests||[],Y=String(s?.assignment?.roverId||"").trim(),[ee,oe]=m.useState(""),ce=async z=>{const q=String(z||"").trim().toLowerCase();if(!q)throw new Error("Identity key required.");if(!xw.test(q))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return R(L=>({...L||{},cookieUserId:q})),await o({cookieUserId:q,nickname:X}),q};return r.jsxs("section",{className:"space-y-2 text-base",children:[r.jsxs("div",{className:"grid gap-2 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[D?null:r.jsx("div",{className:"lg:col-span-2",children:r.jsx(Mw,{pendingRequestId:H,currentStoredKey:O,nickname:X,requestVerification:d,applyIdentityKey:ce,onMessage:oe,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:D?r.jsxs("div",{className:"space-y-2",children:[r.jsx(_w,{neato:s?.neato||null,lidar:l,lidarActive:n,onStart:y,onSendHome:S,onLocate:M,onClearErrors:j,onPowerCycle:E,fullWidth:!0}),r.jsx(Lw,{lift:s?.lift||null,onUp:N,onDown:C,fullWidth:!0}),r.jsx(kw,{ownRoverId:Y,audioForwardByRover:s?.audioForward||{},playUploadedAudio:p,stopUploadedAudio:h,startMicWhip:x,readyMicWhip:g,stopMicWhip:b})]}):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(qw,{requestableRovers:K,pendingRequests:$,requestPrivateRoverAccess:f,onMessage:oe,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(Rw,{currentStoredKey:O,applyIdentityKey:ce,onMessage:oe,fullWidth:!0})})]}),ee?r.jsx("div",{className:Bo,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:ee})}):null]})}const zw=420,Uw=1200,Hw={1:262,2:330,3:392,4:523};function No(){const{session:n}=da(),s=tn(),{value:l}=Ge("audio",rt),o=Number.isFinite(l?.masterVolume)?l.masterVolume:rt.masterVolume,d=Number.isFinite(l?.alertVolume)?l.alertVolume:rt.alertVolume,f=Math.max(0,Math.min(1,o*d)),p=m.useMemo(()=>{const E=Array.isArray(n?.buttonBox?.buttons)?n.buttonBox.buttons:[];return E.length===4?E:[1,2,3,4].map(N=>E.find(C=>Number(C?.id)===N)||{id:N,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n?.buttonBox?.buttons]),[h,x]=m.useState({}),[g,b]=m.useState({}),y=m.useRef(new Map),S=m.useRef(new Map),M=m.useRef({}),j=m.useRef(null);return m.useEffect(()=>{const E={};p.forEach(C=>{E[C.id]=Number(C.lastRewardAt||0)});const N=M.current||{};p.forEach(C=>{const A=Number(C.id),R=E[A]||0,k=Number(N[A]||0);if(R>0&&R!==k){b(D=>({...D,[A]:!0}));const O=S.current.get(A);O&&clearTimeout(O);const X=setTimeout(()=>{b(D=>({...D,[A]:!1})),S.current.delete(A)},Uw);S.current.set(A,X)}}),M.current=E},[p]),m.useEffect(()=>{function E(C){const A=Hw[C];if(!A||f<=0)return;let R=j.current;if(!R){const D=window.AudioContext||window.webkitAudioContext;if(!D)return;R=new D,j.current=R}const k=R.createOscillator(),O=R.createGain();k.type="square",k.frequency.value=A;const X=.14*f;O.gain.setValueAtTime(1e-4,R.currentTime),O.gain.exponentialRampToValueAtTime(Math.max(1e-4,X),R.currentTime+.01),O.gain.exponentialRampToValueAtTime(1e-4,R.currentTime+.2),k.connect(O),O.connect(R.destination),k.start(),k.stop(R.currentTime+.21)}function N(C={}){const A=Number(C.buttonId);if(!Number.isFinite(A)||A<1||A>4)return;x(O=>({...O,[A]:!0}));const R=y.current.get(A);R&&clearTimeout(R);const k=setTimeout(()=>{x(O=>({...O,[A]:!1})),y.current.delete(A)},zw);y.current.set(A,k),E(A)}return s.on("buttonBox:increment",N),()=>{s.off("buttonBox:increment",N)}},[f,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:p.map(E=>{const N=Number(E.id),C=Number.isFinite(E.count)?E.count:0,A=Number.isFinite(E.goal)?E.goal:0,R=typeof E.rewardName=="string"&&E.rewardName.trim()?E.rewardName.trim():"Unassigned",k=Number.isFinite(E.rewardNumber)?E.rewardNumber:"?",O=!!h[N],X=!!g[N];return r.jsx(gg,{buttonId:N,count:C,goal:A,rewardNumber:k,rewardName:R,className:[O?"bg-cyan-900/45":"",X?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},N)})})]})}function Vw(){const{state:{roverId:n}}=Bt(),l=ml(n)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(Vd,{sensors:l})})})}function $w(){const{state:{roverId:n,keymap:s,camera:l,horn:o},pipeline:d,actions:{setServoAngle:f,setNightVision:p,startHorn:h,stopHorn:x}}=Bt(),g=Tg(n),b=g.docked&&!g.driving,y=l?.config,S=!!(n&&l?.enabled&&y),M=!!(n&&d?.nightVision),j=d?.nightVisionState,E=!!(n&&d?.horn),N=o?.overheated,C=typeof y?.minAngle=="number"?y.minAngle:-30,A=typeof y?.maxAngle=="number"?y.maxAngle:30,R=typeof l?.angle=="number"?l.angle:typeof y?.homeAngle=="number"?y.homeAngle:(C+A)/2,k=Nn(s?.nightVisionToggle?.[0]),O=Nn(s?.hornHonk?.[0]),X=Nn(s?.cameraUp?.[0]),D=Nn(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(Dg,{layout:"desktop",expand:!0,driveDockState:g}),b?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[M&&r.jsx(_g,{nightVisionOn:j?.nightVisionOn,disabled:!n,onToggle:p,keyLabel:k}),E&&r.jsx(Bg,{disabled:!n||N,onStart:h,onStop:x,keyLabel:O,active:o?.active,heat:o?.heat}),S&&r.jsx(Og,{value:R,min:C,max:A,onChange:f,keyDownLabel:D,keyUpLabel:X,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 Gw({layout:n,onOpenHelpOverlay:s}){const[l,o]=m.useState("telemetry"),d=Je(E=>E.session),{state:f}=Bt(),{value:p}=Ge("vipAudio",{openMicEnabled:!1,pttMode:"live"}),h=d?.isVerified?"bg-emerald-400":"bg-red-600",x=String(d?.assignment?.roverId||"").trim(),g=x?d?.audioForward?.[x]:null,b=!!f?.mic?.pttActive,y=!!p?.openMicEnabled,S=p?.pttMode==="clip"?"clip":"live",M=!!(x&&d?.isVerified&&(S==="clip"?b:y||b)),j=!!(x&&d?.isVerified&&S==="clip"&&g?.source==="upload"&&g?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(Sf,{defaultTab:"telemetry",currentTab:l,onTabChange:o,children:[r.jsxs(jf,{children:[r.jsx(Wt,{id:"telemetry",children:"Controls"}),r.jsx(Wt,{id:"vip",highlight:j?"green":M?"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 ${h}`,"aria-hidden":"true",title:d?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Wt,{id:"help",children:"Help"}),r.jsx(Wt,{id:"settings",children:"Settings"})]}),r.jsxs(Nf,{children:[r.jsx(en,{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(Vw,{}),r.jsx($w,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(_o,{}),r.jsx(af,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx(cw,{})]}),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(To,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(jo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(ow,{compact:!0})]})]}),r.jsx(Vg,{}),r.jsx(No,{}),r.jsx(ff,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(en,{id:"vip",keepMounted:!0,children:r.jsx(Pg,{isActive:l==="vip"})}),r.jsx(en,{id:"help",children:r.jsx(Zg,{layout:n,onOpenOverlay:s})}),r.jsx(en,{id:"settings",children:r.jsx(Xg,{})})]})]})})}const Yw=new Set(["admin","lockdown","lockdown-admin"]),Fw=new Set(["lockdown","lockdown-admin"]),Xw=new Set(["admin","lockdown"]);function Qw(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 Kw(){const n=Je(S=>S.session),s=n?.mode,l=n?.role,o=n?.adminReason?.text||"";n?.adminReason?.updatedAt;const d=n?.timezone||"UTC",f=n?.socials?.find(S=>String(S?.id||S?.label||"").toLowerCase()==="discord")?.url||n?.discord?.invite||null,p=Xw.has(s),h=s==="lockdown"?Fw.has(l):Yw.has(l),[x,g]=m.useState(()=>new Date),b=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:d,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(x)}catch{return x.toLocaleTimeString()}},[x,d]);if(m.useEffect(()=>{const S=setInterval(()=>g(new Date),1e3);return()=>clearInterval(S)},[]),!p||h)return null;const y=Qw(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:y.title}),r.jsx("p",{className:"text-sm text-slate-300",children:y.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: ",b]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx($g,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(pf,{id:"discord",label:"Join our Discord server for updates!",url:f})}),"You can still use the chat while the server is locked:",r.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[r.jsx(To,{}),r.jsx(Do,{})]})]})})}const Zw="/assets/turn_alert-DVO8EZJa.mp3";function Iw(n,s=1){const l=m.useRef(null);return m.useEffect(()=>{l.current=new Audio(n),l.current.volume=s,l.current.load()},[n,s]),()=>{l.current&&(l.current.volume=s,l.current.currentTime=0,l.current.play().catch(()=>{}))}}function Jw(){const n=Je(b=>b.session),{pushAlert:s}=gn(),{value:l}=Ge("audio",rt),o=Number.isFinite(l?.masterVolume)?l.masterVolume:rt.masterVolume,d=Number.isFinite(l?.alertVolume)?l.alertVolume:rt.alertVolume,f=Math.max(0,Math.min(1,o*d)),p=Iw(Zw,f),h=m.useRef(new Set),x=m.useMemo(()=>n?.turnQueues||{},[n?.turnQueues]),g=n?.socketId||null;return m.useEffect(()=>{if(!g)return;const b=[];Object.entries(x).forEach(([y,S])=>{!S||!S.current||S.current!==g||h.current.has(y)||(b.push(y),h.current.add(y))}),Object.keys(x).forEach(y=>{(!x[y]||x[y].current!==g)&&h.current.delete(y)}),b.length!==0&&(b.forEach(y=>{const S=n?.roster?.find(M=>String(M.id)===String(y))?.name||y;s({title:"Your turn!",message:`You now control ${S}.`,color:"#ff5722"})}),p())},[x,p,s,n?.roster,g]),null}function Pw({visible:n,mode:s,onEnterFullscreen:l,onDismiss:o}){if(!n)return null;const d=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"}),d?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:d?"Got it":"Not now"}),!d&&r.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:l,children:"Enter fullscreen"})]})]})})})}function Ww({side:n="right",onClick:s}){const l=n==="left"?"left-2":"right-2";return r.jsx("button",{type:"button",onClick:s,className:`fixed bottom-2 ${l} 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 Wg="fullscreenPromptDismissed",e2=new Set(["mobile-portrait","mobile-landscape"]),eb=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},t2=()=>{const n=eb();if(!n)return!1;try{return n.getItem(Wg)==="1"}catch{return!1}},Cx=()=>{const n=eb();if(n)try{n.setItem(Wg,"1")}catch{}},n2=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},Ex=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function a2(n){const s=e2.has(n),[l,o]=m.useState(!1),[d,f]=m.useState("native"),[p,h]=m.useState(!1),x=m.useMemo(()=>n2(),[]),g=m.useMemo(()=>Ex(),[]),b=m.useCallback(()=>{if(!s){o(!1),h(!1);return}if(!p&&t2()){o(!1);return}if(x){f("pwa-hint"),o(!0);return}if(!Ex()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}f("native"),o(!0)},[p,x,s]);m.useEffect(()=>{b()},[b]),m.useEffect(()=>{if(typeof document>"u")return;const j=()=>{if(document.fullscreenElement){h(!1),o(!1);return}b()};return document.addEventListener("fullscreenchange",j),document.addEventListener("webkitfullscreenchange",j),()=>{document.removeEventListener("fullscreenchange",j),document.removeEventListener("webkitfullscreenchange",j)}},[b]);const y=m.useCallback(()=>{Cx(),h(!1),o(!1)},[]),S=m.useCallback(async()=>{if(!s||x||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const j=document.documentElement;if(!j)return!1;const E=j.requestFullscreen||j.webkitRequestFullscreen||j.mozRequestFullScreen||j.msRequestFullscreen;if(!E)return!1;try{const N=E.call(j);return N&&typeof N.then=="function"&&await N,Cx(),h(!1),o(!1),!0}catch(N){return console.warn("Failed to enter fullscreen",N),!1}},[x,s]),M=m.useCallback(()=>{s&&(h(!0),f(x?"pwa-hint":"native"),o(!0))},[x,s]);return m.useEffect(()=>{s||(h(!1),o(!1))},[s]),{visible:l,mode:d,isIOS:x,nativeSupported:g,enterFullscreen:S,dismiss:y,showPrompt:M}}function s2({visible:n,layout:s,onClose:l,showOnLoad:o,onToggleShowOnLoad:d}){if(!n)return null;const{state:f}=Bt(),p=h=>{const x=!h.target.checked;d?.(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:p,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:l,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(Kg,{layout:s,keymap:f?.keymap||{}})})]})})}const l2=`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
shrimp
fling`;function i2(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function r2(){const n=String(l2).split(/\r?\n/).map(l=>l.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function Af(){const{setNickname:n}=gn(),{value:s,status:l,save:o}=Ge("profile",{nickname:""}),d=m.useRef(!1);m.useEffect(()=>{if(l!=="ready"||d.current||(s.nickname||"").trim())return;d.current=!0;const p=i2(r2()).slice(0,32);if(!p)return;(async()=>{try{await n(p)}catch{}finally{o({nickname:p})}})()},[o,n,l,s.nickname])}function o2(){const n=tn(),s=Je(N=>N.connected),{identifySession:l}=gn(),{value:o,status:d,save:f}=Ge("identity",{cookieUserId:""}),{value:p,status:h}=Ge("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),b=m.useRef(null),y=d==="ready"&&h==="ready",S=(o?.cookieUserId||"").trim(),M=(p?.nickname||"").trim(),j=m.useCallback(()=>{b.current&&(clearTimeout(b.current),b.current=null)},[]),E=m.useCallback(async()=>{if(!(!y||!s||!n?.id||x.current)){x.current=!0;try{const C=((await l({cookieUserId:S,nickname:M}))?.cookieUserId||"").trim();C&&C!==S&&f(A=>({...A||{},cookieUserId:C})),g.current=n.id,j()}catch{j(),b.current=setTimeout(()=>{E()},2e3)}finally{x.current=!1}}},[j,s,S,l,M,y,f,n?.id]);m.useEffect(()=>{!y||!s||!n?.id||g.current!==n.id&&E()},[s,y,E,n?.id]),m.useEffect(()=>{!y||!s||!n?.id||E()},[y,s,n?.id,S,M,E]),m.useEffect(()=>{const N=()=>{n?.connected&&E()},C=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&E()};return window.addEventListener("online",N),document.addEventListener("visibilitychange",C),()=>{window.removeEventListener("online",N),document.removeEventListener("visibilitychange",C)}},[E,n?.connected]),m.useEffect(()=>()=>j(),[j])}const Sd=1e4,jd=28,c2=14;function Ao({layout:n="desktop",className:s="",dismissable:l=!0}){const o=Je(A=>A.session),d=o?.globalObjective?.text?String(o.globalObjective.text).trim():"",f=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[p,h]=m.useState(!1),[x,g]=m.useState(jd),[b,y]=m.useState(0),S=m.useRef(null),M=m.useRef(null),j=m.useRef(null);m.useEffect(()=>{if(!d){h(!1);return}if(h(!0),!f||!l)return;const A=Date.now();y(Sd);const R=setTimeout(()=>h(!1),Sd),k=setInterval(()=>{const O=Date.now()-A;y(Math.max(0,Sd-O))},250);return()=>{clearTimeout(R),clearInterval(k)}},[d,f]),m.useEffect(()=>{if(!d)return;g(jd);let A=0;const R=()=>{const O=j.current,X=M.current;if(!O||!X)return;const D=O.clientWidth;if(!D)return;const H=X.scrollWidth;if(!H)return;const K=Math.min(1,D/H),$=Math.max(c2,Math.floor(jd*K));g($)};A=window.requestAnimationFrame(R);const k=new ResizeObserver(()=>{window.cancelAnimationFrame(A),A=window.requestAnimationFrame(R)});return S.current&&k.observe(S.current),()=>{window.cancelAnimationFrame(A),k.disconnect()}},[d]);const E=m.useMemo(()=>["panel-section flex w-full items-center justify-center",f?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",s].filter(Boolean).join(" "),[s,f]);if(!d||!p)return null;const N=f?Math.ceil(b/1e3):null,C=l?{onClick:()=>h(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:S,className:E,style:{fontSize:`${x}px`,lineHeight:1.1},...C,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:"Global"}),r.jsx("span",{children:"Objective"})]}),r.jsx("span",{ref:j,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:M,className:"block",children:d})}),f?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:[N,"s"]}):null]})})}const u2=3200;function d2(n={}){const s=typeof n.rewardName=="string"&&n.rewardName.trim()?n.rewardName.trim():"Unknown Event",l=Number.isFinite(Number(n.goal))?Math.max(1,Math.floor(Number(n.goal))):0,o=Number.isFinite(Number(n.count))?Math.max(0,Math.floor(Number(n.count))):l;return{rewardName:s,goal:l,count:o,ts:Date.now()}}function tb(){const n=tn(),{value:s}=Ge("audio",rt),l=Number.isFinite(s?.masterVolume)?s.masterVolume:rt.masterVolume,o=Number.isFinite(s?.alertVolume)?s.alertVolume:rt.alertVolume,d=Math.max(0,Math.min(1,l*o)),[f,p]=m.useState(null),h=m.useRef(null);return m.useEffect(()=>{h.current=new Audio("/tada.mp3"),h.current.volume=d,h.current.load()},[d]),m.useEffect(()=>{let x=null;function g(){const S=h.current;S&&(S.volume=d,S.currentTime=0,S.play().catch(()=>{}))}function b(S={}){const M=d2(S);p(M),g(),x&&clearTimeout(x),x=setTimeout(()=>{p(null)},u2)}function y(S){b(S?.detail||{})}return n.on("buttonBox:rewardRun",b),window.addEventListener("buttonBox:rewardRunLocalTest",y),()=>{x&&clearTimeout(x),n.off("buttonBox:rewardRun",b),window.removeEventListener("buttonBox:rewardRunLocalTest",y)}},[d,n]),f?r.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120] flex items-center justify-center bg-black/75 px-1 py-1",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-2xl",children:r.jsx("div",{className:"surface rounded-none border-2 border-cyan-300 bg-amber-100/95 px-1 py-1 text-center text-black shadow-2xl",children:r.jsxs("div",{className:"flex items-center justify-center gap-1 border-2 border-blue-600 bg-yellow-100 px-0.5 py-1",children:[r.jsx("img",{src:"/party1.gif",alt:"",className:"hidden shrink-0 sm:block"}),r.jsxs("div",{children:[r.jsxs("p",{className:"font-mono text-2xl font-bold text-red-700 sm:text-3xl",children:["Running event: ",f.rewardName,"!"]}),r.jsxs("p",{className:"font-mono text-xl font-bold text-blue-800 sm:text-2xl",children:[f.count,"/",f.goal]})]}),r.jsx("img",{src:"/party2.gif",alt:"",className:"hidden shrink-0 sm:block"})]})})})}):null}function f2(){const[n,s]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function l(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:d}=window;o>=1024?s("desktop"):o>d?s("mobile-landscape"):s("mobile-portrait")}return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[]),n}function m2({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(gf,{}),r.jsx(sj,{}),r.jsx(mf,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(Ao,{layout:n}),r.jsx(Gw,{layout:n,onOpenHelpOverlay:s})]})]})}function nb({layout:n,onOpenHelpOverlay:s,roomPanelId:l,showTelemetry:o=!0}){const[d,f]=m.useState("chat"),p=Je(C=>C.session),{state:h}=Bt(),{value:x}=Ge("vipAudio",{openMicEnabled:!1,pttMode:"live"}),g=p?.isVerified?"bg-emerald-400":"bg-amber-400",b=String(p?.assignment?.roverId||"").trim(),y=b?p?.audioForward?.[b]:null,S=!!h?.mic?.pttActive,M=!!x?.openMicEnabled,j=x?.pttMode==="clip"?"clip":"live",E=!!(b&&p?.isVerified&&(j==="clip"?S:M||S)),N=!!(b&&p?.isVerified&&j==="clip"&&y?.source==="upload"&&y?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(Sf,{defaultTab:"chat",currentTab:d,onTabChange:f,children:[r.jsxs(jf,{children:[r.jsx(Wt,{id:"chat",children:"Chat"}),r.jsx(Wt,{id:"vip",highlight:N?"green":E?"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 ${g}`,"aria-hidden":"true",title:p?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Wt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Wt,{id:"help",children:"Help"}),r.jsx(Wt,{id:"settings",children:"Settings"})]}),r.jsxs(Nf,{children:[r.jsx(en,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(To,{}),r.jsx(jo,{})]})}),r.jsx(en,{id:"vip",keepMounted:!0,children:r.jsx(Pg,{isActive:d==="vip"})}),r.jsx(en,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Vg,{}),r.jsx(No,{}),r.jsx(ff,{panelId:l})]})}),r.jsx(en,{id:"help",children:r.jsx(Zg,{layout:n,onOpenOverlay:s})}),r.jsx(en,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Xg,{}),r.jsx(mf,{})]})})]})]})})}function h2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(gf,{layoutFormat:"mobile-portrait"}),r.jsx(RN,{swapColumns:s}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(af,{panelId:"replay-sources-mobile-portrait"}),r.jsx(_o,{})]}),r.jsx(nb,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function p2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){const l="self-start h-[min(100svh,32rem)]",o=s?r.jsx(yo,{layout:"landscape",className:l}):r.jsx(vo,{layout:"landscape",className:l}),d=s?r.jsx(vo,{layout:"landscape",className:l}):r.jsx(yo,{layout:"landscape",className:l});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(gf,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(af,{panelId:"replay-sources-mobile-landscape"}),r.jsx(_o,{})]})]}),d]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(nb,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function x2(){const n=f2(),s=n==="desktop",l=a2(n);return r.jsx("div",{className:`bg-black text-slate-100 ${s?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(g2,{layout:n,isDesktop:s,fullscreen:l})})}function g2({layout:n,isDesktop:s,fullscreen:l}){Af(),o2();const{visible:o,mode:d,isIOS:f,nativeSupported:p,enterFullscreen:h,dismiss:x,showPrompt:g}=l,{value:b,status:y,save:S}=Ge("help",{showOnLoad:!0}),{value:M}=Ge("page",{swapMobileControlColumns:!1}),j=!!M?.swapMobileControlColumns,E=j?"left":"right",N=!s&&(f||p),[C,A]=m.useState(!1);m.useEffect(()=>{y==="ready"&&A(b?.showOnLoad!==!1)},[y,b?.showOnLoad]);const R=m.useCallback(()=>A(!0),[]),k=m.useCallback(()=>A(!1),[]),O=m.useCallback(async()=>{if(f){g();return}await h()||g()},[h,f,g]),X=m.useCallback(H=>{const K=!!H;S($=>({...$??{},showOnLoad:K})),K||A(!1)},[S]),D=m.useMemo(()=>s?r.jsx(m2,{layout:n,onOpenHelpOverlay:R}):n==="mobile-landscape"?r.jsx(p2,{onOpenHelpOverlay:R,swapMobileControlColumns:j}):r.jsx(h2,{onOpenHelpOverlay:R,swapMobileControlColumns:j}),[s,n,R,j]);return r.jsxs(Jj,{children:[r.jsx(oN,{}),r.jsx(yN,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${s?"h-full overflow-hidden":""}`,children:[s?null:r.jsx(Ao,{layout:n}),D]}),r.jsx(rf,{}),r.jsx(tb,{}),r.jsx(Jw,{}),r.jsx(Kw,{}),r.jsx(s2,{visible:C,layout:n,onClose:k,showOnLoad:b?.showOnLoad!==!1,onToggleShowOnLoad:X}),r.jsx(Pw,{visible:o,mode:d,onEnterFullscreen:h,onDismiss:x}),N?r.jsx(Ww,{side:E,onClick:O}):null]})}function ab(){const{session:n,setRole:s,subscribeAll:l,connected:o}=da(),[d,f]=m.useState(!1);return m.useEffect(()=>{let p=!1;async function h(){if(n?.mode==="lockdown"){f(!1);return}try{n?.role!=="spectator"&&await s("spectator"),await l(),p||f(!0)}catch(x){console.error("Failed to enter spectator mode",x),p||f(!1)}}return h(),()=>{p=!0}},[o,n?.mode,n?.role,s,l]),d}function b2(){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 l=window.matchMedia("(max-aspect-ratio: 4/3)"),o=d=>s(d.matches);return l.addEventListener?l.addEventListener("change",o):l.addListener(o),()=>{l.removeEventListener?l.removeEventListener("change",o):l.removeListener(o)}},[]),n}function v2({roverId:n,session:s}){const l=s?.activeDrivers?.[n]||null,d=(s?.users||[]).find(x=>x.socketId===l)?.nickname||(l?l.slice(0,6):"No driver"),f=s?.mode,p=s?.turnQueues?.[n];return f==="turns"&&p?.current?`${d} (turns)`:d}function y2({rover:n,frame:s,sessionInfo:l,videoMode:o,snapshotFeed:d,audioInfo:f,session:p}){const h=v2({roverId:n.id,session:p});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(wi,{sessionInfo:l,videoMode:o,snapshotFeed:d,audioSessionInfo:f,label:n.name,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:h,hudForceMap:!0,hudMapPosition:"top-center"})})})}function S2({roster:n,frames:s,videoSources:l,snapshotFeeds:o,audioSources:d,session:f,canSpectateVideo:p}){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(h=>r.jsx(y2,{rover:h,frame:s[h.id],sessionInfo:p&&l[h.id]||null,videoMode:p?"whep":"snapshot",snapshotFeed:p?null:o[h.id],audioInfo:d[`${h.id}-audio`],session:f,showHudMap:!0,hudMapPosition:"bottom-left"},h.id))})}function j2(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(ff,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function N2({className:n=""}){return r.jsx("div",{className:`panel ${n}`,children:r.jsx(mf,{})})}function A2(){const{session:n}=da(),s=n?.mode==="lockdown",l=!!n?.isLocalNetwork;Af(),ab();const o=b2(),d=og(),f=n?.roster??[],p=hf(f.map(N=>N.id),{enabled:!s&&!l,version:n?.mode}),h=l?f.map(N=>({type:"rover",id:N.id,key:N.id})):[],x=Ni(h,{enabled:!s&&l,version:n?.mode}),g=f.flatMap(N=>N.media?.audioPublishUrl?[{type:"rover",id:`${N.id}-audio`,key:`${N.id}-audio`}]:[]),b=Ni(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 y=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",M=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",j="",E=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:y,children:[r.jsxs("section",{className:M,children:[o?r.jsxs("div",{className:`${j} ${E} flex flex-col gap-0.5`,children:[r.jsx(Ao,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(No,{}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(jo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsxs("div",{className:j,children:[r.jsx(Ao,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(No,{})]}),r.jsx("div",{className:`${j} ${o?`${E} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(_o,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${j} flex-1 min-h-0`,children:r.jsx(jo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${j} ${o?E:"flex-[1.1] min-h-0"}`,children:r.jsx(To,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${j} ${o?E:""}`,children:r.jsx(N2,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:S,children:[r.jsx(S2,{roster:f,frames:d,videoSources:x,snapshotFeeds:p,audioSources:b,session:n,canSpectateVideo:l}),r.jsx(j2,{})]})]}),r.jsx(rf,{}),r.jsx(tb,{})]})}function w2(){return r.jsx(A2,{})}function C2({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})})})}function E2({roverId:n,session:s}){const l=s?.activeDrivers?.[n]||null,d=(s?.users||[]).find(h=>h.socketId===l)?.nickname||(l?l.slice(0,6):"No driver"),f=s?.mode,p=s?.turnQueues?.[n];return f==="turns"&&p?.current?`${d}`:d}function k2({rover:n,frame:s}){const l=s?.sensors?.batteryChargeMah??null,o=n?.battery??null;return Ug({batteryState:n?.batteryState??null,charge:l,config:o})}function al({children:n,className:s="",maxSize:l=1e3,minSize:o=14,style:d=void 0}){const f=m.useRef(null),p=m.useRef(null),[h,x]=m.useState(l);return m.useLayoutEffect(()=>{const g=f.current,b=p.current;if(!g||!b)return;let y=null;const S=()=>{const E=g.clientWidth;if(!E){M();return}let N=o,C=l,A=o;for(;N<=C;){const R=Math.floor((N+C)/2);b.style.fontSize=`${R}px`,b.scrollWidth<=E?(A=R,N=R+1):C=R-1}x(A)},M=()=>{y&&cancelAnimationFrame(y),y=requestAnimationFrame(S)};M();const j=new ResizeObserver(M);return j.observe(g),()=>{y&&cancelAnimationFrame(y),j.disconnect()}},[n,l,o]),r.jsx("div",{ref:f,className:"w-full min-w-0",children:r.jsx("div",{ref:p,className:`whitespace-nowrap ${s}`,style:{fontSize:`${h}px`,lineHeight:1.1,...d||{}},children:n})})}function kx({rover:n,frame:s,driverLabel:l,sessionInfo:o,videoMode:d="snapshot",snapshotFeed:f,withDivider:p=!1,showPreview:h=!0,variant:x="stacked"}){const g=k2({rover:n,frame:s}),b=g?.available?g.percentDisplay:null,y=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 ${p?"border-r border-slate-700/60":""}`,children:[r.jsx(Hd,{visual:g,orientation:y?"vertical":"horizontal",variant:"background"}),y?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(al,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ca(n.color,.18),children:n.name||n.id})}),l?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(al,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:l})}):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(al,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:b==null?"--%":`${b}%`})})})]}):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(al,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ca(n.color,.18),children:n.name||n.id})}),l?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(al,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:l})}):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(al,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:b==null?"--%":`${b}%`})})})]}),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:h?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(wi,{sessionInfo:o,videoMode:d,snapshotFeed:f,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}const M2=2e4,R2=3600*1e3;function q2(){const{session:n}=da(),s=ab();Af();const l=n?.mode==="lockdown",o=!!n?.isLocalNetwork,d=og(),f=n?.roster??[],[p,h]=m.useState(0),x=n?.activeDrivers||{},g=m.useMemo(()=>f.filter($=>x[$.id]),[f,x]),b=g.length?g:f,y=hf(b.map($=>$.id),{enabled:!l&&!o,version:n?.mode}),S=m.useMemo(()=>o?b.map($=>({type:"rover",id:$.id,key:$.id})):[],[o,b]),M=Ni(S,{enabled:!l&&o,version:n?.mode}),j=m.useMemo(()=>g.flatMap($=>{if(!$?.id||!$.media?.audioPublishUrl)return[];const Y=String($.id);return[{type:"rover",id:`${Y}-audio`,key:`${Y}-audio`}]}),[g]),E=Ni(j,{enabled:!l,version:n?.mode}),N=m.useMemo(()=>{if(!g.length)return[];if(!o){const Y=g.filter(ee=>y[ee.id]?.objectUrl);return Y.length?Y:g}const $=g.filter(Y=>{const ee=M[Y.id];return ee?.url&&!ee?.error});return $.length?$:g},[g,y,M,o]),C=m.useMemo(()=>N.map($=>({type:"rover",rover:$})),[N]),A=m.useMemo(()=>C.map($=>`r:${$.rover.id}`).join("|"),[C]);m.useEffect(()=>{h(0)},[A]),m.useEffect(()=>{if(!C.length)return;const $=setInterval(()=>{h(Y=>(Y+1)%C.length)},M2);return()=>clearInterval($)},[C.length,A]);const R=C.length?C[p%C.length]:null,k=R?.type==="rover"?R.rover:null,O=!o&&k&&y[k.id]||null,X=o&&k&&M[k.id]||null,D=k&&E[`${k.id}-audio`]||null,H=k&&d[k.id]||null,K=k?E2({roverId:k.id,session:n}):null;return l?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?k?r.jsx(C2,{children:o?r.jsx("div",{className:"relative h-full w-full",children:C.map($=>{const Y=$.rover,ee=k?.id===Y.id;return r.jsx("div",{className:`absolute inset-0 ${ee?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(wi,{sessionInfo:M[Y.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:ee?D:null,forceMute:!ee,label:Y.name||Y.id,roverColor:Y.color||null,telemetryFrame:d[Y.id]||null,batteryConfig:Y.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},Y.id)})}):r.jsx(wi,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:O,audioSessionInfo:D,label:k.name||k.id,roverColor:k.color||null,telemetryFrame:H,batteryConfig:k.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:k?r.jsx(kx,{rover:k,frame:H,driverLabel:K,sessionInfo:o?X:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[k.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:f.length?f.map($=>r.jsx(kx,{rover:$,frame:d[$.id]||null,driverLabel:null,sessionInfo:o&&M[$.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[$.id]||null,showPreview:!0,withDivider:!1},$.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function T2(){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())},R2);return()=>clearTimeout(n)},[]),r.jsxs(r.Fragment,{children:[r.jsx(q2,{}),r.jsx(rf,{scale:3})]})}function no(n){if(!n||!n.length)return null;const s=Math.floor(Math.random()*n.length);return n[s]||null}function D2(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const s=no(n),l=no(n),o=s?.classList?.[0]||null;if(o&&l?.classList)try{l.classList.add(o)}catch{}const d=no(n),f=no(n),p=d?.classList?.[1]||null;if(p&&f?.classList)try{f.classList.add(p)}catch{}}function _2(){const n=Je(s=>!!s.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const s=window.setInterval(()=>{D2()},1);return()=>{window.clearInterval(s)}},[n]),null}wy.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(KS,{children:r.jsx(PS,{children:r.jsx(ej,{children:r.jsx(cj,{children:r.jsxs(Wj,{children:[r.jsx(_2,{}),r.jsx(H1,{children:r.jsxs(g1,{children:[r.jsx(ao,{path:"/",element:r.jsx(x2,{})}),r.jsx(ao,{path:"/spectate",element:r.jsx(w2,{})}),r.jsx(ao,{path:"/mini",element:r.jsx(T2,{})})]})})]})})})})})}));