mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
126 lines
538 KiB
JavaScript
126 lines
538 KiB
JavaScript
(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))o(f);new MutationObserver(f=>{for(const d of f)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function i(f){const d={};return f.integrity&&(d.integrity=f.integrity),f.referrerPolicy&&(d.referrerPolicy=f.referrerPolicy),f.crossOrigin==="use-credentials"?d.credentials="include":f.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(f){if(f.ep)return;f.ep=!0;const d=i(f);fetch(f.href,d)}})();function Iy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Bu={exports:{}},ni={};var a0;function Jy(){if(a0)return ni;a0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function i(o,f,d){var h=null;if(d!==void 0&&(h=""+d),f.key!==void 0&&(h=""+f.key),"key"in f){d={};for(var x in f)x!=="key"&&(d[x]=f[x])}else d=f;return f=d.ref,{$$typeof:n,type:o,key:h,ref:f!==void 0?f:null,props:d}}return ni.Fragment=s,ni.jsx=i,ni.jsxs=i,ni}var s0;function Py(){return s0||(s0=1,Bu.exports=Jy()),Bu.exports}var r=Py(),Lu={exports:{}},Ce={};var l0;function Wy(){if(l0)return Ce;l0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),h=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),A=Symbol.iterator;function R(k){return k===null||typeof k!="object"?null:(k=A&&k[A]||k["@@iterator"],typeof k=="function"?k:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},q=Object.assign,j={};function w(k,H,P){this.props=k,this.context=H,this.refs=j,this.updater=P||N}w.prototype.isReactComponent={},w.prototype.setState=function(k,H){if(typeof k!="object"&&typeof k!="function"&&k!=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,k,H,"setState")},w.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function E(){}E.prototype=w.prototype;function C(k,H,P){this.props=k,this.context=H,this.refs=j,this.updater=P||N}var M=C.prototype=new E;M.constructor=C,q(M,w.prototype),M.isPureReactComponent=!0;var L=Array.isArray;function K(){}var _={H:null,A:null,T:null,S:null},Q=Object.prototype.hasOwnProperty;function B(k,H,P){var ne=P.ref;return{$$typeof:n,type:k,key:H,ref:ne!==void 0?ne:null,props:P}}function U(k,H){return B(k.type,H,k.props)}function Y(k){return typeof k=="object"&&k!==null&&k.$$typeof===n}function te(k){var H={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(P){return H[P]})}var fe=/\/+/g;function oe(k,H){return typeof k=="object"&&k!==null&&k.key!=null?te(""+k.key):H.toString(36)}function G(k){switch(k.status){case"fulfilled":return k.value;case"rejected":throw k.reason;default:switch(typeof k.status=="string"?k.then(K,K):(k.status="pending",k.then(function(H){k.status==="pending"&&(k.status="fulfilled",k.value=H)},function(H){k.status==="pending"&&(k.status="rejected",k.reason=H)})),k.status){case"fulfilled":return k.value;case"rejected":throw k.reason}}throw k}function T(k,H,P,ne,pe){var ie=typeof k;(ie==="undefined"||ie==="boolean")&&(k=null);var ce=!1;if(k===null)ce=!0;else switch(ie){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(k.$$typeof){case n:case s:ce=!0;break;case y:return ce=k._init,T(ce(k._payload),H,P,ne,pe)}}if(ce)return pe=pe(k),ce=ne===""?"."+oe(k,0):ne,L(pe)?(P="",ce!=null&&(P=ce.replace(fe,"$&/")+"/"),T(pe,H,P,"",function(xe){return xe})):pe!=null&&(Y(pe)&&(pe=U(pe,P+(pe.key==null||k&&k.key===pe.key?"":(""+pe.key).replace(fe,"$&/")+"/")+ce)),H.push(pe)),1;ce=0;var ve=ne===""?".":ne+":";if(L(k))for(var ye=0;ye<k.length;ye++)ne=k[ye],ie=ve+oe(ne,ye),ce+=T(ne,H,P,ie,pe);else if(ye=R(k),typeof ye=="function")for(k=ye.call(k),ye=0;!(ne=k.next()).done;)ne=ne.value,ie=ve+oe(ne,ye++),ce+=T(ne,H,P,ie,pe);else if(ie==="object"){if(typeof k.then=="function")return T(G(k),H,P,ne,pe);throw H=String(k),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return ce}function F(k,H,P){if(k==null)return k;var ne=[],pe=0;return T(k,ne,"","",function(ie){return H.call(P,ie,pe++)}),ne}function J(k){if(k._status===-1){var H=k._result;H=H(),H.then(function(P){(k._status===0||k._status===-1)&&(k._status=1,k._result=P)},function(P){(k._status===0||k._status===-1)&&(k._status=2,k._result=P)}),k._status===-1&&(k._status=0,k._result=H)}if(k._status===1)return k._result.default;throw k._result}var se=typeof reportError=="function"?reportError:function(k){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof k=="object"&&k!==null&&typeof k.message=="string"?String(k.message):String(k),error:k});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",k);return}console.error(k)},de={map:F,forEach:function(k,H,P){F(k,function(){H.apply(this,arguments)},P)},count:function(k){var H=0;return F(k,function(){H++}),H},toArray:function(k){return F(k,function(H){return H})||[]},only:function(k){if(!Y(k))throw Error("React.Children.only expected to receive a single React element child.");return k}};return Ce.Activity=b,Ce.Children=de,Ce.Component=w,Ce.Fragment=i,Ce.Profiler=f,Ce.PureComponent=C,Ce.StrictMode=o,Ce.Suspense=p,Ce.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,Ce.__COMPILER_RUNTIME={__proto__:null,c:function(k){return _.H.useMemoCache(k)}},Ce.cache=function(k){return function(){return k.apply(null,arguments)}},Ce.cacheSignal=function(){return null},Ce.cloneElement=function(k,H,P){if(k==null)throw Error("The argument must be a React element, but you passed "+k+".");var ne=q({},k.props),pe=k.key;if(H!=null)for(ie in H.key!==void 0&&(pe=""+H.key),H)!Q.call(H,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&H.ref===void 0||(ne[ie]=H[ie]);var ie=arguments.length-2;if(ie===1)ne.children=P;else if(1<ie){for(var ce=Array(ie),ve=0;ve<ie;ve++)ce[ve]=arguments[ve+2];ne.children=ce}return B(k.type,pe,ne)},Ce.createContext=function(k){return k={$$typeof:h,_currentValue:k,_currentValue2:k,_threadCount:0,Provider:null,Consumer:null},k.Provider=k,k.Consumer={$$typeof:d,_context:k},k},Ce.createElement=function(k,H,P){var ne,pe={},ie=null;if(H!=null)for(ne in H.key!==void 0&&(ie=""+H.key),H)Q.call(H,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(pe[ne]=H[ne]);var ce=arguments.length-2;if(ce===1)pe.children=P;else if(1<ce){for(var ve=Array(ce),ye=0;ye<ce;ye++)ve[ye]=arguments[ye+2];pe.children=ve}if(k&&k.defaultProps)for(ne in ce=k.defaultProps,ce)pe[ne]===void 0&&(pe[ne]=ce[ne]);return B(k,ie,pe)},Ce.createRef=function(){return{current:null}},Ce.forwardRef=function(k){return{$$typeof:x,render:k}},Ce.isValidElement=Y,Ce.lazy=function(k){return{$$typeof:y,_payload:{_status:-1,_result:k},_init:J}},Ce.memo=function(k,H){return{$$typeof:g,type:k,compare:H===void 0?null:H}},Ce.startTransition=function(k){var H=_.T,P={};_.T=P;try{var ne=k(),pe=_.S;pe!==null&&pe(P,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(K,se)}catch(ie){se(ie)}finally{H!==null&&P.types!==null&&(H.types=P.types),_.T=H}},Ce.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},Ce.use=function(k){return _.H.use(k)},Ce.useActionState=function(k,H,P){return _.H.useActionState(k,H,P)},Ce.useCallback=function(k,H){return _.H.useCallback(k,H)},Ce.useContext=function(k){return _.H.useContext(k)},Ce.useDebugValue=function(){},Ce.useDeferredValue=function(k,H){return _.H.useDeferredValue(k,H)},Ce.useEffect=function(k,H){return _.H.useEffect(k,H)},Ce.useEffectEvent=function(k){return _.H.useEffectEvent(k)},Ce.useId=function(){return _.H.useId()},Ce.useImperativeHandle=function(k,H,P){return _.H.useImperativeHandle(k,H,P)},Ce.useInsertionEffect=function(k,H){return _.H.useInsertionEffect(k,H)},Ce.useLayoutEffect=function(k,H){return _.H.useLayoutEffect(k,H)},Ce.useMemo=function(k,H){return _.H.useMemo(k,H)},Ce.useOptimistic=function(k,H){return _.H.useOptimistic(k,H)},Ce.useReducer=function(k,H,P){return _.H.useReducer(k,H,P)},Ce.useRef=function(k){return _.H.useRef(k)},Ce.useState=function(k){return _.H.useState(k)},Ce.useSyncExternalStore=function(k,H,P){return _.H.useSyncExternalStore(k,H,P)},Ce.useTransition=function(){return _.H.useTransition()},Ce.version="19.2.0",Ce}var i0;function Tf(){return i0||(i0=1,Lu.exports=Wy()),Lu.exports}var m=Tf();const rs=Iy(m);var zu={exports:{}},ai={},Uu={exports:{}},Hu={};var r0;function eb(){return r0||(r0=1,(function(n){function s(T,F){var J=T.length;T.push(F);e:for(;0<J;){var se=J-1>>>1,de=T[se];if(0<f(de,F))T[se]=F,T[J]=de,J=se;else break e}}function i(T){return T.length===0?null:T[0]}function o(T){if(T.length===0)return null;var F=T[0],J=T.pop();if(J!==F){T[0]=J;e:for(var se=0,de=T.length,k=de>>>1;se<k;){var H=2*(se+1)-1,P=T[H],ne=H+1,pe=T[ne];if(0>f(P,J))ne<de&&0>f(pe,P)?(T[se]=pe,T[ne]=J,se=ne):(T[se]=P,T[H]=J,se=H);else if(ne<de&&0>f(pe,J))T[se]=pe,T[ne]=J,se=ne;else break e}}return F}function f(T,F){var J=T.sortIndex-F.sortIndex;return J!==0?J:T.id-F.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var h=Date,x=h.now();n.unstable_now=function(){return h.now()-x}}var p=[],g=[],y=1,b=null,A=3,R=!1,N=!1,q=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function M(T){for(var F=i(g);F!==null;){if(F.callback===null)o(g);else if(F.startTime<=T)o(g),F.sortIndex=F.expirationTime,s(p,F);else break;F=i(g)}}function L(T){if(q=!1,M(T),!N)if(i(p)!==null)N=!0,K||(K=!0,te());else{var F=i(g);F!==null&&G(L,F.startTime-T)}}var K=!1,_=-1,Q=5,B=-1;function U(){return j?!0:!(n.unstable_now()-B<Q)}function Y(){if(j=!1,K){var T=n.unstable_now();B=T;var F=!0;try{e:{N=!1,q&&(q=!1,E(_),_=-1),R=!0;var J=A;try{t:{for(M(T),b=i(p);b!==null&&!(b.expirationTime>T&&U());){var se=b.callback;if(typeof se=="function"){b.callback=null,A=b.priorityLevel;var de=se(b.expirationTime<=T);if(T=n.unstable_now(),typeof de=="function"){b.callback=de,M(T),F=!0;break t}b===i(p)&&o(p),M(T)}else o(p);b=i(p)}if(b!==null)F=!0;else{var k=i(g);k!==null&&G(L,k.startTime-T),F=!1}}break e}finally{b=null,A=J,R=!1}F=void 0}}finally{F?te():K=!1}}}var te;if(typeof C=="function")te=function(){C(Y)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,oe=fe.port2;fe.port1.onmessage=Y,te=function(){oe.postMessage(null)}}else te=function(){w(Y,0)};function G(T,F){_=w(function(){T(n.unstable_now())},F)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(T){T.callback=null},n.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<T?Math.floor(1e3/T):5},n.unstable_getCurrentPriorityLevel=function(){return A},n.unstable_next=function(T){switch(A){case 1:case 2:case 3:var F=3;break;default:F=A}var J=A;A=F;try{return T()}finally{A=J}},n.unstable_requestPaint=function(){j=!0},n.unstable_runWithPriority=function(T,F){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var J=A;A=T;try{return F()}finally{A=J}},n.unstable_scheduleCallback=function(T,F,J){var se=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?se+J:se):J=se,T){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=J+de,T={id:y++,callback:F,priorityLevel:T,startTime:J,expirationTime:de,sortIndex:-1},J>se?(T.sortIndex=J,s(g,T),i(p)===null&&T===i(g)&&(q?(E(_),_=-1):q=!0,G(L,J-se))):(T.sortIndex=de,s(p,T),N||R||(N=!0,K||(K=!0,te()))),T},n.unstable_shouldYield=U,n.unstable_wrapCallback=function(T){var F=A;return function(){var J=A;A=F;try{return T.apply(this,arguments)}finally{A=J}}}})(Hu)),Hu}var o0;function tb(){return o0||(o0=1,Uu.exports=eb()),Uu.exports}var Vu={exports:{}},Ot={};var c0;function nb(){if(c0)return Ot;c0=1;var n=Tf();function s(p){var g="https://react.dev/errors/"+p;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)g+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+p+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var o={d:{f:i,r:function(){throw Error(s(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},f=Symbol.for("react.portal");function d(p,g,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:b==null?null:""+b,children:p,containerInfo:g,implementation:y}}var h=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function x(p,g){if(p==="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(p,g){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(s(299));return d(p,g,null,y)},Ot.flushSync=function(p){var g=h.T,y=o.p;try{if(h.T=null,o.p=2,p)return p()}finally{h.T=g,o.p=y,o.d.f()}},Ot.preconnect=function(p,g){typeof p=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(p,g))},Ot.prefetchDNS=function(p){typeof p=="string"&&o.d.D(p)},Ot.preinit=function(p,g){if(typeof p=="string"&&g&&typeof g.as=="string"){var y=g.as,b=x(y,g.crossOrigin),A=typeof g.integrity=="string"?g.integrity:void 0,R=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?o.d.S(p,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:A,fetchPriority:R}):y==="script"&&o.d.X(p,{crossOrigin:b,integrity:A,fetchPriority:R,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Ot.preinitModule=function(p,g){if(typeof p=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=x(g.as,g.crossOrigin);o.d.M(p,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(p)},Ot.preload=function(p,g){if(typeof p=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,b=x(y,g.crossOrigin);o.d.L(p,y,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Ot.preloadModule=function(p,g){if(typeof p=="string")if(g){var y=x(g.as,g.crossOrigin);o.d.m(p,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(p)},Ot.requestFormReset=function(p){o.d.r(p)},Ot.unstable_batchedUpdates=function(p,g){return p(g)},Ot.useFormState=function(p,g,y){return h.H.useFormState(p,g,y)},Ot.useFormStatus=function(){return h.H.useHostTransitionStatus()},Ot.version="19.2.0",Ot}var u0;function ab(){if(u0)return Vu.exports;u0=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(),Vu.exports=nb(),Vu.exports}var f0;function sb(){if(f0)return ai;f0=1;var n=tb(),s=Tf(),i=ab();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(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 p(e){if(d(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(o(188));return t!==e?null:e}for(var a=e,l=t;;){var c=a.return;if(c===null)break;var u=c.alternate;if(u===null){if(l=c.return,l!==null){a=l;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===a)return p(c),e;if(u===l)return p(c),t;u=u.sibling}throw Error(o(188))}if(a.return!==l.return)a=c,l=u;else{for(var v=!1,S=c.child;S;){if(S===a){v=!0,a=c,l=u;break}if(S===l){v=!0,l=c,a=u;break}S=S.sibling}if(!v){for(S=u.child;S;){if(S===a){v=!0,a=u,l=c;break}if(S===l){v=!0,l=u,a=c;break}S=S.sibling}if(!v)throw Error(o(189))}}if(a.alternate!==l)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?e:t}function y(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=y(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,A=Symbol.for("react.element"),R=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),C=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function te(e){return e===null||typeof e!="object"?null:(e=Y&&e[Y]||e["@@iterator"],typeof e=="function"?e:null)}var fe=Symbol.for("react.client.reference");function oe(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case q:return"Fragment";case w:return"Profiler";case j:return"StrictMode";case L:return"Suspense";case K:return"SuspenseList";case B:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case N:return"Portal";case C:return e.displayName||"Context";case E:return(e._context.displayName||"Context")+".Consumer";case M:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case Q:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var G=Array.isArray,T=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},se=[],de=-1;function k(e){return{current:e}}function H(e){0>de||(e.current=se[de],se[de]=null,de--)}function P(e,t){de++,se[de]=e.current,e.current=t}var ne=k(null),pe=k(null),ie=k(null),ce=k(null);function ve(e,t){switch(P(ie,t),P(pe,e),P(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Cp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Cp(t),e=Ep(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(ne),P(ne,e)}function ye(){H(ne),H(pe),H(ie)}function xe(e){e.memoizedState!==null&&P(ce,e);var t=ne.current,a=Ep(t,e.type);t!==a&&(P(pe,e),P(ne,a))}function Ue(e){pe.current===e&&(H(ne),H(pe)),ce.current===e&&(H(ce),Pl._currentValue=J)}var $e,Ne;function ae(e){if($e===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);$e=t&&t[1]||"",Ne=-1<a.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+$e+e+Ne}var ue=!1;function be(e,t){if(!e||ue)return"";ue=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(Z){var X=Z}Reflect.construct(e,[],ee)}else{try{ee.call()}catch(Z){X=Z}e.call(ee.prototype)}}else{try{throw Error()}catch(Z){X=Z}(ee=e())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(Z){if(Z&&X&&typeof Z.stack=="string")return[Z.stack,X.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=l.DetermineComponentFrameRoot(),v=u[0],S=u[1];if(v&&S){var D=v.split(`
|
||
`),$=S.split(`
|
||
`);for(c=l=0;l<D.length&&!D[l].includes("DetermineComponentFrameRoot");)l++;for(;c<$.length&&!$[c].includes("DetermineComponentFrameRoot");)c++;if(l===D.length||c===$.length)for(l=D.length-1,c=$.length-1;1<=l&&0<=c&&D[l]!==$[c];)c--;for(;1<=l&&0<=c;l--,c--)if(D[l]!==$[c]){if(l!==1||c!==1)do if(l--,c--,0>c||D[l]!==$[c]){var I=`
|
||
`+D[l].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=l&&0<=c);break}}}finally{ue=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?ae(a):""}function Me(e,t){switch(e.tag){case 26:case 27:case 5:return ae(e.type);case 16:return ae("Lazy");case 13:return e.child!==t&&t!==null?ae("Suspense Fallback"):ae("Suspense");case 19:return ae("SuspenseList");case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return ae("Activity");default:return""}}function le(e){try{var t="",a=null;do t+=Me(e,a),a=e,e=e.return;while(e);return t}catch(l){return`
|
||
Error generating stack: `+l.message+`
|
||
`+l.stack}}var re=Object.prototype.hasOwnProperty,me=n.unstable_scheduleCallback,we=n.unstable_cancelCallback,et=n.unstable_shouldYield,dt=n.unstable_requestPaint,Le=n.unstable_now,xt=n.unstable_getCurrentPriorityLevel,mt=n.unstable_ImmediatePriority,Tn=n.unstable_UserBlockingPriority,Et=n.unstable_NormalPriority,cs=n.unstable_LowPriority,Gt=n.unstable_IdlePriority,Oa=n.log,wo=n.unstable_setDisableYieldValue,Dn=null,At=null;function Yt(e){if(typeof Oa=="function"&&wo(e),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Dn,e)}catch{}}var kt=Math.clz32?Math.clz32:us,ca=Math.log,Co=Math.LN2;function us(e){return e>>>=0,e===0?32:31-(ca(e)/Co|0)|0}var fs=256,Ba=262144,tt=4194304;function _n(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function An(e,t,a){var l=e.pendingLanes;if(l===0)return 0;var c=0,u=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var S=l&134217727;return S!==0?(l=S&~u,l!==0?c=_n(l):(v&=S,v!==0?c=_n(v):a||(a=S&~e,a!==0&&(c=_n(a))))):(S=l&~u,S!==0?c=_n(S):v!==0?c=_n(v):a||(a=l&~e,a!==0&&(c=_n(a)))),c===0?0:t!==0&&t!==c&&(t&u)===0&&(u=c&-c,a=t&-t,u>=a||u===32&&(a&4194048)!==0)?t:c}function On(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ds(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ul(){var e=tt;return tt<<=1,(tt&62914560)===0&&(tt=4194304),e}function fl(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function La(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Eo(e,t,a,l,c,u){var v=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var S=e.entanglements,D=e.expirationTimes,$=e.hiddenUpdates;for(a=v&~a;0<a;){var I=31-kt(a),ee=1<<I;S[I]=0,D[I]=-1;var X=$[I];if(X!==null)for($[I]=null,I=0;I<X.length;I++){var Z=X[I];Z!==null&&(Z.lane&=-536870913)}a&=~ee}l!==0&&dl(e,l,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(v&~t))}function dl(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var l=31-kt(t);e.entangledLanes|=t,e.entanglements[l]=e.entanglements[l]|1073741824|a&261930}function en(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var l=31-kt(a),c=1<<l;c&t|e[l]&t&&(e[l]|=t),a&=~c}}function Ae(e,t){var a=t&-t;return a=(a&42)!==0?1:Ke(a),(a&(e.suspendedLanes|t))!==0?0:a}function Ke(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Pe(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function qe(){var e=F.p;return e!==0?e:(e=window.event,e===void 0?32:Ip(e.type))}function Ye(e,t){var a=F.p;try{return F.p=e,t()}finally{F.p=a}}var it=Math.random().toString(36).slice(2),rt="__reactFiber$"+it,jt="__reactProps$"+it,st="__reactContainer$"+it,Bn="__reactEvents$"+it,Ug="__reactListeners$"+it,Hg="__reactHandles$"+it,md="__reactResources$"+it,ml="__reactMarker$"+it;function ko(e){delete e[rt],delete e[jt],delete e[Bn],delete e[Ug],delete e[Hg]}function ms(e){var t=e[rt];if(t)return t;for(var a=e.parentNode;a;){if(t=a[st]||a[rt]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=_p(e);e!==null;){if(a=e[rt])return a;e=_p(e)}return t}e=a,a=e.parentNode}return null}function hs(e){if(e=e[rt]||e[st]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function hl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function ps(e){var t=e[md];return t||(t=e[md]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function wt(e){e[ml]=!0}var hd=new Set,pd={};function za(e,t){xs(e,t),xs(e+"Capture",t)}function xs(e,t){for(pd[e]=t,e=0;e<t.length;e++)hd.add(t[e])}var Vg=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]*$"),xd={},gd={};function $g(e){return re.call(gd,e)?!0:re.call(xd,e)?!1:Vg.test(e)?gd[e]=!0:(xd[e]=!0,!1)}function Mi(e,t,a){if($g(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var l=t.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function qi(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Ln(e,t,a,l){if(l===null)e.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+l)}}function tn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Gg(e,t,a){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var c=l.get,u=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(v){a=""+v,u.call(this,v)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(v){a=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Mo(e){if(!e._valueTracker){var t=vd(e)?"checked":"value";e._valueTracker=Gg(e,t,""+e[t])}}function yd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),l="";return e&&(l=vd(e)?e.checked?"true":"false":e.value),e=l,e!==a?(t.setValue(e),!0):!1}function Ri(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Yg=/[\n"\\]/g;function nn(e){return e.replace(Yg,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function qo(e,t,a,l,c,u,v,S){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),t!=null?v==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+tn(t)):e.value!==""+tn(t)&&(e.value=""+tn(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?Ro(e,v,tn(t)):a!=null?Ro(e,v,tn(a)):l!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.name=""+tn(S):e.removeAttribute("name")}function bd(e,t,a,l,c,u,v,S){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)){Mo(e);return}a=a!=null?""+tn(a):"",t=t!=null?""+tn(t):a,S||t===e.value||(e.value=t),e.defaultValue=t}l=l??c,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=S?e.checked:!!l,e.defaultChecked=!!l,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),Mo(e)}function Ro(e,t,a){t==="number"&&Ri(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function gs(e,t,a,l){if(e=e.options,t){t={};for(var c=0;c<a.length;c++)t["$"+a[c]]=!0;for(a=0;a<e.length;a++)c=t.hasOwnProperty("$"+e[a].value),e[a].selected!==c&&(e[a].selected=c),c&&l&&(e[a].defaultSelected=!0)}else{for(a=""+tn(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,l&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Sd(e,t,a){if(t!=null&&(t=""+tn(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+tn(a):""}function Ad(e,t,a,l){if(t==null){if(l!=null){if(a!=null)throw Error(o(92));if(G(l)){if(1<l.length)throw Error(o(93));l=l[0]}a=l}a==null&&(a=""),t=a}a=tn(t),e.defaultValue=a,l=e.textContent,l===a&&l!==""&&l!==null&&(e.value=l),Mo(e)}function vs(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var Fg=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 jd(e,t,a){var l=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":l?e.setProperty(t,a):typeof a!="number"||a===0||Fg.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Nd(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||t!=null&&t.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var c in t)l=t[c],t.hasOwnProperty(c)&&a[c]!==l&&jd(e,c,l)}else for(var u in t)t.hasOwnProperty(u)&&jd(e,u,t[u])}function To(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 Xg=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"]]),Qg=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ti(e){return Qg.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function zn(){}var Do=null;function _o(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ys=null,bs=null;function wd(e){var t=hs(e);if(t&&(e=t.stateNode)){var a=e[jt]||null;e:switch(e=t.stateNode,t.type){case"input":if(qo(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+nn(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var l=a[t];if(l!==e&&l.form===e.form){var c=l[jt]||null;if(!c)throw Error(o(90));qo(l,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)l=a[t],l.form===e.form&&yd(l)}break e;case"textarea":Sd(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&gs(e,!!a.multiple,t,!1)}}}var Oo=!1;function Cd(e,t,a){if(Oo)return e(t,a);Oo=!0;try{var l=e(t);return l}finally{if(Oo=!1,(ys!==null||bs!==null)&&(yr(),ys&&(t=ys,e=bs,bs=ys=null,wd(t),e)))for(t=0;t<e.length;t++)wd(e[t])}}function pl(e,t){var a=e.stateNode;if(a===null)return null;var l=a[jt]||null;if(l===null)return null;a=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Un=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Bo=!1;if(Un)try{var xl={};Object.defineProperty(xl,"passive",{get:function(){Bo=!0}}),window.addEventListener("test",xl,xl),window.removeEventListener("test",xl,xl)}catch{Bo=!1}var ua=null,Lo=null,Di=null;function Ed(){if(Di)return Di;var e,t=Lo,a=t.length,l,c="value"in ua?ua.value:ua.textContent,u=c.length;for(e=0;e<a&&t[e]===c[e];e++);var v=a-e;for(l=1;l<=v&&t[a-l]===c[u-l];l++);return Di=c.slice(e,1<l?1-l:void 0)}function _i(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Oi(){return!0}function kd(){return!1}function Lt(e){function t(a,l,c,u,v){this._reactName=a,this._targetInst=c,this.type=l,this.nativeEvent=u,this.target=v,this.currentTarget=null;for(var S in e)e.hasOwnProperty(S)&&(a=e[S],this[S]=a?a(u):u[S]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Oi:kd,this.isPropagationStopped=kd,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Oi)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Oi)},persist:function(){},isPersistent:Oi}),t}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bi=Lt(Ua),gl=b({},Ua,{view:0,detail:0}),Kg=Lt(gl),zo,Uo,vl,Li=b({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vo,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==vl&&(vl&&e.type==="mousemove"?(zo=e.screenX-vl.screenX,Uo=e.screenY-vl.screenY):Uo=zo=0,vl=e),zo)},movementY:function(e){return"movementY"in e?e.movementY:Uo}}),Md=Lt(Li),Zg=b({},Li,{dataTransfer:0}),Ig=Lt(Zg),Jg=b({},gl,{relatedTarget:0}),Ho=Lt(Jg),Pg=b({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),Wg=Lt(Pg),ev=b({},Ua,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tv=Lt(ev),nv=b({},Ua,{data:0}),qd=Lt(nv),av={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},sv={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"},lv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function iv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=lv[e])?!!t[e]:!1}function Vo(){return iv}var rv=b({},gl,{key:function(e){if(e.key){var t=av[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=_i(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?sv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vo,charCode:function(e){return e.type==="keypress"?_i(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_i(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),ov=Lt(rv),cv=b({},Li,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Rd=Lt(cv),uv=b({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vo}),fv=Lt(uv),dv=b({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),mv=Lt(dv),hv=b({},Li,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),pv=Lt(hv),xv=b({},Ua,{newState:0,oldState:0}),gv=Lt(xv),vv=[9,13,27,32],$o=Un&&"CompositionEvent"in window,yl=null;Un&&"documentMode"in document&&(yl=document.documentMode);var yv=Un&&"TextEvent"in window&&!yl,Td=Un&&(!$o||yl&&8<yl&&11>=yl),Dd=" ",_d=!1;function Od(e,t){switch(e){case"keyup":return vv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ss=!1;function bv(e,t){switch(e){case"compositionend":return Bd(t);case"keypress":return t.which!==32?null:(_d=!0,Dd);case"textInput":return e=t.data,e===Dd&&_d?null:e;default:return null}}function Sv(e,t){if(Ss)return e==="compositionend"||!$o&&Od(e,t)?(e=Ed(),Di=Lo=ua=null,Ss=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Td&&t.locale!=="ko"?null:t.data;default:return null}}var Av={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 Ld(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Av[e.type]:t==="textarea"}function zd(e,t,a,l){ys?bs?bs.push(l):bs=[l]:ys=l,t=Cr(t,"onChange"),0<t.length&&(a=new Bi("onChange","change",null,a,l),e.push({event:a,listeners:t}))}var bl=null,Sl=null;function jv(e){bp(e,0)}function zi(e){var t=hl(e);if(yd(t))return e}function Ud(e,t){if(e==="change")return t}var Hd=!1;if(Un){var Go;if(Un){var Yo="oninput"in document;if(!Yo){var Vd=document.createElement("div");Vd.setAttribute("oninput","return;"),Yo=typeof Vd.oninput=="function"}Go=Yo}else Go=!1;Hd=Go&&(!document.documentMode||9<document.documentMode)}function $d(){bl&&(bl.detachEvent("onpropertychange",Gd),Sl=bl=null)}function Gd(e){if(e.propertyName==="value"&&zi(Sl)){var t=[];zd(t,Sl,e,_o(e)),Cd(jv,t)}}function Nv(e,t,a){e==="focusin"?($d(),bl=t,Sl=a,bl.attachEvent("onpropertychange",Gd)):e==="focusout"&&$d()}function wv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return zi(Sl)}function Cv(e,t){if(e==="click")return zi(t)}function Ev(e,t){if(e==="input"||e==="change")return zi(t)}function kv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ft=typeof Object.is=="function"?Object.is:kv;function Al(e,t){if(Ft(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),l=Object.keys(t);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var c=a[l];if(!re.call(t,c)||!Ft(e[c],t[c]))return!1}return!0}function Yd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Fd(e,t){var a=Yd(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=t&&l>=t)return{node:a,offset:t-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Yd(a)}}function Xd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ri(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=Ri(e.document)}return t}function Fo(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 Mv=Un&&"documentMode"in document&&11>=document.documentMode,As=null,Xo=null,jl=null,Qo=!1;function Kd(e,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Qo||As==null||As!==Ri(l)||(l=As,"selectionStart"in l&&Fo(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jl&&Al(jl,l)||(jl=l,l=Cr(Xo,"onSelect"),0<l.length&&(t=new Bi("onSelect","select",null,t,a),e.push({event:t,listeners:l}),t.target=As)))}function Ha(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var js={animationend:Ha("Animation","AnimationEnd"),animationiteration:Ha("Animation","AnimationIteration"),animationstart:Ha("Animation","AnimationStart"),transitionrun:Ha("Transition","TransitionRun"),transitionstart:Ha("Transition","TransitionStart"),transitioncancel:Ha("Transition","TransitionCancel"),transitionend:Ha("Transition","TransitionEnd")},Ko={},Zd={};Un&&(Zd=document.createElement("div").style,"AnimationEvent"in window||(delete js.animationend.animation,delete js.animationiteration.animation,delete js.animationstart.animation),"TransitionEvent"in window||delete js.transitionend.transition);function Va(e){if(Ko[e])return Ko[e];if(!js[e])return e;var t=js[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Zd)return Ko[e]=t[a];return e}var Id=Va("animationend"),Jd=Va("animationiteration"),Pd=Va("animationstart"),qv=Va("transitionrun"),Rv=Va("transitionstart"),Tv=Va("transitioncancel"),Wd=Va("transitionend"),em=new Map,Zo="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(" ");Zo.push("scrollEnd");function pn(e,t){em.set(e,t),za(t,[e])}var Ui=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},an=[],Ns=0,Io=0;function Hi(){for(var e=Ns,t=Io=Ns=0;t<e;){var a=an[t];an[t++]=null;var l=an[t];an[t++]=null;var c=an[t];an[t++]=null;var u=an[t];if(an[t++]=null,l!==null&&c!==null){var v=l.pending;v===null?c.next=c:(c.next=v.next,v.next=c),l.pending=c}u!==0&&tm(a,c,u)}}function Vi(e,t,a,l){an[Ns++]=e,an[Ns++]=t,an[Ns++]=a,an[Ns++]=l,Io|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function Jo(e,t,a,l){return Vi(e,t,a,l),$i(e)}function $a(e,t){return Vi(e,null,null,t),$i(e)}function tm(e,t,a){e.lanes|=a;var l=e.alternate;l!==null&&(l.lanes|=a);for(var c=!1,u=e.return;u!==null;)u.childLanes|=a,l=u.alternate,l!==null&&(l.childLanes|=a),u.tag===22&&(e=u.stateNode,e===null||e._visibility&1||(c=!0)),e=u,u=u.return;return e.tag===3?(u=e.stateNode,c&&t!==null&&(c=31-kt(a),e=u.hiddenUpdates,l=e[c],l===null?e[c]=[t]:l.push(t),t.lane=a|536870912),u):null}function $i(e){if(50<Fl)throw Fl=0,iu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ws={};function Dv(e,t,a,l){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xt(e,t,a,l){return new Dv(e,t,a,l)}function Po(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hn(e,t){var a=e.alternate;return a===null?(a=Xt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function nm(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Gi(e,t,a,l,c,u){var v=0;if(l=e,typeof e=="function")Po(e)&&(v=1);else if(typeof e=="string")v=zy(e,a,ne.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case B:return e=Xt(31,a,t,c),e.elementType=B,e.lanes=u,e;case q:return Ga(a.children,c,u,t);case j:v=8,c|=24;break;case w:return e=Xt(12,a,t,c|2),e.elementType=w,e.lanes=u,e;case L:return e=Xt(13,a,t,c),e.elementType=L,e.lanes=u,e;case K:return e=Xt(19,a,t,c),e.elementType=K,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case C:v=10;break e;case E:v=9;break e;case M:v=11;break e;case _:v=14;break e;case Q:v=16,l=null;break e}v=29,a=Error(o(130,e===null?"null":typeof e,"")),l=null}return t=Xt(v,a,t,c),t.elementType=e,t.type=l,t.lanes=u,t}function Ga(e,t,a,l){return e=Xt(7,e,l,t),e.lanes=a,e}function Wo(e,t,a){return e=Xt(6,e,null,t),e.lanes=a,e}function am(e){var t=Xt(18,null,null,0);return t.stateNode=e,t}function ec(e,t,a){return t=Xt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var sm=new WeakMap;function sn(e,t){if(typeof e=="object"&&e!==null){var a=sm.get(e);return a!==void 0?a:(t={value:e,source:t,stack:le(t)},sm.set(e,t),t)}return{value:e,source:t,stack:le(t)}}var Cs=[],Es=0,Yi=null,Nl=0,ln=[],rn=0,fa=null,jn=1,Nn="";function Vn(e,t){Cs[Es++]=Nl,Cs[Es++]=Yi,Yi=e,Nl=t}function lm(e,t,a){ln[rn++]=jn,ln[rn++]=Nn,ln[rn++]=fa,fa=e;var l=jn;e=Nn;var c=32-kt(l)-1;l&=~(1<<c),a+=1;var u=32-kt(t)+c;if(30<u){var v=c-c%5;u=(l&(1<<v)-1).toString(32),l>>=v,c-=v,jn=1<<32-kt(t)+c|a<<c|l,Nn=u+e}else jn=1<<u|a<<c|l,Nn=e}function tc(e){e.return!==null&&(Vn(e,1),lm(e,1,0))}function nc(e){for(;e===Yi;)Yi=Cs[--Es],Cs[Es]=null,Nl=Cs[--Es],Cs[Es]=null;for(;e===fa;)fa=ln[--rn],ln[rn]=null,Nn=ln[--rn],ln[rn]=null,jn=ln[--rn],ln[rn]=null}function im(e,t){ln[rn++]=jn,ln[rn++]=Nn,ln[rn++]=fa,jn=t.id,Nn=t.overflow,fa=e}var Mt=null,nt=null,Oe=!1,da=null,on=!1,ac=Error(o(519));function ma(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw wl(sn(t,e)),ac}function rm(e){var t=e.stateNode,a=e.type,l=e.memoizedProps;switch(t[rt]=e,t[jt]=l,a){case"dialog":Te("cancel",t),Te("close",t);break;case"iframe":case"object":case"embed":Te("load",t);break;case"video":case"audio":for(a=0;a<Ql.length;a++)Te(Ql[a],t);break;case"source":Te("error",t);break;case"img":case"image":case"link":Te("error",t),Te("load",t);break;case"details":Te("toggle",t);break;case"input":Te("invalid",t),bd(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Te("invalid",t);break;case"textarea":Te("invalid",t),Ad(t,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||l.suppressHydrationWarning===!0||Np(t.textContent,a)?(l.popover!=null&&(Te("beforetoggle",t),Te("toggle",t)),l.onScroll!=null&&Te("scroll",t),l.onScrollEnd!=null&&Te("scrollend",t),l.onClick!=null&&(t.onclick=zn),t=!0):t=!1,t||ma(e,!0)}function om(e){for(Mt=e.return;Mt;)switch(Mt.tag){case 5:case 31:case 13:on=!1;return;case 27:case 3:on=!0;return;default:Mt=Mt.return}}function ks(e){if(e!==Mt)return!1;if(!Oe)return om(e),Oe=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Su(e.type,e.memoizedProps)),a=!a),a&&nt&&ma(e),om(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Dp(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Dp(e)}else t===27?(t=nt,Ea(e.type)?(e=Cu,Cu=null,nt=e):nt=t):nt=Mt?un(e.stateNode.nextSibling):null;return!0}function Ya(){nt=Mt=null,Oe=!1}function sc(){var e=da;return e!==null&&(Vt===null?Vt=e:Vt.push.apply(Vt,e),da=null),e}function wl(e){da===null?da=[e]:da.push(e)}var lc=k(null),Fa=null,$n=null;function ha(e,t,a){P(lc,t._currentValue),t._currentValue=a}function Gn(e){e._currentValue=lc.current,H(lc)}function ic(e,t,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===a)break;e=e.return}}function rc(e,t,a,l){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var u=c.dependencies;if(u!==null){var v=c.child;u=u.firstContext;e:for(;u!==null;){var S=u;u=c;for(var D=0;D<t.length;D++)if(S.context===t[D]){u.lanes|=a,S=u.alternate,S!==null&&(S.lanes|=a),ic(u.return,a,e),l||(v=null);break e}u=S.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),ic(v,a,e),v=null}else v=c.child;if(v!==null)v.return=c;else for(v=c;v!==null;){if(v===e){v=null;break}if(c=v.sibling,c!==null){c.return=v.return,v=c;break}v=v.return}c=v}}function Ms(e,t,a,l){e=null;for(var c=t,u=!1;c!==null;){if(!u){if((c.flags&524288)!==0)u=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var v=c.alternate;if(v===null)throw Error(o(387));if(v=v.memoizedProps,v!==null){var S=c.type;Ft(c.pendingProps.value,v.value)||(e!==null?e.push(S):e=[S])}}else if(c===ce.current){if(v=c.alternate,v===null)throw Error(o(387));v.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Pl):e=[Pl])}c=c.return}e!==null&&rc(t,e,a,l),t.flags|=262144}function Fi(e){for(e=e.firstContext;e!==null;){if(!Ft(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xa(e){Fa=e,$n=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function qt(e){return cm(Fa,e)}function Xi(e,t){return Fa===null&&Xa(e),cm(e,t)}function cm(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},$n===null){if(e===null)throw Error(o(308));$n=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $n=$n.next=t;return a}var _v=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,l){e.push(l)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Ov=n.unstable_scheduleCallback,Bv=n.unstable_NormalPriority,gt={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function oc(){return{controller:new _v,data:new Map,refCount:0}}function Cl(e){e.refCount--,e.refCount===0&&Ov(Bv,function(){e.controller.abort()})}var El=null,cc=0,qs=0,Rs=null;function Lv(e,t){if(El===null){var a=El=[];cc=0,qs=du(),Rs={status:"pending",value:void 0,then:function(l){a.push(l)}}}return cc++,t.then(um,um),t}function um(){if(--cc===0&&El!==null){Rs!==null&&(Rs.status="fulfilled");var e=El;El=null,qs=0,Rs=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function zv(e,t){var a=[],l={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){l.status="fulfilled",l.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(l.status="rejected",l.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),l}var fm=T.S;T.S=function(e,t){Kh=Le(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Lv(e,t),fm!==null&&fm(e,t)};var Qa=k(null);function uc(){var e=Qa.current;return e!==null?e:We.pooledCache}function Qi(e,t){t===null?P(Qa,Qa.current):P(Qa,t.pool)}function dm(){var e=uc();return e===null?null:{parent:gt._currentValue,pool:e}}var Ts=Error(o(460)),fc=Error(o(474)),Ki=Error(o(542)),Zi={then:function(){}};function mm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function hm(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(zn,zn),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,xm(e),e;default:if(typeof t.status=="string")t.then(zn,zn);else{if(e=We,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(l){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=l}},function(l){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=l}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,xm(e),e}throw Za=t,Ts}}function Ka(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Za=a,Ts):a}}var Za=null;function pm(){if(Za===null)throw Error(o(459));var e=Za;return Za=null,e}function xm(e){if(e===Ts||e===Ki)throw Error(o(483))}var Ds=null,kl=0;function Ii(e){var t=kl;return kl+=1,Ds===null&&(Ds=[]),hm(Ds,e,t)}function Ml(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ji(e,t){throw t.$$typeof===A?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function gm(e){function t(z,O){if(e){var V=z.deletions;V===null?(z.deletions=[O],z.flags|=16):V.push(O)}}function a(z,O){if(!e)return null;for(;O!==null;)t(z,O),O=O.sibling;return null}function l(z){for(var O=new Map;z!==null;)z.key!==null?O.set(z.key,z):O.set(z.index,z),z=z.sibling;return O}function c(z,O){return z=Hn(z,O),z.index=0,z.sibling=null,z}function u(z,O,V){return z.index=V,e?(V=z.alternate,V!==null?(V=V.index,V<O?(z.flags|=67108866,O):V):(z.flags|=67108866,O)):(z.flags|=1048576,O)}function v(z){return e&&z.alternate===null&&(z.flags|=67108866),z}function S(z,O,V,W){return O===null||O.tag!==6?(O=Wo(V,z.mode,W),O.return=z,O):(O=c(O,V),O.return=z,O)}function D(z,O,V,W){var Se=V.type;return Se===q?I(z,O,V.props.children,W,V.key):O!==null&&(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===Q&&Ka(Se)===O.type)?(O=c(O,V.props),Ml(O,V),O.return=z,O):(O=Gi(V.type,V.key,V.props,null,z.mode,W),Ml(O,V),O.return=z,O)}function $(z,O,V,W){return O===null||O.tag!==4||O.stateNode.containerInfo!==V.containerInfo||O.stateNode.implementation!==V.implementation?(O=ec(V,z.mode,W),O.return=z,O):(O=c(O,V.children||[]),O.return=z,O)}function I(z,O,V,W,Se){return O===null||O.tag!==7?(O=Ga(V,z.mode,W,Se),O.return=z,O):(O=c(O,V),O.return=z,O)}function ee(z,O,V){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=Wo(""+O,z.mode,V),O.return=z,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case R:return V=Gi(O.type,O.key,O.props,null,z.mode,V),Ml(V,O),V.return=z,V;case N:return O=ec(O,z.mode,V),O.return=z,O;case Q:return O=Ka(O),ee(z,O,V)}if(G(O)||te(O))return O=Ga(O,z.mode,V,null),O.return=z,O;if(typeof O.then=="function")return ee(z,Ii(O),V);if(O.$$typeof===C)return ee(z,Xi(z,O),V);Ji(z,O)}return null}function X(z,O,V,W){var Se=O!==null?O.key:null;if(typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint")return Se!==null?null:S(z,O,""+V,W);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case R:return V.key===Se?D(z,O,V,W):null;case N:return V.key===Se?$(z,O,V,W):null;case Q:return V=Ka(V),X(z,O,V,W)}if(G(V)||te(V))return Se!==null?null:I(z,O,V,W,null);if(typeof V.then=="function")return X(z,O,Ii(V),W);if(V.$$typeof===C)return X(z,O,Xi(z,V),W);Ji(z,V)}return null}function Z(z,O,V,W,Se){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return z=z.get(V)||null,S(O,z,""+W,Se);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case R:return z=z.get(W.key===null?V:W.key)||null,D(O,z,W,Se);case N:return z=z.get(W.key===null?V:W.key)||null,$(O,z,W,Se);case Q:return W=Ka(W),Z(z,O,V,W,Se)}if(G(W)||te(W))return z=z.get(V)||null,I(O,z,W,Se,null);if(typeof W.then=="function")return Z(z,O,V,Ii(W),Se);if(W.$$typeof===C)return Z(z,O,V,Xi(O,W),Se);Ji(O,W)}return null}function he(z,O,V,W){for(var Se=null,He=null,ge=O,ke=O=0,_e=null;ge!==null&&ke<V.length;ke++){ge.index>ke?(_e=ge,ge=null):_e=ge.sibling;var Ve=X(z,ge,V[ke],W);if(Ve===null){ge===null&&(ge=_e);break}e&&ge&&Ve.alternate===null&&t(z,ge),O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve,ge=_e}if(ke===V.length)return a(z,ge),Oe&&Vn(z,ke),Se;if(ge===null){for(;ke<V.length;ke++)ge=ee(z,V[ke],W),ge!==null&&(O=u(ge,O,ke),He===null?Se=ge:He.sibling=ge,He=ge);return Oe&&Vn(z,ke),Se}for(ge=l(ge);ke<V.length;ke++)_e=Z(ge,z,ke,V[ke],W),_e!==null&&(e&&_e.alternate!==null&&ge.delete(_e.key===null?ke:_e.key),O=u(_e,O,ke),He===null?Se=_e:He.sibling=_e,He=_e);return e&&ge.forEach(function(Ta){return t(z,Ta)}),Oe&&Vn(z,ke),Se}function je(z,O,V,W){if(V==null)throw Error(o(151));for(var Se=null,He=null,ge=O,ke=O=0,_e=null,Ve=V.next();ge!==null&&!Ve.done;ke++,Ve=V.next()){ge.index>ke?(_e=ge,ge=null):_e=ge.sibling;var Ta=X(z,ge,Ve.value,W);if(Ta===null){ge===null&&(ge=_e);break}e&&ge&&Ta.alternate===null&&t(z,ge),O=u(Ta,O,ke),He===null?Se=Ta:He.sibling=Ta,He=Ta,ge=_e}if(Ve.done)return a(z,ge),Oe&&Vn(z,ke),Se;if(ge===null){for(;!Ve.done;ke++,Ve=V.next())Ve=ee(z,Ve.value,W),Ve!==null&&(O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve);return Oe&&Vn(z,ke),Se}for(ge=l(ge);!Ve.done;ke++,Ve=V.next())Ve=Z(ge,z,ke,Ve.value,W),Ve!==null&&(e&&Ve.alternate!==null&&ge.delete(Ve.key===null?ke:Ve.key),O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve);return e&&ge.forEach(function(Zy){return t(z,Zy)}),Oe&&Vn(z,ke),Se}function Je(z,O,V,W){if(typeof V=="object"&&V!==null&&V.type===q&&V.key===null&&(V=V.props.children),typeof V=="object"&&V!==null){switch(V.$$typeof){case R:e:{for(var Se=V.key;O!==null;){if(O.key===Se){if(Se=V.type,Se===q){if(O.tag===7){a(z,O.sibling),W=c(O,V.props.children),W.return=z,z=W;break e}}else if(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===Q&&Ka(Se)===O.type){a(z,O.sibling),W=c(O,V.props),Ml(W,V),W.return=z,z=W;break e}a(z,O);break}else t(z,O);O=O.sibling}V.type===q?(W=Ga(V.props.children,z.mode,W,V.key),W.return=z,z=W):(W=Gi(V.type,V.key,V.props,null,z.mode,W),Ml(W,V),W.return=z,z=W)}return v(z);case N:e:{for(Se=V.key;O!==null;){if(O.key===Se)if(O.tag===4&&O.stateNode.containerInfo===V.containerInfo&&O.stateNode.implementation===V.implementation){a(z,O.sibling),W=c(O,V.children||[]),W.return=z,z=W;break e}else{a(z,O);break}else t(z,O);O=O.sibling}W=ec(V,z.mode,W),W.return=z,z=W}return v(z);case Q:return V=Ka(V),Je(z,O,V,W)}if(G(V))return he(z,O,V,W);if(te(V)){if(Se=te(V),typeof Se!="function")throw Error(o(150));return V=Se.call(V),je(z,O,V,W)}if(typeof V.then=="function")return Je(z,O,Ii(V),W);if(V.$$typeof===C)return Je(z,O,Xi(z,V),W);Ji(z,V)}return typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint"?(V=""+V,O!==null&&O.tag===6?(a(z,O.sibling),W=c(O,V),W.return=z,z=W):(a(z,O),W=Wo(V,z.mode,W),W.return=z,z=W),v(z)):a(z,O)}return function(z,O,V,W){try{kl=0;var Se=Je(z,O,V,W);return Ds=null,Se}catch(ge){if(ge===Ts||ge===Ki)throw ge;var He=Xt(29,ge,null,z.mode);return He.lanes=W,He.return=z,He}finally{}}}var Ia=gm(!0),vm=gm(!1),pa=!1;function dc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function xa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ga(e,t,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ge&2)!==0){var c=l.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),l.pending=t,t=$i(e),tm(e,null,a),t}return Vi(e,l,t,a),$i(e)}function ql(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,en(e,a)}}function hc(e,t){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var c=null,u=null;if(a=a.firstBaseUpdate,a!==null){do{var v={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};u===null?c=u=v:u=u.next=v,a=a.next}while(a!==null);u===null?c=u=t:u=u.next=t}else c=u=t;a={baseState:l.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:l.shared,callbacks:l.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var pc=!1;function Rl(){if(pc){var e=Rs;if(e!==null)throw e}}function Tl(e,t,a,l){pc=!1;var c=e.updateQueue;pa=!1;var u=c.firstBaseUpdate,v=c.lastBaseUpdate,S=c.shared.pending;if(S!==null){c.shared.pending=null;var D=S,$=D.next;D.next=null,v===null?u=$:v.next=$,v=D;var I=e.alternate;I!==null&&(I=I.updateQueue,S=I.lastBaseUpdate,S!==v&&(S===null?I.firstBaseUpdate=$:S.next=$,I.lastBaseUpdate=D))}if(u!==null){var ee=c.baseState;v=0,I=$=D=null,S=u;do{var X=S.lane&-536870913,Z=X!==S.lane;if(Z?(De&X)===X:(l&X)===X){X!==0&&X===qs&&(pc=!0),I!==null&&(I=I.next={lane:0,tag:S.tag,payload:S.payload,callback:null,next:null});e:{var he=e,je=S;X=t;var Je=a;switch(je.tag){case 1:if(he=je.payload,typeof he=="function"){ee=he.call(Je,ee,X);break e}ee=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=je.payload,X=typeof he=="function"?he.call(Je,ee,X):he,X==null)break e;ee=b({},ee,X);break e;case 2:pa=!0}}X=S.callback,X!==null&&(e.flags|=64,Z&&(e.flags|=8192),Z=c.callbacks,Z===null?c.callbacks=[X]:Z.push(X))}else Z={lane:X,tag:S.tag,payload:S.payload,callback:S.callback,next:null},I===null?($=I=Z,D=ee):I=I.next=Z,v|=X;if(S=S.next,S===null){if(S=c.shared.pending,S===null)break;Z=S,S=Z.next,Z.next=null,c.lastBaseUpdate=Z,c.shared.pending=null}}while(!0);I===null&&(D=ee),c.baseState=D,c.firstBaseUpdate=$,c.lastBaseUpdate=I,u===null&&(c.shared.lanes=0),Aa|=v,e.lanes=v,e.memoizedState=ee}}function ym(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function bm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)ym(a[e],t)}var _s=k(null),Pi=k(0);function Sm(e,t){e=Pn,P(Pi,e),P(_s,t),Pn=e|t.baseLanes}function xc(){P(Pi,Pn),P(_s,_s.current)}function gc(){Pn=Pi.current,H(_s),H(Pi)}var Qt=k(null),cn=null;function va(e){var t=e.alternate;P(ht,ht.current&1),P(Qt,e),cn===null&&(t===null||_s.current!==null||t.memoizedState!==null)&&(cn=e)}function vc(e){P(ht,ht.current),P(Qt,e),cn===null&&(cn=e)}function Am(e){e.tag===22?(P(ht,ht.current),P(Qt,e),cn===null&&(cn=e)):ya()}function ya(){P(ht,ht.current),P(Qt,Qt.current)}function Kt(e){H(Qt),cn===e&&(cn=null),H(ht)}var ht=k(0);function Wi(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Nu(a)||wu(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Yn=0,Ee=null,Ze=null,vt=null,er=!1,Os=!1,Ja=!1,tr=0,Dl=0,Bs=null,Uv=0;function ct(){throw Error(o(321))}function yc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Ft(e[a],t[a]))return!1;return!0}function bc(e,t,a,l,c,u){return Yn=u,Ee=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?lh:Oc,Ja=!1,u=a(l,c),Ja=!1,Os&&(u=Nm(t,a,l,c)),jm(e),u}function jm(e){T.H=Bl;var t=Ze!==null&&Ze.next!==null;if(Yn=0,vt=Ze=Ee=null,er=!1,Dl=0,Bs=null,t)throw Error(o(300));e===null||yt||(e=e.dependencies,e!==null&&Fi(e)&&(yt=!0))}function Nm(e,t,a,l){Ee=e;var c=0;do{if(Os&&(Bs=null),Dl=0,Os=!1,25<=c)throw Error(o(301));if(c+=1,vt=Ze=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}T.H=ih,u=t(a,l)}while(Os);return u}function Hv(){var e=T.H,t=e.useState()[0];return t=typeof t.then=="function"?_l(t):t,e=e.useState()[0],(Ze!==null?Ze.memoizedState:null)!==e&&(Ee.flags|=1024),t}function Sc(){var e=tr!==0;return tr=0,e}function Ac(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function jc(e){if(er){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}er=!1}Yn=0,vt=Ze=Ee=null,Os=!1,Dl=tr=0,Bs=null}function Bt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vt===null?Ee.memoizedState=vt=e:vt=vt.next=e,vt}function pt(){if(Ze===null){var e=Ee.alternate;e=e!==null?e.memoizedState:null}else e=Ze.next;var t=vt===null?Ee.memoizedState:vt.next;if(t!==null)vt=t,Ze=e;else{if(e===null)throw Ee.alternate===null?Error(o(467)):Error(o(310));Ze=e,e={memoizedState:Ze.memoizedState,baseState:Ze.baseState,baseQueue:Ze.baseQueue,queue:Ze.queue,next:null},vt===null?Ee.memoizedState=vt=e:vt=vt.next=e}return vt}function nr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function _l(e){var t=Dl;return Dl+=1,Bs===null&&(Bs=[]),e=hm(Bs,e,t),t=Ee,(vt===null?t.memoizedState:vt.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?lh:Oc),e}function ar(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return _l(e);if(e.$$typeof===C)return qt(e)}throw Error(o(438,String(e)))}function Nc(e){var t=null,a=Ee.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var l=Ee.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(t={data:l.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=nr(),Ee.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),l=0;l<e;l++)a[l]=U;return t.index++,a}function Fn(e,t){return typeof t=="function"?t(e):t}function sr(e){var t=pt();return wc(t,Ze,e)}function wc(e,t,a){var l=e.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=a;var c=e.baseQueue,u=l.pending;if(u!==null){if(c!==null){var v=c.next;c.next=u.next,u.next=v}t.baseQueue=c=u,l.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var S=v=null,D=null,$=t,I=!1;do{var ee=$.lane&-536870913;if(ee!==$.lane?(De&ee)===ee:(Yn&ee)===ee){var X=$.revertLane;if(X===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),ee===qs&&(I=!0);else if((Yn&X)===X){$=$.next,X===qs&&(I=!0);continue}else ee={lane:0,revertLane:$.revertLane,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},D===null?(S=D=ee,v=u):D=D.next=ee,Ee.lanes|=X,Aa|=X;ee=$.action,Ja&&a(u,ee),u=$.hasEagerState?$.eagerState:a(u,ee)}else X={lane:ee,revertLane:$.revertLane,gesture:$.gesture,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},D===null?(S=D=X,v=u):D=D.next=X,Ee.lanes|=ee,Aa|=ee;$=$.next}while($!==null&&$!==t);if(D===null?v=u:D.next=S,!Ft(u,e.memoizedState)&&(yt=!0,I&&(a=Rs,a!==null)))throw a;e.memoizedState=u,e.baseState=v,e.baseQueue=D,l.lastRenderedState=u}return c===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function Cc(e){var t=pt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var l=a.dispatch,c=a.pending,u=t.memoizedState;if(c!==null){a.pending=null;var v=c=c.next;do u=e(u,v.action),v=v.next;while(v!==c);Ft(u,t.memoizedState)||(yt=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),a.lastRenderedState=u}return[u,l]}function wm(e,t,a){var l=Ee,c=pt(),u=Oe;if(u){if(a===void 0)throw Error(o(407));a=a()}else a=t();var v=!Ft((Ze||c).memoizedState,a);if(v&&(c.memoizedState=a,yt=!0),c=c.queue,Mc(km.bind(null,l,c,e),[e]),c.getSnapshot!==t||v||vt!==null&&vt.memoizedState.tag&1){if(l.flags|=2048,Ls(9,{destroy:void 0},Em.bind(null,l,c,a,t),null),We===null)throw Error(o(349));u||(Yn&127)!==0||Cm(l,t,a)}return a}function Cm(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=Ee.updateQueue,t===null?(t=nr(),Ee.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Em(e,t,a,l){t.value=a,t.getSnapshot=l,Mm(t)&&qm(e)}function km(e,t,a){return a(function(){Mm(t)&&qm(e)})}function Mm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Ft(e,a)}catch{return!0}}function qm(e){var t=$a(e,2);t!==null&&$t(t,e,2)}function Ec(e){var t=Bt();if(typeof e=="function"){var a=e;if(e=a(),Ja){Yt(!0);try{a()}finally{Yt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:e},t}function Rm(e,t,a,l){return e.baseState=a,wc(e,Ze,typeof l=="function"?l:Fn)}function Vv(e,t,a,l,c){if(rr(e))throw Error(o(485));if(e=t.action,e!==null){var u={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){u.listeners.push(v)}};T.T!==null?a(!0):u.isTransition=!1,l(u),a=t.pending,a===null?(u.next=t.pending=u,Tm(t,u)):(u.next=a.next,t.pending=a.next=u)}}function Tm(e,t){var a=t.action,l=t.payload,c=e.state;if(t.isTransition){var u=T.T,v={};T.T=v;try{var S=a(c,l),D=T.S;D!==null&&D(v,S),Dm(e,t,S)}catch($){kc(e,t,$)}finally{u!==null&&v.types!==null&&(u.types=v.types),T.T=u}}else try{u=a(c,l),Dm(e,t,u)}catch($){kc(e,t,$)}}function Dm(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){_m(e,t,l)},function(l){return kc(e,t,l)}):_m(e,t,a)}function _m(e,t,a){t.status="fulfilled",t.value=a,Om(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Tm(e,a)))}function kc(e,t,a){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do t.status="rejected",t.reason=a,Om(t),t=t.next;while(t!==l)}e.action=null}function Om(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Bm(e,t){return t}function Lm(e,t){if(Oe){var a=We.formState;if(a!==null){e:{var l=Ee;if(Oe){if(nt){t:{for(var c=nt,u=on;c.nodeType!==8;){if(!u){c=null;break t}if(c=un(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){nt=un(c.nextSibling),l=c.data==="F!";break e}}ma(l)}l=!1}l&&(t=a[0])}}return a=Bt(),a.memoizedState=a.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bm,lastRenderedState:t},a.queue=l,a=nh.bind(null,Ee,l),l.dispatch=a,l=Ec(!1),u=_c.bind(null,Ee,!1,l.queue),l=Bt(),c={state:t,dispatch:null,action:e,pending:null},l.queue=c,a=Vv.bind(null,Ee,c,u,a),c.dispatch=a,l.memoizedState=e,[t,a,!1]}function zm(e){var t=pt();return Um(t,Ze,e)}function Um(e,t,a){if(t=wc(e,t,Bm)[0],e=sr(Fn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var l=_l(t)}catch(v){throw v===Ts?Ki:v}else l=t;t=pt();var c=t.queue,u=c.dispatch;return a!==t.memoizedState&&(Ee.flags|=2048,Ls(9,{destroy:void 0},$v.bind(null,c,a),null)),[l,u,e]}function $v(e,t){e.action=t}function Hm(e){var t=pt(),a=Ze;if(a!==null)return Um(t,a,e);pt(),t=t.memoizedState,a=pt();var l=a.queue.dispatch;return a.memoizedState=e,[t,l,!1]}function Ls(e,t,a,l){return e={tag:e,create:a,deps:l,inst:t,next:null},t=Ee.updateQueue,t===null&&(t=nr(),Ee.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,t.lastEffect=e),e}function Vm(){return pt().memoizedState}function lr(e,t,a,l){var c=Bt();Ee.flags|=e,c.memoizedState=Ls(1|t,{destroy:void 0},a,l===void 0?null:l)}function ir(e,t,a,l){var c=pt();l=l===void 0?null:l;var u=c.memoizedState.inst;Ze!==null&&l!==null&&yc(l,Ze.memoizedState.deps)?c.memoizedState=Ls(t,u,a,l):(Ee.flags|=e,c.memoizedState=Ls(1|t,u,a,l))}function $m(e,t){lr(8390656,8,e,t)}function Mc(e,t){ir(2048,8,e,t)}function Gv(e){Ee.flags|=4;var t=Ee.updateQueue;if(t===null)t=nr(),Ee.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function Gm(e){var t=pt().memoizedState;return Gv({ref:t,nextImpl:e}),function(){if((Ge&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Ym(e,t){return ir(4,2,e,t)}function Fm(e,t){return ir(4,4,e,t)}function Xm(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 Qm(e,t,a){a=a!=null?a.concat([e]):null,ir(4,4,Xm.bind(null,t,e),a)}function qc(){}function Km(e,t){var a=pt();t=t===void 0?null:t;var l=a.memoizedState;return t!==null&&yc(t,l[1])?l[0]:(a.memoizedState=[e,t],e)}function Zm(e,t){var a=pt();t=t===void 0?null:t;var l=a.memoizedState;if(t!==null&&yc(t,l[1]))return l[0];if(l=e(),Ja){Yt(!0);try{e()}finally{Yt(!1)}}return a.memoizedState=[l,t],l}function Rc(e,t,a){return a===void 0||(Yn&1073741824)!==0&&(De&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=Ih(),Ee.lanes|=e,Aa|=e,a)}function Im(e,t,a,l){return Ft(a,t)?a:_s.current!==null?(e=Rc(e,a,l),Ft(e,t)||(yt=!0),e):(Yn&42)===0||(Yn&1073741824)!==0&&(De&261930)===0?(yt=!0,e.memoizedState=a):(e=Ih(),Ee.lanes|=e,Aa|=e,t)}function Jm(e,t,a,l,c){var u=F.p;F.p=u!==0&&8>u?u:8;var v=T.T,S={};T.T=S,_c(e,!1,t,a);try{var D=c(),$=T.S;if($!==null&&$(S,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var I=zv(D,l);Ol(e,t,I,Jt(e))}else Ol(e,t,l,Jt(e))}catch(ee){Ol(e,t,{then:function(){},status:"rejected",reason:ee},Jt())}finally{F.p=u,v!==null&&S.types!==null&&(v.types=S.types),T.T=v}}function Yv(){}function Tc(e,t,a,l){if(e.tag!==5)throw Error(o(476));var c=Pm(e).queue;Jm(e,c,t,J,a===null?Yv:function(){return Wm(e),a(l)})}function Pm(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:J},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Wm(e){var t=Pm(e);t.next===null&&(t=e.alternate.memoizedState),Ol(e,t.next.queue,{},Jt())}function Dc(){return qt(Pl)}function eh(){return pt().memoizedState}function th(){return pt().memoizedState}function Fv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=Jt();e=xa(a);var l=ga(t,e,a);l!==null&&($t(l,t,a),ql(l,t,a)),t={cache:oc()},e.payload=t;return}t=t.return}}function Xv(e,t,a){var l=Jt();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},rr(e)?ah(t,a):(a=Jo(e,t,a,l),a!==null&&($t(a,e,l),sh(a,t,l)))}function nh(e,t,a){var l=Jt();Ol(e,t,a,l)}function Ol(e,t,a,l){var c={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(rr(e))ah(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,S=u(v,a);if(c.hasEagerState=!0,c.eagerState=S,Ft(S,v))return Vi(e,t,c,0),We===null&&Hi(),!1}catch{}finally{}if(a=Jo(e,t,c,l),a!==null)return $t(a,e,l),sh(a,t,l),!0}return!1}function _c(e,t,a,l){if(l={lane:2,revertLane:du(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},rr(e)){if(t)throw Error(o(479))}else t=Jo(e,a,l,2),t!==null&&$t(t,e,2)}function rr(e){var t=e.alternate;return e===Ee||t!==null&&t===Ee}function ah(e,t){Os=er=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function sh(e,t,a){if((a&4194048)!==0){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,en(e,a)}}var Bl={readContext:qt,use:ar,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};Bl.useEffectEvent=ct;var lh={readContext:qt,use:ar,useCallback:function(e,t){return Bt().memoizedState=[e,t===void 0?null:t],e},useContext:qt,useEffect:$m,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,lr(4194308,4,Xm.bind(null,t,e),a)},useLayoutEffect:function(e,t){return lr(4194308,4,e,t)},useInsertionEffect:function(e,t){lr(4,2,e,t)},useMemo:function(e,t){var a=Bt();t=t===void 0?null:t;var l=e();if(Ja){Yt(!0);try{e()}finally{Yt(!1)}}return a.memoizedState=[l,t],l},useReducer:function(e,t,a){var l=Bt();if(a!==void 0){var c=a(t);if(Ja){Yt(!0);try{a(t)}finally{Yt(!1)}}}else c=t;return l.memoizedState=l.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},l.queue=e,e=e.dispatch=Xv.bind(null,Ee,e),[l.memoizedState,e]},useRef:function(e){var t=Bt();return e={current:e},t.memoizedState=e},useState:function(e){e=Ec(e);var t=e.queue,a=nh.bind(null,Ee,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:qc,useDeferredValue:function(e,t){var a=Bt();return Rc(a,e,t)},useTransition:function(){var e=Ec(!1);return e=Jm.bind(null,Ee,e.queue,!0,!1),Bt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var l=Ee,c=Bt();if(Oe){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),We===null)throw Error(o(349));(De&127)!==0||Cm(l,t,a)}c.memoizedState=a;var u={value:a,getSnapshot:t};return c.queue=u,$m(km.bind(null,l,u,e),[e]),l.flags|=2048,Ls(9,{destroy:void 0},Em.bind(null,l,u,a,t),null),a},useId:function(){var e=Bt(),t=We.identifierPrefix;if(Oe){var a=Nn,l=jn;a=(l&~(1<<32-kt(l)-1)).toString(32)+a,t="_"+t+"R_"+a,a=tr++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=Uv++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Dc,useFormState:Lm,useActionState:Lm,useOptimistic:function(e){var t=Bt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=_c.bind(null,Ee,!0,a),a.dispatch=t,[e,t]},useMemoCache:Nc,useCacheRefresh:function(){return Bt().memoizedState=Fv.bind(null,Ee)},useEffectEvent:function(e){var t=Bt(),a={impl:e};return t.memoizedState=a,function(){if((Ge&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Oc={readContext:qt,use:ar,useCallback:Km,useContext:qt,useEffect:Mc,useImperativeHandle:Qm,useInsertionEffect:Ym,useLayoutEffect:Fm,useMemo:Zm,useReducer:sr,useRef:Vm,useState:function(){return sr(Fn)},useDebugValue:qc,useDeferredValue:function(e,t){var a=pt();return Im(a,Ze.memoizedState,e,t)},useTransition:function(){var e=sr(Fn)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:_l(e),t]},useSyncExternalStore:wm,useId:eh,useHostTransitionStatus:Dc,useFormState:zm,useActionState:zm,useOptimistic:function(e,t){var a=pt();return Rm(a,Ze,e,t)},useMemoCache:Nc,useCacheRefresh:th};Oc.useEffectEvent=Gm;var ih={readContext:qt,use:ar,useCallback:Km,useContext:qt,useEffect:Mc,useImperativeHandle:Qm,useInsertionEffect:Ym,useLayoutEffect:Fm,useMemo:Zm,useReducer:Cc,useRef:Vm,useState:function(){return Cc(Fn)},useDebugValue:qc,useDeferredValue:function(e,t){var a=pt();return Ze===null?Rc(a,e,t):Im(a,Ze.memoizedState,e,t)},useTransition:function(){var e=Cc(Fn)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:_l(e),t]},useSyncExternalStore:wm,useId:eh,useHostTransitionStatus:Dc,useFormState:Hm,useActionState:Hm,useOptimistic:function(e,t){var a=pt();return Ze!==null?Rm(a,Ze,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Nc,useCacheRefresh:th};ih.useEffectEvent=Gm;function Bc(e,t,a,l){t=e.memoizedState,a=a(l,t),a=a==null?t:b({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Lc={enqueueSetState:function(e,t,a){e=e._reactInternals;var l=Jt(),c=xa(l);c.payload=t,a!=null&&(c.callback=a),t=ga(e,c,l),t!==null&&($t(t,e,l),ql(t,e,l))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var l=Jt(),c=xa(l);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=ga(e,c,l),t!==null&&($t(t,e,l),ql(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=Jt(),l=xa(a);l.tag=2,t!=null&&(l.callback=t),t=ga(e,l,a),t!==null&&($t(t,e,a),ql(t,e,a))}};function rh(e,t,a,l,c,u,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,u,v):t.prototype&&t.prototype.isPureReactComponent?!Al(a,l)||!Al(c,u):!0}function oh(e,t,a,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,l),t.state!==e&&Lc.enqueueReplaceState(t,t.state,null)}function Pa(e,t){var a=t;if("ref"in t){a={};for(var l in t)l!=="ref"&&(a[l]=t[l])}if(e=e.defaultProps){a===t&&(a=b({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function ch(e){Ui(e)}function uh(e){console.error(e)}function fh(e){Ui(e)}function or(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function dh(e,t,a){try{var l=e.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function zc(e,t,a){return a=xa(a),a.tag=3,a.payload={element:null},a.callback=function(){or(e,t)},a}function mh(e){return e=xa(e),e.tag=3,e}function hh(e,t,a,l){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var u=l.value;e.payload=function(){return c(u)},e.callback=function(){dh(t,a,l)}}var v=a.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){dh(t,a,l),typeof c!="function"&&(ja===null?ja=new Set([this]):ja.add(this));var S=l.stack;this.componentDidCatch(l.value,{componentStack:S!==null?S:""})})}function Qv(e,t,a,l,c){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(t=a.alternate,t!==null&&Ms(t,a,c,!0),a=Qt.current,a!==null){switch(a.tag){case 31:case 13:return cn===null?br():a.alternate===null&&ut===0&&(ut=3),a.flags&=-257,a.flags|=65536,a.lanes=c,l===Zi?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([l]):t.add(l),cu(e,l,c)),!1;case 22:return a.flags|=65536,l===Zi?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([l]):a.add(l)),cu(e,l,c)),!1}throw Error(o(435,a.tag))}return cu(e,l,c),br(),!1}if(Oe)return t=Qt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,l!==ac&&(e=Error(o(422),{cause:l}),wl(sn(e,a)))):(l!==ac&&(t=Error(o(423),{cause:l}),wl(sn(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,l=sn(l,a),c=zc(e.stateNode,l,c),hc(e,c),ut!==4&&(ut=2)),!1;var u=Error(o(520),{cause:l});if(u=sn(u,a),Yl===null?Yl=[u]:Yl.push(u),ut!==4&&(ut=2),t===null)return!0;l=sn(l,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=zc(a.stateNode,l,e),hc(a,e),!1;case 1:if(t=a.type,u=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(ja===null||!ja.has(u))))return a.flags|=65536,c&=-c,a.lanes|=c,c=mh(c),hh(c,e,a,l),hc(a,c),!1}a=a.return}while(a!==null);return!1}var Uc=Error(o(461)),yt=!1;function Rt(e,t,a,l){t.child=e===null?vm(t,null,a,l):Ia(t,e.child,a,l)}function ph(e,t,a,l,c){a=a.render;var u=t.ref;if("ref"in l){var v={};for(var S in l)S!=="ref"&&(v[S]=l[S])}else v=l;return Xa(t),l=bc(e,t,a,v,u,c),S=Sc(),e!==null&&!yt?(Ac(e,t,c),Xn(e,t,c)):(Oe&&S&&tc(t),t.flags|=1,Rt(e,t,l,c),t.child)}function xh(e,t,a,l,c){if(e===null){var u=a.type;return typeof u=="function"&&!Po(u)&&u.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=u,gh(e,t,u,l,c)):(e=Gi(a.type,null,l,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!Qc(e,c)){var v=u.memoizedProps;if(a=a.compare,a=a!==null?a:Al,a(v,l)&&e.ref===t.ref)return Xn(e,t,c)}return t.flags|=1,e=Hn(u,l),e.ref=t.ref,e.return=t,t.child=e}function gh(e,t,a,l,c){if(e!==null){var u=e.memoizedProps;if(Al(u,l)&&e.ref===t.ref)if(yt=!1,t.pendingProps=l=u,Qc(e,c))(e.flags&131072)!==0&&(yt=!0);else return t.lanes=e.lanes,Xn(e,t,c)}return Hc(e,t,a,l,c)}function vh(e,t,a,l){var c=l.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|a:a,e!==null){for(l=t.child=e.child,c=0;l!==null;)c=c|l.lanes|l.childLanes,l=l.sibling;l=c&~u}else l=0,t.child=null;return yh(e,t,u,a,l)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Qi(t,u!==null?u.cachePool:null),u!==null?Sm(t,u):xc(),Am(t);else return l=t.lanes=536870912,yh(e,t,u!==null?u.baseLanes|a:a,a,l)}else u!==null?(Qi(t,u.cachePool),Sm(t,u),ya(),t.memoizedState=null):(e!==null&&Qi(t,null),xc(),ya());return Rt(e,t,c,a),t.child}function Ll(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function yh(e,t,a,l,c){var u=uc();return u=u===null?null:{parent:gt._currentValue,pool:u},t.memoizedState={baseLanes:a,cachePool:u},e!==null&&Qi(t,null),xc(),Am(t),e!==null&&Ms(e,t,l,!0),t.childLanes=c,null}function cr(e,t){return t=fr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function bh(e,t,a){return Ia(t,e.child,null,a),e=cr(t,t.pendingProps),e.flags|=2,Kt(t),t.memoizedState=null,e}function Kv(e,t,a){var l=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Oe){if(l.mode==="hidden")return e=cr(t,l),t.lanes=536870912,Ll(null,e);if(vc(t),(e=nt)?(e=Tp(e,on),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:jn,overflow:Nn}:null,retryLane:536870912,hydrationErrors:null},a=am(e),a.return=t,t.child=a,Mt=t,nt=null)):e=null,e===null)throw ma(t);return t.lanes=536870912,null}return cr(t,l)}var u=e.memoizedState;if(u!==null){var v=u.dehydrated;if(vc(t),c)if(t.flags&256)t.flags&=-257,t=bh(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(yt||Ms(e,t,a,!1),c=(a&e.childLanes)!==0,yt||c){if(l=We,l!==null&&(v=Ae(l,a),v!==0&&v!==u.retryLane))throw u.retryLane=v,$a(e,v),$t(l,e,v),Uc;br(),t=bh(e,t,a)}else e=u.treeContext,nt=un(v.nextSibling),Mt=t,Oe=!0,da=null,on=!1,e!==null&&im(t,e),t=cr(t,l),t.flags|=4096;return t}return e=Hn(e.child,{mode:l.mode,children:l.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ur(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(o(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Hc(e,t,a,l,c){return Xa(t),a=bc(e,t,a,l,void 0,c),l=Sc(),e!==null&&!yt?(Ac(e,t,c),Xn(e,t,c)):(Oe&&l&&tc(t),t.flags|=1,Rt(e,t,a,c),t.child)}function Sh(e,t,a,l,c,u){return Xa(t),t.updateQueue=null,a=Nm(t,l,a,c),jm(e),l=Sc(),e!==null&&!yt?(Ac(e,t,u),Xn(e,t,u)):(Oe&&l&&tc(t),t.flags|=1,Rt(e,t,a,u),t.child)}function Ah(e,t,a,l,c){if(Xa(t),t.stateNode===null){var u=ws,v=a.contextType;typeof v=="object"&&v!==null&&(u=qt(v)),u=new a(l,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Lc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=l,u.state=t.memoizedState,u.refs={},dc(t),v=a.contextType,u.context=typeof v=="object"&&v!==null?qt(v):ws,u.state=t.memoizedState,v=a.getDerivedStateFromProps,typeof v=="function"&&(Bc(t,a,v,l),u.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(v=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),v!==u.state&&Lc.enqueueReplaceState(u,u.state,null),Tl(t,l,u,c),Rl(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),l=!0}else if(e===null){u=t.stateNode;var S=t.memoizedProps,D=Pa(a,S);u.props=D;var $=u.context,I=a.contextType;v=ws,typeof I=="object"&&I!==null&&(v=qt(I));var ee=a.getDerivedStateFromProps;I=typeof ee=="function"||typeof u.getSnapshotBeforeUpdate=="function",S=t.pendingProps!==S,I||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(S||$!==v)&&oh(t,u,l,v),pa=!1;var X=t.memoizedState;u.state=X,Tl(t,l,u,c),Rl(),$=t.memoizedState,S||X!==$||pa?(typeof ee=="function"&&(Bc(t,a,ee,l),$=t.memoizedState),(D=pa||rh(t,a,D,l,X,$,v))?(I||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=$),u.props=l,u.state=$,u.context=v,l=D):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{u=t.stateNode,mc(e,t),v=t.memoizedProps,I=Pa(a,v),u.props=I,ee=t.pendingProps,X=u.context,$=a.contextType,D=ws,typeof $=="object"&&$!==null&&(D=qt($)),S=a.getDerivedStateFromProps,($=typeof S=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(v!==ee||X!==D)&&oh(t,u,l,D),pa=!1,X=t.memoizedState,u.state=X,Tl(t,l,u,c),Rl();var Z=t.memoizedState;v!==ee||X!==Z||pa||e!==null&&e.dependencies!==null&&Fi(e.dependencies)?(typeof S=="function"&&(Bc(t,a,S,l),Z=t.memoizedState),(I=pa||rh(t,a,I,l,X,Z,D)||e!==null&&e.dependencies!==null&&Fi(e.dependencies))?($||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(l,Z,D),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(l,Z,D)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=Z),u.props=l,u.state=Z,u.context=D,l=I):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),l=!1)}return u=l,ur(e,t),l=(t.flags&128)!==0,u||l?(u=t.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&l?(t.child=Ia(t,e.child,null,c),t.child=Ia(t,null,a,c)):Rt(e,t,a,c),t.memoizedState=u.state,e=t.child):e=Xn(e,t,c),e}function jh(e,t,a,l){return Ya(),t.flags|=256,Rt(e,t,a,l),t.child}var Vc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function $c(e){return{baseLanes:e,cachePool:dm()}}function Gc(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=It),e}function Nh(e,t,a){var l=t.pendingProps,c=!1,u=(t.flags&128)!==0,v;if((v=u)||(v=e!==null&&e.memoizedState===null?!1:(ht.current&2)!==0),v&&(c=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,e===null){if(Oe){if(c?va(t):ya(),(e=nt)?(e=Tp(e,on),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:jn,overflow:Nn}:null,retryLane:536870912,hydrationErrors:null},a=am(e),a.return=t,t.child=a,Mt=t,nt=null)):e=null,e===null)throw ma(t);return wu(e)?t.lanes=32:t.lanes=536870912,null}var S=l.children;return l=l.fallback,c?(ya(),c=t.mode,S=fr({mode:"hidden",children:S},c),l=Ga(l,c,a,null),S.return=t,l.return=t,S.sibling=l,t.child=S,l=t.child,l.memoizedState=$c(a),l.childLanes=Gc(e,v,a),t.memoizedState=Vc,Ll(null,l)):(va(t),Yc(t,S))}var D=e.memoizedState;if(D!==null&&(S=D.dehydrated,S!==null)){if(u)t.flags&256?(va(t),t.flags&=-257,t=Fc(e,t,a)):t.memoizedState!==null?(ya(),t.child=e.child,t.flags|=128,t=null):(ya(),S=l.fallback,c=t.mode,l=fr({mode:"visible",children:l.children},c),S=Ga(S,c,a,null),S.flags|=2,l.return=t,S.return=t,l.sibling=S,t.child=l,Ia(t,e.child,null,a),l=t.child,l.memoizedState=$c(a),l.childLanes=Gc(e,v,a),t.memoizedState=Vc,t=Ll(null,l));else if(va(t),wu(S)){if(v=S.nextSibling&&S.nextSibling.dataset,v)var $=v.dgst;v=$,l=Error(o(419)),l.stack="",l.digest=v,wl({value:l,source:null,stack:null}),t=Fc(e,t,a)}else if(yt||Ms(e,t,a,!1),v=(a&e.childLanes)!==0,yt||v){if(v=We,v!==null&&(l=Ae(v,a),l!==0&&l!==D.retryLane))throw D.retryLane=l,$a(e,l),$t(v,e,l),Uc;Nu(S)||br(),t=Fc(e,t,a)}else Nu(S)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,nt=un(S.nextSibling),Mt=t,Oe=!0,da=null,on=!1,e!==null&&im(t,e),t=Yc(t,l.children),t.flags|=4096);return t}return c?(ya(),S=l.fallback,c=t.mode,D=e.child,$=D.sibling,l=Hn(D,{mode:"hidden",children:l.children}),l.subtreeFlags=D.subtreeFlags&65011712,$!==null?S=Hn($,S):(S=Ga(S,c,a,null),S.flags|=2),S.return=t,l.return=t,l.sibling=S,t.child=l,Ll(null,l),l=t.child,S=e.child.memoizedState,S===null?S=$c(a):(c=S.cachePool,c!==null?(D=gt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=dm(),S={baseLanes:S.baseLanes|a,cachePool:c}),l.memoizedState=S,l.childLanes=Gc(e,v,a),t.memoizedState=Vc,Ll(e.child,l)):(va(t),a=e.child,e=a.sibling,a=Hn(a,{mode:"visible",children:l.children}),a.return=t,a.sibling=null,e!==null&&(v=t.deletions,v===null?(t.deletions=[e],t.flags|=16):v.push(e)),t.child=a,t.memoizedState=null,a)}function Yc(e,t){return t=fr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function fr(e,t){return e=Xt(22,e,null,t),e.lanes=0,e}function Fc(e,t,a){return Ia(t,e.child,null,a),e=Yc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function wh(e,t,a){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),ic(e.return,t,a)}function Xc(e,t,a,l,c,u){var v=e.memoizedState;v===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:c,treeForkCount:u}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=l,v.tail=a,v.tailMode=c,v.treeForkCount=u)}function Ch(e,t,a){var l=t.pendingProps,c=l.revealOrder,u=l.tail;l=l.children;var v=ht.current,S=(v&2)!==0;if(S?(v=v&1|2,t.flags|=128):v&=1,P(ht,v),Rt(e,t,l,a),l=Oe?Nl:0,!S&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wh(e,a,t);else if(e.tag===19)wh(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(a=t.child,c=null;a!==null;)e=a.alternate,e!==null&&Wi(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),Xc(t,!1,c,a,u,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Wi(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}Xc(t,!0,a,null,u,l);break;case"together":Xc(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function Xn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Aa|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ms(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,a=Hn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Hn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function Qc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Fi(e)))}function Zv(e,t,a){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),ha(t,gt,e.memoizedState.cache),Ya();break;case 27:case 5:xe(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:ha(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,vc(t),null;break;case 13:var l=t.memoizedState;if(l!==null)return l.dehydrated!==null?(va(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Nh(e,t,a):(va(t),e=Xn(e,t,a),e!==null?e.sibling:null);va(t);break;case 19:var c=(e.flags&128)!==0;if(l=(a&t.childLanes)!==0,l||(Ms(e,t,a,!1),l=(a&t.childLanes)!==0),c){if(l)return Ch(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),P(ht,ht.current),l)break;return null;case 22:return t.lanes=0,vh(e,t,a,t.pendingProps);case 24:ha(t,gt,e.memoizedState.cache)}return Xn(e,t,a)}function Eh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)yt=!0;else{if(!Qc(e,a)&&(t.flags&128)===0)return yt=!1,Zv(e,t,a);yt=(e.flags&131072)!==0}else yt=!1,Oe&&(t.flags&1048576)!==0&&lm(t,Nl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var l=t.pendingProps;if(e=Ka(t.elementType),t.type=e,typeof e=="function")Po(e)?(l=Pa(e,l),t.tag=1,t=Ah(null,t,e,l,a)):(t.tag=0,t=Hc(null,t,e,l,a));else{if(e!=null){var c=e.$$typeof;if(c===M){t.tag=11,t=ph(null,t,e,l,a);break e}else if(c===_){t.tag=14,t=xh(null,t,e,l,a);break e}}throw t=oe(e)||e,Error(o(306,t,""))}}return t;case 0:return Hc(e,t,t.type,t.pendingProps,a);case 1:return l=t.type,c=Pa(l,t.pendingProps),Ah(e,t,l,c,a);case 3:e:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(o(387));l=t.pendingProps;var u=t.memoizedState;c=u.element,mc(e,t),Tl(t,l,null,a);var v=t.memoizedState;if(l=v.cache,ha(t,gt,l),l!==u.cache&&rc(t,[gt],a,!0),Rl(),l=v.element,u.isDehydrated)if(u={element:l,isDehydrated:!1,cache:v.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=jh(e,t,l,a);break e}else if(l!==c){c=sn(Error(o(424)),t),wl(c),t=jh(e,t,l,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(nt=un(e.firstChild),Mt=t,Oe=!0,da=null,on=!0,a=vm(t,null,l,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Ya(),l===c){t=Xn(e,t,a);break e}Rt(e,t,l,a)}t=t.child}return t;case 26:return ur(e,t),e===null?(a=zp(t.type,null,t.pendingProps,null))?t.memoizedState=a:Oe||(a=t.type,e=t.pendingProps,l=Er(ie.current).createElement(a),l[rt]=t,l[jt]=e,Tt(l,a,e),wt(l),t.stateNode=l):t.memoizedState=zp(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&Oe&&(l=t.stateNode=Op(t.type,t.pendingProps,ie.current),Mt=t,on=!0,c=nt,Ea(t.type)?(Cu=c,nt=un(l.firstChild)):nt=c),Rt(e,t,t.pendingProps.children,a),ur(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Oe&&((c=l=nt)&&(l=wy(l,t.type,t.pendingProps,on),l!==null?(t.stateNode=l,Mt=t,nt=un(l.firstChild),on=!1,c=!0):c=!1),c||ma(t)),xe(t),c=t.type,u=t.pendingProps,v=e!==null?e.memoizedProps:null,l=u.children,Su(c,u)?l=null:v!==null&&Su(c,v)&&(t.flags|=32),t.memoizedState!==null&&(c=bc(e,t,Hv,null,null,a),Pl._currentValue=c),ur(e,t),Rt(e,t,l,a),t.child;case 6:return e===null&&Oe&&((e=a=nt)&&(a=Cy(a,t.pendingProps,on),a!==null?(t.stateNode=a,Mt=t,nt=null,e=!0):e=!1),e||ma(t)),null;case 13:return Nh(e,t,a);case 4:return ve(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=Ia(t,null,l,a):Rt(e,t,l,a),t.child;case 11:return ph(e,t,t.type,t.pendingProps,a);case 7:return Rt(e,t,t.pendingProps,a),t.child;case 8:return Rt(e,t,t.pendingProps.children,a),t.child;case 12:return Rt(e,t,t.pendingProps.children,a),t.child;case 10:return l=t.pendingProps,ha(t,t.type,l.value),Rt(e,t,l.children,a),t.child;case 9:return c=t.type._context,l=t.pendingProps.children,Xa(t),c=qt(c),l=l(c),t.flags|=1,Rt(e,t,l,a),t.child;case 14:return xh(e,t,t.type,t.pendingProps,a);case 15:return gh(e,t,t.type,t.pendingProps,a);case 19:return Ch(e,t,a);case 31:return Kv(e,t,a);case 22:return vh(e,t,a,t.pendingProps);case 24:return Xa(t),l=qt(gt),e===null?(c=uc(),c===null&&(c=We,u=oc(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=a),c=u),t.memoizedState={parent:l,cache:c},dc(t),ha(t,gt,c)):((e.lanes&a)!==0&&(mc(e,t),Tl(t,null,null,a),Rl()),c=e.memoizedState,u=t.memoizedState,c.parent!==l?(c={parent:l,cache:l},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),ha(t,gt,l)):(l=u.cache,ha(t,gt,l),l!==c.cache&&rc(t,[gt],a,!0))),Rt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Qn(e){e.flags|=4}function Kc(e,t,a,l,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(ep())e.flags|=8192;else throw Za=Zi,fc}else e.flags&=-16777217}function kh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Gp(t))if(ep())e.flags|=8192;else throw Za=Zi,fc}function dr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?ul():536870912,e.lanes|=t,Vs|=t)}function zl(e,t){if(!Oe)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function at(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(t)for(var c=e.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags&65011712,l|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags,l|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=l,e.childLanes=a,t}function Iv(e,t,a){var l=t.pendingProps;switch(nc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(t),null;case 1:return at(t),null;case 3:return a=t.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Gn(gt),ye(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(ks(t)?Qn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,sc())),at(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Qn(t),u!==null?(at(t),kh(t,u)):(at(t),Kc(t,c,null,l,a))):u?u!==e.memoizedState?(Qn(t),at(t),kh(t,u)):(at(t),t.flags&=-16777217):(e=e.memoizedProps,e!==l&&Qn(t),at(t),Kc(t,c,e,l,a)),null;case 27:if(Ue(t),a=ie.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Qn(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return at(t),null}e=ne.current,ks(t)?rm(t):(e=Op(c,l,a),t.stateNode=e,Qn(t))}return at(t),null;case 5:if(Ue(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Qn(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return at(t),null}if(u=ne.current,ks(t))rm(t);else{var v=Er(ie.current);switch(u){case 1:u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":u=v.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof l.is=="string"?v.createElement("select",{is:l.is}):v.createElement("select"),l.multiple?u.multiple=!0:l.size&&(u.size=l.size);break;default:u=typeof l.is=="string"?v.createElement(c,{is:l.is}):v.createElement(c)}}u[rt]=t,u[jt]=l;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)u.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=u;e:switch(Tt(u,c,l),c){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Qn(t)}}return at(t),Kc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==l&&Qn(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(o(166));if(e=ie.current,ks(t)){if(e=t.stateNode,a=t.memoizedProps,l=null,c=Mt,c!==null)switch(c.tag){case 27:case 5:l=c.memoizedProps}e[rt]=t,e=!!(e.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Np(e.nodeValue,a)),e||ma(t,!0)}else e=Er(e).createTextNode(l),e[rt]=t,t.stateNode=e}return at(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(l=ks(t),a!==null){if(e===null){if(!l)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[rt]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),e=!1}else a=sc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Kt(t),t):(Kt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return at(t),null;case 13:if(l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=ks(t),l!==null&&l.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[rt]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),c=!1}else c=sc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Kt(t),t):(Kt(t),null)}return Kt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=l!==null,e=e!==null&&e.memoizedState!==null,a&&(l=t.child,c=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(c=l.alternate.memoizedState.cachePool.pool),u=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(u=l.memoizedState.cachePool.pool),u!==c&&(l.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),dr(t,t.updateQueue),at(t),null);case 4:return ye(),e===null&&xu(t.stateNode.containerInfo),at(t),null;case 10:return Gn(t.type),at(t),null;case 19:if(H(ht),l=t.memoizedState,l===null)return at(t),null;if(c=(t.flags&128)!==0,u=l.rendering,u===null)if(c)zl(l,!1);else{if(ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=Wi(e),u!==null){for(t.flags|=128,zl(l,!1),e=u.updateQueue,t.updateQueue=e,dr(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)nm(a,e),a=a.sibling;return P(ht,ht.current&1|2),Oe&&Vn(t,l.treeForkCount),t.child}e=e.sibling}l.tail!==null&&Le()>gr&&(t.flags|=128,c=!0,zl(l,!1),t.lanes=4194304)}else{if(!c)if(e=Wi(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,dr(t,e),zl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!u.alternate&&!Oe)return at(t),null}else 2*Le()-l.renderingStartTime>gr&&a!==536870912&&(t.flags|=128,c=!0,zl(l,!1),t.lanes=4194304);l.isBackwards?(u.sibling=t.child,t.child=u):(e=l.last,e!==null?e.sibling=u:t.child=u,l.last=u)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=Le(),e.sibling=null,a=ht.current,P(ht,c?a&1|2:a&1),Oe&&Vn(t,l.treeForkCount),e):(at(t),null);case 22:case 23:return Kt(t),gc(),l=t.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(a&536870912)!==0&&(t.flags&128)===0&&(at(t),t.subtreeFlags&6&&(t.flags|=8192)):at(t),a=t.updateQueue,a!==null&&dr(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==a&&(t.flags|=2048),e!==null&&H(Qa),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Gn(gt),at(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Jv(e,t){switch(nc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gn(gt),ye(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ue(t),null;case 31:if(t.memoizedState!==null){if(Kt(t),t.alternate===null)throw Error(o(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Kt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(ht),null;case 4:return ye(),null;case 10:return Gn(t.type),null;case 22:case 23:return Kt(t),gc(),e!==null&&H(Qa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Gn(gt),null;case 25:return null;default:return null}}function Mh(e,t){switch(nc(t),t.tag){case 3:Gn(gt),ye();break;case 26:case 27:case 5:Ue(t);break;case 4:ye();break;case 31:t.memoizedState!==null&&Kt(t);break;case 13:Kt(t);break;case 19:H(ht);break;case 10:Gn(t.type);break;case 22:case 23:Kt(t),gc(),e!==null&&H(Qa);break;case 24:Gn(gt)}}function Ul(e,t){try{var a=t.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var c=l.next;a=c;do{if((a.tag&e)===e){l=void 0;var u=a.create,v=a.inst;l=u(),v.destroy=l}a=a.next}while(a!==c)}}catch(S){Xe(t,t.return,S)}}function ba(e,t,a){try{var l=t.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var u=c.next;l=u;do{if((l.tag&e)===e){var v=l.inst,S=v.destroy;if(S!==void 0){v.destroy=void 0,c=t;var D=a,$=S;try{$()}catch(I){Xe(c,D,I)}}}l=l.next}while(l!==u)}}catch(I){Xe(t,t.return,I)}}function qh(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{bm(t,a)}catch(l){Xe(e,e.return,l)}}}function Rh(e,t,a){a.props=Pa(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(l){Xe(e,t,l)}}function Hl(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof a=="function"?e.refCleanup=a(l):a.current=l}}catch(c){Xe(e,t,c)}}function wn(e,t){var a=e.ref,l=e.refCleanup;if(a!==null)if(typeof l=="function")try{l()}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 Th(e){var t=e.type,a=e.memoizedProps,l=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(c){Xe(e,e.return,c)}}function Zc(e,t,a){try{var l=e.stateNode;yy(l,e.type,a,t),l[jt]=t}catch(c){Xe(e,e.return,c)}}function Dh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ea(e.type)||e.tag===4}function Ic(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Dh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Ea(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jc(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=zn));else if(l!==4&&(l===27&&Ea(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(Jc(e,t,a),e=e.sibling;e!==null;)Jc(e,t,a),e=e.sibling}function mr(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(l!==4&&(l===27&&Ea(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(mr(e,t,a),e=e.sibling;e!==null;)mr(e,t,a),e=e.sibling}function _h(e){var t=e.stateNode,a=e.memoizedProps;try{for(var l=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Tt(t,l,a),t[rt]=e,t[jt]=a}catch(u){Xe(e,e.return,u)}}var Kn=!1,bt=!1,Pc=!1,Oh=typeof WeakSet=="function"?WeakSet:Set,Ct=null;function Pv(e,t){if(e=e.containerInfo,yu=_r,e=Qd(e),Fo(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var c=l.anchorOffset,u=l.focusNode;l=l.focusOffset;try{a.nodeType,u.nodeType}catch{a=null;break e}var v=0,S=-1,D=-1,$=0,I=0,ee=e,X=null;t:for(;;){for(var Z;ee!==a||c!==0&&ee.nodeType!==3||(S=v+c),ee!==u||l!==0&&ee.nodeType!==3||(D=v+l),ee.nodeType===3&&(v+=ee.nodeValue.length),(Z=ee.firstChild)!==null;)X=ee,ee=Z;for(;;){if(ee===e)break t;if(X===a&&++$===c&&(S=v),X===u&&++I===l&&(D=v),(Z=ee.nextSibling)!==null)break;ee=X,X=ee.parentNode}ee=Z}a=S===-1||D===-1?null:{start:S,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(bu={focusedElem:e,selectionRange:a},_r=!1,Ct=t;Ct!==null;)if(t=Ct,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ct=e;else for(;Ct!==null;){switch(t=Ct,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)c=e[a],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,a=t,c=u.memoizedProps,u=u.memoizedState,l=a.stateNode;try{var he=Pa(a.type,c);e=l.getSnapshotBeforeUpdate(he,u),l.__reactInternalSnapshotBeforeUpdate=e}catch(je){Xe(a,a.return,je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)ju(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":ju(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,Ct=e;break}Ct=t.return}}function Bh(e,t,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:In(e,a),l&4&&Ul(5,a);break;case 1:if(In(e,a),l&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(v){Xe(a,a.return,v)}else{var c=Pa(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(v){Xe(a,a.return,v)}}l&64&&qh(a),l&512&&Hl(a,a.return);break;case 3:if(In(e,a),l&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{bm(e,t)}catch(v){Xe(a,a.return,v)}}break;case 27:t===null&&l&4&&_h(a);case 26:case 5:In(e,a),t===null&&l&4&&Th(a),l&512&&Hl(a,a.return);break;case 12:In(e,a);break;case 31:In(e,a),l&4&&Uh(e,a);break;case 13:In(e,a),l&4&&Hh(e,a),l&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=ry.bind(null,a),Ey(e,a))));break;case 22:if(l=a.memoizedState!==null||Kn,!l){t=t!==null&&t.memoizedState!==null||bt,c=Kn;var u=bt;Kn=l,(bt=t)&&!u?Jn(e,a,(a.subtreeFlags&8772)!==0):In(e,a),Kn=c,bt=u}break;case 30:break;default:In(e,a)}}function Lh(e){var t=e.alternate;t!==null&&(e.alternate=null,Lh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ko(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var lt=null,zt=!1;function Zn(e,t,a){for(a=a.child;a!==null;)zh(e,t,a),a=a.sibling}function zh(e,t,a){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(Dn,a)}catch{}switch(a.tag){case 26:bt||wn(a,t),Zn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:bt||wn(a,t);var l=lt,c=zt;Ea(a.type)&&(lt=a.stateNode,zt=!1),Zn(e,t,a),Zl(a.stateNode),lt=l,zt=c;break;case 5:bt||wn(a,t);case 6:if(l=lt,c=zt,lt=null,Zn(e,t,a),lt=l,zt=c,lt!==null)if(zt)try{(lt.nodeType===9?lt.body:lt.nodeName==="HTML"?lt.ownerDocument.body:lt).removeChild(a.stateNode)}catch(u){Xe(a,t,u)}else try{lt.removeChild(a.stateNode)}catch(u){Xe(a,t,u)}break;case 18:lt!==null&&(zt?(e=lt,qp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Zs(e)):qp(lt,a.stateNode));break;case 4:l=lt,c=zt,lt=a.stateNode.containerInfo,zt=!0,Zn(e,t,a),lt=l,zt=c;break;case 0:case 11:case 14:case 15:ba(2,a,t),bt||ba(4,a,t),Zn(e,t,a);break;case 1:bt||(wn(a,t),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Rh(a,t,l)),Zn(e,t,a);break;case 21:Zn(e,t,a);break;case 22:bt=(l=bt)||a.memoizedState!==null,Zn(e,t,a),bt=l;break;default:Zn(e,t,a)}}function Uh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Zs(e)}catch(a){Xe(t,t.return,a)}}}function Hh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Zs(e)}catch(a){Xe(t,t.return,a)}}function Wv(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Oh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Oh),t;default:throw Error(o(435,e.tag))}}function hr(e,t){var a=Wv(e);t.forEach(function(l){if(!a.has(l)){a.add(l);var c=oy.bind(null,e,l);l.then(c,c)}})}function Ut(e,t){var a=t.deletions;if(a!==null)for(var l=0;l<a.length;l++){var c=a[l],u=e,v=t,S=v;e:for(;S!==null;){switch(S.tag){case 27:if(Ea(S.type)){lt=S.stateNode,zt=!1;break e}break;case 5:lt=S.stateNode,zt=!1;break e;case 3:case 4:lt=S.stateNode.containerInfo,zt=!0;break e}S=S.return}if(lt===null)throw Error(o(160));zh(u,v,c),lt=null,zt=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Vh(t,e),t=t.sibling}var xn=null;function Vh(e,t){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ut(t,e),Ht(e),l&4&&(ba(3,e,e.return),Ul(3,e),ba(5,e,e.return));break;case 1:Ut(t,e),Ht(e),l&512&&(bt||a===null||wn(a,a.return)),l&64&&Kn&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var c=xn;if(Ut(t,e),Ht(e),l&512&&(bt||a===null||wn(a,a.return)),l&4){var u=a!==null?a.memoizedState:null;if(l=e.memoizedState,a===null)if(l===null)if(e.stateNode===null){e:{l=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(l){case"title":u=c.getElementsByTagName("title")[0],(!u||u[ml]||u[rt]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(l),c.head.insertBefore(u,c.querySelector("head > title"))),Tt(u,l,a),u[rt]=e,wt(u),l=u;break e;case"link":var v=Vp("link","href",c).get(l+(a.href||""));if(v){for(var S=0;S<v.length;S++)if(u=v[S],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(S,1);break t}}u=c.createElement(l),Tt(u,l,a),c.head.appendChild(u);break;case"meta":if(v=Vp("meta","content",c).get(l+(a.content||""))){for(S=0;S<v.length;S++)if(u=v[S],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(S,1);break t}}u=c.createElement(l),Tt(u,l,a),c.head.appendChild(u);break;default:throw Error(o(468,l))}u[rt]=e,wt(u),l=u}e.stateNode=l}else $p(c,e.type,e.stateNode);else e.stateNode=Hp(c,l,e.memoizedProps);else u!==l?(u===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):u.count--,l===null?$p(c,e.type,e.stateNode):Hp(c,l,e.memoizedProps)):l===null&&e.stateNode!==null&&Zc(e,e.memoizedProps,a.memoizedProps)}break;case 27:Ut(t,e),Ht(e),l&512&&(bt||a===null||wn(a,a.return)),a!==null&&l&4&&Zc(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Ut(t,e),Ht(e),l&512&&(bt||a===null||wn(a,a.return)),e.flags&32){c=e.stateNode;try{vs(c,"")}catch(he){Xe(e,e.return,he)}}l&4&&e.stateNode!=null&&(c=e.memoizedProps,Zc(e,c,a!==null?a.memoizedProps:c)),l&1024&&(Pc=!0);break;case 6:if(Ut(t,e),Ht(e),l&4){if(e.stateNode===null)throw Error(o(162));l=e.memoizedProps,a=e.stateNode;try{a.nodeValue=l}catch(he){Xe(e,e.return,he)}}break;case 3:if(qr=null,c=xn,xn=kr(t.containerInfo),Ut(t,e),xn=c,Ht(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Zs(t.containerInfo)}catch(he){Xe(e,e.return,he)}Pc&&(Pc=!1,$h(e));break;case 4:l=xn,xn=kr(e.stateNode.containerInfo),Ut(t,e),Ht(e),xn=l;break;case 12:Ut(t,e),Ht(e);break;case 31:Ut(t,e),Ht(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,hr(e,l)));break;case 13:Ut(t,e),Ht(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(xr=Le()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,hr(e,l)));break;case 22:c=e.memoizedState!==null;var D=a!==null&&a.memoizedState!==null,$=Kn,I=bt;if(Kn=$||c,bt=I||D,Ut(t,e),bt=I,Kn=$,Ht(e),l&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||D||Kn||bt||Wa(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){D=a=t;try{if(u=D.stateNode,c)v=u.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{S=D.stateNode;var ee=D.memoizedProps.style,X=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;S.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(he){Xe(D,D.return,he)}}}else if(t.tag===6){if(a===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(he){Xe(D,D.return,he)}}}else if(t.tag===18){if(a===null){D=t;try{var Z=D.stateNode;c?Rp(Z,!0):Rp(D.stateNode,!1)}catch(he){Xe(D,D.return,he)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}l&4&&(l=e.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,hr(e,a))));break;case 19:Ut(t,e),Ht(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,hr(e,l)));break;case 30:break;case 21:break;default:Ut(t,e),Ht(e)}}function Ht(e){var t=e.flags;if(t&2){try{for(var a,l=e.return;l!==null;){if(Dh(l)){a=l;break}l=l.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,u=Ic(e);mr(e,u,c);break;case 5:var v=a.stateNode;a.flags&32&&(vs(v,""),a.flags&=-33);var S=Ic(e);mr(e,S,v);break;case 3:case 4:var D=a.stateNode.containerInfo,$=Ic(e);Jc(e,$,D);break;default:throw Error(o(161))}}catch(I){Xe(e,e.return,I)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function $h(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;$h(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function In(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Bh(e,t.alternate,t),t=t.sibling}function Wa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ba(4,t,t.return),Wa(t);break;case 1:wn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Rh(t,t.return,a),Wa(t);break;case 27:Zl(t.stateNode);case 26:case 5:wn(t,t.return),Wa(t);break;case 22:t.memoizedState===null&&Wa(t);break;case 30:Wa(t);break;default:Wa(t)}e=e.sibling}}function Jn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var l=t.alternate,c=e,u=t,v=u.flags;switch(u.tag){case 0:case 11:case 15:Jn(c,u,a),Ul(4,u);break;case 1:if(Jn(c,u,a),l=u,c=l.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch($){Xe(l,l.return,$)}if(l=u,c=l.updateQueue,c!==null){var S=l.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)ym(D[c],S)}catch($){Xe(l,l.return,$)}}a&&v&64&&qh(u),Hl(u,u.return);break;case 27:_h(u);case 26:case 5:Jn(c,u,a),a&&l===null&&v&4&&Th(u),Hl(u,u.return);break;case 12:Jn(c,u,a);break;case 31:Jn(c,u,a),a&&v&4&&Uh(c,u);break;case 13:Jn(c,u,a),a&&v&4&&Hh(c,u);break;case 22:u.memoizedState===null&&Jn(c,u,a),Hl(u,u.return);break;case 30:break;default:Jn(c,u,a)}t=t.sibling}}function Wc(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Cl(a))}function eu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cl(e))}function gn(e,t,a,l){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Gh(e,t,a,l),t=t.sibling}function Gh(e,t,a,l){var c=t.flags;switch(t.tag){case 0:case 11:case 15:gn(e,t,a,l),c&2048&&Ul(9,t);break;case 1:gn(e,t,a,l);break;case 3:gn(e,t,a,l),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cl(e)));break;case 12:if(c&2048){gn(e,t,a,l),e=t.stateNode;try{var u=t.memoizedProps,v=u.id,S=u.onPostCommit;typeof S=="function"&&S(v,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){Xe(t,t.return,D)}}else gn(e,t,a,l);break;case 31:gn(e,t,a,l);break;case 13:gn(e,t,a,l);break;case 23:break;case 22:u=t.stateNode,v=t.alternate,t.memoizedState!==null?u._visibility&2?gn(e,t,a,l):Vl(e,t):u._visibility&2?gn(e,t,a,l):(u._visibility|=2,zs(e,t,a,l,(t.subtreeFlags&10256)!==0||!1)),c&2048&&Wc(v,t);break;case 24:gn(e,t,a,l),c&2048&&eu(t.alternate,t);break;default:gn(e,t,a,l)}}function zs(e,t,a,l,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,v=t,S=a,D=l,$=v.flags;switch(v.tag){case 0:case 11:case 15:zs(u,v,S,D,c),Ul(8,v);break;case 23:break;case 22:var I=v.stateNode;v.memoizedState!==null?I._visibility&2?zs(u,v,S,D,c):Vl(u,v):(I._visibility|=2,zs(u,v,S,D,c)),c&&$&2048&&Wc(v.alternate,v);break;case 24:zs(u,v,S,D,c),c&&$&2048&&eu(v.alternate,v);break;default:zs(u,v,S,D,c)}t=t.sibling}}function Vl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,l=t,c=l.flags;switch(l.tag){case 22:Vl(a,l),c&2048&&Wc(l.alternate,l);break;case 24:Vl(a,l),c&2048&&eu(l.alternate,l);break;default:Vl(a,l)}t=t.sibling}}var $l=8192;function Us(e,t,a){if(e.subtreeFlags&$l)for(e=e.child;e!==null;)Yh(e,t,a),e=e.sibling}function Yh(e,t,a){switch(e.tag){case 26:Us(e,t,a),e.flags&$l&&e.memoizedState!==null&&Uy(a,xn,e.memoizedState,e.memoizedProps);break;case 5:Us(e,t,a);break;case 3:case 4:var l=xn;xn=kr(e.stateNode.containerInfo),Us(e,t,a),xn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=$l,$l=16777216,Us(e,t,a),$l=l):Us(e,t,a));break;default:Us(e,t,a)}}function Fh(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Gl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];Ct=l,Qh(l,e)}Fh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Xh(e),e=e.sibling}function Xh(e){switch(e.tag){case 0:case 11:case 15:Gl(e),e.flags&2048&&ba(9,e,e.return);break;case 3:Gl(e);break;case 12:Gl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,pr(e)):Gl(e);break;default:Gl(e)}}function pr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];Ct=l,Qh(l,e)}Fh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ba(8,t,t.return),pr(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,pr(t));break;default:pr(t)}e=e.sibling}}function Qh(e,t){for(;Ct!==null;){var a=Ct;switch(a.tag){case 0:case 11:case 15:ba(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Cl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Ct=l;else e:for(a=e;Ct!==null;){l=Ct;var c=l.sibling,u=l.return;if(Lh(l),l===a){Ct=null;break e}if(c!==null){c.return=u,Ct=c;break e}Ct=u}}}var ey={getCacheForType:function(e){var t=qt(gt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return qt(gt).controller.signal}},ty=typeof WeakMap=="function"?WeakMap:Map,Ge=0,We=null,Re=null,De=0,Fe=0,Zt=null,Sa=!1,Hs=!1,tu=!1,Pn=0,ut=0,Aa=0,es=0,nu=0,It=0,Vs=0,Yl=null,Vt=null,au=!1,xr=0,Kh=0,gr=1/0,vr=null,ja=null,Nt=0,Na=null,$s=null,Wn=0,su=0,lu=null,Zh=null,Fl=0,iu=null;function Jt(){return(Ge&2)!==0&&De!==0?De&-De:T.T!==null?du():qe()}function Ih(){if(It===0)if((De&536870912)===0||Oe){var e=Ba;Ba<<=1,(Ba&3932160)===0&&(Ba=262144),It=e}else It=536870912;return e=Qt.current,e!==null&&(e.flags|=32),It}function $t(e,t,a){(e===We&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)&&(Gs(e,0),wa(e,De,It,!1)),La(e,a),((Ge&2)===0||e!==We)&&(e===We&&((Ge&2)===0&&(es|=a),ut===4&&wa(e,De,It,!1)),Cn(e))}function Jh(e,t,a){if((Ge&6)!==0)throw Error(o(327));var l=!a&&(t&127)===0&&(t&e.expiredLanes)===0||On(e,t),c=l?sy(e,t):ou(e,t,!0),u=l;do{if(c===0){Hs&&!l&&wa(e,t,0,!1);break}else{if(a=e.current.alternate,u&&!ny(a)){c=ou(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 S=e;c=Yl;var D=S.current.memoizedState.isDehydrated;if(D&&(Gs(S,v).flags|=256),v=ou(S,v,!1),v!==2){if(tu&&!D){S.errorRecoveryDisabledLanes|=u,es|=u,c=4;break e}u=Vt,Vt=c,u!==null&&(Vt===null?Vt=u:Vt.push.apply(Vt,u))}c=v}if(u=!1,c!==2)continue}}if(c===1){Gs(e,0),wa(e,t,0,!0);break}e:{switch(l=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:wa(l,t,It,!Sa);break e;case 2:Vt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=xr+300-Le(),10<c)){if(wa(l,t,It,!Sa),An(l,0,!0)!==0)break e;Wn=t,l.timeoutHandle=kp(Ph.bind(null,l,a,Vt,vr,au,t,It,es,Vs,Sa,u,"Throttled",-0,0),c);break e}Ph(l,a,Vt,vr,au,t,It,es,Vs,Sa,u,null,-0,0)}}break}while(!0);Cn(e)}function Ph(e,t,a,l,c,u,v,S,D,$,I,ee,X,Z){if(e.timeoutHandle=-1,ee=t.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zn},Yh(t,u,ee);var he=(u&62914560)===u?xr-Le():(u&4194048)===u?Kh-Le():0;if(he=Hy(ee,he),he!==null){Wn=u,e.cancelPendingCommit=he(ip.bind(null,e,t,u,a,l,c,v,S,D,I,ee,null,X,Z)),wa(e,u,v,!$);return}}ip(e,t,u,a,l,c,v,S,D)}function ny(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var c=a[l],u=c.getSnapshot;c=c.value;try{if(!Ft(u(),c))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function wa(e,t,a,l){t&=~nu,t&=~es,e.suspendedLanes|=t,e.pingedLanes&=~t,l&&(e.warmLanes|=t),l=e.expirationTimes;for(var c=t;0<c;){var u=31-kt(c),v=1<<u;l[u]=-1,c&=~v}a!==0&&dl(e,a,t)}function yr(){return(Ge&6)===0?(Xl(0),!1):!0}function ru(){if(Re!==null){if(Fe===0)var e=Re.return;else e=Re,$n=Fa=null,jc(e),Ds=null,kl=0,e=Re;for(;e!==null;)Mh(e.alternate,e),e=e.return;Re=null}}function Gs(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Ay(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),Wn=0,ru(),We=e,Re=a=Hn(e.current,null),De=t,Fe=0,Zt=null,Sa=!1,Hs=On(e,t),tu=!1,Vs=It=nu=es=Aa=ut=0,Vt=Yl=null,au=!1,(t&8)!==0&&(t|=t&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=t;0<l;){var c=31-kt(l),u=1<<c;t|=e[c],l&=~u}return Pn=t,Hi(),a}function Wh(e,t){Ee=null,T.H=Bl,t===Ts||t===Ki?(t=pm(),Fe=3):t===fc?(t=pm(),Fe=4):Fe=t===Uc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Zt=t,Re===null&&(ut=1,or(e,sn(t,e.current)))}function ep(){var e=Qt.current;return e===null?!0:(De&4194048)===De?cn===null:(De&62914560)===De||(De&536870912)!==0?e===cn:!1}function tp(){var e=T.H;return T.H=Bl,e===null?Bl:e}function np(){var e=T.A;return T.A=ey,e}function br(){ut=4,Sa||(De&4194048)!==De&&Qt.current!==null||(Hs=!0),(Aa&134217727)===0&&(es&134217727)===0||We===null||wa(We,De,It,!1)}function ou(e,t,a){var l=Ge;Ge|=2;var c=tp(),u=np();(We!==e||De!==t)&&(vr=null,Gs(e,t)),t=!1;var v=ut;e:do try{if(Fe!==0&&Re!==null){var S=Re,D=Zt;switch(Fe){case 8:ru(),v=6;break e;case 3:case 2:case 9:case 6:Qt.current===null&&(t=!0);var $=Fe;if(Fe=0,Zt=null,Ys(e,S,D,$),a&&Hs){v=0;break e}break;default:$=Fe,Fe=0,Zt=null,Ys(e,S,D,$)}}ay(),v=ut;break}catch(I){Wh(e,I)}while(!0);return t&&e.shellSuspendCounter++,$n=Fa=null,Ge=l,T.H=c,T.A=u,Re===null&&(We=null,De=0,Hi()),v}function ay(){for(;Re!==null;)ap(Re)}function sy(e,t){var a=Ge;Ge|=2;var l=tp(),c=np();We!==e||De!==t?(vr=null,gr=Le()+500,Gs(e,t)):Hs=On(e,t);e:do try{if(Fe!==0&&Re!==null){t=Re;var u=Zt;t:switch(Fe){case 1:Fe=0,Zt=null,Ys(e,t,u,1);break;case 2:case 9:if(mm(u)){Fe=0,Zt=null,sp(t);break}t=function(){Fe!==2&&Fe!==9||We!==e||(Fe=7),Cn(e)},u.then(t,t);break e;case 3:Fe=7;break e;case 4:Fe=5;break e;case 7:mm(u)?(Fe=0,Zt=null,sp(t)):(Fe=0,Zt=null,Ys(e,t,u,7));break;case 5:var v=null;switch(Re.tag){case 26:v=Re.memoizedState;case 5:case 27:var S=Re;if(v?Gp(v):S.stateNode.complete){Fe=0,Zt=null;var D=S.sibling;if(D!==null)Re=D;else{var $=S.return;$!==null?(Re=$,Sr($)):Re=null}break t}}Fe=0,Zt=null,Ys(e,t,u,5);break;case 6:Fe=0,Zt=null,Ys(e,t,u,6);break;case 8:ru(),ut=6;break e;default:throw Error(o(462))}}ly();break}catch(I){Wh(e,I)}while(!0);return $n=Fa=null,T.H=l,T.A=c,Ge=a,Re!==null?0:(We=null,De=0,Hi(),ut)}function ly(){for(;Re!==null&&!et();)ap(Re)}function ap(e){var t=Eh(e.alternate,e,Pn);e.memoizedProps=e.pendingProps,t===null?Sr(e):Re=t}function sp(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Sh(a,t,t.pendingProps,t.type,void 0,De);break;case 11:t=Sh(a,t,t.pendingProps,t.type.render,t.ref,De);break;case 5:jc(t);default:Mh(a,t),t=Re=nm(t,Pn),t=Eh(a,t,Pn)}e.memoizedProps=e.pendingProps,t===null?Sr(e):Re=t}function Ys(e,t,a,l){$n=Fa=null,jc(t),Ds=null,kl=0;var c=t.return;try{if(Qv(e,c,t,a,De)){ut=1,or(e,sn(a,e.current)),Re=null;return}}catch(u){if(c!==null)throw Re=c,u;ut=1,or(e,sn(a,e.current)),Re=null;return}t.flags&32768?(Oe||l===1?e=!0:Hs||(De&536870912)!==0?e=!1:(Sa=e=!0,(l===2||l===9||l===3||l===6)&&(l=Qt.current,l!==null&&l.tag===13&&(l.flags|=16384))),lp(t,e)):Sr(t)}function Sr(e){var t=e;do{if((t.flags&32768)!==0){lp(t,Sa);return}e=t.return;var a=Iv(t.alternate,t,Pn);if(a!==null){Re=a;return}if(t=t.sibling,t!==null){Re=t;return}Re=t=e}while(t!==null);ut===0&&(ut=5)}function lp(e,t){do{var a=Jv(e.alternate,e);if(a!==null){a.flags&=32767,Re=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Re=e;return}Re=e=a}while(e!==null);ut=6,Re=null}function ip(e,t,a,l,c,u,v,S,D){e.cancelPendingCommit=null;do Ar();while(Nt!==0);if((Ge&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=Io,Eo(e,a,u,v,S,D),e===We&&(Re=We=null,De=0),$s=t,Na=e,Wn=a,su=u,lu=c,Zh=l,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,cy(Et,function(){return fp(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||l){l=T.T,T.T=null,c=F.p,F.p=2,v=Ge,Ge|=4;try{Pv(e,t,a)}finally{Ge=v,F.p=c,T.T=l}}Nt=1,rp(),op(),cp()}}function rp(){if(Nt===1){Nt=0;var e=Na,t=$s,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=T.T,T.T=null;var l=F.p;F.p=2;var c=Ge;Ge|=4;try{Vh(t,e);var u=bu,v=Qd(e.containerInfo),S=u.focusedElem,D=u.selectionRange;if(v!==S&&S&&S.ownerDocument&&Xd(S.ownerDocument.documentElement,S)){if(D!==null&&Fo(S)){var $=D.start,I=D.end;if(I===void 0&&(I=$),"selectionStart"in S)S.selectionStart=$,S.selectionEnd=Math.min(I,S.value.length);else{var ee=S.ownerDocument||document,X=ee&&ee.defaultView||window;if(X.getSelection){var Z=X.getSelection(),he=S.textContent.length,je=Math.min(D.start,he),Je=D.end===void 0?je:Math.min(D.end,he);!Z.extend&&je>Je&&(v=Je,Je=je,je=v);var z=Fd(S,je),O=Fd(S,Je);if(z&&O&&(Z.rangeCount!==1||Z.anchorNode!==z.node||Z.anchorOffset!==z.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var V=ee.createRange();V.setStart(z.node,z.offset),Z.removeAllRanges(),je>Je?(Z.addRange(V),Z.extend(O.node,O.offset)):(V.setEnd(O.node,O.offset),Z.addRange(V))}}}}for(ee=[],Z=S;Z=Z.parentNode;)Z.nodeType===1&&ee.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof S.focus=="function"&&S.focus(),S=0;S<ee.length;S++){var W=ee[S];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}_r=!!yu,bu=yu=null}finally{Ge=c,F.p=l,T.T=a}}e.current=t,Nt=2}}function op(){if(Nt===2){Nt=0;var e=Na,t=$s,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=T.T,T.T=null;var l=F.p;F.p=2;var c=Ge;Ge|=4;try{Bh(e,t.alternate,t)}finally{Ge=c,F.p=l,T.T=a}}Nt=3}}function cp(){if(Nt===4||Nt===3){Nt=0,dt();var e=Na,t=$s,a=Wn,l=Zh;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Nt=5:(Nt=0,$s=Na=null,up(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(ja=null),Pe(a),t=t.stateNode,At&&typeof At.onCommitFiberRoot=="function")try{At.onCommitFiberRoot(Dn,t,void 0,(t.current.flags&128)===128)}catch{}if(l!==null){t=T.T,c=F.p,F.p=2,T.T=null;try{for(var u=e.onRecoverableError,v=0;v<l.length;v++){var S=l[v];u(S.value,{componentStack:S.stack})}}finally{T.T=t,F.p=c}}(Wn&3)!==0&&Ar(),Cn(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===iu?Fl++:(Fl=0,iu=e):Fl=0,Xl(0)}}function up(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Cl(t)))}function Ar(){return rp(),op(),cp(),fp()}function fp(){if(Nt!==5)return!1;var e=Na,t=su;su=0;var a=Pe(Wn),l=T.T,c=F.p;try{F.p=32>a?32:a,T.T=null,a=lu,lu=null;var u=Na,v=Wn;if(Nt=0,$s=Na=null,Wn=0,(Ge&6)!==0)throw Error(o(331));var S=Ge;if(Ge|=4,Xh(u.current),Gh(u,u.current,v,a),Ge=S,Xl(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Dn,u)}catch{}return!0}finally{F.p=c,T.T=l,up(e,t)}}function dp(e,t,a){t=sn(a,t),t=zc(e.stateNode,t,2),e=ga(e,t,2),e!==null&&(La(e,2),Cn(e))}function Xe(e,t,a){if(e.tag===3)dp(e,e,a);else for(;t!==null;){if(t.tag===3){dp(t,e,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ja===null||!ja.has(l))){e=sn(a,e),a=mh(2),l=ga(t,a,2),l!==null&&(hh(a,l,t,e),La(l,2),Cn(l));break}}t=t.return}}function cu(e,t,a){var l=e.pingCache;if(l===null){l=e.pingCache=new ty;var c=new Set;l.set(t,c)}else c=l.get(t),c===void 0&&(c=new Set,l.set(t,c));c.has(a)||(tu=!0,c.add(a),e=iy.bind(null,e,t,a),t.then(e,e))}function iy(e,t,a){var l=e.pingCache;l!==null&&l.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,We===e&&(De&a)===a&&(ut===4||ut===3&&(De&62914560)===De&&300>Le()-xr?(Ge&2)===0&&Gs(e,0):nu|=a,Vs===De&&(Vs=0)),Cn(e)}function mp(e,t){t===0&&(t=ul()),e=$a(e,t),e!==null&&(La(e,t),Cn(e))}function ry(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),mp(e,a)}function oy(e,t){var a=0;switch(e.tag){case 31:case 13:var l=e.stateNode,c=e.memoizedState;c!==null&&(a=c.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(o(314))}l!==null&&l.delete(t),mp(e,a)}function cy(e,t){return me(e,t)}var jr=null,Fs=null,uu=!1,Nr=!1,fu=!1,Ca=0;function Cn(e){e!==Fs&&e.next===null&&(Fs===null?jr=Fs=e:Fs=Fs.next=e),Nr=!0,uu||(uu=!0,fy())}function Xl(e,t){if(!fu&&Nr){fu=!0;do for(var a=!1,l=jr;l!==null;){if(e!==0){var c=l.pendingLanes;if(c===0)var u=0;else{var v=l.suspendedLanes,S=l.pingedLanes;u=(1<<31-kt(42|e)+1)-1,u&=c&~(v&~S),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(a=!0,gp(l,u))}else u=De,u=An(l,l===We?u:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(u&3)===0||On(l,u)||(a=!0,gp(l,u));l=l.next}while(a);fu=!1}}function uy(){hp()}function hp(){Nr=uu=!1;var e=0;Ca!==0&&Sy()&&(e=Ca);for(var t=Le(),a=null,l=jr;l!==null;){var c=l.next,u=pp(l,t);u===0?(l.next=null,a===null?jr=c:a.next=c,c===null&&(Fs=a)):(a=l,(e!==0||(u&3)!==0)&&(Nr=!0)),l=c}Nt!==0&&Nt!==5||Xl(e),Ca!==0&&(Ca=0)}function pp(e,t){for(var a=e.suspendedLanes,l=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var v=31-kt(u),S=1<<v,D=c[v];D===-1?((S&a)===0||(S&l)!==0)&&(c[v]=ds(S,t)):D<=t&&(e.expiredLanes|=S),u&=~S}if(t=We,a=De,a=An(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,a===0||e===t&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&we(l),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||On(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(l!==null&&we(l),Pe(a)){case 2:case 8:a=Tn;break;case 32:a=Et;break;case 268435456:a=Gt;break;default:a=Et}return l=xp.bind(null,e),a=me(a,l),e.callbackPriority=t,e.callbackNode=a,t}return l!==null&&l!==null&&we(l),e.callbackPriority=2,e.callbackNode=null,2}function xp(e,t){if(Nt!==0&&Nt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Ar()&&e.callbackNode!==a)return null;var l=De;return l=An(e,e===We?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(Jh(e,l,t),pp(e,Le()),e.callbackNode!=null&&e.callbackNode===a?xp.bind(null,e):null)}function gp(e,t){if(Ar())return null;Jh(e,t,!0)}function fy(){jy(function(){(Ge&6)!==0?me(mt,uy):hp()})}function du(){if(Ca===0){var e=qs;e===0&&(e=fs,fs<<=1,(fs&261888)===0&&(fs=256)),Ca=e}return Ca}function vp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ti(""+e)}function yp(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 dy(e,t,a,l,c){if(t==="submit"&&a&&a.stateNode===c){var u=vp((c[jt]||null).action),v=l.submitter;v&&(t=(t=v[jt]||null)?vp(t.formAction):v.getAttribute("formAction"),t!==null&&(u=t,v=null));var S=new Bi("action","action",null,l,c);e.push({event:S,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Ca!==0){var D=v?yp(c,v):new FormData(c);Tc(a,{pending:!0,data:D,method:c.method,action:u},null,D)}}else typeof u=="function"&&(S.preventDefault(),D=v?yp(c,v):new FormData(c),Tc(a,{pending:!0,data:D,method:c.method,action:u},u,D))},currentTarget:c}]})}}for(var mu=0;mu<Zo.length;mu++){var hu=Zo[mu],my=hu.toLowerCase(),hy=hu[0].toUpperCase()+hu.slice(1);pn(my,"on"+hy)}pn(Id,"onAnimationEnd"),pn(Jd,"onAnimationIteration"),pn(Pd,"onAnimationStart"),pn("dblclick","onDoubleClick"),pn("focusin","onFocus"),pn("focusout","onBlur"),pn(qv,"onTransitionRun"),pn(Rv,"onTransitionStart"),pn(Tv,"onTransitionCancel"),pn(Wd,"onTransitionEnd"),xs("onMouseEnter",["mouseout","mouseover"]),xs("onMouseLeave",["mouseout","mouseover"]),xs("onPointerEnter",["pointerout","pointerover"]),xs("onPointerLeave",["pointerout","pointerover"]),za("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),za("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),za("onBeforeInput",["compositionend","keypress","textInput","paste"]),za("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),za("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),za("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ql="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),py=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ql));function bp(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],c=l.event;l=l.listeners;e:{var u=void 0;if(t)for(var v=l.length-1;0<=v;v--){var S=l[v],D=S.instance,$=S.currentTarget;if(S=S.listener,D!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=$;try{u(c)}catch(I){Ui(I)}c.currentTarget=null,u=D}else for(v=0;v<l.length;v++){if(S=l[v],D=S.instance,$=S.currentTarget,S=S.listener,D!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=$;try{u(c)}catch(I){Ui(I)}c.currentTarget=null,u=D}}}}function Te(e,t){var a=t[Bn];a===void 0&&(a=t[Bn]=new Set);var l=e+"__bubble";a.has(l)||(Sp(t,e,2,!1),a.add(l))}function pu(e,t,a){var l=0;t&&(l|=4),Sp(a,e,l,t)}var wr="_reactListening"+Math.random().toString(36).slice(2);function xu(e){if(!e[wr]){e[wr]=!0,hd.forEach(function(a){a!=="selectionchange"&&(py.has(a)||pu(a,!1,e),pu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wr]||(t[wr]=!0,pu("selectionchange",!1,t))}}function Sp(e,t,a,l){switch(Ip(t)){case 2:var c=Gy;break;case 8:c=Yy;break;default:c=Ru}a=c.bind(null,t,a,e),c=void 0,!Bo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),l?c!==void 0?e.addEventListener(t,a,{capture:!0,passive:c}):e.addEventListener(t,a,!0):c!==void 0?e.addEventListener(t,a,{passive:c}):e.addEventListener(t,a,!1)}function gu(e,t,a,l,c){var u=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var v=l.tag;if(v===3||v===4){var S=l.stateNode.containerInfo;if(S===c)break;if(v===4)for(v=l.return;v!==null;){var D=v.tag;if((D===3||D===4)&&v.stateNode.containerInfo===c)return;v=v.return}for(;S!==null;){if(v=ms(S),v===null)return;if(D=v.tag,D===5||D===6||D===26||D===27){l=u=v;continue e}S=S.parentNode}}l=l.return}Cd(function(){var $=u,I=_o(a),ee=[];e:{var X=em.get(e);if(X!==void 0){var Z=Bi,he=e;switch(e){case"keypress":if(_i(a)===0)break e;case"keydown":case"keyup":Z=ov;break;case"focusin":he="focus",Z=Ho;break;case"focusout":he="blur",Z=Ho;break;case"beforeblur":case"afterblur":Z=Ho;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=Md;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=Ig;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=fv;break;case Id:case Jd:case Pd:Z=Wg;break;case Wd:Z=mv;break;case"scroll":case"scrollend":Z=Kg;break;case"wheel":Z=pv;break;case"copy":case"cut":case"paste":Z=tv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Rd;break;case"toggle":case"beforetoggle":Z=gv}var je=(t&4)!==0,Je=!je&&(e==="scroll"||e==="scrollend"),z=je?X!==null?X+"Capture":null:X;je=[];for(var O=$,V;O!==null;){var W=O;if(V=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||V===null||z===null||(W=pl(O,z),W!=null&&je.push(Kl(O,W,V))),Je)break;O=O.return}0<je.length&&(X=new Z(X,he,null,a,I),ee.push({event:X,listeners:je}))}}if((t&7)===0){e:{if(X=e==="mouseover"||e==="pointerover",Z=e==="mouseout"||e==="pointerout",X&&a!==Do&&(he=a.relatedTarget||a.fromElement)&&(ms(he)||he[st]))break e;if((Z||X)&&(X=I.window===I?I:(X=I.ownerDocument)?X.defaultView||X.parentWindow:window,Z?(he=a.relatedTarget||a.toElement,Z=$,he=he?ms(he):null,he!==null&&(Je=d(he),je=he.tag,he!==Je||je!==5&&je!==27&&je!==6)&&(he=null)):(Z=null,he=$),Z!==he)){if(je=Md,W="onMouseLeave",z="onMouseEnter",O="mouse",(e==="pointerout"||e==="pointerover")&&(je=Rd,W="onPointerLeave",z="onPointerEnter",O="pointer"),Je=Z==null?X:hl(Z),V=he==null?X:hl(he),X=new je(W,O+"leave",Z,a,I),X.target=Je,X.relatedTarget=V,W=null,ms(I)===$&&(je=new je(z,O+"enter",he,a,I),je.target=V,je.relatedTarget=Je,W=je),Je=W,Z&&he)t:{for(je=xy,z=Z,O=he,V=0,W=z;W;W=je(W))V++;W=0;for(var Se=O;Se;Se=je(Se))W++;for(;0<V-W;)z=je(z),V--;for(;0<W-V;)O=je(O),W--;for(;V--;){if(z===O||O!==null&&z===O.alternate){je=z;break t}z=je(z),O=je(O)}je=null}else je=null;Z!==null&&Ap(ee,X,Z,je,!1),he!==null&&Je!==null&&Ap(ee,Je,he,je,!0)}}e:{if(X=$?hl($):window,Z=X.nodeName&&X.nodeName.toLowerCase(),Z==="select"||Z==="input"&&X.type==="file")var He=Ud;else if(Ld(X))if(Hd)He=Ev;else{He=wv;var ge=Nv}else Z=X.nodeName,!Z||Z.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?$&&To($.elementType)&&(He=Ud):He=Cv;if(He&&(He=He(e,$))){zd(ee,He,a,I);break e}ge&&ge(e,X,$),e==="focusout"&&$&&X.type==="number"&&$.memoizedProps.value!=null&&Ro(X,"number",X.value)}switch(ge=$?hl($):window,e){case"focusin":(Ld(ge)||ge.contentEditable==="true")&&(As=ge,Xo=$,jl=null);break;case"focusout":jl=Xo=As=null;break;case"mousedown":Qo=!0;break;case"contextmenu":case"mouseup":case"dragend":Qo=!1,Kd(ee,a,I);break;case"selectionchange":if(Mv)break;case"keydown":case"keyup":Kd(ee,a,I)}var ke;if($o)e:{switch(e){case"compositionstart":var _e="onCompositionStart";break e;case"compositionend":_e="onCompositionEnd";break e;case"compositionupdate":_e="onCompositionUpdate";break e}_e=void 0}else Ss?Od(e,a)&&(_e="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(_e="onCompositionStart");_e&&(Td&&a.locale!=="ko"&&(Ss||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&Ss&&(ke=Ed()):(ua=I,Lo="value"in ua?ua.value:ua.textContent,Ss=!0)),ge=Cr($,_e),0<ge.length&&(_e=new qd(_e,e,null,a,I),ee.push({event:_e,listeners:ge}),ke?_e.data=ke:(ke=Bd(a),ke!==null&&(_e.data=ke)))),(ke=yv?bv(e,a):Sv(e,a))&&(_e=Cr($,"onBeforeInput"),0<_e.length&&(ge=new qd("onBeforeInput","beforeinput",null,a,I),ee.push({event:ge,listeners:_e}),ge.data=ke)),dy(ee,e,$,a,I)}bp(ee,t)})}function Kl(e,t,a){return{instance:e,listener:t,currentTarget:a}}function Cr(e,t){for(var a=t+"Capture",l=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=pl(e,a),c!=null&&l.unshift(Kl(e,c,u)),c=pl(e,t),c!=null&&l.push(Kl(e,c,u))),e.tag===3)return l;e=e.return}return[]}function xy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ap(e,t,a,l,c){for(var u=t._reactName,v=[];a!==null&&a!==l;){var S=a,D=S.alternate,$=S.stateNode;if(S=S.tag,D!==null&&D===l)break;S!==5&&S!==26&&S!==27||$===null||(D=$,c?($=pl(a,u),$!=null&&v.unshift(Kl(a,$,D))):c||($=pl(a,u),$!=null&&v.push(Kl(a,$,D)))),a=a.return}v.length!==0&&e.push({event:t,listeners:v})}var gy=/\r\n?/g,vy=/\u0000|\uFFFD/g;function jp(e){return(typeof e=="string"?e:""+e).replace(gy,`
|
||
`).replace(vy,"")}function Np(e,t){return t=jp(t),jp(e)===t}function Ie(e,t,a,l,c,u){switch(a){case"children":typeof l=="string"?t==="body"||t==="textarea"&&l===""||vs(e,l):(typeof l=="number"||typeof l=="bigint")&&t!=="body"&&vs(e,""+l);break;case"className":qi(e,"class",l);break;case"tabIndex":qi(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":qi(e,a,l);break;case"style":Nd(e,l,u);break;case"data":if(t!=="object"){qi(e,"data",l);break}case"src":case"href":if(l===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Ti(""+l),e.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(a==="formAction"?(t!=="input"&&Ie(e,t,"name",c.name,c,null),Ie(e,t,"formEncType",c.formEncType,c,null),Ie(e,t,"formMethod",c.formMethod,c,null),Ie(e,t,"formTarget",c.formTarget,c,null)):(Ie(e,t,"encType",c.encType,c,null),Ie(e,t,"method",c.method,c,null),Ie(e,t,"target",c.target,c,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Ti(""+l),e.setAttribute(a,l);break;case"onClick":l!=null&&(e.onclick=zn);break;case"onScroll":l!=null&&Te("scroll",e);break;case"onScrollEnd":l!=null&&Te("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}a=Ti(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""+l):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":l===!0?e.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,l):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(a,l):e.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(a):e.setAttribute(a,l);break;case"popover":Te("beforetoggle",e),Te("toggle",e),Mi(e,"popover",l);break;case"xlinkActuate":Ln(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Ln(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Ln(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Ln(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Ln(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Ln(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Mi(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Xg.get(a)||a,Mi(e,a,l))}}function vu(e,t,a,l,c,u){switch(a){case"style":Nd(e,l,u);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof l=="string"?vs(e,l):(typeof l=="number"||typeof l=="bigint")&&vs(e,""+l);break;case"onScroll":l!=null&&Te("scroll",e);break;case"onScrollEnd":l!=null&&Te("scrollend",e);break;case"onClick":l!=null&&(e.onclick=zn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!pd.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[jt]||null,u=u!=null?u[a]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof l=="function")){typeof u!="function"&&u!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,l,c);break e}a in e?e[a]=l:l===!0?e.setAttribute(a,""):Mi(e,a,l)}}}function Tt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Te("error",e),Te("load",e);var l=!1,c=!1,u;for(u in a)if(a.hasOwnProperty(u)){var v=a[u];if(v!=null)switch(u){case"src":l=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ie(e,t,u,v,a,null)}}c&&Ie(e,t,"srcSet",a.srcSet,a,null),l&&Ie(e,t,"src",a.src,a,null);return;case"input":Te("invalid",e);var S=u=v=c=null,D=null,$=null;for(l in a)if(a.hasOwnProperty(l)){var I=a[l];if(I!=null)switch(l){case"name":c=I;break;case"type":v=I;break;case"checked":D=I;break;case"defaultChecked":$=I;break;case"value":u=I;break;case"defaultValue":S=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:Ie(e,t,l,I,a,null)}}bd(e,u,S,D,$,v,c,!1);return;case"select":Te("invalid",e),l=v=u=null;for(c in a)if(a.hasOwnProperty(c)&&(S=a[c],S!=null))switch(c){case"value":u=S;break;case"defaultValue":v=S;break;case"multiple":l=S;default:Ie(e,t,c,S,a,null)}t=u,a=v,e.multiple=!!l,t!=null?gs(e,!!l,t,!1):a!=null&&gs(e,!!l,a,!0);return;case"textarea":Te("invalid",e),u=c=l=null;for(v in a)if(a.hasOwnProperty(v)&&(S=a[v],S!=null))switch(v){case"value":l=S;break;case"defaultValue":c=S;break;case"children":u=S;break;case"dangerouslySetInnerHTML":if(S!=null)throw Error(o(91));break;default:Ie(e,t,v,S,a,null)}Ad(e,l,c,u);return;case"option":for(D in a)if(a.hasOwnProperty(D)&&(l=a[D],l!=null))switch(D){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:Ie(e,t,D,l,a,null)}return;case"dialog":Te("beforetoggle",e),Te("toggle",e),Te("cancel",e),Te("close",e);break;case"iframe":case"object":Te("load",e);break;case"video":case"audio":for(l=0;l<Ql.length;l++)Te(Ql[l],e);break;case"image":Te("error",e),Te("load",e);break;case"details":Te("toggle",e);break;case"embed":case"source":case"link":Te("error",e),Te("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for($ in a)if(a.hasOwnProperty($)&&(l=a[$],l!=null))switch($){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ie(e,t,$,l,a,null)}return;default:if(To(t)){for(I in a)a.hasOwnProperty(I)&&(l=a[I],l!==void 0&&vu(e,t,I,l,a,void 0));return}}for(S in a)a.hasOwnProperty(S)&&(l=a[S],l!=null&&Ie(e,t,S,l,a,null))}function yy(e,t,a,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,u=null,v=null,S=null,D=null,$=null,I=null;for(Z in a){var ee=a[Z];if(a.hasOwnProperty(Z)&&ee!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=ee;default:l.hasOwnProperty(Z)||Ie(e,t,Z,null,l,ee)}}for(var X in l){var Z=l[X];if(ee=a[X],l.hasOwnProperty(X)&&(Z!=null||ee!=null))switch(X){case"type":u=Z;break;case"name":c=Z;break;case"checked":$=Z;break;case"defaultChecked":I=Z;break;case"value":v=Z;break;case"defaultValue":S=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(o(137,t));break;default:Z!==ee&&Ie(e,t,X,Z,l,ee)}}qo(e,v,S,D,$,I,u,c);return;case"select":Z=v=S=X=null;for(u in a)if(D=a[u],a.hasOwnProperty(u)&&D!=null)switch(u){case"value":break;case"multiple":Z=D;default:l.hasOwnProperty(u)||Ie(e,t,u,null,l,D)}for(c in l)if(u=l[c],D=a[c],l.hasOwnProperty(c)&&(u!=null||D!=null))switch(c){case"value":X=u;break;case"defaultValue":S=u;break;case"multiple":v=u;default:u!==D&&Ie(e,t,c,u,l,D)}t=S,a=v,l=Z,X!=null?gs(e,!!a,X,!1):!!l!=!!a&&(t!=null?gs(e,!!a,t,!0):gs(e,!!a,a?[]:"",!1));return;case"textarea":Z=X=null;for(S in a)if(c=a[S],a.hasOwnProperty(S)&&c!=null&&!l.hasOwnProperty(S))switch(S){case"value":break;case"children":break;default:Ie(e,t,S,null,l,c)}for(v in l)if(c=l[v],u=a[v],l.hasOwnProperty(v)&&(c!=null||u!=null))switch(v){case"value":X=c;break;case"defaultValue":Z=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Ie(e,t,v,c,l,u)}Sd(e,X,Z);return;case"option":for(var he in a)if(X=a[he],a.hasOwnProperty(he)&&X!=null&&!l.hasOwnProperty(he))switch(he){case"selected":e.selected=!1;break;default:Ie(e,t,he,null,l,X)}for(D in l)if(X=l[D],Z=a[D],l.hasOwnProperty(D)&&X!==Z&&(X!=null||Z!=null))switch(D){case"selected":e.selected=X&&typeof X!="function"&&typeof X!="symbol";break;default:Ie(e,t,D,X,l,Z)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var je in a)X=a[je],a.hasOwnProperty(je)&&X!=null&&!l.hasOwnProperty(je)&&Ie(e,t,je,null,l,X);for($ in l)if(X=l[$],Z=a[$],l.hasOwnProperty($)&&X!==Z&&(X!=null||Z!=null))switch($){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(o(137,t));break;default:Ie(e,t,$,X,l,Z)}return;default:if(To(t)){for(var Je in a)X=a[Je],a.hasOwnProperty(Je)&&X!==void 0&&!l.hasOwnProperty(Je)&&vu(e,t,Je,void 0,l,X);for(I in l)X=l[I],Z=a[I],!l.hasOwnProperty(I)||X===Z||X===void 0&&Z===void 0||vu(e,t,I,X,l,Z);return}}for(var z in a)X=a[z],a.hasOwnProperty(z)&&X!=null&&!l.hasOwnProperty(z)&&Ie(e,t,z,null,l,X);for(ee in l)X=l[ee],Z=a[ee],!l.hasOwnProperty(ee)||X===Z||X==null&&Z==null||Ie(e,t,ee,X,l,Z)}function wp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function by(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var c=a[l],u=c.transferSize,v=c.initiatorType,S=c.duration;if(u&&S&&wp(v)){for(v=0,S=c.responseEnd,l+=1;l<a.length;l++){var D=a[l],$=D.startTime;if($>S)break;var I=D.transferSize,ee=D.initiatorType;I&&wp(ee)&&(D=D.responseEnd,v+=I*(D<S?1:(S-$)/(D-$)))}if(--l,t+=8*(u+v)/(c.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var yu=null,bu=null;function Er(e){return e.nodeType===9?e:e.ownerDocument}function Cp(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 Ep(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 Su(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 Au=null;function Sy(){var e=window.event;return e&&e.type==="popstate"?e===Au?!1:(Au=e,!0):(Au=null,!1)}var kp=typeof setTimeout=="function"?setTimeout:void 0,Ay=typeof clearTimeout=="function"?clearTimeout:void 0,Mp=typeof Promise=="function"?Promise:void 0,jy=typeof queueMicrotask=="function"?queueMicrotask:typeof Mp<"u"?function(e){return Mp.resolve(null).then(e).catch(Ny)}:kp;function Ny(e){setTimeout(function(){throw e})}function Ea(e){return e==="head"}function qp(e,t){var a=t,l=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(l===0){e.removeChild(c),Zs(t);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Zl(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Zl(a);for(var u=a.firstChild;u;){var v=u.nextSibling,S=u.nodeName;u[ml]||S==="SCRIPT"||S==="STYLE"||S==="LINK"&&u.rel.toLowerCase()==="stylesheet"||a.removeChild(u),u=v}}else a==="body"&&Zl(e.ownerDocument.body);a=c}while(a);Zs(t)}function Rp(e,t){var a=e;e=0;do{var l=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=l}while(a)}function ju(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":ju(a),ko(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function wy(e,t,a,l){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[ml])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(u=e.getAttribute("rel"),u==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(u!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(u=e.getAttribute("src"),(u!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&u&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var u=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===u)return e}else return e;if(e=un(e.nextSibling),e===null)break}return null}function Cy(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=un(e.nextSibling),e===null))return null;return e}function Tp(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=un(e.nextSibling),e===null))return null;return e}function Nu(e){return e.data==="$?"||e.data==="$~"}function wu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Ey(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var l=function(){t(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function un(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Cu=null;function Dp(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return un(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function _p(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 Op(e,t,a){switch(t=Er(a),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Zl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ko(e)}var fn=new Map,Bp=new Set;function kr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ea=F.d;F.d={f:ky,r:My,D:qy,C:Ry,L:Ty,m:Dy,X:Oy,S:_y,M:By};function ky(){var e=ea.f(),t=yr();return e||t}function My(e){var t=hs(e);t!==null&&t.tag===5&&t.type==="form"?Wm(t):ea.r(e)}var Xs=typeof document>"u"?null:document;function Lp(e,t,a){var l=Xs;if(l&&typeof t=="string"&&t){var c=nn(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),Bp.has(c)||(Bp.add(c),e={rel:e,crossOrigin:a,href:t},l.querySelector(c)===null&&(t=l.createElement("link"),Tt(t,"link",e),wt(t),l.head.appendChild(t)))}}function qy(e){ea.D(e),Lp("dns-prefetch",e,null)}function Ry(e,t){ea.C(e,t),Lp("preconnect",e,t)}function Ty(e,t,a){ea.L(e,t,a);var l=Xs;if(l&&e&&t){var c='link[rel="preload"][as="'+nn(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+nn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+nn(a.imageSizes)+'"]')):c+='[href="'+nn(e)+'"]';var u=c;switch(t){case"style":u=Qs(e);break;case"script":u=Ks(e)}fn.has(u)||(e=b({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),fn.set(u,e),l.querySelector(c)!==null||t==="style"&&l.querySelector(Il(u))||t==="script"&&l.querySelector(Jl(u))||(t=l.createElement("link"),Tt(t,"link",e),wt(t),l.head.appendChild(t)))}}function Dy(e,t){ea.m(e,t);var a=Xs;if(a&&e){var l=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+nn(l)+'"][href="'+nn(e)+'"]',u=c;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Ks(e)}if(!fn.has(u)&&(e=b({rel:"modulepreload",href:e},t),fn.set(u,e),a.querySelector(c)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Jl(u)))return}l=a.createElement("link"),Tt(l,"link",e),wt(l),a.head.appendChild(l)}}}function _y(e,t,a){ea.S(e,t,a);var l=Xs;if(l&&e){var c=ps(l).hoistableStyles,u=Qs(e);t=t||"default";var v=c.get(u);if(!v){var S={loading:0,preload:null};if(v=l.querySelector(Il(u)))S.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},a),(a=fn.get(u))&&Eu(e,a);var D=v=l.createElement("link");wt(D),Tt(D,"link",e),D._p=new Promise(function($,I){D.onload=$,D.onerror=I}),D.addEventListener("load",function(){S.loading|=1}),D.addEventListener("error",function(){S.loading|=2}),S.loading|=4,Mr(v,t,l)}v={type:"stylesheet",instance:v,count:1,state:S},c.set(u,v)}}}function Oy(e,t){ea.X(e,t);var a=Xs;if(a&&e){var l=ps(a).hoistableScripts,c=Ks(e),u=l.get(c);u||(u=a.querySelector(Jl(c)),u||(e=b({src:e,async:!0},t),(t=fn.get(c))&&ku(e,t),u=a.createElement("script"),wt(u),Tt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},l.set(c,u))}}function By(e,t){ea.M(e,t);var a=Xs;if(a&&e){var l=ps(a).hoistableScripts,c=Ks(e),u=l.get(c);u||(u=a.querySelector(Jl(c)),u||(e=b({src:e,async:!0,type:"module"},t),(t=fn.get(c))&&ku(e,t),u=a.createElement("script"),wt(u),Tt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},l.set(c,u))}}function zp(e,t,a,l){var c=(c=ie.current)?kr(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Qs(a.href),a=ps(c).hoistableStyles,l=a.get(t),l||(l={type:"style",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Qs(a.href);var u=ps(c).hoistableStyles,v=u.get(e);if(v||(c=c.ownerDocument||c,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,v),(u=c.querySelector(Il(e)))&&!u._p&&(v.instance=u,v.state.loading=5),fn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},fn.set(e,a),u||Ly(c,e,a,v.state))),t&&l===null)throw Error(o(528,""));return v}if(t&&l!==null)throw Error(o(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ks(a),a=ps(c).hoistableScripts,l=a.get(t),l||(l={type:"script",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Qs(e){return'href="'+nn(e)+'"'}function Il(e){return'link[rel="stylesheet"]['+e+"]"}function Up(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Ly(e,t,a,l){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=e.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),Tt(t,"link",a),wt(t),e.head.appendChild(t))}function Ks(e){return'[src="'+nn(e)+'"]'}function Jl(e){return"script[async]"+e}function Hp(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var l=e.querySelector('style[data-href~="'+nn(a.href)+'"]');if(l)return t.instance=l,wt(l),l;var c=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),wt(l),Tt(l,"style",c),Mr(l,a.precedence,e),t.instance=l;case"stylesheet":c=Qs(a.href);var u=e.querySelector(Il(c));if(u)return t.state.loading|=4,t.instance=u,wt(u),u;l=Up(a),(c=fn.get(c))&&Eu(l,c),u=(e.ownerDocument||e).createElement("link"),wt(u);var v=u;return v._p=new Promise(function(S,D){v.onload=S,v.onerror=D}),Tt(u,"link",l),t.state.loading|=4,Mr(u,a.precedence,e),t.instance=u;case"script":return u=Ks(a.src),(c=e.querySelector(Jl(u)))?(t.instance=c,wt(c),c):(l=a,(c=fn.get(u))&&(l=b({},a),ku(l,c)),e=e.ownerDocument||e,c=e.createElement("script"),wt(c),Tt(c,"link",l),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(l=t.instance,t.state.loading|=4,Mr(l,a.precedence,e));return t.instance}function Mr(e,t,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=l.length?l[l.length-1]:null,u=c,v=0;v<l.length;v++){var S=l[v];if(S.dataset.precedence===t)u=S;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 Eu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function ku(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var qr=null;function Vp(e,t,a){if(qr===null){var l=new Map,c=qr=new Map;c.set(a,l)}else c=qr,l=c.get(a),l||(l=new Map,c.set(a,l));if(l.has(e))return l;for(l.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var u=a[c];if(!(u[ml]||u[rt]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var v=u.getAttribute(t)||"";v=e+v;var S=l.get(v);S?S.push(u):l.set(v,[u])}}return l}function $p(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function zy(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 Gp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Uy(e,t,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Qs(l.href),u=t.querySelector(Il(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Rr.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=u,wt(u);return}u=t.ownerDocument||t,l=Up(l),(c=fn.get(c))&&Eu(l,c),u=u.createElement("link"),wt(u);var v=u;v._p=new Promise(function(S,D){v.onload=S,v.onerror=D}),Tt(u,"link",l),a.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Rr.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Mu=0;function Hy(e,t){return e.stylesheets&&e.count===0&&Dr(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var l=setTimeout(function(){if(e.stylesheets&&Dr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&Mu===0&&(Mu=62500*by());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Dr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>Mu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(c)}}:null}function Rr(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Dr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Tr=null;function Dr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Tr=new Map,t.forEach(Vy,e),Tr=null,Rr.call(e))}function Vy(e,t){if(!(t.state.loading&4)){var a=Tr.get(e);if(a)var l=a.get(null);else{a=new Map,Tr.set(e,a);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<c.length;u++){var v=c[u];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(a.set(v.dataset.precedence,v),l=v)}l&&a.set(null,l)}c=t.instance,v=c.getAttribute("data-precedence"),u=a.get(v)||l,u===l&&a.set(null,c),a.set(v,c),this.count++,l=Rr.bind(this),c.addEventListener("load",l),c.addEventListener("error",l),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Pl={$$typeof:C,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function $y(e,t,a,l,c,u,v,S,D){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=fl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fl(0),this.hiddenUpdates=fl(null),this.identifierPrefix=l,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function Yp(e,t,a,l,c,u,v,S,D,$,I,ee){return e=new $y(e,t,a,v,D,$,I,ee,S),t=1,u===!0&&(t|=24),u=Xt(3,null,null,t),e.current=u,u.stateNode=e,t=oc(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:l,isDehydrated:a,cache:t},dc(u),e}function Fp(e){return e?(e=ws,e):ws}function Xp(e,t,a,l,c,u){c=Fp(c),l.context===null?l.context=c:l.pendingContext=c,l=xa(t),l.payload={element:a},u=u===void 0?null:u,u!==null&&(l.callback=u),a=ga(e,l,t),a!==null&&($t(a,e,t),ql(a,e,t))}function Qp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function qu(e,t){Qp(e,t),(e=e.alternate)&&Qp(e,t)}function Kp(e){if(e.tag===13||e.tag===31){var t=$a(e,67108864);t!==null&&$t(t,e,67108864),qu(e,67108864)}}function Zp(e){if(e.tag===13||e.tag===31){var t=Jt();t=Ke(t);var a=$a(e,t);a!==null&&$t(a,e,t),qu(e,t)}}var _r=!0;function Gy(e,t,a,l){var c=T.T;T.T=null;var u=F.p;try{F.p=2,Ru(e,t,a,l)}finally{F.p=u,T.T=c}}function Yy(e,t,a,l){var c=T.T;T.T=null;var u=F.p;try{F.p=8,Ru(e,t,a,l)}finally{F.p=u,T.T=c}}function Ru(e,t,a,l){if(_r){var c=Tu(l);if(c===null)gu(e,t,l,Or,a),Jp(e,l);else if(Xy(c,e,t,a,l))l.stopPropagation();else if(Jp(e,l),t&4&&-1<Fy.indexOf(e)){for(;c!==null;){var u=hs(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var v=_n(u.pendingLanes);if(v!==0){var S=u;for(S.pendingLanes|=2,S.entangledLanes|=2;v;){var D=1<<31-kt(v);S.entanglements[1]|=D,v&=~D}Cn(u),(Ge&6)===0&&(gr=Le()+500,Xl(0))}}break;case 31:case 13:S=$a(u,2),S!==null&&$t(S,u,2),yr(),qu(u,2)}if(u=Tu(l),u===null&&gu(e,t,l,Or,a),u===c)break;c=u}c!==null&&l.stopPropagation()}else gu(e,t,l,null,a)}}function Tu(e){return e=_o(e),Du(e)}var Or=null;function Du(e){if(Or=null,e=ms(e),e!==null){var t=d(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=h(t),e!==null)return e;e=null}else if(a===31){if(e=x(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Or=e,null}function Ip(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(xt()){case mt:return 2;case Tn:return 8;case Et:case cs:return 32;case Gt:return 268435456;default:return 32}default:return 32}}var _u=!1,ka=null,Ma=null,qa=null,Wl=new Map,ei=new Map,Ra=[],Fy="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 Jp(e,t){switch(e){case"focusin":case"focusout":ka=null;break;case"dragenter":case"dragleave":Ma=null;break;case"mouseover":case"mouseout":qa=null;break;case"pointerover":case"pointerout":Wl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ei.delete(t.pointerId)}}function ti(e,t,a,l,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:a,eventSystemFlags:l,nativeEvent:u,targetContainers:[c]},t!==null&&(t=hs(t),t!==null&&Kp(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function Xy(e,t,a,l,c){switch(t){case"focusin":return ka=ti(ka,e,t,a,l,c),!0;case"dragenter":return Ma=ti(Ma,e,t,a,l,c),!0;case"mouseover":return qa=ti(qa,e,t,a,l,c),!0;case"pointerover":var u=c.pointerId;return Wl.set(u,ti(Wl.get(u)||null,e,t,a,l,c)),!0;case"gotpointercapture":return u=c.pointerId,ei.set(u,ti(ei.get(u)||null,e,t,a,l,c)),!0}return!1}function Pp(e){var t=ms(e.target);if(t!==null){var a=d(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){Zp(a)});return}}else if(t===31){if(t=x(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){Zp(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Br(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Tu(e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Do=l,a.target.dispatchEvent(l),Do=null}else return t=hs(a),t!==null&&Kp(t),e.blockedOn=a,!1;t.shift()}return!0}function Wp(e,t,a){Br(e)&&a.delete(t)}function Qy(){_u=!1,ka!==null&&Br(ka)&&(ka=null),Ma!==null&&Br(Ma)&&(Ma=null),qa!==null&&Br(qa)&&(qa=null),Wl.forEach(Wp),ei.forEach(Wp)}function Lr(e,t){e.blockedOn===t&&(e.blockedOn=null,_u||(_u=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Qy)))}var zr=null;function e0(e){zr!==e&&(zr=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){zr===e&&(zr=null);for(var t=0;t<e.length;t+=3){var a=e[t],l=e[t+1],c=e[t+2];if(typeof l!="function"){if(Du(l||a)===null)continue;break}var u=hs(a);u!==null&&(e.splice(t,3),t-=3,Tc(u,{pending:!0,data:c,method:a.method,action:l},l,c))}}))}function Zs(e){function t(D){return Lr(D,e)}ka!==null&&Lr(ka,e),Ma!==null&&Lr(Ma,e),qa!==null&&Lr(qa,e),Wl.forEach(t),ei.forEach(t);for(var a=0;a<Ra.length;a++){var l=Ra[a];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Ra.length&&(a=Ra[0],a.blockedOn===null);)Pp(a),a.blockedOn===null&&Ra.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var c=a[l],u=a[l+1],v=c[jt]||null;if(typeof u=="function")v||e0(a);else if(v){var S=null;if(u&&u.hasAttribute("formAction")){if(c=u,v=u[jt]||null)S=v.formAction;else if(Du(c)!==null)continue}else S=v.action;typeof S=="function"?a[l+1]=S:(a.splice(l,3),l-=3),e0(a)}}}function t0(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(v){return c=v})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Ou(e){this._internalRoot=e}Ur.prototype.render=Ou.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,l=Jt();Xp(a,l,e,t,null,null)},Ur.prototype.unmount=Ou.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Xp(e.current,2,null,e,null,null),yr(),t[st]=null}};function Ur(e){this._internalRoot=e}Ur.prototype.unstable_scheduleHydration=function(e){if(e){var t=qe();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Ra.length&&t!==0&&t<Ra[a].priority;a++);Ra.splice(a,0,e),a===0&&Pp(e)}};var n0=s.version;if(n0!=="19.2.0")throw Error(o(527,n0,"19.2.0"));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=g(t),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var Ky={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hr.isDisabled&&Hr.supportsFiber)try{Dn=Hr.inject(Ky),At=Hr}catch{}}return ai.createRoot=function(e,t){if(!f(e))throw Error(o(299));var a=!1,l="",c=ch,u=uh,v=fh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(v=t.onRecoverableError)),t=Yp(e,1,!1,null,null,a,l,null,c,u,v,t0),e[st]=t.current,xu(e),new Ou(t)},ai.hydrateRoot=function(e,t,a){if(!f(e))throw Error(o(299));var l=!1,c="",u=ch,v=uh,S=fh,D=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(u=a.onUncaughtError),a.onCaughtError!==void 0&&(v=a.onCaughtError),a.onRecoverableError!==void 0&&(S=a.onRecoverableError),a.formState!==void 0&&(D=a.formState)),t=Yp(e,1,!0,t,a??null,l,c,D,u,v,S,t0),t.context=Fp(null),a=t.current,l=Jt(),l=Ke(l),c=xa(l),c.callback=null,ga(a,c,l),a=l,t.current.lanes=a,La(t,a),Cn(t),e[st]=t.current,xu(e),new Ur(t)},ai.version="19.2.0",ai}var d0;function lb(){if(d0)return zu.exports;d0=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=sb(),zu.exports}var ib=lb();var m0="popstate";function rb(n={}){function s(o,f){let{pathname:d,search:h,hash:x}=o.location;return hf("",{pathname:d,search:h,hash:x},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function i(o,f){return typeof f=="string"?f:pi(f)}return cb(s,i,null,n)}function ot(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function Sn(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function ob(){return Math.random().toString(36).substring(2,10)}function h0(n,s){return{usr:n.state,key:n.key,idx:s}}function hf(n,s,i=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?il(s):s,state:i,key:s&&s.key||o||ob()}}function pi({pathname:n="/",search:s="",hash:i=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function il(n){let s={};if(n){let i=n.indexOf("#");i>=0&&(s.hash=n.substring(i),n=n.substring(0,i));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function cb(n,s,i,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,h=f.history,x="POP",p=null,g=y();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function y(){return(h.state||{idx:null}).idx}function b(){x="POP";let j=y(),w=j==null?null:j-g;g=j,p&&p({action:x,location:q.location,delta:w})}function A(j,w){x="PUSH";let E=hf(q.location,j,w);g=y()+1;let C=h0(E,g),M=q.createHref(E);try{h.pushState(C,"",M)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;f.location.assign(M)}d&&p&&p({action:x,location:q.location,delta:1})}function R(j,w){x="REPLACE";let E=hf(q.location,j,w);g=y();let C=h0(E,g),M=q.createHref(E);h.replaceState(C,"",M),d&&p&&p({action:x,location:q.location,delta:0})}function N(j){return ub(j)}let q={get action(){return x},get location(){return n(f,h)},listen(j){if(p)throw new Error("A history only accepts one active listener");return f.addEventListener(m0,b),p=j,()=>{f.removeEventListener(m0,b),p=null}},createHref(j){return s(f,j)},createURL:N,encodeLocation(j){let w=N(j);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:A,replace:R,go(j){return h.go(j)}};return q}function ub(n,s=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),ot(i,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:pi(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function mx(n,s,i="/"){return fb(n,s,i,!1)}function fb(n,s,i,o){let f=typeof s=="string"?il(s):s,d=ia(f.pathname||"/",i);if(d==null)return null;let h=hx(n);db(h);let x=null;for(let p=0;x==null&&p<h.length;++p){let g=jb(d);x=Sb(h[p],g,o)}return x}function hx(n,s=[],i=[],o="",f=!1){let d=(h,x,p=f,g)=>{let y={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:x,route:h};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&p)return;ot(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let b=la([o,y.relativePath]),A=i.concat(y);h.children&&h.children.length>0&&(ot(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),hx(h.children,s,A,b,p)),!(h.path==null&&!h.index)&&s.push({path:b,score:yb(b,h.index),routesMeta:A})};return n.forEach((h,x)=>{if(h.path===""||!h.path?.includes("?"))d(h,x);else for(let p of px(h.path))d(h,x,!0,p)}),s}function px(n){let s=n.split("/");if(s.length===0)return[];let[i,...o]=s,f=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return f?[d,""]:[d];let h=px(o.join("/")),x=[];return x.push(...h.map(p=>p===""?d:[d,p].join("/"))),f&&x.push(...h),x.map(p=>n.startsWith("/")&&p===""?"/":p)}function db(n){n.sort((s,i)=>s.score!==i.score?i.score-s.score:bb(s.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var mb=/^:[\w-]+$/,hb=3,pb=2,xb=1,gb=10,vb=-2,p0=n=>n==="*";function yb(n,s){let i=n.split("/"),o=i.length;return i.some(p0)&&(o+=vb),s&&(o+=pb),i.filter(f=>!p0(f)).reduce((f,d)=>f+(mb.test(d)?hb:d===""?xb:gb),o)}function bb(n,s){return n.length===s.length&&n.slice(0,-1).every((o,f)=>o===s[f])?n[n.length-1]-s[s.length-1]:0}function Sb(n,s,i=!1){let{routesMeta:o}=n,f={},d="/",h=[];for(let x=0;x<o.length;++x){let p=o[x],g=x===o.length-1,y=d==="/"?s:s.slice(d.length)||"/",b=so({path:p.relativePath,caseSensitive:p.caseSensitive,end:g},y),A=p.route;if(!b&&g&&i&&!o[o.length-1].route.index&&(b=so({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},y)),!b)return null;Object.assign(f,b.params),h.push({params:f,pathname:la([d,b.pathname]),pathnameBase:kb(la([d,b.pathnameBase])),route:A}),b.pathnameBase!=="/"&&(d=la([d,b.pathnameBase]))}return h}function so(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,o]=Ab(n.path,n.caseSensitive,n.end),f=s.match(i);if(!f)return null;let d=f[0],h=d.replace(/(.)\/+$/,"$1"),x=f.slice(1);return{params:o.reduce((g,{paramName:y,isOptional:b},A)=>{if(y==="*"){let N=x[A]||"";h=d.slice(0,d.length-N.length).replace(/(.)\/+$/,"$1")}const R=x[A];return b&&!R?g[y]=void 0:g[y]=(R||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:n}}function Ab(n,s=!1,i=!0){Sn(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],f="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,x,p)=>(o.push({paramName:x,isOptional:p!=null}),p?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),f+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?f+="\\/*$":n!==""&&n!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,s?void 0:"i"),o]}function jb(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Sn(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function ia(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let i=s.endsWith("/")?s.length-1:s.length,o=n.charAt(i);return o&&o!=="/"?null:n.slice(i)||"/"}var Nb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wb=n=>Nb.test(n);function Cb(n,s="/"){let{pathname:i,search:o="",hash:f=""}=typeof n=="string"?il(n):n,d;if(i)if(wb(i))d=i;else{if(i.includes("//")){let h=i;i=i.replace(/\/\/+/g,"/"),Sn(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${i}`)}i.startsWith("/")?d=x0(i.substring(1),"/"):d=x0(i,s)}else d=s;return{pathname:d,search:Mb(o),hash:qb(f)}}function x0(n,s){let i=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(f=>{f===".."?i.length>1&&i.pop():f!=="."&&i.push(f)}),i.length>1?i.join("/"):"/"}function $u(n,s,i,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Eb(n){return n.filter((s,i)=>i===0||s.route.path&&s.route.path.length>0)}function xx(n){let s=Eb(n);return s.map((i,o)=>o===s.length-1?i.pathname:i.pathnameBase)}function gx(n,s,i,o=!1){let f;typeof n=="string"?f=il(n):(f={...n},ot(!f.pathname||!f.pathname.includes("?"),$u("?","pathname","search",f)),ot(!f.pathname||!f.pathname.includes("#"),$u("#","pathname","hash",f)),ot(!f.search||!f.search.includes("#"),$u("#","search","hash",f)));let d=n===""||f.pathname==="",h=d?"/":f.pathname,x;if(h==null)x=i;else{let b=s.length-1;if(!o&&h.startsWith("..")){let A=h.split("/");for(;A[0]==="..";)A.shift(),b-=1;f.pathname=A.join("/")}x=b>=0?s[b]:"/"}let p=Cb(f,x),g=h&&h!=="/"&&h.endsWith("/"),y=(d||h===".")&&i.endsWith("/");return!p.pathname.endsWith("/")&&(g||y)&&(p.pathname+="/"),p}var la=n=>n.join("/").replace(/\/\/+/g,"/"),kb=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Mb=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,qb=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Rb(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 vx=["POST","PUT","PATCH","DELETE"];new Set(vx);var Tb=["GET",...vx];new Set(Tb);var rl=m.createContext(null);rl.displayName="DataRouter";var ho=m.createContext(null);ho.displayName="DataRouterState";m.createContext(!1);var yx=m.createContext({isTransitioning:!1});yx.displayName="ViewTransition";var Db=m.createContext(new Map);Db.displayName="Fetchers";var _b=m.createContext(null);_b.displayName="Await";var qn=m.createContext(null);qn.displayName="Navigation";var Ni=m.createContext(null);Ni.displayName="Location";var oa=m.createContext({outlet:null,matches:[],isDataRoute:!1});oa.displayName="Route";var Df=m.createContext(null);Df.displayName="RouteError";function Ob(n,{relative:s}={}){ot(wi(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=m.useContext(qn),{hash:f,pathname:d,search:h}=Ci(n,{relative:s}),x=d;return i!=="/"&&(x=d==="/"?i:la([i,d])),o.createHref({pathname:x,search:h,hash:f})}function wi(){return m.useContext(Ni)!=null}function os(){return ot(wi(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Ni).location}var bx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Sx(n){m.useContext(qn).static||m.useLayoutEffect(n)}function Bb(){let{isDataRoute:n}=m.useContext(oa);return n?Zb():Lb()}function Lb(){ot(wi(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(rl),{basename:s,navigator:i}=m.useContext(qn),{matches:o}=m.useContext(oa),{pathname:f}=os(),d=JSON.stringify(xx(o)),h=m.useRef(!1);return Sx(()=>{h.current=!0}),m.useCallback((p,g={})=>{if(Sn(h.current,bx),!h.current)return;if(typeof p=="number"){i.go(p);return}let y=gx(p,JSON.parse(d),f,g.relative==="path");n==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:la([s,y.pathname])),(g.replace?i.replace:i.push)(y,g.state,g)},[s,i,d,f,n])}m.createContext(null);function Ci(n,{relative:s}={}){let{matches:i}=m.useContext(oa),{pathname:o}=os(),f=JSON.stringify(xx(i));return m.useMemo(()=>gx(n,JSON.parse(f),o,s==="path"),[n,f,o,s])}function zb(n,s){return Ax(n,s)}function Ax(n,s,i,o,f){ot(wi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(qn),{matches:h}=m.useContext(oa),x=h[h.length-1],p=x?x.params:{},g=x?x.pathname:"/",y=x?x.pathnameBase:"/",b=x&&x.route;{let E=b&&b.path||"";jx(g,!b||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
||
|
||
Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let A=os(),R;if(s){let E=typeof s=="string"?il(s):s;ot(y==="/"||E.pathname?.startsWith(y),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${y}" but pathname "${E.pathname}" was given in the \`location\` prop.`),R=E}else R=A;let N=R.pathname||"/",q=N;if(y!=="/"){let E=y.replace(/^\//,"").split("/");q="/"+N.replace(/^\//,"").split("/").slice(E.length).join("/")}let j=mx(n,{pathname:q});Sn(b||j!=null,`No routes matched location "${R.pathname}${R.search}${R.hash}" `),Sn(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${R.pathname}${R.search}${R.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=Gb(j&&j.map(E=>Object.assign({},E,{params:Object.assign({},p,E.params),pathname:la([y,d.encodeLocation?d.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?y:la([y,d.encodeLocation?d.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),h,i,o,f);return s&&w?m.createElement(Ni.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...R},navigationType:"POP"}},w):w}function Ub(){let n=Kb(),s=Rb(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",n),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:d},"ErrorBoundary")," or"," ",m.createElement("code",{style:d},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},s),i?m.createElement("pre",{style:f},i):null,h)}var Hb=m.createElement(Ub,null),Vb=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(oa.Provider,{value:this.props.routeContext},m.createElement(Df.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function $b({routeContext:n,match:s,children:i}){let o=m.useContext(rl);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(oa.Provider,{value:n},i)}function Gb(n,s=[],i=null,o=null,f=null){if(n==null){if(!i)return null;if(i.errors)n=i.matches;else if(s.length===0&&!i.initialized&&i.matches.length>0)n=i.matches;else return null}let d=n,h=i?.errors;if(h!=null){let y=d.findIndex(b=>b.route.id&&h?.[b.route.id]!==void 0);ot(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),d=d.slice(0,Math.min(d.length,y+1))}let x=!1,p=-1;if(i)for(let y=0;y<d.length;y++){let b=d[y];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(p=y),b.route.id){let{loaderData:A,errors:R}=i,N=b.route.loader&&!A.hasOwnProperty(b.route.id)&&(!R||R[b.route.id]===void 0);if(b.route.lazy||N){x=!0,p>=0?d=d.slice(0,p+1):d=[d[0]];break}}}let g=i&&o?(y,b)=>{o(y,{location:i.location,params:i.matches?.[0]?.params??{},errorInfo:b})}:void 0;return d.reduceRight((y,b,A)=>{let R,N=!1,q=null,j=null;i&&(R=h&&b.route.id?h[b.route.id]:void 0,q=b.route.errorElement||Hb,x&&(p<0&&A===0?(jx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,j=null):p===A&&(N=!0,j=b.route.hydrateFallbackElement||null)));let w=s.concat(d.slice(0,A+1)),E=()=>{let C;return R?C=q:N?C=j:b.route.Component?C=m.createElement(b.route.Component,null):b.route.element?C=b.route.element:C=y,m.createElement($b,{match:b,routeContext:{outlet:y,matches:w,isDataRoute:i!=null},children:C})};return i&&(b.route.ErrorBoundary||b.route.errorElement||A===0)?m.createElement(Vb,{location:i.location,revalidation:i.revalidation,component:q,error:R,children:E(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:g}):E()},null)}function _f(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yb(n){let s=m.useContext(rl);return ot(s,_f(n)),s}function Fb(n){let s=m.useContext(ho);return ot(s,_f(n)),s}function Xb(n){let s=m.useContext(oa);return ot(s,_f(n)),s}function Of(n){let s=Xb(n),i=s.matches[s.matches.length-1];return ot(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function Qb(){return Of("useRouteId")}function Kb(){let n=m.useContext(Df),s=Fb("useRouteError"),i=Of("useRouteError");return n!==void 0?n:s.errors?.[i]}function Zb(){let{router:n}=Yb("useNavigate"),s=Of("useNavigate"),i=m.useRef(!1);return Sx(()=>{i.current=!0}),m.useCallback(async(f,d={})=>{Sn(i.current,bx),i.current&&(typeof f=="number"?n.navigate(f):await n.navigate(f,{fromRouteId:s,...d}))},[n,s])}var g0={};function jx(n,s,i){!s&&!g0[n]&&(g0[n]=!0,Sn(!1,i))}m.memo(Ib);function Ib({routes:n,future:s,state:i,unstable_onError:o}){return Ax(n,void 0,i,o,s)}function Qr(n){ot(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Jb({basename:n="/",children:s=null,location:i,navigationType:o="POP",navigator:f,static:d=!1}){ot(!wi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=n.replace(/^\/*/,"/"),x=m.useMemo(()=>({basename:h,navigator:f,static:d,future:{}}),[h,f,d]);typeof i=="string"&&(i=il(i));let{pathname:p="/",search:g="",hash:y="",state:b=null,key:A="default"}=i,R=m.useMemo(()=>{let N=ia(p,h);return N==null?null:{location:{pathname:N,search:g,hash:y,state:b,key:A},navigationType:o}},[h,p,g,y,b,A,o]);return Sn(R!=null,`<Router basename="${h}"> is not able to match the URL "${p}${g}${y}" because it does not start with the basename, so the <Router> won't render anything.`),R==null?null:m.createElement(qn.Provider,{value:x},m.createElement(Ni.Provider,{children:s,value:R}))}function Pb({children:n,location:s}){return zb(pf(n),s)}function pf(n,s=[]){let i=[];return m.Children.forEach(n,(o,f)=>{if(!m.isValidElement(o))return;let d=[...s,f];if(o.type===m.Fragment){i.push.apply(i,pf(o.props.children,d));return}ot(o.type===Qr,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ot(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=pf(o.props.children,d)),i.push(h)}),i}var Kr="get",Zr="application/x-www-form-urlencoded";function po(n){return n!=null&&typeof n.tagName=="string"}function Wb(n){return po(n)&&n.tagName.toLowerCase()==="button"}function e1(n){return po(n)&&n.tagName.toLowerCase()==="form"}function t1(n){return po(n)&&n.tagName.toLowerCase()==="input"}function n1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function a1(n,s){return n.button===0&&(!s||s==="_self")&&!n1(n)}var Vr=null;function s1(){if(Vr===null)try{new FormData(document.createElement("form"),0),Vr=!1}catch{Vr=!0}return Vr}var l1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Gu(n){return n!=null&&!l1.has(n)?(Sn(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zr}"`),null):n}function i1(n,s){let i,o,f,d,h;if(e1(n)){let x=n.getAttribute("action");o=x?ia(x,s):null,i=n.getAttribute("method")||Kr,f=Gu(n.getAttribute("enctype"))||Zr,d=new FormData(n)}else if(Wb(n)||t1(n)&&(n.type==="submit"||n.type==="image")){let x=n.form;if(x==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=n.getAttribute("formaction")||x.getAttribute("action");if(o=p?ia(p,s):null,i=n.getAttribute("formmethod")||x.getAttribute("method")||Kr,f=Gu(n.getAttribute("formenctype"))||Gu(x.getAttribute("enctype"))||Zr,d=new FormData(x,n),!s1()){let{name:g,type:y,value:b}=n;if(y==="image"){let A=g?`${g}.`:"";d.append(`${A}x`,"0"),d.append(`${A}y`,"0")}else g&&d.append(g,b)}}else{if(po(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Kr,o=null,f=Zr,h=n}return d&&f==="text/plain"&&(h=d,d=void 0),{action:o,method:i.toLowerCase(),encType:f,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Bf(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function r1(n,s,i){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${i}`:s&&ia(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${i}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${i}`,o}async function o1(n,s){if(n.id in s)return s[n.id];try{let i=await import(n.module);return s[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function c1(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 u1(n,s,i){let o=await Promise.all(n.map(async f=>{let d=s.routes[f.route.id];if(d){let h=await o1(d,i);return h.links?h.links():[]}return[]}));return h1(o.flat(1).filter(c1).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function v0(n,s,i,o,f,d){let h=(p,g)=>i[g]?p.route.id!==i[g].route.id:!0,x=(p,g)=>i[g].pathname!==p.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==p.params["*"];return d==="assets"?s.filter((p,g)=>h(p,g)||x(p,g)):d==="data"?s.filter((p,g)=>{let y=o.routes[p.route.id];if(!y||!y.hasLoader)return!1;if(h(p,g)||x(p,g))return!0;if(p.route.shouldRevalidate){let b=p.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function f1(n,s,{includeHydrateFallback:i}={}){return d1(n.map(o=>{let f=s.routes[o.route.id];if(!f)return[];let d=[f.module];return f.clientActionModule&&(d=d.concat(f.clientActionModule)),f.clientLoaderModule&&(d=d.concat(f.clientLoaderModule)),i&&f.hydrateFallbackModule&&(d=d.concat(f.hydrateFallbackModule)),f.imports&&(d=d.concat(f.imports)),d}).flat(1))}function d1(n){return[...new Set(n)]}function m1(n){let s={},i=Object.keys(n).sort();for(let o of i)s[o]=n[o];return s}function h1(n,s){let i=new Set;return new Set(s),n.reduce((o,f)=>{let d=JSON.stringify(m1(f));return i.has(d)||(i.add(d),o.push({key:d,link:f})),o},[])}function Nx(){let n=m.useContext(rl);return Bf(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function p1(){let n=m.useContext(ho);return Bf(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Lf=m.createContext(void 0);Lf.displayName="FrameworkContext";function wx(){let n=m.useContext(Lf);return Bf(n,"You must render this element inside a <HydratedRouter> element"),n}function x1(n,s){let i=m.useContext(Lf),[o,f]=m.useState(!1),[d,h]=m.useState(!1),{onFocus:x,onBlur:p,onMouseEnter:g,onMouseLeave:y,onTouchStart:b}=s,A=m.useRef(null);m.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let q=w=>{w.forEach(E=>{h(E.isIntersecting)})},j=new IntersectionObserver(q,{threshold:.5});return A.current&&j.observe(A.current),()=>{j.disconnect()}}},[n]),m.useEffect(()=>{if(o){let q=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(q)}}},[o]);let R=()=>{f(!0)},N=()=>{f(!1),h(!1)};return i?n!=="intent"?[d,A,{}]:[d,A,{onFocus:si(x,R),onBlur:si(p,N),onMouseEnter:si(g,R),onMouseLeave:si(y,N),onTouchStart:si(b,R)}]:[!1,A,{}]}function si(n,s){return i=>{n&&n(i),i.defaultPrevented||s(i)}}function g1({page:n,...s}){let{router:i}=Nx(),o=m.useMemo(()=>mx(i.routes,n,i.basename),[i.routes,n,i.basename]);return o?m.createElement(y1,{page:n,matches:o,...s}):null}function v1(n){let{manifest:s,routeModules:i}=wx(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return u1(n,s,i).then(h=>{d||f(h)}),()=>{d=!0}},[n,s,i]),o}function y1({page:n,matches:s,...i}){let o=os(),{manifest:f,routeModules:d}=wx(),{basename:h}=Nx(),{loaderData:x,matches:p}=p1(),g=m.useMemo(()=>v0(n,s,p,f,o,"data"),[n,s,p,f,o]),y=m.useMemo(()=>v0(n,s,p,f,o,"assets"),[n,s,p,f,o]),b=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let N=new Set,q=!1;if(s.forEach(w=>{let E=f.routes[w.route.id];!E||!E.hasLoader||(!g.some(C=>C.route.id===w.route.id)&&w.route.id in x&&d[w.route.id]?.shouldRevalidate||E.hasClientLoader?q=!0:N.add(w.route.id))}),N.size===0)return[];let j=r1(n,h,"data");return q&&N.size>0&&j.searchParams.set("_routes",s.filter(w=>N.has(w.route.id)).map(w=>w.route.id).join(",")),[j.pathname+j.search]},[h,x,o,f,g,s,n,d]),A=m.useMemo(()=>f1(y,f),[y,f]),R=v1(y);return m.createElement(m.Fragment,null,b.map(N=>m.createElement("link",{key:N,rel:"prefetch",as:"fetch",href:N,...i})),A.map(N=>m.createElement("link",{key:N,rel:"modulepreload",href:N,...i})),R.map(({key:N,link:q})=>m.createElement("link",{key:N,nonce:i.nonce,...q})))}function b1(...n){return s=>{n.forEach(i=>{typeof i=="function"?i(s):i!=null&&(i.current=s)})}}var Cx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Cx&&(window.__reactRouterVersion="7.9.6")}catch{}function S1({basename:n,children:s,window:i}){let o=m.useRef();o.current==null&&(o.current=rb({window:i,v5Compat:!0}));let f=o.current,[d,h]=m.useState({action:f.action,location:f.location}),x=m.useCallback(p=>{m.startTransition(()=>h(p))},[h]);return m.useLayoutEffect(()=>f.listen(x),[f,x]),m.createElement(Jb,{basename:n,children:s,location:d.location,navigationType:d.action,navigator:f})}var Ex=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kx=m.forwardRef(function({onClick:s,discover:i="render",prefetch:o="none",relative:f,reloadDocument:d,replace:h,state:x,target:p,to:g,preventScrollReset:y,viewTransition:b,...A},R){let{basename:N}=m.useContext(qn),q=typeof g=="string"&&Ex.test(g),j,w=!1;if(typeof g=="string"&&q&&(j=g,Cx))try{let B=new URL(window.location.href),U=g.startsWith("//")?new URL(B.protocol+g):new URL(g),Y=ia(U.pathname,N);U.origin===B.origin&&Y!=null?g=Y+U.search+U.hash:w=!0}catch{Sn(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=Ob(g,{relative:f}),[C,M,L]=x1(o,A),K=w1(g,{replace:h,state:x,target:p,preventScrollReset:y,relative:f,viewTransition:b});function _(B){s&&s(B),B.defaultPrevented||K(B)}let Q=m.createElement("a",{...A,...L,href:j||E,onClick:w||d?s:_,ref:b1(R,M),target:p,"data-discover":!q&&i==="render"?"true":void 0});return C&&!q?m.createElement(m.Fragment,null,Q,m.createElement(g1,{page:E})):Q});kx.displayName="Link";var A1=m.forwardRef(function({"aria-current":s="page",caseSensitive:i=!1,className:o="",end:f=!1,style:d,to:h,viewTransition:x,children:p,...g},y){let b=Ci(h,{relative:g.relative}),A=os(),R=m.useContext(ho),{navigator:N,basename:q}=m.useContext(qn),j=R!=null&&q1(b)&&x===!0,w=N.encodeLocation?N.encodeLocation(b).pathname:b.pathname,E=A.pathname,C=R&&R.navigation&&R.navigation.location?R.navigation.location.pathname:null;i||(E=E.toLowerCase(),C=C?C.toLowerCase():null,w=w.toLowerCase()),C&&q&&(C=ia(C,q)||C);const M=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let L=E===w||!f&&E.startsWith(w)&&E.charAt(M)==="/",K=C!=null&&(C===w||!f&&C.startsWith(w)&&C.charAt(w.length)==="/"),_={isActive:L,isPending:K,isTransitioning:j},Q=L?s:void 0,B;typeof o=="function"?B=o(_):B=[o,L?"active":null,K?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let U=typeof d=="function"?d(_):d;return m.createElement(kx,{...g,"aria-current":Q,className:B,ref:y,style:U,to:h,viewTransition:x},typeof p=="function"?p(_):p)});A1.displayName="NavLink";var j1=m.forwardRef(({discover:n="render",fetcherKey:s,navigate:i,reloadDocument:o,replace:f,state:d,method:h=Kr,action:x,onSubmit:p,relative:g,preventScrollReset:y,viewTransition:b,...A},R)=>{let N=k1(),q=M1(x,{relative:g}),j=h.toLowerCase()==="get"?"get":"post",w=typeof x=="string"&&Ex.test(x),E=C=>{if(p&&p(C),C.defaultPrevented)return;C.preventDefault();let M=C.nativeEvent.submitter,L=M?.getAttribute("formmethod")||h;N(M||C.currentTarget,{fetcherKey:s,method:L,navigate:i,replace:f,state:d,relative:g,preventScrollReset:y,viewTransition:b})};return m.createElement("form",{ref:R,method:j,action:q,onSubmit:o?p:E,...A,"data-discover":!w&&n==="render"?"true":void 0})});j1.displayName="Form";function N1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Mx(n){let s=m.useContext(rl);return ot(s,N1(n)),s}function w1(n,{target:s,replace:i,state:o,preventScrollReset:f,relative:d,viewTransition:h}={}){let x=Bb(),p=os(),g=Ci(n,{relative:d});return m.useCallback(y=>{if(a1(y,s)){y.preventDefault();let b=i!==void 0?i:pi(p)===pi(g);x(n,{replace:b,state:o,preventScrollReset:f,relative:d,viewTransition:h})}},[p,x,g,i,o,s,n,f,d,h])}var C1=0,E1=()=>`__${String(++C1)}__`;function k1(){let{router:n}=Mx("useSubmit"),{basename:s}=m.useContext(qn),i=Qb();return m.useCallback(async(o,f={})=>{let{action:d,method:h,encType:x,formData:p,body:g}=i1(o,s);if(f.navigate===!1){let y=f.fetcherKey||E1();await n.fetch(y,i,f.action||d,{preventScrollReset:f.preventScrollReset,formData:p,body:g,formMethod:f.method||h,formEncType:f.encType||x,flushSync:f.flushSync})}else await n.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:p,body:g,formMethod:f.method||h,formEncType:f.encType||x,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[n,s,i])}function M1(n,{relative:s}={}){let{basename:i}=m.useContext(qn),o=m.useContext(oa);ot(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...Ci(n||".",{relative:s})},h=os();if(n==null){d.search=h.search;let x=new URLSearchParams(d.search),p=x.getAll("index");if(p.some(y=>y==="")){x.delete("index"),p.filter(b=>b).forEach(b=>x.append("index",b));let y=x.toString();d.search=y?`?${y}`:""}}return(!n||n===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:la([i,d.pathname])),pi(d)}function q1(n,{relative:s}={}){let i=m.useContext(yx);ot(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Mx("useViewTransitionState"),f=Ci(n,{relative:s});if(!i.isTransitioning)return!1;let d=ia(i.currentLocation.pathname,o)||i.currentLocation.pathname,h=ia(i.nextLocation.pathname,o)||i.nextLocation.pathname;return so(f.pathname,h)!=null||so(f.pathname,d)!=null}const Mn=Object.create(null);Mn.open="0";Mn.close="1";Mn.ping="2";Mn.pong="3";Mn.message="4";Mn.upgrade="5";Mn.noop="6";const Ir=Object.create(null);Object.keys(Mn).forEach(n=>{Ir[Mn[n]]=n});const xf={type:"error",data:"parser error"},qx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Rx=typeof ArrayBuffer=="function",Tx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,zf=({type:n,data:s},i,o)=>qx&&s instanceof Blob?i?o(s):y0(s,o):Rx&&(s instanceof ArrayBuffer||Tx(s))?i?o(s):y0(new Blob([s]),o):o(Mn[n]+(s||"")),y0=(n,s)=>{const i=new FileReader;return i.onload=function(){const o=i.result.split(",")[1];s("b"+(o||""))},i.readAsDataURL(n)};function b0(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Yu;function R1(n,s){if(qx&&n.data instanceof Blob)return n.data.arrayBuffer().then(b0).then(s);if(Rx&&(n.data instanceof ArrayBuffer||Tx(n.data)))return s(b0(n.data));zf(n,!1,i=>{Yu||(Yu=new TextEncoder),s(Yu.encode(i))})}const S0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ui=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<S0.length;n++)ui[S0.charCodeAt(n)]=n;const T1=n=>{let s=n.length*.75,i=n.length,o,f=0,d,h,x,p;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);const g=new ArrayBuffer(s),y=new Uint8Array(g);for(o=0;o<i;o+=4)d=ui[n.charCodeAt(o)],h=ui[n.charCodeAt(o+1)],x=ui[n.charCodeAt(o+2)],p=ui[n.charCodeAt(o+3)],y[f++]=d<<2|h>>4,y[f++]=(h&15)<<4|x>>2,y[f++]=(x&3)<<6|p&63;return g},D1=typeof ArrayBuffer=="function",Uf=(n,s)=>{if(typeof n!="string")return{type:"message",data:Dx(n,s)};const i=n.charAt(0);return i==="b"?{type:"message",data:_1(n.substring(1),s)}:Ir[i]?n.length>1?{type:Ir[i],data:n.substring(1)}:{type:Ir[i]}:xf},_1=(n,s)=>{if(D1){const i=T1(n);return Dx(i,s)}else return{base64:!0,data:n}},Dx=(n,s)=>{switch(s){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},_x="",O1=(n,s)=>{const i=n.length,o=new Array(i);let f=0;n.forEach((d,h)=>{zf(d,!1,x=>{o[h]=x,++f===i&&s(o.join(_x))})})},B1=(n,s)=>{const i=n.split(_x),o=[];for(let f=0;f<i.length;f++){const d=Uf(i[f],s);if(o.push(d),d.type==="error")break}return o};function L1(){return new TransformStream({transform(n,s){R1(n,i=>{const o=i.length;let f;if(o<126)f=new Uint8Array(1),new DataView(f.buffer).setUint8(0,o);else if(o<65536){f=new Uint8Array(3);const d=new DataView(f.buffer);d.setUint8(0,126),d.setUint16(1,o)}else{f=new Uint8Array(9);const d=new DataView(f.buffer);d.setUint8(0,127),d.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(f[0]|=128),s.enqueue(f),s.enqueue(i)})}})}let Fu;function $r(n){return n.reduce((s,i)=>s+i.length,0)}function Gr(n,s){if(n[0].length===s)return n.shift();const i=new Uint8Array(s);let o=0;for(let f=0;f<s;f++)i[f]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),i}function z1(n,s){Fu||(Fu=new TextDecoder);const i=[];let o=0,f=-1,d=!1;return new TransformStream({transform(h,x){for(i.push(h);;){if(o===0){if($r(i)<1)break;const p=Gr(i,1);d=(p[0]&128)===128,f=p[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if($r(i)<2)break;const p=Gr(i,2);f=new DataView(p.buffer,p.byteOffset,p.length).getUint16(0),o=3}else if(o===2){if($r(i)<8)break;const p=Gr(i,8),g=new DataView(p.buffer,p.byteOffset,p.length),y=g.getUint32(0);if(y>Math.pow(2,21)-1){x.enqueue(xf);break}f=y*Math.pow(2,32)+g.getUint32(4),o=3}else{if($r(i)<f)break;const p=Gr(i,f);x.enqueue(Uf(d?p:Fu.decode(p),s)),o=0}if(f===0||f>n){x.enqueue(xf);break}}}})}const Ox=4;function St(n){if(n)return U1(n)}function U1(n){for(var s in St.prototype)n[s]=St.prototype[s];return n}St.prototype.on=St.prototype.addEventListener=function(n,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(s),this};St.prototype.once=function(n,s){function i(){this.off(n,i),s.apply(this,arguments)}return i.fn=s,this.on(n,i),this};St.prototype.off=St.prototype.removeListener=St.prototype.removeAllListeners=St.prototype.removeEventListener=function(n,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,f=0;f<i.length;f++)if(o=i[f],o===s||o.fn===s){i.splice(f,1);break}return i.length===0&&delete this._callbacks["$"+n],this};St.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),i=this._callbacks["$"+n],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,f=i.length;o<f;++o)i[o].apply(this,s)}return this};St.prototype.emitReserved=St.prototype.emit;St.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};St.prototype.hasListeners=function(n){return!!this.listeners(n).length};const xo=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,i)=>i(s,0),hn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),H1="arraybuffer";function Bx(n,...s){return s.reduce((i,o)=>(n.hasOwnProperty(o)&&(i[o]=n[o]),i),{})}const V1=hn.setTimeout,$1=hn.clearTimeout;function go(n,s){s.useNativeTimers?(n.setTimeoutFn=V1.bind(hn),n.clearTimeoutFn=$1.bind(hn)):(n.setTimeoutFn=hn.setTimeout.bind(hn),n.clearTimeoutFn=hn.clearTimeout.bind(hn))}const G1=1.33;function Y1(n){return typeof n=="string"?F1(n):Math.ceil((n.byteLength||n.size)*G1)}function F1(n){let s=0,i=0;for(let o=0,f=n.length;o<f;o++)s=n.charCodeAt(o),s<128?i+=1:s<2048?i+=2:s<55296||s>=57344?i+=3:(o++,i+=4);return i}function Lx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function X1(n){let s="";for(let i in n)n.hasOwnProperty(i)&&(s.length&&(s+="&"),s+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return s}function Q1(n){let s={},i=n.split("&");for(let o=0,f=i.length;o<f;o++){let d=i[o].split("=");s[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return s}class K1 extends Error{constructor(s,i,o){super(s),this.description=i,this.context=o,this.type="TransportError"}}class Hf extends St{constructor(s){super(),this.writable=!1,go(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,i,o){return super.emitReserved("error",new K1(s,i,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const i=Uf(s,this.socket.binaryType);this.onPacket(i)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,i={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const s=this.opts.hostname;return s.indexOf(":")===-1?s:"["+s+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(s){const i=X1(s);return i.length?"?"+i:""}}class Z1 extends Hf{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const i=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||i()})),this.writable||(o++,this.once("drain",function(){--o||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const i=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};B1(s,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const s=()=>{this.write([{type:"close"}])};this.readyState==="open"?s():this.once("open",s)}write(s){this.writable=!1,O1(s,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=Lx()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(s,i)}}let zx=!1;try{zx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const I1=zx;function J1(){}class P1 extends Z1{constructor(s){if(super(s),typeof location<"u"){const i=location.protocol==="https:";let o=location.port;o||(o=i?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||o!==s.port}}doWrite(s,i){const o=this.request({method:"POST",data:s});o.on("success",i),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(i,o)=>{this.onError("xhr poll error",i,o)}),this.pollXhr=s}}class kn extends St{constructor(s,i,o){super(),this.createRequest=s,go(this,o),this._opts=o,this._method=o.method||"GET",this._uri=i,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var s;const i=Bx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(i);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let f in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(f)&&o.setRequestHeader(f,this._opts.extraHeaders[f])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var f;o.readyState===3&&((f=this._opts.cookieJar)===null||f===void 0||f.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(f){this.setTimeoutFn(()=>{this._onError(f)},0);return}typeof document<"u"&&(this._index=kn.requestsCount++,kn.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=J1,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete kn.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()}}kn.requestsCount=0;kn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",A0);else if(typeof addEventListener=="function"){const n="onpagehide"in hn?"pagehide":"unload";addEventListener(n,A0,!1)}}function A0(){for(let n in kn.requests)kn.requests.hasOwnProperty(n)&&kn.requests[n].abort()}const W1=(function(){const n=Ux({xdomain:!1});return n&&n.responseType!==null})();class eS extends P1{constructor(s){super(s);const i=s&&s.forceBase64;this.supportsBinary=W1&&!i}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new kn(Ux,this.uri(),s)}}function Ux(n){const s=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||I1))return new XMLHttpRequest}catch{}if(!s)try{return new hn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Hx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class tS extends Hf{get name(){return"websocket"}doOpen(){const s=this.uri(),i=this.opts.protocols,o=Hx?{}:Bx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(s,i,o)}catch(f){return this.emitReserved("error",f)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=s=>this.onClose({description:"websocket connection closed",context:s}),this.ws.onmessage=s=>this.onData(s.data),this.ws.onerror=s=>this.onError("websocket error",s)}write(s){this.writable=!1;for(let i=0;i<s.length;i++){const o=s[i],f=i===s.length-1;zf(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&xo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const s=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=Lx()),this.supportsBinary||(i.b64=1),this.createUri(s,i)}}const Xu=hn.WebSocket||hn.MozWebSocket;class nS extends tS{createSocket(s,i,o){return Hx?new Xu(s,i,o):i?new Xu(s,i):new Xu(s)}doWrite(s,i){this.ws.send(i)}}class aS extends Hf{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const i=z1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=s.readable.pipeThrough(i).getReader(),f=L1();f.readable.pipeTo(s.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:x,value:p})=>{x||(this.onPacket(p),d())}).catch(x=>{})};d();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let i=0;i<s.length;i++){const o=s[i],f=i===s.length-1;this._writer.write(o).then(()=>{f&&xo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const sS={websocket:nS,webtransport:aS,polling:eS},lS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,iS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function gf(n){if(n.length>8e3)throw"URI too long";const s=n,i=n.indexOf("["),o=n.indexOf("]");i!=-1&&o!=-1&&(n=n.substring(0,i)+n.substring(i,o).replace(/:/g,";")+n.substring(o,n.length));let f=lS.exec(n||""),d={},h=14;for(;h--;)d[iS[h]]=f[h]||"";return i!=-1&&o!=-1&&(d.source=s,d.host=d.host.substring(1,d.host.length-1).replace(/;/g,":"),d.authority=d.authority.replace("[","").replace("]","").replace(/;/g,":"),d.ipv6uri=!0),d.pathNames=rS(d,d.path),d.queryKey=oS(d,d.query),d}function rS(n,s){const i=/\/{2,9}/g,o=s.replace(i,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&o.splice(0,1),s.slice(-1)=="/"&&o.splice(o.length-1,1),o}function oS(n,s){const i={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(i[f]=d)}),i}const vf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Jr=[];vf&&addEventListener("offline",()=>{Jr.forEach(n=>n())},!1);class _a extends St{constructor(s,i){if(super(),this.binaryType=H1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(i=s,s=null),s){const o=gf(s);i.hostname=o.host,i.secure=o.protocol==="https"||o.protocol==="wss",i.port=o.port,o.query&&(i.query=o.query)}else i.host&&(i.hostname=gf(i.host).host);go(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(o=>{const f=o.prototype.name;this.transports.push(f),this._transportsByName[f]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Q1(this.opts.query)),vf&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Jr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const i=Object.assign({},this.opts.query);i.EIO=Ox,i.transport=s,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[s]);return new this._transportsByName[s](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&_a.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(s);i.open(),this.setTransport(i)}setTransport(s){this.transport&&this.transport.removeAllListeners(),this.transport=s,s.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",_a.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=s.data,this._onError(i);break;case"message":this.emitReserved("data",s.data),this.emitReserved("message",s.data);break}}onHandshake(s){this.emitReserved("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this._pingInterval=s.pingInterval,this._pingTimeout=s.pingTimeout,this._maxPayload=s.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const s=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+s,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},s),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const s=this._getWritablePackets();this.transport.send(s),this._prevBufferLen=s.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let o=0;o<this.writeBuffer.length;o++){const f=this.writeBuffer[o].data;if(f&&(i+=Y1(f)),o>0&&i>this._maxPayload)return this.writeBuffer.slice(0,o);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,xo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,i,o){return this._sendPacket("message",s,i,o),this}send(s,i,o){return this._sendPacket("message",s,i,o),this}_sendPacket(s,i,o,f){if(typeof i=="function"&&(f=i,i=void 0),typeof o=="function"&&(f=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const d={type:s,data:i,options:o};this.emitReserved("packetCreate",d),this.writeBuffer.push(d),f&&this.once("flush",f),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),s()},o=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():s()}):this.upgrading?o():s()),this}_onError(s){if(_a.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),vf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Jr.indexOf(this._offlineEventListener);o!==-1&&Jr.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,i),this.writeBuffer=[],this._prevBufferLen=0}}}_a.protocol=Ox;class cS extends _a{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let i=this.createTransport(s),o=!1;_a.priorWebsocketSuccess=!1;const f=()=>{o||(i.send([{type:"ping",data:"probe"}]),i.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;_a.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const A=new Error("probe error");A.transport=i.name,this.emitReserved("upgradeError",A)}}))};function d(){o||(o=!0,y(),i.close(),i=null)}const h=b=>{const A=new Error("probe error: "+b);A.transport=i.name,d(),this.emitReserved("upgradeError",A)};function x(){h("transport closed")}function p(){h("socket closed")}function g(b){i&&b.name!==i.name&&d()}const y=()=>{i.removeListener("open",f),i.removeListener("error",h),i.removeListener("close",x),this.off("close",p),this.off("upgrading",g)};i.once("open",f),i.once("error",h),i.once("close",x),this.once("close",p),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{o||i.open()},200):i.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const i=[];for(let o=0;o<s.length;o++)~this.transports.indexOf(s[o])&&i.push(s[o]);return i}}let uS=class extends cS{constructor(s,i={}){const o=typeof s=="object"?s:i;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(f=>sS[f]).filter(f=>!!f)),super(s,o)}};function fS(n,s="",i){let o=n;i=i||typeof location<"u"&&location,n==null&&(n=i.protocol+"//"+i.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=i.protocol+n:n=i.host+n),/^(https?|wss?):\/\//.test(n)||(typeof i<"u"?n=i.protocol+"//"+n:n="https://"+n),o=gf(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const d=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+d+":"+o.port+s,o.href=o.protocol+"://"+d+(i&&i.port===o.port?"":":"+o.port),o}const dS=typeof ArrayBuffer=="function",mS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Vx=Object.prototype.toString,hS=typeof Blob=="function"||typeof Blob<"u"&&Vx.call(Blob)==="[object BlobConstructor]",pS=typeof File=="function"||typeof File<"u"&&Vx.call(File)==="[object FileConstructor]";function Vf(n){return dS&&(n instanceof ArrayBuffer||mS(n))||hS&&n instanceof Blob||pS&&n instanceof File}function Pr(n,s){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let i=0,o=n.length;i<o;i++)if(Pr(n[i]))return!0;return!1}if(Vf(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Pr(n.toJSON(),!0);for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&Pr(n[i]))return!0;return!1}function xS(n){const s=[],i=n.data,o=n;return o.data=yf(i,s),o.attachments=s.length,{packet:o,buffers:s}}function yf(n,s){if(!n)return n;if(Vf(n)){const i={_placeholder:!0,num:s.length};return s.push(n),i}else if(Array.isArray(n)){const i=new Array(n.length);for(let o=0;o<n.length;o++)i[o]=yf(n[o],s);return i}else if(typeof n=="object"&&!(n instanceof Date)){const i={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=yf(n[o],s));return i}return n}function gS(n,s){return n.data=bf(n.data,s),delete n.attachments,n}function bf(n,s){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<s.length)return s[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let i=0;i<n.length;i++)n[i]=bf(n[i],s);else if(typeof n=="object")for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=bf(n[i],s));return n}const vS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],yS=5;var Be;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Be||(Be={}));class bS{constructor(s){this.replacer=s}encode(s){return(s.type===Be.EVENT||s.type===Be.ACK)&&Pr(s)?this.encodeAsBinary({type:s.type===Be.EVENT?Be.BINARY_EVENT:Be.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let i=""+s.type;return(s.type===Be.BINARY_EVENT||s.type===Be.BINARY_ACK)&&(i+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(i+=s.nsp+","),s.id!=null&&(i+=s.id),s.data!=null&&(i+=JSON.stringify(s.data,this.replacer)),i}encodeAsBinary(s){const i=xS(s),o=this.encodeAsString(i.packet),f=i.buffers;return f.unshift(o),f}}function j0(n){return Object.prototype.toString.call(n)==="[object Object]"}class $f extends St{constructor(s){super(),this.reviver=s}add(s){let i;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(s);const o=i.type===Be.BINARY_EVENT;o||i.type===Be.BINARY_ACK?(i.type=o?Be.EVENT:Be.ACK,this.reconstructor=new SS(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Vf(s)||s.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(s),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let i=0;const o={type:Number(s.charAt(0))};if(Be[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Be.BINARY_EVENT||o.type===Be.BINARY_ACK){const d=i+1;for(;s.charAt(++i)!=="-"&&i!=s.length;);const h=s.substring(d,i);if(h!=Number(h)||s.charAt(i)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(s.charAt(i+1)==="/"){const d=i+1;for(;++i&&!(s.charAt(i)===","||i===s.length););o.nsp=s.substring(d,i)}else o.nsp="/";const f=s.charAt(i+1);if(f!==""&&Number(f)==f){const d=i+1;for(;++i;){const h=s.charAt(i);if(h==null||Number(h)!=h){--i;break}if(i===s.length)break}o.id=Number(s.substring(d,i+1))}if(s.charAt(++i)){const d=this.tryParse(s.substr(i));if($f.isPayloadValid(o.type,d))o.data=d;else throw new Error("invalid payload")}return o}tryParse(s){try{return JSON.parse(s,this.reviver)}catch{return!1}}static isPayloadValid(s,i){switch(s){case Be.CONNECT:return j0(i);case Be.DISCONNECT:return i===void 0;case Be.CONNECT_ERROR:return typeof i=="string"||j0(i);case Be.EVENT:case Be.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&vS.indexOf(i[0])===-1);case Be.ACK:case Be.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class SS{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const i=gS(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const AS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:$f,Encoder:bS,get PacketType(){return Be},protocol:yS},Symbol.toStringTag,{value:"Module"}));function yn(n,s,i){return n.on(s,i),function(){n.off(s,i)}}const jS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class $x extends St{constructor(s,i,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=s,this.nsp=i,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const s=this.io;this.subs=[yn(s,"open",this.onopen.bind(this)),yn(s,"packet",this.onpacket.bind(this)),yn(s,"error",this.onerror.bind(this)),yn(s,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...i){var o,f,d;if(jS.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(i.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const h={type:Be.EVENT,data:i};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const y=this.ids++,b=i.pop();this._registerAckCallback(y,b),h.id=y}const x=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,p=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!x||(p?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(s,i){var o;const f=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(f===void 0){this.acks[s]=i;return}const d=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let x=0;x<this.sendBuffer.length;x++)this.sendBuffer[x].id===s&&this.sendBuffer.splice(x,1);i.call(this,new Error("operation has timed out"))},f),h=(...x)=>{this.io.clearTimeoutFn(d),i.apply(this,x)};h.withError=!0,this.acks[s]=h}emitWithAck(s,...i){return new Promise((o,f)=>{const d=(h,x)=>h?f(h):o(x);d.withError=!0,i.push(d),this.emit(s,...i)})}_addToQueue(s){let i;typeof s[s.length-1]=="function"&&(i=s.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((f,...d)=>o!==this._queue[0]?void 0:(f!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(f)):(this._queue.shift(),i&&i(null,...d)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!s||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:Be.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},s):s})}onerror(s){this.connected||this.emitReserved("connect_error",s)}onclose(s,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(s=>{if(!this.sendBuffer.some(o=>String(o.id)===s)){const o=this.acks[s];delete this.acks[s],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(s){if(s.nsp===this.nsp)switch(s.type){case Be.CONNECT:s.data&&s.data.sid?this.onconnect(s.data.sid,s.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Be.EVENT:case Be.BINARY_EVENT:this.onevent(s);break;case Be.ACK:case Be.BINARY_ACK:this.onack(s);break;case Be.DISCONNECT:this.ondisconnect();break;case Be.CONNECT_ERROR:this.destroy();const o=new Error(s.data.message);o.data=s.data.data,this.emitReserved("connect_error",o);break}}onevent(s){const i=s.data||[];s.id!=null&&i.push(this.ack(s.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const o of i)o.apply(this,s)}super.emit.apply(this,s),this._pid&&s.length&&typeof s[s.length-1]=="string"&&(this._lastOffset=s[s.length-1])}ack(s){const i=this;let o=!1;return function(...f){o||(o=!0,i.packet({type:Be.ACK,id:s,data:f}))}}onack(s){const i=this.acks[s.id];typeof i=="function"&&(delete this.acks[s.id],i.withError&&s.data.unshift(null),i.apply(this,s.data))}onconnect(s,i){this.id=s,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(s=>this.emitEvent(s)),this.receiveBuffer=[],this.sendBuffer.forEach(s=>{this.notifyOutgoingListeners(s),this.packet(s)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(s=>s()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Be.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(s){return this.flags.compress=s,this}get volatile(){return this.flags.volatile=!0,this}timeout(s){return this.flags.timeout=s,this}onAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(s),this}prependAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(s),this}offAny(s){if(!this._anyListeners)return this;if(s){const i=this._anyListeners;for(let o=0;o<i.length;o++)if(s===i[o])return i.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(s),this}prependAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(s),this}offAnyOutgoing(s){if(!this._anyOutgoingListeners)return this;if(s){const i=this._anyOutgoingListeners;for(let o=0;o<i.length;o++)if(s===i[o])return i.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const o of i)o.apply(this,s.data)}}}function ol(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}ol.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),i=Math.floor(s*this.jitter*n);n=(Math.floor(s*10)&1)==0?n-i:n+i}return Math.min(n,this.max)|0};ol.prototype.reset=function(){this.attempts=0};ol.prototype.setMin=function(n){this.ms=n};ol.prototype.setMax=function(n){this.max=n};ol.prototype.setJitter=function(n){this.jitter=n};class Sf extends St{constructor(s,i){var o;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(i=s,s=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,go(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((o=i.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new ol({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=s;const f=i.parser||AS;this.encoder=new f.Encoder,this.decoder=new f.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(s){return arguments.length?(this._reconnection=!!s,s||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(s){return s===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=s,this)}reconnectionDelay(s){var i;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(i=this.backoff)===null||i===void 0||i.setMin(s),this)}randomizationFactor(s){var i;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(i=this.backoff)===null||i===void 0||i.setJitter(s),this)}reconnectionDelayMax(s){var i;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(i=this.backoff)===null||i===void 0||i.setMax(s),this)}timeout(s){return arguments.length?(this._timeout=s,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(s){if(~this._readyState.indexOf("open"))return this;this.engine=new uS(this.uri,this.opts);const i=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=yn(i,"open",function(){o.onopen(),s&&s()}),d=x=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",x),s?s(x):this.maybeReconnectOnOpen()},h=yn(i,"error",d);if(this._timeout!==!1){const x=this._timeout,p=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),i.close()},x);this.opts.autoUnref&&p.unref(),this.subs.push(()=>{this.clearTimeoutFn(p)})}return this.subs.push(f),this.subs.push(h),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(yn(s,"ping",this.onping.bind(this)),yn(s,"data",this.ondata.bind(this)),yn(s,"error",this.onerror.bind(this)),yn(s,"close",this.onclose.bind(this)),yn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(i){this.onclose("parse error",i)}}ondecoded(s){xo(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,i){let o=this.nsps[s];return o?this._autoConnect&&!o.active&&o.connect():(o=new $x(this,s,i),this.nsps[s]=o),o}_destroy(s){const i=Object.keys(this.nsps);for(const o of i)if(this.nsps[o].active)return;this._close()}_packet(s){const i=this.encoder.encode(s);for(let o=0;o<i.length;o++)this.engine.write(i[o],s.options)}cleanup(){this.subs.forEach(s=>s()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,i){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(f=>{f?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",f)):s.onreconnect()}))},i);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const li={};function Wr(n,s){typeof n=="object"&&(s=n,n=void 0),s=s||{};const i=fS(n,s.path||"/socket.io"),o=i.source,f=i.id,d=i.path,h=li[f]&&d in li[f].nsps,x=s.forceNew||s["force new connection"]||s.multiplex===!1||h;let p;return x?p=new Sf(o,s):(li[f]||(li[f]=new Sf(o,s)),p=li[f]),i.query&&!s.query&&(s.query=i.queryKey),p.socket(i.path,s)}Object.assign(Wr,{Manager:Sf,Socket:$x,io:Wr,connect:Wr});const Gx="roverSettings",NS=3600*24*365;function wS(n){try{const s=decodeURIComponent(n??"");return JSON.parse(s)}catch(s){return console.warn("Failed to parse settings cookie",s),null}}function Af(){if(typeof document>"u")return{};const n=`${Gx}=`,s=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!s)return{};const i=s.substring(n.length);return wS(i)??{}}function N0(n){if(typeof document>"u")return!1;try{const s=encodeURIComponent(JSON.stringify(n??{})),i=`${Gx}=${s}; path=/; max-age=${NS}; samesite=strict`;return document.cookie=i,!0}catch(s){return console.warn("Failed to write settings cookie",s),!1}}const Yx=window.location.origin;console.info("[socket] connecting to",Yx);const CS=Af(),ES=CS?.page?.connectionTransport||"websocket",kS=ES==="polling"?["polling"]:["websocket","polling"],Gf=Wr(Yx,{transports:kS,timeout:15e3});Gf.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const Fx=m.createContext(Gf),MS=({children:n})=>r.jsx(Fx.Provider,{value:Gf,children:n}),Rn=()=>m.useContext(Fx),Xx=m.createContext({connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,identifySession:async()=>{},login:async()=>{},setRole:async()=>{},requestControl:async()=>{},releaseControl:async()=>{},subscribeAll:async()=>{},homeAssistantToggle:async()=>{},homeAssistantSetState:async()=>{},homeAssistantSetLightColor:async()=>{},setNickname:async()=>{},requestVerification:async()=>{},requestPrivateRoverAccess:async()=>{},triggerReplay:async()=>{},setCommunityGoal:async()=>{},setAdminReason:async()=>{},rebootRover:async()=>{},rebootServer:async()=>{},playUploadedAudio:async()=>{},stopUploadedAudio:async()=>{},startMicWhip:async()=>{},readyMicWhip:async()=>{},stopMicWhip:async()=>{},setAudioLevels:async()=>{},setPrivateSafety:async()=>{},llmControl:async()=>{}});function qS(n){return m.useCallback((s,i={})=>new Promise((o,f)=>{n.emit(s,i,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[n])}function RS({children:n}){const s=Rn(),i=qS(s),[o,f]=m.useState(null),[d,h]=m.useState([]),[x,p]=m.useState([]),[g,y]=m.useState(null),[b,A]=m.useState(null),[R,N]=m.useState([]),[q,j]=m.useState(s.connected);m.useEffect(()=>{const C=()=>j(!0),M=()=>j(!1);return s.on("connect",C),s.on("disconnect",M),()=>{s.off("connect",C),s.off("disconnect",M)}},[s]),m.useEffect(()=>{function C(B){f(B)}function M(B=[]){h(B)}function L(B){h(U=>[...U.slice(-199),B])}function K(B=[]){p(B)}function _(B){p(U=>[...U.slice(-199),B])}function Q(B=null){const U=B&&typeof B=="object"?B:null,Y=U?.debug?.status&&typeof U.debug.status=="object"?U.debug.status:null;y(U),A(Y)}return s.on("session:sync",C),s.on("log:init",M),s.on("log:entry",L),s.on("adminlog:init",K),s.on("adminlog:entry",_),s.on("llm:state",Q),s.on("alert:new",(B={})=>{N(U=>[...U.slice(-49),{...B,receivedAt:Date.now()}])}),()=>{s.off("session:sync",C),s.off("log:init",M),s.off("log:entry",L),s.off("adminlog:init",K),s.off("adminlog:entry",_),s.off("llm:state",Q),s.off("alert:new")}},[s]);const w=m.useMemo(()=>({login:(C,M)=>i("auth:login",{username:C,password:M}),identifySession:({cookieUserId:C,nickname:M}={})=>i("session:identify",{cookieUserId:C,nickname:M}),setRole:C=>i("session:setRole",{role:C}),requestControl:(C,M={})=>i("session:requestControl",{roverId:C,...M}),releaseControl:C=>i("session:releaseControl",{roverId:C}),subscribeAll:()=>i("session:subscribeAll"),lockRover:(C,M)=>i("session:lockRover",{roverId:C,locked:M}),setMode:C=>i("setMode",{mode:C}),homeAssistantToggle:C=>i("homeAssistant:toggle",{entityId:C}),homeAssistantSetState:(C,M)=>i("homeAssistant:setState",{entityId:C,state:M}),homeAssistantSetLightColor:(C,M)=>i("homeAssistant:lightColor",{entityId:C,rgbColor:M}),setNickname:C=>i("nickname:set",{nickname:C}),requestVerification:()=>i("verification:request"),requestPrivateRoverAccess:C=>i("session:privateRover:requestAccess",{roverId:C}),triggerReplay:(C=[])=>i("replay:trigger",{sources:C}),setCommunityGoal:C=>i("communityGoal:set",{text:C}),setAdminReason:C=>i("adminReason:set",{text:C}),rebootRover:C=>i("command",{roverId:C,type:"reboot",data:{reboot:{}}}),rebootServer:()=>i("server:reboot"),playUploadedAudio:({roverId:C,name:M,mime:L,dataBase64:K})=>i("audio:uploadPlay",{roverId:C,name:M,mime:L,dataBase64:K}),stopUploadedAudio:C=>i("audio:uploadStop",{roverId:C}),startMicWhip:C=>i("audio:micWhipStart",{roverId:C}),readyMicWhip:C=>i("audio:micWhipReady",{roverId:C}),stopMicWhip:C=>i("audio:micWhipStop",{roverId:C}),setAudioLevels:(C={})=>i("audioLevels:set",C),setPrivateSafety:(C,M={})=>i("session:privateSafety:set",{roverId:C,safety:M}),llmControl:(C,M={})=>i("llm:control",{controls:{action:C,...M}}),pushAlert:C=>N(M=>[...M.slice(-49),{...C,receivedAt:Date.now(),id:C.id||Math.random().toString(36).slice(2)}])}),[i]),E=m.useMemo(()=>({connected:q,session:o,logs:d,adminLogs:x,llmCommentaryState:g,llmCommentaryStatus:b,alerts:R,...w}),[w,x,R,q,g,b,d,o]);return r.jsx(Xx.Provider,{value:E,children:n})}function ze(){return m.useContext(Xx)}const Qx=m.createContext({frames:{}});function TS({children:n}){const s=Rn(),[i,o]=m.useState({});m.useEffect(()=>{function d({roverId:h,sensors:x={},frame:p={}}){h&&o(g=>({...g,[h]:{roverId:h,sensors:x,raw:p?.data||null,receivedAt:Date.now()}}))}return s.on("sensorFrame",d),()=>{s.off("sensorFrame",d)}},[s]);const f=m.useMemo(()=>({frames:i}),[i]);return r.jsx(Qx.Provider,{value:f,children:n})}function Yf(){return m.useContext(Qx).frames}function cl(n){const s=Yf();return n?s[n]??null:null}const DS=650,_S={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 Qu(n){if(typeof n!="number"||n<=0)return null;const s=_S[n];return s?{code:n,...s}:null}function OS(n,s={}){const i=s.holdMs||DS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,h]=m.useState(0);return m.useEffect(()=>{const x=setInterval(()=>h(Date.now()),Math.max(i/2,100));return()=>clearInterval(x)},[i]),m.useEffect(()=>{const x=Date.now(),p=Qu(n?.infraredCharacterLeft),g=Qu(n?.infraredCharacterRight),y=Qu(n?.infraredCharacterOmni);!p&&!g&&!y||f(b=>({left:p?{...p,ts:x}:b.left,right:g?{...g,ts:x}:b.right,omni:y?{...y,ts:x}:b.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useEffect(()=>{const{left:x,right:p,omni:g}=o;if(!(x?.ts||p?.ts||g?.ts))return;const b=new Date().toISOString();console.debug("[DockIR]",b,{left:x?.code??0,omni:g?.code??0,right:p?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const x=Date.now(),p=j=>{if(!j)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const w=x-j.ts,E=w<=i;return{active:E,age:w,code:j.code,red:!!(j.red&&E),green:!!(j.green&&E),force:!!(j.force&&E)}},g=p(o.left),y=p(o.right),b=p(o.omni),A=g.force||y.force||b.force,R=g.active||y.active||b.active,N=g.active&&!y.active?"right":y.active&&!g.active?"left":"center",q=(y.active?1:0)-(g.active?1:0);return{visible:R,forceDetected:A,left:g,right:y,omni:b,bias:N,balance:Math.max(-1,Math.min(1,q))}},[o.left,o.right,o.omni,i,d])}function BS(){const{connected:n,session:s}=ze(),i=s?.assignment?.roverId,o=cl(i),f=o?.sensors||{},d=OS(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,x=f.currentMa!=null?`${f.currentMa} mA`:null,p=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,g=f.batteryChargeMah,y=f.batteryCapacityMah;o?.receivedAt&&new Date(o.receivedAt).toLocaleTimeString();const b=o?.raw?o.raw:null,A=i?s?.activeDrivers?.[i]:null;return m.useMemo(()=>i?A?A===s?.socketId?"You":(s?.users||[]).find(N=>N.socketId===A)?.nickname||A.slice(0,6):"Available":"n/a",[A,i,s?.socketId,s?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[i?o?r.jsxs(r.Fragment,{children:[r.jsx(LS,{sensors:f,voltage:h,current:x,batteryTemp:p,charge:g,capacity:y}),r.jsx(zS,{sensors:f,dockState:d})]}):r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):r.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),b&&r.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:b})]})}function LS({sensors:n,voltage:s,current:i,batteryTemp:o,charge:f,capacity:d}){const h=f!=null&&d?`${Math.round(f/d*100)}`:"--",x=n?.oiMode?.label||"--",p=n?.chargingSources?.homeBase?"Yes":"No",g=n?.chargingState?.label||"--";return r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[r.jsx(ta,{label:"Voltage",value:s??"--"}),r.jsx(ta,{label:"Current",value:i??"--"}),r.jsx(ta,{label:"Battery temp",value:o??"--"}),r.jsx(ta,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(ta,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(ta,{label:"Charge",value:h}),r.jsx(ta,{label:"OI mode",value:x}),r.jsx(ta,{label:"Docked",value:p}),r.jsx(ta,{label:"Charging state",value:g})]})}function ta({label:n,value:s}){return r.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[r.jsx("span",{className:"text-slate-400",children:n}),r.jsx("span",{className:"text-slate-100",children:s})]})}function zS({sensors:n,dockState:s}){const i=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},f=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],d=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],h=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs(Is,{title:"Dock IR",children:[r.jsx(US,{sensors:n}),r.jsx(HS,{state:s})]}),r.jsxs(Is,{title:"Bumps & drops",children:[r.jsx(na,{label:"Bump L",value:r.jsx(ii,{active:i.bumpLeft})}),r.jsx(na,{label:"Bump R",value:r.jsx(ii,{active:i.bumpRight})}),r.jsx(na,{label:"Wheel drop L",value:r.jsx(ii,{active:i.wheelDropLeft,tone:"amber"})}),r.jsx(na,{label:"Wheel drop R",value:r.jsx(ii,{active:i.wheelDropRight,tone:"amber"})})]}),r.jsx(Is,{title:"Light bumps (raw)",children:f.map(x=>r.jsx(na,{label:x.label,value:ri(x.value)},x.label))}),r.jsx(Is,{title:"Cliff sensors",children:d.map(x=>r.jsx(na,{label:x.label,value:`${ri(x.value)} · ${x.active?"bool: true":"bool: false"}`},x.label))}),r.jsx(Is,{title:"Currents",children:h.map(x=>r.jsx(na,{label:x.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:ri(x.value,"mA")}),x.over?r.jsx(ii,{active:!0,tone:"red",label:"over"}):null]})},x.label))}),r.jsxs(Is,{title:"Dirt detect",children:[r.jsx(na,{label:"Left",value:ri(n?.dirtDetectLeft)}),r.jsx(na,{label:"Right",value:ri(n?.dirtDetect)})]})]})}function Is({title:n,children:s}){return r.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[r.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:n}),r.jsx("div",{className:"space-y-0.5",children:s})]})}function na({label:n,value:s}){return r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-300",children:n}),r.jsx("span",{className:"text-slate-100",children:s})]})}function ii({active:n,tone:s="green",label:i}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=s==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":s==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:i||(n?"true":"false")})}function ri(n,s){return n==null||Number.isNaN(n)?"--":s?`${n} ${s}`:n}function US({sensors:n}){const s=n?.infraredCharacterLeft,i=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,f=d=>r.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${d?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:d||"--"});return r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"L"}),f(s)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"O"}),f(o)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"R"}),f(i)]})]})}function HS({state:n}){if(!n)return null;const s=o=>{const f=[];return o?.red&&f.push("R"),o?.green&&f.push("G"),o?.force&&f.push("F"),f.length?f.join(""):"none"},i=o=>o?.age!=null?`${o.age}ms`:"--";return r.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Left: ${n.left.code??"--"} (${s(n.left)}) · age ${i(n.left)}`}),r.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${s(n.omni)}) · age ${i(n.omni)}`}),r.jsx("div",{children:`Right: ${n.right.code??"--"} (${s(n.right)}) · age ${i(n.right)}`})]})}const Kx=m.createContext(null);function VS({children:n}){const[s,i]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const x=Af();i({status:"ready",data:x??{}})},[]);const o=m.useCallback(()=>{const x=Af();i({status:"ready",data:x??{}})},[]),f=m.useCallback(x=>{const p=N0(x??{});return i(p?{status:"ready",data:x??{}}:g=>({...g,status:"error"})),p},[]),d=m.useCallback((x,p)=>{i(g=>{const y=g.data[x]||{},b=typeof p=="function"?p(y):{...y,...p??{}},A={...g.data,[x]:b};return N0(A)?{status:"ready",data:A}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:s.data,status:s.status,reload:o,saveAll:f,setNamespace:d}),[s,o,f,d]);return r.jsx(Kx.Provider,{value:h,children:n})}function $S(){const n=m.useContext(Kx);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Qe(n,s={}){const{data:i,status:o,setNamespace:f}=$S(),d=i[n]??s??{},h=m.useCallback(g=>{f(n,y=>{const b=y??{};return typeof g=="function"?g(b):{...b,...g??{}}})},[n,f]),x=m.useCallback(g=>{f(n,()=>g??{})},[n,f]),p=m.useCallback(()=>{const g=typeof s=="object"?{...s}:s;f(n,()=>g??{})},[s,n,f]);return{value:d,status:o,save:h,replace:x,reset:p}}const GS=/^#[0-9A-Fa-f]{6}$/;function Ff(n){const s=typeof n=="string"?n.trim():"";return!s||!GS.test(s)?null:s.toUpperCase()}function ra(n,s=.2){const i=Ff(n);if(!i)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=Zx(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.65)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function YS(n,s=.2){const i=Ff(n);if(!i)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=Zx(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.55)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function Zx(n){const s=Ff(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 FS(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 Xf({panelId:n="replay-sources",fillHeight:s=!1}){const{session:i,triggerReplay:o}=ze(),f=FS(i?.replaySources||[]),{value:d,save:h}=Qe("replaySources",{}),[x,p]=m.useState([]),[g,y]=m.useState(!1),[b,A]=m.useState(null),[R,N]=m.useState(null),q=i?.replay||null,[j,w]=m.useState(0),E=m.useMemo(()=>{const B=i?.assignment?.roverId;return B?[`rover:${B}`]:[]},[i?.assignment?.roverId]);m.useEffect(()=>{const B=d?.[n];if(Array.isArray(B)&&B.length){p(B);return}p(E)},[d?.[n],E,n]),m.useEffect(()=>{const B=new Set(f.map(U=>U.key));p(U=>U.filter(Y=>B.has(Y)))},[f]);const C=m.useMemo(()=>({rovers:f.filter(B=>B.type==="rover"),rooms:f.filter(B=>B.type==="room")}),[f]);m.useEffect(()=>{if(!q?.lastTriggeredAt||!q?.cooldownMs){w(0);return}const B=()=>{const Y=q.lastTriggeredAt+q.cooldownMs-Date.now();w(Math.max(0,Y))};B();const U=setInterval(B,250);return()=>clearInterval(U)},[q?.lastTriggeredAt,q?.cooldownMs,q?.remainingMs]);const M=g||i?.mode==="lockdown"||j>0||!x.length,L=B=>{p(U=>{const Y=U.includes(B)?U.filter(te=>te!==B):[...U,B];return h(te=>({...te||{},[n]:Y})),Y}),N(null)},K=async()=>{if(!M){y(!0),A(null),N(null);try{const B=x.map(U=>{const[Y,te]=U.split(":");return{type:Y,id:te}});await o(B),N("Replay sent. Check the Discord replay channel.")}catch(B){A(B.message)}finally{y(!1)}}},_=s?"h-full flex flex-col":"",Q=s?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${_}`,children:[r.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[r.jsx("span",{children:"Replay Sources"}),r.jsx("span",{children:f.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${Q}`,children:[r.jsx(w0,{title:"Rovers",items:C.rovers,selected:x,onToggle:L}),r.jsx(w0,{title:"Room Cams",items:C.rooms,selected:x,onToggle:L})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:K,disabled:M,children:j>0?`Replay (${Math.ceil(j/1e3)}s)`:g?"Replay…":"Replay"}),b?r.jsx("div",{className:"text-xs text-amber-400",children:b}):null,R?r.jsx("div",{className:"text-xs text-emerald-300",children:R}):null]})]})}function w0({title:n,items:s,selected:i,onToggle:o}){return s.length?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs",children:n}),r.jsx("div",{className:"space-y-0.5",children:s.map(f=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:i.includes(f.key),onChange:()=>o(f.key),className:"accent-emerald-400"}),r.jsx("span",{className:`truncate ${f.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:f.type==="rover"?ra(f.color,.16):void 0,children:f.label})]},f.key))})]}):null}var Ix={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},C0=rs.createContext&&rs.createContext(Ix),XS=["attr","size","title"];function QS(n,s){if(n==null)return{};var i=KS(n,s),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(n);for(f=0;f<d.length;f++)o=d[f],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(i[o]=n[o])}return i}function KS(n,s){if(n==null)return{};var i={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(s.indexOf(o)>=0)continue;i[o]=n[o]}return i}function lo(){return lo=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])}return n},lo.apply(this,arguments)}function E0(n,s){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);s&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(n,f).enumerable})),i.push.apply(i,o)}return i}function io(n){for(var s=1;s<arguments.length;s++){var i=arguments[s]!=null?arguments[s]:{};s%2?E0(Object(i),!0).forEach(function(o){ZS(n,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):E0(Object(i)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(i,o))})}return n}function ZS(n,s,i){return s=IS(s),s in n?Object.defineProperty(n,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[s]=i,n}function IS(n){var s=JS(n,"string");return typeof s=="symbol"?s:s+""}function JS(n,s){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var o=i.call(n,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function Jx(n){return n&&n.map((s,i)=>rs.createElement(s.tag,io({key:i},s.attr),Jx(s.child)))}function Ei(n){return s=>rs.createElement(PS,lo({attr:io({},n.attr)},s),Jx(n.child))}function PS(n){var s=i=>{var{attr:o,size:f,title:d}=n,h=QS(n,XS),x=f||i.size||"1em",p;return i.className&&(p=i.className),n.className&&(p=(p?p+" ":"")+n.className),rs.createElement("svg",lo({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,o,h,{className:p,style:io(io({color:n.color||i.color},i.style),n.style),height:x,width:x,xmlns:"http://www.w3.org/2000/svg"}),d&&rs.createElement("title",null,d),n.children)};return C0!==void 0?rs.createElement(C0.Consumer,null,i=>s(i)):s(Ix)}function Px(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(n)}function WS(n){return Ei({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(n)}function k0(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(n)}function eA(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(n)}function tA(n){return Ei({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(n)}function nA(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 Qf(n){return!!n?.system}function aA(n){const s=new Date(n);return`${s.getHours().toString().padStart(2,"0")}:${s.getMinutes().toString().padStart(2,"0")}`}function M0(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function sA({guildIconUrl:n,userAvatarUrl:s,label:i}){return!n&&!s?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:i,children:[r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${n?"bg-cover":""}`,style:n?{backgroundImage:`url(${n})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${s?"bg-cover":""}`,style:s?{backgroundImage:`url(${s})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function Wx({message:n}){const s=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${M0(n)}`:null,i=Qf(n),o=i?"text-emerald-300":nA(n.role);return r.jsxs(r.Fragment,{children:[n.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(Px,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(sA,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:s})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:M0(n)}),i?r.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,n.roverId&&r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",style:YS(n.roverColor,.14),children:n.roverId})]})}function eg(n){return Qf(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 Kf({message:n}){const s=Qf(n);return r.jsxs("div",{className:eg(n),children:[r.jsx(Wx,{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:aA(n.ts)})]})}function tg({message:n}){return r.jsxs("div",{className:`${eg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(Wx,{message:n}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}const lA=3e3,iA="#2196f3";function rA(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function Zf({scale:n=1}){const{alerts:s}=ze(),[i,o]=m.useState(()=>Date.now()),f=m.useMemo(()=>s.slice(-3).map(p=>({alert:p,key:rA(p)})),[s]);m.useEffect(()=>{if(!f.length)return;const p=setInterval(()=>o(Date.now()),200);return()=>clearInterval(p)},[f.length]);const d=f.map(p=>({...p,age:i-(p.alert.receivedAt??p.alert.timestamp??0)})).filter(p=>p.age<=lA);if(!d.length)return null;const h=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},x=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:x,style:h,children:d.map(p=>r.jsx(oA,{alert:p.alert},p.key))})}function q0(n){const s=typeof n=="string"?n.trim():"",i=/^#?([0-9a-fA-F]{6})$/.exec(s);if(!i)return null;const o=i[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function oA({alert:n}){if(n.kind==="chat"&&n.payload)return r.jsx(Kf,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return r.jsx(tg,{message:n.payload});const s=q0(n.color)||q0(iA),i=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return r.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:i,border:`1px solid ${o}`},children:r.jsxs("p",{className:"truncate text-slate-100",children:[r.jsx("span",{className:"text-slate-300",children:n.title||"Alert"}),r.jsx("span",{className:"text-slate-500",children:" · "}),r.jsx("span",{className:"text-white",children:n.message})]})})}const Js={main:[-127,127],side:[-127,127],vacuum:[0,127]},Ku={maxSpeed:500,baseSpeed:250,boostSpeed:400},jf=100,If=[31,127],al=60,Nf=8,cA=250,uA=4e3,Zu=.4,fA=.8,dA={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},di={driveForward:["w"],driveBackward:["s"],driveLeft:["a"],driveRight:["d"],boostModifier:["\\"],slowModifier:["shift"],auxMainForward:["i"],auxMainReverse:["k"],auxSideForward:["o"],auxSideReverse:["l"],auxVacuumFast:["p"],auxVacuumSlow:[";"],auxAllForward:[","],cameraUp:["u"],cameraDown:["j"],nightVisionToggle:["e"],hornHonk:["h"],micPtt:["m"],driveMacro:["f"],dockMacro:["g"],chatFocus:["enter"],songNoteUp:["ArrowUp"],songNoteDown:["ArrowDown"],homeAssistantOn:["ArrowRight"],homeAssistantOff:["ArrowLeft"]},ng=[{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:jf},{type:"oi",command:"dock"},{type:"pause",duration:jf},{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 wf(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Cf(){return{main:0,side:0,vacuum:0}}function mA(){return{enabled:!1,angle:null,config:null}}function eo(){return{note:al}}function fi(){return{active:!1,heat:0,overheated:!1}}function to(){return{pttActive:!1}}const R0={roverId:null,mode:"drive",drive:wf(),aux:Cf(),camera:mA(),song:eo(),horn:fi(),mic:to(),lastControlIntentAt:0,macros:ng,keymap:di,inputs:{}};function hA(n,s){switch(s.type){case"control/set-rover":return{...n,roverId:s.payload??null,drive:s.payload?n.drive:wf(),aux:s.payload?n.aux:Cf(),song:s.payload?n.song:eo(),horn:s.payload?n.horn:fi(),mic:s.payload?n.mic:to(),lastControlIntentAt:s.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===s.payload?n:{...n,mode:s.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:i,speeds:o,source:f}=s.payload;return{...n,drive:{vector:i??n.drive.vector,speeds:o??n.drive.speeds,source:f??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...s.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!s.payload?.config,config:s.payload?.config??null,angle:typeof s.payload?.angle=="number"?s.payload.angle:s.payload?.config?s.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:s.payload}};case"control/register-input-state":{const i=s.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[i]:{...n.inputs[i]??{},...s.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...s.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(s.payload)?s.payload:n.macros};case"control/reset":return{...n,drive:wf(),aux:Cf(),song:eo(),horn:fi(),mic:to(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||fi(),active:!!s.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||fi(),heat:typeof s.payload?.heat=="number"?s.payload.heat:0,overheated:!!s.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||eo(),note:s.payload??al}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||to(),pttActive:!!s.payload}};default:return n}}function sl(n,s,i){return typeof n!="number"||Number.isNaN(n)?s:Math.max(s,Math.min(i,n))}function ll(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function dn(n,s){return!Array.isArray(s)||s.length!==2?n:sl(n,s[0],s[1])}function pA(n={}){const s=ll(n.x??0),i=ll(n.y??0);return{x:s,y:i,boost:!!n.boost}}function xA(n={},s={}){const i=pA(n),o=typeof s.maxSpeed=="number"?s.maxSpeed:Ku.maxSpeed,f=typeof s.baseSpeed=="number"?s.baseSpeed:Ku.baseSpeed,d=typeof s.boostSpeed=="number"?s.boostSpeed:Ku.boostSpeed,h=i.boost?d:f,x=i.y*h,p=i.x*h;return{vector:i,speeds:{left:sl(Math.round(x+p),-o,o),right:sl(Math.round(x-p),-o,o)}}}function gA(n){const s=Array.isArray(n)?n:[],i=String.fromCharCode(...s);if(typeof btoa=="function")return btoa(i);if(typeof Buffer<"u")return Buffer.from(s).toString("base64");throw new Error("No base64 encoder available")}function T0(n){return new Promise(s=>setTimeout(s,n))}function vA(n={}){const{driveTransform:s,auxTransform:i}=n,o=Rn(),{session:f}=ze(),d=f?.assignment?.roverId,h=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(L=>String(L.id)===String(d))||null,[d,f?.roster]),x=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),p=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),y=m.useMemo(()=>h?.nightVision?.state??null,[h]),b=m.useCallback((L,K)=>{d&&o.emit("command",{roverId:d,...L},K)},[o,d]),A=m.useCallback(()=>{d&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,d]),R=m.useCallback(L=>{if(!d)return null;const K={left:dn(L?.left??0,[-500,500]),right:dn(L?.right??0,[-500,500])},_=s?s(K):K,Q={left:dn(_?.left??0,[-500,500]),right:dn(_?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:Q}}),Q},[s,b,d]),N=m.useCallback(({main:L=0,side:K=0,vacuum:_=0}={})=>{if(!d)return null;const Q={main:dn(L,Js.main),side:dn(K,Js.side),vacuum:dn(_,Js.vacuum)},B=i?i(Q):Q,U={main:dn(B?.main??0,Js.main),side:dn(B?.side??0,Js.side),vacuum:dn(B?.vacuum??0,Js.vacuum)};return b({type:"motors",data:{motorPwm:U}}),U},[i,b,d]),q=m.useCallback(L=>!d||!x?null:(b({type:"servo",data:{servo:{angle:L}}}),L),[b,d,x]),j=m.useCallback(L=>{if(!d)return!1;const K=Array.isArray(L)?L:typeof L=="string"?dA[L]:null;return K?(b({type:"raw",data:{raw:gA(K)}}),A(),!0):!1},[b,A,d]),w=m.useCallback(async L=>{if(!(!L||!Array.isArray(L.steps)||!d))for(const K of L.steps){if(!d)break;switch(K.type){case"oi":j(K.command);break;case"drive":R(K.speeds??{left:0,right:0});break;case"motors":N(K.values??{});break;case"servo":q(K.angle);break;case"pause":await T0(K.duration??jf);break}if(K.delay||K.delayMs){const _=K.delayMs??K.delay;typeof _=="number"&&_>0&&await T0(_)}}},[d,j,R,N,q]),E=m.useCallback((L="toggle")=>!d||!p?null:(b({type:"nightVision",data:{nightVision:{action:L}}}),L),[b,p,d]),C=m.useCallback(L=>d?(b({type:"horn",data:{horn:L}}),L):null,[b,d]),M=m.useCallback((L=[],K={})=>{if(!d)return null;const Q=(Array.isArray(L)&&L.length>0?L:[{note:al,duration:Nf}]).slice(0,16).map(B=>({note:dn(Math.round(B?.note??al),If),duration:dn(Math.round(B?.duration??Nf),[1,255])}));return b({type:"song",data:{song:{notes:Q,slot:K.slot,loop:K.loop}}}),Q},[b,d]);return m.useMemo(()=>({roverId:d,rosterEntry:h,servoConfig:x,nightVision:p,nightVisionState:y,horn:g,emitCommand:b,enableSensorStream:A,sendDriveDirect:R,sendAuxMotors:N,sendServoAngle:q,sendOiCommand:j,sendNightVision:E,sendHorn:C,sendSong:M,runMacroSteps:w}),[d,h,x,p,y,g,b,A,R,N,q,j,E,C,w])}const yA={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},D0={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function ki(n){if(typeof n!="string")return"";const s=n.toLowerCase();return yA[s]??s}function bA(n){const s=ki(n);if(!s)return null;if(D0[s])return D0[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 ag(n){const s=ki(n);return s?`key:${s}`:null}function SA(n){const s=bA(n);return s?`code:${s}`:null}function _0(n){const s=new Set,i=ag(n?.key??"");i&&s.add(i);const o=n?.code?`code:${n.code}`:null;return o&&s.add(o),Array.from(s)}function AA(n={}){return Object.fromEntries(Object.entries(n).map(([s,i])=>{const o=Array.isArray(i)?i:[i],f=new Set;return o.forEach(d=>{const h=ag(String(d));h&&f.add(h);const x=SA(String(d));x&&f.add(x)}),[s,f]}))}function bn(n){const s=ki(n);return s?s===" "?"Space":s==="\\"?"Backslash":s==="`"?"Backtick":s==="["?"[ or {":s==="]"?"] or }":s===";"?"; or :":s==="'"?`' or "`:s===","?", or <":s==="."?". or >":s==="/"?"/ or ?":s==="-"?"- or _":s==="="?"= or +":s==="arrowup"?"Arrow Up":s==="arrowdown"?"Arrow Down":s==="arrowleft"?"Arrow Left":s==="arrowright"?"Arrow Right":s.length===1?s.toUpperCase():s:"—"}const En={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},sa={label:"Default",calibration:{driveDeadzone:.18,cameraDeadzone:.08,auxDeadzone:.05,driveCurve:"linear",cameraCurve:"linear",auxCurve:"linear",cameraMode:"absolute",cameraSensitivity:60,auxSideScale:.55},bindings:{drive:{kind:"axisPair",sources:[{kind:"axisPair",x:0,y:1,invertX:!1,invertY:!0}]},cameraTilt:{kind:"axis",sources:[{kind:"axis",index:3,invert:!0},{kind:"axis",index:1,invert:!0}]},mainBrush:{kind:"axis",sources:[{kind:"buttonAxis",index:6},{kind:"axis",index:2,invert:!1}]},sideBrush:{kind:"axis",sources:[{kind:"buttonAxis",index:7},{kind:"axis",index:5,invert:!1}]},vacuum:{kind:"button",sources:[{kind:"button",index:0}]},allAux:{kind:"button",sources:[{kind:"button",index:1}]},mainReverse:{kind:"button",sources:[{kind:"button",index:4}]},sideReverse:{kind:"button",sources:[{kind:"button",index:5}]},driveMacro:{kind:"button",sources:[{kind:"button",index:2}]},dockMacro:{kind:"button",sources:[{kind:"button",index:3}]},nightVisionToggle:{kind:"button",sources:[{kind:"button",index:9}]}}},Da={activeSignature:null,profiles:{},defaults:{profile:sa}},is={waveform:"saw",freqs:[440,550,660,0]},Dt={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},tl=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],jA={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function O0(){return tl.reduce((n,s)=>(n[s.key]={cap:1,clearSec:0},n),{})}function B0(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function NA(n,s={}){const{session:i}=ze(),d=(cl(n)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...jA,...s.config||{}}),[s.config]),[x,p]=m.useState(()=>O0()),g=m.useRef(typeof performance<"u"?performance.now():Date.now()),y=m.useRef(d);m.useEffect(()=>{y.current=d||{}},[d]),m.useEffect(()=>{p(O0())},[n]),m.useEffect(()=>{const N=setInterval(()=>{const q=typeof performance<"u"?performance.now():Date.now(),j=Math.max(0,q-g.current);g.current=q;const w=j/1e3;w<=0||p(E=>{let C=!1;const M={},L=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,K=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,_=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return tl.forEach(Q=>{const B=E[Q.key]||{cap:1,clearSec:0},U=Number.isFinite(B.cap)?B.cap:1,Y=Number.isFinite(B.clearSec)?B.clearSec:0,te=Q.motors.some(T=>!!y.current?.[T]),fe=te?0:Y+w,oe=!te&&fe>=_,G=B0(te?U-L*w:oe?U+K*w:U);(Math.abs(G-U)>1e-4||Math.abs(fe-Y)>1e-4)&&(C=!0),M[Q.key]={cap:G,clearSec:fe}}),C?M:E})},100);return()=>clearInterval(N)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec]);const b=m.useMemo(()=>{const N=tl.reduce((q,j)=>{const w=x?.[j.key],E=Number.isFinite(w?.cap)?w.cap:1;return q[j.key]=B0(E),q},{});return{perGroup:N,drive:{left:N.drive??1,right:N.drive??1},aux:{main:N.aux??1,side:N.aux??1,vacuum:1}}},[x]),A=m.useMemo(()=>{const N={};tl.forEach(j=>{j.motors.forEach(w=>{N[w]=!!d?.[w]})});const q=tl.reduce((j,w)=>(j[w.key]=w.motors.some(E=>!!d?.[E]),j),{});return{motors:N,groups:q}},[d]),R=i?.role==="admin"||i?.role==="lockdown"||i?.role==="lockdown-admin";return m.useMemo(()=>({caps:x,overcurrent:A,scales:b,isActive:(b?.drive?.left??1)<1||(b?.drive?.right??1)<1||(b?.aux?.main??1)<1||(b?.aux?.side??1)<1,config:h,adminImmune:R}),[x,A,b,h,R])}function wA(n={},s,i=!1){if(i||!s?.drive)return n;const o=typeof s.drive.left=="number"?s.drive.left:1,f=typeof s.drive.right=="number"?s.drive.right:1;return o>=.999&&f>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*f)}}function CA(n={},s,i=!1){if(i||!s?.aux)return n;const o=typeof s.aux.main=="number"?s.aux.main:1,f=typeof s.aux.side=="number"?s.aux.side:1,d=typeof s.aux.vacuum=="number"?s.aux.vacuum:1;return o>=.999&&f>=.999&&d>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*f),vacuum:Math.round((n.vacuum??0)*d)}}const sg=m.createContext(null);function L0(n){return Object.fromEntries(Object.entries(n||{}).map(([s,i])=>[s,Array.isArray(i)?[...i]:[]]))}function EA(n,s){if(!n)return s;const i=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return sl(s,i,o)}function kA(n=[]){if(!Array.isArray(n)||n.length<3)return n;const s=n.slice(-3),[i,o,f]=s,d=i?.type==="drive"&&Number(i?.speeds?.left)===-300&&Number(i?.speeds?.right)===-300,h=o?.type==="pause"&&Number(o?.duration)===600,x=f?.type==="drive"&&Number(f?.speeds?.left)===0&&Number(f?.speeds?.right)===0;return!d||!h||!x?n:n.slice(0,-3)}function MA({children:n}){const[s,i]=m.useReducer(hA,R0),o=m.useRef(null),f=m.useRef(!1),d=m.useRef(R0.camera.angle),h=m.useRef(null),x=m.useRef(0),p=m.useRef(0),{value:g,save:y}=Qe("controls",{keymap:di,macros:ng}),{value:b}=Qe("page",{driveMacroBackoffEnabled:!0}),{value:A}=Qe("horn",is),R=typeof b?.driveMacroBackoffEnabled=="boolean"?b.driveMacroBackoffEnabled:!0,{session:N,homeAssistantSetState:q}=ze(),j=N?.assignment?.roverId??null,w=NA(j),E=m.useCallback(ae=>wA(ae,w.scales,w.adminImmune),[w.adminImmune,w.scales]),C=m.useCallback(ae=>CA(ae,w.scales,w.adminImmune),[w.adminImmune,w.scales]),M=vA({driveTransform:E,auxTransform:C}),L=m.useCallback(()=>{const ue=(N?.homeAssistant?.entities||[]).filter(be=>(be.type==="light"||be.type==="switch")&&be.available!==!1&&be.state!=="on");if(ue.length===0){f.current=!1;return}f.current=!0,ue.forEach(be=>{q(be.id,"on").catch(()=>{})}),f.current=!1},[N?.homeAssistant?.entities,q]);m.useEffect(()=>{i({type:"control/set-rover",payload:M.roverId})},[M.roverId]),m.useEffect(()=>{const ae=o.current;o.current=s.mode,ae!=="drive"&&s.mode==="drive"&&N?.homeAssistant?.entities?L():ae!=="drive"&&s.mode==="drive"&&(f.current=!0)},[s.mode,N?.homeAssistant?.entities,L]),m.useEffect(()=>{f.current&&N?.homeAssistant?.entities&&L()},[N?.homeAssistant?.entities,L]),m.useEffect(()=>{const ae={...di,...g?.keymap||{}};i({type:"control/set-keymap",payload:ae}),g?.macros&&i({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const ae=M.servoConfig;if(!ae){i({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const ue=typeof ae.minAngle=="number"?ae.minAngle:-45,be=typeof ae.maxAngle=="number"?ae.maxAngle:45,Me=typeof ae.homeAngle=="number"?ae.homeAngle:(ue+be)/2,le=typeof d.current=="number"?sl(d.current,ue,be):null,re=le??sl(Me,ue,be);i({type:"control/set-camera-config",payload:{config:ae,angle:re}}),d.current=re},[M.servoConfig]),m.useEffect(()=>{d.current=typeof s.camera.angle=="number"?s.camera.angle:d.current},[s.camera.angle]),m.useEffect(()=>{M.roverId&&M.enableSensorStream()},[M.roverId,M.enableSensorStream]);const K=m.useCallback(ae=>{i({type:"control/set-mode",payload:ae})},[]),_=m.useCallback(()=>{i({type:"control/record-intent"})},[]),Q=m.useRef(s.drive.speeds),B=m.useRef(s.aux),U=m.useMemo(()=>JSON.stringify(w.scales),[w.scales]),Y=m.useRef(0),te=m.useRef(0);m.useEffect(()=>{Q.current=s.drive.speeds},[s.drive.speeds]),m.useEffect(()=>{B.current=s.aux},[s.aux]),m.useEffect(()=>{if(!M.roverId||w.adminImmune||!w.isActive)return;const ae=Math.max(0,Number(w?.config?.outputRateMs)||0),ue=typeof performance<"u"?performance.now():Date.now(),be=Q.current||{left:0,right:0},Me=B.current||{main:0,side:0,vacuum:0},le=!!(be.left||be.right),re=!!(Me.main||Me.side||Me.vacuum);!le&&!re||(le&&ue-Y.current>=ae&&(Y.current=ue,M.sendDriveDirect(be)),re&&ue-te.current>=ae&&(te.current=ue,M.sendAuxMotors(Me)))},[U,w.adminImmune,w.config,w.isActive,M]);const fe=m.useCallback((ae,ue={})=>{const be=xA(ae,ue.speedOptions);i({type:"control/update-drive",payload:{...be,source:ue.source??null}}),_(),M.sendDriveDirect(be.speeds)},[M,_]),oe=m.useCallback((ae={})=>{const ue=M.sendAuxMotors(ae)??ae;i({type:"control/set-aux-motors",payload:ue}),_()},[M,_]),G=m.useCallback((ae,ue)=>{if(!ae)return!1;const be=ki(ue);if(!be)return!1;const Me=L0(s.keymap);return Me[ae]=[be],i({type:"control/set-keymap",payload:Me}),y(le=>({...le??{},keymap:Me})),!0},[s.keymap,y]),T=m.useCallback(()=>{const ae=L0(di);i({type:"control/set-keymap",payload:ae}),y(ue=>({...ue??{},keymap:ae}))},[y]),F=m.useCallback(ae=>{if(!M.servoConfig)return;const ue=EA(M.servoConfig,ae);i({type:"control/set-camera-angle",payload:ue}),M.sendServoAngle(ue),d.current=ue,_()},[M,_]),J=m.useCallback((ae=0)=>{const ue=M.servoConfig;if(!ue)return;const be=typeof ae=="number"&&ae!==0?ae:ue.nudgeDegrees||1,Me=typeof d.current=="number"?d.current:typeof ue.homeAngle=="number"?ue.homeAngle:0;F(Me+be)},[M.servoConfig,F]),se=m.useCallback(()=>{const ae=M.servoConfig;if(!ae)return;const ue=typeof ae.homeAngle=="number"?ae.homeAngle:typeof ae.minAngle=="number"&&typeof ae.maxAngle=="number"?(ae.minAngle+ae.maxAngle)/2:0;F(ue)},[M.servoConfig,F]),de=m.useCallback(async ae=>{const ue=s.macros.find(Me=>Me.id===ae)||null;if(!ue)return;let be=ue;ae==="drive-sequence"?(L(),N?.homeAssistant?.entities||(f.current=!0),_(),R||(be={...ue,steps:kA(ue.steps)})):ae==="seek-dock"&&_(),await M.runMacroSteps(be)},[R,M,_,N?.homeAssistant?.entities,s.macros,L]),k=m.useCallback(()=>{i({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),M.sendDriveDirect({left:0,right:0}),M.sendAuxMotors({main:0,side:0,vacuum:0})},[M]),H=m.useCallback(ae=>{M.sendOiCommand(ae)},[M]),P=m.useCallback(ae=>{M.roverId&&M.emitCommand({type:"sensorStream",data:{sensorStream:{enable:ae}}})},[M]),ne=m.useCallback(ae=>{if(M.nightVision){if(typeof ae=="boolean"){const ue=ae?"off":"on";M.sendNightVision(ue)}else M.sendNightVision("toggle");_()}},[M,_]),pe=m.useCallback(()=>{ne()},[ne]),ie=m.useCallback(ae=>{const ue=typeof ae=="number"?ae:al;return i({type:"control/set-song-note",payload:ue}),ue},[]),ce=m.useCallback((ae,ue)=>M.sendSong(ae,ue),[M]),ve=m.useMemo(()=>{const ae=A??is,ue=ae.waveform==="sine"?"sine":"saw",Me=[...Array.isArray(ae.freqs)?ae.freqs:is.freqs,0,0,0,0].slice(0,4).map(le=>{const re=Number(le);return Number.isFinite(re)?re<=0?0:Math.min(5e3,Math.round(re)):0});return{waveform:ue,freqs:Me}},[A]),ye=m.useCallback(()=>{if(!M.horn)return;if(s.horn?.overheated||(s.horn?.heat??0)>=1||s.horn?.active)return!1;const ae=Date.now();return M.sendHorn({action:"start",...ve}),i({type:"control/set-horn-active",payload:!0}),x.current=ae,p.current=ae,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{xe()},uA),_(),!0},[i,ve,M,_,s.horn?.active,s.horn?.heat,s.horn?.overheated]),xe=m.useCallback(()=>{if(!M.horn)return;M.sendHorn({action:"stop"}),i({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const ae=Date.now(),ue=x.current||ae,be=Math.max(0,ae-ue);if(x.current=0,be>0){const Me=s.horn?.heat??0,le=be/1e3*Zu;let re=Math.max(0,Math.min(1,Me+le)),me=s.horn?.overheated??!1;re>=1&&(re=1,me=!0),i({type:"control/set-horn-heat",payload:{heat:re,overheated:me}})}},[i,M,s.horn?.heat,s.horn?.overheated,Zu]);m.useEffect(()=>{const ue=setInterval(()=>{const be=Date.now(),Me=p.current||be;p.current=be;const le=Math.min(1e3,Math.max(0,be-Me))/1e3,re=s.horn?.heat??0,me=!!s.horn?.active,we=!!s.horn?.overheated,et=le*(me?Zu:-.2);let dt=Math.max(0,Math.min(1,re+et)),Le=we;dt>=1?(dt=1,Le=!0,me&&xe()):Le&&dt<=fA&&(Le=!1),(dt!==re||Le!==we)&&i({type:"control/set-horn-heat",payload:{heat:dt,overheated:Le}})},100);return()=>clearInterval(ue)},[i,s.horn?.active,s.horn?.heat,s.horn?.overheated,xe]);const Ue=m.useCallback((ae,ue)=>{i({type:"control/register-input-state",payload:{source:ae,state:ue}})},[]),$e=m.useCallback(ae=>{i({type:"control/set-mic-ptt",payload:!!ae})},[]),Ne=m.useMemo(()=>({state:s,dispatch:i,pipeline:M,overcurrentLimiter:w,actions:{setMode:K,setDriveVector:fe,setAuxMotors:oe,setServoAngle:F,nudgeServo:J,goServoHome:se,runMacro:de,stopAllMotion:k,sendOiCommand:H,setSensorStream:P,setNightVision:ne,toggleNightVision:pe,updateKeyBinding:G,resetKeyBindings:T,registerInputState:Ue,setSongNote:ie,sendSong:ce,startHorn:ye,stopHorn:xe,setMicPttActive:$e}}),[s,M,w,K,fe,oe,F,J,se,de,k,H,P,ne,pe,G,T,Ue,ie,ce,ye,xe,$e]);return r.jsx(sg.Provider,{value:Ne,children:n})}function _t(){const n=m.useContext(sg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const qA="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=",lg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function RA({children:n}){const s=Rn(),{session:i,pushAlert:o}=ze(),{value:f}=Qe("audio",Dt),[d,h]=m.useState([]),[x,p]=m.useState([]),[g,y]=m.useState(!1),b=m.useRef(null),A=m.useRef(null),R=m.useRef(null),N=m.useRef(new Map),q=m.useRef(new Map),j=m.useRef({isTyping:!1,lastSent:0}),w=Number.isFinite(f?.masterVolume)?f.masterVolume:Dt.masterVolume,E=Number.isFinite(f?.alertVolume)?f.alertVolume:Dt.alertVolume,C=Math.max(0,Math.min(1,w*E)),M=m.useCallback(()=>{const G=Array.from(N.current.values()).sort((T,F)=>T.lastUpdate-F.lastUpdate).map(T=>T.payload);p(G)},[]),L=m.useCallback(G=>!G||typeof G!="object"?null:G.typingId?G.typingId:G.fromDiscord?`discord:${G.discordUserId||G.discordUserName||G.nickname||"unknown"}`:`socket:${G.socketId||G.nickname||"unknown"}`,[]);m.useEffect(()=>{R.current=new Audio(qA),R.current.volume=C,R.current.load()},[C]);const K=m.useCallback(()=>{const G=R.current;G&&(G.volume=C,G.currentTime=0,G.play().catch(()=>{}))},[C]);m.useEffect(()=>{function G(T={}){h(F=>[...F.slice(-99),T]),!(T?.socketId&&i?.socketId&&T.socketId===i.socketId)&&(K(),o?.({kind:"chat",payload:T,id:`chat-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return s.on("chat:message",G),()=>{s.off("chat:message",G)}},[K,i?.socketId,s]),m.useEffect(()=>{function G(T={}){const F=L(T);if(!F)return;const J=Date.now();if(T?.socketId&&i?.socketId&&T.socketId===i.socketId){T.isTyping||(N.current.delete(F),M());return}if(T.isTyping){N.current.set(F,{payload:T,expiresAt:J+6e3,lastUpdate:J});const se=q.current.get(F)||0;J-se>=2500&&(q.current.set(F,J),o?.({kind:"chat-typing",payload:T,id:`chat-typing-${F}-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:J}))}else N.current.delete(F);M()}return s.on("chat:typing",G),()=>{s.off("chat:typing",G)}},[o,M,L,i?.socketId,s]),m.useEffect(()=>{const G=setInterval(()=>{const T=Date.now();let F=!1;N.current.forEach((J,se)=>{J.expiresAt<=T&&(N.current.delete(se),F=!0)}),F&&M()},2e3);return()=>clearInterval(G)},[M]),m.useEffect(()=>{function G(T=[]){Array.isArray(T)&&h(F=>{if(F.length===0)return T.slice(-100);const J=new Set(T.map(de=>de?.id));return[...T,...F.filter(de=>de?.id&&!J.has(de.id))].slice(-100)})}return s.on("chat:init",G),()=>{s.off("chat:init",G)}},[s]);const _=m.useCallback(G=>{const T=!!G,F=Date.now(),J=j.current,se=!T&&J.isTyping;!(T&&(!J.isTyping||F-J.lastSent>=3500))&&!se||(j.current={isTyping:T,lastSent:F},s.emit("chat:typing",{isTyping:T}))},[s]),Q=m.useCallback((G,T=null)=>new Promise((F,J)=>{s.emit("chat:send",{text:G,tts:T},(se={})=>{se.error?J(new Error(se.error)):F(se)})}),[s]),B=m.useCallback((G,T={})=>{(T?.target==="hud"?"hud":"panel")==="hud"?A.current=G:b.current=G},[]),U=m.useCallback(()=>{y(!0),(A.current||b.current)?.focus()},[]),Y=m.useCallback(()=>{y(!1),A.current?.blur(),b.current?.blur()},[]),te=m.useCallback(()=>y(!0),[]),fe=m.useCallback(()=>y(!1),[]),oe=m.useMemo(()=>({messages:d,sendMessage:Q,focusChat:U,blurChat:Y,registerInputRef:B,onInputFocus:te,onInputBlur:fe,setTypingActive:_,typing:x,isChatFocused:g,selfSocketId:i?.socketId||null}),[Y,U,g,d,fe,te,B,Q,i?.socketId,_,x]);return r.jsx(lg.Provider,{value:oe,children:n})}function Jf(){const n=m.useContext(lg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let ig=!1;function Iu(n){ig=!!n}function z0(){return ig}const TA=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function rg(n){if(!n||n.nodeType!==1)return!1;const s=n.tagName;if(s==="TEXTAREA"||n.isContentEditable)return!0;if(s!=="INPUT")return!1;const i=n.type?n.type.toLowerCase():"";return TA.has(i)}function DA(){return typeof document>"u"?!1:rg(document.activeElement)}const Ju="keyboard",Pu={x:0,y:0,boost:!1},Wu={main:0,side:0,vacuum:0},U0=If[0],H0=If[1],Pf=5,xi=500,gi=1,Wf=100;function ef(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):s}function _A(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(Pf,Math.min(xi,i)):s}function og(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(gi,Math.min(Wf,i)):s}function OA(n){const i=(og(n,n)-gi)/(Wf-gi),o=xi-i*(xi-Pf);return Math.round(o)}function BA(n){const s=_A(n,n),i=(xi-s)/(xi-Pf),o=gi+i*(Wf-gi);return Math.round(o)}function LA(n){return rg(n?.target)}function ft(n,s){if(!n||n.size===0)return!1;for(const i of s)if(n.has(i))return!0;return!1}function zA(n,s){const i=ft(s.driveForward,n),o=ft(s.driveBackward,n),f=ft(s.driveLeft,n),d=ft(s.driveRight,n),h=ft(s.boostModifier,n),x=ft(s.slowModifier,n);let p=0;i&&!o?p=1:o&&!i&&(p=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const y=x?.4:1;return{x:g*y,y:p*y,boost:h&&!x}}function UA(n,s){if(ft(s.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=ft(s.auxMainForward,n)?127:ft(s.auxMainReverse,n)?-127:0,f=ft(s.auxSideForward,n)?127:ft(s.auxSideReverse,n)?-70:0,d=ft(s.auxVacuumFast,n)?127:ft(s.auxVacuumSlow,n)?50:0;return{main:o,side:f,vacuum:d}}function HA(){const{state:n,actions:{setMode:s,setDriveVector:i,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:h,registerInputState:x,toggleNightVision:p,startHorn:g,stopHorn:y,setMicPttActive:b,setSongNote:A,sendSong:R}}=_t(),{session:N,homeAssistantSetState:q}=ze(),{focusChat:j,blurChat:w,isChatFocused:E}=Jf(),{value:C}=Qe("inputs",En),M=m.useMemo(()=>AA(n.keymap),[n.keymap]),L=m.useMemo(()=>{const ie=new Set;return Object.values(M).forEach(ce=>{ce&&ce.forEach(ve=>ie.add(ve))}),ie},[M]),K=m.useMemo(()=>{const ie=En.keyboard,ce=C?.keyboard??{};return{baseSpeed:ef(ce.baseSpeed,ie.baseSpeed),turboSpeed:ef(ce.turboSpeed,ie.turboSpeed),precisionSpeed:ef(ce.precisionSpeed,ie.precisionSpeed)}},[C?.keyboard]),_=m.useMemo(()=>{const ie=En.keyboard,ce=C?.keyboard??{},ve=og(typeof ce.tiltSpeed=="number"?ce.tiltSpeed:typeof ce.tiltIntervalMs=="number"?BA(ce.tiltIntervalMs):ie.tiltSpeed,ie.tiltSpeed);return OA(ve)},[C?.keyboard]),Q=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),B=m.useRef(new Set),U=m.useRef(Pu),Y=m.useRef(Wu),te=m.useRef(null),fe=m.useRef(null),oe=m.useRef(!1),G=m.useCallback(()=>{const ie=new Set(B.current);ft(M.boostModifier,ie);const ve=ft(M.slowModifier,ie)?{baseSpeed:K.precisionSpeed,boostSpeed:K.precisionSpeed}:{baseSpeed:K.baseSpeed,boostSpeed:K.turboSpeed},ye=zA(ie,M),xe=UA(ie,M);(ye.x!==U.current.x||ye.y!==U.current.y||ye.boost!==U.current.boost)&&(U.current=ye,i(ye,{source:Ju,speedOptions:ve})),(xe.main!==Y.current.main||xe.side!==Y.current.side||xe.vacuum!==Y.current.vacuum)&&(Y.current=xe,o(xe)),x(Ju,{keys:Array.from(ie),vector:ye,aux:xe})},[M,K,x,o,i]),T=m.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=null)},[]),F=m.useCallback(()=>{const ie=new Set(B.current),ce=ft(M.cameraUp,ie),ve=ft(M.cameraDown,ie);return(ce?1:0)-(ve?1:0)},[M]),J=m.useCallback(()=>{if(F()===0){T();return}if(te.current)return;const ce=()=>{const ve=F();if(ve===0){T();return}f(ve*Q),te.current=setTimeout(ce,_)};te.current=setTimeout(ce,0)},[F,f,_,Q,T]),se=m.useCallback(()=>{fe.current&&(clearTimeout(fe.current),fe.current=null)},[]),de=m.useCallback(()=>{const ie=new Set(B.current),ce=ft(M.songNoteUp,ie),ve=ft(M.songNoteDown,ie);return(ce?1:0)-(ve?1:0)},[M]),k=m.useCallback(ie=>{if(ie===0)return;let ve=(typeof n.song?.note=="number"?n.song.note:al)+ie;ve>H0?ve=U0:ve<U0&&(ve=H0);const ye=A(ve);R([{note:ye,duration:Nf}],{slot:0})},[R,A,n.song?.note]),H=m.useCallback(()=>{if(de()===0){se();return}if(fe.current)return;const ce=()=>{const ve=de();if(ve===0){se();return}k(ve),fe.current=setTimeout(ce,cA)};fe.current=setTimeout(ce,0)},[de,se,k]),P=m.useCallback(()=>{B.current.clear(),U.current=Pu,Y.current=Wu,T(),se(),oe.current&&(oe.current=!1,y()),b(!1),h(),x(Ju,{keys:[],vector:Pu,aux:Wu})},[x,b,h,y,T,se]),ne=m.useCallback(ie=>{const ce=N?.homeAssistant;if(!ce?.enabled||!ce?.connected)return;const ye=(ce.entities||[]).filter(xe=>(xe.type==="light"||xe.type==="switch")&&xe.available!==!1&&xe.state!=="unavailable");if(ye.length!==0){if(ie==="on"){const xe=ye.find(Ue=>Ue.state!=="on");xe&&q(xe.id,"on").catch(()=>{});return}if(ie==="off")for(let xe=ye.length-1;xe>=0;xe-=1){const Ue=ye[xe];if(Ue.state==="on"){q(Ue.id,"off").catch(()=>{});break}}}},[q,N?.homeAssistant]);m.useEffect(()=>{function ie(ye){if(z0()||LA(ye))return;const xe=_0(ye);if(xe.length===0)return;const Ue=new Set(xe);if(ft(M.chatFocus,Ue)){ye.preventDefault(),P(),E||j();return}xe.some(Ne=>L.has(Ne))&&ye.preventDefault();const $e=xe.filter(Ne=>!B.current.has(Ne));if($e.forEach(Ne=>B.current.add(Ne)),$e.length>0)if($e.some(Ne=>M.driveMacro?.has(Ne)))s("drive"),d("drive-sequence");else if($e.some(Ne=>M.dockMacro?.has(Ne)))s("dock"),d("seek-dock");else if($e.some(Ne=>M.nightVisionToggle?.has(Ne)))p();else if($e.some(Ne=>M.hornHonk?.has(Ne))){if(!oe.current){const Ne=g();oe.current=!!Ne}}else $e.some(Ne=>M.micPtt?.has(Ne))?b(!0):$e.some(Ne=>M.homeAssistantOn?.has(Ne))?ne("on"):$e.some(Ne=>M.homeAssistantOff?.has(Ne))&&ne("off");J(),H(),G()}function ce(ye){if(z0())return;_0(ye).forEach(Ue=>B.current.delete(Ue)),oe.current&&!ft(M.hornHonk,B.current)&&(oe.current=!1,y()),ft(M.micPtt,B.current)||b(!1),J(),H(),G()}function ve(){P()}return window.addEventListener("keydown",ie,{capture:!0}),window.addEventListener("keyup",ce,{capture:!0}),window.addEventListener("blur",ve),()=>{window.removeEventListener("keydown",ie,{capture:!0}),window.removeEventListener("keyup",ce,{capture:!0}),window.removeEventListener("blur",ve)}},[L,w,G,J,H,j,E,M.chatFocus,M.dockMacro,M.driveMacro,M.hornHonk,M.micPtt,P,d,b,s,h,se,g,y,ne]);const pe=m.useRef(P);return m.useEffect(()=>{pe.current=P},[P]),m.useEffect(()=>{pe.current()},[n.roverId]),m.useEffect(()=>{oe.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{T(),se()},[T,se]),null}const VA=1.6;function cg(n){if(!n)return"unknown::none::0::0";const s=n.id||"unknown",i=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,f=Array.isArray(n.buttons)?n.buttons.length:0;return`${s}::${i}::${o}::${f}`}function $A(n){return JSON.parse(JSON.stringify(n??{}))}function ug(n,s){const i=$A(s);return i.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},i}function ls(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function oi(n,s){if(!n)return 0;const i=Math.abs(n);return s==="expo"?Math.sign(n)*Math.pow(i,VA):n}function tf(n,s){const i=Math.abs(n);if(i<=s)return 0;const o=(i-s)/(1-s);return Math.sign(n)*o}function GA(n,s,i){const o=Math.hypot(n,s);if(o<=i)return{x:0,y:0};const d=(o-i)/(1-i)/o;return{x:n*d,y:s*d}}function ro(n,s){if(!n||!Array.isArray(n.axes))return null;const i=n.axes[s];return Number.isFinite(i)?ls(i):null}function Ef(n,s){if(!n||!Array.isArray(n.buttons))return null;const i=n.buttons[s];if(!i)return null;const o=typeof i.value=="number"?i.value:i.pressed?1:0;return{pressed:!!(i.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function nf(n,s=[]){for(const i of s)if(i){if(i.kind==="axis"){const o=ro(n,i.index);if(o===null)continue;return{value:i.invert?-o:o,source:i}}if(i.kind==="buttonAxis"){const o=Ef(n,i.index);if(!o)continue;return{value:ls(o.value),source:i}}}return{value:0,source:null}}function YA(n,s=[]){for(const i of s){if(!i||i.kind!=="axisPair")continue;const o=ro(n,i.x),f=ro(n,i.y);if(o===null||f===null)continue;const d=i.invertX?-o:o,h=i.invertY?-f:f;return{x:d,y:h,source:i}}return{x:0,y:0,source:null}}function ts(n,s=[]){for(const i of s)if(i){if(i.kind==="button"){const o=Ef(n,i.index);if(!o)continue;return{pressed:o.pressed,source:i}}if(i.kind==="axisButton"){const o=ro(n,i.index);if(o===null)continue;const f=i.direction||1,d=typeof i.threshold=="number"?i.threshold:.6;return{pressed:o*f>d,source:i}}if(i.kind==="buttonAxis"){const o=Ef(n,i.index);if(!o)continue;return{pressed:o.value>.5,source:i}}}return{pressed:!1,source:null}}function fg(n,s){const i=s?.bindings??{},o=s?.calibration??{},f=i.drive??{},d=YA(n,f.sources);let h=ls(d.x),x=ls(d.y);const p=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=GA(h,x,p);h=oi(g.x,o.driveCurve),x=oi(g.y,o.driveCurve);const y=i.cameraTilt??{},b=nf(n,y.sources),A=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let R=tf(ls(b.value),A);R=oi(R,o.cameraCurve);const N=Math.min(Math.max(o.auxDeadzone??.05,0),.6),q=i.mainBrush??{},j=nf(n,q.sources);let w=tf(ls(j.value),N);w=oi(w,o.auxCurve);const E=i.sideBrush??{},C=nf(n,E.sources);let M=tf(ls(C.value),N);M=oi(M,o.auxCurve);const L=ts(n,i.vacuum?.sources),K=ts(n,i.allAux?.sources),_=ts(n,i.mainReverse?.sources),Q=ts(n,i.sideReverse?.sources),B=ts(n,i.driveMacro?.sources),U=ts(n,i.dockMacro?.sources),Y=ts(n,i.nightVisionToggle?.sources);return{driveVector:{x:h,y:x,boost:!1},cameraAxis:R,auxAxis:{main:w,side:M},buttons:{vacuum:L.pressed,allAux:K.pressed,mainReverse:_.pressed,sideReverse:Q.pressed,driveMacro:B.pressed,dockMacro:U.pressed,nightVisionToggle:Y.pressed},sources:{drive:d.source,cameraTilt:b.source,mainBrush:j.source,sideBrush:C.source,vacuum:L.source,allAux:K.source,mainReverse:_.source,sideReverse:Q.source,driveMacro:B.source,dockMacro:U.source,nightVisionToggle:Y.source}}}const no=new Set;let nl=null,oo={pads:[],timestamp:0};function FA(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function XA(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:cg(n)}}function QA(){oo={pads:FA().map(XA),timestamp:typeof performance<"u"?performance.now():Date.now()},no.forEach(s=>s(oo))}function dg(){QA(),nl=requestAnimationFrame(dg)}function KA(){nl||(nl=requestAnimationFrame(dg))}function ZA(){nl&&(cancelAnimationFrame(nl),nl=null)}function mg(n){return no.add(n),KA(),n(oo),()=>{no.delete(n),no.size===0&&ZA()}}function IA(){const[n,s]=m.useState(oo);return m.useEffect(()=>mg(s),[]),n}const Ps="gamepad",ns={x:0,y:0,boost:!1},as={main:0,side:0,vacuum:0},JA=100,PA=100;function af(n,s){return n&&s&&n.x===s.x&&n.y===s.y&&n.boost===s.boost}function sf(n,s){return n&&s&&n.main===s.main&&n.side===s.side&&n.vacuum===s.vacuum}function WA(n){return n?Math.hypot(n.x||0,n.y||0):0}function ej(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function tj(n,s){if(!n||n.length===0)return null;if(s){const i=n.find(o=>o.signature===s);if(i)return i}return n[0]}function nj(){const{state:n,actions:{setMode:s,setDriveVector:i,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:h,registerInputState:x}}=_t(),{value:p,save:g}=Qe("gamepad",Da),y=m.useRef(new Set),b=m.useRef(ns),A=m.useRef(as),R=m.useRef({main:!1,side:!1}),N=m.useRef(new Map),q=m.useRef(0),j=m.useRef(0),w=m.useRef(0),E=m.useRef(null),C=m.useCallback(_=>{const Q=_.signature??cg(_);p?.profiles?.[Q]||y.current.has(Q)||(y.current.add(Q),g(B=>{const U=B??Da;if(U.profiles?.[Q])return U;const Y=U?.defaults?.profile??sa,te=ug(_,Y);return{...U,profiles:{...U.profiles??{},[Q]:te}}}))},[p?.profiles,g]),M=m.useCallback((_,Q)=>{const B=N.current.get(_)||!1;return N.current.set(_,Q),Q&&!B},[]),L=m.useCallback((_,Q)=>{const B=n.camera?.config;if(!B)return;const U=typeof performance<"u"?performance.now():Date.now(),Y=Q?.cameraMode??"absolute",te=Math.max(1,Math.min(180,Q?.cameraSensitivity??60));if(Y==="velocity"){const F=Math.min(50,U-w.current||16),J=_*te*(F/1e3);if(Math.abs(J)<.01)return;const de=(typeof E.current=="number"?E.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof B.homeAngle=="number"?B.homeAngle:0)+J;f(de),E.current=de,w.current=U;return}const fe=typeof B.minAngle=="number"?B.minAngle:-45,oe=typeof B.maxAngle=="number"?B.maxAngle:45,G=typeof B.homeAngle=="number"?B.homeAngle:(fe+oe)/2,T=_<0?G+_*(G-fe):G+_*(oe-G);typeof E.current=="number"&&Math.abs(E.current-T)<.35&&U-w.current<80||(w.current=U,E.current=T,f(T))},[f,n.camera?.angle,n.camera?.config]),K=m.useMemo(()=>p?.activeSignature??null,[p?.activeSignature]);return m.useEffect(()=>mg(_=>{const Q=tj(_.pads,K);if(!Q){af(b.current,ns)||(b.current=ns,i(ns,{source:Ps})),sf(A.current,as)||(A.current=as,o(as)),N.current=new Map,R.current={main:!1,side:!1},q.current=0,j.current=0,x(Ps,{connected:!1});return}if(DA()){af(b.current,ns)||(b.current=ns,i(ns,{source:Ps})),sf(A.current,as)||(A.current=as,o(as)),N.current=new Map,R.current={main:!1,side:!1},x(Ps,{connected:!0,blocked:!0});return}C(Q);const B=Q.signature,U=p?.profiles?.[B]??p?.defaults?.profile??sa,Y=fg(Q,U);if(!af(Y.driveVector,b.current)){const J=typeof performance<"u"?performance.now():Date.now();(WA(Y.driveVector)<.02||J-q.current>=JA)&&(b.current=Y.driveVector,q.current=J,i(Y.driveVector,{source:Ps}))}const te=U.calibration?.auxSideScale??.55,fe=Math.round(Math.min(Math.abs(Y.auxAxis.main),1)*127),oe=Math.round(Math.min(Math.abs(Y.auxAxis.side),1)*127),G=R.current.main?-fe:fe,T=R.current.side?-Math.round(oe*te):Math.round(oe*te);let F={main:Y.auxAxis.main!==0?G:0,side:Y.auxAxis.side!==0?T:0,vacuum:Y.buttons.vacuum?127:0};if(Y.buttons.allAux&&(F={main:127,side:127,vacuum:127}),!sf(F,A.current)){const J=typeof performance<"u"?performance.now():Date.now();(ej(F)||J-j.current>=PA)&&(A.current=F,j.current=J,o(F))}Y.buttons.mainReverse&&M("mainReverse",!0)?R.current.main=!R.current.main:Y.buttons.mainReverse||M("mainReverse",!1),Y.buttons.sideReverse&&M("sideReverse",!0)?R.current.side=!R.current.side:Y.buttons.sideReverse||M("sideReverse",!1),Y.buttons.driveMacro&&M("driveMacro",!0)?(s("drive"),d("drive-sequence")):Y.buttons.driveMacro||M("driveMacro",!1),Y.buttons.dockMacro&&M("dockMacro",!0)?(s("dock"),d("seek-dock")):Y.buttons.dockMacro||M("dockMacro",!1),Y.buttons.nightVisionToggle&&M("nightVisionToggle",!0)?h():Y.buttons.nightVisionToggle||M("nightVisionToggle",!1),Math.abs(Y.cameraAxis)>.001&&L(Y.cameraAxis,U.calibration),x(Ps,{connected:!0,signature:B,id:Q.id,index:Q.index,axes:Q.axes,buttons:Q.buttons,drive:Y.driveVector,aux:F,cameraAxis:Y.cameraAxis,bindings:Y.sources})}),[K,C,p?.defaults?.profile,p?.profiles,M,L,x,d,o,i,s,h]),null}function hg(n){const s=n?.sensors||{},i=s.oiMode?.label||"Unknown",o=i.toLowerCase(),f=s.chargingState?.label||"",d=!!s.chargingSources?.homeBase,h=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:h,dockedNotCharging:d&&!h,dockingInProgress:!d&&!h&&o==="passive",oiLabel:i,chargingLabel:f}}function pg(n){const s=cl(n);return m.useMemo(()=>hg(s),[s])}function Ws({label:n,value:s,tone:i="neutral"}){const o=i==="good"?"border-emerald-200 bg-emerald-600 text-white":i==="warn"?"border-amber-200 bg-amber-600 text-white":i==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return r.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:r.jsx("span",{className:"text-base font-semibold md:text-lg",children:s})})}function V0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function lf({label:n,tone:s}){const i=s==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":s==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return r.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${i}`,children:n})}function aj({instructions:n,onConfirm:s,onCancel:i,pending:o}){return r.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),r.jsx("p",{className:"text-sm text-slate-200",children:n.summary}),r.jsx(kf,{steps:n.steps,tone:"indigo"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[r.jsx("button",{type:"button",onClick:i,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),r.jsx("button",{type:"button",disabled:o,onClick:s,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Docking…":"Confirm Dock"})]})]})})}function xg({layout:n="desktop",expand:s=!1,fill:i=!1,driveDockState:o,compactHeightClass:f=""}){const d=n==="mobile",{state:{roverId:h,keymap:x},actions:p}=_t(),g=cl(h),y=o??hg(g),{driving:b,docked:A,charging:R,dockingInProgress:N}=y,[q,j]=m.useState(null),[w,E]=m.useState(!1),[C,M]=m.useState(!1),L=!h||q!==null,K=!h||q!==null,_=bn(x?.driveMacro?.[0]),Q=bn(x?.dockMacro?.[0]),B={summary:"You are about to trigger an automatic docking attempt! To have a successful dock:",steps:["Line up the rover straight in front of the dock","Make sure the rover is about one foot or half a meter away from the dock","Press Confirm Dock to begin the docking process"]},U="Click this button to initate auto-dock.",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"]},te=A?"Docked":"Undocked",fe=A?"good":"bad",oe=R?"Charging":A?"Charging in 5s":"—",G=R?"good":A?"warn":"bad",T=async()=>{if(!(!h||q)){j("drive");try{p.setMode("drive"),await p.runMacro("drive-sequence")}catch(ue){alert(ue.message)}finally{j(null)}}},F=async()=>{if(!(!h||q)){E(!1),M(!1),j("drive");try{p.setMode("drive"),await p.runMacro("drive-sequence")}catch(ue){alert(ue.message)}finally{j(null)}}},J=async()=>{if(!(!h||q)){j("dock");try{p.setMode("dock"),await p.runMacro("seek-dock")}catch(ue){alert(ue.message)}finally{j(null),E(!1),M(!1)}}},se=()=>{K||(M(!0),E(!0))},de="flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-0.75 py-0.75 text-slate-100 shadow-md transition hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 select-none no-touch-select",k="text-center",H="items-center justify-between",P="items-center justify-center",ne=d?"text-sm font-semibold":"",pe="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",ie="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ce="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",ve="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",xe=s||N,Ue=xe?"h-full flex-1":i?"flex-1":"",$e=d&&!xe?f:"",Ne=d&&!xe?P:H,ae=d&&!xe&&b&&A;if(!b&&!N)return r.jsxs("button",{type:"button",onClick:F,onContextMenu:ue=>ue.preventDefault(),disabled:L,className:`${de} ${Ue} ${$e} ${k} ${Ne} ${ne} ${pe}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[_?r.jsx(V0,{label:_}):null,r.jsx(lf,{label:"Click to start",tone:"emerald"})]}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:Y.summary}),r.jsx(kf,{steps:Y.steps,tone:"emerald"})]}):null]}),xe?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Ws,{label:"Dock",value:te,tone:fe}),r.jsx(Ws,{label:"Charge",value:oe,tone:G})]}):null]});if(N){const ue={summary:"If the rover is failing to dock, click to drive and try again.",steps:["The rover should be slowly wiggling towards the dock","If it is obviously not working, press this button to enter driving mode and try again"]};return r.jsxs("button",{type:"button",disabled:L,onClick:T,onContextMenu:be=>be.preventDefault(),className:`${de} ${Ue} ${$e} ${k} ${Ne} ${ne} ${ie}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),xe?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(lf,{label:"Return to driving mode",tone:"emerald"})}):null]}),xe?r.jsx("p",{className:"text-sm text-amber-50/90",children:ue.summary}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Ws,{label:"Dock",value:te,tone:fe}),r.jsx(Ws,{label:"Charge",value:oe,tone:G})]}),d?null:r.jsx(kf,{steps:ue.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:K,onClick:se,onContextMenu:ue=>ue.preventDefault(),className:d?`flex w-full ${de} ${$e} ${k} ${Ne} ${ne} ${ae?ve:ce}`:`${de} ${Ue} ${k} ${H} ${ne} ${ce}`,children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:ae?"Docked!":"Dock and Charge"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[Q?r.jsx(V0,{label:Q}):null,r.jsx(lf,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!d&&xe&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:U}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Ws,{label:"Dock",value:te,tone:fe}),r.jsx(Ws,{label:"Charge",value:oe,tone:G})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),C||!d&&w?r.jsx(aj,{instructions:B,pending:q==="dock",onCancel:()=>{M(!1),E(!1)},onConfirm:J}):null]})}function kf({steps:n,tone:s="emerald"}){const i=s==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":s==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=s==="emerald"?"text-emerald-200":s==="amber"?"text-amber-200":"text-indigo-200";return r.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${i}`,children:n.map((f,d)=>r.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[r.jsxs("div",{className:"flex items-start",children:[r.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[d+1,"."]}),r.jsx("span",{className:"align-top",children:f})]}),d<n.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},f))})}function rf(n){return typeof n=="boolean"}function gg({nightVisionOn:n,disabled:s,onToggle:i,keyLabel:o,className:f="",heightClass:d=""}){const[h,x]=m.useState(rf(n)?n:null);m.useEffect(()=>{rf(n)&&x(n)},[n]);const p=rf(h),g=p?h:!1,y=p?g?"On":"Off":"—",b=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",A=()=>{if(s)return;const N=p?!g:!0;x(N),i?.(N)},R=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",g?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",d,f].filter(Boolean).join(" "),[f,g,d]);return r.jsxs("button",{type:"button",onClick:A,onContextMenu:N=>N.preventDefault(),disabled:s,"aria-pressed":g,className:R,children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?r.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:y})]})}function of(n){const s=Number(n);return!Number.isFinite(s)||s<=0?0:Math.min(5e3,Math.round(s))}function vg({disabled:n,onStart:s,onStop:i,keyLabel:o,active:f,heat:d=0,className:h="",defaultShowSettings:x=!0,showSettingsToggle:p=!1,compactSettings:g=!1}){const[y,b]=m.useState(!1),[A,R]=m.useState(x),{value:N,save:q}=Qe("horn",is),[j,w]=m.useState(N?.waveform||is.waveform),[E,C]=m.useState(()=>[...Array.isArray(N?.freqs)?N.freqs:is.freqs,0,0,0,0].slice(0,4).map(T=>of(T)));m.useEffect(()=>{w(N?.waveform||is.waveform),Array.isArray(N?.freqs)&&C([...N.freqs,0,0,0,0].slice(0,4).map(G=>of(G)))},[N?.freqs,N?.waveform]);const M=!!f,L=Math.max(0,Math.min(1,Number(d)||0)),K=m.useMemo(()=>["group relative flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-1 py-1.5 text-xs font-semibold select-none no-touch-select",M?"border-fuchsia-300/70 bg-fuchsia-700 text-fuchsia-50":"border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800","disabled:opacity-50",h].filter(Boolean).join(" "),[h,M]),_=()=>{n||y||(b(!0),s?.())},Q=()=>{y&&(b(!1),i?.())};m.useEffect(()=>{!M&&y&&b(!1)},[M,y]);const B=j==="sine"?"sine":"saw",U=m.useCallback(G=>{const T=G.target.value==="sine"?"sine":"saw";w(T),q(F=>({...F??{},waveform:T}))},[q]),Y=m.useCallback((G,T)=>{C(F=>{const J=[...F];return J[G]=of(T),q(se=>({...se??{},freqs:J})),J})},[q]),te=G=>{if(n)return;const T=G.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(G.preventDefault(),_())},fe=G=>{const T=G.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(G.preventDefault(),Q())},oe=p?r.jsx("button",{type:"button",onClick:G=>{G.preventDefault(),R(T=>!T)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:A?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":y,onPointerDown:te,onPointerUp:fe,onPointerLeave:Q,onPointerCancel:Q,onContextMenu:G=>G.preventDefault(),onBlur:Q,className:K,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${L*100}%, rgba(0,0,0,0) ${L*100}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${M?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),r.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[r.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[r.jsx("span",{children:"Horn"}),o?r.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),oe,r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${M?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:M?"Honk":"Hold"})]}),A?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:B,onChange:U,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:E.map((G,T)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:G,onChange:F=>Y(T,F.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))})]}):r.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:B,onChange:U,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),E.map((G,T)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:G,onChange:F=>Y(T,F.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))]}):null]})}function Yr(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function $0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function yg({value:n,min:s,max:i,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:h,onCommit:x,throttleMs:p=0,disabled:g=!1,keyDownLabel:y,keyUpLabel:b,className:A="",labelRowClass:R="",labelClass:N="",valueClass:q="",sliderClass:j="",endpointClass:w="",endpointLabelClass:E="",accentClass:C="",showValue:M=!0,showEndpoints:L}){const K=d==="vertical",Q=typeof L=="boolean"?L:!K,[B,U]=m.useState(n),Y=m.useRef(!1),te=m.useRef(null);m.useEffect(()=>{Y.current||U(n)},[n]),m.useEffect(()=>()=>{te.current&&clearTimeout(te.current)},[]);const fe=J=>{if(h){if(p>0){te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{h(J)},p);return}h(J)}},oe=J=>{const se=Number.parseFloat(J.target.value);Number.isNaN(se)||(Y.current=!0,U(se),fe(se))},G=()=>{Y.current=!1,te.current&&(clearTimeout(te.current),te.current=null),x?x(B):p>0&&h?.(B)};if(typeof s!="number"||typeof i!="number")return null;const T=[K?"h-28 w-5":"w-full",C,j].filter(Boolean).join(" "),F=r.jsx("input",{type:"range",orient:K?"vertical":void 0,min:s,max:i,step:o,value:Number.isFinite(B)?B:s,onChange:oe,onMouseUp:G,onTouchEnd:G,onPointerUp:G,disabled:g,className:T,style:K?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return K?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${A}`.trim(),children:[M?r.jsx("div",{className:`flex flex-col items-center ${R}`.trim(),children:r.jsx("span",{className:q,children:Yr(n)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:N,children:f}),F]})]}):r.jsxs("div",{className:`space-y-0.5 ${A}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${R}`.trim(),children:[r.jsx("span",{className:N,children:f}),M?r.jsx("span",{className:q,children:Yr(n)}):null]}),r.jsxs("div",{children:[F,Q?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${w}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${E}`.trim(),children:[y?r.jsx($0,{label:y}):null,Yr(s)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${E}`.trim(),children:[Yr(i),b?r.jsx($0,{label:b}):null]})]}):null]})]})}const Fr="mobile-joystick",sj=80,lj=.15,ij={main:0,side:0,vacuum:0},rj={main:127,side:127,vacuum:127},oj={main:-127,side:-127,vacuum:-127};function cj({disabled:n,layout:s,radius:i,onMove:o,onStop:f}){const d=m.useRef(null),h=m.useRef(null),x=m.useRef({x:0,y:0}),[p,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),y=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),b=m.useCallback(q=>{if(n||h.current!==null)return;q.preventDefault();const j=d.current;if(!j)return;const w=j.getBoundingClientRect(),E=q.clientX-w.left,C=q.clientY-w.top;x.current={x:E,y:C},h.current=q.pointerId,j.setPointerCapture?.(q.pointerId),g({active:!0,base:{x:E,y:C},knob:{x:0,y:0}})},[n]),A=m.useCallback(q=>{if(n||h.current!==q.pointerId)return;q.preventDefault();const j=d.current;if(!j)return;const w=j.getBoundingClientRect(),E=q.clientX-w.left,C=q.clientY-w.top,M=E-x.current.x,L=C-x.current.y,K=Math.min(Math.hypot(M,L),i),_=Math.atan2(L,M),Q=Math.cos(_)*K,B=Math.sin(_)*K,U={x:ll(Q/i),y:ll(-B/i),boost:!1};g(Y=>({...Y,knob:{x:Q,y:B}})),o?.(U)},[n,o]),R=m.useCallback(q=>{if(h.current!==q.pointerId)return;q.preventDefault(),d.current?.releasePointerCapture?.(q.pointerId),y()},[y]);return m.useEffect(()=>{n&&y()},[n,y]),r.jsxs("div",{ref:d,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:A,onPointerUp:R,onPointerLeave:R,onPointerCancel:R,onContextMenu:q=>q.preventDefault(),children:[!p.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"})]}),p.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:p.base.x,top:p.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:p.base.x+p.knob.x,top:p.base.y+p.knob.y}})]})]})}function uj({layout:n}){const{state:{roverId:s},actions:{setDriveVector:i,registerInputState:o}}=_t(),f=pg(s),d=f.docked&&!f.driving,h=d||f.dockingInProgress,x=!s,p=sj,g=lj,y=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{x&&(y.current={x:0,y:0,boost:!1})},[x]);const b=m.useCallback((q={})=>{if(x)return;const j={x:ll(q.x??0),y:ll(q.y??0),boost:!!q.boost},w={x:y.current.x+(j.x-y.current.x)*(1-g),y:y.current.y+(j.y-y.current.y)*(1-g),boost:j.boost};y.current=w,i(w,{source:Fr}),o(Fr,{vector:w,lastEvent:"move"})},[x,o,i,g]),A=m.useCallback(()=>{if(x)return;const q={x:0,y:0,boost:!1};y.current=q,i(q,{source:Fr}),o(Fr,{vector:q,lastEvent:"stop"})},[x,o,i]),N=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:N,children:[r.jsx(xg,{layout:"mobile",expand:h,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),h?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(cj,{disabled:x,layout:n,radius:p,onMove:b,onStop:A})})]})}function G0({id:n,label:s,values:i,color:o,disabled:f,onPress:d,onRelease:h}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:x=>{x.preventDefault(),d(n,i)},onPointerUp:()=>h(n),onPointerLeave:()=>h(n),onPointerCancel:()=>h(n),onContextMenu:x=>x.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:s})}function fj({layout:n}){const{state:{roverId:s,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,setAuxMotors:x,startHorn:p,stopHorn:g}}=_t(),y=!s,b=m.useRef(null),A=i?.config,R=!!(s&&i?.enabled&&A),N=!!(s&&f?.nightVision),q=f?.nightVisionState,j=!!(s&&f?.horn),w=o?.overheated,E=typeof A?.minAngle=="number"?A.minAngle:-45,C=typeof A?.maxAngle=="number"?A.maxAngle:45,M=typeof i?.angle=="number"?i.angle:typeof A?.homeAngle=="number"?A.homeAngle:(E+C)/2,L=m.useCallback(Q=>{N&&h(Q)},[N,h]),K=m.useCallback((Q,B)=>{y||(b.current=Q,x(B))},[y,x]),_=m.useCallback(Q=>{y||b.current===Q&&(b.current=null,x(ij))},[y,x]);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(G0,{id:"aux-vac-forward",label:"Vacuum Forward",values:rj,color:"bg-fuchsia-600",disabled:y,onPress:K,onRelease:_}),r.jsx(G0,{id:"aux-vac-backward",label:"Vacuum Backward",values:oj,color:"bg-fuchsia-800",disabled:y,onPress:K,onRelease:_})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[R?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(yg,{value:M,min:E,max:C,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,N?r.jsx(gg,{nightVisionOn:q?.nightVisionOn,disabled:y,onToggle:L,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:j?r.jsx(vg,{disabled:y||w,onStart:p,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function co({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(fj,{layout:n})})}function uo({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(uj,{layout:n==="landscape"?"landscape":"portrait"})})}function dj({swapColumns:n=!1}){const s="h-[min(60svh,24rem)]",i=n?r.jsx(uo,{layout:"portrait",className:s}):r.jsx(co,{layout:"portrait",className:s}),o=n?r.jsx(co,{layout:"portrait",className:s}):r.jsx(uo,{layout:"portrait",className:s});return r.jsx("section",{className:"panel",children:r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[i,o]})})}function mj(n=[],s={}){const i=Rn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),x=m.useRef(new Map),p=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id),[n]),g=m.useMemo(()=>{const N=p.join("|");return f?`${N}|v:${f}`:N},[p,f]),y=m.useRef([]),[b,A]=m.useState(0),R=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const N=()=>A(q=>q+1);return i.on("connect",N),()=>i.off("connect",N)},[i]),m.useEffect(()=>{y.current=p},[g,p]),m.useEffect(()=>{x.current.forEach(N=>URL.revokeObjectURL(N)),x.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){x.current.forEach(E=>URL.revokeObjectURL(E)),x.current.clear(),h({});return}if(!y.current.length||!i)return;let N=!1;const q=y.current,j=(E={},C)=>{if(N||!E.id||!C)return;const M=C.byteLength??C.length??0,L=Date.now(),K=R.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:K.count+1,totalBytes:K.totalBytes+M,lastLogAt:K.lastLogAt};if(!_.lastLogAt||L-_.lastLogAt>=1e4){const Y=_.count?_.totalBytes/_.count:0;console.log("[roomCamera]",E.id,`frame=${M}B`,`avg=${Math.round(Y)}B`,`count=${_.count}`),_.lastLogAt=L}R.current.set(E.id,_);const Q=new Blob([C],{type:"image/jpeg"}),B=URL.createObjectURL(Q),U=x.current.get(E.id);U&&URL.revokeObjectURL(U),x.current.set(E.id,B),h(Y=>({...Y,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:B}}))},w=(E={})=>{N||!E.id||h(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return i.on("roomCamera:frame",j),i.on("roomCamera:status",w),i.emit("roomCamera:subscribe",{ids:q},(E={})=>{E.error}),()=>{N=!0,i.emit("roomCamera:unsubscribe",{ids:q}),i.off("roomCamera:frame",j),i.off("roomCamera:status",w),x.current.forEach(E=>URL.revokeObjectURL(E)),x.current.clear()}},[i,g,o,b]),d}function hj({feed:n,label:s}){const[i,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(d=>!d))},[n?.ts,n?.objectUrl]);const f=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return r.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?r.jsx("img",{src:n.objectUrl,alt:s,className:"h-full w-full object-cover"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:s}),r.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[r.jsx("span",{className:`h-2 w-2 rounded-full ${i?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:f})]})]})}function pj(){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 bg=["horizontal","vertical"];function cf(n,s){return bg.includes(n)?n:s}function ed({defaultOrientation:n="horizontal",orientation:s,hideLayoutToggle:i=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=ze(),h=d?.roomCameras||[],x=mj(h.map(j=>({id:j.id}))),{value:p,save:g}=Qe("roomCameraPanels",{}),[y,b]=m.useState(()=>cf(f?p?.[f]:n,"horizontal"));m.useEffect(()=>{if(!f)return;const j=p?.[f];j&&b(cf(j,"horizontal"))},[f,p?.[f]]);const A=s?cf(s,"horizontal"):y,R=A==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",N=!i&&!s&&h.length>0,q=j=>{b(j),f&&g(w=>({...w||{},[f]:j}))};return h.length===0?r.jsx(pj,{}):r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&r.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room cameras"}),r.jsx("span",{className:"text-xs text-slate-500",children:h.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:N&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-500",children:"Layout:"}),r.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:bg.map(j=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${A===j?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>q(j),children:j==="vertical"?"Vertical":"Grid"},j))})]})})]}),r.jsx("div",{className:R,children:h.map(j=>{const w=x[j.id]||null;return r.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:r.jsx(hj,{feed:w,label:j.name||j.id})},j.id)})})]})}function td(){const{logs:n}=ze();return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Server logs"}),r.jsx("span",{children:n.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?r.jsx("p",{children:"No logs yet."}):n.slice().reverse().map(s=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:s.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",s.level,"]"]})," ",s.label&&r.jsxs("span",{className:"text-teal-400",children:["[",s.label,"]"]})," ",r.jsx("span",{children:s.message})]},s.id))})]})}function xj(n){if(!n)return null;if(typeof n=="string"){const s=String(n).trim();return s?{type:"rover",id:s,key:s}:null}if(typeof n=="object"){if(n.type&&n.id){const s=String(n.id);let i=n.key;return i||(i=n.type==="room"?`room:${s}`:s),{type:n.type,id:s,key:i}}if(n.roverId){const s=String(n.roverId);return{type:"rover",id:s,key:n.key||s}}if(n.roomCameraId){const s=String(n.roomCameraId);return{type:"room",id:s,key:n.key||`room:${s}`}}}return null}function gj(n=[]){const s=new Set,i=[];return n.forEach(o=>{!o?.key||s.has(o.key)||(s.add(o.key),i.push(o))}),i.sort((o,f)=>o.key.localeCompare(f.key))}function vi(n=[],s={}){const i=Rn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),x=m.useMemo(()=>Array.isArray(n)?gj(n.map(xj).filter(Boolean)):[],[n]),p=m.useMemo(()=>{const R=x.map(N=>`${N.type}:${N.id}:${N.key}`).join("|");return f?`${R}|v:${f}`:R},[x,f]),g=m.useRef([]),[y,b]=m.useState(0);return m.useEffect(()=>{if(!i)return;const R=()=>b(N=>N+1);return i.on("connect",R),()=>{i.off("connect",R)}},[i]),m.useEffect(()=>{g.current=x},[x]),m.useEffect(()=>{if(!p||!o){h({});return}const R=g.current;let N=!1;function q(j){const w=j.type==="room"?{roomCameraId:j.id}:{roverId:j.id};i.emit("video:request",w,(E={})=>{N||h(C=>({...C,[j.key]:E}))})}return R.forEach(j=>{q(j)}),()=>{N=!0}},[i,p,o,y]),m.useMemo(()=>{if(!p||!o)return{};const R={};return x.forEach(N=>{d[N.key]&&(R[N.key]=d[N.key])}),R},[p,d,x])}function nd(n=[],s={}){const i=Rn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),x=m.useRef(new Map),p=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id).filter(Boolean),[n]),g=m.useMemo(()=>{const N=p.join("|");return f?`${N}|v:${f}`:N},[p,f]),y=m.useRef([]),[b,A]=m.useState(0),R=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const N=()=>A(q=>q+1);return i.on("connect",N),()=>i.off("connect",N)},[i]),m.useEffect(()=>{y.current=p},[g,p]),m.useEffect(()=>{x.current.forEach(N=>URL.revokeObjectURL(N)),x.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){x.current.forEach(E=>URL.revokeObjectURL(E)),x.current.clear(),h({});return}if(!y.current.length||!i)return;let N=!1;const q=y.current,j=(E={},C)=>{if(N||!E.id||!C)return;const M=C.byteLength??C.length??0,L=Date.now(),K=R.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:K.count+1,totalBytes:K.totalBytes+M,lastLogAt:K.lastLogAt};if(!_.lastLogAt||L-_.lastLogAt>=1e4){const Y=_.count?_.totalBytes/_.count:0;console.log("[roverSnapshot]",E.id,`frame=${M}B`,`avg=${Math.round(Y)}B`,`count=${_.count}`),_.lastLogAt=L}R.current.set(E.id,_);const Q=new Blob([C],{type:"image/jpeg"}),B=URL.createObjectURL(Q),U=x.current.get(E.id);U&&URL.revokeObjectURL(U),x.current.set(E.id,B),h(Y=>({...Y,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:B}}))},w=(E={})=>{N||!E.id||h(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return i.on("roverSnapshot:frame",j),i.on("roverSnapshot:status",w),i.emit("roverSnapshot:subscribe",{ids:q},(E={})=>{E.error}),()=>{N=!0,i.emit("roverSnapshot:unsubscribe",{ids:q}),i.off("roverSnapshot:frame",j),i.off("roverSnapshot:status",w),x.current.forEach(E=>URL.revokeObjectURL(E)),x.current.clear()}},[i,g,o,b]),d}const vj={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function yj(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 bj(n){if(!n)return{};const s=`${n}:${n}`;return{Authorization:`Basic ${yj(s)}`}}class Y0{constructor({url:s,token:i,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:h=!0}){this.url=s,this.token=i,this.video=o,this.audioOnly=d,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=f}notify(s,i){typeof this.onStatus=="function"&&this.onStatus(s,i)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const s=new RTCPeerConnection(vj);this.pc=s;const i=new MediaStream;s.ontrack=o=>{o.streams[0]?.getTracks().forEach(f=>i.addTrack(f)),this.video.srcObject=i,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?s.addTransceiver("audio",{direction:"recvonly"}):(s.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&s.addTransceiver("audio",{direction:"recvonly"})),s.onconnectionstatechange=()=>{this.notify(s.connectionState)},s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await s.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await s.setLocalDescription(o);const f=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...bj(this.token)},body:o.sdp,signal:this.abortController.signal});if(!f.ok)throw new Error(`WHEP request failed: ${f.status}`);const d=await f.text();await s.setRemoteDescription({type:"answer",sdp:d}),s.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(s=>s.track?.stop()),this.pc.getReceivers().forEach(s=>s.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function Mf({sensors:n={},variant:s="full",size:i,overlay:o=!1}){const f=i||(s==="mini"?190:260),d=f/2,h=f*.07,x=d,p=d+h,g=d*.8,y=g-4,b=g+4,A=g-14,R=g-6,N=g*.65,q=n?.bumpsAndWheelDrops||{},j=n?.wheelOvercurrents||{},w=n?.wheelLeftCurrentMa??0,E=n?.wheelRightCurrentMa??0,C=n?.sideBrushCurrentMa??0,M=n?.mainBrushCurrentMa??0,L=6,K=q.bumpLeft?L:0,_=q.bumpRight?L:0,Q=Ej({count:6,totalSpan:140,gap:6,startAngle:-70}),B=["L","FL","CL","CR","FR","R"],U=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],Y=Q.map((G,T)=>({label:B[T],start:G.start,end:G.end,value:U[T]})),te=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],fe=U.filter(G=>G!=null),oe=fe.length?Math.max(...fe,1200):1200;return r.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${f}px`,height:`${f}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),r.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",oe]})]}),r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${f}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:x,cy:p,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(F0,{cx:x-N,cy:p,current:w,drop:q.wheelDropLeft,overcurrent:j.leftWheel,label:"L"}),r.jsx(F0,{cx:x+N,cy:p,current:E,drop:q.wheelDropRight,overcurrent:j.rightWheel,label:"R"}),r.jsx(jj,{cx:x+g*.65,cy:p-g*.55,current:C,overcurrent:j.sideBrush}),r.jsx(Nj,{cx:x,cy:p,current:M,overcurrent:j.mainBrush,variant:s,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),Y.map(G=>{const T=wj(G.value,oe),F=b+4,J=F+28;return r.jsx(Sj,{cx:x,cy:p,rBase:J,rTip:F,startDeg:G.start,endDeg:G.end,color:T,value:G.value,max:oe},G.label)}),te.map(G=>{const T=Cj(G.value,G.active);return r.jsx(uf,{cx:x,cy:p,rInner:A,rOuter:R,startDeg:G.start,endDeg:G.end,color:T,opacity:1,pulse:!!G.active},G.label)}),r.jsx(uf,{cx:x,cy:p,rInner:y-K,rOuter:b-K,startDeg:-70,endDeg:-6,color:q.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!q.bumpLeft}),r.jsx(uf,{cx:x,cy:p,rInner:y-_,rOuter:b-_,startDeg:6,endDeg:70,color:q.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!q.bumpRight})]})]})}function uf({cx:n,cy:s,rInner:i,rOuter:o,startDeg:f,endDeg:d,color:h,pulse:x=!1,opacity:p=1}){const g=(i+o)/2,y=o-i,b=Aj(n,s,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:b,stroke:h,strokeWidth:y,strokeLinecap:"round",fill:"none",opacity:p}),x?r.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:y,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function Sj({cx:n,cy:s,rBase:i,rTip:o,startDeg:f,endDeg:d,color:h,value:x,max:p}){const g=(f+d)/2,y=mi(n,s,o,g),b=vo(x!=null?x/(p||1):0),A=Math.pow(b,.35),R=i-(i-o)*A,N=mi(n,s,R,f),q=mi(n,s,R,d),j=`M ${y.x} ${y.y} L ${N.x} ${N.y} L ${q.x} ${q.y} Z`;return r.jsx("path",{d:j,fill:h,opacity:1,stroke:"none"})}function Aj(n,s,i,o,f){let d=o,h=f;h<=d&&(h+=360);const x=mi(n,s,i,d),p=mi(n,s,i,h);return["M",x.x,x.y,"A",i,i,0,0,1,p.x,p.y].join(" ")}function mi(n,s,i,o){const f=Sg(o);return{x:n+i*Math.cos(f),y:s+i*Math.sin(f)}}function Sg(n){return(n-90)*Math.PI/180}function ad(n,s){if(s)return"#ef4444";const i=Math.abs(n);return i>900?"#f59e0b":i>300?"#22c55e":"#64748b"}function vo(n){return Math.max(0,Math.min(1,n))}function F0({cx:n,cy:s,current:i,drop:o,overcurrent:f,label:d}){const h=Math.abs(i),x=vo(h/1200),p=ad(i,f),g=56,y=14,b=9,A=3,R=g*x,N=d==="L"?-1:1,q=N*(-b/2-A/2),j=N*(y/2+A/2),w=y+b+A+2,E=g+4;return r.jsxs("g",{transform:`translate(${n},${s})`,children:[r.jsx("rect",{x:-w/2,y:-E/2,width:w,height:E,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:q-y/2,y:-g/2,width:y,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:q-y/2,y:g/2-R,width:y,height:R,fill:p,className:f?"animate-pulse":""}),r.jsx("rect",{x:j-b/2,y:-g/2,width:b,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),r.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:d})]})}function jj({cx:n,cy:s,current:i,overcurrent:o}){var f=Math.abs(i);f<10&&(f=0);const d=ad(i*3,o),h=43,x=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${n}px ${s}px`,animation:x?`spin ${x}s linear infinite`:"none",animationDirection:x?"reverse":"normal"},children:[r.jsx("circle",{cx:n,cy:s,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const y=Sg(g),b=n+h*Math.cos(y),A=s+h*Math.sin(y);return r.jsx("line",{x1:n,y1:s,x2:b,y2:A,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:n,cy:s,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function Nj({cx:n,cy:s,current:i,overcurrent:o,variant:f,dirtLeft:d,dirtRight:h}){const x=Math.abs(i),p=ad(i,o),g=1,y=96,b=12,A=`main-brush-pattern-a-${f}`,R=`main-brush-pattern-b-${f}`,N=x>0?.6:null,q=i>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[A,R].map((j,w)=>r.jsxs("pattern",{id:j,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:p,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),N?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${q*(w===0?6:-6)}`,dur:`${N}s`,repeatCount:"indefinite"}):null]},j))}),r.jsx("rect",{x:n-y/2,y:s-14,width:y,height:b,rx:"3",fill:`url(#${A})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:n-y/2,y:s+4,width:y,height:b,rx:"3",fill:`url(#${R})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:n-y/4,cy:s-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:n+y/4,cy:s+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:n-y/2-4,y:s-16,width:y+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function wj(n,s){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=vo(n/(s||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function Cj(n,s){if(s)return"#ef4444";const i=vo(n==null?0:n/4095),o=[47,55,69],f=[245,158,11],[d,h,x]=o.map((p,g)=>Math.round(p+(f[g]-p)*i));return`rgb(${d}, ${h}, ${x})`}function Ej({count:n,totalSpan:s,gap:i,startAngle:o}){const d=(s-i*(n-1))/n,h=[];let x=o;for(let p=0;p<n;p+=1){const g=x+d;h.push({start:x,end:g}),x=g+i}return h}function Ag(){const{value:n,save:s}=Qe("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,f=>{s({hudMapDesktop:!!f})}]}const kj={discord:Px,kofi:k0,"ko-fi":k0,wiki:WS,throne:eA},Mj={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 qj(){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 Rj(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 sd({id:n,label:s,url:i,className:o=""}){if(!i)return null;qj();const f=Rj(n,s),d=kj[f]||tA,h=Mj[f]||null,x=s||n||"Link";return r.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","aria-label":x,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${h?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:h||void 0,children:[r.jsx(d,{className:"mr-0"}),x]})}const yi=10;function jg({batteryState:n=null,charge:s=null,config:i=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,f=n?.warnActive??null,d=n?.urgentActive??null,h=i?.Full??null,x=i?.Warn??null,p=i?.Urgent??null,g=s??n?.charge??null;let y=o;if(y==null&&(y=Tj({charge:g,full:h,warn:x,urgent:p})),y==null)return{available:!1};const b=Math.max(0,Math.min(1,y/100)),A=f??(x!=null&&g!=null&&g<=x),R=d??(p!=null&&g!=null&&g<=p);return{available:!0,percent:b,percentDisplay:y,warnActive:A,urgentActive:R,warnDisplayPercent:yi}}function Tj({charge:n,full:s,warn:i,urgent:o}){if(n!=null&&s!=null&&i!=null&&o!=null&&s>i&&i>o){const f=yi/100,d=1-f;if(n<=o)return 0;if(n<=i){const x=(n-o)/(i-o);return Math.round(Math.max(0,Math.min(1,x))*yi)}if(n>=s)return 100;const h=(n-i)/(s-i);return Math.round((f+Math.max(0,Math.min(1,h))*d)*100)}return null}const Dj=1600,_j=800;function vn(...n){return n.filter(Boolean).join(" ")}function qf({visual:n,orientation:s="horizontal",variant:i="inline",compact:o=!1,showLabel:f,className:d=""}){const h=i==="background",x=s==="vertical",p=f??!h;if(!n?.available){if(h){const te=yi,fe=vn("absolute z-10",x?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!A&&"battery-tick-warn"),oe=x?{bottom:`${te}%`}:{left:`${te}%`},G=vn("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:G,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:fe,style:oe})]})}return x?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,y=Math.max(0,Math.min(100,g)),b=n.warnDisplayPercent??yi,A=!!n.urgentActive,R=!!n.warnActive,N=A?`${_j}ms`:R?`${Dj}ms`:void 0,j=h?A||R?"bg-red-500/45":"bg-emerald-500/45":A||R?"bg-red-500":"bg-emerald-500",w=A||R?"bg-red-900/35":"bg-slate-900/35",E=A||R?"bg-red-900/45":"bg-slate-900/35",C=vn(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",x&&!h?"flex flex-col items-center justify-center":"w-full",d);if(h){const te=x?{height:`${y}%`}:{width:`${y}%`},fe=vn("absolute",x?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",A&&"battery-urgent-flash"),oe=vn("absolute z-10",x?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!A&&"battery-tick-warn"),G=x?{bottom:`${b}%`}:{left:`${b}%`};return r.jsxs("div",{className:C,children:[r.jsx("div",{className:vn("absolute inset-0",w,A&&"battery-urgent-flash")}),r.jsx("div",{className:fe,style:{...te,animationDuration:N}}),r.jsx("div",{className:oe,style:G})]})}const M=vn("relative overflow-hidden rounded-sm border border-slate-800",A||R?E:"bg-zinc-900/90",A&&"battery-urgent-flash",x?"w-full flex-1":o?"h-4":"h-5"),L=x?{height:`${y}%`}:{width:`${y}%`},K=vn("absolute",x?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",A&&"battery-urgent-flash"),_=vn("absolute z-10",x?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!A&&"battery-tick-warn"),Q=x?{bottom:`${b}%`}:{left:`${b}%`},B=`Battery ${g}%`,U=vn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",x?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),Y=vn("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:C,children:[r.jsxs("div",{className:M,children:[r.jsx("div",{className:K,style:{...L,animationDuration:N}}),r.jsx("div",{className:_,style:Q})]}),p&&!x?r.jsx("div",{className:U,children:r.jsx("span",{className:Y,children:B})}):null,p&&x?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:Y,children:[g,"%"]})}):null]})}const X0=2e3,Oj=3e3,Bj=3e3,Lj=40,zj=1e3;function bi({sessionInfo:n,audioSessionInfo:s,videoMode:i="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,roverColor:h=null,forceMute:x=!1,telemetryFrame:p,batteryConfig:g,layoutFormat:y="desktop",hudVariant:b="default",driverLabel:A=null,hudForceMap:R=!1,hudMapPosition:N="top-center",hudLabelScale:q=1,fitParent:j=!1,overcurrentLimiter:w=null,showTurnCue:E=!1,turnTimerText:C=null,turnSeconds:M=null,isActiveDriver:L=!1,idleSkipSeconds:K=null}){const{session:_}=ze(),Q=m.useRef(null),B=m.useRef(null),U=m.useRef(null),Y=m.useRef(null),te=m.useRef(null),fe=m.useRef(null),oe=m.useRef(null),G=m.useRef(null),[T,F]=m.useState("idle"),[J,se]=m.useState(null),[de,k]=m.useState("idle"),[H,P]=m.useState(null),[ne,pe]=m.useState(0),[ie,ce]=m.useState(0),[ve,ye]=m.useState(!0),xe=!!s?.url,Ue=i==="snapshot",$e=p?.sensors,{value:Ne}=Qe("audio",Dt),ae=Number.isFinite(Ne?.masterVolume)?Ne.masterVolume:Dt.masterVolume,ue=Number.isFinite(Ne?.roverVolume)?Ne.roverVolume:Dt.roverVolume,be=typeof Ne?.mainBrushDuckEnabled=="boolean"?Ne.mainBrushDuckEnabled:typeof Ne?.autoLevelEnabled=="boolean"?Ne.autoLevelEnabled:Dt.mainBrushDuckEnabled,Me=Number.isFinite(Ne?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Ne.mainBrushDuckAmount)):Dt.mainBrushDuckAmount,le=Math.max(0,Math.min(1,ae*ue)),re=$e?.batteryChargeMah??null,me=y==="desktop",we=!me,et=we?"top-right":N,[dt]=Ag(),Le=R||we?!0:dt,xt=jg({charge:re,config:g}),mt=$e?.wheelOvercurrents||null,Tn=mt==null?[]:Object.entries(mt).filter(([,Ae])=>!!Ae).map(([Ae])=>Ae),Et=w?.caps||null,cs=w?.overcurrent?.groups||null,Gt=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),Oa=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),wo=m.useMemo(()=>{if(!Et)return null;const Ae=Number.isFinite(Et?.drive?.cap)?Et.drive.cap:1,Ke=Number.isFinite(Et?.aux?.cap)?Et.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(Ae,Ke)))},[Et]),Dn=!!w?.isActive,At=Tn.length?Tn:Dn?["limiter"]:[],Yt=wo??(Tn.length?1:0),kt=!!At.length,ca=!!((Number($e?.mainBrushCurrentMa)||0)>Lj||$e?.wheelOvercurrents?.mainBrush),Co=be&&ca?1-Me:1,us=Math.max(0,Math.min(1,le*Co)),fs=be&&ca&&Me>0?`Volume decreased ${Math.round(Me*1e3)/10}%`:null,Ba=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Ba.current={hasDedicatedAudio:xe,audioUrl:s?.url||null,mainBrushDuckEnabled:be,mainBrushDuckAmount:Me,mainBrushActive:ca,baseRoverGain:le,effectiveRoverGain:us}},[xe,s?.url,be,Me,ca,le,us]);const tt=m.useCallback((Ae,Ke={})=>{if(!Gt)return;const Pe=B.current,qe=Ba.current,Ye={event:Ae,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:qe.hasDedicatedAudio,audioUrl:qe.audioUrl,mainBrushDuckEnabled:qe.mainBrushDuckEnabled,mainBrushDuckAmount:qe.mainBrushDuckAmount,mainBrushActive:qe.mainBrushActive,baseRoverGain:qe.baseRoverGain,effectiveRoverGain:qe.effectiveRoverGain,element:Pe?{muted:Pe.muted,volume:Pe.volume,paused:Pe.paused,ended:Pe.ended,readyState:Pe.readyState,networkState:Pe.networkState}:null,...Ke};try{console.log(`[AudioDebug] ${Ae} ${JSON.stringify(Ye)}`)}catch{console.log("[AudioDebug]",Ae,Ye)}},[Gt,d]),_n=_?.socials?.find(Ae=>String(Ae?.id||Ae?.label||"").toLowerCase()==="discord")?.url||_?.discord?.invite||null;m.useEffect(()=>{Oa&&console.log("[OvercurrentHUD]",{overlayVisible:kt,overlayMotors:At,overlayFill:Yt,limiterActive:Dn,limiterCaps:Et,limiterGroups:cs,wheelOvercurrents:mt})},[Oa,Yt,At,kt,Dn,Et,cs,mt]),m.useEffect(()=>{tt("settings/update")},[tt]);const An=m.useCallback(()=>{clearTimeout(U.current),U.current=setTimeout(()=>pe(Date.now()),X0)},[]),On=m.useCallback(()=>{clearTimeout(Y.current),Y.current=setTimeout(()=>ce(Date.now()),X0)},[]),ds=m.useCallback(async()=>{const Ae=Q.current;if(Ae)try{Ae.muted=!0,await Ae.play()}catch{}},[]),ul=m.useCallback((Ae=0)=>{if(x||xe)return;clearTimeout(fe.current);const Ke=()=>{clearTimeout(fe.current),fe.current=setTimeout(()=>{x||Pe()},Oj)},Pe=async()=>{const qe=Q.current;if(qe)try{await ds(),qe.muted=!1,await qe.play(),ye(!1)}catch{qe.muted=!0,ye(!0),Ke()}};fe.current=setTimeout(Pe,Ae)},[ds,x,xe]);m.useEffect(()=>()=>{clearTimeout(U.current),clearTimeout(Y.current),clearTimeout(fe.current),clearInterval(te.current),oe.current&&(cancelAnimationFrame(oe.current),oe.current=null)},[]),m.useEffect(()=>{T==="playing"&&ul(0)},[T,ul]),m.useEffect(()=>{Ue&&(F("snapshot"),se(null))},[Ue]),m.useEffect(()=>{if(Ue||!n?.url||!Q.current)return;let Ae=!0,Ke;const Pe=setTimeout(()=>ye(!0),0),qe=(Ye,it)=>{Ae&&(tt("video/status",{nextStatus:Ye,info:it||null}),F(Ye),se(it||null),Ye==="playing"&&ds(),["error","failed","disconnected","closed"].includes(Ye)&&An())};return Ke=new Y0({url:n.url,token:n.token,video:Q.current,receiveAudio:!xe,onStatus:qe}),Ke.start().catch(Ye=>{Ae&&(F("error"),se(Ye.message),An())}),()=>{Ae=!1,clearTimeout(Pe),Ke?.stop()}},[Ue,n?.url,n?.token,ne,An,ds,xe,tt]),m.useEffect(()=>{T==="stopped"&&n?.url&&An()},[T,n?.url,An]),m.useEffect(()=>{const Ae=B.current;if(!Ae||!s?.url){tt("route/no-audio-url"),G.current=null;return}const Ke=Math.max(0,Math.min(1,us)),Pe=G.current==null?Math.max(0,Math.min(1,Ae.volume)):G.current;if(oe.current&&(cancelAnimationFrame(oe.current),oe.current=null),Ke>Pe){const qe=performance.now(),Ye=Pe,it=Ke-Ye,rt=jt=>{const st=Math.min(1,(jt-qe)/zj),Bn=Ye+it*st;Ae.volume=Bn,G.current=Bn,st<1?oe.current=requestAnimationFrame(rt):oe.current=null};oe.current=requestAnimationFrame(rt)}else Ae.volume=Ke,G.current=Ke;tt("route/direct",{elementVolume:Ke,duckEnabled:be,mainBrushActive:ca,duckAmount:Me})},[s?.url,us,be,ca,Me,tt]),m.useEffect(()=>{if(!s?.url||!B.current)return;let Ae=!0,Ke;const Pe=(qe,Ye)=>{Ae&&(tt("audio/status",{nextStatus:qe,info:Ye||null}),P(Ye||(qe==="connected"?"connected":null)),k(it=>qe==="connected"&&(it==="playing"||it==="connecting")||qe==="new"?it:qe),["error","failed"].includes(qe)&&On())};return Ke=new Y0({url:s.url,token:s.token,video:B.current,audioOnly:!0,onStatus:Pe}),Ke.start().catch(qe=>{Ae&&(k("error"),P(qe.message),On())}),()=>{Ae=!1,Ke?.stop()}},[s?.url,s?.token,ie,On,tt]),m.useEffect(()=>{const Ae=B.current;if(!s?.url||!Ae){clearInterval(te.current);return}if(!["connecting","connected","playing","paused"].includes(de)){clearInterval(te.current);return}const Pe=async()=>{const qe=B.current;qe&&(qe.muted=!1,!(!qe.paused&&!qe.ended)&&(tt("retry/play-attempt"),qe.play().then(()=>{tt("retry/play-ok"),k(Ye=>Ye==="connected"?"playing":Ye),P(Ye=>Ye==="paused"?null:Ye)}).catch(Ye=>{tt("retry/play-fail",{error:Ye?.message}),P(it=>it||Ye?.message||"autoplay blocked")})))};return Pe(),te.current=setInterval(Pe,Bj),()=>clearInterval(te.current)},[s?.url,de,tt]),m.useEffect(()=>{const Ae=B.current;if(!Ae)return;const Ke=()=>{tt("element/play"),k(st=>st==="error"?st:"playing"),P(null)},Pe=()=>{tt("element/pause"),k(st=>["error","failed","disconnected","closed","stopped"].includes(st)?st:"paused"),P(st=>st||"paused")},qe=()=>{tt("element/ended"),k(st=>st==="error"?st:"stopped"),P(st=>st||"ended")},Ye=()=>{const{error:st}=Ae,Bn=st?.message||"audio error";tt("element/error",{error:Bn}),k("error"),P(Bn)},it=()=>tt("element/waiting"),rt=()=>tt("element/canplay"),jt=()=>tt("element/stalled");return Ae.addEventListener("play",Ke),Ae.addEventListener("pause",Pe),Ae.addEventListener("ended",qe),Ae.addEventListener("error",Ye),Ae.addEventListener("waiting",it),Ae.addEventListener("canplay",rt),Ae.addEventListener("stalled",jt),()=>{Ae.removeEventListener("play",Ke),Ae.removeEventListener("pause",Pe),Ae.removeEventListener("ended",qe),Ae.removeEventListener("error",Ye),Ae.removeEventListener("waiting",it),Ae.removeEventListener("canplay",rt),Ae.removeEventListener("stalled",jt)}},[s?.url,tt]);const fl=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",La=Ue?fl:n?.url?T==="error"?`Error: ${J||"unknown"}`:J?`${T} (${J})`:T:"waiting",Eo=s?.error?`Error: ${s.error}`:s?.url?de==="error"?`Error: ${H||"unknown"}`:H?`${de} (${H})`:de:null,dl=b==="spectator",en=b==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${j?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${j?"h-full flex-1":"aspect-[4/3]"}`,children:[Ue?o?.objectUrl?r.jsx("img",{src:o.objectUrl,alt:d,className:"h-full w-full object-contain",draggable:!1}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):r.jsx("video",{ref:Q,muted:x||ve||xe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:B,autoPlay:!0,hidden:!0}),!en&&E?r.jsx(Vj,{mobileHud:we,turnSeconds:M,isActiveDriver:L,idleSkipSeconds:K}):null,en?null:r.jsx(Hj,{frame:p,sensors:$e,label:d,roverColor:h,status:La,audioStatus:Eo,levelStatus:fs,desktopLayout:me,layoutFormat:y,variant:b,driverLabel:A,battery:xt,showTopDown:Le,mobileHud:we,mapPosition:et,turnTimerText:C,labelScale:q}),en?null:r.jsx(Fj,{compact:we}),!en&&Oa?r.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-40 rounded bg-black/80 px-1 py-0.5 text-[0.6rem] text-lime-200",children:`OC vis:${kt?1:0} motors:${At.length} fill:${Math.round(Yt*100)}%`}):null,en?null:r.jsx(Gj,{motors:At,fill:Yt,compact:we}),en?null:r.jsx(Yj,{battery:xt,compact:we}),!en&&dl&&xt.available?r.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:r.jsx(qf,{visual:xt,orientation:"vertical",variant:"inline",compact:we,className:"h-full w-4"})}):null,!en&&f?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2",children:r.jsxs("div",{className:`mx-auto w-fit rounded border border-amber-300/80 bg-black/75 text-amber-200 ${we?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[r.jsx("div",{className:"text-center",children:f}),r.jsx("div",{className:"pointer-events-auto mt-0",children:r.jsx(sd,{id:"discord",label:"Join our Discord server while you wait!",url:_n})})]})}):null]}),!en&&!dl&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Uj,{sensors:$e}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(qf,{visual:xt,compact:we})})]})]})}function Uj({sensors:n}){const s=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],i=s.filter(x=>x!=null).reduce((x,p)=>Math.max(x,p),1200),o=x=>Math.pow(Math.max(0,Math.min(1,(x??0)/i)),.35),f=x=>x==null||x<=0?"hsl(200 60% 18%)":`hsl(${(200+o(x)*360)%360} 100% 60%)`,d=6,h=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:s.map((x,p)=>{const g=o(x),y=p<d/2?-1:1,b=`${g*100}%`,A=f(x);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${h}px`},children:r.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:r.jsx("div",{className:"h-full",style:{width:b,background:A,float:y===-1?"right":"left"}})})},p)})})}function Hj({frame:n,sensors:s,label:i,roverColor:o=null,status:f,audioStatus:d,levelStatus:h,desktopLayout:x=!0,layoutFormat:p="desktop",variant:g="default",driverLabel:y=null,battery:b,showTopDown:A=!1,mobileHud:R=!1,mapPosition:N="top-center",turnTimerText:q=null,labelScale:j=1}){s?.bumpsAndWheelDrops;const[w,E]=m.useState(()=>Date.now());m.useEffect(()=>{const se=setInterval(()=>E(Date.now()),150);return()=>clearInterval(se)},[]),n?.receivedAt&&w-n.receivedAt<200;const C=R,M=p==="mobile-portrait",L=C?"text-[0.45rem]":"text-[0.65rem]",K=C?"px-0.25 py-0.25":"px-1 py-0.5",_=C?"px-0.25 py-0.25":"px-0.5 py-0.5",Q=C?"text-[0.55rem]":"text-[0.8rem]",B=C?"left-0.5 top-0.5":"left-1 top-1",U=C?"text-[0.5rem]":"text-[0.7rem]",Y=C?"px-0.5 py-0.25":"px-1 py-0.5",te=C?"left-0.5 top-1/2":"left-1 top-1/2",fe="bottom-0.5",oe={transform:`translateX(-50%) scale(${j})`,transformOrigin:"center bottom"},G="240px",T=M?.3:C?.33:.7,J={width:G,height:G,opacity:C?.6:.7,transform:N==="top-center"?`translateX(-50%) scale(${T})`:`scale(${T})`,transformOrigin:N==="bottom-left"?"bottom left":N==="top-center"?"top center":"top right",...N==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:N==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(g==="none")return null;if(g==="spectator"){const se=[["Voltage",s?.voltageMv!=null?`${(s.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",s?.currentMa!=null?`${s.currentMa} mA`:"--"],["Charge",s?.batteryChargeMah!=null?`${s.batteryChargeMah}`:"--"],["OI",s?.oiMode?.label||"--"]],de=!!s?.chargingSources?.homeBase,k=s?.chargingState?.label||"",H=!!(k&&k.toLowerCase()!=="not charging"),P=s?.oiMode?.label||"Unknown",ne=P.toLowerCase(),pe=ne==="full"?"bg-emerald-500/80 text-emerald-50":ne==="safe"?"bg-amber-400/80 text-amber-950":ne==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",ie=de?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",ce=H?"bg-emerald-500/80 text-emerald-50":de?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${B} font-medium text-slate-100 ${L}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,h?r.jsx("span",{className:"text-cyan-300",children:h}):null]})}),r.jsx("div",{className:`absolute ${te} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${L} ${K}`,children:r.jsxs("div",{className:"space-y-0.5 leading-tight",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[r.jsx("span",{className:`rounded px-1.5 py-0.5 ${ie}`,children:de?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${ce}`,children:H?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${pe}`,children:["OI: ",P]})]}),se.map(([ve,ye])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:ve}),r.jsx("span",{className:"font-semibold text-white",children:ye})]},ve))]})}),r.jsx("div",{className:`absolute ${fe} left-1/2`,style:oe,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${_} ${Q}`,children:[r.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ra(o,.18),children:i||"Unnamed Rover"}),y?r.jsxs("span",{className:"text-slate-300",children:["• ",y]}):null]})})]}),A?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:r.jsx(Mf,{sensors:s,size:240,overlay:!0})}):null]})}return r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${B} font-medium text-slate-100 ${L}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,h?r.jsx("span",{className:"text-cyan-300",children:h}):null]})}),q?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${Y} ${U}`,children:q}):null,r.jsx("div",{className:`absolute ${fe} left-1/2`,style:oe,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${_} ${Q}`,children:r.jsxs("span",{children:["Rover:"," ",r.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(o,.18),children:['"',i||"Unnamed Rover",'"']})]})})}),A&&g!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:r.jsx(Mf,{sensors:s,size:240,overlay:!0})}):null]})}function Vj({mobileHud:n=!1,turnSeconds:s=null,isActiveDriver:i=!1,idleSkipSeconds:o=null}){const f=n?"text-3xl":"text-5xl",d=n?"text-xs":"text-sm",h=n?"text-[0.55rem]":"text-[0.75rem]",x=n?"px-4 py-3":"px-6 py-4",p=i&&typeof o=="number";return r.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:r.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${x}`,children:[r.jsx("div",{className:`font-semibold text-amber-200 ${f}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${d}`,children:"Start driving!"}),p?r.jsxs("div",{className:`text-red-100/90 ${h}`,children:["Idle skip in ",o,"s"]}):null]})})}const $j={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function Gj({motors:n,fill:s=0,compact:i=!1}){if(!n?.length)return null;const o=n.map(y=>$j[y]||y),f=i?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=i?"px-2 py-1":"px-4 py-2",h=i?"text-lg":"text-4xl",x=i?"text-xs":"text-xl",p=Math.max(0,Math.min(1,s)),g=`${Math.round(p*100)}%`;return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${f}`,children:r.jsxs("div",{className:"relative h-full w-full",children:[r.jsx("div",{className:"absolute inset-0 overflow-hidden",children:r.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),r.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${h} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${x}`,children:o.join(", ")})]})]})})}function Yj({battery:n,compact:s=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const i=n.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=s?"p-2 top-6":"p-4 top-10",f=s?"text-sm":"text-2xl";return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${o}`,children:r.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${f}`,children:r.jsx("div",{children:i})})})}function Fj({compact:n=!1}){const{session:s}=ze(),{sendMessage:i,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:h,setTypingActive:x}=Jf(),{value:p}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[g,y]=m.useState(""),[b,A]=m.useState(!1),R=s?.role!=="spectator",N=s?.role==="spectator",q=s?.assignment?.roverId||null,w=!!m.useMemo(()=>s?.roster?.find(_=>String(_.id)===String(q))||null,[q,s?.roster])?.audio?.ttsEnabled,E=m.useMemo(()=>{if(!w)return null;const _=p?.engine==="espeak"?"espeak":"flite";if(_==="espeak"){let B=Number.isFinite(p?.pitch)?Math.round(p.pitch):void 0;return typeof B=="number"&&(B=Math.max(0,Math.min(99,B))),{speak:!0,engine:_,pitch:B}}const Q=typeof p?.voice=="string"?p.voice:void 0;return{speak:!0,engine:_,voice:Q}},[p?.engine,p?.pitch,p?.voice,w]),C=n?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",M=n?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",L=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 K(_){if(_.preventDefault(),!R)return;const Q=g.trim();if(Q){A(!0);try{await i(Q,E),y(""),d(),x(!1)}catch(B){alert(B.message)}finally{A(!1)}}}return N?null:r.jsxs("form",{onSubmit:K,className:C,children:[r.jsx("input",{className:M,value:g,onChange:_=>{const Q=_.target.value;y(Q),x(!!Q.trim())},onFocus:_=>{o(_),x(!!g.trim())},onBlur:_=>{f(_),x(!1)},onKeyDown:_=>{_.key==="Enter"&&!g.trim()&&(_.preventDefault(),d(),x(!1))},ref:_=>h(_,{target:"hud"}),placeholder:R?"Chat (TTS)":"Spectator",disabled:!R}),r.jsx("button",{type:"submit",disabled:!R||b,className:L,children:"Speak"})]})}function ld({layoutFormat:n="desktop"}){const{session:s}=ze(),{state:{song:i,lastControlIntentAt:o},overcurrentLimiter:f}=_t(),[d,h]=m.useState(()=>Date.now()),[x,p]=m.useState(!1),[g,y]=m.useState(null),b=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(s?.mode!=="turns")return;const ne=setInterval(()=>h(Date.now()),250);return()=>clearInterval(ne)},[s?.mode]);const A=s?.assignment?.roverId,N=!!(A&&s?.roster?s.roster.find(ne=>String(ne.id)===String(A)):null)?.media?.audioPublishUrl,q=A?s?.turnQueues?.[A]:null,j=s?.socketId||null,w=A?s?.activeDrivers?.[A]:null,E=!!(j&&w===j),C=m.useMemo(()=>{const ne=q?.queue||[];if(!ne.length||!q?.current||ne.length<=1)return null;const pe=ne.findIndex(ie=>ie===q.current);return pe===-1?ne[0]||null:ne[(pe+1)%ne.length]||null},[q?.queue,q?.current]),M=!!(j&&C===j),L=q?.deadline||null,K=q?.idleDeadline||null,_=L?L-d:null,Q=K?K-d:null,B=s?.mode==="turns"&&M&&_!=null&&_<=5e3&&_>0,U=s?.mode!=="turns"||E||B,Y=_!=null&&Number.isFinite(_)?Math.max(0,Math.ceil(_/1e3)):null,te=Q!=null&&Number.isFinite(Q)?Math.max(0,Math.ceil(Q/1e3)):null,fe=E?Y!=null?`${Y}s left`:null:M&&Y!=null?`Your turn in ${Y}s`:null,oe=A?[...U?[{type:"rover",id:A,key:A}]:[],...N?[{type:"rover",id:`${A}-audio`,key:`${A}-audio`}]:[]]:[],G=vi(oe),T=A&&U?G[A]:null,F=A&&N?G[`${A}-audio`]:null,J=nd(A?[A]:[],{enabled:!!A,version:s?.mode}),se=A&&J[A]||null,de=cl(A),k=A&&s?.roster?s.roster.find(ne=>String(ne.id)===String(A)):null,H=k?.battery??null,P=k?.name||(A?`Rover ${A}`:"");return m.useEffect(()=>{if(s?.mode!=="turns"){p(!1),y(null),b.current={active:!1,roverId:null};return}const ne=b.current,pe=E&&!ne.active,ie=E&&A&&A!==ne.roverId;pe||ie?(p(!0),y(Date.now())):!E&&ne.active&&(p(!1),y(null)),b.current={active:E,roverId:A}},[E,A,s?.mode]),m.useEffect(()=>{!x||!g||o>g&&p(!1)},[o,g,x]),r.jsx("section",{className:"panel",children:A?r.jsx(bi,{sessionInfo:T,videoMode:U?"whep":"snapshot",snapshotFeed:se,audioSessionInfo:F,label:P,roverColor:k?.color||null,telemetryFrame:de,batteryConfig:H,layoutFormat:n,overcurrentLimiter:f,songNote:i?.note,qualityNotice:U?null:"Preview feed (low FPS) until your turn.",showTurnCue:x,turnTimerText:fe,turnSeconds:Y,isActiveDriver:E,idleSkipSeconds:te}):r.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[r.jsx("p",{children:"You are not assigned to a rover."}),r.jsx("p",{className:"mt-0",children:r.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function Rf({label:n,tone:s="muted"}){const i=s==="success"?"bg-emerald-900 text-emerald-100":s==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return r.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${i}`,children:n})}function yo(n){if(!Number.isFinite(n))return 0;const s=n%360;return s<0?s+360:s}function Xj(n){if(!Array.isArray(n)||n.length<3)return 0;const[s,i,o]=n,f=Math.max(0,Math.min(255,Number(s)))/255,d=Math.max(0,Math.min(255,Number(i)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,x=Math.max(f,d,h),p=Math.min(f,d,h),g=x-p;if(g===0)return 0;let y=0;return x===f?y=(d-h)/g%6:x===d?y=(h-f)/g+2:y=(f-d)/g+4,yo(Math.round(y*60))}function Q0(n){const s=yo(n),i=1,o=1-Math.abs(s/60%2-1);let f=0,d=0,h=0;return s<60?(f=i,d=o):s<120?(f=o,d=i):s<180?(d=i,h=o):s<240?(d=o,h=i):s<300?(f=o,h=i):(f=i,h=o),[Math.round(f*255),Math.round(d*255),Math.round(h*255)]}function K0(n){return n?Array.isArray(n.hsColor)?yo(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?Xj(n.rgbColor):0:0}function Qj({entity:n,connected:s,onToggle:i,onSetColor:o}){const f=n.state==="unavailable"||!n.available,d=n.state==="on",h=n.type==="light"&&n.supportsColor,x=f?"warn":d?"success":"muted",p=f?"Unavailable":d?"On":"Off",g=!s||f,y=g||!h,[b,A]=m.useState(()=>K0(n)),R=m.useRef(b),N=m.useRef(!1),q=f?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":d?"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(!h||N.current)return;const L=K0(n);R.current=L,A(L)},[n.rgbColor,n.hsColor,h]);const j=L=>{const K=yo(Number(L.target.value));R.current=K,A(K)},w=()=>{y||!o||o(n.id,Q0(R.current))},E=L=>{L.stopPropagation()},M=`rgb(${(h?Q0(R.current):[255,255,255]).join(",")})`;return r.jsxs("button",{type:"button",onClick:()=>i(n.id),disabled:g,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 ${q} 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}),h&&r.jsxs(r.Fragment,{children:[r.jsx(Rf,{label:p,tone:x}),!s&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),h?r.jsx("div",{className:"-mt-0.5 w-full",onClick:E,onPointerDown:L=>{E(L),N.current=!0},onPointerUp:L=>{E(L),N.current=!1,w()},onPointerCancel:L=>{E(L),N.current=!1,w()},onKeyUp:L=>{E(L),w()},onBlur:w,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:b,onChange:j,disabled:y,"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(Rf,{label:p,tone:x}),!s&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),h&&r.jsx("span",{className:"pointer-events-none absolute right-1 top-1 h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:M}}),!h&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:d?"Turn off":"Turn on"})]})}function Ng(){const{state:{keymap:n}}=_t(),{session:s,homeAssistantToggle:i,homeAssistantSetLightColor:o}=ze(),f=s?.homeAssistant,d=m.useMemo(()=>f?.entities||[],[f?.entities]),h=bn(n?.homeAssistantOn?.[0]),x=bn(n?.homeAssistantOff?.[0]);if(!f?.enabled)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(d.length===0)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const p=!!f?.connected;return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room Controls"}),r.jsx("span",{className:"text-xs text-slate-500",children:d.length}),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"}),h?r.jsx(Z0,{label:h}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),x?r.jsx(Z0,{label:x}):null]})]})]}),r.jsx(Rf,{label:p?"Connected":"Offline",tone:p?"success":"warn"})]}),r.jsx("div",{className:"flex flex-wrap gap-0.5",children:d.map(g=>r.jsx(Qj,{entity:g,connected:p,onToggle:i,onSetColor:o},g.id))})]})}function Z0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function wg(){const{login:n,setRole:s}=ze(),[i,o]=m.useState(""),[f,d]=m.useState(""),[h,x]=m.useState(!1);async function p(g){g.preventDefault(),x(!0);try{await n(i,f),o(""),d("")}catch(y){alert(y.message)}finally{x(!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:p,children:[r.jsx("input",{className:"field-input",placeholder:"Username",value:i,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:f,onChange:g=>d(g.target.value)}),r.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function I0(...n){return n.filter(Boolean).join(" ")}function Kj(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function Zj(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Ij({title:n,roster:s=[],emptyText:i="No roster data.",renderActions:o=null}){return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),s.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:i}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:s.map(f=>{const d=!!(f?.private?.enabled&&f?.private?.open),h=!!f?.locked;return r.jsxs("li",{className:I0("surface flex flex-wrap items-center justify-between gap-0.5",h?"bg-red-900/40":d?"bg-amber-700/35 border border-amber-200/30":null),children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-slate-200",children:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(f.color,.16),children:f.name})}),r.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[r.jsx("span",{children:f.locked?"locked":"free"}),f.lockReason&&r.jsx("span",{className:"rounded bg-black/30 px-1",children:f.lockReason}),r.jsxs("span",{className:I0("font-semibold",Zj(f)),children:["Battery ",Kj(f)]})]})]}),o?o(f):null]},f.id)})})]})}const Jj=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Pj(){const{session:n,lockRover:s,setMode:i,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:h,rebootServer:x,setAudioLevels:p,setPrivateSafety:g,llmControl:y,adminLogs:b,llmCommentaryState:A}=ze(),R=m.useMemo(()=>n?.roster??[],[n?.roster]),[N,q]=m.useState({}),[j,w]=m.useState({}),[E,C]=m.useState(!1),[M,L]=m.useState(!1),K=n?.health||null,_=n?.communityGoal?.text||"",Q=n?.communityGoal?.updatedAt||null,[B,U]=m.useState(_),Y=n?.adminReason?.text||"",te=n?.adminReason?.updatedAt||null,[fe,oe]=m.useState(Y),G=n?.audioLevels||{},[T,F]=m.useState({hornGain:Number.isFinite(G.hornGain)?G.hornGain:1,ttsGain:Number.isFinite(G.ttsGain)?G.ttsGain:1,forwardGain:Number.isFinite(G.forwardGain)?G.forwardGain:1}),[J,se]=m.useState({}),de=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",k=n?.role==="lockdown"||n?.role==="lockdown-admin",H=n?.mode??"open",P=async(le,re)=>{try{await s(le,re),q(me=>({...me,[le]:re}))}catch(me){alert(me.message)}},ne=async le=>{const re=le.target.value;try{await i(re)}catch(me){alert(me.message)}},pe=async le=>{try{await o(le,{force:!0})}catch(re){alert(re.message)}},ie=async le=>{if(!(!le?.id||!window.confirm(`Reboot rover "${le.name||le.id}" now?`))){w(me=>({...me,[le.id]:!0}));try{await h(le.id)}catch(me){alert(me.message)}finally{w(me=>({...me,[le.id]:!1}))}}},ce=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){C(!0);try{await x()}catch(re){alert(re.message),C(!1)}}},ve=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){L(!0);try{await y("clearHistory")}catch(re){alert(re.message)}finally{L(!1)}}},ye=async()=>{try{await f(B)}catch(le){alert(le.message)}},xe=async()=>{try{await f(null)}catch(le){alert(le.message)}},Ue=async()=>{try{await d(fe)}catch(le){alert(le.message)}},$e=async()=>{try{await d(null)}catch(le){alert(le.message)}},Ne=le=>re=>{const me=Number(re.target.value);F(we=>({...we||{},[le]:Number.isFinite(me)?me:1}))},ae=async()=>{try{await p(T)}catch(le){alert(le.message)}};m.useEffect(()=>{U(_)},[_]),m.useEffect(()=>{oe(Y)},[Y]),m.useEffect(()=>{F({hornGain:Number.isFinite(G.hornGain)?G.hornGain:1,ttsGain:Number.isFinite(G.ttsGain)?G.ttsGain:1,forwardGain:Number.isFinite(G.forwardGain)?G.forwardGain:1})},[G.forwardGain,G.hornGain,G.ttsGain]),m.useEffect(()=>{const le={};(R||[]).forEach(re=>{re?.private?.enabled&&(le[re.id]={speedLimitEnabled:!!re?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(re?.private?.safety?.speedLimitMaxWheelSpeed)?re.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!re?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(re?.private?.safety?.overcurrentStopMs)?re.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!re?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(re?.private?.safety?.bumpBackoffSpeed)?re.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(re?.private?.safety?.bumpBackoffMs)?re.private.safety.bumpBackoffMs:350,cliffEnabled:!!re?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(re?.private?.safety?.cliffBackoffSpeed)?re.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(re?.private?.safety?.cliffBackoffMs)?re.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(re?.private?.safety?.triggerCooldownMs)?re.private.safety.triggerCooldownMs:800})}),se(le)},[R]);const ue=m.useMemo(()=>{const le={};return R.forEach(re=>{le[re.id]=N[re.id]??re.locked}),le},[R,N]),be=(le,re={})=>{se(me=>({...me||{},[le]:{...me?.[le]||{},...re||{}}}))},Me=async le=>{try{const re=J?.[le];if(!re)return;await g(le,re)}catch(re){alert(re.message)}};return de?r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[r.jsx("span",{children:"Admin controls"}),r.jsx("select",{value:H,onChange:ne,className:"field-input text-sm",children:Jj.map(le=>r.jsx("option",{value:le.key,children:le.label},le.key))})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ce,disabled:E,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:E?"Server rebooting...":"Reboot Server"})}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Global audio levels"}),n?.audioLevels?.updatedAt?r.jsxs("span",{children:["Updated ",new Date(n.audioLevels.updatedAt).toLocaleString()]}):null]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Horn gain"}),r.jsxs("span",{children:[T.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.hornGain,onChange:Ne("hornGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"TTS gain"}),r.jsxs("span",{children:[T.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.ttsGain,onChange:Ne("ttsGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Forward gain"}),r.jsxs("span",{children:[T.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.forwardGain,onChange:Ne("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ae,className:"button-dark",children:"Apply audio levels"})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Community goal"}),Q?r.jsxs("span",{children:["Updated ",new Date(Q).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:B,onChange:le=>U(le.target.value),placeholder:"Set a community goal",className:"field-input text-sm"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:ye,className:"button-dark",children:"Set goal"}),r.jsx("button",{type:"button",onClick:xe,className:"button-danger",children:"Clear"})]})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Admin mode reason"}),te?r.jsxs("span",{children:["Updated ",new Date(te).toLocaleString()]}):null]}),r.jsx("textarea",{value:fe,onChange:le=>oe(le.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:Ue,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:$e,className:"button-danger",children:"Clear"})]})]}),r.jsx(Ij,{roster:R,renderActions:le=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>P(le.id,!ue[le.id]),className:"button-dark",children:ue[le.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>pe(le.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>ie(le),disabled:!!j[le.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:j[le.id]?"Rebooting...":"Reboot"}),le?.private?.enabled?r.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[r.jsx("div",{className:"text-slate-300",children:"Private safety"}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.speedLimitEnabled,disabled:!k,onChange:re=>be(le.id,{speedLimitEnabled:!!re.target.checked})}),r.jsx("span",{children:"Speed limit"})]}),r.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!k,value:J?.[le.id]?.speedLimitMaxWheelSpeed??250,onChange:re=>be(le.id,{speedLimitMaxWheelSpeed:Number(re.target.value)||250})}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.hardOvercurrentEnabled,disabled:!k,onChange:re=>be(le.id,{hardOvercurrentEnabled:!!re.target.checked})}),r.jsx("span",{children:"Hard overcurrent"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.hardBumpEnabled,disabled:!k,onChange:re=>be(le.id,{hardBumpEnabled:!!re.target.checked})}),r.jsx("span",{children:"Hard bump"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[le.id]?.cliffEnabled,disabled:!k,onChange:re=>be(le.id,{cliffEnabled:!!re.target.checked})}),r.jsx("span",{children:"Cliff safety"})]}),r.jsx("button",{type:"button",disabled:!k,onClick:()=>Me(le.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),r.jsx(nN,{health:K,roster:R}),r.jsx(Wj,{state:A,onClearHistory:ve,clearingHistory:M}),r.jsx(aN,{entries:b})]}):null}function Wj({state:n,onClearHistory:s,clearingHistory:i}){const[o,f]=m.useState(null);if(!n)return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const d=n.runtime||{},h=n.counters||{},x=n.timings||{},p=n.input||{},g=n.output||{},y=n.errors||{},b=Array.isArray(n.history)?n.history:[],A=b.find(j=>j.runId===o)||(b.length?b[b.length-1]:null),R=eN(n),N=tN(p.modelMessages,g.raw),q=[{label:"running",value:d.running?"yes":"no"},{label:"in flight",value:d.inFlight?"yes":"no"},{label:"phase",value:d.phase||"--"},{label:"run id",value:d.currentRunId??"--"},{label:"tick count",value:d.tickCount??0},{label:"last tick",value:d.lastTickAt?new Date(d.lastTickAt).toLocaleString():"never"},{label:"next run",value:d.nextRunAt?new Date(d.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:d.outcome||"--"},{label:"reason",value:d.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:x.lastGenerationMs!=null?`${x.lastGenerationMs} ms`:"--"},{label:"avg gen",value:x.avgGenerationMs!=null?`${x.avgGenerationMs} ms`:"--"},{label:"gen count",value:x.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:s,disabled:!!i,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:i?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${R.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:R.label}),r.jsx("div",{className:"text-xs text-slate-200",children:R.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:q.map(j=>r.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[j.label,": ",j.value]},j.label))}),y.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",y.message]}):null,y.details?r.jsxs("details",{className:"surface text-xs text-red-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(y.details,null,2)})]}):null,g.generated?r.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?r.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),r.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:N.length?N.map(j=>r.jsx(Kf,{message:j.message},j.id)):r.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),r.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),r.jsxs("div",{children:["Output at:"," ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),r.jsxs("div",{children:["Failed at: ",y.failedAt?new Date(y.failedAt).toLocaleString():"n/a"]})]})]})]}),r.jsxs("details",{className:"surface text-xs text-slate-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),r.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(j=>r.jsxs("button",{type:"button",onClick:()=>f(j.runId),className:`w-full text-left surface ${A?.runId===j.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",j.runId]})," ",r.jsx("span",{className:"text-slate-200",children:j.outcome||j.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:j.durationMs!=null?`${j.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:j.reason||""})]},j.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),A?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 #",A.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(A,null,2)})]}):null]})}function eN(n){const s=n?.runtime||{},i=n?.output||{},o=n?.errors||{};return s.inFlight?{label:"IN FLIGHT",detail:s.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:s.outcome==="posted"?{label:"POSTED",detail:i.posted?`Last: ${i.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:s.outcome==="skipped"?{label:"SKIPPED",detail:s.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:s.outcome==="failed"?{label:"FAILED",detail:o.message||s.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:s.running?"IDLE":"STOPPED",detail:s.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function tN(n,s){const i=Date.now(),f=(Array.isArray(n)?n:[]).map((d,h)=>{const x=String(d?.role||"").toLowerCase(),p=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=x==="system"?"LLM System":x==="assistant"?"LLM Context":x==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:i+h,nickname:g,text:p,role:"spectator",system:x==="system"}}});if(s!=null){const d=String(s);f.push({id:"llm-output",message:{ts:i+f.length+1,nickname:"LLM Output",text:d.trim()?d:"<empty>",role:"spectator",system:!0}})}return f}function nN({health:n,roster:s=[]}){if(!n)return null;const i=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},f=p=>s.find(g=>String(g.id)===String(p))?.color||null,d=`${i.readyCount}/${i.totalCount} sources ready`,h=o.rovers.filter(p=>p.stale).length,x=o.rooms.filter(p=>p.stale).length;return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Replay segments"}),r.jsx("span",{className:"text-slate-400",children:d})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rovers.length-h,"/",o.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:x?"text-amber-300":"text-emerald-300",children:[o.rooms.length-x,"/",o.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.sources.map(p=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:`${p.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:p.type==="rover"?ra(f(p.id),.16):void 0,children:p.label}),r.jsxs("span",{className:p.ready?"text-emerald-300":"text-amber-300",children:[p.recentCount,"/",p.neededCount]})]},`${p.type}:${p.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(p=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(f(p.id),.16),children:p.name}),r.jsx("span",{className:p.stale?"text-amber-300":"text-emerald-300",children:p.stale?"stale":"ok"})]},`rover:${p.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(p=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:p.name}),r.jsx("span",{className:p.stale?"text-amber-300":"text-emerald-300",children:p.error?"error":p.stale?"stale":"ok"})]},`room:${p.id}`))})]})}function aN({entries:n}){const s=n||[];return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Admin IP log"}),r.jsx("span",{children:s.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No admin log entries yet."}):s.slice().reverse().map(i=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:i.ts?new Date(i.ts).toLocaleTimeString():"--"})," ",i.label&&r.jsxs("span",{className:"text-teal-400",children:["[",i.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:i.message})," ",i.ip&&r.jsx("span",{className:"text-cyan-300",children:i.ip})," ",i.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(i.meta)})]},i.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const sN=[{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 lN(n){return n.reduce((s,i)=>((s[i.group]||(s[i.group]=[])).push(i),s),{})}function iN(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):s}const id=5,Si=500,Ai=1,rd=100;function rN(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(id,Math.min(Si,i)):s}function ao(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(Ai,Math.min(rd,i)):s}function oN(n){const i=(ao(n,n)-Ai)/(rd-Ai),o=Si-i*(Si-id);return Math.round(o)}function cN(n){const s=rN(n,n),i=(Si-s)/(Si-id),o=Ai+i*(rd-Ai);return Math.round(o)}function uN(n){const[s,i]=m.useState(null),o=m.useCallback(h=>{Iu(!0),i(h)},[]),f=m.useCallback(()=>{Iu(!1),i(null)},[]),d=m.useCallback((h,x)=>{if(x.preventDefault(),x.stopPropagation(),x.key==="Escape"){f();return}const p=ki(x.key??"");p&&(n(h,p,x),f())},[f,n]);return m.useEffect(()=>()=>Iu(!1),[]),{active:s,startCapture:o,cancel:f,captureFromEvent:d}}function Xr({label:n,description:s,value:i,onChange:o,min:f=0,max:d=500,step:h=5}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("input",{type:"number",min:f,max:d,value:i,onChange:x=>o(x.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[r.jsx("input",{type:"range",min:f,max:d,step:h,value:i,onChange:x=>o(x.target.value),className:"h-2 flex-1 accent-emerald-400"}),r.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:i})]})]})}function fN(){const{state:{keymap:n},actions:{updateKeyBinding:s,resetKeyBindings:i}}=_t(),{value:o,save:f}=Qe("inputs",En),d={...En.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof d.tiltSpeed=="number"?ao(d.tiltSpeed,En.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?ao(cN(d.tiltIntervalMs),En.keyboard.tiltSpeed):En.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),x=m.useMemo(()=>lN(sN),[]),{active:p,startCapture:g,cancel:y,captureFromEvent:b}=uN((q,j)=>{s(q,j)}),A=m.useCallback(q=>n?.[q]?.[0]||di[q]?.[0]||"",[n]),R=m.useCallback((q,j)=>{const w=En.keyboard,E=iN(j,w[q]);f(C=>({...C??{},keyboard:{...C?.keyboard??w,[q]:E}}))},[f]),N=m.useCallback(q=>{const j=En.keyboard,w=ao(q,j.tiltSpeed),E=oN(w);f(C=>({...C??{},keyboard:{...C?.keyboard??j,tiltSpeed:w,tiltIntervalMs:E}}))},[f]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),r.jsx("button",{type:"button",onClick:()=>i(),className:"button-dark text-xs",children:"Reset defaults"})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Xr,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:q=>R("baseSpeed",q)}),r.jsx(Xr,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:q=>R("turboSpeed",q)}),r.jsx(Xr,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:q=>R("precisionSpeed",q)})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),r.jsx(Xr,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:h,onChange:N,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(x).map(([q,j])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:q}),r.jsx("div",{className:"space-y-0.5",children:j.map(w=>{const E=A(w.id),C=p===w.id;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:w.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:bn(E)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[C&&r.jsx("button",{type:"button",onClick:()=>y(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(w.id),onKeyDown:C?M=>b(w.id,M):void 0,autoFocus:C,className:`${C?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium transition-colors`,children:C?"Press a key…":"Change"})]})]},w.id)})})]},q))})]})}const aa=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),dN=[{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"}],J0=.45,mN=.6;function ci({label:n,description:s,min:i,max:o,step:f,value:d,onChange:h}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("span",{className:"font-mono text-slate-400",children:aa.format(d)})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsx("input",{type:"range",min:i,max:o,step:f,value:d,onChange:x=>h(Number(x.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function hN(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const s=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${s?` (${s})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const s=n.direction<0?"<":">";return`Axis ${n.index} ${s} ${aa.format(n.threshold??.6)}`}return"Unassigned"}function pN(n){return n.reduce((s,i)=>((s[i.section]||(s[i.section]=[])).push(i),s),{})}function xN(n,s){if(!n||n.length===0)return null;if(s){const i=n.find(o=>o.signature===s);if(i)return i}return n[0]}function gN(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 vN(n,s,i){const o=(n.axes??[]).map((d,h)=>({index:h,delta:Math.abs((d??0)-(s.axes?.[h]??0)),value:d}));if(o.sort((d,h)=>h.delta-d.delta),i.kind==="axisPair"){const d=o.filter(h=>h.delta>J0).slice(0,2);return d.length<2?null:{kind:"axisPair",x:d[0].index,y:d[1].index,...i.invertDefaults??{}}}const f=o.find(d=>d.delta>J0);return f?{kind:"axis",index:f.index,...i.invertDefaults??{}}:null}function yN(n,s,i){const o=n.buttons??[];for(let d=0;d<o.length;d+=1){const h=o[d],x=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||x>mN)return i.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=n.axes??[];for(let d=0;d<f.length;d+=1){const h=f[d]??0,x=Math.abs(h-(s.axes?.[d]??0));if(Math.abs(h)>.7&&x>.5)return i.kind==="axis"?{kind:"axis",index:d,...i.invertDefaults??{}}:{kind:"axisButton",index:d,direction:h>=0?1:-1,threshold:.6}}return null}function bN(n,s,i){if(!n)return null;if(i.kind==="axis"||i.kind==="axisPair"){const o=vN(n,s,i);if(o)return o}return yN(n,s,i)}function SN(){const n=IA(),{value:s,save:i}=Qe("gamepad",Da),[o,f]=m.useState(null),d=m.useRef(null),h=m.useMemo(()=>pN(dN),[]),x=m.useMemo(()=>xN(n.pads,s.activeSignature),[n.pads,s.activeSignature]),p=x?.signature??null,g=m.useMemo(()=>p?s?.profiles?.[p]??s?.defaults?.profile??sa:s?.defaults?.profile??sa,[p,s?.defaults?.profile,s?.profiles]);m.useEffect(()=>{!x||!p||s?.profiles?.[p]||i(j=>{const w=j??Da;if(w.profiles?.[p])return w;const E=w?.defaults?.profile??sa,C=ug(x,E);return{...w,profiles:{...w.profiles??{},[p]:C}}})},[x,p,s?.profiles,i]),m.useEffect(()=>{d.current=null},[o,p]),m.useEffect(()=>{if(!o||!x)return;if(!d.current){d.current=gN(x);return}const j=bN(x,d.current,o);j&&(i(w=>{const E=w??Da,C=E.profiles?.[p]??E?.defaults?.profile??sa,M={...C,bindings:{...C.bindings??{},[o.id]:{...C.bindings?.[o.id]??{},kind:o.kind,sources:[j]}}};return{...E,profiles:{...E.profiles??{},[p]:M}}}),f(null))},[x,p,o,i]);const y=m.useCallback(j=>{i(w=>({...w??Da,activeSignature:j||null}))},[i]),b=m.useCallback(j=>{i(w=>{const E=w??Da,C=(p&&E.profiles?.[p])??E?.defaults?.profile??sa,M={...C,calibration:{...C.calibration??{},...j}};return p?{...E,profiles:{...E.profiles??{},[p]:M}}:{...E,defaults:{...E.defaults??{},profile:M}}})},[p,i]),A=m.useCallback((j,w)=>{i(E=>{const C=E??Da,M=(p&&C.profiles?.[p])??C?.defaults?.profile??sa,L=w(M.bindings?.[j]??{}),K={...M,bindings:{...M.bindings??{},[j]:L}};return p?{...C,profiles:{...C.profiles??{},[p]:K}}:{...C,defaults:{...C.defaults??{},profile:K}}})},[p,i]),R=m.useCallback(j=>{A(j.id,w=>({...w,sources:[]}))},[A]),N=m.useCallback((j,w)=>{A(j.id,E=>{const C=Array.isArray(E.sources)?[...E.sources]:[];if(!C[0])return E;const M={...C[0]};return w==="invertX"?M.invertX=!M.invertX:w==="invertY"?M.invertY=!M.invertY:M.invert=!M.invert,C[0]=M,{...E,sources:C}})},[A]),q=m.useMemo(()=>x?{outputs:fg(x,g)}:null,[x,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:x?"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:p??"",onChange:j=>y(j.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(j=>r.jsx("option",{value:j.signature,children:j.id||"Unknown controller"},j.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:x?.mapping??"unknown"})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ci,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:j=>b({driveDeadzone:j})}),r.jsx(ci,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:j=>b({cameraDeadzone:j})}),r.jsx(ci,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:j=>b({auxDeadzone:j})}),r.jsx(ci,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:j=>b({auxSideScale:j})}),r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),r.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:j=>b({cameraMode:j.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[r.jsx("option",{value:"absolute",children:"Absolute"}),r.jsx("option",{value:"velocity",children:"Velocity"})]})]}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),r.jsx(ci,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:j=>b({cameraSensitivity:j})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([j,w])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:j}),r.jsx("div",{className:"space-y-0.5",children:w.map(E=>{const M=g.bindings?.[E.id]?.sources?.[0]??null;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:E.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:hN(M)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[E.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),E.kind==="axis"&&r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>R(E),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(E),className:`${o?.id===E.id?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium`,children:o?.id===E.id?"Waiting…":"Capture"})]})]},E.id)})})]},j))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),x?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:x.axes.map((j,w)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",w,": ",aa.format(j)]},`axis-${w}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:x.buttons.map((j,w)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",w,": ",aa.format(j.value)," ",j.pressed?"●":""]},`btn-${w}`))}),q?.outputs&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",aa.format(q.outputs.driveVector.x),","," ",aa.format(q.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",aa.format(q.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",aa.format(q.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",aa.format(q.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const AN={drive:"Drive wheels",aux:"Aux motors"};function P0(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function jN({value:n,color:s="bg-emerald-500"}){const i=`${Math.round(Math.max(0,Math.min(1,n))*100)}%`;return r.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:r.jsx("div",{className:`h-full ${s}`,style:{width:i}})})}function NN(){const{state:{roverId:n},overcurrentLimiter:s}=_t(),i=m.useMemo(()=>tl.map(o=>o.key),[]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Overcurrent limiter"}),r.jsx("span",{children:s?.adminImmune?"Admin immune":"Active"})]}),n?r.jsxs("div",{className:"space-y-0.5",children:[i.map(o=>{const f=s?.caps?.[o]?.cap??0,d=s?.overcurrent?.groups?.[o]??!1,h=s?.scales?.perGroup?.[o]??1;return r.jsxs("div",{className:"surface space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-slate-200",children:AN[o]||o}),r.jsx("span",{className:d?"text-red-300":"text-slate-400",children:d?"overcurrent":"ok"})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Cap"}),r.jsx("span",{children:P0(f)})]}),r.jsx(jN,{value:f,color:"bg-amber-500"}),r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Scale"}),r.jsx("span",{children:P0(h)})]})]})]},o)}),r.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Down rate ${s?.config?.downRatePerSec}/s · Up rate ${s?.config?.upRatePerSec}/s`}),r.jsx("div",{children:`Release delay ${s?.config?.releaseDelaySec}s`}),r.jsx("div",{children:`Output rate ${s?.config?.outputRateMs}ms`})]})]}):r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Cg=m.createContext(null);function Eg(){const n=m.useContext(Cg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const W0={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"}},ex={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"},kg="primary";function od(...n){return n.filter(Boolean).join(" ")}function cd({children:n,defaultTab:s,currentTab:i,onTabChange:o,variant:f=kg}){const[d,h]=m.useState(s??null),[x,p]=m.useState([]),g=m.useCallback(R=>R?(p(N=>N.includes(R)?N:[...N,R]),()=>p(N=>N.includes(R)?N.filter(q=>q!==R):N)):()=>{},[]),y=i??d??x[0]??null;m.useEffect(()=>{s&&i===void 0&&h(s)},[s,i]);const b=m.useCallback(R=>{R&&(i===void 0&&h(R),o&&o(R))},[i,o]),A=m.useMemo(()=>({activeTab:y,setActiveTab:b,registerTab:g,variant:f}),[y,b,g,f]);return r.jsx(Cg.Provider,{value:A,children:n})}function ud({children:n,className:s=""}){return r.jsx("div",{className:od("flex gap-0.5",s),children:n})}function Pt({id:n,children:s,className:i="",disabled:o=!1,highlight:f="none"}){const{activeTab:d,setActiveTab:h,registerTab:x,variant:p}=Eg();m.useEffect(()=>x(n),[n,x]);const g=W0[p]??W0[kg],y=d===n,b=ex[f]||ex.none,A=od(g.base,b||(y?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",i);return r.jsx("button",{type:"button",className:A,onClick:()=>!o&&h(n),"aria-pressed":y,"aria-disabled":o,children:s})}function fd({children:n,className:s=""}){return r.jsx("div",{className:od("mt-0 space-y-0.5",s),children:n})}function Wt({id:n,children:s,keepMounted:i=!1}){const{activeTab:o}=Eg(),f=o===n;return!f&&!i?null:!f&&i?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:s}):r.jsx(r.Fragment,{children:s})}function wN(){const{session:n}=ze(),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 tx=300,nx=240;function CN(n,s){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(s||(s=new WeakSet),typeof n=="object"){if(s.has(n))return"[Circular]";s.add(n)}try{return JSON.stringify(n,(i,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function EN(n){const i=n.map(o=>CN(o)).join(" ");return i.length>nx?`${i.slice(0,nx)}…`:i}function kN(){const n=Rn(),[s,i]=m.useState([]),o=m.useMemo(()=>s.reduce((f,d)=>(d.direction==="in"&&(f.in+=1),d.direction==="out"&&(f.out+=1),f),{in:0,out:0}),[s]);return m.useEffect(()=>{const f=(p,g,y)=>{i(b=>{const A=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:p,event:g,payload:EN(y),timestamp:new Date().toLocaleTimeString()}];return A.length>tx?A.slice(-tx):A})},d=(p,...g)=>f("in",p,g),h=(p,...g)=>f("out",p,g);n.onAny(d);let x=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(h),x=()=>n.offAnyOutgoing(h);else{const p=n.emit.bind(n);n.emit=(g,...y)=>(h(g,...y),p(g,...y)),x=()=>{n.emit=p}}return()=>{n.offAny(d),x&&x()}},[n]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Socket activity"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),r.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),r.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>i([]),children:"Clear"})]})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No socket activity yet."}):s.slice().reverse().map(f=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-slate-400",children:f.timestamp})," ",r.jsxs("span",{className:f.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",f.direction.toUpperCase(),"]"]})," ",r.jsx("span",{className:"text-cyan-300",children:f.event})," ",r.jsx("span",{className:"text-slate-200",children:f.payload})]},f.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const MN=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Mg(){const{state:{roverId:n},actions:{sendOiCommand:s,setSensorStream:i}}=_t(),o=!!n,[f,d]=Ag(),h=Rn(),{value:x,save:p}=Qe("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:y}=Qe("audio",Dt),b=x?.connectionTransport||"websocket",A=!!x?.swapMobileControlColumns,R=typeof x?.driveMacroBackoffEnabled=="boolean"?x.driveMacroBackoffEnabled:!0,N=Number.isFinite(g?.masterVolume)?g.masterVolume:Dt.masterVolume,q=Number.isFinite(g?.alertVolume)?g.alertVolume:Dt.alertVolume,j=Number.isFinite(g?.roverVolume)?g.roverVolume:Dt.roverVolume,w=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:Dt.mainBrushDuckEnabled,E=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):Dt.mainBrushDuckAmount,C=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),M=U=>{n&&i(U)},L=U=>{const Y=U.target.value;p(te=>({...te??{},connectionTransport:Y})),h?.io?.opts&&(h.io.opts.transports=Y==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},K=U=>Y=>{const te=Number(Y.target.value),fe=Number.isFinite(te)?Math.max(0,Math.min(1,te)):0;y(oe=>({...oe??{},[U]:fe}))},_=U=>{const Y=!!U.target.checked;y(te=>({...te??{},mainBrushDuckEnabled:Y}))},Q=U=>{const Y=!!U.target.checked;p(te=>({...te??{},swapMobileControlColumns:Y}))},B=U=>{const Y=!!U.target.checked;p(te=>({...te??{},driveMacroBackoffEnabled:Y}))};return r.jsxs(cd,{defaultTab:"keybindings",children:[r.jsxs(ud,{children:[r.jsx(Pt,{id:"keybindings",children:"Keybindings"}),r.jsx(Pt,{id:"controller",children:"Controller"}),r.jsx(Pt,{id:"page",children:"Page settings"}),r.jsx(Pt,{id:"admin",children:"Admin"})]}),r.jsxs(fd,{children:[r.jsx(Wt,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(fN,{})})}),r.jsx(Wt,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(SN,{})})}),r.jsx(Wt,{id:"page",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"HUD"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:f,onChange:U=>d(U.target.checked)}),r.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:A,onChange:Q}),r.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Macros"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:R,onChange:B}),r.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Audio"}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Master volume"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:K("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(q*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:q,onChange:K("alertVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Rover audio"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(j*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:j,onChange:K("roverVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Main brush ducking"}),r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:w,onChange:_})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Main brush duck amount"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(E*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:K("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!w})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Connection"}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Transport"}),r.jsxs("select",{value:b,onChange:L,className:"field-input text-sm",children:[r.jsx("option",{value:"websocket",children:"WebSocket"}),r.jsx("option",{value:"polling",children:"Polling"})]})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),r.jsx(Wt,{id:"admin",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:MN.map(U=>r.jsx("button",{type:"button",onClick:()=>s(U.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:U.label},U.key))})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),r.jsx("div",{className:"surface flex gap-0.5",children:C.map(U=>r.jsx("button",{type:"button",onClick:()=>M(U.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:U.label},U.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(wg,{}),r.jsx(NN,{}),r.jsx(Pj,{}),r.jsx(wN,{}),r.jsx(kN,{})]})})]})]})}const ax={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 qN(n){return ax[n]||ax.desktop}function qg({actionId:n,keymap:s}){const i=s?.[n]?.[0]??"";return r.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:bn(i)})}function sx(n,s){return n.map((i,o)=>typeof i=="string"?r.jsx("span",{children:i},`text-${o}`):i?.action?r.jsx(qg,{actionId:i.action,keymap:s},`pill-${i.action}-${o}`):i?.text?r.jsx("span",{children:i.text},`span-${o}`):null)}function bo(n,s,i){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return sx(n.segments,s);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return sx(n,s)}return String(n??"")}function RN({hero:n,keymap:s}){return n?r.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-white",children:n.title}),n.subtitle&&r.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&r.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(i=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:i},i))})]}),n.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((i,o)=>{const f=Array.isArray(i?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:bo(i,s)},f)})})]}):null}function TN({block:n,keymap:s}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items.map((i,o)=>{const f=`item-${o}`;return r.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:bo(i,s)},f)})})]})}function DN({block:n}){const s=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return r.jsxs("div",{className:`surface space-y-0.5 border ${s} px-0.5 py-0.5`,children:[r.jsx("p",{className:"text-xs font-semibold text-slate-100",children:n.title}),n.body&&r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((i,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:bo(i,{})},`callout-${o}`))})]})}function _N({group:n,keymap:s}){return r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:n.title}),r.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.items.map(i=>r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[r.jsx("span",{className:"text-slate-200",children:i.label}),r.jsx(qg,{actionId:i.action,keymap:s})]},i.action))})]})}function ON({block:n,keymap:s}){return n?r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:n.title}),n.footnote&&r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(i=>r.jsx(_N,{group:i,keymap:s},i.id))})]}):null}function BN({block:n}){return n?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((s,i)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:bo(s,{})},`gamepad-${i}`))})]}):null}function lx({block:n,keymap:s}){if(!n)return null;switch(n.type){case"list":return r.jsx(TN,{block:n,keymap:s});case"callout":return r.jsx(DN,{block:n});case"keyboard":return r.jsx(ON,{block:n,keymap:s});case"gamepad":return r.jsx(BN,{block:n});default:return null}}function Rg({layout:n,keymap:s}){const i=m.useMemo(()=>qN(n),[n]),o=s||{},f=i.main||[],d=i.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(RN,{hero:i.hero,keymap:o}),r.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[r.jsx("div",{className:"space-y-0.5",children:f.map((h,x)=>r.jsx(lx,{block:h,keymap:o},h.title||x))}),r.jsx("div",{className:"space-y-0.5",children:d.map((h,x)=>r.jsx(lx,{block:h,keymap:o},h.title||x))})]})]})}function Tg({layout:n,onOpenOverlay:s}){const{state:i}=_t();return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Help"}),r.jsx("button",{type:"button",onClick:s,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),r.jsx(Rg,{layout:n,keymap:i?.keymap||{}})]})}const LN=["kal","rms","slt","ksp","bdl"],zN=Array.from({length:10},(n,s)=>s*10);function So({hideInput:n=!1,hideSpectatorNotice:s=!1,fillHeight:i=!1,allowSpectatorInput:o=!1}){const{session:f}=ze(),{messages:d,typing:h,sendMessage:x,registerInputRef:p,onInputFocus:g,onInputBlur:y,blurChat:b,setTypingActive:A}=Jf(),{value:R,save:N}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[q,j]=m.useState(""),[w,E]=m.useState(!1),[C,M]=m.useState(!1),[L,K]=m.useState(()=>R?.engine||"flite"),[_,Q]=m.useState(()=>R?.voice||"rms"),[B,U]=m.useState(()=>Number.isFinite(R?.pitch)?R.pitch:50),Y=f?.role!=="spectator"||o,te=m.useRef(null),fe=f?.assignment?.roverId||null,G=!!m.useMemo(()=>f?.roster?.find(k=>String(k.id)===String(fe))||null,[fe,f?.roster])?.audio?.ttsEnabled,T=m.useMemo(()=>d.slice(-200),[d]),F=m.useMemo(()=>h||[],[h]);m.useEffect(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[T,F]),m.useEffect(()=>{const k=R?.engine||"flite",H=R?.voice||"rms",P=Number.isFinite(R?.pitch)?R.pitch:50;L!==k&&K(k),_!==H&&Q(H),B!==P&&U(P)},[L,B,R?.engine,R?.pitch,R?.voice,_]),m.useEffect(()=>{M(!!G)},[G]);const J=m.useMemo(()=>!G||!C?null:L==="espeak"?{speak:!0,engine:L,pitch:B}:{speak:!0,engine:L,voice:_},[L,B,C,G,_]);async function se(k){if(k.preventDefault(),!Y||n)return;const P=q.replace(/\\n/g,`
|
||
`).trim();if(P){E(!0);try{await x(P,J),j(""),b(),A(!1)}catch(ne){alert(ne.message)}finally{E(!1)}}}const de=i?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${i?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${de}`,ref:te,children:[T.length===0&&F.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):T.map(k=>r.jsx(Kf,{message:k},k.id)),F.map(k=>r.jsx(tg,{message:k},`typing-${k.typingId||k.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:q,onChange:k=>{const H=k.target.value;j(H),A(!!H.trim())},onFocus:k=>{g(k),A(!!q.trim())},onBlur:k=>{y(k),A(!1)},onKeyDown:k=>{k.key==="Enter"&&!q.trim()&&(k.preventDefault(),b(),A(!1))},ref:k=>p(k,{target:"panel"}),placeholder:Y?"Type a message…":s?"":"Spectators cannot chat",disabled:!Y}),G&&r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:C,onChange:k=>M(k.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:L,onChange:k=>{const H=k.target.value;K(H),N(P=>({...P||{},engine:H}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),L==="flite"?r.jsx("select",{value:_,onChange:k=>{const H=k.target.value;Q(H),N(P=>({...P||{},voice:H}))},className:"field-input text-xs",children:LN.map(k=>r.jsx("option",{value:k,children:k},k))}):r.jsx("select",{value:B,onChange:k=>{const H=Number(k.target.value);U(H),N(P=>({...P||{},pitch:H}))},className:"field-input text-xs",children:zN.map(k=>r.jsxs("option",{value:k,children:["pitch ",k]},k))})]}),r.jsx("button",{type:"submit",disabled:!Y||w,className:"button-dark h-full disabled:opacity-50 self-stretch",children:w?"...":"Send"})]})]})}function Ao({compact:n=!1}){const{session:s,setNickname:i}=ze(),{value:o,save:f}=Qe("profile",{nickname:""}),[d,h]=m.useState(o.nickname||""),[x,p]=m.useState(!1),g=s?.role!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function y(b){if(b.preventDefault(),!g)return;const A=(d||"").trim().slice(0,32);if(A){p(!0);try{await i(A),f({nickname:A})}catch(R){alert(R.message)}finally{p(!1)}}}return r.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:y,children:[r.jsx("input",{className:"field-input flex-1 min-w-0",value:d,onChange:b=>h(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||x,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:x?"Saving…":n?"Set":"Save"})]})}function UN(n){const s=Array.isArray(n?.socials)?n.socials:null;if(s&&s.length)return s;const i=[];return n?.discord?.invite&&i.push({id:"discord",label:"Discord",url:n.discord.invite}),n?.kofi?.link&&i.push({id:"kofi",label:"Ko-fi",url:n.kofi.link}),i}function HN(n){if(!n||typeof n!="object")return null;const s=n.id||n.service||n.key||n.name||null,i=n.label||n.title||n.name||s||"Link",o=n.url||n.link||n.href||null;return o?{id:s,label:i,url:o}:null}function Dg({className:n=""}){const{session:s}=ze(),i=UN(s).map(HN).filter(Boolean).slice(0,4);return i.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:i.map(o=>r.jsx(sd,{...o},`${o.id||o.label}-${o.url}`))}):null}function VN({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(Ao,{compact:n})})})}function $N(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Dg,{className:"flex-1 min-h-0"})})}function ff(...n){return n.filter(Boolean).join(" ")}function GN(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function YN(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function FN(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 XN(n,s){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${i} (you)`:i}function jo({title:n="Rovers"}){const{session:s,requestControl:i}=ze(),[o,f]=m.useState({}),[d,h]=m.useState(()=>Date.now()),x=m.useMemo(()=>s?.role&&s.role!=="spectator",[s?.role]),p=m.useMemo(()=>s?.role==="admin"||s?.role==="lockdown"||s?.role==="lockdown-admin",[s?.role]),g=s?.roster??[],y=s?.turnQueues??{},b=s?.users??[],A=s?.socketId||null,R=m.useMemo(()=>Object.values(y||{}).some(w=>w?.deadline||w?.idleDeadline),[y]);m.useEffect(()=>{if(!R)return;const w=setInterval(()=>{h(Date.now())},1e3);return()=>clearInterval(w)},[R]);const N=m.useMemo(()=>{const w=new Set(g.map(C=>String(C.id))),E=Object.keys(y||{}).filter(C=>!w.has(String(C))).map(C=>({id:C,name:C,locked:!1,batteryState:null}));return[...g,...E]},[g,y]);async function q(w){if(w){f(E=>({...E,[w]:!0}));try{await i(w)}catch(E){alert(E.message)}finally{f(E=>({...E,[w]:!1}))}}}const j=w=>b.find(E=>E.socketId===w)||{socketId:w,nickname:null,role:null};return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),N.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:N.map(w=>{const E=String(w.id),C=y?.[E]||null,M=C?.queue||[],L=C?.idleDeadline||C?.deadline||null,K=L&&L>d?Math.ceil((L-d)/1e3):L?0:null,_=C?.current||null,Q=_?M.findIndex(se=>se===_):-1,B=M.length>1?Q>=0?M[(Q+1)%M.length]:M[0]:null,U=!!(A&&_&&_===A),Y=!!(A&&B&&B===A),te=K!=null&&(U||Y),fe=!!w.locked,oe=fe&&!p,G=!!(w?.private?.enabled&&w?.private?.open),T=w.lockReason?`locked: ${w.lockReason}`:"locked",F=fe?T:o[E]?"...":"request",J=x&&!oe&&!o[E];return r.jsxs("li",{className:ff("surface flex flex-wrap items-start justify-between gap-0.5",J&&"cursor-pointer",fe?"bg-red-900/40":G?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{J&&q(w.id)},children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{className:"text-slate-200",children:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(w.color,.16),children:w.name})}),te?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:U?`${K}s left`:`Your turn in ${K}s`}):null]}),r.jsx("span",{className:ff("text-[0.75rem] font-semibold",YN(w)),children:GN(w)})]}),M.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):r.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:M.map((se,de)=>{const k=j(se),H=se===_,P=!!(B&&se===B&&!H),ne=H?"bg-sky-600 text-white ring-2 ring-amber-300":P?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return r.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${ne}`,children:[r.jsx("span",{className:`${FN(k.role)} font-semibold`,children:XN(k,A)}),H&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),P&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${E}-${se}-${de}`)})})]}),x?r.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),q(w.id)},disabled:o[E]||oe,className:ff("button-dark disabled:opacity-40",fe&&"bg-red-600/70 text-white hover:bg-red-600"),children:F}):null]},w.id)})})]})}function QN(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 KN(n,s){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${i} (you)`:i}function fo({hideNicknameForm:n=!1,hideHeader:s=!1,className:i="",fillHeight:o=!1,compact:f=!1}){const{session:d}=ze(),h=d?.role!=="spectator",x=d?.users??[],p=d?.socketId||null,g=m.useMemo(()=>[...x].sort((b,A)=>b.socketId===p?-1:A.socketId===p?1:(b.nickname||"").localeCompare(A.nickname||"")),[p,x]),y=o?"flex-1 min-h-0 overflow-y-auto":f?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${i}`,children:[!n&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(Ao,{compact:f})})}),r.jsx(Dg,{})]}),!h&&r.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),r.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!s&&r.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${f?"text-xs":""}`,children:[r.jsx("span",{children:"Users"}),r.jsx("span",{className:"text-xs text-slate-500",children:g.length})]}),r.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${y} ${f?"text-[0.8rem]":""}`,children:g.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(b=>r.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${QN(b.role)}`,children:KN(b,p)},b.socketId))})]})]})}const ZN=/^cu_[a-f0-9]{32}$/,ji="field-input w-full max-w-sm text-left focus:ring-emerald-500",No="mx-auto w-full max-w-xl flex justify-center",hi="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function IN(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 ix=8*1024*1024,ss=16e3,JN={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function rx(n){let s="";for(let o=0;o<n.length;o+=32768){const f=n.subarray(o,o+32768);s+=String.fromCharCode(...f)}return btoa(s)}function PN(n){return typeof btoa=="function"?btoa(n):""}function WN(n){if(!n)return{};const s=PN(`${n}:${n}`);return s?{Authorization:`Basic ${s}`}:{}}function ew(n,s=1500){return new Promise(i=>{if(!n||n.iceGatheringState==="complete"){i();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",f),i()},s);function f(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",f),i())}n.addEventListener("icegatheringstatechange",f)})}function ox(n){if(!n)return!1;const s=n.connectionState,i=n.iceConnectionState;return s==="connected"||i==="connected"||i==="completed"}function tw(n,s=1e4){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(ox(n)){i();return}const f=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},s),d=()=>{ox(n)?(h(),i()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(h(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function h(){clearTimeout(f),n.removeEventListener("connectionstatechange",d),n.removeEventListener("iceconnectionstatechange",d)}n.addEventListener("connectionstatechange",d),n.addEventListener("iceconnectionstatechange",d)})}async function nw(n){if(!n?.getParameters||!n?.setParameters)return;const s=n.getParameters()||{},i=s.encodings&&s.encodings[0]||{};s.encodings=[{...i,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(s)}catch{}}function aw(n,s=6e3){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}const f=Date.now();let d=-1;const h=setInterval(async()=>{if(Date.now()-f>s){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const x=n.getSenders().filter(p=>p.track?.kind==="audio");for(const p of x){const g=await p.getStats();for(const y of g.values()){if(y.type!=="outbound-rtp"||y.kind!=="audio")continue;const b=Number(y.bytesSent||0),A=Number(y.packetsSent||0);if(d<0)d=b;else if(b>d+200||A>5){clearInterval(h),i();return}}}}catch{}},250)})}function mn({label:n,active:s,detail:i=""}){return r.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${s?"bg-emerald-500":"bg-slate-700"}`,children:[r.jsx("div",{className:"text-center font-medium",children:n}),r.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:i||(s?"active":"idle")})]})}function cx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function sw(n){const s=n.reduce((f,d)=>f+d.length,0),i=new Float32Array(s);let o=0;for(const f of n)i.set(f,o),o+=f.length;return i}function lw(n){const s=new Int16Array(n.length);for(let i=0;i<n.length;i+=1){const o=Math.max(-1,Math.min(1,n[i]));s[i]=o<0?o*32768:o*32767}return s}function iw(n,s){const i=lw(n),o=i.length*2,f=new ArrayBuffer(44+o),d=new DataView(f),h=(p,g)=>{for(let y=0;y<g.length;y+=1)d.setUint8(p+y,g.charCodeAt(y))};h(0,"RIFF"),d.setUint32(4,36+o,!0),h(8,"WAVE"),h(12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,1,!0),d.setUint32(24,s,!0),d.setUint32(28,s*2,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),h(36,"data"),d.setUint32(40,o,!0);let x=44;for(let p=0;p<i.length;p+=1,x+=2)d.setInt16(x,i[p],!0);return new Uint8Array(f)}function rw({ownRoverId:n="",audioForwardByRover:s={},playUploadedAudio:i,stopUploadedAudio:o,startMicWhip:f,readyMicWhip:d,stopMicWhip:h}){const{state:x}=_t(),{value:p,save:g}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),y=String(n||"").trim(),[b,A]=m.useState(null),[R,N]=m.useState(!1),q=!!p?.openMicEnabled,w=(p?.pttMode==="clip"?"clip":"live")==="clip",[E,C]=m.useState("idle"),[M,L]=m.useState("idle"),[K,_]=m.useState(""),Q=m.useRef(null),B=m.useRef(null),U=m.useRef(null),Y=m.useRef(!1),te=m.useRef(""),fe=m.useRef(null),oe=m.useRef(null),G=m.useRef(null),T=m.useRef(null),F=m.useRef(null),J=m.useRef([]),se=m.useRef(!1),de=m.useRef(ss),k=!!x?.mic?.pttActive,H=m.useMemo(()=>y&&s?.[y]||null,[s,y]),P=!!(H&&H.state!=="offline"&&!H.error),ne=H?.source==="upload"&&H?.state==="playing",pe=H?.source==="mic-whip"&&(H?.state==="starting"||H?.state==="playing"),ie=!!(!w&&B.current&&(q||k)),ce=!w&&(E==="live"||E==="starting"),ve=w&&M==="recording",ye=w&&M==="sending",xe=bn(x?.keymap?.micPtt?.[0])||"M",Ue=m.useCallback(me=>{const we=me==="clip"?"clip":"live";g(et=>({...et||{},pttMode:we}))},[g]),$e=async()=>{if(!y){_("Take control of your rover first.");return}if(!b){_("Select an audio file first.");return}if(b.size>ix){_(`File too large (max ${ix} bytes).`);return}N(!0),_("");try{const me=await b.arrayBuffer(),we=rx(new Uint8Array(me));await i?.({roverId:y,name:b.name,mime:b.type||"",dataBase64:we}),_("Upload playback started.")}catch(me){_(me?.message||"Failed to play upload.")}finally{N(!1)}},Ne=async()=>{if(!y){_("Take control of your rover first.");return}N(!0),_("");try{await o?.(y),_("Upload playback stopped.")}catch(me){_(me?.message||"Failed to stop upload.")}finally{N(!1)}},ae=m.useCallback(async me=>{const we=String(me||te.current||"").trim();if(Y.current=!1,C("idle"),U.current){try{U.current.getSenders().forEach(et=>et.track?.stop())}catch{}try{U.current.close()}catch{}}if(U.current=null,Q.current)try{Q.current.getTracks().forEach(et=>et.stop())}catch{}if(Q.current=null,B.current=null,we)try{await h?.(we)}catch{}te.current=""},[h]),ue=m.useCallback(async me=>{const we=await f?.(me),et=String(we?.whipUrl||"").trim(),dt=String(we?.token||"").trim();if(!et||!dt)throw new Error("WHIP endpoint unavailable");const Le=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});Q.current=Le;const xt=Le.getAudioTracks()?.[0];if(B.current=xt||null,xt&&(xt.enabled=!!(q||k)),xt?.applyConstraints)try{await xt.applyConstraints({channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const mt=new RTCPeerConnection(JN);U.current=mt,mt.onconnectionstatechange=()=>{if(!Y.current)return;const Gt=mt.connectionState;if(Gt==="connected"){C("live");return}(Gt==="failed"||Gt==="disconnected"||Gt==="closed")&&(C("error"),_(`WHIP transport ${Gt}.`))},Le.getAudioTracks().forEach(Gt=>{const Oa=mt.addTrack(Gt,Le);nw(Oa)});const Tn=await mt.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await mt.setLocalDescription(Tn),await ew(mt,1800);const Et=await fetch(et,{method:"POST",headers:{"Content-Type":"application/sdp",...WN(dt)},body:mt.localDescription?.sdp||Tn.sdp});if(!Et.ok)throw new Error(`WHIP request failed: ${Et.status}`);const cs=await Et.text();await mt.setRemoteDescription({type:"answer",sdp:cs}),await tw(mt,1e4),await aw(mt,6e3),await d?.(me)},[q,k,d,f]),be=m.useCallback(async()=>{if(se.current=!1,T.current){try{T.current.disconnect()}catch{}T.current.onaudioprocess=null}if(G.current)try{G.current.disconnect()}catch{}if(F.current)try{F.current.disconnect()}catch{}if(fe.current)try{fe.current.getTracks().forEach(me=>me.stop())}catch{}if(oe.current)try{await oe.current.close()}catch{}J.current=[],T.current=null,G.current=null,F.current=null,fe.current=null,oe.current=null,de.current=ss},[]),Me=m.useCallback(async()=>{if(fe.current&&oe.current&&T.current)return;L(xt=>xt==="recording"?xt:"arming");const me=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),we=new AudioContext({latencyHint:"interactive"}),et=we.createMediaStreamSource(me),dt=we.createScriptProcessor(1024,1,1),Le=we.createGain();Le.gain.value=0,dt.onaudioprocess=xt=>{if(!se.current)return;const mt=xt.inputBuffer.getChannelData(0);J.current.push(new Float32Array(mt))},et.connect(dt),dt.connect(Le),Le.connect(we.destination),fe.current=me,oe.current=we,G.current=et,T.current=dt,F.current=Le,de.current=we.sampleRate||ss},[]),le=m.useCallback(async({send:me})=>{const we=se.current;if(se.current=!1,!we){me||L("idle");return}const et=J.current;if(J.current=[],!me){L("idle");return}if(!y){L("idle");return}if(!et.length){L("idle");return}L("sending");try{const dt=sw(et),Le=iw(dt,de.current||ss),xt=rx(Le);await i?.({roverId:y,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:xt}),L("idle")}catch(dt){L("error"),_(dt?.message||"Failed to send PTT clip.")}},[i,y]),re=m.useCallback(async()=>{if(!y){_("Take control of your rover first.");return}await Me(),J.current=[],se.current=!0,L("recording")},[Me,y]);return m.useEffect(()=>{let me=!1;async function we(){if(w){await ae(te.current||y);return}if(!y){await ae(te.current);return}if(!(Y.current&&te.current===y)&&!(!q&&!k))try{C("starting"),_(""),Y.current=!0,te.current=y,await ue(y),me||C("live")}catch(et){me||(C("error"),_(et?.message||"Failed to start mic forwarding.")),await ae(y)}}return we(),()=>{me=!0}},[w,q,k,y,ue,ae]),m.useEffect(()=>{const me=B.current;me&&(me.enabled=!!(!w&&(q||k)))},[w,q,k]),m.useEffect(()=>{let me=!1;async function we(){if(!w||!y){se.current&&await le({send:!1}),L("idle");return}try{await Me(),!me&&!se.current&&L("idle")}catch(et){me||(L("error"),_(et?.message||"Microphone access failed for clip mode."))}}return we(),()=>{me=!0}},[w,Me,le,y]),m.useEffect(()=>{let me=!1;async function we(){if(w){if(!y){se.current&&await le({send:!1});return}if(k){if(!se.current)try{_(""),await re()}catch(et){me||(L("error"),_(et?.message||"Failed to start clip recording."))}}else se.current&&await le({send:!0})}}return we(),()=>{me=!0}},[w,le,k,y,re]),m.useEffect(()=>()=>{ae(te.current||y),be()},[y,ae,be]),r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[r.jsx("span",{children:"Push-to-Talk Key"}),r.jsx(cx,{label:xe})]})}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),r.jsx("p",{className:"text-xs text-slate-400 text-center",children:"Choose how holding your PTT key behaves: live mic stream, or record-and-send clip. If the live stream doesn't work, switch to clip mode."}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${w?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Ue("live"),children:"Live Mic (WHIP)"}),r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${w?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Ue("clip"),children:"Record Clip"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(mn,{label:"Mode",active:w,detail:w?"record clip":"live mic"}),r.jsx(mn,{label:"PTT hold",active:k,detail:k?"held":"released"}),r.jsx(mn,{label:"Recording",active:ve,detail:ve?"capturing":"idle"}),r.jsx(mn,{label:"Playback",active:w&&ne,detail:w&&ne?"playing":"idle"})]})]})})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),r.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),r.jsx("input",{className:`${ji} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:R||!y,onChange:me=>A(me.target.files?.[0]||null)})]}),r.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:b?r.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[b.name," (",b.size," bytes)"]}):r.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:R||!y,onClick:$e,children:R?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:R||!y,onClick:Ne,children:"Stop"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),r.jsxs("label",{className:"surface-muted mx-auto flex w-full max-w-sm items-center justify-center gap-0.5 px-0.5 py-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:q,disabled:!y||w,onChange:me=>g(we=>({...we||{},openMicEnabled:!!me.target.checked}))}),r.jsx("span",{children:w?"Open mic (live mode only)":"Open mic"})]}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(mn,{label:"WHIP link",active:ce,detail:E}),r.jsx(mn,{label:"Mic hot",active:ie,detail:ie?"transmitting":"muted"}),r.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",r.jsx(cx,{label:xe})," to talk"]})]})]})})]}),r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[r.jsx(mn,{label:"Forward pipe",active:P,detail:P?"connected":"offline"}),r.jsx(mn,{label:"Upload playback",active:ne,detail:ne?"playing":"idle"}),r.jsx(mn,{label:"Mic relay",active:pe,detail:pe?"active":"idle"}),r.jsx(mn,{label:"WHIP transport",active:ce,detail:E}),r.jsx(mn,{label:"Clip recording",active:ve,detail:ve?"recording":"idle"}),r.jsx(mn,{label:"Clip sending",active:ye,detail:ye?"sending":"idle"})]}),K?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:K}):null]})})]})}function ow({pendingRequestId:n,currentStoredKey:s,nickname:i,requestVerification:o,applyIdentityKey:f,onMessage:d,fullWidth:h=!1}){const[x,p]=m.useState(0),[g,y]=m.useState(""),[b,A]=m.useState(!1),[R,N]=m.useState(!1),q=()=>{p(1),y(s),A(!1),d?.("")},j=()=>{p(0),A(!1)},w=async C=>{if(C.preventDefault(),!b){d?.("Please confirm your nickname agreement before sending.");return}if(x<3){d?.("Complete all request steps before sending.");return}N(!0),d?.("");try{const M=await f(g);await o?.(),y(M),p(0),A(!1),d?.("Verification request sent to lockdown admins.")}catch(M){d?.(M.message||"Failed to submit request.")}finally{N(!1)}},E=h?"w-full":No;return n?r.jsx("section",{className:`surface text-sm text-slate-300 ${E}`,children:r.jsxs("div",{className:hi,children:["Verification request pending: ",n]})}):x===0?r.jsx("section",{className:`surface ${E}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:q,disabled:R,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${E}`,onSubmit:w,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",x," of 3"]}),x===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(Ao,{compact:!0})}),r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",r.jsx("span",{className:"font-semibold",children:i||"(not set)"})]}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:C=>A(C.target.checked)}),r.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!i||!b,onClick:()=>p(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:j,children:"Cancel"})]})]}):null,x===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:ji,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:C=>y(C.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>navigator.clipboard?.writeText(g),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>p(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>p(1),children:"Back"})]})]}):null,x===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:ji,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:C=>y(C.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:R||!g,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>p(2),children:"Back"})]})]}):null]})})}function cw({currentStoredKey:n,applyIdentityKey:s,onMessage:i,fullWidth:o=!1}){const[f,d]=m.useState(0),[h,x]=m.useState(""),[p,g]=m.useState(!1),y=()=>{d(1),x(""),i?.("")},b=()=>{d(0),x("")},A=async N=>{if(N.preventDefault(),!(f<2)){g(!0),i?.("");try{await s(h),d(0),x(""),i?.("Identity key restored.")}catch(q){i?.(q.message||"Failed to restore key.")}finally{g(!1)}}},R=o?"w-full":No;return r.jsx("section",{className:`surface ${R}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",IN(n)||"not set yet"]}),r.jsx("input",{className:ji,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),f===0?r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,disabled:p,children:"Restore Key"})]}):null,f===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,f===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:A,children:[r.jsx("input",{className:ji,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:h,onChange:N=>x(N.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:p||!h,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(1),children:"Back"})]})]}):null]})})}function uw({requestableRovers:n=[],pendingRequests:s=[],requestPrivateRoverAccess:i,onMessage:o,fullWidth:f=!1}){const[d,h]=m.useState({}),x=m.useMemo(()=>{const y=new Map;return(s||[]).forEach(b=>{b?.roverId&&y.set(String(b.roverId),b)}),y},[s]),p=f?"w-full":No,g=async y=>{if(y){h(b=>({...b,[y]:!0})),o?.("");try{(await i?.(y))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(b){o?.(b.message||"Failed to send request.")}finally{h(b=>({...b,[y]:!1}))}}};return r.jsx("section",{className:`surface text-sm text-slate-300 ${p}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?r.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):r.jsx("div",{className:"w-full space-y-0.5",children:n.map(y=>{const b=String(y.id),A=!!d[b],R=x.get(b);return r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[r.jsxs("div",{className:"min-w-0 text-left",children:[r.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:y.name||b}),r.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:b})]}),R?r.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):r.jsx("button",{type:"button",onClick:()=>g(b),disabled:A,className:"button-dark text-xs disabled:opacity-50",children:A?"Sending...":"Request"})]},b)})})]})})}function _g(){const{session:n,identifySession:s,requestVerification:i,requestPrivateRoverAccess:o,playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:x,stopMicWhip:p}=ze(),{value:g,save:y}=Qe("identity",{cookieUserId:""}),{value:b}=Qe("profile",{nickname:""}),A=m.useMemo(()=>(g?.cookieUserId||"").trim(),[g?.cookieUserId]),R=(b?.nickname||"").trim(),N=!!n?.isVerified,q=n?.verification?.pendingRequestId||null,j=n?.privateRoverAccess?.requestableRovers||[],w=n?.privateRoverAccess?.pendingRequests||[],E=String(n?.assignment?.roverId||"").trim(),[C,M]=m.useState(""),L=async K=>{const _=String(K||"").trim().toLowerCase();if(!_)throw new Error("Identity key required.");if(!ZN.test(_))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return y(Q=>({...Q||{},cookieUserId:_})),await s({cookieUserId:_,nickname:R}),_};return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[r.jsx("div",{className:"lg:col-span-2",children:N?r.jsx("section",{className:"surface w-full",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center",children:[r.jsx("p",{className:"text-sm text-emerald-300",children:"Verification complete"}),r.jsx("p",{className:"text-xs text-slate-400",children:"VIP controls are unlocked for your assigned rover."})]})}):r.jsx(ow,{pendingRequestId:q,currentStoredKey:A,nickname:R,requestVerification:i,applyIdentityKey:L,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:N?r.jsx(rw,{ownRoverId:E,audioForwardByRover:n?.audioForward||{},playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:x,stopMicWhip:p}):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(uw,{requestableRovers:j,pendingRequests:w,requestPrivateRoverAccess:o,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(cw,{currentStoredKey:A,applyIdentityKey:L,onMessage:M,fullWidth:!0})})]}),C?r.jsx("div",{className:No,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:C})}):null]})}function fw(){const{state:{roverId:n}}=_t(),i=cl(n)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(Mf,{sensors:i})})})}function dw(){const{state:{roverId:n,keymap:s,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,startHorn:x,stopHorn:p}}=_t(),g=pg(n),y=g.docked&&!g.driving,b=i?.config,A=!!(n&&i?.enabled&&b),R=!!(n&&f?.nightVision),N=f?.nightVisionState,q=!!(n&&f?.horn),j=o?.overheated,w=typeof b?.minAngle=="number"?b.minAngle:-30,E=typeof b?.maxAngle=="number"?b.maxAngle:30,C=typeof i?.angle=="number"?i.angle:typeof b?.homeAngle=="number"?b.homeAngle:(w+E)/2,M=bn(s?.nightVisionToggle?.[0]),L=bn(s?.hornHonk?.[0]),K=bn(s?.cameraUp?.[0]),_=bn(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(xg,{layout:"desktop",expand:!0,driveDockState:g}),y?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[R&&r.jsx(gg,{nightVisionOn:N?.nightVisionOn,disabled:!n,onToggle:h,keyLabel:M}),q&&r.jsx(vg,{disabled:!n||j,onStart:x,onStop:p,keyLabel:L,active:o?.active,heat:o?.heat}),A&&r.jsx(yg,{value:C,min:w,max:E,onChange:d,keyDownLabel:_,keyUpLabel:K,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 mw({layout:n,onOpenHelpOverlay:s}){const{session:i}=ze(),{state:o}=_t(),{value:f}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),d=i?.isVerified?"bg-emerald-400":"bg-red-600",h=String(i?.assignment?.roverId||"").trim(),x=h?i?.audioForward?.[h]:null,p=!!o?.mic?.pttActive,g=!!f?.openMicEnabled,y=f?.pttMode==="clip"?"clip":"live",b=!!(h&&i?.isVerified&&(y==="clip"?p:g||p)),A=!!(h&&i?.isVerified&&y==="clip"&&x?.source==="upload"&&x?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(cd,{defaultTab:"telemetry",children:[r.jsxs(ud,{children:[r.jsx(Pt,{id:"telemetry",children:"Controls"}),r.jsx(Pt,{id:"vip",highlight:A?"green":b?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${d}`,"aria-hidden":"true",title:i?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Pt,{id:"help",children:"Help"}),r.jsx(Pt,{id:"settings",children:"Settings"})]}),r.jsxs(fd,{children:[r.jsx(Wt,{id:"telemetry",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[r.jsx(fw,{}),r.jsx(dw,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(jo,{}),r.jsx(Xf,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx($N,{})]}),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(So,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(fo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(VN,{compact:!0})]})]}),r.jsx(Ng,{}),r.jsx(ed,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(Wt,{id:"vip",keepMounted:!0,children:r.jsx(_g,{})}),r.jsx(Wt,{id:"help",children:r.jsx(Tg,{layout:n,onOpenOverlay:s})}),r.jsx(Wt,{id:"settings",children:r.jsx(Mg,{})})]})]})})}const hw=new Set(["admin","lockdown","lockdown-admin"]),pw=new Set(["lockdown","lockdown-admin"]),xw=new Set(["admin","lockdown"]);function gw(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 vw(){const{session:n}=ze(),s=n?.mode,i=n?.role,o=n?.adminReason?.text||"";n?.adminReason?.updatedAt;const f=n?.timezone||"UTC",d=n?.socials?.find(A=>String(A?.id||A?.label||"").toLowerCase()==="discord")?.url||n?.discord?.invite||null,h=xw.has(s),x=s==="lockdown"?pw.has(i):hw.has(i),[p,g]=m.useState(()=>new Date),y=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:f,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(p)}catch{return p.toLocaleTimeString()}},[p,f]);if(m.useEffect(()=>{const A=setInterval(()=>g(new Date),1e3);return()=>clearInterval(A)},[]),!h||x)return null;const b=gw(s);return r.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black/85 px-0.5 py-0.5",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold",children:b.title}),r.jsx("p",{className:"text-sm text-slate-300",children:b.description})]}),r.jsxs("div",{className:"surface-muted space-y-0.5",children:[r.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),r.jsx("p",{className:"text-lg font-semibold text-slate-100",children:o||"No reason set."}),r.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",y]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx(wg,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(sd,{id:"discord",label:"Join our Discord server for updates!",url:d})}),"You can still use the chat while the server is locked:",r.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[r.jsx(So,{}),r.jsx(Ao,{})]})]})})}const yw="/assets/turn_alert-DVO8EZJa.mp3";function bw(n,s=1){const i=m.useRef(null);return m.useEffect(()=>{i.current=new Audio(n),i.current.volume=s,i.current.load()},[n,s]),()=>{i.current&&(i.current.volume=s,i.current.currentTime=0,i.current.play().catch(()=>{}))}}function Sw(){const{session:n,pushAlert:s}=ze(),{value:i}=Qe("audio",Dt),o=Number.isFinite(i?.masterVolume)?i.masterVolume:Dt.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:Dt.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=bw(yw,d),x=m.useRef(new Set),p=m.useMemo(()=>n?.turnQueues||{},[n?.turnQueues]),g=n?.socketId||null;return m.useEffect(()=>{if(!g)return;const y=[];Object.entries(p).forEach(([b,A])=>{!A||!A.current||A.current!==g||x.current.has(b)||(y.push(b),x.current.add(b))}),Object.keys(p).forEach(b=>{(!p[b]||p[b].current!==g)&&x.current.delete(b)}),y.length!==0&&(y.forEach(b=>{const A=n?.roster?.find(R=>String(R.id)===String(b))?.name||b;s({title:"Your turn!",message:`You now control ${A}.`,color:"#ff5722"})}),h())},[p,h,s,n?.roster,g]),null}function Aw({visible:n,mode:s,onEnterFullscreen:i,onDismiss:o}){if(!n)return null;const f=s==="pwa-hint";return r.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center p-2 pointer-events-none sm:items-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-sm rounded-lg border border-cyan-500/40 bg-zinc-950/95 shadow-xl",children:r.jsxs("div",{className:"space-y-0.5 p-4 text-sm text-slate-100",children:[r.jsx("h2",{className:"text-base font-semibold text-white",children:"Better in fullscreen"}),f?r.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",r.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen removes the browser chrome."]}):r.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),r.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[r.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:f?"Got it":"Not now"}),!f&&r.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:i,children:"Enter fullscreen"})]})]})})})}function jw({side:n="right",onClick:s}){const i=n==="left"?"left-2":"right-2";return r.jsx("button",{type:"button",onClick:s,className:`fixed bottom-2 ${i} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-cyan-200/50 bg-slate-900/70 text-cyan-100 shadow-lg backdrop-blur-sm transition hover:bg-slate-800/80 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:r.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:r.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const Og="fullscreenPromptDismissed",Nw=new Set(["mobile-portrait","mobile-landscape"]),Bg=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},ww=()=>{const n=Bg();if(!n)return!1;try{return n.getItem(Og)==="1"}catch{return!1}},ux=()=>{const n=Bg();if(n)try{n.setItem(Og,"1")}catch{}},Cw=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},fx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function Ew(n){const s=Nw.has(n),[i,o]=m.useState(!1),[f,d]=m.useState("native"),[h,x]=m.useState(!1),p=m.useMemo(()=>Cw(),[]),g=m.useMemo(()=>fx(),[]),y=m.useCallback(()=>{if(!s){o(!1),x(!1);return}if(!h&&ww()){o(!1);return}if(p){d("pwa-hint"),o(!0);return}if(!fx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[h,p,s]);m.useEffect(()=>{y()},[y]),m.useEffect(()=>{if(typeof document>"u")return;const N=()=>{if(document.fullscreenElement){x(!1),o(!1);return}y()};return document.addEventListener("fullscreenchange",N),document.addEventListener("webkitfullscreenchange",N),()=>{document.removeEventListener("fullscreenchange",N),document.removeEventListener("webkitfullscreenchange",N)}},[y]);const b=m.useCallback(()=>{ux(),x(!1),o(!1)},[]),A=m.useCallback(async()=>{if(!s||p||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const N=document.documentElement;if(!N)return!1;const q=N.requestFullscreen||N.webkitRequestFullscreen||N.mozRequestFullScreen||N.msRequestFullscreen;if(!q)return!1;try{const j=q.call(N);return j&&typeof j.then=="function"&&await j,ux(),x(!1),o(!1),!0}catch(j){return console.warn("Failed to enter fullscreen",j),!1}},[p,s]),R=m.useCallback(()=>{s&&(x(!0),d(p?"pwa-hint":"native"),o(!0))},[p,s]);return m.useEffect(()=>{s||(x(!1),o(!1))},[s]),{visible:i,mode:f,isIOS:p,nativeSupported:g,enterFullscreen:A,dismiss:b,showPrompt:R}}function kw({visible:n,layout:s,onClose:i,showOnLoad:o,onToggleShowOnLoad:f}){if(!n)return null;const{state:d}=_t(),h=x=>{const p=!x.target.checked;f?.(p)};return r.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:r.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:"Help & controls"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:i,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),r.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:r.jsx(Rg,{layout:s,keymap:d?.keymap||{}})})]})})}const Mw=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
`;function qw(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function Rw(){const n=String(Mw).split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function dd(){const{setNickname:n}=ze(),{value:s,status:i,save:o}=Qe("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(i!=="ready"||f.current||(s.nickname||"").trim())return;f.current=!0;const h=qw(Rw()).slice(0,32);if(!h)return;(async()=>{try{await n(h)}catch{}finally{o({nickname:h})}})()},[o,n,i,s.nickname])}function Tw(){const n=Rn(),{connected:s,identifySession:i}=ze(),{value:o,status:f,save:d}=Qe("identity",{cookieUserId:""}),{value:h,status:x}=Qe("profile",{nickname:""}),p=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),b=f==="ready"&&x==="ready",A=(o?.cookieUserId||"").trim(),R=(h?.nickname||"").trim(),N=m.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),q=m.useCallback(async()=>{if(!(!b||!s||!n?.id||p.current)){p.current=!0;try{const w=((await i({cookieUserId:A,nickname:R}))?.cookieUserId||"").trim();w&&w!==A&&d(E=>({...E||{},cookieUserId:w})),g.current=n.id,N()}catch{N(),y.current=setTimeout(()=>{q()},2e3)}finally{p.current=!1}}},[N,s,A,i,R,b,d,n?.id]);m.useEffect(()=>{!b||!s||!n?.id||g.current!==n.id&&q()},[s,b,q,n?.id]),m.useEffect(()=>{!b||!s||!n?.id||q()},[b,s,n?.id,A,R,q]),m.useEffect(()=>{const j=()=>{n?.connected&&q()},w=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&q()};return window.addEventListener("online",j),document.addEventListener("visibilitychange",w),()=>{window.removeEventListener("online",j),document.removeEventListener("visibilitychange",w)}},[q,n?.connected]),m.useEffect(()=>()=>N(),[N])}const df=1e4,mf=28,Dw=14;function mo({layout:n="desktop",className:s="",dismissable:i=!0}){const{session:o}=ze(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[h,x]=m.useState(!1),[p,g]=m.useState(mf),[y,b]=m.useState(0),A=m.useRef(null),R=m.useRef(null),N=m.useRef(null);m.useEffect(()=>{if(!f){x(!1);return}if(x(!0),!d||!i)return;const E=Date.now();b(df);const C=setTimeout(()=>x(!1),df),M=setInterval(()=>{const L=Date.now()-E;b(Math.max(0,df-L))},250);return()=>{clearTimeout(C),clearInterval(M)}},[f,d]),m.useEffect(()=>{if(!f)return;g(mf);let E=0;const C=()=>{const L=N.current,K=R.current;if(!L||!K)return;const _=L.clientWidth;if(!_)return;const Q=K.scrollWidth;if(!Q)return;const B=Math.min(1,_/Q),U=Math.max(Dw,Math.floor(mf*B));g(U)};E=window.requestAnimationFrame(C);const M=new ResizeObserver(()=>{window.cancelAnimationFrame(E),E=window.requestAnimationFrame(C)});return A.current&&M.observe(A.current),()=>{window.cancelAnimationFrame(E),M.disconnect()}},[f]);const q=m.useMemo(()=>["panel-section flex w-full items-center justify-center",d?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",s].filter(Boolean).join(" "),[s,d]);if(!f||!h)return null;const j=d?Math.ceil(y/1e3):null,w=i?{onClick:()=>x(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:A,className:q,style:{fontSize:`${p}px`,lineHeight:1.1},...w,children:r.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[r.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[r.jsx("span",{children:"Community"}),r.jsx("span",{children:"Goal"})]}),r.jsx("span",{ref:N,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:R,className:"block",children:f})}),d?r.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[j,"s"]}):null]})})}function _w(){const[n,s]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function i(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:f}=window;o>=1024?s("desktop"):o>f?s("mobile-landscape"):s("mobile-portrait")}return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),n}function Ow({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(ld,{}),r.jsx(BS,{}),r.jsx(td,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(mo,{layout:n}),r.jsx(mw,{layout:n,onOpenHelpOverlay:s})]})]})}function Lg({layout:n,onOpenHelpOverlay:s,roomPanelId:i,showTelemetry:o=!0}){const{session:f}=ze(),{state:d}=_t(),{value:h}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),x=f?.isVerified?"bg-emerald-400":"bg-amber-400",p=String(f?.assignment?.roverId||"").trim(),g=p?f?.audioForward?.[p]:null,y=!!d?.mic?.pttActive,b=!!h?.openMicEnabled,A=h?.pttMode==="clip"?"clip":"live",R=!!(p&&f?.isVerified&&(A==="clip"?y:b||y)),N=!!(p&&f?.isVerified&&A==="clip"&&g?.source==="upload"&&g?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(cd,{defaultTab:"chat",children:[r.jsxs(ud,{children:[r.jsx(Pt,{id:"chat",children:"Chat"}),r.jsx(Pt,{id:"vip",highlight:N?"green":R?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${x}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Pt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Pt,{id:"help",children:"Help"}),r.jsx(Pt,{id:"settings",children:"Settings"})]}),r.jsxs(fd,{children:[r.jsx(Wt,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(So,{}),r.jsx(fo,{})]})}),r.jsx(Wt,{id:"vip",keepMounted:!0,children:r.jsx(_g,{})}),r.jsx(Wt,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Ng,{}),r.jsx(ed,{panelId:i})]})}),r.jsx(Wt,{id:"help",children:r.jsx(Tg,{layout:n,onOpenOverlay:s})}),r.jsx(Wt,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Mg,{}),r.jsx(td,{})]})})]})]})})}function Bw({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(ld,{layoutFormat:"mobile-portrait"}),r.jsx(dj,{swapColumns:s}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Xf,{panelId:"replay-sources-mobile-portrait"}),r.jsx(jo,{})]}),r.jsx(Lg,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function Lw({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){const i="self-start h-[min(100svh,32rem)]",o=s?r.jsx(uo,{layout:"landscape",className:i}):r.jsx(co,{layout:"landscape",className:i}),f=s?r.jsx(co,{layout:"landscape",className:i}):r.jsx(uo,{layout:"landscape",className:i});return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[o,r.jsxs("div",{children:[r.jsx(ld,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Xf,{panelId:"replay-sources-mobile-landscape"}),r.jsx(jo,{})]})]}),f]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(Lg,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function zw(){const n=_w(),s=n==="desktop",i=Ew(n);return r.jsx("div",{className:`bg-black text-slate-100 ${s?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(Uw,{layout:n,isDesktop:s,fullscreen:i})})}function Uw({layout:n,isDesktop:s,fullscreen:i}){dd(),Tw();const{visible:o,mode:f,isIOS:d,nativeSupported:h,enterFullscreen:x,dismiss:p,showPrompt:g}=i,{value:y,status:b,save:A}=Qe("help",{showOnLoad:!0}),{value:R}=Qe("page",{swapMobileControlColumns:!1}),N=!!R?.swapMobileControlColumns,q=N?"left":"right",j=!s&&(d||h),[w,E]=m.useState(!1);m.useEffect(()=>{b==="ready"&&E(y?.showOnLoad!==!1)},[b,y?.showOnLoad]);const C=m.useCallback(()=>E(!0),[]),M=m.useCallback(()=>E(!1),[]),L=m.useCallback(async()=>{if(d){g();return}await x()||g()},[x,d,g]),K=m.useCallback(Q=>{const B=!!Q;A(U=>({...U??{},showOnLoad:B})),B||E(!1)},[A]),_=m.useMemo(()=>s?r.jsx(Ow,{layout:n,onOpenHelpOverlay:C}):n==="mobile-landscape"?r.jsx(Lw,{onOpenHelpOverlay:C,swapMobileControlColumns:N}):r.jsx(Bw,{onOpenHelpOverlay:C,swapMobileControlColumns:N}),[s,n,C,N]);return r.jsxs(MA,{children:[r.jsx(HA,{}),r.jsx(nj,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${s?"h-full overflow-hidden":""}`,children:[s?null:r.jsx(mo,{layout:n}),_]}),r.jsx(Zf,{}),r.jsx(Sw,{}),r.jsx(vw,{}),r.jsx(kw,{visible:w,layout:n,onClose:M,showOnLoad:y?.showOnLoad!==!1,onToggleShowOnLoad:K}),r.jsx(Aw,{visible:o,mode:f,onEnterFullscreen:x,onDismiss:p}),j?r.jsx(jw,{side:q,onClick:L}):null]})}function zg(){const{session:n,setRole:s,subscribeAll:i,connected:o}=ze(),[f,d]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function x(){if(n?.mode==="lockdown"){d(!1);return}try{n?.role!=="spectator"&&await s("spectator"),await i(),h||d(!0)}catch(p){console.error("Failed to enter spectator mode",p),h||d(!1)}}return x(),()=>{h=!0}},[o,n?.mode,n?.role,s,i]),f}function Hw(){const[n,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(max-aspect-ratio: 4/3)"),o=f=>s(f.matches);return i.addEventListener?i.addEventListener("change",o):i.addListener(o),()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener(o)}},[]),n}function Vw({roverId:n,session:s}){const i=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(p=>p.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f} (turns)`:f}function $w({rover:n,frame:s,sessionInfo:i,videoMode:o,snapshotFeed:f,audioInfo:d,session:h}){const x=Vw({roverId:n.id,session:h});return r.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:r.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:r.jsx(bi,{sessionInfo:i,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:n.name,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:x,hudForceMap:!0,hudMapPosition:"top-center"})})})}function Gw({roster:n,frames:s,videoSources:i,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:h}){return n.length===0?r.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):r.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:n.map(x=>r.jsx($w,{rover:x,frame:s[x.id],sessionInfo:h&&i[x.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[x.id],audioInfo:f[`${x.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},x.id))})}function Yw(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(ed,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function Fw({className:n=""}){return r.jsx("div",{className:`panel ${n}`,children:r.jsx(td,{})})}function Xw(){const{session:n}=ze(),s=n?.mode==="lockdown",i=!!n?.isLocalNetwork;dd(),zg();const o=Hw(),f=Yf(),d=n?.roster??[],h=nd(d.map(j=>j.id),{enabled:!s&&!i,version:n?.mode}),x=i?d.map(j=>({type:"rover",id:j.id,key:j.id})):[],p=vi(x,{enabled:!s&&i,version:n?.mode}),g=d.flatMap(j=>j.media?.audioPublishUrl?[{type:"rover",id:`${j.id}-audio`,key:`${j.id}-audio`}]:[]),y=vi(g,{enabled:!s,version:n?.mode});if(s)return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),r.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const b=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",A=o?"order-2 flex min-h-0 min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto":"order-1 flex min-h-0 min-w-0 flex-col gap-0.5 md:overflow-y-auto",R=o?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",N="",q=o?"h-64":"";return r.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[r.jsxs("main",{className:b,children:[r.jsxs("section",{className:R,children:[o?r.jsxs("div",{className:`${N} ${q} flex flex-col gap-0.5`,children:[r.jsx(mo,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(fo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsx("div",{className:N,children:r.jsx(mo,{layout:"desktop",dismissable:!1,className:"text-sm"})}),r.jsx("div",{className:`${N} ${o?`${q} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(jo,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${N} flex-1 min-h-0`,children:r.jsx(fo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${N} ${o?q:"flex-[1.1] min-h-0"}`,children:r.jsx(So,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${N} ${o?q:""}`,children:r.jsx(Fw,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:A,children:[r.jsx(Gw,{roster:d,frames:f,videoSources:p,snapshotFeeds:h,audioSources:y,session:n,canSpectateVideo:i}),r.jsx(Yw,{})]})]}),r.jsx(Zf,{})]})}function Qw(){return r.jsx(Xw,{})}const Kw=2e4,Zw=3600*1e3;function Iw({roverId:n,session:s}){const i=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(x=>x.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f}`:f}function Jw({rover:n,frame:s}){const i=s?.sensors?.batteryChargeMah??null,o=n?.battery??null;return jg({batteryState:n?.batteryState??null,charge:i,config:o})}function dx({rover:n,frame:s,driverLabel:i,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:h=!1,showPreview:x=!0,variant:p="stacked"}){const g=Jw({rover:n,frame:s}),y=g?.available?g.percentDisplay:null,b=p==="active";return r.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[r.jsx(qf,{visual:g,orientation:b?"vertical":"horizontal",variant:"background"}),b?r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ra(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):r.jsx("div",{}),r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:y==null?"--%":`${y}%`})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ra(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):null,r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(el,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:y==null?"--%":`${y}%`})})})]}),r.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:r.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:x?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(bi,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}function el({children:n,className:s="",maxSize:i=1e3,minSize:o=14,style:f=void 0}){const d=m.useRef(null),h=m.useRef(null),[x,p]=m.useState(i);return m.useLayoutEffect(()=>{const g=d.current,y=h.current;if(!g||!y)return;let b=null;const A=()=>{const q=g.clientWidth;if(!q){R();return}let j=o,w=i,E=o;for(;j<=w;){const C=Math.floor((j+w)/2);y.style.fontSize=`${C}px`,y.scrollWidth<=q?(E=C,j=C+1):w=C-1}p(E)},R=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(A)};R();const N=new ResizeObserver(R);return N.observe(g),()=>{b&&cancelAnimationFrame(b),N.disconnect()}},[n,i,o]),r.jsx("div",{ref:d,className:"w-full min-w-0",children:r.jsx("div",{ref:h,className:`whitespace-nowrap ${s}`,style:{fontSize:`${x}px`,lineHeight:1.1,...f||{}},children:n})})}function Pw(){const{session:n}=ze(),s=zg();dd();const i=n?.mode==="lockdown",o=!!n?.isLocalNetwork,f=Yf(),d=n?.roster??[],[h,x]=m.useState(0),p=n?.activeDrivers||{},g=m.useMemo(()=>d.filter(U=>p[U.id]),[d,p]),y=g.length?g:d,b=nd(y.map(U=>U.id),{enabled:!i&&!o,version:n?.mode}),A=m.useMemo(()=>o?y.map(U=>({type:"rover",id:U.id,key:U.id})):[],[o,y]),R=vi(A,{enabled:!i&&o,version:n?.mode}),N=m.useMemo(()=>g.flatMap(U=>{if(!U?.id||!U.media?.audioPublishUrl)return[];const Y=String(U.id);return[{type:"rover",id:`${Y}-audio`,key:`${Y}-audio`}]}),[g]),q=vi(N,{enabled:!i,version:n?.mode}),j=m.useMemo(()=>{if(!g.length)return[];if(!o){const Y=g.filter(te=>b[te.id]?.objectUrl);return Y.length?Y:g}const U=g.filter(Y=>{const te=R[Y.id];return te?.url&&!te?.error});return U.length?U:g},[g,b,R,o]),w=m.useMemo(()=>j.map(U=>({type:"rover",rover:U})),[j]),E=m.useMemo(()=>w.map(U=>`r:${U.rover.id}`).join("|"),[w]);m.useEffect(()=>{x(0)},[E]),m.useEffect(()=>{if(!w.length)return;const U=setInterval(()=>{x(Y=>(Y+1)%w.length)},Kw);return()=>clearInterval(U)},[w.length,E]);const C=w.length?w[h%w.length]:null,M=C?.type==="rover"?C.rover:null,L=!o&&M&&b[M.id]||null,K=o&&M&&R[M.id]||null,_=M&&q[`${M.id}-audio`]||null,Q=M&&f[M.id]||null,B=M?Iw({roverId:M.id,session:n}):null;return i?r.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),r.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):g.length?r.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[r.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:s?M?r.jsx(e2,{children:o?r.jsx("div",{className:"relative h-full w-full",children:w.map(U=>{const Y=U.rover,te=M?.id===Y.id;return r.jsx("div",{className:`absolute inset-0 ${te?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(bi,{sessionInfo:R[Y.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:te?_:null,forceMute:!te,label:Y.name||Y.id,roverColor:Y.color||null,telemetryFrame:f[Y.id]||null,batteryConfig:Y.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},Y.id)})}):r.jsx(bi,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:L,audioSessionInfo:_,label:M.name||M.id,roverColor:M.color||null,telemetryFrame:Q,batteryConfig:M.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:g.length?"No sources available.":"No active drivers."}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),r.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:M?r.jsx(dx,{rover:M,frame:Q,driverLabel:B,sessionInfo:o?K:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[M.id]||null,showPreview:!1,variant:"active"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):r.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:r.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:d.length?d.map((U,Y)=>r.jsx(dx,{rover:U,frame:f[U.id]||null,driverLabel:null,sessionInfo:o&&R[U.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[U.id]||null,showPreview:!0,withDivider:!1},U.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function Ww(){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())},Zw);return()=>clearTimeout(n)},[]),r.jsxs(r.Fragment,{children:[r.jsx(Pw,{}),r.jsx(Zf,{scale:3})]})}function e2({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})})})}ib.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(MS,{children:r.jsx(RS,{children:r.jsx(TS,{children:r.jsx(VS,{children:r.jsx(RA,{children:r.jsx(S1,{children:r.jsxs(Pb,{children:[r.jsx(Qr,{path:"/",element:r.jsx(zw,{})}),r.jsx(Qr,{path:"/spectate",element:r.jsx(Qw,{})}),r.jsx(Qr,{path:"/mini",element:r.jsx(Ww,{})})]})})})})})})})}));
|