mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
132 lines
584 KiB
JavaScript
132 lines
584 KiB
JavaScript
(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))o(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const p of f.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&o(p)}).observe(document,{childList:!0,subtree:!0});function r(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function o(u){if(u.ep)return;u.ep=!0;const f=r(u);fetch(u.href,f)}})();function Cy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Gu={exports:{}},Zl={};var vp;function ky(){if(vp)return Zl;vp=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(o,u,f){var p=null;if(f!==void 0&&(p=""+f),u.key!==void 0&&(p=""+u.key),"key"in u){f={};for(var h in u)h!=="key"&&(f[h]=u[h])}else f=u;return u=f.ref,{$$typeof:n,type:o,key:p,ref:u!==void 0?u:null,props:f}}return Zl.Fragment=a,Zl.jsx=r,Zl.jsxs=r,Zl}var bp;function Ey(){return bp||(bp=1,Gu.exports=ky()),Gu.exports}var l=Ey(),Yu={exports:{}},Me={};var yp;function My(){if(yp)return Me;yp=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),p=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),S=Symbol.iterator;function C(M){return M===null||typeof M!="object"?null:(M=S&&M[S]||M["@@iterator"],typeof M=="function"?M:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,w={};function j(M,D,K){this.props=M,this.context=D,this.refs=w,this.updater=K||E}j.prototype.isReactComponent={},j.prototype.setState=function(M,D){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,D,"setState")},j.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function R(){}R.prototype=j.prototype;function k(M,D,K){this.props=M,this.context=D,this.refs=w,this.updater=K||E}var T=k.prototype=new R;T.constructor=k,N(T,j.prototype),T.isPureReactComponent=!0;var q=Array.isArray;function $(){}var O={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function F(M,D,K){var ae=K.ref;return{$$typeof:n,type:M,key:D,ref:ae!==void 0?ae:null,props:K}}function U(M,D){return F(M.type,D,M.props)}function Z(M){return typeof M=="object"&&M!==null&&M.$$typeof===n}function Q(M){var D={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(K){return D[K]})}var ce=/\/+/g;function ue(M,D){return typeof M=="object"&&M!==null&&M.key!=null?Q(""+M.key):D.toString(36)}function le(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then($,$):(M.status="pending",M.then(function(D){M.status==="pending"&&(M.status="fulfilled",M.value=D)},function(D){M.status==="pending"&&(M.status="rejected",M.reason=D)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function B(M,D,K,ae,he){var we=typeof M;(we==="undefined"||we==="boolean")&&(M=null);var pe=!1;if(M===null)pe=!0;else switch(we){case"bigint":case"string":case"number":pe=!0;break;case"object":switch(M.$$typeof){case n:case a:pe=!0;break;case v:return pe=M._init,B(pe(M._payload),D,K,ae,he)}}if(pe)return he=he(M),pe=ae===""?"."+ue(M,0):ae,q(he)?(K="",pe!=null&&(K=pe.replace(ce,"$&/")+"/"),B(he,D,K,"",function(ye){return ye})):he!=null&&(Z(he)&&(he=U(he,K+(he.key==null||M&&M.key===he.key?"":(""+he.key).replace(ce,"$&/")+"/")+pe)),D.push(he)),1;pe=0;var ge=ae===""?".":ae+":";if(q(M))for(var xe=0;xe<M.length;xe++)ae=M[xe],we=ge+ue(ae,xe),pe+=B(ae,D,K,we,he);else if(xe=C(M),typeof xe=="function")for(M=xe.call(M),xe=0;!(ae=M.next()).done;)ae=ae.value,we=ge+ue(ae,xe++),pe+=B(ae,D,K,we,he);else if(we==="object"){if(typeof M.then=="function")return B(le(M),D,K,ae,he);throw D=String(M),Error("Objects are not valid as a React child (found: "+(D==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":D)+"). If you meant to render a collection of children, use an array instead.")}return pe}function V(M,D,K){if(M==null)return M;var ae=[],he=0;return B(M,ae,"","",function(we){return D.call(K,we,he++)}),ae}function I(M){if(M._status===-1){var D=M._result;D=D(),D.then(function(K){(M._status===0||M._status===-1)&&(M._status=1,M._result=K)},function(K){(M._status===0||M._status===-1)&&(M._status=2,M._result=K)}),M._status===-1&&(M._status=0,M._result=D)}if(M._status===1)return M._result.default;throw M._result}var J=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var D=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(D))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ie={map:V,forEach:function(M,D,K){V(M,function(){D.apply(this,arguments)},K)},count:function(M){var D=0;return V(M,function(){D++}),D},toArray:function(M){return V(M,function(D){return D})||[]},only:function(M){if(!Z(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Me.Activity=b,Me.Children=ie,Me.Component=j,Me.Fragment=r,Me.Profiler=u,Me.PureComponent=k,Me.StrictMode=o,Me.Suspense=g,Me.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Me.__COMPILER_RUNTIME={__proto__:null,c:function(M){return O.H.useMemoCache(M)}},Me.cache=function(M){return function(){return M.apply(null,arguments)}},Me.cacheSignal=function(){return null},Me.cloneElement=function(M,D,K){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var ae=N({},M.props),he=M.key;if(D!=null)for(we in D.key!==void 0&&(he=""+D.key),D)!L.call(D,we)||we==="key"||we==="__self"||we==="__source"||we==="ref"&&D.ref===void 0||(ae[we]=D[we]);var we=arguments.length-2;if(we===1)ae.children=K;else if(1<we){for(var pe=Array(we),ge=0;ge<we;ge++)pe[ge]=arguments[ge+2];ae.children=pe}return F(M.type,he,ae)},Me.createContext=function(M){return M={$$typeof:p,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:f,_context:M},M},Me.createElement=function(M,D,K){var ae,he={},we=null;if(D!=null)for(ae in D.key!==void 0&&(we=""+D.key),D)L.call(D,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(he[ae]=D[ae]);var pe=arguments.length-2;if(pe===1)he.children=K;else if(1<pe){for(var ge=Array(pe),xe=0;xe<pe;xe++)ge[xe]=arguments[xe+2];he.children=ge}if(M&&M.defaultProps)for(ae in pe=M.defaultProps,pe)he[ae]===void 0&&(he[ae]=pe[ae]);return F(M,we,he)},Me.createRef=function(){return{current:null}},Me.forwardRef=function(M){return{$$typeof:h,render:M}},Me.isValidElement=Z,Me.lazy=function(M){return{$$typeof:v,_payload:{_status:-1,_result:M},_init:I}},Me.memo=function(M,D){return{$$typeof:x,type:M,compare:D===void 0?null:D}},Me.startTransition=function(M){var D=O.T,K={};O.T=K;try{var ae=M(),he=O.S;he!==null&&he(K,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then($,J)}catch(we){J(we)}finally{D!==null&&K.types!==null&&(D.types=K.types),O.T=D}},Me.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Me.use=function(M){return O.H.use(M)},Me.useActionState=function(M,D,K){return O.H.useActionState(M,D,K)},Me.useCallback=function(M,D){return O.H.useCallback(M,D)},Me.useContext=function(M){return O.H.useContext(M)},Me.useDebugValue=function(){},Me.useDeferredValue=function(M,D){return O.H.useDeferredValue(M,D)},Me.useEffect=function(M,D){return O.H.useEffect(M,D)},Me.useEffectEvent=function(M){return O.H.useEffectEvent(M)},Me.useId=function(){return O.H.useId()},Me.useImperativeHandle=function(M,D,K){return O.H.useImperativeHandle(M,D,K)},Me.useInsertionEffect=function(M,D){return O.H.useInsertionEffect(M,D)},Me.useLayoutEffect=function(M,D){return O.H.useLayoutEffect(M,D)},Me.useMemo=function(M,D){return O.H.useMemo(M,D)},Me.useOptimistic=function(M,D){return O.H.useOptimistic(M,D)},Me.useReducer=function(M,D,K){return O.H.useReducer(M,D,K)},Me.useRef=function(M){return O.H.useRef(M)},Me.useState=function(M){return O.H.useState(M)},Me.useSyncExternalStore=function(M,D,K){return O.H.useSyncExternalStore(M,D,K)},Me.useTransition=function(){return O.H.useTransition()},Me.version="19.2.0",Me}var Sp;function Hd(){return Sp||(Sp=1,Yu.exports=My()),Yu.exports}var m=Hd();const Dt=Cy(m);var Fu={exports:{}},Jl={},Iu={exports:{}},Xu={};var jp;function Ry(){return jp||(jp=1,(function(n){function a(B,V){var I=B.length;B.push(V);e:for(;0<I;){var J=I-1>>>1,ie=B[J];if(0<u(ie,V))B[J]=V,B[I]=ie,I=J;else break e}}function r(B){return B.length===0?null:B[0]}function o(B){if(B.length===0)return null;var V=B[0],I=B.pop();if(I!==V){B[0]=I;e:for(var J=0,ie=B.length,M=ie>>>1;J<M;){var D=2*(J+1)-1,K=B[D],ae=D+1,he=B[ae];if(0>u(K,I))ae<ie&&0>u(he,K)?(B[J]=he,B[ae]=I,J=ae):(B[J]=K,B[D]=I,J=D);else if(ae<ie&&0>u(he,I))B[J]=he,B[ae]=I,J=ae;else break e}}return V}function u(B,V){var I=B.sortIndex-V.sortIndex;return I!==0?I:B.id-V.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;n.unstable_now=function(){return f.now()}}else{var p=Date,h=p.now();n.unstable_now=function(){return p.now()-h}}var g=[],x=[],v=1,b=null,S=3,C=!1,E=!1,N=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function T(B){for(var V=r(x);V!==null;){if(V.callback===null)o(x);else if(V.startTime<=B)o(x),V.sortIndex=V.expirationTime,a(g,V);else break;V=r(x)}}function q(B){if(N=!1,T(B),!E)if(r(g)!==null)E=!0,$||($=!0,Q());else{var V=r(x);V!==null&&le(q,V.startTime-B)}}var $=!1,O=-1,L=5,F=-1;function U(){return w?!0:!(n.unstable_now()-F<L)}function Z(){if(w=!1,$){var B=n.unstable_now();F=B;var V=!0;try{e:{E=!1,N&&(N=!1,R(O),O=-1),C=!0;var I=S;try{t:{for(T(B),b=r(g);b!==null&&!(b.expirationTime>B&&U());){var J=b.callback;if(typeof J=="function"){b.callback=null,S=b.priorityLevel;var ie=J(b.expirationTime<=B);if(B=n.unstable_now(),typeof ie=="function"){b.callback=ie,T(B),V=!0;break t}b===r(g)&&o(g),T(B)}else o(g);b=r(g)}if(b!==null)V=!0;else{var M=r(x);M!==null&&le(q,M.startTime-B),V=!1}}break e}finally{b=null,S=I,C=!1}V=void 0}}finally{V?Q():$=!1}}}var Q;if(typeof k=="function")Q=function(){k(Z)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,ue=ce.port2;ce.port1.onmessage=Z,Q=function(){ue.postMessage(null)}}else Q=function(){j(Z,0)};function le(B,V){O=j(function(){B(n.unstable_now())},V)}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(B){B.callback=null},n.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<B?Math.floor(1e3/B):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(B){switch(S){case 1:case 2:case 3:var V=3;break;default:V=S}var I=S;S=V;try{return B()}finally{S=I}},n.unstable_requestPaint=function(){w=!0},n.unstable_runWithPriority=function(B,V){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var I=S;S=B;try{return V()}finally{S=I}},n.unstable_scheduleCallback=function(B,V,I){var J=n.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?J+I:J):I=J,B){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=I+ie,B={id:v++,callback:V,priorityLevel:B,startTime:I,expirationTime:ie,sortIndex:-1},I>J?(B.sortIndex=I,a(x,B),r(g)===null&&B===r(x)&&(N?(R(O),O=-1):N=!0,le(q,I-J))):(B.sortIndex=ie,a(g,B),E||C||(E=!0,$||($=!0,Q()))),B},n.unstable_shouldYield=U,n.unstable_wrapCallback=function(B){var V=S;return function(){var I=S;S=V;try{return B.apply(this,arguments)}finally{S=I}}}})(Xu)),Xu}var Np;function Ty(){return Np||(Np=1,Iu.exports=Ry()),Iu.exports}var Qu={exports:{}},qt={};var wp;function qy(){if(wp)return qt;wp=1;var n=Hd();function a(g){var x="https://react.dev/errors/"+g;if(1<arguments.length){x+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)x+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+g+"; visit "+x+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var o={d:{f:r,r:function(){throw Error(a(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},u=Symbol.for("react.portal");function f(g,x,v){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:b==null?null:""+b,children:g,containerInfo:x,implementation:v}}var p=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,x){if(g==="font")return"";if(typeof x=="string")return x==="use-credentials"?x:""}return qt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,qt.createPortal=function(g,x){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)throw Error(a(299));return f(g,x,null,v)},qt.flushSync=function(g){var x=p.T,v=o.p;try{if(p.T=null,o.p=2,g)return g()}finally{p.T=x,o.p=v,o.d.f()}},qt.preconnect=function(g,x){typeof g=="string"&&(x?(x=x.crossOrigin,x=typeof x=="string"?x==="use-credentials"?x:"":void 0):x=null,o.d.C(g,x))},qt.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},qt.preinit=function(g,x){if(typeof g=="string"&&x&&typeof x.as=="string"){var v=x.as,b=h(v,x.crossOrigin),S=typeof x.integrity=="string"?x.integrity:void 0,C=typeof x.fetchPriority=="string"?x.fetchPriority:void 0;v==="style"?o.d.S(g,typeof x.precedence=="string"?x.precedence:void 0,{crossOrigin:b,integrity:S,fetchPriority:C}):v==="script"&&o.d.X(g,{crossOrigin:b,integrity:S,fetchPriority:C,nonce:typeof x.nonce=="string"?x.nonce:void 0})}},qt.preinitModule=function(g,x){if(typeof g=="string")if(typeof x=="object"&&x!==null){if(x.as==null||x.as==="script"){var v=h(x.as,x.crossOrigin);o.d.M(g,{crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0})}}else x==null&&o.d.M(g)},qt.preload=function(g,x){if(typeof g=="string"&&typeof x=="object"&&x!==null&&typeof x.as=="string"){var v=x.as,b=h(v,x.crossOrigin);o.d.L(g,v,{crossOrigin:b,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0,type:typeof x.type=="string"?x.type:void 0,fetchPriority:typeof x.fetchPriority=="string"?x.fetchPriority:void 0,referrerPolicy:typeof x.referrerPolicy=="string"?x.referrerPolicy:void 0,imageSrcSet:typeof x.imageSrcSet=="string"?x.imageSrcSet:void 0,imageSizes:typeof x.imageSizes=="string"?x.imageSizes:void 0,media:typeof x.media=="string"?x.media:void 0})}},qt.preloadModule=function(g,x){if(typeof g=="string")if(x){var v=h(x.as,x.crossOrigin);o.d.m(g,{as:typeof x.as=="string"&&x.as!=="script"?x.as:void 0,crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0})}else o.d.m(g)},qt.requestFormReset=function(g){o.d.r(g)},qt.unstable_batchedUpdates=function(g,x){return g(x)},qt.useFormState=function(g,x,v){return p.H.useFormState(g,x,v)},qt.useFormStatus=function(){return p.H.useHostTransitionStatus()},qt.version="19.2.0",qt}var Ap;function Dy(){if(Ap)return Qu.exports;Ap=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Qu.exports=qy(),Qu.exports}var Cp;function _y(){if(Cp)return Jl;Cp=1;var n=Ty(),a=Hd(),r=Dy();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}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 u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function p(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function h(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g(e){if(f(e)!==e)throw Error(o(188))}function x(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(o(188));return t!==e?null:e}for(var s=e,i=t;;){var c=s.return;if(c===null)break;var d=c.alternate;if(d===null){if(i=c.return,i!==null){s=i;continue}break}if(c.child===d.child){for(d=c.child;d;){if(d===s)return g(c),e;if(d===i)return g(c),t;d=d.sibling}throw Error(o(188))}if(s.return!==i.return)s=c,i=d;else{for(var y=!1,A=c.child;A;){if(A===s){y=!0,s=c,i=d;break}if(A===i){y=!0,i=c,s=d;break}A=A.sibling}if(!y){for(A=d.child;A;){if(A===s){y=!0,s=d,i=c;break}if(A===i){y=!0,i=d,s=c;break}A=A.sibling}if(!y)throw Error(o(189))}}if(s.alternate!==i)throw Error(o(190))}if(s.tag!==3)throw Error(o(188));return s.stateNode.current===s?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,S=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),k=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),Z=Symbol.iterator;function Q(e){return e===null||typeof e!="object"?null:(e=Z&&e[Z]||e["@@iterator"],typeof e=="function"?e:null)}var ce=Symbol.for("react.client.reference");function ue(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case N:return"Fragment";case j:return"Profiler";case w:return"StrictMode";case q:return"Suspense";case $:return"SuspenseList";case F:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case k:return e.displayName||"Context";case R:return(e._context.displayName||"Context")+".Consumer";case T:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case O:return t=e.displayName||null,t!==null?t:ue(e.type)||"Memo";case L:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}var le=Array.isArray,B=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},J=[],ie=-1;function M(e){return{current:e}}function D(e){0>ie||(e.current=J[ie],J[ie]=null,ie--)}function K(e,t){ie++,J[ie]=e.current,e.current=t}var ae=M(null),he=M(null),we=M(null),pe=M(null);function ge(e,t){switch(K(we,t),K(he,e),K(ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?V0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=V0(t),e=$0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}D(ae),K(ae,e)}function xe(){D(ae),D(he),D(we)}function ye(e){e.memoizedState!==null&&K(pe,e);var t=ae.current,s=$0(t,e.type);t!==s&&(K(he,e),K(ae,s))}function Ce(e){he.current===e&&(D(ae),D(he)),pe.current===e&&(D(pe),Il._currentValue=I)}var qe,Ze;function Se(e){if(qe===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);qe=t&&t[1]||"",Ze=-1<s.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+qe+e+Ze}var at=!1;function ht(e,t){if(!e||at)return"";at=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var ne=function(){throw Error()};if(Object.defineProperty(ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ne,[])}catch(P){var X=P}Reflect.construct(e,[],ne)}else{try{ne.call()}catch(P){X=P}e.call(ne.prototype)}}else{try{throw Error()}catch(P){X=P}(ne=e())&&typeof ne.catch=="function"&&ne.catch(function(){})}}catch(P){if(P&&X&&typeof P.stack=="string")return[P.stack,X.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=i.DetermineComponentFrameRoot(),y=d[0],A=d[1];if(y&&A){var _=y.split(`
|
||
`),Y=A.split(`
|
||
`);for(c=i=0;i<_.length&&!_[i].includes("DetermineComponentFrameRoot");)i++;for(;c<Y.length&&!Y[c].includes("DetermineComponentFrameRoot");)c++;if(i===_.length||c===Y.length)for(i=_.length-1,c=Y.length-1;1<=i&&0<=c&&_[i]!==Y[c];)c--;for(;1<=i&&0<=c;i--,c--)if(_[i]!==Y[c]){if(i!==1||c!==1)do if(i--,c--,0>c||_[i]!==Y[c]){var W=`
|
||
`+_[i].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),W}while(1<=i&&0<=c);break}}}finally{at=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?Se(s):""}function Ge(e,t){switch(e.tag){case 26:case 27:case 5:return Se(e.type);case 16:return Se("Lazy");case 13:return e.child!==t&&t!==null?Se("Suspense Fallback"):Se("Suspense");case 19:return Se("SuspenseList");case 0:case 15:return ht(e.type,!1);case 11:return ht(e.type.render,!1);case 1:return ht(e.type,!0);case 31:return Se("Activity");default:return""}}function je(e){try{var t="",s=null;do t+=Ge(e,s),s=e,e=e.return;while(e);return t}catch(i){return`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}}var se=Object.prototype.hasOwnProperty,re=n.unstable_scheduleCallback,de=n.unstable_cancelCallback,fe=n.unstable_shouldYield,Re=n.unstable_requestPaint,te=n.unstable_now,me=n.unstable_getCurrentPriorityLevel,_e=n.unstable_ImmediatePriority,en=n.unstable_UserBlockingPriority,tn=n.unstable_NormalPriority,nn=n.unstable_LowPriority,Nt=n.unstable_IdlePriority,Ae=n.log,tt=n.unstable_setDisableYieldValue,Xe=null,Ee=null;function ze(e){if(typeof Ae=="function"&&tt(e),Ee&&typeof Ee.setStrictMode=="function")try{Ee.setStrictMode(Xe,e)}catch{}}var rt=Math.clz32?Math.clz32:St,Rs=Math.log,sa=Math.LN2;function St(e){return e>>>=0,e===0?32:31-(Rs(e)/sa|0)|0}var Nn=256,wr=262144,Ar=4194304;function Ts(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 Cr(e,t,s){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,y=e.pingedLanes;e=e.warmLanes;var A=i&134217727;return A!==0?(i=A&~d,i!==0?c=Ts(i):(y&=A,y!==0?c=Ts(y):s||(s=A&~e,s!==0&&(c=Ts(s))))):(A=i&~d,A!==0?c=Ts(A):y!==0?c=Ts(y):s||(s=i&~e,s!==0&&(c=Ts(s)))),c===0?0:t!==0&&t!==c&&(t&d)===0&&(d=c&-c,s=t&-t,d>=s||d===32&&(s&4194048)!==0)?t:c}function ll(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function mv(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 jf(){var e=Ar;return Ar<<=1,(Ar&62914560)===0&&(Ar=4194304),e}function To(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function rl(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function hv(e,t,s,i,c,d){var y=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var A=e.entanglements,_=e.expirationTimes,Y=e.hiddenUpdates;for(s=y&~s;0<s;){var W=31-rt(s),ne=1<<W;A[W]=0,_[W]=-1;var X=Y[W];if(X!==null)for(Y[W]=null,W=0;W<X.length;W++){var P=X[W];P!==null&&(P.lane&=-536870913)}s&=~ne}i!==0&&Nf(e,i,0),d!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=d&~(y&~t))}function Nf(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-rt(t);e.entangledLanes|=t,e.entanglements[i]=e.entanglements[i]|1073741824|s&261930}function wf(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var i=31-rt(s),c=1<<i;c&t|e[i]&t&&(e[i]|=t),s&=~c}}function Af(e,t){var s=t&-t;return s=(s&42)!==0?1:qo(s),(s&(e.suspendedLanes|t))!==0?0:s}function qo(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 Do(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Cf(){var e=V.p;return e!==0?e:(e=window.event,e===void 0?32:dp(e.type))}function kf(e,t){var s=V.p;try{return V.p=e,t()}finally{V.p=s}}var as=Math.random().toString(36).slice(2),Ct="__reactFiber$"+as,Bt="__reactProps$"+as,aa="__reactContainer$"+as,_o="__reactEvents$"+as,pv="__reactListeners$"+as,xv="__reactHandles$"+as,Ef="__reactResources$"+as,il="__reactMarker$"+as;function Oo(e){delete e[Ct],delete e[Bt],delete e[_o],delete e[pv],delete e[xv]}function la(e){var t=e[Ct];if(t)return t;for(var s=e.parentNode;s;){if(t=s[aa]||s[Ct]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=K0(e);e!==null;){if(s=e[Ct])return s;e=K0(e)}return t}e=s,s=e.parentNode}return null}function ra(e){if(e=e[Ct]||e[aa]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ol(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function ia(e){var t=e[Ef];return t||(t=e[Ef]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function wt(e){e[il]=!0}var Mf=new Set,Rf={};function qs(e,t){oa(e,t),oa(e+"Capture",t)}function oa(e,t){for(Rf[e]=t,e=0;e<t.length;e++)Mf.add(t[e])}var gv=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]*$"),Tf={},qf={};function vv(e){return se.call(qf,e)?!0:se.call(Tf,e)?!1:gv.test(e)?qf[e]=!0:(Tf[e]=!0,!1)}function kr(e,t,s){if(vv(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function Er(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function qn(e,t,s,i){if(i===null)e.removeAttribute(s);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+i)}}function sn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Df(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function bv(e,t,s){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,d=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(y){s=""+y,d.call(this,y)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return s},setValue:function(y){s=""+y},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Bo(e){if(!e._valueTracker){var t=Df(e)?"checked":"value";e._valueTracker=bv(e,t,""+e[t])}}function _f(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),i="";return e&&(i=Df(e)?e.checked?"true":"false":e.value),e=i,e!==s?(t.setValue(e),!0):!1}function Mr(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 yv=/[\n"\\]/g;function an(e){return e.replace(yv,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Lo(e,t,s,i,c,d,y,A){e.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.type=y:e.removeAttribute("type"),t!=null?y==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+sn(t)):e.value!==""+sn(t)&&(e.value=""+sn(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?zo(e,y,sn(t)):s!=null?zo(e,y,sn(s)):i!=null&&e.removeAttribute("value"),c==null&&d!=null&&(e.defaultChecked=!!d),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+sn(A):e.removeAttribute("name")}function Of(e,t,s,i,c,d,y,A){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(e.type=d),t!=null||s!=null){if(!(d!=="submit"&&d!=="reset"||t!=null)){Bo(e);return}s=s!=null?""+sn(s):"",t=t!=null?""+sn(t):s,A||t===e.value||(e.value=t),e.defaultValue=t}i=i??c,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=A?e.checked:!!i,e.defaultChecked=!!i,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(e.name=y),Bo(e)}function zo(e,t,s){t==="number"&&Mr(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function ca(e,t,s,i){if(e=e.options,t){t={};for(var c=0;c<s.length;c++)t["$"+s[c]]=!0;for(s=0;s<e.length;s++)c=t.hasOwnProperty("$"+e[s].value),e[s].selected!==c&&(e[s].selected=c),c&&i&&(e[s].defaultSelected=!0)}else{for(s=""+sn(s),t=null,c=0;c<e.length;c++){if(e[c].value===s){e[c].selected=!0,i&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Bf(e,t,s){if(t!=null&&(t=""+sn(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+sn(s):""}function Lf(e,t,s,i){if(t==null){if(i!=null){if(s!=null)throw Error(o(92));if(le(i)){if(1<i.length)throw Error(o(93));i=i[0]}s=i}s==null&&(s=""),t=s}s=sn(t),e.defaultValue=s,i=e.textContent,i===s&&i!==""&&i!==null&&(e.value=i),Bo(e)}function ua(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Sv=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 zf(e,t,s){var i=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?i?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":i?e.setProperty(t,s):typeof s!="number"||s===0||Sv.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function Uf(e,t,s){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,s!=null){for(var i in s)!s.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var c in t)i=t[c],t.hasOwnProperty(c)&&s[c]!==i&&zf(e,c,i)}else for(var d in t)t.hasOwnProperty(d)&&zf(e,d,t[d])}function Uo(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 jv=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"]]),Nv=/^[\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 Rr(e){return Nv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Dn(){}var Ho=null;function Vo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var da=null,fa=null;function Hf(e){var t=ra(e);if(t&&(e=t.stateNode)){var s=e[Bt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Lo(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+an(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var i=s[t];if(i!==e&&i.form===e.form){var c=i[Bt]||null;if(!c)throw Error(o(90));Lo(i,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<s.length;t++)i=s[t],i.form===e.form&&_f(i)}break e;case"textarea":Bf(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&ca(e,!!s.multiple,t,!1)}}}var $o=!1;function Vf(e,t,s){if($o)return e(t,s);$o=!0;try{var i=e(t);return i}finally{if($o=!1,(da!==null||fa!==null)&&(gi(),da&&(t=da,e=fa,fa=da=null,Hf(t),e)))for(t=0;t<e.length;t++)Hf(e[t])}}function cl(e,t){var s=e.stateNode;if(s===null)return null;var i=s[Bt]||null;if(i===null)return null;s=i[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(o(231,t,typeof s));return s}var _n=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Go=!1;if(_n)try{var ul={};Object.defineProperty(ul,"passive",{get:function(){Go=!0}}),window.addEventListener("test",ul,ul),window.removeEventListener("test",ul,ul)}catch{Go=!1}var ls=null,Yo=null,Tr=null;function $f(){if(Tr)return Tr;var e,t=Yo,s=t.length,i,c="value"in ls?ls.value:ls.textContent,d=c.length;for(e=0;e<s&&t[e]===c[e];e++);var y=s-e;for(i=1;i<=y&&t[s-i]===c[d-i];i++);return Tr=c.slice(e,1<i?1-i:void 0)}function qr(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 Dr(){return!0}function Gf(){return!1}function Lt(e){function t(s,i,c,d,y){this._reactName=s,this._targetInst=c,this.type=i,this.nativeEvent=d,this.target=y,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(s=e[A],this[A]=s?s(d):d[A]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?Dr:Gf,this.isPropagationStopped=Gf,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Dr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Dr)},persist:function(){},isPersistent:Dr}),t}var Ds={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_r=Lt(Ds),dl=b({},Ds,{view:0,detail:0}),wv=Lt(dl),Fo,Io,fl,Or=b({},dl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Qo,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!==fl&&(fl&&e.type==="mousemove"?(Fo=e.screenX-fl.screenX,Io=e.screenY-fl.screenY):Io=Fo=0,fl=e),Fo)},movementY:function(e){return"movementY"in e?e.movementY:Io}}),Yf=Lt(Or),Av=b({},Or,{dataTransfer:0}),Cv=Lt(Av),kv=b({},dl,{relatedTarget:0}),Xo=Lt(kv),Ev=b({},Ds,{animationName:0,elapsedTime:0,pseudoElement:0}),Mv=Lt(Ev),Rv=b({},Ds,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Tv=Lt(Rv),qv=b({},Ds,{data:0}),Ff=Lt(qv),Dv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},_v={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"},Ov={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Ov[e])?!!t[e]:!1}function Qo(){return Bv}var Lv=b({},dl,{key:function(e){if(e.key){var t=Dv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=qr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?_v[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Qo,charCode:function(e){return e.type==="keypress"?qr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?qr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),zv=Lt(Lv),Uv=b({},Or,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),If=Lt(Uv),Hv=b({},dl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Qo}),Vv=Lt(Hv),$v=b({},Ds,{propertyName:0,elapsedTime:0,pseudoElement:0}),Gv=Lt($v),Yv=b({},Or,{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}),Fv=Lt(Yv),Iv=b({},Ds,{newState:0,oldState:0}),Xv=Lt(Iv),Qv=[9,13,27,32],Ko=_n&&"CompositionEvent"in window,ml=null;_n&&"documentMode"in document&&(ml=document.documentMode);var Kv=_n&&"TextEvent"in window&&!ml,Xf=_n&&(!Ko||ml&&8<ml&&11>=ml),Qf=" ",Kf=!1;function Zf(e,t){switch(e){case"keyup":return Qv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Jf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ma=!1;function Zv(e,t){switch(e){case"compositionend":return Jf(t);case"keypress":return t.which!==32?null:(Kf=!0,Qf);case"textInput":return e=t.data,e===Qf&&Kf?null:e;default:return null}}function Jv(e,t){if(ma)return e==="compositionend"||!Ko&&Zf(e,t)?(e=$f(),Tr=Yo=ls=null,ma=!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 Xf&&t.locale!=="ko"?null:t.data;default:return null}}var Pv={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 Pf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Pv[e.type]:t==="textarea"}function Wf(e,t,s,i){da?fa?fa.push(i):fa=[i]:da=i,t=wi(t,"onChange"),0<t.length&&(s=new _r("onChange","change",null,s,i),e.push({event:s,listeners:t}))}var hl=null,pl=null;function Wv(e){O0(e,0)}function Br(e){var t=ol(e);if(_f(t))return e}function em(e,t){if(e==="change")return t}var tm=!1;if(_n){var Zo;if(_n){var Jo="oninput"in document;if(!Jo){var nm=document.createElement("div");nm.setAttribute("oninput","return;"),Jo=typeof nm.oninput=="function"}Zo=Jo}else Zo=!1;tm=Zo&&(!document.documentMode||9<document.documentMode)}function sm(){hl&&(hl.detachEvent("onpropertychange",am),pl=hl=null)}function am(e){if(e.propertyName==="value"&&Br(pl)){var t=[];Wf(t,pl,e,Vo(e)),Vf(Wv,t)}}function eb(e,t,s){e==="focusin"?(sm(),hl=t,pl=s,hl.attachEvent("onpropertychange",am)):e==="focusout"&&sm()}function tb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Br(pl)}function nb(e,t){if(e==="click")return Br(t)}function sb(e,t){if(e==="input"||e==="change")return Br(t)}function ab(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Gt=typeof Object.is=="function"?Object.is:ab;function xl(e,t){if(Gt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(i=0;i<s.length;i++){var c=s[i];if(!se.call(t,c)||!Gt(e[c],t[c]))return!1}return!0}function lm(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function rm(e,t){var s=lm(e);e=0;for(var i;s;){if(s.nodeType===3){if(i=e+s.textContent.length,e<=t&&i>=t)return{node:s,offset:t-e};e=i}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=lm(s)}}function im(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?im(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function om(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Mr(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Mr(e.document)}return t}function Po(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 lb=_n&&"documentMode"in document&&11>=document.documentMode,ha=null,Wo=null,gl=null,ec=!1;function cm(e,t,s){var i=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;ec||ha==null||ha!==Mr(i)||(i=ha,"selectionStart"in i&&Po(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),gl&&xl(gl,i)||(gl=i,i=wi(Wo,"onSelect"),0<i.length&&(t=new _r("onSelect","select",null,t,s),e.push({event:t,listeners:i}),t.target=ha)))}function _s(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var pa={animationend:_s("Animation","AnimationEnd"),animationiteration:_s("Animation","AnimationIteration"),animationstart:_s("Animation","AnimationStart"),transitionrun:_s("Transition","TransitionRun"),transitionstart:_s("Transition","TransitionStart"),transitioncancel:_s("Transition","TransitionCancel"),transitionend:_s("Transition","TransitionEnd")},tc={},um={};_n&&(um=document.createElement("div").style,"AnimationEvent"in window||(delete pa.animationend.animation,delete pa.animationiteration.animation,delete pa.animationstart.animation),"TransitionEvent"in window||delete pa.transitionend.transition);function Os(e){if(tc[e])return tc[e];if(!pa[e])return e;var t=pa[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in um)return tc[e]=t[s];return e}var dm=Os("animationend"),fm=Os("animationiteration"),mm=Os("animationstart"),rb=Os("transitionrun"),ib=Os("transitionstart"),ob=Os("transitioncancel"),hm=Os("transitionend"),pm=new Map,nc="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(" ");nc.push("scrollEnd");function gn(e,t){pm.set(e,t),qs(t,[e])}var Lr=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},ln=[],xa=0,sc=0;function zr(){for(var e=xa,t=sc=xa=0;t<e;){var s=ln[t];ln[t++]=null;var i=ln[t];ln[t++]=null;var c=ln[t];ln[t++]=null;var d=ln[t];if(ln[t++]=null,i!==null&&c!==null){var y=i.pending;y===null?c.next=c:(c.next=y.next,y.next=c),i.pending=c}d!==0&&xm(s,c,d)}}function Ur(e,t,s,i){ln[xa++]=e,ln[xa++]=t,ln[xa++]=s,ln[xa++]=i,sc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function ac(e,t,s,i){return Ur(e,t,s,i),Hr(e)}function Bs(e,t){return Ur(e,null,null,t),Hr(e)}function xm(e,t,s){e.lanes|=s;var i=e.alternate;i!==null&&(i.lanes|=s);for(var c=!1,d=e.return;d!==null;)d.childLanes|=s,i=d.alternate,i!==null&&(i.childLanes|=s),d.tag===22&&(e=d.stateNode,e===null||e._visibility&1||(c=!0)),e=d,d=d.return;return e.tag===3?(d=e.stateNode,c&&t!==null&&(c=31-rt(s),e=d.hiddenUpdates,i=e[c],i===null?e[c]=[t]:i.push(t),t.lane=s|536870912),d):null}function Hr(e){if(50<Ul)throw Ul=0,mu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ga={};function cb(e,t,s,i){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yt(e,t,s,i){return new cb(e,t,s,i)}function lc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function On(e,t){var s=e.alternate;return s===null?(s=Yt(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function gm(e,t){e.flags&=65011714;var s=e.alternate;return s===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=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Vr(e,t,s,i,c,d){var y=0;if(i=e,typeof e=="function")lc(e)&&(y=1);else if(typeof e=="string")y=hy(e,s,ae.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case F:return e=Yt(31,s,t,c),e.elementType=F,e.lanes=d,e;case N:return Ls(s.children,c,d,t);case w:y=8,c|=24;break;case j:return e=Yt(12,s,t,c|2),e.elementType=j,e.lanes=d,e;case q:return e=Yt(13,s,t,c),e.elementType=q,e.lanes=d,e;case $:return e=Yt(19,s,t,c),e.elementType=$,e.lanes=d,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case k:y=10;break e;case R:y=9;break e;case T:y=11;break e;case O:y=14;break e;case L:y=16,i=null;break e}y=29,s=Error(o(130,e===null?"null":typeof e,"")),i=null}return t=Yt(y,s,t,c),t.elementType=e,t.type=i,t.lanes=d,t}function Ls(e,t,s,i){return e=Yt(7,e,i,t),e.lanes=s,e}function rc(e,t,s){return e=Yt(6,e,null,t),e.lanes=s,e}function vm(e){var t=Yt(18,null,null,0);return t.stateNode=e,t}function ic(e,t,s){return t=Yt(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var bm=new WeakMap;function rn(e,t){if(typeof e=="object"&&e!==null){var s=bm.get(e);return s!==void 0?s:(t={value:e,source:t,stack:je(t)},bm.set(e,t),t)}return{value:e,source:t,stack:je(t)}}var va=[],ba=0,$r=null,vl=0,on=[],cn=0,rs=null,wn=1,An="";function Bn(e,t){va[ba++]=vl,va[ba++]=$r,$r=e,vl=t}function ym(e,t,s){on[cn++]=wn,on[cn++]=An,on[cn++]=rs,rs=e;var i=wn;e=An;var c=32-rt(i)-1;i&=~(1<<c),s+=1;var d=32-rt(t)+c;if(30<d){var y=c-c%5;d=(i&(1<<y)-1).toString(32),i>>=y,c-=y,wn=1<<32-rt(t)+c|s<<c|i,An=d+e}else wn=1<<d|s<<c|i,An=e}function oc(e){e.return!==null&&(Bn(e,1),ym(e,1,0))}function cc(e){for(;e===$r;)$r=va[--ba],va[ba]=null,vl=va[--ba],va[ba]=null;for(;e===rs;)rs=on[--cn],on[cn]=null,An=on[--cn],on[cn]=null,wn=on[--cn],on[cn]=null}function Sm(e,t){on[cn++]=wn,on[cn++]=An,on[cn++]=rs,wn=t.id,An=t.overflow,rs=e}var kt=null,nt=null,Ve=!1,is=null,un=!1,uc=Error(o(519));function os(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw bl(rn(t,e)),uc}function jm(e){var t=e.stateNode,s=e.type,i=e.memoizedProps;switch(t[Ct]=e,t[Bt]=i,s){case"dialog":Le("cancel",t),Le("close",t);break;case"iframe":case"object":case"embed":Le("load",t);break;case"video":case"audio":for(s=0;s<Vl.length;s++)Le(Vl[s],t);break;case"source":Le("error",t);break;case"img":case"image":case"link":Le("error",t),Le("load",t);break;case"details":Le("toggle",t);break;case"input":Le("invalid",t),Of(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":Le("invalid",t);break;case"textarea":Le("invalid",t),Lf(t,i.value,i.defaultValue,i.children)}s=i.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||i.suppressHydrationWarning===!0||U0(t.textContent,s)?(i.popover!=null&&(Le("beforetoggle",t),Le("toggle",t)),i.onScroll!=null&&Le("scroll",t),i.onScrollEnd!=null&&Le("scrollend",t),i.onClick!=null&&(t.onclick=Dn),t=!0):t=!1,t||os(e,!0)}function Nm(e){for(kt=e.return;kt;)switch(kt.tag){case 5:case 31:case 13:un=!1;return;case 27:case 3:un=!0;return;default:kt=kt.return}}function ya(e){if(e!==kt)return!1;if(!Ve)return Nm(e),Ve=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||Eu(e.type,e.memoizedProps)),s=!s),s&&nt&&os(e),Nm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Q0(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Q0(e)}else t===27?(t=nt,js(e.type)?(e=Du,Du=null,nt=e):nt=t):nt=kt?fn(e.stateNode.nextSibling):null;return!0}function zs(){nt=kt=null,Ve=!1}function dc(){var e=is;return e!==null&&(Vt===null?Vt=e:Vt.push.apply(Vt,e),is=null),e}function bl(e){is===null?is=[e]:is.push(e)}var fc=M(null),Us=null,Ln=null;function cs(e,t,s){K(fc,t._currentValue),t._currentValue=s}function zn(e){e._currentValue=fc.current,D(fc)}function mc(e,t,s){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===s)break;e=e.return}}function hc(e,t,s,i){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var d=c.dependencies;if(d!==null){var y=c.child;d=d.firstContext;e:for(;d!==null;){var A=d;d=c;for(var _=0;_<t.length;_++)if(A.context===t[_]){d.lanes|=s,A=d.alternate,A!==null&&(A.lanes|=s),mc(d.return,s,e),i||(y=null);break e}d=A.next}}else if(c.tag===18){if(y=c.return,y===null)throw Error(o(341));y.lanes|=s,d=y.alternate,d!==null&&(d.lanes|=s),mc(y,s,e),y=null}else y=c.child;if(y!==null)y.return=c;else for(y=c;y!==null;){if(y===e){y=null;break}if(c=y.sibling,c!==null){c.return=y.return,y=c;break}y=y.return}c=y}}function Sa(e,t,s,i){e=null;for(var c=t,d=!1;c!==null;){if(!d){if((c.flags&524288)!==0)d=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var y=c.alternate;if(y===null)throw Error(o(387));if(y=y.memoizedProps,y!==null){var A=c.type;Gt(c.pendingProps.value,y.value)||(e!==null?e.push(A):e=[A])}}else if(c===pe.current){if(y=c.alternate,y===null)throw Error(o(387));y.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Il):e=[Il])}c=c.return}e!==null&&hc(t,e,s,i),t.flags|=262144}function Gr(e){for(e=e.firstContext;e!==null;){if(!Gt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Hs(e){Us=e,Ln=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Et(e){return wm(Us,e)}function Yr(e,t){return Us===null&&Hs(e),wm(e,t)}function wm(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},Ln===null){if(e===null)throw Error(o(308));Ln=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ln=Ln.next=t;return s}var ub=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,i){e.push(i)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},db=n.unstable_scheduleCallback,fb=n.unstable_NormalPriority,pt={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function pc(){return{controller:new ub,data:new Map,refCount:0}}function yl(e){e.refCount--,e.refCount===0&&db(fb,function(){e.controller.abort()})}var Sl=null,xc=0,ja=0,Na=null;function mb(e,t){if(Sl===null){var s=Sl=[];xc=0,ja=bu(),Na={status:"pending",value:void 0,then:function(i){s.push(i)}}}return xc++,t.then(Am,Am),t}function Am(){if(--xc===0&&Sl!==null){Na!==null&&(Na.status="fulfilled");var e=Sl;Sl=null,ja=0,Na=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function hb(e,t){var s=[],i={status:"pending",value:null,reason:null,then:function(c){s.push(c)}};return e.then(function(){i.status="fulfilled",i.value=t;for(var c=0;c<s.length;c++)(0,s[c])(t)},function(c){for(i.status="rejected",i.reason=c,c=0;c<s.length;c++)(0,s[c])(void 0)}),i}var Cm=B.S;B.S=function(e,t){c0=te(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&mb(e,t),Cm!==null&&Cm(e,t)};var Vs=M(null);function gc(){var e=Vs.current;return e!==null?e:et.pooledCache}function Fr(e,t){t===null?K(Vs,Vs.current):K(Vs,t.pool)}function km(){var e=gc();return e===null?null:{parent:pt._currentValue,pool:e}}var wa=Error(o(460)),vc=Error(o(474)),Ir=Error(o(542)),Xr={then:function(){}};function Em(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Mm(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(Dn,Dn),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Tm(e),e;default:if(typeof t.status=="string")t.then(Dn,Dn);else{if(e=et,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(i){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=i}},function(i){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=i}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Tm(e),e}throw Gs=t,wa}}function $s(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(Gs=s,wa):s}}var Gs=null;function Rm(){if(Gs===null)throw Error(o(459));var e=Gs;return Gs=null,e}function Tm(e){if(e===wa||e===Ir)throw Error(o(483))}var Aa=null,jl=0;function Qr(e){var t=jl;return jl+=1,Aa===null&&(Aa=[]),Mm(Aa,e,t)}function Nl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Kr(e,t){throw t.$$typeof===S?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function qm(e){function t(H,z){if(e){var G=H.deletions;G===null?(H.deletions=[z],H.flags|=16):G.push(z)}}function s(H,z){if(!e)return null;for(;z!==null;)t(H,z),z=z.sibling;return null}function i(H){for(var z=new Map;H!==null;)H.key!==null?z.set(H.key,H):z.set(H.index,H),H=H.sibling;return z}function c(H,z){return H=On(H,z),H.index=0,H.sibling=null,H}function d(H,z,G){return H.index=G,e?(G=H.alternate,G!==null?(G=G.index,G<z?(H.flags|=67108866,z):G):(H.flags|=67108866,z)):(H.flags|=1048576,z)}function y(H){return e&&H.alternate===null&&(H.flags|=67108866),H}function A(H,z,G,ee){return z===null||z.tag!==6?(z=rc(G,H.mode,ee),z.return=H,z):(z=c(z,G),z.return=H,z)}function _(H,z,G,ee){var Ne=G.type;return Ne===N?W(H,z,G.props.children,ee,G.key):z!==null&&(z.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===L&&$s(Ne)===z.type)?(z=c(z,G.props),Nl(z,G),z.return=H,z):(z=Vr(G.type,G.key,G.props,null,H.mode,ee),Nl(z,G),z.return=H,z)}function Y(H,z,G,ee){return z===null||z.tag!==4||z.stateNode.containerInfo!==G.containerInfo||z.stateNode.implementation!==G.implementation?(z=ic(G,H.mode,ee),z.return=H,z):(z=c(z,G.children||[]),z.return=H,z)}function W(H,z,G,ee,Ne){return z===null||z.tag!==7?(z=Ls(G,H.mode,ee,Ne),z.return=H,z):(z=c(z,G),z.return=H,z)}function ne(H,z,G){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=rc(""+z,H.mode,G),z.return=H,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case C:return G=Vr(z.type,z.key,z.props,null,H.mode,G),Nl(G,z),G.return=H,G;case E:return z=ic(z,H.mode,G),z.return=H,z;case L:return z=$s(z),ne(H,z,G)}if(le(z)||Q(z))return z=Ls(z,H.mode,G,null),z.return=H,z;if(typeof z.then=="function")return ne(H,Qr(z),G);if(z.$$typeof===k)return ne(H,Yr(H,z),G);Kr(H,z)}return null}function X(H,z,G,ee){var Ne=z!==null?z.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Ne!==null?null:A(H,z,""+G,ee);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case C:return G.key===Ne?_(H,z,G,ee):null;case E:return G.key===Ne?Y(H,z,G,ee):null;case L:return G=$s(G),X(H,z,G,ee)}if(le(G)||Q(G))return Ne!==null?null:W(H,z,G,ee,null);if(typeof G.then=="function")return X(H,z,Qr(G),ee);if(G.$$typeof===k)return X(H,z,Yr(H,G),ee);Kr(H,G)}return null}function P(H,z,G,ee,Ne){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return H=H.get(G)||null,A(z,H,""+ee,Ne);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case C:return H=H.get(ee.key===null?G:ee.key)||null,_(z,H,ee,Ne);case E:return H=H.get(ee.key===null?G:ee.key)||null,Y(z,H,ee,Ne);case L:return ee=$s(ee),P(H,z,G,ee,Ne)}if(le(ee)||Q(ee))return H=H.get(G)||null,W(z,H,ee,Ne,null);if(typeof ee.then=="function")return P(H,z,G,Qr(ee),Ne);if(ee.$$typeof===k)return P(H,z,G,Yr(z,ee),Ne);Kr(z,ee)}return null}function ve(H,z,G,ee){for(var Ne=null,Ye=null,be=z,De=z=0,He=null;be!==null&&De<G.length;De++){be.index>De?(He=be,be=null):He=be.sibling;var Fe=X(H,be,G[De],ee);if(Fe===null){be===null&&(be=He);break}e&&be&&Fe.alternate===null&&t(H,be),z=d(Fe,z,De),Ye===null?Ne=Fe:Ye.sibling=Fe,Ye=Fe,be=He}if(De===G.length)return s(H,be),Ve&&Bn(H,De),Ne;if(be===null){for(;De<G.length;De++)be=ne(H,G[De],ee),be!==null&&(z=d(be,z,De),Ye===null?Ne=be:Ye.sibling=be,Ye=be);return Ve&&Bn(H,De),Ne}for(be=i(be);De<G.length;De++)He=P(be,H,De,G[De],ee),He!==null&&(e&&He.alternate!==null&&be.delete(He.key===null?De:He.key),z=d(He,z,De),Ye===null?Ne=He:Ye.sibling=He,Ye=He);return e&&be.forEach(function(ks){return t(H,ks)}),Ve&&Bn(H,De),Ne}function ke(H,z,G,ee){if(G==null)throw Error(o(151));for(var Ne=null,Ye=null,be=z,De=z=0,He=null,Fe=G.next();be!==null&&!Fe.done;De++,Fe=G.next()){be.index>De?(He=be,be=null):He=be.sibling;var ks=X(H,be,Fe.value,ee);if(ks===null){be===null&&(be=He);break}e&&be&&ks.alternate===null&&t(H,be),z=d(ks,z,De),Ye===null?Ne=ks:Ye.sibling=ks,Ye=ks,be=He}if(Fe.done)return s(H,be),Ve&&Bn(H,De),Ne;if(be===null){for(;!Fe.done;De++,Fe=G.next())Fe=ne(H,Fe.value,ee),Fe!==null&&(z=d(Fe,z,De),Ye===null?Ne=Fe:Ye.sibling=Fe,Ye=Fe);return Ve&&Bn(H,De),Ne}for(be=i(be);!Fe.done;De++,Fe=G.next())Fe=P(be,H,De,Fe.value,ee),Fe!==null&&(e&&Fe.alternate!==null&&be.delete(Fe.key===null?De:Fe.key),z=d(Fe,z,De),Ye===null?Ne=Fe:Ye.sibling=Fe,Ye=Fe);return e&&be.forEach(function(Ay){return t(H,Ay)}),Ve&&Bn(H,De),Ne}function We(H,z,G,ee){if(typeof G=="object"&&G!==null&&G.type===N&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case C:e:{for(var Ne=G.key;z!==null;){if(z.key===Ne){if(Ne=G.type,Ne===N){if(z.tag===7){s(H,z.sibling),ee=c(z,G.props.children),ee.return=H,H=ee;break e}}else if(z.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===L&&$s(Ne)===z.type){s(H,z.sibling),ee=c(z,G.props),Nl(ee,G),ee.return=H,H=ee;break e}s(H,z);break}else t(H,z);z=z.sibling}G.type===N?(ee=Ls(G.props.children,H.mode,ee,G.key),ee.return=H,H=ee):(ee=Vr(G.type,G.key,G.props,null,H.mode,ee),Nl(ee,G),ee.return=H,H=ee)}return y(H);case E:e:{for(Ne=G.key;z!==null;){if(z.key===Ne)if(z.tag===4&&z.stateNode.containerInfo===G.containerInfo&&z.stateNode.implementation===G.implementation){s(H,z.sibling),ee=c(z,G.children||[]),ee.return=H,H=ee;break e}else{s(H,z);break}else t(H,z);z=z.sibling}ee=ic(G,H.mode,ee),ee.return=H,H=ee}return y(H);case L:return G=$s(G),We(H,z,G,ee)}if(le(G))return ve(H,z,G,ee);if(Q(G)){if(Ne=Q(G),typeof Ne!="function")throw Error(o(150));return G=Ne.call(G),ke(H,z,G,ee)}if(typeof G.then=="function")return We(H,z,Qr(G),ee);if(G.$$typeof===k)return We(H,z,Yr(H,G),ee);Kr(H,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,z!==null&&z.tag===6?(s(H,z.sibling),ee=c(z,G),ee.return=H,H=ee):(s(H,z),ee=rc(G,H.mode,ee),ee.return=H,H=ee),y(H)):s(H,z)}return function(H,z,G,ee){try{jl=0;var Ne=We(H,z,G,ee);return Aa=null,Ne}catch(be){if(be===wa||be===Ir)throw be;var Ye=Yt(29,be,null,H.mode);return Ye.lanes=ee,Ye.return=H,Ye}finally{}}}var Ys=qm(!0),Dm=qm(!1),us=!1;function bc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yc(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 ds(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function fs(e,t,s){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(Ie&2)!==0){var c=i.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),i.pending=t,t=Hr(e),xm(e,null,s),t}return Ur(e,i,t,s),Hr(e)}function wl(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,s|=i,t.lanes=s,wf(e,s)}}function Sc(e,t){var s=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,s===i)){var c=null,d=null;if(s=s.firstBaseUpdate,s!==null){do{var y={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};d===null?c=d=y:d=d.next=y,s=s.next}while(s!==null);d===null?c=d=t:d=d.next=t}else c=d=t;s={baseState:i.baseState,firstBaseUpdate:c,lastBaseUpdate:d,shared:i.shared,callbacks:i.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var jc=!1;function Al(){if(jc){var e=Na;if(e!==null)throw e}}function Cl(e,t,s,i){jc=!1;var c=e.updateQueue;us=!1;var d=c.firstBaseUpdate,y=c.lastBaseUpdate,A=c.shared.pending;if(A!==null){c.shared.pending=null;var _=A,Y=_.next;_.next=null,y===null?d=Y:y.next=Y,y=_;var W=e.alternate;W!==null&&(W=W.updateQueue,A=W.lastBaseUpdate,A!==y&&(A===null?W.firstBaseUpdate=Y:A.next=Y,W.lastBaseUpdate=_))}if(d!==null){var ne=c.baseState;y=0,W=Y=_=null,A=d;do{var X=A.lane&-536870913,P=X!==A.lane;if(P?(Ue&X)===X:(i&X)===X){X!==0&&X===ja&&(jc=!0),W!==null&&(W=W.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var ve=e,ke=A;X=t;var We=s;switch(ke.tag){case 1:if(ve=ke.payload,typeof ve=="function"){ne=ve.call(We,ne,X);break e}ne=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=ke.payload,X=typeof ve=="function"?ve.call(We,ne,X):ve,X==null)break e;ne=b({},ne,X);break e;case 2:us=!0}}X=A.callback,X!==null&&(e.flags|=64,P&&(e.flags|=8192),P=c.callbacks,P===null?c.callbacks=[X]:P.push(X))}else P={lane:X,tag:A.tag,payload:A.payload,callback:A.callback,next:null},W===null?(Y=W=P,_=ne):W=W.next=P,y|=X;if(A=A.next,A===null){if(A=c.shared.pending,A===null)break;P=A,A=P.next,P.next=null,c.lastBaseUpdate=P,c.shared.pending=null}}while(!0);W===null&&(_=ne),c.baseState=_,c.firstBaseUpdate=Y,c.lastBaseUpdate=W,d===null&&(c.shared.lanes=0),gs|=y,e.lanes=y,e.memoizedState=ne}}function _m(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function Om(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)_m(s[e],t)}var Ca=M(null),Zr=M(0);function Bm(e,t){e=Xn,K(Zr,e),K(Ca,t),Xn=e|t.baseLanes}function Nc(){K(Zr,Xn),K(Ca,Ca.current)}function wc(){Xn=Zr.current,D(Ca),D(Zr)}var Ft=M(null),dn=null;function ms(e){var t=e.alternate;K(ft,ft.current&1),K(Ft,e),dn===null&&(t===null||Ca.current!==null||t.memoizedState!==null)&&(dn=e)}function Ac(e){K(ft,ft.current),K(Ft,e),dn===null&&(dn=e)}function Lm(e){e.tag===22?(K(ft,ft.current),K(Ft,e),dn===null&&(dn=e)):hs()}function hs(){K(ft,ft.current),K(Ft,Ft.current)}function It(e){D(Ft),dn===e&&(dn=null),D(ft)}var ft=M(0);function Jr(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Tu(s)||qu(s)))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 Un=0,Te=null,Je=null,xt=null,Pr=!1,ka=!1,Fs=!1,Wr=0,kl=0,Ea=null,pb=0;function ct(){throw Error(o(321))}function Cc(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Gt(e[s],t[s]))return!1;return!0}function kc(e,t,s,i,c,d){return Un=d,Te=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,B.H=e===null||e.memoizedState===null?yh:$c,Fs=!1,d=s(i,c),Fs=!1,ka&&(d=Um(t,s,i,c)),zm(e),d}function zm(e){B.H=Rl;var t=Je!==null&&Je.next!==null;if(Un=0,xt=Je=Te=null,Pr=!1,kl=0,Ea=null,t)throw Error(o(300));e===null||gt||(e=e.dependencies,e!==null&&Gr(e)&&(gt=!0))}function Um(e,t,s,i){Te=e;var c=0;do{if(ka&&(Ea=null),kl=0,ka=!1,25<=c)throw Error(o(301));if(c+=1,xt=Je=null,e.updateQueue!=null){var d=e.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}B.H=Sh,d=t(s,i)}while(ka);return d}function xb(){var e=B.H,t=e.useState()[0];return t=typeof t.then=="function"?El(t):t,e=e.useState()[0],(Je!==null?Je.memoizedState:null)!==e&&(Te.flags|=1024),t}function Ec(){var e=Wr!==0;return Wr=0,e}function Mc(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function Rc(e){if(Pr){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Pr=!1}Un=0,xt=Je=Te=null,ka=!1,kl=Wr=0,Ea=null}function _t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xt===null?Te.memoizedState=xt=e:xt=xt.next=e,xt}function mt(){if(Je===null){var e=Te.alternate;e=e!==null?e.memoizedState:null}else e=Je.next;var t=xt===null?Te.memoizedState:xt.next;if(t!==null)xt=t,Je=e;else{if(e===null)throw Te.alternate===null?Error(o(467)):Error(o(310));Je=e,e={memoizedState:Je.memoizedState,baseState:Je.baseState,baseQueue:Je.baseQueue,queue:Je.queue,next:null},xt===null?Te.memoizedState=xt=e:xt=xt.next=e}return xt}function ei(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function El(e){var t=kl;return kl+=1,Ea===null&&(Ea=[]),e=Mm(Ea,e,t),t=Te,(xt===null?t.memoizedState:xt.next)===null&&(t=t.alternate,B.H=t===null||t.memoizedState===null?yh:$c),e}function ti(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return El(e);if(e.$$typeof===k)return Et(e)}throw Error(o(438,String(e)))}function Tc(e){var t=null,s=Te.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var i=Te.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=ei(),Te.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),i=0;i<e;i++)s[i]=U;return t.index++,s}function Hn(e,t){return typeof t=="function"?t(e):t}function ni(e){var t=mt();return qc(t,Je,e)}function qc(e,t,s){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=s;var c=e.baseQueue,d=i.pending;if(d!==null){if(c!==null){var y=c.next;c.next=d.next,d.next=y}t.baseQueue=c=d,i.pending=null}if(d=e.baseState,c===null)e.memoizedState=d;else{t=c.next;var A=y=null,_=null,Y=t,W=!1;do{var ne=Y.lane&-536870913;if(ne!==Y.lane?(Ue&ne)===ne:(Un&ne)===ne){var X=Y.revertLane;if(X===0)_!==null&&(_=_.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),ne===ja&&(W=!0);else if((Un&X)===X){Y=Y.next,X===ja&&(W=!0);continue}else ne={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},_===null?(A=_=ne,y=d):_=_.next=ne,Te.lanes|=X,gs|=X;ne=Y.action,Fs&&s(d,ne),d=Y.hasEagerState?Y.eagerState:s(d,ne)}else X={lane:ne,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},_===null?(A=_=X,y=d):_=_.next=X,Te.lanes|=ne,gs|=ne;Y=Y.next}while(Y!==null&&Y!==t);if(_===null?y=d:_.next=A,!Gt(d,e.memoizedState)&&(gt=!0,W&&(s=Na,s!==null)))throw s;e.memoizedState=d,e.baseState=y,e.baseQueue=_,i.lastRenderedState=d}return c===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Dc(e){var t=mt(),s=t.queue;if(s===null)throw Error(o(311));s.lastRenderedReducer=e;var i=s.dispatch,c=s.pending,d=t.memoizedState;if(c!==null){s.pending=null;var y=c=c.next;do d=e(d,y.action),y=y.next;while(y!==c);Gt(d,t.memoizedState)||(gt=!0),t.memoizedState=d,t.baseQueue===null&&(t.baseState=d),s.lastRenderedState=d}return[d,i]}function Hm(e,t,s){var i=Te,c=mt(),d=Ve;if(d){if(s===void 0)throw Error(o(407));s=s()}else s=t();var y=!Gt((Je||c).memoizedState,s);if(y&&(c.memoizedState=s,gt=!0),c=c.queue,Bc(Gm.bind(null,i,c,e),[e]),c.getSnapshot!==t||y||xt!==null&&xt.memoizedState.tag&1){if(i.flags|=2048,Ma(9,{destroy:void 0},$m.bind(null,i,c,s,t),null),et===null)throw Error(o(349));d||(Un&127)!==0||Vm(i,t,s)}return s}function Vm(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=Te.updateQueue,t===null?(t=ei(),Te.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function $m(e,t,s,i){t.value=s,t.getSnapshot=i,Ym(t)&&Fm(e)}function Gm(e,t,s){return s(function(){Ym(t)&&Fm(e)})}function Ym(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Gt(e,s)}catch{return!0}}function Fm(e){var t=Bs(e,2);t!==null&&$t(t,e,2)}function _c(e){var t=_t();if(typeof e=="function"){var s=e;if(e=s(),Fs){ze(!0);try{s()}finally{ze(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hn,lastRenderedState:e},t}function Im(e,t,s,i){return e.baseState=s,qc(e,Je,typeof i=="function"?i:Hn)}function gb(e,t,s,i,c){if(li(e))throw Error(o(485));if(e=t.action,e!==null){var d={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){d.listeners.push(y)}};B.T!==null?s(!0):d.isTransition=!1,i(d),s=t.pending,s===null?(d.next=t.pending=d,Xm(t,d)):(d.next=s.next,t.pending=s.next=d)}}function Xm(e,t){var s=t.action,i=t.payload,c=e.state;if(t.isTransition){var d=B.T,y={};B.T=y;try{var A=s(c,i),_=B.S;_!==null&&_(y,A),Qm(e,t,A)}catch(Y){Oc(e,t,Y)}finally{d!==null&&y.types!==null&&(d.types=y.types),B.T=d}}else try{d=s(c,i),Qm(e,t,d)}catch(Y){Oc(e,t,Y)}}function Qm(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(i){Km(e,t,i)},function(i){return Oc(e,t,i)}):Km(e,t,s)}function Km(e,t,s){t.status="fulfilled",t.value=s,Zm(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,Xm(e,s)))}function Oc(e,t,s){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=s,Zm(t),t=t.next;while(t!==i)}e.action=null}function Zm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Jm(e,t){return t}function Pm(e,t){if(Ve){var s=et.formState;if(s!==null){e:{var i=Te;if(Ve){if(nt){t:{for(var c=nt,d=un;c.nodeType!==8;){if(!d){c=null;break t}if(c=fn(c.nextSibling),c===null){c=null;break t}}d=c.data,c=d==="F!"||d==="F"?c:null}if(c){nt=fn(c.nextSibling),i=c.data==="F!";break e}}os(i)}i=!1}i&&(t=s[0])}}return s=_t(),s.memoizedState=s.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jm,lastRenderedState:t},s.queue=i,s=gh.bind(null,Te,i),i.dispatch=s,i=_c(!1),d=Vc.bind(null,Te,!1,i.queue),i=_t(),c={state:t,dispatch:null,action:e,pending:null},i.queue=c,s=gb.bind(null,Te,c,d,s),c.dispatch=s,i.memoizedState=e,[t,s,!1]}function Wm(e){var t=mt();return eh(t,Je,e)}function eh(e,t,s){if(t=qc(e,t,Jm)[0],e=ni(Hn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=El(t)}catch(y){throw y===wa?Ir:y}else i=t;t=mt();var c=t.queue,d=c.dispatch;return s!==t.memoizedState&&(Te.flags|=2048,Ma(9,{destroy:void 0},vb.bind(null,c,s),null)),[i,d,e]}function vb(e,t){e.action=t}function th(e){var t=mt(),s=Je;if(s!==null)return eh(t,s,e);mt(),t=t.memoizedState,s=mt();var i=s.queue.dispatch;return s.memoizedState=e,[t,i,!1]}function Ma(e,t,s,i){return e={tag:e,create:s,deps:i,inst:t,next:null},t=Te.updateQueue,t===null&&(t=ei(),Te.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(i=s.next,s.next=e,e.next=i,t.lastEffect=e),e}function nh(){return mt().memoizedState}function si(e,t,s,i){var c=_t();Te.flags|=e,c.memoizedState=Ma(1|t,{destroy:void 0},s,i===void 0?null:i)}function ai(e,t,s,i){var c=mt();i=i===void 0?null:i;var d=c.memoizedState.inst;Je!==null&&i!==null&&Cc(i,Je.memoizedState.deps)?c.memoizedState=Ma(t,d,s,i):(Te.flags|=e,c.memoizedState=Ma(1|t,d,s,i))}function sh(e,t){si(8390656,8,e,t)}function Bc(e,t){ai(2048,8,e,t)}function bb(e){Te.flags|=4;var t=Te.updateQueue;if(t===null)t=ei(),Te.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function ah(e){var t=mt().memoizedState;return bb({ref:t,nextImpl:e}),function(){if((Ie&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function lh(e,t){return ai(4,2,e,t)}function rh(e,t){return ai(4,4,e,t)}function ih(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function oh(e,t,s){s=s!=null?s.concat([e]):null,ai(4,4,ih.bind(null,t,e),s)}function Lc(){}function ch(e,t){var s=mt();t=t===void 0?null:t;var i=s.memoizedState;return t!==null&&Cc(t,i[1])?i[0]:(s.memoizedState=[e,t],e)}function uh(e,t){var s=mt();t=t===void 0?null:t;var i=s.memoizedState;if(t!==null&&Cc(t,i[1]))return i[0];if(i=e(),Fs){ze(!0);try{e()}finally{ze(!1)}}return s.memoizedState=[i,t],i}function zc(e,t,s){return s===void 0||(Un&1073741824)!==0&&(Ue&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=d0(),Te.lanes|=e,gs|=e,s)}function dh(e,t,s,i){return Gt(s,t)?s:Ca.current!==null?(e=zc(e,s,i),Gt(e,t)||(gt=!0),e):(Un&42)===0||(Un&1073741824)!==0&&(Ue&261930)===0?(gt=!0,e.memoizedState=s):(e=d0(),Te.lanes|=e,gs|=e,t)}function fh(e,t,s,i,c){var d=V.p;V.p=d!==0&&8>d?d:8;var y=B.T,A={};B.T=A,Vc(e,!1,t,s);try{var _=c(),Y=B.S;if(Y!==null&&Y(A,_),_!==null&&typeof _=="object"&&typeof _.then=="function"){var W=hb(_,i);Ml(e,t,W,Kt(e))}else Ml(e,t,i,Kt(e))}catch(ne){Ml(e,t,{then:function(){},status:"rejected",reason:ne},Kt())}finally{V.p=d,y!==null&&A.types!==null&&(y.types=A.types),B.T=y}}function yb(){}function Uc(e,t,s,i){if(e.tag!==5)throw Error(o(476));var c=mh(e).queue;fh(e,c,t,I,s===null?yb:function(){return hh(e),s(i)})}function mh(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hn,lastRenderedState:I},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hn,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function hh(e){var t=mh(e);t.next===null&&(t=e.alternate.memoizedState),Ml(e,t.next.queue,{},Kt())}function Hc(){return Et(Il)}function ph(){return mt().memoizedState}function xh(){return mt().memoizedState}function Sb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Kt();e=ds(s);var i=fs(t,e,s);i!==null&&($t(i,t,s),wl(i,t,s)),t={cache:pc()},e.payload=t;return}t=t.return}}function jb(e,t,s){var i=Kt();s={lane:i,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},li(e)?vh(t,s):(s=ac(e,t,s,i),s!==null&&($t(s,e,i),bh(s,t,i)))}function gh(e,t,s){var i=Kt();Ml(e,t,s,i)}function Ml(e,t,s,i){var c={lane:i,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(li(e))vh(t,c);else{var d=e.alternate;if(e.lanes===0&&(d===null||d.lanes===0)&&(d=t.lastRenderedReducer,d!==null))try{var y=t.lastRenderedState,A=d(y,s);if(c.hasEagerState=!0,c.eagerState=A,Gt(A,y))return Ur(e,t,c,0),et===null&&zr(),!1}catch{}finally{}if(s=ac(e,t,c,i),s!==null)return $t(s,e,i),bh(s,t,i),!0}return!1}function Vc(e,t,s,i){if(i={lane:2,revertLane:bu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},li(e)){if(t)throw Error(o(479))}else t=ac(e,s,i,2),t!==null&&$t(t,e,2)}function li(e){var t=e.alternate;return e===Te||t!==null&&t===Te}function vh(e,t){ka=Pr=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function bh(e,t,s){if((s&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,s|=i,t.lanes=s,wf(e,s)}}var Rl={readContext:Et,use:ti,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};Rl.useEffectEvent=ct;var yh={readContext:Et,use:ti,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:Et,useEffect:sh,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,si(4194308,4,ih.bind(null,t,e),s)},useLayoutEffect:function(e,t){return si(4194308,4,e,t)},useInsertionEffect:function(e,t){si(4,2,e,t)},useMemo:function(e,t){var s=_t();t=t===void 0?null:t;var i=e();if(Fs){ze(!0);try{e()}finally{ze(!1)}}return s.memoizedState=[i,t],i},useReducer:function(e,t,s){var i=_t();if(s!==void 0){var c=s(t);if(Fs){ze(!0);try{s(t)}finally{ze(!1)}}}else c=t;return i.memoizedState=i.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},i.queue=e,e=e.dispatch=jb.bind(null,Te,e),[i.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:function(e){e=_c(e);var t=e.queue,s=gh.bind(null,Te,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:Lc,useDeferredValue:function(e,t){var s=_t();return zc(s,e,t)},useTransition:function(){var e=_c(!1);return e=fh.bind(null,Te,e.queue,!0,!1),_t().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var i=Te,c=_t();if(Ve){if(s===void 0)throw Error(o(407));s=s()}else{if(s=t(),et===null)throw Error(o(349));(Ue&127)!==0||Vm(i,t,s)}c.memoizedState=s;var d={value:s,getSnapshot:t};return c.queue=d,sh(Gm.bind(null,i,d,e),[e]),i.flags|=2048,Ma(9,{destroy:void 0},$m.bind(null,i,d,s,t),null),s},useId:function(){var e=_t(),t=et.identifierPrefix;if(Ve){var s=An,i=wn;s=(i&~(1<<32-rt(i)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Wr++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=pb++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Hc,useFormState:Pm,useActionState:Pm,useOptimistic:function(e){var t=_t();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=Vc.bind(null,Te,!0,s),s.dispatch=t,[e,t]},useMemoCache:Tc,useCacheRefresh:function(){return _t().memoizedState=Sb.bind(null,Te)},useEffectEvent:function(e){var t=_t(),s={impl:e};return t.memoizedState=s,function(){if((Ie&2)!==0)throw Error(o(440));return s.impl.apply(void 0,arguments)}}},$c={readContext:Et,use:ti,useCallback:ch,useContext:Et,useEffect:Bc,useImperativeHandle:oh,useInsertionEffect:lh,useLayoutEffect:rh,useMemo:uh,useReducer:ni,useRef:nh,useState:function(){return ni(Hn)},useDebugValue:Lc,useDeferredValue:function(e,t){var s=mt();return dh(s,Je.memoizedState,e,t)},useTransition:function(){var e=ni(Hn)[0],t=mt().memoizedState;return[typeof e=="boolean"?e:El(e),t]},useSyncExternalStore:Hm,useId:ph,useHostTransitionStatus:Hc,useFormState:Wm,useActionState:Wm,useOptimistic:function(e,t){var s=mt();return Im(s,Je,e,t)},useMemoCache:Tc,useCacheRefresh:xh};$c.useEffectEvent=ah;var Sh={readContext:Et,use:ti,useCallback:ch,useContext:Et,useEffect:Bc,useImperativeHandle:oh,useInsertionEffect:lh,useLayoutEffect:rh,useMemo:uh,useReducer:Dc,useRef:nh,useState:function(){return Dc(Hn)},useDebugValue:Lc,useDeferredValue:function(e,t){var s=mt();return Je===null?zc(s,e,t):dh(s,Je.memoizedState,e,t)},useTransition:function(){var e=Dc(Hn)[0],t=mt().memoizedState;return[typeof e=="boolean"?e:El(e),t]},useSyncExternalStore:Hm,useId:ph,useHostTransitionStatus:Hc,useFormState:th,useActionState:th,useOptimistic:function(e,t){var s=mt();return Je!==null?Im(s,Je,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:Tc,useCacheRefresh:xh};Sh.useEffectEvent=ah;function Gc(e,t,s,i){t=e.memoizedState,s=s(i,t),s=s==null?t:b({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Yc={enqueueSetState:function(e,t,s){e=e._reactInternals;var i=Kt(),c=ds(i);c.payload=t,s!=null&&(c.callback=s),t=fs(e,c,i),t!==null&&($t(t,e,i),wl(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var i=Kt(),c=ds(i);c.tag=1,c.payload=t,s!=null&&(c.callback=s),t=fs(e,c,i),t!==null&&($t(t,e,i),wl(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Kt(),i=ds(s);i.tag=2,t!=null&&(i.callback=t),t=fs(e,i,s),t!==null&&($t(t,e,s),wl(t,e,s))}};function jh(e,t,s,i,c,d,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,d,y):t.prototype&&t.prototype.isPureReactComponent?!xl(s,i)||!xl(c,d):!0}function Nh(e,t,s,i){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,i),t.state!==e&&Yc.enqueueReplaceState(t,t.state,null)}function Is(e,t){var s=t;if("ref"in t){s={};for(var i in t)i!=="ref"&&(s[i]=t[i])}if(e=e.defaultProps){s===t&&(s=b({},s));for(var c in e)s[c]===void 0&&(s[c]=e[c])}return s}function wh(e){Lr(e)}function Ah(e){console.error(e)}function Ch(e){Lr(e)}function ri(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function kh(e,t,s){try{var i=e.onCaughtError;i(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Fc(e,t,s){return s=ds(s),s.tag=3,s.payload={element:null},s.callback=function(){ri(e,t)},s}function Eh(e){return e=ds(e),e.tag=3,e}function Mh(e,t,s,i){var c=s.type.getDerivedStateFromError;if(typeof c=="function"){var d=i.value;e.payload=function(){return c(d)},e.callback=function(){kh(t,s,i)}}var y=s.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){kh(t,s,i),typeof c!="function"&&(vs===null?vs=new Set([this]):vs.add(this));var A=i.stack;this.componentDidCatch(i.value,{componentStack:A!==null?A:""})})}function Nb(e,t,s,i,c){if(s.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=s.alternate,t!==null&&Sa(t,s,c,!0),s=Ft.current,s!==null){switch(s.tag){case 31:case 13:return dn===null?vi():s.alternate===null&&ut===0&&(ut=3),s.flags&=-257,s.flags|=65536,s.lanes=c,i===Xr?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([i]):t.add(i),xu(e,i,c)),!1;case 22:return s.flags|=65536,i===Xr?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([i]):s.add(i)),xu(e,i,c)),!1}throw Error(o(435,s.tag))}return xu(e,i,c),vi(),!1}if(Ve)return t=Ft.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,i!==uc&&(e=Error(o(422),{cause:i}),bl(rn(e,s)))):(i!==uc&&(t=Error(o(423),{cause:i}),bl(rn(t,s))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,i=rn(i,s),c=Fc(e.stateNode,i,c),Sc(e,c),ut!==4&&(ut=2)),!1;var d=Error(o(520),{cause:i});if(d=rn(d,s),zl===null?zl=[d]:zl.push(d),ut!==4&&(ut=2),t===null)return!0;i=rn(i,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=c&-c,s.lanes|=e,e=Fc(s.stateNode,i,e),Sc(s,e),!1;case 1:if(t=s.type,d=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(vs===null||!vs.has(d))))return s.flags|=65536,c&=-c,s.lanes|=c,c=Eh(c),Mh(c,e,s,i),Sc(s,c),!1}s=s.return}while(s!==null);return!1}var Ic=Error(o(461)),gt=!1;function Mt(e,t,s,i){t.child=e===null?Dm(t,null,s,i):Ys(t,e.child,s,i)}function Rh(e,t,s,i,c){s=s.render;var d=t.ref;if("ref"in i){var y={};for(var A in i)A!=="ref"&&(y[A]=i[A])}else y=i;return Hs(t),i=kc(e,t,s,y,d,c),A=Ec(),e!==null&&!gt?(Mc(e,t,c),Vn(e,t,c)):(Ve&&A&&oc(t),t.flags|=1,Mt(e,t,i,c),t.child)}function Th(e,t,s,i,c){if(e===null){var d=s.type;return typeof d=="function"&&!lc(d)&&d.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=d,qh(e,t,d,i,c)):(e=Vr(s.type,null,i,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(d=e.child,!eu(e,c)){var y=d.memoizedProps;if(s=s.compare,s=s!==null?s:xl,s(y,i)&&e.ref===t.ref)return Vn(e,t,c)}return t.flags|=1,e=On(d,i),e.ref=t.ref,e.return=t,t.child=e}function qh(e,t,s,i,c){if(e!==null){var d=e.memoizedProps;if(xl(d,i)&&e.ref===t.ref)if(gt=!1,t.pendingProps=i=d,eu(e,c))(e.flags&131072)!==0&&(gt=!0);else return t.lanes=e.lanes,Vn(e,t,c)}return Xc(e,t,s,i,c)}function Dh(e,t,s,i){var c=i.children,d=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((t.flags&128)!==0){if(d=d!==null?d.baseLanes|s:s,e!==null){for(i=t.child=e.child,c=0;i!==null;)c=c|i.lanes|i.childLanes,i=i.sibling;i=c&~d}else i=0,t.child=null;return _h(e,t,d,s,i)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Fr(t,d!==null?d.cachePool:null),d!==null?Bm(t,d):Nc(),Lm(t);else return i=t.lanes=536870912,_h(e,t,d!==null?d.baseLanes|s:s,s,i)}else d!==null?(Fr(t,d.cachePool),Bm(t,d),hs(),t.memoizedState=null):(e!==null&&Fr(t,null),Nc(),hs());return Mt(e,t,c,s),t.child}function Tl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function _h(e,t,s,i,c){var d=gc();return d=d===null?null:{parent:pt._currentValue,pool:d},t.memoizedState={baseLanes:s,cachePool:d},e!==null&&Fr(t,null),Nc(),Lm(t),e!==null&&Sa(e,t,i,!0),t.childLanes=c,null}function ii(e,t){return t=ci({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Oh(e,t,s){return Ys(t,e.child,null,s),e=ii(t,t.pendingProps),e.flags|=2,It(t),t.memoizedState=null,e}function wb(e,t,s){var i=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Ve){if(i.mode==="hidden")return e=ii(t,i),t.lanes=536870912,Tl(null,e);if(Ac(t),(e=nt)?(e=X0(e,un),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:rs!==null?{id:wn,overflow:An}:null,retryLane:536870912,hydrationErrors:null},s=vm(e),s.return=t,t.child=s,kt=t,nt=null)):e=null,e===null)throw os(t);return t.lanes=536870912,null}return ii(t,i)}var d=e.memoizedState;if(d!==null){var y=d.dehydrated;if(Ac(t),c)if(t.flags&256)t.flags&=-257,t=Oh(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(gt||Sa(e,t,s,!1),c=(s&e.childLanes)!==0,gt||c){if(i=et,i!==null&&(y=Af(i,s),y!==0&&y!==d.retryLane))throw d.retryLane=y,Bs(e,y),$t(i,e,y),Ic;vi(),t=Oh(e,t,s)}else e=d.treeContext,nt=fn(y.nextSibling),kt=t,Ve=!0,is=null,un=!1,e!==null&&Sm(t,e),t=ii(t,i),t.flags|=4096;return t}return e=On(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oi(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(o(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function Xc(e,t,s,i,c){return Hs(t),s=kc(e,t,s,i,void 0,c),i=Ec(),e!==null&&!gt?(Mc(e,t,c),Vn(e,t,c)):(Ve&&i&&oc(t),t.flags|=1,Mt(e,t,s,c),t.child)}function Bh(e,t,s,i,c,d){return Hs(t),t.updateQueue=null,s=Um(t,i,s,c),zm(e),i=Ec(),e!==null&&!gt?(Mc(e,t,d),Vn(e,t,d)):(Ve&&i&&oc(t),t.flags|=1,Mt(e,t,s,d),t.child)}function Lh(e,t,s,i,c){if(Hs(t),t.stateNode===null){var d=ga,y=s.contextType;typeof y=="object"&&y!==null&&(d=Et(y)),d=new s(i,d),t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Yc,t.stateNode=d,d._reactInternals=t,d=t.stateNode,d.props=i,d.state=t.memoizedState,d.refs={},bc(t),y=s.contextType,d.context=typeof y=="object"&&y!==null?Et(y):ga,d.state=t.memoizedState,y=s.getDerivedStateFromProps,typeof y=="function"&&(Gc(t,s,y,i),d.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(y=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),y!==d.state&&Yc.enqueueReplaceState(d,d.state,null),Cl(t,i,d,c),Al(),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(e===null){d=t.stateNode;var A=t.memoizedProps,_=Is(s,A);d.props=_;var Y=d.context,W=s.contextType;y=ga,typeof W=="object"&&W!==null&&(y=Et(W));var ne=s.getDerivedStateFromProps;W=typeof ne=="function"||typeof d.getSnapshotBeforeUpdate=="function",A=t.pendingProps!==A,W||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(A||Y!==y)&&Nh(t,d,i,y),us=!1;var X=t.memoizedState;d.state=X,Cl(t,i,d,c),Al(),Y=t.memoizedState,A||X!==Y||us?(typeof ne=="function"&&(Gc(t,s,ne,i),Y=t.memoizedState),(_=us||jh(t,s,_,i,X,Y,y))?(W||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(t.flags|=4194308)):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=Y),d.props=i,d.state=Y,d.context=y,i=_):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!1)}else{d=t.stateNode,yc(e,t),y=t.memoizedProps,W=Is(s,y),d.props=W,ne=t.pendingProps,X=d.context,Y=s.contextType,_=ga,typeof Y=="object"&&Y!==null&&(_=Et(Y)),A=s.getDerivedStateFromProps,(Y=typeof A=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(y!==ne||X!==_)&&Nh(t,d,i,_),us=!1,X=t.memoizedState,d.state=X,Cl(t,i,d,c),Al();var P=t.memoizedState;y!==ne||X!==P||us||e!==null&&e.dependencies!==null&&Gr(e.dependencies)?(typeof A=="function"&&(Gc(t,s,A,i),P=t.memoizedState),(W=us||jh(t,s,W,i,X,P,_)||e!==null&&e.dependencies!==null&&Gr(e.dependencies))?(Y||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(i,P,_),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(i,P,_)),typeof d.componentDidUpdate=="function"&&(t.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=P),d.props=i,d.state=P,d.context=_,i=W):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),i=!1)}return d=i,oi(e,t),i=(t.flags&128)!==0,d||i?(d=t.stateNode,s=i&&typeof s.getDerivedStateFromError!="function"?null:d.render(),t.flags|=1,e!==null&&i?(t.child=Ys(t,e.child,null,c),t.child=Ys(t,null,s,c)):Mt(e,t,s,c),t.memoizedState=d.state,e=t.child):e=Vn(e,t,c),e}function zh(e,t,s,i){return zs(),t.flags|=256,Mt(e,t,s,i),t.child}var Qc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Kc(e){return{baseLanes:e,cachePool:km()}}function Zc(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Qt),e}function Uh(e,t,s){var i=t.pendingProps,c=!1,d=(t.flags&128)!==0,y;if((y=d)||(y=e!==null&&e.memoizedState===null?!1:(ft.current&2)!==0),y&&(c=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(Ve){if(c?ms(t):hs(),(e=nt)?(e=X0(e,un),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:rs!==null?{id:wn,overflow:An}:null,retryLane:536870912,hydrationErrors:null},s=vm(e),s.return=t,t.child=s,kt=t,nt=null)):e=null,e===null)throw os(t);return qu(e)?t.lanes=32:t.lanes=536870912,null}var A=i.children;return i=i.fallback,c?(hs(),c=t.mode,A=ci({mode:"hidden",children:A},c),i=Ls(i,c,s,null),A.return=t,i.return=t,A.sibling=i,t.child=A,i=t.child,i.memoizedState=Kc(s),i.childLanes=Zc(e,y,s),t.memoizedState=Qc,Tl(null,i)):(ms(t),Jc(t,A))}var _=e.memoizedState;if(_!==null&&(A=_.dehydrated,A!==null)){if(d)t.flags&256?(ms(t),t.flags&=-257,t=Pc(e,t,s)):t.memoizedState!==null?(hs(),t.child=e.child,t.flags|=128,t=null):(hs(),A=i.fallback,c=t.mode,i=ci({mode:"visible",children:i.children},c),A=Ls(A,c,s,null),A.flags|=2,i.return=t,A.return=t,i.sibling=A,t.child=i,Ys(t,e.child,null,s),i=t.child,i.memoizedState=Kc(s),i.childLanes=Zc(e,y,s),t.memoizedState=Qc,t=Tl(null,i));else if(ms(t),qu(A)){if(y=A.nextSibling&&A.nextSibling.dataset,y)var Y=y.dgst;y=Y,i=Error(o(419)),i.stack="",i.digest=y,bl({value:i,source:null,stack:null}),t=Pc(e,t,s)}else if(gt||Sa(e,t,s,!1),y=(s&e.childLanes)!==0,gt||y){if(y=et,y!==null&&(i=Af(y,s),i!==0&&i!==_.retryLane))throw _.retryLane=i,Bs(e,i),$t(y,e,i),Ic;Tu(A)||vi(),t=Pc(e,t,s)}else Tu(A)?(t.flags|=192,t.child=e.child,t=null):(e=_.treeContext,nt=fn(A.nextSibling),kt=t,Ve=!0,is=null,un=!1,e!==null&&Sm(t,e),t=Jc(t,i.children),t.flags|=4096);return t}return c?(hs(),A=i.fallback,c=t.mode,_=e.child,Y=_.sibling,i=On(_,{mode:"hidden",children:i.children}),i.subtreeFlags=_.subtreeFlags&65011712,Y!==null?A=On(Y,A):(A=Ls(A,c,s,null),A.flags|=2),A.return=t,i.return=t,i.sibling=A,t.child=i,Tl(null,i),i=t.child,A=e.child.memoizedState,A===null?A=Kc(s):(c=A.cachePool,c!==null?(_=pt._currentValue,c=c.parent!==_?{parent:_,pool:_}:c):c=km(),A={baseLanes:A.baseLanes|s,cachePool:c}),i.memoizedState=A,i.childLanes=Zc(e,y,s),t.memoizedState=Qc,Tl(e.child,i)):(ms(t),s=e.child,e=s.sibling,s=On(s,{mode:"visible",children:i.children}),s.return=t,s.sibling=null,e!==null&&(y=t.deletions,y===null?(t.deletions=[e],t.flags|=16):y.push(e)),t.child=s,t.memoizedState=null,s)}function Jc(e,t){return t=ci({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function ci(e,t){return e=Yt(22,e,null,t),e.lanes=0,e}function Pc(e,t,s){return Ys(t,e.child,null,s),e=Jc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Hh(e,t,s){e.lanes|=t;var i=e.alternate;i!==null&&(i.lanes|=t),mc(e.return,t,s)}function Wc(e,t,s,i,c,d){var y=e.memoizedState;y===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:s,tailMode:c,treeForkCount:d}:(y.isBackwards=t,y.rendering=null,y.renderingStartTime=0,y.last=i,y.tail=s,y.tailMode=c,y.treeForkCount=d)}function Vh(e,t,s){var i=t.pendingProps,c=i.revealOrder,d=i.tail;i=i.children;var y=ft.current,A=(y&2)!==0;if(A?(y=y&1|2,t.flags|=128):y&=1,K(ft,y),Mt(e,t,i,s),i=Ve?vl:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Hh(e,s,t);else if(e.tag===19)Hh(e,s,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(s=t.child,c=null;s!==null;)e=s.alternate,e!==null&&Jr(e)===null&&(c=s),s=s.sibling;s=c,s===null?(c=t.child,t.child=null):(c=s.sibling,s.sibling=null),Wc(t,!1,c,s,d,i);break;case"backwards":case"unstable_legacy-backwards":for(s=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Jr(e)===null){t.child=c;break}e=c.sibling,c.sibling=s,s=c,c=e}Wc(t,!0,s,null,d,i);break;case"together":Wc(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Vn(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),gs|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Sa(e,t,s,!1),(s&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,s=On(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=On(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function eu(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Gr(e)))}function Ab(e,t,s){switch(t.tag){case 3:ge(t,t.stateNode.containerInfo),cs(t,pt,e.memoizedState.cache),zs();break;case 27:case 5:ye(t);break;case 4:ge(t,t.stateNode.containerInfo);break;case 10:cs(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ac(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(ms(t),t.flags|=128,null):(s&t.child.childLanes)!==0?Uh(e,t,s):(ms(t),e=Vn(e,t,s),e!==null?e.sibling:null);ms(t);break;case 19:var c=(e.flags&128)!==0;if(i=(s&t.childLanes)!==0,i||(Sa(e,t,s,!1),i=(s&t.childLanes)!==0),c){if(i)return Vh(e,t,s);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),K(ft,ft.current),i)break;return null;case 22:return t.lanes=0,Dh(e,t,s,t.pendingProps);case 24:cs(t,pt,e.memoizedState.cache)}return Vn(e,t,s)}function $h(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)gt=!0;else{if(!eu(e,s)&&(t.flags&128)===0)return gt=!1,Ab(e,t,s);gt=(e.flags&131072)!==0}else gt=!1,Ve&&(t.flags&1048576)!==0&&ym(t,vl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=$s(t.elementType),t.type=e,typeof e=="function")lc(e)?(i=Is(e,i),t.tag=1,t=Lh(null,t,e,i,s)):(t.tag=0,t=Xc(null,t,e,i,s));else{if(e!=null){var c=e.$$typeof;if(c===T){t.tag=11,t=Rh(null,t,e,i,s);break e}else if(c===O){t.tag=14,t=Th(null,t,e,i,s);break e}}throw t=ue(e)||e,Error(o(306,t,""))}}return t;case 0:return Xc(e,t,t.type,t.pendingProps,s);case 1:return i=t.type,c=Is(i,t.pendingProps),Lh(e,t,i,c,s);case 3:e:{if(ge(t,t.stateNode.containerInfo),e===null)throw Error(o(387));i=t.pendingProps;var d=t.memoizedState;c=d.element,yc(e,t),Cl(t,i,null,s);var y=t.memoizedState;if(i=y.cache,cs(t,pt,i),i!==d.cache&&hc(t,[pt],s,!0),Al(),i=y.element,d.isDehydrated)if(d={element:i,isDehydrated:!1,cache:y.cache},t.updateQueue.baseState=d,t.memoizedState=d,t.flags&256){t=zh(e,t,i,s);break e}else if(i!==c){c=rn(Error(o(424)),t),bl(c),t=zh(e,t,i,s);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=fn(e.firstChild),kt=t,Ve=!0,is=null,un=!0,s=Dm(t,null,i,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(zs(),i===c){t=Vn(e,t,s);break e}Mt(e,t,i,s)}t=t.child}return t;case 26:return oi(e,t),e===null?(s=W0(t.type,null,t.pendingProps,null))?t.memoizedState=s:Ve||(s=t.type,e=t.pendingProps,i=Ai(we.current).createElement(s),i[Ct]=t,i[Bt]=e,Rt(i,s,e),wt(i),t.stateNode=i):t.memoizedState=W0(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ye(t),e===null&&Ve&&(i=t.stateNode=Z0(t.type,t.pendingProps,we.current),kt=t,un=!0,c=nt,js(t.type)?(Du=c,nt=fn(i.firstChild)):nt=c),Mt(e,t,t.pendingProps.children,s),oi(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ve&&((c=i=nt)&&(i=ty(i,t.type,t.pendingProps,un),i!==null?(t.stateNode=i,kt=t,nt=fn(i.firstChild),un=!1,c=!0):c=!1),c||os(t)),ye(t),c=t.type,d=t.pendingProps,y=e!==null?e.memoizedProps:null,i=d.children,Eu(c,d)?i=null:y!==null&&Eu(c,y)&&(t.flags|=32),t.memoizedState!==null&&(c=kc(e,t,xb,null,null,s),Il._currentValue=c),oi(e,t),Mt(e,t,i,s),t.child;case 6:return e===null&&Ve&&((e=s=nt)&&(s=ny(s,t.pendingProps,un),s!==null?(t.stateNode=s,kt=t,nt=null,e=!0):e=!1),e||os(t)),null;case 13:return Uh(e,t,s);case 4:return ge(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ys(t,null,i,s):Mt(e,t,i,s),t.child;case 11:return Rh(e,t,t.type,t.pendingProps,s);case 7:return Mt(e,t,t.pendingProps,s),t.child;case 8:return Mt(e,t,t.pendingProps.children,s),t.child;case 12:return Mt(e,t,t.pendingProps.children,s),t.child;case 10:return i=t.pendingProps,cs(t,t.type,i.value),Mt(e,t,i.children,s),t.child;case 9:return c=t.type._context,i=t.pendingProps.children,Hs(t),c=Et(c),i=i(c),t.flags|=1,Mt(e,t,i,s),t.child;case 14:return Th(e,t,t.type,t.pendingProps,s);case 15:return qh(e,t,t.type,t.pendingProps,s);case 19:return Vh(e,t,s);case 31:return wb(e,t,s);case 22:return Dh(e,t,s,t.pendingProps);case 24:return Hs(t),i=Et(pt),e===null?(c=gc(),c===null&&(c=et,d=pc(),c.pooledCache=d,d.refCount++,d!==null&&(c.pooledCacheLanes|=s),c=d),t.memoizedState={parent:i,cache:c},bc(t),cs(t,pt,c)):((e.lanes&s)!==0&&(yc(e,t),Cl(t,null,null,s),Al()),c=e.memoizedState,d=t.memoizedState,c.parent!==i?(c={parent:i,cache:i},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),cs(t,pt,i)):(i=d.cache,cs(t,pt,i),i!==c.cache&&hc(t,[pt],s,!0))),Mt(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function $n(e){e.flags|=4}function tu(e,t,s,i,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(p0())e.flags|=8192;else throw Gs=Xr,vc}else e.flags&=-16777217}function Gh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!ap(t))if(p0())e.flags|=8192;else throw Gs=Xr,vc}function ui(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?jf():536870912,e.lanes|=t,Da|=t)}function ql(e,t){if(!Ve)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var i=null;s!==null;)s.alternate!==null&&(i=s),s=s.sibling;i===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function st(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,i=0;if(t)for(var c=e.child;c!==null;)s|=c.lanes|c.childLanes,i|=c.subtreeFlags&65011712,i|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)s|=c.lanes|c.childLanes,i|=c.subtreeFlags,i|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=i,e.childLanes=s,t}function Cb(e,t,s){var i=t.pendingProps;switch(cc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return st(t),null;case 1:return st(t),null;case 3:return s=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),zn(pt),xe(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(ya(t)?$n(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,dc())),st(t),null;case 26:var c=t.type,d=t.memoizedState;return e===null?($n(t),d!==null?(st(t),Gh(t,d)):(st(t),tu(t,c,null,i,s))):d?d!==e.memoizedState?($n(t),st(t),Gh(t,d)):(st(t),t.flags&=-16777217):(e=e.memoizedProps,e!==i&&$n(t),st(t),tu(t,c,e,i,s)),null;case 27:if(Ce(t),s=we.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&$n(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return st(t),null}e=ae.current,ya(t)?jm(t):(e=Z0(c,i,s),t.stateNode=e,$n(t))}return st(t),null;case 5:if(Ce(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&$n(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return st(t),null}if(d=ae.current,ya(t))jm(t);else{var y=Ai(we.current);switch(d){case 1:d=y.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:d=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":d=y.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":d=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":d=y.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof i.is=="string"?y.createElement("select",{is:i.is}):y.createElement("select"),i.multiple?d.multiple=!0:i.size&&(d.size=i.size);break;default:d=typeof i.is=="string"?y.createElement(c,{is:i.is}):y.createElement(c)}}d[Ct]=t,d[Bt]=i;e:for(y=t.child;y!==null;){if(y.tag===5||y.tag===6)d.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===t)break e;for(;y.sibling===null;){if(y.return===null||y.return===t)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}t.stateNode=d;e:switch(Rt(d,c,i),c){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&$n(t)}}return st(t),tu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&$n(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(o(166));if(e=we.current,ya(t)){if(e=t.stateNode,s=t.memoizedProps,i=null,c=kt,c!==null)switch(c.tag){case 27:case 5:i=c.memoizedProps}e[Ct]=t,e=!!(e.nodeValue===s||i!==null&&i.suppressHydrationWarning===!0||U0(e.nodeValue,s)),e||os(t,!0)}else e=Ai(e).createTextNode(i),e[Ct]=t,t.stateNode=e}return st(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(i=ya(t),s!==null){if(e===null){if(!i)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[Ct]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;st(t),e=!1}else s=dc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(It(t),t):(It(t),null);if((t.flags&128)!==0)throw Error(o(558))}return st(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=ya(t),i!==null&&i.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[Ct]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;st(t),c=!1}else c=dc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(It(t),t):(It(t),null)}return It(t),(t.flags&128)!==0?(t.lanes=s,t):(s=i!==null,e=e!==null&&e.memoizedState!==null,s&&(i=t.child,c=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(c=i.alternate.memoizedState.cachePool.pool),d=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),d!==c&&(i.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),ui(t,t.updateQueue),st(t),null);case 4:return xe(),e===null&&Nu(t.stateNode.containerInfo),st(t),null;case 10:return zn(t.type),st(t),null;case 19:if(D(ft),i=t.memoizedState,i===null)return st(t),null;if(c=(t.flags&128)!==0,d=i.rendering,d===null)if(c)ql(i,!1);else{if(ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(d=Jr(e),d!==null){for(t.flags|=128,ql(i,!1),e=d.updateQueue,t.updateQueue=e,ui(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)gm(s,e),s=s.sibling;return K(ft,ft.current&1|2),Ve&&Bn(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&te()>pi&&(t.flags|=128,c=!0,ql(i,!1),t.lanes=4194304)}else{if(!c)if(e=Jr(d),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,ui(t,e),ql(i,!0),i.tail===null&&i.tailMode==="hidden"&&!d.alternate&&!Ve)return st(t),null}else 2*te()-i.renderingStartTime>pi&&s!==536870912&&(t.flags|=128,c=!0,ql(i,!1),t.lanes=4194304);i.isBackwards?(d.sibling=t.child,t.child=d):(e=i.last,e!==null?e.sibling=d:t.child=d,i.last=d)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=te(),e.sibling=null,s=ft.current,K(ft,c?s&1|2:s&1),Ve&&Bn(t,i.treeForkCount),e):(st(t),null);case 22:case 23:return It(t),wc(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(s&536870912)!==0&&(t.flags&128)===0&&(st(t),t.subtreeFlags&6&&(t.flags|=8192)):st(t),s=t.updateQueue,s!==null&&ui(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==s&&(t.flags|=2048),e!==null&&D(Vs),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),zn(pt),st(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function kb(e,t){switch(cc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zn(pt),xe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ce(t),null;case 31:if(t.memoizedState!==null){if(It(t),t.alternate===null)throw Error(o(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(It(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return D(ft),null;case 4:return xe(),null;case 10:return zn(t.type),null;case 22:case 23:return It(t),wc(),e!==null&&D(Vs),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zn(pt),null;case 25:return null;default:return null}}function Yh(e,t){switch(cc(t),t.tag){case 3:zn(pt),xe();break;case 26:case 27:case 5:Ce(t);break;case 4:xe();break;case 31:t.memoizedState!==null&&It(t);break;case 13:It(t);break;case 19:D(ft);break;case 10:zn(t.type);break;case 22:case 23:It(t),wc(),e!==null&&D(Vs);break;case 24:zn(pt)}}function Dl(e,t){try{var s=t.updateQueue,i=s!==null?s.lastEffect:null;if(i!==null){var c=i.next;s=c;do{if((s.tag&e)===e){i=void 0;var d=s.create,y=s.inst;i=d(),y.destroy=i}s=s.next}while(s!==c)}}catch(A){Ke(t,t.return,A)}}function ps(e,t,s){try{var i=t.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var d=c.next;i=d;do{if((i.tag&e)===e){var y=i.inst,A=y.destroy;if(A!==void 0){y.destroy=void 0,c=t;var _=s,Y=A;try{Y()}catch(W){Ke(c,_,W)}}}i=i.next}while(i!==d)}}catch(W){Ke(t,t.return,W)}}function Fh(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{Om(t,s)}catch(i){Ke(e,e.return,i)}}}function Ih(e,t,s){s.props=Is(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(i){Ke(e,t,i)}}function _l(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof s=="function"?e.refCleanup=s(i):s.current=i}}catch(c){Ke(e,t,c)}}function Cn(e,t){var s=e.ref,i=e.refCleanup;if(s!==null)if(typeof i=="function")try{i()}catch(c){Ke(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(c){Ke(e,t,c)}else s.current=null}function Xh(e){var t=e.type,s=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&i.focus();break e;case"img":s.src?i.src=s.src:s.srcSet&&(i.srcset=s.srcSet)}}catch(c){Ke(e,e.return,c)}}function nu(e,t,s){try{var i=e.stateNode;Kb(i,e.type,s,t),i[Bt]=t}catch(c){Ke(e,e.return,c)}}function Qh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&js(e.type)||e.tag===4}function su(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Qh(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&&js(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 au(e,t,s){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Dn));else if(i!==4&&(i===27&&js(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(au(e,t,s),e=e.sibling;e!==null;)au(e,t,s),e=e.sibling}function di(e,t,s){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(i!==4&&(i===27&&js(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(di(e,t,s),e=e.sibling;e!==null;)di(e,t,s),e=e.sibling}function Kh(e){var t=e.stateNode,s=e.memoizedProps;try{for(var i=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Rt(t,i,s),t[Ct]=e,t[Bt]=s}catch(d){Ke(e,e.return,d)}}var Gn=!1,vt=!1,lu=!1,Zh=typeof WeakSet=="function"?WeakSet:Set,At=null;function Eb(e,t){if(e=e.containerInfo,Cu=qi,e=om(e),Po(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var i=s.getSelection&&s.getSelection();if(i&&i.rangeCount!==0){s=i.anchorNode;var c=i.anchorOffset,d=i.focusNode;i=i.focusOffset;try{s.nodeType,d.nodeType}catch{s=null;break e}var y=0,A=-1,_=-1,Y=0,W=0,ne=e,X=null;t:for(;;){for(var P;ne!==s||c!==0&&ne.nodeType!==3||(A=y+c),ne!==d||i!==0&&ne.nodeType!==3||(_=y+i),ne.nodeType===3&&(y+=ne.nodeValue.length),(P=ne.firstChild)!==null;)X=ne,ne=P;for(;;){if(ne===e)break t;if(X===s&&++Y===c&&(A=y),X===d&&++W===i&&(_=y),(P=ne.nextSibling)!==null)break;ne=X,X=ne.parentNode}ne=P}s=A===-1||_===-1?null:{start:A,end:_}}else s=null}s=s||{start:0,end:0}}else s=null;for(ku={focusedElem:e,selectionRange:s},qi=!1,At=t;At!==null;)if(t=At,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,At=e;else for(;At!==null;){switch(t=At,d=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(s=0;s<e.length;s++)c=e[s],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&d!==null){e=void 0,s=t,c=d.memoizedProps,d=d.memoizedState,i=s.stateNode;try{var ve=Is(s.type,c);e=i.getSnapshotBeforeUpdate(ve,d),i.__reactInternalSnapshotBeforeUpdate=e}catch(ke){Ke(s,s.return,ke)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)Ru(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ru(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,At=e;break}At=t.return}}function Jh(e,t,s){var i=s.flags;switch(s.tag){case 0:case 11:case 15:Fn(e,s),i&4&&Dl(5,s);break;case 1:if(Fn(e,s),i&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(y){Ke(s,s.return,y)}else{var c=Is(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){Ke(s,s.return,y)}}i&64&&Fh(s),i&512&&_l(s,s.return);break;case 3:if(Fn(e,s),i&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{Om(e,t)}catch(y){Ke(s,s.return,y)}}break;case 27:t===null&&i&4&&Kh(s);case 26:case 5:Fn(e,s),t===null&&i&4&&Xh(s),i&512&&_l(s,s.return);break;case 12:Fn(e,s);break;case 31:Fn(e,s),i&4&&e0(e,s);break;case 13:Fn(e,s),i&4&&t0(e,s),i&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=Lb.bind(null,s),sy(e,s))));break;case 22:if(i=s.memoizedState!==null||Gn,!i){t=t!==null&&t.memoizedState!==null||vt,c=Gn;var d=vt;Gn=i,(vt=t)&&!d?In(e,s,(s.subtreeFlags&8772)!==0):Fn(e,s),Gn=c,vt=d}break;case 30:break;default:Fn(e,s)}}function Ph(e){var t=e.alternate;t!==null&&(e.alternate=null,Ph(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Oo(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 Yn(e,t,s){for(s=s.child;s!==null;)Wh(e,t,s),s=s.sibling}function Wh(e,t,s){if(Ee&&typeof Ee.onCommitFiberUnmount=="function")try{Ee.onCommitFiberUnmount(Xe,s)}catch{}switch(s.tag){case 26:vt||Cn(s,t),Yn(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:vt||Cn(s,t);var i=lt,c=zt;js(s.type)&&(lt=s.stateNode,zt=!1),Yn(e,t,s),Gl(s.stateNode),lt=i,zt=c;break;case 5:vt||Cn(s,t);case 6:if(i=lt,c=zt,lt=null,Yn(e,t,s),lt=i,zt=c,lt!==null)if(zt)try{(lt.nodeType===9?lt.body:lt.nodeName==="HTML"?lt.ownerDocument.body:lt).removeChild(s.stateNode)}catch(d){Ke(s,t,d)}else try{lt.removeChild(s.stateNode)}catch(d){Ke(s,t,d)}break;case 18:lt!==null&&(zt?(e=lt,F0(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),Va(e)):F0(lt,s.stateNode));break;case 4:i=lt,c=zt,lt=s.stateNode.containerInfo,zt=!0,Yn(e,t,s),lt=i,zt=c;break;case 0:case 11:case 14:case 15:ps(2,s,t),vt||ps(4,s,t),Yn(e,t,s);break;case 1:vt||(Cn(s,t),i=s.stateNode,typeof i.componentWillUnmount=="function"&&Ih(s,t,i)),Yn(e,t,s);break;case 21:Yn(e,t,s);break;case 22:vt=(i=vt)||s.memoizedState!==null,Yn(e,t,s),vt=i;break;default:Yn(e,t,s)}}function e0(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Va(e)}catch(s){Ke(t,t.return,s)}}}function t0(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Va(e)}catch(s){Ke(t,t.return,s)}}function Mb(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Zh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Zh),t;default:throw Error(o(435,e.tag))}}function fi(e,t){var s=Mb(e);t.forEach(function(i){if(!s.has(i)){s.add(i);var c=zb.bind(null,e,i);i.then(c,c)}})}function Ut(e,t){var s=t.deletions;if(s!==null)for(var i=0;i<s.length;i++){var c=s[i],d=e,y=t,A=y;e:for(;A!==null;){switch(A.tag){case 27:if(js(A.type)){lt=A.stateNode,zt=!1;break e}break;case 5:lt=A.stateNode,zt=!1;break e;case 3:case 4:lt=A.stateNode.containerInfo,zt=!0;break e}A=A.return}if(lt===null)throw Error(o(160));Wh(d,y,c),lt=null,zt=!1,d=c.alternate,d!==null&&(d.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)n0(t,e),t=t.sibling}var vn=null;function n0(e,t){var s=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ut(t,e),Ht(e),i&4&&(ps(3,e,e.return),Dl(3,e),ps(5,e,e.return));break;case 1:Ut(t,e),Ht(e),i&512&&(vt||s===null||Cn(s,s.return)),i&64&&Gn&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?i:s.concat(i))));break;case 26:var c=vn;if(Ut(t,e),Ht(e),i&512&&(vt||s===null||Cn(s,s.return)),i&4){var d=s!==null?s.memoizedState:null;if(i=e.memoizedState,s===null)if(i===null)if(e.stateNode===null){e:{i=e.type,s=e.memoizedProps,c=c.ownerDocument||c;t:switch(i){case"title":d=c.getElementsByTagName("title")[0],(!d||d[il]||d[Ct]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=c.createElement(i),c.head.insertBefore(d,c.querySelector("head > title"))),Rt(d,i,s),d[Ct]=e,wt(d),i=d;break e;case"link":var y=np("link","href",c).get(i+(s.href||""));if(y){for(var A=0;A<y.length;A++)if(d=y[A],d.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&d.getAttribute("rel")===(s.rel==null?null:s.rel)&&d.getAttribute("title")===(s.title==null?null:s.title)&&d.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){y.splice(A,1);break t}}d=c.createElement(i),Rt(d,i,s),c.head.appendChild(d);break;case"meta":if(y=np("meta","content",c).get(i+(s.content||""))){for(A=0;A<y.length;A++)if(d=y[A],d.getAttribute("content")===(s.content==null?null:""+s.content)&&d.getAttribute("name")===(s.name==null?null:s.name)&&d.getAttribute("property")===(s.property==null?null:s.property)&&d.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&d.getAttribute("charset")===(s.charSet==null?null:s.charSet)){y.splice(A,1);break t}}d=c.createElement(i),Rt(d,i,s),c.head.appendChild(d);break;default:throw Error(o(468,i))}d[Ct]=e,wt(d),i=d}e.stateNode=i}else sp(c,e.type,e.stateNode);else e.stateNode=tp(c,i,e.memoizedProps);else d!==i?(d===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):d.count--,i===null?sp(c,e.type,e.stateNode):tp(c,i,e.memoizedProps)):i===null&&e.stateNode!==null&&nu(e,e.memoizedProps,s.memoizedProps)}break;case 27:Ut(t,e),Ht(e),i&512&&(vt||s===null||Cn(s,s.return)),s!==null&&i&4&&nu(e,e.memoizedProps,s.memoizedProps);break;case 5:if(Ut(t,e),Ht(e),i&512&&(vt||s===null||Cn(s,s.return)),e.flags&32){c=e.stateNode;try{ua(c,"")}catch(ve){Ke(e,e.return,ve)}}i&4&&e.stateNode!=null&&(c=e.memoizedProps,nu(e,c,s!==null?s.memoizedProps:c)),i&1024&&(lu=!0);break;case 6:if(Ut(t,e),Ht(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,s=e.stateNode;try{s.nodeValue=i}catch(ve){Ke(e,e.return,ve)}}break;case 3:if(Ei=null,c=vn,vn=Ci(t.containerInfo),Ut(t,e),vn=c,Ht(e),i&4&&s!==null&&s.memoizedState.isDehydrated)try{Va(t.containerInfo)}catch(ve){Ke(e,e.return,ve)}lu&&(lu=!1,s0(e));break;case 4:i=vn,vn=Ci(e.stateNode.containerInfo),Ut(t,e),Ht(e),vn=i;break;case 12:Ut(t,e),Ht(e);break;case 31:Ut(t,e),Ht(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,fi(e,i)));break;case 13:Ut(t,e),Ht(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(hi=te()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,fi(e,i)));break;case 22:c=e.memoizedState!==null;var _=s!==null&&s.memoizedState!==null,Y=Gn,W=vt;if(Gn=Y||c,vt=W||_,Ut(t,e),vt=W,Gn=Y,Ht(e),i&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(s===null||_||Gn||vt||Xs(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){_=s=t;try{if(d=_.stateNode,c)y=d.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{A=_.stateNode;var ne=_.memoizedProps.style,X=ne!=null&&ne.hasOwnProperty("display")?ne.display:null;A.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(ve){Ke(_,_.return,ve)}}}else if(t.tag===6){if(s===null){_=t;try{_.stateNode.nodeValue=c?"":_.memoizedProps}catch(ve){Ke(_,_.return,ve)}}}else if(t.tag===18){if(s===null){_=t;try{var P=_.stateNode;c?I0(P,!0):I0(_.stateNode,!1)}catch(ve){Ke(_,_.return,ve)}}}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;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}i&4&&(i=e.updateQueue,i!==null&&(s=i.retryQueue,s!==null&&(i.retryQueue=null,fi(e,s))));break;case 19:Ut(t,e),Ht(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,fi(e,i)));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 s,i=e.return;i!==null;){if(Qh(i)){s=i;break}i=i.return}if(s==null)throw Error(o(160));switch(s.tag){case 27:var c=s.stateNode,d=su(e);di(e,d,c);break;case 5:var y=s.stateNode;s.flags&32&&(ua(y,""),s.flags&=-33);var A=su(e);di(e,A,y);break;case 3:case 4:var _=s.stateNode.containerInfo,Y=su(e);au(e,Y,_);break;default:throw Error(o(161))}}catch(W){Ke(e,e.return,W)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function s0(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;s0(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Fn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Jh(e,t.alternate,t),t=t.sibling}function Xs(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ps(4,t,t.return),Xs(t);break;case 1:Cn(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&Ih(t,t.return,s),Xs(t);break;case 27:Gl(t.stateNode);case 26:case 5:Cn(t,t.return),Xs(t);break;case 22:t.memoizedState===null&&Xs(t);break;case 30:Xs(t);break;default:Xs(t)}e=e.sibling}}function In(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var i=t.alternate,c=e,d=t,y=d.flags;switch(d.tag){case 0:case 11:case 15:In(c,d,s),Dl(4,d);break;case 1:if(In(c,d,s),i=d,c=i.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(Y){Ke(i,i.return,Y)}if(i=d,c=i.updateQueue,c!==null){var A=i.stateNode;try{var _=c.shared.hiddenCallbacks;if(_!==null)for(c.shared.hiddenCallbacks=null,c=0;c<_.length;c++)_m(_[c],A)}catch(Y){Ke(i,i.return,Y)}}s&&y&64&&Fh(d),_l(d,d.return);break;case 27:Kh(d);case 26:case 5:In(c,d,s),s&&i===null&&y&4&&Xh(d),_l(d,d.return);break;case 12:In(c,d,s);break;case 31:In(c,d,s),s&&y&4&&e0(c,d);break;case 13:In(c,d,s),s&&y&4&&t0(c,d);break;case 22:d.memoizedState===null&&In(c,d,s),_l(d,d.return);break;case 30:break;default:In(c,d,s)}t=t.sibling}}function ru(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&yl(s))}function iu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&yl(e))}function bn(e,t,s,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)a0(e,t,s,i),t=t.sibling}function a0(e,t,s,i){var c=t.flags;switch(t.tag){case 0:case 11:case 15:bn(e,t,s,i),c&2048&&Dl(9,t);break;case 1:bn(e,t,s,i);break;case 3:bn(e,t,s,i),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&yl(e)));break;case 12:if(c&2048){bn(e,t,s,i),e=t.stateNode;try{var d=t.memoizedProps,y=d.id,A=d.onPostCommit;typeof A=="function"&&A(y,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(_){Ke(t,t.return,_)}}else bn(e,t,s,i);break;case 31:bn(e,t,s,i);break;case 13:bn(e,t,s,i);break;case 23:break;case 22:d=t.stateNode,y=t.alternate,t.memoizedState!==null?d._visibility&2?bn(e,t,s,i):Ol(e,t):d._visibility&2?bn(e,t,s,i):(d._visibility|=2,Ra(e,t,s,i,(t.subtreeFlags&10256)!==0||!1)),c&2048&&ru(y,t);break;case 24:bn(e,t,s,i),c&2048&&iu(t.alternate,t);break;default:bn(e,t,s,i)}}function Ra(e,t,s,i,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var d=e,y=t,A=s,_=i,Y=y.flags;switch(y.tag){case 0:case 11:case 15:Ra(d,y,A,_,c),Dl(8,y);break;case 23:break;case 22:var W=y.stateNode;y.memoizedState!==null?W._visibility&2?Ra(d,y,A,_,c):Ol(d,y):(W._visibility|=2,Ra(d,y,A,_,c)),c&&Y&2048&&ru(y.alternate,y);break;case 24:Ra(d,y,A,_,c),c&&Y&2048&&iu(y.alternate,y);break;default:Ra(d,y,A,_,c)}t=t.sibling}}function Ol(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,i=t,c=i.flags;switch(i.tag){case 22:Ol(s,i),c&2048&&ru(i.alternate,i);break;case 24:Ol(s,i),c&2048&&iu(i.alternate,i);break;default:Ol(s,i)}t=t.sibling}}var Bl=8192;function Ta(e,t,s){if(e.subtreeFlags&Bl)for(e=e.child;e!==null;)l0(e,t,s),e=e.sibling}function l0(e,t,s){switch(e.tag){case 26:Ta(e,t,s),e.flags&Bl&&e.memoizedState!==null&&py(s,vn,e.memoizedState,e.memoizedProps);break;case 5:Ta(e,t,s);break;case 3:case 4:var i=vn;vn=Ci(e.stateNode.containerInfo),Ta(e,t,s),vn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=Bl,Bl=16777216,Ta(e,t,s),Bl=i):Ta(e,t,s));break;default:Ta(e,t,s)}}function r0(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 Ll(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var i=t[s];At=i,o0(i,e)}r0(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)i0(e),e=e.sibling}function i0(e){switch(e.tag){case 0:case 11:case 15:Ll(e),e.flags&2048&&ps(9,e,e.return);break;case 3:Ll(e);break;case 12:Ll(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,mi(e)):Ll(e);break;default:Ll(e)}}function mi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var i=t[s];At=i,o0(i,e)}r0(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ps(8,t,t.return),mi(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,mi(t));break;default:mi(t)}e=e.sibling}}function o0(e,t){for(;At!==null;){var s=At;switch(s.tag){case 0:case 11:case 15:ps(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var i=s.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:yl(s.memoizedState.cache)}if(i=s.child,i!==null)i.return=s,At=i;else e:for(s=e;At!==null;){i=At;var c=i.sibling,d=i.return;if(Ph(i),i===s){At=null;break e}if(c!==null){c.return=d,At=c;break e}At=d}}}var Rb={getCacheForType:function(e){var t=Et(pt),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return Et(pt).controller.signal}},Tb=typeof WeakMap=="function"?WeakMap:Map,Ie=0,et=null,Be=null,Ue=0,Qe=0,Xt=null,xs=!1,qa=!1,ou=!1,Xn=0,ut=0,gs=0,Qs=0,cu=0,Qt=0,Da=0,zl=null,Vt=null,uu=!1,hi=0,c0=0,pi=1/0,xi=null,vs=null,jt=0,bs=null,_a=null,Qn=0,du=0,fu=null,u0=null,Ul=0,mu=null;function Kt(){return(Ie&2)!==0&&Ue!==0?Ue&-Ue:B.T!==null?bu():Cf()}function d0(){if(Qt===0)if((Ue&536870912)===0||Ve){var e=wr;wr<<=1,(wr&3932160)===0&&(wr=262144),Qt=e}else Qt=536870912;return e=Ft.current,e!==null&&(e.flags|=32),Qt}function $t(e,t,s){(e===et&&(Qe===2||Qe===9)||e.cancelPendingCommit!==null)&&(Oa(e,0),ys(e,Ue,Qt,!1)),rl(e,s),((Ie&2)===0||e!==et)&&(e===et&&((Ie&2)===0&&(Qs|=s),ut===4&&ys(e,Ue,Qt,!1)),kn(e))}function f0(e,t,s){if((Ie&6)!==0)throw Error(o(327));var i=!s&&(t&127)===0&&(t&e.expiredLanes)===0||ll(e,t),c=i?_b(e,t):pu(e,t,!0),d=i;do{if(c===0){qa&&!i&&ys(e,t,0,!1);break}else{if(s=e.current.alternate,d&&!qb(s)){c=pu(e,t,!1),d=!1;continue}if(c===2){if(d=t,e.errorRecoveryDisabledLanes&d)var y=0;else y=e.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){t=y;e:{var A=e;c=zl;var _=A.current.memoizedState.isDehydrated;if(_&&(Oa(A,y).flags|=256),y=pu(A,y,!1),y!==2){if(ou&&!_){A.errorRecoveryDisabledLanes|=d,Qs|=d,c=4;break e}d=Vt,Vt=c,d!==null&&(Vt===null?Vt=d:Vt.push.apply(Vt,d))}c=y}if(d=!1,c!==2)continue}}if(c===1){Oa(e,0),ys(e,t,0,!0);break}e:{switch(i=e,d=c,d){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:ys(i,t,Qt,!xs);break e;case 2:Vt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=hi+300-te(),10<c)){if(ys(i,t,Qt,!xs),Cr(i,0,!0)!==0)break e;Qn=t,i.timeoutHandle=G0(m0.bind(null,i,s,Vt,xi,uu,t,Qt,Qs,Da,xs,d,"Throttled",-0,0),c);break e}m0(i,s,Vt,xi,uu,t,Qt,Qs,Da,xs,d,null,-0,0)}}break}while(!0);kn(e)}function m0(e,t,s,i,c,d,y,A,_,Y,W,ne,X,P){if(e.timeoutHandle=-1,ne=t.subtreeFlags,ne&8192||(ne&16785408)===16785408){ne={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Dn},l0(t,d,ne);var ve=(d&62914560)===d?hi-te():(d&4194048)===d?c0-te():0;if(ve=xy(ne,ve),ve!==null){Qn=d,e.cancelPendingCommit=ve(S0.bind(null,e,t,d,s,i,c,y,A,_,W,ne,null,X,P)),ys(e,d,y,!Y);return}}S0(e,t,d,s,i,c,y,A,_)}function qb(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var i=0;i<s.length;i++){var c=s[i],d=c.getSnapshot;c=c.value;try{if(!Gt(d(),c))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;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 ys(e,t,s,i){t&=~cu,t&=~Qs,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var c=t;0<c;){var d=31-rt(c),y=1<<d;i[d]=-1,c&=~y}s!==0&&Nf(e,s,t)}function gi(){return(Ie&6)===0?(Hl(0),!1):!0}function hu(){if(Be!==null){if(Qe===0)var e=Be.return;else e=Be,Ln=Us=null,Rc(e),Aa=null,jl=0,e=Be;for(;e!==null;)Yh(e.alternate,e),e=e.return;Be=null}}function Oa(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,Pb(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Qn=0,hu(),et=e,Be=s=On(e.current,null),Ue=t,Qe=0,Xt=null,xs=!1,qa=ll(e,t),ou=!1,Da=Qt=cu=Qs=gs=ut=0,Vt=zl=null,uu=!1,(t&8)!==0&&(t|=t&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=t;0<i;){var c=31-rt(i),d=1<<c;t|=e[c],i&=~d}return Xn=t,zr(),s}function h0(e,t){Te=null,B.H=Rl,t===wa||t===Ir?(t=Rm(),Qe=3):t===vc?(t=Rm(),Qe=4):Qe=t===Ic?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Xt=t,Be===null&&(ut=1,ri(e,rn(t,e.current)))}function p0(){var e=Ft.current;return e===null?!0:(Ue&4194048)===Ue?dn===null:(Ue&62914560)===Ue||(Ue&536870912)!==0?e===dn:!1}function x0(){var e=B.H;return B.H=Rl,e===null?Rl:e}function g0(){var e=B.A;return B.A=Rb,e}function vi(){ut=4,xs||(Ue&4194048)!==Ue&&Ft.current!==null||(qa=!0),(gs&134217727)===0&&(Qs&134217727)===0||et===null||ys(et,Ue,Qt,!1)}function pu(e,t,s){var i=Ie;Ie|=2;var c=x0(),d=g0();(et!==e||Ue!==t)&&(xi=null,Oa(e,t)),t=!1;var y=ut;e:do try{if(Qe!==0&&Be!==null){var A=Be,_=Xt;switch(Qe){case 8:hu(),y=6;break e;case 3:case 2:case 9:case 6:Ft.current===null&&(t=!0);var Y=Qe;if(Qe=0,Xt=null,Ba(e,A,_,Y),s&&qa){y=0;break e}break;default:Y=Qe,Qe=0,Xt=null,Ba(e,A,_,Y)}}Db(),y=ut;break}catch(W){h0(e,W)}while(!0);return t&&e.shellSuspendCounter++,Ln=Us=null,Ie=i,B.H=c,B.A=d,Be===null&&(et=null,Ue=0,zr()),y}function Db(){for(;Be!==null;)v0(Be)}function _b(e,t){var s=Ie;Ie|=2;var i=x0(),c=g0();et!==e||Ue!==t?(xi=null,pi=te()+500,Oa(e,t)):qa=ll(e,t);e:do try{if(Qe!==0&&Be!==null){t=Be;var d=Xt;t:switch(Qe){case 1:Qe=0,Xt=null,Ba(e,t,d,1);break;case 2:case 9:if(Em(d)){Qe=0,Xt=null,b0(t);break}t=function(){Qe!==2&&Qe!==9||et!==e||(Qe=7),kn(e)},d.then(t,t);break e;case 3:Qe=7;break e;case 4:Qe=5;break e;case 7:Em(d)?(Qe=0,Xt=null,b0(t)):(Qe=0,Xt=null,Ba(e,t,d,7));break;case 5:var y=null;switch(Be.tag){case 26:y=Be.memoizedState;case 5:case 27:var A=Be;if(y?ap(y):A.stateNode.complete){Qe=0,Xt=null;var _=A.sibling;if(_!==null)Be=_;else{var Y=A.return;Y!==null?(Be=Y,bi(Y)):Be=null}break t}}Qe=0,Xt=null,Ba(e,t,d,5);break;case 6:Qe=0,Xt=null,Ba(e,t,d,6);break;case 8:hu(),ut=6;break e;default:throw Error(o(462))}}Ob();break}catch(W){h0(e,W)}while(!0);return Ln=Us=null,B.H=i,B.A=c,Ie=s,Be!==null?0:(et=null,Ue=0,zr(),ut)}function Ob(){for(;Be!==null&&!fe();)v0(Be)}function v0(e){var t=$h(e.alternate,e,Xn);e.memoizedProps=e.pendingProps,t===null?bi(e):Be=t}function b0(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=Bh(s,t,t.pendingProps,t.type,void 0,Ue);break;case 11:t=Bh(s,t,t.pendingProps,t.type.render,t.ref,Ue);break;case 5:Rc(t);default:Yh(s,t),t=Be=gm(t,Xn),t=$h(s,t,Xn)}e.memoizedProps=e.pendingProps,t===null?bi(e):Be=t}function Ba(e,t,s,i){Ln=Us=null,Rc(t),Aa=null,jl=0;var c=t.return;try{if(Nb(e,c,t,s,Ue)){ut=1,ri(e,rn(s,e.current)),Be=null;return}}catch(d){if(c!==null)throw Be=c,d;ut=1,ri(e,rn(s,e.current)),Be=null;return}t.flags&32768?(Ve||i===1?e=!0:qa||(Ue&536870912)!==0?e=!1:(xs=e=!0,(i===2||i===9||i===3||i===6)&&(i=Ft.current,i!==null&&i.tag===13&&(i.flags|=16384))),y0(t,e)):bi(t)}function bi(e){var t=e;do{if((t.flags&32768)!==0){y0(t,xs);return}e=t.return;var s=Cb(t.alternate,t,Xn);if(s!==null){Be=s;return}if(t=t.sibling,t!==null){Be=t;return}Be=t=e}while(t!==null);ut===0&&(ut=5)}function y0(e,t){do{var s=kb(e.alternate,e);if(s!==null){s.flags&=32767,Be=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){Be=e;return}Be=e=s}while(e!==null);ut=6,Be=null}function S0(e,t,s,i,c,d,y,A,_){e.cancelPendingCommit=null;do yi();while(jt!==0);if((Ie&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(d=t.lanes|t.childLanes,d|=sc,hv(e,s,d,y,A,_),e===et&&(Be=et=null,Ue=0),_a=t,bs=e,Qn=s,du=d,fu=c,u0=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Ub(tn,function(){return C0(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||i){i=B.T,B.T=null,c=V.p,V.p=2,y=Ie,Ie|=4;try{Eb(e,t,s)}finally{Ie=y,V.p=c,B.T=i}}jt=1,j0(),N0(),w0()}}function j0(){if(jt===1){jt=0;var e=bs,t=_a,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=B.T,B.T=null;var i=V.p;V.p=2;var c=Ie;Ie|=4;try{n0(t,e);var d=ku,y=om(e.containerInfo),A=d.focusedElem,_=d.selectionRange;if(y!==A&&A&&A.ownerDocument&&im(A.ownerDocument.documentElement,A)){if(_!==null&&Po(A)){var Y=_.start,W=_.end;if(W===void 0&&(W=Y),"selectionStart"in A)A.selectionStart=Y,A.selectionEnd=Math.min(W,A.value.length);else{var ne=A.ownerDocument||document,X=ne&&ne.defaultView||window;if(X.getSelection){var P=X.getSelection(),ve=A.textContent.length,ke=Math.min(_.start,ve),We=_.end===void 0?ke:Math.min(_.end,ve);!P.extend&&ke>We&&(y=We,We=ke,ke=y);var H=rm(A,ke),z=rm(A,We);if(H&&z&&(P.rangeCount!==1||P.anchorNode!==H.node||P.anchorOffset!==H.offset||P.focusNode!==z.node||P.focusOffset!==z.offset)){var G=ne.createRange();G.setStart(H.node,H.offset),P.removeAllRanges(),ke>We?(P.addRange(G),P.extend(z.node,z.offset)):(G.setEnd(z.node,z.offset),P.addRange(G))}}}}for(ne=[],P=A;P=P.parentNode;)P.nodeType===1&&ne.push({element:P,left:P.scrollLeft,top:P.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<ne.length;A++){var ee=ne[A];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}qi=!!Cu,ku=Cu=null}finally{Ie=c,V.p=i,B.T=s}}e.current=t,jt=2}}function N0(){if(jt===2){jt=0;var e=bs,t=_a,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=B.T,B.T=null;var i=V.p;V.p=2;var c=Ie;Ie|=4;try{Jh(e,t.alternate,t)}finally{Ie=c,V.p=i,B.T=s}}jt=3}}function w0(){if(jt===4||jt===3){jt=0,Re();var e=bs,t=_a,s=Qn,i=u0;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?jt=5:(jt=0,_a=bs=null,A0(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(vs=null),Do(s),t=t.stateNode,Ee&&typeof Ee.onCommitFiberRoot=="function")try{Ee.onCommitFiberRoot(Xe,t,void 0,(t.current.flags&128)===128)}catch{}if(i!==null){t=B.T,c=V.p,V.p=2,B.T=null;try{for(var d=e.onRecoverableError,y=0;y<i.length;y++){var A=i[y];d(A.value,{componentStack:A.stack})}}finally{B.T=t,V.p=c}}(Qn&3)!==0&&yi(),kn(e),c=e.pendingLanes,(s&261930)!==0&&(c&42)!==0?e===mu?Ul++:(Ul=0,mu=e):Ul=0,Hl(0)}}function A0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,yl(t)))}function yi(){return j0(),N0(),w0(),C0()}function C0(){if(jt!==5)return!1;var e=bs,t=du;du=0;var s=Do(Qn),i=B.T,c=V.p;try{V.p=32>s?32:s,B.T=null,s=fu,fu=null;var d=bs,y=Qn;if(jt=0,_a=bs=null,Qn=0,(Ie&6)!==0)throw Error(o(331));var A=Ie;if(Ie|=4,i0(d.current),a0(d,d.current,y,s),Ie=A,Hl(0,!1),Ee&&typeof Ee.onPostCommitFiberRoot=="function")try{Ee.onPostCommitFiberRoot(Xe,d)}catch{}return!0}finally{V.p=c,B.T=i,A0(e,t)}}function k0(e,t,s){t=rn(s,t),t=Fc(e.stateNode,t,2),e=fs(e,t,2),e!==null&&(rl(e,2),kn(e))}function Ke(e,t,s){if(e.tag===3)k0(e,e,s);else for(;t!==null;){if(t.tag===3){k0(t,e,s);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(vs===null||!vs.has(i))){e=rn(s,e),s=Eh(2),i=fs(t,s,2),i!==null&&(Mh(s,i,t,e),rl(i,2),kn(i));break}}t=t.return}}function xu(e,t,s){var i=e.pingCache;if(i===null){i=e.pingCache=new Tb;var c=new Set;i.set(t,c)}else c=i.get(t),c===void 0&&(c=new Set,i.set(t,c));c.has(s)||(ou=!0,c.add(s),e=Bb.bind(null,e,t,s),t.then(e,e))}function Bb(e,t,s){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,et===e&&(Ue&s)===s&&(ut===4||ut===3&&(Ue&62914560)===Ue&&300>te()-hi?(Ie&2)===0&&Oa(e,0):cu|=s,Da===Ue&&(Da=0)),kn(e)}function E0(e,t){t===0&&(t=jf()),e=Bs(e,t),e!==null&&(rl(e,t),kn(e))}function Lb(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),E0(e,s)}function zb(e,t){var s=0;switch(e.tag){case 31:case 13:var i=e.stateNode,c=e.memoizedState;c!==null&&(s=c.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(t),E0(e,s)}function Ub(e,t){return re(e,t)}var Si=null,La=null,gu=!1,ji=!1,vu=!1,Ss=0;function kn(e){e!==La&&e.next===null&&(La===null?Si=La=e:La=La.next=e),ji=!0,gu||(gu=!0,Vb())}function Hl(e,t){if(!vu&&ji){vu=!0;do for(var s=!1,i=Si;i!==null;){if(e!==0){var c=i.pendingLanes;if(c===0)var d=0;else{var y=i.suspendedLanes,A=i.pingedLanes;d=(1<<31-rt(42|e)+1)-1,d&=c&~(y&~A),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(s=!0,q0(i,d))}else d=Ue,d=Cr(i,i===et?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(d&3)===0||ll(i,d)||(s=!0,q0(i,d));i=i.next}while(s);vu=!1}}function Hb(){M0()}function M0(){ji=gu=!1;var e=0;Ss!==0&&Jb()&&(e=Ss);for(var t=te(),s=null,i=Si;i!==null;){var c=i.next,d=R0(i,t);d===0?(i.next=null,s===null?Si=c:s.next=c,c===null&&(La=s)):(s=i,(e!==0||(d&3)!==0)&&(ji=!0)),i=c}jt!==0&&jt!==5||Hl(e),Ss!==0&&(Ss=0)}function R0(e,t){for(var s=e.suspendedLanes,i=e.pingedLanes,c=e.expirationTimes,d=e.pendingLanes&-62914561;0<d;){var y=31-rt(d),A=1<<y,_=c[y];_===-1?((A&s)===0||(A&i)!==0)&&(c[y]=mv(A,t)):_<=t&&(e.expiredLanes|=A),d&=~A}if(t=et,s=Ue,s=Cr(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,s===0||e===t&&(Qe===2||Qe===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&de(i),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||ll(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(i!==null&&de(i),Do(s)){case 2:case 8:s=en;break;case 32:s=tn;break;case 268435456:s=Nt;break;default:s=tn}return i=T0.bind(null,e),s=re(s,i),e.callbackPriority=t,e.callbackNode=s,t}return i!==null&&i!==null&&de(i),e.callbackPriority=2,e.callbackNode=null,2}function T0(e,t){if(jt!==0&&jt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(yi()&&e.callbackNode!==s)return null;var i=Ue;return i=Cr(e,e===et?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(f0(e,i,t),R0(e,te()),e.callbackNode!=null&&e.callbackNode===s?T0.bind(null,e):null)}function q0(e,t){if(yi())return null;f0(e,t,!0)}function Vb(){Wb(function(){(Ie&6)!==0?re(_e,Hb):M0()})}function bu(){if(Ss===0){var e=ja;e===0&&(e=Nn,Nn<<=1,(Nn&261888)===0&&(Nn=256)),Ss=e}return Ss}function D0(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Rr(""+e)}function _0(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function $b(e,t,s,i,c){if(t==="submit"&&s&&s.stateNode===c){var d=D0((c[Bt]||null).action),y=i.submitter;y&&(t=(t=y[Bt]||null)?D0(t.formAction):y.getAttribute("formAction"),t!==null&&(d=t,y=null));var A=new _r("action","action",null,i,c);e.push({event:A,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Ss!==0){var _=y?_0(c,y):new FormData(c);Uc(s,{pending:!0,data:_,method:c.method,action:d},null,_)}}else typeof d=="function"&&(A.preventDefault(),_=y?_0(c,y):new FormData(c),Uc(s,{pending:!0,data:_,method:c.method,action:d},d,_))},currentTarget:c}]})}}for(var yu=0;yu<nc.length;yu++){var Su=nc[yu],Gb=Su.toLowerCase(),Yb=Su[0].toUpperCase()+Su.slice(1);gn(Gb,"on"+Yb)}gn(dm,"onAnimationEnd"),gn(fm,"onAnimationIteration"),gn(mm,"onAnimationStart"),gn("dblclick","onDoubleClick"),gn("focusin","onFocus"),gn("focusout","onBlur"),gn(rb,"onTransitionRun"),gn(ib,"onTransitionStart"),gn(ob,"onTransitionCancel"),gn(hm,"onTransitionEnd"),oa("onMouseEnter",["mouseout","mouseover"]),oa("onMouseLeave",["mouseout","mouseover"]),oa("onPointerEnter",["pointerout","pointerover"]),oa("onPointerLeave",["pointerout","pointerover"]),qs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),qs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),qs("onBeforeInput",["compositionend","keypress","textInput","paste"]),qs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),qs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),qs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Vl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Fb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Vl));function O0(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var i=e[s],c=i.event;i=i.listeners;e:{var d=void 0;if(t)for(var y=i.length-1;0<=y;y--){var A=i[y],_=A.instance,Y=A.currentTarget;if(A=A.listener,_!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=Y;try{d(c)}catch(W){Lr(W)}c.currentTarget=null,d=_}else for(y=0;y<i.length;y++){if(A=i[y],_=A.instance,Y=A.currentTarget,A=A.listener,_!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=Y;try{d(c)}catch(W){Lr(W)}c.currentTarget=null,d=_}}}}function Le(e,t){var s=t[_o];s===void 0&&(s=t[_o]=new Set);var i=e+"__bubble";s.has(i)||(B0(t,e,2,!1),s.add(i))}function ju(e,t,s){var i=0;t&&(i|=4),B0(s,e,i,t)}var Ni="_reactListening"+Math.random().toString(36).slice(2);function Nu(e){if(!e[Ni]){e[Ni]=!0,Mf.forEach(function(s){s!=="selectionchange"&&(Fb.has(s)||ju(s,!1,e),ju(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ni]||(t[Ni]=!0,ju("selectionchange",!1,t))}}function B0(e,t,s,i){switch(dp(t)){case 2:var c=by;break;case 8:c=yy;break;default:c=zu}s=c.bind(null,t,s,e),c=void 0,!Go||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),i?c!==void 0?e.addEventListener(t,s,{capture:!0,passive:c}):e.addEventListener(t,s,!0):c!==void 0?e.addEventListener(t,s,{passive:c}):e.addEventListener(t,s,!1)}function wu(e,t,s,i,c){var d=i;if((t&1)===0&&(t&2)===0&&i!==null)e:for(;;){if(i===null)return;var y=i.tag;if(y===3||y===4){var A=i.stateNode.containerInfo;if(A===c)break;if(y===4)for(y=i.return;y!==null;){var _=y.tag;if((_===3||_===4)&&y.stateNode.containerInfo===c)return;y=y.return}for(;A!==null;){if(y=la(A),y===null)return;if(_=y.tag,_===5||_===6||_===26||_===27){i=d=y;continue e}A=A.parentNode}}i=i.return}Vf(function(){var Y=d,W=Vo(s),ne=[];e:{var X=pm.get(e);if(X!==void 0){var P=_r,ve=e;switch(e){case"keypress":if(qr(s)===0)break e;case"keydown":case"keyup":P=zv;break;case"focusin":ve="focus",P=Xo;break;case"focusout":ve="blur",P=Xo;break;case"beforeblur":case"afterblur":P=Xo;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":P=Yf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":P=Cv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":P=Vv;break;case dm:case fm:case mm:P=Mv;break;case hm:P=Gv;break;case"scroll":case"scrollend":P=wv;break;case"wheel":P=Fv;break;case"copy":case"cut":case"paste":P=Tv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":P=If;break;case"toggle":case"beforetoggle":P=Xv}var ke=(t&4)!==0,We=!ke&&(e==="scroll"||e==="scrollend"),H=ke?X!==null?X+"Capture":null:X;ke=[];for(var z=Y,G;z!==null;){var ee=z;if(G=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||G===null||H===null||(ee=cl(z,H),ee!=null&&ke.push($l(z,ee,G))),We)break;z=z.return}0<ke.length&&(X=new P(X,ve,null,s,W),ne.push({event:X,listeners:ke}))}}if((t&7)===0){e:{if(X=e==="mouseover"||e==="pointerover",P=e==="mouseout"||e==="pointerout",X&&s!==Ho&&(ve=s.relatedTarget||s.fromElement)&&(la(ve)||ve[aa]))break e;if((P||X)&&(X=W.window===W?W:(X=W.ownerDocument)?X.defaultView||X.parentWindow:window,P?(ve=s.relatedTarget||s.toElement,P=Y,ve=ve?la(ve):null,ve!==null&&(We=f(ve),ke=ve.tag,ve!==We||ke!==5&&ke!==27&&ke!==6)&&(ve=null)):(P=null,ve=Y),P!==ve)){if(ke=Yf,ee="onMouseLeave",H="onMouseEnter",z="mouse",(e==="pointerout"||e==="pointerover")&&(ke=If,ee="onPointerLeave",H="onPointerEnter",z="pointer"),We=P==null?X:ol(P),G=ve==null?X:ol(ve),X=new ke(ee,z+"leave",P,s,W),X.target=We,X.relatedTarget=G,ee=null,la(W)===Y&&(ke=new ke(H,z+"enter",ve,s,W),ke.target=G,ke.relatedTarget=We,ee=ke),We=ee,P&&ve)t:{for(ke=Ib,H=P,z=ve,G=0,ee=H;ee;ee=ke(ee))G++;ee=0;for(var Ne=z;Ne;Ne=ke(Ne))ee++;for(;0<G-ee;)H=ke(H),G--;for(;0<ee-G;)z=ke(z),ee--;for(;G--;){if(H===z||z!==null&&H===z.alternate){ke=H;break t}H=ke(H),z=ke(z)}ke=null}else ke=null;P!==null&&L0(ne,X,P,ke,!1),ve!==null&&We!==null&&L0(ne,We,ve,ke,!0)}}e:{if(X=Y?ol(Y):window,P=X.nodeName&&X.nodeName.toLowerCase(),P==="select"||P==="input"&&X.type==="file")var Ye=em;else if(Pf(X))if(tm)Ye=sb;else{Ye=tb;var be=eb}else P=X.nodeName,!P||P.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?Y&&Uo(Y.elementType)&&(Ye=em):Ye=nb;if(Ye&&(Ye=Ye(e,Y))){Wf(ne,Ye,s,W);break e}be&&be(e,X,Y),e==="focusout"&&Y&&X.type==="number"&&Y.memoizedProps.value!=null&&zo(X,"number",X.value)}switch(be=Y?ol(Y):window,e){case"focusin":(Pf(be)||be.contentEditable==="true")&&(ha=be,Wo=Y,gl=null);break;case"focusout":gl=Wo=ha=null;break;case"mousedown":ec=!0;break;case"contextmenu":case"mouseup":case"dragend":ec=!1,cm(ne,s,W);break;case"selectionchange":if(lb)break;case"keydown":case"keyup":cm(ne,s,W)}var De;if(Ko)e:{switch(e){case"compositionstart":var He="onCompositionStart";break e;case"compositionend":He="onCompositionEnd";break e;case"compositionupdate":He="onCompositionUpdate";break e}He=void 0}else ma?Zf(e,s)&&(He="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(He="onCompositionStart");He&&(Xf&&s.locale!=="ko"&&(ma||He!=="onCompositionStart"?He==="onCompositionEnd"&&ma&&(De=$f()):(ls=W,Yo="value"in ls?ls.value:ls.textContent,ma=!0)),be=wi(Y,He),0<be.length&&(He=new Ff(He,e,null,s,W),ne.push({event:He,listeners:be}),De?He.data=De:(De=Jf(s),De!==null&&(He.data=De)))),(De=Kv?Zv(e,s):Jv(e,s))&&(He=wi(Y,"onBeforeInput"),0<He.length&&(be=new Ff("onBeforeInput","beforeinput",null,s,W),ne.push({event:be,listeners:He}),be.data=De)),$b(ne,e,Y,s,W)}O0(ne,t)})}function $l(e,t,s){return{instance:e,listener:t,currentTarget:s}}function wi(e,t){for(var s=t+"Capture",i=[];e!==null;){var c=e,d=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||d===null||(c=cl(e,s),c!=null&&i.unshift($l(e,c,d)),c=cl(e,t),c!=null&&i.push($l(e,c,d))),e.tag===3)return i;e=e.return}return[]}function Ib(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function L0(e,t,s,i,c){for(var d=t._reactName,y=[];s!==null&&s!==i;){var A=s,_=A.alternate,Y=A.stateNode;if(A=A.tag,_!==null&&_===i)break;A!==5&&A!==26&&A!==27||Y===null||(_=Y,c?(Y=cl(s,d),Y!=null&&y.unshift($l(s,Y,_))):c||(Y=cl(s,d),Y!=null&&y.push($l(s,Y,_)))),s=s.return}y.length!==0&&e.push({event:t,listeners:y})}var Xb=/\r\n?/g,Qb=/\u0000|\uFFFD/g;function z0(e){return(typeof e=="string"?e:""+e).replace(Xb,`
|
||
`).replace(Qb,"")}function U0(e,t){return t=z0(t),z0(e)===t}function Pe(e,t,s,i,c,d){switch(s){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||ua(e,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&ua(e,""+i);break;case"className":Er(e,"class",i);break;case"tabIndex":Er(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Er(e,s,i);break;case"style":Uf(e,i,d);break;case"data":if(t!=="object"){Er(e,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(s);break}i=Rr(""+i),e.setAttribute(s,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(s,"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 d=="function"&&(s==="formAction"?(t!=="input"&&Pe(e,t,"name",c.name,c,null),Pe(e,t,"formEncType",c.formEncType,c,null),Pe(e,t,"formMethod",c.formMethod,c,null),Pe(e,t,"formTarget",c.formTarget,c,null)):(Pe(e,t,"encType",c.encType,c,null),Pe(e,t,"method",c.method,c,null),Pe(e,t,"target",c.target,c,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(s);break}i=Rr(""+i),e.setAttribute(s,i);break;case"onClick":i!=null&&(e.onclick=Dn);break;case"onScroll":i!=null&&Le("scroll",e);break;case"onScrollEnd":i!=null&&Le("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(s=i.__html,s!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=s}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}s=Rr(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,""+i):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":i===!0?e.setAttribute(s,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,i):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(s,i):e.removeAttribute(s);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(s):e.setAttribute(s,i);break;case"popover":Le("beforetoggle",e),Le("toggle",e),kr(e,"popover",i);break;case"xlinkActuate":qn(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":qn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":qn(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":qn(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":qn(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":qn(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":qn(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":qn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":qn(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":kr(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=jv.get(s)||s,kr(e,s,i))}}function Au(e,t,s,i,c,d){switch(s){case"style":Uf(e,i,d);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(s=i.__html,s!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=s}}break;case"children":typeof i=="string"?ua(e,i):(typeof i=="number"||typeof i=="bigint")&&ua(e,""+i);break;case"onScroll":i!=null&&Le("scroll",e);break;case"onScrollEnd":i!=null&&Le("scrollend",e);break;case"onClick":i!=null&&(e.onclick=Dn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Rf.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(c=s.endsWith("Capture"),t=s.slice(2,c?s.length-7:void 0),d=e[Bt]||null,d=d!=null?d[s]:null,typeof d=="function"&&e.removeEventListener(t,d,c),typeof i=="function")){typeof d!="function"&&d!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,i,c);break e}s in e?e[s]=i:i===!0?e.setAttribute(s,""):kr(e,s,i)}}}function Rt(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Le("error",e),Le("load",e);var i=!1,c=!1,d;for(d in s)if(s.hasOwnProperty(d)){var y=s[d];if(y!=null)switch(d){case"src":i=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Pe(e,t,d,y,s,null)}}c&&Pe(e,t,"srcSet",s.srcSet,s,null),i&&Pe(e,t,"src",s.src,s,null);return;case"input":Le("invalid",e);var A=d=y=c=null,_=null,Y=null;for(i in s)if(s.hasOwnProperty(i)){var W=s[i];if(W!=null)switch(i){case"name":c=W;break;case"type":y=W;break;case"checked":_=W;break;case"defaultChecked":Y=W;break;case"value":d=W;break;case"defaultValue":A=W;break;case"children":case"dangerouslySetInnerHTML":if(W!=null)throw Error(o(137,t));break;default:Pe(e,t,i,W,s,null)}}Of(e,d,A,_,Y,y,c,!1);return;case"select":Le("invalid",e),i=y=d=null;for(c in s)if(s.hasOwnProperty(c)&&(A=s[c],A!=null))switch(c){case"value":d=A;break;case"defaultValue":y=A;break;case"multiple":i=A;default:Pe(e,t,c,A,s,null)}t=d,s=y,e.multiple=!!i,t!=null?ca(e,!!i,t,!1):s!=null&&ca(e,!!i,s,!0);return;case"textarea":Le("invalid",e),d=c=i=null;for(y in s)if(s.hasOwnProperty(y)&&(A=s[y],A!=null))switch(y){case"value":i=A;break;case"defaultValue":c=A;break;case"children":d=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(o(91));break;default:Pe(e,t,y,A,s,null)}Lf(e,i,c,d);return;case"option":for(_ in s)if(s.hasOwnProperty(_)&&(i=s[_],i!=null))switch(_){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Pe(e,t,_,i,s,null)}return;case"dialog":Le("beforetoggle",e),Le("toggle",e),Le("cancel",e),Le("close",e);break;case"iframe":case"object":Le("load",e);break;case"video":case"audio":for(i=0;i<Vl.length;i++)Le(Vl[i],e);break;case"image":Le("error",e),Le("load",e);break;case"details":Le("toggle",e);break;case"embed":case"source":case"link":Le("error",e),Le("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(Y in s)if(s.hasOwnProperty(Y)&&(i=s[Y],i!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Pe(e,t,Y,i,s,null)}return;default:if(Uo(t)){for(W in s)s.hasOwnProperty(W)&&(i=s[W],i!==void 0&&Au(e,t,W,i,s,void 0));return}}for(A in s)s.hasOwnProperty(A)&&(i=s[A],i!=null&&Pe(e,t,A,i,s,null))}function Kb(e,t,s,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,d=null,y=null,A=null,_=null,Y=null,W=null;for(P in s){var ne=s[P];if(s.hasOwnProperty(P)&&ne!=null)switch(P){case"checked":break;case"value":break;case"defaultValue":_=ne;default:i.hasOwnProperty(P)||Pe(e,t,P,null,i,ne)}}for(var X in i){var P=i[X];if(ne=s[X],i.hasOwnProperty(X)&&(P!=null||ne!=null))switch(X){case"type":d=P;break;case"name":c=P;break;case"checked":Y=P;break;case"defaultChecked":W=P;break;case"value":y=P;break;case"defaultValue":A=P;break;case"children":case"dangerouslySetInnerHTML":if(P!=null)throw Error(o(137,t));break;default:P!==ne&&Pe(e,t,X,P,i,ne)}}Lo(e,y,A,_,Y,W,d,c);return;case"select":P=y=A=X=null;for(d in s)if(_=s[d],s.hasOwnProperty(d)&&_!=null)switch(d){case"value":break;case"multiple":P=_;default:i.hasOwnProperty(d)||Pe(e,t,d,null,i,_)}for(c in i)if(d=i[c],_=s[c],i.hasOwnProperty(c)&&(d!=null||_!=null))switch(c){case"value":X=d;break;case"defaultValue":A=d;break;case"multiple":y=d;default:d!==_&&Pe(e,t,c,d,i,_)}t=A,s=y,i=P,X!=null?ca(e,!!s,X,!1):!!i!=!!s&&(t!=null?ca(e,!!s,t,!0):ca(e,!!s,s?[]:"",!1));return;case"textarea":P=X=null;for(A in s)if(c=s[A],s.hasOwnProperty(A)&&c!=null&&!i.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:Pe(e,t,A,null,i,c)}for(y in i)if(c=i[y],d=s[y],i.hasOwnProperty(y)&&(c!=null||d!=null))switch(y){case"value":X=c;break;case"defaultValue":P=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==d&&Pe(e,t,y,c,i,d)}Bf(e,X,P);return;case"option":for(var ve in s)if(X=s[ve],s.hasOwnProperty(ve)&&X!=null&&!i.hasOwnProperty(ve))switch(ve){case"selected":e.selected=!1;break;default:Pe(e,t,ve,null,i,X)}for(_ in i)if(X=i[_],P=s[_],i.hasOwnProperty(_)&&X!==P&&(X!=null||P!=null))switch(_){case"selected":e.selected=X&&typeof X!="function"&&typeof X!="symbol";break;default:Pe(e,t,_,X,i,P)}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 ke in s)X=s[ke],s.hasOwnProperty(ke)&&X!=null&&!i.hasOwnProperty(ke)&&Pe(e,t,ke,null,i,X);for(Y in i)if(X=i[Y],P=s[Y],i.hasOwnProperty(Y)&&X!==P&&(X!=null||P!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(o(137,t));break;default:Pe(e,t,Y,X,i,P)}return;default:if(Uo(t)){for(var We in s)X=s[We],s.hasOwnProperty(We)&&X!==void 0&&!i.hasOwnProperty(We)&&Au(e,t,We,void 0,i,X);for(W in i)X=i[W],P=s[W],!i.hasOwnProperty(W)||X===P||X===void 0&&P===void 0||Au(e,t,W,X,i,P);return}}for(var H in s)X=s[H],s.hasOwnProperty(H)&&X!=null&&!i.hasOwnProperty(H)&&Pe(e,t,H,null,i,X);for(ne in i)X=i[ne],P=s[ne],!i.hasOwnProperty(ne)||X===P||X==null&&P==null||Pe(e,t,ne,X,i,P)}function H0(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Zb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),i=0;i<s.length;i++){var c=s[i],d=c.transferSize,y=c.initiatorType,A=c.duration;if(d&&A&&H0(y)){for(y=0,A=c.responseEnd,i+=1;i<s.length;i++){var _=s[i],Y=_.startTime;if(Y>A)break;var W=_.transferSize,ne=_.initiatorType;W&&H0(ne)&&(_=_.responseEnd,y+=W*(_<A?1:(A-Y)/(_-Y)))}if(--i,t+=8*(d+y)/(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 Cu=null,ku=null;function Ai(e){return e.nodeType===9?e:e.ownerDocument}function V0(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 $0(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 Eu(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 Mu=null;function Jb(){var e=window.event;return e&&e.type==="popstate"?e===Mu?!1:(Mu=e,!0):(Mu=null,!1)}var G0=typeof setTimeout=="function"?setTimeout:void 0,Pb=typeof clearTimeout=="function"?clearTimeout:void 0,Y0=typeof Promise=="function"?Promise:void 0,Wb=typeof queueMicrotask=="function"?queueMicrotask:typeof Y0<"u"?function(e){return Y0.resolve(null).then(e).catch(ey)}:G0;function ey(e){setTimeout(function(){throw e})}function js(e){return e==="head"}function F0(e,t){var s=t,i=0;do{var c=s.nextSibling;if(e.removeChild(s),c&&c.nodeType===8)if(s=c.data,s==="/$"||s==="/&"){if(i===0){e.removeChild(c),Va(t);return}i--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")i++;else if(s==="html")Gl(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,Gl(s);for(var d=s.firstChild;d;){var y=d.nextSibling,A=d.nodeName;d[il]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&d.rel.toLowerCase()==="stylesheet"||s.removeChild(d),d=y}}else s==="body"&&Gl(e.ownerDocument.body);s=c}while(s);Va(t)}function I0(e,t){var s=e;e=0;do{var i=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),i&&i.nodeType===8)if(s=i.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=i}while(s)}function Ru(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":Ru(s),Oo(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function ty(e,t,s,i){for(;e.nodeType===1;){var c=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[il])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(d=e.getAttribute("rel"),d==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(d!==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(d=e.getAttribute("src"),(d!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&d&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var d=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===d)return e}else return e;if(e=fn(e.nextSibling),e===null)break}return null}function ny(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=fn(e.nextSibling),e===null))return null;return e}function X0(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=fn(e.nextSibling),e===null))return null;return e}function Tu(e){return e.data==="$?"||e.data==="$~"}function qu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function sy(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var i=function(){t(),s.removeEventListener("DOMContentLoaded",i)};s.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function fn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Du=null;function Q0(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return fn(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function K0(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function Z0(e,t,s){switch(t=Ai(s),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 Gl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Oo(e)}var mn=new Map,J0=new Set;function Ci(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Kn=V.d;V.d={f:ay,r:ly,D:ry,C:iy,L:oy,m:cy,X:dy,S:uy,M:fy};function ay(){var e=Kn.f(),t=gi();return e||t}function ly(e){var t=ra(e);t!==null&&t.tag===5&&t.type==="form"?hh(t):Kn.r(e)}var za=typeof document>"u"?null:document;function P0(e,t,s){var i=za;if(i&&typeof t=="string"&&t){var c=an(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof s=="string"&&(c+='[crossorigin="'+s+'"]'),J0.has(c)||(J0.add(c),e={rel:e,crossOrigin:s,href:t},i.querySelector(c)===null&&(t=i.createElement("link"),Rt(t,"link",e),wt(t),i.head.appendChild(t)))}}function ry(e){Kn.D(e),P0("dns-prefetch",e,null)}function iy(e,t){Kn.C(e,t),P0("preconnect",e,t)}function oy(e,t,s){Kn.L(e,t,s);var i=za;if(i&&e&&t){var c='link[rel="preload"][as="'+an(t)+'"]';t==="image"&&s&&s.imageSrcSet?(c+='[imagesrcset="'+an(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(c+='[imagesizes="'+an(s.imageSizes)+'"]')):c+='[href="'+an(e)+'"]';var d=c;switch(t){case"style":d=Ua(e);break;case"script":d=Ha(e)}mn.has(d)||(e=b({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),mn.set(d,e),i.querySelector(c)!==null||t==="style"&&i.querySelector(Yl(d))||t==="script"&&i.querySelector(Fl(d))||(t=i.createElement("link"),Rt(t,"link",e),wt(t),i.head.appendChild(t)))}}function cy(e,t){Kn.m(e,t);var s=za;if(s&&e){var i=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+an(i)+'"][href="'+an(e)+'"]',d=c;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=Ha(e)}if(!mn.has(d)&&(e=b({rel:"modulepreload",href:e},t),mn.set(d,e),s.querySelector(c)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Fl(d)))return}i=s.createElement("link"),Rt(i,"link",e),wt(i),s.head.appendChild(i)}}}function uy(e,t,s){Kn.S(e,t,s);var i=za;if(i&&e){var c=ia(i).hoistableStyles,d=Ua(e);t=t||"default";var y=c.get(d);if(!y){var A={loading:0,preload:null};if(y=i.querySelector(Yl(d)))A.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},s),(s=mn.get(d))&&_u(e,s);var _=y=i.createElement("link");wt(_),Rt(_,"link",e),_._p=new Promise(function(Y,W){_.onload=Y,_.onerror=W}),_.addEventListener("load",function(){A.loading|=1}),_.addEventListener("error",function(){A.loading|=2}),A.loading|=4,ki(y,t,i)}y={type:"stylesheet",instance:y,count:1,state:A},c.set(d,y)}}}function dy(e,t){Kn.X(e,t);var s=za;if(s&&e){var i=ia(s).hoistableScripts,c=Ha(e),d=i.get(c);d||(d=s.querySelector(Fl(c)),d||(e=b({src:e,async:!0},t),(t=mn.get(c))&&Ou(e,t),d=s.createElement("script"),wt(d),Rt(d,"link",e),s.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function fy(e,t){Kn.M(e,t);var s=za;if(s&&e){var i=ia(s).hoistableScripts,c=Ha(e),d=i.get(c);d||(d=s.querySelector(Fl(c)),d||(e=b({src:e,async:!0,type:"module"},t),(t=mn.get(c))&&Ou(e,t),d=s.createElement("script"),wt(d),Rt(d,"link",e),s.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function W0(e,t,s,i){var c=(c=we.current)?Ci(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=Ua(s.href),s=ia(c).hoistableStyles,i=s.get(t),i||(i={type:"style",instance:null,count:0,state:null},s.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=Ua(s.href);var d=ia(c).hoistableStyles,y=d.get(e);if(y||(c=c.ownerDocument||c,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(e,y),(d=c.querySelector(Yl(e)))&&!d._p&&(y.instance=d,y.state.loading=5),mn.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},mn.set(e,s),d||my(c,e,s,y.state))),t&&i===null)throw Error(o(528,""));return y}if(t&&i!==null)throw Error(o(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ha(s),s=ia(c).hoistableScripts,i=s.get(t),i||(i={type:"script",instance:null,count:0,state:null},s.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Ua(e){return'href="'+an(e)+'"'}function Yl(e){return'link[rel="stylesheet"]['+e+"]"}function ep(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function my(e,t,s,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Rt(t,"link",s),wt(t),e.head.appendChild(t))}function Ha(e){return'[src="'+an(e)+'"]'}function Fl(e){return"script[async]"+e}function tp(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+an(s.href)+'"]');if(i)return t.instance=i,wt(i),i;var c=b({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),wt(i),Rt(i,"style",c),ki(i,s.precedence,e),t.instance=i;case"stylesheet":c=Ua(s.href);var d=e.querySelector(Yl(c));if(d)return t.state.loading|=4,t.instance=d,wt(d),d;i=ep(s),(c=mn.get(c))&&_u(i,c),d=(e.ownerDocument||e).createElement("link"),wt(d);var y=d;return y._p=new Promise(function(A,_){y.onload=A,y.onerror=_}),Rt(d,"link",i),t.state.loading|=4,ki(d,s.precedence,e),t.instance=d;case"script":return d=Ha(s.src),(c=e.querySelector(Fl(d)))?(t.instance=c,wt(c),c):(i=s,(c=mn.get(d))&&(i=b({},s),Ou(i,c)),e=e.ownerDocument||e,c=e.createElement("script"),wt(c),Rt(c,"link",i),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(i=t.instance,t.state.loading|=4,ki(i,s.precedence,e));return t.instance}function ki(e,t,s){for(var i=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=i.length?i[i.length-1]:null,d=c,y=0;y<i.length;y++){var A=i[y];if(A.dataset.precedence===t)d=A;else if(d!==c)break}d?d.parentNode.insertBefore(e,d.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function _u(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Ou(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Ei=null;function np(e,t,s){if(Ei===null){var i=new Map,c=Ei=new Map;c.set(s,i)}else c=Ei,i=c.get(s),i||(i=new Map,c.set(s,i));if(i.has(e))return i;for(i.set(e,null),s=s.getElementsByTagName(e),c=0;c<s.length;c++){var d=s[c];if(!(d[il]||d[Ct]||e==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var y=d.getAttribute(t)||"";y=e+y;var A=i.get(y);A?A.push(d):i.set(y,[d])}}return i}function sp(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function hy(e,t,s){if(s===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 ap(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function py(e,t,s,i){if(s.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var c=Ua(i.href),d=t.querySelector(Yl(c));if(d){t=d._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Mi.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=d,wt(d);return}d=t.ownerDocument||t,i=ep(i),(c=mn.get(c))&&_u(i,c),d=d.createElement("link"),wt(d);var y=d;y._p=new Promise(function(A,_){y.onload=A,y.onerror=_}),Rt(d,"link",i),s.instance=d}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=Mi.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var Bu=0;function xy(e,t){return e.stylesheets&&e.count===0&&Ti(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var i=setTimeout(function(){if(e.stylesheets&&Ti(e,e.stylesheets),e.unsuspend){var d=e.unsuspend;e.unsuspend=null,d()}},6e4+t);0<e.imgBytes&&Bu===0&&(Bu=62500*Zb());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ti(e,e.stylesheets),e.unsuspend)){var d=e.unsuspend;e.unsuspend=null,d()}},(e.imgBytes>Bu?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(c)}}:null}function Mi(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ti(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Ri=null;function Ti(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Ri=new Map,t.forEach(gy,e),Ri=null,Mi.call(e))}function gy(e,t){if(!(t.state.loading&4)){var s=Ri.get(e);if(s)var i=s.get(null);else{s=new Map,Ri.set(e,s);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<c.length;d++){var y=c[d];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(s.set(y.dataset.precedence,y),i=y)}i&&s.set(null,i)}c=t.instance,y=c.getAttribute("data-precedence"),d=s.get(y)||i,d===i&&s.set(null,c),s.set(y,c),this.count++,i=Mi.bind(this),c.addEventListener("load",i),c.addEventListener("error",i),d?d.parentNode.insertBefore(c,d.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Il={$$typeof:k,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function vy(e,t,s,i,c,d,y,A,_){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=To(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=To(0),this.hiddenUpdates=To(null),this.identifierPrefix=i,this.onUncaughtError=c,this.onCaughtError=d,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=_,this.incompleteTransitions=new Map}function lp(e,t,s,i,c,d,y,A,_,Y,W,ne){return e=new vy(e,t,s,y,_,Y,W,ne,A),t=1,d===!0&&(t|=24),d=Yt(3,null,null,t),e.current=d,d.stateNode=e,t=pc(),t.refCount++,e.pooledCache=t,t.refCount++,d.memoizedState={element:i,isDehydrated:s,cache:t},bc(d),e}function rp(e){return e?(e=ga,e):ga}function ip(e,t,s,i,c,d){c=rp(c),i.context===null?i.context=c:i.pendingContext=c,i=ds(t),i.payload={element:s},d=d===void 0?null:d,d!==null&&(i.callback=d),s=fs(e,i,t),s!==null&&($t(s,e,t),wl(s,e,t))}function op(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Lu(e,t){op(e,t),(e=e.alternate)&&op(e,t)}function cp(e){if(e.tag===13||e.tag===31){var t=Bs(e,67108864);t!==null&&$t(t,e,67108864),Lu(e,67108864)}}function up(e){if(e.tag===13||e.tag===31){var t=Kt();t=qo(t);var s=Bs(e,t);s!==null&&$t(s,e,t),Lu(e,t)}}var qi=!0;function by(e,t,s,i){var c=B.T;B.T=null;var d=V.p;try{V.p=2,zu(e,t,s,i)}finally{V.p=d,B.T=c}}function yy(e,t,s,i){var c=B.T;B.T=null;var d=V.p;try{V.p=8,zu(e,t,s,i)}finally{V.p=d,B.T=c}}function zu(e,t,s,i){if(qi){var c=Uu(i);if(c===null)wu(e,t,i,Di,s),fp(e,i);else if(jy(c,e,t,s,i))i.stopPropagation();else if(fp(e,i),t&4&&-1<Sy.indexOf(e)){for(;c!==null;){var d=ra(c);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var y=Ts(d.pendingLanes);if(y!==0){var A=d;for(A.pendingLanes|=2,A.entangledLanes|=2;y;){var _=1<<31-rt(y);A.entanglements[1]|=_,y&=~_}kn(d),(Ie&6)===0&&(pi=te()+500,Hl(0))}}break;case 31:case 13:A=Bs(d,2),A!==null&&$t(A,d,2),gi(),Lu(d,2)}if(d=Uu(i),d===null&&wu(e,t,i,Di,s),d===c)break;c=d}c!==null&&i.stopPropagation()}else wu(e,t,i,null,s)}}function Uu(e){return e=Vo(e),Hu(e)}var Di=null;function Hu(e){if(Di=null,e=la(e),e!==null){var t=f(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=p(t),e!==null)return e;e=null}else if(s===31){if(e=h(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Di=e,null}function dp(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(me()){case _e:return 2;case en:return 8;case tn:case nn:return 32;case Nt:return 268435456;default:return 32}default:return 32}}var Vu=!1,Ns=null,ws=null,As=null,Xl=new Map,Ql=new Map,Cs=[],Sy="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 fp(e,t){switch(e){case"focusin":case"focusout":Ns=null;break;case"dragenter":case"dragleave":ws=null;break;case"mouseover":case"mouseout":As=null;break;case"pointerover":case"pointerout":Xl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ql.delete(t.pointerId)}}function Kl(e,t,s,i,c,d){return e===null||e.nativeEvent!==d?(e={blockedOn:t,domEventName:s,eventSystemFlags:i,nativeEvent:d,targetContainers:[c]},t!==null&&(t=ra(t),t!==null&&cp(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function jy(e,t,s,i,c){switch(t){case"focusin":return Ns=Kl(Ns,e,t,s,i,c),!0;case"dragenter":return ws=Kl(ws,e,t,s,i,c),!0;case"mouseover":return As=Kl(As,e,t,s,i,c),!0;case"pointerover":var d=c.pointerId;return Xl.set(d,Kl(Xl.get(d)||null,e,t,s,i,c)),!0;case"gotpointercapture":return d=c.pointerId,Ql.set(d,Kl(Ql.get(d)||null,e,t,s,i,c)),!0}return!1}function mp(e){var t=la(e.target);if(t!==null){var s=f(t);if(s!==null){if(t=s.tag,t===13){if(t=p(s),t!==null){e.blockedOn=t,kf(e.priority,function(){up(s)});return}}else if(t===31){if(t=h(s),t!==null){e.blockedOn=t,kf(e.priority,function(){up(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function _i(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=Uu(e.nativeEvent);if(s===null){s=e.nativeEvent;var i=new s.constructor(s.type,s);Ho=i,s.target.dispatchEvent(i),Ho=null}else return t=ra(s),t!==null&&cp(t),e.blockedOn=s,!1;t.shift()}return!0}function hp(e,t,s){_i(e)&&s.delete(t)}function Ny(){Vu=!1,Ns!==null&&_i(Ns)&&(Ns=null),ws!==null&&_i(ws)&&(ws=null),As!==null&&_i(As)&&(As=null),Xl.forEach(hp),Ql.forEach(hp)}function Oi(e,t){e.blockedOn===t&&(e.blockedOn=null,Vu||(Vu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Ny)))}var Bi=null;function pp(e){Bi!==e&&(Bi=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Bi===e&&(Bi=null);for(var t=0;t<e.length;t+=3){var s=e[t],i=e[t+1],c=e[t+2];if(typeof i!="function"){if(Hu(i||s)===null)continue;break}var d=ra(s);d!==null&&(e.splice(t,3),t-=3,Uc(d,{pending:!0,data:c,method:s.method,action:i},i,c))}}))}function Va(e){function t(_){return Oi(_,e)}Ns!==null&&Oi(Ns,e),ws!==null&&Oi(ws,e),As!==null&&Oi(As,e),Xl.forEach(t),Ql.forEach(t);for(var s=0;s<Cs.length;s++){var i=Cs[s];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Cs.length&&(s=Cs[0],s.blockedOn===null);)mp(s),s.blockedOn===null&&Cs.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(i=0;i<s.length;i+=3){var c=s[i],d=s[i+1],y=c[Bt]||null;if(typeof d=="function")y||pp(s);else if(y){var A=null;if(d&&d.hasAttribute("formAction")){if(c=d,y=d[Bt]||null)A=y.formAction;else if(Hu(c)!==null)continue}else A=y.action;typeof A=="function"?s[i+1]=A:(s.splice(i,3),i-=3),pp(s)}}}function xp(){function e(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(y){return c=y})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),i||setTimeout(s,20)}function s(){if(!i&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function $u(e){this._internalRoot=e}Li.prototype.render=$u.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var s=t.current,i=Kt();ip(s,i,e,t,null,null)},Li.prototype.unmount=$u.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ip(e.current,2,null,e,null,null),gi(),t[aa]=null}};function Li(e){this._internalRoot=e}Li.prototype.unstable_scheduleHydration=function(e){if(e){var t=Cf();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Cs.length&&t!==0&&t<Cs[s].priority;s++);Cs.splice(s,0,e),s===0&&mp(e)}};var gp=a.version;if(gp!=="19.2.0")throw Error(o(527,gp,"19.2.0"));V.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=x(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var wy={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zi.isDisabled&&zi.supportsFiber)try{Xe=zi.inject(wy),Ee=zi}catch{}}return Jl.createRoot=function(e,t){if(!u(e))throw Error(o(299));var s=!1,i="",c=wh,d=Ah,y=Ch;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(d=t.onCaughtError),t.onRecoverableError!==void 0&&(y=t.onRecoverableError)),t=lp(e,1,!1,null,null,s,i,null,c,d,y,xp),e[aa]=t.current,Nu(e),new $u(t)},Jl.hydrateRoot=function(e,t,s){if(!u(e))throw Error(o(299));var i=!1,c="",d=wh,y=Ah,A=Ch,_=null;return s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(y=s.onCaughtError),s.onRecoverableError!==void 0&&(A=s.onRecoverableError),s.formState!==void 0&&(_=s.formState)),t=lp(e,1,!0,t,s??null,i,c,_,d,y,A,xp),t.context=rp(null),s=t.current,i=Kt(),i=qo(i),c=ds(i),c.callback=null,fs(s,c,i),s=i,t.current.lanes=s,rl(t,s),kn(t),e[aa]=t.current,Nu(e),new Li(t)},Jl.version="19.2.0",Jl}var kp;function Oy(){if(kp)return Fu.exports;kp=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(a){console.error(a)}}return n(),Fu.exports=_y(),Fu.exports}var By=Oy();var Ep="popstate";function Ly(n={}){function a(o,u){let{pathname:f,search:p,hash:h}=o.location;return yd("",{pathname:f,search:p,hash:h},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function r(o,u){return typeof u=="string"?u:cr(u)}return Uy(a,r,null,n)}function ot(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function jn(n,a){if(!n){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function zy(){return Math.random().toString(36).substring(2,10)}function Mp(n,a){return{usr:n.state,key:n.key,idx:a}}function yd(n,a,r=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof a=="string"?tl(a):a,state:r,key:a&&a.key||o||zy()}}function cr({pathname:n="/",search:a="",hash:r=""}){return a&&a!=="?"&&(n+=a.charAt(0)==="?"?a:"?"+a),r&&r!=="#"&&(n+=r.charAt(0)==="#"?r:"#"+r),n}function tl(n){let a={};if(n){let r=n.indexOf("#");r>=0&&(a.hash=n.substring(r),n=n.substring(0,r));let o=n.indexOf("?");o>=0&&(a.search=n.substring(o),n=n.substring(0,o)),n&&(a.pathname=n)}return a}function Uy(n,a,r,o={}){let{window:u=document.defaultView,v5Compat:f=!1}=o,p=u.history,h="POP",g=null,x=v();x==null&&(x=0,p.replaceState({...p.state,idx:x},""));function v(){return(p.state||{idx:null}).idx}function b(){h="POP";let w=v(),j=w==null?null:w-x;x=w,g&&g({action:h,location:N.location,delta:j})}function S(w,j){h="PUSH";let R=yd(N.location,w,j);x=v()+1;let k=Mp(R,x),T=N.createHref(R);try{p.pushState(k,"",T)}catch(q){if(q instanceof DOMException&&q.name==="DataCloneError")throw q;u.location.assign(T)}f&&g&&g({action:h,location:N.location,delta:1})}function C(w,j){h="REPLACE";let R=yd(N.location,w,j);x=v();let k=Mp(R,x),T=N.createHref(R);p.replaceState(k,"",T),f&&g&&g({action:h,location:N.location,delta:0})}function E(w){return Hy(w)}let N={get action(){return h},get location(){return n(u,p)},listen(w){if(g)throw new Error("A history only accepts one active listener");return u.addEventListener(Ep,b),g=w,()=>{u.removeEventListener(Ep,b),g=null}},createHref(w){return a(u,w)},createURL:E,encodeLocation(w){let j=E(w);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:S,replace:C,go(w){return p.go(w)}};return N}function Hy(n,a=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),ot(r,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:cr(n);return o=o.replace(/ $/,"%20"),!a&&o.startsWith("//")&&(o=r+o),new URL(o,r)}function Dx(n,a,r="/"){return Vy(n,a,r,!1)}function Vy(n,a,r,o){let u=typeof a=="string"?tl(a):a,f=ts(u.pathname||"/",r);if(f==null)return null;let p=_x(n);$y(p);let h=null;for(let g=0;h==null&&g<p.length;++g){let x=Wy(f);h=Jy(p[g],x,o)}return h}function _x(n,a=[],r=[],o="",u=!1){let f=(p,h,g=u,x)=>{let v={relativePath:x===void 0?p.path||"":x,caseSensitive:p.caseSensitive===!0,childrenIndex:h,route:p};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&g)return;ot(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let b=es([o,v.relativePath]),S=r.concat(v);p.children&&p.children.length>0&&(ot(p.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),_x(p.children,a,S,b,g)),!(p.path==null&&!p.index)&&a.push({path:b,score:Ky(b,p.index),routesMeta:S})};return n.forEach((p,h)=>{if(p.path===""||!p.path?.includes("?"))f(p,h);else for(let g of Ox(p.path))f(p,h,!0,g)}),a}function Ox(n){let a=n.split("/");if(a.length===0)return[];let[r,...o]=a,u=r.endsWith("?"),f=r.replace(/\?$/,"");if(o.length===0)return u?[f,""]:[f];let p=Ox(o.join("/")),h=[];return h.push(...p.map(g=>g===""?f:[f,g].join("/"))),u&&h.push(...p),h.map(g=>n.startsWith("/")&&g===""?"/":g)}function $y(n){n.sort((a,r)=>a.score!==r.score?r.score-a.score:Zy(a.routesMeta.map(o=>o.childrenIndex),r.routesMeta.map(o=>o.childrenIndex)))}var Gy=/^:[\w-]+$/,Yy=3,Fy=2,Iy=1,Xy=10,Qy=-2,Rp=n=>n==="*";function Ky(n,a){let r=n.split("/"),o=r.length;return r.some(Rp)&&(o+=Qy),a&&(o+=Fy),r.filter(u=>!Rp(u)).reduce((u,f)=>u+(Gy.test(f)?Yy:f===""?Iy:Xy),o)}function Zy(n,a){return n.length===a.length&&n.slice(0,-1).every((o,u)=>o===a[u])?n[n.length-1]-a[a.length-1]:0}function Jy(n,a,r=!1){let{routesMeta:o}=n,u={},f="/",p=[];for(let h=0;h<o.length;++h){let g=o[h],x=h===o.length-1,v=f==="/"?a:a.slice(f.length)||"/",b=io({path:g.relativePath,caseSensitive:g.caseSensitive,end:x},v),S=g.route;if(!b&&x&&r&&!o[o.length-1].route.index&&(b=io({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},v)),!b)return null;Object.assign(u,b.params),p.push({params:u,pathname:es([f,b.pathname]),pathnameBase:a1(es([f,b.pathnameBase])),route:S}),b.pathnameBase!=="/"&&(f=es([f,b.pathnameBase]))}return p}function io(n,a){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[r,o]=Py(n.path,n.caseSensitive,n.end),u=a.match(r);if(!u)return null;let f=u[0],p=f.replace(/(.)\/+$/,"$1"),h=u.slice(1);return{params:o.reduce((x,{paramName:v,isOptional:b},S)=>{if(v==="*"){let E=h[S]||"";p=f.slice(0,f.length-E.length).replace(/(.)\/+$/,"$1")}const C=h[S];return b&&!C?x[v]=void 0:x[v]=(C||"").replace(/%2F/g,"/"),x},{}),pathname:f,pathnameBase:p,pattern:n}}function Py(n,a=!1,r=!0){jn(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=[],u="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(p,h,g)=>(o.push({paramName:h,isOptional:g!=null}),g?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),u+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?u+="\\/*$":n!==""&&n!=="/"&&(u+="(?:(?=\\/|$))"),[new RegExp(u,a?void 0:"i"),o]}function Wy(n){try{return n.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return jn(!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 (${a}).`),n}}function ts(n,a){if(a==="/")return n;if(!n.toLowerCase().startsWith(a.toLowerCase()))return null;let r=a.endsWith("/")?a.length-1:a.length,o=n.charAt(r);return o&&o!=="/"?null:n.slice(r)||"/"}var e1=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,t1=n=>e1.test(n);function n1(n,a="/"){let{pathname:r,search:o="",hash:u=""}=typeof n=="string"?tl(n):n,f;if(r)if(t1(r))f=r;else{if(r.includes("//")){let p=r;r=r.replace(/\/\/+/g,"/"),jn(!1,`Pathnames cannot have embedded double slashes - normalizing ${p} -> ${r}`)}r.startsWith("/")?f=Tp(r.substring(1),"/"):f=Tp(r,a)}else f=a;return{pathname:f,search:l1(o),hash:r1(u)}}function Tp(n,a){let r=a.replace(/\/+$/,"").split("/");return n.split("/").forEach(u=>{u===".."?r.length>1&&r.pop():u!=="."&&r.push(u)}),r.length>1?r.join("/"):"/"}function Ku(n,a,r,o){return`Cannot include a '${n}' character in a manually specified \`to.${a}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function s1(n){return n.filter((a,r)=>r===0||a.route.path&&a.route.path.length>0)}function Bx(n){let a=s1(n);return a.map((r,o)=>o===a.length-1?r.pathname:r.pathnameBase)}function Lx(n,a,r,o=!1){let u;typeof n=="string"?u=tl(n):(u={...n},ot(!u.pathname||!u.pathname.includes("?"),Ku("?","pathname","search",u)),ot(!u.pathname||!u.pathname.includes("#"),Ku("#","pathname","hash",u)),ot(!u.search||!u.search.includes("#"),Ku("#","search","hash",u)));let f=n===""||u.pathname==="",p=f?"/":u.pathname,h;if(p==null)h=r;else{let b=a.length-1;if(!o&&p.startsWith("..")){let S=p.split("/");for(;S[0]==="..";)S.shift(),b-=1;u.pathname=S.join("/")}h=b>=0?a[b]:"/"}let g=n1(u,h),x=p&&p!=="/"&&p.endsWith("/"),v=(f||p===".")&&r.endsWith("/");return!g.pathname.endsWith("/")&&(x||v)&&(g.pathname+="/"),g}var es=n=>n.join("/").replace(/\/\/+/g,"/"),a1=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),l1=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,r1=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function i1(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 zx=["POST","PUT","PATCH","DELETE"];new Set(zx);var o1=["GET",...zx];new Set(o1);var nl=m.createContext(null);nl.displayName="DataRouter";var yo=m.createContext(null);yo.displayName="DataRouterState";m.createContext(!1);var Ux=m.createContext({isTransitioning:!1});Ux.displayName="ViewTransition";var c1=m.createContext(new Map);c1.displayName="Fetchers";var u1=m.createContext(null);u1.displayName="Await";var Tn=m.createContext(null);Tn.displayName="Navigation";var xr=m.createContext(null);xr.displayName="Location";var ss=m.createContext({outlet:null,matches:[],isDataRoute:!1});ss.displayName="Route";var Vd=m.createContext(null);Vd.displayName="RouteError";function d1(n,{relative:a}={}){ot(gr(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:o}=m.useContext(Tn),{hash:u,pathname:f,search:p}=vr(n,{relative:a}),h=f;return r!=="/"&&(h=f==="/"?r:es([r,f])),o.createHref({pathname:h,search:p,hash:u})}function gr(){return m.useContext(xr)!=null}function na(){return ot(gr(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(xr).location}var Hx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Vx(n){m.useContext(Tn).static||m.useLayoutEffect(n)}function f1(){let{isDataRoute:n}=m.useContext(ss);return n?A1():m1()}function m1(){ot(gr(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(nl),{basename:a,navigator:r}=m.useContext(Tn),{matches:o}=m.useContext(ss),{pathname:u}=na(),f=JSON.stringify(Bx(o)),p=m.useRef(!1);return Vx(()=>{p.current=!0}),m.useCallback((g,x={})=>{if(jn(p.current,Hx),!p.current)return;if(typeof g=="number"){r.go(g);return}let v=Lx(g,JSON.parse(f),u,x.relative==="path");n==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:es([a,v.pathname])),(x.replace?r.replace:r.push)(v,x.state,x)},[a,r,f,u,n])}m.createContext(null);function vr(n,{relative:a}={}){let{matches:r}=m.useContext(ss),{pathname:o}=na(),u=JSON.stringify(Bx(r));return m.useMemo(()=>Lx(n,JSON.parse(u),o,a==="path"),[n,u,o,a])}function h1(n,a){return $x(n,a)}function $x(n,a,r,o,u){ot(gr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:f}=m.useContext(Tn),{matches:p}=m.useContext(ss),h=p[p.length-1],g=h?h.params:{},x=h?h.pathname:"/",v=h?h.pathnameBase:"/",b=h&&h.route;{let R=b&&b.path||"";Gx(x,!b||R.endsWith("*")||R.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${x}" (under <Route path="${R}">) 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="${R}"> to <Route path="${R==="/"?"*":`${R}/*`}">.`)}let S=na(),C;if(a){let R=typeof a=="string"?tl(a):a;ot(v==="/"||R.pathname?.startsWith(v),`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 "${v}" but pathname "${R.pathname}" was given in the \`location\` prop.`),C=R}else C=S;let E=C.pathname||"/",N=E;if(v!=="/"){let R=v.replace(/^\//,"").split("/");N="/"+E.replace(/^\//,"").split("/").slice(R.length).join("/")}let w=Dx(n,{pathname:N});jn(b||w!=null,`No routes matched location "${C.pathname}${C.search}${C.hash}" `),jn(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${C.pathname}${C.search}${C.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 j=b1(w&&w.map(R=>Object.assign({},R,{params:Object.assign({},g,R.params),pathname:es([v,f.encodeLocation?f.encodeLocation(R.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?v:es([v,f.encodeLocation?f.encodeLocation(R.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathnameBase])})),p,r,o,u);return a&&j?m.createElement(xr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...C},navigationType:"POP"}},j):j}function p1(){let n=w1(),a=i1(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),r=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",u={padding:"0.5rem",backgroundColor:o},f={padding:"2px 4px",backgroundColor:o},p=null;return console.error("Error handled by React Router default ErrorBoundary:",n),p=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:f},"ErrorBoundary")," or"," ",m.createElement("code",{style:f},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},a),r?m.createElement("pre",{style:u},r):null,p)}var x1=m.createElement(p1,null),g1=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,a){return a.location!==n.location||a.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:a.error,location:a.location,revalidation:n.revalidation||a.revalidation}}componentDidCatch(n,a){this.props.onError?this.props.onError(n,a):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(ss.Provider,{value:this.props.routeContext},m.createElement(Vd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function v1({routeContext:n,match:a,children:r}){let o=m.useContext(nl);return o&&o.static&&o.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=a.route.id),m.createElement(ss.Provider,{value:n},r)}function b1(n,a=[],r=null,o=null,u=null){if(n==null){if(!r)return null;if(r.errors)n=r.matches;else if(a.length===0&&!r.initialized&&r.matches.length>0)n=r.matches;else return null}let f=n,p=r?.errors;if(p!=null){let v=f.findIndex(b=>b.route.id&&p?.[b.route.id]!==void 0);ot(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(p).join(",")}`),f=f.slice(0,Math.min(f.length,v+1))}let h=!1,g=-1;if(r)for(let v=0;v<f.length;v++){let b=f[v];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(g=v),b.route.id){let{loaderData:S,errors:C}=r,E=b.route.loader&&!S.hasOwnProperty(b.route.id)&&(!C||C[b.route.id]===void 0);if(b.route.lazy||E){h=!0,g>=0?f=f.slice(0,g+1):f=[f[0]];break}}}let x=r&&o?(v,b)=>{o(v,{location:r.location,params:r.matches?.[0]?.params??{},errorInfo:b})}:void 0;return f.reduceRight((v,b,S)=>{let C,E=!1,N=null,w=null;r&&(C=p&&b.route.id?p[b.route.id]:void 0,N=b.route.errorElement||x1,h&&(g<0&&S===0?(Gx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,w=null):g===S&&(E=!0,w=b.route.hydrateFallbackElement||null)));let j=a.concat(f.slice(0,S+1)),R=()=>{let k;return C?k=N:E?k=w:b.route.Component?k=m.createElement(b.route.Component,null):b.route.element?k=b.route.element:k=v,m.createElement(v1,{match:b,routeContext:{outlet:v,matches:j,isDataRoute:r!=null},children:k})};return r&&(b.route.ErrorBoundary||b.route.errorElement||S===0)?m.createElement(g1,{location:r.location,revalidation:r.revalidation,component:N,error:C,children:R(),routeContext:{outlet:null,matches:j,isDataRoute:!0},onError:x}):R()},null)}function $d(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function y1(n){let a=m.useContext(nl);return ot(a,$d(n)),a}function S1(n){let a=m.useContext(yo);return ot(a,$d(n)),a}function j1(n){let a=m.useContext(ss);return ot(a,$d(n)),a}function Gd(n){let a=j1(n),r=a.matches[a.matches.length-1];return ot(r.route.id,`${n} can only be used on routes that contain a unique "id"`),r.route.id}function N1(){return Gd("useRouteId")}function w1(){let n=m.useContext(Vd),a=S1("useRouteError"),r=Gd("useRouteError");return n!==void 0?n:a.errors?.[r]}function A1(){let{router:n}=y1("useNavigate"),a=Gd("useNavigate"),r=m.useRef(!1);return Vx(()=>{r.current=!0}),m.useCallback(async(u,f={})=>{jn(r.current,Hx),r.current&&(typeof u=="number"?n.navigate(u):await n.navigate(u,{fromRouteId:a,...f}))},[n,a])}var qp={};function Gx(n,a,r){!a&&!qp[n]&&(qp[n]=!0,jn(!1,r))}m.memo(C1);function C1({routes:n,future:a,state:r,unstable_onError:o}){return $x(n,void 0,r,o,a)}function Zi(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 k1({basename:n="/",children:a=null,location:r,navigationType:o="POP",navigator:u,static:f=!1}){ot(!gr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=n.replace(/^\/*/,"/"),h=m.useMemo(()=>({basename:p,navigator:u,static:f,future:{}}),[p,u,f]);typeof r=="string"&&(r=tl(r));let{pathname:g="/",search:x="",hash:v="",state:b=null,key:S="default"}=r,C=m.useMemo(()=>{let E=ts(g,p);return E==null?null:{location:{pathname:E,search:x,hash:v,state:b,key:S},navigationType:o}},[p,g,x,v,b,S,o]);return jn(C!=null,`<Router basename="${p}"> is not able to match the URL "${g}${x}${v}" because it does not start with the basename, so the <Router> won't render anything.`),C==null?null:m.createElement(Tn.Provider,{value:h},m.createElement(xr.Provider,{children:a,value:C}))}function E1({children:n,location:a}){return h1(Sd(n),a)}function Sd(n,a=[]){let r=[];return m.Children.forEach(n,(o,u)=>{if(!m.isValidElement(o))return;let f=[...a,u];if(o.type===m.Fragment){r.push.apply(r,Sd(o.props.children,f));return}ot(o.type===Zi,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ot(!o.props.index||!o.props.children,"An index route cannot have child routes.");let p={id:o.props.id||f.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(p.children=Sd(o.props.children,f)),r.push(p)}),r}var Ji="get",Pi="application/x-www-form-urlencoded";function So(n){return n!=null&&typeof n.tagName=="string"}function M1(n){return So(n)&&n.tagName.toLowerCase()==="button"}function R1(n){return So(n)&&n.tagName.toLowerCase()==="form"}function T1(n){return So(n)&&n.tagName.toLowerCase()==="input"}function q1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function D1(n,a){return n.button===0&&(!a||a==="_self")&&!q1(n)}var Ui=null;function _1(){if(Ui===null)try{new FormData(document.createElement("form"),0),Ui=!1}catch{Ui=!0}return Ui}var O1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Zu(n){return n!=null&&!O1.has(n)?(jn(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Pi}"`),null):n}function B1(n,a){let r,o,u,f,p;if(R1(n)){let h=n.getAttribute("action");o=h?ts(h,a):null,r=n.getAttribute("method")||Ji,u=Zu(n.getAttribute("enctype"))||Pi,f=new FormData(n)}else if(M1(n)||T1(n)&&(n.type==="submit"||n.type==="image")){let h=n.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=n.getAttribute("formaction")||h.getAttribute("action");if(o=g?ts(g,a):null,r=n.getAttribute("formmethod")||h.getAttribute("method")||Ji,u=Zu(n.getAttribute("formenctype"))||Zu(h.getAttribute("enctype"))||Pi,f=new FormData(h,n),!_1()){let{name:x,type:v,value:b}=n;if(v==="image"){let S=x?`${x}.`:"";f.append(`${S}x`,"0"),f.append(`${S}y`,"0")}else x&&f.append(x,b)}}else{if(So(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Ji,o=null,u=Pi,p=n}return f&&u==="text/plain"&&(p=f,f=void 0),{action:o,method:r.toLowerCase(),encType:u,formData:f,body:p}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Yd(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function L1(n,a,r){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${r}`:a&&ts(o.pathname,a)==="/"?o.pathname=`${a.replace(/\/$/,"")}/_root.${r}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${r}`,o}async function z1(n,a){if(n.id in a)return a[n.id];try{let r=await import(n.module);return a[n.id]=r,r}catch(r){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function U1(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 H1(n,a,r){let o=await Promise.all(n.map(async u=>{let f=a.routes[u.route.id];if(f){let p=await z1(f,r);return p.links?p.links():[]}return[]}));return Y1(o.flat(1).filter(U1).filter(u=>u.rel==="stylesheet"||u.rel==="preload").map(u=>u.rel==="stylesheet"?{...u,rel:"prefetch",as:"style"}:{...u,rel:"prefetch"}))}function Dp(n,a,r,o,u,f){let p=(g,x)=>r[x]?g.route.id!==r[x].route.id:!0,h=(g,x)=>r[x].pathname!==g.pathname||r[x].route.path?.endsWith("*")&&r[x].params["*"]!==g.params["*"];return f==="assets"?a.filter((g,x)=>p(g,x)||h(g,x)):f==="data"?a.filter((g,x)=>{let v=o.routes[g.route.id];if(!v||!v.hasLoader)return!1;if(p(g,x)||h(g,x))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(u.pathname+u.search+u.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function V1(n,a,{includeHydrateFallback:r}={}){return $1(n.map(o=>{let u=a.routes[o.route.id];if(!u)return[];let f=[u.module];return u.clientActionModule&&(f=f.concat(u.clientActionModule)),u.clientLoaderModule&&(f=f.concat(u.clientLoaderModule)),r&&u.hydrateFallbackModule&&(f=f.concat(u.hydrateFallbackModule)),u.imports&&(f=f.concat(u.imports)),f}).flat(1))}function $1(n){return[...new Set(n)]}function G1(n){let a={},r=Object.keys(n).sort();for(let o of r)a[o]=n[o];return a}function Y1(n,a){let r=new Set;return new Set(a),n.reduce((o,u)=>{let f=JSON.stringify(G1(u));return r.has(f)||(r.add(f),o.push({key:f,link:u})),o},[])}function Yx(){let n=m.useContext(nl);return Yd(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function F1(){let n=m.useContext(yo);return Yd(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Fd=m.createContext(void 0);Fd.displayName="FrameworkContext";function Fx(){let n=m.useContext(Fd);return Yd(n,"You must render this element inside a <HydratedRouter> element"),n}function I1(n,a){let r=m.useContext(Fd),[o,u]=m.useState(!1),[f,p]=m.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:x,onMouseLeave:v,onTouchStart:b}=a,S=m.useRef(null);m.useEffect(()=>{if(n==="render"&&p(!0),n==="viewport"){let N=j=>{j.forEach(R=>{p(R.isIntersecting)})},w=new IntersectionObserver(N,{threshold:.5});return S.current&&w.observe(S.current),()=>{w.disconnect()}}},[n]),m.useEffect(()=>{if(o){let N=setTimeout(()=>{p(!0)},100);return()=>{clearTimeout(N)}}},[o]);let C=()=>{u(!0)},E=()=>{u(!1),p(!1)};return r?n!=="intent"?[f,S,{}]:[f,S,{onFocus:Pl(h,C),onBlur:Pl(g,E),onMouseEnter:Pl(x,C),onMouseLeave:Pl(v,E),onTouchStart:Pl(b,C)}]:[!1,S,{}]}function Pl(n,a){return r=>{n&&n(r),r.defaultPrevented||a(r)}}function X1({page:n,...a}){let{router:r}=Yx(),o=m.useMemo(()=>Dx(r.routes,n,r.basename),[r.routes,n,r.basename]);return o?m.createElement(K1,{page:n,matches:o,...a}):null}function Q1(n){let{manifest:a,routeModules:r}=Fx(),[o,u]=m.useState([]);return m.useEffect(()=>{let f=!1;return H1(n,a,r).then(p=>{f||u(p)}),()=>{f=!0}},[n,a,r]),o}function K1({page:n,matches:a,...r}){let o=na(),{manifest:u,routeModules:f}=Fx(),{basename:p}=Yx(),{loaderData:h,matches:g}=F1(),x=m.useMemo(()=>Dp(n,a,g,u,o,"data"),[n,a,g,u,o]),v=m.useMemo(()=>Dp(n,a,g,u,o,"assets"),[n,a,g,u,o]),b=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let E=new Set,N=!1;if(a.forEach(j=>{let R=u.routes[j.route.id];!R||!R.hasLoader||(!x.some(k=>k.route.id===j.route.id)&&j.route.id in h&&f[j.route.id]?.shouldRevalidate||R.hasClientLoader?N=!0:E.add(j.route.id))}),E.size===0)return[];let w=L1(n,p,"data");return N&&E.size>0&&w.searchParams.set("_routes",a.filter(j=>E.has(j.route.id)).map(j=>j.route.id).join(",")),[w.pathname+w.search]},[p,h,o,u,x,a,n,f]),S=m.useMemo(()=>V1(v,u),[v,u]),C=Q1(v);return m.createElement(m.Fragment,null,b.map(E=>m.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...r})),S.map(E=>m.createElement("link",{key:E,rel:"modulepreload",href:E,...r})),C.map(({key:E,link:N})=>m.createElement("link",{key:E,nonce:r.nonce,...N})))}function Z1(...n){return a=>{n.forEach(r=>{typeof r=="function"?r(a):r!=null&&(r.current=a)})}}var Ix=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ix&&(window.__reactRouterVersion="7.9.6")}catch{}function J1({basename:n,children:a,window:r}){let o=m.useRef();o.current==null&&(o.current=Ly({window:r,v5Compat:!0}));let u=o.current,[f,p]=m.useState({action:u.action,location:u.location}),h=m.useCallback(g=>{m.startTransition(()=>p(g))},[p]);return m.useLayoutEffect(()=>u.listen(h),[u,h]),m.createElement(k1,{basename:n,children:a,location:f.location,navigationType:f.action,navigator:u})}var Xx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qx=m.forwardRef(function({onClick:a,discover:r="render",prefetch:o="none",relative:u,reloadDocument:f,replace:p,state:h,target:g,to:x,preventScrollReset:v,viewTransition:b,...S},C){let{basename:E}=m.useContext(Tn),N=typeof x=="string"&&Xx.test(x),w,j=!1;if(typeof x=="string"&&N&&(w=x,Ix))try{let F=new URL(window.location.href),U=x.startsWith("//")?new URL(F.protocol+x):new URL(x),Z=ts(U.pathname,E);U.origin===F.origin&&Z!=null?x=Z+U.search+U.hash:j=!0}catch{jn(!1,`<Link to="${x}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let R=d1(x,{relative:u}),[k,T,q]=I1(o,S),$=tS(x,{replace:p,state:h,target:g,preventScrollReset:v,relative:u,viewTransition:b});function O(F){a&&a(F),F.defaultPrevented||$(F)}let L=m.createElement("a",{...S,...q,href:w||R,onClick:j||f?a:O,ref:Z1(C,T),target:g,"data-discover":!N&&r==="render"?"true":void 0});return k&&!N?m.createElement(m.Fragment,null,L,m.createElement(X1,{page:R})):L});Qx.displayName="Link";var P1=m.forwardRef(function({"aria-current":a="page",caseSensitive:r=!1,className:o="",end:u=!1,style:f,to:p,viewTransition:h,children:g,...x},v){let b=vr(p,{relative:x.relative}),S=na(),C=m.useContext(yo),{navigator:E,basename:N}=m.useContext(Tn),w=C!=null&&rS(b)&&h===!0,j=E.encodeLocation?E.encodeLocation(b).pathname:b.pathname,R=S.pathname,k=C&&C.navigation&&C.navigation.location?C.navigation.location.pathname:null;r||(R=R.toLowerCase(),k=k?k.toLowerCase():null,j=j.toLowerCase()),k&&N&&(k=ts(k,N)||k);const T=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let q=R===j||!u&&R.startsWith(j)&&R.charAt(T)==="/",$=k!=null&&(k===j||!u&&k.startsWith(j)&&k.charAt(j.length)==="/"),O={isActive:q,isPending:$,isTransitioning:w},L=q?a:void 0,F;typeof o=="function"?F=o(O):F=[o,q?"active":null,$?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let U=typeof f=="function"?f(O):f;return m.createElement(Qx,{...x,"aria-current":L,className:F,ref:v,style:U,to:p,viewTransition:h},typeof g=="function"?g(O):g)});P1.displayName="NavLink";var W1=m.forwardRef(({discover:n="render",fetcherKey:a,navigate:r,reloadDocument:o,replace:u,state:f,method:p=Ji,action:h,onSubmit:g,relative:x,preventScrollReset:v,viewTransition:b,...S},C)=>{let E=aS(),N=lS(h,{relative:x}),w=p.toLowerCase()==="get"?"get":"post",j=typeof h=="string"&&Xx.test(h),R=k=>{if(g&&g(k),k.defaultPrevented)return;k.preventDefault();let T=k.nativeEvent.submitter,q=T?.getAttribute("formmethod")||p;E(T||k.currentTarget,{fetcherKey:a,method:q,navigate:r,replace:u,state:f,relative:x,preventScrollReset:v,viewTransition:b})};return m.createElement("form",{ref:C,method:w,action:N,onSubmit:o?g:R,...S,"data-discover":!j&&n==="render"?"true":void 0})});W1.displayName="Form";function eS(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Kx(n){let a=m.useContext(nl);return ot(a,eS(n)),a}function tS(n,{target:a,replace:r,state:o,preventScrollReset:u,relative:f,viewTransition:p}={}){let h=f1(),g=na(),x=vr(n,{relative:f});return m.useCallback(v=>{if(D1(v,a)){v.preventDefault();let b=r!==void 0?r:cr(g)===cr(x);h(n,{replace:b,state:o,preventScrollReset:u,relative:f,viewTransition:p})}},[g,h,x,r,o,a,n,u,f,p])}var nS=0,sS=()=>`__${String(++nS)}__`;function aS(){let{router:n}=Kx("useSubmit"),{basename:a}=m.useContext(Tn),r=N1();return m.useCallback(async(o,u={})=>{let{action:f,method:p,encType:h,formData:g,body:x}=B1(o,a);if(u.navigate===!1){let v=u.fetcherKey||sS();await n.fetch(v,r,u.action||f,{preventScrollReset:u.preventScrollReset,formData:g,body:x,formMethod:u.method||p,formEncType:u.encType||h,flushSync:u.flushSync})}else await n.navigate(u.action||f,{preventScrollReset:u.preventScrollReset,formData:g,body:x,formMethod:u.method||p,formEncType:u.encType||h,replace:u.replace,state:u.state,fromRouteId:r,flushSync:u.flushSync,viewTransition:u.viewTransition})},[n,a,r])}function lS(n,{relative:a}={}){let{basename:r}=m.useContext(Tn),o=m.useContext(ss);ot(o,"useFormAction must be used inside a RouteContext");let[u]=o.matches.slice(-1),f={...vr(n||".",{relative:a})},p=na();if(n==null){f.search=p.search;let h=new URLSearchParams(f.search),g=h.getAll("index");if(g.some(v=>v==="")){h.delete("index"),g.filter(b=>b).forEach(b=>h.append("index",b));let v=h.toString();f.search=v?`?${v}`:""}}return(!n||n===".")&&u.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(f.pathname=f.pathname==="/"?r:es([r,f.pathname])),cr(f)}function rS(n,{relative:a}={}){let r=m.useContext(Ux);ot(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Kx("useViewTransitionState"),u=vr(n,{relative:a});if(!r.isTransitioning)return!1;let f=ts(r.currentLocation.pathname,o)||r.currentLocation.pathname,p=ts(r.nextLocation.pathname,o)||r.nextLocation.pathname;return io(u.pathname,p)!=null||io(u.pathname,f)!=null}const Rn=Object.create(null);Rn.open="0";Rn.close="1";Rn.ping="2";Rn.pong="3";Rn.message="4";Rn.upgrade="5";Rn.noop="6";const Wi=Object.create(null);Object.keys(Rn).forEach(n=>{Wi[Rn[n]]=n});const jd={type:"error",data:"parser error"},Zx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Jx=typeof ArrayBuffer=="function",Px=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Id=({type:n,data:a},r,o)=>Zx&&a instanceof Blob?r?o(a):_p(a,o):Jx&&(a instanceof ArrayBuffer||Px(a))?r?o(a):_p(new Blob([a]),o):o(Rn[n]+(a||"")),_p=(n,a)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];a("b"+(o||""))},r.readAsDataURL(n)};function Op(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Ju;function iS(n,a){if(Zx&&n.data instanceof Blob)return n.data.arrayBuffer().then(Op).then(a);if(Jx&&(n.data instanceof ArrayBuffer||Px(n.data)))return a(Op(n.data));Id(n,!1,r=>{Ju||(Ju=new TextEncoder),a(Ju.encode(r))})}const Bp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ar=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Bp.length;n++)ar[Bp.charCodeAt(n)]=n;const oS=n=>{let a=n.length*.75,r=n.length,o,u=0,f,p,h,g;n[n.length-1]==="="&&(a--,n[n.length-2]==="="&&a--);const x=new ArrayBuffer(a),v=new Uint8Array(x);for(o=0;o<r;o+=4)f=ar[n.charCodeAt(o)],p=ar[n.charCodeAt(o+1)],h=ar[n.charCodeAt(o+2)],g=ar[n.charCodeAt(o+3)],v[u++]=f<<2|p>>4,v[u++]=(p&15)<<4|h>>2,v[u++]=(h&3)<<6|g&63;return x},cS=typeof ArrayBuffer=="function",Xd=(n,a)=>{if(typeof n!="string")return{type:"message",data:Wx(n,a)};const r=n.charAt(0);return r==="b"?{type:"message",data:uS(n.substring(1),a)}:Wi[r]?n.length>1?{type:Wi[r],data:n.substring(1)}:{type:Wi[r]}:jd},uS=(n,a)=>{if(cS){const r=oS(n);return Wx(r,a)}else return{base64:!0,data:n}},Wx=(n,a)=>{switch(a){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},eg="",dS=(n,a)=>{const r=n.length,o=new Array(r);let u=0;n.forEach((f,p)=>{Id(f,!1,h=>{o[p]=h,++u===r&&a(o.join(eg))})})},fS=(n,a)=>{const r=n.split(eg),o=[];for(let u=0;u<r.length;u++){const f=Xd(r[u],a);if(o.push(f),f.type==="error")break}return o};function mS(){return new TransformStream({transform(n,a){iS(n,r=>{const o=r.length;let u;if(o<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,o);else if(o<65536){u=new Uint8Array(3);const f=new DataView(u.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{u=new Uint8Array(9);const f=new DataView(u.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(u[0]|=128),a.enqueue(u),a.enqueue(r)})}})}let Pu;function Hi(n){return n.reduce((a,r)=>a+r.length,0)}function Vi(n,a){if(n[0].length===a)return n.shift();const r=new Uint8Array(a);let o=0;for(let u=0;u<a;u++)r[u]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function hS(n,a){Pu||(Pu=new TextDecoder);const r=[];let o=0,u=-1,f=!1;return new TransformStream({transform(p,h){for(r.push(p);;){if(o===0){if(Hi(r)<1)break;const g=Vi(r,1);f=(g[0]&128)===128,u=g[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(Hi(r)<2)break;const g=Vi(r,2);u=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),o=3}else if(o===2){if(Hi(r)<8)break;const g=Vi(r,8),x=new DataView(g.buffer,g.byteOffset,g.length),v=x.getUint32(0);if(v>Math.pow(2,21)-1){h.enqueue(jd);break}u=v*Math.pow(2,32)+x.getUint32(4),o=3}else{if(Hi(r)<u)break;const g=Vi(r,u);h.enqueue(Xd(f?g:Pu.decode(g),a)),o=0}if(u===0||u>n){h.enqueue(jd);break}}}})}const tg=4;function bt(n){if(n)return pS(n)}function pS(n){for(var a in bt.prototype)n[a]=bt.prototype[a];return n}bt.prototype.on=bt.prototype.addEventListener=function(n,a){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(a),this};bt.prototype.once=function(n,a){function r(){this.off(n,r),a.apply(this,arguments)}return r.fn=a,this.on(n,r),this};bt.prototype.off=bt.prototype.removeListener=bt.prototype.removeAllListeners=bt.prototype.removeEventListener=function(n,a){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,u=0;u<r.length;u++)if(o=r[u],o===a||o.fn===a){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+n],this};bt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var a=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)a[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,u=r.length;o<u;++o)r[o].apply(this,a)}return this};bt.prototype.emitReserved=bt.prototype.emit;bt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};bt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const jo=typeof Promise=="function"&&typeof Promise.resolve=="function"?a=>Promise.resolve().then(a):(a,r)=>r(a,0),xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),xS="arraybuffer";function ng(n,...a){return a.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const gS=xn.setTimeout,vS=xn.clearTimeout;function No(n,a){a.useNativeTimers?(n.setTimeoutFn=gS.bind(xn),n.clearTimeoutFn=vS.bind(xn)):(n.setTimeoutFn=xn.setTimeout.bind(xn),n.clearTimeoutFn=xn.clearTimeout.bind(xn))}const bS=1.33;function yS(n){return typeof n=="string"?SS(n):Math.ceil((n.byteLength||n.size)*bS)}function SS(n){let a=0,r=0;for(let o=0,u=n.length;o<u;o++)a=n.charCodeAt(o),a<128?r+=1:a<2048?r+=2:a<55296||a>=57344?r+=3:(o++,r+=4);return r}function sg(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function jS(n){let a="";for(let r in n)n.hasOwnProperty(r)&&(a.length&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return a}function NS(n){let a={},r=n.split("&");for(let o=0,u=r.length;o<u;o++){let f=r[o].split("=");a[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return a}class wS extends Error{constructor(a,r,o){super(a),this.description=r,this.context=o,this.type="TransportError"}}class Qd extends bt{constructor(a){super(),this.writable=!1,No(this,a),this.opts=a,this.query=a.query,this.socket=a.socket,this.supportsBinary=!a.forceBase64}onError(a,r,o){return super.emitReserved("error",new wS(a,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(a){this.readyState==="open"&&this.write(a)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(a){const r=Xd(a,this.socket.binaryType);this.onPacket(r)}onPacket(a){super.emitReserved("packet",a)}onClose(a){this.readyState="closed",super.emitReserved("close",a)}pause(a){}createUri(a,r={}){return a+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const a=this.opts.hostname;return a.indexOf(":")===-1?a:"["+a+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(a){const r=jS(a);return r.length?"?"+r:""}}class AS extends Qd{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(a){this.readyState="pausing";const r=()=>{this.readyState="paused",a()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(a){const r=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)};fS(a,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const a=()=>{this.write([{type:"close"}])};this.readyState==="open"?a():this.once("open",a)}write(a){this.writable=!1,dS(a,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const a=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=sg()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(a,r)}}let ag=!1;try{ag=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const CS=ag;function kS(){}class ES extends AS{constructor(a){if(super(a),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&a.hostname!==location.hostname||o!==a.port}}doWrite(a,r){const o=this.request({method:"POST",data:a});o.on("success",r),o.on("error",(u,f)=>{this.onError("xhr post error",u,f)})}doPoll(){const a=this.request();a.on("data",this.onData.bind(this)),a.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=a}}class Mn extends bt{constructor(a,r,o){super(),this.createRequest=a,No(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var a;const r=ng(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let u in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(u)&&o.setRequestHeader(u,this._opts.extraHeaders[u])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(a=this._opts.cookieJar)===null||a===void 0||a.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var u;o.readyState===3&&((u=this._opts.cookieJar)===null||u===void 0||u.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(u){this.setTimeoutFn(()=>{this._onError(u)},0);return}typeof document<"u"&&(this._index=Mn.requestsCount++,Mn.requests[this._index]=this)}_onError(a){this.emitReserved("error",a,this._xhr),this._cleanup(!0)}_cleanup(a){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=kS,a)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Mn.requests[this._index],this._xhr=null}}_onLoad(){const a=this._xhr.responseText;a!==null&&(this.emitReserved("data",a),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Mn.requestsCount=0;Mn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Lp);else if(typeof addEventListener=="function"){const n="onpagehide"in xn?"pagehide":"unload";addEventListener(n,Lp,!1)}}function Lp(){for(let n in Mn.requests)Mn.requests.hasOwnProperty(n)&&Mn.requests[n].abort()}const MS=(function(){const n=lg({xdomain:!1});return n&&n.responseType!==null})();class RS extends ES{constructor(a){super(a);const r=a&&a.forceBase64;this.supportsBinary=MS&&!r}request(a={}){return Object.assign(a,{xd:this.xd},this.opts),new Mn(lg,this.uri(),a)}}function lg(n){const a=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!a||CS))return new XMLHttpRequest}catch{}if(!a)try{return new xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const rg=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class TS extends Qd{get name(){return"websocket"}doOpen(){const a=this.uri(),r=this.opts.protocols,o=rg?{}:ng(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(a,r,o)}catch(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=a=>this.onClose({description:"websocket connection closed",context:a}),this.ws.onmessage=a=>this.onData(a.data),this.ws.onerror=a=>this.onError("websocket error",a)}write(a){this.writable=!1;for(let r=0;r<a.length;r++){const o=a[r],u=r===a.length-1;Id(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}u&&jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const a=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=sg()),this.supportsBinary||(r.b64=1),this.createUri(a,r)}}const Wu=xn.WebSocket||xn.MozWebSocket;class qS extends TS{createSocket(a,r,o){return rg?new Wu(a,r,o):r?new Wu(a,r):new Wu(a)}doWrite(a,r){this.ws.send(r)}}class DS extends Qd{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(a){return this.emitReserved("error",a)}this._transport.closed.then(()=>{this.onClose()}).catch(a=>{this.onError("webtransport error",a)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(a=>{const r=hS(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=a.readable.pipeThrough(r).getReader(),u=mS();u.readable.pipeTo(a.writable),this._writer=u.writable.getWriter();const f=()=>{o.read().then(({done:h,value:g})=>{h||(this.onPacket(g),f())}).catch(h=>{})};f();const p={type:"open"};this.query.sid&&(p.data=`{"sid":"${this.query.sid}"}`),this._writer.write(p).then(()=>this.onOpen())})})}write(a){this.writable=!1;for(let r=0;r<a.length;r++){const o=a[r],u=r===a.length-1;this._writer.write(o).then(()=>{u&&jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var a;(a=this._transport)===null||a===void 0||a.close()}}const _S={websocket:qS,webtransport:DS,polling:RS},OS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,BS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Nd(n){if(n.length>8e3)throw"URI too long";const a=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let u=OS.exec(n||""),f={},p=14;for(;p--;)f[BS[p]]=u[p]||"";return r!=-1&&o!=-1&&(f.source=a,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=LS(f,f.path),f.queryKey=zS(f,f.query),f}function LS(n,a){const r=/\/{2,9}/g,o=a.replace(r,"/").split("/");return(a.slice(0,1)=="/"||a.length===0)&&o.splice(0,1),a.slice(-1)=="/"&&o.splice(o.length-1,1),o}function zS(n,a){const r={};return a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,f){u&&(r[u]=f)}),r}const wd=typeof addEventListener=="function"&&typeof removeEventListener=="function",eo=[];wd&&addEventListener("offline",()=>{eo.forEach(n=>n())},!1);class Ms extends bt{constructor(a,r){if(super(),this.binaryType=xS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,a&&typeof a=="object"&&(r=a,a=null),a){const o=Nd(a);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=Nd(r.host).host);No(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{const u=o.prototype.name;this.transports.push(u),this._transportsByName[u]=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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=NS(this.opts.query)),wd&&(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"})},eo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(a){const r=Object.assign({},this.opts.query);r.EIO=tg,r.transport=a,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[a]);return new this._transportsByName[a](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const a=this.opts.rememberUpgrade&&Ms.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(a);r.open(),this.setTransport(r)}setTransport(a){this.transport&&this.transport.removeAllListeners(),this.transport=a,a.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Ms.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(a){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",a),this.emitReserved("heartbeat"),a.type){case"open":this.onHandshake(JSON.parse(a.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=a.data,this._onError(r);break;case"message":this.emitReserved("data",a.data),this.emitReserved("message",a.data);break}}onHandshake(a){this.emitReserved("handshake",a),this.id=a.sid,this.transport.query.sid=a.sid,this._pingInterval=a.pingInterval,this._pingTimeout=a.pingTimeout,this._maxPayload=a.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const a=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+a,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},a),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 a=this._getWritablePackets();this.transport.send(a),this._prevBufferLen=a.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const u=this.writeBuffer[o].data;if(u&&(r+=yS(u)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const a=Date.now()>this._pingTimeoutTime;return a&&(this._pingTimeoutTime=0,jo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),a}write(a,r,o){return this._sendPacket("message",a,r,o),this}send(a,r,o){return this._sendPacket("message",a,r,o),this}_sendPacket(a,r,o,u){if(typeof r=="function"&&(u=r,r=void 0),typeof o=="function"&&(u=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:a,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),u&&this.once("flush",u),this.flush()}close(){const a=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),a()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():a()}):this.upgrading?o():a()),this}_onError(a){if(Ms.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",a),this._onClose("transport error",a)}_onClose(a,r){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(),wd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=eo.indexOf(this._offlineEventListener);o!==-1&&eo.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",a,r),this.writeBuffer=[],this._prevBufferLen=0}}}Ms.protocol=tg;class US extends Ms{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let a=0;a<this._upgrades.length;a++)this._probe(this._upgrades[a])}_probe(a){let r=this.createTransport(a),o=!1;Ms.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Ms.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(v(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=r.name,this.emitReserved("upgradeError",S)}}))};function f(){o||(o=!0,v(),r.close(),r=null)}const p=b=>{const S=new Error("probe error: "+b);S.transport=r.name,f(),this.emitReserved("upgradeError",S)};function h(){p("transport closed")}function g(){p("socket closed")}function x(b){r&&b.name!==r.name&&f()}const v=()=>{r.removeListener("open",u),r.removeListener("error",p),r.removeListener("close",h),this.off("close",g),this.off("upgrading",x)};r.once("open",u),r.once("error",p),r.once("close",h),this.once("close",g),this.once("upgrading",x),this._upgrades.indexOf("webtransport")!==-1&&a!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(a){this._upgrades=this._filterUpgrades(a.upgrades),super.onHandshake(a)}_filterUpgrades(a){const r=[];for(let o=0;o<a.length;o++)~this.transports.indexOf(a[o])&&r.push(a[o]);return r}}let HS=class extends US{constructor(a,r={}){const o=typeof a=="object"?a:r;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(u=>_S[u]).filter(u=>!!u)),super(a,o)}};function VS(n,a="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=Nd(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+a,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const $S=typeof ArrayBuffer=="function",GS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ig=Object.prototype.toString,YS=typeof Blob=="function"||typeof Blob<"u"&&ig.call(Blob)==="[object BlobConstructor]",FS=typeof File=="function"||typeof File<"u"&&ig.call(File)==="[object FileConstructor]";function Kd(n){return $S&&(n instanceof ArrayBuffer||GS(n))||YS&&n instanceof Blob||FS&&n instanceof File}function to(n,a){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(to(n[r]))return!0;return!1}if(Kd(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return to(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&to(n[r]))return!0;return!1}function IS(n){const a=[],r=n.data,o=n;return o.data=Ad(r,a),o.attachments=a.length,{packet:o,buffers:a}}function Ad(n,a){if(!n)return n;if(Kd(n)){const r={_placeholder:!0,num:a.length};return a.push(n),r}else if(Array.isArray(n)){const r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=Ad(n[o],a);return r}else if(typeof n=="object"&&!(n instanceof Date)){const r={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=Ad(n[o],a));return r}return n}function XS(n,a){return n.data=Cd(n.data,a),delete n.attachments,n}function Cd(n,a){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<a.length)return a[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=Cd(n[r],a);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=Cd(n[r],a));return n}const QS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],KS=5;var $e;(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"})($e||($e={}));class ZS{constructor(a){this.replacer=a}encode(a){return(a.type===$e.EVENT||a.type===$e.ACK)&&to(a)?this.encodeAsBinary({type:a.type===$e.EVENT?$e.BINARY_EVENT:$e.BINARY_ACK,nsp:a.nsp,data:a.data,id:a.id}):[this.encodeAsString(a)]}encodeAsString(a){let r=""+a.type;return(a.type===$e.BINARY_EVENT||a.type===$e.BINARY_ACK)&&(r+=a.attachments+"-"),a.nsp&&a.nsp!=="/"&&(r+=a.nsp+","),a.id!=null&&(r+=a.id),a.data!=null&&(r+=JSON.stringify(a.data,this.replacer)),r}encodeAsBinary(a){const r=IS(a),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function zp(n){return Object.prototype.toString.call(n)==="[object Object]"}class Zd extends bt{constructor(a){super(),this.reviver=a}add(a){let r;if(typeof a=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(a);const o=r.type===$e.BINARY_EVENT;o||r.type===$e.BINARY_ACK?(r.type=o?$e.EVENT:$e.ACK,this.reconstructor=new JS(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Kd(a)||a.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(a),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+a)}decodeString(a){let r=0;const o={type:Number(a.charAt(0))};if($e[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===$e.BINARY_EVENT||o.type===$e.BINARY_ACK){const f=r+1;for(;a.charAt(++r)!=="-"&&r!=a.length;);const p=a.substring(f,r);if(p!=Number(p)||a.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(p)}if(a.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(a.charAt(r)===","||r===a.length););o.nsp=a.substring(f,r)}else o.nsp="/";const u=a.charAt(r+1);if(u!==""&&Number(u)==u){const f=r+1;for(;++r;){const p=a.charAt(r);if(p==null||Number(p)!=p){--r;break}if(r===a.length)break}o.id=Number(a.substring(f,r+1))}if(a.charAt(++r)){const f=this.tryParse(a.substr(r));if(Zd.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(a){try{return JSON.parse(a,this.reviver)}catch{return!1}}static isPayloadValid(a,r){switch(a){case $e.CONNECT:return zp(r);case $e.DISCONNECT:return r===void 0;case $e.CONNECT_ERROR:return typeof r=="string"||zp(r);case $e.EVENT:case $e.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&QS.indexOf(r[0])===-1);case $e.ACK:case $e.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class JS{constructor(a){this.packet=a,this.buffers=[],this.reconPack=a}takeBinaryData(a){if(this.buffers.push(a),this.buffers.length===this.reconPack.attachments){const r=XS(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const PS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Zd,Encoder:ZS,get PacketType(){return $e},protocol:KS},Symbol.toStringTag,{value:"Module"}));function Sn(n,a,r){return n.on(a,r),function(){n.off(a,r)}}const WS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class og extends bt{constructor(a,r,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=a,this.nsp=r,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 a=this.io;this.subs=[Sn(a,"open",this.onopen.bind(this)),Sn(a,"packet",this.onpacket.bind(this)),Sn(a,"error",this.onerror.bind(this)),Sn(a,"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(...a){return a.unshift("message"),this.emit.apply(this,a),this}emit(a,...r){var o,u,f;if(WS.hasOwnProperty(a))throw new Error('"'+a.toString()+'" is a reserved event name');if(r.unshift(a),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const p={type:$e.EVENT,data:r};if(p.options={},p.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const v=this.ids++,b=r.pop();this._registerAckCallback(v,b),p.id=v}const h=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!h||(g?(this.notifyOutgoingListeners(p),this.packet(p)):this.sendBuffer.push(p)),this.flags={},this}_registerAckCallback(a,r){var o;const u=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(u===void 0){this.acks[a]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[a];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===a&&this.sendBuffer.splice(h,1);r.call(this,new Error("operation has timed out"))},u),p=(...h)=>{this.io.clearTimeoutFn(f),r.apply(this,h)};p.withError=!0,this.acks[a]=p}emitWithAck(a,...r){return new Promise((o,u)=>{const f=(p,h)=>p?u(p):o(h);f.withError=!0,r.push(f),this.emit(a,...r)})}_addToQueue(a){let r;typeof a[a.length-1]=="function"&&(r=a.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:a,flags:Object.assign({fromQueue:!0},this.flags)};a.push((u,...f)=>o!==this._queue[0]?void 0:(u!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(a=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!a||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(a){a.nsp=this.nsp,this.io._packet(a)}onopen(){typeof this.auth=="function"?this.auth(a=>{this._sendConnectPacket(a)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(a){this.packet({type:$e.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},a):a})}onerror(a){this.connected||this.emitReserved("connect_error",a)}onclose(a,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",a,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(a=>{if(!this.sendBuffer.some(o=>String(o.id)===a)){const o=this.acks[a];delete this.acks[a],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(a){if(a.nsp===this.nsp)switch(a.type){case $e.CONNECT:a.data&&a.data.sid?this.onconnect(a.data.sid,a.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 $e.EVENT:case $e.BINARY_EVENT:this.onevent(a);break;case $e.ACK:case $e.BINARY_ACK:this.onack(a);break;case $e.DISCONNECT:this.ondisconnect();break;case $e.CONNECT_ERROR:this.destroy();const o=new Error(a.data.message);o.data=a.data.data,this.emitReserved("connect_error",o);break}}onevent(a){const r=a.data||[];a.id!=null&&r.push(this.ack(a.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(a){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,a)}super.emit.apply(this,a),this._pid&&a.length&&typeof a[a.length-1]=="string"&&(this._lastOffset=a[a.length-1])}ack(a){const r=this;let o=!1;return function(...u){o||(o=!0,r.packet({type:$e.ACK,id:a,data:u}))}}onack(a){const r=this.acks[a.id];typeof r=="function"&&(delete this.acks[a.id],r.withError&&a.data.unshift(null),r.apply(this,a.data))}onconnect(a,r){this.id=a,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(a=>this.emitEvent(a)),this.receiveBuffer=[],this.sendBuffer.forEach(a=>{this.notifyOutgoingListeners(a),this.packet(a)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(a=>a()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:$e.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(a){return this.flags.compress=a,this}get volatile(){return this.flags.volatile=!0,this}timeout(a){return this.flags.timeout=a,this}onAny(a){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(a),this}prependAny(a){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(a),this}offAny(a){if(!this._anyListeners)return this;if(a){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(a===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(a){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(a),this}prependAnyOutgoing(a){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(a),this}offAnyOutgoing(a){if(!this._anyOutgoingListeners)return this;if(a){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(a===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(a){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,a.data)}}}function sl(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}sl.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var a=Math.random(),r=Math.floor(a*this.jitter*n);n=(Math.floor(a*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};sl.prototype.reset=function(){this.attempts=0};sl.prototype.setMin=function(n){this.ms=n};sl.prototype.setMax=function(n){this.max=n};sl.prototype.setJitter=function(n){this.jitter=n};class kd extends bt{constructor(a,r){var o;super(),this.nsps={},this.subs=[],a&&typeof a=="object"&&(r=a,a=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,No(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new sl({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=a;const u=r.parser||PS;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(a){return arguments.length?(this._reconnection=!!a,a||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(a){return a===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=a,this)}reconnectionDelay(a){var r;return a===void 0?this._reconnectionDelay:(this._reconnectionDelay=a,(r=this.backoff)===null||r===void 0||r.setMin(a),this)}randomizationFactor(a){var r;return a===void 0?this._randomizationFactor:(this._randomizationFactor=a,(r=this.backoff)===null||r===void 0||r.setJitter(a),this)}reconnectionDelayMax(a){var r;return a===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=a,(r=this.backoff)===null||r===void 0||r.setMax(a),this)}timeout(a){return arguments.length?(this._timeout=a,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(a){if(~this._readyState.indexOf("open"))return this;this.engine=new HS(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=Sn(r,"open",function(){o.onopen(),a&&a()}),f=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),a?a(h):this.maybeReconnectOnOpen()},p=Sn(r,"error",f);if(this._timeout!==!1){const h=this._timeout,g=this.setTimeoutFn(()=>{u(),f(new Error("timeout")),r.close()},h);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(u),this.subs.push(p),this}connect(a){return this.open(a)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const a=this.engine;this.subs.push(Sn(a,"ping",this.onping.bind(this)),Sn(a,"data",this.ondata.bind(this)),Sn(a,"error",this.onerror.bind(this)),Sn(a,"close",this.onclose.bind(this)),Sn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(a){try{this.decoder.add(a)}catch(r){this.onclose("parse error",r)}}ondecoded(a){jo(()=>{this.emitReserved("packet",a)},this.setTimeoutFn)}onerror(a){this.emitReserved("error",a)}socket(a,r){let o=this.nsps[a];return o?this._autoConnect&&!o.active&&o.connect():(o=new og(this,a,r),this.nsps[a]=o),o}_destroy(a){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(a){const r=this.encoder.encode(a);for(let o=0;o<r.length;o++)this.engine.write(r[o],a.options)}cleanup(){this.subs.forEach(a=>a()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(a,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",a,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const a=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{a.skipReconnect||(this.emitReserved("reconnect_attempt",a.backoff.attempts),!a.skipReconnect&&a.open(u=>{u?(a._reconnecting=!1,a.reconnect(),this.emitReserved("reconnect_error",u)):a.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const a=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",a)}}const Wl={};function no(n,a){typeof n=="object"&&(a=n,n=void 0),a=a||{};const r=VS(n,a.path||"/socket.io"),o=r.source,u=r.id,f=r.path,p=Wl[u]&&f in Wl[u].nsps,h=a.forceNew||a["force new connection"]||a.multiplex===!1||p;let g;return h?g=new kd(o,a):(Wl[u]||(Wl[u]=new kd(o,a)),g=Wl[u]),r.query&&!a.query&&(a.query=r.queryKey),g.socket(r.path,a)}Object.assign(no,{Manager:kd,Socket:og,io:no,connect:no});const cg="roverSettings",ej=3600*24*365;function tj(n){try{const a=decodeURIComponent(n??"");return JSON.parse(a)}catch(a){return console.warn("Failed to parse settings cookie",a),null}}function Ed(){if(typeof document>"u")return{};const n=`${cg}=`,a=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!a)return{};const r=a.substring(n.length);return tj(r)??{}}function Up(n){if(typeof document>"u")return!1;try{const a=encodeURIComponent(JSON.stringify(n??{})),r=`${cg}=${a}; path=/; max-age=${ej}; samesite=strict`;return document.cookie=r,!0}catch(a){return console.warn("Failed to write settings cookie",a),!1}}const ug=window.location.origin;console.info("[socket] connecting to",ug);const nj=Ed(),sj=nj?.page?.connectionTransport||"websocket",aj=sj==="polling"?["polling"]:["websocket","polling"],Jd=no(ug,{transports:aj,timeout:15e3});Jd.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const dg=m.createContext(Jd),lj=({children:n})=>l.jsx(dg.Provider,{value:Jd,children:n}),Pt=()=>m.useContext(dg),rj={connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,overseerControlState:null,alerts:[]},Pd=m.createContext(null);function ij(n){return m.useCallback((a,r={})=>new Promise((o,u)=>{n.emit(a,r,(f={})=>{f.error?u(new Error(f.error)):o(f)})}),[n])}function oj(n){return typeof n=="function"?n:a=>a}function cj({children:n}){const a=Pt(),r=ij(a),o=m.useRef({...rj,connected:a.connected}),u=m.useRef(new Set),f=m.useCallback(()=>o.current,[]),p=m.useCallback(v=>{const b=o.current,S=typeof v=="function"?v(b):{...b,...v||{}};S!==b&&(o.current=S,u.current.forEach(C=>{const E=C.selector(S);C.equalityFn(C.current,E)||(C.current=E,C.listener(E))}))},[]),h=m.useCallback((v,b,S=Object.is)=>{const C=oj(v),E={selector:C,equalityFn:S,listener:b,current:C(o.current)};return u.current.add(E),()=>{u.current.delete(E)}},[]);m.useEffect(()=>{const v=()=>{p(S=>S.connected?S:{...S,connected:!0})},b=()=>{p(S=>S.connected?{...S,connected:!1}:S)};return a.on("connect",v),a.on("disconnect",b),()=>{a.off("connect",v),a.off("disconnect",b)}},[p,a]),m.useEffect(()=>{function v(R){p(k=>({...k,session:R}))}function b(R=[]){p(k=>({...k,logs:R}))}function S(R){p(k=>({...k,logs:[...k.logs.slice(-199),R]}))}function C(R=[]){p(k=>({...k,adminLogs:R}))}function E(R){p(k=>({...k,adminLogs:[...k.adminLogs.slice(-199),R]}))}function N(R=null){const k=R&&typeof R=="object"?R:null,T=k?.debug?.status&&typeof k.debug.status=="object"?k.debug.status:null;p(q=>({...q,llmCommentaryState:k,llmCommentaryStatus:T}))}function w(R={}){p(k=>({...k,alerts:[...k.alerts.slice(-49),{...R,receivedAt:Date.now()}]}))}function j(R=null){const k=R&&typeof R=="object"?R:null;p(T=>({...T,overseerControlState:k}))}return a.on("session:sync",v),a.on("log:init",b),a.on("log:entry",S),a.on("adminlog:init",C),a.on("adminlog:entry",E),a.on("llm:state",N),a.on("overseer:state",j),a.on("alert:new",w),()=>{a.off("session:sync",v),a.off("log:init",b),a.off("log:entry",S),a.off("adminlog:init",C),a.off("adminlog:entry",E),a.off("llm:state",N),a.off("overseer:state",j),a.off("alert:new",w)}},[p,a]);const g=m.useMemo(()=>({login:(v,b)=>r("auth:login",{username:v,password:b}),identifySession:({cookieUserId:v,nickname:b,overseerEnabled:S}={})=>r("session:identify",{cookieUserId:v,nickname:b,overseerEnabled:S}),setRole:v=>r("session:setRole",{role:v}),requestControl:(v,b={})=>r("session:requestControl",{roverId:v,...b}),releaseControl:v=>r("session:releaseControl",{roverId:v}),subscribeAll:()=>r("session:subscribeAll"),lockRover:(v,b)=>r("session:lockRover",{roverId:v,locked:b}),setMode:v=>r("setMode",{mode:v}),homeAssistantToggle:v=>r("homeAssistant:toggle",{entityId:v}),homeAssistantSetState:(v,b)=>r("homeAssistant:setState",{entityId:v,state:b}),homeAssistantSetLightColor:(v,b)=>r("homeAssistant:lightColor",{entityId:v,rgbColor:b}),homeAssistantSetLightWhite:v=>r("homeAssistant:lightWhite",{entityId:v}),neatoStart:()=>r("neato:start"),neatoSendHome:()=>r("neato:sendHome"),neatoLocate:()=>r("neato:locate"),neatoClearErrors:()=>r("neato:clearErrors"),neatoPowerCycle:()=>r("neato:powerCycle"),liftUp:()=>r("lift:up"),liftDown:()=>r("lift:down"),setNickname:v=>r("nickname:set",{nickname:v}),requestVerification:()=>r("verification:request"),requestPrivateRoverAccess:v=>r("session:privateRover:requestAccess",{roverId:v}),triggerReplay:(v=[],b="")=>v&&typeof v=="object"&&!Array.isArray(v)?r("replay:trigger",v):r("replay:trigger",{sources:v,title:b}),setGlobalObjective:v=>r("globalObjective:set",{text:v}),setAdminReason:v=>r("adminReason:set",{text:v}),rebootRover:v=>r("command",{roverId:v,type:"reboot",data:{reboot:{}}}),rebootServer:()=>r("server:reboot"),playUploadedAudio:({roverId:v,name:b,mime:S,dataBase64:C})=>r("audio:uploadPlay",{roverId:v,name:b,mime:S,dataBase64:C}),stopUploadedAudio:v=>r("audio:uploadStop",{roverId:v}),startMicWhip:v=>r("audio:micWhipStart",{roverId:v}),readyMicWhip:v=>r("audio:micWhipReady",{roverId:v}),stopMicWhip:v=>r("audio:micWhipStop",{roverId:v}),setAudioLevels:(v={})=>r("audioLevels:set",v),setPrivateSafety:(v,b={})=>r("session:privateSafety:set",{roverId:v,safety:b}),llmControl:(v,b={})=>r("llm:control",{controls:{action:v,...b}}),overseerControl:(v,b={})=>r("overseer:control",{controls:{action:v,...b}}),pushAlert:v=>p(b=>({...b,alerts:[...b.alerts.slice(-49),{...v,receivedAt:Date.now(),id:v.id||Math.random().toString(36).slice(2)}]}))}),[r,p]),x=m.useMemo(()=>({getState:f,subscribe:h,actions:g}),[g,f,h]);return l.jsx(Pd.Provider,{value:x,children:n})}function oe(n,a=Object.is){const r=m.useContext(Pd);if(!r)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const u=m.useRef(a);u.current=a;const[f,p]=m.useState(()=>n(r.getState()));return m.useEffect(()=>(p(h=>{const g=o.current(r.getState());return u.current(h,g)?h:g}),r.subscribe(h=>o.current(h),h=>{p(g=>u.current(g,h)?g:h)},(h,g)=>u.current(h,g))),[r]),f}function Ot(){const n=m.useContext(Pd);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function br(){const n=oe(r=>r),a=Ot();return m.useMemo(()=>({...n,...a}),[a,n])}const uj=Object.freeze({}),Md=null,Wd=m.createContext(null);function dj({children:n}){const a=Pt(),r=m.useRef({}),o=m.useRef(new Map),u=m.useRef(new Set),f=h=>{const g=o.current.get(h);g&&g.forEach(x=>x()),u.current.forEach(x=>x())},p=m.useMemo(()=>({getFrames:()=>r.current,getFrame:h=>h?r.current[h]??Md:Md,subscribeAll:h=>(u.current.add(h),()=>{u.current.delete(h)}),subscribeRover:(h,g)=>{if(!h)return()=>{};let x=o.current.get(h);return x||(x=new Set,o.current.set(h,x)),x.add(g),()=>{const v=o.current.get(h);v&&(v.delete(g),v.size||o.current.delete(h))}}}),[]);return m.useEffect(()=>{function h({roverId:g,sensors:x={},frame:v={}}){g&&(r.current={...r.current,[g]:{roverId:g,sensors:x,raw:v?.data||null,receivedAt:Date.now()}},f(g))}return a.on("sensorFrame",h),()=>{a.off("sensorFrame",h)}},[a]),l.jsx(Wd.Provider,{value:p,children:n})}function fj(){const n=m.useContext(Wd);if(!n)throw new Error("useTelemetryFrames must be used within TelemetryProvider");return m.useSyncExternalStore(n.subscribeAll,n.getFrames,()=>uj)}function Wt(n){const a=m.useContext(Wd);if(!a)throw new Error("useTelemetryFrame must be used within TelemetryProvider");return m.useSyncExternalStore(r=>a.subscribeRover(n,r),()=>a.getFrame(n),()=>Md)}const mj=650,hj={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 ed(n){if(typeof n!="number"||n<=0)return null;const a=hj[n];return a?{code:n,...a}:null}function pj(n,a={}){const r=a.holdMs||mj,[o,u]=m.useState({left:null,right:null,omni:null}),[f,p]=m.useState(0);return m.useEffect(()=>{const h=setInterval(()=>p(Date.now()),Math.max(r/2,100));return()=>clearInterval(h)},[r]),m.useEffect(()=>{const h=Date.now(),g=ed(n?.infraredCharacterLeft),x=ed(n?.infraredCharacterRight),v=ed(n?.infraredCharacterOmni);!g&&!x&&!v||u(b=>({left:g?{...g,ts:h}:b.left,right:x?{...x,ts:h}:b.right,omni:v?{...v,ts:h}:b.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useMemo(()=>{const h=Date.now(),g=w=>{if(!w)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const j=h-w.ts,R=j<=r;return{active:R,age:j,code:w.code,red:!!(w.red&&R),green:!!(w.green&&R),force:!!(w.force&&R)}},x=g(o.left),v=g(o.right),b=g(o.omni),S=x.force||v.force||b.force,C=x.active||v.active||b.active,E=x.active&&!v.active?"right":v.active&&!x.active?"left":"center",N=(v.active?1:0)-(x.active?1:0);return{visible:C,forceDetected:S,left:x,right:v,omni:b,bias:E,balance:Math.max(-1,Math.min(1,N))}},[o.left,o.right,o.omni,r,f])}function xj(){oe(C=>C.connected);const n=oe(C=>C.session?.assignment?.roverId??null),a=oe(C=>{const E=C.session?.assignment?.roverId;return E&&C.session?.activeDrivers?.[E]||null}),r=oe(C=>C.session?.socketId||null),o=oe(C=>C.session?.users??[]),u=Wt(n),f=u?.sensors||{},p=pj(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,g=f.currentMa!=null?`${f.currentMa} mA`:null,x=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,v=f.batteryChargeMah,b=f.batteryCapacityMah;u?.receivedAt&&new Date(u.receivedAt).toLocaleTimeString();const S=u?.raw?u.raw:null;return m.useMemo(()=>n?a?a===r?"You":o.find(E=>E.socketId===a)?.nickname||a.slice(0,6):"Available":"n/a",[a,n,r,o]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[n?u?l.jsxs(l.Fragment,{children:[l.jsx(gj,{sensors:f,voltage:h,current:g,batteryTemp:x,charge:v,capacity:b}),l.jsx(vj,{sensors:f,dockState:p})]}):l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):l.jsx("p",{className:"text-sm text-slate-500",children:"You are not assigned to a rover!!!!!!"}),S&&l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:S})]})}function gj({sensors:n,voltage:a,current:r,batteryTemp:o,charge:u,capacity:f}){const p=u!=null&&f?`${Math.round(u/f*100)}`:"--",h=n?.oiMode?.label||"--",g=n?.chargingSources?.homeBase?"Yes":"No",x=n?.chargingState?.label||"--";return l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[l.jsx(Zn,{label:"Voltage",value:a??"--"}),l.jsx(Zn,{label:"Current",value:r??"--"}),l.jsx(Zn,{label:"Battery temp",value:o??"--"}),l.jsx(Zn,{label:"Charge",value:u!=null?`${u} mAh`:"--"}),l.jsx(Zn,{label:"Capacity",value:f!=null?`${f} mAh`:"--"}),l.jsx(Zn,{label:"Charge",value:p}),l.jsx(Zn,{label:"OI mode",value:h}),l.jsx(Zn,{label:"Docked",value:g}),l.jsx(Zn,{label:"Charging state",value:x})]})}function Zn({label:n,value:a}){return l.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[l.jsx("span",{className:"text-slate-400",children:n}),l.jsx("span",{className:"text-slate-100",children:a})]})}function vj({sensors:n,dockState:a}){const r=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},u=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],f=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],p=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs($a,{title:"Dock IR",children:[l.jsx(bj,{sensors:n}),l.jsx(yj,{state:a})]}),l.jsxs($a,{title:"Bumps & drops",children:[l.jsx(Jn,{label:"Bump L",value:l.jsx(er,{active:r.bumpLeft})}),l.jsx(Jn,{label:"Bump R",value:l.jsx(er,{active:r.bumpRight})}),l.jsx(Jn,{label:"Wheel drop L",value:l.jsx(er,{active:r.wheelDropLeft,tone:"amber"})}),l.jsx(Jn,{label:"Wheel drop R",value:l.jsx(er,{active:r.wheelDropRight,tone:"amber"})})]}),l.jsx($a,{title:"Light bumps (raw)",children:u.map(h=>l.jsx(Jn,{label:h.label,value:tr(h.value)},h.label))}),l.jsx($a,{title:"Cliff sensors",children:f.map(h=>l.jsx(Jn,{label:h.label,value:`${tr(h.value)} · ${h.active?"bool: true":"bool: false"}`},h.label))}),l.jsx($a,{title:"Currents",children:p.map(h=>l.jsx(Jn,{label:h.label,value:l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:tr(h.value,"mA")}),h.over?l.jsx(er,{active:!0,tone:"red",label:"over"}):null]})},h.label))}),l.jsxs($a,{title:"Dirt detect",children:[l.jsx(Jn,{label:"Left",value:tr(n?.dirtDetectLeft)}),l.jsx(Jn,{label:"Right",value:tr(n?.dirtDetect)})]})]})}function $a({title:n,children:a}){return l.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[l.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:n}),l.jsx("div",{className:"space-y-0.5",children:a})]})}function Jn({label:n,value:a}){return l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-300",children:n}),l.jsx("span",{className:"text-slate-100",children:a})]})}function er({active:n,tone:a="green",label:r}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",u=a==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":a==="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 l.jsx("span",{className:`${o} ${u}`,children:r||(n?"true":"false")})}function tr(n,a){return n==null||Number.isNaN(n)?"--":a?`${n} ${a}`:n}function bj({sensors:n}){const a=n?.infraredCharacterLeft,r=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,u=f=>l.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${f?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:f||"--"});return l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"L"}),u(a)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"O"}),u(o)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"R"}),u(r)]})]})}function yj({state:n}){if(!n)return null;const a=o=>{const u=[];return o?.red&&u.push("R"),o?.green&&u.push("G"),o?.force&&u.push("F"),u.length?u.join(""):"none"},r=o=>o?.age!=null?`${o.age}ms`:"--";return l.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Left: ${n.left.code??"--"} (${a(n.left)}) · age ${r(n.left)}`}),l.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${a(n.omni)}) · age ${r(n.omni)}`}),l.jsx("div",{children:`Right: ${n.right.code??"--"} (${a(n.right)}) · age ${r(n.right)}`})]})}const fg=m.createContext(null);function Sj({children:n}){const[a,r]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const h=Ed();r({status:"ready",data:h??{}})},[]);const o=m.useCallback(()=>{const h=Ed();r({status:"ready",data:h??{}})},[]),u=m.useCallback(h=>{const g=Up(h??{});return r(g?{status:"ready",data:h??{}}:x=>({...x,status:"error"})),g},[]),f=m.useCallback((h,g)=>{r(x=>{const v=x.data[h]||{},b=typeof g=="function"?g(v):{...v,...g??{}},S={...x.data,[h]:b};return Up(S)?{status:"ready",data:S}:{...x,status:"error"}})},[]),p=m.useMemo(()=>({data:a.data,status:a.status,reload:o,saveAll:u,setNamespace:f}),[a,o,u,f]);return l.jsx(fg.Provider,{value:p,children:n})}function jj(){const n=m.useContext(fg);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Oe(n,a={}){const{data:r,status:o,setNamespace:u}=jj(),f=r[n]??a??{},p=m.useCallback(x=>{u(n,v=>{const b=v??{};return typeof x=="function"?x(b):{...b,...x??{}}})},[n,u]),h=m.useCallback(x=>{u(n,()=>x??{})},[n,u]),g=m.useCallback(()=>{const x=typeof a=="object"?{...a}:a;u(n,()=>x??{})},[a,n,u]);return{value:f,status:o,save:p,replace:h,reset:g}}const Nj=/^#[0-9A-Fa-f]{6}$/;function ef(n){const a=typeof n=="string"?n.trim():"";return!a||!Nj.test(a)?null:a.toUpperCase()}function ns(n,a=.2){const r=ef(n);if(!r)return;const o=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.2,u=mg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.65)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function wj(n,a=.2){const r=ef(n);if(!r)return;const o=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.2,u=mg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.55)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function mg(n){const a=ef(n);return a?{r:parseInt(a.slice(1,3),16),g:parseInt(a.slice(3,5),16),b:parseInt(a.slice(5,7),16)}:null}function Aj(n=[]){return n.map(a=>!a?.type||!a?.id?null:{type:a.type,id:String(a.id),label:a.label||String(a.id),color:a.color||null,key:`${a.type}:${a.id}`}).filter(Boolean)}function tf({panelId:n="replay-sources",fillHeight:a=!1}){const r=oe(M=>M.session?.replaySources??[]),o=oe(M=>M.session?.mode||null),u=oe(M=>M.session?.assignment?.roverId??null),f=oe(M=>M.session?.users??[]),p=oe(M=>M.session?.socketId||null),h=oe(M=>M.session?.roster??[]),g=oe(M=>M.session?.replay||null),{triggerReplay:x}=Ot(),v=Aj(r||[]),{value:b,save:S}=Oe("replaySources",{}),[C,E]=m.useState([]),[N,w]=m.useState(!1),[j,R]=m.useState(null),[k,T]=m.useState(null),[q,$]=m.useState(""),[O,L]=m.useState(!1),[F,U]=m.useState(!0),[Z,Q]=m.useState(0),ce=m.useMemo(()=>{const M=u;return M?[`rover:${M}`]:[]},[u]),ue=m.useMemo(()=>{const D=((Array.isArray(f)?f.find(he=>he?.socketId===p):null)?.nickname||"Someone").trim()||"Someone",K=u||null,ae=K&&Array.isArray(h)?h.find(he=>String(he?.id)===String(K))?.name||K:"a rover";return`${D} driving ${ae}`},[f,p,u,h]);m.useEffect(()=>{E(ce)},[ce]),m.useEffect(()=>{const M=b?.[`${n}:includeSidebar`];if(typeof M=="boolean"){U(M);return}U(!0)},[b?.[`${n}:includeSidebar`],n]),m.useEffect(()=>{const M=b?.[`${n}:title`];if(typeof M=="string"){$(M),L(!0);return}L(!1)},[b?.[`${n}:title`],n]),m.useEffect(()=>{O||$(ue)},[ue,O]),m.useEffect(()=>{const M=new Set(v.map(D=>D.key));E(D=>D.filter(K=>M.has(K)))},[v]);const le=m.useMemo(()=>({rovers:v.filter(M=>M.type==="rover"),rooms:v.filter(M=>M.type==="room")}),[v]);m.useEffect(()=>{if(!g?.lastTriggeredAt||!g?.cooldownMs){Q(0);return}const M=()=>{const K=g.lastTriggeredAt+g.cooldownMs-Date.now();Q(Math.max(0,K))};M();const D=setInterval(M,250);return()=>clearInterval(D)},[g?.lastTriggeredAt,g?.cooldownMs,g?.remainingMs]);const B=N||o==="lockdown"||Z>0||!C.length,V=M=>{E(D=>D.includes(M)?D.filter(K=>K!==M):[...D,M]),T(null)},I=async()=>{if(!B){w(!0),R(null),T(null);try{const M=C.map(K=>{const[ae,he]=K.split(":");return{type:ae,id:he}}),D=String(q||"").trim()||ue;await x({sources:M,title:D,includeSidebar:F}),T("Replay sent. Check the Discord replay channel.")}catch(M){R(M.message)}finally{w(!1)}}},J=a?"h-full flex flex-col":"",ie=a?"flex-1 min-h-0 overflow-y-auto":"";return l.jsxs("section",{className:`panel-section p-0.75 text-sm ${J}`,children:[l.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[l.jsx("span",{children:"Replay Sources"}),l.jsx("span",{children:v.length})]}),l.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${ie}`,children:[l.jsx(Hp,{title:"Rovers",items:le.rovers,selected:C,onToggle:V}),l.jsx(Hp,{title:"Room Cams",items:le.rooms,selected:C,onToggle:V})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("label",{className:"panel-muted block text-xs",htmlFor:`${n}-title`,children:"Replay title"}),l.jsx("input",{id:`${n}-title`,type:"text",className:"field-input w-full text-xs",value:q,onChange:M=>{const D=M.target.value;$(D),L(!0),S(K=>({...K||{},[`${n}:title`]:D}))},placeholder:ue,maxLength:120}),l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:F,onChange:M=>{const D=!!M.target.checked;U(D),S(K=>({...K||{},[`${n}:includeSidebar`]:D}))},className:"accent-emerald-400"}),l.jsx("span",{children:"Include replay sidebar"})]}),l.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:I,disabled:B,children:Z>0?`Replay (${Math.ceil(Z/1e3)}s)`:N?"Replay…":"Replay"}),j?l.jsx("div",{className:"text-xs text-amber-400",children:j}):null,k?l.jsx("div",{className:"text-xs text-emerald-300",children:k}):null]})]})}function Hp({title:n,items:a,selected:r,onToggle:o}){return a.length?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs",children:n}),l.jsx("div",{className:"space-y-0.5",children:a.map(u=>l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:r.includes(u.key),onChange:()=>o(u.key),className:"accent-emerald-400"}),l.jsx("span",{className:`truncate ${u.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:u.type==="rover"?ns(u.color,.16):void 0,children:u.label})]},u.key))})]}):null}var hg={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Vp=Dt.createContext&&Dt.createContext(hg),Cj=["attr","size","title"];function kj(n,a){if(n==null)return{};var r=Ej(n,a),o,u;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(n);for(u=0;u<f.length;u++)o=f[u],!(a.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(r[o]=n[o])}return r}function Ej(n,a){if(n==null)return{};var r={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(a.indexOf(o)>=0)continue;r[o]=n[o]}return r}function oo(){return oo=Object.assign?Object.assign.bind():function(n){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])}return n},oo.apply(this,arguments)}function $p(n,a){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);a&&(o=o.filter(function(u){return Object.getOwnPropertyDescriptor(n,u).enumerable})),r.push.apply(r,o)}return r}function co(n){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?$p(Object(r),!0).forEach(function(o){Mj(n,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):$p(Object(r)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(r,o))})}return n}function Mj(n,a,r){return a=Rj(a),a in n?Object.defineProperty(n,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[a]=r,n}function Rj(n){var a=Tj(n,"string");return typeof a=="symbol"?a:a+""}function Tj(n,a){if(typeof n!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var o=r.call(n,a);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function pg(n){return n&&n.map((a,r)=>Dt.createElement(a.tag,co({key:r},a.attr),pg(a.child)))}function yr(n){return a=>Dt.createElement(qj,oo({attr:co({},n.attr)},a),pg(n.child))}function qj(n){var a=r=>{var{attr:o,size:u,title:f}=n,p=kj(n,Cj),h=u||r.size||"1em",g;return r.className&&(g=r.className),n.className&&(g=(g?g+" ":"")+n.className),Dt.createElement("svg",oo({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,o,p,{className:g,style:co(co({color:n.color||r.color},r.style),n.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),f&&Dt.createElement("title",null,f),n.children)};return Vp!==void 0?Dt.createElement(Vp.Consumer,null,r=>a(r)):a(hg)}function xg(n){return yr({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 Dj(n){return yr({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 Gp(n){return yr({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 _j(n){return yr({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 Oj(n){return yr({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 Bj(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 nf(n){return!!n?.bot}function Lj(n){const a=new Date(n);return`${a.getHours().toString().padStart(2,"0")}:${a.getMinutes().toString().padStart(2,"0")}`}function td(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function zj({guildIconUrl:n,userAvatarUrl:a,label:r}){return!n&&!a?null:l.jsxs("span",{className:"flex h-4 w-4 shrink-0 overflow-hidden rounded-none border border-slate-700/80",title:r,children:[l.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}),l.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${a?"bg-cover":""}`,style:a?{backgroundImage:`url(${a})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function Uj({imageUrl:n,label:a}){return n?l.jsx("span",{className:"flex h-4 w-4 shrink-0 overflow-hidden rounded-none border border-slate-700/80",title:a,children:l.jsx("span",{className:"h-full w-full bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${n})`}})}):null}function gg({message:n,toolsToggle:a=null}){const r=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${td(n)}`:null,o=nf(n),u=o?"text-emerald-300":Bj(n.role);return l.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 align-middle",children:[n.fromDiscord?l.jsx(xg,{className:"h-4 w-4 shrink-0 text-indigo-200"}):null,l.jsx("span",{className:`font-semibold text-[0.85rem] ${u}`,children:td(n)}),l.jsx(Uj,{imageUrl:n.profileImage,label:r||td(n)}),n.profileImage?null:l.jsx(zj,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:r}),o?l.jsx("span",{className:"shrink-0 rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,n.roverId&&l.jsx("span",{className:"shrink-0 rounded bg-slate-800 px-1 text-[0.7rem]",style:wj(n.roverColor,.14),children:n.roverId}),a]})}function vg(n){return nf(n)?"surface-muted flex flex-col gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted flex flex-col 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 sf({message:n}){const a=nf(n),o=oe(v=>v.session?.role||null)==="spectator",[u,f]=m.useState(!1),p=o||u,h=Array.isArray(n?.toolCalls)?n.toolCalls:[],g=!!String(n?.text||"").trim(),x=h.length>0?l.jsxs("button",{type:"button",className:"shrink-0 rounded border border-slate-600/70 bg-slate-800/60 px-1 py-[1px] text-[0.65rem] text-slate-200 hover:bg-slate-700/70",onClick:()=>{o||f(v=>!v)},children:[p?"▼":"▶"," Tools (",h.length,")"]}):null;return l.jsxs("div",{className:vg(n),children:[l.jsxs("div",{className:"flex w-full items-start gap-0.5",children:[l.jsxs("span",{className:`min-w-0 flex-1 break-words leading-tight whitespace-pre-wrap ${a?"text-emerald-100":"text-slate-100"}`,children:[l.jsx(gg,{message:n,toolsToggle:x}),!p&&g?` ${n.text}`:""]}),l.jsx("span",{className:"shrink-0 text-[0.65rem] text-slate-400/60",children:Lj(n.ts)})]}),p&&h.length>0?l.jsx("div",{className:"w-full rounded border border-slate-700/70 bg-slate-900/70 p-0.5 text-[0.68rem] text-slate-200",children:h.map((v,b)=>{const S=String(v?.status||"unknown"),C=S==="ok"?"ok":S==="blocked"?"blocked":S==="error"?"error":"unknown",E=JSON.stringify(v?.args&&typeof v.args=="object"?v.args:{});return l.jsxs("div",{className:"mb-0.5 last:mb-0",children:[l.jsxs("div",{children:[C," ",v?.tool||"unknown"," args=",E]}),v?.error?l.jsxs("div",{className:"text-rose-300",children:["error: ",String(v.error)]}):null]},`${v?.tool||"tool"}-${b}`)})}):null,p&&g?l.jsx("div",{className:`w-full break-words leading-tight whitespace-pre-wrap ${a?"text-emerald-100":"text-slate-100"}`,children:n.text}):null]})}function bg({message:n}){return l.jsxs("div",{className:`${vg(n)} !flex-row items-center italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[l.jsx(gg,{message:n}),l.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function yg({buttonId:n,count:a,goal:r,rewardNumber:o,rewardName:u,className:f=""}){return l.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",f].filter(Boolean).join(" "),children:[l.jsxs("p",{className:"text-xs text-slate-400",children:["Button ",n]}),l.jsxs("p",{className:"text-sm font-semibold text-white",children:[a," / ",r]}),l.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",u]})]})}const Hj=3e3,Vj=3500,$j="#2196f3";function Gj(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function af({scale:n=1}){const a=oe(S=>S.alerts),r=oe(S=>S.session?.buttonBox?.buttons??[]),{pushAlert:o}=Ot(),u=Pt(),[f,p]=m.useState(()=>Date.now());m.useEffect(()=>{function S(C={}){const E=Number(C.buttonId);if(!Number.isFinite(E)||E<1||E>4)return;const w=(Array.isArray(r)?r:[]).find(q=>Number(q?.id)===E)||{},j=Number.isFinite(C.count)?C.count:Number(w.count)||0,R=Number.isFinite(w.goal)?w.goal:0,k=Number.isFinite(w.rewardNumber)?w.rewardNumber:"?",T=typeof w.rewardName=="string"&&w.rewardName.trim()?w.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${E}`,kind:"buttonbox-active",lifetimeMs:Vj,payload:{buttonId:E,count:j,goal:R,rewardNumber:k,rewardName:T}})}return u.on("buttonBox:increment",S),()=>{u.off("buttonBox:increment",S)}},[o,r,u]);const h=m.useMemo(()=>a.slice(-12).map(S=>({alert:S,key:Gj(S)})),[a]);m.useEffect(()=>{if(!h.length)return;const S=setInterval(()=>p(Date.now()),200);return()=>clearInterval(S)},[h.length]);const g=new Map;h.forEach(S=>{const C=f-(S.alert.receivedAt??S.alert.timestamp??0),E=Number.isFinite(S.alert.lifetimeMs)?S.alert.lifetimeMs:Hj;C<=E&&g.set(S.key,{...S,age:C})});const x=Array.from(g.values()).slice(-3);if(!x.length)return null;const v=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},b=n===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return l.jsx("div",{className:b,style:v,children:x.map(S=>l.jsx(Yj,{alert:S.alert},S.key))})}function Yp(n){const a=typeof n=="string"?n.trim():"",r=/^#?([0-9a-fA-F]{6})$/.exec(a);if(!r)return null;const o=r[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function Yj({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const u=n.payload;return l.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:l.jsx(yg,{buttonId:u.buttonId,count:u.count,goal:u.goal,rewardNumber:u.rewardNumber,rewardName:u.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return l.jsx(sf,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return l.jsx(bg,{message:n.payload});const a=Yp(n.color)||Yp($j),r=a?`rgba(${a.r}, ${a.g}, ${a.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=a?`rgba(${a.r}, ${a.g}, ${a.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return l.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:r,border:`1px solid ${o}`},children:l.jsxs("p",{className:"truncate text-slate-100",children:[l.jsx("span",{className:"text-slate-300",children:n.title||"Alert"}),l.jsx("span",{className:"text-slate-500",children:" · "}),l.jsx("span",{className:"text-white",children:n.message})]})})}const Ga={main:[-127,127],side:[-127,127],vacuum:[0,127]},nd={maxSpeed:500,baseSpeed:250,boostSpeed:400},Fj=60,Rd=100,lf=[31,127],Za=60,Td=8,Ij=250,Xj=4e3,uo=2e3,$i=.4,Fp=.2,Ip=.8,Qj={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},ir={driveForward:["w"],driveBackward:["s"],driveLeft:["a"],driveRight:["d"],boostModifier:["\\"],slowModifier:["shift"],auxMainForward:["i"],auxMainReverse:["k"],auxSideForward:["o"],auxSideReverse:["l"],auxVacuumFast:["p"],auxVacuumSlow:[";"],auxAllForward:[","],cameraUp:["u"],cameraDown:["j"],nightVisionToggle:["e"],hornHonk:["h"],micPtt:["m"],driveMacro:["f"],dockMacro:["g"],chatFocus:["enter"],songNoteUp:["ArrowUp"],songNoteDown:["ArrowDown"],homeAssistantOn:["ArrowRight"],homeAssistantOff:["ArrowLeft"]},Sg=[{id:"drive-sequence",label:"Drive",description:"Start, undock, and full command sequence used by the drive button.",steps:[{type:"servo",angle:0},{type:"oi",command:"start"},{type:"pause",duration:Rd},{type:"oi",command:"dock"},{type:"pause",duration:Rd},{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}}]}];function qd(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Dd(){return{main:0,side:0,vacuum:0}}function Kj(){return{enabled:!1,angle:null,config:null}}function so(){return{note:Za}}function lr(){return{active:!1,heat:0,overheated:!1}}function ao(){return{pttActive:!1}}function _d(){return{active:!1}}const Xp={roverId:null,mode:"drive",drive:qd(),aux:Dd(),camera:Kj(),song:so(),horn:lr(),mic:ao(),manualDockAssist:_d(),lastControlIntentAt:0,macros:Sg,keymap:ir,inputs:{}};function Zj(n,a){switch(a.type){case"control/set-rover":return{...n,roverId:a.payload??null,drive:a.payload?n.drive:qd(),aux:a.payload?n.aux:Dd(),song:a.payload?n.song:so(),horn:a.payload?n.horn:lr(),mic:a.payload?n.mic:ao(),manualDockAssist:a.payload?n.manualDockAssist:_d(),lastControlIntentAt:a.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===a.payload?n:{...n,mode:a.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:r,speeds:o,source:u}=a.payload;return{...n,drive:{vector:r??n.drive.vector,speeds:o??n.drive.speeds,source:u??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...a.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!a.payload?.config,config:a.payload?.config??null,angle:typeof a.payload?.angle=="number"?a.payload.angle:a.payload?.config?a.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:a.payload}};case"control/register-input-state":{const r=a.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[r]:{...n.inputs[r]??{},...a.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...a.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(a.payload)?a.payload:n.macros};case"control/reset":return{...n,drive:qd(),aux:Dd(),song:so(),horn:lr(),mic:ao(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||lr(),active:!!a.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||lr(),heat:typeof a.payload?.heat=="number"?a.payload.heat:0,overheated:!!a.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||so(),note:a.payload??Za}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||ao(),pttActive:!!a.payload}};case"control/set-manual-dock-assist":return{...n,manualDockAssist:{...n.manualDockAssist||_d(),active:!!a.payload}};default:return n}}function Ja(n,a,r){return typeof n!="number"||Number.isNaN(n)?a:Math.max(a,Math.min(r,n))}function Pa(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function hn(n,a){return!Array.isArray(a)||a.length!==2?n:Ja(n,a[0],a[1])}function Jj(n={}){const a=Pa(n.x??0),r=Pa(n.y??0);return{x:a,y:r,boost:!!n.boost}}function Pj(n={},a={}){const r=Jj(n),o=typeof a.maxSpeed=="number"?a.maxSpeed:nd.maxSpeed,u=typeof a.baseSpeed=="number"?a.baseSpeed:nd.baseSpeed,f=typeof a.boostSpeed=="number"?a.boostSpeed:nd.boostSpeed,p=r.boost?f:u,h=r.y*p,g=r.x*p;return{vector:r,speeds:{left:Ja(Math.round(h+g),-o,o),right:Ja(Math.round(h-g),-o,o)}}}function Wj(n){const a=Array.isArray(n)?n:[],r=String.fromCharCode(...a);if(typeof btoa=="function")return btoa(r);if(typeof Buffer<"u")return Buffer.from(a).toString("base64");throw new Error("No base64 encoder available")}function Qp(n){return new Promise(a=>setTimeout(a,n))}function eN(n={}){const{driveTransform:a,auxTransform:r}=n,o=Pt(),u=oe(q=>q.session?.assignment?.roverId??null),f=oe(q=>q.session?.roster??[]),p=m.useMemo(()=>!u||!Array.isArray(f)?null:f.find(q=>String(q.id)===String(u))||null,[u,f]),h=m.useMemo(()=>!p?.cameraServo||!p.cameraServo.enabled?null:p.cameraServo,[p]),g=m.useMemo(()=>!p?.nightVision||!p.nightVision.enabled?null:p.nightVision,[p]),x=m.useMemo(()=>!p?.horn||!p.horn.enabled?null:p.horn,[p]),v=m.useMemo(()=>p?.nightVision?.state??null,[p]),b=m.useCallback((q,$)=>{u&&o.emit("command",{roverId:u,...q},$)},[o,u]),S=m.useCallback(()=>{u&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,u]),C=m.useCallback(q=>{if(!u)return null;const $={left:hn(q?.left??0,[-500,500]),right:hn(q?.right??0,[-500,500])},O=a?a($):$,L={left:hn(O?.left??0,[-500,500]),right:hn(O?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:L}}),L},[a,b,u]),E=m.useCallback(({main:q=0,side:$=0,vacuum:O=0}={})=>{if(!u)return null;const L={main:hn(q,Ga.main),side:hn($,Ga.side),vacuum:hn(O,Ga.vacuum)},F=r?r(L):L,U={main:hn(F?.main??0,Ga.main),side:hn(F?.side??0,Ga.side),vacuum:hn(F?.vacuum??0,Ga.vacuum)};return b({type:"motors",data:{motorPwm:U}}),U},[r,b,u]),N=m.useCallback(q=>!u||!h?null:(b({type:"servo",data:{servo:{angle:q}}}),q),[b,u,h]),w=m.useCallback(q=>{if(!u)return!1;const $=Array.isArray(q)?q:typeof q=="string"?Qj[q]:null;return $?(b({type:"raw",data:{raw:Wj($)}}),S(),!0):!1},[b,S,u]),j=m.useCallback(async q=>{if(!(!q||!Array.isArray(q.steps)||!u))for(const $ of q.steps){if(!u)break;switch($.type){case"oi":w($.command);break;case"drive":C($.speeds??{left:0,right:0});break;case"motors":E($.values??{});break;case"servo":N($.angle);break;case"pause":await Qp($.duration??Rd);break}if($.delay||$.delayMs){const O=$.delayMs??$.delay;typeof O=="number"&&O>0&&await Qp(O)}}},[u,w,C,E,N]),R=m.useCallback((q="toggle")=>!u||!g?null:(b({type:"nightVision",data:{nightVision:{action:q}}}),q),[b,g,u]),k=m.useCallback(q=>u?(b({type:"horn",data:{horn:q}}),q):null,[b,u]),T=m.useCallback((q=[],$={})=>{if(!u)return null;const L=(Array.isArray(q)&&q.length>0?q:[{note:Za,duration:Td}]).slice(0,16).map(F=>({note:hn(Math.round(F?.note??Za),lf),duration:hn(Math.round(F?.duration??Td),[1,255])}));return b({type:"song",data:{song:{notes:L,slot:$.slot,loop:$.loop}}}),L},[b,u]);return m.useMemo(()=>({roverId:u,rosterEntry:p,servoConfig:h,nightVision:g,nightVisionState:v,horn:x,emitCommand:b,enableSensorStream:S,sendDriveDirect:C,sendAuxMotors:E,sendServoAngle:N,sendOiCommand:w,sendNightVision:R,sendHorn:k,sendSong:T,runMacroSteps:j}),[u,p,h,g,v,x,b,S,C,E,N,w,R,k,j])}const tN={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Kp={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function Sr(n){if(typeof n!="string")return"";const a=n.toLowerCase();return tN[a]??a}function nN(n){const a=Sr(n);if(!a)return null;if(Kp[a])return Kp[a];if(a.length===1){if(/[a-z]/.test(a))return`Key${a.toUpperCase()}`;if(/[0-9]/.test(a))return`Digit${a}`}return null}function jg(n){const a=Sr(n);return a?`key:${a}`:null}function sN(n){const a=nN(n);return a?`code:${a}`:null}function Zp(n){const a=new Set,r=jg(n?.key??"");r&&a.add(r);const o=n?.code?`code:${n.code}`:null;return o&&a.add(o),Array.from(a)}function aN(n={}){return Object.fromEntries(Object.entries(n).map(([a,r])=>{const o=Array.isArray(r)?r:[r],u=new Set;return o.forEach(f=>{const p=jg(String(f));p&&u.add(p);const h=sN(String(f));h&&u.add(h)}),[a,u]}))}function Tt(n){const a=Sr(n);return a?a===" "?"Space":a==="\\"?"Backslash":a==="`"?"Backtick":a==="["?"[ or {":a==="]"?"] or }":a===";"?"; or :":a==="'"?`' or "`:a===","?", or <":a==="."?". or >":a==="/"?"/ or ?":a==="-"?"- or _":a==="="?"= or +":a==="arrowup"?"Arrow Up":a==="arrowdown"?"Arrow Down":a==="arrowleft"?"Arrow Left":a==="arrowright"?"Arrow Right":a.length===1?a.toUpperCase():a:"—"}const En={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},Wn={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}]}}},Es={activeSignature:null,profiles:{},defaults:{profile:Wn}},ta={waveform:"saw",freqs:[440,550,660,0]},it={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},Ws=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],lN={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function Jp(){return Ws.reduce((n,a)=>(n[a.key]={cap:1,clearSec:0},n),{})}function Pp(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function Ng(n,a={}){const r=oe(j=>j.session?.role||null),f=(Wt(n)?.sensors||{})?.wheelOvercurrents||{},p=m.useMemo(()=>({...lN,...a.config||{}}),[a.config]),[h,g]=m.useState(()=>Jp()),x=m.useRef(0),v=m.useRef(f);m.useEffect(()=>{v.current=f||{}},[f]),m.useEffect(()=>{g(Jp()),x.current=0},[n]);const b=m.useMemo(()=>Ws.some(j=>j.motors.some(R=>!!f?.[R])),[f]),S=m.useMemo(()=>Object.values(h||{}).some(j=>(Number.isFinite(j?.cap)?j.cap:1)<.999),[h]),C=!!n&&(b||S);m.useEffect(()=>{if(!C)return;x.current=typeof performance<"u"?performance.now():Date.now();const j=setInterval(()=>{const R=typeof performance<"u"?performance.now():Date.now(),k=Math.max(0,R-x.current);x.current=R;const T=Math.min(.25,k/1e3);T<=0||g(q=>{let $=!1;const O={},L=Number.isFinite(p.downRatePerSec)?Math.max(0,p.downRatePerSec):0,F=Number.isFinite(p.upRatePerSec)?Math.max(0,p.upRatePerSec):0,U=Number.isFinite(p.releaseDelaySec)?Math.max(0,p.releaseDelaySec):0;return Ws.forEach(Z=>{const Q=q[Z.key]||{cap:1,clearSec:0},ce=Number.isFinite(Q.cap)?Q.cap:1,ue=Number.isFinite(Q.clearSec)?Q.clearSec:0,le=Z.motors.some(J=>!!v.current?.[J]),B=le?0:ue+T,V=!le&&B>=U,I=Pp(le?ce-L*T:V?ce+F*T:ce);(Math.abs(I-ce)>1e-4||Math.abs(B-ue)>1e-4)&&($=!0),O[Z.key]={cap:I,clearSec:B}}),$?O:q})},100);return()=>clearInterval(j)},[p.downRatePerSec,p.releaseDelaySec,p.upRatePerSec,n,C]);const E=m.useMemo(()=>{const j=Ws.reduce((R,k)=>{const T=h?.[k.key],q=Number.isFinite(T?.cap)?T.cap:1;return R[k.key]=Pp(q),R},{});return{perGroup:j,drive:{left:j.drive??1,right:j.drive??1},aux:{main:j.aux??1,side:j.aux??1,vacuum:1}}},[h]),N=m.useMemo(()=>{const j={};Ws.forEach(k=>{k.motors.forEach(T=>{j[T]=!!f?.[T]})});const R=Ws.reduce((k,T)=>(k[T.key]=T.motors.some(q=>!!f?.[q]),k),{});return{motors:j,groups:R}},[f]),w=r==="admin"||r==="lockdown"||r==="lockdown-admin";return m.useMemo(()=>({caps:h,overcurrent:N,scales:E,isActive:(E?.drive?.left??1)<1||(E?.drive?.right??1)<1||(E?.aux?.main??1)<1||(E?.aux?.side??1)<1,config:p,adminImmune:w}),[h,N,E,p,w])}function rN(n={},a,r=!1){if(r||!a?.drive)return n;const o=typeof a.drive.left=="number"?a.drive.left:1,u=typeof a.drive.right=="number"?a.drive.right:1;return o>=.999&&u>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*u)}}function iN(n={},a,r=!1){if(r||!a?.aux)return n;const o=typeof a.aux.main=="number"?a.aux.main:1,u=typeof a.aux.side=="number"?a.aux.side:1,f=typeof a.aux.vacuum=="number"?a.aux.vacuum:1;return o>=.999&&u>=.999&&f>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*u),vacuum:Math.round((n.vacuum??0)*f)}}const wg=m.createContext(null);function Wp(n){return Object.fromEntries(Object.entries(n||{}).map(([a,r])=>[a,Array.isArray(r)?[...r]:[]]))}function oN(n,a){if(!n)return a;const r=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return Ja(a,r,o)}function cN(n=[]){if(!Array.isArray(n)||n.length<3)return n;const a=n.slice(-3),[r,o,u]=a,f=r?.type==="drive"&&Number(r?.speeds?.left)===-300&&Number(r?.speeds?.right)===-300,p=o?.type==="pause"&&Number(o?.duration)===600,h=u?.type==="drive"&&Number(u?.speeds?.left)===0&&Number(u?.speeds?.right)===0;return!f||!p||!h?n:n.slice(0,-3)}function uN({children:n}){const[a,r]=m.useReducer(Zj,Xp),o=m.useRef(null),u=m.useRef(!1),f=m.useRef(Xp.camera.angle),p=m.useRef(null),h=m.useRef(0),g=m.useRef(0),{value:x,save:v}=Oe("controls",{keymap:ir,macros:Sg}),{value:b}=Oe("page",{driveMacroBackoffEnabled:!0}),{value:S}=Oe("horn",ta),C=typeof b?.driveMacroBackoffEnabled=="boolean"?b.driveMacroBackoffEnabled:!0,E=oe(se=>se.session?.assignment?.roverId??null),N=oe(se=>se.session?.homeAssistant?.entities??[]),{homeAssistantSetState:w}=Ot(),j=Ng(E),R=m.useCallback(se=>rN(se,j.scales,j.adminImmune),[j.adminImmune,j.scales]),k=m.useCallback(se=>iN(se,j.scales,j.adminImmune),[j.adminImmune,j.scales]),T=eN({driveTransform:R,auxTransform:k}),q=m.useCallback(()=>{const re=(N||[]).filter(de=>(de.type==="light"||de.type==="switch")&&de.available!==!1&&de.state!=="on");if(re.length===0){u.current=!1;return}u.current=!0,re.forEach(de=>{w(de.id,"on").catch(()=>{})}),u.current=!1},[N,w]);m.useEffect(()=>{r({type:"control/set-rover",payload:T.roverId})},[T.roverId]),m.useEffect(()=>{const se=o.current;o.current=a.mode,se!=="drive"&&a.mode==="drive"&&N?.length?q():se!=="drive"&&a.mode==="drive"&&(u.current=!0)},[a.mode,N,q]),m.useEffect(()=>{u.current&&N?.length&&q()},[N,q]),m.useEffect(()=>{const se={...ir,...x?.keymap||{}};r({type:"control/set-keymap",payload:se}),x?.macros&&r({type:"control/set-macros",payload:x.macros})},[x?.keymap,x?.macros]),m.useEffect(()=>{const se=T.servoConfig;if(!se){r({type:"control/set-camera-config",payload:{config:null}}),f.current=null;return}const re=typeof se.minAngle=="number"?se.minAngle:-45,de=typeof se.maxAngle=="number"?se.maxAngle:45,fe=typeof se.homeAngle=="number"?se.homeAngle:(re+de)/2,Re=typeof f.current=="number"?Ja(f.current,re,de):null,te=Re??Ja(fe,re,de);r({type:"control/set-camera-config",payload:{config:se,angle:te}}),f.current=te},[T.servoConfig]),m.useEffect(()=>{f.current=typeof a.camera.angle=="number"?a.camera.angle:f.current},[a.camera.angle]),m.useEffect(()=>{T.roverId&&T.enableSensorStream()},[T.roverId,T.enableSensorStream]);const $=m.useCallback(se=>{r({type:"control/set-mode",payload:se})},[]),O=m.useCallback(()=>{r({type:"control/record-intent"})},[]),L=m.useRef(a.drive.speeds),F=m.useRef(a.aux),U=m.useMemo(()=>JSON.stringify(j.scales),[j.scales]),Z=m.useRef(0),Q=m.useRef(0);m.useEffect(()=>{L.current=a.drive.speeds},[a.drive.speeds]),m.useEffect(()=>{F.current=a.aux},[a.aux]),m.useEffect(()=>{if(!T.roverId||j.adminImmune||!j.isActive)return;const se=Math.max(0,Number(j?.config?.outputRateMs)||0),re=typeof performance<"u"?performance.now():Date.now(),de=L.current||{left:0,right:0},fe=F.current||{main:0,side:0,vacuum:0},Re=!!(de.left||de.right),te=!!(fe.main||fe.side||fe.vacuum);!Re&&!te||(Re&&re-Z.current>=se&&(Z.current=re,T.sendDriveDirect(de)),te&&re-Q.current>=se&&(Q.current=re,T.sendAuxMotors(fe)))},[U,j.adminImmune,j.config,j.isActive,T]);const ce=m.useCallback((se,re={})=>{const de={...re.speedOptions||{}};if(a.manualDockAssist?.active){const Re=Math.max(1,Math.min(Fj,500));de.maxSpeed=Math.min(typeof de.maxSpeed=="number"?de.maxSpeed:Re,Re),de.baseSpeed=Math.min(typeof de.baseSpeed=="number"?de.baseSpeed:Re,Re),de.boostSpeed=Math.min(typeof de.boostSpeed=="number"?de.boostSpeed:Re,Re)}const fe=Pj(se,de);r({type:"control/update-drive",payload:{...fe,source:re.source??null}}),O(),T.sendDriveDirect(fe.speeds)},[T,O,a.manualDockAssist?.active]),ue=m.useCallback((se={})=>{const re=T.sendAuxMotors(se)??se;r({type:"control/set-aux-motors",payload:re}),O()},[T,O]),le=m.useCallback((se,re)=>{if(!se)return!1;const de=Sr(re);if(!de)return!1;const fe=Wp(a.keymap);return fe[se]=[de],r({type:"control/set-keymap",payload:fe}),v(Re=>({...Re??{},keymap:fe})),!0},[a.keymap,v]),B=m.useCallback(()=>{const se=Wp(ir);r({type:"control/set-keymap",payload:se}),v(re=>({...re??{},keymap:se}))},[v]),V=m.useCallback((se,re={})=>{if(!T.servoConfig)return;const de=!!re?.force;if(a.manualDockAssist?.active&&!de)return;const fe=oN(T.servoConfig,se);r({type:"control/set-camera-angle",payload:fe}),T.sendServoAngle(fe),f.current=fe,O()},[T,O,a.manualDockAssist?.active]),I=m.useCallback((se=0)=>{const re=T.servoConfig;if(!re)return;const de=typeof se=="number"&&se!==0?se:re.nudgeDegrees||1,fe=typeof f.current=="number"?f.current:typeof re.homeAngle=="number"?re.homeAngle:0;V(fe+de)},[T.servoConfig,V]),J=m.useCallback(()=>{const se=T.servoConfig;if(!se)return;const re=typeof se.homeAngle=="number"?se.homeAngle:typeof se.minAngle=="number"&&typeof se.maxAngle=="number"?(se.minAngle+se.maxAngle)/2:0;V(re)},[T.servoConfig,V]),ie=m.useCallback(async se=>{const re=a.macros.find(fe=>fe.id===se)||null;if(!re)return;let de=re;se==="drive-sequence"&&(q(),N?.length||(u.current=!0),O(),C||(de={...re,steps:cN(re.steps)})),await T.runMacroSteps(de)},[C,T,O,N,a.macros,q]),M=m.useCallback(()=>{r({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),T.sendDriveDirect({left:0,right:0}),T.sendAuxMotors({main:0,side:0,vacuum:0})},[T]),D=m.useCallback(se=>{T.sendOiCommand(se)},[T]),K=m.useCallback(se=>{T.roverId&&T.emitCommand({type:"sensorStream",data:{sensorStream:{enable:se}}})},[T]),ae=m.useCallback(se=>{if(T.nightVision){if(typeof se=="boolean"){const re=se?"off":"on";T.sendNightVision(re)}else T.sendNightVision("toggle");O()}},[T,O]),he=m.useCallback(()=>{ae()},[ae]),we=m.useCallback(se=>{const re=typeof se=="number"?se:Za;return r({type:"control/set-song-note",payload:re}),re},[]),pe=m.useCallback((se,re)=>T.sendSong(se,re),[T]),ge=m.useMemo(()=>{const se=S??ta,re=se.waveform==="sine"?"sine":"saw",fe=[...Array.isArray(se.freqs)?se.freqs:ta.freqs,0,0,0,0].slice(0,4).map(Re=>{const te=Number(Re);return Number.isFinite(te)?te<=0?0:Math.min(uo,Math.round(te)):0});return{waveform:re,freqs:fe}},[S]),xe=m.useCallback(()=>{if(!T.horn)return;if(a.horn?.overheated||(a.horn?.heat??0)>=1||a.horn?.active)return!1;const se=Date.now();return T.sendHorn({action:"start",...ge}),r({type:"control/set-horn-active",payload:!0}),h.current=se,g.current=se,p.current&&(clearTimeout(p.current),p.current=null),p.current=setTimeout(()=>{ye()},Xj),O(),!0},[r,ge,T,O,a.horn?.active,a.horn?.heat,a.horn?.overheated]),ye=m.useCallback(()=>{if(!T.horn)return;T.sendHorn({action:"stop"}),r({type:"control/set-horn-active",payload:!1}),p.current&&(clearTimeout(p.current),p.current=null);const se=Date.now(),re=h.current||se,de=Math.max(0,se-re);if(h.current=0,de>0){const fe=a.horn?.heat??0,Re=de/1e3*$i;let te=Math.max(0,Math.min(1,fe+Re)),me=a.horn?.overheated??!1;te>=1&&(te=1,me=!0),r({type:"control/set-horn-heat",payload:{heat:te,overheated:me}})}},[r,T,a.horn?.heat,a.horn?.overheated,$i]),Ce=m.useRef({active:!!a.horn?.active,heat:a.horn?.heat??0,overheated:!!a.horn?.overheated}),qe=m.useRef(ye);m.useEffect(()=>{Ce.current={active:!!a.horn?.active,heat:a.horn?.heat??0,overheated:!!a.horn?.overheated}},[a.horn?.active,a.horn?.heat,a.horn?.overheated]),m.useEffect(()=>{qe.current=ye},[ye]);const Ze=!!a.horn?.active||(a.horn?.heat??0)>0||!!a.horn?.overheated;m.useEffect(()=>{if(!Ze)return;const re=setInterval(()=>{const de=Date.now(),fe=g.current||de;g.current=de;const Re=Math.min(1e3,Math.max(0,de-fe))/1e3,te=Ce.current,me=te.heat??0,_e=!!te.active,en=!!te.overheated,tn=Re*(_e?$i:-Fp);let nn=Math.max(0,Math.min(1,me+tn)),Nt=en;nn>=1?(nn=1,Nt=!0,_e&&qe.current()):Nt&&nn<=Ip&&(Nt=!1),(nn!==me||Nt!==en)&&r({type:"control/set-horn-heat",payload:{heat:nn,overheated:Nt}})},100);return()=>clearInterval(re)},[r,Ze,Fp,Ip,$i]);const Se=m.useCallback(se=>{const re=!!se;if(!!a.manualDockAssist?.active===re)return;if(r({type:"control/set-manual-dock-assist",payload:re}),!re){T.sendSong([{note:83,duration:10},{note:76,duration:10}],{slot:0}),V(0,{force:!0});return}const fe=typeof T.servoConfig?.minAngle=="number"?T.servoConfig.minAngle:-45;V(fe,{force:!0}),T.sendSong([{note:76,duration:10},{note:83,duration:10}],{slot:0}),O()},[T,O,V,a.manualDockAssist?.active]),at=m.useCallback(()=>{Se(!a.manualDockAssist?.active)},[Se,a.manualDockAssist?.active]),ht=m.useCallback((se,re)=>{r({type:"control/register-input-state",payload:{source:se,state:re}})},[]),Ge=m.useCallback(se=>{r({type:"control/set-mic-ptt",payload:!!se})},[]),je=m.useMemo(()=>({state:a,dispatch:r,pipeline:T,overcurrentLimiter:j,actions:{setMode:$,setDriveVector:ce,setAuxMotors:ue,setServoAngle:V,nudgeServo:I,goServoHome:J,runMacro:ie,stopAllMotion:M,sendOiCommand:D,setSensorStream:K,setNightVision:ae,toggleNightVision:he,updateKeyBinding:le,resetKeyBindings:B,registerInputState:ht,setManualDockAssistActive:Se,toggleManualDockAssist:at,setSongNote:we,sendSong:pe,startHorn:xe,stopHorn:ye,setMicPttActive:Ge}}),[a,T,j,$,ce,ue,V,I,J,ie,M,D,K,ae,he,le,B,ht,Se,at,we,pe,xe,ye,Ge]);return l.jsx(wg.Provider,{value:je,children:n})}function yt(){const n=m.useContext(wg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const dN="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=",Ag=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function fN({children:n}){const a=Pt(),r=oe(I=>I.session),{pushAlert:o}=Ot(),{value:u}=Oe("audio",it),{value:f}=Oe("profile",{nickname:"",profileImageUrl:""}),[p,h]=m.useState([]),[g,x]=m.useState([]),[v,b]=m.useState(!1),S=m.useRef(null),C=m.useRef(null),E=m.useRef(null),N=m.useRef(new Map),w=m.useRef(new Map),j=m.useRef({isTyping:!1,lastSent:0}),R=Number.isFinite(u?.masterVolume)?u.masterVolume:it.masterVolume,k=Number.isFinite(u?.alertVolume)?u.alertVolume:it.alertVolume,T=Math.max(0,Math.min(1,R*k)),$=!!r?.isVerified?String(f?.profileImageUrl||"").trim():"",O=m.useCallback(()=>{const I=Array.from(N.current.values()).sort((J,ie)=>J.lastUpdate-ie.lastUpdate).map(J=>J.payload);x(I)},[]),L=m.useCallback(I=>!I||typeof I!="object"?null:I.typingId?I.typingId:I.fromDiscord?`discord:${I.discordUserId||I.discordUserName||I.nickname||"unknown"}`:`socket:${I.socketId||I.nickname||"unknown"}`,[]);m.useEffect(()=>{E.current=new Audio(dN),E.current.volume=T,E.current.load()},[T]);const F=m.useCallback(()=>{const I=E.current;I&&(I.volume=T,I.currentTime=0,I.play().catch(()=>{}))},[T]);m.useEffect(()=>{function I(J={}){h(ie=>[...ie.slice(-99),J]),!(J?.socketId&&r?.socketId&&J.socketId===r.socketId)&&(F(),o?.({kind:"chat",payload:J,id:`chat-${J.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return a.on("chat:message",I),()=>{a.off("chat:message",I)}},[F,r?.socketId,a]),m.useEffect(()=>{function I(J={}){const ie=L(J);if(!ie)return;const M=Date.now();if(J?.socketId&&r?.socketId&&J.socketId===r.socketId){J.isTyping||(N.current.delete(ie),O());return}if(J.isTyping){N.current.set(ie,{payload:J,expiresAt:M+6e3,lastUpdate:M});const D=w.current.get(ie)||0;M-D>=2500&&(w.current.set(ie,M),o?.({kind:"chat-typing",payload:J,id:`chat-typing-${ie}-${J.id||Math.random().toString(36).slice(2)}`,receivedAt:M}))}else N.current.delete(ie);O()}return a.on("chat:typing",I),()=>{a.off("chat:typing",I)}},[o,O,L,r?.socketId,a]),m.useEffect(()=>{const I=setInterval(()=>{const J=Date.now();let ie=!1;N.current.forEach((M,D)=>{M.expiresAt<=J&&(N.current.delete(D),ie=!0)}),ie&&O()},2e3);return()=>clearInterval(I)},[O]),m.useEffect(()=>{function I(J=[]){Array.isArray(J)&&h(ie=>{if(ie.length===0)return J.slice(-100);const M=new Set(J.map(K=>K?.id));return[...J,...ie.filter(K=>K?.id&&!M.has(K.id))].slice(-100)})}return a.on("chat:init",I),()=>{a.off("chat:init",I)}},[a]);const U=m.useCallback(I=>{const J=!!I,ie=Date.now(),M=j.current,D=!J&&M.isTyping;!(J&&(!M.isTyping||ie-M.lastSent>=3500))&&!D||(j.current={isTyping:J,lastSent:ie},a.emit("chat:typing",{isTyping:J}))},[a]),Z=m.useCallback((I,J=null)=>new Promise((ie,M)=>{const D={text:I,tts:J};$&&(D.profileImage=$),a.emit("chat:send",D,(K={})=>{K.error?M(new Error(K.error)):ie(K)})}),[$,a]),Q=m.useCallback((I,J={})=>{(J?.target==="hud"?"hud":"panel")==="hud"?C.current=I:S.current=I},[]),ce=m.useCallback(()=>{b(!0),(C.current||S.current)?.focus()},[]),ue=m.useCallback(()=>{b(!1),C.current?.blur(),S.current?.blur()},[]),le=m.useCallback(()=>b(!0),[]),B=m.useCallback(()=>b(!1),[]),V=m.useMemo(()=>({messages:p,sendMessage:Z,focusChat:ce,blurChat:ue,registerInputRef:Q,onInputFocus:le,onInputBlur:B,setTypingActive:U,typing:g,isChatFocused:v,selfSocketId:r?.socketId||null}),[ue,ce,v,p,B,le,Q,Z,r?.socketId,U,g]);return l.jsx(Ag.Provider,{value:V,children:n})}function rf(){const n=m.useContext(Ag);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let Cg=!1;function sd(n){Cg=!!n}function ex(){return Cg}const mN=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function kg(n){if(!n||n.nodeType!==1)return!1;const a=n.tagName;if(a==="TEXTAREA"||n.isContentEditable)return!0;if(a!=="INPUT")return!1;const r=n.type?n.type.toLowerCase():"";return mN.has(r)}function hN(){return typeof document>"u"?!1:kg(document.activeElement)}function al(n={}){const{manageLifecycle:a=!1}=n,{state:{roverId:r,manualDockAssist:o},actions:u}=yt(),p=Wt(r)?.sensors||{},h=p?.chargingState?.label||"",g=!!p?.chargingSources?.homeBase,x=g&&h.toLowerCase()!=="not charging"&&h!=="",v=!!o?.active,b=m.useRef(!1),S=m.useCallback(()=>{u.setManualDockAssistActive(!0)},[u]),C=m.useCallback(()=>{u.setManualDockAssistActive(!1)},[u]),E=m.useCallback(()=>{u.toggleManualDockAssist()},[u]);m.useEffect(()=>{if(!a)return;const R=g&&!b.current,k=!g&&b.current;v&&R?u.sendSong([{note:84,duration:6}],{slot:1}):v&&k&&u.sendSong([{note:72,duration:6}],{slot:1}),b.current=g},[u,v,g,a]),m.useEffect(()=>{!a||!v||!x||C()},[v,x,C,a]);const N=x?"Docked and charging":g?"Docked":"Docking assist active",w=x?"good":g?"warn":"active",j=v||g;return m.useMemo(()=>({active:v,docked:g,charging:x,cameraLocked:v,visible:j,statusLabel:N,statusTone:w,enterAssist:S,exitAssist:C,toggleAssist:E}),[v,x,g,S,C,N,w,E,j])}const ad="keyboard",ld={x:0,y:0,boost:!1},rd={main:0,side:0,vacuum:0},tx=lf[0],nx=lf[1],of=5,ur=500,dr=1,cf=100;function id(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):a}function pN(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(of,Math.min(ur,r)):a}function Eg(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(dr,Math.min(cf,r)):a}function xN(n){const r=(Eg(n,n)-dr)/(cf-dr),o=ur-r*(ur-of);return Math.round(o)}function gN(n){const a=pN(n,n),r=(ur-a)/(ur-of),o=dr+r*(cf-dr);return Math.round(o)}function vN(n){return kg(n?.target)}function dt(n,a){if(!n||n.size===0)return!1;for(const r of a)if(n.has(r))return!0;return!1}function bN(n,a){const r=dt(a.driveForward,n),o=dt(a.driveBackward,n),u=dt(a.driveLeft,n),f=dt(a.driveRight,n),p=dt(a.boostModifier,n),h=dt(a.slowModifier,n);let g=0;r&&!o?g=1:o&&!r&&(g=-1);let x=0;u&&!f?x=-1:f&&!u&&(x=1);const v=h?.4:1;return{x:x*v,y:g*v,boost:p&&!h}}function yN(n,a){if(dt(a.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=dt(a.auxMainForward,n)?127:dt(a.auxMainReverse,n)?-127:0,u=dt(a.auxSideForward,n)?127:dt(a.auxSideReverse,n)?-70:0,f=dt(a.auxVacuumFast,n)?127:dt(a.auxVacuumSlow,n)?50:0;return{main:o,side:u,vacuum:f}}function SN(){const{state:n,actions:{setMode:a,setDriveVector:r,setAuxMotors:o,nudgeServo:u,runMacro:f,stopAllMotion:p,registerInputState:h,toggleNightVision:g,startHorn:x,stopHorn:v,setMicPttActive:b,setSongNote:S,sendSong:C}}=yt(),E=oe(pe=>pe.session?.homeAssistant||null),N=al(),{homeAssistantSetState:w}=Ot(),{focusChat:j,blurChat:R,isChatFocused:k}=rf(),{value:T}=Oe("inputs",En),q=m.useMemo(()=>aN(n.keymap),[n.keymap]),$=m.useMemo(()=>{const pe=new Set;return Object.values(q).forEach(ge=>{ge&&ge.forEach(xe=>pe.add(xe))}),pe},[q]),O=m.useMemo(()=>{const pe=En.keyboard,ge=T?.keyboard??{};return{baseSpeed:id(ge.baseSpeed,pe.baseSpeed),turboSpeed:id(ge.turboSpeed,pe.turboSpeed),precisionSpeed:id(ge.precisionSpeed,pe.precisionSpeed)}},[T?.keyboard]),L=m.useMemo(()=>{const pe=En.keyboard,ge=T?.keyboard??{},xe=Eg(typeof ge.tiltSpeed=="number"?ge.tiltSpeed:typeof ge.tiltIntervalMs=="number"?gN(ge.tiltIntervalMs):pe.tiltSpeed,pe.tiltSpeed);return xN(xe)},[T?.keyboard]),F=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),U=m.useRef(new Set),Z=m.useRef(ld),Q=m.useRef(rd),ce=m.useRef(null),ue=m.useRef(null),le=m.useRef(!1),B=m.useCallback(()=>{const pe=new Set(U.current);dt(q.boostModifier,pe);const xe=dt(q.slowModifier,pe)?{baseSpeed:O.precisionSpeed,boostSpeed:O.precisionSpeed}:{baseSpeed:O.baseSpeed,boostSpeed:O.turboSpeed},ye=bN(pe,q),Ce=yN(pe,q);(ye.x!==Z.current.x||ye.y!==Z.current.y||ye.boost!==Z.current.boost)&&(Z.current=ye,r(ye,{source:ad,speedOptions:xe})),(Ce.main!==Q.current.main||Ce.side!==Q.current.side||Ce.vacuum!==Q.current.vacuum)&&(Q.current=Ce,o(Ce)),h(ad,{keys:Array.from(pe),vector:ye,aux:Ce})},[q,O,h,o,r]),V=m.useCallback(()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},[]),I=m.useCallback(()=>{const pe=new Set(U.current),ge=dt(q.cameraUp,pe),xe=dt(q.cameraDown,pe);return(ge?1:0)-(xe?1:0)},[q]),J=m.useCallback(()=>{if(I()===0){V();return}if(ce.current)return;const ge=()=>{const xe=I();if(xe===0){V();return}u(xe*F),ce.current=setTimeout(ge,L)};ce.current=setTimeout(ge,0)},[I,u,L,F,V]),ie=m.useCallback(()=>{ue.current&&(clearTimeout(ue.current),ue.current=null)},[]),M=m.useCallback(()=>{const pe=new Set(U.current),ge=dt(q.songNoteUp,pe),xe=dt(q.songNoteDown,pe);return(ge?1:0)-(xe?1:0)},[q]),D=m.useCallback(pe=>{if(pe===0)return;let xe=(typeof n.song?.note=="number"?n.song.note:Za)+pe;xe>nx?xe=tx:xe<tx&&(xe=nx);const ye=S(xe);C([{note:ye,duration:Td}],{slot:0})},[C,S,n.song?.note]),K=m.useCallback(()=>{if(M()===0){ie();return}if(ue.current)return;const ge=()=>{const xe=M();if(xe===0){ie();return}D(xe),ue.current=setTimeout(ge,Ij)};ue.current=setTimeout(ge,0)},[M,ie,D]),ae=m.useCallback(()=>{U.current.clear(),Z.current=ld,Q.current=rd,V(),ie(),le.current&&(le.current=!1,v()),b(!1),p(),h(ad,{keys:[],vector:ld,aux:rd})},[h,b,p,v,V,ie]),he=m.useCallback(pe=>{const ge=E;if(!ge?.enabled||!ge?.connected||ge?.lightPolicy?.locked||ge?.lightPolicy?.lockedOn)return;const ye=(ge.entities||[]).filter(Ce=>(Ce.type==="light"||Ce.type==="switch")&&Ce.available!==!1&&Ce.state!=="unavailable");if(ye.length!==0){if(pe==="on"){const Ce=ye.find(qe=>qe.state!=="on");Ce&&w(Ce.id,"on").catch(()=>{});return}if(pe==="off")for(let Ce=ye.length-1;Ce>=0;Ce-=1){const qe=ye[Ce];if(qe.state==="on"){w(qe.id,"off").catch(()=>{});break}}}},[w,E]);m.useEffect(()=>{function pe(ye){if(ex()||vN(ye))return;const Ce=Zp(ye);if(Ce.length===0)return;const qe=new Set(Ce);if(dt(q.chatFocus,qe)){ye.preventDefault(),ae(),k||j();return}Ce.some(Se=>$.has(Se))&&ye.preventDefault();const Ze=Ce.filter(Se=>!U.current.has(Se));if(Ze.forEach(Se=>U.current.add(Se)),Ze.length>0)if(Ze.some(Se=>q.driveMacro?.has(Se)))N.exitAssist(),a("drive"),f("drive-sequence");else if(Ze.some(Se=>q.dockMacro?.has(Se)))N.toggleAssist();else if(Ze.some(Se=>q.nightVisionToggle?.has(Se)))g();else if(Ze.some(Se=>q.hornHonk?.has(Se))){if(!le.current){const Se=x();le.current=!!Se}}else Ze.some(Se=>q.micPtt?.has(Se))?b(!0):Ze.some(Se=>q.homeAssistantOn?.has(Se))?he("on"):Ze.some(Se=>q.homeAssistantOff?.has(Se))&&he("off");J(),K(),B()}function ge(ye){if(ex())return;Zp(ye).forEach(qe=>U.current.delete(qe)),le.current&&!dt(q.hornHonk,U.current)&&(le.current=!1,v()),dt(q.micPtt,U.current)||b(!1),J(),K(),B()}function xe(){ae()}return window.addEventListener("keydown",pe,{capture:!0}),window.addEventListener("keyup",ge,{capture:!0}),window.addEventListener("blur",xe),()=>{window.removeEventListener("keydown",pe,{capture:!0}),window.removeEventListener("keyup",ge,{capture:!0}),window.removeEventListener("blur",xe)}},[$,R,B,J,K,j,k,q.chatFocus,q.dockMacro,q.driveMacro,q.hornHonk,q.micPtt,ae,f,b,a,p,ie,x,v,he,N]);const we=m.useRef(ae);return m.useEffect(()=>{we.current=ae},[ae]),m.useEffect(()=>{we.current()},[n.roverId]),m.useEffect(()=>{le.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{V(),ie()},[V,ie]),null}const jN=1.6;function Mg(n){if(!n)return"unknown::none::0::0";const a=n.id||"unknown",r=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,u=Array.isArray(n.buttons)?n.buttons.length:0;return`${a}::${r}::${o}::${u}`}function NN(n){return JSON.parse(JSON.stringify(n??{}))}function Rg(n,a){const r=NN(a);return r.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},r}function ea(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function nr(n,a){if(!n)return 0;const r=Math.abs(n);return a==="expo"?Math.sign(n)*Math.pow(r,jN):n}function od(n,a){const r=Math.abs(n);if(r<=a)return 0;const o=(r-a)/(1-a);return Math.sign(n)*o}function wN(n,a,r){const o=Math.hypot(n,a);if(o<=r)return{x:0,y:0};const f=(o-r)/(1-r)/o;return{x:n*f,y:a*f}}function fo(n,a){if(!n||!Array.isArray(n.axes))return null;const r=n.axes[a];return Number.isFinite(r)?ea(r):null}function Od(n,a){if(!n||!Array.isArray(n.buttons))return null;const r=n.buttons[a];if(!r)return null;const o=typeof r.value=="number"?r.value:r.pressed?1:0;return{pressed:!!(r.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function cd(n,a=[]){for(const r of a)if(r){if(r.kind==="axis"){const o=fo(n,r.index);if(o===null)continue;return{value:r.invert?-o:o,source:r}}if(r.kind==="buttonAxis"){const o=Od(n,r.index);if(!o)continue;return{value:ea(o.value),source:r}}}return{value:0,source:null}}function AN(n,a=[]){for(const r of a){if(!r||r.kind!=="axisPair")continue;const o=fo(n,r.x),u=fo(n,r.y);if(o===null||u===null)continue;const f=r.invertX?-o:o,p=r.invertY?-u:u;return{x:f,y:p,source:r}}return{x:0,y:0,source:null}}function Ks(n,a=[]){for(const r of a)if(r){if(r.kind==="button"){const o=Od(n,r.index);if(!o)continue;return{pressed:o.pressed,source:r}}if(r.kind==="axisButton"){const o=fo(n,r.index);if(o===null)continue;const u=r.direction||1,f=typeof r.threshold=="number"?r.threshold:.6;return{pressed:o*u>f,source:r}}if(r.kind==="buttonAxis"){const o=Od(n,r.index);if(!o)continue;return{pressed:o.value>.5,source:r}}}return{pressed:!1,source:null}}function Tg(n,a){const r=a?.bindings??{},o=a?.calibration??{},u=r.drive??{},f=AN(n,u.sources);let p=ea(f.x),h=ea(f.y);const g=Math.min(Math.max(o.driveDeadzone??.18,0),.8),x=wN(p,h,g);p=nr(x.x,o.driveCurve),h=nr(x.y,o.driveCurve);const v=r.cameraTilt??{},b=cd(n,v.sources),S=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let C=od(ea(b.value),S);C=nr(C,o.cameraCurve);const E=Math.min(Math.max(o.auxDeadzone??.05,0),.6),N=r.mainBrush??{},w=cd(n,N.sources);let j=od(ea(w.value),E);j=nr(j,o.auxCurve);const R=r.sideBrush??{},k=cd(n,R.sources);let T=od(ea(k.value),E);T=nr(T,o.auxCurve);const q=Ks(n,r.vacuum?.sources),$=Ks(n,r.allAux?.sources),O=Ks(n,r.mainReverse?.sources),L=Ks(n,r.sideReverse?.sources),F=Ks(n,r.driveMacro?.sources),U=Ks(n,r.dockMacro?.sources),Z=Ks(n,r.nightVisionToggle?.sources);return{driveVector:{x:p,y:h,boost:!1},cameraAxis:C,auxAxis:{main:j,side:T},buttons:{vacuum:q.pressed,allAux:$.pressed,mainReverse:O.pressed,sideReverse:L.pressed,driveMacro:F.pressed,dockMacro:U.pressed,nightVisionToggle:Z.pressed},sources:{drive:f.source,cameraTilt:b.source,mainBrush:w.source,sideBrush:k.source,vacuum:q.source,allAux:$.source,mainReverse:O.source,sideReverse:L.source,driveMacro:F.source,dockMacro:U.source,nightVisionToggle:Z.source}}}const rr=new Set;let Qa=null,Wa={pads:[],timestamp:0},Gi=!1,Yi=null;function sx(){return qg().some(n=>n?.connected!==!1)}function qg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function CN(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(a=>({pressed:!!a?.pressed,value:typeof a?.value=="number"?a.value:a?.pressed?1:0})),signature:Mg(n)}}function mo(){Wa={pads:qg().map(CN),timestamp:typeof performance<"u"?performance.now():Date.now()},rr.forEach(a=>a(Wa))}function Dg(){if(mo(),Wa.pads.length===0){Bd();return}Qa=requestAnimationFrame(Dg)}function ax(){Qa||(mo(),Wa.pads.length!==0&&(Qa=requestAnimationFrame(Dg)))}function Bd(){Qa&&(cancelAnimationFrame(Qa),Qa=null)}function _g(n){if(rr.add(n),!Gi&&typeof window<"u"){const a=()=>{mo(),rr.size!==0&&(sx()?ax():Bd())};window.addEventListener("gamepadconnected",a),window.addEventListener("gamepaddisconnected",a),Yi=a,Gi=!0}return sx()?ax():mo(),n(Wa),()=>{rr.delete(n),rr.size===0&&(Bd(),Gi&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",Yi),window.removeEventListener("gamepaddisconnected",Yi),Yi=null,Gi=!1))}}function kN(){const[n,a]=m.useState(Wa);return m.useEffect(()=>_g(a),[]),n}const Ya="gamepad",Zs={x:0,y:0,boost:!1},Js={main:0,side:0,vacuum:0},EN=100,MN=100;function ud(n,a){return n&&a&&n.x===a.x&&n.y===a.y&&n.boost===a.boost}function dd(n,a){return n&&a&&n.main===a.main&&n.side===a.side&&n.vacuum===a.vacuum}function RN(n){return n?Math.hypot(n.x||0,n.y||0):0}function TN(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function qN(n,a){if(!n||n.length===0)return null;if(a){const r=n.find(o=>o.signature===a);if(r)return r}return n[0]}function DN(){const{state:n,actions:{setMode:a,setDriveVector:r,setAuxMotors:o,setServoAngle:u,runMacro:f,toggleNightVision:p,registerInputState:h}}=yt(),g=al(),{value:x,save:v}=Oe("gamepad",Es),b=m.useRef(new Set),S=m.useRef(Zs),C=m.useRef(Js),E=m.useRef({main:!1,side:!1}),N=m.useRef(new Map),w=m.useRef(0),j=m.useRef(0),R=m.useRef(0),k=m.useRef(null),T=m.useCallback(L=>{const F=L.signature??Mg(L);x?.profiles?.[F]||b.current.has(F)||(b.current.add(F),v(U=>{const Z=U??Es;if(Z.profiles?.[F])return Z;const Q=Z?.defaults?.profile??Wn,ce=Rg(L,Q);return{...Z,profiles:{...Z.profiles??{},[F]:ce}}}))},[x?.profiles,v]),q=m.useCallback((L,F)=>{const U=N.current.get(L)||!1;return N.current.set(L,F),F&&!U},[]),$=m.useCallback((L,F)=>{const U=n.camera?.config;if(!U)return;const Z=typeof performance<"u"?performance.now():Date.now(),Q=F?.cameraMode??"absolute",ce=Math.max(1,Math.min(180,F?.cameraSensitivity??60));if(Q==="velocity"){const I=Math.min(50,Z-R.current||16),J=L*ce*(I/1e3);if(Math.abs(J)<.01)return;const M=(typeof k.current=="number"?k.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof U.homeAngle=="number"?U.homeAngle:0)+J;u(M),k.current=M,R.current=Z;return}const ue=typeof U.minAngle=="number"?U.minAngle:-45,le=typeof U.maxAngle=="number"?U.maxAngle:45,B=typeof U.homeAngle=="number"?U.homeAngle:(ue+le)/2,V=L<0?B+L*(B-ue):B+L*(le-B);typeof k.current=="number"&&Math.abs(k.current-V)<.35&&Z-R.current<80||(R.current=Z,k.current=V,u(V))},[u,n.camera?.angle,n.camera?.config]),O=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>_g(L=>{const F=qN(L.pads,O);if(!F){ud(S.current,Zs)||(S.current=Zs,r(Zs,{source:Ya})),dd(C.current,Js)||(C.current=Js,o(Js)),N.current=new Map,E.current={main:!1,side:!1},w.current=0,j.current=0,h(Ya,{connected:!1});return}if(hN()){ud(S.current,Zs)||(S.current=Zs,r(Zs,{source:Ya})),dd(C.current,Js)||(C.current=Js,o(Js)),N.current=new Map,E.current={main:!1,side:!1},h(Ya,{connected:!0,blocked:!0});return}T(F);const U=F.signature,Z=x?.profiles?.[U]??x?.defaults?.profile??Wn,Q=Tg(F,Z);if(!ud(Q.driveVector,S.current)){const J=typeof performance<"u"?performance.now():Date.now();(RN(Q.driveVector)<.02||J-w.current>=EN)&&(S.current=Q.driveVector,w.current=J,r(Q.driveVector,{source:Ya}))}const ce=Z.calibration?.auxSideScale??.55,ue=Math.round(Math.min(Math.abs(Q.auxAxis.main),1)*127),le=Math.round(Math.min(Math.abs(Q.auxAxis.side),1)*127),B=E.current.main?-ue:ue,V=E.current.side?-Math.round(le*ce):Math.round(le*ce);let I={main:Q.auxAxis.main!==0?B:0,side:Q.auxAxis.side!==0?V:0,vacuum:Q.buttons.vacuum?127:0};if(Q.buttons.allAux&&(I={main:127,side:127,vacuum:127}),!dd(I,C.current)){const J=typeof performance<"u"?performance.now():Date.now();(TN(I)||J-j.current>=MN)&&(C.current=I,j.current=J,o(I))}Q.buttons.mainReverse&&q("mainReverse",!0)?E.current.main=!E.current.main:Q.buttons.mainReverse||q("mainReverse",!1),Q.buttons.sideReverse&&q("sideReverse",!0)?E.current.side=!E.current.side:Q.buttons.sideReverse||q("sideReverse",!1),Q.buttons.driveMacro&&q("driveMacro",!0)?(g.exitAssist(),a("drive"),f("drive-sequence")):Q.buttons.driveMacro||q("driveMacro",!1),Q.buttons.dockMacro&&q("dockMacro",!0)?g.toggleAssist():Q.buttons.dockMacro||q("dockMacro",!1),Q.buttons.nightVisionToggle&&q("nightVisionToggle",!0)?p():Q.buttons.nightVisionToggle||q("nightVisionToggle",!1),Math.abs(Q.cameraAxis)>.001&&$(Q.cameraAxis,Z.calibration),h(Ya,{connected:!0,signature:U,id:F.id,index:F.index,axes:F.axes,buttons:F.buttons,drive:Q.driveVector,aux:I,cameraAxis:Q.cameraAxis,bindings:Q.sources})}),[O,T,x?.defaults?.profile,x?.profiles,q,$,h,f,o,r,a,p,g]),null}function Og(n){const a=n?.sensors||{},r=a.oiMode?.label||"Unknown",o=r.toLowerCase(),u=a.chargingState?.label||"",f=!!a.chargingSources?.homeBase,p=f&&u.toLowerCase()!=="not charging"&&u!=="";return{driving:o==="full",docked:f,charging:p,dockedNotCharging:f&&!p,dockingInProgress:!f&&!p&&o==="passive",oiLabel:r,chargingLabel:u}}function Bg(n){const a=Wt(n);return m.useMemo(()=>Og(a),[a])}function Fa({label:n,value:a,tone:r="neutral"}){const o=r==="good"?"border-emerald-200 bg-emerald-600 text-white":r==="warn"?"border-amber-200 bg-amber-600 text-white":r==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return l.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:l.jsx("span",{className:"text-base font-semibold md:text-lg",children:a})})}function lx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function fd({label:n,tone:a}){const r=a==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":a==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return l.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${r}`,children:n})}function _N({instructions:n,onConfirm:a,onCancel:r,pending:o}){return l.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:l.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:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Manual Docking Assist"}),l.jsx("p",{className:"text-sm text-slate-200",children:n.summary}),l.jsx(Ld,{steps:n.steps,tone:"indigo"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[l.jsx("button",{type:"button",onClick:r,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),l.jsx("button",{type:"button",disabled:o,onClick:a,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Starting…":"Enter Assist"})]})]})})}function Lg({layout:n="desktop",expand:a=!1,fill:r=!1,driveDockState:o,compactHeightClass:u=""}){const f=n==="mobile",{state:{roverId:p,keymap:h},actions:g}=yt(),x=al(),v=Wt(p),b=o??Og(v),{driving:S,docked:C,charging:E,dockingInProgress:N}=b,[w,j]=m.useState(null),[R,k]=m.useState(!1),[T,q]=m.useState(!1),$=!!x.active,O=!p||w!==null,L=!p||w!==null,F=Tt(h?.driveMacro?.[0]),U=Tt(h?.dockMacro?.[0]),Z={summary:"Use assist mode to manually line up with the dock.",steps:["Line up the center dot of your rover with the center of the dock","The UI will indicate when you are successfully docked","When good contact is made, the dock will stop flashing."]},Q={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"]},ce=C?"Docked":"Undocked",ue=C?"good":"bad",le=E?"Charging":C?"Charging soon...":"—",B=E?"good":C?"warn":"bad",V=async()=>{if(!(!p||w)){j("drive");try{x.exitAssist(),g.setMode("drive"),await g.runMacro("drive-sequence")}catch(Ge){alert(Ge.message)}finally{j(null)}}},I=async()=>{if(!(!p||w)){k(!1),q(!1),j("drive");try{x.exitAssist(),g.setMode("drive"),await g.runMacro("drive-sequence")}catch(Ge){alert(Ge.message)}finally{j(null)}}},J=async()=>{if(!(!p||w)){j("dock");try{x.enterAssist()}catch(Ge){alert(Ge.message)}finally{j(null),k(!1),q(!1)}}},ie=()=>{if(!L){if($){x.exitAssist();return}q(!0),k(!0)}},M="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",D="text-center",K="items-center justify-between",ae="items-center justify-center",he=f?"text-sm font-semibold":"",we="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",pe="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ge="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",xe="border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800 focus-visible:ring-cyan-300",ye="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",qe=a||N,Ze=qe?"h-full flex-1":r?"flex-1":"",Se=f&&!qe?u:"",at=f&&!qe?ae:K,ht=f&&!qe&&S&&C;if(!S&&!N)return l.jsxs("button",{type:"button",onClick:I,onContextMenu:Ge=>Ge.preventDefault(),disabled:O,className:`${M} ${Ze} ${Se} ${D} ${at} ${he} ${we}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!f&&qe?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[F?l.jsx(lx,{label:F}):null,l.jsx(fd,{label:"Click to start",tone:"emerald"})]}):null]}),qe?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-emerald-50/90",children:Q.summary}),l.jsx(Ld,{steps:Q.steps,tone:"emerald"})]}):null]}),qe?l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:ce,tone:ue}),l.jsx(Fa,{label:"Charge",value:le,tone:B})]}):null]});if(N){const Ge={summary:"The rover is currently attempting to dock itself due to being idle.",steps:["Click to return to driving mode."]};return l.jsxs("button",{type:"button",disabled:O,onClick:V,onContextMenu:je=>je.preventDefault(),className:`${M} ${Ze} ${Se} ${D} ${at} ${he} ${pe}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Attempting to auto-dock..."}),qe?l.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:l.jsx(fd,{label:"Return to driving mode",tone:"emerald"})}):null]}),qe?l.jsx("p",{className:"text-sm text-amber-50/90",children:Ge.summary}):null]}),qe?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:ce,tone:ue}),l.jsx(Fa,{label:"Charge",value:le,tone:B})]}),f?null:l.jsx(Ld,{steps:Ge.steps,tone:"amber"})]}):null]})}return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",disabled:L,onClick:ie,onContextMenu:Ge=>Ge.preventDefault(),className:f?`flex w-full ${M} ${Se} ${D} ${at} ${he} ${$?xe:ht?ye:ge}`:`${M} ${Ze} ${D} ${K} ${he} ${$?xe:ge}`,children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:ht?"Docked!":$?"Exit Docking Assist":"Dock and charge"}),!f&&qe?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[U?l.jsx(lx,{label:U}):null,l.jsx(fd,{label:$?"Click to exit assist":"Click to enable assist",tone:"indigo"})]}):null]}),!f&&qe&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-indigo-50/90",children:"Get near a dock and press this button to enter docking assist mode."}),l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:ce,tone:ue}),l.jsx(Fa,{label:"Charge",value:le,tone:B})]})]})]}),T||!f&&R?l.jsx(_N,{instructions:Z,pending:w==="dock",onCancel:()=>{q(!1),k(!1)},onConfirm:J}):null]})}function Ld({steps:n,tone:a="emerald"}){const r=a==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":a==="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=a==="emerald"?"text-emerald-200":a==="amber"?"text-amber-200":"text-indigo-200";return l.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${r}`,children:n.map((u,f)=>l.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[l.jsxs("div",{className:"flex items-start",children:[l.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[f+1,"."]}),l.jsx("span",{className:"align-top",children:u})]}),f<n.length-1?l.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},u))})}function md(n){return typeof n=="boolean"}function zg({nightVisionOn:n,disabled:a,onToggle:r,keyLabel:o,className:u="",heightClass:f=""}){const[p,h]=m.useState(md(n)?n:null);m.useEffect(()=>{md(n)&&h(n)},[n]);const g=md(p),x=g?p:!1,v=g?x?"On":"Off":"—",b=x?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",S=()=>{if(a)return;const E=g?!x:!0;h(E),r?.(E)},C=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",x?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",f,u].filter(Boolean).join(" "),[u,x,f]);return l.jsxs("button",{type:"button",onClick:S,onContextMenu:E=>E.preventDefault(),disabled:a,"aria-pressed":x,className:C,children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?l.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:v})]})}function hd(n){const a=Number(n);return!Number.isFinite(a)||a<=0?0:Math.min(uo,Math.round(a))}function Ug({disabled:n,onStart:a,onStop:r,keyLabel:o,active:u,heat:f=0,className:p="",defaultShowSettings:h=!0,showSettingsToggle:g=!1,compactSettings:x=!1}){const[v,b]=m.useState(!1),[S,C]=m.useState(h),{value:E,save:N}=Oe("horn",ta),[w,j]=m.useState(E?.waveform||ta.waveform),R=m.useRef(null),[k,T]=m.useState(()=>[...Array.isArray(E?.freqs)?E.freqs:ta.freqs,0,0,0,0].slice(0,4).map(V=>hd(V)));m.useEffect(()=>{j(E?.waveform||ta.waveform),Array.isArray(E?.freqs)&&T([...E.freqs,0,0,0,0].slice(0,4).map(B=>hd(B)))},[E?.freqs,E?.waveform]);const q=!!u,$=Math.max(0,Math.min(1,Number(f)||0)),O=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",q?"border-fuchsia-300/70 bg-fuchsia-700 text-fuchsia-50":"border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800","disabled:opacity-50",p].filter(Boolean).join(" "),[p,q]),L=()=>{n||v||(b(!0),a?.())},F=()=>{v&&(b(!1),r?.())};m.useEffect(()=>{!q&&v&&b(!1)},[q,v]);const U=w==="sine"?"sine":"saw",Z=m.useCallback(B=>{const V=B.target.value==="sine"?"sine":"saw";j(V),N(I=>({...I??{},waveform:V}))},[N]),Q=m.useCallback((B,V)=>{T(I=>{const J=[...I];return J[B]=hd(V),N(ie=>({...ie??{},freqs:J})),J})},[N]);m.useEffect(()=>{const B=R.current;if(!B)return;const V=I=>{const J=I.target;if(!(J instanceof Element))return;const ie=J.closest("input[data-horn-freq-index]");if(!ie)return;const M=Number(ie.dataset.hornFreqIndex);if(!Number.isInteger(M)||M<0||M>=k.length)return;I.preventDefault(),I.stopPropagation();const D=I.deltaY<0?1:-1,K=Number(k[M])||0;Q(M,K+D*25)};return B.addEventListener("wheel",V,{passive:!1,capture:!0}),()=>{B.removeEventListener("wheel",V,{capture:!0})}},[k,Q]);const ce=B=>{if(n)return;const V=B.target?.tagName?.toLowerCase();V==="input"||V==="select"||V==="option"||V==="label"||V==="button"||(B.preventDefault(),L())},ue=B=>{const V=B.target?.tagName?.toLowerCase();V==="input"||V==="select"||V==="option"||V==="label"||V==="button"||(B.preventDefault(),F())},le=g?l.jsx("button",{type:"button",onClick:B=>{B.preventDefault(),C(V=>!V)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:S?"Hide":"Settings"}):null;return l.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":v,onPointerDown:ce,onPointerUp:ue,onPointerLeave:F,onPointerCancel:F,onContextMenu:B=>B.preventDefault(),onBlur:F,className:O,children:[l.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${$*100}%, rgba(0,0,0,0) ${$*100}%)`}}),l.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${q?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),l.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[l.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[l.jsx("span",{children:"Horn"}),o?l.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),le,l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${q?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:q?"Honk":"Hold"})]}),S?x?l.jsxs("div",{ref:R,className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:U,onChange:Z,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:k.map((B,V)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:V+1}),l.jsx("input",{type:"number",min:0,max:uo,step:1,value:B,"data-horn-freq-index":V,onChange:I=>Q(V,I.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-${V}`))})]}):l.jsxs("div",{ref:R,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:[l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:U,onChange:Z,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),k.map((B,V)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:V+1}),l.jsx("input",{type:"number",min:0,max:uo,step:1,value:B,"data-horn-freq-index":V,onChange:I=>Q(V,I.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-${V}`))]}):null]})}function Fi(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function rx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Hg({value:n,min:a,max:r,step:o=.5,label:u="Camera Tilt",orientation:f="horizontal",onChange:p,onCommit:h,throttleMs:g=0,disabled:x=!1,keyDownLabel:v,keyUpLabel:b,className:S="",labelRowClass:C="",labelClass:E="",valueClass:N="",sliderClass:w="",endpointClass:j="",endpointLabelClass:R="",accentClass:k="",showValue:T=!0,showEndpoints:q}){const $=f==="vertical",L=typeof q=="boolean"?q:!$,[F,U]=m.useState(n),Z=m.useRef(!1),Q=m.useRef(null);m.useEffect(()=>{Z.current||U(n)},[n]),m.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);const ce=I=>{if(p){if(g>0){Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{p(I)},g);return}p(I)}},ue=I=>{const J=Number.parseFloat(I.target.value);Number.isNaN(J)||(Z.current=!0,U(J),ce(J))},le=()=>{Z.current=!1,Q.current&&(clearTimeout(Q.current),Q.current=null),h?h(F):g>0&&p?.(F)};if(typeof a!="number"||typeof r!="number")return null;const B=[$?"h-28 w-5":"w-full",k,w].filter(Boolean).join(" "),V=l.jsx("input",{type:"range",orient:$?"vertical":void 0,min:a,max:r,step:o,value:Number.isFinite(F)?F:a,onChange:ue,onMouseUp:le,onTouchEnd:le,onPointerUp:le,disabled:x,className:B,style:$?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return $?l.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${S}`.trim(),children:[T?l.jsx("div",{className:`flex flex-col items-center ${C}`.trim(),children:l.jsx("span",{className:N,children:Fi(n)})}):null,l.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[l.jsx("span",{className:E,children:u}),V]})]}):l.jsxs("div",{className:`space-y-0.5 ${S}`.trim(),children:[l.jsxs("div",{className:`flex items-center justify-between ${C}`.trim(),children:[l.jsx("span",{className:E,children:u}),T?l.jsx("span",{className:N,children:Fi(n)}):null]}),l.jsxs("div",{children:[V,L?l.jsxs("div",{className:`mt-0 flex items-center justify-between ${j}`.trim(),children:[l.jsxs("span",{className:`flex items-center gap-0.5 ${R}`.trim(),children:[v?l.jsx(rx,{label:v}):null,Fi(a)]}),l.jsxs("span",{className:`flex items-center gap-0.5 ${R}`.trim(),children:[Fi(r),b?l.jsx(rx,{label:b}):null]})]}):null]})]})}function ON({disabled:n,layout:a,radius:r,onMove:o,onStop:u}){const f=m.useRef(null),p=m.useRef(null),h=m.useRef({x:0,y:0}),[g,x]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),v=m.useCallback(()=>{p.current=null,x({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),u?.()},[u]),b=m.useCallback(N=>{if(n||p.current!==null)return;N.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),R=N.clientX-j.left,k=N.clientY-j.top;h.current={x:R,y:k},p.current=N.pointerId,w.setPointerCapture?.(N.pointerId),x({active:!0,base:{x:R,y:k},knob:{x:0,y:0}})},[n]),S=m.useCallback(N=>{if(n||p.current!==N.pointerId)return;N.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),R=N.clientX-j.left,k=N.clientY-j.top,T=R-h.current.x,q=k-h.current.y,$=Math.min(Math.hypot(T,q),r),O=Math.atan2(q,T),L=Math.cos(O)*$,F=Math.sin(O)*$,U={x:Pa(L/r),y:Pa(-F/r),boost:!1};x(Z=>({...Z,knob:{x:L,y:F}})),o?.(U)},[n,o,r]),C=m.useCallback(N=>{if(p.current!==N.pointerId)return;N.preventDefault(),f.current?.releasePointerCapture?.(N.pointerId),v()},[v]);return m.useEffect(()=>{n&&v()},[n,v]),l.jsxs("div",{ref:f,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:S,onPointerUp:C,onPointerLeave:C,onPointerCancel:C,onContextMenu:N=>N.preventDefault(),children:[!g.active&&l.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[l.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),l.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),g.active&&l.jsxs(l.Fragment,{children:[l.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:g.base.x,top:g.base.y}}),l.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:g.base.x+g.knob.x,top:g.base.y+g.knob.y}})]})]})}function ix({id:n,label:a,values:r,color:o,disabled:u,onPress:f,onRelease:p}){return l.jsx("button",{type:"button",disabled:u,onPointerDown:h=>{h.preventDefault(),f(n,r)},onPointerUp:()=>p(n),onPointerLeave:()=>p(n),onPointerCancel:()=>p(n),onContextMenu:h=>h.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:a})}const Ii="mobile-joystick",BN=80,LN=.15,zN={main:0,side:0,vacuum:0},UN={main:127,side:127,vacuum:127},HN={main:-127,side:-127,vacuum:-127};function VN({layout:n}){const{state:{roverId:a},actions:{setDriveVector:r,registerInputState:o}}=yt(),u=Bg(a),f=u.docked&&!u.driving,p=f||u.dockingInProgress,h=!a,g=BN,x=LN,v=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{h&&(v.current={x:0,y:0,boost:!1})},[h]);const b=m.useCallback((N={})=>{if(h)return;const w={x:Pa(N.x??0),y:Pa(N.y??0),boost:!!N.boost},j={x:v.current.x+(w.x-v.current.x)*(1-x),y:v.current.y+(w.y-v.current.y)*(1-x),boost:w.boost};v.current=j,r(j,{source:Ii}),o(Ii,{vector:j,lastEvent:"move"})},[h,o,r,x]),S=m.useCallback(()=>{if(h)return;const N={x:0,y:0,boost:!1};v.current=N,r(N,{source:Ii}),o(Ii,{vector:N,lastEvent:"stop"})},[h,o,r]),E=`flex h-full flex-col gap-0.5 text-slate-100 ${f?"max-h-screen self-start":""}`;return l.jsxs("div",{className:E,children:[l.jsx(Lg,{layout:"mobile",expand:p,driveDockState:u,compactHeightClass:"min-h-[5rem]"}),p?null:l.jsx("div",{className:"flex-1 min-h-0",children:l.jsx(ON,{disabled:h,layout:n,radius:g,onMove:b,onStop:S})})]})}function $N({layout:n}){const{state:{roverId:a,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:p,setAuxMotors:h,startHorn:g,stopHorn:x}}=yt(),v=al(),b=!a,S=m.useRef(null),C=r?.config,E=!!(a&&r?.enabled&&C),N=!!(a&&u?.nightVision),w=u?.nightVisionState,j=!!(a&&u?.horn),R=o?.overheated,k=typeof C?.minAngle=="number"?C.minAngle:-45,T=typeof C?.maxAngle=="number"?C.maxAngle:45,q=typeof r?.angle=="number"?r.angle:typeof C?.homeAngle=="number"?C.homeAngle:(k+T)/2,$=!!(b||v.cameraLocked),O=m.useCallback(U=>{N&&p(U)},[N,p]),L=m.useCallback((U,Z)=>{b||(S.current=U,h(Z))},[b,h]),F=m.useCallback(U=>{b||S.current===U&&(S.current=null,h(zN))},[b,h]);return l.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:[l.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[l.jsx(ix,{id:"aux-vac-forward",label:"Vacuum Forward",values:UN,color:"bg-fuchsia-600",disabled:b,onPress:L,onRelease:F}),l.jsx(ix,{id:"aux-vac-backward",label:"Vacuum Backward",values:HN,color:"bg-fuchsia-800",disabled:b,onPress:L,onRelease:F})]}),l.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[E?l.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:l.jsx(Hg,{value:q,min:k,max:T,step:.5,disabled:$,onChange:f,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,N?l.jsx(zg,{nightVisionOn:w?.nightVisionOn,disabled:b,onToggle:O,heightClass:"h-full"}):null]}),l.jsx("div",{className:"min-h-0",children:j?l.jsx(Ug,{disabled:b||R,onStart:g,onStop:x,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function ho({layout:n,className:a=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${a}`.trim(),children:l.jsx($N,{layout:n})})}function po({layout:n,className:a=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${a}`.trim(),children:l.jsx(VN,{layout:n==="landscape"?"landscape":"portrait"})})}function GN({swapColumns:n=!1}){const a="h-[min(60svh,24rem)]",r=n?l.jsx(po,{layout:"portrait",className:a}):l.jsx(ho,{layout:"portrait",className:a}),o=n?l.jsx(ho,{layout:"portrait",className:a}):l.jsx(po,{layout:"portrait",className:a});return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[r,o]})})}function YN(n=[],a={}){const r=Pt(),{enabled:o=!0,version:u=null}=a,[f,p]=m.useState({}),h=m.useRef(new Map),g=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id),[n]),x=m.useMemo(()=>{const N=g.join("|");return u?`${N}|v:${u}`:N},[g,u]),v=m.useRef([]),[b,S]=m.useState(0),C=m.useRef(new Map),E=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const N=()=>S(w=>w+1);return r.on("connect",N),()=>r.off("connect",N)},[r]),m.useEffect(()=>{v.current=g},[x,g]),m.useEffect(()=>{h.current.forEach(N=>URL.revokeObjectURL(N)),h.current.clear(),p({})},[x]),m.useEffect(()=>{if(!o){h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear(),p({});return}if(!v.current.length||!r)return;let N=!1;const w=v.current,j=(k={},T)=>{if(N||!k.id||!T)return;const q=T.byteLength??T.length??0,$=Date.now(),O=C.current.get(k.id)||{count:0,totalBytes:0,lastLogAt:0},L={count:O.count+1,totalBytes:O.totalBytes+q,lastLogAt:O.lastLogAt};if(E&&(!L.lastLogAt||$-L.lastLogAt>=1e4)){const Q=L.count?L.totalBytes/L.count:0;console.log("[roomCamera]",k.id,`frame=${q}B`,`avg=${Math.round(Q)}B`,`count=${L.count}`),L.lastLogAt=$}C.current.set(k.id,L);const F=new Blob([T],{type:"image/jpeg"}),U=URL.createObjectURL(F),Z=h.current.get(k.id);Z&&URL.revokeObjectURL(Z),h.current.set(k.id,U),p(Q=>({...Q,[k.id]:{status:"playing",ts:k.ts||Date.now(),error:null,objectUrl:U}}))},R=(k={})=>{N||!k.id||p(T=>({...T,[k.id]:{...T[k.id]||{},status:k.error?"error":T[k.id]?.status||"connecting",error:k.error||null,ts:k.ts||T[k.id]?.ts||null,objectUrl:T[k.id]?.objectUrl||null}}))};return r.on("roomCamera:frame",j),r.on("roomCamera:status",R),r.emit("roomCamera:subscribe",{ids:w},(k={})=>{k.error}),()=>{N=!0,r.emit("roomCamera:unsubscribe",{ids:w}),r.off("roomCamera:frame",j),r.off("roomCamera:status",R),h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear()}},[r,x,o,b,E]),f}function FN({feed:n,label:a}){const[r,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(f=>!f))},[n?.ts,n?.objectUrl]);const u=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return l.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?l.jsx("img",{src:n.objectUrl,alt:a,className:"h-full w-full object-cover"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),l.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:a}),l.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:[l.jsx("span",{className:`h-2 w-2 rounded-full ${r?"bg-emerald-400":"bg-slate-500"}`}),l.jsx("span",{children:u})]})]})}function IN(){return l.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),l.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const Vg=["horizontal","vertical"];function pd(n,a){return Vg.includes(n)?n:a}function uf({defaultOrientation:n="horizontal",orientation:a,hideLayoutToggle:r=!1,hideHeader:o=!1,panelId:u=null}){const f=oe(N=>N.session?.roomCameras||[]),p=YN(f.map(N=>({id:N.id}))),{value:h,save:g}=Oe("roomCameraPanels",{}),[x,v]=m.useState(()=>pd(u?h?.[u]:n,"horizontal"));m.useEffect(()=>{if(!u)return;const N=h?.[u];N&&v(pd(N,"horizontal"))},[u,h?.[u]]);const b=a?pd(a,"horizontal"):x,S=b==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",C=!r&&!a&&f.length>0,E=N=>{v(N),u&&g(w=>({...w||{},[u]:N}))};return f.length===0?l.jsx(IN,{}):l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&l.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room cameras"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length})]}),l.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:C&&l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-500",children:"Layout:"}),l.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:Vg.map(N=>l.jsx("button",{type:"button",className:`px-1 py-0.5 ${b===N?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>E(N),children:N==="vertical"?"Vertical":"Grid"},N))})]})})]}),l.jsx("div",{className:S,children:f.map(N=>{const w=p[N.id]||null;return l.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:l.jsx(FN,{feed:w,label:N.name||N.id})},N.id)})})]})}function df(){const n=oe(r=>r.logs),a=m.useMemo(()=>n.slice().reverse(),[n]);return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Server logs"}),l.jsx("span",{children:n.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?l.jsx("p",{children:"No logs yet."}):a.map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.timestamp})," ",l.jsxs("span",{className:"text-lime-400",children:["[",r.level,"]"]})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{children:r.message})]},r.id))})]})}const XN={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function QN(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 KN(n){if(!n)return{};const a=`${n}:${n}`;return{Authorization:`Basic ${QN(a)}`}}class ox{constructor({url:a,token:r,video:o,onStatus:u,audioOnly:f=!1,receiveAudio:p=!0}){this.url=a,this.token=r,this.video=o,this.audioOnly=f,this.receiveAudio=p,this.pc=null,this.abortController=null,this.onStatus=u}notify(a,r){typeof this.onStatus=="function"&&this.onStatus(a,r)}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 a=new RTCPeerConnection(XN);this.pc=a;const r=new MediaStream;a.ontrack=o=>{o.streams[0]?.getTracks().forEach(u=>r.addTrack(u)),this.video.srcObject=r,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?a.addTransceiver("audio",{direction:"recvonly"}):(a.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&a.addTransceiver("audio",{direction:"recvonly"})),a.onconnectionstatechange=()=>{this.notify(a.connectionState)},a.oniceconnectionstatechange=()=>{const o=a.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await a.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await a.setLocalDescription(o);const u=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...KN(this.token)},body:o.sdp,signal:this.abortController.signal});if(!u.ok)throw new Error(`WHEP request failed: ${u.status}`);const f=await u.text();await a.setRemoteDescription({type:"answer",sdp:f}),a.getReceivers().forEach(p=>{"playoutDelayHint"in p&&(p.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(a=>a.track?.stop()),this.pc.getReceivers().forEach(a=>a.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function ZN(n){if(!n)return null;if(typeof n=="string"){const a=String(n).trim();return a?{type:"rover",id:a,key:a}:null}if(typeof n=="object"){if(n.type&&n.id){const a=String(n.id);let r=n.key;return r||(r=n.type==="room"?`room:${a}`:a),{type:n.type,id:a,key:r}}if(n.roverId){const a=String(n.roverId);return{type:"rover",id:a,key:n.key||a}}if(n.roomCameraId){const a=String(n.roomCameraId);return{type:"room",id:a,key:n.key||`room:${a}`}}}return null}function JN(n=[]){const a=new Set,r=[];return n.forEach(o=>{!o?.key||a.has(o.key)||(a.add(o.key),r.push(o))}),r.sort((o,u)=>o.key.localeCompare(u.key))}function zd(n=[],a={}){const r=Pt(),{enabled:o=!0,version:u=null}=a,[f,p]=m.useState({}),h=m.useMemo(()=>Array.isArray(n)?JN(n.map(ZN).filter(Boolean)):[],[n]),g=m.useMemo(()=>{const C=h.map(E=>`${E.type}:${E.id}:${E.key}`).join("|");return u?`${C}|v:${u}`:C},[h,u]),x=m.useRef([]),[v,b]=m.useState(0);return m.useEffect(()=>{if(!r)return;const C=()=>b(E=>E+1);return r.on("connect",C),()=>{r.off("connect",C)}},[r]),m.useEffect(()=>{x.current=h},[h]),m.useEffect(()=>{if(!g||!o){p({});return}const C=x.current;let E=!1;function N(w){const j=w.type==="room"?{roomCameraId:w.id}:{roverId:w.id};r.emit("video:request",j,(R={})=>{E||p(k=>({...k,[w.key]:R}))})}return C.forEach(w=>{N(w)}),()=>{E=!0}},[r,g,o,v]),m.useMemo(()=>{if(!g||!o)return{};const C={};return h.forEach(E=>{f[E.key]&&(C[E.key]=f[E.key])}),C},[g,f,h])}function $g(n=[],a={}){const r=Pt(),{enabled:o=!0,version:u=null}=a,[f,p]=m.useState({}),h=m.useRef(new Map),g=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id).filter(Boolean),[n]),x=m.useMemo(()=>{const N=g.join("|");return u?`${N}|v:${u}`:N},[g,u]),v=m.useRef([]),[b,S]=m.useState(0),C=m.useRef(new Map),E=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const N=()=>S(w=>w+1);return r.on("connect",N),()=>r.off("connect",N)},[r]),m.useEffect(()=>{v.current=g},[x,g]),m.useEffect(()=>{h.current.forEach(N=>URL.revokeObjectURL(N)),h.current.clear(),p({})},[x]),m.useEffect(()=>{if(!o){h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear(),p({});return}if(!v.current.length||!r)return;let N=!1;const w=v.current,j=(k={},T)=>{if(N||!k.id||!T)return;const q=T.byteLength??T.length??0,$=Date.now(),O=C.current.get(k.id)||{count:0,totalBytes:0,lastLogAt:0},L={count:O.count+1,totalBytes:O.totalBytes+q,lastLogAt:O.lastLogAt};if(E&&(!L.lastLogAt||$-L.lastLogAt>=1e4)){const Q=L.count?L.totalBytes/L.count:0;console.log("[roverSnapshot]",k.id,`frame=${q}B`,`avg=${Math.round(Q)}B`,`count=${L.count}`),L.lastLogAt=$}C.current.set(k.id,L);const F=new Blob([T],{type:"image/jpeg"}),U=URL.createObjectURL(F),Z=h.current.get(k.id);Z&&URL.revokeObjectURL(Z),h.current.set(k.id,U),p(Q=>({...Q,[k.id]:{status:"playing",ts:k.ts||Date.now(),error:null,objectUrl:U}}))},R=(k={})=>{N||!k.id||p(T=>({...T,[k.id]:{...T[k.id]||{},status:k.error?"error":T[k.id]?.status||"connecting",error:k.error||null,ts:k.ts||T[k.id]?.ts||null,objectUrl:T[k.id]?.objectUrl||null}}))};return r.on("roverSnapshot:frame",j),r.on("roverSnapshot:status",R),r.emit("roverSnapshot:subscribe",{ids:w},(k={})=>{k.error}),()=>{N=!0,r.emit("roverSnapshot:unsubscribe",{ids:w}),r.off("roverSnapshot:frame",j),r.off("roverSnapshot:status",R),h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear()}},[r,x,o,b,E]),f}const cx=2e3,PN=3e3,WN=3e3,ew=40,tw=1e3;function fr({roverId:n=null,sessionInfo:a=null,audioSessionInfo:r=null,videoMode:o=null,snapshotFeed:u=null,label:f,forceMute:p=!1,sensors:h}){const g=oe(Ae=>Ae.session?.assignment?.roverId??null),x=n??g,v=oe(Ae=>Ae.session?.mode||null),b=oe(Ae=>x&&Array.isArray(Ae.session?.roster)&&Ae.session.roster.find(tt=>String(tt.id)===String(x))||null),S=!!b?.media?.audioPublishUrl,C=o?o==="whep":!0,E=m.useMemo(()=>!x||!C?[]:[{type:"rover",id:x,key:x},...S?[{type:"rover",id:`${x}-audio`,key:`${x}-audio`}]:[]],[x,C,S]),N=zd(E,{enabled:!!(x&&C),version:v}),w=a??(x&&N[x]||null),j=r??(x&&S&&N[`${x}-audio`]||null),R=$g(x?[x]:[],{enabled:!!(x&&!w?.url),version:v}),k=u??(x&&R[x]||null),T=f||b?.name||(x?`Rover ${x}`:"Rover"),q=Wt(x),$=h??q?.sensors??null,O=m.useRef(null),L=m.useRef(null),F=m.useRef(null),U=m.useRef(null),Z=m.useRef(null),Q=m.useRef(null),ce=m.useRef(null),ue=m.useRef(null),[le,B]=m.useState("idle"),[V,I]=m.useState(null),[J,ie]=m.useState("idle"),[M,D]=m.useState(null),[K,ae]=m.useState(0),[he,we]=m.useState(0),[pe,ge]=m.useState(!0),xe=!!j?.url,ye=o==="snapshot"||!o&&!w?.url,{value:Ce}=Oe("audio",it),qe=Number.isFinite(Ce?.masterVolume)?Ce.masterVolume:it.masterVolume,Ze=Number.isFinite(Ce?.roverVolume)?Ce.roverVolume:it.roverVolume,Se=typeof Ce?.mainBrushDuckEnabled=="boolean"?Ce.mainBrushDuckEnabled:typeof Ce?.autoLevelEnabled=="boolean"?Ce.autoLevelEnabled:it.mainBrushDuckEnabled,at=Number.isFinite(Ce?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Ce.mainBrushDuckAmount)):it.mainBrushDuckAmount,ht=Math.max(0,Math.min(1,qe*Ze)),Ge=!!((Number($?.mainBrushCurrentMa)||0)>ew||$?.wheelOvercurrents?.mainBrush),je=Se&&Ge?1-at:1,se=Math.max(0,Math.min(1,ht*je)),re=m.useMemo(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).has("debugAudio"),[]),de=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{de.current={hasDedicatedAudio:xe,audioUrl:j?.url||null,mainBrushDuckEnabled:Se,mainBrushDuckAmount:at,mainBrushActive:Ge,baseRoverGain:ht,effectiveRoverGain:se}},[xe,j?.url,Se,at,Ge,ht,se]);const fe=m.useCallback((Ae,tt={})=>{if(!re)return;const Xe=L.current,Ee=de.current,ze={event:Ae,ts:Date.now(),roverLabel:T||null,hasDedicatedAudio:Ee.hasDedicatedAudio,audioUrl:Ee.audioUrl,mainBrushDuckEnabled:Ee.mainBrushDuckEnabled,mainBrushDuckAmount:Ee.mainBrushDuckAmount,mainBrushActive:Ee.mainBrushActive,baseRoverGain:Ee.baseRoverGain,effectiveRoverGain:Ee.effectiveRoverGain,element:Xe?{muted:Xe.muted,volume:Xe.volume,paused:Xe.paused,ended:Xe.ended,readyState:Xe.readyState,networkState:Xe.networkState}:null,...tt};try{console.log(`[AudioDebug] ${Ae} ${JSON.stringify(ze)}`)}catch{console.log("[AudioDebug]",Ae,ze)}},[re,T]);m.useEffect(()=>{fe("settings/update")},[fe]);const Re=m.useCallback(()=>{clearTimeout(F.current),F.current=setTimeout(()=>ae(Date.now()),cx)},[]),te=m.useCallback(()=>{clearTimeout(U.current),U.current=setTimeout(()=>we(Date.now()),cx)},[]),me=m.useCallback(async()=>{const Ae=O.current;if(Ae)try{Ae.muted=!0,await Ae.play()}catch{}},[]),_e=m.useCallback((Ae=0)=>{if(p||xe)return;clearTimeout(Q.current);const tt=()=>{clearTimeout(Q.current),Q.current=setTimeout(()=>{p||Xe()},PN)},Xe=async()=>{const Ee=O.current;if(Ee)try{await me(),Ee.muted=!1,await Ee.play(),ge(!1)}catch{Ee.muted=!0,ge(!0),tt()}};Q.current=setTimeout(Xe,Ae)},[me,p,xe]);m.useEffect(()=>()=>{clearTimeout(F.current),clearTimeout(U.current),clearTimeout(Q.current),clearInterval(Z.current),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)},[]),m.useEffect(()=>{le==="playing"&&_e(0)},[le,_e]),m.useEffect(()=>{ye&&(B("snapshot"),I(null))},[ye]),m.useEffect(()=>{if(ye||!w?.url||!O.current)return;let Ae=!0,tt;const Xe=setTimeout(()=>ge(!0),0),Ee=(ze,rt)=>{Ae&&(fe("video/status",{nextStatus:ze,info:rt||null}),B(ze),I(rt||null),ze==="playing"&&me(),["error","failed","disconnected","closed"].includes(ze)&&Re())};return tt=new ox({url:w.url,token:w.token,video:O.current,receiveAudio:!xe,onStatus:Ee}),tt.start().catch(ze=>{Ae&&(B("error"),I(ze.message),Re())}),()=>{Ae=!1,clearTimeout(Xe),tt?.stop()}},[ye,w?.url,w?.token,K,Re,me,xe,fe]),m.useEffect(()=>{le==="stopped"&&w?.url&&Re()},[le,w?.url,Re]),m.useEffect(()=>{const Ae=L.current;if(!Ae||!j?.url){fe("route/no-audio-url"),ue.current=null;return}const tt=Math.max(0,Math.min(1,se)),Xe=ue.current==null?Math.max(0,Math.min(1,Ae.volume)):ue.current;if(ce.current&&(cancelAnimationFrame(ce.current),ce.current=null),tt>Xe){const Ee=performance.now(),ze=Xe,rt=tt-ze,Rs=sa=>{const St=Math.min(1,(sa-Ee)/tw),Nn=ze+rt*St;Ae.volume=Nn,ue.current=Nn,St<1?ce.current=requestAnimationFrame(Rs):ce.current=null};ce.current=requestAnimationFrame(Rs)}else Ae.volume=tt,ue.current=tt;fe("route/direct",{elementVolume:tt,duckEnabled:Se,mainBrushActive:Ge,duckAmount:at})},[j?.url,se,Se,Ge,at,fe]),m.useEffect(()=>{if(!j?.url||!L.current)return;let Ae=!0,tt;const Xe=(Ee,ze)=>{Ae&&(fe("audio/status",{nextStatus:Ee,info:ze||null}),ie(Ee),D(ze||null),["error","failed"].includes(Ee)&&te())};return tt=new ox({url:j.url,token:j.token,video:L.current,audioOnly:!0,onStatus:Xe}),tt.start().catch(Ee=>{Ae&&(ie("error"),D(Ee.message),te())}),()=>{Ae=!1,tt?.stop()}},[j?.url,j?.token,he,te,fe]),m.useEffect(()=>{const Ae=L.current;if(!j?.url||!Ae){clearInterval(Z.current);return}if(!["connecting","connected","playing","paused"].includes(J)){clearInterval(Z.current);return}const Xe=async()=>{const Ee=L.current;Ee&&(Ee.muted=!1,!(!Ee.paused&&!Ee.ended)&&(fe("retry/play-attempt"),Ee.play().then(()=>{fe("retry/play-ok"),ie(ze=>ze==="connected"?"playing":ze),D(ze=>ze==="paused"?null:ze)}).catch(ze=>{fe("retry/play-fail",{error:ze?.message}),D(rt=>rt||ze?.message||"autoplay blocked")})))};return Xe(),Z.current=setInterval(Xe,WN),()=>clearInterval(Z.current)},[j?.url,J,fe]),m.useEffect(()=>{const Ae=L.current;if(!Ae)return;const tt=()=>{fe("element/play"),ie(St=>St==="error"?St:"playing"),D(null)},Xe=()=>{fe("element/pause"),ie(St=>["error","failed","disconnected","closed","stopped"].includes(St)?St:"paused"),D(St=>St||"paused")},Ee=()=>{fe("element/ended"),ie(St=>St==="error"?St:"stopped"),D(St=>St||"ended")},ze=()=>{const{error:St}=Ae,Nn=St?.message||"audio error";fe("element/error",{error:Nn}),ie("error"),D(Nn)},rt=()=>fe("element/waiting"),Rs=()=>fe("element/canplay"),sa=()=>fe("element/stalled");return Ae.addEventListener("play",tt),Ae.addEventListener("pause",Xe),Ae.addEventListener("ended",Ee),Ae.addEventListener("error",ze),Ae.addEventListener("waiting",rt),Ae.addEventListener("canplay",Rs),Ae.addEventListener("stalled",sa),()=>{Ae.removeEventListener("play",tt),Ae.removeEventListener("pause",Xe),Ae.removeEventListener("ended",Ee),Ae.removeEventListener("error",ze),Ae.removeEventListener("waiting",rt),Ae.removeEventListener("canplay",Rs),Ae.removeEventListener("stalled",sa)}},[j?.url,fe]);const en=k?.error?`Error: ${k.error}`:k?.objectUrl?"snapshot":k?.status||"waiting",tn=ye?en:w?.url?le==="error"?`Error: ${V||"unknown"}`:V?`${le} (${V})`:le:"waiting",nn=j?.error?`Error: ${j.error}`:j?.url?J==="error"?`Error: ${M||"unknown"}`:M?`${J} (${M})`:J:null,Nt=!ye&&!w?.error&&["idle","new","connecting"].includes(le);return l.jsxs(l.Fragment,{children:[ye?k?.objectUrl?l.jsx("img",{src:k.objectUrl,alt:T,className:"h-full w-full object-contain",draggable:!1}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):l.jsx("video",{ref:O,muted:p||pe||xe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),Nt?l.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/45",children:l.jsx("div",{className:"rounded border border-slate-500/70 bg-black/70 px-3 py-1 text-sm font-semibold text-slate-100",children:"Connecting to video...."})}):null,l.jsx("audio",{ref:L,autoPlay:!0,hidden:!0}),l.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-20 font-medium text-slate-100 text-[0.65rem]",children:l.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[l.jsxs("span",{children:["Status: ",tn]}),nn?l.jsxs("span",{children:["Audio: ",nn]}):null]})})]})}function nw(n){const a=oe(O=>O.session?.mode||null),r=oe(O=>O.session?.roster??[]),o=oe(O=>O.session?.users??[]),u=oe(O=>O.session?.turnQueues??{}),f=oe(O=>O.session?.socketId||null),p=oe(O=>O.session?.activeDrivers??{}),[h,g]=m.useState(()=>Date.now()),x=n&&u?.[n]||null,v=n&&p?.[n]||null,b=!!(f&&v===f),S=m.useMemo(()=>{const O=x?.queue||[];if(!O.length||!x?.current||O.length<=1)return null;const L=O.findIndex(F=>F===x.current);return L===-1?O[0]||null:O[(L+1)%O.length]||null},[x?.queue,x?.current]),C=!!(f&&S===f),E=x?.deadline||null,N=E?E-h:null,w=a==="turns",j=r.length,R=m.useMemo(()=>{const O=new Set;return o.forEach(L=>{if(String(L?.role||"")==="spectator")return;const U=String(L?.roverId||"").trim(),Z=String(L?.socketId||"").trim();!U||!Z||O.add(Z)}),O.size},[o]),k=w&&R>j,T=w&&C&&N!=null&&N<=5e3&&N>0,$=w&&!b&&!T&&k;return m.useEffect(()=>{if(a!=="turns")return;const O=setInterval(()=>g(Date.now()),250);return()=>clearInterval(O)},[a]),$?"snapshot":null}const sw={discord:xg,kofi:Gp,"ko-fi":Gp,wiki:Dj,throne:_j},aw={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 lw(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const a=document.createElement("style");a.id=n,a.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(a)},[])}function rw(n,a){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof a=="string"&&a.trim()?a.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function wo({id:n,label:a,url:r,className:o=""}){if(!r)return null;lw();const u=rw(n,a),f=sw[u]||Oj,p=aw[u]||null,h=a||n||"Link";return l.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer","aria-label":h,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${p?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:p||void 0,children:[l.jsx(f,{className:"mr-0"}),h]})}function iw({roverId:n=null,mobileHud:a=!1,discordUrl:r=null}){const o=oe(je=>je.session?.assignment?.roverId??null),u=n??o,f=oe(je=>je.session?.mode||null),p=oe(je=>je.session?.roster??[]),h=oe(je=>je.session?.users??[]),g=oe(je=>je.session?.turnQueues??{}),x=oe(je=>je.session?.socketId||null),v=oe(je=>je.session?.activeDrivers??{}),b=oe(je=>(je.session?.socials||[]).find(de=>String(de?.id||de?.label||"").toLowerCase()==="discord")?.url||null||je.session?.discord?.invite||null),{state:{lastControlIntentAt:S}}=yt(),C=r||b,[E,N]=m.useState(()=>Date.now()),[w,j]=m.useState(!1),[R,k]=m.useState(null),[T,q]=m.useState(!1),[$,O]=m.useState(0),L=m.useRef({initialized:!1,roverId:null,activeDriverId:null}),F=m.useRef(S||0),U=a?"text-[0.5rem]":"text-[0.7rem]",Z=a?"px-0.5 py-0.25":"px-1 py-0.5",Q=a?"text-3xl":"text-5xl",ce=a?"text-xs":"text-sm",ue=a?"text-[0.55rem]":"text-[0.75rem]",le=a?"px-4 py-3":"px-6 py-4",B=u?g?.[u]:null,V=u?v?.[u]:null,I=!!(x&&V===x),J=m.useMemo(()=>{const je=B?.queue||[];if(!je.length||!B?.current||je.length<=1)return null;const se=je.findIndex(re=>re===B.current);return se===-1?je[0]||null:je[(se+1)%je.length]||null},[B?.queue,B?.current]),ie=!!(x&&J===x),M=B?.deadline||null,D=B?.idleDeadline||null,K=M?M-E:null,ae=D?D-E:null,he=f==="turns",we=p.length,pe=m.useMemo(()=>{const je=new Set;return h.forEach(se=>{if(String(se?.role||"")==="spectator")return;const de=String(se?.roverId||"").trim(),fe=String(se?.socketId||"").trim();!de||!fe||je.add(fe)}),je.size},[h]),ge=he&&pe>we,xe=he&&ie&&K!=null&&K<=5e3&&K>0,ye=he&&!I,Ce=ye&&!xe&&ge,qe=K!=null&&Number.isFinite(K)?Math.max(0,Math.ceil(K/1e3)):null,Ze=ae!=null&&Number.isFinite(ae)?Math.max(0,Math.ceil(ae/1e3)):null,Se=m.useMemo(()=>!he||!I?null:qe!=null?`${qe}s left`:"Your turn",[he,I,qe]),at=m.useMemo(()=>!ye||!ie||qe==null?null:`${qe} seconds until your turn.`,[ye,ie,qe]),ht=I&&typeof Ze=="number",Ge=T;return m.useEffect(()=>{if(f!=="turns")return;const je=setInterval(()=>N(Date.now()),250);return()=>clearInterval(je)},[f]),m.useEffect(()=>{if(f!=="turns"){j(!1),k(null),L.current={initialized:!1,roverId:null,activeDriverId:null};return}const je=L.current,se=V||null;if(!x||!u){j(!1),k(null),L.current={initialized:!1,roverId:null,activeDriverId:null};return}if(!je.initialized||je.roverId!==u){L.current={initialized:!0,roverId:u,activeDriverId:se};return}!!je.activeDriverId&&je.activeDriverId!==x&&se===x?(j(!0),k(Date.now())):se!==x&&w&&(j(!1),k(null)),L.current={initialized:!0,roverId:u,activeDriverId:se}},[V,f,u,x,w]),m.useEffect(()=>{!w||!R||S>R&&j(!1)},[S,w,R]),m.useEffect(()=>{const je=Number(F.current)||0,se=Number(S)||0;se>je&&ye&&O(Date.now()),F.current=se},[S,ye]),m.useEffect(()=>{if(!ye||!$)return;q(!0);const je=setTimeout(()=>q(!1),650);return()=>clearTimeout(je)},[ye,$]),l.jsxs(l.Fragment,{children:[w?l.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:l.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${le}`,children:[l.jsx("div",{className:`font-semibold text-amber-200 ${Q}`,children:"IT IS YOUR TURN!"}),l.jsx("div",{className:`text-amber-200/80 ${ce}`,children:"Start driving!"}),ht?l.jsxs("div",{className:`text-red-100/90 ${ue}`,children:["Idle skip in ",Ze,"s"]}):null]})}):null,Se?l.jsx("div",{className:`pointer-events-none absolute bottom-1 left-1 rounded border ${Ge?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${Z} ${U}`,children:Se}):null,ye?l.jsx("div",{className:"pointer-events-none absolute bottom-1 left-1 z-40",children:l.jsxs("div",{className:`w-fit rounded border ${T?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${a?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[l.jsx("div",{className:T?"text-[0.82rem] font-semibold text-red-50":"text-[0.82rem] font-semibold text-white",children:"Not your turn to drive!"}),at?l.jsx("div",{className:T?"text-red-100/95":"text-amber-100",children:at}):null,Ce?l.jsx("div",{className:T?"text-red-100/90":"text-amber-200/85",children:"Video switched to preview mode to save bandwidth."}):null,l.jsx("div",{className:"pointer-events-auto mt-0.5",children:l.jsx(wo,{id:"discord",label:"Join our Discord while you wait!",url:C})})]})}):null]})}const ow=Dt.memo(iw);function Gg(){const{value:n,save:a}=Oe("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,u=>{a({hudMapDesktop:!!u})}]}function ux({variant:n="default",label:a,roverColor:r=null,driverLabel:o=null,mobileHud:u=!1,labelScale:f=1}){const p=u?"px-0.25 py-0.25":"px-0.5 py-0.5",h=u?"text-[0.55rem]":"text-[0.8rem]",g="bottom-0.5",x={transform:`translateX(-50%) scale(${f})`,transformOrigin:"center bottom"};return n==="spectator"?l.jsx("div",{className:`absolute ${g} left-1/2`,style:x,children:l.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${p} ${h}`,children:[l.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ns(r,.18),children:a||"No rover"}),o?l.jsxs("span",{className:"text-slate-300",children:["• ",o]}):null]})}):l.jsx("div",{className:`absolute ${g} left-1/2`,style:x,children:l.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${p} ${h}`,children:l.jsxs("span",{children:["Rover:"," ",l.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(r,.18),children:['"',a||"No rover",'"']})]})})})}function cw({sensors:n,mobileHud:a=!1}){const r=a?"px-0.25 py-0.25":"px-1 py-0.5",o=a?"left-0.5 top-1/2":"left-1 top-1/2",u=a?"text-[0.45rem]":"text-[0.65rem]",f=[["Voltage",n?.voltageMv!=null?`${(n.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",n?.currentMa!=null?`${n.currentMa} mA`:"--"],["Charge",n?.batteryChargeMah!=null?`${n.batteryChargeMah}`:"--"],["OI",n?.oiMode?.label||"--"]],p=!!n?.chargingSources?.homeBase,h=n?.chargingState?.label||"",g=!!(h&&h.toLowerCase()!=="not charging"),x=n?.oiMode?.label||"Unknown",v=x.toLowerCase(),b=v==="full"?"bg-emerald-500/80 text-emerald-50":v==="safe"?"bg-amber-400/80 text-amber-950":v==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",S=p?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",C=g?"bg-emerald-500/80 text-emerald-50":p?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return l.jsx("div",{className:`absolute ${o} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${u} ${r}`,children:l.jsxs("div",{className:"space-y-0.5 leading-tight",children:[l.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[l.jsx("span",{className:`rounded px-1.5 py-0.5 ${S}`,children:p?"Docked":"Undocked"}),l.jsx("span",{className:`rounded px-1.5 py-0.5 ${C}`,children:g?"Charging":"Not charging"}),l.jsxs("span",{className:`rounded px-1.5 py-0.5 ${b}`,children:["OI: ",x]})]}),f.map(([E,N])=>l.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:E}),l.jsx("span",{className:"font-semibold text-white",children:N})]},E))]})})}function Ao(n){return Math.max(0,Math.min(1,n))}function Yg(n){return(n-90)*Math.PI/180}function or(n,a,r,o){const u=Yg(o);return{x:n+r*Math.cos(u),y:a+r*Math.sin(u)}}function uw(n,a,r,o,u){let f=o,p=u;p<=f&&(p+=360);const h=or(n,a,r,f),g=or(n,a,r,p);return["M",h.x,h.y,"A",r,r,0,0,1,g.x,g.y].join(" ")}function ff(n,a){if(a)return"#ef4444";const r=Math.abs(n);return r>900?"#f59e0b":r>300?"#22c55e":"#64748b"}function dw(n,a){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=Ao(n/(a||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function fw(n,a){if(a)return"#ef4444";const r=Ao(n==null?0:n/4095),o=[47,55,69],u=[245,158,11],[f,p,h]=o.map((g,x)=>Math.round(g+(u[x]-g)*r));return`rgb(${f}, ${p}, ${h})`}function mw({count:n,totalSpan:a,gap:r,startAngle:o}){const f=(a-r*(n-1))/n,p=[];let h=o;for(let g=0;g<n;g+=1){const x=h+f;p.push({start:h,end:x}),h=x+r}return p}function xd({cx:n,cy:a,rInner:r,rOuter:o,startDeg:u,endDeg:f,color:p,pulse:h=!1,opacity:g=1}){const x=(r+o)/2,v=o-r,b=uw(n,a,x,u,f);return l.jsxs(l.Fragment,{children:[l.jsx("path",{d:b,stroke:p,strokeWidth:v,strokeLinecap:"round",fill:"none",opacity:g}),h?l.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:v,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function hw({cx:n,cy:a,rBase:r,rTip:o,startDeg:u,endDeg:f,color:p,value:h,max:g}){const x=(u+f)/2,v=or(n,a,o,x),b=Ao(h!=null?h/(g||1):0),S=Math.pow(b,.35),C=r-(r-o)*S,E=Math.max(o,Math.min(C,r)),N=or(n,a,E,u),w=or(n,a,E,f),j=`M ${v.x} ${v.y} L ${N.x} ${N.y} L ${w.x} ${w.y} Z`;return l.jsx("path",{d:j,fill:p,opacity:1,stroke:"none"})}function dx({cx:n,cy:a,current:r,drop:o,overcurrent:u,label:f}){const p=Math.abs(r),h=Ao(p/1200),g=ff(r,u),x=56,v=14,b=9,S=3,C=x*h,E=f==="L"?-1:1,N=E*(-b/2-S/2),w=E*(v/2+S/2),j=v+b+S+2,R=x+4;return l.jsxs("g",{transform:`translate(${n},${a})`,children:[l.jsx("rect",{x:-j/2,y:-R/2,width:j,height:R,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:N-v/2,y:-x/2,width:v,height:x,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),l.jsx("rect",{x:N-v/2,y:x/2-C,width:v,height:C,fill:g,className:u?"animate-pulse":""}),l.jsx("rect",{x:w-b/2,y:-x/2,width:b,height:x,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),l.jsx("text",{x:0,y:x/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:f})]})}function pw({cx:n,cy:a,current:r,overcurrent:o}){let u=Math.abs(r);u<10&&(u=0);const f=ff(r*3,o),p=43,h=u>0?.65:null;return l.jsxs("g",{style:{transformOrigin:`${n}px ${a}px`,animation:h?`spin ${h}s linear infinite`:"none",animationDirection:h?"reverse":"normal"},children:[l.jsx("circle",{cx:n,cy:a,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(x=>{const v=Yg(x),b=n+p*Math.cos(v),S=a+p*Math.sin(v);return l.jsx("line",{x1:n,y1:a,x2:b,y2:S,stroke:f,strokeWidth:"4",strokeLinecap:"round"},x)}),o?l.jsx("circle",{cx:n,cy:a,r:p+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function xw({cx:n,cy:a,current:r,overcurrent:o,variant:u,dirtLeft:f,dirtRight:p}){const h=Math.abs(r),g=ff(r,o),x=1,v=96,b=12,S=`main-brush-pattern-a-${u}`,C=`main-brush-pattern-b-${u}`,E=h>0?.6:null,N=r>=0?1:-1;return l.jsxs("g",{children:[l.jsx("defs",{children:[S,C].map((w,j)=>l.jsxs("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[l.jsx("rect",{width:"6",height:"6",fill:g,opacity:x}),l.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),E?l.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${N*(j===0?6:-6)}`,dur:`${E}s`,repeatCount:"indefinite"}):null]},w))}),l.jsx("rect",{x:n-v/2,y:a-14,width:v,height:b,rx:"3",fill:`url(#${S})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:n-v/2,y:a+4,width:v,height:b,rx:"3",fill:`url(#${C})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("circle",{cx:n-v/4,cy:a-8,r:3.5,fill:"#fbbf24"}),l.jsx("circle",{cx:n+v/4,cy:a+8,r:3.5,fill:"#fbbf24"}),o?l.jsx("rect",{x:n-v/2-4,y:a-16,width:v+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function gw({sensors:n={},variant:a="full",size:r,overlay:o=!1}){const u=r||(a==="mini"?190:260),f=u/2,p=u*.07,h=f,g=f+p,x=f*.8,v=x-4,b=x+4,S=x-14,C=x-6,E=x*.65,N=n?.bumpsAndWheelDrops||{},w=n?.wheelOvercurrents||{},j=n?.wheelLeftCurrentMa??0,R=n?.wheelRightCurrentMa??0,k=n?.sideBrushCurrentMa??0,T=n?.mainBrushCurrentMa??0,q=6,$=N.bumpLeft?q:0,O=N.bumpRight?q:0,L=mw({count:6,totalSpan:140,gap:6,startAngle:-70}),F=["L","FL","CL","CR","FR","R"],U=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],Z=L.map((le,B)=>({label:F[B],start:le.start,end:le.end,value:U[B]})),Q=[{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}],ce=U.filter(le=>le!=null),ue=ce.length?Math.max(...ce,1200):1200;return l.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${u}px`,height:`${u}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),l.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",ue]})]}),l.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${u} ${u}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[l.jsx("circle",{cx:h,cy:g,r:x,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),l.jsx(dx,{cx:h-E,cy:g,current:j,drop:N.wheelDropLeft,overcurrent:w.leftWheel,label:"L"}),l.jsx(dx,{cx:h+E,cy:g,current:R,drop:N.wheelDropRight,overcurrent:w.rightWheel,label:"R"}),l.jsx(pw,{cx:h+x*.65,cy:g-x*.55,current:k,overcurrent:w.sideBrush}),l.jsx(xw,{cx:h,cy:g,current:T,overcurrent:w.mainBrush,variant:a,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),Z.map(le=>{const B=dw(le.value,ue),V=b+4,I=V+28;return l.jsx(hw,{cx:h,cy:g,rBase:I,rTip:V,startDeg:le.start,endDeg:le.end,color:B,value:le.value,max:ue},le.label)}),Q.map(le=>l.jsx(xd,{cx:h,cy:g,rInner:S,rOuter:C,startDeg:le.start,endDeg:le.end,color:fw(le.value,le.active),opacity:1,pulse:!!le.active},le.label)),l.jsx(xd,{cx:h,cy:g,rInner:v-$,rOuter:b-$,startDeg:-70,endDeg:-6,color:N.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!N.bumpLeft}),l.jsx(xd,{cx:h,cy:g,rInner:v-O,rOuter:b-O,startDeg:6,endDeg:70,color:N.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!N.bumpRight})]})]})}const Fg=Dt.memo(gw);function fx({sensors:n,show:a=!0,mapPosition:r="top-center",layoutFormat:o="desktop",mobileHud:u=!1}){if(!a)return null;const f=o==="mobile-portrait",p="240px",h=f?.3:u?.33:.7,x={width:p,height:p,opacity:u?.6:.7,transform:r==="top-center"?`translateX(-50%) scale(${h})`:`scale(${h})`,transformOrigin:r==="bottom-left"?"bottom left":r==="top-center"?"top center":"top right",...r==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:r==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};return l.jsx("div",{className:"pointer-events-none absolute rounded",style:x,children:l.jsx(Fg,{sensors:n,size:240,overlay:!0})})}function vw({roverId:n=null,sensors:a,label:r,roverColor:o=null,layoutFormat:u="desktop",variant:f="default",driverLabel:p=null,showTopDown:h=void 0,mobileHud:g=!1,mapPosition:x=null,labelScale:v=1}){const b=oe(L=>L.session?.assignment?.roverId??null),S=n??b,C=Wt(S),E=oe(L=>{if(!S)return{label:null,roverColor:null};const U=(L.session?.roster||[]).find(Z=>String(Z.id)===String(S));return{label:U?.name||null,roverColor:U?.color||null}}),N=oe(L=>{if(!S||f!=="spectator")return null;const F=L.session?.activeDrivers?.[S]||null,Z=(L.session?.users||[]).find(Q=>String(Q.socketId||"")===String(F||""));return Z?.nickname||Z?.name||null}),w=a??C?.sensors??null,j=r??E.label??null,R=o??E.roverColor??null,k=p??N,T=g,[q]=Gg(),$=typeof h=="boolean"?h:f==="spectator"||T?!0:q,O=x||(f==="spectator"?"top-center":T?"top-right":"top-center");return f==="none"?null:f==="spectator"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx(cw,{sensors:w,mobileHud:T}),l.jsx(ux,{variant:"spectator",label:j,roverColor:R,driverLabel:k,mobileHud:T,labelScale:v})]}),l.jsx(fx,{sensors:w,show:$,mapPosition:O,layoutFormat:u,mobileHud:T})]}):l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx(ux,{variant:"default",label:j,roverColor:R,mobileHud:T,labelScale:v}),l.jsx(fx,{sensors:w,show:$&&f!=="spectator",mapPosition:O,layoutFormat:u,mobileHud:T})]})}const Ig=Dt.memo(vw);function bw({mobileHud:n=!1}){const{visible:a,statusLabel:r,statusTone:o,active:u,charging:f}=al({manageLifecycle:!0}),[p,h]=m.useState(""),g=m.useRef(null),x=m.useRef(u);if(m.useEffect(()=>{const b=x.current;u&&!b?h("Dock assist mode enabled"):!u&&b&&f&&h("Docking successful! Thank you!"),x.current=u},[u,f]),m.useEffect(()=>{if(p)return g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{h(""),g.current=null},2500),()=>{g.current&&(clearTimeout(g.current),g.current=null)}},[p]),!a)return null;const v=o==="good"?"border-emerald-200/90 bg-emerald-900/90 text-emerald-50":o==="warn"?"border-amber-200/90 bg-amber-900/90 text-amber-50":"border-cyan-200/90 bg-cyan-900/90 text-cyan-50";return l.jsx("div",{className:"pointer-events-none absolute inset-0",children:p?l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx("div",{className:`rounded-xl border border-indigo-200/95 bg-black/95 px-4 py-2 text-center font-semibold text-indigo-50 shadow-2xl ${n?"text-lg":"text-2xl"}`,children:p})}):l.jsx("div",{className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-lg border px-2 py-1 font-semibold shadow-lg ${v} ${n?"text-[0.65rem]":"text-xs"}`,children:r})})}const yw=Dt.memo(bw),mx=5e3,Sw=700;function Xg({roverId:n=null,description:a,variant:r="default",mobileHud:o=!1,displayKey:u="",controlIntentAt:f}){const p=oe(R=>R.session?.assignment?.roverId??null),h=n??p,g=oe(R=>h&&(R.session?.roster||[]).find(q=>String(q.id)===String(h))?.description||null),x=a??g,v=typeof f=="number"?f:0,b=u||`${h||""}::${x||""}`,[S,C]=m.useState(!1),[E,N]=m.useState(!1),w=m.useRef(null),j=m.useRef(null);return m.useEffect(()=>()=>{clearTimeout(w.current),clearTimeout(j.current)},[]),m.useEffect(()=>{if(r!=="default"||!x){C(!1),N(!1),clearTimeout(w.current),clearTimeout(j.current);return}clearTimeout(w.current),clearTimeout(j.current),C(!0),N(!1)},[x,b,r]),m.useEffect(()=>{r!=="default"||!x||!S||E||(Number(v)||0)<=0||w.current||j.current||(w.current=setTimeout(()=>{N(!0),w.current=null},mx),j.current=setTimeout(()=>{C(!1),j.current=null},mx+Sw))},[v,x,E,S,r]),x?r==="spectator"?l.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1 z-50 flex justify-center",children:l.jsx("div",{className:"surface max-w-[92%] border border-slate-600/80 px-1 py-0.5 text-center text-[0.62rem] leading-tight text-slate-100 shadow-lg",children:x})}):r!=="default"||!S?null:l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center",children:l.jsxs("div",{className:`surface max-w-[94%] border border-slate-400 bg-neutral-900 px-2 py-1 text-center font-semibold text-slate-100 shadow-xl transition-opacity duration-700 ${E?"opacity-0":"opacity-100"} ${o?"text-[1rem] leading-tight":"text-[1.5rem] leading-tight"}`,children:[l.jsx("p",{children:"Just so you know, this rover"}),l.jsx("p",{children:x}),l.jsx("p",{className:`${o?"text-[0.58rem]":"text-[0.72rem]"} mt-0.5 font-normal text-slate-300`,children:"This fades 5 seconds after your first control input."})]})}):null}const jw={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function Nw({roverId:n=null,sensors:a,overcurrentLimiter:r=null,compact:o=!1}){const u=oe(L=>L.session?.assignment?.roverId??null),f=n??u,p=Wt(f),h=Ng(f),g=a??p?.sensors??null,x=r??h??null,v=g?.wheelOvercurrents||null,b=m.useMemo(()=>v==null?[]:Object.entries(v).filter(([,L])=>!!L).map(([L])=>L),[v]),S=x?.caps||null,C=m.useMemo(()=>{if(!S)return null;const L=Number.isFinite(S?.drive?.cap)?S.drive.cap:1,F=Number.isFinite(S?.aux?.cap)?S.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(L,F)))},[S]),E=!!x?.isActive,N=m.useMemo(()=>b.length?b:E?["limiter"]:[],[b,E]),w=C??(b.length?1:0);if(!N?.length)return null;const j=N.map(L=>jw[L]||L),R=o?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",k=o?"px-2 py-1":"px-4 py-2",T=o?"text-lg":"text-4xl",q=o?"text-xs":"text-xl",$=Math.max(0,Math.min(1,w)),O=`${Math.round($*100)}%`;return l.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 ${R}`,children:l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx("div",{className:"absolute inset-0 overflow-hidden",children:l.jsx("div",{className:"h-full bg-red-700/60",style:{width:O}})}),l.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 ${T} ${k}`,children:[l.jsx("div",{children:"OVERCURRENT"}),l.jsx("div",{className:`mt-0 font-medium text-white ${q}`,children:j.join(", ")})]})]})})}const Qg=Dt.memo(Nw),mr=10;function Co({batteryState:n=null,charge:a=null,config:r=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,u=n?.warnActive??null,f=n?.urgentActive??null,p=r?.Full??null,h=r?.Warn??null,g=r?.Urgent??null,x=a??n?.charge??null;let v=o;if(v==null&&(v=ww({charge:x,full:p,warn:h,urgent:g})),v==null)return{available:!1};const b=Math.max(0,Math.min(1,v/100)),S=u??(h!=null&&x!=null&&x<=h),C=f??(g!=null&&x!=null&&x<=g);return{available:!0,percent:b,percentDisplay:v,warnActive:S,urgentActive:C,warnDisplayPercent:mr}}function ww({charge:n,full:a,warn:r,urgent:o}){if(n!=null&&a!=null&&r!=null&&o!=null&&a>r&&r>o){const u=mr/100,f=1-u;if(n<=o)return 0;if(n<=r){const h=(n-o)/(r-o);return Math.round(Math.max(0,Math.min(1,h))*mr)}if(n>=a)return 100;const p=(n-r)/(a-r);return Math.round((u+Math.max(0,Math.min(1,p))*f)*100)}return null}function Aw({roverId:n=null,sensors:a,batteryConfig:r,compact:o=!1}){const u=oe(E=>E.session?.assignment?.roverId??null),f=n??u,p=Wt(f),h=oe(E=>f?(E.session?.roster||[]).find(j=>String(j.id)===String(f))?.battery??null:null),g=a??p?.sensors??null,x=r??h,v=Co({charge:g?.batteryChargeMah??null,config:x});if(!v?.available||!v.warnActive&&!v.urgentActive)return null;const b=v.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",S=o?"p-2 top-6":"p-4 top-10",C=o?"text-sm":"text-2xl";return l.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${S}`,children:l.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${C}`,children:l.jsx("div",{children:b})})})}const Kg=Dt.memo(Aw);function Cw({roverId:n=null,sensors:a}){const r=oe(S=>S.session?.assignment?.roverId??null),u=Wt(n??r),f=a??u?.sensors??null,p=[f?.lightBumpLeftSignal,f?.lightBumpFrontLeftSignal,f?.lightBumpCenterLeftSignal,f?.lightBumpCenterRightSignal,f?.lightBumpFrontRightSignal,f?.lightBumpRightSignal],h=p.filter(S=>S!=null).reduce((S,C)=>Math.max(S,C),1200),g=S=>Math.pow(Math.max(0,Math.min(1,(S??0)/h)),.35),x=S=>S==null||S<=0?"hsl(200 60% 18%)":`hsl(${(200+g(S)*360)%360} 100% 60%)`,v=6,b=12;return l.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:p.map((S,C)=>{const E=g(S),N=C<v/2?-1:1,w=`${E*100}%`,j=x(S);return l.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${b}px`},children:l.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:l.jsx("div",{className:"h-full",style:{width:w,background:j,float:N===-1?"right":"left"}})})},C)})})}const kw=Dt.memo(Cw),Ew=1600,Mw=800;function yn(...n){return n.filter(Boolean).join(" ")}function Rw({visual:n,orientation:a="horizontal",variant:r="inline",compact:o=!1,showLabel:u,className:f=""}){const p=r==="background",h=a==="vertical",g=u??!p;if(!n?.available){if(p){const Q=mr,ce=yn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",C&&!S&&"battery-tick-warn"),ue=h?{bottom:`${Q}%`}:{left:`${Q}%`},le=yn("absolute inset-0 pointer-events-none",f);return l.jsxs("div",{className:le,children:[l.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),l.jsx("div",{className:ce,style:ue})]})}return h?null:l.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const x=n.percentDisplay??0,v=Math.max(0,Math.min(100,x)),b=n.warnDisplayPercent??mr,S=!!n.urgentActive,C=!!n.warnActive,E=S?`${Mw}ms`:C?`${Ew}ms`:void 0,w=p?S||C?"bg-red-500/45":"bg-emerald-500/45":S||C?"bg-red-500":"bg-emerald-500",j=S||C?"bg-red-900/35":"bg-slate-900/35",R=S||C?"bg-red-900/45":"bg-slate-900/35",k=yn(p?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",h&&!p?"flex flex-col items-center justify-center":"w-full",f);if(p){const Q=h?{height:`${v}%`}:{width:`${v}%`},ce=yn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),ue=yn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",C&&!S&&"battery-tick-warn"),le=h?{bottom:`${b}%`}:{left:`${b}%`};return l.jsxs("div",{className:k,children:[l.jsx("div",{className:yn("absolute inset-0",j,S&&"battery-urgent-flash")}),l.jsx("div",{className:ce,style:{...Q,animationDuration:E}}),l.jsx("div",{className:ue,style:le})]})}const T=yn("relative overflow-hidden rounded-sm border border-slate-800",S||C?R:"bg-zinc-900/90",S&&"battery-urgent-flash",h?"w-full flex-1":o?"h-4":"h-5"),q=h?{height:`${v}%`}:{width:`${v}%`},$=yn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),O=yn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",C&&!S&&"battery-tick-warn"),L=h?{bottom:`${b}%`}:{left:`${b}%`},F=`Battery ${x}%`,U=yn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",h?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),Z=yn("rounded px-1.5 py-0.5",p?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return l.jsxs("div",{className:k,children:[l.jsxs("div",{className:T,children:[l.jsx("div",{className:$,style:{...q,animationDuration:E}}),l.jsx("div",{className:O,style:L})]}),g&&!h?l.jsx("div",{className:U,children:l.jsx("span",{className:Z,children:F})}):null,g&&h?l.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:l.jsxs("span",{className:Z,children:[x,"%"]})}):null]})}const mf=Dt.memo(Rw);function Tw({roverId:n=null,mobileHud:a=!1}){const r=oe(g=>g.session?.assignment?.roverId??null),o=n??r,f=Wt(o)?.sensors??null,p=oe(g=>o?(g.session?.roster||[]).find(b=>String(b.id)===String(o))?.battery??null:null),h=Co({charge:f?.batteryChargeMah??null,config:p});return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(kw,{roverId:o}),l.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:l.jsx(mf,{visual:h,compact:a})})]})}function qw({compact:n=!1}){const a=oe(L=>L.session?.role||null),r=oe(L=>L.session?.assignment?.roverId||null),o=oe(L=>L.session?.roster||[]),{sendMessage:u,onInputFocus:f,onInputBlur:p,blurChat:h,registerInputRef:g,setTypingActive:x}=rf(),{value:v}=Oe("tts",{engine:"flite",voice:"rms",pitch:50}),[b,S]=m.useState(""),[C,E]=m.useState(!1),N=a!=="spectator",w=a==="spectator",R=!!m.useMemo(()=>o.find(L=>String(L.id)===String(r))||null,[r,o])?.audio?.ttsEnabled,k=m.useMemo(()=>{if(!R)return null;const L=v?.engine==="espeak"?"espeak":"flite";if(L==="espeak"){let U=Number.isFinite(v?.pitch)?Math.round(v.pitch):void 0;return typeof U=="number"&&(U=Math.max(0,Math.min(99,U))),{speak:!0,engine:L,pitch:U}}const F=typeof v?.voice=="string"?v.voice:void 0;return{speak:!0,engine:L,voice:F}},[v?.engine,v?.pitch,v?.voice,R]),T=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",q=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",$=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 O(L){if(L.preventDefault(),!N)return;const F=b.trim();if(F){E(!0);try{await u(F,k),S(""),h(),x(!1)}catch(U){alert(U.message)}finally{E(!1)}}}return w?null:l.jsxs("form",{onSubmit:O,className:T,children:[l.jsx("input",{className:q,value:b,onChange:L=>{const F=L.target.value;S(F),x(!!F.trim())},onFocus:L=>{f(L),x(!!b.trim())},onBlur:L=>{p(L),x(!1)},onKeyDown:L=>{L.key==="Enter"&&!b.trim()&&(L.preventDefault(),h(),x(!1))},ref:L=>g(L,{target:"hud"}),placeholder:N?"Chat (TTS)":"Spectator",disabled:!N}),l.jsx("button",{type:"submit",disabled:!N||C,className:$,children:"Speak"})]})}const Dw=m.memo(qw);function hf({layoutFormat:n="desktop"}){const a=oe(f=>f.session?.assignment?.roverId??null),r=nw(a),{state:{lastControlIntentAt:o}}=yt();if(!a)return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[l.jsx("p",{children:"You are not assigned to a rover."}),l.jsx("p",{className:"mt-0",children:l.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})});const u=n!=="desktop";return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsxs("div",{className:"relative w-full overflow-hidden bg-black aspect-[4/3]",children:[l.jsx(fr,{roverId:a,videoMode:r}),l.jsx(ow,{mobileHud:u}),l.jsx(Xg,{variant:"default",mobileHud:u,controlIntentAt:o}),l.jsx(Ig,{layoutFormat:n,variant:"default",mobileHud:u,labelScale:1}),l.jsx(yw,{mobileHud:u}),l.jsx(Dw,{compact:u}),l.jsx(Qg,{compact:u}),l.jsx(Kg,{compact:u})]}),l.jsx(Tw,{mobileHud:u})]})})}function xo({label:n,tone:a="muted"}){const r=a==="success"?"bg-emerald-900 text-emerald-100":a==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return l.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${r}`,children:n})}function ko(n){if(!Number.isFinite(n))return 0;const a=n%360;return a<0?a+360:a}function _w(n){if(!Array.isArray(n)||n.length<3)return 0;const[a,r,o]=n,u=Math.max(0,Math.min(255,Number(a)))/255,f=Math.max(0,Math.min(255,Number(r)))/255,p=Math.max(0,Math.min(255,Number(o)))/255,h=Math.max(u,f,p),g=Math.min(u,f,p),x=h-g;if(x===0)return 0;let v=0;return h===u?v=(f-p)/x%6:h===f?v=(p-u)/x+2:v=(u-f)/x+4,ko(Math.round(v*60))}function hx(n){const a=ko(n),r=1,o=1-Math.abs(a/60%2-1);let u=0,f=0,p=0;return a<60?(u=r,f=o):a<120?(u=o,f=r):a<180?(f=r,p=o):a<240?(f=o,p=r):a<300?(u=o,p=r):(u=r,p=o),[Math.round(u*255),Math.round(f*255),Math.round(p*255)]}function px(n){return n?Array.isArray(n.hsColor)?ko(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?_w(n.rgbColor):0:0}function Ow({entity:n,connected:a,controlsLocked:r,onToggle:o,onSetColor:u,onSetWhite:f}){const p=n.state==="unavailable"||!n.available,h=n.state==="on",g=n.type==="light"&&n.supportsColor,x=p?"warn":h?"success":"muted",v=p?"Unavailable":h?"On":"Off",b=r||!a||p,S=b||!g,[C,E]=m.useState(()=>px(n)),N=m.useRef(C),w=m.useRef(!1),j=p?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":r?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":h?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!g||w.current)return;const L=px(n);N.current=L,E(L)},[n.rgbColor,n.hsColor,g]);const R=L=>{const F=ko(Number(L.target.value));N.current=F,E(F)},k=()=>{S||!u||u(n.id,hx(N.current))},T=L=>{L.stopPropagation()},q=L=>{T(L),!(S||!f)&&f(n.id)},O=`rgb(${(g?hx(N.current):[255,255,255]).join(",")})`;return l.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:b,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${j} disabled:opacity-60 disabled:hover:bg-inherit`,children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[l.jsx("span",{className:"truncate font-semibold text-white",children:n.name||n.id}),g&&l.jsxs(l.Fragment,{children:[l.jsx(xo,{label:v,tone:x}),!a&&l.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),g?l.jsx("div",{className:"-mt-0.5 w-full",onClick:T,onPointerDown:L=>{T(L),w.current=!0},onPointerUp:L=>{T(L),w.current=!1,k()},onPointerCancel:L=>{T(L),w.current=!1,k()},onKeyUp:L=>{T(L),k()},onBlur:k,children:l.jsx("div",{className:"relative w-full",children:l.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:C,onChange:R,disabled:S,"aria-label":`Set color for ${n.name||n.id}`,className:"ha-hue-slider w-full"})})}):l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsx(xo,{label:v,tone:x}),!a&&l.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),g&&l.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[l.jsx("span",{role:"button",tabIndex:S?-1:0,onClick:q,onPointerDown:T,onKeyDown:L=>{S||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),q(L))},title:"Set white color temperature","aria-label":`Set ${n.name||n.id} to white`,"aria-disabled":S,className:`inline-flex items-center justify-center rounded border border-slate-200 bg-white px-1 py-0.5 text-xs font-semibold leading-none text-slate-900 ${S?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-slate-100"}`,children:"white"}),l.jsx("span",{className:"pointer-events-none h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:O}})]}),!g&&l.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:h?"Turn off":"Turn on"})]})}function Zg(){const{state:{keymap:n}}=yt(),a=oe(S=>S.session?.homeAssistant||null),{homeAssistantToggle:r,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:u}=Ot(),f=m.useMemo(()=>a?.entities||[],[a?.entities]),p=a?.lightPolicy||null,h=!!(p?.locked||p?.lockedOn),g=p?.lockState||(p?.lockedOn?"on":null),x=Tt(n?.homeAssistantOn?.[0]),v=Tt(n?.homeAssistantOff?.[0]);if(!a?.enabled)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(f.length===0)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const b=!!a?.connected;return l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room Controls"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length}),h?l.jsx(xo,{label:g==="off"?"Locked Off":"Locked On",tone:"warn"}):null,l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"On"}),x?l.jsx(xx,{label:x}):null]}),l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"Off"}),v?l.jsx(xx,{label:v}):null]})]})]}),l.jsx(xo,{label:b?"Connected":"Offline",tone:b?"success":"warn"})]}),h?l.jsx("p",{className:"rounded border border-amber-600/60 bg-amber-900/40 px-1 py-0.5 text-xs text-amber-100",children:g==="off"?"Lights are locked off. Room controls are disabled.":"Lights are locked on. Room controls are disabled."}):null,l.jsx("div",{className:"flex flex-wrap gap-0.5",children:f.map(S=>l.jsx(Ow,{entity:S,connected:b,controlsLocked:h,onToggle:r,onSetColor:o,onSetWhite:u},S.id))})]})}function xx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Jg(){const{login:n,setRole:a}=Ot(),[r,o]=m.useState(""),[u,f]=m.useState(""),[p,h]=m.useState(!1);async function g(x){x.preventDefault(),h(!0);try{await n(r,u),o(""),f("")}catch(v){alert(v.message)}finally{h(!1)}}return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),l.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:g,children:[l.jsx("input",{className:"field-input",placeholder:"Username",value:r,onChange:x=>o(x.target.value)}),l.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:u,onChange:x=>f(x.target.value)}),l.jsx("button",{type:"submit",disabled:p,className:"button-dark w-full disabled:opacity-50",children:p?"Logging in…":"Login"})]})]})}function gx(...n){return n.filter(Boolean).join(" ")}function Bw(n){const a=n?.batteryState?.percentDisplay;return a==null?"--":`${a}%`}function Lw(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function zw({title:n,roster:a=[],emptyText:r="No roster data.",renderActions:o=null}){return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),a.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:r}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:a.map(u=>{const f=!!(u?.private?.enabled&&u?.private?.open),p=!!u?.locked;return l.jsxs("li",{className:gx("surface flex flex-wrap items-center justify-between gap-0.5",p?"bg-red-900/40":f?"bg-amber-700/35 border border-amber-200/30":null),children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-slate-200",children:l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(u.color,.16),children:u.name})}),l.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[l.jsx("span",{children:u.locked?"locked":"free"}),u.lockReason&&l.jsx("span",{className:"rounded bg-black/30 px-1",children:u.lockReason}),l.jsxs("span",{className:gx("font-semibold",Lw(u)),children:["Battery ",Bw(u)]})]})]}),o?o(u):null]},u.id)})})]})}function Uw(n){const a=n?.runtime||{},r=n?.output||{},o=n?.errors||{};return a.inFlight?{label:"IN FLIGHT",detail:a.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:a.outcome==="posted"?{label:"POSTED",detail:r.posted?`Last: ${r.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:a.outcome==="skipped"?{label:"SKIPPED",detail:a.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:a.outcome==="failed"?{label:"FAILED",detail:o.message||a.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:a.running?"IDLE":"STOPPED",detail:a.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Hw(n,a){const r=Date.now(),u=(Array.isArray(n)?n:[]).map((f,p)=>{const h=String(f?.role||"").toLowerCase(),g=typeof f?.content=="string"?f.content:JSON.stringify(f?.content??null,null,2),x=h==="system"?"LLM System":h==="assistant"?"LLM Context":h==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${p}`,message:{ts:r+p,nickname:x,text:g,role:"spectator",bot:h==="system"}}});if(a!=null){const f=String(a);u.push({id:"llm-output",message:{ts:r+u.length+1,nickname:"LLM Output",text:f.trim()?f:"<empty>",role:"spectator",bot:!0}})}return u}function Vw({state:n,onClearHistory:a,clearingHistory:r}){const[o,u]=m.useState(null);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},p=n.counters||{},h=n.timings||{},g=n.input||{},x=n.output||{},v=n.errors||{},b=Array.isArray(n.history)?n.history:[],S=b.find(w=>w.runId===o)||(b.length?b[b.length-1]:null),C=Uw(n),E=Hw(g.modelMessages,x.raw),N=[{label:"running",value:f.running?"yes":"no"},{label:"in flight",value:f.inFlight?"yes":"no"},{label:"phase",value:f.phase||"--"},{label:"run id",value:f.currentRunId??"--"},{label:"tick count",value:f.tickCount??0},{label:"last tick",value:f.lastTickAt?new Date(f.lastTickAt).toLocaleString():"never"},{label:"next run",value:f.nextRunAt?new Date(f.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:f.outcome||"--"},{label:"reason",value:f.reason||"--"},{label:"skip streak",value:p.skipStreak??0},{label:"clear count",value:p.clearCount??0},{label:"last gen",value:h.lastGenerationMs!=null?`${h.lastGenerationMs} ms`:"--"},{label:"avg gen",value:h.avgGenerationMs!=null?`${h.avgGenerationMs} ms`:"--"},{label:"gen count",value:h.generationCount??0},{label:"prompt chars",value:p.promptChars??0},{label:"active drivers",value:p.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:p.snapshotSummary?.rovers??0},{label:"snapshot chat",value:p.snapshotSummary?.chatMessages??0}];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:a,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear LLM History"})}),l.jsxs("div",{className:`surface border text-center ${C.className}`,children:[l.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:C.label}),l.jsx("div",{className:"text-xs text-slate-200",children:C.detail})]}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:N.map(w=>l.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:[w.label,": ",w.value]},w.label))}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",v.message]}):null,v.details?l.jsxs("details",{className:"surface text-xs text-red-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(v.details,null,2)})]}):null,x.generated?l.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",x.generated]}):null,x.posted?l.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",x.posted]}):null,l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),l.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:E.length?E.map(w=>l.jsx(sf,{message:w.message},w.id)):l.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{children:["Raw output: ",x.raw?.trim()?x.raw:"<none>"]}),l.jsxs("div",{children:["Posted: ",x.posted||"<none>"]}),l.jsxs("div",{children:["Output at: ",x.modelOutputAt?new Date(x.modelOutputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Failed at: ",v.failedAt?new Date(v.failedAt).toLocaleString():"n/a"]})]})]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),l.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(w=>l.jsxs("button",{type:"button",onClick:()=>u(w.runId),className:`w-full text-left surface ${S?.runId===w.runId?"border border-sky-400/50":""}`,children:[l.jsxs("span",{className:"text-slate-300",children:["#",w.runId]})," ",l.jsx("span",{className:"text-slate-200",children:w.outcome||w.phase||"--"})," ",l.jsx("span",{className:"text-slate-400",children:w.durationMs!=null?`${w.durationMs}ms`:"--"})," ",l.jsx("span",{className:"text-slate-500",children:w.reason||""})]},w.runId)):l.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),S?l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",S.runId," details"]}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(S,null,2)})]}):null]})}function $w({state:n,onClearHistory:a,clearingHistory:r}){const[o,u]=m.useState(!1);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},p=n.config||{},h=n.output||{},g=n.timings||{},x=n.input||{},v=n.errors||{},b=()=>{const S=Array.isArray(x.modelMessages)?x.modelMessages:[];return S.length?S.map((C,E)=>{const N=String(C?.role||"unknown").toUpperCase(),w=String(C?.content||"");return`#${E+1} ${N}
|
||
${w}`}).join(`
|
||
|
||
----------------------------------------
|
||
|
||
`):"<none>"};return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:a,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear Overseer History"})}),l.jsxs("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:[l.jsxs("span",{className:"surface-muted",children:["running: ",f.running?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["phase: ",f.phase||"--"]}),l.jsxs("span",{className:"surface-muted",children:["tick: ",f.tickCount??0]}),l.jsxs("span",{className:"surface-muted",children:["trigger: ",f.lastTriggerReason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["name: ",p.name||"--"]}),l.jsxs("span",{className:"surface-muted",children:["model: ",p.model||"--"]}),l.jsxs("span",{className:"surface-muted",children:["observeOnly: ",p.observeOnly?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["decision: ",h.normalized||"--"]}),l.jsxs("span",{className:"surface-muted",children:["outcome: ",h.outcome||"--"]}),l.jsxs("span",{className:"surface-muted",children:["reason: ",h.reason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["last gen: ",g.lastGenerationMs!=null?`${g.lastGenerationMs}ms`:"--"]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Latest Context"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:x.stateUpdate||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Input (messages[])"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:b()})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact System Prompt"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:x.systemPrompt||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Transcript Rows"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(x.transcript||[],null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Tool Availability"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify({available:x.availableTools,blocked:x.blockedTools},null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Output"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:h.raw||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Live Tool Calls"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(h.liveToolCalls||[],null,2)})]}),l.jsxs("div",{className:"surface text-xs text-slate-200",children:[l.jsxs("div",{children:["Normalized decision: ",h.normalized||"--"]}),l.jsxs("div",{children:["Model input at: ",x.modelInputAt?new Date(x.modelInputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Model output at: ",h.outputAt?new Date(h.outputAt).toLocaleString():"n/a"]})]}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300",children:["Error: ",v.message]}):null,l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Recent Runs"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n.history||[],null,2)})]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>u(S=>!S),children:o?"Hide Full Payload":"Show Full Payload"}),o?l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)}):null]})}function Gw({health:n,roster:a=[]}){if(!n)return null;const r=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},u=g=>a.find(x=>String(x.id)===String(g))?.color||null,f=`${r.readyCount}/${r.totalCount} sources ready`,p=o.rovers.filter(g=>g.stale).length,h=o.rooms.filter(g=>g.stale).length;return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Replay segments"}),l.jsx("span",{className:"text-slate-400",children:f})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Rover snapshots"}),l.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rovers.length-p,"/",o.rovers.length," ok"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Room cameras"}),l.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rooms.length-h,"/",o.rooms.length," ok"]})]})]}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:r.sources.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:`${g.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:g.type==="rover"?ns(u(g.id),.16):void 0,children:g.label}),l.jsxs("span",{className:g.ready?"text-emerald-300":"text-amber-300",children:[g.recentCount,"/",g.neededCount]})]},`${g.type}:${g.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(u(g.id),.16),children:g.name}),l.jsx("span",{className:g.stale?"text-amber-300":"text-emerald-300",children:g.stale?"stale":"ok"})]},`rover:${g.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:g.name}),l.jsx("span",{className:g.stale?"text-amber-300":"text-emerald-300",children:g.error?"error":g.stale?"stale":"ok"})]},`room:${g.id}`))})]})}function Yw({entries:n}){const a=n||[];return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Admin IP log"}),l.jsx("span",{children:a.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?l.jsx("p",{children:"No admin log entries yet."}):a.slice().reverse().map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.ts?new Date(r.ts).toLocaleTimeString():"--"})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{className:"text-slate-200",children:r.message})," ",r.ip&&l.jsx("span",{className:"text-cyan-300",children:r.ip})," ",r.meta&&l.jsx("span",{className:"text-slate-500",children:JSON.stringify(r.meta)})]},r.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const Fw=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Iw(){const{session:n,lockRover:a,setMode:r,requestControl:o,setGlobalObjective:u,setAdminReason:f,rebootRover:p,rebootServer:h,setAudioLevels:g,setPrivateSafety:x,llmControl:v,overseerControl:b,adminLogs:S,llmCommentaryState:C,overseerControlState:E}=br(),N=m.useMemo(()=>n?.roster??[],[n?.roster]),[w,j]=m.useState({}),[R,k]=m.useState({}),[T,q]=m.useState(!1),[$,O]=m.useState(!1),[L,F]=m.useState(!1),U=n?.health||null,Z=n?.globalObjective?.text||"",Q=n?.globalObjective?.updatedAt||null,[ce,ue]=m.useState(Z),le=n?.adminReason?.text||"",B=n?.adminReason?.updatedAt||null,[V,I]=m.useState(le),J=n?.audioLevels||{},[ie,M]=m.useState({hornGain:Number.isFinite(J.hornGain)?J.hornGain:1,ttsGain:Number.isFinite(J.ttsGain)?J.ttsGain:1,forwardGain:Number.isFinite(J.forwardGain)?J.forwardGain:1}),[D,K]=m.useState({}),ae=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",he=n?.role==="lockdown"||n?.role==="lockdown-admin",we=n?.mode??"open",pe=async(te,me)=>{try{await a(te,me),j(_e=>({..._e,[te]:me}))}catch(_e){alert(_e.message)}},ge=async te=>{const me=te.target.value;try{await r(me)}catch(_e){alert(_e.message)}},xe=async te=>{try{await o(te,{force:!0})}catch(me){alert(me.message)}},ye=async te=>{if(!(!te?.id||!window.confirm(`Reboot rover "${te.name||te.id}" now?`))){k(_e=>({..._e,[te.id]:!0}));try{await p(te.id)}catch(_e){alert(_e.message)}finally{k(_e=>({..._e,[te.id]:!1}))}}},Ce=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){q(!0);try{await h()}catch(me){alert(me.message),q(!1)}}},qe=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){O(!0);try{await v("clearHistory")}catch(me){alert(me.message)}finally{O(!1)}}},Ze=async()=>{if(window.confirm("Clear Overseer Control history now?")){F(!0);try{await b("clearHistory")}catch(me){alert(me.message)}finally{F(!1)}}},Se=async()=>{try{await u(ce)}catch(te){alert(te.message)}},at=async()=>{try{await u(null)}catch(te){alert(te.message)}},ht=async()=>{try{await f(V)}catch(te){alert(te.message)}},Ge=async()=>{try{await f(null)}catch(te){alert(te.message)}},je=te=>me=>{const _e=Number(me.target.value);M(en=>({...en||{},[te]:Number.isFinite(_e)?_e:1}))},se=async()=>{try{await g(ie)}catch(te){alert(te.message)}},re=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{ue(Z)},[Z]),m.useEffect(()=>{I(le)},[le]),m.useEffect(()=>{M({hornGain:Number.isFinite(J.hornGain)?J.hornGain:1,ttsGain:Number.isFinite(J.ttsGain)?J.ttsGain:1,forwardGain:Number.isFinite(J.forwardGain)?J.forwardGain:1})},[J.forwardGain,J.hornGain,J.ttsGain]),m.useEffect(()=>{const te={};(N||[]).forEach(me=>{me?.private?.enabled&&(te[me.id]={speedLimitEnabled:!!me?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(me?.private?.safety?.speedLimitMaxWheelSpeed)?me.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!me?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(me?.private?.safety?.overcurrentStopMs)?me.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!me?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(me?.private?.safety?.bumpBackoffSpeed)?me.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(me?.private?.safety?.bumpBackoffMs)?me.private.safety.bumpBackoffMs:350,cliffEnabled:!!me?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(me?.private?.safety?.cliffBackoffSpeed)?me.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(me?.private?.safety?.cliffBackoffMs)?me.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(me?.private?.safety?.triggerCooldownMs)?me.private.safety.triggerCooldownMs:800})}),K(te)},[N]);const de=m.useMemo(()=>{const te={};return N.forEach(me=>{te[me.id]=w[me.id]??me.locked}),te},[N,w]),fe=(te,me={})=>{K(_e=>({..._e||{},[te]:{..._e?.[te]||{},...me||{}}}))},Re=async te=>{try{const me=D?.[te];if(!me)return;await x(te,me)}catch(me){alert(me.message)}};return ae?l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[l.jsx("span",{children:"Admin controls"}),l.jsx("select",{value:we,onChange:ge,className:"field-input text-sm",children:Fw.map(te=>l.jsx("option",{value:te.key,children:te.label},te.key))})]}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:Ce,disabled:T,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:T?"Server rebooting...":"Reboot Server"}),l.jsx("button",{type:"button",onClick:re,className:"button-dark",children:"Test Reward Popup"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global audio levels"}),n?.audioLevels?.updatedAt?l.jsxs("span",{children:["Updated ",new Date(n.audioLevels.updatedAt).toLocaleString()]}):null]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Horn gain"}),l.jsxs("span",{children:[ie.hornGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ie.hornGain,onChange:je("hornGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"TTS gain"}),l.jsxs("span",{children:[ie.ttsGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ie.ttsGain,onChange:je("ttsGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Forward gain"}),l.jsxs("span",{children:[ie.forwardGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ie.forwardGain,onChange:je("forwardGain"),className:"w-full accent-emerald-500"})]}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:se,className:"button-dark",children:"Apply audio levels"})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global objective"}),Q?l.jsxs("span",{children:["Updated ",new Date(Q).toLocaleString()]}):null]}),l.jsx("input",{type:"text",value:ce,onChange:te=>ue(te.target.value),placeholder:"Set a global objective",className:"field-input text-sm"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:Se,className:"button-dark",children:"Set objective"}),l.jsx("button",{type:"button",onClick:at,className:"button-danger",children:"Clear"})]})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Admin mode reason"}),B?l.jsxs("span",{children:["Updated ",new Date(B).toLocaleString()]}):null]}),l.jsx("textarea",{value:V,onChange:te=>I(te.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:ht,className:"button-dark",children:"Set reason"}),l.jsx("button",{type:"button",onClick:Ge,className:"button-danger",children:"Clear"})]})]}),l.jsx(zw,{roster:N,renderActions:te=>l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:()=>pe(te.id,!de[te.id]),className:"button-dark",children:de[te.id]?"Unlock":"Lock"}),l.jsx("button",{type:"button",onClick:()=>xe(te.id),className:"button-dark",children:"Force"}),l.jsx("button",{type:"button",onClick:()=>ye(te),disabled:!!R[te.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:R[te.id]?"Rebooting...":"Reboot"}),te?.private?.enabled?l.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[l.jsx("div",{className:"text-slate-300",children:"Private safety"}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!D?.[te.id]?.speedLimitEnabled,disabled:!he,onChange:me=>fe(te.id,{speedLimitEnabled:!!me.target.checked})}),l.jsx("span",{children:"Speed limit"})]}),l.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!he,value:D?.[te.id]?.speedLimitMaxWheelSpeed??250,onChange:me=>fe(te.id,{speedLimitMaxWheelSpeed:Number(me.target.value)||250})}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!D?.[te.id]?.hardOvercurrentEnabled,disabled:!he,onChange:me=>fe(te.id,{hardOvercurrentEnabled:!!me.target.checked})}),l.jsx("span",{children:"Hard overcurrent"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!D?.[te.id]?.hardBumpEnabled,disabled:!he,onChange:me=>fe(te.id,{hardBumpEnabled:!!me.target.checked})}),l.jsx("span",{children:"Hard bump"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!D?.[te.id]?.cliffEnabled,disabled:!he,onChange:me=>fe(te.id,{cliffEnabled:!!me.target.checked})}),l.jsx("span",{children:"Cliff safety"})]}),l.jsx("button",{type:"button",disabled:!he,onClick:()=>Re(te.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),l.jsx(Gw,{health:U,roster:N}),l.jsx(Vw,{state:C,onClearHistory:qe,clearingHistory:$}),l.jsx($w,{state:E,onClearHistory:Ze,clearingHistory:L}),l.jsx(Yw,{entries:S})]}):null}const Xw=[{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 Qw(n){return n.reduce((a,r)=>((a[r.group]||(a[r.group]=[])).push(r),a),{})}function Kw(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):a}const pf=5,hr=500,pr=1,xf=100;function Zw(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(pf,Math.min(hr,r)):a}function lo(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(pr,Math.min(xf,r)):a}function Jw(n){const r=(lo(n,n)-pr)/(xf-pr),o=hr-r*(hr-pf);return Math.round(o)}function Pw(n){const a=Zw(n,n),r=(hr-a)/(hr-pf),o=pr+r*(xf-pr);return Math.round(o)}function Ww(n){const[a,r]=m.useState(null),o=m.useCallback(p=>{sd(!0),r(p)},[]),u=m.useCallback(()=>{sd(!1),r(null)},[]),f=m.useCallback((p,h)=>{if(h.preventDefault(),h.stopPropagation(),h.key==="Escape"){u();return}const g=Sr(h.key??"");g&&(n(p,g,h),u())},[u,n]);return m.useEffect(()=>()=>sd(!1),[]),{active:a,startCapture:o,cancel:u,captureFromEvent:f}}function Xi({label:n,description:a,value:r,onChange:o,min:u=0,max:f=500,step:p=5}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("input",{type:"number",min:u,max:f,value:r,onChange:h=>o(h.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),a&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:a}),l.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[l.jsx("input",{type:"range",min:u,max:f,step:p,value:r,onChange:h=>o(h.target.value),className:"h-2 flex-1 accent-emerald-400"}),l.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:r})]})]})}function eA(){const{state:{keymap:n},actions:{updateKeyBinding:a,resetKeyBindings:r}}=yt(),{value:o,save:u}=Oe("inputs",En),f={...En.keyboard,...o.keyboard??{}},p=m.useMemo(()=>typeof f.tiltSpeed=="number"?lo(f.tiltSpeed,En.keyboard.tiltSpeed):typeof f.tiltIntervalMs=="number"?lo(Pw(f.tiltIntervalMs),En.keyboard.tiltSpeed):En.keyboard.tiltSpeed,[f.tiltIntervalMs,f.tiltSpeed]),h=m.useMemo(()=>Qw(Xw),[]),{active:g,startCapture:x,cancel:v,captureFromEvent:b}=Ww((N,w)=>{a(N,w)}),S=m.useCallback(N=>n?.[N]?.[0]||ir[N]?.[0]||"",[n]),C=m.useCallback((N,w)=>{const j=En.keyboard,R=Kw(w,j[N]);u(k=>({...k??{},keyboard:{...k?.keyboard??j,[N]:R}}))},[u]),E=m.useCallback(N=>{const w=En.keyboard,j=lo(N,w.tiltSpeed),R=Jw(j);u(k=>({...k??{},keyboard:{...k?.keyboard??w,tiltSpeed:j,tiltIntervalMs:R}}))},[u]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),l.jsx("button",{type:"button",onClick:()=>r(),className:"button-dark text-xs",children:"Reset defaults"})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Xi,{label:"Base speed",description:"Normal driving speed",value:f.baseSpeed,onChange:N=>C("baseSpeed",N)}),l.jsx(Xi,{label:"Turbo speed",description:"Used when holding the boost modifier",value:f.turboSpeed,onChange:N=>C("turboSpeed",N)}),l.jsx(Xi,{label:"Precision speed",description:"Used when holding the precision modifier",value:f.precisionSpeed,onChange:N=>C("precisionSpeed",N)})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),l.jsx(Xi,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:p,onChange:E,min:1,max:100,step:1})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([N,w])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.75rem] text-slate-400",children:N}),l.jsx("div",{className:"space-y-0.5",children:w.map(j=>{const R=S(j.id),k=g===j.id;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:j.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Tt(R)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[k&&l.jsx("button",{type:"button",onClick:()=>v(),className:"button-danger text-[0.7rem]",children:"Cancel"}),l.jsx("button",{type:"button",onClick:()=>x(j.id),onKeyDown:k?T=>b(j.id,T):void 0,autoFocus:k,className:`${k?"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:k?"Press a key…":"Change"})]})]},j.id)})})]},N))})]})}const Pn=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),tA=[{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"}],vx=.45,nA=.6;function sr({label:n,description:a,min:r,max:o,step:u,value:f,onChange:p}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("span",{className:"font-mono text-slate-400",children:Pn.format(f)})]}),a&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:a}),l.jsx("input",{type:"range",min:r,max:o,step:u,value:f,onChange:h=>p(Number(h.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function sA(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const a=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${a?` (${a})`:""}`}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 a=n.direction<0?"<":">";return`Axis ${n.index} ${a} ${Pn.format(n.threshold??.6)}`}return"Unassigned"}function aA(n){return n.reduce((a,r)=>((a[r.section]||(a[r.section]=[])).push(r),a),{})}function lA(n,a){if(!n||n.length===0)return null;if(a){const r=n.find(o=>o.signature===a);if(r)return r}return n[0]}function rA(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(a=>({pressed:!!a?.pressed,value:typeof a?.value=="number"?a.value:a?.pressed?1:0}))}}function iA(n,a,r){const o=(n.axes??[]).map((f,p)=>({index:p,delta:Math.abs((f??0)-(a.axes?.[p]??0)),value:f}));if(o.sort((f,p)=>p.delta-f.delta),r.kind==="axisPair"){const f=o.filter(p=>p.delta>vx).slice(0,2);return f.length<2?null:{kind:"axisPair",x:f[0].index,y:f[1].index,...r.invertDefaults??{}}}const u=o.find(f=>f.delta>vx);return u?{kind:"axis",index:u.index,...r.invertDefaults??{}}:null}function oA(n,a,r){const o=n.buttons??[];for(let f=0;f<o.length;f+=1){const p=o[f],h=typeof p?.value=="number"?p.value:p?.pressed?1:0;if(p?.pressed||h>nA)return r.kind==="axis"?{kind:"buttonAxis",index:f}:{kind:"button",index:f}}const u=n.axes??[];for(let f=0;f<u.length;f+=1){const p=u[f]??0,h=Math.abs(p-(a.axes?.[f]??0));if(Math.abs(p)>.7&&h>.5)return r.kind==="axis"?{kind:"axis",index:f,...r.invertDefaults??{}}:{kind:"axisButton",index:f,direction:p>=0?1:-1,threshold:.6}}return null}function cA(n,a,r){if(!n)return null;if(r.kind==="axis"||r.kind==="axisPair"){const o=iA(n,a,r);if(o)return o}return oA(n,a,r)}function uA(){const n=kN(),{value:a,save:r}=Oe("gamepad",Es),[o,u]=m.useState(null),f=m.useRef(null),p=m.useMemo(()=>aA(tA),[]),h=m.useMemo(()=>lA(n.pads,a.activeSignature),[n.pads,a.activeSignature]),g=h?.signature??null,x=m.useMemo(()=>g?a?.profiles?.[g]??a?.defaults?.profile??Wn:a?.defaults?.profile??Wn,[g,a?.defaults?.profile,a?.profiles]);m.useEffect(()=>{!h||!g||a?.profiles?.[g]||r(w=>{const j=w??Es;if(j.profiles?.[g])return j;const R=j?.defaults?.profile??Wn,k=Rg(h,R);return{...j,profiles:{...j.profiles??{},[g]:k}}})},[h,g,a?.profiles,r]),m.useEffect(()=>{f.current=null},[o,g]),m.useEffect(()=>{if(!o||!h)return;if(!f.current){f.current=rA(h);return}const w=cA(h,f.current,o);w&&(r(j=>{const R=j??Es,k=R.profiles?.[g]??R?.defaults?.profile??Wn,T={...k,bindings:{...k.bindings??{},[o.id]:{...k.bindings?.[o.id]??{},kind:o.kind,sources:[w]}}};return{...R,profiles:{...R.profiles??{},[g]:T}}}),u(null))},[h,g,o,r]);const v=m.useCallback(w=>{r(j=>({...j??Es,activeSignature:w||null}))},[r]),b=m.useCallback(w=>{r(j=>{const R=j??Es,k=(g&&R.profiles?.[g])??R?.defaults?.profile??Wn,T={...k,calibration:{...k.calibration??{},...w}};return g?{...R,profiles:{...R.profiles??{},[g]:T}}:{...R,defaults:{...R.defaults??{},profile:T}}})},[g,r]),S=m.useCallback((w,j)=>{r(R=>{const k=R??Es,T=(g&&k.profiles?.[g])??k?.defaults?.profile??Wn,q=j(T.bindings?.[w]??{}),$={...T,bindings:{...T.bindings??{},[w]:q}};return g?{...k,profiles:{...k.profiles??{},[g]:$}}:{...k,defaults:{...k.defaults??{},profile:$}}})},[g,r]),C=m.useCallback(w=>{S(w.id,j=>({...j,sources:[]}))},[S]),E=m.useCallback((w,j)=>{S(w.id,R=>{const k=Array.isArray(R.sources)?[...R.sources]:[];if(!k[0])return R;const T={...k[0]};return j==="invertX"?T.invertX=!T.invertX:j==="invertY"?T.invertY=!T.invertY:T.invert=!T.invert,k[0]=T,{...R,sources:k}})},[S]),N=m.useMemo(()=>h?{outputs:Tg(h,x)}:null,[h,x]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:h?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&l.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),n.pads.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[l.jsx("select",{value:g??"",onChange:w=>v(w.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(w=>l.jsx("option",{value:w.signature,children:w.id||"Unknown controller"},w.signature))}),l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:h?.mapping??"unknown"})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(sr,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:x.calibration?.driveDeadzone??.18,onChange:w=>b({driveDeadzone:w})}),l.jsx(sr,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:x.calibration?.cameraDeadzone??.08,onChange:w=>b({cameraDeadzone:w})}),l.jsx(sr,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:x.calibration?.auxDeadzone??.05,onChange:w=>b({auxDeadzone:w})}),l.jsx(sr,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:x.calibration?.auxSideScale??.55,onChange:w=>b({auxSideScale:w})}),l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),l.jsxs("select",{value:x.calibration?.cameraMode??"absolute",onChange:w=>b({cameraMode:w.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[l.jsx("option",{value:"absolute",children:"Absolute"}),l.jsx("option",{value:"velocity",children:"Velocity"})]})]}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),l.jsx(sr,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:x.calibration?.cameraSensitivity??60,onChange:w=>b({cameraSensitivity:w})})]})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([w,j])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:w}),l.jsx("div",{className:"space-y-0.5",children:j.map(R=>{const T=x.bindings?.[R.id]?.sources?.[0]??null;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:R.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:sA(T)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[R.kind==="axisPair"&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:!T,onClick:()=>E(R,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),l.jsx("button",{type:"button",disabled:!T,onClick:()=>E(R,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),R.kind==="axis"&&l.jsx("button",{type:"button",disabled:!T,onClick:()=>E(R),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),l.jsx("button",{type:"button",onClick:()=>C(R),className:"button-dark text-[0.7rem]",children:"Clear"}),l.jsx("button",{type:"button",onClick:()=>u(R),className:`${o?.id===R.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===R.id?"Waiting…":"Capture"})]})]},R.id)})})]},w))}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),h?l.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[l.jsx("p",{className:"text-slate-400",children:"Raw axes"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.axes.map((w,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["A",j,": ",Pn.format(w)]},`axis-${j}`))}),l.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.buttons.map((w,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["B",j,": ",Pn.format(w.value)," ",w.pressed?"●":""]},`btn-${j}`))}),N?.outputs&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",Pn.format(N.outputs.driveVector.x),","," ",Pn.format(N.outputs.driveVector.y)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",Pn.format(N.outputs.cameraAxis)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",Pn.format(N.outputs.auxAxis.main)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",Pn.format(N.outputs.auxAxis.side)]})]})]})]}):l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const dA={drive:"Drive wheels",aux:"Aux motors"};function bx(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function fA({value:n,color:a="bg-emerald-500"}){const r=`${Math.round(Math.max(0,Math.min(1,n))*100)}%`;return l.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:l.jsx("div",{className:`h-full ${a}`,style:{width:r}})})}function mA(){const{state:{roverId:n},overcurrentLimiter:a}=yt(),r=m.useMemo(()=>Ws.map(o=>o.key),[]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Overcurrent limiter"}),l.jsx("span",{children:a?.adminImmune?"Admin immune":"Active"})]}),n?l.jsxs("div",{className:"space-y-0.5",children:[r.map(o=>{const u=a?.caps?.[o]?.cap??0,f=a?.overcurrent?.groups?.[o]??!1,p=a?.scales?.perGroup?.[o]??1;return l.jsxs("div",{className:"surface space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-slate-200",children:dA[o]||o}),l.jsx("span",{className:f?"text-red-300":"text-slate-400",children:f?"overcurrent":"ok"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Cap"}),l.jsx("span",{children:bx(u)})]}),l.jsx(fA,{value:u,color:"bg-amber-500"}),l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Scale"}),l.jsx("span",{children:bx(p)})]})]})]},o)}),l.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Down rate ${a?.config?.downRatePerSec}/s · Up rate ${a?.config?.upRatePerSec}/s`}),l.jsx("div",{children:`Release delay ${a?.config?.releaseDelaySec}s`}),l.jsx("div",{children:`Output rate ${a?.config?.outputRateMs}ms`})]})]}):l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Pg=m.createContext(null);function Wg(){const n=m.useContext(Pg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const yx={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"}},Sx={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"},ev="primary";function gf(...n){return n.filter(Boolean).join(" ")}function vf({children:n,defaultTab:a,currentTab:r,onTabChange:o,variant:u=ev}){const[f,p]=m.useState(a??null),[h,g]=m.useState([]),x=m.useCallback(C=>C?(g(E=>E.includes(C)?E:[...E,C]),()=>g(E=>E.includes(C)?E.filter(N=>N!==C):E)):()=>{},[]),v=r??f??h[0]??null;m.useEffect(()=>{a&&r===void 0&&p(a)},[a,r]);const b=m.useCallback(C=>{C&&(r===void 0&&p(C),o&&o(C))},[r,o]),S=m.useMemo(()=>({activeTab:v,setActiveTab:b,registerTab:x,variant:u}),[v,b,x,u]);return l.jsx(Pg.Provider,{value:S,children:n})}function bf({children:n,className:a=""}){return l.jsx("div",{className:gf("flex gap-0.5",a),children:n})}function Zt({id:n,children:a,className:r="",disabled:o=!1,highlight:u="none"}){const{activeTab:f,setActiveTab:p,registerTab:h,variant:g}=Wg();m.useEffect(()=>h(n),[n,h]);const x=yx[g]??yx[ev],v=f===n,b=Sx[u]||Sx.none,S=gf(x.base,b||(v?x.active:x.inactive),o?"cursor-not-allowed opacity-50":"",r);return l.jsx("button",{type:"button",className:S,onClick:()=>!o&&p(n),"aria-pressed":v,"aria-disabled":o,children:a})}function yf({children:n,className:a=""}){return l.jsx("div",{className:gf("mt-0 space-y-0.5",a),children:n})}function Jt({id:n,children:a,keepMounted:r=!1}){const{activeTab:o}=Wg(),u=o===n;return!u&&!r?null:!u&&r?l.jsx("div",{hidden:!0,"aria-hidden":"true",children:a}):l.jsx(l.Fragment,{children:a})}function hA(){const{session:n}=br(),a=m.useMemo(()=>JSON.stringify(n??{},null,2),[n]);return l.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),l.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:a})]})}const jx=300,Nx=240;function pA(n,a){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(a||(a=new WeakSet),typeof n=="object"){if(a.has(n))return"[Circular]";a.add(n)}try{return JSON.stringify(n,(r,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function xA(n){const r=n.map(o=>pA(o)).join(" ");return r.length>Nx?`${r.slice(0,Nx)}…`:r}function gA(){const n=Pt(),[a,r]=m.useState([]),o=m.useMemo(()=>a.reduce((u,f)=>(f.direction==="in"&&(u.in+=1),f.direction==="out"&&(u.out+=1),u),{in:0,out:0}),[a]);return m.useEffect(()=>{const u=(g,x,v)=>{r(b=>{const S=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:g,event:x,payload:xA(v),timestamp:new Date().toLocaleTimeString()}];return S.length>jx?S.slice(-jx):S})},f=(g,...x)=>u("in",g,x),p=(g,...x)=>u("out",g,x);n.onAny(f);let h=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(p),h=()=>n.offAnyOutgoing(p);else{const g=n.emit.bind(n);n.emit=(x,...v)=>(p(x,...v),g(x,...v)),h=()=>{n.emit=g}}return()=>{n.offAny(f),h&&h()}},[n]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Socket activity"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),l.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>r([]),children:"Clear"})]})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?l.jsx("p",{children:"No socket activity yet."}):a.slice().reverse().map(u=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-slate-400",children:u.timestamp})," ",l.jsxs("span",{className:u.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",u.direction.toUpperCase(),"]"]})," ",l.jsx("span",{className:"text-cyan-300",children:u.event})," ",l.jsx("span",{className:"text-slate-200",children:u.payload})]},u.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const vA=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function tv(){const{state:{roverId:n},actions:{sendOiCommand:a,setSensorStream:r}}=yt(),o=!!n,[u,f]=Gg(),p=Pt(),{value:h,save:g}=Oe("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:x,save:v}=Oe("audio",it),b=h?.connectionTransport||"websocket",S=!!h?.swapMobileControlColumns,C=typeof h?.driveMacroBackoffEnabled=="boolean"?h.driveMacroBackoffEnabled:!0,E=Number.isFinite(x?.masterVolume)?x.masterVolume:it.masterVolume,N=Number.isFinite(x?.alertVolume)?x.alertVolume:it.alertVolume,w=Number.isFinite(x?.roverVolume)?x.roverVolume:it.roverVolume,j=typeof x?.mainBrushDuckEnabled=="boolean"?x.mainBrushDuckEnabled:typeof x?.autoLevelEnabled=="boolean"?x.autoLevelEnabled:it.mainBrushDuckEnabled,R=Number.isFinite(x?.mainBrushDuckAmount)?Math.max(0,Math.min(1,x.mainBrushDuckAmount)):it.mainBrushDuckAmount,k=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),T=U=>{n&&r(U)},q=U=>{const Z=U.target.value;g(Q=>({...Q??{},connectionTransport:Z})),p?.io?.opts&&(p.io.opts.transports=Z==="polling"?["polling"]:["websocket","polling"],p.disconnect(),p.connect())},$=U=>Z=>{const Q=Number(Z.target.value),ce=Number.isFinite(Q)?Math.max(0,Math.min(1,Q)):0;v(ue=>({...ue??{},[U]:ce}))},O=U=>{const Z=!!U.target.checked;v(Q=>({...Q??{},mainBrushDuckEnabled:Z}))},L=U=>{const Z=!!U.target.checked;g(Q=>({...Q??{},swapMobileControlColumns:Z}))},F=U=>{const Z=!!U.target.checked;g(Q=>({...Q??{},driveMacroBackoffEnabled:Z}))};return l.jsxs(vf,{defaultTab:"keybindings",children:[l.jsxs(bf,{children:[l.jsx(Zt,{id:"keybindings",children:"Keybindings"}),l.jsx(Zt,{id:"controller",children:"Controller"}),l.jsx(Zt,{id:"page",children:"Page settings"}),l.jsx(Zt,{id:"admin",children:"Admin"})]}),l.jsxs(yf,{children:[l.jsx(Jt,{id:"keybindings",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(eA,{})})}),l.jsx(Jt,{id:"controller",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(uA,{})})}),l.jsx(Jt,{id:"page",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"HUD"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:u,onChange:U=>f(U.target.checked)}),l.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:S,onChange:L}),l.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Macros"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:C,onChange:F}),l.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Audio"}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Master volume"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(E*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:$("masterVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Alert/page sounds"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:$("alertVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Rover audio"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(w*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:w,onChange:$("roverVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Main brush ducking"}),l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:j,onChange:O})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Main brush duck amount"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(R*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:R,onChange:$("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!j})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Connection"}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Transport"}),l.jsxs("select",{value:b,onChange:q,className:"field-input text-sm",children:[l.jsx("option",{value:"websocket",children:"WebSocket"}),l.jsx("option",{value:"polling",children:"Polling"})]})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),l.jsx(Jt,{id:"admin",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:vA.map(U=>l.jsx("button",{type:"button",onClick:()=>a(U.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:U.label},U.key))})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),l.jsx("div",{className:"surface flex gap-0.5",children:k.map(U=>l.jsx("button",{type:"button",onClick:()=>T(U.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:U.label},U.key))}),!o&&l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),l.jsx(Jg,{}),l.jsx(mA,{}),l.jsx(Iw,{}),l.jsx(hA,{}),l.jsx(gA,{})]})})]})]})}const wx={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:['If the rover shows "Docking in Progress", it is already auto-seeking the dock.',"To dock manually, enter Docking Assist from the drive panel.",{segments:['Press "Enter Docking Assist", or press ',{action:"dockMacro"},"."]},"In assist mode, camera tilts down and driving speed is limited for precise alignment."]}],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:"Docking assist toggle"},{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:['If you see "Docking in Progress", the rover is currently auto-seeking the dock.',{segments:['For manual docking, press "Enter Docking Assist".']},"Assist mode tilts camera down and limits speed for precise alignment."]}]},"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:['If you see "Docking in Progress", the rover is currently auto-seeking the dock.',{segments:['For manual docking, press "Enter Docking Assist" (or "Dock" button).']},"Assist mode tilts camera down and limits speed for precise alignment."]}]}};function bA(n){return wx[n]||wx.desktop}function nv({actionId:n,keymap:a}){const r=a?.[n]?.[0]??"";return l.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:Tt(r)})}function Ax(n,a){return n.map((r,o)=>typeof r=="string"?l.jsx("span",{children:r},`text-${o}`):r?.action?l.jsx(nv,{actionId:r.action,keymap:a},`pill-${r.action}-${o}`):r?.text?l.jsx("span",{children:r.text},`span-${o}`):null)}function Eo(n,a,r){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return Ax(n.segments,a);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return Ax(n,a)}return String(n??"")}function yA({hero:n,keymap:a}){return n?l.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-white",children:n.title}),n.subtitle&&l.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&l.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(r=>l.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:r},r))})]}),n.bullets&&l.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((r,o)=>{const u=Array.isArray(r?.segments)?`hero-${o}`:`hero-${o}`;return l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Eo(r,a)},u)})})]}):null}function SA({block:n,keymap:a}){return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items.map((r,o)=>{const u=`item-${o}`;return l.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:Eo(r,a)},u)})})]})}function jA({block:n}){const a=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return l.jsxs("div",{className:`surface space-y-0.5 border ${a} px-0.5 py-0.5`,children:[l.jsx("p",{className:"text-xs font-semibold text-slate-100",children:n.title}),n.body&&l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((r,o)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Eo(r,{})},`callout-${o}`))})]})}function NA({group:n,keymap:a}){return l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:n.title}),l.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.items.map(r=>l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[l.jsx("span",{className:"text-slate-200",children:r.label}),l.jsx(nv,{actionId:r.action,keymap:a})]},r.action))})]})}function wA({block:n,keymap:a}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[l.jsx("span",{className:"font-semibold",children:n.title}),n.footnote&&l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(r=>l.jsx(NA,{group:r,keymap:a},r.id))})]}):null}function AA({block:n}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((a,r)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Eo(a,{})},`gamepad-${r}`))})]}):null}function Cx({block:n,keymap:a}){if(!n)return null;switch(n.type){case"list":return l.jsx(SA,{block:n,keymap:a});case"callout":return l.jsx(jA,{block:n});case"keyboard":return l.jsx(wA,{block:n,keymap:a});case"gamepad":return l.jsx(AA,{block:n});default:return null}}function sv({layout:n,keymap:a}){const r=m.useMemo(()=>bA(n),[n]),o=a||{},u=r.main||[],f=r.aside||[];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(yA,{hero:r.hero,keymap:o}),l.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[l.jsx("div",{className:"space-y-0.5",children:u.map((p,h)=>l.jsx(Cx,{block:p,keymap:o},p.title||h))}),l.jsx("div",{className:"space-y-0.5",children:f.map((p,h)=>l.jsx(Cx,{block:p,keymap:o},p.title||h))})]})]})}function av({layout:n,onOpenOverlay:a}){const{state:r}=yt();return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Help"}),l.jsx("button",{type:"button",onClick:a,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),l.jsx(sv,{layout:n,keymap:r?.keymap||{}})]})}const CA=["kal","rms","slt","ksp","bdl"],kA=Array.from({length:10},(n,a)=>a*10);function Mo({hideInput:n=!1,hideSpectatorNotice:a=!1,fillHeight:r=!1,allowSpectatorInput:o=!1}){const u=oe(D=>D.session?.role||null),f=oe(D=>D.session?.assignment?.roverId||null),p=oe(D=>D.session?.roster??[]),{messages:h,typing:g,sendMessage:x,registerInputRef:v,onInputFocus:b,onInputBlur:S,blurChat:C,setTypingActive:E}=rf(),{value:N,save:w}=Oe("tts",{engine:"flite",voice:"rms",pitch:50}),[j,R]=m.useState(""),[k,T]=m.useState(!1),[q,$]=m.useState(!1),[O,L]=m.useState(()=>N?.engine||"flite"),[F,U]=m.useState(()=>N?.voice||"rms"),[Z,Q]=m.useState(()=>Number.isFinite(N?.pitch)?N.pitch:50),ce=u!=="spectator"||o,ue=m.useRef(null),B=!!m.useMemo(()=>p.find(D=>String(D.id)===String(f))||null,[f,p])?.audio?.ttsEnabled,V=m.useMemo(()=>h.slice(-200),[h]),I=m.useMemo(()=>g||[],[g]);m.useEffect(()=>{ue.current&&(ue.current.scrollTop=ue.current.scrollHeight)},[V,I]),m.useEffect(()=>{const D=N?.engine||"flite",K=N?.voice||"rms",ae=Number.isFinite(N?.pitch)?N.pitch:50;O!==D&&L(D),F!==K&&U(K),Z!==ae&&Q(ae)},[O,Z,N?.engine,N?.pitch,N?.voice,F]),m.useEffect(()=>{$(!!B)},[B]);const J=m.useMemo(()=>!B||!q?null:O==="espeak"?{speak:!0,engine:O,pitch:Z}:{speak:!0,engine:O,voice:F},[O,Z,q,B,F]);async function ie(D){if(D.preventDefault(),!ce||n)return;const ae=j.replace(/\\n/g,`
|
||
`).trim();if(ae){T(!0);try{await x(ae,J),R(""),C(),E(!1)}catch(he){alert(he.message)}finally{T(!1)}}}const M=r?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${r?"flex h-full flex-col overflow-hidden":""}`,children:[l.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${M}`,ref:ue,children:[V.length===0&&I.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):V.map(D=>l.jsx(sf,{message:D},D.id)),I.map(D=>l.jsx(bg,{message:D},`typing-${D.typingId||D.id}`))]}),!n&&l.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:ie,children:[l.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:j,onChange:D=>{const K=D.target.value;R(K),E(!!K.trim())},onFocus:D=>{b(D),E(!!j.trim())},onBlur:D=>{S(D),E(!1)},onKeyDown:D=>{D.key==="Enter"&&!j.trim()&&(D.preventDefault(),C(),E(!1))},ref:D=>v(D,{target:"panel"}),placeholder:ce?"Type a message…":a?"":"Spectators cannot chat",disabled:!ce}),B&&l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:q,onChange:D=>$(D.target.checked),className:"accent-cyan-500"}),l.jsx("span",{children:"Speak"})]}),l.jsxs("select",{value:O,onChange:D=>{const K=D.target.value;L(K),w(ae=>({...ae||{},engine:K}))},className:"field-input text-xs",children:[l.jsx("option",{value:"flite",children:"flite"}),l.jsx("option",{value:"espeak",children:"espeak"})]}),O==="flite"?l.jsx("select",{value:F,onChange:D=>{const K=D.target.value;U(K),w(ae=>({...ae||{},voice:K}))},className:"field-input text-xs",children:CA.map(D=>l.jsx("option",{value:D,children:D},D))}):l.jsx("select",{value:Z,onChange:D=>{const K=Number(D.target.value);Q(K),w(ae=>({...ae||{},pitch:K}))},className:"field-input text-xs",children:kA.map(D=>l.jsxs("option",{value:D,children:["pitch ",D]},D))})]}),l.jsx("button",{type:"submit",disabled:!ce||k,className:"button-dark h-full disabled:opacity-50 self-stretch",children:k?"...":"Send"})]})]})}function jr({compact:n=!1}){const a=oe(b=>b.session?.role||null),{setNickname:r}=Ot(),{value:o,save:u}=Oe("profile",{nickname:""}),[f,p]=m.useState(o.nickname||""),[h,g]=m.useState(!1),x=a!=="spectator";m.useEffect(()=>{p(o.nickname||"")},[o.nickname]);async function v(b){if(b.preventDefault(),!x)return;const S=(f||"").trim().slice(0,32);if(S){g(!0);try{await r(S),u({nickname:S})}catch(C){alert(C.message)}finally{g(!1)}}}return l.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:v,children:[l.jsx("input",{className:"field-input flex-1 min-w-0",value:f,onChange:b=>p(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!x}),l.jsx("button",{type:"submit",disabled:!x||h,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:h?"Saving…":n?"Set":"Save"})]})}function EA({socials:n,discordInvite:a,kofiLink:r}){const o=Array.isArray(n)?n:null;if(o&&o.length)return o;const u=[];return a&&u.push({id:"discord",label:"Discord",url:a}),r&&u.push({id:"kofi",label:"Ko-fi",url:r}),u}function MA(n){if(!n||typeof n!="object")return null;const a=n.id||n.service||n.key||n.name||null,r=n.label||n.title||n.name||a||"Link",o=n.url||n.link||n.href||null;return o?{id:a,label:r,url:o}:null}function lv({className:n=""}){const a=oe(o=>({socials:o.session?.socials??[],discordInvite:o.session?.discord?.invite||null,kofiLink:o.session?.kofi?.link||null})),r=EA(a).map(MA).filter(Boolean).slice(0,4);return r.length?l.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:r.map(o=>l.jsx(wo,{...o},`${o.id||o.label}-${o.url}`))}):null}function RA({compact:n=!1}){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(jr,{compact:n})})})}function TA(){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx(lv,{className:"flex-1 min-h-0"})})}function gd(...n){return n.filter(Boolean).join(" ")}function qA(n){const a=n?.batteryState?.percentDisplay;return a==null?"--":`${a}%`}function DA(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function _A(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 OA(n,a){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===a?`${r} (you)`:r}function Ro({title:n="Rovers"}){const a=oe(j=>j.session?.role||null),r=oe(j=>j.session?.roster??[]),o=oe(j=>j.session?.turnQueues??{}),u=oe(j=>j.session?.users??[]),f=oe(j=>j.session?.socketId||null),{requestControl:p}=Ot(),[h,g]=m.useState({}),[x,v]=m.useState(()=>Date.now()),b=m.useMemo(()=>a&&a!=="spectator",[a]),S=m.useMemo(()=>a==="admin"||a==="lockdown"||a==="lockdown-admin",[a]),C=m.useMemo(()=>Object.values(o||{}).some(j=>j?.deadline||j?.idleDeadline),[o]);m.useEffect(()=>{if(!C)return;const j=setInterval(()=>{v(Date.now())},1e3);return()=>clearInterval(j)},[C]);const E=m.useMemo(()=>{const j=new Set(r.map(k=>String(k.id))),R=Object.keys(o||{}).filter(k=>!j.has(String(k))).map(k=>({id:k,name:k,locked:!1,batteryState:null}));return[...r,...R]},[r,o]);async function N(j){if(j){g(R=>({...R,[j]:!0}));try{await p(j)}catch(R){alert(R.message)}finally{g(R=>({...R,[j]:!1}))}}}const w=j=>u.find(R=>R.socketId===j)||{socketId:j,nickname:null,role:null};return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),E.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:E.map(j=>{const R=String(j.id),k=o?.[R]||null,T=k?.queue||[],q=k?.idleDeadline||k?.deadline||null,$=q&&q>x?Math.ceil((q-x)/1e3):q?0:null,O=k?.current||null,L=O?T.findIndex(J=>J===O):-1,F=T.length>1?L>=0?T[(L+1)%T.length]:T[0]:null,U=!!(f&&O&&O===f),Z=!!(f&&F&&F===f),Q=$!=null&&(U||Z),ce=!!j.locked,ue=ce&&!S,le=!!(j?.private?.enabled&&j?.private?.open),B=j.lockReason?`locked: ${j.lockReason}`:"locked",V=ce?B:h[R]?"...":"request",I=b&&!ue&&!h[R];return l.jsxs("li",{className:gd("surface flex flex-wrap items-start justify-between gap-0.5",I&&"cursor-pointer",ce?"bg-red-900/40":le?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{I&&N(j.id)},children:[l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-0.5",children:[l.jsxs("p",{className:"min-w-0 flex items-center gap-0.5 whitespace-nowrap text-slate-200",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(j.color,.16),children:j.name}),j.description?l.jsx("span",{className:"min-w-0 flex-1 truncate text-[0.7rem] text-slate-400",children:j.description}):null]}),Q?l.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:U?`${$}s left`:`Your turn in ${$}s`}):null]}),l.jsx("span",{className:gd("text-[0.75rem] font-semibold",DA(j)),children:qA(j)})]}),T.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):l.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:T.map((J,ie)=>{const M=w(J),D=J===O,K=!!(F&&J===F&&!D),ae=D?"bg-sky-600 text-white ring-2 ring-amber-300":K?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return l.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${ae}`,children:[l.jsx("span",{className:`${_A(M.role)} font-semibold`,children:OA(M,f)}),D&&l.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),K&&l.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${R}-${J}-${ie}`)})})]}),b?l.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),N(j.id)},disabled:h[R]||ue,className:gd("button-dark disabled:opacity-40",ce&&"bg-red-600/70 text-white hover:bg-red-600"),children:V}):null]},j.id)})})]})}function BA(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 LA(n,a){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===a?`${r} (you)`:r}function go({hideNicknameForm:n=!1,hideHeader:a=!1,className:r="",fillHeight:o=!1,compact:u=!1}){const f=oe(b=>b.session?.role||null),p=oe(b=>b.session?.users??[]),h=oe(b=>b.session?.socketId||null),g=f!=="spectator",x=m.useMemo(()=>[...p].sort((b,S)=>b.socketId===h?-1:S.socketId===h?1:(b.nickname||"").localeCompare(S.nickname||"")),[h,p]),v=o?"flex-1 min-h-0 overflow-y-auto":u?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${r}`,children:[!n&&l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(jr,{compact:u})})}),l.jsx(lv,{})]}),!g&&l.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),l.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!a&&l.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${u?"text-xs":""}`,children:[l.jsx("span",{children:"Users"}),l.jsx("span",{className:"text-xs text-slate-500",children:x.length})]}),l.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${v} ${u?"text-[0.8rem]":""}`,children:x.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):x.map(b=>l.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${BA(b.role)}`,children:LA(b,h)},b.socketId))})]})]})}const zA=/^cu_[a-f0-9]{32}$/,el="field-input w-full max-w-sm text-left focus:ring-emerald-500",Nr="mx-auto w-full max-w-xl flex justify-center",Ka="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function UA(n){const a=String(n||"").trim();return a?a.length<=10?`${a.slice(0,2)}***${a.slice(-2)}`:`${a.slice(0,6)}...${a.slice(-6)}`:""}const kx=8*1024*1024,Ps=16e3,HA={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function Ex(n){let a="";for(let o=0;o<n.length;o+=32768){const u=n.subarray(o,o+32768);a+=String.fromCharCode(...u)}return btoa(a)}function VA(n){return typeof btoa=="function"?btoa(n):""}function $A(n){if(!n)return{};const a=VA(`${n}:${n}`);return a?{Authorization:`Basic ${a}`}:{}}function GA(n,a=1500){return new Promise(r=>{if(!n||n.iceGatheringState==="complete"){r();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",u),r()},a);function u(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",u),r())}n.addEventListener("icegatheringstatechange",u)})}function Mx(n){if(!n)return!1;const a=n.connectionState,r=n.iceConnectionState;return a==="connected"||r==="connected"||r==="completed"}function YA(n,a=1e4){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(Mx(n)){r();return}const u=setTimeout(()=>{p(),o(new Error("Peer connection timeout"))},a),f=()=>{Mx(n)?(p(),r()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(p(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function p(){clearTimeout(u),n.removeEventListener("connectionstatechange",f),n.removeEventListener("iceconnectionstatechange",f)}n.addEventListener("connectionstatechange",f),n.addEventListener("iceconnectionstatechange",f)})}async function FA(n){if(!n?.getParameters||!n?.setParameters)return;const a=n.getParameters()||{},r=a.encodings&&a.encodings[0]||{};a.encodings=[{...r,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(a)}catch{}}function IA(n,a=6e3){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}const u=Date.now();let f=-1;const p=setInterval(async()=>{if(Date.now()-u>a){clearInterval(p),o(new Error("WHIP connected but no outbound audio flow"));return}try{const h=n.getSenders().filter(g=>g.track?.kind==="audio");for(const g of h){const x=await g.getStats();for(const v of x.values()){if(v.type!=="outbound-rtp"||v.kind!=="audio")continue;const b=Number(v.bytesSent||0),S=Number(v.packetsSent||0);if(f<0)f=b;else if(b>f+200||S>5){clearInterval(p),r();return}}}}catch{}},250)})}function XA(n){const a=n.reduce((u,f)=>u+f.length,0),r=new Float32Array(a);let o=0;for(const u of n)r.set(u,o),o+=u.length;return r}function QA(n){const a=new Int16Array(n.length);for(let r=0;r<n.length;r+=1){const o=Math.max(-1,Math.min(1,n[r]));a[r]=o<0?o*32768:o*32767}return a}function KA(n,a){const r=QA(n),o=r.length*2,u=new ArrayBuffer(44+o),f=new DataView(u),p=(g,x)=>{for(let v=0;v<x.length;v+=1)f.setUint8(g+v,x.charCodeAt(v))};p(0,"RIFF"),f.setUint32(4,36+o,!0),p(8,"WAVE"),p(12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,1,!0),f.setUint16(22,1,!0),f.setUint32(24,a,!0),f.setUint32(28,a*2,!0),f.setUint16(32,2,!0),f.setUint16(34,16,!0),p(36,"data"),f.setUint32(40,o,!0);let h=44;for(let g=0;g<r.length;g+=1,h+=2)f.setInt16(h,r[g],!0);return new Uint8Array(u)}function pn({label:n,active:a,detail:r=""}){return l.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${a?"bg-emerald-500":"bg-slate-700"}`,children:[l.jsx("div",{className:"text-center font-medium",children:n}),l.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:r||(a?"active":"idle")})]})}function Ud({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function ZA({ownRoverId:n="",audioForwardByRover:a={},playUploadedAudio:r,stopUploadedAudio:o,startMicWhip:u,readyMicWhip:f,stopMicWhip:p}){const{state:h}=yt(),{value:g,save:x}=Oe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),v=String(n||"").trim(),[b,S]=m.useState(null),[C,E]=m.useState(!1),N=!!g?.openMicEnabled,j=(g?.pttMode==="clip"?"clip":"live")==="clip",[R,k]=m.useState("idle"),[T,q]=m.useState("idle"),[$,O]=m.useState(""),L=m.useRef(null),F=m.useRef(null),U=m.useRef(null),Z=m.useRef(!1),Q=m.useRef(""),ce=m.useRef(null),ue=m.useRef(null),le=m.useRef(null),B=m.useRef(null),V=m.useRef(null),I=m.useRef([]),J=m.useRef(!1),ie=m.useRef(Ps),M=!!h?.mic?.pttActive,D=m.useMemo(()=>v&&a?.[v]||null,[a,v]),K=!!(D&&D.state!=="offline"&&!D.error),ae=D?.source==="upload"&&D?.state==="playing",he=D?.source==="mic-whip"&&(D?.state==="starting"||D?.state==="playing"),we=!!(!j&&F.current&&(N||M)),pe=!j&&(R==="live"||R==="starting"),ge=j&&T==="recording",xe=j&&T==="sending",ye=Tt(h?.keymap?.micPtt?.[0])||"M",Ce=m.useCallback(re=>{const de=re==="clip"?"clip":"live";x(fe=>({...fe||{},pttMode:de}))},[x]),qe=async()=>{if(!v){O("Take control of your rover first.");return}if(!b){O("Select an audio file first.");return}if(b.size>kx){O(`File too large (max ${kx} bytes).`);return}E(!0),O("");try{const re=await b.arrayBuffer(),de=Ex(new Uint8Array(re));await r?.({roverId:v,name:b.name,mime:b.type||"",dataBase64:de}),O("Upload playback started.")}catch(re){O(re?.message||"Failed to play upload.")}finally{E(!1)}},Ze=async()=>{if(!v){O("Take control of your rover first.");return}E(!0),O("");try{await o?.(v),O("Upload playback stopped.")}catch(re){O(re?.message||"Failed to stop upload.")}finally{E(!1)}},Se=m.useCallback(async re=>{const de=String(re||Q.current||"").trim();if(Z.current=!1,k("idle"),U.current){try{U.current.getSenders().forEach(fe=>fe.track?.stop())}catch{}try{U.current.close()}catch{}}if(U.current=null,L.current)try{L.current.getTracks().forEach(fe=>fe.stop())}catch{}if(L.current=null,F.current=null,de)try{await p?.(de)}catch{}Q.current=""},[p]),at=m.useCallback(async re=>{const de=await u?.(re),fe=String(de?.whipUrl||"").trim(),Re=String(de?.token||"").trim();if(!fe||!Re)throw new Error("WHIP endpoint unavailable");const te=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:Ps,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});L.current=te;const me=te.getAudioTracks()?.[0];if(F.current=me||null,me&&(me.enabled=!!(N||M)),me?.applyConstraints)try{await me.applyConstraints({channelCount:1,sampleRate:Ps,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const _e=new RTCPeerConnection(HA);U.current=_e,_e.onconnectionstatechange=()=>{if(!Z.current)return;const Nt=_e.connectionState;if(Nt==="connected"){k("live");return}(Nt==="failed"||Nt==="disconnected"||Nt==="closed")&&(k("error"),O(`WHIP transport ${Nt}.`))},te.getAudioTracks().forEach(Nt=>{const Ae=_e.addTrack(Nt,te);FA(Ae)});const en=await _e.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await _e.setLocalDescription(en),await GA(_e,1800);const tn=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp",...$A(Re)},body:_e.localDescription?.sdp||en.sdp});if(!tn.ok)throw new Error(`WHIP request failed: ${tn.status}`);const nn=await tn.text();await _e.setRemoteDescription({type:"answer",sdp:nn}),await YA(_e,1e4),await IA(_e,6e3),await f?.(re)},[N,M,f,u]),ht=m.useCallback(async()=>{if(J.current=!1,B.current){try{B.current.disconnect()}catch{}B.current.onaudioprocess=null}if(le.current)try{le.current.disconnect()}catch{}if(V.current)try{V.current.disconnect()}catch{}if(ce.current)try{ce.current.getTracks().forEach(re=>re.stop())}catch{}if(ue.current)try{await ue.current.close()}catch{}I.current=[],B.current=null,le.current=null,V.current=null,ce.current=null,ue.current=null,ie.current=Ps},[]),Ge=m.useCallback(async()=>{if(ce.current&&ue.current&&B.current)return;q(me=>me==="recording"?me:"arming");const re=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:Ps,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),de=new AudioContext({latencyHint:"interactive"}),fe=de.createMediaStreamSource(re),Re=de.createScriptProcessor(1024,1,1),te=de.createGain();te.gain.value=0,Re.onaudioprocess=me=>{if(!J.current)return;const _e=me.inputBuffer.getChannelData(0);I.current.push(new Float32Array(_e))},fe.connect(Re),Re.connect(te),te.connect(de.destination),ce.current=re,ue.current=de,le.current=fe,B.current=Re,V.current=te,ie.current=de.sampleRate||Ps},[]),je=m.useCallback(async({send:re})=>{const de=J.current;if(J.current=!1,!de){re||q("idle");return}const fe=I.current;if(I.current=[],!re){q("idle");return}if(!v){q("idle");return}if(!fe.length){q("idle");return}q("sending");try{const Re=XA(fe),te=KA(Re,ie.current||Ps),me=Ex(te);await r?.({roverId:v,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:me}),q("idle")}catch(Re){q("error"),O(Re?.message||"Failed to send PTT clip.")}},[r,v]),se=m.useCallback(async()=>{if(!v){O("Take control of your rover first.");return}await Ge(),I.current=[],J.current=!0,q("recording")},[Ge,v]);return m.useEffect(()=>{let re=!1;async function de(){if(j){await Se(Q.current||v);return}if(!v){await Se(Q.current);return}if(!(Z.current&&Q.current===v)&&!(!N&&!M))try{k("starting"),O(""),Z.current=!0,Q.current=v,await at(v),re||k("live")}catch(fe){re||(k("error"),O(fe?.message||"Failed to start mic forwarding.")),await Se(v)}}return de(),()=>{re=!0}},[j,N,M,v,at,Se]),m.useEffect(()=>{const re=F.current;re&&(re.enabled=!!(!j&&(N||M)))},[j,N,M]),m.useEffect(()=>{let re=!1;async function de(){if(!j||!v){J.current&&await je({send:!1}),q("idle");return}try{await Ge(),!re&&!J.current&&q("idle")}catch(fe){re||(q("error"),O(fe?.message||"Microphone access failed for clip mode."))}}return de(),()=>{re=!0}},[j,Ge,je,v]),m.useEffect(()=>{let re=!1;async function de(){if(j){if(!v){J.current&&await je({send:!1});return}if(M){if(!J.current)try{O(""),await se()}catch(fe){re||(q("error"),O(fe?.message||"Failed to start clip recording."))}}else J.current&&await je({send:!0})}}return de(),()=>{re=!0}},[j,je,M,v,se]),m.useEffect(()=>()=>{Se(Q.current||v),ht()},[v,Se,ht]),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"grid gap-1",children:[l.jsx("p",{className:"text-sm text-slate-100 text-center",children:"Audio Controls"}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[l.jsx("span",{children:"Push-to-Talk Key"}),l.jsx(Ud,{label:ye})]})}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),l.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."}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${j?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Ce("live"),children:"Live Mic (WHIP)"}),l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${j?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Ce("clip"),children:"Record Clip"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(pn,{label:"Mode",active:j,detail:j?"record clip":"live mic"}),l.jsx(pn,{label:"PTT hold",active:M,detail:M?"held":"released"}),l.jsx(pn,{label:"Recording",active:ge,detail:ge?"capturing":"idle"}),l.jsx(pn,{label:"Playback",active:j&&ae,detail:j&&ae?"playing":"idle"})]})]})})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),l.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),l.jsx("input",{className:`${el} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:C||!v,onChange:re=>S(re.target.files?.[0]||null)})]}),l.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:b?l.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[b.name," (",b.size," bytes)"]}):l.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:C||!v,onClick:qe,children:C?"Working...":"Play Upload"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:C||!v,onClick:Ze,children:"Stop"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),l.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:[l.jsx("input",{type:"checkbox",checked:N,disabled:!v||j,onChange:re=>x(de=>({...de||{},openMicEnabled:!!re.target.checked}))}),l.jsx("span",{children:j?"Open mic (live mode only)":"Open mic"})]}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(pn,{label:"WHIP link",active:pe,detail:R}),l.jsx(pn,{label:"Mic hot",active:we,detail:we?"transmitting":"muted"}),l.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",l.jsx(Ud,{label:ye})," to talk"]})]})]})})]}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[l.jsx(pn,{label:"Forward pipe",active:K,detail:K?"connected":"offline"}),l.jsx(pn,{label:"Upload playback",active:ae,detail:ae?"playing":"idle"}),l.jsx(pn,{label:"Mic relay",active:he,detail:he?"active":"idle"}),l.jsx(pn,{label:"WHIP transport",active:pe,detail:R}),l.jsx(pn,{label:"Clip recording",active:ge,detail:ge?"recording":"idle"}),l.jsx(pn,{label:"Clip sending",active:xe,detail:xe?"sending":"idle"})]}),$?l.jsx("div",{className:"text-xs text-slate-400 text-center",children:$}):null]})})]})})}function JA({pendingRequestId:n,currentStoredKey:a,nickname:r,requestVerification:o,applyIdentityKey:u,onMessage:f,fullWidth:p=!1}){const[h,g]=m.useState(0),[x,v]=m.useState(""),[b,S]=m.useState(!1),[C,E]=m.useState(!1),N=()=>{g(1),v(a),S(!1),f?.("")},w=()=>{g(0),S(!1)},j=async k=>{if(k.preventDefault(),!b){f?.("Please confirm your nickname agreement before sending.");return}if(h<3){f?.("Complete all request steps before sending.");return}E(!0),f?.("");try{const T=await u(x);await o?.(),v(T),g(0),S(!1),f?.("Verification request sent to lockdown admins.")}catch(T){f?.(T.message||"Failed to submit request.")}finally{E(!1)}},R=p?"w-full":Nr;return n?l.jsx("section",{className:`surface text-sm text-slate-300 ${R}`,children:l.jsxs("div",{className:Ka,children:["Verification request pending: ",n]})}):h===0?l.jsx("section",{className:`surface ${R}`,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:N,disabled:C,children:"Request Verification"})]})}):l.jsx("form",{className:`surface ${R}`,onSubmit:j,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",h," of 3"]}),h===1?l.jsxs("div",{className:"space-y-0.5",children:[l.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."}),l.jsx("div",{className:"mx-auto w-full max-w-sm",children:l.jsx(jr,{compact:!0})}),l.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",l.jsx("span",{className:"font-semibold",children:r||"(not set)"})]}),l.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:k=>S(k.target.checked)}),l.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!r||!b,onClick:()=>g(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,h===2?l.jsxs("div",{className:"space-y-0.5",children:[l.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."}),l.jsx("input",{className:el,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:x,onChange:k=>v(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>navigator.clipboard?.writeText(x),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>g(3),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>g(1),children:"Back"})]})]}):null,h===3?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),l.jsx("input",{className:el,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:x,onChange:k=>v(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:C||!x,children:"Confirm Request"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>g(2),children:"Back"})]})]}):null]})})}function PA({currentStoredKey:n,applyIdentityKey:a,onMessage:r,fullWidth:o=!1}){const[u,f]=m.useState(0),[p,h]=m.useState(""),[g,x]=m.useState(!1),v=()=>{f(1),h(""),r?.("")},b=()=>{f(0),h("")},S=async E=>{if(E.preventDefault(),!(u<2)){x(!0),r?.("");try{await a(p),f(0),h(""),r?.("Identity key restored.")}catch(N){r?.(N.message||"Failed to restore key.")}finally{x(!1)}}},C=o?"w-full":Nr;return l.jsx("section",{className:`surface ${C}`,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",UA(n)||"not set yet"]}),l.jsx("input",{className:el,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),u===0?l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:v,disabled:g,children:"Restore Key"})]}):null,u===1?l.jsxs("div",{className:"space-y-0.5",children:[l.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."}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,u===2?l.jsxs("form",{className:"space-y-0.5",onSubmit:S,children:[l.jsx("input",{className:el,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:p,onChange:E=>h(E.target.value.toLowerCase()),placeholder:"Paste key to restore"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:g||!p,children:"Confirm Restore"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function WA({requestableRovers:n=[],pendingRequests:a=[],requestPrivateRoverAccess:r,onMessage:o,fullWidth:u=!1}){const[f,p]=m.useState({}),h=m.useMemo(()=>{const v=new Map;return(a||[]).forEach(b=>{b?.roverId&&v.set(String(b.roverId),b)}),v},[a]),g=u?"w-full":Nr,x=async v=>{if(v){p(b=>({...b,[v]:!0})),o?.("");try{(await r?.(v))?.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{p(b=>({...b,[v]:!1}))}}};return l.jsx("section",{className:`surface text-sm text-slate-300 ${g}`,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?l.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):l.jsx("div",{className:"w-full space-y-0.5",children:n.map(v=>{const b=String(v.id),S=!!f[b],C=h.get(b);return l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[l.jsxs("div",{className:"min-w-0 text-left",children:[l.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:v.name||b}),l.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:b})]}),C?l.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):l.jsx("button",{type:"button",onClick:()=>x(b),disabled:S,className:"button-dark text-xs disabled:opacity-50",children:S?"Sending...":"Request"})]},b)})})]})})}function ro(n){return String(n||"").trim()}function e2(n){const a=ro(n);return a?a.includes("DOCKINGRUNNING")?"Returning":a.includes("PAUSED")?"Paused":a.includes("HOUSECLEANINGRUNNING")?"Cleaning":a.includes("SPOTCLEANINGRUNNING")?"Spot cleaning":a.includes("STATE_START")?"Starting":a.includes("STATE_IDLE")||a.includes("STATE_STANDBY")?"Idle":a:"--"}function rv(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function Qi({label:n,value:a,tone:r="muted",valueClass:o="",hideLabel:u=!1}){return l.jsxs("div",{className:`rounded-md px-1 py-0.75 text-center ${rv(r)}`,children:[u?null:l.jsx("div",{className:"text-[0.72rem] opacity-90",children:n}),l.jsx("div",{className:`text-sm font-semibold ${o}`,title:String(a||""),children:a})]})}function t2({neato:n,onStart:a,onSendHome:r,onLocate:o,onClearErrors:u,onPowerCycle:f,fullWidth:p=!1}){const[h,g]=m.useState(""),x=p?"w-full":"w-full max-w-xl",v=!!n?.configured,b=!!(n?.enabled&&n?.connected),S=!!n?.telemetry?.extPowerPresent,C=!!n?.telemetry?.chargingActive,E=e2(n?.telemetry?.uiState),N=ro(n?.telemetry?.robotState)||"--",w=n?.telemetry?.batteryPercent,j=Number.isFinite(w)?`${w}%`:"--",R=n?.telemetry?.batteryVoltage,k=Number.isFinite(R)?`${R.toFixed(2)} V`:"--",T=ro(n?.telemetry?.robotError)||"--",q=ro(n?.telemetry?.robotAlert)||"--",$=n?.controls||{},O=!!$?.start?.available,L=!!$?.sendHome?.available,F=!!$?.locate?.available,U=!!$?.clearErrors?.available,Z=!!$?.powerCycle?.available,Q=v&&b&&O,ce=v&&b&&L,ue=v&&b&&F,le=v&&b&&U,B=v&&b&&Z,V=async(D,K)=>{if(K){g(D);try{await K()}catch{}finally{g("")}}},I=v?b?"Online":"Offline":"Not configured",J=v?b?"good":"danger":"warn",ie=w==null?"muted":w>=60?"good":w>=25?"warn":"danger",M=S?"Docked":E!=="--"?E:"Away from dock";return l.jsx("section",{className:`surface text-sm text-slate-200 ${x}`,children:l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Neato Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Control the autonomous Neato robovac. Be nice to him."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${rv(J)}`,children:I})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-0.5",children:[l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Controls"}),l.jsx("button",{type:"button",disabled:!Q||!!h,onClick:()=>V("start",a),className:"rounded-md border border-sky-300 bg-emerald-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-emerald-500 disabled:opacity-50",children:h==="start"?"Starting...":"Start cleaning"}),l.jsx("button",{type:"button",disabled:!ce||!!h,onClick:()=>V("sendHome",r),className:"rounded-md border border-sky-300 bg-sky-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-sky-500 disabled:opacity-50",children:h==="sendHome"?"Sending...":"Send to dock"}),l.jsxs("div",{className:"grid grid-cols-3 gap-0.5",children:[l.jsx("button",{type:"button",disabled:!ue||!!h,onClick:()=>V("locate",o),className:"w-full rounded-md border border-sky-300 bg-fuchsia-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-sky-500 hover:bg-fuchsia-500 disabled:opacity-50",children:h==="locate"?"Playing...":"Play sound"}),l.jsx("button",{type:"button",disabled:!le||!!h,onClick:()=>V("clearErrors",u),className:"w-full rounded-md border border-sky-300 bg-amber-500 px-1 py-0.5 text-xs font-semibold text-slate-900 transition hover:border-sky-500 hover:bg-amber-400 disabled:opacity-50",children:h==="clearErrors"?"Clearing...":"Clear errors"}),l.jsx("button",{type:"button",disabled:!B||!!h,onClick:()=>V("powerCycle",f),className:"w-full rounded-md border border-rose-300 bg-rose-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-rose-500 hover:bg-rose-500 disabled:opacity-50",children:h==="powerCycle"?"Cycling...":"Power cycle"})]}),l.jsxs("div",{className:"surface-muted grid gap-0.5 pt-0.25",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Power status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx(Qi,{label:"Battery",value:j,tone:ie}),l.jsx(Qi,{label:"Voltage",value:k,tone:"muted"}),l.jsx(Qi,{label:"Docked",value:S?"Docked":"Not docked",tone:S?"good":"muted",hideLabel:!0}),l.jsx(Qi,{label:"Charging",value:C?"charging":"not charging",tone:C?"good":"muted",hideLabel:!0})]})]})]}),l.jsx("div",{className:"grid gap-0.5",children:l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Robot Status"}),l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot state (raw)"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:N})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Basic state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:M})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"UI state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:E})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot error"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:T})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot alert"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:q})]})]})]})})]}),!v||!b||!O||!L||!F||!U||!Z?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:v?b?"Waiting for required Neato entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.neato.device in server config to enable Neato controls."}):null]})})}function n2(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function s2(n){return n==="up"?"Up":n==="down"?"Down":n==="stopped"?"Transitioning...":n==="conflict"?"Conflict":"--"}function a2({lift:n,onUp:a,onDown:r,fullWidth:o=!1}){const[u,f]=m.useState(""),[p,h]=m.useState(()=>Date.now()),g=o?"w-full":"w-full max-w-xl",x=!!n?.configured,v=!!(n?.enabled&&n?.connected),b=!!n?.busy,S=String(n?.target||"").toLowerCase(),C=String(n?.position||"").toLowerCase(),E=!!n?.availability?.upSwitch,N=!!n?.availability?.downSwitch,w=Number(n?.lastActionAt||0),j=Math.max(0,Number(n?.commandCooldownMs||0)),R=Math.max(0,w+j-p),k=!b&&R>0,T=b||k;m.useEffect(()=>{if(!T)return;const U=setInterval(()=>{h(Date.now())},100);return()=>clearInterval(U)},[T]),m.useEffect(()=>{h(Date.now())},[w,j,b]);const q=x?v?T?"Busy":"Ready":"Offline":"Not configured",$=x?v?T?"warn":"good":"danger":"warn",O=x&&v&&!T&&!u&&E&&N,L=m.useMemo(()=>Math.ceil(R/1e3),[R]),F=async(U,Z)=>{if(Z){f(U);try{await Z()}catch{}finally{f("")}}};return l.jsxs("section",{className:`surface relative text-sm text-slate-200 ${g}`,children:[T?l.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center rounded-md bg-slate-950/80 px-1.5 text-center",children:l.jsxs("div",{className:"space-y-0.25",children:[l.jsx("p",{className:"text-sm font-semibold text-slate-100",children:b?"Preparing to move":"Moving!"}),l.jsx("p",{className:"text-xs text-slate-300",children:"Controls are disabled while the lift is moving, otherwise its tiny brain would get confused."}),!b&&k?l.jsxs("p",{className:"text-xs text-slate-400",children:["About ",L,"s remaining."]}):null]})}):null,l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Lift Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Move the lift up and down. Please don't break anything..."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${n2($)}`,children:q})]}),l.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.75 text-center",children:[l.jsx("div",{className:"text-xs text-slate-300",children:"Position"}),l.jsx("div",{className:"text-base font-semibold text-slate-100",children:s2(C)})]}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>F("down",r),className:`button-dark w-full text-sm disabled:opacity-50 ${C==="down"||S==="down"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="down"||S==="down"?"Lowering...":"Down"}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>F("up",a),className:`button-dark w-full text-sm disabled:opacity-50 ${C==="up"||S==="up"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="up"||S==="up"?"Raising...":"Up"})]})}),!x||!v||!E||!N?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:x?v?"Waiting for required lift switch entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.lift.upSwitch and homeAssistant.lift.downSwitch in server config."}):null,n?.lastError?l.jsxs("p",{className:"text-xs text-rose-300 text-center",children:["Last error: ",n.lastError]}):null]})]})}function l2(n){const a=String(n||"").trim();if(!a)return"";try{const r=new URL(a),o=String(r.protocol||"").toLowerCase();return o!=="http:"&&o!=="https:"?"":r.toString()}catch{return""}}function r2({isVerified:n=!1,fullWidth:a=!1,onMessage:r}){const{value:o,save:u}=Oe("profile",{nickname:"",profileImageUrl:""}),f=String(o?.profileImageUrl||"").trim(),[p,h]=m.useState(f),[g,x]=m.useState(!1);m.useEffect(()=>{h(f)},[f]);const v=m.useMemo(()=>l2(p),[p]),b=String(p||"").trim()!==f,S=!!(n&&b&&(v||!String(p||"").trim())),C=a?"w-full":Nr,E=async N=>{if(N.preventDefault(),!n){r?.("Verify your account before setting a profile image URL.");return}x(!0),r?.("");try{const w=v||"";u(j=>({...j||{},profileImageUrl:w})),r?.(w?"Profile image URL saved.":"Profile image URL cleared.")}finally{x(!1)}};return l.jsx("section",{className:`surface text-sm text-slate-300 ${C}`,children:l.jsxs("form",{className:Ka,onSubmit:E,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Chat profile image URL"}),l.jsx("p",{className:"text-xs text-slate-500",children:"Verified users can set a custom avatar for chat and Discord bridge messages."}),l.jsx("input",{className:el,type:"url",name:"vip_profile_image_url",placeholder:"https://example.com/avatar.png",value:p,onChange:N=>h(N.target.value),disabled:!n||g}),!v&&String(p||"").trim()?l.jsx("p",{className:"text-xs text-amber-300",children:"Enter a valid http/https image URL."}):null,l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm disabled:opacity-50",disabled:!S||g,children:g?"Saving...":"Save URL"}),l.jsx("button",{type:"button",className:"button-dark text-sm disabled:opacity-50",disabled:!n||g||!f,onClick:()=>h(""),children:"Clear"})]})]})})}function iv({isActive:n=!0}){const a=oe(ue=>ue.session),{identifySession:r,requestVerification:o,requestPrivateRoverAccess:u,playUploadedAudio:f,stopUploadedAudio:p,startMicWhip:h,readyMicWhip:g,stopMicWhip:x,neatoStart:v,neatoSendHome:b,neatoLocate:S,neatoClearErrors:C,neatoPowerCycle:E,liftUp:N,liftDown:w}=Ot(),{value:j,save:R}=Oe("identity",{cookieUserId:""}),{value:k}=Oe("profile",{nickname:""}),T=m.useMemo(()=>(j?.cookieUserId||"").trim(),[j?.cookieUserId]),q=(k?.nickname||"").trim(),$=!!a?.isVerified,O=a?.verification?.pendingRequestId||null,L=a?.privateRoverAccess?.requestableRovers||[],F=a?.privateRoverAccess?.pendingRequests||[],U=String(a?.assignment?.roverId||"").trim(),[Z,Q]=m.useState(""),ce=async ue=>{const le=String(ue||"").trim().toLowerCase();if(!le)throw new Error("Identity key required.");if(!zA.test(le))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return R(B=>({...B||{},cookieUserId:le})),await r({cookieUserId:le,nickname:q}),le};return l.jsxs("section",{className:"space-y-2 text-base",children:[l.jsxs("div",{className:"grid gap-2 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[$?null:l.jsx("div",{className:"lg:col-span-2",children:l.jsx(JA,{pendingRequestId:O,currentStoredKey:T,nickname:q,requestVerification:o,applyIdentityKey:ce,onMessage:Q,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:$?l.jsxs("div",{className:"space-y-2",children:[l.jsx(t2,{neato:a?.neato||null,onStart:v,onSendHome:b,onLocate:S,onClearErrors:C,onPowerCycle:E,fullWidth:!0}),l.jsx(a2,{lift:a?.lift||null,onUp:N,onDown:w,fullWidth:!0}),l.jsx(ZA,{ownRoverId:U,audioForwardByRover:a?.audioForward||{},playUploadedAudio:f,stopUploadedAudio:p,startMicWhip:h,readyMicWhip:g,stopMicWhip:x})]}):l.jsx("section",{className:"surface h-full",children:l.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."})})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(WA,{requestableRovers:L,pendingRequests:F,requestPrivateRoverAccess:u,onMessage:Q,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(PA,{currentStoredKey:T,applyIdentityKey:ce,onMessage:Q,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(r2,{isVerified:$,onMessage:Q,fullWidth:!0})})]}),Z?l.jsx("div",{className:Nr,children:l.jsx("p",{className:"text-xs text-slate-400 text-center",children:Z})}):null]})}const i2=420,o2=1200,c2={1:262,2:330,3:392,4:523};function vo(){const n=oe(N=>N.session?.buttonBox?.buttons??[]),a=Pt(),{value:r}=Oe("audio",it),o=Number.isFinite(r?.masterVolume)?r.masterVolume:it.masterVolume,u=Number.isFinite(r?.alertVolume)?r.alertVolume:it.alertVolume,f=Math.max(0,Math.min(1,o*u)),p=m.useMemo(()=>{const N=Array.isArray(n)?n:[];return N.length===4?N:[1,2,3,4].map(w=>N.find(j=>Number(j?.id)===w)||{id:w,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n]),[h,g]=m.useState({}),[x,v]=m.useState({}),b=m.useRef(new Map),S=m.useRef(new Map),C=m.useRef({}),E=m.useRef(null);return m.useEffect(()=>{const N={};p.forEach(j=>{N[j.id]=Number(j.lastRewardAt||0)});const w=C.current||{};p.forEach(j=>{const R=Number(j.id),k=N[R]||0,T=Number(w[R]||0);if(k>0&&k!==T){v(O=>({...O,[R]:!0}));const q=S.current.get(R);q&&clearTimeout(q);const $=setTimeout(()=>{v(O=>({...O,[R]:!1})),S.current.delete(R)},o2);S.current.set(R,$)}}),C.current=N},[p]),m.useEffect(()=>{function N(j){const R=c2[j];if(!R||f<=0)return;let k=E.current;if(!k){const O=window.AudioContext||window.webkitAudioContext;if(!O)return;k=new O,E.current=k}const T=k.createOscillator(),q=k.createGain();T.type="square",T.frequency.value=R;const $=.14*f;q.gain.setValueAtTime(1e-4,k.currentTime),q.gain.exponentialRampToValueAtTime(Math.max(1e-4,$),k.currentTime+.01),q.gain.exponentialRampToValueAtTime(1e-4,k.currentTime+.2),T.connect(q),q.connect(k.destination),T.start(),T.stop(k.currentTime+.21)}function w(j={}){const R=Number(j.buttonId);if(!Number.isFinite(R)||R<1||R>4)return;g(q=>({...q,[R]:!0}));const k=b.current.get(R);k&&clearTimeout(k);const T=setTimeout(()=>{g(q=>({...q,[R]:!1})),b.current.delete(R)},i2);b.current.set(R,T),N(R)}return a.on("buttonBox:increment",w),()=>{a.off("buttonBox:increment",w)}},[f,a]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("header",{className:"panel-muted text-center text-sm",children:l.jsx("p",{children:"Button Box"})}),l.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:p.map(N=>{const w=Number(N.id),j=Number.isFinite(N.count)?N.count:0,R=Number.isFinite(N.goal)?N.goal:0,k=typeof N.rewardName=="string"&&N.rewardName.trim()?N.rewardName.trim():"Unassigned",T=Number.isFinite(N.rewardNumber)?N.rewardNumber:"?",q=!!h[w],$=!!x[w];return l.jsx(yg,{buttonId:w,count:j,goal:R,rewardNumber:T,rewardName:k,className:[q?"bg-cyan-900/45":"",$?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},w)})})]})}function u2(){const{identifySession:n}=Ot(),a=oe(x=>x.session?.overseerVote||null),{value:r}=Oe("profile",{nickname:""}),{value:o}=Oe("identity",{cookieUserId:""}),{value:u,save:f}=Oe("overseerPreference",{enabled:!0}),p=!!u?.enabled,h=!!a?.running,g=async x=>{const v=!!x?.target?.checked;await f(b=>({...b||{},enabled:v})),await n({cookieUserId:String(o?.cookieUserId||"").trim(),nickname:String(r?.nickname||"").trim(),overseerEnabled:v})};return l.jsxs("section",{className:"surface p-1 text-xs text-slate-200 text-center",children:[l.jsxs("label",{className:"flex items-center justify-center gap-1.5",children:[l.jsx("input",{type:"checkbox",checked:p,onChange:g}),l.jsx("span",{children:"Enable Overseer LLM"})]}),l.jsxs("div",{className:"mt-0.5 text-slate-400",children:["Yes?: ",Number(a?.yesCount||0),", No!: ",Number(a?.noCount||0)]}),l.jsx("div",{className:"mt-0.5 flex justify-center",children:l.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.7rem] font-medium ${h?"bg-emerald-600/80 text-emerald-50":"bg-slate-600/70 text-slate-100"}`,children:h?"Running!":"Stopped..."})})]})}function d2(){const{state:{roverId:n}}=yt(),r=Wt(n)?.sensors||{};return l.jsx("section",{className:"panel-section",children:l.jsx("div",{className:"aspect-square w-full",children:l.jsx(Fg,{sensors:r})})})}function f2(){const{state:{roverId:n,keymap:a,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:p,startHorn:h,stopHorn:g}}=yt(),x=al(),v=Bg(n),b=v.docked&&!v.driving,S=r?.config,C=!!(n&&r?.enabled&&S),E=!!(n&&u?.nightVision),N=u?.nightVisionState,w=!!(n&&u?.horn),j=o?.overheated,R=typeof S?.minAngle=="number"?S.minAngle:-30,k=typeof S?.maxAngle=="number"?S.maxAngle:30,T=typeof r?.angle=="number"?r.angle:typeof S?.homeAngle=="number"?S.homeAngle:(R+k)/2,q=Tt(a?.nightVisionToggle?.[0]),$=Tt(a?.hornHonk?.[0]),O=Tt(a?.cameraUp?.[0]),L=Tt(a?.cameraDown?.[0]),F=!!(!n||x.cameraLocked);return l.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[l.jsx(Lg,{layout:"desktop",expand:!0,driveDockState:v}),b?null:l.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[E&&l.jsx(zg,{nightVisionOn:N?.nightVisionOn,disabled:!n,onToggle:p,keyLabel:q}),w&&l.jsx(Ug,{disabled:!n||j,onStart:h,onStop:g,keyLabel:$,active:o?.active,heat:o?.heat}),C&&l.jsx(Hg,{value:T,min:R,max:k,disabled:F,onChange:f,keyDownLabel:L,keyUpLabel:O,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 m2({layout:n,onOpenHelpOverlay:a}){const[r,o]=m.useState("telemetry"),u=oe(N=>!!N.session?.isVerified),f=oe(N=>String(N.session?.assignment?.roverId||"").trim()),p=oe(N=>{const w=String(N.session?.assignment?.roverId||"").trim();return w&&N.session?.audioForward?.[w]||null}),{state:h}=yt(),{value:g}=Oe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),x=u?"bg-emerald-400":"bg-red-600",v=!!h?.mic?.pttActive,b=!!g?.openMicEnabled,S=g?.pttMode==="clip"?"clip":"live",C=!!(f&&u&&(S==="clip"?v:b||v)),E=!!(f&&u&&S==="clip"&&p?.source==="upload"&&p?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(vf,{defaultTab:"telemetry",currentTab:r,onTabChange:o,children:[l.jsxs(bf,{children:[l.jsx(Zt,{id:"telemetry",children:"Controls"}),l.jsx(Zt,{id:"vip",highlight:E?"green":C?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-2",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${x}`,"aria-hidden":"true",title:u?"Verified":"Not verified"})]})}),l.jsx(Zt,{id:"help",children:"Help"}),l.jsx(Zt,{id:"settings",children:"Settings"})]}),l.jsxs(yf,{children:[l.jsx(Jt,{id:"telemetry",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[l.jsx(d2,{}),l.jsx(f2,{})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[l.jsx(Ro,{}),l.jsx(tf,{panelId:"replay-sources-desktop",fillHeight:!0}),l.jsx(TA,{})]}),l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[l.jsx(Mo,{fillHeight:!0}),l.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[auto_minmax(0,1fr)_auto]",children:[l.jsx(u2,{}),l.jsx(go,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),l.jsx(RA,{compact:!0})]})]}),l.jsx(Zg,{}),l.jsx(vo,{}),l.jsx(uf,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),l.jsx(Jt,{id:"vip",keepMounted:!0,children:l.jsx(iv,{isActive:r==="vip"})}),l.jsx(Jt,{id:"help",children:l.jsx(av,{layout:n,onOpenOverlay:a})}),l.jsx(Jt,{id:"settings",children:l.jsx(tv,{})})]})]})})}const h2=new Set(["admin","lockdown","lockdown-admin"]),p2=new Set(["lockdown","lockdown-admin"]),x2=new Set(["admin","lockdown"]);function g2(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 v2(){const n=oe(b=>b.session?.mode||null),a=oe(b=>b.session?.role||null),r=oe(b=>b.session?.adminReason?.text||"");oe(b=>b.session?.adminReason?.updatedAt||null);const o=oe(b=>b.session?.timezone||"UTC"),u=oe(b=>(b.session?.socials||[]).find(E=>String(E?.id||E?.label||"").toLowerCase()==="discord")?.url||b.session?.discord?.invite||null),f=x2.has(n),p=n==="lockdown"?p2.has(a):h2.has(a),[h,g]=m.useState(()=>new Date),x=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:o,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(h)}catch{return h.toLocaleTimeString()}},[h,o]);if(m.useEffect(()=>{const b=setInterval(()=>g(new Date),1e3);return()=>clearInterval(b)},[]),!f||p)return null;const v=g2(n);return l.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black px-0.5 py-0.5",children:l.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold",children:v.title}),l.jsx("p",{className:"text-sm text-slate-300",children:v.description})]}),l.jsxs("div",{className:"surface-muted space-y-0.5",children:[l.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),l.jsx("p",{className:"text-lg font-semibold text-slate-100",children:r||"No reason set."}),l.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",x]})]}),l.jsx("div",{className:"surface-muted",children:l.jsx(Jg,{})}),l.jsx("div",{className:"w-full justify-center items-center",children:l.jsx(wo,{id:"discord",label:"Join our Discord server for updates!",url:u})}),"You can still use the chat while the server is locked:",l.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[l.jsx(Mo,{}),l.jsx(jr,{})]})]})})}const b2="/assets/turn_alert-DVO8EZJa.mp3";function y2(n,a=1){const r=m.useRef(null);return m.useEffect(()=>{r.current=new Audio(n),r.current.volume=a,r.current.load()},[n,a]),()=>{r.current&&(r.current.volume=a,r.current.currentTime=0,r.current.play().catch(()=>{}))}}function S2(){const n=oe(v=>v.session?.socketId||null),a=oe(v=>v.session?.turnQueues||{}),r=oe(v=>v.session?.roster||[]),{pushAlert:o}=Ot(),{value:u}=Oe("audio",it),f=Number.isFinite(u?.masterVolume)?u.masterVolume:it.masterVolume,p=Number.isFinite(u?.alertVolume)?u.alertVolume:it.alertVolume,h=Math.max(0,Math.min(1,f*p)),g=y2(b2,h),x=m.useRef(new Set);return m.useEffect(()=>{if(!n)return;const v=[];Object.entries(a).forEach(([b,S])=>{!S||!S.current||S.current!==n||x.current.has(b)||(v.push(b),x.current.add(b))}),Object.keys(a).forEach(b=>{(!a[b]||a[b].current!==n)&&x.current.delete(b)}),v.length!==0&&(v.forEach(b=>{const S=r.find(C=>String(C.id)===String(b))?.name||b;o({title:"Your turn!",message:`You now control ${S}.`,color:"#ff5722"})}),g())},[a,g,o,r,n]),null}function j2({visible:n,mode:a,onEnterFullscreen:r,onDismiss:o}){if(!n)return null;const u=a==="pwa-hint";return l.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center p-1 pointer-events-none bg-black/20",children:l.jsx("div",{className:"pointer-events-auto w-full max-w-sm surface center",children:l.jsxs("div",{className:"space-y-0.5 p-1 text-sm text-slate-100",children:[l.jsx("h2",{className:"text-base font-semibold text-white border-b border-slate-700",children:"Better in fullscreen!"}),u?l.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",l.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen then makes it fullscreen."]}):l.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."}),l.jsx("p",{className:"text-xs border-t border-b border-slate-700 p-0.5 text-blue-300 text-center",children:"This will only show once just to let you know. There is a fullscreen button in the bottom right for later use."}),l.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[l.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:u?"Got it":"Not now"}),!u&&l.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:r,children:"Enter fullscreen"})]})]})})})}function N2({side:n="right",onClick:a}){const r=n==="left"?"left-2":"right-2";return l.jsx("button",{type:"button",onClick:a,className:`fixed bottom-2 ${r} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-slate-700 bg-black text-slate-200 transition hover:bg-zinc-900 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:l.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const ov="fullscreenPromptDismissed",w2=new Set(["mobile-portrait","mobile-landscape"]),cv=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},A2=()=>{const n=cv();if(!n)return!1;try{return n.getItem(ov)==="1"}catch{return!1}},Rx=()=>{const n=cv();if(n)try{n.setItem(ov,"1")}catch{}},C2=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},Tx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function k2(n){const a=w2.has(n),[r,o]=m.useState(!1),[u,f]=m.useState("native"),[p,h]=m.useState(!1),g=m.useMemo(()=>C2(),[]),x=m.useMemo(()=>Tx(),[]),v=m.useCallback(()=>{if(!a){o(!1),h(!1);return}if(!p&&A2()){o(!1);return}if(g){f("pwa-hint"),o(!0);return}if(!Tx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}f("native"),o(!0)},[p,g,a]);m.useEffect(()=>{v()},[v]),m.useEffect(()=>{if(typeof document>"u")return;const E=()=>{if(document.fullscreenElement){h(!1),o(!1);return}v()};return document.addEventListener("fullscreenchange",E),document.addEventListener("webkitfullscreenchange",E),()=>{document.removeEventListener("fullscreenchange",E),document.removeEventListener("webkitfullscreenchange",E)}},[v]);const b=m.useCallback(()=>{Rx(),h(!1),o(!1)},[]),S=m.useCallback(async()=>{if(!a||g||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const E=document.documentElement;if(!E)return!1;const N=E.requestFullscreen||E.webkitRequestFullscreen||E.mozRequestFullScreen||E.msRequestFullscreen;if(!N)return!1;try{const w=N.call(E);return w&&typeof w.then=="function"&&await w,Rx(),h(!1),o(!1),!0}catch(w){return console.warn("Failed to enter fullscreen",w),!1}},[g,a]),C=m.useCallback(()=>{a&&(h(!0),f(g?"pwa-hint":"native"),o(!0))},[g,a]);return m.useEffect(()=>{a||(h(!1),o(!1))},[a]),{visible:r,mode:u,isIOS:g,nativeSupported:x,enterFullscreen:S,dismiss:b,showPrompt:C}}function E2({visible:n,layout:a,onClose:r,showOnLoad:o,onToggleShowOnLoad:u}){if(!n)return null;const{state:f}=yt(),p=h=>{const g=!h.target.checked;u?.(g)};return l.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:l.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[l.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:[l.jsx("span",{className:"font-semibold",children:"Help & controls"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!o,onChange:p,className:"accent-cyan-500"}),l.jsx("span",{children:"Don't show again"})]}),l.jsx("button",{type:"button",onClick:r,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),l.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:l.jsx(sv,{layout:a,keymap:f?.keymap||{}})})]})})}function Ia({label:n,keyLabel:a}){return l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.35 text-[0.8rem] text-slate-200",children:[l.jsx("span",{children:n}),l.jsx(Ud,{label:a})]})}function M2({keymap:n}){return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200",children:'1. Press "Start Driving" put your rover into driving mode.'}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200",children:"2. Use the drive controls to move your rover:"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Ia,{label:"Forward",keyLabel:Tt(n?.driveForward?.[0])}),l.jsx(Ia,{label:"Backward",keyLabel:Tt(n?.driveBackward?.[0])}),l.jsx(Ia,{label:"Turn Left",keyLabel:Tt(n?.driveLeft?.[0])}),l.jsx(Ia,{label:"Turn Right",keyLabel:Tt(n?.driveRight?.[0])}),l.jsx(Ia,{label:"Move faster",keyLabel:Tt(n?.boostModifier?.[0])}),l.jsx(Ia,{label:"Move slower",keyLabel:Tt(n?.slowModifier?.[0])})]})]}),l.jsx("p",{className:"text-sm text-slate-200",children:'3. When done, enter "Docking Assist" and line up the front sensor with the dock sensor.'})]})}function R2(){return l.jsxs("div",{className:"space-y-0.5 text-sm text-slate-200",children:[l.jsx("p",{children:'1. Press "Start Driving" put your rover into driving mode.'}),l.jsx("p",{children:"2. Touch and hold in Joystick area to move."}),l.jsx("p",{children:"3. Use the other column for motor, horn, and camera controls."}),l.jsx("p",{children:'4. When done, enter "Docking Assist" and line up the front sensor with the dock sensor.'})]})}function T2({visible:n,layout:a,showOnLoad:r,onToggleShowOnLoad:o,onOpenHelp:u,onClose:f}){const{state:p}=yt(),h=a==="desktop",g=oe(b=>(b.session?.socials||[]).find(E=>String(E?.id||E?.label||"").toLowerCase()==="discord")?.url||b.session?.discord?.invite||null),x=m.useMemo(()=>p?.keymap||{},[p?.keymap]);if(!n)return null;const v=b=>{const S=!b.target.checked;o?.(S)};return l.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center bg-black/75 p-0.5 items-center",children:l.jsxs("div",{className:"pointer-events-auto surface w-full max-w-3xl overflow-hidden shadow-2xl",children:[l.jsx("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.35 text-sm text-slate-200",children:l.jsx("span",{className:"font-semibold text-xl",children:"Welcome! To get started:"})}),l.jsxs("div",{className:`grid gap-0.5 p-0.5 ${h?"md:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]":"grid-cols-1"}`,children:[l.jsx("section",{className:"space-y-0.5 border-b border-slate-700",children:h?l.jsx(M2,{keymap:x}):l.jsx(R2,{})}),l.jsxs("section",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-left",children:"Next..."}),l.jsxs("div",{className:"surface space-y-0.5 p-0.5 border-b border-slate-700",children:[l.jsx("p",{className:"text-xl font-semibold text-slate-200",children:"Set your nickname"}),l.jsx("p",{className:"text-sm font-semibold text-slate-200",children:"Nicknames are assigned randomly by default, you can change yours here."}),l.jsx(jr,{compact:!0})]}),l.jsxs("div",{className:"surface p-0.5",children:[l.jsx("p",{className:"text-xl font-semibold text-slate-200",children:"Join our Discord server!"}),l.jsx("p",{className:"text-sm font-semibold text-slate-200",children:"We have an active and welcoming community :3"}),l.jsx(wo,{id:"discord",label:"Join Discord",url:g})]})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5 border-t border-slate-700 px-0.5 py-0.35 text-[0.8rem]",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:!r,onChange:v,className:"accent-cyan-500"}),l.jsx("span",{children:"Don't show again"})]}),l.jsx("div",{className:"flex items-center gap-0.5",children:l.jsx("button",{type:"button",onClick:f,className:"button-dark px-1 py-0.25 text-2xl bg-green-600 hover:bg-green-400 hover:border-green-100 border-green-400",children:"Got it! Let me in!"})})]})]})})}const q2=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
shrimp
|
||
fling`;function D2(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function _2(){const n=String(q2).split(/\r?\n/).map(r=>r.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function Sf(){const{setNickname:n}=Ot(),{value:a,status:r,save:o}=Oe("profile",{nickname:""}),u=m.useRef(!1);m.useEffect(()=>{if(r!=="ready"||u.current||(a.nickname||"").trim())return;u.current=!0;const p=D2(_2()).slice(0,32);if(!p)return;(async()=>{try{await n(p)}catch{}finally{o({nickname:p})}})()},[o,n,r,a.nickname])}function O2(){const n=Pt(),a=oe(k=>k.connected),{identifySession:r}=Ot(),{value:o,status:u,save:f}=Oe("identity",{cookieUserId:""}),{value:p,status:h}=Oe("profile",{nickname:""}),{value:g,status:x}=Oe("overseerPreference",{enabled:!0}),v=m.useRef(!1),b=m.useRef(null),S=m.useRef(null),C=u==="ready"&&h==="ready"&&x==="ready",E=(o?.cookieUserId||"").trim(),N=(p?.nickname||"").trim(),w=!!g?.enabled,j=m.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),R=m.useCallback(async()=>{if(!(!C||!a||!n?.id||v.current)){v.current=!0;try{const T=((await r({cookieUserId:E,nickname:N,overseerEnabled:w}))?.cookieUserId||"").trim();T&&T!==E&&f(q=>({...q||{},cookieUserId:T})),b.current=n.id,j()}catch{j(),S.current=setTimeout(()=>{R()},2e3)}finally{v.current=!1}}},[j,a,E,r,N,w,C,f,n?.id]);m.useEffect(()=>{!C||!a||!n?.id||b.current!==n.id&&R()},[a,C,R,n?.id]),m.useEffect(()=>{!C||!a||!n?.id||R()},[C,a,n?.id,E,N,w,R]),m.useEffect(()=>{const k=()=>{n?.connected&&R()},T=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&R()};return window.addEventListener("online",k),document.addEventListener("visibilitychange",T),()=>{window.removeEventListener("online",k),document.removeEventListener("visibilitychange",T)}},[R,n?.connected]),m.useEffect(()=>()=>j(),[j])}const vd=1e4,bd=28,B2=14;function bo({layout:n="desktop",className:a="",dismissable:r=!0}){const o=oe(j=>{const R=j.session?.globalObjective?.text;return R?String(R).trim():""}),u=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[f,p]=m.useState(!1),[h,g]=m.useState(bd),[x,v]=m.useState(0),b=m.useRef(null),S=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!o){p(!1);return}if(p(!0),!u||!r)return;const j=Date.now();v(vd);const R=setTimeout(()=>p(!1),vd),k=setInterval(()=>{const T=Date.now()-j;v(Math.max(0,vd-T))},250);return()=>{clearTimeout(R),clearInterval(k)}},[o,u]),m.useEffect(()=>{if(!o)return;g(bd);let j=0;const R=()=>{const T=C.current,q=S.current;if(!T||!q)return;const $=T.clientWidth;if(!$)return;const O=q.scrollWidth;if(!O)return;const L=Math.min(1,$/O),F=Math.max(B2,Math.floor(bd*L));g(F)};j=window.requestAnimationFrame(R);const k=new ResizeObserver(()=>{window.cancelAnimationFrame(j),j=window.requestAnimationFrame(R)});return b.current&&k.observe(b.current),()=>{window.cancelAnimationFrame(j),k.disconnect()}},[o]);const E=m.useMemo(()=>["panel-section flex w-full items-center justify-center",u?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",a].filter(Boolean).join(" "),[a,u]);if(!o||!f)return null;const N=u?Math.ceil(x/1e3):null,w=r?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return l.jsx("div",{ref:b,className:E,style:{fontSize:`${h}px`,lineHeight:1.1},...w,children:l.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[l.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:[l.jsx("span",{children:"Global"}),l.jsx("span",{children:"Objective"})]}),l.jsx("span",{ref:C,className:"flex-1 overflow-hidden text-slate-100",children:l.jsx("span",{ref:S,className:"block",children:o})}),u?l.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[N,"s"]}):null]})})}const L2=3200;function z2(n={}){const a=typeof n.rewardName=="string"&&n.rewardName.trim()?n.rewardName.trim():"Unknown Event",r=Number.isFinite(Number(n.goal))?Math.max(1,Math.floor(Number(n.goal))):0,o=Number.isFinite(Number(n.count))?Math.max(0,Math.floor(Number(n.count))):r;return{rewardName:a,goal:r,count:o,ts:Date.now()}}function uv(){const n=Pt(),{value:a}=Oe("audio",it),r=Number.isFinite(a?.masterVolume)?a.masterVolume:it.masterVolume,o=Number.isFinite(a?.alertVolume)?a.alertVolume:it.alertVolume,u=Math.max(0,Math.min(1,r*o)),[f,p]=m.useState(null),h=m.useRef(null);return m.useEffect(()=>{h.current=new Audio("/tada.mp3"),h.current.volume=u,h.current.load()},[u]),m.useEffect(()=>{let g=null;function x(){const S=h.current;S&&(S.volume=u,S.currentTime=0,S.play().catch(()=>{}))}function v(S={}){const C=z2(S);p(C),x(),g&&clearTimeout(g),g=setTimeout(()=>{p(null)},L2)}function b(S){v(S?.detail||{})}return n.on("buttonBox:rewardRun",v),window.addEventListener("buttonBox:rewardRunLocalTest",b),()=>{g&&clearTimeout(g),n.off("buttonBox:rewardRun",v),window.removeEventListener("buttonBox:rewardRunLocalTest",b)}},[u,n]),f?l.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120] flex items-center justify-center bg-black/75 px-1 py-1",children:l.jsx("div",{className:"pointer-events-auto w-full max-w-2xl",children:l.jsx("div",{className:"surface rounded-none border-2 border-cyan-300 bg-amber-100/95 px-1 py-1 text-center text-black shadow-2xl",children:l.jsxs("div",{className:"flex items-center justify-center gap-1 border-2 border-blue-600 bg-yellow-100 px-0.5 py-1",children:[l.jsx("img",{src:"/party1.gif",alt:"",className:"hidden shrink-0 sm:block"}),l.jsxs("div",{children:[l.jsxs("p",{className:"font-mono text-2xl font-bold text-red-700 sm:text-3xl",children:["Running event: ",f.rewardName,"!"]}),l.jsxs("p",{className:"font-mono text-xl font-bold text-blue-800 sm:text-2xl",children:[f.count,"/",f.goal]})]}),l.jsx("img",{src:"/party2.gif",alt:"",className:"hidden shrink-0 sm:block"})]})})})}):null}function U2(){const[n,a]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function r(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:u}=window;o>=1024?a("desktop"):o>u?a("mobile-landscape"):a("mobile-portrait")}return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),n}function H2({layout:n,onOpenHelpOverlay:a}){return l.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[l.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[l.jsx(hf,{}),l.jsx(xj,{}),l.jsx(df,{})]}),l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[l.jsx(bo,{layout:n}),l.jsx(m2,{layout:n,onOpenHelpOverlay:a})]})]})}function dv({layout:n,onOpenHelpOverlay:a,roomPanelId:r,showTelemetry:o=!0}){const[u,f]=m.useState("chat"),p=oe(j=>!!j.session?.isVerified),h=oe(j=>String(j.session?.assignment?.roverId||"").trim()),g=oe(j=>{const R=String(j.session?.assignment?.roverId||"").trim();return R&&j.session?.audioForward?.[R]||null}),{state:x}=yt(),{value:v}=Oe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),b=p?"bg-emerald-400":"bg-amber-400",S=!!x?.mic?.pttActive,C=!!v?.openMicEnabled,E=v?.pttMode==="clip"?"clip":"live",N=!!(h&&p&&(E==="clip"?S:C||S)),w=!!(h&&p&&E==="clip"&&g?.source==="upload"&&g?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(vf,{defaultTab:"chat",currentTab:u,onTabChange:f,children:[l.jsxs(bf,{children:[l.jsx(Zt,{id:"chat",children:"Chat"}),l.jsx(Zt,{id:"vip",highlight:w?"green":N?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${b}`,"aria-hidden":"true",title:p?"Verified":"Not verified"})]})}),l.jsx(Zt,{id:"roomcontrols",children:"Room Controls"}),l.jsx(Zt,{id:"help",children:"Help"}),l.jsx(Zt,{id:"settings",children:"Settings"})]}),l.jsxs(yf,{children:[l.jsx(Jt,{id:"chat",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Mo,{}),l.jsx(go,{})]})}),l.jsx(Jt,{id:"vip",keepMounted:!0,children:l.jsx(iv,{isActive:u==="vip"})}),l.jsx(Jt,{id:"roomcontrols",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Zg,{}),l.jsx(vo,{}),l.jsx(uf,{panelId:r})]})}),l.jsx(Jt,{id:"help",children:l.jsx(av,{layout:n,onOpenOverlay:a})}),l.jsx(Jt,{id:"settings",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(tv,{}),l.jsx(df,{})]})})]})]})})}function V2({onOpenHelpOverlay:n,swapMobileControlColumns:a=!1}){return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx(hf,{layoutFormat:"mobile-portrait"}),l.jsx(GN,{swapColumns:a}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(tf,{panelId:"replay-sources-mobile-portrait"}),l.jsx(Ro,{})]}),l.jsx(dv,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function $2({onOpenHelpOverlay:n,swapMobileControlColumns:a=!1}){const r="self-start h-[min(100svh,32rem)]",o=a?l.jsx(po,{layout:"landscape",className:r}):l.jsx(ho,{layout:"landscape",className:r}),u=a?l.jsx(ho,{layout:"landscape",className:r}):l.jsx(po,{layout:"landscape",className:r});return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.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,l.jsxs("div",{children:[l.jsx(hf,{layoutFormat:"mobile-landscape"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(tf,{panelId:"replay-sources-mobile-landscape"}),l.jsx(Ro,{})]})]}),u]}),l.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:l.jsx(dv,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function G2(){const n=U2(),a=n==="desktop",r=k2(n);return l.jsx("div",{className:`bg-black text-slate-100 ${a?"h-screen overflow-hidden":"min-h-screen"}`,children:l.jsx(Y2,{layout:n,isDesktop:a,fullscreen:r})})}function Y2({layout:n,isDesktop:a,fullscreen:r}){Sf(),O2();const{visible:o,mode:u,isIOS:f,nativeSupported:p,enterFullscreen:h,dismiss:g,showPrompt:x}=r,{value:v,save:b}=Oe("help",{showOnLoad:!0}),{value:S,status:C,save:E}=Oe("quickstart",{showOnLoad:!0}),{value:N}=Oe("page",{swapMobileControlColumns:!1}),w=!!N?.swapMobileControlColumns,j=w?"left":"right",R=!a&&(f||p),[k,T]=m.useState(!1),[q,$]=m.useState(!1);m.useEffect(()=>{C==="ready"&&$(S?.showOnLoad!==!1)},[C,S?.showOnLoad]);const O=m.useCallback(()=>T(!0),[]),L=m.useCallback(()=>T(!1),[]),F=m.useCallback(()=>$(!1),[]),U=m.useCallback(async()=>{if(f){x();return}await h()||x()},[h,f,x]),Z=m.useCallback(ue=>{const le=!!ue;E(B=>({...B??{},showOnLoad:le})),le||$(!1)},[E]),Q=m.useCallback(()=>{$(!1),T(!0)},[]),ce=m.useMemo(()=>a?l.jsx(H2,{layout:n,onOpenHelpOverlay:O}):n==="mobile-landscape"?l.jsx($2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}):l.jsx(V2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}),[a,n,O,w]);return l.jsxs(uN,{children:[l.jsx(SN,{}),l.jsx(DN,{}),l.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${a?"h-full overflow-hidden":""}`,children:[a?null:l.jsx(bo,{layout:n}),ce]}),l.jsx(af,{}),l.jsx(uv,{}),l.jsx(S2,{}),l.jsx(v2,{}),l.jsx(E2,{visible:k,layout:n,onClose:L,showOnLoad:v?.showOnLoad!==!1,onToggleShowOnLoad:ue=>b(le=>({...le??{},showOnLoad:!!ue}))}),l.jsx(j2,{visible:o,mode:u,onEnterFullscreen:h,onDismiss:g}),l.jsx(T2,{visible:q,layout:n,showOnLoad:S?.showOnLoad!==!1,onToggleShowOnLoad:Z,onOpenHelp:Q,onClose:F}),R?l.jsx(N2,{side:j,onClick:U}):null]})}function fv(){const{session:n,setRole:a,subscribeAll:r,connected:o}=br(),[u,f]=m.useState(!1);return m.useEffect(()=>{let p=!1;async function h(){if(n?.mode==="lockdown"){f(!1);return}try{n?.role!=="spectator"&&await a("spectator"),await r(),p||f(!0)}catch(g){console.error("Failed to enter spectator mode",g),p||f(!1)}}return h(),()=>{p=!0}},[o,n?.mode,n?.role,a,r]),u}function F2(){const[n,a]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia("(max-aspect-ratio: 4/3)"),o=u=>a(u.matches);return r.addEventListener?r.addEventListener("change",o):r.addListener(o),()=>{r.removeEventListener?r.removeEventListener("change",o):r.removeListener(o)}},[]),n}function I2({show:n=!1,roverId:a=null,sensors:r,batteryConfig:o,mobileHud:u=!1}){const f=Wt(a),p=oe(v=>a?(v.session?.roster||[]).find(C=>String(C.id)===String(a))?.battery??null:null),h=r??f?.sensors??null,g=o??p,x=Co({charge:h?.batteryChargeMah??null,config:g});return!n||!x?.available?null:l.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:l.jsx(mf,{visual:x,orientation:"vertical",variant:"inline",compact:u,className:"h-full w-4"})})}const X2=Dt.memo(I2);function Q2({roverId:n=null,label:a,fitParent:r=!1,layoutFormat:o="desktop"}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${r?"h-full":""}`,children:l.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${r?"h-full flex-1":"aspect-[4/3]"}`,children:[l.jsx(fr,{roverId:n,label:a}),l.jsx(Xg,{roverId:n,variant:"spectator",mobileHud:!1}),l.jsx(Ig,{roverId:n,layoutFormat:o,variant:"spectator",mobileHud:!1,labelScale:1}),l.jsx(Qg,{roverId:n,compact:!1}),l.jsx(Kg,{roverId:n,compact:!1}),l.jsx(X2,{show:!0,roverId:n,mobileHud:!1})]})})}function K2({rover:n}){return l.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:l.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:l.jsx(Q2,{roverId:n.id,label:n.name})})})}function Z2({roster:n}){return n.length===0?l.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):l.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:n.map(a=>l.jsx(K2,{rover:a},a.id))})}function J2(){return l.jsx("section",{className:"min-h-0",children:l.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:l.jsx(uf,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function P2({className:n=""}){return l.jsx("div",{className:`panel ${n}`,children:l.jsx(df,{})})}function W2(){const{session:n}=br(),a=n?.mode==="lockdown";Sf(),fv();const r=F2(),o=n?.roster??[];if(a)return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),l.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const u=r?"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]",f=r?"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",p=r?"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",h="",g=r?"h-64":"";return l.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[l.jsxs("main",{className:u,children:[l.jsxs("section",{className:p,children:[r?l.jsxs("div",{className:`${h} ${g} flex flex-col gap-0.5`,children:[l.jsx(bo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(vo,{}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(go,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):l.jsxs("div",{className:h,children:[l.jsx(bo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(vo,{})]}),l.jsx("div",{className:`${h} ${r?`${g} overflow-y-auto`:""}`,children:l.jsx("div",{className:"panel h-full",children:l.jsx(Ro,{title:"Rovers"})})}),r?null:l.jsx("div",{className:`${h} flex-1 min-h-0`,children:l.jsx(go,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),l.jsx("div",{className:`${h} ${r?g:"flex-[1.1] min-h-0"}`,children:l.jsx(Mo,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),l.jsx("div",{className:`${h} ${r?g:""}`,children:l.jsx(P2,{className:`${r?"h-full":"h-40"} overflow-hidden`})})]}),l.jsxs("section",{className:f,children:[l.jsx(Z2,{roster:o}),l.jsx(J2,{})]})]}),l.jsx(af,{}),l.jsx(uv,{})]})}function e5(){return l.jsx(W2,{})}function t5({children:n}){return l.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:l.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:l.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:n})})})}function n5({roverId:n,session:a}){const r=a?.activeDrivers?.[n]||null,u=(a?.users||[]).find(h=>h.socketId===r)?.nickname||(r?r.slice(0,6):"No driver"),f=a?.mode,p=a?.turnQueues?.[n];return f==="turns"&&p?.current?`${u}`:u}function s5({rover:n,frame:a}){const r=a?.sensors?.batteryChargeMah??null,o=n?.battery??null;return Co({batteryState:n?.batteryState??null,charge:r,config:o})}function Xa({children:n,className:a="",maxSize:r=1e3,minSize:o=14,style:u=void 0}){const f=m.useRef(null),p=m.useRef(null),[h,g]=m.useState(r);return m.useLayoutEffect(()=>{const x=f.current,v=p.current;if(!x||!v)return;let b=null;const S=()=>{const N=x.clientWidth;if(!N){C();return}let w=o,j=r,R=o;for(;w<=j;){const k=Math.floor((w+j)/2);v.style.fontSize=`${k}px`,v.scrollWidth<=N?(R=k,w=k+1):j=k-1}g(R)},C=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(S)};C();const E=new ResizeObserver(C);return E.observe(x),()=>{b&&cancelAnimationFrame(b),E.disconnect()}},[n,r,o]),l.jsx("div",{ref:f,className:"w-full min-w-0",children:l.jsx("div",{ref:p,className:`whitespace-nowrap ${a}`,style:{fontSize:`${h}px`,lineHeight:1.1,...u||{}},children:n})})}function qx({rover:n,frame:a,driverLabel:r,sessionInfo:o,videoMode:u="snapshot",snapshotFeed:f,withDivider:p=!1,showPreview:h=!0,variant:g="stacked"}){const x=s5({rover:n,frame:a}),v=x?.available?x.percentDisplay:null,b=g==="active";return l.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${p?"border-r border-slate-700/60":""}`,children:[l.jsx(mf,{visual:x,orientation:b?"vertical":"horizontal",variant:"background"}),b?l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ns(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):l.jsx("div",{}),l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:v==null?"--%":`${v}%`})})})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ns(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):null,l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:v==null?"--%":`${v}%`})})})]}),l.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:l.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:h?l.jsx("div",{className:"mt-auto w-full",children:l.jsx("div",{className:"w-full aspect-[4/3]",children:l.jsx(fr,{sessionInfo:o,videoMode:u,snapshotFeed:f,audioSessionInfo:null,label:n.name||n.id,sensors:a?.sensors||null})})}):null})})]})]})}const a5=2e4,l5=3600*1e3;function r5(){const{session:n}=br(),a=fv();Sf();const r=n?.mode==="lockdown",o=!!n?.isLocalNetwork,u=fj(),f=n?.roster??[],[p,h]=m.useState(0),g=n?.activeDrivers||{},x=m.useMemo(()=>f.filter(U=>g[U.id]),[f,g]),v=x.length?x:f,b=$g(v.map(U=>U.id),{enabled:!r&&!o,version:n?.mode}),S=m.useMemo(()=>o?v.map(U=>({type:"rover",id:U.id,key:U.id})):[],[o,v]),C=zd(S,{enabled:!r&&o,version:n?.mode}),E=m.useMemo(()=>x.flatMap(U=>{if(!U?.id||!U.media?.audioPublishUrl)return[];const Z=String(U.id);return[{type:"rover",id:`${Z}-audio`,key:`${Z}-audio`}]}),[x]),N=zd(E,{enabled:!r,version:n?.mode}),w=m.useMemo(()=>{if(!x.length)return[];if(!o){const Z=x.filter(Q=>b[Q.id]?.objectUrl);return Z.length?Z:x}const U=x.filter(Z=>{const Q=C[Z.id];return Q?.url&&!Q?.error});return U.length?U:x},[x,b,C,o]),j=m.useMemo(()=>w.map(U=>({type:"rover",rover:U})),[w]),R=m.useMemo(()=>j.map(U=>`r:${U.rover.id}`).join("|"),[j]);m.useEffect(()=>{h(0)},[R]),m.useEffect(()=>{if(!j.length)return;const U=setInterval(()=>{h(Z=>(Z+1)%j.length)},a5);return()=>clearInterval(U)},[j.length,R]);const k=j.length?j[p%j.length]:null,T=k?.type==="rover"?k.rover:null,q=!o&&T&&b[T.id]||null,$=o&&T&&C[T.id]||null,O=T&&N[`${T.id}-audio`]||null,L=T&&u[T.id]||null,F=T?n5({roverId:T.id,session:n}):null;return r?l.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),l.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):x.length?l.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[l.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:a?T?l.jsx(t5,{children:o?l.jsx("div",{className:"relative h-full w-full",children:j.map(U=>{const Z=U.rover,Q=T?.id===Z.id;return l.jsx("div",{className:`absolute inset-0 ${Q?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsx(fr,{sessionInfo:C[Z.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:Q?O:null,forceMute:!Q,label:Z.name||Z.id,sensors:u[Z.id]?.sensors||null})},Z.id)})}):l.jsx(fr,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:q,audioSessionInfo:O,label:T.name||T.id,sensors:L?.sensors||null})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:x.length?"No sources available.":"No active drivers."}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),l.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:T?l.jsx(qx,{rover:T,frame:L,driverLabel:F,sessionInfo:o?$:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[T.id]||null,showPreview:!1,variant:"active"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):l.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:l.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:f.length?f.map(U=>l.jsx(qx,{rover:U,frame:u[U.id]||null,driverLabel:null,sessionInfo:o&&C[U.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[U.id]||null,showPreview:!0,withDivider:!1},U.id)):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function i5(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const a=new URL(window.location.href);a.searchParams.set("refresh",Date.now().toString()),window.location.replace(a.toString())},l5);return()=>clearTimeout(n)},[]),l.jsxs(l.Fragment,{children:[l.jsx(r5,{}),l.jsx(af,{scale:3})]})}function Ki(n){if(!n||!n.length)return null;const a=Math.floor(Math.random()*n.length);return n[a]||null}function o5(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const a=Ki(n),r=Ki(n),o=a?.classList?.[0]||null;if(o&&r?.classList)try{r.classList.add(o)}catch{}const u=Ki(n),f=Ki(n),p=u?.classList?.[1]||null;if(p&&f?.classList)try{f.classList.add(p)}catch{}}function c5(){const n=oe(a=>!!a.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const a=window.setInterval(()=>{o5()},1);return()=>{window.clearInterval(a)}},[n]),null}By.createRoot(document.getElementById("root")).render(l.jsx(m.StrictMode,{children:l.jsx(lj,{children:l.jsx(cj,{children:l.jsx(dj,{children:l.jsx(Sj,{children:l.jsxs(fN,{children:[l.jsx(c5,{}),l.jsx(J1,{children:l.jsxs(E1,{children:[l.jsx(Zi,{path:"/",element:l.jsx(G2,{})}),l.jsx(Zi,{path:"/spectate",element:l.jsx(e5,{})}),l.jsx(Zi,{path:"/mini",element:l.jsx(i5,{})})]})})]})})})})})}));
|