import{e as Wr,ap as wa,r as R,hg as va,cy as ba,dC as ka,dD as Ca,j as m,ay as Eo,dE as Ea,az as So,m as qt,a4 as Yn,aA as Mo,cb as Sa,c as Cn,a6 as q0,V as ur,Z as vn,hh as J0,hi as Bo,hj as Ma,cm as Ba,ct as Da,cw as _a,dA as Do,cu as _o,ar as jo,aB as Ro,d as Sr,b as En,B as Ft,dT as ja,co as ps,H as Us,G as Vs,dK as To,w as Io,d2 as Lo,R as No,bK as Sn,bF as wi,hk as Fo,W as Ra,aa as Ta,dS as Ia,hl as La,aw as Po,bR as vi,bT as Na,a5 as X0,a7 as As,cq as Fa,b6 as Pa,f7 as Qo,hm as Qa,hn as Oa,dU as za,dB as Ha,ho as Ga,hp as Ua,aO as Oo,$ as bt,hq as Va,hr as zo,gR as Wa,aq as Mr,bN as Ho,dJ as Ya,hs as Go,ht as Uo,cd as Ka,he as $a,cg as Za,dH as Vo,dL as qa,ad as Ja,hu as Xa,fj as Au,hv as gs,gi as eu,fR as tu,dz as ru}from"./index-C4inJ1rU.js";import{u as Yr,M as nu,S as su}from"./maplibre-gl-ClZLWYTA.js";import{u as Wo,r as Yo,e as bi,f as ki,g as iu}from"./consumer-registry-BEMotsU4.js";import{L as V0,c as ou}from"./link-scoring-BT92qwBN.js";import{C as lu}from"./ConfirmModal-Dr1cpMpw.js";import{s as au,a as uu,M as cu}from"./variants-BxtUhUrZ.js";import{G as Bs}from"./git-branch-Dnk0SYSJ.js";import{H as fu,A as y0,D as Ci,p as hu,c as du,u as mn}from"./useMapViewStore-MJt-JUde.js";import{F as mu}from"./funnel-MRZBOee_.js";import{P as pu}from"./plus-BvSKm1y6.js";import{C as gu}from"./compass-BqGOlCkL.js";import{Z as yu}from"./zap-NBmxZJvi.js";import{b as xu,e as wu,a as Ko,m as Ei,E as vu,u as bu,G as ku,g as Cu,d as Eu,f as Su}from"./max-Cf6xo70m.js";import{T as Mu}from"./trash-2-1fU70LRT.js";import{W as Bu}from"./wifi-off-DcMGHQmj.js";import{W as Du}from"./wifi-CrCnex2M.js";import{C as _u}from"./circle-alert-CIOCr8DK.js";import{C as $o}from"./clock-BOSF_clE.js";import{C as ju}from"./chevron-right-CU8UihKL.js";import{u as Ws,a as Zo,b as qo,c as Ru,d as Tu,e as Ys,f as Si,R as Iu,g as Lu,h as Jo,t as Nu,i as Fu,j as Pu,k as Qu}from"./useReplayTick-BfUplIIt.js";import{L as Ou}from"./LightSparkline-CReUcxTn.js";import{P as Xo,R as zu}from"./Contacts-BXfeM7gK.js";import{H as K0,C as cr,N as Hu,a as Gu}from"./badge-colors-Dl76Mz8m.js";import{M as Uu}from"./map-pin-DlTTkXK_.js";import{W as Vu}from"./wrench-d23m0Iuc.js";import{S as Vr,L as Zt}from"./layer-D6BnwDKL.js";import{c as Mi}from"./node-types-chTBCezS.js";import{B as Wu}from"./BasemapLayer-zAPrA2Lm.js";import{a as Al,b as Ds,c as Yu}from"./easing-C4vSIYXU.js";import"./index-BXWmGYBj.js";import"./index-CLVX1WuQ.js";import"./payload-detail-BWRHeO7M.js";import"./usePipelineStore-BdsvnjJV.js";import"./PageLayout-CdGXajgM.js";import"./listbox-C-kqERsa.js";import"./element-movement-Dl45gerR.js";import"./floating-4TW7J4UF.js";import"./use-text-value-BO4BQQts.js";import"./frozen-BB9d2dXD.js";import"./TimeRangeStepper-DNUdgVzA.js";import"./MqttModeBadge-BTwynmjt.js";import"./chat-utils-C6kvX8nY.js";import"./SignalIndicator-BTMFmuDD.js";import"./CollisionExplorerModal-D4h1t6K4.js";import"./share-2-CGZnW2u_.js";import"./map-pin-off-lllWd_C7.js";import"./activity-Q-NGsRUt.js";import"./target-C8oxWH8W.js";import"./search-qUivGgU1.js";/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ku=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],_s=Wr("boxes",Ku);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $u=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],el=Wr("ghost",$u);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Zu=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],qu=Wr("map",Zu);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ju=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],Xu=Wr("mountain",Ju);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ac=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],ec=Wr("navigation",Ac);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const tc=[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]],tl=Wr("nfc",tc);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rc=[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]],nc=Wr("sigma",rc);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const sc=[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]],ic=Wr("swords",sc);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oc=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],lc=Wr("trending-down",oc);function ac(a,u){return u.filter(y=>y.nodes.includes(a)).sort((y,x)=>x.avgCertainCount-y.avgCertainCount)}function uc(a,u,g){const y=ac(a,u),x=new Set,k=[];for(const D of y)for(const Q of D.edgeKeys)if(!x.has(Q)){x.add(Q);const M=g.get(Q);k.push({key:Q,certainCount:(M==null?void 0:M.certainCount)??0})}return k.sort((D,Q)=>Q.certainCount-D.certainCount),{loops:y,highlightedEdgeKeys:x,sortedEdges:k}}function cc(a){const u=new Map;for(const g of a)for(const y of g.edgeKeys){const x=u.get(y)??[];x.push(g),u.set(y,x)}return u}const _0={MAX_THICKNESS_AT:300,MIN_VALIDATIONS:5},fc=6,Bi=1;function js(a,u){const g=Math.max(_0.MIN_VALIDATIONS,Math.min(a,_0.MAX_THICKNESS_AT)),y=Math.log(_0.MIN_VALIDATIONS),x=Math.log(_0.MAX_THICKNESS_AT),D=(Math.log(g)-y)/(x-y);return Bi+(fc-Bi)*D}const hc=dc(mc);function dc(a){return function(u,g,y=g){if(!((g=+g)>=0))throw new RangeError("invalid rx");if(!((y=+y)>=0))throw new RangeError("invalid ry");let{data:x,width:k,height:D}=u;if(!((k=Math.floor(k))>=0))throw new RangeError("invalid width");if(!((D=Math.floor(D!==void 0?D:x.length/k))>=0))throw new RangeError("invalid height");if(!k||!D||!g&&!y)return u;const Q=g&&a(g),M=y&&a(y),b=x.slice();return Q&&M?(Qn(Q,b,x,k,D),Qn(Q,x,b,k,D),Qn(Q,b,x,k,D),On(M,x,b,k,D),On(M,b,x,k,D),On(M,x,b,k,D)):Q?(Qn(Q,x,b,k,D),Qn(Q,b,x,k,D),Qn(Q,x,b,k,D)):M&&(On(M,x,b,k,D),On(M,b,x,k,D),On(M,x,b,k,D)),u}}function Qn(a,u,g,y,x){for(let k=0,D=y*x;k<D;)a(u,g,k,k+=y,1)}function On(a,u,g,y,x){for(let k=0,D=y*x;k<y;++k)a(u,g,k,k+D,y)}function mc(a){const u=Math.floor(a);if(u===a)return pc(a);const g=a-u,y=2*a+1;return(x,k,D,Q,M)=>{if(!((Q-=M)>=D))return;let b=u*k[D];const T=M*u,O=T+M;for(let z=D,W=D+T;z<W;z+=M)b+=k[Math.min(Q,z)];for(let z=D,W=Q;z<=W;z+=M)b+=k[Math.min(Q,z+T)],x[z]=(b+g*(k[Math.max(D,z-O)]+k[Math.min(Q,z+O)]))/y,b-=k[Math.max(D,z-T)]}}function pc(a){const u=2*a+1;return(g,y,x,k,D)=>{if(!((k-=D)>=x))return;let Q=a*y[x];const M=D*a;for(let b=x,T=x+M;b<T;b+=D)Q+=y[Math.min(k,b)];for(let b=x,T=k;b<=T;b+=D)Q+=y[Math.min(k,b+M)],g[b]=Q/u,Q-=y[Math.max(x,b-M)]}}function gc(a,u){let g=0;for(let y of a)y!=null&&(y=+y)>=y&&++g;return g}function yc(a,u,g){let y;for(;;){const x=xu(a,u,g);if(x===y||x===0||!isFinite(x))return[a,u];x>0?(a=Math.floor(a/x)*x,u=Math.ceil(u/x)*x):x<0&&(a=Math.ceil(a*x)/x,u=Math.floor(u*x)/x),y=x}}function xc(a){return Math.max(1,Math.ceil(Math.log(gc(a))/Math.LN2)+1)}var wc=Array.prototype,rl=wc.slice;function vc(a,u){return a-u}function bc(a){for(var u=0,g=a.length,y=a[g-1][1]*a[0][0]-a[g-1][0]*a[0][1];++u<g;)y+=a[u-1][1]*a[u][0]-a[u-1][0]*a[u][1];return y}const sn=a=>()=>a;function kc(a,u){for(var g=-1,y=u.length,x;++g<y;)if(x=Cc(a,u[g]))return x;return 0}function Cc(a,u){for(var g=u[0],y=u[1],x=-1,k=0,D=a.length,Q=D-1;k<D;Q=k++){var M=a[k],b=M[0],T=M[1],O=a[Q],z=O[0],W=O[1];if(Ec(M,O,u))return 0;T>y!=W>y&&g<(z-b)*(y-T)/(W-T)+b&&(x=-x)}return x}function Ec(a,u,g){var y;return Sc(a,u,g)&&Mc(a[y=+(a[0]===u[0])],g[y],u[y])}function Sc(a,u,g){return(u[0]-a[0])*(g[1]-a[1])===(g[0]-a[0])*(u[1]-a[1])}function Mc(a,u,g){return a<=u&&u<=g||g<=u&&u<=a}function Bc(){}var Ur=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Di(){var a=1,u=1,g=xc,y=M;function x(b){var T=g(b);if(Array.isArray(T))T=T.slice().sort(vc);else{const O=wu(b,Dc);for(T=Ko(...yc(O[0],O[1],T),T);T[T.length-1]>=O[1];)T.pop();for(;T[1]<O[0];)T.shift()}return T.map(O=>k(b,O))}function k(b,T){const O=T==null?NaN:+T;if(isNaN(O))throw new Error(`invalid value: ${T}`);var z=[],W=[];return D(b,O,function(V){y(V,b,O),bc(V)>0?z.push([V]):W.push(V)}),W.forEach(function(V){for(var J=0,iA=z.length,eA;J<iA;++J)if(kc((eA=z[J])[0],V)!==-1){eA.push(V);return}}),{type:"MultiPolygon",value:T,coordinates:z}}function D(b,T,O){var z=new Array,W=new Array,V,J,iA,eA,Z,aA;for(V=J=-1,eA=pn(b[0],T),Ur[eA<<1].forEach(cA);++V<a-1;)iA=eA,eA=pn(b[V+1],T),Ur[iA|eA<<1].forEach(cA);for(Ur[eA<<0].forEach(cA);++J<u-1;){for(V=-1,eA=pn(b[J*a+a],T),Z=pn(b[J*a],T),Ur[eA<<1|Z<<2].forEach(cA);++V<a-1;)iA=eA,eA=pn(b[J*a+a+V+1],T),aA=Z,Z=pn(b[J*a+V+1],T),Ur[iA|eA<<1|Z<<2|aA<<3].forEach(cA);Ur[eA|Z<<3].forEach(cA)}for(V=-1,Z=b[J*a]>=T,Ur[Z<<2].forEach(cA);++V<a-1;)aA=Z,Z=pn(b[J*a+V+1],T),Ur[Z<<2|aA<<3].forEach(cA);Ur[Z<<3].forEach(cA);function cA(RA){var sA=[RA[0][0]+V,RA[0][1]+J],lA=[RA[1][0]+V,RA[1][1]+J],BA=Q(sA),SA=Q(lA),bA,kA;(bA=W[BA])?(kA=z[SA])?(delete W[bA.end],delete z[kA.start],bA===kA?(bA.ring.push(lA),O(bA.ring)):z[bA.start]=W[kA.end]={start:bA.start,end:kA.end,ring:bA.ring.concat(kA.ring)}):(delete W[bA.end],bA.ring.push(lA),W[bA.end=SA]=bA):(bA=z[SA])?(kA=W[BA])?(delete z[bA.start],delete W[kA.end],bA===kA?(bA.ring.push(lA),O(bA.ring)):z[kA.start]=W[bA.end]={start:kA.start,end:bA.end,ring:kA.ring.concat(bA.ring)}):(delete z[bA.start],bA.ring.unshift(sA),z[bA.start=BA]=bA):z[BA]=W[SA]={start:BA,end:SA,ring:[sA,lA]}}}function Q(b){return b[0]*2+b[1]*(a+1)*4}function M(b,T,O){b.forEach(function(z){var W=z[0],V=z[1],J=W|0,iA=V|0,eA=ys(T[iA*a+J]);W>0&&W<a&&J===W&&(z[0]=_i(W,ys(T[iA*a+J-1]),eA,O)),V>0&&V<u&&iA===V&&(z[1]=_i(V,ys(T[(iA-1)*a+J]),eA,O))})}return x.contour=k,x.size=function(b){if(!arguments.length)return[a,u];var T=Math.floor(b[0]),O=Math.floor(b[1]);if(!(T>=0&&O>=0))throw new Error("invalid size");return a=T,u=O,x},x.thresholds=function(b){return arguments.length?(g=typeof b=="function"?b:Array.isArray(b)?sn(rl.call(b)):sn(b),x):g},x.smooth=function(b){return arguments.length?(y=b?M:Bc,x):y===M},x}function Dc(a){return isFinite(a)?a:NaN}function pn(a,u){return a==null?!1:+a>=u}function ys(a){return a==null||isNaN(a=+a)?-1/0:a}function _i(a,u,g,y){const x=y-u,k=g-u,D=isFinite(x)||isFinite(k)?x/k:Math.sign(x)/Math.sign(k);return isNaN(D)?a:a+D-.5}function _c(a){return a[0]}function jc(a){return a[1]}function Rc(){return 1}function Tc(){var a=_c,u=jc,g=Rc,y=960,x=500,k=20,D=2,Q=k*3,M=y+Q*2>>D,b=x+Q*2>>D,T=sn(20);function O(Z){var aA=new Float32Array(M*b),cA=Math.pow(2,-D),RA=-1;for(const FA of Z){var sA=(a(FA,++RA,Z)+Q)*cA,lA=(u(FA,RA,Z)+Q)*cA,BA=+g(FA,RA,Z);if(BA&&sA>=0&&sA<M&&lA>=0&&lA<b){var SA=Math.floor(sA),bA=Math.floor(lA),kA=sA-SA-.5,vA=lA-bA-.5;aA[SA+bA*M]+=(1-kA)*(1-vA)*BA,aA[SA+1+bA*M]+=kA*(1-vA)*BA,aA[SA+1+(bA+1)*M]+=kA*vA*BA,aA[SA+(bA+1)*M]+=(1-kA)*vA*BA}}return hc({data:aA,width:M,height:b},k*cA),aA}function z(Z){var aA=O(Z),cA=T(aA),RA=Math.pow(2,2*D);return Array.isArray(cA)||(cA=Ko(Number.MIN_VALUE,Ei(aA)/RA,cA)),Di().size([M,b]).thresholds(cA.map(sA=>sA*RA))(aA).map((sA,lA)=>(sA.value=+cA[lA],W(sA)))}z.contours=function(Z){var aA=O(Z),cA=Di().size([M,b]),RA=Math.pow(2,2*D),sA=lA=>{lA=+lA;var BA=W(cA.contour(aA,lA*RA));return BA.value=lA,BA};return Object.defineProperty(sA,"max",{get:()=>Ei(aA)/RA}),sA};function W(Z){return Z.coordinates.forEach(V),Z}function V(Z){Z.forEach(J)}function J(Z){Z.forEach(iA)}function iA(Z){Z[0]=Z[0]*Math.pow(2,D)-Q,Z[1]=Z[1]*Math.pow(2,D)-Q}function eA(){return Q=k*3,M=y+Q*2>>D,b=x+Q*2>>D,z}return z.x=function(Z){return arguments.length?(a=typeof Z=="function"?Z:sn(+Z),z):a},z.y=function(Z){return arguments.length?(u=typeof Z=="function"?Z:sn(+Z),z):u},z.weight=function(Z){return arguments.length?(g=typeof Z=="function"?Z:sn(+Z),z):g},z.size=function(Z){if(!arguments.length)return[y,x];var aA=+Z[0],cA=+Z[1];if(!(aA>=0&&cA>=0))throw new Error("invalid size");return y=aA,x=cA,eA()},z.cellSize=function(Z){if(!arguments.length)return 1<<D;if(!((Z=+Z)>=1))throw new Error("invalid cell size");return D=Math.floor(Math.log(Z)/Math.LN2),eA()},z.thresholds=function(Z){return arguments.length?(T=typeof Z=="function"?Z:Array.isArray(Z)?sn(rl.call(Z)):sn(Z),z):T},z.bandwidth=function(Z){if(!arguments.length)return Math.sqrt(k*(k+1));if(!((Z=+Z)>=0))throw new Error("invalid bandwidth");return k=(Math.sqrt(4*Z*Z+1)-1)/2,eA()},z}function Rs(){const a=wa();return R.useMemo(()=>va.getPackets(),[a])}function j0({label:a,icon:u,status:g,detail:y}){return m.jsxs("div",{className:Cn("flex items-center gap-3 py-3 px-4 radius-inset transition-base",g==="active"&&"bg-sys-blue/10",g==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",g==="pending"&&"opacity-40"),children:[m.jsx("div",{className:Cn("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",g==="active"&&"bg-sys-blue/20",g==="complete"&&"bg-sys-blue/20",g==="pending"&&"bg-subtle-fill"),children:g==="complete"?m.jsx(Yn,{className:"w-4 h-4 text-sys-blue"}):g==="active"?m.jsx(q0,{className:"w-4 h-4 animate-spin text-sys-blue"}):m.jsx("span",{className:"text-fg-muted",children:u})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:Cn("text-sm font-medium transition-colors",g==="active"&&"text-sys-blue",g==="complete"&&"text-sys-blue",g==="pending"&&"text-fg-muted"),children:a}),y&&g!=="pending"&&m.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:y})]})]})}function Ic({isOpen:a,onClose:u}){const{packetCacheState:g,triggerDeepAnalysis:y}=ba(),x=ka(),k=Ca(),D=g.packetCount,[Q,M]=R.useState("fetching");R.useEffect(()=>{a&&y()},[a,y]),R.useEffect(()=>{if(a){if(g.isTopologyLoading)M("fetching");else if(x)M("analyzing"),setTimeout(()=>M("building"),500),setTimeout(()=>M("discovering"),1e3);else if(k>0&&!g.isTopologyLoading){M("complete");const V=setTimeout(()=>{u()},1500);return()=>clearTimeout(V)}}},[a,g.isTopologyLoading,x,k,u]);const b=Q==="complete",T=g.loadProgress,O=R.useMemo(()=>{if(T&&T.target>0){const V=(T.loaded/1e3).toFixed(1),J=(T.target/1e3).toFixed(1);return`Loading... ${V}k / ${J}k packets (${T.percent}%)`}return D>0?`${D.toLocaleString()} packets loaded`:"Connecting to database..."},[T,D]),z=V=>{const J=["fetching","analyzing","building","discovering","complete"],iA=J.indexOf(Q),eA=J.indexOf(V);return eA<iA?"complete":eA===iA?"active":"pending"},W=b?u:()=>{};return m.jsx(Eo,{open:a,onClose:W,size:"sm",bottomSheet:!1,children:m.jsx(Ea,{isLoading:!b,borderRadius:16,children:m.jsx(So,{className:"p-6 radius-card overflow-hidden",children:b?m.jsxs("div",{className:"flex flex-col items-center py-6",children:[m.jsx(qt.div,{variants:au,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:m.jsx(Yn,{className:"w-8 h-8 text-sys-blue"})}),m.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),m.jsx("button",{onClick:u,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[m.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:m.jsx(Bs,{className:"w-5 h-5 text-sys-blue"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),m.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(j0,{label:"Fetching Packets",icon:m.jsx(Mo,{className:"w-4 h-4"}),status:z("fetching"),detail:O}),m.jsx(j0,{label:"Analyzing Database",icon:m.jsx(Sa,{className:"w-4 h-4"}),status:z("analyzing"),detail:"Processing packet paths"}),m.jsx(j0,{label:"Building Topology",icon:m.jsx(Bs,{className:"w-4 h-4"}),status:z("building"),detail:"Computing mesh edges"}),m.jsx(j0,{label:"Discovering Nodes",icon:m.jsx(el,{className:"w-4 h-4"}),status:z("discovering"),detail:"Viterbi HMM ghost detection"})]}),m.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const Lc=R.memo(Ic),nl=16,Ts=24,Nc=nl,Fc=5,bn={nodeFill:ur.blue,nodeStroke:"rgba(255,255,255,0.9)",nodeColor:ur.indigo,localColor:ur.amber,hubColor:ur.purple,gatewayColor:ur.indigo,mobileColor:ur.orange,roomServerColor:ur.pink,neighborColor:ur.amber,edges:{rest:vn[700],restBright:vn[600],restDim:vn[800],hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:vn[400],hoverNeighbor:ur.amber,neighborRest:vn[500],neighborHover:ur.amber,highlight:"#FFD700"},edgeOpacity:.82};function Ks(){if(typeof window>"u")return bn;const a=J0(),u=Bo();return{nodeFill:a.nodeFill,nodeStroke:a.nodeStroke,nodeColor:bn.nodeColor,localColor:a.localColor,hubColor:a.hubColor,gatewayColor:a.gatewayColor,mobileColor:a.mobileColor,roomServerColor:a.roomColor,neighborColor:a.neighborColor,edges:{rest:u.rest,restBright:u.restBright,restDim:u.restDim,hoverDirect:u.hoverDirect,hoverLoop:u.hoverLoop,hoverStandard:u.hoverStandard,hoverNeighbor:u.hoverNeighbor,neighborRest:bn.edges.neighborRest,neighborHover:bn.edges.neighborHover,highlight:u.highlight},edgeOpacity:bn.edgeOpacity}}const R0=2e3,T0=750,Pc="#00FF00",Qc=500,ji=500,Ri=250,Oc=150,sl=200,zc=En.snappy;function zn({color:a,ring:u}){const g=Nc-2;return m.jsx("span",{className:"shrink-0 rounded-full","aria-hidden":"true",style:{width:g,height:g,backgroundColor:u?"transparent":a,border:u?`${Fc-1}px solid ${a}`:void 0,boxSizing:"border-box"}})}function xs({color:a,pattern:u="solid"}){return m.jsx("svg",{className:"shrink-0","aria-hidden":"true",width:18,height:6,viewBox:"0 0 18 6",children:m.jsx("line",{x1:0,y1:3,x2:18,y2:3,stroke:a,strokeWidth:3,strokeLinecap:"round",strokeDasharray:u==="dashed"?"5,3":u==="dotted"?"2,3":void 0})})}function ar({indicator:a,label:u,tooltip:g}){return m.jsxs("div",{className:"flex items-center gap-1.5",children:[a,m.jsx("span",{className:"text-fg-secondary",children:u}),g&&m.jsx(jo,{content:g,delay:sl,children:m.jsx("span",{className:"cursor-help text-[11px] text-fg-muted opacity-75 hover:opacity-100 transition-opacity",children:"ⓘ"})})]})}function Hc(a){return`legend-section-${a.toLowerCase().replace(/\s+/g,"-")}`}function ws({title:a,tooltip:u,isOpen:g,onToggle:y,showDivider:x,children:k}){const D=Hc(a);return m.jsxs("div",{className:x?"mt-2 pt-2 border-t border-edge-subtle":"",children:[m.jsxs("button",{type:"button",onClick:y,"aria-expanded":g,"aria-controls":D,className:"group w-full flex items-center justify-between py-1 min-h-[44px] sm:min-h-0 font-medium text-fg-secondary hover:text-fg-primary transition-colors",children:[m.jsxs("span",{className:"flex items-center gap-1",children:[a,m.jsx(jo,{content:u,delay:sl,children:m.jsx("span",{className:"cursor-help text-[11px] text-fg-muted opacity-75 group-hover:opacity-100 transition-opacity",children:"ⓘ"})})]}),m.jsx(qt.span,{animate:{rotate:g?0:-90},transition:{duration:.15},"aria-hidden":"true",children:m.jsx(Ro,{className:"w-3 h-3 text-fg-muted"})})]}),m.jsx(Sr,{initial:!1,children:g&&m.jsx(qt.div,{id:D,role:"region","aria-label":a,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:zc,className:"overflow-hidden",children:m.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:k})})})]})}function Ti({label:a,value:u,color:g}){return m.jsxs("div",{className:"flex justify-between tabular-nums text-fg-muted",children:[m.jsx("span",{children:a}),m.jsx("span",{className:g?"":"text-fg-secondary",style:g?{color:g}:void 0,children:u})]})}function Ii({icon:a,color:u,title:g,subtitle:y}){return m.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-edge-subtle",children:m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"shrink-0",style:{color:u},children:a}),m.jsxs("div",{className:"flex flex-col min-w-0",children:[m.jsx("span",{className:"font-medium truncate",style:{color:u},children:g}),m.jsx("span",{className:"text-[10px] leading-tight text-fg-muted",children:y})]})]})})}function Gc(a){return a.some(([,u])=>{var y;const g=(y=u.contact_type)==null?void 0:y.toLowerCase();return g==="room server"||g==="room_server"||g==="room"||g==="server"})}function Uc(a){let u=0;for(const g of a.txDelayRecommendations.values())g.networkRole==="backbone"&&u++;return u}function Vc({showTopology:a,validatedPolylineCount:u,filteredNeighborCount:g,hasLocalNode:y,meshTopology:x,zeroHopNeighbors:k,neighborsWithLocation:D,basemapMode:Q="dark"}){const M=Ma(),b=Ba(),T=Da(),O=b.filter(cA=>cA.isLikelyReal).length,z=Uc(x),W=k.size>0,[V,J]=R.useState(!0),[iA,eA]=R.useState(!0),[Z,aA]=R.useState(!0);return m.jsxs("div",{className:"map-control-surface p-2.5 text-xs",children:[m.jsxs(ws,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:V,onToggle:()=>J(cA=>!cA),children:[m.jsx(ar,{indicator:m.jsx(zn,{color:M.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),m.jsx(ar,{indicator:m.jsx(zn,{color:M.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),Gc(D)&&m.jsx(ar,{indicator:m.jsx(_a,{className:"w-3 h-3 shrink-0",style:{color:M.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."}),m.jsx(ar,{indicator:m.jsx(fu,{className:"w-3 h-3 shrink-0",style:{color:M.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running pyMC_Repeater."}),W&&m.jsx(ar,{indicator:m.jsx(zn,{color:M.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),x.gatewayNodes.length>0&&m.jsx(ar,{indicator:m.jsx(zn,{color:M.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),z>0&&m.jsx(ar,{indicator:m.jsx(zn,{color:M.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),x.mobileNodes.length>0&&m.jsx(ar,{indicator:m.jsx(zn,{color:M.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),O>0&&m.jsx(ar,{indicator:m.jsx(el,{className:"w-3 h-3 shrink-0",style:{color:M.ghostColor},strokeWidth:2.5}),label:`Ghost (${O})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),W&&m.jsxs(ws,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:iA,onToggle:()=>eA(cA=>!cA),showDivider:!0,children:[m.jsx(ar,{indicator:m.jsx(xs,{color:V0.YELLOW,pattern:"solid"}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),m.jsx(ar,{indicator:m.jsx(xs,{color:V0.GREEN,pattern:"dashed"}),label:"Listener",tooltip:">67% listener. They hear us well."}),m.jsx(ar,{indicator:m.jsx(xs,{color:V0.RED,pattern:"dotted"}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),a&&u>0&&m.jsxs(ws,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:Z,onToggle:()=>aA(cA=>!cA),showDivider:!0,children:[m.jsx(Ti,{label:"Nodes",value:g+(y?1:0)}),x.hubNodes.length>0&&m.jsx(Ti,{label:"Hubs",value:x.hubNodes.length,color:bn.hubColor}),x.loops.length>0&&m.jsx(Ii,{icon:m.jsx(Do,{className:"w-3 h-3"}),color:bn.edges.hoverLoop,title:`${x.loops.length} ${x.loops.length===1?"Loop":"Loops"}`,subtitle:"Redundant paths"}),T.totalPaths>0&&m.jsx(Ii,{icon:m.jsx(_o,{className:"w-3 h-3"}),color:M.ghostColor,title:`${T.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]})}const Li={repeater:"blue",companion:"cyan",room_server:"pink",hubs:"indigo",direct:"green"},I0={repeater:"Repeaters",companion:"Companions",room_server:"Rooms",hubs:"Hubs",direct:"Direct"},Ni={repeater:"Repeater nodes (mesh relays)",companion:"Companion devices (clients)",room_server:"Room server nodes",hubs:"Hub nodes and their connections",direct:"Zero-hop (direct RF) neighbors"},Wc=["repeater","companion","room_server"],Fi=["hubs","direct"],Hn="!p-2.5 sm:!p-1.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",L0="!p-2.5 sm:!p-1.5 !rounded-none min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",Yc=()=>typeof window>"u"?!1:window.innerWidth<640;function Kc({mapRef:a,showNeighborLines:u,onToggleNeighborLines:g,hasNeighborPolylines:y,nodeFilters:x,onToggleFilter:k,onToggleAll:D,filterCounts:Q,showCoverage:M,onToggleCoverage:b,showMinCut:T=!1,onToggleMinCut:O,hasMinCutData:z=!1,show3DTerrain:W,onToggle3DTerrain:V,basemapMode:J,onToggleBasemap:iA,isFullscreen:eA,onToggleFullscreen:Z,showLinkQuality:aA=!1,onToggleLinkQuality:cA,hasTraceLinks:RA=!1}){const[sA,lA]=R.useState(()=>!Yc()),BA=()=>{var IA,WA;(WA=(IA=a.current)==null?void 0:IA.getMap())==null||WA.zoomIn()},SA=()=>{var IA,WA;(WA=(IA=a.current)==null?void 0:IA.getMap())==null||WA.zoomOut()},bA=()=>{var WA;const IA=(WA=a.current)==null?void 0:WA.getMap();IA&&IA.easeTo({bearing:0,pitch:0,duration:300})},kA="w-4 h-4",vA=J==="light"?"#525252":"var(--fg-secondary)",FA=x.length>=y0.length;return m.jsx(m.Fragment,{children:m.jsxs("div",{className:"absolute top-3 right-3 z-[600] flex flex-col gap-2 sm:top-4 sm:right-4 max-w-[calc(100vw-1.5rem)] sm:max-w-none pr-[env(safe-area-inset-right)] pointer-events-none",children:[m.jsxs("div",{className:"map-control-surface flex flex-nowrap items-center gap-0.5 sm:gap-1 p-1 overflow-hidden pointer-events-auto",children:[y&&m.jsx(Ft,{plain:!0,color:u?"warning":"muted",onClick:g,title:u?"Hide edge lines":"Show edge lines","aria-label":u?"Hide edge lines":"Show edge lines","aria-pressed":u,className:Hn,"data-tint":u?"warning":void 0,children:m.jsx(ja,{className:kA})}),m.jsx(Ft,{plain:!0,color:"muted",onClick:()=>lA(IA=>!IA),title:sA?"Hide node filters":"Show node filters","aria-label":sA?"Collapse node filters":"Expand node filters","aria-expanded":sA,className:Hn,children:m.jsx(mu,{className:kA})}),m.jsx(Sr,{initial:!1,children:sA&&m.jsxs(qt.div,{className:"flex items-center gap-0.5 flex-nowrap overflow-x-auto scrollbar-none max-w-[50vw] sm:max-w-none sm:overflow-visible",role:"group","aria-label":"Node type filters",initial:{width:0,opacity:0},animate:{width:"auto",opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},children:[m.jsx(ps,{color:FA?"green":"zinc",customColor:FA?void 0:vA,onClick:D,title:"Show all nodes","aria-pressed":FA,"aria-label":"Show all node types",className:"shrink-0",children:"All"}),Wc.map(IA=>{const WA=Q[IA];if(WA===0)return null;const wA=!FA&&x.includes(IA);return m.jsx(ps,{color:wA?Li[IA]:"zinc",customColor:wA?void 0:vA,onClick:()=>k(IA),title:Ni[IA],"aria-pressed":wA,"aria-label":`${I0[IA]} (${WA})`,className:"shrink-0",children:I0[IA]},IA)}),Fi.some(IA=>Q[IA]>0)&&m.jsx("span",{className:"mx-0.5 h-3 w-px bg-[var(--map-ui-border,var(--edge-subtle))] hidden sm:block shrink-0","aria-hidden":"true"}),Fi.map(IA=>{const WA=Q[IA];if(WA===0)return null;const wA=!FA&&x.includes(IA);return m.jsx(ps,{color:wA?Li[IA]:"zinc",customColor:wA?void 0:vA,onClick:()=>k(IA),title:Ni[IA],"aria-pressed":wA,"aria-label":`${I0[IA]} (${WA})`,className:"shrink-0",children:I0[IA]},IA)})]})}),z&&O&&m.jsx(Ft,{plain:!0,color:T?"primary":"muted",onClick:O,title:T?"Hide community partition":"Show community partition","aria-label":T?"Hide community partition":"Show community partition","aria-pressed":T,className:Hn,"data-tint":T?"primary":void 0,children:m.jsx(_s,{className:kA})}),m.jsx(Ft,{plain:!0,color:J==="light"?"primary":"muted",onClick:iA,title:J==="light"?"Switch to dark map":"Switch to light map","aria-label":J==="light"?"Switch to dark map":"Switch to light map","aria-pressed":J==="light",className:Hn,"data-tint":J==="light"?"primary":void 0,children:J==="light"?m.jsx(Us,{className:kA}):m.jsx(Vs,{className:kA})}),m.jsx(Ft,{plain:!0,color:W?"success":"muted",onClick:V,title:W?"Disable 3D terrain":"Enable 3D terrain","aria-label":W?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":W,className:Hn,"data-tint":W?"success":void 0,children:m.jsx(Xu,{className:kA})}),m.jsx(Ft,{plain:!0,color:"muted",onClick:Z,title:eA?"Exit fullscreen":"Fullscreen","aria-label":eA?"Exit fullscreen":"Enter fullscreen","aria-pressed":eA,className:Hn,children:eA?m.jsx(uu,{className:kA}):m.jsx(cu,{className:kA})})]}),m.jsxs("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0 pointer-events-auto",children:[m.jsx(Ft,{plain:!0,color:"muted",onClick:BA,title:"Zoom in","aria-label":"Zoom in",className:L0,children:m.jsx(pu,{className:kA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Ft,{plain:!0,color:"muted",onClick:SA,title:"Zoom out","aria-label":"Zoom out",className:L0,children:m.jsx(To,{className:kA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Ft,{plain:!0,color:"muted",onClick:bA,title:"Reset bearing to north","aria-label":"Reset bearing to north",className:L0,children:m.jsx(gu,{className:kA})})]}),RA&&cA&&m.jsx("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0 pointer-events-auto",children:m.jsx(Ft,{plain:!0,color:aA?"success":"muted",onClick:cA,title:aA?"Hide link quality overlay":"Show link quality overlay","aria-label":aA?"Hide link quality overlay":"Show link quality overlay","aria-pressed":aA,className:L0,"data-tint":aA?"success":void 0,children:m.jsx(tl,{className:kA})})})]})})}const $c="#4ADE80",Zc="#16A34A",qc="rgba(10, 26, 10, 1)",Jc="rgba(220, 252, 231, 1)",gn="DeepAnalysis",Xc=700,Pi="abcdefghijklmnopqrstuvwxyz0123456789";function Af(){return Pi[Math.floor(Math.random()*Pi.length)]}function ef({isActive:a,hasAnalyzed:u,isLoading:g,onClick:y,basemapMode:x="dark"}){const k=x==="light",D=k?Zc:$c,[Q,M]=R.useState(!1),[b,T]=R.useState(gn),O=R.useRef(!1),z=R.useRef(null),[W]=R.useState(()=>{var eA;return typeof window<"u"&&(((eA=window.matchMedia)==null?void 0:eA.call(window,"(hover: hover)").matches)??!1)}),V=Q&&!a&&!g&&W;R.useEffect(()=>{if(Q&&!a&&!g&&!O.current){O.current=!0;const eA=performance.now(),Z=aA=>{const cA=aA-eA,RA=Math.min(cA/Xc,1),sA=Math.floor(RA*gn.length);let lA="";for(let BA=0;BA<gn.length;BA++)BA<sA?lA+=gn[BA]:gn[BA]===" "?lA+=" ":lA+=Af();T(lA),RA<1?z.current=requestAnimationFrame(Z):T(gn)};z.current=requestAnimationFrame(Z)}return Q||(z.current&&(cancelAnimationFrame(z.current),z.current=null),O.current=!1,T(gn)),()=>{z.current&&cancelAnimationFrame(z.current)}},[Q,a,g]);const J=g?"Analyzing...":b,iA=g?"Analyzing packet history":u?a?"Hide topology edges":"Show topology edges":"Load full packet history and build topology";return m.jsxs("button",{onClick:y,onMouseEnter:()=>W&&M(!0),onMouseLeave:()=>W&&M(!1),onPointerEnter:()=>W&&M(!0),onPointerLeave:()=>W&&M(!1),disabled:g,className:`map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base ${g?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",...a&&{backgroundColor:k?Jc:qc}},title:iA,"aria-label":iA,"aria-pressed":a,children:[g?m.jsx(q0,{className:"w-3.5 h-3.5 shrink-0 animate-spin",style:{color:D}}):m.jsx(Bs,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${a?"":"text-fg-secondary"}`,style:{...a&&{color:D},...V&&{color:D}}}),m.jsx("span",{className:`${a?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:a||V?700:500,letterSpacing:"-0.01em",lineHeight:1,...a&&{color:D},...V&&{color:D}},children:J})]})}const tf=ur.teal,rf="#0D7377",nf="rgba(10, 36, 32, 1)",sf="rgba(204, 251, 241, 1)",Qi="LiveTrace",of=400,Oi=100;function lf({isActive:a,onClick:u,basemapMode:g="dark"}){const y=g==="light",x=y?rf:tf,[k,D]=R.useState(!1),[Q,M]=R.useState(0),b=R.useRef(!1),T=R.useRef(null),[O,z]=R.useState(0),W=R.useRef(!1),[V]=R.useState(()=>{var Z;return typeof window<"u"&&(((Z=window.matchMedia)==null?void 0:Z.call(window,"(hover: hover)").matches)??!1)}),J=k&&!a&&V;R.useEffect(()=>{J&&!W.current&&(W.current=!0,z(1),setTimeout(()=>z(2),Oi),setTimeout(()=>z(3),Oi*2)),k||(W.current=!1,z(0))},[J,k]),R.useEffect(()=>{if(k&&!a&&!b.current){b.current=!0;const Z=performance.now(),aA=cA=>{const RA=cA-Z,sA=Math.min(RA/of,1);M(sA),sA<1&&(T.current=requestAnimationFrame(aA))};T.current=requestAnimationFrame(aA)}return k||(T.current&&(cancelAnimationFrame(T.current),T.current=null),b.current=!1,M(0)),()=>{T.current&&cancelAnimationFrame(T.current)}},[k,a]);const iA=Z=>{if(a)return x;if(!J)return;const aA=Qi.length,cA=Q*(aA+2);return Z>=cA-2&&Z<cA?"#FFFFFF":x},eA=a?"Disable live packet tracing":"Enable live packet tracing";return m.jsxs("button",{onClick:u,onMouseEnter:()=>V&&D(!0),onMouseLeave:()=>V&&D(!1),onPointerEnter:()=>V&&D(!0),onPointerLeave:()=>V&&D(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...a&&{backgroundColor:y?sf:nf}},title:a?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing","aria-label":eA,"aria-pressed":a,children:[m.jsx(yu,{className:`w-3.5 h-3.5 shrink-0 ${a?"":"text-fg-secondary"}`,fill:O===1?"#FFFFFF":O===3?x:"none",stroke:O===1||O===2?"#FFFFFF":a||J?x:"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),m.jsx("span",{className:`${a?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:a||J?700:500,letterSpacing:"-0.01em",lineHeight:1},children:Qi.split("").map((Z,aA)=>m.jsx("span",{style:{color:iA(aA)||void 0},children:Z},aA))})]})}const zi=.2,af="rgba(26, 20, 8, 1)",uf="rgba(254, 243, 199, 1)",vs=.01,bs=1,Hi="#fe8019",cf="'Wardrive', serif",Is=1.45,ff=Is*1.1,hf=80;function df({isActive:a,onClick:u,brightness:g=.7,onBrightnessChange:y,basemapMode:x="dark"}){const k=x==="light",[D,Q]=R.useState(!1),[M,b]=R.useState(!1),[T]=R.useState(()=>{var Z;return typeof window<"u"&&(((Z=window.matchMedia)==null?void 0:Z.call(window,"(hover: hover)").matches)??!1)});R.useEffect(()=>{if(!D||a)return;const Z=requestAnimationFrame(()=>b(!0)),aA=setTimeout(()=>b(!1),hf);return()=>{cancelAnimationFrame(Z),clearTimeout(aA)}},[D,a]);const O=Math.max(vs,Math.min(bs,g)),z=Z=>{Z.stopPropagation();const aA=Math.min(bs,O+zi);y==null||y(aA)},W=Z=>{Z.stopPropagation();const aA=Math.max(vs,O-zi);y==null||y(aA)},V=O<bs-.001,J=O>vs+.001,iA=D&&!a&&T,eA=a?"Configure wardriving coverage":"Show wardriving coverage";return m.jsxs("button",{onClick:u,onMouseEnter:()=>T&&Q(!0),onMouseLeave:()=>T&&Q(!1),onPointerEnter:()=>T&&Q(!0),onPointerLeave:()=>T&&Q(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...a&&{backgroundColor:k?uf:af}},title:eA,"aria-label":eA,"aria-pressed":a,children:[m.jsx(ic,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${a?"text-sys-amber":"text-fg-secondary"}`,style:iA?{color:Hi}:void 0}),m.jsx("span",{className:`${a?"text-sys-amber":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:a||iA?cf:"ui-monospace, SFMono-Regular, monospace",fontSize:a||iA?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:a?`scale(${Is})`:iA?`scale(${M?ff:Is})`:void 0,transformOrigin:"left center",...iA?{color:Hi}:{}},children:"Wardrive"}),a&&y&&m.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m.jsx("button",{onClick:W,disabled:!J,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${J?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:J?void 0:{color:k?"rgba(0, 0, 0, 0.25)":"rgba(251, 191, 36, 0.3)"},title:`Decrease opacity (${Math.round(O*100)}%)`,"aria-label":`Decrease opacity, currently ${Math.round(O*100)}%`,children:m.jsx(Us,{className:"w-3.5 h-3.5"})}),m.jsx("button",{onClick:z,disabled:!V,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${V?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:V?void 0:{color:k?"rgba(0, 0, 0, 0.25)":"rgba(251, 191, 36, 0.3)"},title:`Increase opacity (${Math.round(O*100)}%)`,"aria-label":`Increase opacity, currently ${Math.round(O*100)}%`,children:m.jsx(Vs,{className:"w-3.5 h-3.5"})})]})]})}const mf="0123456789bcdefghjkmnpqrstuvwxyz";function pf(a){let u=!0,g=-90,y=90,x=-180,k=180;for(const D of a.toLowerCase()){const Q=mf.indexOf(D);if(Q!==-1)for(let M=4;M>=0;M--){const b=Q>>M&1;if(u){const T=(x+k)/2;b?x=T:k=T}else{const T=(g+y)/2;b?g=T:y=T}u=!u}}return{lat:(g+y)/2,lon:(x+k)/2}}function gf(a){return Math.exp(-a*Math.LN2/7)}const Ls="pymc-wardriving-url",il="pymc-wardriving-enabled",ol="pymc-wardriving-brightness",Gi=.7;function yf(){return typeof localStorage>"u"?"":localStorage.getItem(Ls)||""}function Ui(a){typeof localStorage>"u"||(a?localStorage.setItem(Ls,a):localStorage.removeItem(Ls))}function xf(){return typeof localStorage>"u"?!1:localStorage.getItem(il)==="true"}function N0(a){typeof localStorage>"u"||localStorage.setItem(il,String(a))}function wf(){if(typeof localStorage>"u")return Gi;const a=localStorage.getItem(ol);if(a){const u=parseFloat(a);if(!isNaN(u)&&u>=.01&&u<=1)return u}return Gi}function vf(a){if(typeof localStorage>"u")return;const u=Math.max(.01,Math.min(1,a));localStorage.setItem(ol,String(u))}const bf=8e3;async function kf(a,u={},g=bf){const y=new AbortController,x=setTimeout(()=>y.abort(),g);try{return await fetch(a,{...u,signal:y.signal})}catch(k){throw k instanceof Error&&k.name==="AbortError"?new Error(`Connection timed out after ${g/1e3}s`):k}finally{clearTimeout(x)}}async function Cf(a){const g=`${a.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,y=await kf(g,{headers:{Accept:"application/json"}});if(!y.ok)throw new Error(`Failed to fetch precise samples: ${y.status}`);return y.json()}function Ef(a,u=null){if(a!==null){const y=(Math.max(-12,Math.min(12,a))+12)/24;if(u!==null){const k=(Math.max(-120,Math.min(-50,u))+120)/70;return y*.8+k*.2}return y}return u!==null?(Math.max(-120,Math.min(-50,u))+120)/70:.5}function Sf(a){var g;const u=[];for(const y of a.keys){if(!y.observed)continue;const{lat:x,lon:k}=pf(y.hash),D=parseInt(y.time,10),Q=isNaN(D)?30:(Date.now()-D)/(1e3*60*60*24),M=gf(Q),T=Ef(y.snr,y.rssi)*(.3+M*.7);u.push({lat:x,lon:k,successRate:y.observed?1:0,weight:T,totalSamples:1,ageDays:Q,geohash:y.hash,repeaters:((g=y.path)==null?void 0:g.map(O=>O.toLowerCase()))||[]})}return u}const x0=Io((a,u)=>({status:"idle",isVisible:xf(),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:yf(),brightness:wf(),isModalOpen:!1,openModal:()=>a({isModalOpen:!0}),closeModal:()=>a({isModalOpen:!1}),setUrl:g=>a({url:g}),setBrightness:g=>{const y=Math.max(.01,Math.min(1,g));vf(y),a({brightness:y})},toggleVisibility:()=>{const g=!u().isVisible;N0(g),a({isVisible:g})},setVisible:g=>{N0(g),a({isVisible:g})},loadCoverage:async g=>{if(!g.trim())return a({error:"Please enter a URL",status:"error"}),!1;try{new URL(g.trim())}catch{return a({error:"Invalid URL format",status:"error"}),!1}a({error:null,status:"connecting"});try{a({status:"loading"});const y=await Cf(g.trim());if(!y||typeof y!="object")throw new Error("Invalid response from server");if(!Array.isArray(y.keys))throw new Error("No sample data found in response");a({status:"processing"});const x=Sf(y);if(x.length===0)throw new Error("No valid coverage points found");return a({coveragePoints:x,repeaters:[],stats:{coverageCount:x.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:g.trim()}),Ui(g.trim()),N0(!0),!0}catch(y){const x=y instanceof Error?y.message:"Failed to load coverage data";let k=x;return x.includes("timed out")?k="Connection timed out. Server may be unreachable or slow.":x.includes("Failed to fetch")||x.includes("NetworkError")?k="Could not connect to server. Check the URL and try again.":x.includes("CORS")?k="Server does not allow cross-origin requests.":x.includes("404")?k="Coverage endpoint not found. Check the URL.":(x.includes("ERR_NAME_NOT_RESOLVED")||x.includes("DNS"))&&(k="Server not found. Check the URL for typos."),a({error:k,status:"error"}),!1}},clearCoverage:()=>{a({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),Ui(""),N0(!1)}})),Mf={bg:"#F8F8F8",bgSubtle:"#F0F0F0",bgElevated:"#FFFFFF",bgInput:"#FFFFFF",border:"rgba(0, 0, 0, 0.12)",borderStrong:"rgba(0, 0, 0, 0.20)",borderFocus:"#3B82F6",text:"#1A1A1A",textSecondary:"#4A4A4A",textMuted:"#737373",success:"#059669",successBg:"#ECFDF5",successBorder:"#A7F3D0",error:"#DC2626",errorBg:"#FEF2F2",errorBorder:"#FECACA",info:"#2563EB",infoBg:"#EFF6FF",infoBorder:"#BFDBFE",warning:"#D97706",warningBg:"#FFFBEB",warningBorder:"#FDE68A",primary:"#F59E0B",hoverBg:"rgba(0, 0, 0, 0.04)",sliderTrack:"#E5E7EB",sliderThumb:"#F59E0B"},ll={bg:"var(--surface)",bgSubtle:"var(--subtle)",bgElevated:"var(--elevated)",bgInput:"var(--subtle)",border:"var(--edge-subtle)",borderStrong:"var(--edge-strong)",borderFocus:"var(--sys-blue)",text:"var(--fg-primary)",textSecondary:"var(--fg-secondary)",textMuted:"var(--fg-muted)",success:"var(--sys-green)",successBg:"rgba(74, 222, 128, 0.1)",successBorder:"rgba(74, 222, 128, 0.3)",error:"var(--sys-red)",errorBg:"rgba(239, 68, 68, 0.1)",errorBorder:"rgba(239, 68, 68, 0.3)",info:"var(--sys-indigo)",infoBg:"rgba(249, 210, 111, 0.1)",infoBorder:"rgba(249, 210, 111, 0.3)",warning:"var(--sys-indigo)",warningBg:"rgba(249, 210, 111, 0.1)",warningBorder:"rgba(249, 210, 111, 0.3)",primary:"var(--sys-indigo)",hoverBg:"var(--hover-tint)",sliderTrack:"var(--elevated)",sliderThumb:"var(--sys-indigo)"},al=R.createContext({theme:ll,isLight:!1});function Mn(){return R.useContext(al)}function Bf({status:a,hasData:u}){const{theme:g,isLight:y}=Mn(),x=R.useMemo(()=>a==="connecting"||a==="loading"||a==="processing"?{icon:m.jsx(q0,{className:"w-3.5 h-3.5 animate-spin"}),label:a==="connecting"?"Connecting...":a==="loading"?"Loading...":"Processing...",color:g.warning,bg:g.warningBg}:a==="error"?{icon:m.jsx(Bu,{className:"w-3.5 h-3.5"}),label:"Disconnected",color:g.error,bg:g.errorBg}:u?{icon:m.jsx(Du,{className:"w-3.5 h-3.5"}),label:"Connected",color:g.success,bg:g.successBg}:{icon:m.jsx(No,{className:"w-3.5 h-3.5"}),label:"Ready",color:g.textMuted,bg:y?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},[a,u,g,y]);return m.jsxs(qt.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium",style:{backgroundColor:x.bg,color:x.color},children:[x.icon,m.jsx("span",{children:x.label})]},x.label)}function Df({status:a}){const{theme:u}=Mn(),g=R.useMemo(()=>{switch(a){case"connecting":return 25;case"loading":return 60;case"processing":return 90;default:return 0}},[a]);return g===0?null:m.jsx(qt.div,{initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},exit:{opacity:0,scaleY:0},className:"h-1 rounded-full overflow-hidden origin-top",style:{backgroundColor:u.sliderTrack},children:m.jsx(qt.div,{className:"h-full rounded-full",style:{backgroundColor:u.primary},initial:{width:0},animate:{width:`${g}%`},transition:{duration:.4,ease:"easeOut"}})})}function Vi({variant:a,title:u,description:g,onDismiss:y}){const{theme:x}=Mn(),k=R.useMemo(()=>{switch(a){case"success":return{icon:m.jsx(Yn,{className:"w-4 h-4"}),color:x.success,bg:x.successBg,border:x.successBorder};case"error":return{icon:m.jsx(_u,{className:"w-4 h-4"}),color:x.error,bg:x.errorBg,border:x.errorBorder};case"info":return{icon:m.jsx(qu,{className:"w-4 h-4"}),color:x.info,bg:x.infoBg,border:x.infoBorder}}},[a,x]);return m.jsxs(qt.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:En.snappy,className:"flex items-start gap-3 p-3 rounded-lg border",style:{backgroundColor:k.bg,borderColor:k.border,color:k.color},children:[m.jsx("div",{className:"shrink-0 mt-0.5",children:k.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-sm font-medium",children:u}),g&&m.jsx("p",{className:"text-xs mt-0.5 opacity-80",children:g})]}),y&&m.jsx("button",{onClick:y,className:"shrink-0 p-1 rounded hover:bg-black/10 transition-colors","aria-label":"Dismiss",children:m.jsx(Sn,{className:"w-3.5 h-3.5"})})]})}function _f({value:a,onChange:u,onSubmit:g,disabled:y}){const{theme:x,isLight:k}=Mn(),[D,Q]=R.useState(!1),M=b=>{b.key==="Enter"&&!b.shiftKey&&!y&&(b.preventDefault(),g())};return m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("label",{className:"block text-sm font-medium",style:{color:x.textSecondary},children:"Coverage Server URL"}),m.jsxs("div",{className:"relative",children:[m.jsx("input",{type:"url",value:a,onChange:b=>u(b.target.value),onKeyDown:M,onFocus:()=>Q(!0),onBlur:()=>Q(!1),placeholder:"https://coverage.wcmesh.com",disabled:y,className:Cn("w-full pl-3 pr-10 py-2.5 rounded-lg border text-sm transition-all duration-150","focus:outline-none",y&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:x.bgInput,borderColor:D?x.borderFocus:x.border,color:x.text,boxShadow:D?`0 0 0 3px ${k?"rgba(59, 130, 246, 0.15)":"rgba(139, 92, 246, 0.15)"}`:"none"}}),a&&!y&&m.jsx("button",{onClick:()=>u(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 rounded transition-colors",style:{color:x.textMuted},onMouseEnter:b=>b.currentTarget.style.color=x.text,onMouseLeave:b=>b.currentTarget.style.color=x.textMuted,"aria-label":"Clear URL",children:m.jsx(Sn,{className:"w-4 h-4"})})]}),m.jsx("p",{className:"text-xs",style:{color:x.textMuted},children:"Press Enter to connect, or use the Connect button below"})]})}function jf({value:a,onChange:u}){const{theme:g,isLight:y}=Mn(),x=Math.round(a*100);return m.jsx(qt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:En.gentle,className:"overflow-hidden",children:m.jsx("div",{className:"p-3 rounded-lg border",style:{backgroundColor:g.bgSubtle,borderColor:g.border},children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs("div",{className:"relative w-4 h-4",children:[m.jsx(Us,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.textMuted,opacity:a<.5?1:0}}),m.jsx(Vs,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.primary,opacity:a>=.5?1:0}})]}),m.jsxs("div",{className:"flex-1",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[m.jsx("span",{className:"text-xs font-medium",style:{color:g.textSecondary},children:"Layer Opacity"}),m.jsxs("span",{className:"text-xs font-mono tabular-nums px-1.5 py-0.5 rounded",style:{color:g.text,backgroundColor:y?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)"},children:[x,"%"]})]}),m.jsx("input",{type:"range",min:5,max:100,value:x,onChange:k=>u(Number(k.target.value)/100),className:Cn("w-full h-2 rounded-full appearance-none cursor-pointer","[&::-webkit-slider-thumb]:appearance-none","[&::-webkit-slider-thumb]:w-4","[&::-webkit-slider-thumb]:h-4","[&::-webkit-slider-thumb]:rounded-full","[&::-webkit-slider-thumb]:cursor-pointer","[&::-webkit-slider-thumb]:transition-transform","[&::-webkit-slider-thumb]:hover:scale-110","[&::-webkit-slider-thumb]:shadow-lg","[&::-moz-range-thumb]:appearance-none","[&::-moz-range-thumb]:w-4","[&::-moz-range-thumb]:h-4","[&::-moz-range-thumb]:rounded-full","[&::-moz-range-thumb]:border-0","[&::-moz-range-thumb]:cursor-pointer"),style:{background:`linear-gradient(to right, ${g.primary} ${x}%, ${g.sliderTrack} ${x}%)`,"--thumb-color":g.sliderThumb}}),m.jsx("style",{children:`
              input[type="range"]::-webkit-slider-thumb {
                background-color: ${g.sliderThumb};
              }
              input[type="range"]::-moz-range-thumb {
                background-color: ${g.sliderThumb};
              }
            `})]})]})})})}function Rf({coverageCount:a,repeaterCount:u,lastUpdated:g}){const{theme:y}=Mn();return m.jsxs("div",{className:"grid grid-cols-3 gap-2 p-3 rounded-lg border",style:{backgroundColor:y.bgSubtle,borderColor:y.border},children:[m.jsxs("div",{className:"text-center",children:[m.jsx(Ci,{value:a,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Points"})]}),m.jsxs("div",{className:"text-center border-x",style:{borderColor:y.border},children:[m.jsx(Ci,{value:u,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Repeaters"})]}),m.jsxs("div",{className:"text-center",children:[m.jsxs("div",{className:"flex items-center justify-center gap-1",children:[m.jsx($o,{className:"w-3.5 h-3.5",style:{color:y.textMuted}}),m.jsx("span",{className:"text-lg font-semibold tabular-nums",style:{color:y.text},children:g?g.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"—"})]}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Updated"})]})]})}function Wi({icon:a,label:u,onClick:g,disabled:y,variant:x="default",active:k}){const{theme:D,isLight:Q}=Mn(),M=R.useMemo(()=>x==="danger"?{text:D.error,hoverBg:Q?"rgba(220, 38, 38, 0.08)":"rgba(239, 68, 68, 0.15)"}:{text:k?D.primary:D.textSecondary,hoverBg:D.hoverBg},[x,k,D,Q]);return m.jsxs("button",{onClick:g,disabled:y,className:Cn("flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-sm font-medium transition-colors",y&&"opacity-50 cursor-not-allowed"),style:{color:M.text},onMouseEnter:b=>!y&&(b.currentTarget.style.backgroundColor=M.hoverBg),onMouseLeave:b=>b.currentTarget.style.backgroundColor="transparent",children:[a,m.jsx("span",{children:u})]})}function Tf(){const a=Lo(),u=a==="light",g=u?Mf:ll,{isModalOpen:y,closeModal:x,status:k,isVisible:D,stats:Q,error:M,url:b,brightness:T,loadCoverage:O,clearCoverage:z,toggleVisibility:W,setUrl:V,setBrightness:J}=x0(),iA=k==="connecting"||k==="loading"||k==="processing",eA=Q.coverageCount>0,[Z,aA]=R.useState(!0),[cA,RA]=R.useState(b);R.useEffect(()=>{RA(b)},[b]),R.useEffect(()=>{k==="error"&&aA(!0)},[k]);const sA=R.useCallback(async()=>{await O(cA)},[cA,O]),lA=R.useCallback(()=>{RA(""),z()},[z]),BA=R.useCallback(kA=>{RA(kA),V(kA)},[V]),SA=R.useCallback(()=>{iA||x()},[iA,x]),bA=cA.trim().length>0&&!iA;return m.jsx(al.Provider,{value:{theme:g,isLight:u},children:m.jsxs(Eo,{open:y,onClose:SA,size:"md",bottomSheet:!0,basemapMode:a,children:[m.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:g.border},children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:g.bgSubtle,color:g.primary},children:m.jsx(No,{className:"w-5 h-5"})}),m.jsxs("div",{children:[m.jsx("h2",{className:"type-micro",style:{color:g.text},children:"Wardriving Coverage"}),m.jsx("p",{className:"text-xs",style:{color:g.textMuted},children:"RF coverage heatmap overlay"})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Bf,{status:k,hasData:eA}),!iA&&m.jsxs(m.Fragment,{children:[m.jsx("button",{onClick:SA,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium transition-base radius-inner active:bg-subtle-fill",style:{color:g.primary},children:"Done"}),m.jsx("button",{onClick:SA,className:"hidden sm:flex items-center justify-center p-2 rounded-lg transition-colors",style:{color:g.textMuted},onMouseEnter:kA=>{kA.currentTarget.style.color=g.text,kA.currentTarget.style.backgroundColor=g.hoverBg},onMouseLeave:kA=>{kA.currentTarget.style.color=g.textMuted,kA.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:m.jsx(Sn,{className:"w-5 h-5"})})]})]})]}),m.jsx(Sr,{children:iA&&m.jsx(Df,{status:k})}),m.jsxs(So,{className:"space-y-4",children:[m.jsx(_f,{value:cA,onChange:BA,onSubmit:sA,disabled:iA}),m.jsx(Sr,{children:k==="error"&&M&&Z&&m.jsx(Vi,{variant:"error",title:"Connection Failed",description:M,onDismiss:()=>aA(!1)})}),m.jsx(Sr,{children:k==="success"&&eA&&m.jsx(Vi,{variant:"success",title:"Coverage Data Loaded",description:"Adjust opacity below, then close to view on map"})}),m.jsx(Sr,{children:eA&&!iA&&m.jsx(qt.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:En.snappy,children:m.jsx(Rf,{coverageCount:Q.coverageCount,repeaterCount:Q.repeaterCount,lastUpdated:Q.lastUpdated})})}),m.jsx(Sr,{children:eA&&!iA&&m.jsx(jf,{value:T,onChange:J})})]}),m.jsxs("div",{className:"flex items-center justify-between p-4 border-t",style:{borderColor:g.border},children:[m.jsx("div",{className:"flex items-center gap-1",children:m.jsx(Sr,{children:eA&&m.jsxs(qt.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:En.snappy,className:"flex items-center gap-1",children:[m.jsx(Wi,{icon:D?m.jsx(vu,{className:"w-4 h-4"}):m.jsx(_o,{className:"w-4 h-4"}),label:D?"Hide":"Show",onClick:W,disabled:iA,active:D}),m.jsx(Wi,{icon:m.jsx(Mu,{className:"w-4 h-4"}),label:"Clear",onClick:lA,disabled:iA,variant:"danger"})]})})}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Ft,{plain:!0,color:"muted",onClick:SA,disabled:iA,children:eA?"Done":"Cancel"}),m.jsx(Ft,{color:"warning",onClick:sA,disabled:!bA,children:iA?m.jsxs(m.Fragment,{children:[m.jsx(q0,{"data-slot":"icon",className:"animate-spin"}),k==="connecting"?"Connecting...":k==="loading"?"Loading...":"Processing..."]}):eA?m.jsxs(m.Fragment,{children:[m.jsx(Do,{"data-slot":"icon"}),"Refresh"]}):m.jsxs(m.Fragment,{children:[m.jsx(Mo,{"data-slot":"icon"}),"Connect"]})})]})]})]})})}const If={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5};function F0({label:a,value:u,min:g,max:y,step:x,unit:k,formatValue:D,onChange:Q}){const M=D?D(u):u.toFixed(2);return m.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[m.jsx("span",{className:"text-xs font-medium w-14 sm:w-16 shrink-0 text-fg-secondary",children:a}),m.jsx("input",{type:"range",min:g,max:y,step:x,value:u,onChange:b=>Q(parseFloat(b.target.value)),className:`flex-1 h-1.5 rounded-full appearance-none cursor-pointer bg-elevated
                   [&::-webkit-slider-thumb]:appearance-none
                   [&::-webkit-slider-thumb]:w-3.5
                   [&::-webkit-slider-thumb]:h-3.5
                   [&::-webkit-slider-thumb]:rounded-full
                   [&::-webkit-slider-thumb]:bg-sys-indigo
                   [&::-webkit-slider-thumb]:cursor-pointer
                   [&::-webkit-slider-thumb]:transition-transform
                   [&::-webkit-slider-thumb]:hover:scale-110
                   [&::-webkit-slider-thumb]:shadow-md`}),m.jsxs("span",{className:"text-xs font-mono tabular-nums w-12 sm:w-14 text-right shrink-0 text-fg-muted",children:[M,k&&m.jsx("span",{className:"ml-0.5 opacity-70",children:k})]})]})}function P0({icon:a,label:u,value:g,subtext:y}){return m.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 py-0.5 sm:py-1",children:[m.jsx("div",{className:"text-fg-muted",children:a}),m.jsx("div",{className:"flex-1 min-w-0",children:m.jsx("div",{className:"text-[10px] sm:text-xs truncate text-fg-secondary",children:u})}),m.jsxs("div",{className:"text-right",children:[m.jsx("div",{className:"text-xs font-mono tabular-nums text-fg-primary",children:g}),y&&m.jsx("div",{className:"text-[9px] leading-tight opacity-70 text-fg-muted",children:y})]})]})}function Lf({visible:a,onClose:u,settings:g,onSettingsChange:y,partition:x,totalNodes:k,basemapMode:D="dark"}){const Q=bu(),M=R.useRef(null),b=R.useMemo(()=>{if(!x)return{numCommunities:0,avgCommunitySize:0,minCommunitySize:0,maxCommunitySize:0,fiedlerValue:0,modularity:0,coveragePercent:0};const z=Array.from(x.communities.values()).map(V=>V.length),W=z.reduce((V,J)=>V+J,0);return{numCommunities:x.numCommunities,avgCommunitySize:z.length>0?Math.round(W/z.length):0,minCommunitySize:z.length>0?Math.min(...z):0,maxCommunitySize:z.length>0?Math.max(...z):0,fiedlerValue:x.fiedlerValue,modularity:0,coveragePercent:k>0?Math.round(W/k*100):0}},[x,k]),T=(z,W)=>{y({...g,[z]:W})},O=(g.bandwidth*111).toFixed(1);return m.jsx("div",{ref:M,className:"absolute inset-0 z-[600] pointer-events-none",children:m.jsx(Sr,{children:a&&m.jsx(qt.div,{drag:!0,dragControls:Q,dragConstraints:M,dragElastic:.1,dragMomentum:!1,initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:En.smooth,className:`
              absolute pointer-events-auto
              /* Mobile: bottom sheet style, full width with margins */
              bottom-2 left-2 right-2
              /* sm+: floating panel in bottom-right */
              sm:bottom-16 sm:left-auto sm:right-3 sm:w-64
              /* md+: slightly wider */
              md:w-72
            `,style:{touchAction:"none"},children:m.jsxs("div",{className:`
              map-control-surface rounded-lg overflow-hidden shadow-lg
              /* Mobile: limit height, allow scroll */
              max-h-[45vh] sm:max-h-[calc(100vh-180px)] overflow-y-auto
              /* iOS momentum scrolling */
              overscroll-contain
            `,children:[m.jsxs("div",{className:`
                  flex items-center justify-between 
                  px-3 py-2 sm:px-2.5 sm:py-1.5 
                  border-b border-edge-subtle
                  cursor-grab active:cursor-grabbing
                  min-h-[44px] sm:min-h-0
                `,onPointerDown:z=>Q.start(z),children:[m.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5",children:[m.jsx(ku,{className:"w-4 h-4 sm:w-3 sm:h-3 text-fg-muted"}),m.jsx(_s,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-blue"}),m.jsx("span",{className:"text-sm sm:text-xs font-medium text-fg-primary",children:"Partition"})]}),m.jsx(Ft,{plain:!0,color:"muted",onClick:u,className:"!p-1.5 sm:!p-0.5 !rounded min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close toolbox",children:m.jsx(Sn,{className:"w-4 h-4 sm:w-3 sm:h-3"})})]}),m.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5 border-b border-edge-subtle",children:m.jsxs("div",{className:"grid grid-cols-2 gap-x-4 sm:gap-x-3 gap-y-1 sm:gap-y-0.5",children:[m.jsx(P0,{icon:m.jsx(_s,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Communities",value:b.numCommunities}),m.jsx(P0,{icon:m.jsx(wi,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Avg Size",value:b.avgCommunitySize,subtext:`${b.minCommunitySize}–${b.maxCommunitySize}`}),m.jsx(P0,{icon:m.jsx(nc,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Fiedler λ₂",value:b.fiedlerValue.toFixed(3)}),m.jsx(P0,{icon:m.jsx(wi,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Coverage",value:`${b.coveragePercent}%`,subtext:`of ${k}`})]})}),m.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5",children:m.jsxs("div",{className:"space-y-3 sm:space-y-1.5",children:[m.jsx(F0,{label:"Bandwidth",value:g.bandwidth,min:.01,max:.15,step:.005,formatValue:()=>O,unit:"km",onChange:z=>T("bandwidth",z)}),m.jsx(F0,{label:"Threshold",value:g.threshold,min:.05,max:.5,step:.01,formatValue:z=>`${Math.round((1-z)*100)}%`,unit:"cov",onChange:z=>T("threshold",z)}),m.jsx(F0,{label:"Opacity",value:g.opacity,min:.1,max:1,step:.05,formatValue:z=>`${Math.round(z*100)}%`,onChange:z=>T("opacity",z)}),m.jsx(F0,{label:"Stroke",value:g.strokeWidth,min:0,max:5,step:.5,unit:"px",formatValue:z=>z.toFixed(1),onChange:z=>T("strokeWidth",z)})]})})]})})})})}const Nf={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-signal-poor",critical:"text-signal-critical"};function w0(a,u){return Nf[Qo(a,u)]}const Ff={backgroundColor:"var(--map-ui-hover, var(--elevated))",color:"var(--map-ui-text, var(--fg-primary))",boxShadow:"inset 0 0 0 1px var(--map-ui-border-strong, var(--edge-strong))"},Pf={backgroundColor:"var(--map-ui-bg, var(--body))",color:"var(--map-ui-text, var(--fg-primary))",boxShadow:"0 1px 4px rgba(0,0,0,0.15), inset 0 0 0 1px var(--map-ui-border, var(--edge-subtle))"};function Gn({prefix:a,name:u}){const g=R.useRef(null),[y,x]=R.useState(!1),[k,D]=R.useState({top:0,left:0}),Q=()=>{if(!u||!g.current)return;const M=g.current.getBoundingClientRect();D({top:M.top-4,left:M.left+M.width/2}),x(!0)};return m.jsxs(m.Fragment,{children:[m.jsx("span",{ref:g,className:"inline-flex items-center px-1.5 py-0.5 rounded font-mono text-[10px] font-semibold transition-opacity hover:opacity-80 cursor-default",style:Ff,onMouseEnter:Q,onMouseLeave:()=>x(!1),children:a}),u&&y&&Pa.createPortal(m.jsx("span",{className:"fixed z-[9999] pointer-events-none -translate-x-1/2 -translate-y-full whitespace-nowrap rounded px-1.5 py-0.5 text-[10px] font-medium",style:{...Pf,top:k.top,left:k.left},children:u}),document.body)]})}function ul(a){if(a._tracePathHashes)return a._tracePathHashes;if(a.payload&&a.payload.length>=20){const u=parseInt(a.payload.slice(16,18),16),y=(isNaN(u)?1:1<<(u&3))*2,x=a.payload.slice(18),k=[];for(let D=0;D+y<=x.length;D+=y)k.push(x.slice(D,D+y).toUpperCase());return k.length>0?k:null}return null}function cl(a,u){return a.src_hash?[a.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase(),...u.map(y=>y.toUpperCase())]:u.map(g=>g.toUpperCase())}function Qf(a,u,g,y=15){const x=[],k=u.toUpperCase(),D=g.toUpperCase();for(const Q of a){if((Q.type??Q.payload_type)!==Fa.TRACE)continue;const b=ul(Q);if(!b||b.length<1)continue;const T=cl(Q,b);if(!(T.length<2)){for(let O=0;O<T.length-1;O++)if(T[O]===k&&T[O+1]===D||T[O]===D&&T[O+1]===k){x.push(Q);break}if(x.length>=y)break}}return x}function Of(a){switch(a){case"improving":return m.jsx(Oa,{className:"w-3 h-3 text-sys-green"});case"degrading":return m.jsx(lc,{className:"w-3 h-3 text-sys-red"});case"stable":return m.jsx(To,{className:"w-3 h-3 text-fg-muted"});default:return null}}const zf={backgroundColor:"var(--map-ui-stripe)"};function W0({label:a,value:u,unit:g,color:y,tooltip:x}){return m.jsxs("div",{className:`flex items-center justify-between gap-2 py-[3px] ${x?"cursor-help":""}`,title:x,children:[m.jsx("span",{className:"type-data-xs text-fg-muted",children:a}),m.jsxs("span",{className:`data-box data-box-compact ${y||""}`,children:[u,g&&m.jsx("span",{className:"text-fg-muted ml-0.5",children:g})]})]})}function Yi({stats:a,direction:u,sf:g,noiseFloor:y}){if(!a)return m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"flex items-center justify-between mb-1.5",children:m.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:u})}),m.jsx("p",{className:"type-data-xs text-fg-muted italic px-1.5",children:"No data"})]});const x=a.max-a.min,k=a.median-a.mean,D=Qa(g),Q=a.mean-D,M=Qo(a.mean,g),b=[`Mean SNR: ${a.mean.toFixed(1)} dB (${M}) from ${a.count} measurement${a.count!==1?"s":""}`,`Variability: ±${a.stdDev.toFixed(1)} dB`,"",`Link budget (SF${g}, 3.5 dBi omni):`,`  Demod threshold: ${D.toFixed(1)} dB`,`  SNR margin: ${Q>=0?"+":""}${Q.toFixed(1)} dB`];return y!=null&&b.push(`  Noise floor: ${y} dBm`),m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[m.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:u}),m.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",title:`${a.count} measurement${a.count!==1?"s":""}`,children:["n=",a.count]})]}),m.jsx(W0,{label:"Mean",value:a.mean.toFixed(1),unit:"dB",color:w0(a.mean,g),tooltip:b.join(`
`)}),m.jsx(W0,{label:"Median",value:a.median.toFixed(1),unit:"dB",tooltip:`Middle value — less affected by unusual readings than the average.${Math.abs(k)>=.15?`
Differs from mean by ${k>0?"+":""}${k.toFixed(1)} dB`:""}`}),m.jsx(W0,{label:"Range",value:`${a.min.toFixed(1)}–${a.max.toFixed(1)}`,unit:"dB",tooltip:`Best to worst signal observed. Total spread: ${x.toFixed(1)} dB.`})]})}function Hf({pair:a,onClose:u,prefixToName:g}){var RA,sA,lA,BA,SA,bA,kA,vA,FA,IA,WA,wA;const y=Fo(),x=Ra(),k=Ta(),D=Ia(),[Q,M]=R.useState(null),b=((sA=(RA=k==null?void 0:k.config)==null?void 0:RA.radio)==null?void 0:sA.spreading_factor)??La,T=R.useMemo(()=>{const uA=`${a.nodeA.hash}>${a.nodeB.hash}`,dA=`${a.nodeB.hash}>${a.nodeA.hash}`;return{forward:y.get(uA)??null,reverse:y.get(dA)??null}},[y,a.nodeA.hash,a.nodeB.hash]),O=R.useMemo(()=>!x||x.length===0?[]:Qf(x,a.nodeA.prefix,a.nodeB.prefix),[x,a.nodeA.prefix,a.nodeB.prefix]),z=a.nodeA.name||(g==null?void 0:g.get(a.nodeA.prefix.toUpperCase()))||null,W=a.nodeB.name||(g==null?void 0:g.get(a.nodeB.prefix.toUpperCase()))||null,V=((lA=T.forward)==null?void 0:lA.trend)??((BA=T.reverse)==null?void 0:BA.trend)??"insufficient",J=Math.max(((SA=T.forward)==null?void 0:SA.lastSeen)??0,((bA=T.reverse)==null?void 0:bA.lastSeen)??0),iA=(((kA=T.forward)==null?void 0:kA.uniqueTraceCount)??0)+(((vA=T.reverse)==null?void 0:vA.uniqueTraceCount)??0),eA=V==="insufficient"?"Not enough data to determine trend (need at least 4 measurements).":`Whether signal quality is getting better or worse over time.
Compares older measurements to newer ones.`,Z=((FA=T.forward)==null?void 0:FA.uniqueTraceCount)??0,aA=((IA=T.reverse)==null?void 0:IA.uniqueTraceCount)??0,cA=["Number of trace packets that traveled through this link.",`${a.nodeA.prefix}→${a.nodeB.prefix}: ${Z}`,`${a.nodeB.prefix}→${a.nodeA.prefix}: ${aA}`].join(`
`);return m.jsx("div",{className:`
      absolute z-[700] overflow-hidden
      /* Mobile: full-width bottom sheet with breathing room */
      bottom-2 left-2 right-2
      /* sm+: right-aligned floating panel */
      sm:bottom-16 sm:left-auto sm:right-4 sm:w-[280px]
    `,children:m.jsxs("div",{className:`
        map-control-surface flex flex-col
        /* Mobile: cap at 45vh so map stays visible */
        max-h-[45vh]
        /* sm+: taller allowance */
        sm:max-h-[420px]
      `,children:[m.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 sm:py-2 min-h-[44px] sm:min-h-0 border-b border-edge-subtle",children:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[m.jsx(tl,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-green shrink-0"}),m.jsx(Gn,{prefix:a.nodeA.prefix,name:z}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"↔"}),m.jsx(Gn,{prefix:a.nodeB.prefix,name:W})]}),m.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[J>0&&m.jsx("span",{className:"type-data-xs text-fg-muted",title:vi(J),children:Po(J)}),m.jsx(Ft,{plain:!0,color:"muted",onClick:u,className:"!p-1.5 sm:!p-0.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:m.jsx(Sn,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"})})]})]}),m.jsxs("div",{className:"px-3 py-2.5 border-b border-edge-subtle",children:[m.jsxs("div",{className:"space-y-1.5 mb-2",children:[m.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${a.nodeA.prefix}→${a.nodeB.prefix}: mean of ${((WA=a.aToB)==null?void 0:WA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Gn,{prefix:a.nodeA.prefix,name:z}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Gn,{prefix:a.nodeB.prefix,name:W})]}),a.aToB?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${w0(a.aToB.mean,b)}`,children:[a.aToB.mean.toFixed(1),m.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):m.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]}),m.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${a.nodeB.prefix}→${a.nodeA.prefix}: mean of ${((wA=a.bToA)==null?void 0:wA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Gn,{prefix:a.nodeB.prefix,name:W}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Gn,{prefix:a.nodeA.prefix,name:z})]}),a.bToA?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${w0(a.bToA.mean,b)}`,children:[a.bToA.mean.toFixed(1),m.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):m.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]})]}),m.jsxs("div",{className:"grid grid-cols-2 gap-0 -mx-3 border-t border-edge-subtle",children:[m.jsx("div",{className:"px-3 pt-2 pb-1 border-r border-edge-subtle",children:m.jsx(Yi,{stats:a.aToB,direction:`${a.nodeA.prefix}→${a.nodeB.prefix}`,sf:b,noiseFloor:D})}),m.jsx("div",{className:"px-3 pt-2 pb-1",children:m.jsx(Yi,{stats:a.bToA,direction:`${a.nodeB.prefix}→${a.nodeA.prefix}`,sf:b,noiseFloor:D})})]})]}),m.jsxs("div",{className:"px-3 py-1.5 border-b border-edge-subtle",children:[V!=="insufficient"&&m.jsxs("div",{className:"flex items-center justify-between gap-2 py-[3px] cursor-help",title:eA,children:[m.jsx("span",{className:"type-data-xs text-fg-muted",children:"Trend"}),m.jsx("span",{className:"data-box data-box-compact",children:m.jsxs("span",{className:"flex items-center gap-1",children:[Of(V),m.jsx("span",{className:"text-fg-secondary capitalize",children:V})]})})]}),iA>0&&m.jsx(W0,{label:"Unique traces",value:iA.toString(),tooltip:cA})]}),O.length>0&&m.jsxs("div",{className:"px-3 py-2 flex-1 min-h-0 flex flex-col",children:[m.jsxs("p",{className:"type-micro text-fg-secondary mb-1 shrink-0",children:["Source packets (",O.length,")"]}),m.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain",style:{scrollbarGutter:"stable"},children:O.map((uA,dA)=>{const jA=ul(uA),LA=jA?cl(uA,jA):null,zA=LA?Math.max(0,LA.length-1):0,de=LA?LA.map(VA=>(g==null?void 0:g.get(VA))??VA).join(" → "):null,ZA=Q===dA,KA=uA.id??`${uA.packet_hash}-${uA.timestamp}`;return m.jsxs("div",{className:"rounded-sm",style:dA%2===1?zf:void 0,children:[m.jsxs("button",{onClick:()=>M(ZA?null:dA),className:"flex items-center gap-1.5 py-[3px] px-1 w-full text-left text-[10px] font-mono text-fg-secondary hover:text-fg-primary transition-colors group",children:[ZA?m.jsx(Ro,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"}):m.jsx(ju,{className:"w-2.5 h-2.5 text-fg-muted shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),m.jsx("span",{className:"text-fg-muted w-[52px] shrink-0",children:vi(uA.timestamp)}),de?m.jsx("span",{className:"text-fg-secondary truncate min-w-0",title:LA.join(" → "),children:de}):m.jsx("span",{className:"text-fg-muted truncate min-w-0 italic",children:"path n/a"}),m.jsxs("span",{className:"text-fg-muted shrink-0",children:[zA,"h"]}),uA.snr!=null&&m.jsx("span",{className:`shrink-0 tabular-nums ${w0(uA.snr,b)}`,children:uA.snr.toFixed(1)})]}),ZA&&m.jsxs("div",{className:"mb-1 mt-0.5 mx-1 pl-2 border-l border-edge-subtle space-y-0.5 text-[10px]",children:[uA.rssi!=null&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"RSSI"}),m.jsxs("span",{className:"font-mono tabular-nums text-fg-secondary",children:[uA.rssi," dBm"]})]}),uA.snr!=null&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"SNR"}),m.jsxs("span",{className:`font-mono tabular-nums ${w0(uA.snr,b)}`,children:[uA.snr.toFixed(1)," dB"]})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Route"}),m.jsx("span",{className:"font-mono text-fg-secondary",children:Na(uA.route??uA.route_type)})]}),uA.packet_hash&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Hash"}),m.jsxs("button",{onClick:VA=>{VA.stopPropagation(),As(uA.packet_hash)},className:"flex items-center gap-1 font-mono text-fg-secondary hover:text-fg-primary transition-colors",title:"Copy packet hash",children:[m.jsx("span",{className:"truncate max-w-[120px]",children:uA.packet_hash}),m.jsx(X0,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"})]})]}),uA.src_hash&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Source"}),m.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:uA.src_hash,children:uA.src_hash})]}),LA&&LA.length>0&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Path"}),m.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:LA.join(" → "),children:LA.join(" → ")})]})]})]},KA)})})]})]})})}function Gf({channels:a,messages:u}){const g=R.useMemo(()=>a.find(k=>k.name.toLowerCase().includes("wardrive"))??null,[a]),y=R.useMemo(()=>g?u.get(`ch:${g.index}`)??[]:[],[g,u]);if(!g||y.length===0)return null;const x=()=>{const k=Lu(y);k.length>=2&&Ys.getState().startRewind(k,"contacts-map")};return m.jsxs("button",{onClick:x,className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem"},title:`Replay #wardrive journey (${y.length} msgs)`,"aria-label":"Replay #wardrive journey",children:[m.jsx(ec,{className:"w-3.5 h-3.5 shrink-0 text-fg-secondary"}),m.jsx("span",{className:"text-fg-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1},children:"Replay"}),m.jsx("span",{className:"ml-auto text-fg-muted tabular-nums",style:{fontSize:"0.625rem"},children:y.length})]})}function Uf(){const a=Ws(),u=Zo(),g=qo(),y=Ru(),x=Tu(),{togglePlay:k,setSpeed:D,seek:Q,stopRewind:M}=Ys.getState(),b=x.end-x.start,T=x.end-g,O=b>0?(g-x.start)/b:1,z=R.useCallback(W=>{const V=parseFloat(W.target.value)/100;Q(x.start+V*b)},[Q,x.start,b]);return a?m.jsx("div",{className:"absolute bottom-3 left-3 right-3 z-[700] sm:bottom-4 sm:left-4 sm:right-4",children:m.jsxs("div",{className:"map-control-surface flex items-center gap-2 px-2.5 py-2 sm:gap-3 sm:px-3",children:[m.jsx("button",{onClick:M,className:"p-1 rounded text-fg-muted hover:text-fg-primary hover:bg-[var(--map-ui-hover,var(--elevated))] transition-colors shrink-0",title:"Stop rewind","aria-label":"Stop rewind",children:m.jsx(Sn,{className:"w-3.5 h-3.5"})}),m.jsx("button",{onClick:k,className:"p-1.5 rounded-full bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 transition-colors shrink-0",title:u?"Pause":"Rewind","aria-label":u?"Pause rewind":"Rewind",children:u?m.jsx(za,{className:"w-3.5 h-3.5"}):m.jsx(Ha,{className:"w-3.5 h-3.5"})}),m.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:m.jsx("input",{type:"range",min:0,max:100,step:.1,value:O*100,onChange:z,className:"replay-scrubber w-full h-1 appearance-none bg-edge-subtle rounded-full cursor-pointer","aria-label":"Replay timeline","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(O*100)})}),m.jsxs("span",{className:"text-[10px] sm:text-xs tabular-nums text-fg-muted whitespace-nowrap shrink-0",children:["-",Si(T)," / ",Si(b)]}),m.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:Iu.map(W=>m.jsxs("button",{onClick:()=>D(W),className:Cn("px-1.5 py-0.5 rounded text-[10px] sm:text-xs font-medium transition-colors",W===y?"bg-sys-blue/20 text-sys-blue shadow-[inset_0_0_0_1px_var(--sys-blue)]":"text-fg-muted hover:text-fg-secondary hover:bg-[var(--map-ui-hover,var(--elevated))]"),title:`${W}× speed`,"aria-label":`${W} times speed`,"aria-pressed":W===y,children:[W,"×"]},W))})]})}):null}const fl=[{target:"Sparklines",fn:"sparklines",minStage:2}];Yo(fl);const hl=R.memo(function({nodeHash:u,width:g=60,height:y=20,color:x,showArea:k=!0,showTooltip:D=!1,className:Q=""}){Wo(fl);const M=Ga(u),b=Ua(),O=!Oo().backgroundLoadComplete||b,z=typeof g=="number"?g:60;return m.jsx(Ou,{data:M,width:z,height:y,color:x,isLoading:O,className:Q})});function Vf(a){return a===null?"—":a<1e3?`${Math.round(a)}m`:`${(a/1e3).toFixed(1)}km`}function Wf(a){const u=new Date(a*1e3);return`${(u.getMonth()+1).toString().padStart(2,"0")}/${u.getDate().toString().padStart(2,"0")}`}function Yf({txDelayRec:a,networkRole:u,roleTitles:g,dataConfidence:y,dataQualityTitles:x}){const[k,D]=R.useState(!1),Q=a.floodFactor??a.txDelayFactor,M=a.directFactor??a.directTxDelayFactor,b=async()=>{const T=`set txdelay ${Q.toFixed(1)}
set direct.txdelay ${M.toFixed(1)}`;await As(T),D(!0),setTimeout(()=>D(!1),1500)};return m.jsxs("div",{className:"flex flex-col gap-1.5 text-sm",children:[(u||y)&&m.jsxs("div",{className:"flex items-center gap-2",children:[u&&m.jsx(bt,{color:Hu[u],compact:!0,title:g[u],children:u}),y&&m.jsxs(bt,{color:Gu[y],compact:!0,title:x[y],children:[y," data"]})]}),m.jsxs("button",{onClick:b,className:"flex items-center gap-2 py-1.5 px-2 bg-subtle-fill hover:bg-subtle-fill-hover rounded transition-colors group",title:"Click to copy CLI commands",children:[m.jsx(Vu,{className:"w-3.5 h-3.5 text-sys-amber shrink-0"}),m.jsx("span",{className:"text-fg-muted",children:"TxDelay"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"text-fg-muted",children:"F"}),m.jsxs("span",{className:"data-box text-sys-amber",children:["×",Q.toFixed(1)]})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"text-fg-muted",children:"D"}),m.jsxs("span",{className:"data-box text-sys-amber",children:["×",M.toFixed(1)]})]})]}),k?m.jsx(Yn,{className:"w-3.5 h-3.5 text-sys-green ml-auto"}):m.jsx(X0,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]})]})}function Kf({hash:a,hashPrefix:u,name:g,isHub:y,isGateway:x,isBackbone:k,isZeroHop:D,isMobile:Q,isRoomServer:M,isStale:b,lastSeenTimestamp:T,centrality:O,affinity:z,meanSnr:W,meanRssi:V,neighbor:J,onRemove:iA,txDelayRec:eA,hideHeader:Z=!1}){const[aA,cA]=R.useState(!1),RA=async()=>{await As(a),cA(!0),setTimeout(()=>cA(!1),1500)},sA=D?"Direct":z!=null&&z.typicalHopPosition?`${z.typicalHopPosition}-hop`:null,lA=eA&&!eA.insufficientData,BA={hub:"Hub: High-connectivity node that bridges many paths",backbone:"Backbone: Critical relay with high traffic",relay:"Relay: Standard forwarding node",edge:"Edge: Peripheral node"},SA={high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"};return m.jsxs("div",{children:[!Z&&m.jsx("div",{className:"text-[14px] font-semibold text-fg-primary leading-tight truncate mb-1",children:g}),!Z&&m.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[m.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded",children:u}),m.jsx("button",{onClick:RA,className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:aA?m.jsx(Yn,{className:"w-3 h-3 text-sys-green"}):m.jsx(X0,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(Xo,{hash:a,size:"sm"}),sA&&m.jsx(bt,{color:D?K0.direct:K0.multihop,compact:!0,children:sA}),J.is_repeater&&m.jsx(bt,{color:cr.repeater,compact:!0,children:"Rptr"}),y&&m.jsx(bt,{color:cr.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),x&&!y&&m.jsx(bt,{color:cr.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),k&&m.jsx(bt,{color:cr.backbone,compact:!0,title:"Backbone",children:"Bone"}),Q&&m.jsx(bt,{color:cr.mobile,compact:!0,children:"Mobile"}),M&&m.jsx(bt,{color:cr.room,compact:!0,children:"Room"}),b&&T&&m.jsxs(bt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",Wf(T)]})]}),m.jsx("div",{title:"7-day activity trend (6-hour buckets)",children:m.jsx(hl,{nodeHash:a,width:224,height:28,showArea:!0,showTooltip:!0,className:"w-full"})}),m.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-sm text-fg-secondary mt-2",children:[m.jsxs("span",{className:"flex items-center gap-0.5",title:J.last_seen?`Last heard: ${new Date(J.last_seen*1e3).toLocaleString()}`:"Last heard time",children:[m.jsx($o,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsx("span",{className:"font-mono",children:Po(J.last_seen)})]}),(z==null?void 0:z.distanceMeters)&&m.jsxs("span",{className:"flex items-center gap-0.5",title:"Line-of-sight distance from local node",children:[m.jsx(zu,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsx("span",{className:"font-mono font-semibold text-fg-primary",children:Vf(z.distanceMeters)})]}),J.latitude&&J.longitude&&J.latitude!==0&&J.longitude!==0&&m.jsxs("span",{className:"flex items-center gap-0.5",title:"GPS coordinates (lat, lon)",children:[m.jsx(Uu,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsxs("span",{className:"font-mono text-fg-muted",children:[J.latitude.toFixed(2),", ",J.longitude.toFixed(2)]})]})]}),m.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5 text-sm mt-2",children:[m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Total packets seen from this node",children:[m.jsx("span",{className:"text-fg-muted",children:"Packets"}),m.jsx("span",{className:"data-box",children:(z==null?void 0:z.frequency)||0})]}),m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"ADVERT beacon packets received",children:[m.jsx("span",{className:"text-fg-muted",children:"Adverts"}),m.jsx("span",{className:"data-box",children:J.advert_count||0})]}),D&&W!==void 0&&m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Average Signal-to-Noise Ratio (direct zero-hop)",children:[m.jsx("span",{className:"text-fg-muted",children:"SNR"}),m.jsxs("span",{className:"data-box",children:[W.toFixed(1)," dB"]})]}),D&&V!==void 0&&m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Average Received Signal Strength (direct zero-hop)",children:[m.jsx("span",{className:"text-fg-muted",children:"RSSI"}),m.jsxs("span",{className:"data-box",children:[Math.round(V)," dBm"]})]})]}),lA&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"border-t border-edge-subtle mt-2.5 mb-2"}),m.jsx(Yf,{txDelayRec:eA,networkRole:eA.networkRole,roleTitles:BA,dataConfidence:eA.dataConfidence,dataQualityTitles:SA})]}),iA&&m.jsx("button",{onClick:iA,className:"w-full text-center text-sm mt-2 py-3 sm:py-1.5 rounded text-fg-muted hover:text-sys-red hover:bg-sys-red/10 transition-colors",children:"Remove from Contacts"})]})}function $f(a){const u=new Date(a*1e3);return`${(u.getMonth()+1).toString().padStart(2,"0")}/${u.getDate().toString().padStart(2,"0")}`}function Zf({data:a,localNode:u,localColor:g,onClose:y,onRemove:x}){var b,T,O,z;const[k,D]=R.useState(!1);R.useEffect(()=>{if(!a)return;const W=V=>{V.key==="Escape"&&y()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[a,y]);const Q=async()=>{a!=null&&a.hash&&(await As(a.hash),D(!0),setTimeout(()=>D(!1),1500))},M=a!=null&&a.isZeroHop?"Direct":(b=a==null?void 0:a.affinity)!=null&&b.typicalHopPosition?`${a.affinity.typicalHopPosition}-hop`:null;return m.jsx(Sr,{children:a&&m.jsx(qt.div,{className:"map-node-panel",initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:16},transition:En.smooth,children:m.jsxs("div",{className:"map-control-surface flex flex-col max-h-[38dvh] sm:max-h-[50vh]",children:[m.jsx("div",{className:"map-node-panel-drag-handle sm:hidden"}),m.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2.5 shrink-0",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[m.jsx("span",{className:"text-sm font-semibold truncate text-fg-primary",children:a.name||"Unknown"}),a.hash&&m.jsxs(m.Fragment,{children:[m.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded ml-1",children:a.hashPrefix||a.hash.substring(0,2)}),m.jsx("button",{onClick:Q,className:"p-2 -m-1.5 sm:p-0.5 sm:m-0 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:k?m.jsx(Yn,{className:"w-3 h-3 text-sys-green"}):m.jsx(X0,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(Xo,{hash:a.hash,size:"sm"})]})]}),m.jsx(Ft,{plain:!0,color:"muted",onClick:y,className:"!p-1 !rounded-md -mr-1 -mt-1 hover:bg-subtle-fill-hover min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close node detail",children:m.jsx(Sn,{className:"w-4 h-4"})})]}),(M||((T=a.neighbor)==null?void 0:T.is_repeater)||a.isHub||a.isGateway&&!a.isHub||a.isBackbone||a.isMobile||a.isRoomServer||a.isStale&&a.lastSeenTimestamp)&&m.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[M&&m.jsx(bt,{color:a.isZeroHop?K0.direct:K0.multihop,compact:!0,title:a.isZeroHop?"Direct RF contact (zero-hop)":`${((O=a.affinity)==null?void 0:O.typicalHopPosition)??"?"} hops from local node`,children:M}),((z=a.neighbor)==null?void 0:z.is_repeater)&&m.jsx(bt,{color:cr.repeater,compact:!0,title:"Repeater node (forwards packets)",children:"Rptr"}),a.isHub&&m.jsx(bt,{color:cr.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),a.isGateway&&!a.isHub&&m.jsx(bt,{color:cr.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),a.isBackbone&&m.jsx(bt,{color:cr.backbone,compact:!0,title:"Backbone: critical relay with high traffic",children:"Bone"}),a.isMobile&&m.jsx(bt,{color:cr.mobile,compact:!0,title:"Mobile repeater (path volatility detected)",children:"Mobile"}),a.isRoomServer&&m.jsx(bt,{color:cr.room,compact:!0,title:"Room server node",children:"Room"}),a.isStale&&a.lastSeenTimestamp&&m.jsxs(bt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",$f(a.lastSeenTimestamp)]})]})]}),m.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain px-3 pt-2 pb-3",children:a.isLocal?m.jsxs("div",{className:"text-sm",children:[m.jsx("div",{className:"mb-2",children:m.jsx("span",{style:{color:g},className:"font-medium",children:"This Node (Local)"})}),a.hash&&m.jsx("div",{className:"mb-2",children:m.jsx(hl,{nodeHash:a.hash,width:224,height:28,showArea:!0,showTooltip:!0,className:"w-full"})}),u&&m.jsxs("div",{className:"text-xs text-fg-muted font-mono border-t border-edge-subtle pt-2",children:[u.latitude.toFixed(5),", ",u.longitude.toFixed(5)]})]}):a.neighbor&&a.hash?m.jsx(Kf,{hash:a.hash,hashPrefix:a.hashPrefix,name:a.name,isHub:a.isHub,isGateway:a.isGateway,isBackbone:a.isBackbone,isZeroHop:a.isZeroHop,isMobile:a.isMobile,isRoomServer:a.isRoomServer,isStale:a.isStale,lastSeenTimestamp:a.lastSeenTimestamp,centrality:a.centrality,affinity:a.affinity,meanSnr:a.meanSnr,meanRssi:a.meanRssi,neighbor:a.neighbor,txDelayRec:a.txDelayRec,onRemove:x?()=>x(a.hash,a.name):void 0,hideHeader:!0}):null})]})})})}const qf={getItem:a=>{try{return localStorage.getItem(a)}catch{return null}},setItem:(a,u)=>{try{localStorage.setItem(a,u)}catch{}},removeItem:a=>{try{localStorage.removeItem(a)}catch{}}},dl=Io()(hu(a=>({isEnabled:!1,toggle:()=>a(u=>({isEnabled:!u.isEnabled})),setEnabled:u=>a({isEnabled:u})}),{name:"pymc-live-trace",storage:du(()=>qf)})),Jf=()=>dl(a=>a.isEnabled),Xf=()=>dl(a=>a.toggle);var Pt=(function(a){a=a||{};var u=typeof a<"u"?a:{},g={},y;for(y in u)u.hasOwnProperty(y)&&(g[y]=u[y]);var x="";function k(tA){return u.locateFile?u.locateFile(tA,x):x+tA}var D;typeof document<"u"&&document.currentScript&&(x=document.currentScript.src),x.indexOf("blob:")!==0?x=x.substr(0,x.lastIndexOf("/")+1):x="",D=function(yA,TA,mA){var t=new XMLHttpRequest;t.open("GET",yA,!0),t.responseType="arraybuffer",t.onload=function(){if(t.status==200||t.status==0&&t.response){TA(t.response);return}var xe=Rr(yA);if(xe){TA(xe.buffer);return}mA()},t.onerror=mA,t.send(null)};var Q=u.print||console.log.bind(console),M=u.printErr||console.warn.bind(console);for(y in g)g.hasOwnProperty(y)&&(u[y]=g[y]);g=null,u.arguments&&u.arguments;var b=0,T=function(tA){b=tA},O=function(){return b},z=8;function W(tA,yA,TA,mA){switch(TA=TA||"i8",TA.charAt(TA.length-1)==="*"&&(TA="i32"),TA){case"i1":vA[tA>>0]=yA;break;case"i8":vA[tA>>0]=yA;break;case"i16":IA[tA>>1]=yA;break;case"i32":WA[tA>>2]=yA;break;case"i64":at=[yA>>>0,(Ze=yA,+fe(Ze)>=1?Ze>0?(Ke(+te(Ze/4294967296),4294967295)|0)>>>0:~~+Pe((Ze-+(~~Ze>>>0))/4294967296)>>>0:0)],WA[tA>>2]=at[0],WA[tA+4>>2]=at[1];break;case"float":wA[tA>>2]=yA;break;case"double":uA[tA>>3]=yA;break;default:dt("invalid type for setValue: "+TA)}}function V(tA,yA,TA){switch(yA=yA||"i8",yA.charAt(yA.length-1)==="*"&&(yA="i32"),yA){case"i1":return vA[tA>>0];case"i8":return vA[tA>>0];case"i16":return IA[tA>>1];case"i32":return WA[tA>>2];case"i64":return WA[tA>>2];case"float":return wA[tA>>2];case"double":return uA[tA>>3];default:dt("invalid type for getValue: "+yA)}return null}var J=!1;function iA(tA,yA){tA||dt("Assertion failed: "+yA)}function eA(tA){var yA=u["_"+tA];return iA(yA,"Cannot call unknown function "+tA+", make sure it is exported"),yA}function Z(tA,yA,TA,mA,t){var C={string:function(ie){var rt=0;if(ie!=null&&ie!==0){var Dt=(ie.length<<2)+1;rt=er(Dt),BA(ie,rt,Dt)}return rt},array:function(ie){var rt=er(ie.length);return SA(ie,rt),rt}};function xe(ie){return yA==="string"?sA(ie):yA==="boolean"?!!ie:ie}var Be=eA(tA),Ue=[],qA=0;if(mA)for(var be=0;be<mA.length;be++){var mt=C[TA[be]];mt?(qA===0&&(qA=fr()),Ue[be]=mt(mA[be])):Ue[be]=mA[be]}var ue=Be.apply(null,Ue);return ue=xe(ue),qA!==0&&Se(qA),ue}function aA(tA,yA,TA,mA){TA=TA||[];var t=TA.every(function(xe){return xe==="number"}),C=yA!=="string";return C&&t&&!mA?eA(tA):function(){return Z(tA,yA,TA,arguments)}}var cA=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function RA(tA,yA,TA){for(var mA=yA+TA,t=yA;tA[t]&&!(t>=mA);)++t;if(t-yA>16&&tA.subarray&&cA)return cA.decode(tA.subarray(yA,t));for(var C="";yA<t;){var xe=tA[yA++];if(!(xe&128)){C+=String.fromCharCode(xe);continue}var Be=tA[yA++]&63;if((xe&224)==192){C+=String.fromCharCode((xe&31)<<6|Be);continue}var Ue=tA[yA++]&63;if((xe&240)==224?xe=(xe&15)<<12|Be<<6|Ue:xe=(xe&7)<<18|Be<<12|Ue<<6|tA[yA++]&63,xe<65536)C+=String.fromCharCode(xe);else{var qA=xe-65536;C+=String.fromCharCode(55296|qA>>10,56320|qA&1023)}}return C}function sA(tA,yA){return tA?RA(FA,tA,yA):""}function lA(tA,yA,TA,mA){if(!(mA>0))return 0;for(var t=TA,C=TA+mA-1,xe=0;xe<tA.length;++xe){var Be=tA.charCodeAt(xe);if(Be>=55296&&Be<=57343){var Ue=tA.charCodeAt(++xe);Be=65536+((Be&1023)<<10)|Ue&1023}if(Be<=127){if(TA>=C)break;yA[TA++]=Be}else if(Be<=2047){if(TA+1>=C)break;yA[TA++]=192|Be>>6,yA[TA++]=128|Be&63}else if(Be<=65535){if(TA+2>=C)break;yA[TA++]=224|Be>>12,yA[TA++]=128|Be>>6&63,yA[TA++]=128|Be&63}else{if(TA+3>=C)break;yA[TA++]=240|Be>>18,yA[TA++]=128|Be>>12&63,yA[TA++]=128|Be>>6&63,yA[TA++]=128|Be&63}}return yA[TA]=0,TA-t}function BA(tA,yA,TA){return lA(tA,FA,yA,TA)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function SA(tA,yA){vA.set(tA,yA)}function bA(tA,yA){return tA%yA>0&&(tA+=yA-tA%yA),tA}var kA,vA,FA,IA,WA,wA,uA;function dA(tA){kA=tA,u.HEAP8=vA=new Int8Array(tA),u.HEAP16=IA=new Int16Array(tA),u.HEAP32=WA=new Int32Array(tA),u.HEAPU8=FA=new Uint8Array(tA),u.HEAPU16=new Uint16Array(tA),u.HEAPU32=new Uint32Array(tA),u.HEAPF32=wA=new Float32Array(tA),u.HEAPF64=uA=new Float64Array(tA)}var jA=5271536,LA=28624,zA=u.TOTAL_MEMORY||33554432;u.buffer?kA=u.buffer:kA=new ArrayBuffer(zA),zA=kA.byteLength,dA(kA),WA[LA>>2]=jA;function de(tA){for(;tA.length>0;){var yA=tA.shift();if(typeof yA=="function"){yA();continue}var TA=yA.func;typeof TA=="number"?yA.arg===void 0?u.dynCall_v(TA):u.dynCall_vi(TA,yA.arg):TA(yA.arg===void 0?null:yA.arg)}}var ZA=[],KA=[],VA=[],Te=[];function _e(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Ie(u.preRun.shift());de(ZA)}function pe(){de(KA)}function ce(){de(VA)}function Me(){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)Le(u.postRun.shift());de(Te)}function Ie(tA){ZA.unshift(tA)}function Le(tA){Te.unshift(tA)}var fe=Math.abs,Pe=Math.ceil,te=Math.floor,Ke=Math.min,$e=0,At=null;function it(tA){$e++,u.monitorRunDependencies&&u.monitorRunDependencies($e)}function St(tA){if($e--,u.monitorRunDependencies&&u.monitorRunDependencies($e),$e==0&&At){var yA=At;At=null,yA()}}u.preloadedImages={},u.preloadedAudios={};var Ve=null,We="data:application/octet-stream;base64,";function ke(tA){return String.prototype.startsWith?tA.startsWith(We):tA.indexOf(We)===0}var Ze,at;Ve="data:application/octet-stream;base64, ";var Bt=28640;function Jt(tA,yA,TA,mA){dt("Assertion failed: "+sA(tA)+", at: "+[yA?sA(yA):"unknown filename",TA,mA?sA(mA):"unknown function"])}function Xt(){return vA.length}function Dr(tA,yA,TA){FA.set(FA.subarray(yA,yA+TA),tA)}function Ar(tA){return u.___errno_location&&(WA[u.___errno_location()>>2]=tA),tA}function on(tA){dt("OOM")}function _r(tA){try{var yA=new ArrayBuffer(tA);return yA.byteLength!=tA?void 0:(new Int8Array(yA).set(vA),xr(yA),dA(yA),1)}catch{}}function gr(tA){var yA=Xt(),TA=16777216,mA=2147483648-TA;if(tA>mA)return!1;for(var t=16777216,C=Math.max(yA,t);C<tA;)C<=536870912?C=bA(2*C,TA):C=Math.min(bA((3*C+2147483648)/4,TA),mA);var xe=_r(C);return!!xe}var yr=typeof atob=="function"?atob:function(tA){var yA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",TA="",mA,t,C,xe,Be,Ue,qA,be=0;tA=tA.replace(/[^A-Za-z0-9\+\/\=]/g,"");do xe=yA.indexOf(tA.charAt(be++)),Be=yA.indexOf(tA.charAt(be++)),Ue=yA.indexOf(tA.charAt(be++)),qA=yA.indexOf(tA.charAt(be++)),mA=xe<<2|Be>>4,t=(Be&15)<<4|Ue>>2,C=(Ue&3)<<6|qA,TA=TA+String.fromCharCode(mA),Ue!==64&&(TA=TA+String.fromCharCode(t)),qA!==64&&(TA=TA+String.fromCharCode(C));while(be<tA.length);return TA};function jr(tA){try{for(var yA=yr(tA),TA=new Uint8Array(yA.length),mA=0;mA<yA.length;++mA)TA[mA]=yA.charCodeAt(mA);return TA}catch{throw new Error("Converting base64 string to bytes failed.")}}function Rr(tA){if(ke(tA))return jr(tA.slice(We.length))}var Kr={Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},ln={b:T,c:O,d:Jt,e:Ar,f:Xt,g:Dr,h:gr,i:on,o:Bt,p:LA},gA=(function(tA,yA,TA){"almost asm";var mA=new tA.Int8Array(TA),t=new tA.Int32Array(TA);new tA.Uint8Array(TA),new tA.Float32Array(TA);var C=new tA.Float64Array(TA),xe=yA.o|0,Be=yA.p|0,Ue=tA.Math.floor,qA=tA.Math.abs,be=tA.Math.sqrt,mt=tA.Math.pow,ue=tA.Math.cos,ie=tA.Math.sin,rt=tA.Math.tan,Dt=tA.Math.acos,rr=tA.Math.asin,Ct=tA.Math.atan,nt=tA.Math.atan2,Qt=tA.Math.ceil,pt=tA.Math.imul,ot=tA.Math.min,Tr=tA.Math.max,Et=tA.Math.clz32,JA=yA.b,S=yA.c,PA=yA.d,ft=yA.e,qe=yA.f,Ut=yA.g,dr=yA.h,Ir=yA.i,E=28656;function Ot(e){return mA=new Int8Array(e),t=new Int32Array(e),C=new Float64Array(e),TA=e,!0}function nr(e){e=e|0;var A=0;return A=E,E=E+e|0,E=E+15&-16,A|0}function Lr(){return E|0}function Nr(e){e=e|0,E=e}function Fr(e,A){e=e|0,E=e}function h(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;return(e|0)<0?(A=2,A|0):(e|0)>13780509?(A=E0(15,A)|0,A|0):(r=((e|0)<0)<<31>>31,s=wt(e|0,r|0,3,0)|0,n=S()|0,r=YA(e|0,r|0,1,0)|0,r=wt(s|0,n|0,r|0,S()|0)|0,r=YA(r|0,S()|0,1,0)|0,e=S()|0,t[A>>2]=r,t[A+4>>2]=e,A=0,A|0)}function v(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,j(e,A,r,n,0)|0}function j(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0;if(c=E,E=E+16|0,o=c,!(P(e,A,r,n,s)|0))return n=0,E=c,n|0;do if((r|0)>=0){if((r|0)>13780509){if(i=E0(15,o)|0,i|0)break;l=o,o=t[l>>2]|0,l=t[l+4>>2]|0}else i=((r|0)<0)<<31>>31,f=wt(r|0,i|0,3,0)|0,l=S()|0,i=YA(r|0,i|0,1,0)|0,i=wt(f|0,l|0,i|0,S()|0)|0,i=YA(i|0,S()|0,1,0)|0,l=S()|0,t[o>>2]=i,t[o+4>>2]=l,o=i;if(An(n|0,0,o<<3|0)|0,s|0){An(s|0,0,o<<2|0)|0,i=X(e,A,r,n,s,o,l,0)|0;break}i=Gt(o,4)|0,i?(f=X(e,A,r,n,i,o,l,0)|0,$A(i),i=f):i=13}else i=2;while(!1);return f=i,E=c,f|0}function P(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0;if(G=E,E=E+16|0,L=G,N=G+8|0,I=L,t[I>>2]=e,t[I+4>>2]=A,(r|0)<0)return N=2,E=G,N|0;if(i=n,t[i>>2]=e,t[i+4>>2]=A,i=(s|0)!=0,i&&(t[s>>2]=0),Fe(e,A)|0)return N=9,E=G,N|0;t[N>>2]=0;A:do if((r|0)>=1)if(i)for(p=1,f=0,B=0,I=1,i=e;;){if(!(f|B)){if(i=K(i,A,4,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,Fe(i,A)|0){i=9;break A}}if(i=K(i,A,t[26800+(B<<2)>>2]|0,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(p<<3)|0,t[e>>2]=i,t[e+4>>2]=A,t[s+(p<<2)>>2]=I,e=f+1|0,o=(e|0)==(I|0),l=B+1|0,c=(l|0)==6,Fe(i,A)|0){i=9;break A}if(I=I+(c&o&1)|0,(I|0)>(r|0)){i=0;break}else p=p+1|0,f=o?0:e,B=o?c?0:l:B}else for(p=1,f=0,B=0,I=1,i=e;;){if(!(f|B)){if(i=K(i,A,4,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,Fe(i,A)|0){i=9;break A}}if(i=K(i,A,t[26800+(B<<2)>>2]|0,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(p<<3)|0,t[e>>2]=i,t[e+4>>2]=A,e=f+1|0,o=(e|0)==(I|0),l=B+1|0,c=(l|0)==6,Fe(i,A)|0){i=9;break A}if(I=I+(c&o&1)|0,(I|0)>(r|0)){i=0;break}else p=p+1|0,f=o?0:e,B=o?c?0:l:B}else i=0;while(!1);return N=i,E=G,N|0}function X(e,A,r,n,s,i,o,l){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0,o=o|0,l=l|0;var c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0;if(G=E,E=E+16|0,L=G+8|0,N=G,c=Fn(e|0,A|0,i|0,o|0)|0,p=S()|0,B=n+(c<<3)|0,Y=B,nA=t[Y>>2]|0,Y=t[Y+4>>2]|0,f=(nA|0)==(e|0)&(Y|0)==(A|0),!((nA|0)==0&(Y|0)==0|f))do c=YA(c|0,p|0,1,0)|0,c=Nn(c|0,S()|0,i|0,o|0)|0,p=S()|0,B=n+(c<<3)|0,nA=B,Y=t[nA>>2]|0,nA=t[nA+4>>2]|0,f=(Y|0)==(e|0)&(nA|0)==(A|0);while(!((Y|0)==0&(nA|0)==0|f));if(c=s+(c<<2)|0,f&&(t[c>>2]|0)<=(l|0)||(nA=B,t[nA>>2]=e,t[nA+4>>2]=A,t[c>>2]=l,(l|0)>=(r|0)))return nA=0,E=G,nA|0;switch(f=l+1|0,t[L>>2]=0,c=K(e,A,2,L,N)|0,c|0){case 9:{I=9;break}case 0:{c=N,c=X(t[c>>2]|0,t[c+4>>2]|0,r,n,s,i,o,f)|0,c||(I=9);break}}A:do if((I|0)==9){switch(t[L>>2]=0,c=K(e,A,3,L,N)|0,c|0){case 9:break;case 0:{if(c=N,c=X(t[c>>2]|0,t[c+4>>2]|0,r,n,s,i,o,f)|0,c|0)break A;break}default:break A}switch(t[L>>2]=0,c=K(e,A,1,L,N)|0,c|0){case 9:break;case 0:{if(c=N,c=X(t[c>>2]|0,t[c+4>>2]|0,r,n,s,i,o,f)|0,c|0)break A;break}default:break A}switch(t[L>>2]=0,c=K(e,A,5,L,N)|0,c|0){case 9:break;case 0:{if(c=N,c=X(t[c>>2]|0,t[c+4>>2]|0,r,n,s,i,o,f)|0,c|0)break A;break}default:break A}switch(t[L>>2]=0,c=K(e,A,4,L,N)|0,c|0){case 9:break;case 0:{if(c=N,c=X(t[c>>2]|0,t[c+4>>2]|0,r,n,s,i,o,f)|0,c|0)break A;break}default:break A}switch(t[L>>2]=0,c=K(e,A,6,L,N)|0,c|0){case 9:break;case 0:{if(c=N,c=X(t[c>>2]|0,t[c+4>>2]|0,r,n,s,i,o,f)|0,c|0)break A;break}default:break A}return nA=0,E=G,nA|0}while(!1);return nA=c,E=G,nA|0}function K(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0;if(r>>>0>6)return s=1,s|0;if(B=(t[n>>2]|0)%6|0,t[n>>2]=B,(B|0)>0){i=0;do r=Wt(r)|0,i=i+1|0;while((i|0)<(t[n>>2]|0))}if(B=xA(e|0,A|0,45)|0,S()|0,p=B&127,p>>>0>121)return s=5,s|0;c=Ht(e,A)|0,i=xA(e|0,A|0,52)|0,S()|0,i=i&15;A:do if(!i)f=8;else{for(;;){if(o=(15-i|0)*3|0,l=xA(e|0,A|0,o|0)|0,S()|0,l=l&7,(l|0)==7){A=5;break}if(N=(or(i)|0)==0,i=i+-1|0,I=CA(7,0,o|0)|0,A=A&~(S()|0),L=CA(t[(N?432:16)+(l*28|0)+(r<<2)>>2]|0,0,o|0)|0,o=S()|0,r=t[(N?640:224)+(l*28|0)+(r<<2)>>2]|0,e=L|e&~I,A=o|A,!r){r=0;break A}if(!i){f=8;break A}}return A|0}while(!1);(f|0)==8&&(N=t[848+(p*28|0)+(r<<2)>>2]|0,L=CA(N|0,0,45)|0,e=L|e,A=S()|0|A&-1040385,r=t[4272+(p*28|0)+(r<<2)>>2]|0,(N&127|0)==127&&(N=CA(t[848+(p*28|0)+20>>2]|0,0,45)|0,A=S()|0|A&-1040385,r=t[4272+(p*28|0)+20>>2]|0,e=hn(N|e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1)),l=xA(e|0,A|0,45)|0,S()|0,l=l&127;A:do if(je(l)|0){e:do if((Ht(e,A)|0)==1){if((p|0)!=(l|0))if(Qr(l,t[7696+(p*28|0)>>2]|0)|0){e=ns(e,A)|0,o=1,A=S()|0;break}else PA(27795,26864,533,26872);switch(c|0){case 3:{e=hn(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1,o=0;break e}case 5:{e=ns(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+5,o=0;break e}case 0:return N=9,N|0;default:return N=1,N|0}}else o=0;while(!1);if((r|0)>0){i=0;do e=rs(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}if((p|0)!=(l|0)){if(!(jt(l)|0)){if((o|0)!=0|(Ht(e,A)|0)!=5)break;t[n>>2]=(t[n>>2]|0)+1;break}switch(B&127){case 8:case 118:break A}(Ht(e,A)|0)!=3&&(t[n>>2]=(t[n>>2]|0)+1)}}else if((r|0)>0){i=0;do e=hn(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}while(!1);return t[n>>2]=((t[n>>2]|0)+r|0)%6|0,N=s,t[N>>2]=e,t[N+4>>2]=A,N=0,N|0}function fA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,_A(e,A,r,n)|0?(An(n|0,0,r*48|0)|0,n=XA(e,A,r,n)|0,n|0):(n=0,n|0)}function _A(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0;if(N=E,E=E+16|0,I=N,L=N+8|0,B=I,t[B>>2]=e,t[B+4>>2]=A,(r|0)<0)return L=2,E=N,L|0;if(!r)return L=n,t[L>>2]=e,t[L+4>>2]=A,L=0,E=N,L|0;t[L>>2]=0;A:do if(Fe(e,A)|0)e=9;else{s=0,B=e;do{if(e=K(B,A,4,L,I)|0,e|0)break A;if(A=I,B=t[A>>2]|0,A=t[A+4>>2]|0,s=s+1|0,Fe(B,A)|0){e=9;break A}}while((s|0)<(r|0));p=n,t[p>>2]=B,t[p+4>>2]=A,p=r+-1|0,f=0,e=1;do{if(s=26800+(f<<2)|0,(f|0)==5)for(o=t[s>>2]|0,i=0,s=e;;){if(e=I,e=K(t[e>>2]|0,t[e+4>>2]|0,o,L,I)|0,e|0)break A;if((i|0)!=(p|0))if(c=I,l=t[c>>2]|0,c=t[c+4>>2]|0,e=n+(s<<3)|0,t[e>>2]=l,t[e+4>>2]=c,!(Fe(l,c)|0))e=s+1|0;else{e=9;break A}else e=s;if(i=i+1|0,(i|0)>=(r|0))break;s=e}else for(o=I,c=t[s>>2]|0,l=0,s=e,i=t[o>>2]|0,o=t[o+4>>2]|0;;){if(e=K(i,o,c,L,I)|0,e|0)break A;if(o=I,i=t[o>>2]|0,o=t[o+4>>2]|0,e=n+(s<<3)|0,t[e>>2]=i,t[e+4>>2]=o,e=s+1|0,Fe(i,o)|0){e=9;break A}if(l=l+1|0,(l|0)>=(r|0))break;s=e}f=f+1|0}while(f>>>0<6);e=I,e=(B|0)==(t[e>>2]|0)&&(A|0)==(t[e+4>>2]|0)?0:9}while(!1);return L=e,E=N,L|0}function XA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0;if(B=E,E=E+16|0,o=B,!r)return t[n>>2]=e,t[n+4>>2]=A,n=0,E=B,n|0;do if((r|0)>=0){if((r|0)>13780509){if(s=E0(15,o)|0,s|0)break;i=o,s=t[i>>2]|0,i=t[i+4>>2]|0}else s=((r|0)<0)<<31>>31,p=wt(r|0,s|0,3,0)|0,i=S()|0,s=YA(r|0,s|0,1,0)|0,s=wt(p|0,i|0,s|0,S()|0)|0,s=YA(s|0,S()|0,1,0)|0,i=S()|0,p=o,t[p>>2]=s,t[p+4>>2]=i;if(f=Gt(s,8)|0,!f)s=13;else{if(p=Gt(s,4)|0,!p){$A(f),s=13;break}if(s=X(e,A,r,f,p,s,i,0)|0,s|0){$A(f),$A(p);break}if(A=t[o>>2]|0,o=t[o+4>>2]|0,(o|0)>0|(o|0)==0&A>>>0>0){s=0,l=0,c=0;do e=f+(l<<3)|0,i=t[e>>2]|0,e=t[e+4>>2]|0,!((i|0)==0&(e|0)==0)&&(t[p+(l<<2)>>2]|0)==(r|0)&&(I=n+(s<<3)|0,t[I>>2]=i,t[I+4>>2]=e,s=s+1|0),l=YA(l|0,c|0,1,0)|0,c=S()|0;while((c|0)<(o|0)|(c|0)==(o|0)&l>>>0<A>>>0)}$A(f),$A(p),s=0}}else s=2;while(!1);return I=s,E=B,I|0}function Ae(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0;for(l=E,E=E+16|0,i=l,o=l+8|0,s=(Fe(e,A)|0)==0,s=s?1:2;;){if(t[o>>2]=0,f=(K(e,A,s,o,i)|0)==0,c=i,f&((t[c>>2]|0)==(r|0)?(t[c+4>>2]|0)==(n|0):0)){e=4;break}if(s=s+1|0,s>>>0>=7){s=7,e=4;break}}return(e|0)==4?(E=l,s|0):0}function he(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0;if(l=E,E=E+48|0,s=l+16|0,i=l+8|0,o=l,r=l0(r)|0,r|0)return o=r,E=l,o|0;if(f=e,c=t[f+4>>2]|0,r=i,t[r>>2]=t[f>>2],t[r+4>>2]=c,si(i,s),r=Vt(s,A,o)|0,!r){if(A=t[i>>2]|0,i=t[e+8>>2]|0,(i|0)>0){s=t[e+12>>2]|0,r=0;do A=(t[s+(r<<3)>>2]|0)+A|0,r=r+1|0;while((r|0)<(i|0))}r=o,s=t[r>>2]|0,r=t[r+4>>2]|0,i=((A|0)<0)<<31>>31,(r|0)<(i|0)|(r|0)==(i|0)&s>>>0<A>>>0?(r=o,t[r>>2]=A,t[r+4>>2]=i,r=i):A=s,c=YA(A|0,r|0,12,0)|0,f=S()|0,r=o,t[r>>2]=c,t[r+4>>2]=f,r=n,t[r>>2]=c,t[r+4>>2]=f,r=0}return f=r,E=l,f|0}function Oe(e,A,r,n,s,i,o){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0,o=o|0;var l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0,ge=0,Ee=0,se=0,UA=0,EA=0,ve=0,He=0,ye=0,Ge=0,Nt=0,xi=0;if(He=E,E=E+64|0,se=He+48|0,UA=He+32|0,EA=He+24|0,MA=He+8|0,GA=He,c=t[e>>2]|0,(c|0)<=0)return ve=0,E=He,ve|0;for(OA=e+4|0,me=se+8|0,ge=UA+8|0,Ee=MA+8|0,l=0,$=0;;){f=t[OA>>2]|0,q=f+($<<4)|0,t[se>>2]=t[q>>2],t[se+4>>2]=t[q+4>>2],t[se+8>>2]=t[q+8>>2],t[se+12>>2]=t[q+12>>2],($|0)==(c+-1|0)?(t[UA>>2]=t[f>>2],t[UA+4>>2]=t[f+4>>2],t[UA+8>>2]=t[f+8>>2],t[UA+12>>2]=t[f+12>>2]):(q=f+($+1<<4)|0,t[UA>>2]=t[q>>2],t[UA+4>>2]=t[q+4>>2],t[UA+8>>2]=t[q+8>>2],t[UA+12>>2]=t[q+12>>2]),c=$r(se,UA,n,EA)|0;A:do if(c)f=0,l=c;else if(c=EA,f=t[c>>2]|0,c=t[c+4>>2]|0,(c|0)>0|(c|0)==0&f>>>0>0){nA=0,q=0;e:for(;;){if(Ge=1/(+(f>>>0)+4294967296*+(c|0)),xi=+C[se>>3],c=xt(f|0,c|0,nA|0,q|0)|0,Nt=+(c>>>0)+4294967296*+(S()|0),ye=+(nA>>>0)+4294967296*+(q|0),C[MA>>3]=Ge*(xi*Nt)+Ge*(+C[UA>>3]*ye),C[Ee>>3]=Ge*(+C[me>>3]*Nt)+Ge*(+C[ge>>3]*ye),c=ss(MA,n,GA)|0,c|0){l=c;break}Y=GA,G=t[Y>>2]|0,Y=t[Y+4>>2]|0,I=Fn(G|0,Y|0,A|0,r|0)|0,p=S()|0,c=o+(I<<3)|0,B=c,f=t[B>>2]|0,B=t[B+4>>2]|0;t:do if((f|0)==0&(B|0)==0)U=c,ve=16;else for(L=0,N=0;;){if((L|0)>(r|0)|(L|0)==(r|0)&N>>>0>A>>>0){l=1;break e}if((f|0)==(G|0)&(B|0)==(Y|0))break t;if(c=YA(I|0,p|0,1,0)|0,I=Nn(c|0,S()|0,A|0,r|0)|0,p=S()|0,N=YA(N|0,L|0,1,0)|0,L=S()|0,c=o+(I<<3)|0,B=c,f=t[B>>2]|0,B=t[B+4>>2]|0,(f|0)==0&(B|0)==0){U=c,ve=16;break}}while(!1);if((ve|0)==16&&(ve=0,!((G|0)==0&(Y|0)==0))&&(N=U,t[N>>2]=G,t[N+4>>2]=Y,N=i+(t[s>>2]<<3)|0,t[N>>2]=G,t[N+4>>2]=Y,N=s,N=YA(t[N>>2]|0,t[N+4>>2]|0,1,0)|0,G=S()|0,Y=s,t[Y>>2]=N,t[Y+4>>2]=G),nA=YA(nA|0,q|0,1,0)|0,q=S()|0,c=EA,f=t[c>>2]|0,c=t[c+4>>2]|0,!((c|0)>(q|0)|(c|0)==(q|0)&f>>>0>nA>>>0)){f=1;break A}}f=0}else f=1;while(!1);if($=$+1|0,!f){ve=21;break}if(c=t[e>>2]|0,($|0)>=(c|0)){l=0,ve=21;break}}return(ve|0)==21?(E=He,l|0):0}function ht(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0,ge=0,Ee=0,se=0,UA=0,EA=0,ve=0,He=0,ye=0,Ge=0,Nt=0;if(Nt=E,E=E+112|0,ve=Nt+80|0,c=Nt+72|0,He=Nt,ye=Nt+56|0,s=l0(r)|0,s|0)return Ge=s,E=Nt,Ge|0;if(f=e+8|0,Ge=Er((t[f>>2]<<5)+32|0)|0,!Ge)return Ge=13,E=Nt,Ge|0;if(fs(e,Ge),s=l0(r)|0,!s){if(UA=e,EA=t[UA+4>>2]|0,s=c,t[s>>2]=t[UA>>2],t[s+4>>2]=EA,si(c,ve),s=Vt(ve,A,He)|0,s)UA=0,EA=0;else{if(s=t[c>>2]|0,i=t[f>>2]|0,(i|0)>0){o=t[e+12>>2]|0,r=0;do s=(t[o+(r<<3)>>2]|0)+s|0,r=r+1|0;while((r|0)!=(i|0));r=s}else r=s;s=He,i=t[s>>2]|0,s=t[s+4>>2]|0,o=((r|0)<0)<<31>>31,(s|0)<(o|0)|(s|0)==(o|0)&i>>>0<r>>>0?(s=He,t[s>>2]=r,t[s+4>>2]=o,s=o):r=i,UA=YA(r|0,s|0,12,0)|0,EA=S()|0,s=He,t[s>>2]=UA,t[s+4>>2]=EA,s=0}if(!s){if(r=Gt(UA,8)|0,!r)return $A(Ge),Ge=13,E=Nt,Ge|0;if(l=Gt(UA,8)|0,!l)return $A(Ge),$A(r),Ge=13,E=Nt,Ge|0;Ee=ve,t[Ee>>2]=0,t[Ee+4>>2]=0,Ee=e,se=t[Ee+4>>2]|0,s=c,t[s>>2]=t[Ee>>2],t[s+4>>2]=se,s=Oe(c,UA,EA,A,ve,r,l)|0;A:do if(s)$A(r),$A(l),$A(Ge);else{e:do if((t[f>>2]|0)>0){for(o=e+12|0,i=0;s=Oe((t[o>>2]|0)+(i<<3)|0,UA,EA,A,ve,r,l)|0,i=i+1|0,!(s|0);)if((i|0)>=(t[f>>2]|0))break e;$A(r),$A(l),$A(Ge);break A}while(!1);(EA|0)>0|(EA|0)==0&UA>>>0>0&&An(l|0,0,UA<<3|0)|0,se=ve,Ee=t[se+4>>2]|0;e:do if((Ee|0)>0|(Ee|0)==0&(t[se>>2]|0)>>>0>0){OA=r,me=l,ge=r,Ee=l,se=r,s=r,U=r,MA=l,GA=l,r=l;t:for(;;){for(Y=0,nA=0,q=0,$=0,i=0,o=0;;){l=He,c=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(c|0));if(A=OA+(Y<<3)|0,f=t[A>>2]|0,A=t[A+4>>2]|0,P(f,A,1,He,0)|0){l=He,c=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(c|0));l=Gt(7,4)|0,l|0&&(X(f,A,1,He,l,7,0,0)|0,$A(l))}for(G=0;;){N=He+(G<<3)|0,L=t[N>>2]|0,N=t[N+4>>2]|0;r:do if((L|0)==0&(N|0)==0)l=i,c=o;else{if(p=Fn(L|0,N|0,UA|0,EA|0)|0,f=S()|0,l=n+(p<<3)|0,A=l,c=t[A>>2]|0,A=t[A+4>>2]|0,!((c|0)==0&(A|0)==0)){B=0,I=0;do{if((B|0)>(EA|0)|(B|0)==(EA|0)&I>>>0>UA>>>0)break t;if((c|0)==(L|0)&(A|0)==(N|0)){l=i,c=o;break r}l=YA(p|0,f|0,1,0)|0,p=Nn(l|0,S()|0,UA|0,EA|0)|0,f=S()|0,I=YA(I|0,B|0,1,0)|0,B=S()|0,l=n+(p<<3)|0,A=l,c=t[A>>2]|0,A=t[A+4>>2]|0}while(!((c|0)==0&(A|0)==0))}if((L|0)==0&(N|0)==0){l=i,c=o;break}dn(L,N,ye)|0,hs(e,Ge,ye)|0&&(I=YA(i|0,o|0,1,0)|0,o=S()|0,B=l,t[B>>2]=L,t[B+4>>2]=N,i=me+(i<<3)|0,t[i>>2]=L,t[i+4>>2]=N,i=I),l=i,c=o}while(!1);if(G=G+1|0,G>>>0>=7)break;i=l,o=c}if(Y=YA(Y|0,nA|0,1,0)|0,nA=S()|0,q=YA(q|0,$|0,1,0)|0,$=S()|0,o=ve,i=t[o>>2]|0,o=t[o+4>>2]|0,($|0)<(o|0)|($|0)==(o|0)&q>>>0<i>>>0)i=l,o=c;else break}if((o|0)>0|(o|0)==0&i>>>0>0){i=0,o=0;do $=OA+(i<<3)|0,t[$>>2]=0,t[$+4>>2]=0,i=YA(i|0,o|0,1,0)|0,o=S()|0,$=ve,q=t[$+4>>2]|0;while((o|0)<(q|0)|((o|0)==(q|0)?i>>>0<(t[$>>2]|0)>>>0:0))}if($=ve,t[$>>2]=l,t[$+4>>2]=c,(c|0)>0|(c|0)==0&l>>>0>0)G=r,Y=GA,nA=se,q=MA,$=me,r=U,GA=s,MA=ge,U=G,s=Y,se=Ee,Ee=nA,ge=q,me=OA,OA=$;else break e}$A(ge),$A(Ee),$A(Ge),s=1;break A}else s=l;while(!1);$A(Ge),$A(r),$A(s),s=0}while(!1);return Ge=s,E=Nt,Ge|0}}return $A(Ge),Ge=s,E=Nt,Ge|0}function _t(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(p=E,E=E+176|0,c=p,(A|0)<1)return ci(r,0,0),f=0,E=p,f|0;for(l=e,l=xA(t[l>>2]|0,t[l+4>>2]|0,52)|0,S()|0,ci(r,(A|0)>6?A:6,l&15),l=0;n=e+(l<<3)|0,n=In(t[n>>2]|0,t[n+4>>2]|0,c)|0,!(n|0);){if(n=t[c>>2]|0,(n|0)>0){o=0;do i=c+8+(o<<4)|0,o=o+1|0,n=c+8+(((o|0)%(n|0)|0)<<4)|0,s=pa(r,n,i)|0,s?di(r,s)|0:ma(r,i,n)|0,n=t[c>>2]|0;while((o|0)<(n|0))}if(l=l+1|0,(l|0)>=(A|0)){n=0,f=13;break}}return(f|0)==13?(E=p,n|0):(fi(r),f=n,E=p,f|0)}function Je(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;if(i=E,E=E+32|0,n=i,s=i+16|0,e=_t(e,A,s)|0,e|0)return r=e,E=i,r|0;if(t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,e=hi(s)|0,e|0)do{A=Vl(r)|0;do Wl(A,e)|0,o=e+16|0,t[n>>2]=t[o>>2],t[n+4>>2]=t[o+4>>2],t[n+8>>2]=t[o+8>>2],t[n+12>>2]=t[o+12>>2],di(s,e)|0,e=ga(s,n)|0;while((e|0)!=0);e=hi(s)|0}while((e|0)!=0);return fi(s),e=Yl(r)|0,e?(ei(r),o=e,E=i,o|0):(o=0,E=i,o|0)}function je(e){return e=e|0,e>>>0>121?(e=0,e|0):(e=t[7696+(e*28|0)+16>>2]|0,e|0)}function jt(e){return e=e|0,(e|0)==4|(e|0)==117|0}function vr(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)>>2]|0}function mr(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)+4>>2]|0}function Pr(e,A){e=e|0,A=A|0,e=7696+(e*28|0)|0,t[A>>2]=t[e>>2],t[A+4>>2]=t[e+4>>2],t[A+8>>2]=t[e+8>>2],t[A+12>>2]=t[e+12>>2]}function sr(e,A){e=e|0,A=A|0;var r=0,n=0;if(A>>>0>20)return A=-1,A|0;do if((t[11120+(A*216|0)>>2]|0)!=(e|0))if((t[11120+(A*216|0)+8>>2]|0)!=(e|0))if((t[11120+(A*216|0)+16>>2]|0)!=(e|0))if((t[11120+(A*216|0)+24>>2]|0)!=(e|0))if((t[11120+(A*216|0)+32>>2]|0)!=(e|0))if((t[11120+(A*216|0)+40>>2]|0)!=(e|0))if((t[11120+(A*216|0)+48>>2]|0)!=(e|0))if((t[11120+(A*216|0)+56>>2]|0)!=(e|0))if((t[11120+(A*216|0)+64>>2]|0)!=(e|0))if((t[11120+(A*216|0)+72>>2]|0)!=(e|0))if((t[11120+(A*216|0)+80>>2]|0)!=(e|0))if((t[11120+(A*216|0)+88>>2]|0)!=(e|0))if((t[11120+(A*216|0)+96>>2]|0)!=(e|0))if((t[11120+(A*216|0)+104>>2]|0)!=(e|0))if((t[11120+(A*216|0)+112>>2]|0)!=(e|0))if((t[11120+(A*216|0)+120>>2]|0)!=(e|0))if((t[11120+(A*216|0)+128>>2]|0)!=(e|0))if((t[11120+(A*216|0)+136>>2]|0)==(e|0))e=2,r=1,n=2;else{if((t[11120+(A*216|0)+144>>2]|0)==(e|0)){e=0,r=2,n=0;break}if((t[11120+(A*216|0)+152>>2]|0)==(e|0)){e=0,r=2,n=1;break}if((t[11120+(A*216|0)+160>>2]|0)==(e|0)){e=0,r=2,n=2;break}if((t[11120+(A*216|0)+168>>2]|0)==(e|0)){e=1,r=2,n=0;break}if((t[11120+(A*216|0)+176>>2]|0)==(e|0)){e=1,r=2,n=1;break}if((t[11120+(A*216|0)+184>>2]|0)==(e|0)){e=1,r=2,n=2;break}if((t[11120+(A*216|0)+192>>2]|0)==(e|0)){e=2,r=2,n=0;break}if((t[11120+(A*216|0)+200>>2]|0)==(e|0)){e=2,r=2,n=1;break}if((t[11120+(A*216|0)+208>>2]|0)==(e|0)){e=2,r=2,n=2;break}else e=-1;return e|0}else e=2,r=1,n=1;else e=2,r=1,n=0;else e=1,r=1,n=2;else e=1,r=1,n=1;else e=1,r=1,n=0;else e=0,r=1,n=2;else e=0,r=1,n=1;else e=0,r=1,n=0;else e=2,r=0,n=2;else e=2,r=0,n=1;else e=2,r=0,n=0;else e=1,r=0,n=2;else e=1,r=0,n=1;else e=1,r=0,n=0;else e=0,r=0,n=2;else e=0,r=0,n=1;else e=0,r=0,n=0;while(!1);return A=t[11120+(A*216|0)+(r*72|0)+(e*24|0)+(n<<3)+4>>2]|0,A|0}function Qr(e,A){return e=e|0,A=A|0,(t[7696+(e*28|0)+20>>2]|0)==(A|0)?(A=1,A|0):(A=(t[7696+(e*28|0)+24>>2]|0)==(A|0),A|0)}function an(e,A){return e=e|0,A=A|0,t[848+(e*28|0)+(A<<2)>>2]|0}function un(e,A){return e=e|0,A=A|0,(t[848+(e*28|0)>>2]|0)==(A|0)?(A=0,A|0):(t[848+(e*28|0)+4>>2]|0)==(A|0)?(A=1,A|0):(t[848+(e*28|0)+8>>2]|0)==(A|0)?(A=2,A|0):(t[848+(e*28|0)+12>>2]|0)==(A|0)?(A=3,A|0):(t[848+(e*28|0)+16>>2]|0)==(A|0)?(A=4,A|0):(t[848+(e*28|0)+20>>2]|0)==(A|0)?(A=5,A|0):((t[848+(e*28|0)+24>>2]|0)==(A|0)?6:7)|0}function Kn(){return 122}function $n(e){e=e|0;var A=0,r=0,n=0;A=0;do CA(A|0,0,45)|0,n=S()|0|134225919,r=e+(A<<3)|0,t[r>>2]=-1,t[r+4>>2]=n,A=A+1|0;while((A|0)!=122);return 0}function Zn(e){e=e|0;var A=0,r=0,n=0;return n=+C[e+16>>3],r=+C[e+24>>3],A=n-r,+(n<r?A+6.283185307179586:A)}function zt(e){return e=e|0,+C[e+16>>3]<+C[e+24>>3]|0}function cn(e){return e=e|0,+(+C[e>>3]-+C[e+8>>3])}function br(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;return r=+C[A>>3],!(r>=+C[e+8>>3])||!(r<=+C[e>>3])?(A=0,A|0):(n=+C[e+16>>3],r=+C[e+24>>3],s=+C[A+8>>3],A=s>=r,e=s<=n&1,n<r?A&&(e=1):A||(e=0),A=(e|0)!=0,A|0)}function Ne(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;return+C[e>>3]<+C[A+8>>3]||+C[e+8>>3]>+C[A>>3]?(n=0,n|0):(i=+C[e+16>>3],r=e+24|0,p=+C[r>>3],o=i<p,n=A+16|0,f=+C[n>>3],s=A+24|0,c=+C[s>>3],l=f<c,A=p-f<c-i,e=o?l|A?1:2:0,A=l?o?1:A?2:1:0,i=+Kt(i,e),i<+Kt(+C[s>>3],A)||(p=+Kt(+C[r>>3],e),p>+Kt(+C[n>>3],A))?(l=0,l|0):(l=1,l|0))}function Or(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0;i=+C[e+16>>3],c=+C[e+24>>3],e=i<c,l=+C[A+16>>3],o=+C[A+24>>3],s=l<o,A=c-l<o-i,t[r>>2]=e?s|A?1:2:0,t[n>>2]=s?e?1:A?2:1:0}function zr(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;return+C[e>>3]<+C[A>>3]||+C[e+8>>3]>+C[A+8>>3]?(n=0,n|0):(n=e+16|0,c=+C[n>>3],i=+C[e+24>>3],o=c<i,r=A+16|0,p=+C[r>>3],s=A+24|0,f=+C[s>>3],l=p<f,A=i-p<f-c,e=o?l|A?1:2:0,A=l?o?1:A?2:1:0,i=+Kt(i,e),i<=+Kt(+C[s>>3],A)?(p=+Kt(+C[n>>3],e),l=p>=+Kt(+C[r>>3],A),l|0):(l=0,l|0))}function kr(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;s=E,E=E+176|0,n=s,t[n>>2]=4,l=+C[A>>3],C[n+8>>3]=l,i=+C[A+16>>3],C[n+16>>3]=i,C[n+24>>3]=l,l=+C[A+24>>3],C[n+32>>3]=l,o=+C[A+8>>3],C[n+40>>3]=o,C[n+48>>3]=l,C[n+56>>3]=o,C[n+64>>3]=i,A=n+72|0,r=A+96|0;do t[A>>2]=0,A=A+4|0;while((A|0)<(r|0));Pn(e|0,n|0,168)|0,E=s}function Vt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0;N=E,E=E+288|0,p=N+264|0,B=N+96|0,f=N,l=f,c=l+96|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(c|0));return A=os(A,f)|0,A|0?(L=A,E=N,L|0):(c=f,f=t[c>>2]|0,c=t[c+4>>2]|0,dn(f,c,p)|0,In(f,c,B)|0,o=+i0(p,B+8|0),C[p>>3]=+C[e>>3],c=p+8|0,C[c>>3]=+C[e+16>>3],C[B>>3]=+C[e+8>>3],f=B+8|0,C[f>>3]=+C[e+24>>3],s=+i0(p,B),Y=+C[c>>3]-+C[f>>3],i=+qA(+Y),G=+C[p>>3]-+C[B>>3],n=+qA(+G),!(Y==0|G==0)&&(Y=+gi(+i,+n),Y=+Qt(+(s*s/+B0(+(Y/+B0(+i,+n)),3)/(o*(o*2.59807621135)*.8))),C[xe>>3]=Y,I=~~Y>>>0,L=+qA(Y)>=1?Y>0?~~+ot(+Ue(Y/4294967296),4294967295)>>>0:~~+Qt((Y-+(~~Y>>>0))/4294967296)>>>0:0,(t[xe+4>>2]&2146435072|0)!=2146435072)?(B=(I|0)==0&(L|0)==0,A=r,t[A>>2]=B?1:I,t[A+4>>2]=B?0:L,A=0):A=1,L=A,E=N,L|0)}function $r(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0;f=E,E=E+288|0,o=f+264|0,l=f+96|0,c=f,s=c,i=s+96|0;do t[s>>2]=0,s=s+4|0;while((s|0)<(i|0));return r=os(r,c)|0,r|0?(n=r,E=f,n|0):(r=c,s=t[r>>2]|0,r=t[r+4>>2]|0,dn(s,r,o)|0,In(s,r,l)|0,p=+i0(o,l+8|0),p=+Qt(+(+i0(e,A)/(p*2))),C[xe>>3]=p,r=~~p>>>0,s=+qA(p)>=1?p>0?~~+ot(+Ue(p/4294967296),4294967295)>>>0:~~+Qt((p-+(~~p>>>0))/4294967296)>>>0:0,(t[xe+4>>2]&2146435072|0)==2146435072?(n=1,E=f,n|0):(c=(r|0)==0&(s|0)==0,t[n>>2]=c?1:r,t[n+4>>2]=c?0:s,n=0,E=f,n|0))}function pr(e,A){e=e|0,A=+A;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;i=e+16|0,o=+C[i>>3],r=e+24|0,s=+C[r>>3],n=o-s,n=o<s?n+6.283185307179586:n,f=+C[e>>3],l=e+8|0,c=+C[l>>3],p=f-c,n=(n*A-n)*.5,A=(p*A-p)*.5,f=f+A,C[e>>3]=f>1.5707963267948966?1.5707963267948966:f,A=c-A,C[l>>3]=A<-1.5707963267948966?-1.5707963267948966:A,A=o+n,A=A>3.141592653589793?A+-6.283185307179586:A,C[i>>3]=A<-3.141592653589793?A+6.283185307179586:A,A=s-n,A=A>3.141592653589793?A+-6.283185307179586:A,C[r>>3]=A<-3.141592653589793?A+6.283185307179586:A}function Bn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0,t[e>>2]=A,t[e+4>>2]=r,t[e+8>>2]=n}function Hr(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0;B=A+8|0,t[B>>2]=0,c=+C[e>>3],o=+qA(+c),f=+C[e+8>>3],l=+qA(+f)*1.1547005383792515,o=o+l*.5,r=~~o,e=~~l,o=o-+(r|0),l=l-+(e|0);do if(o<.5)if(o<.3333333333333333)if(t[A>>2]=r,l<(o+1)*.5){t[A+4>>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}else if(I=1-o,e=(!(l<I)&1)+e|0,t[A+4>>2]=e,I<=l&l<o*2){r=r+1|0,t[A>>2]=r;break}else{t[A>>2]=r;break}else{if(!(o<.6666666666666666))if(r=r+1|0,t[A>>2]=r,l<o*.5){t[A+4>>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}if(l<1-o){if(t[A+4>>2]=e,o*2+-1<l){t[A>>2]=r;break}}else e=e+1|0,t[A+4>>2]=e;r=r+1|0,t[A>>2]=r}while(!1);do if(c<0)if(e&1){p=(e+1|0)/2|0,p=xt(r|0,((r|0)<0)<<31>>31|0,p|0,((p|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-((+(p>>>0)+4294967296*+(S()|0))*2+1)),t[A>>2]=r;break}else{p=(e|0)/2|0,p=xt(r|0,((r|0)<0)<<31>>31|0,p|0,((p|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-(+(p>>>0)+4294967296*+(S()|0))*2),t[A>>2]=r;break}while(!1);p=A+4|0,f<0&&(r=r-((e<<1|1|0)/2|0)|0,t[A>>2]=r,e=0-e|0,t[p>>2]=e),n=e-r|0,(r|0)<0?(s=0-r|0,t[p>>2]=n,t[B>>2]=s,t[A>>2]=0,e=n,r=0):s=0,(e|0)<0&&(r=r-e|0,t[A>>2]=r,s=s-e|0,t[B>>2]=s,t[p>>2]=0,e=0),i=r-s|0,n=e-s|0,(s|0)<0&&(t[A>>2]=i,t[p>>2]=n,t[B>>2]=0,e=n,r=i,s=0),n=(e|0)<(r|0)?e:r,n=(s|0)<(n|0)?s:n,!((n|0)<=0)&&(t[A>>2]=r-n,t[p>>2]=e-n,t[B>>2]=s-n)}function et(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,(A|0)<0&&(r=r-A|0,t[o>>2]=r,i=e+8|0,t[i>>2]=(t[i>>2]|0)-A,t[e>>2]=0,A=0),(r|0)<0?(A=A-r|0,t[e>>2]=A,i=e+8|0,s=(t[i>>2]|0)-r|0,t[i>>2]=s,t[o>>2]=0,r=0):(s=e+8|0,i=s,s=t[s>>2]|0),(s|0)<0&&(A=A-s|0,t[e>>2]=A,r=r-s|0,t[o>>2]=r,t[i>>2]=0,s=0),n=(r|0)<(A|0)?r:A,n=(s|0)<(n|0)?s:n,!((n|0)<=0)&&(t[e>>2]=A-n,t[o>>2]=r-n,t[i>>2]=s-n)}function ir(e,A){e=e|0,A=A|0;var r=0,n=0;n=t[e+8>>2]|0,r=+((t[e+4>>2]|0)-n|0),C[A>>3]=+((t[e>>2]|0)-n|0)-r*.5,C[A+8>>3]=r*.8660254037844386}function H(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[A>>2]|0)+(t[e>>2]|0),t[r+4>>2]=(t[A+4>>2]|0)+(t[e+4>>2]|0),t[r+8>>2]=(t[A+8>>2]|0)+(t[e+8>>2]|0)}function oA(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[e>>2]|0)-(t[A>>2]|0),t[r+4>>2]=(t[e+4>>2]|0)-(t[A+4>>2]|0),t[r+8>>2]=(t[e+8>>2]|0)-(t[A+8>>2]|0)}function pA(e,A){e=e|0,A=A|0;var r=0,n=0;r=pt(t[e>>2]|0,A)|0,t[e>>2]=r,r=e+4|0,n=pt(t[r>>2]|0,A)|0,t[r>>2]=n,e=e+8|0,A=pt(t[e>>2]|0,A)|0,t[e>>2]=A}function NA(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;o=t[e>>2]|0,l=(o|0)<0,n=(t[e+4>>2]|0)-(l?o:0)|0,i=(n|0)<0,s=(i?0-n|0:0)+((t[e+8>>2]|0)-(l?o:0))|0,r=(s|0)<0,e=r?0:s,A=(i?0:n)-(r?s:0)|0,s=(l?0:o)-(i?n:0)-(r?s:0)|0,r=(A|0)<(s|0)?A:s,r=(e|0)<(r|0)?e:r,n=(r|0)>0,e=e-(n?r:0)|0,A=A-(n?r:0)|0;A:do switch(s-(n?r:0)|0){case 0:switch(A|0){case 0:return l=(e|0)==0?0:(e|0)==1?1:7,l|0;case 1:return l=(e|0)==0?2:(e|0)==1?3:7,l|0;default:break A}case 1:switch(A|0){case 0:return l=(e|0)==0?4:(e|0)==1?5:7,l|0;case 1:{if(!e)e=6;else break A;return e|0}default:break A}}while(!1);return l=7,l|0}function HA(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0;if(c=e+8|0,o=t[c>>2]|0,l=(t[e>>2]|0)-o|0,f=e+4|0,o=(t[f>>2]|0)-o|0,l>>>0>715827881|o>>>0>715827881){if(n=(l|0)>0,s=2147483647-l|0,i=-2147483648-l|0,(n?(s|0)<(l|0):(i|0)>(l|0))||(r=l<<1,n?(2147483647-r|0)<(l|0):(-2147483648-r|0)>(l|0))||((o|0)>0?(2147483647-o|0)<(o|0):(-2147483648-o|0)>(o|0))||(A=l*3|0,r=o<<1,(n?(s|0)<(r|0):(i|0)>(r|0))||((l|0)>-1?(A|-2147483648|0)>=(o|0):(A^-2147483648|0)<(o|0))))return f=1,f|0}else r=o<<1,A=l*3|0;return n=Jr(+(A-o|0)*.14285714285714285)|0,t[e>>2]=n,s=Jr(+(r+l|0)*.14285714285714285)|0,t[f>>2]=s,t[c>>2]=0,r=(s|0)<(n|0),A=r?n:s,r=r?s:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&PA(27795,26892,354,26903),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&PA(27795,26892,354,26903)),A=s-n|0,(n|0)<0?(r=0-n|0,t[f>>2]=A,t[c>>2]=r,t[e>>2]=0,n=0):(A=s,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[c>>2]=r,t[f>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[f>>2]=s,t[c>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,(n|0)<=0?(f=0,f|0):(t[e>>2]=s-n,t[f>>2]=A-n,t[c>>2]=r-n,f=0,f|0)}function oe(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,c=0;if(o=e+8|0,s=t[o>>2]|0,i=(t[e>>2]|0)-s|0,l=e+4|0,s=(t[l>>2]|0)-s|0,i>>>0>715827881|s>>>0>715827881){if(r=(i|0)>0,(r?(2147483647-i|0)<(i|0):(-2147483648-i|0)>(i|0))||(A=i<<1,n=(s|0)>0,n?(2147483647-s|0)<(s|0):(-2147483648-s|0)>(s|0)))return l=1,l|0;if(c=s<<1,(n?(2147483647-c|0)<(s|0):(-2147483648-c|0)>(s|0))||(r?(2147483647-A|0)<(s|0):(-2147483648-A|0)>(s|0))||(r=s*3|0,(s|0)>-1?(r|-2147483648|0)>=(i|0):(r^-2147483648|0)<(i|0)))return c=1,c|0}else r=s*3|0,A=i<<1;return n=Jr(+(A+s|0)*.14285714285714285)|0,t[e>>2]=n,s=Jr(+(r-i|0)*.14285714285714285)|0,t[l>>2]=s,t[o>>2]=0,r=(s|0)<(n|0),A=r?n:s,r=r?s:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&PA(27795,26892,402,26917),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&PA(27795,26892,402,26917)),A=s-n|0,(n|0)<0?(r=0-n|0,t[l>>2]=A,t[o>>2]=r,t[e>>2]=0,n=0):(A=s,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,(n|0)<=0?(c=0,c|0):(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n,c=0,c|0)}function De(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;o=e+8|0,r=t[o>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=Jr(+((A*3|0)-r|0)*.14285714285714285)|0,t[e>>2]=n,A=Jr(+((r<<1)+A|0)*.14285714285714285)|0,t[l>>2]=A,t[o>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[o>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n)}function Qe(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;o=e+8|0,r=t[o>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=Jr(+((A<<1)+r|0)*.14285714285714285)|0,t[e>>2]=n,A=Jr(+((r*3|0)-A|0)*.14285714285714285)|0,t[l>>2]=A,t[o>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[o>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),i=n-r|0,s=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,A=s,s=i,r=0):s=n,n=(A|0)<(s|0)?A:s,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n)}function st(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,l=e+8|0,n=t[l>>2]|0,s=r+(A*3|0)|0,t[e>>2]=s,r=n+(r*3|0)|0,t[o>>2]=r,A=(n*3|0)+A|0,t[l>>2]=A,n=r-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=s,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function Xe(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A*3|0)+s|0,s=r+(s*3|0)|0,t[e>>2]=s,t[o>>2]=n,A=(r*3|0)+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,s=0):r=n,(r|0)<0&&(s=s-r|0,t[e>>2]=s,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=s-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=n,t[l>>2]=0,s=i,A=0):n=r,r=(n|0)<(s|0)?n:s,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=s-r,t[o>>2]=n-r,t[l>>2]=A-r)}function gt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;(A+-1|0)>>>0>=6||(s=(t[15440+(A*12|0)>>2]|0)+(t[e>>2]|0)|0,t[e>>2]=s,l=e+4|0,n=(t[15440+(A*12|0)+4>>2]|0)+(t[l>>2]|0)|0,t[l>>2]=n,o=e+8|0,A=(t[15440+(A*12|0)+8>>2]|0)+(t[o>>2]|0)|0,t[o>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[l>>2]=r,t[o>>2]=A,t[e>>2]=0,n=0):(r=n,n=s),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[o>>2]=A,t[l>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[l>>2]=s,t[o>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[l>>2]=s-r,t[o>>2]=A-r))}function tt(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=A+s|0,s=r+s|0,t[e>>2]=s,t[o>>2]=n,A=r+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=s),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function yt(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,n=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,s=n+A|0,t[e>>2]=s,n=r+n|0,t[o>>2]=n,A=r+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=s),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function Wt(e){switch(e=e|0,e|0){case 1:{e=5;break}case 5:{e=4;break}case 4:{e=6;break}case 6:{e=2;break}case 2:{e=3;break}case 3:{e=1;break}}return e|0}function Yt(e){switch(e=e|0,e|0){case 1:{e=3;break}case 3:{e=2;break}case 2:{e=6;break}case 6:{e=4;break}case 4:{e=5;break}case 5:{e=1;break}}return e|0}function qn(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,l=e+8|0,n=t[l>>2]|0,s=r+(A<<1)|0,t[e>>2]=s,r=n+(r<<1)|0,t[o>>2]=r,A=(n<<1)+A|0,t[l>>2]=A,n=r-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=s,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=n-A|0,s=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=s,t[l>>2]=0,n=i,A=0):s=r,r=(s|0)<(n|0)?s:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=s-r,t[l>>2]=A-r)}function Jn(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A<<1)+s|0,s=r+(s<<1)|0,t[e>>2]=s,t[o>>2]=n,A=(r<<1)+A|0,t[l>>2]=A,r=n-s|0,(s|0)<0?(A=A-s|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,s=0):r=n,(r|0)<0&&(s=s-r|0,t[e>>2]=s,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),i=s-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[o>>2]=n,t[l>>2]=0,s=i,A=0):n=r,r=(n|0)<(s|0)?n:s,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=s-r,t[o>>2]=n-r,t[l>>2]=A-r)}function Dn(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;return o=(t[e>>2]|0)-(t[A>>2]|0)|0,l=(o|0)<0,n=(t[e+4>>2]|0)-(t[A+4>>2]|0)-(l?o:0)|0,i=(n|0)<0,s=(l?0-o|0:0)+(t[e+8>>2]|0)-(t[A+8>>2]|0)+(i?0-n|0:0)|0,e=(s|0)<0,A=e?0:s,r=(i?0:n)-(e?s:0)|0,s=(l?0:o)-(i?n:0)-(e?s:0)|0,e=(r|0)<(s|0)?r:s,e=(A|0)<(e|0)?A:e,n=(e|0)>0,A=A-(n?e:0)|0,r=r-(n?e:0)|0,e=s-(n?e:0)|0,e=(e|0)>-1?e:0-e|0,r=(r|0)>-1?r:0-r|0,A=(A|0)>-1?A:0-A|0,A=(r|0)>(A|0)?r:A,((e|0)>(A|0)?e:A)|0}function Xn(e,A){e=e|0,A=A|0;var r=0;r=t[e+8>>2]|0,t[A>>2]=(t[e>>2]|0)-r,t[A+4>>2]=(t[e+4>>2]|0)-r}function Rt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;return n=t[e>>2]|0,t[A>>2]=n,s=t[e+4>>2]|0,o=A+4|0,t[o>>2]=s,l=A+8|0,t[l>>2]=0,r=(s|0)<(n|0),e=r?n:s,r=r?s:n,(r|0)<0&&((r|0)==-2147483648||((e|0)>0?(2147483647-e|0)<(r|0):(-2147483648-e|0)>(r|0))||((e|0)>-1?(e|-2147483648|0)>=(r|0):(e^-2147483648|0)<(r|0)))?(A=1,A|0):(e=s-n|0,(n|0)<0?(r=0-n|0,t[o>>2]=e,t[l>>2]=r,t[A>>2]=0,n=0):(e=s,r=0),(e|0)<0&&(n=n-e|0,t[A>>2]=n,r=r-e|0,t[l>>2]=r,t[o>>2]=0,e=0),i=n-r|0,s=e-r|0,(r|0)<0?(t[A>>2]=i,t[o>>2]=s,t[l>>2]=0,e=s,s=i,r=0):s=n,n=(e|0)<(s|0)?e:s,n=(r|0)<(n|0)?r:n,(n|0)<=0?(A=0,A|0):(t[A>>2]=s-n,t[o>>2]=e-n,t[l>>2]=r-n,A=0,A|0))}function A0(e){e=e|0;var A=0,r=0,n=0,s=0;A=e+8|0,s=t[A>>2]|0,r=s-(t[e>>2]|0)|0,t[e>>2]=r,n=e+4|0,e=(t[n>>2]|0)-s|0,t[n>>2]=e,t[A>>2]=0-(e+r)}function e0(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;r=t[e>>2]|0,A=0-r|0,t[e>>2]=A,o=e+8|0,t[o>>2]=0,l=e+4|0,n=t[l>>2]|0,s=n+r|0,(r|0)>0?(t[l>>2]=s,t[o>>2]=r,t[e>>2]=0,A=0,n=s):r=0,(n|0)<0?(i=A-n|0,t[e>>2]=i,r=r-n|0,t[o>>2]=r,t[l>>2]=0,s=i-r|0,A=0-r|0,(r|0)<0?(t[e>>2]=s,t[l>>2]=A,t[o>>2]=0,n=A,r=0):(n=0,s=i)):s=A,A=(n|0)<(s|0)?n:s,A=(r|0)<(A|0)?r:A,!((A|0)<=0)&&(t[e>>2]=s-A,t[l>>2]=n-A,t[o>>2]=r-A)}function ts(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0;if(B=E,E=E+64|0,p=B,l=B+56|0,!(!0&(A&2013265920|0)==134217728&(!0&(n&2013265920|0)==134217728)))return s=5,E=B,s|0;if((e|0)==(r|0)&(A|0)==(n|0))return t[s>>2]=0,s=0,E=B,s|0;if(o=xA(e|0,A|0,52)|0,S()|0,o=o&15,f=xA(r|0,n|0,52)|0,S()|0,(o|0)!=(f&15|0))return s=12,E=B,s|0;if(i=o+-1|0,o>>>0>1){Lt(e,A,i,p)|0,Lt(r,n,i,l)|0,f=p,c=t[f>>2]|0,f=t[f+4>>2]|0;A:do if((c|0)==(t[l>>2]|0)&&(f|0)==(t[l+4>>2]|0)){o=(o^15)*3|0,i=xA(e|0,A|0,o|0)|0,S()|0,i=i&7,o=xA(r|0,n|0,o|0)|0,S()|0,o=o&7;do if((i|0)==0|(o|0)==0)t[s>>2]=1,i=0;else if((i|0)==7)i=5;else{if((i|0)==1|(o|0)==1&&Fe(c,f)|0){i=5;break}if((t[15536+(i<<2)>>2]|0)!=(o|0)&&(t[15568+(i<<2)>>2]|0)!=(o|0))break A;t[s>>2]=1,i=0}while(!1);return s=i,E=B,s|0}while(!1)}i=p,o=i+56|0;do t[i>>2]=0,i=i+4|0;while((i|0)<(o|0));return v(e,A,1,p)|0,A=p,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0))&&(A=p+8|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+16|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+24|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+32|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=p+40|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))?(i=p+48|0,i=((t[i>>2]|0)==(r|0)?(t[i+4>>2]|0)==(n|0):0)&1):i=1,t[s>>2]=i,s=0,E=B,s|0}function v0(e,A,r,n,s){return e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,r=Ae(e,A,r,n)|0,(r|0)==7?(s=11,s|0):(n=CA(r|0,0,56)|0,A=A&-2130706433|(S()|0)|268435456,t[s>>2]=e|n,t[s+4>>2]=A,s=0,s|0)}function _n(e,A,r){return e=e|0,A=A|0,r=r|0,!0&(A&2013265920|0)==268435456?(t[r>>2]=e,t[r+4>>2]=A&-2130706433|134217728,r=0,r|0):(r=6,r|0)}function b0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return s=E,E=E+16|0,n=s,t[n>>2]=0,!0&(A&2013265920|0)==268435456?(i=xA(e|0,A|0,56)|0,S()|0,n=K(e,A&-2130706433|134217728,i&7,n,r)|0,E=s,n|0):(n=6,E=s,n|0)}function t0(e,A){e=e|0,A=A|0;var r=0;switch(r=xA(e|0,A|0,56)|0,S()|0,r&7){case 0:case 7:return r=0,r|0}return r=A&-2130706433|134217728,!(!0&(A&2013265920|0)==268435456)||!0&(A&117440512|0)==16777216&(Fe(e,r)|0)!=0?(r=0,r|0):(r=ze(e,r)|0,r|0)}function jn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;return s=E,E=E+16|0,n=s,!0&(A&2013265920|0)==268435456?(i=A&-2130706433|134217728,o=r,t[o>>2]=e,t[o+4>>2]=i,t[n>>2]=0,A=xA(e|0,A|0,56)|0,S()|0,n=K(e,i,A&7,n,r+8|0)|0,E=s,n|0):(n=6,E=s,n|0)}function Rn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;return s=(Fe(e,A)|0)==0,A=A&-2130706433,n=r,t[n>>2]=s?e:0,t[n+4>>2]=s?A|285212672:0,n=r+8|0,t[n>>2]=e,t[n+4>>2]=A|301989888,n=r+16|0,t[n>>2]=e,t[n+4>>2]=A|318767104,n=r+24|0,t[n>>2]=e,t[n+4>>2]=A|335544320,n=r+32|0,t[n>>2]=e,t[n+4>>2]=A|352321536,r=r+40|0,t[r>>2]=e,t[r+4>>2]=A|369098752,0}function fn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;return o=E,E=E+16|0,s=o,i=A&-2130706433|134217728,!0&(A&2013265920|0)==268435456?(n=xA(e|0,A|0,56)|0,S()|0,n=fa(e,i,n&7)|0,(n|0)==-1?(t[r>>2]=0,i=6,E=o,i|0):(Tn(e,i,s)|0&&PA(27795,26932,282,26947),A=xA(e|0,A|0,52)|0,S()|0,A=A&15,Fe(e,i)|0?w(s,A,n,2,r):AA(s,A,n,2,r),i=0,E=o,i|0)):(i=6,E=o,i|0)}function k0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;n=E,E=E+16|0,s=n,C0(e,A,r,s),Hr(s,r+4|0),E=n}function C0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0;if(l=E,E=E+16|0,c=l,r0(e,r,c),i=+Dt(+(1-+C[c>>3]*.5)),i<1e-16){t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,t[n+12>>2]=0,E=l;return}if(c=t[r>>2]|0,s=+C[15920+(c*24|0)>>3],s=+s0(s-+s0(+Ll(15600+(c<<4)|0,e))),or(A)|0?o=+s0(s+-.3334731722518321):o=s,s=+rt(+i)*2.618033988749896,(A|0)>0){e=0;do s=s*2.6457513110645907,e=e+1|0;while((e|0)!=(A|0))}i=+ue(+o)*s,C[n>>3]=i,o=+ie(+o)*s,C[n+8>>3]=o,E=l}function r0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(i=E,E=E+32|0,s=i,ca(e,s),t[A>>2]=0,C[r>>3]=5,n=+ut(16400,s),n<+C[r>>3]&&(t[A>>2]=0,C[r>>3]=n),n=+ut(16424,s),n<+C[r>>3]&&(t[A>>2]=1,C[r>>3]=n),n=+ut(16448,s),n<+C[r>>3]&&(t[A>>2]=2,C[r>>3]=n),n=+ut(16472,s),n<+C[r>>3]&&(t[A>>2]=3,C[r>>3]=n),n=+ut(16496,s),n<+C[r>>3]&&(t[A>>2]=4,C[r>>3]=n),n=+ut(16520,s),n<+C[r>>3]&&(t[A>>2]=5,C[r>>3]=n),n=+ut(16544,s),n<+C[r>>3]&&(t[A>>2]=6,C[r>>3]=n),n=+ut(16568,s),n<+C[r>>3]&&(t[A>>2]=7,C[r>>3]=n),n=+ut(16592,s),n<+C[r>>3]&&(t[A>>2]=8,C[r>>3]=n),n=+ut(16616,s),n<+C[r>>3]&&(t[A>>2]=9,C[r>>3]=n),n=+ut(16640,s),n<+C[r>>3]&&(t[A>>2]=10,C[r>>3]=n),n=+ut(16664,s),n<+C[r>>3]&&(t[A>>2]=11,C[r>>3]=n),n=+ut(16688,s),n<+C[r>>3]&&(t[A>>2]=12,C[r>>3]=n),n=+ut(16712,s),n<+C[r>>3]&&(t[A>>2]=13,C[r>>3]=n),n=+ut(16736,s),n<+C[r>>3]&&(t[A>>2]=14,C[r>>3]=n),n=+ut(16760,s),n<+C[r>>3]&&(t[A>>2]=15,C[r>>3]=n),n=+ut(16784,s),n<+C[r>>3]&&(t[A>>2]=16,C[r>>3]=n),n=+ut(16808,s),n<+C[r>>3]&&(t[A>>2]=17,C[r>>3]=n),n=+ut(16832,s),n<+C[r>>3]&&(t[A>>2]=18,C[r>>3]=n),n=+ut(16856,s),!(n<+C[r>>3])){E=i;return}t[A>>2]=19,C[r>>3]=n,E=i}function Zr(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0;if(i=+ua(e),i<1e-16){A=15600+(A<<4)|0,t[s>>2]=t[A>>2],t[s+4>>2]=t[A+4>>2],t[s+8>>2]=t[A+8>>2],t[s+12>>2]=t[A+12>>2];return}if(o=+nt(+ +C[e+8>>3],+ +C[e>>3]),(r|0)>0){e=0;do i=i*.37796447300922725,e=e+1|0;while((e|0)!=(r|0))}l=i*.3333333333333333,n?(r=(or(r)|0)==0,i=+Ct(+((r?l:l*.37796447300922725)*.381966011250105))):(i=+Ct(+(i*.381966011250105)),or(r)|0&&(o=+s0(o+.3334731722518321))),Nl(15600+(A<<4)|0,+s0(+C[15920+(A*24|0)>>3]-o),i,s)}function d(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;n=E,E=E+16|0,s=n,ir(e+4|0,s),Zr(s,t[e>>2]|0,A,0,r),E=n}function w(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0,ge=0,Ee=0,se=0,UA=0,EA=0,ve=0,He=0,ye=0;if(ve=E,E=E+272|0,i=ve+256|0,q=ve+240|0,se=ve,UA=ve+224|0,EA=ve+208|0,$=ve+176|0,U=ve+160|0,MA=ve+192|0,GA=ve+144|0,OA=ve+128|0,me=ve+112|0,ge=ve+96|0,Ee=ve+80|0,t[i>>2]=A,t[q>>2]=t[e>>2],t[q+4>>2]=t[e+4>>2],t[q+8>>2]=t[e+8>>2],t[q+12>>2]=t[e+12>>2],_(q,i,se),t[s>>2]=0,q=n+r+((n|0)==5&1)|0,(q|0)<=(r|0)){E=ve;return}c=t[i>>2]|0,f=UA+4|0,p=$+4|0,B=r+5|0,I=16880+(c<<2)|0,L=16960+(c<<2)|0,N=OA+8|0,G=me+8|0,Y=ge+8|0,nA=EA+4|0,l=r;A:for(;;){o=se+(((l|0)%5|0)<<4)|0,t[EA>>2]=t[o>>2],t[EA+4>>2]=t[o+4>>2],t[EA+8>>2]=t[o+8>>2],t[EA+12>>2]=t[o+12>>2];do;while((F(EA,c,0,1)|0)==2);if((l|0)>(r|0)&(or(A)|0)!=0){if(t[$>>2]=t[EA>>2],t[$+4>>2]=t[EA+4>>2],t[$+8>>2]=t[EA+8>>2],t[$+12>>2]=t[EA+12>>2],ir(f,U),n=t[$>>2]|0,i=t[17040+(n*80|0)+(t[UA>>2]<<2)>>2]|0,t[$>>2]=t[18640+(n*80|0)+(i*20|0)>>2],o=t[18640+(n*80|0)+(i*20|0)+16>>2]|0,(o|0)>0){e=0;do tt(p),e=e+1|0;while((e|0)<(o|0))}switch(o=18640+(n*80|0)+(i*20|0)+4|0,t[MA>>2]=t[o>>2],t[MA+4>>2]=t[o+4>>2],t[MA+8>>2]=t[o+8>>2],pA(MA,(t[I>>2]|0)*3|0),H(p,MA,p),et(p),ir(p,GA),He=+(t[L>>2]|0),C[OA>>3]=He*3,C[N>>3]=0,ye=He*-1.5,C[me>>3]=ye,C[G>>3]=He*2.598076211353316,C[ge>>3]=ye,C[Y>>3]=He*-2.598076211353316,t[17040+((t[$>>2]|0)*80|0)+(t[EA>>2]<<2)>>2]|0){case 1:{e=me,n=OA;break}case 3:{e=ge,n=me;break}case 2:{e=OA,n=ge;break}default:{e=12;break A}}li(U,GA,n,e,Ee),Zr(Ee,t[$>>2]|0,c,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1}if((l|0)<(B|0)&&(ir(nA,$),Zr($,t[EA>>2]|0,c,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1),t[UA>>2]=t[EA>>2],t[UA+4>>2]=t[EA+4>>2],t[UA+8>>2]=t[EA+8>>2],t[UA+12>>2]=t[EA+12>>2],l=l+1|0,(l|0)>=(q|0)){e=3;break}}if((e|0)==3){E=ve;return}else(e|0)==12&&PA(26970,27017,572,27027)}function _(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0;c=E,E=E+128|0,n=c+64|0,s=c,i=n,o=20240,l=i+60|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));i=s,o=20304,l=i+60|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));l=(or(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,qn(s),Jn(s),or(t[A>>2]|0)|0&&(Xe(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,H(s,n,A),et(A),t[r+16>>2]=t[e>>2],A=r+20|0,H(s,n+12|0,A),et(A),t[r+32>>2]=t[e>>2],A=r+36|0,H(s,n+24|0,A),et(A),t[r+48>>2]=t[e>>2],A=r+52|0,H(s,n+36|0,A),et(A),t[r+64>>2]=t[e>>2],r=r+68|0,H(s,n+48|0,r),et(r),E=c}function F(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0;if(N=E,E=E+32|0,I=N+12|0,l=N,L=e+4|0,B=t[16960+(A<<2)>>2]|0,p=(n|0)!=0,B=p?B*3|0:B,s=t[L>>2]|0,f=e+8|0,o=t[f>>2]|0,p){if(i=e+12|0,n=t[i>>2]|0,s=o+s+n|0,(s|0)==(B|0))return L=1,E=N,L|0;c=i}else c=e+12|0,n=t[c>>2]|0,s=o+s+n|0;if((s|0)<=(B|0))return L=0,E=N,L|0;do if((n|0)>0){if(n=t[e>>2]|0,(o|0)>0){i=18640+(n*80|0)+60|0,n=e;break}n=18640+(n*80|0)+40|0,r?(Bn(I,B,0,0),oA(L,I,l),yt(l),H(l,I,L),i=n,n=e):(i=n,n=e)}else i=18640+((t[e>>2]|0)*80|0)+20|0,n=e;while(!1);if(t[n>>2]=t[i>>2],s=i+16|0,(t[s>>2]|0)>0){n=0;do tt(L),n=n+1|0;while((n|0)<(t[s>>2]|0))}return e=i+4|0,t[I>>2]=t[e>>2],t[I+4>>2]=t[e+4>>2],t[I+8>>2]=t[e+8>>2],A=t[16880+(A<<2)>>2]|0,pA(I,p?A*3|0:A),H(L,I,L),et(L),p?n=((t[f>>2]|0)+(t[L>>2]|0)+(t[c>>2]|0)|0)==(B|0)?1:2:n=2,L=n,E=N,L|0}function rA(e,A){e=e|0,A=A|0;var r=0;do r=F(e,A,0,1)|0;while((r|0)==2);return r|0}function AA(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0,ge=0,Ee=0,se=0;if(ge=E,E=E+240|0,i=ge+224|0,MA=ge+208|0,GA=ge,OA=ge+192|0,me=ge+176|0,Y=ge+160|0,nA=ge+144|0,q=ge+128|0,$=ge+112|0,U=ge+96|0,t[i>>2]=A,t[MA>>2]=t[e>>2],t[MA+4>>2]=t[e+4>>2],t[MA+8>>2]=t[e+8>>2],t[MA+12>>2]=t[e+12>>2],hA(MA,i,GA),t[s>>2]=0,G=n+r+((n|0)==6&1)|0,(G|0)<=(r|0)){E=ge;return}c=t[i>>2]|0,f=r+6|0,p=16960+(c<<2)|0,B=nA+8|0,I=q+8|0,L=$+8|0,N=OA+4|0,o=0,l=r,n=-1;A:for(;;){if(i=(l|0)%6|0,e=GA+(i<<4)|0,t[OA>>2]=t[e>>2],t[OA+4>>2]=t[e+4>>2],t[OA+8>>2]=t[e+8>>2],t[OA+12>>2]=t[e+12>>2],e=o,o=F(OA,c,0,1)|0,(l|0)>(r|0)&(or(A)|0)!=0&&(e|0)!=1&&(t[OA>>2]|0)!=(n|0)){switch(ir(GA+(((i+5|0)%6|0)<<4)+4|0,me),ir(GA+(i<<4)+4|0,Y),Ee=+(t[p>>2]|0),C[nA>>3]=Ee*3,C[B>>3]=0,se=Ee*-1.5,C[q>>3]=se,C[I>>3]=Ee*2.598076211353316,C[$>>3]=se,C[L>>3]=Ee*-2.598076211353316,i=t[MA>>2]|0,t[17040+(i*80|0)+(((n|0)==(i|0)?t[OA>>2]|0:n)<<2)>>2]|0){case 1:{e=q,n=nA;break}case 3:{e=$,n=q;break}case 2:{e=nA,n=$;break}default:{e=8;break A}}li(me,Y,n,e,U),!(ai(me,U)|0)&&!(ai(Y,U)|0)&&(Zr(U,t[MA>>2]|0,c,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1)}if((l|0)<(f|0)&&(ir(N,me),Zr(me,t[OA>>2]|0,c,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1),l=l+1|0,(l|0)>=(G|0)){e=3;break}else n=t[OA>>2]|0}if((e|0)==3){E=ge;return}else(e|0)==8&&PA(27054,27017,737,27099)}function hA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0;c=E,E=E+160|0,n=c+80|0,s=c,i=n,o=20368,l=i+72|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));i=s,o=20448,l=i+72|0;do t[i>>2]=t[o>>2],i=i+4|0,o=o+4|0;while((i|0)<(l|0));l=(or(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,qn(s),Jn(s),or(t[A>>2]|0)|0&&(Xe(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,H(s,n,A),et(A),t[r+16>>2]=t[e>>2],A=r+20|0,H(s,n+12|0,A),et(A),t[r+32>>2]=t[e>>2],A=r+36|0,H(s,n+24|0,A),et(A),t[r+48>>2]=t[e>>2],A=r+52|0,H(s,n+36|0,A),et(A),t[r+64>>2]=t[e>>2],A=r+68|0,H(s,n+48|0,A),et(A),t[r+80>>2]=t[e>>2],r=r+84|0,H(s,n+60|0,r),et(r),E=c}function DA(e,A){return e=e|0,A=A|0,A=xA(e|0,A|0,52)|0,S()|0,A&15|0}function re(e,A){return e=e|0,A=A|0,A=xA(e|0,A|0,45)|0,S()|0,A&127|0}function Ce(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(r+-1|0)>>>0>14?(n=4,n|0):(r=xA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,t[n>>2]=r&7,n=0,n|0)}function we(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0;if(e>>>0>15)return n=4,n|0;if(A>>>0>121)return n=17,n|0;o=CA(e|0,0,52)|0,s=S()|0,l=CA(A|0,0,45)|0,s=s|(S()|0)|134225919;A:do if((e|0)>=1){for(l=1,o=(mA[20528+A>>0]|0)!=0,i=-1;;){if(A=t[r+(l+-1<<2)>>2]|0,A>>>0>6){s=18,A=10;break}if(!((A|0)==0|o^1))if((A|0)==1){s=19,A=10;break}else o=0;if(f=(15-l|0)*3|0,c=CA(7,0,f|0)|0,s=s&~(S()|0),A=CA(A|0,((A|0)<0)<<31>>31|0,f|0)|0,i=A|i&~c,s=S()|0|s,(l|0)<(e|0))l=l+1|0;else break A}if((A|0)==10)return s|0}else i=-1;while(!1);return f=n,t[f>>2]=i,t[f+4>>2]=s,f=0,f|0}function ze(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;return!(!0&(A&-16777216|0)==134217728)||(n=xA(e|0,A|0,52)|0,S()|0,n=n&15,r=xA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0>121)?(e=0,e|0):(o=(n^15)*3|0,s=xA(e|0,A|0,o|0)|0,o=CA(s|0,S()|0,o|0)|0,s=S()|0,i=xt(-1227133514,-1171,o|0,s|0)|0,!((o&613566756&i|0)==0&(s&4681&(S()|0)|0)==0)||(o=(n*3|0)+19|0,i=CA(~e|0,~A|0,o|0)|0,o=xA(i|0,S()|0,o|0)|0,!((n|0)==15|(o|0)==0&(S()|0)==0))?(o=0,o|0):!(mA[20528+r>>0]|0)||(A=A&8191,(e|0)==0&(A|0)==0)?(o=1,o|0):(o=ms(e|0,A|0)|0,S()|0,((63-o|0)%3|0|0)!=0|0))}function Tt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;return!0&(A&-16777216|0)==134217728&&(n=xA(e|0,A|0,52)|0,S()|0,n=n&15,r=xA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0<=121)&&(o=(n^15)*3|0,s=xA(e|0,A|0,o|0)|0,o=CA(s|0,S()|0,o|0)|0,s=S()|0,i=xt(-1227133514,-1171,o|0,s|0)|0,(o&613566756&i|0)==0&(s&4681&(S()|0)|0)==0)&&(o=(n*3|0)+19|0,i=CA(~e|0,~A|0,o|0)|0,o=xA(i|0,S()|0,o|0)|0,(n|0)==15|(o|0)==0&(S()|0)==0)&&(!(mA[20528+r>>0]|0)||(r=A&8191,(e|0)==0&(r|0)==0)||(o=ms(e|0,r|0)|0,S()|0,(63-o|0)%3|0|0))||t0(e,A)|0?(o=1,o|0):(o=(ui(e,A)|0)!=0&1,o|0)}function It(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0;if(s=CA(A|0,0,52)|0,i=S()|0,r=CA(r|0,0,45)|0,r=i|(S()|0)|134225919,(A|0)<1){i=-1,n=r,A=e,t[A>>2]=i,e=e+4|0,t[e>>2]=n;return}for(i=1,s=-1;o=(15-i|0)*3|0,l=CA(7,0,o|0)|0,r=r&~(S()|0),o=CA(n|0,0,o|0)|0,s=s&~l|o,r=r|(S()|0),(i|0)!=(A|0);)i=i+1|0;l=e,o=l,t[o>>2]=s,l=l+4|0,t[l>>2]=r}function Lt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;if(i=xA(e|0,A|0,52)|0,S()|0,i=i&15,r>>>0>15)return n=4,n|0;if((i|0)<(r|0))return n=12,n|0;if((i|0)==(r|0))return t[n>>2]=e,t[n+4>>2]=A,n=0,n|0;if(s=CA(r|0,0,52)|0,s=s|e,e=S()|0|A&-15728641,(i|0)>(r|0))do A=CA(7,0,(14-r|0)*3|0)|0,r=r+1|0,s=A|s,e=S()|0|e;while((r|0)<(i|0));return t[n>>2]=s,t[n+4>>2]=e,n=0,n|0}function Cr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;if(i=xA(e|0,A|0,52)|0,S()|0,i=i&15,!((r|0)<16&(i|0)<=(r|0)))return n=4,n|0;s=r-i|0,r=xA(e|0,A|0,45)|0,S()|0;A:do if(!(je(r&127)|0))r=qr(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;else{e:do if(i|0){for(r=1;o=CA(7,0,(15-r|0)*3|0)|0,!!((o&e|0)==0&((S()|0)&A|0)==0);)if(r>>>0<i>>>0)r=r+1|0;else break e;r=qr(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;break A}while(!1);r=qr(7,0,s,((s|0)<0)<<31>>31)|0,r=wt(r|0,S()|0,5,0)|0,r=YA(r|0,S()|0,-5,-1)|0,r=Xr(r|0,S()|0,6,0)|0,r=YA(r|0,S()|0,1,0)|0,s=S()|0}while(!1);return o=n,t[o>>2]=r,t[o+4>>2]=s,o=0,o|0}function Fe(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;if(s=xA(e|0,A|0,45)|0,S()|0,!(je(s&127)|0))return s=0,s|0;s=xA(e|0,A|0,52)|0,S()|0,s=s&15;A:do if(!s)r=0;else for(n=1;;){if(r=xA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0)break A;if(n>>>0<s>>>0)n=n+1|0;else{r=0;break}}while(!1);return s=(r|0)==0&1,s|0}function n0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0;if(o=E,E=E+16|0,i=o,ls(i,e,A,r),A=i,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0)return E=o,0;s=0,r=0;do l=n+(s<<3)|0,t[l>>2]=e,t[l+4>>2]=A,s=YA(s|0,r|0,1,0)|0,r=S()|0,as(i),l=i,e=t[l>>2]|0,A=t[l+4>>2]|0;while(!((e|0)==0&(A|0)==0));return E=o,0}function $s(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(n|0)<(r|0)?(r=A,n=e,JA(r|0),n|0):(r=CA(-1,-1,((n-r|0)*3|0)+3|0)|0,n=CA(~r|0,~(S()|0)|0,(15-n|0)*3|0)|0,r=~(S()|0)&A,n=~n&e,JA(r|0),n|0)}function Zs(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0;return s=xA(e|0,A|0,52)|0,S()|0,s=s&15,(r|0)<16&(s|0)<=(r|0)?((s|0)<(r|0)&&(s=CA(-1,-1,((r+-1-s|0)*3|0)+3|0)|0,s=CA(~s|0,~(S()|0)|0,(15-r|0)*3|0)|0,A=~(S()|0)&A,e=~s&e),s=CA(r|0,0,52)|0,r=A&-15728641|(S()|0),t[n>>2]=e|s,t[n+4>>2]=r,n=0,n|0):(n=4,n|0)}function kl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0,ge=0,Ee=0,se=0,UA=0,EA=0;if((r|0)==0&(n|0)==0)return EA=0,EA|0;if(s=e,i=t[s>>2]|0,s=t[s+4>>2]|0,!0&(s&15728640|0)==0){if(!((n|0)>0|(n|0)==0&r>>>0>0)||(EA=A,t[EA>>2]=i,t[EA+4>>2]=s,(r|0)==1&(n|0)==0))return EA=0,EA|0;s=1,i=0;do se=e+(s<<3)|0,UA=t[se+4>>2]|0,EA=A+(s<<3)|0,t[EA>>2]=t[se>>2],t[EA+4>>2]=UA,s=YA(s|0,i|0,1,0)|0,i=S()|0;while((i|0)<(n|0)|(i|0)==(n|0)&s>>>0<r>>>0);return s=0,s|0}if(Ee=r<<3,UA=Er(Ee)|0,!UA)return EA=13,EA|0;if(Pn(UA|0,e|0,Ee|0)|0,se=Gt(r,8)|0,!se)return $A(UA),EA=13,EA|0;A:for(;;){s=UA,f=t[s>>2]|0,s=t[s+4>>2]|0,me=xA(f|0,s|0,52)|0,S()|0,me=me&15,ge=me+-1|0,OA=(me|0)!=0,GA=(n|0)>0|(n|0)==0&r>>>0>0;e:do if(OA&GA){if(q=CA(ge|0,0,52)|0,$=S()|0,ge>>>0>15){if(!((f|0)==0&(s|0)==0)){EA=16;break A}for(i=0,e=0;;){if(i=YA(i|0,e|0,1,0)|0,e=S()|0,!((e|0)<(n|0)|(e|0)==(n|0)&i>>>0<r>>>0))break e;if(o=UA+(i<<3)|0,MA=t[o>>2]|0,o=t[o+4>>2]|0,!((MA|0)==0&(o|0)==0)){s=o,EA=16;break A}}}for(l=f,e=s,i=0,o=0;;){if(!((l|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){EA=21;break A}if(p=xA(l|0,e|0,52)|0,S()|0,p=p&15,(p|0)<(ge|0)){s=12,EA=27;break A}if((p|0)!=(ge|0)&&(l=l|q,e=e&-15728641|$,p>>>0>=me>>>0)){c=ge;do MA=CA(7,0,(14-c|0)*3|0)|0,c=c+1|0,l=MA|l,e=S()|0|e;while(c>>>0<p>>>0)}if(I=Fn(l|0,e|0,r|0,n|0)|0,L=S()|0,c=se+(I<<3)|0,p=c,B=t[p>>2]|0,p=t[p+4>>2]|0,!((B|0)==0&(p|0)==0)){Y=0,nA=0;do{if((Y|0)>(n|0)|(Y|0)==(n|0)&nA>>>0>r>>>0){EA=31;break A}if((B|0)==(l|0)&(p&-117440513|0)==(e|0)){N=xA(B|0,p|0,56)|0,S()|0,N=N&7,G=N+1|0,MA=xA(B|0,p|0,45)|0,S()|0;t:do if(!(je(MA&127)|0))p=7;else{if(B=xA(B|0,p|0,52)|0,S()|0,B=B&15,!B){p=6;break}for(p=1;;){if(MA=CA(7,0,(15-p|0)*3|0)|0,!((MA&l|0)==0&((S()|0)&e|0)==0)){p=7;break t}if(p>>>0<B>>>0)p=p+1|0;else{p=6;break}}}while(!1);if((N+2|0)>>>0>p>>>0){EA=41;break A}MA=CA(G|0,0,56)|0,e=S()|0|e&-117440513,U=c,t[U>>2]=0,t[U+4>>2]=0,l=MA|l}else I=YA(I|0,L|0,1,0)|0,I=Nn(I|0,S()|0,r|0,n|0)|0,L=S()|0;nA=YA(nA|0,Y|0,1,0)|0,Y=S()|0,c=se+(I<<3)|0,p=c,B=t[p>>2]|0,p=t[p+4>>2]|0}while(!((B|0)==0&(p|0)==0))}MA=c,t[MA>>2]=l,t[MA+4>>2]=e}if(i=YA(i|0,o|0,1,0)|0,o=S()|0,!((o|0)<(n|0)|(o|0)==(n|0)&i>>>0<r>>>0))break e;e=UA+(i<<3)|0,l=t[e>>2]|0,e=t[e+4>>2]|0}}while(!1);if(MA=YA(r|0,n|0,5,0)|0,U=S()|0,U>>>0<0|(U|0)==0&MA>>>0<11){EA=85;break}if(MA=Xr(r|0,n|0,6,0)|0,S()|0,MA=Gt(MA,8)|0,!MA){EA=48;break}do if(GA){for(G=0,e=0,N=0,Y=0;;){if(p=se+(G<<3)|0,o=p,i=t[o>>2]|0,o=t[o+4>>2]|0,(i|0)==0&(o|0)==0)U=N;else{B=xA(i|0,o|0,56)|0,S()|0,B=B&7,l=B+1|0,I=o&-117440513,U=xA(i|0,o|0,45)|0,S()|0;e:do if(je(U&127)|0){if(L=xA(i|0,o|0,52)|0,S()|0,L=L&15,L|0)for(c=1;;){if(U=CA(7,0,(15-c|0)*3|0)|0,!((i&U|0)==0&(I&(S()|0)|0)==0))break e;if(c>>>0<L>>>0)c=c+1|0;else break}o=CA(l|0,0,56)|0,i=o|i,o=S()|0|I,l=p,t[l>>2]=i,t[l+4>>2]=o,l=B+2|0}while(!1);(l|0)==7?(U=MA+(e<<3)|0,t[U>>2]=i,t[U+4>>2]=o&-117440513,e=YA(e|0,N|0,1,0)|0,U=S()|0):U=N}if(G=YA(G|0,Y|0,1,0)|0,Y=S()|0,(Y|0)<(n|0)|(Y|0)==(n|0)&G>>>0<r>>>0)N=U;else break}if(GA){if(nA=ge>>>0>15,q=CA(ge|0,0,52)|0,$=S()|0,!OA){for(i=0,c=0,l=0,o=0;(f|0)==0&(s|0)==0||(ge=A+(i<<3)|0,t[ge>>2]=f,t[ge+4>>2]=s,i=YA(i|0,c|0,1,0)|0,c=S()|0),l=YA(l|0,o|0,1,0)|0,o=S()|0,!!((o|0)<(n|0)|(o|0)==(n|0)&l>>>0<r>>>0);)s=UA+(l<<3)|0,f=t[s>>2]|0,s=t[s+4>>2]|0;s=U;break}for(i=0,c=0,o=0,l=0;;){do if(!((f|0)==0&(s|0)==0)){if(L=xA(f|0,s|0,52)|0,S()|0,L=L&15,nA|(L|0)<(ge|0)){EA=80;break A}if((L|0)!=(ge|0)){if(p=f|q,B=s&-15728641|$,L>>>0>=me>>>0){I=ge;do OA=CA(7,0,(14-I|0)*3|0)|0,I=I+1|0,p=OA|p,B=S()|0|B;while(I>>>0<L>>>0)}}else p=f,B=s;N=Fn(p|0,B|0,r|0,n|0)|0,I=0,L=0,Y=S()|0;do{if((I|0)>(n|0)|(I|0)==(n|0)&L>>>0>r>>>0){EA=81;break A}if(OA=se+(N<<3)|0,G=t[OA+4>>2]|0,(G&-117440513|0)==(B|0)&&(t[OA>>2]|0)==(p|0)){EA=65;break}OA=YA(N|0,Y|0,1,0)|0,N=Nn(OA|0,S()|0,r|0,n|0)|0,Y=S()|0,L=YA(L|0,I|0,1,0)|0,I=S()|0,OA=se+(N<<3)|0}while(!((t[OA>>2]|0)==(p|0)&&(t[OA+4>>2]|0)==(B|0)));if((EA|0)==65&&(EA=0,!0&(G&117440512|0)==100663296))break;OA=A+(i<<3)|0,t[OA>>2]=f,t[OA+4>>2]=s,i=YA(i|0,c|0,1,0)|0,c=S()|0}while(!1);if(o=YA(o|0,l|0,1,0)|0,l=S()|0,!((l|0)<(n|0)|(l|0)==(n|0)&o>>>0<r>>>0))break;s=UA+(o<<3)|0,f=t[s>>2]|0,s=t[s+4>>2]|0}s=U}else i=0,s=U}else i=0,e=0,s=0;while(!1);if(An(se|0,0,Ee|0)|0,Pn(UA|0,MA|0,e<<3|0)|0,$A(MA),(e|0)==0&(s|0)==0){EA=89;break}else A=A+(i<<3)|0,n=s,r=e}if((EA|0)==16)!0&(s&117440512|0)==0?(s=4,EA=27):EA=21;else if((EA|0)==31)PA(27795,27122,620,27132);else{if((EA|0)==41)return $A(UA),$A(se),EA=10,EA|0;if((EA|0)==48)return $A(UA),$A(se),EA=13,EA|0;(EA|0)==80?PA(27795,27122,711,27132):(EA|0)==81?PA(27795,27122,723,27132):(EA|0)==85&&(Pn(A|0,UA|0,r<<3|0)|0,EA=89)}return(EA|0)==21?($A(UA),$A(se),EA=5,EA|0):(EA|0)==27?($A(UA),$A(se),EA=s,EA|0):(EA|0)==89?($A(UA),$A(se),EA=0,EA|0):0}function Cl(e,A,r,n,s,i,o){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0,o=o|0;var l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0;if(G=E,E=E+16|0,N=G,!((r|0)>0|(r|0)==0&A>>>0>0))return N=0,E=G,N|0;if((o|0)>=16)return N=12,E=G,N|0;I=0,L=0,B=0,l=0;A:for(;;){if(f=e+(I<<3)|0,c=t[f>>2]|0,f=t[f+4>>2]|0,p=xA(c|0,f|0,52)|0,S()|0,(p&15|0)>(o|0)){l=12,c=11;break}if(ls(N,c,f,o),p=N,f=t[p>>2]|0,p=t[p+4>>2]|0,(f|0)==0&(p|0)==0)c=B;else{c=B;do{if(!((l|0)<(i|0)|(l|0)==(i|0)&c>>>0<s>>>0)){c=10;break A}B=n+(c<<3)|0,t[B>>2]=f,t[B+4>>2]=p,c=YA(c|0,l|0,1,0)|0,l=S()|0,as(N),B=N,f=t[B>>2]|0,p=t[B+4>>2]|0}while(!((f|0)==0&(p|0)==0))}if(I=YA(I|0,L|0,1,0)|0,L=S()|0,(L|0)<(r|0)|(L|0)==(r|0)&I>>>0<A>>>0)B=c;else{l=0,c=11;break}}return(c|0)==10?(N=14,E=G,N|0):(c|0)==11?(E=G,l|0):0}function El(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0;I=E,E=E+16|0,B=I;A:do if((r|0)>0|(r|0)==0&A>>>0>0){for(f=0,o=0,i=0,p=0;;){if(c=e+(f<<3)|0,l=t[c>>2]|0,c=t[c+4>>2]|0,!((l|0)==0&(c|0)==0)&&(c=(Cr(l,c,n,B)|0)==0,l=B,o=YA(t[l>>2]|0,t[l+4>>2]|0,o|0,i|0)|0,i=S()|0,!c)){i=12;break}if(f=YA(f|0,p|0,1,0)|0,p=S()|0,!((p|0)<(r|0)|(p|0)==(r|0)&f>>>0<A>>>0))break A}return E=I,i|0}else o=0,i=0;while(!1);return t[s>>2]=o,t[s+4>>2]=i,s=0,E=I,s|0}function Sl(e,A){return e=e|0,A=A|0,A=xA(e|0,A|0,52)|0,S()|0,A&1|0}function Ht(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;if(s=xA(e|0,A|0,52)|0,S()|0,s=s&15,!s)return s=0,s|0;for(n=1;;){if(r=xA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0){n=5;break}if(n>>>0<s>>>0)n=n+1|0;else{r=0,n=5;break}}return(n|0)==5?r|0:0}function rs(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0;if(c=xA(e|0,A|0,52)|0,S()|0,c=c&15,!c)return l=A,c=e,JA(l|0),c|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=CA(7,0,i|0)|0,s=S()|0,o=xA(e|0,A|0,i|0)|0,S()|0,i=CA(Wt(o&7)|0,0,i|0)|0,o=S()|0,e=i|e&~n,A=o|A&~s;A:do if(!r)if((i&n|0)==0&(o&s|0)==0)r=0;else if(n=xA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(o=xA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,o&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0<n>>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(o=(15-r|0)*3|0,s=xA(e|0,A|0,o|0)|0,S()|0,i=CA(7,0,o|0)|0,A=A&~(S()|0),o=CA(Wt(s&7)|0,0,o|0)|0,e=e&~i|o,A=A|(S()|0),r>>>0<n>>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0<c>>>0)l=l+1|0;else break}return JA(A|0),e|0}function hn(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;if(n=xA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,JA(r|0),n|0;for(r=1;i=(15-r|0)*3|0,o=xA(e|0,A|0,i|0)|0,S()|0,s=CA(7,0,i|0)|0,A=A&~(S()|0),i=CA(Wt(o&7)|0,0,i|0)|0,e=i|e&~s,A=S()|0|A,r>>>0<n>>>0;)r=r+1|0;return JA(A|0),e|0}function Ml(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0;if(c=xA(e|0,A|0,52)|0,S()|0,c=c&15,!c)return l=A,c=e,JA(l|0),c|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=CA(7,0,i|0)|0,s=S()|0,o=xA(e|0,A|0,i|0)|0,S()|0,i=CA(Yt(o&7)|0,0,i|0)|0,o=S()|0,e=i|e&~n,A=o|A&~s;A:do if(!r)if((i&n|0)==0&(o&s|0)==0)r=0;else if(n=xA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(o=xA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,o&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0<n>>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(s=(15-r|0)*3|0,i=CA(7,0,s|0)|0,o=A&~(S()|0),A=xA(e|0,A|0,s|0)|0,S()|0,A=CA(Yt(A&7)|0,0,s|0)|0,e=e&~i|A,A=o|(S()|0),r>>>0<n>>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0<c>>>0)l=l+1|0;else break}return JA(A|0),e|0}function ns(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;if(n=xA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,JA(r|0),n|0;for(r=1;o=(15-r|0)*3|0,i=CA(7,0,o|0)|0,s=A&~(S()|0),A=xA(e|0,A|0,o|0)|0,S()|0,A=CA(Yt(A&7)|0,0,o|0)|0,e=A|e&~i,A=S()|0|s,r>>>0<n>>>0;)r=r+1|0;return JA(A|0),e|0}function Bl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(c=E,E=E+64|0,l=c+40|0,n=c+24|0,s=c+12|0,i=c,CA(A|0,0,52)|0,r=S()|0|134225919,!A)return(t[e+4>>2]|0)>2||(t[e+8>>2]|0)>2||(t[e+12>>2]|0)>2?(o=0,l=0,JA(o|0),E=c,l|0):(CA(vr(e)|0,0,45)|0,o=S()|0|r,l=-1,JA(o|0),E=c,l|0);if(t[l>>2]=t[e>>2],t[l+4>>2]=t[e+4>>2],t[l+8>>2]=t[e+8>>2],t[l+12>>2]=t[e+12>>2],o=l+4|0,(A|0)>0)for(e=-1;t[n>>2]=t[o>>2],t[n+4>>2]=t[o+4>>2],t[n+8>>2]=t[o+8>>2],A&1?(De(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],st(s)):(Qe(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],Xe(s)),oA(n,s,i),et(i),p=(15-A|0)*3|0,f=CA(7,0,p|0)|0,r=r&~(S()|0),p=CA(NA(i)|0,0,p|0)|0,e=p|e&~f,r=S()|0|r,(A|0)>1;)A=A+-1|0;else e=-1;A:do if((t[o>>2]|0)<=2&&(t[l+8>>2]|0)<=2&&(t[l+12>>2]|0)<=2){if(n=vr(l)|0,A=CA(n|0,0,45)|0,A=A|e,e=S()|0|r&-1040385,i=mr(l)|0,!(je(n)|0)){if((i|0)<=0)break;for(s=0;;){if(n=xA(A|0,e|0,52)|0,S()|0,n=n&15,n)for(r=1;p=(15-r|0)*3|0,l=xA(A|0,e|0,p|0)|0,S()|0,f=CA(7,0,p|0)|0,e=e&~(S()|0),p=CA(Wt(l&7)|0,0,p|0)|0,A=A&~f|p,e=e|(S()|0),r>>>0<n>>>0;)r=r+1|0;if(s=s+1|0,(s|0)==(i|0))break A}}s=xA(A|0,e|0,52)|0,S()|0,s=s&15;e:do if(s){r=1;t:for(;;){switch(p=xA(A|0,e|0,(15-r|0)*3|0)|0,S()|0,p&7){case 1:break t;case 0:break;default:break e}if(r>>>0<s>>>0)r=r+1|0;else break e}if(Qr(n,t[l>>2]|0)|0)for(r=1;l=(15-r|0)*3|0,f=CA(7,0,l|0)|0,p=e&~(S()|0),e=xA(A|0,e|0,l|0)|0,S()|0,e=CA(Yt(e&7)|0,0,l|0)|0,A=A&~f|e,e=p|(S()|0),r>>>0<s>>>0;)r=r+1|0;else for(r=1;p=(15-r|0)*3|0,l=xA(A|0,e|0,p|0)|0,S()|0,f=CA(7,0,p|0)|0,e=e&~(S()|0),p=CA(Wt(l&7)|0,0,p|0)|0,A=A&~f|p,e=e|(S()|0),r>>>0<s>>>0;)r=r+1|0}while(!1);if((i|0)>0){r=0;do A=rs(A,e)|0,e=S()|0,r=r+1|0;while((r|0)!=(i|0))}}else A=0,e=0;while(!1);return f=e,p=A,JA(f|0),E=c,p|0}function or(e){return e=e|0,(e|0)%2|0|0}function ss(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;return s=E,E=E+16|0,n=s,A>>>0>15?(n=4,E=s,n|0):(t[e+4>>2]&2146435072|0)==2146435072||(t[e+8+4>>2]&2146435072|0)==2146435072?(n=3,E=s,n|0):(k0(e,A,n),A=Bl(n,A)|0,n=S()|0,t[r>>2]=A,t[r+4>>2]=n,(A|0)==0&(n|0)==0&&PA(27795,27122,1050,27145),n=0,E=s,n|0)}function is(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;if(s=r+4|0,i=xA(e|0,A|0,52)|0,S()|0,i=i&15,o=xA(e|0,A|0,45)|0,S()|0,n=(i|0)==0,je(o&127)|0){if(n)return o=1,o|0;n=1}else{if(n)return o=0,o|0;(t[s>>2]|0)==0&&(t[r+8>>2]|0)==0?n=(t[r+12>>2]|0)!=0&1:n=1}for(r=1;r&1?st(s):Xe(s),o=xA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,gt(s,o&7),r>>>0<i>>>0;)r=r+1|0;return n|0}function Tn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(p=E,E=E+16|0,c=p,f=xA(e|0,A|0,45)|0,S()|0,f=f&127,f>>>0>121)return t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,t[r+12>>2]=0,f=5,E=p,f|0;A:do if((je(f)|0)!=0&&(i=xA(e|0,A|0,52)|0,S()|0,i=i&15,(i|0)!=0)){n=1;e:for(;;){switch(l=xA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,l&7){case 5:break e;case 0:break;default:{n=A;break A}}if(n>>>0<i>>>0)n=n+1|0;else{n=A;break A}}for(s=1,n=A;A=(15-s|0)*3|0,o=CA(7,0,A|0)|0,l=n&~(S()|0),n=xA(e|0,n|0,A|0)|0,S()|0,n=CA(Yt(n&7)|0,0,A|0)|0,e=e&~o|n,n=l|(S()|0),s>>>0<i>>>0;)s=s+1|0}else n=A;while(!1);if(l=7696+(f*28|0)|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],!(is(e,n,r)|0))return f=0,E=p,f|0;if(o=r+4|0,t[c>>2]=t[o>>2],t[c+4>>2]=t[o+4>>2],t[c+8>>2]=t[o+8>>2],i=xA(e|0,n|0,52)|0,S()|0,l=i&15,i&1?(Xe(o),i=l+1|0):i=l,!(je(f)|0))n=0;else{A:do if(!l)n=0;else for(A=1;;){if(s=xA(e|0,n|0,(15-A|0)*3|0)|0,S()|0,s=s&7,s|0){n=s;break A}if(A>>>0<l>>>0)A=A+1|0;else{n=0;break}}while(!1);n=(n|0)==4&1}if(!(F(r,i,n,0)|0))(i|0)!=(l|0)&&(t[o>>2]=t[c>>2],t[o+4>>2]=t[c+4>>2],t[o+8>>2]=t[c+8>>2]);else{if(je(f)|0)do;while((F(r,i,0,0)|0)!=0);(i|0)!=(l|0)&&Qe(o)}return f=0,E=p,f|0}function dn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return i=E,E=E+16|0,n=i,s=Tn(e,A,n)|0,s|0?(E=i,s|0):(s=xA(e|0,A|0,52)|0,S()|0,d(n,s&15,r),s=0,E=i,s|0)}function In(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0;if(o=E,E=E+16|0,i=o,n=Tn(e,A,i)|0,n|0)return i=n,E=o,i|0;n=xA(e|0,A|0,45)|0,S()|0,n=(je(n&127)|0)==0,s=xA(e|0,A|0,52)|0,S()|0,s=s&15;A:do if(!n){if(s|0)for(n=1;;){if(l=CA(7,0,(15-n|0)*3|0)|0,!((l&e|0)==0&((S()|0)&A|0)==0))break A;if(n>>>0<s>>>0)n=n+1|0;else break}return w(i,s,0,5,r),l=0,E=o,l|0}while(!1);return AA(i,s,0,6,r),l=0,E=o,l|0}function Dl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(s=xA(e|0,A|0,45)|0,S()|0,!(je(s&127)|0))return s=2,t[r>>2]=s,0;if(s=xA(e|0,A|0,52)|0,S()|0,s=s&15,!s)return s=5,t[r>>2]=s,0;for(n=1;;){if(i=CA(7,0,(15-n|0)*3|0)|0,!((i&e|0)==0&((S()|0)&A|0)==0)){n=2,e=6;break}if(n>>>0<s>>>0)n=n+1|0;else{n=5,e=6;break}}return(e|0)==6&&(t[r>>2]=n),0}function qs(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0;B=E,E=E+128|0,f=B+112|0,i=B+96|0,p=B,s=xA(e|0,A|0,52)|0,S()|0,l=s&15,t[f>>2]=l,o=xA(e|0,A|0,45)|0,S()|0,o=o&127;A:do if(je(o)|0){if(l|0)for(n=1;;){if(c=CA(7,0,(15-n|0)*3|0)|0,!((c&e|0)==0&((S()|0)&A|0)==0)){s=0;break A}if(n>>>0<l>>>0)n=n+1|0;else break}if(s&1)s=1;else return c=CA(l+1|0,0,52)|0,p=S()|0|A&-15728641,f=CA(7,0,(14-l|0)*3|0)|0,p=qs((c|e)&~f,p&~(S()|0),r)|0,E=B,p|0}else s=0;while(!1);if(n=Tn(e,A,i)|0,!n){s?(_(i,f,p),c=5):(hA(i,f,p),c=6);A:do if(je(o)|0)if(!l)e=5;else for(n=1;;){if(o=CA(7,0,(15-n|0)*3|0)|0,!((o&e|0)==0&((S()|0)&A|0)==0)){e=2;break A}if(n>>>0<l>>>0)n=n+1|0;else{e=5;break}}else e=2;while(!1);An(r|0,-1,e<<2|0)|0;A:do if(s)for(i=0;;){if(o=p+(i<<4)|0,rA(o,t[f>>2]|0)|0,o=t[o>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(o|0))n=r;else{s=0;do{if(s=s+1|0,s>>>0>=e>>>0){n=1;break A}n=r+(s<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(o|0)))}if(t[n>>2]=o,i=i+1|0,i>>>0>=c>>>0){n=0;break}}else for(i=0;;){if(o=p+(i<<4)|0,F(o,t[f>>2]|0,0,1)|0,o=t[o>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(o|0))n=r;else{s=0;do{if(s=s+1|0,s>>>0>=e>>>0){n=1;break A}n=r+(s<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(o|0)))}if(t[n>>2]=o,i=i+1|0,i>>>0>=c>>>0){n=0;break}}while(!1)}return p=n,E=B,p|0}function _l(){return 12}function os(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0;if(e>>>0>15)return l=4,l|0;if(CA(e|0,0,52)|0,l=S()|0|134225919,!e){r=0,n=0;do je(n)|0&&(CA(n|0,0,45)|0,o=l|(S()|0),e=A+(r<<3)|0,t[e>>2]=-1,t[e+4>>2]=o,r=r+1|0),n=n+1|0;while((n|0)!=122);return r=0,r|0}r=0,o=0;do{if(je(o)|0){for(CA(o|0,0,45)|0,n=1,s=-1,i=l|(S()|0);c=CA(7,0,(15-n|0)*3|0)|0,s=s&~c,i=i&~(S()|0),(n|0)!=(e|0);)n=n+1|0;c=A+(r<<3)|0,t[c>>2]=s,t[c+4>>2]=i,r=r+1|0}o=o+1|0}while((o|0)!=122);return r=0,r|0}function jl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0;if(q=E,E=E+16|0,Y=q,nA=xA(e|0,A|0,52)|0,S()|0,nA=nA&15,r>>>0>15)return nA=4,E=q,nA|0;if((nA|0)<(r|0))return nA=12,E=q,nA|0;if((nA|0)!=(r|0))if(i=CA(r|0,0,52)|0,i=i|e,l=S()|0|A&-15728641,(nA|0)>(r|0)){c=r;do G=CA(7,0,(14-c|0)*3|0)|0,c=c+1|0,i=G|i,l=S()|0|l;while((c|0)<(nA|0));G=i}else G=i;else G=e,l=A;N=xA(G|0,l|0,45)|0,S()|0;A:do if(je(N&127)|0){if(c=xA(G|0,l|0,52)|0,S()|0,c=c&15,c|0)for(i=1;;){if(N=CA(7,0,(15-i|0)*3|0)|0,!((N&G|0)==0&((S()|0)&l|0)==0)){f=33;break A}if(i>>>0<c>>>0)i=i+1|0;else break}if(N=n,t[N>>2]=0,t[N+4>>2]=0,(nA|0)>(r|0)){for(N=A&-15728641,L=nA;;){if(I=L,L=L+-1|0,L>>>0>15|(nA|0)<(L|0)){f=19;break}if((nA|0)!=(L|0))if(i=CA(L|0,0,52)|0,i=i|e,c=S()|0|N,(nA|0)<(I|0))B=i;else{f=L;do B=CA(7,0,(14-f|0)*3|0)|0,f=f+1|0,i=B|i,c=S()|0|c;while((f|0)<(nA|0));B=i}else B=e,c=A;if(p=xA(B|0,c|0,45)|0,S()|0,!(je(p&127)|0))i=0;else{p=xA(B|0,c|0,52)|0,S()|0,p=p&15;e:do if(!p)i=0;else for(f=1;;){if(i=xA(B|0,c|0,(15-f|0)*3|0)|0,S()|0,i=i&7,i|0)break e;if(f>>>0<p>>>0)f=f+1|0;else{i=0;break}}while(!1);i=(i|0)==0&1}if(c=xA(e|0,A|0,(15-I|0)*3|0)|0,S()|0,c=c&7,(c|0)==7){s=5,f=42;break}if(i=(i|0)!=0,(c|0)==1&i){s=5,f=42;break}if(B=c+(((c|0)!=0&i)<<31>>31)|0,B|0&&(f=nA-I|0,f=qr(7,0,f,((f|0)<0)<<31>>31)|0,p=S()|0,i?(i=wt(f|0,p|0,5,0)|0,i=YA(i|0,S()|0,-5,-1)|0,i=Xr(i|0,S()|0,6,0)|0,i=YA(i|0,S()|0,1,0)|0,c=S()|0):(i=f,c=p),I=B+-1|0,I=wt(f|0,p|0,I|0,((I|0)<0)<<31>>31|0)|0,I=YA(i|0,c|0,I|0,S()|0)|0,B=S()|0,p=n,p=YA(I|0,B|0,t[p>>2]|0,t[p+4>>2]|0)|0,B=S()|0,I=n,t[I>>2]=p,t[I+4>>2]=B),(L|0)<=(r|0)){f=37;break}}if((f|0)==19)PA(27795,27122,1367,27158);else if((f|0)==37){o=n,s=t[o+4>>2]|0,o=t[o>>2]|0;break}else if((f|0)==42)return E=q,s|0}else s=0,o=0}else f=33;while(!1);A:do if((f|0)==33)if(N=n,t[N>>2]=0,t[N+4>>2]=0,(nA|0)>(r|0)){for(i=nA;;){if(s=xA(e|0,A|0,(15-i|0)*3|0)|0,S()|0,s=s&7,(s|0)==7){s=5;break}if(o=nA-i|0,o=qr(7,0,o,((o|0)<0)<<31>>31)|0,s=wt(o|0,S()|0,s|0,0)|0,o=S()|0,N=n,o=YA(t[N>>2]|0,t[N+4>>2]|0,s|0,o|0)|0,s=S()|0,N=n,t[N>>2]=o,t[N+4>>2]=s,i=i+-1|0,(i|0)<=(r|0))break A}return E=q,s|0}else s=0,o=0;while(!1);return Cr(G,l,nA,Y)|0&&PA(27795,27122,1327,27173),nA=Y,Y=t[nA+4>>2]|0,((s|0)>-1|(s|0)==-1&o>>>0>4294967295)&((Y|0)>(s|0)|((Y|0)==(s|0)?(t[nA>>2]|0)>>>0>o>>>0:0))?(nA=0,E=q,nA|0):(PA(27795,27122,1407,27158),0)}function Rl(e,A,r,n,s,i){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0;var o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0;if(B=E,E=E+16|0,o=B,s>>>0>15)return i=4,E=B,i|0;if(l=xA(r|0,n|0,52)|0,S()|0,l=l&15,(l|0)>(s|0))return i=12,E=B,i|0;if(Cr(r,n,s,o)|0&&PA(27795,27122,1327,27173),p=o,f=t[p+4>>2]|0,!(((A|0)>-1|(A|0)==-1&e>>>0>4294967295)&((f|0)>(A|0)|((f|0)==(A|0)?(t[p>>2]|0)>>>0>e>>>0:0))))return i=2,E=B,i|0;p=s-l|0,s=CA(s|0,0,52)|0,c=S()|0|n&-15728641,f=i,t[f>>2]=s|r,t[f+4>>2]=c,f=xA(r|0,n|0,45)|0,S()|0;A:do if(je(f&127)|0){if(l|0)for(o=1;;){if(f=CA(7,0,(15-o|0)*3|0)|0,!((f&r|0)==0&((S()|0)&n|0)==0))break A;if(o>>>0<l>>>0)o=o+1|0;else break}if((p|0)<1)return i=0,E=B,i|0;for(f=l^15,n=-1,c=1,o=1;;){l=p-c|0,l=qr(7,0,l,((l|0)<0)<<31>>31)|0,r=S()|0;do if(o)if(o=wt(l|0,r|0,5,0)|0,o=YA(o|0,S()|0,-5,-1)|0,o=Xr(o|0,S()|0,6,0)|0,s=S()|0,(A|0)>(s|0)|(A|0)==(s|0)&e>>>0>o>>>0){A=YA(e|0,A|0,-1,-1)|0,A=xt(A|0,S()|0,o|0,s|0)|0,o=S()|0,I=i,N=t[I>>2]|0,I=t[I+4>>2]|0,G=(f+n|0)*3|0,L=CA(7,0,G|0)|0,I=I&~(S()|0),n=Xr(A|0,o|0,l|0,r|0)|0,e=S()|0,s=YA(n|0,e|0,2,0)|0,G=CA(s|0,S()|0,G|0)|0,I=S()|0|I,s=i,t[s>>2]=G|N&~L,t[s+4>>2]=I,e=wt(n|0,e|0,l|0,r|0)|0,e=xt(A|0,o|0,e|0,S()|0)|0,o=0,A=S()|0;break}else{G=i,L=t[G>>2]|0,G=t[G+4>>2]|0,N=CA(7,0,(f+n|0)*3|0)|0,G=G&~(S()|0),o=i,t[o>>2]=L&~N,t[o+4>>2]=G,o=1;break}else L=i,s=t[L>>2]|0,L=t[L+4>>2]|0,n=(f+n|0)*3|0,I=CA(7,0,n|0)|0,L=L&~(S()|0),G=Xr(e|0,A|0,l|0,r|0)|0,o=S()|0,n=CA(G|0,o|0,n|0)|0,L=S()|0|L,N=i,t[N>>2]=n|s&~I,t[N+4>>2]=L,o=wt(G|0,o|0,l|0,r|0)|0,e=xt(e|0,A|0,o|0,S()|0)|0,o=0,A=S()|0;while(!1);if((p|0)>(c|0))n=~c,c=c+1|0;else{A=0;break}}return E=B,A|0}while(!1);if((p|0)<1)return G=0,E=B,G|0;for(s=l^15,o=1;;)if(N=p-o|0,N=qr(7,0,N,((N|0)<0)<<31>>31)|0,G=S()|0,c=i,r=t[c>>2]|0,c=t[c+4>>2]|0,l=(s-o|0)*3|0,n=CA(7,0,l|0)|0,c=c&~(S()|0),I=Xr(e|0,A|0,N|0,G|0)|0,L=S()|0,l=CA(I|0,L|0,l|0)|0,c=S()|0|c,f=i,t[f>>2]=l|r&~n,t[f+4>>2]=c,G=wt(I|0,L|0,N|0,G|0)|0,e=xt(e|0,A|0,G|0,S()|0)|0,A=S()|0,(p|0)<=(o|0)){A=0;break}else o=o+1|0;return E=B,A|0}function ls(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;s=xA(A|0,r|0,52)|0,S()|0,s=s&15,(A|0)==0&(r|0)==0|((n|0)>15|(s|0)>(n|0))?(i=-1,A=-1,r=0,s=0):(A=$s(A,r,s+1|0,n)|0,o=(S()|0)&-15728641,r=CA(n|0,0,52)|0,r=A|r,o=o|(S()|0),A=(Fe(r,o)|0)==0,i=s,A=A?-1:n,s=o),o=e,t[o>>2]=r,t[o+4>>2]=s,t[e+8>>2]=i,t[e+12>>2]=A}function Js(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;if(s=xA(e|0,A|0,52)|0,S()|0,s=s&15,i=n+8|0,t[i>>2]=s,(e|0)==0&(A|0)==0|((r|0)>15|(s|0)>(r|0))){r=n,t[r>>2]=0,t[r+4>>2]=0,t[i>>2]=-1,t[n+12>>2]=-1;return}if(e=$s(e,A,s+1|0,r)|0,i=(S()|0)&-15728641,s=CA(r|0,0,52)|0,s=e|s,i=i|(S()|0),e=n,t[e>>2]=s,t[e+4>>2]=i,e=n+12|0,Fe(s,i)|0){t[e>>2]=r;return}else{t[e>>2]=-1;return}}function as(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0;if(r=e,A=t[r>>2]|0,r=t[r+4>>2]|0,!((A|0)==0&(r|0)==0)&&(n=xA(A|0,r|0,52)|0,S()|0,n=n&15,l=CA(1,0,(n^15)*3|0)|0,A=YA(l|0,S()|0,A|0,r|0)|0,r=S()|0,l=e,t[l>>2]=A,t[l+4>>2]=r,l=e+8|0,o=t[l>>2]|0,!((n|0)<(o|0)))){for(c=e+12|0,i=n;;){if((i|0)==(o|0)){n=5;break}if(f=(i|0)==(t[c>>2]|0),s=(15-i|0)*3|0,n=xA(A|0,r|0,s|0)|0,S()|0,n=n&7,f&((n|0)==1&!0)){n=7;break}if(!((n|0)==7&!0)){n=10;break}if(f=CA(1,0,s|0)|0,A=YA(A|0,r|0,f|0,S()|0)|0,r=S()|0,f=e,t[f>>2]=A,t[f+4>>2]=r,(i|0)>(o|0))i=i+-1|0;else{n=10;break}}if((n|0)==5){f=e,t[f>>2]=0,t[f+4>>2]=0,t[l>>2]=-1,t[c>>2]=-1;return}else if((n|0)==7){o=CA(1,0,s|0)|0,o=YA(A|0,r|0,o|0,S()|0)|0,l=S()|0,f=e,t[f>>2]=o,t[f+4>>2]=l,t[c>>2]=i+-1;return}else if((n|0)==10)return}}function s0(e){e=+e;var A=0;return A=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?A+-6.283185307179586:A)}function Ln(e,A){return e=e|0,A=A|0,+qA(+(+C[e>>3]-+C[A>>3]))<17453292519943298e-27?(A=+qA(+(+C[e+8>>3]-+C[A+8>>3]))<17453292519943298e-27,A|0):(A=0,A|0)}function Kt(e,A){switch(e=+e,A=A|0,A|0){case 1:{e=e<0?e+6.283185307179586:e;break}case 2:{e=e>0?e+-6.283185307179586:e;break}}return+e}function Tl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+C[A>>3],n=+C[e>>3],i=+ie(+((s-n)*.5)),r=+ie(+((+C[A+8>>3]-+C[e+8>>3])*.5)),r=i*i+r*(+ue(+s)*+ue(+n)*r),+(+nt(+ +be(+r),+ +be(+(1-r)))*2)}function i0(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+C[A>>3],n=+C[e>>3],i=+ie(+((s-n)*.5)),r=+ie(+((+C[A+8>>3]-+C[e+8>>3])*.5)),r=i*i+r*(+ue(+s)*+ue(+n)*r),+(+nt(+ +be(+r),+ +be(+(1-r)))*2*6371.007180918475)}function Il(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+C[A>>3],n=+C[e>>3],i=+ie(+((s-n)*.5)),r=+ie(+((+C[A+8>>3]-+C[e+8>>3])*.5)),r=i*i+r*(+ue(+s)*+ue(+n)*r),+(+nt(+ +be(+r),+ +be(+(1-r)))*2*6371.007180918475*1e3)}function Ll(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;return i=+C[A>>3],n=+ue(+i),s=+C[A+8>>3]-+C[e+8>>3],o=n*+ie(+s),r=+C[e>>3],+ +nt(+o,+(+ie(+i)*+ue(+r)-+ue(+s)*(n*+ie(+r))))}function Nl(e,A,r,n){e=e|0,A=+A,r=+r,n=n|0;var s=0,i=0,o=0,l=0;if(r<1e-16){t[n>>2]=t[e>>2],t[n+4>>2]=t[e+4>>2],t[n+8>>2]=t[e+8>>2],t[n+12>>2]=t[e+12>>2];return}i=A<0?A+6.283185307179586:A,i=A>=6.283185307179586?i+-6.283185307179586:i;do if(i<1e-16)A=+C[e>>3]+r,C[n>>3]=A,s=n;else{if(s=+qA(+(i+-3.141592653589793))<1e-16,A=+C[e>>3],s){A=A-r,C[n>>3]=A,s=n;break}if(o=+ue(+r),r=+ie(+r),A=o*+ie(+A)+ +ue(+i)*(r*+ue(+A)),A=A>1?1:A,A=+rr(+(A<-1?-1:A)),C[n>>3]=A,+qA(+(A+-1.5707963267948966))<1e-16){C[n>>3]=1.5707963267948966,C[n+8>>3]=0;return}if(+qA(+(A+1.5707963267948966))<1e-16){C[n>>3]=-1.5707963267948966,C[n+8>>3]=0;return}if(l=1/+ue(+A),i=r*+ie(+i)*l,r=+C[e>>3],A=l*((o-+ie(+A)*+ie(+r))/+ue(+r)),o=i>1?1:i,A=A>1?1:A,A=+C[e+8>>3]+ +nt(+(o<-1?-1:o),+(A<-1?-1:A)),A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);C[n+8>>3]=A;return}while(!1);if(+qA(+(A+-1.5707963267948966))<1e-16){C[s>>3]=1.5707963267948966,C[n+8>>3]=0;return}if(+qA(+(A+1.5707963267948966))<1e-16){C[s>>3]=-1.5707963267948966,C[n+8>>3]=0;return}if(A=+C[e+8>>3],A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);C[n+8>>3]=A}function Xs(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(C[A>>3]=+C[20656+(e<<3)>>3],A=0,A|0)}function Fl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(C[A>>3]=+C[20784+(e<<3)>>3],A=0,A|0)}function Pl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(C[A>>3]=+C[20912+(e<<3)>>3],A=0,A|0)}function Ql(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(C[A>>3]=+C[21040+(e<<3)>>3],A=0,A|0)}function E0(e,A){e=e|0,A=A|0;var r=0;return e>>>0>15?(A=4,A|0):(r=qr(7,0,e,((e|0)<0)<<31>>31)|0,r=wt(r|0,S()|0,120,0)|0,e=S()|0,t[A>>2]=r|2,t[A+4>>2]=e,A=0,A|0)}function Ai(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0;return I=+C[A>>3],p=+C[e>>3],c=+ie(+((I-p)*.5)),i=+C[A+8>>3],f=+C[e+8>>3],o=+ie(+((i-f)*.5)),l=+ue(+p),B=+ue(+I),o=c*c+o*(B*l*o),o=+nt(+ +be(+o),+ +be(+(1-o)))*2,c=+C[r>>3],I=+ie(+((c-I)*.5)),n=+C[r+8>>3],i=+ie(+((n-i)*.5)),s=+ue(+c),i=I*I+i*(B*s*i),i=+nt(+ +be(+i),+ +be(+(1-i)))*2,c=+ie(+((p-c)*.5)),n=+ie(+((f-n)*.5)),n=c*c+n*(l*s*n),n=+nt(+ +be(+n),+ +be(+(1-n)))*2,s=(o+i+n)*.5,+(+Ct(+ +be(+(+rt(+(s*.5))*+rt(+((s-o)*.5))*+rt(+((s-i)*.5))*+rt(+((s-n)*.5)))))*4)}function us(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0;if(l=E,E=E+192|0,i=l+168|0,o=l,s=dn(e,A,i)|0,s|0)return r=s,E=l,r|0;if(In(e,A,o)|0&&PA(27795,27190,415,27199),A=t[o>>2]|0,(A|0)>0){if(n=+Ai(o+8|0,o+8+(((A|0)!=1&1)<<4)|0,i)+0,(A|0)!=1){e=1;do s=e,e=e+1|0,n=n+ +Ai(o+8+(s<<4)|0,o+8+(((e|0)%(A|0)|0)<<4)|0,i);while((e|0)<(A|0))}}else n=0;return C[r>>3]=n,r=0,E=l,r|0}function Ol(e,A,r){return e=e|0,A=A|0,r=r|0,e=us(e,A,r)|0,e|0||(C[r>>3]=+C[r>>3]*6371.007180918475*6371.007180918475),e|0}function zl(e,A,r){return e=e|0,A=A|0,r=r|0,e=us(e,A,r)|0,e|0||(C[r>>3]=+C[r>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function Hl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(l=E,E=E+176|0,o=l,e=fn(e,A,o)|0,e|0)return o=e,E=l,o|0;if(C[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,E=l,o|0;A=e+-1|0,e=0,n=+C[o+8>>3],s=+C[o+16>>3],i=0;do e=e+1|0,f=n,n=+C[o+8+(e<<4)>>3],p=+ie(+((n-f)*.5)),c=s,s=+C[o+8+(e<<4)+8>>3],c=+ie(+((s-c)*.5)),c=p*p+c*(+ue(+n)*+ue(+f)*c),i=i+ +nt(+ +be(+c),+ +be(+(1-c)))*2;while((e|0)<(A|0));return C[r>>3]=i,o=0,E=l,o|0}function Gl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(l=E,E=E+176|0,o=l,e=fn(e,A,o)|0,e|0)return o=e,i=+C[r>>3],i=i*6371.007180918475,C[r>>3]=i,E=l,o|0;if(C[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,i=0,i=i*6371.007180918475,C[r>>3]=i,E=l,o|0;A=e+-1|0,e=0,n=+C[o+8>>3],s=+C[o+16>>3],i=0;do e=e+1|0,f=n,n=+C[o+8+(e<<4)>>3],p=+ie(+((n-f)*.5)),c=s,s=+C[o+8+(e<<4)+8>>3],c=+ie(+((s-c)*.5)),c=p*p+c*(+ue(+f)*+ue(+n)*c),i=i+ +nt(+ +be(+c),+ +be(+(1-c)))*2;while((e|0)!=(A|0));return C[r>>3]=i,o=0,p=i,p=p*6371.007180918475,C[r>>3]=p,E=l,o|0}function Ul(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(l=E,E=E+176|0,o=l,e=fn(e,A,o)|0,e|0)return o=e,i=+C[r>>3],i=i*6371.007180918475,i=i*1e3,C[r>>3]=i,E=l,o|0;if(C[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,i=0,i=i*6371.007180918475,i=i*1e3,C[r>>3]=i,E=l,o|0;A=e+-1|0,e=0,n=+C[o+8>>3],s=+C[o+16>>3],i=0;do e=e+1|0,f=n,n=+C[o+8+(e<<4)>>3],p=+ie(+((n-f)*.5)),c=s,s=+C[o+8+(e<<4)+8>>3],c=+ie(+((s-c)*.5)),c=p*p+c*(+ue(+f)*+ue(+n)*c),i=i+ +nt(+ +be(+c),+ +be(+(1-c)))*2;while((e|0)!=(A|0));return C[r>>3]=i,o=0,p=i,p=p*6371.007180918475,p=p*1e3,C[r>>3]=p,E=l,o|0}function Vl(e){e=e|0;var A=0,r=0,n=0;return A=Gt(1,12)|0,A||PA(27280,27235,49,27293),r=e+4|0,n=t[r>>2]|0,n|0?(n=n+8|0,t[n>>2]=A,t[r>>2]=A,A|0):(t[e>>2]|0&&PA(27310,27235,61,27333),n=e,t[n>>2]=A,t[r>>2]=A,A|0)}function Wl(e,A){e=e|0,A=A|0;var r=0,n=0;return n=Er(24)|0,n||PA(27347,27235,78,27361),t[n>>2]=t[A>>2],t[n+4>>2]=t[A+4>>2],t[n+8>>2]=t[A+8>>2],t[n+12>>2]=t[A+12>>2],t[n+16>>2]=0,A=e+4|0,r=t[A>>2]|0,r|0?(t[r+16>>2]=n,t[A>>2]=n,n|0):(t[e>>2]|0&&PA(27376,27235,82,27361),t[e>>2]=n,t[A>>2]=n,n|0)}function ei(e){e=e|0;var A=0,r=0,n=0,s=0;if(e)for(n=1;;){if(A=t[e>>2]|0,A|0)do{if(r=t[A>>2]|0,r|0)do s=r,r=t[r+16>>2]|0,$A(s);while((r|0)!=0);s=A,A=t[A+8>>2]|0,$A(s)}while((A|0)!=0);if(A=e,e=t[e+8>>2]|0,n||$A(A),e)n=0;else break}}function Yl(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0,ge=0,Ee=0,se=0,UA=0,EA=0,ve=0,He=0,ye=0;if(s=e+8|0,t[s>>2]|0)return ye=1,ye|0;if(n=t[e>>2]|0,!n)return ye=0,ye|0;A=n,r=0;do r=r+1|0,A=t[A+8>>2]|0;while((A|0)!=0);if(r>>>0<2)return ye=0,ye|0;ve=Er(r<<2)|0,ve||PA(27396,27235,317,27415),EA=Er(r<<5)|0,EA||PA(27437,27235,321,27415),t[e>>2]=0,GA=e+4|0,t[GA>>2]=0,t[s>>2]=0,r=0,UA=0,MA=0,B=0;A:for(;;){if(p=t[n>>2]|0,p){i=0,o=p;do{if(c=+C[o+8>>3],A=o,o=t[o+16>>2]|0,f=(o|0)==0,s=f?p:o,l=+C[s+8>>3],+qA(+(c-l))>3.141592653589793){ye=14;break}i=i+(l-c)*(+C[A>>3]+ +C[s>>3])}while(!f);if((ye|0)==14){ye=0,i=0,A=p;do U=+C[A+8>>3],se=A+16|0,Ee=t[se>>2]|0,Ee=(Ee|0)==0?p:Ee,$=+C[Ee+8>>3],i=i+(+C[A>>3]+ +C[Ee>>3])*(($<0?$+6.283185307179586:$)-(U<0?U+6.283185307179586:U)),A=t[((A|0)==0?n:se)>>2]|0;while((A|0)!=0)}i>0?(t[ve+(UA<<2)>>2]=n,UA=UA+1|0,s=MA,A=B):ye=19}else ye=19;if((ye|0)==19){ye=0;do if(r){if(A=r+8|0,t[A>>2]|0){ye=21;break A}if(r=Gt(1,12)|0,!r){ye=23;break A}t[A>>2]=r,s=r+4|0,o=r,A=B}else if(B){s=GA,o=B+8|0,A=n,r=e;break}else if(t[e>>2]|0){ye=27;break A}else{s=GA,o=e,A=n,r=e;break}while(!1);if(t[o>>2]=n,t[s>>2]=n,o=EA+(MA<<5)|0,f=t[n>>2]|0,f){for(p=EA+(MA<<5)+8|0,C[p>>3]=17976931348623157e292,B=EA+(MA<<5)+24|0,C[B>>3]=17976931348623157e292,C[o>>3]=-17976931348623157e292,I=EA+(MA<<5)+16|0,C[I>>3]=-17976931348623157e292,nA=17976931348623157e292,q=-17976931348623157e292,s=0,L=f,c=17976931348623157e292,G=17976931348623157e292,Y=-17976931348623157e292,l=-17976931348623157e292;i=+C[L>>3],U=+C[L+8>>3],L=t[L+16>>2]|0,N=(L|0)==0,$=+C[(N?f:L)+8>>3],i<c&&(C[p>>3]=i,c=i),U<G&&(C[B>>3]=U,G=U),i>Y?C[o>>3]=i:i=Y,U>l&&(C[I>>3]=U,l=U),nA=U>0&U<nA?U:nA,q=U<0&U>q?U:q,s=s|+qA(+(U-$))>3.141592653589793,!N;)Y=i;s&&(C[I>>3]=q,C[B>>3]=nA)}else t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,t[o+12>>2]=0,t[o+16>>2]=0,t[o+20>>2]=0,t[o+24>>2]=0,t[o+28>>2]=0;s=MA+1|0}if(se=n+8|0,n=t[se>>2]|0,t[se>>2]=0,n)MA=s,B=A;else{ye=45;break}}if((ye|0)==21)PA(27213,27235,35,27247);else if((ye|0)==23)PA(27267,27235,37,27247);else if((ye|0)==27)PA(27310,27235,61,27333);else if((ye|0)==45){A:do if((UA|0)>0){for(se=(s|0)==0,ge=s<<2,Ee=(e|0)==0,me=0,A=0;;){if(OA=t[ve+(me<<2)>>2]|0,se)ye=73;else{if(MA=Er(ge)|0,!MA){ye=50;break}if(GA=Er(ge)|0,!GA){ye=52;break}e:do if(Ee)r=0;else{for(s=0,r=0,o=e;n=EA+(s<<5)|0,ti(t[o>>2]|0,n,t[OA>>2]|0)|0?(t[MA+(r<<2)>>2]=o,t[GA+(r<<2)>>2]=n,N=r+1|0):N=r,o=t[o+8>>2]|0,o;)s=s+1|0,r=N;if((N|0)>0)if(n=t[MA>>2]|0,(N|0)==1)r=n;else for(I=0,L=-1,r=n,B=n;;){for(f=t[B>>2]|0,n=0,o=0;s=t[t[MA+(o<<2)>>2]>>2]|0,(s|0)==(f|0)?p=n:p=n+((ti(s,t[GA+(o<<2)>>2]|0,t[f>>2]|0)|0)&1)|0,o=o+1|0,(o|0)!=(N|0);)n=p;if(s=(p|0)>(L|0),r=s?B:r,n=I+1|0,(n|0)==(N|0))break e;I=n,L=s?p:L,B=t[MA+(n<<2)>>2]|0}else r=0}while(!1);if($A(MA),$A(GA),r){if(s=r+4|0,n=t[s>>2]|0,n)r=n+8|0;else if(t[r>>2]|0){ye=70;break}t[r>>2]=OA,t[s>>2]=OA}else ye=73}if((ye|0)==73){if(ye=0,A=t[OA>>2]|0,A|0)do GA=A,A=t[A+16>>2]|0,$A(GA);while((A|0)!=0);$A(OA),A=1}if(me=me+1|0,(me|0)>=(UA|0)){He=A;break A}}(ye|0)==50?PA(27452,27235,249,27471):(ye|0)==52?PA(27490,27235,252,27471):(ye|0)==70&&PA(27310,27235,61,27333)}else He=0;while(!1);return $A(ve),$A(EA),ye=He,ye|0}return 0}function ti(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(!(br(A,r)|0)||(A=zt(A)|0,n=+C[r>>3],s=+C[r+8>>3],s=A&s<0?s+6.283185307179586:s,e=t[e>>2]|0,!e))return e=0,e|0;if(A){A=0,f=s,r=e;A:for(;;){for(;o=+C[r>>3],s=+C[r+8>>3],r=r+16|0,p=t[r>>2]|0,p=(p|0)==0?e:p,i=+C[p>>3],l=+C[p+8>>3],o>i?(c=o,o=l):(c=i,i=o,o=s,s=l),n=n==i|n==c?n+2220446049250313e-31:n,!!(n<i|n>c);)if(r=t[r>>2]|0,!r){r=22;break A}if(l=o<0?o+6.283185307179586:o,o=s<0?s+6.283185307179586:s,f=l==f|o==f?f+-2220446049250313e-31:f,c=l+(o-l)*((n-i)/(c-i)),(c<0?c+6.283185307179586:c)>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}else{A=0,f=s,r=e;A:for(;;){for(;o=+C[r>>3],s=+C[r+8>>3],r=r+16|0,p=t[r>>2]|0,p=(p|0)==0?e:p,i=+C[p>>3],l=+C[p+8>>3],o>i?(c=o,o=l):(c=i,i=o,o=s,s=l),n=n==i|n==c?n+2220446049250313e-31:n,!!(n<i|n>c);)if(r=t[r>>2]|0,!r){r=22;break A}if(f=o==f|s==f?f+-2220446049250313e-31:f,o+(s-o)*((n-i)/(c-i))>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}return 0}function Gr(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0;if(q=E,E=E+32|0,nA=q+16|0,Y=q,i=xA(e|0,A|0,52)|0,S()|0,i=i&15,L=xA(r|0,n|0,52)|0,S()|0,(i|0)!=(L&15|0))return nA=12,E=q,nA|0;if(f=xA(e|0,A|0,45)|0,S()|0,f=f&127,p=xA(r|0,n|0,45)|0,S()|0,p=p&127,f>>>0>121|p>>>0>121)return nA=5,E=q,nA|0;if(L=(f|0)!=(p|0),L){if(l=un(f,p)|0,(l|0)==7)return nA=1,E=q,nA|0;c=un(p,f)|0,(c|0)==7?PA(27514,27538,161,27548):(N=l,o=c)}else N=0,o=0;B=je(f)|0,I=je(p)|0,t[nA>>2]=0,t[nA+4>>2]=0,t[nA+8>>2]=0,t[nA+12>>2]=0;do if(N){if(p=t[4272+(f*28|0)+(N<<2)>>2]|0,l=(p|0)>0,I)if(l){f=0,c=r,l=n;do c=Ml(c,l)|0,l=S()|0,o=Yt(o)|0,(o|0)==1&&(o=Yt(1)|0),f=f+1|0;while((f|0)!=(p|0));p=o,f=c,c=l}else p=o,f=r,c=n;else if(l){f=0,c=r,l=n;do c=ns(c,l)|0,l=S()|0,o=Yt(o)|0,f=f+1|0;while((f|0)!=(p|0));p=o,f=c,c=l}else p=o,f=r,c=n;if(is(f,c,nA)|0,L||PA(27563,27538,191,27548),l=(B|0)!=0,o=(I|0)!=0,l&o&&PA(27590,27538,192,27548),l){if(o=Ht(e,A)|0,(o|0)==7){i=5;break}if(mA[22e3+(o*7|0)+N>>0]|0){i=1;break}c=t[21168+(o*28|0)+(N<<2)>>2]|0,f=c}else if(o){if(o=Ht(f,c)|0,(o|0)==7){i=5;break}if(mA[22e3+(o*7|0)+p>>0]|0){i=1;break}f=0,c=t[21168+(p*28|0)+(o<<2)>>2]|0}else f=0,c=0;if((f|c|0)<0)i=5;else{if((c|0)>0){l=nA+4|0,o=0;do yt(l),o=o+1|0;while((o|0)!=(c|0))}if(t[Y>>2]=0,t[Y+4>>2]=0,t[Y+8>>2]=0,gt(Y,N),i|0)for(;or(i)|0?st(Y):Xe(Y),(i|0)>1;)i=i+-1|0;if((f|0)>0){i=0;do yt(Y),i=i+1|0;while((i|0)!=(f|0))}G=nA+4|0,H(G,Y,G),et(G),G=51}}else if(is(r,n,nA)|0,(B|0)!=0&(I|0)!=0)if((p|0)!=(f|0)&&PA(27621,27538,261,27548),o=Ht(e,A)|0,i=Ht(r,n)|0,(o|0)==7|(i|0)==7)i=5;else if(mA[22e3+(o*7|0)+i>>0]|0)i=1;else if(o=t[21168+(o*28|0)+(i<<2)>>2]|0,(o|0)>0){l=nA+4|0,i=0;do yt(l),i=i+1|0;while((i|0)!=(o|0));G=51}else G=51;else G=51;while(!1);return(G|0)==51&&(i=nA+4|0,t[s>>2]=t[i>>2],t[s+4>>2]=t[i+4>>2],t[s+8>>2]=t[i+8>>2],i=0),nA=i,E=q,nA|0}function ri(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0;if(G=E,E=E+48|0,f=G+36|0,o=G+24|0,l=G+12|0,c=G,s=xA(e|0,A|0,52)|0,S()|0,s=s&15,I=xA(e|0,A|0,45)|0,S()|0,I=I&127,I>>>0>121)return n=5,E=G,n|0;if(p=je(I)|0,CA(s|0,0,52)|0,Y=S()|0|134225919,i=n,t[i>>2]=-1,t[i+4>>2]=Y,!s)return s=NA(r)|0,(s|0)==7||(s=an(I,s)|0,(s|0)==127)?(Y=1,E=G,Y|0):(L=CA(s|0,0,45)|0,N=S()|0,I=n,N=t[I+4>>2]&-1040385|N,Y=n,t[Y>>2]=t[I>>2]|L,t[Y+4>>2]=N,Y=0,E=G,Y|0);for(t[f>>2]=t[r>>2],t[f+4>>2]=t[r+4>>2],t[f+8>>2]=t[r+8>>2],r=s;;){if(i=r,r=r+-1|0,t[o>>2]=t[f>>2],t[o+4>>2]=t[f+4>>2],t[o+8>>2]=t[f+8>>2],or(i)|0){if(s=HA(f)|0,s|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],st(l)}else{if(s=oe(f)|0,s|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],Xe(l)}if(oA(o,l,c),et(c),s=n,q=t[s>>2]|0,s=t[s+4>>2]|0,$=(15-i|0)*3|0,nA=CA(7,0,$|0)|0,s=s&~(S()|0),$=CA(NA(c)|0,0,$|0)|0,s=S()|0|s,Y=n,t[Y>>2]=$|q&~nA,t[Y+4>>2]=s,(i|0)<=1){r=14;break}}A:do if((r|0)!=13&&(r|0)==14)if((t[f>>2]|0)<=1&&(t[f+4>>2]|0)<=1&&(t[f+8>>2]|0)<=1){r=NA(f)|0,s=an(I,r)|0,(s|0)==127?c=0:c=je(s)|0;e:do if(r){if(p){if(s=Ht(e,A)|0,(s|0)==7){s=5;break A}if(i=t[21376+(s*28|0)+(r<<2)>>2]|0,(i|0)>0){s=r,r=0;do s=Wt(s)|0,r=r+1|0;while((r|0)!=(i|0))}else s=r;if((s|0)==1){s=9;break A}r=an(I,s)|0,(r|0)==127&&PA(27648,27538,411,27678),je(r)|0?PA(27693,27538,412,27678):(N=r,L=i,B=s)}else N=s,L=0,B=r;if(l=t[4272+(I*28|0)+(B<<2)>>2]|0,(l|0)<=-1&&PA(27724,27538,419,27678),!c){if((L|0)<0){s=5;break A}if(L|0){i=n,s=0,r=t[i>>2]|0,i=t[i+4>>2]|0;do r=hn(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,s=s+1|0;while((s|0)<(L|0))}if((l|0)<=0){s=N,r=58;break}for(i=n,s=0,r=t[i>>2]|0,i=t[i+4>>2]|0;;)if(r=hn(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,s=s+1|0,(s|0)==(l|0)){s=N,r=58;break e}}if(o=un(N,I)|0,(o|0)==7&&PA(27514,27538,428,27678),s=n,r=t[s>>2]|0,s=t[s+4>>2]|0,(l|0)>0){i=0;do r=hn(r,s)|0,s=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=s,i=i+1|0;while((i|0)!=(l|0))}if(s=Ht(r,s)|0,(s|0)==7&&PA(27795,27538,440,27678),r=jt(N)|0,r=t[(r?21792:21584)+(o*28|0)+(s<<2)>>2]|0,(r|0)<0&&PA(27795,27538,454,27678),!r)s=N,r=58;else{o=n,s=0,i=t[o>>2]|0,o=t[o+4>>2]|0;do i=rs(i,o)|0,o=S()|0,$=n,t[$>>2]=i,t[$+4>>2]=o,s=s+1|0;while((s|0)<(r|0));s=N,r=58}}else if((p|0)!=0&(c|0)!=0){if(r=Ht(e,A)|0,i=n,i=Ht(t[i>>2]|0,t[i+4>>2]|0)|0,(r|0)==7|(i|0)==7){s=5;break A}if(i=t[21376+(r*28|0)+(i<<2)>>2]|0,(i|0)<0){s=5;break A}if(!i)r=59;else{l=n,r=0,o=t[l>>2]|0,l=t[l+4>>2]|0;do o=hn(o,l)|0,l=S()|0,$=n,t[$>>2]=o,t[$+4>>2]=l,r=r+1|0;while((r|0)<(i|0));r=58}}else r=58;while(!1);if((r|0)==58&&c&&(r=59),(r|0)==59&&($=n,(Ht(t[$>>2]|0,t[$+4>>2]|0)|0)==1)){s=9;break}$=n,nA=t[$>>2]|0,$=t[$+4>>2]&-1040385,q=CA(s|0,0,45)|0,$=$|(S()|0),s=n,t[s>>2]=nA|q,t[s+4>>2]=$,s=0}else s=1;while(!1);return $=s,E=G,$|0}function Kl(e,A,r,n,s,i){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0;var o=0,l=0;return l=E,E=E+16|0,o=l,s?e=15:(e=Gr(e,A,r,n,o)|0,e||(Xn(o,i),e=0)),E=l,e|0}function $l(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0;return o=E,E=E+16|0,i=o,n?r=15:(r=Rt(r,i)|0,r||(r=ri(e,A,i,s)|0)),E=o,r|0}function Zl(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0;return c=E,E=E+32|0,o=c+12|0,l=c,i=Gr(e,A,e,A,o)|0,i|0?(l=i,E=c,l|0):(e=Gr(e,A,r,n,l)|0,e|0?(l=e,E=c,l|0):(o=Dn(o,l)|0,l=s,t[l>>2]=o,t[l+4>>2]=((o|0)<0)<<31>>31,l=0,E=c,l|0))}function ql(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0;return c=E,E=E+32|0,o=c+12|0,l=c,i=Gr(e,A,e,A,o)|0,!i&&(i=Gr(e,A,r,n,l)|0,!i)?(n=Dn(o,l)|0,n=YA(n|0,((n|0)<0)<<31>>31|0,1,0)|0,o=S()|0,l=s,t[l>>2]=n,t[l+4>>2]=o,l=0,E=c,l|0):(l=i,E=c,l|0)}function Jl(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0;if(OA=E,E=E+48|0,MA=OA+24|0,o=OA+12|0,GA=OA,i=Gr(e,A,e,A,MA)|0,!i&&(i=Gr(e,A,r,n,o)|0,!i)){$=Dn(MA,o)|0,U=(($|0)<0)<<31>>31,t[MA>>2]=0,t[MA+4>>2]=0,t[MA+8>>2]=0,t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,Gr(e,A,e,A,MA)|0&&PA(27795,27538,692,27747),Gr(e,A,r,n,o)|0&&PA(27795,27538,697,27747),A0(MA),A0(o),p=($|0)==0?0:1/+($|0),r=t[MA>>2]|0,G=p*+((t[o>>2]|0)-r|0),Y=MA+4|0,n=t[Y>>2]|0,nA=p*+((t[o+4>>2]|0)-n|0),q=MA+8|0,i=t[q>>2]|0,p=p*+((t[o+8>>2]|0)-i|0),t[GA>>2]=r,B=GA+4|0,t[B>>2]=n,I=GA+8|0,t[I>>2]=i;A:do if(($|0)<0)i=0;else for(L=0,N=0;;){c=+(N>>>0)+4294967296*+(L|0),me=G*c+ +(r|0),l=nA*c+ +(n|0),c=p*c+ +(i|0),r=~~+D0(+me),o=~~+D0(+l),i=~~+D0(+c),me=+qA(+(+(r|0)-me)),l=+qA(+(+(o|0)-l)),c=+qA(+(+(i|0)-c));do if(me>l&me>c)r=0-(o+i)|0,n=o;else if(f=0-r|0,l>c){n=f-i|0;break}else{n=o,i=f-o|0;break}while(!1);if(t[GA>>2]=r,t[B>>2]=n,t[I>>2]=i,e0(GA),i=ri(e,A,GA,s+(N<<3)|0)|0,i|0)break A;if(!((L|0)<(U|0)|(L|0)==(U|0)&N>>>0<$>>>0)){i=0;break A}r=YA(N|0,L|0,1,0)|0,n=S()|0,L=n,N=r,r=t[MA>>2]|0,n=t[Y>>2]|0,i=t[q>>2]|0}while(!1);return GA=i,E=OA,GA|0}return GA=i,E=OA,GA|0}function qr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;if((r|0)==0&(n|0)==0)return s=0,i=1,JA(s|0),i|0;i=e,s=A,e=1,A=0;do o=(r&1|0)==0&!0,e=wt((o?1:i)|0,(o?0:s)|0,e|0,A|0)|0,A=S()|0,r=pi(r|0,n|0,1)|0,n=S()|0,i=wt(i|0,s|0,i|0,s|0)|0,s=S()|0;while(!((r|0)==0&(n|0)==0));return JA(A|0),e|0}function cs(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0;l=E,E=E+16|0,i=l,o=xA(e|0,A|0,52)|0,S()|0,o=o&15;do if(o){if(s=dn(e,A,i)|0,!s){f=+C[i>>3],c=1/+ue(+f),p=+C[25968+(o<<3)>>3],C[r>>3]=f+p,C[r+8>>3]=f-p,f=+C[i+8>>3],c=p*c,C[r+16>>3]=c+f,C[r+24>>3]=f-c;break}return o=s,E=l,o|0}else{if(s=xA(e|0,A|0,45)|0,S()|0,s=s&127,s>>>0>121)return o=5,E=l,o|0;i=22064+(s<<5)|0,t[r>>2]=t[i>>2],t[r+4>>2]=t[i+4>>2],t[r+8>>2]=t[i+8>>2],t[r+12>>2]=t[i+12>>2],t[r+16>>2]=t[i+16>>2],t[r+20>>2]=t[i+20>>2],t[r+24>>2]=t[i+24>>2],t[r+28>>2]=t[i+28>>2];break}while(!1);return pr(r,n?1.4:1.1),n=26096+(o<<3)|0,(t[n>>2]|0)==(e|0)&&(t[n+4>>2]|0)==(A|0)&&(C[r>>3]=1.5707963267948966),o=26224+(o<<3)|0,(t[o>>2]|0)==(e|0)&&(t[o+4>>2]|0)==(A|0)&&(C[r+8>>3]=-1.5707963267948966),+C[r>>3]!=1.5707963267948966&&+C[r+8>>3]!=-1.5707963267948966?(o=0,E=l,o|0):(C[r+16>>3]=3.141592653589793,C[r+24>>3]=-3.141592653589793,o=0,E=l,o|0)}function Xl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0;f=E,E=E+48|0,o=f+32|0,i=f+40|0,l=f,It(o,0,0,0),c=t[o>>2]|0,o=t[o+4>>2]|0;do if(r>>>0<=15){if(s=l0(n)|0,s|0){n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=s,t[l+12>>2]=-1,n=l+16|0,c=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,mA[n+12>>0]=0,mA[c>>0]=mA[i>>0]|0,mA[c+1>>0]=mA[i+1>>0]|0,mA[c+2>>0]=mA[i+2>>0]|0;break}if(s=Gt((t[A+8>>2]|0)+1|0,32)|0,s){fs(A,s),p=l,t[p>>2]=c,t[p+4>>2]=o,t[l+8>>2]=0,t[l+12>>2]=r,t[l+16>>2]=n,t[l+20>>2]=A,t[l+24>>2]=s,mA[l+28>>0]=0,c=l+29|0,mA[c>>0]=mA[i>>0]|0,mA[c+1>>0]=mA[i+1>>0]|0,mA[c+2>>0]=mA[i+2>>0]|0;break}else{n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=13,t[l+12>>2]=-1,n=l+16|0,c=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,mA[n+12>>0]=0,mA[c>>0]=mA[i>>0]|0,mA[c+1>>0]=mA[i+1>>0]|0,mA[c+2>>0]=mA[i+2>>0]|0;break}}else c=l,t[c>>2]=0,t[c+4>>2]=0,t[l+8>>2]=4,t[l+12>>2]=-1,c=l+16|0,p=l+29|0,t[c>>2]=0,t[c+4>>2]=0,t[c+8>>2]=0,mA[c+12>>0]=0,mA[p>>0]=mA[i>>0]|0,mA[p+1>>0]=mA[i+1>>0]|0,mA[p+2>>0]=mA[i+2>>0]|0;while(!1);S0(l),t[e>>2]=t[l>>2],t[e+4>>2]=t[l+4>>2],t[e+8>>2]=t[l+8>>2],t[e+12>>2]=t[l+12>>2],t[e+16>>2]=t[l+16>>2],t[e+20>>2]=t[l+20>>2],t[e+24>>2]=t[l+24>>2],t[e+28>>2]=t[l+28>>2],E=f}function S0(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0;if(U=E,E=E+336|0,L=U+168|0,N=U,n=e,r=t[n>>2]|0,n=t[n+4>>2]|0,(r|0)==0&(n|0)==0){E=U;return}if(A=e+28|0,mA[A>>0]|0?(r=ni(r,n)|0,n=S()|0):mA[A>>0]=1,$=e+20|0,!(t[t[$>>2]>>2]|0)){A=e+24|0,r=t[A>>2]|0,r|0&&$A(r),q=e,t[q>>2]=0,t[q+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[e+16>>2]=0,t[A>>2]=0,E=U;return}q=e+16|0,A=t[q>>2]|0,s=A&15;A:do if((r|0)==0&(n|0)==0)nA=e+24|0;else{G=e+12|0,B=(s|0)==3,p=A&255,c=(s|1|0)==3,I=e+24|0,f=(s+-1|0)>>>0<3,o=(s|2|0)==3,l=N+8|0;e:for(;;){if(i=xA(r|0,n|0,52)|0,S()|0,i=i&15,(i|0)==(t[G>>2]|0)){switch(p&15){case 0:case 2:case 3:{if(s=dn(r,n,L)|0,s|0){Y=15;break e}if(hs(t[$>>2]|0,t[I>>2]|0,L)|0){Y=19;break e}break}}if(c&&(s=t[(t[$>>2]|0)+4>>2]|0,t[L>>2]=t[s>>2],t[L+4>>2]=t[s+4>>2],t[L+8>>2]=t[s+8>>2],t[L+12>>2]=t[s+12>>2],br(26832,L)|0)){if(ss(t[(t[$>>2]|0)+4>>2]|0,i,N)|0){Y=25;break}if(s=N,(t[s>>2]|0)==(r|0)&&(t[s+4>>2]|0)==(n|0)){Y=29;break}}if(f){if(s=In(r,n,L)|0,s|0){Y=32;break}if(cs(r,n,N,0)|0){Y=36;break}if(o&&ii(t[$>>2]|0,t[I>>2]|0,L,N)|0){Y=42;break}if(c&&oi(t[$>>2]|0,t[I>>2]|0,L,N)|0){Y=42;break}}if(B){if(A=cs(r,n,L,1)|0,s=t[I>>2]|0,A|0){Y=45;break}if(Ne(s,L)|0){if(kr(N,L),zr(L,t[I>>2]|0)|0){Y=53;break}if(hs(t[$>>2]|0,t[I>>2]|0,l)|0){Y=53;break}if(oi(t[$>>2]|0,t[I>>2]|0,N,L)|0){Y=53;break}}}}do if((i|0)<(t[G>>2]|0)){if(A=cs(r,n,L,1)|0,s=t[I>>2]|0,A|0){Y=58;break e}if(!(Ne(s,L)|0)){Y=73;break}if(zr(t[I>>2]|0,L)|0&&(kr(N,L),ii(t[$>>2]|0,t[I>>2]|0,N,L)|0)){Y=65;break e}if(r=Zs(r,n,i+1|0,N)|0,r|0){Y=67;break e}n=N,r=t[n>>2]|0,n=t[n+4>>2]|0}else Y=73;while(!1);if((Y|0)==73&&(Y=0,r=ni(r,n)|0,n=S()|0),(r|0)==0&(n|0)==0){nA=I;break A}}switch(Y|0){case 15:{A=t[I>>2]|0,A|0&&$A(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=s,Y=20;break}case 19:{t[e>>2]=r,t[e+4>>2]=n,Y=20;break}case 25:{PA(27795,27761,470,27772);break}case 29:{t[e>>2]=r,t[e+4>>2]=n,E=U;return}case 32:{A=t[I>>2]|0,A|0&&$A(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=s,E=U;return}case 36:{PA(27795,27761,493,27772);break}case 42:{t[e>>2]=r,t[e+4>>2]=n,E=U;return}case 45:{s|0&&$A(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=A,Y=55;break}case 53:{t[e>>2]=r,t[e+4>>2]=n,Y=55;break}case 58:{s|0&&$A(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=A,Y=71;break}case 65:{t[e>>2]=r,t[e+4>>2]=n,Y=71;break}case 67:{A=t[I>>2]|0,A|0&&$A(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=r,E=U;return}}if((Y|0)==20){E=U;return}else if((Y|0)==55){E=U;return}else if((Y|0)==71){E=U;return}}while(!1);A=t[nA>>2]|0,A|0&&$A(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[q>>2]=0,t[nA>>2]=0,E=U}function ni(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0;B=E,E=E+16|0,p=B,n=xA(e|0,A|0,52)|0,S()|0,n=n&15,r=xA(e|0,A|0,45)|0,S()|0;do if(n){for(;r=CA(n+4095|0,0,52)|0,s=S()|0|A&-15728641,i=(15-n|0)*3|0,o=CA(7,0,i|0)|0,l=S()|0,r=r|e|o,s=s|l,c=xA(e|0,A|0,i|0)|0,S()|0,c=c&7,n=n+-1|0,!(c>>>0<6);)if(n)A=s,e=r;else{f=4;break}if((f|0)==4){r=xA(r|0,s|0,45)|0,S()|0;break}return p=(c|0)==0&(Fe(r,s)|0)!=0,p=CA((p?2:1)+c|0,0,i|0)|0,f=S()|0|A&~l,p=p|e&~o,JA(f|0),E=B,p|0}while(!1);return r=r&127,r>>>0>120?(f=0,p=0,JA(f|0),E=B,p|0):(It(p,0,r+1|0,0),f=t[p+4>>2]|0,p=t[p>>2]|0,JA(f|0),E=B,p|0)}function Aa(e,A,r,n,s,i){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0;var o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0;Y=E,E=E+160|0,B=Y+80|0,l=Y+64|0,I=Y+112|0,G=Y,Xl(B,e,A,r),f=B,ls(l,t[f>>2]|0,t[f+4>>2]|0,A),f=l,c=t[f>>2]|0,f=t[f+4>>2]|0,o=t[B+8>>2]|0,L=I+4|0,t[L>>2]=t[B>>2],t[L+4>>2]=t[B+4>>2],t[L+8>>2]=t[B+8>>2],t[L+12>>2]=t[B+12>>2],t[L+16>>2]=t[B+16>>2],t[L+20>>2]=t[B+20>>2],t[L+24>>2]=t[B+24>>2],t[L+28>>2]=t[B+28>>2],L=G,t[L>>2]=c,t[L+4>>2]=f,L=G+8|0,t[L>>2]=o,e=G+12|0,A=I,r=e+36|0;do t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0;while((e|0)<(r|0));if(I=G+48|0,t[I>>2]=t[l>>2],t[I+4>>2]=t[l+4>>2],t[I+8>>2]=t[l+8>>2],t[I+12>>2]=t[l+12>>2],(c|0)==0&(f|0)==0)return G=o,E=Y,G|0;r=G+16|0,p=G+24|0,B=G+28|0,o=0,l=0,A=c,e=f;do{if(!((o|0)<(s|0)|(o|0)==(s|0)&l>>>0<n>>>0)){N=4;break}if(f=l,l=YA(l|0,o|0,1,0)|0,o=S()|0,f=i+(f<<3)|0,t[f>>2]=A,t[f+4>>2]=e,as(I),e=I,A=t[e>>2]|0,e=t[e+4>>2]|0,(A|0)==0&(e|0)==0){if(S0(r),A=r,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0){N=10;break}Js(e,A,t[B>>2]|0,I),e=I,A=t[e>>2]|0,e=t[e+4>>2]|0}f=G,t[f>>2]=A,t[f+4>>2]=e}while(!((A|0)==0&(e|0)==0));return(N|0)==4?(e=G+40|0,A=t[e>>2]|0,A|0&&$A(A),N=G+16|0,t[N>>2]=0,t[N+4>>2]=0,t[p>>2]=0,t[G+36>>2]=0,t[B>>2]=-1,t[G+32>>2]=0,t[e>>2]=0,Js(0,0,0,I),t[G>>2]=0,t[G+4>>2]=0,t[L>>2]=0,G=14,E=Y,G|0):((N|0)==10&&(t[G>>2]=0,t[G+4>>2]=0,t[L>>2]=t[p>>2]),G=t[L>>2]|0,E=Y,G|0)}function ea(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0;if(B=E,E=E+48|0,c=B+32|0,l=B+40|0,f=B,!(t[e>>2]|0))return p=n,t[p>>2]=0,t[p+4>>2]=0,p=0,E=B,p|0;It(c,0,0,0),o=c,s=t[o>>2]|0,o=t[o+4>>2]|0;do if(A>>>0>15)p=f,t[p>>2]=0,t[p+4>>2]=0,t[f+8>>2]=4,t[f+12>>2]=-1,p=f+16|0,r=f+29|0,t[p>>2]=0,t[p+4>>2]=0,t[p+8>>2]=0,mA[p+12>>0]=0,mA[r>>0]=mA[l>>0]|0,mA[r+1>>0]=mA[l+1>>0]|0,mA[r+2>>0]=mA[l+2>>0]|0,r=4,p=9;else{if(r=l0(r)|0,r|0){c=f,t[c>>2]=0,t[c+4>>2]=0,t[f+8>>2]=r,t[f+12>>2]=-1,c=f+16|0,p=f+29|0,t[c>>2]=0,t[c+4>>2]=0,t[c+8>>2]=0,mA[c+12>>0]=0,mA[p>>0]=mA[l>>0]|0,mA[p+1>>0]=mA[l+1>>0]|0,mA[p+2>>0]=mA[l+2>>0]|0,p=9;break}if(r=Gt((t[e+8>>2]|0)+1|0,32)|0,!r){p=f,t[p>>2]=0,t[p+4>>2]=0,t[f+8>>2]=13,t[f+12>>2]=-1,p=f+16|0,r=f+29|0,t[p>>2]=0,t[p+4>>2]=0,t[p+8>>2]=0,mA[p+12>>0]=0,mA[r>>0]=mA[l>>0]|0,mA[r+1>>0]=mA[l+1>>0]|0,mA[r+2>>0]=mA[l+2>>0]|0,r=13,p=9;break}fs(e,r),L=f,t[L>>2]=s,t[L+4>>2]=o,o=f+8|0,t[o>>2]=0,t[f+12>>2]=A,t[f+20>>2]=e,t[f+24>>2]=r,mA[f+28>>0]=0,s=f+29|0,mA[s>>0]=mA[l>>0]|0,mA[s+1>>0]=mA[l+1>>0]|0,mA[s+2>>0]=mA[l+2>>0]|0,t[f+16>>2]=3,I=+cn(r),I=I*+Zn(r),i=+qA(+ +C[r>>3]),i=I/+ue(+ +B0(+i,+ +qA(+ +C[r+8>>3])))*6371.007180918475*6371.007180918475,s=f+12|0,r=t[s>>2]|0;A:do if((r|0)>0)do{if(Xs(r+-1|0,c)|0,!(i/+C[c>>3]>10))break A;L=t[s>>2]|0,r=L+-1|0,t[s>>2]=r}while((L|0)>1);while(!1);if(S0(f),s=n,t[s>>2]=0,t[s+4>>2]=0,s=f,r=t[s>>2]|0,s=t[s+4>>2]|0,!((r|0)==0&(s|0)==0))do Cr(r,s,A,c)|0,l=c,e=n,l=YA(t[e>>2]|0,t[e+4>>2]|0,t[l>>2]|0,t[l+4>>2]|0)|0,e=S()|0,L=n,t[L>>2]=l,t[L+4>>2]=e,S0(f),L=f,r=t[L>>2]|0,s=t[L+4>>2]|0;while(!((r|0)==0&(s|0)==0));r=t[o>>2]|0}while(!1);return L=r,E=B,L|0}function o0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0;if(!(br(A,r)|0)||(A=zt(A)|0,n=+C[r>>3],s=+C[r+8>>3],s=A&s<0?s+6.283185307179586:s,I=t[e>>2]|0,(I|0)<=0))return I=0,I|0;if(B=t[e+4>>2]|0,A){A=0,p=s,r=-1,e=0;A:for(;;){for(f=e;o=+C[B+(f<<4)>>3],s=+C[B+(f<<4)+8>>3],e=(r+2|0)%(I|0)|0,i=+C[B+(e<<4)>>3],l=+C[B+(e<<4)+8>>3],o>i?(c=o,o=l):(c=i,i=o,o=s,s=l),n=n==i|n==c?n+2220446049250313e-31:n,!!(n<i|n>c);)if(r=f+1|0,(r|0)>=(I|0)){r=22;break A}else e=f,f=r,r=e;if(l=o<0?o+6.283185307179586:o,o=s<0?s+6.283185307179586:s,p=l==p|o==p?p+-2220446049250313e-31:p,c=l+(o-l)*((n-i)/(c-i)),(c<0?c+6.283185307179586:c)>p&&(A=A^1),e=f+1|0,(e|0)>=(I|0)){r=22;break}else r=f}if((r|0)==22)return A|0}else{A=0,p=s,r=-1,e=0;A:for(;;){for(f=e;o=+C[B+(f<<4)>>3],s=+C[B+(f<<4)+8>>3],e=(r+2|0)%(I|0)|0,i=+C[B+(e<<4)>>3],l=+C[B+(e<<4)+8>>3],o>i?(c=o,o=l):(c=i,i=o,o=s,s=l),n=n==i|n==c?n+2220446049250313e-31:n,!!(n<i|n>c);)if(r=f+1|0,(r|0)>=(I|0)){r=22;break A}else e=f,f=r,r=e;if(p=o==p|s==p?p+-2220446049250313e-31:p,o+(s-o)*((n-i)/(c-i))>p&&(A=A^1),e=f+1|0,(e|0)>=(I|0)){r=22;break}else r=f}if((r|0)==22)return A|0}return 0}function si(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0;if(N=t[e>>2]|0,!N){t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;return}if(G=A+8|0,C[G>>3]=17976931348623157e292,Y=A+24|0,C[Y>>3]=17976931348623157e292,C[A>>3]=-17976931348623157e292,nA=A+16|0,C[nA>>3]=-17976931348623157e292,!((N|0)<=0)){for(I=t[e+4>>2]|0,f=17976931348623157e292,p=-17976931348623157e292,B=0,e=-1,i=17976931348623157e292,o=17976931348623157e292,c=-17976931348623157e292,n=-17976931348623157e292,L=0;r=+C[I+(L<<4)>>3],l=+C[I+(L<<4)+8>>3],e=e+2|0,s=+C[I+(((e|0)==(N|0)?0:e)<<4)+8>>3],r<i&&(C[G>>3]=r,i=r),l<o&&(C[Y>>3]=l,o=l),r>c?C[A>>3]=r:r=c,l>n&&(C[nA>>3]=l,n=l),f=l>0&l<f?l:f,p=l<0&l>p?l:p,B=B|+qA(+(l-s))>3.141592653589793,e=L+1|0,(e|0)!=(N|0);)q=L,c=r,L=e,e=q;B&&(C[nA>>3]=p,C[Y>>3]=f)}}function l0(e){return e=e|0,(e>>>0<4?0:15)|0}function fs(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0;if(N=t[e>>2]|0,N){if(G=A+8|0,C[G>>3]=17976931348623157e292,Y=A+24|0,C[Y>>3]=17976931348623157e292,C[A>>3]=-17976931348623157e292,nA=A+16|0,C[nA>>3]=-17976931348623157e292,(N|0)>0){for(s=t[e+4>>2]|0,I=17976931348623157e292,L=-17976931348623157e292,n=0,r=-1,c=17976931348623157e292,f=17976931348623157e292,B=-17976931348623157e292,o=-17976931348623157e292,q=0;i=+C[s+(q<<4)>>3],p=+C[s+(q<<4)+8>>3],GA=r+2|0,l=+C[s+(((GA|0)==(N|0)?0:GA)<<4)+8>>3],i<c&&(C[G>>3]=i,c=i),p<f&&(C[Y>>3]=p,f=p),i>B?C[A>>3]=i:i=B,p>o&&(C[nA>>3]=p,o=p),I=p>0&p<I?p:I,L=p<0&p>L?p:L,n=n|+qA(+(p-l))>3.141592653589793,r=q+1|0,(r|0)!=(N|0);)GA=q,B=i,q=r,r=GA;n&&(C[nA>>3]=L,C[Y>>3]=I)}}else t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;if(GA=e+8|0,r=t[GA>>2]|0,!((r|0)<=0)){MA=e+12|0,U=0;do if(s=t[MA>>2]|0,n=U,U=U+1|0,Y=A+(U<<5)|0,nA=t[s+(n<<3)>>2]|0,nA){if(q=A+(U<<5)+8|0,C[q>>3]=17976931348623157e292,e=A+(U<<5)+24|0,C[e>>3]=17976931348623157e292,C[Y>>3]=-17976931348623157e292,$=A+(U<<5)+16|0,C[$>>3]=-17976931348623157e292,(nA|0)>0){for(N=t[s+(n<<3)+4>>2]|0,I=17976931348623157e292,L=-17976931348623157e292,s=0,n=-1,G=0,c=17976931348623157e292,f=17976931348623157e292,p=-17976931348623157e292,o=-17976931348623157e292;i=+C[N+(G<<4)>>3],B=+C[N+(G<<4)+8>>3],n=n+2|0,l=+C[N+(((n|0)==(nA|0)?0:n)<<4)+8>>3],i<c&&(C[q>>3]=i,c=i),B<f&&(C[e>>3]=B,f=B),i>p?C[Y>>3]=i:i=p,B>o&&(C[$>>3]=B,o=B),I=B>0&B<I?B:I,L=B<0&B>L?B:L,s=s|+qA(+(B-l))>3.141592653589793,n=G+1|0,(n|0)!=(nA|0);)OA=G,G=n,p=i,n=OA;s&&(C[$>>3]=L,C[e>>3]=I)}}else t[Y>>2]=0,t[Y+4>>2]=0,t[Y+8>>2]=0,t[Y+12>>2]=0,t[Y+16>>2]=0,t[Y+20>>2]=0,t[Y+24>>2]=0,t[Y+28>>2]=0,r=t[GA>>2]|0;while((U|0)<(r|0))}}function hs(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(!(o0(e,A,r)|0))return s=0,s|0;if(s=e+8|0,(t[s>>2]|0)<=0)return s=1,s|0;for(n=e+12|0,e=0;;){if(i=e,e=e+1|0,o0((t[n>>2]|0)+(i<<3)|0,A+(e<<5)|0,r)|0){e=0,n=6;break}if((e|0)>=(t[s>>2]|0)){e=1,n=6;break}}return(n|0)==6?e|0:0}function ii(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(f=E,E=E+16|0,l=f,o=r+8|0,!(o0(e,A,o)|0))return c=0,E=f,c|0;c=e+8|0;A:do if((t[c>>2]|0)>0){for(i=e+12|0,s=0;;){if(p=s,s=s+1|0,o0((t[i>>2]|0)+(p<<3)|0,A+(s<<5)|0,o)|0){s=0;break}if((s|0)>=(t[c>>2]|0))break A}return E=f,s|0}while(!1);if(M0(e,A,r,n)|0)return p=0,E=f,p|0;t[l>>2]=t[r>>2],t[l+4>>2]=o,s=t[c>>2]|0;A:do if((s|0)>0)for(e=e+12|0,o=0,i=s;;){if(s=t[e>>2]|0,(t[s+(o<<3)>>2]|0)>0){if(o0(l,n,t[s+(o<<3)+4>>2]|0)|0){s=0;break A}if(s=o+1|0,M0((t[e>>2]|0)+(o<<3)|0,A+(s<<5)|0,r,n)|0){s=0;break A}i=t[c>>2]|0}else s=o+1|0;if((s|0)<(i|0))o=s;else{s=1;break}}else s=1;while(!1);return p=s,E=f,p|0}function M0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0,GA=0,OA=0,me=0;if(GA=E,E=E+176|0,q=GA+172|0,s=GA+168|0,$=GA,!(Ne(A,n)|0))return e=0,E=GA,e|0;if(Or(A,n,q,s),Pn($|0,r|0,168)|0,(t[r>>2]|0)>0){A=0;do OA=$+8+(A<<4)+8|0,nA=+Kt(+C[OA>>3],t[s>>2]|0),C[OA>>3]=nA,A=A+1|0;while((A|0)<(t[r>>2]|0))}G=+C[n>>3],Y=+C[n+8>>3],nA=+Kt(+C[n+16>>3],t[s>>2]|0),L=+Kt(+C[n+24>>3],t[s>>2]|0);A:do if((t[e>>2]|0)>0){if(n=e+4|0,s=t[$>>2]|0,(s|0)<=0){for(A=0;;)if(A=A+1|0,(A|0)>=(t[e>>2]|0)){A=0;break A}}for(r=0;;){if(A=t[n>>2]|0,I=+C[A+(r<<4)>>3],N=+Kt(+C[A+(r<<4)+8>>3],t[q>>2]|0),A=t[n>>2]|0,r=r+1|0,OA=(r|0)%(t[e>>2]|0)|0,i=+C[A+(OA<<4)>>3],o=+Kt(+C[A+(OA<<4)+8>>3],t[q>>2]|0),!(I>=G)|!(i>=G)&&!(I<=Y)|!(i<=Y)&&!(N<=L)|!(o<=L)&&!(N>=nA)|!(o>=nA)){B=i-I,f=o-N,A=0;do if(me=A,A=A+1|0,OA=(A|0)==(s|0)?0:A,i=+C[$+8+(me<<4)+8>>3],o=+C[$+8+(OA<<4)+8>>3]-i,l=+C[$+8+(me<<4)>>3],c=+C[$+8+(OA<<4)>>3]-l,p=B*o-f*c,p!=0&&(U=N-i,MA=I-l,c=(U*c-o*MA)/p,!(c<0|c>1))&&(p=(B*U-f*MA)/p,p>=0&p<=1)){A=1;break A}while((A|0)<(s|0))}if((r|0)>=(t[e>>2]|0)){A=0;break}}}else A=0;while(!1);return me=A,E=GA,me|0}function oi(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;if(M0(e,A,r,n)|0)return i=1,i|0;if(i=e+8|0,(t[i>>2]|0)<=0)return i=0,i|0;for(s=e+12|0,e=0;;){if(o=e,e=e+1|0,M0((t[s>>2]|0)+(o<<3)|0,A+(e<<5)|0,r,n)|0){e=1,s=6;break}if((e|0)>=(t[i>>2]|0)){e=0,s=6;break}}return(s|0)==6?e|0:0}function ta(){return 8}function ra(){return 16}function na(){return 168}function sa(){return 8}function ia(){return 16}function oa(){return 12}function la(){return 8}function aa(e){return e=e|0,+(+((t[e>>2]|0)>>>0)+4294967296*+(t[e+4>>2]|0))}function ua(e){e=e|0;var A=0,r=0;return r=+C[e>>3],A=+C[e+8>>3],+ +be(+(r*r+A*A))}function li(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0;f=+C[e>>3],c=+C[A>>3]-f,l=+C[e+8>>3],o=+C[A+8>>3]-l,B=+C[r>>3],i=+C[n>>3]-B,I=+C[r+8>>3],p=+C[n+8>>3]-I,i=(i*(l-I)-(f-B)*p)/(c*p-o*i),C[s>>3]=f+c*i,C[s+8>>3]=l+o*i}function ai(e,A){return e=e|0,A=A|0,+qA(+(+C[e>>3]-+C[A>>3]))<11920928955078125e-23?(A=+qA(+(+C[e+8>>3]-+C[A+8>>3]))<11920928955078125e-23,A|0):(A=0,A|0)}function ut(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;return s=+C[e>>3]-+C[A>>3],n=+C[e+8>>3]-+C[A+8>>3],r=+C[e+16>>3]-+C[A+16>>3],+(s*s+n*n+r*r)}function ca(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;r=+C[e>>3],n=+ue(+r),r=+ie(+r),C[A+16>>3]=r,r=+C[e+8>>3],s=n*+ue(+r),C[A>>3]=s,r=n*+ie(+r),C[A+8>>3]=r}function fa(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(i=E,E=E+16|0,s=i,n=Fe(e,A)|0,(r+-1|0)>>>0>5||(n=(n|0)!=0,(r|0)==1&n))return s=-1,E=i,s|0;do if(a0(e,A,s)|0)n=-1;else if(n){n=((t[26352+(r<<2)>>2]|0)+5-(t[s>>2]|0)|0)%5|0;break}else{n=((t[26384+(r<<2)>>2]|0)+6-(t[s>>2]|0)|0)%6|0;break}while(!1);return s=n,E=i,s|0}function a0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0;if(p=E,E=E+32|0,l=p+16|0,c=p,n=Tn(e,A,l)|0,n|0)return r=n,E=p,r|0;i=re(e,A)|0,f=Ht(e,A)|0,Pr(i,c),n=sr(i,t[l>>2]|0)|0;do if(je(i)|0){do switch(i|0){case 4:{s=0;break}case 14:{s=1;break}case 24:{s=2;break}case 38:{s=3;break}case 49:{s=4;break}case 58:{s=5;break}case 63:{s=6;break}case 72:{s=7;break}case 83:{s=8;break}case 97:{s=9;break}case 107:{s=10;break}case 117:{s=11;break}default:PA(27795,27797,75,27806)}while(!1);if(o=t[26416+(s*24|0)+8>>2]|0,A=t[26416+(s*24|0)+16>>2]|0,e=t[l>>2]|0,(e|0)!=(t[c>>2]|0)&&(c=jt(i)|0,e=t[l>>2]|0,c|(e|0)==(A|0)&&(n=(n+1|0)%6|0)),(f|0)==3&(e|0)==(A|0)){n=(n+5|0)%6|0;break}(f|0)==5&(e|0)==(o|0)&&(n=(n+1|0)%6|0)}while(!1);return t[r>>2]=n,r=0,E=p,r|0}function lr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0;if($=E,E=E+32|0,q=$+24|0,Y=$+20|0,N=$+8|0,L=$+16|0,I=$,c=(Fe(e,A)|0)==0,c=c?6:5,p=xA(e|0,A|0,52)|0,S()|0,p=p&15,c>>>0<=r>>>0)return n=2,E=$,n|0;B=(p|0)==0,!B&&(G=CA(7,0,(p^15)*3|0)|0,(G&e|0)==0&((S()|0)&A|0)==0)?s=r:i=4;A:do if((i|0)==4){if(s=(Fe(e,A)|0)!=0,((s?4:5)|0)<(r|0)||a0(e,A,q)|0||(i=(t[q>>2]|0)+r|0,s?s=26704+(((i|0)%5|0)<<2)|0:s=26736+(((i|0)%6|0)<<2)|0,G=t[s>>2]|0,(G|0)==7))return n=1,E=$,n|0;t[Y>>2]=0,s=K(e,A,G,Y,N)|0;do if(!s){if(l=N,f=t[l>>2]|0,l=t[l+4>>2]|0,o=l>>>0<A>>>0|(l|0)==(A|0)&f>>>0<e>>>0,i=o?f:e,o=o?l:A,!B&&(B=CA(7,0,(p^15)*3|0)|0,(f&B|0)==0&(l&(S()|0)|0)==0))s=r;else{if(l=(r+-1+c|0)%(c|0)|0,s=Fe(e,A)|0,(l|0)<0&&PA(27795,27797,248,27822),c=(s|0)!=0,((c?4:5)|0)<(l|0)&&PA(27795,27797,248,27822),a0(e,A,q)|0&&PA(27795,27797,248,27822),s=(t[q>>2]|0)+l|0,c?s=26704+(((s|0)%5|0)<<2)|0:s=26736+(((s|0)%6|0)<<2)|0,l=t[s>>2]|0,(l|0)==7&&PA(27795,27797,248,27822),t[L>>2]=0,s=K(e,A,l,L,I)|0,s|0)break;f=I,c=t[f>>2]|0,f=t[f+4>>2]|0;do if(f>>>0<o>>>0|(f|0)==(o|0)&c>>>0<i>>>0){if(Fe(c,f)|0?i=Ae(c,f,e,A)|0:i=t[26800+((((t[L>>2]|0)+(t[26768+(l<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,s=Fe(c,f)|0,(i+-1|0)>>>0>5){s=-1,i=c,o=f;break}if(s=(s|0)!=0,(i|0)==1&s){s=-1,i=c,o=f;break}do if(a0(c,f,q)|0)s=-1;else if(s){s=((t[26352+(i<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{s=((t[26384+(i<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);i=c,o=f}else s=r;while(!1);l=N,f=t[l>>2]|0,l=t[l+4>>2]|0}if((i|0)==(f|0)&(o|0)==(l|0)){if(c=(Fe(f,l)|0)!=0,c?e=Ae(f,l,e,A)|0:e=t[26800+((((t[Y>>2]|0)+(t[26768+(G<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,s=Fe(f,l)|0,(e+-1|0)>>>0<=5&&(nA=(s|0)!=0,!((e|0)==1&nA)))do if(a0(f,l,q)|0)s=-1;else if(nA){s=((t[26352+(e<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{s=((t[26384+(e<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);else s=-1;s=s+1|0,s=(s|0)==6|c&(s|0)==5?0:s}A=o,e=i;break A}while(!1);return n=s,E=$,n|0}while(!1);return nA=CA(s|0,0,56)|0,q=S()|0|A&-2130706433|536870912,t[n>>2]=nA|e,t[n+4>>2]=q,n=0,E=$,n|0}function ha(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return i=(Fe(e,A)|0)==0,n=lr(e,A,0,r)|0,s=(n|0)==0,i?!s||(n=lr(e,A,1,r+8|0)|0,n|0)||(n=lr(e,A,2,r+16|0)|0,n|0)||(n=lr(e,A,3,r+24|0)|0,n|0)||(n=lr(e,A,4,r+32|0)|0,n)?(i=n,i|0):lr(e,A,5,r+40|0)|0:!s||(n=lr(e,A,1,r+8|0)|0,n|0)||(n=lr(e,A,2,r+16|0)|0,n|0)||(n=lr(e,A,3,r+24|0)|0,n|0)||(n=lr(e,A,4,r+32|0)|0,n|0)?(i=n,i|0):(i=r+40|0,t[i>>2]=0,t[i+4>>2]=0,i=0,i|0)}function da(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,c=0;return c=E,E=E+192|0,s=c,i=c+168|0,o=xA(e|0,A|0,56)|0,S()|0,o=o&7,l=A&-2130706433|134217728,n=Tn(e,l,i)|0,n|0?(l=n,E=c,l|0):(A=xA(e|0,A|0,52)|0,S()|0,A=A&15,Fe(e,l)|0?w(i,A,o,1,s):AA(i,A,o,1,s),l=s+8|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],l=0,E=c,l|0)}function ui(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=E,E=E+16|0,r=s,!(!0&(A&2013265920|0)==536870912)||(n=A&-2130706433|134217728,!(ze(e,n)|0))?(n=0,E=s,n|0):(i=xA(e|0,A|0,56)|0,S()|0,i=(lr(e,n,i&7,r)|0)==0,n=r,n=i&((t[n>>2]|0)==(e|0)?(t[n+4>>2]|0)==(A|0):0)&1,E=s,n|0)}function ci(e,A,r){e=e|0,A=A|0,r=r|0;var n=0;(A|0)>0?(n=Gt(A,4)|0,t[e>>2]=n,n||PA(27835,27858,40,27872)):t[e>>2]=0,t[e+4>>2]=A,t[e+8>>2]=0,t[e+12>>2]=r}function fi(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0;s=e+4|0,i=e+12|0,o=e+8|0;A:for(;;){for(r=t[s>>2]|0,A=0;;){if((A|0)>=(r|0))break A;if(n=t[e>>2]|0,l=t[n+(A<<2)>>2]|0,!l)A=A+1|0;else break}A=n+(~~(+qA(+(+mt(10,+ +(15-(t[i>>2]|0)|0))*(+C[l>>3]+ +C[l+8>>3])))%+(r|0))>>>0<<2)|0,r=t[A>>2]|0;e:do if(r|0){if(n=l+32|0,(r|0)==(l|0))t[A>>2]=t[n>>2];else{if(r=r+32|0,A=t[r>>2]|0,!A)break;for(;(A|0)!=(l|0);)if(r=A+32|0,A=t[r>>2]|0,!A)break e;t[r>>2]=t[n>>2]}$A(l),t[o>>2]=(t[o>>2]|0)+-1}while(!1)}$A(t[e>>2]|0)}function hi(e){e=e|0;var A=0,r=0,n=0;for(n=t[e+4>>2]|0,r=0;;){if((r|0)>=(n|0)){A=0,r=4;break}if(A=t[(t[e>>2]|0)+(r<<2)>>2]|0,!A)r=r+1|0;else{r=4;break}}return(r|0)==4?A|0:0}function di(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;if(r=~~(+qA(+(+mt(10,+ +(15-(t[e+12>>2]|0)|0))*(+C[A>>3]+ +C[A+8>>3])))%+(t[e+4>>2]|0))>>>0,r=(t[e>>2]|0)+(r<<2)|0,n=t[r>>2]|0,!n)return i=1,i|0;i=A+32|0;do if((n|0)!=(A|0)){if(r=t[n+32>>2]|0,!r)return i=1,i|0;for(s=r;;){if((s|0)==(A|0)){s=8;break}if(r=t[s+32>>2]|0,r)n=s,s=r;else{r=1,s=10;break}}if((s|0)==8){t[n+32>>2]=t[i>>2];break}else if((s|0)==10)return r|0}else t[r>>2]=t[i>>2];while(!1);return $A(A),i=e+8|0,t[i>>2]=(t[i>>2]|0)+-1,i=0,i|0}function ma(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;i=Er(40)|0,i||PA(27888,27858,98,27901),t[i>>2]=t[A>>2],t[i+4>>2]=t[A+4>>2],t[i+8>>2]=t[A+8>>2],t[i+12>>2]=t[A+12>>2],s=i+16|0,t[s>>2]=t[r>>2],t[s+4>>2]=t[r+4>>2],t[s+8>>2]=t[r+8>>2],t[s+12>>2]=t[r+12>>2],t[i+32>>2]=0,s=~~(+qA(+(+mt(10,+ +(15-(t[e+12>>2]|0)|0))*(+C[A>>3]+ +C[A+8>>3])))%+(t[e+4>>2]|0))>>>0,s=(t[e>>2]|0)+(s<<2)|0,n=t[s>>2]|0;do if(!n)t[s>>2]=i;else{for(;!(Ln(n,A)|0&&Ln(n+16|0,r)|0);)if(s=t[n+32>>2]|0,n=(s|0)==0?n:s,!(t[n+32>>2]|0)){o=10;break}if((o|0)==10){t[n+32>>2]=i;break}return $A(i),o=n,o|0}while(!1);return o=e+8|0,t[o>>2]=(t[o>>2]|0)+1,o=i,o|0}function pa(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;if(s=~~(+qA(+(+mt(10,+ +(15-(t[e+12>>2]|0)|0))*(+C[A>>3]+ +C[A+8>>3])))%+(t[e+4>>2]|0))>>>0,s=t[(t[e>>2]|0)+(s<<2)>>2]|0,!s)return r=0,r|0;if(!r){for(e=s;;){if(Ln(e,A)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}if((n|0)==10)return e|0}for(e=s;;){if(Ln(e,A)|0&&Ln(e+16|0,r)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}return(n|0)==10?e|0:0}function ga(e,A){e=e|0,A=A|0;var r=0;if(r=~~(+qA(+(+mt(10,+ +(15-(t[e+12>>2]|0)|0))*(+C[A>>3]+ +C[A+8>>3])))%+(t[e+4>>2]|0))>>>0,e=t[(t[e>>2]|0)+(r<<2)>>2]|0,!e)return r=0,r|0;for(;;){if(Ln(e,A)|0){A=5;break}if(e=t[e+32>>2]|0,!e){e=0,A=5;break}}return(A|0)==5?e|0:0}function ya(){return 27920}function Jr(e){return e=+e,~~+yi(+e)|0}function Er(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,nA=0,q=0,$=0,U=0,MA=0;MA=E,E=E+16|0,I=MA;do if(e>>>0<245){if(f=e>>>0<11?16:e+11&-8,e=f>>>3,B=t[6981]|0,r=B>>>e,r&3|0)return A=(r&1^1)+e|0,e=27964+(A<<1<<2)|0,r=e+8|0,n=t[r>>2]|0,s=n+8|0,i=t[s>>2]|0,(i|0)==(e|0)?t[6981]=B&~(1<<A):(t[i+12>>2]=e,t[r>>2]=i),U=A<<3,t[n+4>>2]=U|3,U=n+U+4|0,t[U>>2]=t[U>>2]|1,U=s,E=MA,U|0;if(p=t[6983]|0,f>>>0>p>>>0){if(r|0)return A=2<<e,A=r<<e&(A|0-A),A=(A&0-A)+-1|0,l=A>>>12&16,A=A>>>l,r=A>>>5&8,A=A>>>r,i=A>>>2&4,A=A>>>i,e=A>>>1&2,A=A>>>e,n=A>>>1&1,n=(r|l|i|e|n)+(A>>>n)|0,A=27964+(n<<1<<2)|0,e=A+8|0,i=t[e>>2]|0,l=i+8|0,r=t[l>>2]|0,(r|0)==(A|0)?(e=B&~(1<<n),t[6981]=e):(t[r+12>>2]=A,t[e>>2]=r,e=B),U=n<<3,o=U-f|0,t[i+4>>2]=f|3,s=i+f|0,t[s+4>>2]=o|1,t[i+U>>2]=o,p|0&&(n=t[6986]|0,A=p>>>3,r=27964+(A<<1<<2)|0,A=1<<A,e&A?(e=r+8|0,A=t[e>>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=o,t[6986]=s,U=l,E=MA,U|0;if(i=t[6982]|0,i){for(r=(i&0-i)+-1|0,s=r>>>12&16,r=r>>>s,n=r>>>5&8,r=r>>>n,o=r>>>2&4,r=r>>>o,l=r>>>1&2,r=r>>>l,c=r>>>1&1,c=t[28228+((n|s|o|l|c)+(r>>>c)<<2)>>2]|0,r=c,l=c,c=(t[c+4>>2]&-8)-f|0;e=t[r+16>>2]|0,!(!e&&(e=t[r+20>>2]|0,!e));)o=(t[e+4>>2]&-8)-f|0,s=o>>>0<c>>>0,r=e,l=s?e:l,c=s?o:c;if(o=l+f|0,o>>>0>l>>>0){s=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){r=0;break}for(;;)if(n=A+20|0,r=t[n>>2]|0,r)A=r,e=n;else if(n=A+16|0,r=t[n>>2]|0,r)A=r,e=n;else break;t[e>>2]=0,r=A}else r=t[l+8>>2]|0,t[r+12>>2]=A,t[A+8>>2]=r,r=A;while(!1);do if(s|0){if(A=t[l+28>>2]|0,e=28228+(A<<2)|0,(l|0)==(t[e>>2]|0)){if(t[e>>2]=r,!r){t[6982]=i&~(1<<A);break}}else if(U=s+16|0,t[((t[U>>2]|0)==(l|0)?U:s+20|0)>>2]=r,!r)break;t[r+24>>2]=s,A=t[l+16>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),A=t[l+20>>2]|0,A|0&&(t[r+20>>2]=A,t[A+24>>2]=r)}while(!1);return c>>>0<16?(U=c+f|0,t[l+4>>2]=U|3,U=l+U+4|0,t[U>>2]=t[U>>2]|1):(t[l+4>>2]=f|3,t[o+4>>2]=c|1,t[o+c>>2]=c,p|0&&(n=t[6986]|0,A=p>>>3,r=27964+(A<<1<<2)|0,A=1<<A,A&B?(e=r+8|0,A=t[e>>2]|0):(t[6981]=A|B,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=c,t[6986]=o),U=l+8|0,E=MA,U|0}else B=f}else B=f}else B=f}else if(e>>>0<=4294967231)if(e=e+11|0,f=e&-8,n=t[6982]|0,n){s=0-f|0,e=e>>>8,e?f>>>0>16777215?c=31:(B=(e+1048320|0)>>>16&8,G=e<<B,l=(G+520192|0)>>>16&4,G=G<<l,c=(G+245760|0)>>>16&2,c=14-(l|B|c)+(G<<c>>>15)|0,c=f>>>(c+7|0)&1|c<<1):c=0,r=t[28228+(c<<2)>>2]|0;A:do if(!r)r=0,e=0,G=61;else for(e=0,l=f<<((c|0)==31?0:25-(c>>>1)|0),i=0;;){if(o=(t[r+4>>2]&-8)-f|0,o>>>0<s>>>0)if(o)e=r,s=o;else{e=r,s=0,G=65;break A}if(G=t[r+20>>2]|0,r=t[r+16+(l>>>31<<2)>>2]|0,i=(G|0)==0|(G|0)==(r|0)?i:G,r)l=l<<1;else{r=i,G=61;break}}while(!1);if((G|0)==61){if((r|0)==0&(e|0)==0){if(e=2<<c,e=(e|0-e)&n,!e){B=f;break}B=(e&0-e)+-1|0,o=B>>>12&16,B=B>>>o,i=B>>>5&8,B=B>>>i,l=B>>>2&4,B=B>>>l,c=B>>>1&2,B=B>>>c,r=B>>>1&1,e=0,r=t[28228+((i|o|l|c|r)+(B>>>r)<<2)>>2]|0}r?G=65:(l=e,o=s)}if((G|0)==65)for(i=r;;)if(B=(t[i+4>>2]&-8)-f|0,r=B>>>0<s>>>0,s=r?B:s,e=r?i:e,r=t[i+16>>2]|0,r||(r=t[i+20>>2]|0),r)i=r;else{l=e,o=s;break}if((l|0)!=0&&o>>>0<((t[6983]|0)-f|0)>>>0&&(p=l+f|0,p>>>0>l>>>0)){i=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){A=0;break}for(;;)if(s=A+20|0,r=t[s>>2]|0,r)A=r,e=s;else if(s=A+16|0,r=t[s>>2]|0,r)A=r,e=s;else break;t[e>>2]=0}else U=t[l+8>>2]|0,t[U+12>>2]=A,t[A+8>>2]=U;while(!1);do if(i){if(e=t[l+28>>2]|0,r=28228+(e<<2)|0,(l|0)==(t[r>>2]|0)){if(t[r>>2]=A,!A){n=n&~(1<<e),t[6982]=n;break}}else if(U=i+16|0,t[((t[U>>2]|0)==(l|0)?U:i+20|0)>>2]=A,!A)break;t[A+24>>2]=i,e=t[l+16>>2]|0,e|0&&(t[A+16>>2]=e,t[e+24>>2]=A),e=t[l+20>>2]|0,e&&(t[A+20>>2]=e,t[e+24>>2]=A)}while(!1);A:do if(o>>>0<16)U=o+f|0,t[l+4>>2]=U|3,U=l+U+4|0,t[U>>2]=t[U>>2]|1;else{if(t[l+4>>2]=f|3,t[p+4>>2]=o|1,t[p+o>>2]=o,A=o>>>3,o>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<<A,e&A?(e=r+8|0,A=t[e>>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=p,t[A+12>>2]=p,t[p+8>>2]=A,t[p+12>>2]=r;break}if(A=o>>>8,A?o>>>0>16777215?r=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<<q,r=(U+245760|0)>>>16&2,r=14-(q|$|r)+(U<<r>>>15)|0,r=o>>>(r+7|0)&1|r<<1):r=0,A=28228+(r<<2)|0,t[p+28>>2]=r,e=p+16|0,t[e+4>>2]=0,t[e>>2]=0,e=1<<r,!(n&e)){t[6982]=n|e,t[A>>2]=p,t[p+24>>2]=A,t[p+12>>2]=p,t[p+8>>2]=p;break}A=t[A>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(o|0)){for(n=o<<((r|0)==31?0:25-(r>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(o|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=p,t[p+24>>2]=A,t[p+12>>2]=p,t[p+8>>2]=p;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=p,t[$>>2]=p,t[p+8>>2]=U,t[p+12>>2]=A,t[p+24>>2]=0}while(!1);return U=l+8|0,E=MA,U|0}else B=f}else B=f;else B=-1;while(!1);if(r=t[6983]|0,r>>>0>=B>>>0)return A=r-B|0,e=t[6986]|0,A>>>0>15?(U=e+B|0,t[6986]=U,t[6983]=A,t[U+4>>2]=A|1,t[e+r>>2]=A,t[e+4>>2]=B|3):(t[6983]=0,t[6986]=0,t[e+4>>2]=r|3,U=e+r+4|0,t[U>>2]=t[U>>2]|1),U=e+8|0,E=MA,U|0;if(o=t[6984]|0,o>>>0>B>>>0)return q=o-B|0,t[6984]=q,U=t[6987]|0,$=U+B|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=B|3,U=U+8|0,E=MA,U|0;if(t[7099]|0?e=t[7101]|0:(t[7101]=4096,t[7100]=4096,t[7102]=-1,t[7103]=-1,t[7104]=0,t[7092]=0,t[7099]=I&-16^1431655768,e=4096),l=B+48|0,c=B+47|0,i=e+c|0,s=0-e|0,f=i&s,f>>>0<=B>>>0||(e=t[7091]|0,e|0&&(p=t[7089]|0,I=p+f|0,I>>>0<=p>>>0|I>>>0>e>>>0)))return U=0,E=MA,U|0;A:do if(t[7092]&4)A=0,G=143;else{r=t[6987]|0;e:do if(r){for(n=28372;I=t[n>>2]|0,!(I>>>0<=r>>>0&&(I+(t[n+4>>2]|0)|0)>>>0>r>>>0);)if(e=t[n+8>>2]|0,e)n=e;else{G=128;break e}if(A=i-o&s,A>>>0<2147483647)if(e=en(A|0)|0,(e|0)==((t[n>>2]|0)+(t[n+4>>2]|0)|0)){if((e|0)!=-1){o=A,i=e,G=145;break A}}else n=e,G=136;else A=0}else G=128;while(!1);do if((G|0)==128)if(r=en(0)|0,(r|0)!=-1&&(A=r,L=t[7100]|0,N=L+-1|0,A=((N&A|0)==0?0:(N+A&0-L)-A|0)+f|0,L=t[7089]|0,N=A+L|0,A>>>0>B>>>0&A>>>0<2147483647)){if(I=t[7091]|0,I|0&&N>>>0<=L>>>0|N>>>0>I>>>0){A=0;break}if(e=en(A|0)|0,(e|0)==(r|0)){o=A,i=r,G=145;break A}else n=e,G=136}else A=0;while(!1);do if((G|0)==136){if(r=0-A|0,!(l>>>0>A>>>0&(A>>>0<2147483647&(n|0)!=-1)))if((n|0)==-1){A=0;break}else{o=A,i=n,G=145;break A}if(e=t[7101]|0,e=c-A+e&0-e,e>>>0>=2147483647){o=A,i=n,G=145;break A}if((en(e|0)|0)==-1){en(r|0)|0,A=0;break}else{o=e+A|0,i=n,G=145;break A}}while(!1);t[7092]=t[7092]|4,G=143}while(!1);if((G|0)==143&&f>>>0<2147483647&&(q=en(f|0)|0,N=en(0)|0,Y=N-q|0,nA=Y>>>0>(B+40|0)>>>0,!((q|0)==-1|nA^1|q>>>0<N>>>0&((q|0)!=-1&(N|0)!=-1)^1))&&(o=nA?Y:A,i=q,G=145),(G|0)==145){A=(t[7089]|0)+o|0,t[7089]=A,A>>>0>(t[7090]|0)>>>0&&(t[7090]=A),c=t[6987]|0;A:do if(c){for(A=28372;;){if(e=t[A>>2]|0,r=t[A+4>>2]|0,(i|0)==(e+r|0)){G=154;break}if(n=t[A+8>>2]|0,n)A=n;else break}if((G|0)==154&&($=A+4|0,(t[A+12>>2]&8|0)==0)&&i>>>0>c>>>0&e>>>0<=c>>>0){t[$>>2]=r+o,U=(t[6984]|0)+o|0,q=c+8|0,q=(q&7|0)==0?0:0-q&7,$=c+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[c+U+4>>2]=40,t[6988]=t[7103];break}for(i>>>0<(t[6985]|0)>>>0&&(t[6985]=i),r=i+o|0,A=28372;;){if((t[A>>2]|0)==(r|0)){G=162;break}if(e=t[A+8>>2]|0,e)A=e;else break}if((G|0)==162&&(t[A+12>>2]&8|0)==0){t[A>>2]=i,p=A+4|0,t[p>>2]=(t[p>>2]|0)+o,p=i+8|0,p=i+((p&7|0)==0?0:0-p&7)|0,A=r+8|0,A=r+((A&7|0)==0?0:0-A&7)|0,f=p+B|0,l=A-p-B|0,t[p+4>>2]=B|3;e:do if((c|0)==(A|0))U=(t[6984]|0)+l|0,t[6984]=U,t[6987]=f,t[f+4>>2]=U|1;else{if((t[6986]|0)==(A|0)){U=(t[6983]|0)+l|0,t[6983]=U,t[6986]=f,t[f+4>>2]=U|1,t[f+U>>2]=U;break}if(e=t[A+4>>2]|0,(e&3|0)==1){o=e&-8,n=e>>>3;t:do if(e>>>0<256)if(e=t[A+8>>2]|0,r=t[A+12>>2]|0,(r|0)==(e|0)){t[6981]=t[6981]&~(1<<n);break}else{t[e+12>>2]=r,t[r+8>>2]=e;break}else{i=t[A+24>>2]|0,e=t[A+12>>2]|0;do if((e|0)==(A|0)){if(r=A+16|0,n=r+4|0,e=t[n>>2]|0,e)r=n;else if(e=t[r>>2]|0,!e){e=0;break}for(;;)if(s=e+20|0,n=t[s>>2]|0,n)e=n,r=s;else if(s=e+16|0,n=t[s>>2]|0,n)e=n,r=s;else break;t[r>>2]=0}else U=t[A+8>>2]|0,t[U+12>>2]=e,t[e+8>>2]=U;while(!1);if(!i)break;r=t[A+28>>2]|0,n=28228+(r<<2)|0;do if((t[n>>2]|0)!=(A|0)){if(U=i+16|0,t[((t[U>>2]|0)==(A|0)?U:i+20|0)>>2]=e,!e)break t}else{if(t[n>>2]=e,e|0)break;t[6982]=t[6982]&~(1<<r);break t}while(!1);if(t[e+24>>2]=i,r=A+16|0,n=t[r>>2]|0,n|0&&(t[e+16>>2]=n,t[n+24>>2]=e),r=t[r+4>>2]|0,!r)break;t[e+20>>2]=r,t[r+24>>2]=e}while(!1);A=A+o|0,s=o+l|0}else s=l;if(A=A+4|0,t[A>>2]=t[A>>2]&-2,t[f+4>>2]=s|1,t[f+s>>2]=s,A=s>>>3,s>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<<A,e&A?(e=r+8|0,A=t[e>>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=f,t[A+12>>2]=f,t[f+8>>2]=A,t[f+12>>2]=r;break}A=s>>>8;do if(!A)n=0;else{if(s>>>0>16777215){n=31;break}$=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<<q,n=(U+245760|0)>>>16&2,n=14-(q|$|n)+(U<<n>>>15)|0,n=s>>>(n+7|0)&1|n<<1}while(!1);if(A=28228+(n<<2)|0,t[f+28>>2]=n,e=f+16|0,t[e+4>>2]=0,t[e>>2]=0,e=t[6982]|0,r=1<<n,!(e&r)){t[6982]=e|r,t[A>>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break}A=t[A>>2]|0;t:do if((t[A+4>>2]&-8|0)!=(s|0)){for(n=s<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(s|0)){A=e;break t}else n=n<<1,A=e;t[r>>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break e}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=f,t[$>>2]=f,t[f+8>>2]=U,t[f+12>>2]=A,t[f+24>>2]=0}while(!1);return U=p+8|0,E=MA,U|0}for(A=28372;e=t[A>>2]|0,!(e>>>0<=c>>>0&&(U=e+(t[A+4>>2]|0)|0,U>>>0>c>>>0));)A=t[A+8>>2]|0;s=U+-47|0,e=s+8|0,e=s+((e&7|0)==0?0:0-e&7)|0,s=c+16|0,e=e>>>0<s>>>0?c:e,A=e+8|0,r=o+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=r-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+r+4>>2]=40,t[6988]=t[7103],r=e+4|0,t[r>>2]=27,t[A>>2]=t[7093],t[A+4>>2]=t[7094],t[A+8>>2]=t[7095],t[A+12>>2]=t[7096],t[7093]=i,t[7094]=o,t[7096]=0,t[7095]=A,A=e+24|0;do $=A,A=A+4|0,t[A>>2]=7;while(($+8|0)>>>0<U>>>0);if((e|0)!=(c|0)){if(i=e-c|0,t[r>>2]=t[r>>2]&-2,t[c+4>>2]=i|1,t[e>>2]=i,A=i>>>3,i>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<<A,e&A?(e=r+8|0,A=t[e>>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=c,t[A+12>>2]=c,t[c+8>>2]=A,t[c+12>>2]=r;break}if(A=i>>>8,A?i>>>0>16777215?n=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<<q,n=(U+245760|0)>>>16&2,n=14-(q|$|n)+(U<<n>>>15)|0,n=i>>>(n+7|0)&1|n<<1):n=0,r=28228+(n<<2)|0,t[c+28>>2]=n,t[c+20>>2]=0,t[s>>2]=0,A=t[6982]|0,e=1<<n,!(A&e)){t[6982]=A|e,t[r>>2]=c,t[c+24>>2]=r,t[c+12>>2]=c,t[c+8>>2]=c;break}A=t[r>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(i|0)){for(n=i<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(i|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=c,t[c+24>>2]=A,t[c+12>>2]=c,t[c+8>>2]=c;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=c,t[$>>2]=c,t[c+8>>2]=U,t[c+12>>2]=A,t[c+24>>2]=0}}else U=t[6985]|0,(U|0)==0|i>>>0<U>>>0&&(t[6985]=i),t[7093]=i,t[7094]=o,t[7096]=0,t[6990]=t[7099],t[6989]=-1,t[6994]=27964,t[6993]=27964,t[6996]=27972,t[6995]=27972,t[6998]=27980,t[6997]=27980,t[7e3]=27988,t[6999]=27988,t[7002]=27996,t[7001]=27996,t[7004]=28004,t[7003]=28004,t[7006]=28012,t[7005]=28012,t[7008]=28020,t[7007]=28020,t[7010]=28028,t[7009]=28028,t[7012]=28036,t[7011]=28036,t[7014]=28044,t[7013]=28044,t[7016]=28052,t[7015]=28052,t[7018]=28060,t[7017]=28060,t[7020]=28068,t[7019]=28068,t[7022]=28076,t[7021]=28076,t[7024]=28084,t[7023]=28084,t[7026]=28092,t[7025]=28092,t[7028]=28100,t[7027]=28100,t[7030]=28108,t[7029]=28108,t[7032]=28116,t[7031]=28116,t[7034]=28124,t[7033]=28124,t[7036]=28132,t[7035]=28132,t[7038]=28140,t[7037]=28140,t[7040]=28148,t[7039]=28148,t[7042]=28156,t[7041]=28156,t[7044]=28164,t[7043]=28164,t[7046]=28172,t[7045]=28172,t[7048]=28180,t[7047]=28180,t[7050]=28188,t[7049]=28188,t[7052]=28196,t[7051]=28196,t[7054]=28204,t[7053]=28204,t[7056]=28212,t[7055]=28212,U=o+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+U+4>>2]=40,t[6988]=t[7103];while(!1);if(A=t[6984]|0,A>>>0>B>>>0)return q=A-B|0,t[6984]=q,U=t[6987]|0,$=U+B|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=B|3,U=U+8|0,E=MA,U|0}return U=ya()|0,t[U>>2]=12,U=0,E=MA,U|0}function $A(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,c=0;if(e){r=e+-8|0,s=t[6985]|0,e=t[e+-4>>2]|0,A=e&-8,c=r+A|0;do if(e&1)l=r,o=r;else{if(n=t[r>>2]|0,!(e&3)||(o=r+(0-n)|0,i=n+A|0,o>>>0<s>>>0))return;if((t[6986]|0)==(o|0)){if(e=c+4|0,A=t[e>>2]|0,(A&3|0)!=3){l=o,A=i;break}t[6983]=i,t[e>>2]=A&-2,t[o+4>>2]=i|1,t[o+i>>2]=i;return}if(r=n>>>3,n>>>0<256)if(e=t[o+8>>2]|0,A=t[o+12>>2]|0,(A|0)==(e|0)){t[6981]=t[6981]&~(1<<r),l=o,A=i;break}else{t[e+12>>2]=A,t[A+8>>2]=e,l=o,A=i;break}s=t[o+24>>2]|0,e=t[o+12>>2]|0;do if((e|0)==(o|0)){if(A=o+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){e=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0}else l=t[o+8>>2]|0,t[l+12>>2]=e,t[e+8>>2]=l;while(!1);if(s){if(A=t[o+28>>2]|0,r=28228+(A<<2)|0,(t[r>>2]|0)==(o|0)){if(t[r>>2]=e,!e){t[6982]=t[6982]&~(1<<A),l=o,A=i;break}}else if(l=s+16|0,t[((t[l>>2]|0)==(o|0)?l:s+20|0)>>2]=e,!e){l=o,A=i;break}t[e+24>>2]=s,A=o+16|0,r=t[A>>2]|0,r|0&&(t[e+16>>2]=r,t[r+24>>2]=e),A=t[A+4>>2]|0,A?(t[e+20>>2]=A,t[A+24>>2]=e,l=o,A=i):(l=o,A=i)}else l=o,A=i}while(!1);if(!(o>>>0>=c>>>0)&&(e=c+4|0,n=t[e>>2]|0,!!(n&1))){if(n&2)t[e>>2]=n&-2,t[l+4>>2]=A|1,t[o+A>>2]=A,s=A;else{if((t[6987]|0)==(c|0)){if(c=(t[6984]|0)+A|0,t[6984]=c,t[6987]=l,t[l+4>>2]=c|1,(l|0)!=(t[6986]|0))return;t[6986]=0,t[6983]=0;return}if((t[6986]|0)==(c|0)){c=(t[6983]|0)+A|0,t[6983]=c,t[6986]=o,t[l+4>>2]=c|1,t[o+c>>2]=c;return}s=(n&-8)+A|0,r=n>>>3;do if(n>>>0<256)if(A=t[c+8>>2]|0,e=t[c+12>>2]|0,(e|0)==(A|0)){t[6981]=t[6981]&~(1<<r);break}else{t[A+12>>2]=e,t[e+8>>2]=A;break}else{i=t[c+24>>2]|0,e=t[c+12>>2]|0;do if((e|0)==(c|0)){if(A=c+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){r=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0,r=e}else r=t[c+8>>2]|0,t[r+12>>2]=e,t[e+8>>2]=r,r=e;while(!1);if(i|0){if(e=t[c+28>>2]|0,A=28228+(e<<2)|0,(t[A>>2]|0)==(c|0)){if(t[A>>2]=r,!r){t[6982]=t[6982]&~(1<<e);break}}else if(n=i+16|0,t[((t[n>>2]|0)==(c|0)?n:i+20|0)>>2]=r,!r)break;t[r+24>>2]=i,e=c+16|0,A=t[e>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),e=t[e+4>>2]|0,e|0&&(t[r+20>>2]=e,t[e+24>>2]=r)}}while(!1);if(t[l+4>>2]=s|1,t[o+s>>2]=s,(l|0)==(t[6986]|0)){t[6983]=s;return}}if(e=s>>>3,s>>>0<256){r=27964+(e<<1<<2)|0,A=t[6981]|0,e=1<<e,A&e?(A=r+8|0,e=t[A>>2]|0):(t[6981]=A|e,e=r,A=r+8|0),t[A>>2]=l,t[e+12>>2]=l,t[l+8>>2]=e,t[l+12>>2]=r;return}e=s>>>8,e?s>>>0>16777215?n=31:(o=(e+1048320|0)>>>16&8,c=e<<o,i=(c+520192|0)>>>16&4,c=c<<i,n=(c+245760|0)>>>16&2,n=14-(i|o|n)+(c<<n>>>15)|0,n=s>>>(n+7|0)&1|n<<1):n=0,e=28228+(n<<2)|0,t[l+28>>2]=n,t[l+20>>2]=0,t[l+16>>2]=0,A=t[6982]|0,r=1<<n;A:do if(!(A&r))t[6982]=A|r,t[e>>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;else{e=t[e>>2]|0;e:do if((t[e+4>>2]&-8|0)!=(s|0)){for(n=s<<((n|0)==31?0:25-(n>>>1)|0);r=e+16+(n>>>31<<2)|0,A=t[r>>2]|0,!!A;)if((t[A+4>>2]&-8|0)==(s|0)){e=A;break e}else n=n<<1,e=A;t[r>>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;break A}while(!1);o=e+8|0,c=t[o>>2]|0,t[c+12>>2]=l,t[o>>2]=l,t[l+8>>2]=c,t[l+12>>2]=e,t[l+24>>2]=0}while(!1);if(c=(t[6989]|0)+-1|0,t[6989]=c,!(c|0)){for(e=28380;e=t[e>>2]|0,e;)e=e+8|0;t[6989]=-1}}}}function Gt(e,A){e=e|0,A=A|0;var r=0;return e?(r=pt(A,e)|0,(A|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0|0)==(A|0)?r:-1)):r=0,e=Er(r)|0,!e||!(t[e+-4>>2]&3)||An(e|0,0,r|0)|0,e|0}function YA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,r=e+r>>>0,JA(A+n+(r>>>0<e>>>0|0)>>>0|0),r|0|0}function xt(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,n=A-n-(r>>>0>e>>>0|0)>>>0,JA(n|0),e-r>>>0|0|0}function mi(e){return e=e|0,(e?31-(Et(e^e-1)|0)|0:32)|0}function ds(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,c=0,f=0,p=0,B=0,I=0,L=0,N=0;if(p=e,c=A,f=c,o=r,I=n,l=I,!f)return i=(s|0)!=0,l?i?(t[s>>2]=e|0,t[s+4>>2]=A&0,I=0,s=0,JA(I|0),s|0):(I=0,s=0,JA(I|0),s|0):(i&&(t[s>>2]=(p>>>0)%(o>>>0),t[s+4>>2]=0),I=0,s=(p>>>0)/(o>>>0)>>>0,JA(I|0),s|0);i=(l|0)==0;do if(o){if(!i){if(i=(Et(l|0)|0)-(Et(f|0)|0)|0,i>>>0<=31){B=i+1|0,l=31-i|0,A=i-31>>31,o=B,e=p>>>(B>>>0)&A|f<<l,A=f>>>(B>>>0)&A,i=0,l=p<<l;break}return s?(t[s>>2]=e|0,t[s+4>>2]=c|A&0,I=0,s=0,JA(I|0),s|0):(I=0,s=0,JA(I|0),s|0)}if(i=o-1|0,i&o|0){l=(Et(o|0)|0)+33-(Et(f|0)|0)|0,N=64-l|0,B=32-l|0,c=B>>31,L=l-32|0,A=L>>31,o=l,e=B-1>>31&f>>>(L>>>0)|(f<<B|p>>>(l>>>0))&A,A=A&f>>>(l>>>0),i=p<<N&c,l=(f<<N|p>>>(L>>>0))&c|p<<B&l-33>>31;break}return s|0&&(t[s>>2]=i&p,t[s+4>>2]=0),(o|0)==1?(L=c|A&0,N=e|0|0,JA(L|0),N|0):(N=mi(o|0)|0,L=f>>>(N>>>0)|0,N=f<<32-N|p>>>(N>>>0)|0,JA(L|0),N|0)}else{if(i)return s|0&&(t[s>>2]=(f>>>0)%(o>>>0),t[s+4>>2]=0),L=0,N=(f>>>0)/(o>>>0)>>>0,JA(L|0),N|0;if(!p)return s|0&&(t[s>>2]=0,t[s+4>>2]=(f>>>0)%(l>>>0)),L=0,N=(f>>>0)/(l>>>0)>>>0,JA(L|0),N|0;if(i=l-1|0,!(i&l))return s|0&&(t[s>>2]=e|0,t[s+4>>2]=i&f|A&0),L=0,N=f>>>((mi(l|0)|0)>>>0),JA(L|0),N|0;if(i=(Et(l|0)|0)-(Et(f|0)|0)|0,i>>>0<=30){A=i+1|0,l=31-i|0,o=A,e=f<<l|p>>>(A>>>0),A=f>>>(A>>>0),i=0,l=p<<l;break}return s?(t[s>>2]=e|0,t[s+4>>2]=c|A&0,L=0,N=0,JA(L|0),N|0):(L=0,N=0,JA(L|0),N|0)}while(!1);if(!o)f=l,c=0,l=0;else{B=r|0|0,p=I|n&0,f=YA(B|0,p|0,-1,-1)|0,r=S()|0,c=l,l=0;do n=c,c=i>>>31|c<<1,i=l|i<<1,n=e<<1|n>>>31|0,I=e>>>31|A<<1|0,xt(f|0,r|0,n|0,I|0)|0,N=S()|0,L=N>>31|((N|0)<0?-1:0)<<1,l=L&1,e=xt(n|0,I|0,L&B|0,(((N|0)<0?-1:0)>>31|((N|0)<0?-1:0)<<1)&p|0)|0,A=S()|0,o=o-1|0;while((o|0)!=0);f=c,c=0}return o=0,s|0&&(t[s>>2]=e,t[s+4>>2]=A),L=(i|0)>>>31|(f|o)<<1|(o<<1|i>>>31)&0|c,N=(i<<1|0)&-2|l,JA(L|0),N|0}function Xr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0;return f=A>>31|((A|0)<0?-1:0)<<1,c=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,i=n>>31|((n|0)<0?-1:0)<<1,s=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,l=xt(f^e|0,c^A|0,f|0,c|0)|0,o=S()|0,e=i^f,A=s^c,xt((ds(l,o,xt(i^r|0,s^n|0,i|0,s|0)|0,S()|0,0)|0)^e|0,(S()|0)^A|0,e|0,A|0)|0}function xa(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return i=e&65535,s=A&65535,r=pt(s,i)|0,n=e>>>16,e=(r>>>16)+(pt(s,n)|0)|0,s=A>>>16,A=pt(s,i)|0,JA((e>>>16)+(pt(s,n)|0)+(((e&65535)+A|0)>>>16)|0),e+A<<16|r&65535|0|0}function wt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;return s=e,i=r,r=xa(s,i)|0,e=S()|0,JA((pt(A,i)|0)+(pt(n,s)|0)+e|e&0|0),r|0|0|0}function Nn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,c=0,f=0;return s=E,E=E+16|0,l=s|0,o=A>>31|((A|0)<0?-1:0)<<1,i=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,f=n>>31|((n|0)<0?-1:0)<<1,c=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,e=xt(o^e|0,i^A|0,o|0,i|0)|0,A=S()|0,ds(e,A,xt(f^r|0,c^n|0,f|0,c|0)|0,S()|0,l)|0,n=xt(t[l>>2]^o|0,t[l+4>>2]^i|0,o|0,i|0)|0,r=S()|0,E=s,JA(r|0),n|0}function Fn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;return i=E,E=E+16|0,s=i|0,ds(e,A,r,n,s)|0,E=i,JA(t[s+4>>2]|0),t[s>>2]|0|0}function pi(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(JA(A>>r|0),e>>>r|(A&(1<<r)-1)<<32-r):(JA(((A|0)<0?-1:0)|0),A>>r-32|0)}function xA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(JA(A>>>r|0),e>>>r|(A&(1<<r)-1)<<32-r):(JA(0),A>>>r-32|0)}function CA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(JA(A<<r|(e&(1<<r)-1<<32-r)>>>32-r|0),e<<r):(JA(e<<r-32|0),0)}function ms(e,A,r){return e=e|0,A=A|0,A=Et(A)|0,(A|0)==32&&(A=A+(Et(e)|0)|0),JA(0),A|0}function gi(e,A){return e=+e,A=+A,e!=e?+A:A!=A?+e:+Tr(+e,+A)}function B0(e,A){return e=+e,A=+A,e!=e?+A:A!=A?+e:+ot(+e,+A)}function D0(e){return e=+e,e>=0?+Ue(e+.5):+Qt(e-.5)}function Pn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if((r|0)>=8192)return Ut(e|0,A|0,r|0)|0,e|0;if(i=e|0,s=e+r|0,(e&3)==(A&3)){for(;e&3;){if(!r)return i|0;mA[e>>0]=mA[A>>0]|0,e=e+1|0,A=A+1|0,r=r-1|0}for(r=s&-4|0,n=r-64|0;(e|0)<=(n|0);)t[e>>2]=t[A>>2],t[e+4>>2]=t[A+4>>2],t[e+8>>2]=t[A+8>>2],t[e+12>>2]=t[A+12>>2],t[e+16>>2]=t[A+16>>2],t[e+20>>2]=t[A+20>>2],t[e+24>>2]=t[A+24>>2],t[e+28>>2]=t[A+28>>2],t[e+32>>2]=t[A+32>>2],t[e+36>>2]=t[A+36>>2],t[e+40>>2]=t[A+40>>2],t[e+44>>2]=t[A+44>>2],t[e+48>>2]=t[A+48>>2],t[e+52>>2]=t[A+52>>2],t[e+56>>2]=t[A+56>>2],t[e+60>>2]=t[A+60>>2],e=e+64|0,A=A+64|0;for(;(e|0)<(r|0);)t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0}else for(r=s-4|0;(e|0)<(r|0);)mA[e>>0]=mA[A>>0]|0,mA[e+1>>0]=mA[A+1>>0]|0,mA[e+2>>0]=mA[A+2>>0]|0,mA[e+3>>0]=mA[A+3>>0]|0,e=e+4|0,A=A+4|0;for(;(e|0)<(s|0);)mA[e>>0]=mA[A>>0]|0,e=e+1|0,A=A+1|0;return i|0}function An(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;if(i=e+r|0,A=A&255,(r|0)>=67){for(;e&3;)mA[e>>0]=A,e=e+1|0;for(n=i&-4|0,o=A|A<<8|A<<16|A<<24,s=n-64|0;(e|0)<=(s|0);)t[e>>2]=o,t[e+4>>2]=o,t[e+8>>2]=o,t[e+12>>2]=o,t[e+16>>2]=o,t[e+20>>2]=o,t[e+24>>2]=o,t[e+28>>2]=o,t[e+32>>2]=o,t[e+36>>2]=o,t[e+40>>2]=o,t[e+44>>2]=o,t[e+48>>2]=o,t[e+52>>2]=o,t[e+56>>2]=o,t[e+60>>2]=o,e=e+64|0;for(;(e|0)<(n|0);)t[e>>2]=o,e=e+4|0}for(;(e|0)<(i|0);)mA[e>>0]=A,e=e+1|0;return i-r|0}function yi(e){return e=+e,e>=0?+Ue(e+.5):+Qt(e-.5)}function en(e){e=e|0;var A=0,r=0,n=0;return n=qe()|0,r=t[Be>>2]|0,A=r+e|0,(e|0)>0&(A|0)<(r|0)|(A|0)<0?(Ir(A|0)|0,ft(12),-1):(A|0)>(n|0)&&!(dr(A|0)|0)?(ft(12),-1):(t[Be>>2]=A,r|0)}return{___divdi3:Xr,___muldi3:wt,___remdi3:Nn,___uremdi3:Fn,_areNeighborCells:ts,_bitshift64Ashr:pi,_bitshift64Lshr:xA,_bitshift64Shl:CA,_calloc:Gt,_cellAreaKm2:Ol,_cellAreaM2:zl,_cellAreaRads2:us,_cellToBoundary:In,_cellToCenterChild:Zs,_cellToChildPos:jl,_cellToChildren:n0,_cellToChildrenSize:Cr,_cellToLatLng:dn,_cellToLocalIj:Kl,_cellToParent:Lt,_cellToVertex:lr,_cellToVertexes:ha,_cellsToDirectedEdge:v0,_cellsToLinkedMultiPolygon:Je,_childPosToCell:Rl,_compactCells:kl,_constructCell:we,_destroyLinkedMultiPolygon:ei,_directedEdgeToBoundary:fn,_directedEdgeToCells:jn,_edgeLengthKm:Gl,_edgeLengthM:Ul,_edgeLengthRads:Hl,_emscripten_replace_memory:Ot,_free:$A,_getBaseCellNumber:re,_getDirectedEdgeDestination:b0,_getDirectedEdgeOrigin:_n,_getHexagonAreaAvgKm2:Xs,_getHexagonAreaAvgM2:Fl,_getHexagonEdgeLengthAvgKm:Pl,_getHexagonEdgeLengthAvgM:Ql,_getIcosahedronFaces:qs,_getIndexDigit:Ce,_getNumCells:E0,_getPentagons:os,_getRes0Cells:$n,_getResolution:DA,_greatCircleDistanceKm:i0,_greatCircleDistanceM:Il,_greatCircleDistanceRads:Tl,_gridDisk:v,_gridDiskDistances:j,_gridDistance:Zl,_gridPathCells:Jl,_gridPathCellsSize:ql,_gridRing:fA,_gridRingUnsafe:_A,_i64Add:YA,_i64Subtract:xt,_isPentagon:Fe,_isResClassIII:Sl,_isValidCell:ze,_isValidDirectedEdge:t0,_isValidIndex:Tt,_isValidVertex:ui,_latLngToCell:ss,_llvm_ctlz_i64:ms,_llvm_maxnum_f64:gi,_llvm_minnum_f64:B0,_llvm_round_f64:D0,_localIjToCell:$l,_malloc:Er,_maxFaceCount:Dl,_maxGridDiskSize:h,_maxPolygonToCellsSize:he,_maxPolygonToCellsSizeExperimental:ea,_memcpy:Pn,_memset:An,_originToDirectedEdges:Rn,_pentagonCount:_l,_polygonToCells:ht,_polygonToCellsExperimental:Aa,_readInt64AsDoubleFromPointer:aa,_res0CellCount:Kn,_round:yi,_sbrk:en,_sizeOfCellBoundary:na,_sizeOfCoordIJ:la,_sizeOfGeoLoop:sa,_sizeOfGeoPolygon:ia,_sizeOfH3Index:ta,_sizeOfLatLng:ra,_sizeOfLinkedGeoPolygon:oa,_uncompactCells:Cl,_uncompactCellsSize:El,_vertexToLatLng:da,establishStackSpace:Fr,stackAlloc:nr,stackRestore:Nr,stackSave:Lr}})(Kr,ln,kA);u.___divdi3=gA.___divdi3,u.___muldi3=gA.___muldi3,u.___remdi3=gA.___remdi3,u.___uremdi3=gA.___uremdi3,u._areNeighborCells=gA._areNeighborCells,u._bitshift64Ashr=gA._bitshift64Ashr,u._bitshift64Lshr=gA._bitshift64Lshr,u._bitshift64Shl=gA._bitshift64Shl,u._calloc=gA._calloc,u._cellAreaKm2=gA._cellAreaKm2,u._cellAreaM2=gA._cellAreaM2,u._cellAreaRads2=gA._cellAreaRads2,u._cellToBoundary=gA._cellToBoundary,u._cellToCenterChild=gA._cellToCenterChild,u._cellToChildPos=gA._cellToChildPos,u._cellToChildren=gA._cellToChildren,u._cellToChildrenSize=gA._cellToChildrenSize,u._cellToLatLng=gA._cellToLatLng,u._cellToLocalIj=gA._cellToLocalIj,u._cellToParent=gA._cellToParent,u._cellToVertex=gA._cellToVertex,u._cellToVertexes=gA._cellToVertexes,u._cellsToDirectedEdge=gA._cellsToDirectedEdge,u._cellsToLinkedMultiPolygon=gA._cellsToLinkedMultiPolygon,u._childPosToCell=gA._childPosToCell,u._compactCells=gA._compactCells,u._constructCell=gA._constructCell,u._destroyLinkedMultiPolygon=gA._destroyLinkedMultiPolygon,u._directedEdgeToBoundary=gA._directedEdgeToBoundary,u._directedEdgeToCells=gA._directedEdgeToCells,u._edgeLengthKm=gA._edgeLengthKm,u._edgeLengthM=gA._edgeLengthM,u._edgeLengthRads=gA._edgeLengthRads;var xr=u._emscripten_replace_memory=gA._emscripten_replace_memory;u._free=gA._free,u._getBaseCellNumber=gA._getBaseCellNumber,u._getDirectedEdgeDestination=gA._getDirectedEdgeDestination,u._getDirectedEdgeOrigin=gA._getDirectedEdgeOrigin,u._getHexagonAreaAvgKm2=gA._getHexagonAreaAvgKm2,u._getHexagonAreaAvgM2=gA._getHexagonAreaAvgM2,u._getHexagonEdgeLengthAvgKm=gA._getHexagonEdgeLengthAvgKm,u._getHexagonEdgeLengthAvgM=gA._getHexagonEdgeLengthAvgM,u._getIcosahedronFaces=gA._getIcosahedronFaces,u._getIndexDigit=gA._getIndexDigit,u._getNumCells=gA._getNumCells,u._getPentagons=gA._getPentagons,u._getRes0Cells=gA._getRes0Cells,u._getResolution=gA._getResolution,u._greatCircleDistanceKm=gA._greatCircleDistanceKm,u._greatCircleDistanceM=gA._greatCircleDistanceM,u._greatCircleDistanceRads=gA._greatCircleDistanceRads,u._gridDisk=gA._gridDisk,u._gridDiskDistances=gA._gridDiskDistances,u._gridDistance=gA._gridDistance,u._gridPathCells=gA._gridPathCells,u._gridPathCellsSize=gA._gridPathCellsSize,u._gridRing=gA._gridRing,u._gridRingUnsafe=gA._gridRingUnsafe,u._i64Add=gA._i64Add,u._i64Subtract=gA._i64Subtract,u._isPentagon=gA._isPentagon,u._isResClassIII=gA._isResClassIII,u._isValidCell=gA._isValidCell,u._isValidDirectedEdge=gA._isValidDirectedEdge,u._isValidIndex=gA._isValidIndex,u._isValidVertex=gA._isValidVertex,u._latLngToCell=gA._latLngToCell,u._llvm_ctlz_i64=gA._llvm_ctlz_i64,u._llvm_maxnum_f64=gA._llvm_maxnum_f64,u._llvm_minnum_f64=gA._llvm_minnum_f64,u._llvm_round_f64=gA._llvm_round_f64,u._localIjToCell=gA._localIjToCell,u._malloc=gA._malloc,u._maxFaceCount=gA._maxFaceCount,u._maxGridDiskSize=gA._maxGridDiskSize,u._maxPolygonToCellsSize=gA._maxPolygonToCellsSize,u._maxPolygonToCellsSizeExperimental=gA._maxPolygonToCellsSizeExperimental,u._memcpy=gA._memcpy,u._memset=gA._memset,u._originToDirectedEdges=gA._originToDirectedEdges,u._pentagonCount=gA._pentagonCount,u._polygonToCells=gA._polygonToCells,u._polygonToCellsExperimental=gA._polygonToCellsExperimental,u._readInt64AsDoubleFromPointer=gA._readInt64AsDoubleFromPointer,u._res0CellCount=gA._res0CellCount,u._round=gA._round,u._sbrk=gA._sbrk,u._sizeOfCellBoundary=gA._sizeOfCellBoundary,u._sizeOfCoordIJ=gA._sizeOfCoordIJ,u._sizeOfGeoLoop=gA._sizeOfGeoLoop,u._sizeOfGeoPolygon=gA._sizeOfGeoPolygon,u._sizeOfH3Index=gA._sizeOfH3Index,u._sizeOfLatLng=gA._sizeOfLatLng,u._sizeOfLinkedGeoPolygon=gA._sizeOfLinkedGeoPolygon,u._uncompactCells=gA._uncompactCells,u._uncompactCellsSize=gA._uncompactCellsSize,u._vertexToLatLng=gA._vertexToLatLng,u.establishStackSpace=gA.establishStackSpace;var er=u.stackAlloc=gA.stackAlloc,Se=u.stackRestore=gA.stackRestore,fr=u.stackSave=gA.stackSave;if(u.asm=gA,u.cwrap=aA,u.setValue=W,u.getValue=V,Ve){ke(Ve)||(Ve=k(Ve));{it();var tr=function(tA){tA.byteLength&&(tA=new Uint8Array(tA)),FA.set(tA,z),u.memoryInitializerRequest&&delete u.memoryInitializerRequest.response,St()},Ye=function(){D(Ve,tr,function(){throw"could not load memory initializer "+Ve})},ct=Rr(Ve);if(ct)tr(ct.buffer);else if(u.memoryInitializerRequest){var hr=function(){var tA=u.memoryInitializerRequest,yA=tA.response;if(tA.status!==200&&tA.status!==0){var TA=Rr(u.memoryInitializerRequestURL);if(TA)yA=TA.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+tA.status+", retrying "+Ve),Ye();return}}tr(yA)};u.memoryInitializerRequest.response?setTimeout(hr,0):u.memoryInitializerRequest.addEventListener("load",hr)}else Ye()}}var kt;At=function tA(){kt||wr(),kt||(At=tA)};function wr(tA){if($e>0||(_e(),$e>0))return;function yA(){kt||(kt=!0,!J&&(pe(),ce(),u.onRuntimeInitialized&&u.onRuntimeInitialized(),Me()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),yA()},1)):yA()}u.run=wr;function dt(tA){throw u.onAbort&&u.onAbort(tA),tA+="",Q(tA),M(tA),J=!0,"abort("+tA+"). Build with -s ASSERTIONS=1 for more info."}if(u.abort=dt,u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();return wr(),a})(typeof Pt=="object"?Pt:{}),ne="number",ee=ne,Un=ne,le=ne,ae=ne,vt=ne,QA=ne,A2=[["sizeOfH3Index",ne],["sizeOfLatLng",ne],["sizeOfCellBoundary",ne],["sizeOfGeoLoop",ne],["sizeOfGeoPolygon",ne],["sizeOfLinkedGeoPolygon",ne],["sizeOfCoordIJ",ne],["readInt64AsDoubleFromPointer",ne],["isValidCell",Un,[le,ae]],["isValidIndex",Un,[le,ae]],["latLngToCell",ee,[ne,ne,vt,QA]],["cellToLatLng",ee,[le,ae,QA]],["cellToBoundary",ee,[le,ae,QA]],["maxGridDiskSize",ee,[ne,QA]],["gridDisk",ee,[le,ae,ne,QA]],["gridDiskDistances",ee,[le,ae,ne,QA,QA]],["gridRing",ee,[le,ae,ne,QA]],["gridRingUnsafe",ee,[le,ae,ne,QA]],["maxPolygonToCellsSize",ee,[QA,vt,ne,QA]],["polygonToCells",ee,[QA,vt,ne,QA]],["maxPolygonToCellsSizeExperimental",ee,[QA,vt,ne,QA]],["polygonToCellsExperimental",ee,[QA,vt,ne,ne,ne,QA]],["cellsToLinkedMultiPolygon",ee,[QA,ne,QA]],["destroyLinkedMultiPolygon",null,[QA]],["compactCells",ee,[QA,QA,ne,ne]],["uncompactCells",ee,[QA,ne,ne,QA,ne,vt]],["uncompactCellsSize",ee,[QA,ne,ne,vt,QA]],["isPentagon",Un,[le,ae]],["isResClassIII",Un,[le,ae]],["getBaseCellNumber",ne,[le,ae]],["getResolution",ne,[le,ae]],["getIndexDigit",ne,[le,ae,ne]],["constructCell",ee,[ne,ne,QA,QA]],["maxFaceCount",ee,[le,ae,QA]],["getIcosahedronFaces",ee,[le,ae,QA]],["cellToParent",ee,[le,ae,vt,QA]],["cellToChildren",ee,[le,ae,vt,QA]],["cellToCenterChild",ee,[le,ae,vt,QA]],["cellToChildrenSize",ee,[le,ae,vt,QA]],["cellToChildPos",ee,[le,ae,vt,QA]],["childPosToCell",ee,[ne,ne,le,ae,vt,QA]],["areNeighborCells",ee,[le,ae,le,ae,QA]],["cellsToDirectedEdge",ee,[le,ae,le,ae,QA]],["getDirectedEdgeOrigin",ee,[le,ae,QA]],["getDirectedEdgeDestination",ee,[le,ae,QA]],["isValidDirectedEdge",Un,[le,ae]],["directedEdgeToCells",ee,[le,ae,QA]],["originToDirectedEdges",ee,[le,ae,QA]],["directedEdgeToBoundary",ee,[le,ae,QA]],["gridDistance",ee,[le,ae,le,ae,QA]],["gridPathCells",ee,[le,ae,le,ae,QA]],["gridPathCellsSize",ee,[le,ae,le,ae,QA]],["cellToLocalIj",ee,[le,ae,le,ae,ne,QA]],["localIjToCell",ee,[le,ae,QA,ne,QA]],["getHexagonAreaAvgM2",ee,[vt,QA]],["getHexagonAreaAvgKm2",ee,[vt,QA]],["getHexagonEdgeLengthAvgM",ee,[vt,QA]],["getHexagonEdgeLengthAvgKm",ee,[vt,QA]],["greatCircleDistanceM",ne,[QA,QA]],["greatCircleDistanceKm",ne,[QA,QA]],["greatCircleDistanceRads",ne,[QA,QA]],["cellAreaM2",ee,[le,ae,QA]],["cellAreaKm2",ee,[le,ae,QA]],["cellAreaRads2",ee,[le,ae,QA]],["edgeLengthM",ee,[le,ae,QA]],["edgeLengthKm",ee,[le,ae,QA]],["edgeLengthRads",ee,[le,ae,QA]],["getNumCells",ee,[vt,QA]],["getRes0Cells",ee,[QA]],["res0CellCount",ne],["getPentagons",ee,[ne,QA]],["pentagonCount",ne],["cellToVertex",ee,[le,ae,ne,QA]],["cellToVertexes",ee,[le,ae,QA]],["vertexToLatLng",ee,[le,ae,QA]],["isValidVertex",Un,[le,ae]]],e2=0,t2=1,r2=2,n2=3,s2=4,i2=5,o2=6,l2=7,a2=8,u2=9,c2=10,f2=11,h2=12,d2=13,m2=14,p2=15,g2=16,y2=17,x2=18,w2=19,lt={};lt[e2]="Success";lt[t2]="The operation failed but a more specific error is not available";lt[r2]="Argument was outside of acceptable range";lt[n2]="Latitude or longitude arguments were outside of acceptable range";lt[s2]="Resolution argument was outside of acceptable range";lt[i2]="Cell argument was not valid";lt[o2]="Directed edge argument was not valid";lt[l2]="Undirected edge argument was not valid";lt[a2]="Vertex argument was not valid";lt[u2]="Pentagon distortion was encountered";lt[c2]="Duplicate input";lt[f2]="Cell arguments were not neighbors";lt[h2]="Cell arguments had incompatible resolutions";lt[d2]="Memory allocation failed";lt[m2]="Bounds of provided memory were insufficient";lt[p2]="Mode or flags argument was not valid";lt[g2]="Index argument was not valid";lt[y2]="Base cell number was outside of acceptable range";lt[x2]="Child indexing digits invalid";lt[w2]="Child indexing digits refer to a deleted subsequence";var v2=1e3,b2=1001,ml=1002,es={};es[v2]="Unknown unit";es[b2]="Array length out of bounds";es[ml]="Got unexpected null value for H3 index";var k2="Unknown error";function pl(a,u,g){var y=g&&"value"in g,x=new Error((a[u]||k2)+" (code: "+u+(y?", value: "+g.value:"")+")");return x.code=u,x}function C2(a,u){var g=arguments.length===2?{value:u}:{};return pl(lt,a,g)}function E2(a,u){var g=arguments.length===2?{value:u}:{};return pl(es,a,g)}function gl(a){if(a!==0)throw C2(a)}var Br={};A2.forEach(function(u){Br[u[0]]=Pt.cwrap.apply(Pt,u)});var Wn=16,S2=4,$0=8,Ns=Br.sizeOfH3Index(),M2=Br.sizeOfLatLng(),B2=Br.sizeOfCellBoundary();Br.sizeOfGeoPolygon();Br.sizeOfGeoLoop();Br.sizeOfLinkedGeoPolygon();Br.sizeOfCoordIJ();function D2(a){if(!a)throw E2(ml);return a}var _2=/[^0-9a-fA-F]/;function j2(a){if(Array.isArray(a)&&a.length===2&&Number.isInteger(a[0])&&Number.isInteger(a[1]))return a;if(typeof a!="string"||_2.test(a))return[0,0];var u=parseInt(a.substring(0,a.length-8),Wn),g=parseInt(a.substring(a.length-8),Wn);return[g,u]}function Ki(a){if(a>=0)return a.toString(Wn);a=a&2147483647;var u=yl(8,a.toString(Wn)),g=(parseInt(u[0],Wn)+8).toString(Wn);return u=g+u.substring(1),u}function R2(a,u){return Ki(u)+yl(8,Ki(a))}function yl(a,u){for(var g=a-u.length,y="",x=0;x<g;x++)y+="0";return y=y+u,y}function T2(a,u){u===void 0&&(u=0);var g=Pt.getValue(a+Ns*u,"i32"),y=Pt.getValue(a+Ns*u+S2,"i32");return y?R2(g,y):null}function $i(a){return P2(Pt.getValue(a,"double"))}function I2(a){return[$i(a),$i(a+$0)]}function L2(a,u,g){for(var y=Pt.getValue(a,"i32"),x=a+$0,k=[],D=I2,Q=0;Q<y*2;Q+=2)k.push(D(x+$0*Q));return k}function N2(a,u,g){var y=Pt._malloc(M2);Pt.HEAPF64.set([a,u].map(F2),y/$0);var x=Pt._malloc(Ns);try{return gl(Br.latLngToCell(y,g,x)),D2(T2(x))}finally{Pt._free(x),Pt._free(y)}}function xl(a,u){var g=Pt._malloc(B2),y=j2(a),x=y[0],k=y[1];try{return gl(Br.cellToBoundary(x,k,g)),L2(g,u,u)}finally{Pt._free(g)}}function F2(a){return a*Math.PI/180}function P2(a){return a*180/Math.PI}const yn="wardriving-hexagons",xn="wardriving-hexagons-fill",Q2=8,O2=.7,z2=300,wl=500,H2=[[15,5,30,255],[35,10,55,255],[55,15,75,255],[75,20,90,255],[95,25,100,255],[115,30,105,255],[135,35,100,255],[155,45,90,255],[175,55,75,255],[195,70,60,255],[210,90,50,255],[225,110,45,255],[235,135,45,255],[245,160,50,255],[250,185,60,255],[252,205,80,255],[254,225,105,255],[255,240,135,255],[255,248,170,255],[255,252,200,255],[255,254,225,255],[255,255,240,255],[255,255,250,255],[255,255,255,255]],G2=[[60,20,120,255],[80,30,140,255],[100,40,160,255],[120,50,170,255],[140,60,175,255],[160,70,175,255],[180,60,150,255],[200,55,120,255],[215,55,90,255],[230,65,60,255],[240,80,40,255],[250,100,30,255],[255,130,30,255],[255,155,35,255],[255,175,40,255],[255,195,50,255],[255,210,60,255],[255,225,70,255],[255,200,40,255],[255,185,30,255],[255,170,20,255],[245,155,15,255],[235,140,10,255],[225,125,5,255]];function U2(a="dark"){var g;if(a==="light")return G2;const u=Va();return u.length===24&&((g=u[0])==null?void 0:g[0])!==0?u:H2}function Zi(a){return`rgb(${a[0]}, ${a[1]}, ${a[2]})`}function V2(a){return a<.15?a/.15*.1:a>.85?.9+(a-.85)/.15*.1:.1+(a-.15)/.7*.8}function vl(a,u,g,y){const x=g-u;if(x<.001)return Zi(y[12]);const k=Math.max(0,Math.min(1,(a-u)/x)),D=V2(k),Q=Math.min(23,Math.floor(D*24));return Zi(y[Q])}function W2(a){const u=new Map;for(const k of a){if(typeof k.lat!="number"||typeof k.lon!="number"||isNaN(k.lat)||isNaN(k.lon))continue;const D=N2(k.lat,k.lon,Q2),Q=u.get(D),M=k.weight;Q?(Q.count++,Q.qualitySum+=M):u.set(D,{count:1,qualitySum:M})}const g=[];let y=1/0,x=-1/0;for(const[k,D]of u.entries()){const Q=D.qualitySum/D.count;g.push({hexId:k,count:D.count,avgQuality:Q}),y=Math.min(y,Q),x=Math.max(x,Q)}return{cells:g,minQuality:g.length>0?y:0,maxQuality:g.length>0?x:0}}function Y2(a,u,g,y){const x=[];for(const k of a){const Q=xl(k.hexId).map(([b,T])=>[T,b]);Q.push(Q[0]);const M=vl(k.avgQuality,u,g,y);x.push({type:"Feature",properties:{color:M,quality:k.avgQuality,count:k.count},geometry:{type:"Polygon",coordinates:[Q]}})}return{type:"FeatureCollection",features:x}}async function K2(a,u,g,y,x){const k=[];let D=0;for(;D<a.length;){if(x.aborted)return null;const Q=Math.min(D+wl,a.length);for(;D<Q;D++){const M=a[D],T=xl(M.hexId).map(([z,W])=>[W,z]);T.push(T[0]);const O=vl(M.avgQuality,u,g,y);k.push({type:"Feature",properties:{color:O,quality:M.avgQuality,count:M.count},geometry:{type:"Polygon",coordinates:[T]}})}D<a.length&&await new Promise(M=>requestAnimationFrame(M))}return{type:"FeatureCollection",features:k}}function $2(a,u){const[g,y]=R.useState(a);return R.useEffect(()=>{const x=setTimeout(()=>y(a),u);return()=>clearTimeout(x)},[a,u]),g}function Z2(a,u){const g=[];for(const y of a){if(y.timestampS>u)break;const x=y.msgSnr??y.pathSnr??0,k=Math.max(0,Math.min(1,(x+20)/40));g.push({lat:y.lat,lon:y.lon,successRate:1,weight:k,totalSamples:1,ageDays:0,geohash:"",repeaters:y.pathHops??[]})}return g}function q2({coveragePoints:a,visible:u,terrainEnabled:g=!1,brightness:y=O2,basemapMode:x="dark",replaySamples:k,replayTimeS:D}){const Q=R.useMemo(()=>k&&k.length>0&&D!=null?Z2(k,D):a,[k,D,a]),{current:M}=Yr(),[b,T]=R.useState(null);R.useEffect(()=>{const sA=()=>{var bA;const SA=(bA=M==null?void 0:M.getMap)==null?void 0:bA.call(M);SA&&!b&&T(SA)};sA();const lA=setInterval(sA,50),BA=setTimeout(()=>clearInterval(lA),5e3);return()=>{clearInterval(lA),clearTimeout(BA)}},[M,b]);const[O,z]=R.useState(null),[W,V]=R.useState(!1),J=R.useRef({aborted:!1}),iA=R.useRef(0),eA=R.useRef(x),aA=$2(Q,k?100:z2),cA=R.useMemo(()=>U2(x),[x]);R.useEffect(()=>{if(!aA||!Array.isArray(aA)||aA.length===0){queueMicrotask(()=>{z(null),iA.current=0});return}const sA=eA.current!==x;if(aA.length===iA.current&&O&&!sA)return;iA.current=aA.length,eA.current=x,J.current.aborted=!0,J.current={aborted:!1};const lA=J.current;V(!0);const{cells:BA,minQuality:SA,maxQuality:bA}=W2(aA);if(BA.length===0){z(null),V(!1);return}if(BA.length<wl){const kA=Y2(BA,SA,bA,cA);lA.aborted||(z(kA),V(!1));return}return K2(BA,SA,bA,cA,lA).then(kA=>{!lA.aborted&&kA&&z(kA)}).finally(()=>{lA.aborted||V(!1)}),()=>{lA.aborted=!0}},[aA,cA]),R.useEffect(()=>{if(!b)return;const sA=()=>{var lA,BA;try{const SA=b.getLayer(xn),bA=b.getSource(yn);if(u&&O&&O.features.length>0){if(bA?b.getSource(yn).setData(O):b.addSource(yn,{type:"geojson",data:O}),!SA){const kA=b.getLayer("topology-weak-edges-native"),vA=(BA=(lA=b.getStyle())==null?void 0:lA.layers)==null?void 0:BA.find(IA=>IA.type==="symbol"),FA=kA?"topology-weak-edges-native":vA==null?void 0:vA.id;b.addLayer({id:xn,type:"fill",source:yn,paint:{"fill-color":["get","color"],"fill-opacity":y}},FA)}}else SA&&b.removeLayer(xn),bA&&b.removeSource(yn)}catch(SA){console.warn("[WardrivingHexLayerMapLibre] Layer update error:",SA)}};b.isStyleLoaded()?sA():b.once("style.load",sA)},[b,u,O,g]),R.useEffect(()=>{if(!(!b||!u))try{b.getLayer(xn)&&b.setPaintProperty(xn,"fill-opacity",y)}catch{}},[b,y,u]),R.useEffect(()=>()=>{if(b)try{b.getLayer(xn)&&b.removeLayer(xn),b.getSource(yn)&&b.removeSource(yn)}catch{}},[b]);const RA=(O==null?void 0:O.features.length)??0;return RA>0&&u?m.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(a==null?void 0:a.length)||0,"data-cell-count":RA,"data-terrain-enabled":g,"data-is-processing":W,style:{display:"none"}}):null}const u0="replay-marker",Q0="replay-marker-circle",c0="replay-trail",O0="replay-trail-line",f0="replay-trace",ks="replay-trace-line",h0="replay-marker-icon",qi=7,J2=2.5,X2=1.5;function A1(){const a=qi*2*2,u=document.createElement("canvas");u.width=a,u.height=a;const g=u.getContext("2d");if(!g)return u;const y=a/2,x=a/2,k=qi*2-2;return g.beginPath(),g.arc(y,x,k+2,0,Math.PI*2),g.fillStyle="rgba(59, 130, 246, 0.25)",g.fill(),g.beginPath(),g.arc(y,x,k,0,Math.PI*2),g.fillStyle="#3B82F6",g.fill(),g.lineWidth=2,g.strokeStyle="#1E3A5F",g.stroke(),g.beginPath(),g.arc(y,x,3,0,Math.PI*2),g.fillStyle="#FFFFFF",g.fill(),u}const e1={type:"FeatureCollection",features:[]},d0={type:"FeatureCollection",features:[]};function t1({neighbors:a}){const{current:u}=Yr(),g=Ws(),y=R.useRef(null),x=R.useRef(0),k=R.useRef(!1);return R.useEffect(()=>{const D=u==null?void 0:u.getMap();if(!D||!g)return;const Q=()=>{if(!k.current){if(!D.hasImage(h0)){const M=A1(),b=M.getContext("2d");if(b){const T=b.getImageData(0,0,M.width,M.height);D.addImage(h0,T,{pixelRatio:2})}}D.getSource(u0)||D.addSource(u0,{type:"geojson",data:e1}),D.getLayer(Q0)||D.addLayer({id:Q0,type:"symbol",source:u0,layout:{"icon-image":h0,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}),D.getSource(c0)||D.addSource(c0,{type:"geojson",data:d0}),D.getLayer(O0)||D.addLayer({id:O0,type:"line",source:c0,paint:{"line-color":"rgba(59, 130, 246, 0.4)","line-width":J2},layout:{"line-cap":"round","line-join":"round"}},Q0),D.getSource(f0)||D.addSource(f0,{type:"geojson",data:d0}),D.getLayer(ks)||D.addLayer({id:ks,type:"line",source:f0,paint:{"line-color":"rgba(251, 191, 36, 0.6)","line-width":X2,"line-dasharray":[4,4]},layout:{"line-cap":"round"}},O0),k.current=!0}};return D.isStyleLoaded()?Q():D.once("styledata",Q),()=>{if(cancelAnimationFrame(x.current),y.current=null,!D.isStyleLoaded()){k.current=!1;return}for(const M of[Q0,O0,ks])D.getLayer(M)&&D.removeLayer(M);for(const M of[u0,c0,f0])D.getSource(M)&&D.removeSource(M);D.hasImage(h0)&&D.removeImage(h0),k.current=!1}},[u,g]),R.useEffect(()=>{const D=u==null?void 0:u.getMap();if(!D||!g)return;const Q=()=>{if(!k.current){x.current=requestAnimationFrame(Q);return}const M=Ys.getState();if(!M.isActive)return;const{samples:b,currentTimeS:T}=M,O=Jo(),z=D.getSource(u0);z&&O&&z.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[O.lon,O.lat]},properties:{}}]});const W=D.getSource(c0);if(W){const J=Nu(b,T);J.length>=2?W.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:J},properties:{}}]}):W.setData(d0)}const V=D.getSource(f0);if(V&&O){const J=Fu(),iA=(J==null?void 0:J[0])??null;if(iA!==y.current||iA)if(y.current=iA,iA&&a){const eA=r1(iA,a);eA?V.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:[[O.lon,O.lat],[eA.lon,eA.lat]]},properties:{}}]}):V.setData(d0)}else V.setData(d0)}x.current=requestAnimationFrame(Q)};return x.current=requestAnimationFrame(Q),()=>cancelAnimationFrame(x.current)},[u,g,a]),null}function r1(a,u){const g=a.toLowerCase();for(const[y,x]of Object.entries(u))if((y.startsWith("0x")?y.slice(2):y).toLowerCase().startsWith(g)&&x.latitude&&x.longitude&&x.latitude!==0&&x.longitude!==0)return{lat:x.latitude,lon:x.longitude};return null}const Ji="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Xi="terrarium",Ao=256,eo=14,m0={shadowColor:"rgba(10, 10, 10, 0.6)",highlightColor:"rgba(245, 240, 230, 0.4)",accentColor:"rgba(90, 75, 65, 0.3)",illuminationDirection:315,exaggeration:.35},tn="terrain-dem",Vn="hillshade-dem",z0="terrain-hillshade";function n1({enabled:a,exaggeration:u=4}){const{current:g}=Yr(),[y,x]=R.useState(null),k=R.useRef(null);return R.useEffect(()=>{const D=()=>{var T;const b=(T=g==null?void 0:g.getMap)==null?void 0:T.call(g);b&&!y&&x(b)};D();const Q=setInterval(D,50),M=setTimeout(()=>clearInterval(Q),5e3);return()=>{clearInterval(Q),clearTimeout(M)}},[g,y]),R.useEffect(()=>{if(!y)return;let D=!0;const Q=()=>{var M,b;if(D)try{if(y.getSource(Vn)||y.addSource(Vn,{type:"raster-dem",tiles:[Ji],encoding:Xi,tileSize:Ao,maxzoom:eo}),!y.getLayer(z0)){const T=(b=(M=y.getStyle())==null?void 0:M.layers)==null?void 0:b.find(O=>O.type==="symbol");y.addLayer({id:z0,type:"hillshade",source:Vn,paint:{"hillshade-shadow-color":m0.shadowColor,"hillshade-highlight-color":m0.highlightColor,"hillshade-accent-color":m0.accentColor,"hillshade-illumination-direction":m0.illuminationDirection,"hillshade-exaggeration":m0.exaggeration}},T==null?void 0:T.id)}y.getSource(tn)||y.addSource(tn,{type:"raster-dem",tiles:[Ji],encoding:Xi,tileSize:Ao,maxzoom:eo})}catch(T){console.error("[TerrainLayer] Source/layer setup error:",T)}};return y.isStyleLoaded()?Q():(y.once("style.load",Q),y.once("load",()=>{D&&!y.getSource(Vn)&&Q()})),()=>{D=!1}},[y]),R.useEffect(()=>{if(!y)return;let D=!0,Q=!1;const M=()=>{if(!(!D||!y.getSource(tn)))try{a?(y.setCenterClampedToGround(!1),y.setTerrain({source:tn,exaggeration:u}),y.setMaxPitch(70),!Q&&y.getPitch()<30&&!y.isMoving()&&(Q=!0,k.current!==null&&clearTimeout(k.current),k.current=window.setTimeout(()=>{k.current=null,D&&!y.isMoving()&&y.getPitch()<30&&y.easeTo({pitch:45,duration:1e3})},200))):(y.setTerrain(null),y.setCenterClampedToGround(!0),y.getPitch()>0&&!y.isMoving()&&y.easeTo({pitch:0,duration:800}),y.setMaxPitch(60))}catch(b){console.error("[TerrainLayer] Terrain state error:",b)}};if(y.isStyleLoaded()&&y.getSource(tn))M();else{const b=()=>{y.getSource(tn)&&M()};y.once("idle",b)}return()=>{D=!1,k.current!==null&&(clearTimeout(k.current),k.current=null)}},[y,a,u]),R.useEffect(()=>()=>{var D;try{(D=y==null?void 0:y.getStyle)!=null&&D.call(y)&&y.isStyleLoaded()&&(y.setTerrain(null),y.getLayer(z0)&&y.removeLayer(z0),y.getSource(Vn)&&y.removeSource(Vn),y.getSource(tn)&&y.removeSource(tn))}catch{}},[y]),null}const s1=.03,i1=.1,o1=2,l1=3,a1=.02,u1=3;function c1(a,u=u1){if(a.length<3||u<=0)return a;let g=a;for(let y=0;y<u;y++){const x=[],k=g.length,D=g[0][0]===g[k-1][0]&&g[0][1]===g[k-1][1],Q=D?k-1:k;for(let M=0;M<Q;M++){const b=g[M],T=g[(M+1)%Q],O=.75*b[0]+.25*T[0],z=.75*b[1]+.25*T[1],W=.25*b[0]+.75*T[0],V=.25*b[1]+.75*T[1];x.push([O,z]),x.push([W,V])}D&&x.length>0&&x.push([x[0][0],x[0][1]]),g=x}return g}function f1(a,u){let g=1/0,y=-1/0,x=1/0,k=-1/0;for(const[D,Q]of a)D<g&&(g=D),D>y&&(y=D),Q<x&&(x=Q),Q>k&&(k=Q);return g-=u,y+=u,x-=u,k+=u,{minX:g,minY:x,maxX:y,maxY:k,width:y-g,height:k-x}}function h1(a,u={}){if(a.length<l1)return{coordinates:[],valid:!1};const{bandwidth:g=s1,threshold:y=i1,cellSize:x=o1}=u,k=f1(a,a1),D=Math.ceil(k.width/(g/2)),Q=Math.ceil(k.height/(g/2)),b=Math.min(1,200/Math.max(D,Q)),T=Math.max(10,Math.ceil(D*b)),O=Math.max(10,Math.ceil(Q*b)),z=eA=>(eA-k.minX)/k.width*T,W=eA=>(eA-k.minY)/k.height*O,V=eA=>eA/T*k.width+k.minX,J=eA=>eA/O*k.height+k.minY,iA=g/k.width*T;try{const Z=Tc().x(SA=>z(SA[0])).y(SA=>W(SA[1])).size([T,O]).bandwidth(Math.max(5,iA)).cellSize(x)(a);if(Z.length===0)return{coordinates:[],valid:!1};const cA=Math.max(...Z.map(SA=>SA.value))*y;let RA=Z[0],sA=1/0;for(const SA of Z){const bA=Math.abs(SA.value-cA);bA<sA&&(sA=bA,RA=SA)}const lA=[];for(const SA of RA.coordinates){const bA=[];for(const kA of SA){const vA=[];for(const FA of kA){const IA=V(FA[0]),WA=J(FA[1]);vA.push([IA,WA])}if(vA.length>0){const FA=vA[0],IA=vA[vA.length-1];(FA[0]!==IA[0]||FA[1]!==IA[1])&&vA.push([FA[0],FA[1]])}if(vA.length>=4){const FA=c1(vA);bA.push(FA)}}bA.length>0&&lA.push(bA)}const BA=[];for(const SA of lA)for(const bA of SA)BA.push(bA);return{coordinates:lA,valid:lA.length>0}}catch(eA){return console.warn("[KDE Contour] Failed to generate contour:",eA),{coordinates:[],valid:!1}}}function d1(a,u={}){const g=h1(a,u);return!g.valid||g.coordinates.length===0?null:g.coordinates.length===1?{type:"Polygon",coordinates:g.coordinates[0]}:{type:"MultiPolygon",coordinates:g.coordinates}}const m1="mincut-partition",p1="mincut-partition-fill",g1="mincut-partition-stroke",y1=3,x1=.05,w1=.15,v1=.008,to=12;function ro(a,u,g){return(u[0]-a[0])*(g[1]-a[1])-(u[1]-a[1])*(g[0]-a[0])}function b1(a){if(a.length<3)return a;const u=[...a].sort((x,k)=>x[0]-k[0]||x[1]-k[1]),g=[];for(const x of u){for(;g.length>=2&&ro(g[g.length-2],g[g.length-1],x)<=0;)g.pop();g.push(x)}const y=[];for(let x=u.length-1;x>=0;x--){const k=u[x];for(;y.length>=2&&ro(y[y.length-2],y[y.length-1],k)<=0;)y.pop();y.push(k)}return g.pop(),y.pop(),g.concat(y)}function k1(a,u){if(a.length<3)return a;let g=0,y=0;for(const[x,k]of a)g+=x,y+=k;return g/=a.length,y/=a.length,a.map(([x,k])=>{const D=x-g,Q=k-y,M=Math.sqrt(D*D+Q*Q);if(M<1e-4)return[x,k];const b=(M+u)/M;return[g+D*b,y+Q*b]})}function C1(a,u,g,y,x){const k=x*x,D=k*x;return[.5*(2*u[0]+(-a[0]+g[0])*x+(2*a[0]-5*u[0]+4*g[0]-y[0])*k+(-a[0]+3*u[0]-3*g[0]+y[0])*D),.5*(2*u[1]+(-a[1]+g[1])*x+(2*a[1]-5*u[1]+4*g[1]-y[1])*k+(-a[1]+3*u[1]-3*g[1]+y[1])*D)]}function E1(a){if(a.length<3)return a;const u=[],g=a.length;for(let y=0;y<g;y++){const x=a[(y-1+g)%g],k=a[y],D=a[(y+1)%g],Q=a[(y+2)%g];for(let M=0;M<to;M++)u.push(C1(x,k,D,Q,M/to))}return u}function S1(a){let u=b1(a);if(u.length<3)return null;u=k1(u,v1);const g=E1(u);return{type:"Polygon",coordinates:[[...g,g[0]]]}}function M1(a,u,g,y){const x=[];for(const[k,D]of a.communities){const Q=[];for(const b of D){const T=u.get(b);T&&Q.push([T[1],T[0]])}if(Q.length<y1)continue;let M=d1(Q,{bandwidth:g,threshold:y});M||(M=S1(Q)),M&&x.push({type:"Feature",properties:{community:k,color:Eu(k),borderColor:Cu(k),nodeCount:D.length},geometry:M})}return{type:"FeatureCollection",features:x}}function B1({partition:a,nodeCoordinates:u,visible:g,opacity:y=.7,bandwidth:x=x1,threshold:k=w1,strokeWidth:D=2}){const Q=R.useMemo(()=>a?M1(a,u,x,k):{type:"FeatureCollection",features:[]},[a,u,x,k]),M=g?y:0,b={"fill-color":["get","color"],"fill-opacity":M},T={"line-color":["get","borderColor"],"line-width":D,"line-opacity":M};return m.jsxs(Vr,{id:m1,type:"geojson",data:Q,children:[m.jsx(Zt,{id:p1,type:"fill",paint:b}),m.jsx(Zt,{id:g1,type:"line",paint:T})]})}function D1(a,u=!1,g=!1,y=!1,x=.7,k){const D=Bo(k);return y?x>=.75?D.restBright:D.rest:x>=.85?D.rest:(x>=.7,D.restDim)}function no(a){return[a[1],a[0]]}function _1(a,u,g,y=12){const[x,k]=a,[D,Q]=u,M=[];for(let b=0;b<=y;b++){const T=b/y,O=k+(Q-k)*T,z=x+(D-x)*T,W=4*g*T*(1-T);M.push([O,z,W])}return M}function so(a,u,g,y,x,k,D,Q,M,b,T,O="dark"){const z=Ks(),W=[];let V=1/0,J=-1/0;const iA=[];for(const Z of a){const aA=Z.edge.avgConfidence??(u?.7:.5),cA=Z.edge.certainCount/Math.max(D,1),RA=aA*.7+cA*.3+(u?.5:0);iA.push({polyline:Z,brightnessScore:RA}),V=Math.min(V,RA),J=Math.max(J,RA)}if(iA.length===0)return{type:"FeatureCollection",features:[]};const eA=J-V||1;iA.sort((Z,aA)=>Z.brightnessScore-aA.brightnessScore);for(const{polyline:Z,brightnessScore:aA}of iA){const{from:cA,to:RA,edge:sA}=Z,lA=g.get(sA.key)??0;if(lA<=0)continue;const BA=Q.has(sA.key),SA=M.has(sA.key),bA=sA.avgConfidence??(u?.7:.5),kA=b===sA.key,vA=T[sA.fromHash],FA=T[sA.toHash],IA=(vA==null?void 0:vA.node_name)||(vA==null?void 0:vA.name)||sA.fromHash.slice(0,8),WA=(FA==null?void 0:FA.node_name)||(FA==null?void 0:FA.name)||sA.toHash.slice(0,8),wA=[cA[0]+(RA[0]-cA[0])*lA,cA[1]+(RA[1]-cA[1])*lA];let uA;if(!u)uA=1.5;else{const de=k.get(sA.key)??js(sA.certainCount),ZA=x.get(sA.key)??de;uA=ZA+(de-ZA)*y,kA?uA=Math.max(uA*1.6,4.5):SA&&(uA=uA*1.3)}let dA;kA?dA=z.edges.highlight:dA=D1(!1,sA.isDirectPathEdge??!1,BA,SA,bA,O);let jA;kA?jA=z.edges.highlight:sA.isDirectPathEdge?jA=z.edges.hoverDirect:BA?jA=z.edges.hoverLoop:jA=z.edges.hoverStandard;let LA;if(!u)LA=(.3+bA*.3)*lA;else{const de=Math.min(lA*1.5,1)*z.edgeOpacity;LA=SA?de*1.15:de}kA&&(LA=.95);const zA=(aA-V)/eA;W.push({type:"Feature",properties:{key:sA.key,baseColor:dA,hoverColor:jA,baseWidth:uA,baseOpacity:LA,brightnessScore:zA,isLoopEdge:BA,isBackbone:SA,isDirectPath:sA.isDirectPathEdge??!1,isHubConnection:sA.isHubConnection??!1,isZeroHop:sA.isZeroHop??!1,isValidated:u,certainCount:sA.certainCount,confidence:bA,symmetryRatio:sA.symmetryRatio??1,dominantDirection:sA.dominantDirection??"balanced",fromName:IA,toName:WA,fromHash:sA.fromHash,toHash:sA.toHash},geometry:{type:"LineString",coordinates:[no(cA),no(wA)]}})}return{type:"FeatureCollection",features:W}}const j1=150,R1=8;function io(a,u){const g=Ks(),y=[];let x=0;for(const k of a){const D=u.get(k.hash);D&&D.blendedScore>x&&(x=D.blendedScore)}for(const k of a){const{from:D,to:Q,hash:M,neighbor:b,lastHopData:T}=k,O=`neighbor-${M}`,z=(T==null?void 0:T.avgRssi)??b.rssi??null,W=(T==null?void 0:T.avgSnr)??b.snr??null,V=(T==null?void 0:T.count)??0,J=(T==null?void 0:T.confidence)??1,iA=u.get(M),eA=(iA==null?void 0:iA.listenerScore)??0,Z=(iA==null?void 0:iA.loudScore)??0,aA=(iA==null?void 0:iA.blendedScore)??0,cA=x>0?aA/x:0,RA=k.rxAdvertCount??0,sA=k.txProxyCount??0,lA=RA+sA,BA=lA>0?(sA-RA)/lA:0,SA=_1(D,Q,j1,R1);y.push({type:"Feature",properties:{key:O,hash:M,name:b.node_name||b.name||M.slice(0,8),prefix:M.slice(2,4).toUpperCase(),color:g.neighborColor,width:2.5,opacity:.85,rssi:z,snr:W,packetCount:V,confidence:J,hasAvgRssi:(T==null?void 0:T.avgRssi)!==void 0,hasAvgSnr:(T==null?void 0:T.avgSnr)!==void 0,isNeighborEdge:!0,listenerScore:eA,loudScore:Z,blendedScore:aA,trafficWeight:cA,linkAsymmetry:BA,rxAdvertCount:RA,txProxyCount:sA},geometry:{type:"LineString",coordinates:SA}})}return{type:"FeatureCollection",features:y}}function T1({map:a,showTopology:u,validatedPolylines:g,weakPolylines:y,maxCertainCount:x,loopEdgeKeys:k,backboneEdgeKeys:D,highlightedEdgeKey:Q,neighbors:M,validatedSourceId:b,weakSourceId:T,neighborPolylines:O=[],showNeighborLines:z=!0,neighborSourceId:W,neighborLinkScores:V=new Map,basemapMode:J}){const iA=R.useRef(null);R.useEffect(()=>{const pe=a&&"current"in a?a.current:a;iA.current=pe});const eA=R.useRef(new Map),Z=R.useRef(1),aA=R.useRef(new Map),cA=R.useRef(new Map),RA=R.useRef(!1),sA=R.useRef(null),lA=R.useRef(u),BA=R.useRef(new Set),SA=R.useRef(""),bA=R.useRef(new Map),kA=R.useRef(""),vA=R.useRef(""),FA=R.useRef(""),IA=R.useRef(g),WA=R.useRef(y),wA=R.useRef(x),uA=R.useRef(k),dA=R.useRef(D),jA=R.useRef(Q),LA=R.useRef(M),zA=R.useRef(O),de=R.useRef(z),ZA=R.useRef(V),KA=R.useRef(J);R.useEffect(()=>{IA.current=g,WA.current=y,wA.current=x,uA.current=k,dA.current=D,jA.current=Q,LA.current=M,zA.current=O,de.current=z,ZA.current=V,KA.current=J},[g,y,x,k,D,Q,M,O,z,V,J]);const VA=R.useCallback((pe=!1)=>{var fe,Pe,te,Ke,$e,At,it,St,Ve,We;const ce=iA.current;if(!ce)return;const Me=ce.getSource(b),Ie=ce.getSource(T),Le=ce.getSource(W);if(Me){const ke=so(IA.current,!0,eA.current,Z.current,aA.current,cA.current,wA.current,uA.current,dA.current,jA.current,LA.current,KA.current),Ze=`${ke.features.length}:${((Pe=(fe=ke.features[0])==null?void 0:fe.properties)==null?void 0:Pe.key)??""}:${((Ke=(te=ke.features[ke.features.length-1])==null?void 0:te.properties)==null?void 0:Ke.key)??""}:${Array.from(eA.current.values()).reduce((at,Bt)=>at+Bt,0).toFixed(2)}`;(pe||Ze!==kA.current)&&(Me.setData(ke),kA.current=Ze)}if(Ie){const ke=so(WA.current,!1,eA.current,Z.current,aA.current,cA.current,wA.current,uA.current,dA.current,jA.current,LA.current,KA.current),Ze=`${ke.features.length}:${((At=($e=ke.features[0])==null?void 0:$e.properties)==null?void 0:At.key)??""}:${((St=(it=ke.features[ke.features.length-1])==null?void 0:it.properties)==null?void 0:St.key)??""}`;(pe||Ze!==vA.current)&&(Ie.setData(ke),vA.current=Ze)}if(Le&&zA.current.length>0){const ke=io(zA.current,ZA.current),Ze=`${ke.features.length}:${((We=(Ve=ke.features[0])==null?void 0:Ve.properties)==null?void 0:We.hash)??""}`;(pe||Ze!==FA.current)&&(Le.setData(ke),FA.current=Ze)}},[b,T,W]),Te=R.useCallback(()=>{sA.current&&(cancelAnimationFrame(sA.current),sA.current=null),eA.current=new Map,Z.current=1,aA.current=new Map,cA.current=new Map,RA.current=!1,BA.current=new Set,SA.current="",bA.current=new Map},[]);R.useEffect(()=>{const pe=lA.current,ce=u;if(lA.current=u,!!iA.current){if(sA.current&&(cancelAnimationFrame(sA.current),sA.current=null),pe&&!ce&&!RA.current){RA.current=!0;const Ie=new Map(eA.current);let Le=null;const fe=Pe=>{Le||(Le=Pe);const te=Pe-Le,Ke=Math.min(te/Qc,1),$e=Al(Ke);for(const[At,it]of Ie)eA.current.set(At,it*(1-$e));VA(!0),Ke<1?sA.current=requestAnimationFrame(fe):(RA.current=!1,eA.current=new Map,BA.current=new Set,SA.current="",aA.current=new Map,cA.current=new Map,sA.current=null,VA(!0))};sA.current=requestAnimationFrame(fe)}!pe&&ce&&(eA.current=new Map,BA.current=new Set,SA.current="")}},[u,VA]),R.useEffect(()=>{const pe=iA.current;if(!u||RA.current||!pe)return;const ce=[...g,...y],Me=ce.map(te=>`${te.edge.key}:${te.edge.certainCount}`).sort().join(","),Ie=BA.current.size===0,Le=SA.current!==""&&SA.current!==Me;if(!Ie&&!Le){VA();return}const fe=[],Pe=[];for(const{edge:te}of ce)BA.current.has(te.key)?Pe.push(te.key):fe.push(te.key);Le&&Pe.length>0&&(aA.current=new Map(bA.current),Z.current=0),cA.current=new Map;for(const{edge:te}of g){const Ke=js(te.certainCount);cA.current.set(te.key,Ke)}for(const te of fe)eA.current.set(te,0);for(const te of Pe)eA.current.has(te)||eA.current.set(te,1);if(fe.length>0||Le&&Pe.length>0){sA.current&&(cancelAnimationFrame(sA.current),sA.current=null);let te=null;const Ke=Math.min(100,R0/Math.max(fe.length,1)/2),$e=At=>{te||(te=At);const it=At-te;for(let Ve=0;Ve<fe.length;Ve++){const We=fe[Ve],ke=Ve*Ke,Ze=Math.max(0,it-ke),at=Math.min(Ze/R0,1);eA.current.set(We,Ds(at))}if(Le&&Pe.length>0){const Ve=Math.min(it/R0,1);Z.current=Ds(Ve)}VA(!0);const St=R0+(fe.length-1)*Ke;it<St?sA.current=requestAnimationFrame($e):sA.current=null};sA.current=requestAnimationFrame($e)}else VA();for(const te of fe)BA.current.add(te);for(const{edge:te}of g){const Ke=js(te.certainCount);bA.current.set(te.key,Ke)}SA.current=Me},[u,g,y,x,VA]),R.useEffect(()=>{const pe=iA.current;if(!pe||!W)return;const ce=()=>{const Le=pe.getSource(W);if(!Le)return!1;if(O.length>0){const fe=io(O,V);Le.setData(fe)}else Le.setData({type:"FeatureCollection",features:[]});return!0};if(ce())return;const Me=Le=>{Le.sourceId===W&&ce()&&pe.off("sourcedata",Me)};pe.on("sourcedata",Me);const Ie=()=>{ce()&&(pe.off("styledata",Ie),pe.off("sourcedata",Me))};return pe.on("styledata",Ie),()=>{pe.off("sourcedata",Me),pe.off("styledata",Ie)}},[W,O,V]);const _e=R.useRef(J);return R.useEffect(()=>{J!==_e.current&&(_e.current=J,kA.current="",vA.current="",FA.current="",VA(!0))},[J,VA]),R.useEffect(()=>()=>{sA.current&&(cancelAnimationFrame(sA.current),sA.current=null)},[]),{isExiting:RA.current,isAnimating:sA.current!==null,resetAnimationState:Te,weightAnimProgress:Z.current,animStartWeights:aA.current,animTargetWeights:cA.current}}function I1({activeFilters:a,neighborHashes:u,hubConnectedNodes:g,directNodeSet:y,localConnectedNodes:x,nodeTypeMap:k,showTopology:D}){const[Q,M]=R.useState(new Map),b=R.useMemo(()=>[...a].sort().join(","),[a]),T=R.useRef(b),O=R.useRef(!1),z=R.useRef(new Map),W=R.useRef(null),V=R.useRef(g),J=R.useRef(y),iA=R.useRef(x),eA=R.useRef(k),Z=R.useRef(D);return R.useEffect(()=>{V.current=g,J.current=y,iA.current=x,eA.current=k,Z.current=D},[g,y,x,k,D]),R.useEffect(()=>{const cA=T.current,RA=b;if(T.current=b,cA===RA)return;W.current&&(cancelAnimationFrame(W.current),W.current=null);const sA=new Set(cA?cA.split(",").filter(Boolean):[]),lA=a,BA=V.current,SA=J.current,bA=eA.current;for(const wA of u)z.current.has(wA)||z.current.set(wA,Math.random());const kA=(wA,uA)=>{if(uA.size===0)return!1;const dA=bA.get(wA)??"unknown";return!!(uA.has("repeater")&&dA==="repeater"||uA.has("companion")&&(dA==="companion"||dA==="unknown")||uA.has("room_server")&&dA==="room_server"||uA.has("direct")&&SA.has(wA)||uA.has("hubs")&&BA.has(wA))},vA=[];for(const wA of u){const uA=kA(wA,sA),dA=kA(wA,lA);uA!==dA&&vA.push({hash:wA,startOpacity:uA?1:0,targetOpacity:dA?1:0})}if(vA.length===0)return;O.current=!0,M(wA=>{const uA=new Map(wA);for(const{hash:dA,startOpacity:jA}of vA)uA.set(dA,jA);return uA});const FA=vA;let IA=null;const WA=wA=>{IA||(IA=wA);const uA=wA-IA;let dA=!0;M(()=>{const LA=new Map;for(const{hash:zA,startOpacity:de,targetOpacity:ZA}of FA){const KA=(z.current.get(zA)??0)*Ri,VA=Math.max(0,uA-KA),Te=Math.min(VA/ji,1),_e=Ds(Te),pe=de+(ZA-de)*_e;LA.set(zA,pe),Te<1&&(dA=!1)}return LA});const jA=ji+Ri;uA<jA&&!dA?W.current=requestAnimationFrame(WA):(W.current=null,O.current=!1,M(new Map))};return W.current=requestAnimationFrame(WA),()=>{W.current&&(cancelAnimationFrame(W.current),W.current=null),O.current=!1}},[b,a,u]),{nodeOpacities:Q,getNodeOpacity:(cA,RA)=>O.current&&Q.has(cA)?Q.get(cA):RA?1:0}}const Cs=240,oo=240;function L1(a,u){if(a<Cs)return .5;if(a<Cs+oo)return 1;const g=Cs+oo,y=u-g,x=(a-g)/y;return Math.max(0,.33*(1-x))}function N1(a){return Wa(Object.keys(a).map(u=>[u,u]))}function F1(a,u,g){const y=g?Mr(g):null,x=[];for(const k of a){if(y&&Ho(k.toUpperCase(),y)){g&&x.push(g);continue}const D=u.get(k.toUpperCase());D&&x.push(D)}return x}function P1({neighbors:a,localHash:u,enabled:g=!0}){const[y,x]=R.useState(new Map),k=Rs(),D=R.useRef(k);R.useEffect(()=>{D.current=k},[k]);const Q=R.useRef(0),M=R.useRef(null),b=R.useRef(new Map),T=R.useRef(new Map);R.useEffect(()=>{T.current=N1(a)},[a]);const O=R.useRef(null);return R.useEffect(()=>{const z=()=>{const W=performance.now(),V=b.current;if(V.size===0){M.current=null,x(new Map);return}const J=new Map,iA=[];for(const[eA,{startTime:Z,staggerDelay:aA}]of V){const cA=W-Z-aA;if(!(cA<0))if(cA>=T0)iA.push(eA);else{const RA=L1(cA,T0);RA>0&&J.set(eA,RA)}}for(const eA of iA)V.delete(eA);x(J),V.size>0&&O.current?M.current=requestAnimationFrame(O.current):M.current=null};O.current=z},[]),R.useEffect(()=>{if(!g)return;const z=D.current;if(z.length===0)return;const W=Q.current,V=z.filter(Z=>(Z.timestamp??0)>W);if(W===0){const Z=z.reduce((aA,cA)=>Math.max(aA,cA.timestamp??0),0);Q.current=Z;return}if(V.length===0)return;const J=V.reduce((Z,aA)=>Math.max(Z,aA.timestamp??0),0);Q.current=J;const iA=performance.now();let eA=0;for(const Z of V){const aA=zo(Z,u);if(!aA||aA.original.length===0)continue;const cA=F1(aA.original,T.current,u);if(cA.length===0)continue;const RA=T0*.5;for(let sA=0;sA<cA.length;sA++){const lA=cA[sA];b.current.has(lA)||b.current.set(lA,{startTime:iA,staggerDelay:eA+sA*RA})}eA+=T0*.3}M.current===null&&O.current&&(M.current=requestAnimationFrame(O.current))},[k,u,g]),R.useEffect(()=>()=>{M.current!==null&&(cancelAnimationFrame(M.current),M.current=null)},[]),{blinkingNodes:y,blinkColor:Pc}}const rn="edge-blink-source",kn="edge-blink-layer",Fs=1e3,Ps=1e3,Es=150,Q1=175,O1=3e4,z1=ur.teal,H1="#8B7BAD",G1=2.5,U1=1.875,V1=.5,Z0="node-markers-layer";function W1(a){if(!a.getLayer(kn))return;const u=a.getLayer(Z0)?Z0:void 0;try{a.moveLayer(kn,u)}catch{}}function Y1(a,u){const g=new Map;for(const y of Object.keys(a)){const x=Mr(y);g.has(x)||g.set(x,y)}if(u){const y=Mr(u);g.set(y,u)}return g}function K1(a){return a<0||a>=Fs?0:1-a/Fs}function $1(a){if(a<0||a>=Ps)return 0;const u=a/Ps;return Math.pow(1-u,3)}function H0(a){return[a[1],a[0]]}function Z1({map:a,nodeCoordinates:u,packets:g,localHash:y,neighbors:x,meshTopology:k,enabled:D=!0}){const Q=R.useRef(null),M=a&&"current"in a?a.current:a;R.useEffect(()=>{Q.current=M},[M]);const b=R.useRef(!1),T=R.useRef(null),O=R.useRef([]),z=R.useRef(0),W=R.useRef(!1),[V,J]=R.useState(!1),iA=R.useRef(null),eA=R.useRef([]),Z=R.useRef(new Map),aA=R.useRef(u);R.useEffect(()=>{aA.current=u},[u]),R.useEffect(()=>{Z.current=Y1(x,y)},[x,y]),R.useEffect(()=>{if(!D){iA.current&&(clearTimeout(iA.current),iA.current=null),eA.current=[],T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),O.current=[];const lA=Q.current;if(lA&&b.current){const BA=lA.getSource(rn);BA&&BA.setData({type:"FeatureCollection",features:[]})}W.current=!1,z.current=0}},[D]),R.useEffect(()=>{const lA=M;if(!lA)return;let BA=null,SA=!1;const bA=()=>{if(!SA&&!b.current)try{lA.getLayer(kn)&&lA.removeLayer(kn),lA.getSource(rn)&&lA.removeSource(rn),lA.addSource(rn,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const kA=lA.getLayer(Z0)?Z0:void 0;lA.addLayer({id:kn,type:"line",source:rn,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],H1,z1],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],U1,G1],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},kA),b.current=!0,J(!0),BA&&(clearInterval(BA),BA=null)}catch{}};return lA.isStyleLoaded()&&bA(),lA.once("style.load",()=>{bA()}),b.current||(BA=setInterval(()=>{if(b.current){BA&&clearInterval(BA);return}bA()},100),setTimeout(()=>{BA&&(clearInterval(BA),BA=null)},5e3)),()=>{SA=!0,BA&&clearInterval(BA),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null);const kA=Q.current;if(kA&&b.current){try{kA.getLayer(kn)&&kA.removeLayer(kn),kA.getSource(rn)&&kA.removeSource(rn)}catch{}b.current=!1,J(!1)}}},[M]);const cA=R.useRef(()=>{});R.useEffect(()=>{cA.current=()=>{const lA=Q.current;if(!lA)return;const BA=lA.getSource(rn);if(!BA)return;const SA=performance.now(),bA=O.current,kA=[],vA=[];for(const FA of bA){const IA=SA-FA.startTime-FA.delay,WA=FA.isSpeculative?Ps:Fs;if(IA<WA){vA.push(FA);const wA=FA.isSpeculative?$1(IA):K1(IA);wA>0&&kA.push({type:"Feature",properties:{intensity:wA,opacityMult:FA.isSpeculative?V1:1,isSpeculative:FA.isSpeculative??!1},geometry:{type:"LineString",coordinates:[FA.fromCoord,FA.toCoord]}})}}BA.setData({type:"FeatureCollection",features:kA}),O.current=vA,vA.length>0?T.current=requestAnimationFrame(()=>cA.current()):T.current=null}},[]);const RA=R.useCallback(()=>{const lA=Q.current;lA&&W1(lA),T.current===null&&(T.current=requestAnimationFrame(()=>cA.current()))},[]),sA=R.useCallback(()=>{if(!Q.current||!b.current)return;const BA=eA.current;if(eA.current=[],iA.current=null,BA.length===0)return;const SA=Z.current,bA=aA.current;if(SA.size===0)return;const kA=performance.now();let vA=0,FA=!1;const IA=new Set;for(const WA of BA){const wA=zo(WA,y);if(!wA||wA.original.length<2)continue;const uA=wA.original;let dA=0,jA=null;for(let ZA=0;ZA<uA.length-1;ZA++){const KA=uA[ZA].toUpperCase(),VA=uA[ZA+1].toUpperCase(),Te=SA.get(KA),_e=SA.get(VA);if(!Te||!_e)continue;const pe=bA.get(Te),ce=bA.get(_e);if(!pe||!ce)continue;const Me=[Te,_e].sort().join("-");O.current.push({edgeKey:Me,fromCoord:H0(pe),toCoord:H0(ce),startTime:kA,delay:vA+dA*Es}),IA.add(Me),jA=_e,dA++,FA=!0}const LA=WA.route??WA.route_type;if(Ya(LA)&&jA&&!(jA===y)&&(k!=null&&k.edgeMap)){const ZA=[];for(const[KA,VA]of k.edgeMap){if(!(VA.fromHash===jA||VA.toHash===jA)||IA.has(KA))continue;const _e=VA.fromHash===jA?VA.toHash:VA.fromHash,pe=bA.get(jA),ce=bA.get(_e);!pe||!ce||ZA.push({edgeKey:KA,otherHash:_e,confidence:VA.avgConfidence??0})}if(ZA.length>0){ZA.sort((_e,pe)=>pe.confidence-_e.confidence);const KA=Math.max(1,Math.ceil(ZA.length*.25)),VA=ZA.slice(0,KA),Te=vA+dA*Es;for(const{edgeKey:_e,otherHash:pe}of VA){const ce=bA.get(jA),Me=bA.get(pe);O.current.push({edgeKey:_e,fromCoord:H0(ce),toCoord:H0(Me),startTime:kA,delay:Te,isSpeculative:!0}),IA.add(_e),FA=!0}}}dA>0&&(vA+=dA*Es*.5)}FA&&RA()},[y,k,RA]);R.useEffect(()=>{const lA=Q.current;if(!D||!lA||!V||g.length===0)return;const BA=Date.now(),SA=z.current;if(!W.current){W.current=!0;const vA=(BA-O1)/1e3,FA=g.filter(WA=>(WA.timestamp??0)>=vA);let IA=0;for(const WA of g){const wA=WA.timestamp??0;wA>IA&&(IA=wA)}if(z.current=IA,FA.length>0){FA.sort((wA,uA)=>(wA.timestamp??0)-(uA.timestamp??0));const WA=FA.slice(-20);eA.current.push(...WA),sA()}return}const bA=g.filter(vA=>(vA.timestamp??0)>SA);if(bA.length===0)return;let kA=0;for(const vA of bA){const FA=vA.timestamp??0;FA>kA&&(kA=FA)}z.current=kA,eA.current.push(...bA),iA.current&&clearTimeout(iA.current),iA.current=setTimeout(sA,Q1)},[D,g,sA,V]),R.useEffect(()=>()=>{iA.current&&clearTimeout(iA.current)},[])}var nn={},wn={};/**
 * @license React
 * react-dom-server-legacy.browser.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var lo;function q1(){if(lo)return wn;lo=1;var a=Go();function u(h){for(var v="https://reactjs.org/docs/error-decoder.html?invariant="+h,j=1;j<arguments.length;j++)v+="&args[]="+encodeURIComponent(arguments[j]);return"Minified React error #"+h+"; visit "+v+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var g=Object.prototype.hasOwnProperty,y=/^[: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]*$/,x={},k={};function D(h){return g.call(k,h)?!0:g.call(x,h)?!1:y.test(h)?k[h]=!0:(x[h]=!0,!1)}function Q(h,v,j,P,X,K,fA){this.acceptsBooleans=v===2||v===3||v===4,this.attributeName=P,this.attributeNamespace=X,this.mustUseProperty=j,this.propertyName=h,this.type=v,this.sanitizeURL=K,this.removeEmptyString=fA}var M={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(h){M[h]=new Q(h,0,!1,h,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(h){var v=h[0];M[v]=new Q(v,1,!1,h[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(h){M[h]=new Q(h,2,!1,h.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(h){M[h]=new Q(h,2,!1,h,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(h){M[h]=new Q(h,3,!1,h.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(h){M[h]=new Q(h,3,!0,h,null,!1,!1)}),["capture","download"].forEach(function(h){M[h]=new Q(h,4,!1,h,null,!1,!1)}),["cols","rows","size","span"].forEach(function(h){M[h]=new Q(h,6,!1,h,null,!1,!1)}),["rowSpan","start"].forEach(function(h){M[h]=new Q(h,5,!1,h.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function T(h){return h[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(h){var v=h.replace(b,T);M[v]=new Q(v,1,!1,h,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(h){var v=h.replace(b,T);M[v]=new Q(v,1,!1,h,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(h){var v=h.replace(b,T);M[v]=new Q(v,1,!1,h,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(h){M[h]=new Q(h,1,!1,h.toLowerCase(),null,!1,!1)}),M.xlinkHref=new Q("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(h){M[h]=new Q(h,1,!1,h.toLowerCase(),null,!0,!0)});var O={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},z=["Webkit","ms","Moz","O"];Object.keys(O).forEach(function(h){z.forEach(function(v){v=v+h.charAt(0).toUpperCase()+h.substring(1),O[v]=O[h]})});var W=/["'&<>]/;function V(h){if(typeof h=="boolean"||typeof h=="number")return""+h;h=""+h;var v=W.exec(h);if(v){var j="",P,X=0;for(P=v.index;P<h.length;P++){switch(h.charCodeAt(P)){case 34:v="&quot;";break;case 38:v="&amp;";break;case 39:v="&#x27;";break;case 60:v="&lt;";break;case 62:v="&gt;";break;default:continue}X!==P&&(j+=h.substring(X,P)),X=P+1,j+=v}h=X!==P?j+h.substring(X,P):j}return h}var J=/([A-Z])/g,iA=/^ms-/,eA=Array.isArray;function Z(h,v){return{insertionMode:h,selectedValue:v}}function aA(h,v,j){switch(v){case"select":return Z(1,j.value!=null?j.value:j.defaultValue);case"svg":return Z(2,null);case"math":return Z(3,null);case"foreignObject":return Z(1,null);case"table":return Z(4,null);case"thead":case"tbody":case"tfoot":return Z(5,null);case"colgroup":return Z(7,null);case"tr":return Z(6,null)}return 4<=h.insertionMode||h.insertionMode===0?Z(1,null):h}var cA=new Map;function RA(h,v,j){if(typeof j!="object")throw Error(u(62));v=!0;for(var P in j)if(g.call(j,P)){var X=j[P];if(X!=null&&typeof X!="boolean"&&X!==""){if(P.indexOf("--")===0){var K=V(P);X=V((""+X).trim())}else{K=P;var fA=cA.get(K);fA!==void 0||(fA=V(K.replace(J,"-$1").toLowerCase().replace(iA,"-ms-")),cA.set(K,fA)),K=fA,X=typeof X=="number"?X===0||g.call(O,P)?""+X:X+"px":V((""+X).trim())}v?(v=!1,h.push(' style="',K,":",X)):h.push(";",K,":",X)}}v||h.push('"')}function sA(h,v,j,P){switch(j){case"style":RA(h,v,P);return;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<j.length)||j[0]!=="o"&&j[0]!=="O"||j[1]!=="n"&&j[1]!=="N"){if(v=M.hasOwnProperty(j)?M[j]:null,v!==null){switch(typeof P){case"function":case"symbol":return;case"boolean":if(!v.acceptsBooleans)return}switch(j=v.attributeName,v.type){case 3:P&&h.push(" ",j,'=""');break;case 4:P===!0?h.push(" ",j,'=""'):P!==!1&&h.push(" ",j,'="',V(P),'"');break;case 5:isNaN(P)||h.push(" ",j,'="',V(P),'"');break;case 6:!isNaN(P)&&1<=P&&h.push(" ",j,'="',V(P),'"');break;default:v.sanitizeURL&&(P=""+P),h.push(" ",j,'="',V(P),'"')}}else if(D(j)){switch(typeof P){case"function":case"symbol":return;case"boolean":if(v=j.toLowerCase().slice(0,5),v!=="data-"&&v!=="aria-")return}h.push(" ",j,'="',V(P),'"')}}}function lA(h,v,j){if(v!=null){if(j!=null)throw Error(u(60));if(typeof v!="object"||!("__html"in v))throw Error(u(61));v=v.__html,v!=null&&h.push(""+v)}}function BA(h){var v="";return a.Children.forEach(h,function(j){j!=null&&(v+=j)}),v}function SA(h,v,j,P){h.push(vA(j));var X=j=null,K;for(K in v)if(g.call(v,K)){var fA=v[K];if(fA!=null)switch(K){case"children":j=fA;break;case"dangerouslySetInnerHTML":X=fA;break;default:sA(h,P,K,fA)}}return h.push(">"),lA(h,X,j),typeof j=="string"?(h.push(V(j)),null):j}var bA=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,kA=new Map;function vA(h){var v=kA.get(h);if(v===void 0){if(!bA.test(h))throw Error(u(65,h));v="<"+h,kA.set(h,v)}return v}function FA(h,v,j,P,X){switch(v){case"select":h.push(vA("select"));var K=null,fA=null;for(he in j)if(g.call(j,he)){var _A=j[he];if(_A!=null)switch(he){case"children":K=_A;break;case"dangerouslySetInnerHTML":fA=_A;break;case"defaultValue":case"value":break;default:sA(h,P,he,_A)}}return h.push(">"),lA(h,fA,K),K;case"option":fA=X.selectedValue,h.push(vA("option"));var XA=_A=null,Ae=null,he=null;for(K in j)if(g.call(j,K)){var Oe=j[K];if(Oe!=null)switch(K){case"children":_A=Oe;break;case"selected":Ae=Oe;break;case"dangerouslySetInnerHTML":he=Oe;break;case"value":XA=Oe;default:sA(h,P,K,Oe)}}if(fA!=null)if(j=XA!==null?""+XA:BA(_A),eA(fA)){for(P=0;P<fA.length;P++)if(""+fA[P]===j){h.push(' selected=""');break}}else""+fA===j&&h.push(' selected=""');else Ae&&h.push(' selected=""');return h.push(">"),lA(h,he,_A),_A;case"textarea":h.push(vA("textarea")),he=fA=K=null;for(_A in j)if(g.call(j,_A)&&(XA=j[_A],XA!=null))switch(_A){case"children":he=XA;break;case"value":K=XA;break;case"defaultValue":fA=XA;break;case"dangerouslySetInnerHTML":throw Error(u(91));default:sA(h,P,_A,XA)}if(K===null&&fA!==null&&(K=fA),h.push(">"),he!=null){if(K!=null)throw Error(u(92));if(eA(he)&&1<he.length)throw Error(u(93));K=""+he}return typeof K=="string"&&K[0]===`
`&&h.push(`
`),K!==null&&h.push(V(""+K)),null;case"input":h.push(vA("input")),XA=he=_A=K=null;for(fA in j)if(g.call(j,fA)&&(Ae=j[fA],Ae!=null))switch(fA){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,"input"));case"defaultChecked":XA=Ae;break;case"defaultValue":_A=Ae;break;case"checked":he=Ae;break;case"value":K=Ae;break;default:sA(h,P,fA,Ae)}return he!==null?sA(h,P,"checked",he):XA!==null&&sA(h,P,"checked",XA),K!==null?sA(h,P,"value",K):_A!==null&&sA(h,P,"value",_A),h.push("/>"),null;case"menuitem":h.push(vA("menuitem"));for(var ht in j)if(g.call(j,ht)&&(K=j[ht],K!=null))switch(ht){case"children":case"dangerouslySetInnerHTML":throw Error(u(400));default:sA(h,P,ht,K)}return h.push(">"),null;case"title":h.push(vA("title")),K=null;for(Oe in j)if(g.call(j,Oe)&&(fA=j[Oe],fA!=null))switch(Oe){case"children":K=fA;break;case"dangerouslySetInnerHTML":throw Error(u(434));default:sA(h,P,Oe,fA)}return h.push(">"),K;case"listing":case"pre":h.push(vA(v)),fA=K=null;for(XA in j)if(g.call(j,XA)&&(_A=j[XA],_A!=null))switch(XA){case"children":K=_A;break;case"dangerouslySetInnerHTML":fA=_A;break;default:sA(h,P,XA,_A)}if(h.push(">"),fA!=null){if(K!=null)throw Error(u(60));if(typeof fA!="object"||!("__html"in fA))throw Error(u(61));j=fA.__html,j!=null&&(typeof j=="string"&&0<j.length&&j[0]===`
`?h.push(`
`,j):h.push(""+j))}return typeof K=="string"&&K[0]===`
`&&h.push(`
`),K;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":h.push(vA(v));for(var _t in j)if(g.call(j,_t)&&(K=j[_t],K!=null))switch(_t){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,v));default:sA(h,P,_t,K)}return h.push("/>"),null;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 SA(h,j,v,P);case"html":return X.insertionMode===0&&h.push("<!DOCTYPE html>"),SA(h,j,v,P);default:if(v.indexOf("-")===-1&&typeof j.is!="string")return SA(h,j,v,P);h.push(vA(v)),fA=K=null;for(Ae in j)if(g.call(j,Ae)&&(_A=j[Ae],_A!=null))switch(Ae){case"children":K=_A;break;case"dangerouslySetInnerHTML":fA=_A;break;case"style":RA(h,P,_A);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:D(Ae)&&typeof _A!="function"&&typeof _A!="symbol"&&h.push(" ",Ae,'="',V(_A),'"')}return h.push(">"),lA(h,fA,K),K}}function IA(h,v,j){if(h.push('<!--$?--><template id="'),j===null)throw Error(u(395));return h.push(j),h.push('"></template>')}function WA(h,v,j,P){switch(j.insertionMode){case 0:case 1:return h.push('<div hidden id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 2:return h.push('<svg aria-hidden="true" style="display:none" id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 3:return h.push('<math aria-hidden="true" style="display:none" id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 4:return h.push('<table hidden id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 5:return h.push('<table hidden><tbody id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 6:return h.push('<table hidden><tr id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 7:return h.push('<table hidden><colgroup id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');default:throw Error(u(397))}}function wA(h,v){switch(v.insertionMode){case 0:case 1:return h.push("</div>");case 2:return h.push("</svg>");case 3:return h.push("</math>");case 4:return h.push("</table>");case 5:return h.push("</tbody></table>");case 6:return h.push("</tr></table>");case 7:return h.push("</colgroup></table>");default:throw Error(u(397))}}var uA=/[<\u2028\u2029]/g;function dA(h){return JSON.stringify(h).replace(uA,function(v){switch(v){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}function jA(h,v){return v=v===void 0?"":v,{bootstrapChunks:[],startInlineScript:"<script>",placeholderPrefix:v+"P:",segmentPrefix:v+"S:",boundaryPrefix:v+"B:",idPrefix:v,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1,generateStaticMarkup:h}}function LA(h,v,j,P){return j.generateStaticMarkup?(h.push(V(v)),!1):(v===""?h=P:(P&&h.push("<!-- -->"),h.push(V(v)),h=!0),h)}var zA=Object.assign,de=Symbol.for("react.element"),ZA=Symbol.for("react.portal"),KA=Symbol.for("react.fragment"),VA=Symbol.for("react.strict_mode"),Te=Symbol.for("react.profiler"),_e=Symbol.for("react.provider"),pe=Symbol.for("react.context"),ce=Symbol.for("react.forward_ref"),Me=Symbol.for("react.suspense"),Ie=Symbol.for("react.suspense_list"),Le=Symbol.for("react.memo"),fe=Symbol.for("react.lazy"),Pe=Symbol.for("react.scope"),te=Symbol.for("react.debug_trace_mode"),Ke=Symbol.for("react.legacy_hidden"),$e=Symbol.for("react.default_value"),At=Symbol.iterator;function it(h){if(h==null)return null;if(typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case KA:return"Fragment";case ZA:return"Portal";case Te:return"Profiler";case VA:return"StrictMode";case Me:return"Suspense";case Ie:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case pe:return(h.displayName||"Context")+".Consumer";case _e:return(h._context.displayName||"Context")+".Provider";case ce:var v=h.render;return h=h.displayName,h||(h=v.displayName||v.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case Le:return v=h.displayName||null,v!==null?v:it(h.type)||"Memo";case fe:v=h._payload,h=h._init;try{return it(h(v))}catch{}}return null}var St={};function Ve(h,v){if(h=h.contextTypes,!h)return St;var j={},P;for(P in h)j[P]=v[P];return j}var We=null;function ke(h,v){if(h!==v){h.context._currentValue2=h.parentValue,h=h.parent;var j=v.parent;if(h===null){if(j!==null)throw Error(u(401))}else{if(j===null)throw Error(u(401));ke(h,j)}v.context._currentValue2=v.value}}function Ze(h){h.context._currentValue2=h.parentValue,h=h.parent,h!==null&&Ze(h)}function at(h){var v=h.parent;v!==null&&at(v),h.context._currentValue2=h.value}function Bt(h,v){if(h.context._currentValue2=h.parentValue,h=h.parent,h===null)throw Error(u(402));h.depth===v.depth?ke(h,v):Bt(h,v)}function Jt(h,v){var j=v.parent;if(j===null)throw Error(u(402));h.depth===j.depth?ke(h,j):Jt(h,j),v.context._currentValue2=v.value}function Xt(h){var v=We;v!==h&&(v===null?at(h):h===null?Ze(v):v.depth===h.depth?ke(v,h):v.depth>h.depth?Bt(v,h):Jt(v,h),We=h)}var Dr={isMounted:function(){return!1},enqueueSetState:function(h,v){h=h._reactInternals,h.queue!==null&&h.queue.push(v)},enqueueReplaceState:function(h,v){h=h._reactInternals,h.replace=!0,h.queue=[v]},enqueueForceUpdate:function(){}};function Ar(h,v,j,P){var X=h.state!==void 0?h.state:null;h.updater=Dr,h.props=j,h.state=X;var K={queue:[],replace:!1};h._reactInternals=K;var fA=v.contextType;if(h.context=typeof fA=="object"&&fA!==null?fA._currentValue2:P,fA=v.getDerivedStateFromProps,typeof fA=="function"&&(fA=fA(j,X),X=fA==null?X:zA({},X,fA),h.state=X),typeof v.getDerivedStateFromProps!="function"&&typeof h.getSnapshotBeforeUpdate!="function"&&(typeof h.UNSAFE_componentWillMount=="function"||typeof h.componentWillMount=="function"))if(v=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),v!==h.state&&Dr.enqueueReplaceState(h,h.state,null),K.queue!==null&&0<K.queue.length)if(v=K.queue,fA=K.replace,K.queue=null,K.replace=!1,fA&&v.length===1)h.state=v[0];else{for(K=fA?v[0]:h.state,X=!0,fA=fA?1:0;fA<v.length;fA++){var _A=v[fA];_A=typeof _A=="function"?_A.call(h,K,j,P):_A,_A!=null&&(X?(X=!1,K=zA({},K,_A)):zA(K,_A))}h.state=K}else K.queue=null}var on={id:1,overflow:""};function _r(h,v,j){var P=h.id;h=h.overflow;var X=32-gr(P)-1;P&=~(1<<X),j+=1;var K=32-gr(v)+X;if(30<K){var fA=X-X%5;return K=(P&(1<<fA)-1).toString(32),P>>=fA,X-=fA,{id:1<<32-gr(v)+X|j<<X|P,overflow:K+h}}return{id:1<<K|j<<X|P,overflow:h}}var gr=Math.clz32?Math.clz32:Rr,yr=Math.log,jr=Math.LN2;function Rr(h){return h>>>=0,h===0?32:31-(yr(h)/jr|0)|0}function Kr(h,v){return h===v&&(h!==0||1/h===1/v)||h!==h&&v!==v}var ln=typeof Object.is=="function"?Object.is:Kr,gA=null,xr=null,er=null,Se=null,fr=!1,tr=!1,Ye=0,ct=null,hr=0;function kt(){if(gA===null)throw Error(u(321));return gA}function wr(){if(0<hr)throw Error(u(312));return{memoizedState:null,queue:null,next:null}}function dt(){return Se===null?er===null?(fr=!1,er=Se=wr()):(fr=!0,Se=er):Se.next===null?(fr=!1,Se=Se.next=wr()):(fr=!0,Se=Se.next),Se}function tA(){xr=gA=null,tr=!1,er=null,hr=0,Se=ct=null}function yA(h,v){return typeof v=="function"?v(h):v}function TA(h,v,j){if(gA=kt(),Se=dt(),fr){var P=Se.queue;if(v=P.dispatch,ct!==null&&(j=ct.get(P),j!==void 0)){ct.delete(P),P=Se.memoizedState;do P=h(P,j.action),j=j.next;while(j!==null);return Se.memoizedState=P,[P,v]}return[Se.memoizedState,v]}return h=h===yA?typeof v=="function"?v():v:j!==void 0?j(v):v,Se.memoizedState=h,h=Se.queue={last:null,dispatch:null},h=h.dispatch=t.bind(null,gA,h),[Se.memoizedState,h]}function mA(h,v){if(gA=kt(),Se=dt(),v=v===void 0?null:v,Se!==null){var j=Se.memoizedState;if(j!==null&&v!==null){var P=j[1];A:if(P===null)P=!1;else{for(var X=0;X<P.length&&X<v.length;X++)if(!ln(v[X],P[X])){P=!1;break A}P=!0}if(P)return j[0]}}return h=h(),Se.memoizedState=[h,v],h}function t(h,v,j){if(25<=hr)throw Error(u(301));if(h===gA)if(tr=!0,h={action:j,next:null},ct===null&&(ct=new Map),j=ct.get(v),j===void 0)ct.set(v,h);else{for(v=j;v.next!==null;)v=v.next;v.next=h}}function C(){throw Error(u(394))}function xe(){}var Be={readContext:function(h){return h._currentValue2},useContext:function(h){return kt(),h._currentValue2},useMemo:mA,useReducer:TA,useRef:function(h){gA=kt(),Se=dt();var v=Se.memoizedState;return v===null?(h={current:h},Se.memoizedState=h):v},useState:function(h){return TA(yA,h)},useInsertionEffect:xe,useLayoutEffect:function(){},useCallback:function(h,v){return mA(function(){return h},v)},useImperativeHandle:xe,useEffect:xe,useDebugValue:xe,useDeferredValue:function(h){return kt(),h},useTransition:function(){return kt(),[!1,C]},useId:function(){var h=xr.treeContext,v=h.overflow;h=h.id,h=(h&~(1<<32-gr(h)-1)).toString(32)+v;var j=Ue;if(j===null)throw Error(u(404));return v=Ye++,h=":"+j.idPrefix+"R"+h,0<v&&(h+="H"+v.toString(32)),h+":"},useMutableSource:function(h,v){return kt(),v(h._source)},useSyncExternalStore:function(h,v,j){if(j===void 0)throw Error(u(407));return j()}},Ue=null,qA=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function be(h){return console.error(h),null}function mt(){}function ue(h,v,j,P,X,K,fA,_A,XA){var Ae=[],he=new Set;return v={destination:null,responseState:v,progressiveChunkSize:P===void 0?12800:P,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:he,pingedTasks:Ae,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:X===void 0?be:X,onAllReady:mt,onShellReady:fA===void 0?mt:fA,onShellError:mt,onFatalError:mt},j=rt(v,0,null,j,!1,!1),j.parentFlushed=!0,h=ie(v,h,null,j,he,St,null,on),Ae.push(h),v}function ie(h,v,j,P,X,K,fA,_A){h.allPendingTasks++,j===null?h.pendingRootTasks++:j.pendingTasks++;var XA={node:v,ping:function(){var Ae=h.pingedTasks;Ae.push(XA),Ae.length===1&&qe(h)},blockedBoundary:j,blockedSegment:P,abortSet:X,legacyContext:K,context:fA,treeContext:_A};return X.add(XA),XA}function rt(h,v,j,P,X,K){return{status:0,id:-1,index:v,parentFlushed:!1,chunks:[],children:[],formatContext:P,boundary:j,lastPushedText:X,textEmbedded:K}}function Dt(h,v){if(h=h.onError(v),h!=null&&typeof h!="string")throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "'+typeof h+'" instead');return h}function rr(h,v){var j=h.onShellError;j(v),j=h.onFatalError,j(v),h.destination!==null?(h.status=2,h.destination.destroy(v)):(h.status=1,h.fatalError=v)}function Ct(h,v,j,P,X){for(gA={},xr=v,Ye=0,h=j(P,X);tr;)tr=!1,Ye=0,hr+=1,Se=null,h=j(P,X);return tA(),h}function nt(h,v,j,P){var X=j.render(),K=P.childContextTypes;if(K!=null){var fA=v.legacyContext;if(typeof j.getChildContext!="function")P=fA;else{j=j.getChildContext();for(var _A in j)if(!(_A in K))throw Error(u(108,it(P)||"Unknown",_A));P=zA({},fA,j)}v.legacyContext=P,ot(h,v,X),v.legacyContext=fA}else ot(h,v,X)}function Qt(h,v){if(h&&h.defaultProps){v=zA({},v),h=h.defaultProps;for(var j in h)v[j]===void 0&&(v[j]=h[j]);return v}return v}function pt(h,v,j,P,X){if(typeof j=="function")if(j.prototype&&j.prototype.isReactComponent){X=Ve(j,v.legacyContext);var K=j.contextType;K=new j(P,typeof K=="object"&&K!==null?K._currentValue2:X),Ar(K,j,P,X),nt(h,v,K,j)}else{K=Ve(j,v.legacyContext),X=Ct(h,v,j,P,K);var fA=Ye!==0;if(typeof X=="object"&&X!==null&&typeof X.render=="function"&&X.$$typeof===void 0)Ar(X,j,P,K),nt(h,v,X,j);else if(fA){P=v.treeContext,v.treeContext=_r(P,1,0);try{ot(h,v,X)}finally{v.treeContext=P}}else ot(h,v,X)}else if(typeof j=="string"){switch(X=v.blockedSegment,K=FA(X.chunks,j,P,h.responseState,X.formatContext),X.lastPushedText=!1,fA=X.formatContext,X.formatContext=aA(fA,j,P),Et(h,v,K),X.formatContext=fA,j){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":break;default:X.chunks.push("</",j,">")}X.lastPushedText=!1}else{switch(j){case Ke:case te:case VA:case Te:case KA:ot(h,v,P.children);return;case Ie:ot(h,v,P.children);return;case Pe:throw Error(u(343));case Me:A:{j=v.blockedBoundary,X=v.blockedSegment,K=P.fallback,P=P.children,fA=new Set;var _A={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:fA,errorDigest:null},XA=rt(h,X.chunks.length,_A,X.formatContext,!1,!1);X.children.push(XA),X.lastPushedText=!1;var Ae=rt(h,0,null,X.formatContext,!1,!1);Ae.parentFlushed=!0,v.blockedBoundary=_A,v.blockedSegment=Ae;try{if(Et(h,v,P),h.responseState.generateStaticMarkup||Ae.lastPushedText&&Ae.textEmbedded&&Ae.chunks.push("<!-- -->"),Ae.status=1,PA(_A,Ae),_A.pendingTasks===0)break A}catch(he){Ae.status=4,_A.forceClientRender=!0,_A.errorDigest=Dt(h,he)}finally{v.blockedBoundary=j,v.blockedSegment=X}v=ie(h,K,j,XA,fA,v.legacyContext,v.context,v.treeContext),h.pingedTasks.push(v)}return}if(typeof j=="object"&&j!==null)switch(j.$$typeof){case ce:if(P=Ct(h,v,j.render,P,X),Ye!==0){j=v.treeContext,v.treeContext=_r(j,1,0);try{ot(h,v,P)}finally{v.treeContext=j}}else ot(h,v,P);return;case Le:j=j.type,P=Qt(j,P),pt(h,v,j,P,X);return;case _e:if(X=P.children,j=j._context,P=P.value,K=j._currentValue2,j._currentValue2=P,fA=We,We=P={parent:fA,depth:fA===null?0:fA.depth+1,context:j,parentValue:K,value:P},v.context=P,ot(h,v,X),h=We,h===null)throw Error(u(403));P=h.parentValue,h.context._currentValue2=P===$e?h.context._defaultValue:P,h=We=h.parent,v.context=h;return;case pe:P=P.children,P=P(j._currentValue2),ot(h,v,P);return;case fe:X=j._init,j=X(j._payload),P=Qt(j,P),pt(h,v,j,P,void 0);return}throw Error(u(130,j==null?j:typeof j,""))}}function ot(h,v,j){if(v.node=j,typeof j=="object"&&j!==null){switch(j.$$typeof){case de:pt(h,v,j.type,j.props,j.ref);return;case ZA:throw Error(u(257));case fe:var P=j._init;j=P(j._payload),ot(h,v,j);return}if(eA(j)){Tr(h,v,j);return}if(j===null||typeof j!="object"?P=null:(P=At&&j[At]||j["@@iterator"],P=typeof P=="function"?P:null),P&&(P=P.call(j))){if(j=P.next(),!j.done){var X=[];do X.push(j.value),j=P.next();while(!j.done);Tr(h,v,X)}return}throw h=Object.prototype.toString.call(j),Error(u(31,h==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":h))}typeof j=="string"?(P=v.blockedSegment,P.lastPushedText=LA(v.blockedSegment.chunks,j,h.responseState,P.lastPushedText)):typeof j=="number"&&(P=v.blockedSegment,P.lastPushedText=LA(v.blockedSegment.chunks,""+j,h.responseState,P.lastPushedText))}function Tr(h,v,j){for(var P=j.length,X=0;X<P;X++){var K=v.treeContext;v.treeContext=_r(K,P,X);try{Et(h,v,j[X])}finally{v.treeContext=K}}}function Et(h,v,j){var P=v.blockedSegment.formatContext,X=v.legacyContext,K=v.context;try{return ot(h,v,j)}catch(XA){if(tA(),typeof XA=="object"&&XA!==null&&typeof XA.then=="function"){j=XA;var fA=v.blockedSegment,_A=rt(h,fA.chunks.length,null,fA.formatContext,fA.lastPushedText,!0);fA.children.push(_A),fA.lastPushedText=!1,h=ie(h,v.node,v.blockedBoundary,_A,v.abortSet,v.legacyContext,v.context,v.treeContext).ping,j.then(h,h),v.blockedSegment.formatContext=P,v.legacyContext=X,v.context=K,Xt(K)}else throw v.blockedSegment.formatContext=P,v.legacyContext=X,v.context=K,Xt(K),XA}}function JA(h){var v=h.blockedBoundary;h=h.blockedSegment,h.status=3,ft(this,v,h)}function S(h,v,j){var P=h.blockedBoundary;h.blockedSegment.status=3,P===null?(v.allPendingTasks--,v.status!==2&&(v.status=2,v.destination!==null&&v.destination.push(null))):(P.pendingTasks--,P.forceClientRender||(P.forceClientRender=!0,h=j===void 0?Error(u(432)):j,P.errorDigest=v.onError(h),P.parentFlushed&&v.clientRenderedBoundaries.push(P)),P.fallbackAbortableTasks.forEach(function(X){return S(X,v,j)}),P.fallbackAbortableTasks.clear(),v.allPendingTasks--,v.allPendingTasks===0&&(P=v.onAllReady,P()))}function PA(h,v){if(v.chunks.length===0&&v.children.length===1&&v.children[0].boundary===null){var j=v.children[0];j.id=v.id,j.parentFlushed=!0,j.status===1&&PA(h,j)}else h.completedSegments.push(v)}function ft(h,v,j){if(v===null){if(j.parentFlushed){if(h.completedRootSegment!==null)throw Error(u(389));h.completedRootSegment=j}h.pendingRootTasks--,h.pendingRootTasks===0&&(h.onShellError=mt,v=h.onShellReady,v())}else v.pendingTasks--,v.forceClientRender||(v.pendingTasks===0?(j.parentFlushed&&j.status===1&&PA(v,j),v.parentFlushed&&h.completedBoundaries.push(v),v.fallbackAbortableTasks.forEach(JA,h),v.fallbackAbortableTasks.clear()):j.parentFlushed&&j.status===1&&(PA(v,j),v.completedSegments.length===1&&v.parentFlushed&&h.partialBoundaries.push(v)));h.allPendingTasks--,h.allPendingTasks===0&&(h=h.onAllReady,h())}function qe(h){if(h.status!==2){var v=We,j=qA.current;qA.current=Be;var P=Ue;Ue=h.responseState;try{var X=h.pingedTasks,K;for(K=0;K<X.length;K++){var fA=X[K],_A=h,XA=fA.blockedSegment;if(XA.status===0){Xt(fA.context);try{ot(_A,fA,fA.node),_A.responseState.generateStaticMarkup||XA.lastPushedText&&XA.textEmbedded&&XA.chunks.push("<!-- -->"),fA.abortSet.delete(fA),XA.status=1,ft(_A,fA.blockedBoundary,XA)}catch(Je){if(tA(),typeof Je=="object"&&Je!==null&&typeof Je.then=="function"){var Ae=fA.ping;Je.then(Ae,Ae)}else{fA.abortSet.delete(fA),XA.status=4;var he=fA.blockedBoundary,Oe=Je,ht=Dt(_A,Oe);if(he===null?rr(_A,Oe):(he.pendingTasks--,he.forceClientRender||(he.forceClientRender=!0,he.errorDigest=ht,he.parentFlushed&&_A.clientRenderedBoundaries.push(he))),_A.allPendingTasks--,_A.allPendingTasks===0){var _t=_A.onAllReady;_t()}}}finally{}}}X.splice(0,K),h.destination!==null&&nr(h,h.destination)}catch(Je){Dt(h,Je),rr(h,Je)}finally{Ue=P,qA.current=j,j===Be&&Xt(v)}}}function Ut(h,v,j){switch(j.parentFlushed=!0,j.status){case 0:var P=j.id=h.nextSegmentId++;return j.lastPushedText=!1,j.textEmbedded=!1,h=h.responseState,v.push('<template id="'),v.push(h.placeholderPrefix),h=P.toString(16),v.push(h),v.push('"></template>');case 1:j.status=2;var X=!0;P=j.chunks;var K=0;j=j.children;for(var fA=0;fA<j.length;fA++){for(X=j[fA];K<X.index;K++)v.push(P[K]);X=dr(h,v,X)}for(;K<P.length-1;K++)v.push(P[K]);return K<P.length&&(X=v.push(P[K])),X;default:throw Error(u(390))}}function dr(h,v,j){var P=j.boundary;if(P===null)return Ut(h,v,j);if(P.parentFlushed=!0,P.forceClientRender)return h.responseState.generateStaticMarkup||(P=P.errorDigest,v.push("<!--$!-->"),v.push("<template"),P&&(v.push(' data-dgst="'),P=V(P),v.push(P),v.push('"')),v.push("></template>")),Ut(h,v,j),h=h.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),h;if(0<P.pendingTasks){P.rootSegmentID=h.nextSegmentId++,0<P.completedSegments.length&&h.partialBoundaries.push(P);var X=h.responseState,K=X.nextSuspenseID++;return X=X.boundaryPrefix+K.toString(16),P=P.id=X,IA(v,h.responseState,P),Ut(h,v,j),v.push("<!--/$-->")}if(P.byteSize>h.progressiveChunkSize)return P.rootSegmentID=h.nextSegmentId++,h.completedBoundaries.push(P),IA(v,h.responseState,P.id),Ut(h,v,j),v.push("<!--/$-->");if(h.responseState.generateStaticMarkup||v.push("<!--$-->"),j=P.completedSegments,j.length!==1)throw Error(u(391));return dr(h,v,j[0]),h=h.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),h}function Ir(h,v,j){return WA(v,h.responseState,j.formatContext,j.id),dr(h,v,j),wA(v,j.formatContext)}function E(h,v,j){for(var P=j.completedSegments,X=0;X<P.length;X++)Ot(h,v,j,P[X]);if(P.length=0,h=h.responseState,P=j.id,j=j.rootSegmentID,v.push(h.startInlineScript),h.sentCompleteBoundaryFunction?v.push('$RC("'):(h.sentCompleteBoundaryFunction=!0,v.push('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("')),P===null)throw Error(u(395));return j=j.toString(16),v.push(P),v.push('","'),v.push(h.segmentPrefix),v.push(j),v.push('")<\/script>')}function Ot(h,v,j,P){if(P.status===2)return!0;var X=P.id;if(X===-1){if((P.id=j.rootSegmentID)===-1)throw Error(u(392));return Ir(h,v,P)}return Ir(h,v,P),h=h.responseState,v.push(h.startInlineScript),h.sentCompleteSegmentFunction?v.push('$RS("'):(h.sentCompleteSegmentFunction=!0,v.push('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("')),v.push(h.segmentPrefix),X=X.toString(16),v.push(X),v.push('","'),v.push(h.placeholderPrefix),v.push(X),v.push('")<\/script>')}function nr(h,v){try{var j=h.completedRootSegment;if(j!==null&&h.pendingRootTasks===0){dr(h,v,j),h.completedRootSegment=null;var P=h.responseState.bootstrapChunks;for(j=0;j<P.length-1;j++)v.push(P[j]);j<P.length&&v.push(P[j])}var X=h.clientRenderedBoundaries,K;for(K=0;K<X.length;K++){var fA=X[K];P=v;var _A=h.responseState,XA=fA.id,Ae=fA.errorDigest,he=fA.errorMessage,Oe=fA.errorComponentStack;if(P.push(_A.startInlineScript),_A.sentClientRenderFunction?P.push('$RX("'):(_A.sentClientRenderFunction=!0,P.push('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("')),XA===null)throw Error(u(395));if(P.push(XA),P.push('"'),Ae||he||Oe){P.push(",");var ht=dA(Ae||"");P.push(ht)}if(he||Oe){P.push(",");var _t=dA(he||"");P.push(_t)}if(Oe){P.push(",");var Je=dA(Oe);P.push(Je)}if(!P.push(")<\/script>")){h.destination=null,K++,X.splice(0,K);return}}X.splice(0,K);var je=h.completedBoundaries;for(K=0;K<je.length;K++)if(!E(h,v,je[K])){h.destination=null,K++,je.splice(0,K);return}je.splice(0,K);var jt=h.partialBoundaries;for(K=0;K<jt.length;K++){var vr=jt[K];A:{X=h,fA=v;var mr=vr.completedSegments;for(_A=0;_A<mr.length;_A++)if(!Ot(X,fA,vr,mr[_A])){_A++,mr.splice(0,_A);var Pr=!1;break A}mr.splice(0,_A),Pr=!0}if(!Pr){h.destination=null,K++,jt.splice(0,K);return}}jt.splice(0,K);var sr=h.completedBoundaries;for(K=0;K<sr.length;K++)if(!E(h,v,sr[K])){h.destination=null,K++,sr.splice(0,K);return}sr.splice(0,K)}finally{h.allPendingTasks===0&&h.pingedTasks.length===0&&h.clientRenderedBoundaries.length===0&&h.completedBoundaries.length===0&&v.push(null)}}function Lr(h,v){try{var j=h.abortableTasks;j.forEach(function(P){return S(P,h,v)}),j.clear(),h.destination!==null&&nr(h,h.destination)}catch(P){Dt(h,P),rr(h,P)}}function Nr(){}function Fr(h,v,j,P){var X=!1,K=null,fA="",_A={push:function(Ae){return Ae!==null&&(fA+=Ae),!0},destroy:function(Ae){X=!0,K=Ae}},XA=!1;if(h=ue(h,jA(j,v?v.identifierPrefix:void 0),{insertionMode:1,selectedValue:null},1/0,Nr,void 0,function(){XA=!0}),qe(h),Lr(h,P),h.status===1)h.status=2,_A.destroy(h.fatalError);else if(h.status!==2&&h.destination===null){h.destination=_A;try{nr(h,_A)}catch(Ae){Dt(h,Ae),rr(h,Ae)}}if(X)throw K;if(!XA)throw Error(u(426));return fA}return wn.renderToNodeStream=function(){throw Error(u(207))},wn.renderToStaticMarkup=function(h,v){return Fr(h,v,!0,'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server')},wn.renderToStaticNodeStream=function(){throw Error(u(208))},wn.renderToString=function(h,v){return Fr(h,v,!1,'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server')},wn.version="18.3.1",wn}var G0={};/**
 * @license React
 * react-dom-server.browser.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var ao;function J1(){if(ao)return G0;ao=1;var a=Go();function u(d){for(var w="https://reactjs.org/docs/error-decoder.html?invariant="+d,_=1;_<arguments.length;_++)w+="&args[]="+encodeURIComponent(arguments[_]);return"Minified React error #"+d+"; visit "+w+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var g=null,y=0;function x(d,w){if(w.length!==0)if(512<w.length)0<y&&(d.enqueue(new Uint8Array(g.buffer,0,y)),g=new Uint8Array(512),y=0),d.enqueue(w);else{var _=g.length-y;_<w.length&&(_===0?d.enqueue(g):(g.set(w.subarray(0,_),y),d.enqueue(g),w=w.subarray(_)),g=new Uint8Array(512),y=0),g.set(w,y),y+=w.length}}function k(d,w){return x(d,w),!0}function D(d){g&&0<y&&(d.enqueue(new Uint8Array(g.buffer,0,y)),g=null,y=0)}var Q=new TextEncoder;function M(d){return Q.encode(d)}function b(d){return Q.encode(d)}function T(d,w){typeof d.error=="function"?d.error(w):d.close()}var O=Object.prototype.hasOwnProperty,z=/^[: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]*$/,W={},V={};function J(d){return O.call(V,d)?!0:O.call(W,d)?!1:z.test(d)?V[d]=!0:(W[d]=!0,!1)}function iA(d,w,_,F,rA,AA,hA){this.acceptsBooleans=w===2||w===3||w===4,this.attributeName=F,this.attributeNamespace=rA,this.mustUseProperty=_,this.propertyName=d,this.type=w,this.sanitizeURL=AA,this.removeEmptyString=hA}var eA={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(d){eA[d]=new iA(d,0,!1,d,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(d){var w=d[0];eA[w]=new iA(w,1,!1,d[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(d){eA[d]=new iA(d,2,!1,d.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(d){eA[d]=new iA(d,2,!1,d,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(d){eA[d]=new iA(d,3,!1,d.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(d){eA[d]=new iA(d,3,!0,d,null,!1,!1)}),["capture","download"].forEach(function(d){eA[d]=new iA(d,4,!1,d,null,!1,!1)}),["cols","rows","size","span"].forEach(function(d){eA[d]=new iA(d,6,!1,d,null,!1,!1)}),["rowSpan","start"].forEach(function(d){eA[d]=new iA(d,5,!1,d.toLowerCase(),null,!1,!1)});var Z=/[\-:]([a-z])/g;function aA(d){return d[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(d){var w=d.replace(Z,aA);eA[w]=new iA(w,1,!1,d,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(d){var w=d.replace(Z,aA);eA[w]=new iA(w,1,!1,d,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(d){var w=d.replace(Z,aA);eA[w]=new iA(w,1,!1,d,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(d){eA[d]=new iA(d,1,!1,d.toLowerCase(),null,!1,!1)}),eA.xlinkHref=new iA("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(d){eA[d]=new iA(d,1,!1,d.toLowerCase(),null,!0,!0)});var cA={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},RA=["Webkit","ms","Moz","O"];Object.keys(cA).forEach(function(d){RA.forEach(function(w){w=w+d.charAt(0).toUpperCase()+d.substring(1),cA[w]=cA[d]})});var sA=/["'&<>]/;function lA(d){if(typeof d=="boolean"||typeof d=="number")return""+d;d=""+d;var w=sA.exec(d);if(w){var _="",F,rA=0;for(F=w.index;F<d.length;F++){switch(d.charCodeAt(F)){case 34:w="&quot;";break;case 38:w="&amp;";break;case 39:w="&#x27;";break;case 60:w="&lt;";break;case 62:w="&gt;";break;default:continue}rA!==F&&(_+=d.substring(rA,F)),rA=F+1,_+=w}d=rA!==F?_+d.substring(rA,F):_}return d}var BA=/([A-Z])/g,SA=/^ms-/,bA=Array.isArray,kA=b("<script>"),vA=b("<\/script>"),FA=b('<script src="'),IA=b('<script type="module" src="'),WA=b('" async=""><\/script>'),wA=/(<\/|<)(s)(cript)/gi;function uA(d,w,_,F){return""+w+(_==="s"?"\\u0073":"\\u0053")+F}function dA(d,w,_,F,rA){d=d===void 0?"":d,w=w===void 0?kA:b('<script nonce="'+lA(w)+'">');var AA=[];if(_!==void 0&&AA.push(w,M((""+_).replace(wA,uA)),vA),F!==void 0)for(_=0;_<F.length;_++)AA.push(FA,M(lA(F[_])),WA);if(rA!==void 0)for(F=0;F<rA.length;F++)AA.push(IA,M(lA(rA[F])),WA);return{bootstrapChunks:AA,startInlineScript:w,placeholderPrefix:b(d+"P:"),segmentPrefix:b(d+"S:"),boundaryPrefix:d+"B:",idPrefix:d,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1}}function jA(d,w){return{insertionMode:d,selectedValue:w}}function LA(d){return jA(d==="http://www.w3.org/2000/svg"?2:d==="http://www.w3.org/1998/Math/MathML"?3:0,null)}function zA(d,w,_){switch(w){case"select":return jA(1,_.value!=null?_.value:_.defaultValue);case"svg":return jA(2,null);case"math":return jA(3,null);case"foreignObject":return jA(1,null);case"table":return jA(4,null);case"thead":case"tbody":case"tfoot":return jA(5,null);case"colgroup":return jA(7,null);case"tr":return jA(6,null)}return 4<=d.insertionMode||d.insertionMode===0?jA(1,null):d}var de=b("<!-- -->");function ZA(d,w,_,F){return w===""?F:(F&&d.push(de),d.push(M(lA(w))),!0)}var KA=new Map,VA=b(' style="'),Te=b(":"),_e=b(";");function pe(d,w,_){if(typeof _!="object")throw Error(u(62));w=!0;for(var F in _)if(O.call(_,F)){var rA=_[F];if(rA!=null&&typeof rA!="boolean"&&rA!==""){if(F.indexOf("--")===0){var AA=M(lA(F));rA=M(lA((""+rA).trim()))}else{AA=F;var hA=KA.get(AA);hA!==void 0||(hA=b(lA(AA.replace(BA,"-$1").toLowerCase().replace(SA,"-ms-"))),KA.set(AA,hA)),AA=hA,rA=typeof rA=="number"?rA===0||O.call(cA,F)?M(""+rA):M(rA+"px"):M(lA((""+rA).trim()))}w?(w=!1,d.push(VA,AA,Te,rA)):d.push(_e,AA,Te,rA)}}w||d.push(Ie)}var ce=b(" "),Me=b('="'),Ie=b('"'),Le=b('=""');function fe(d,w,_,F){switch(_){case"style":pe(d,w,F);return;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N"){if(w=eA.hasOwnProperty(_)?eA[_]:null,w!==null){switch(typeof F){case"function":case"symbol":return;case"boolean":if(!w.acceptsBooleans)return}switch(_=M(w.attributeName),w.type){case 3:F&&d.push(ce,_,Le);break;case 4:F===!0?d.push(ce,_,Le):F!==!1&&d.push(ce,_,Me,M(lA(F)),Ie);break;case 5:isNaN(F)||d.push(ce,_,Me,M(lA(F)),Ie);break;case 6:!isNaN(F)&&1<=F&&d.push(ce,_,Me,M(lA(F)),Ie);break;default:w.sanitizeURL&&(F=""+F),d.push(ce,_,Me,M(lA(F)),Ie)}}else if(J(_)){switch(typeof F){case"function":case"symbol":return;case"boolean":if(w=_.toLowerCase().slice(0,5),w!=="data-"&&w!=="aria-")return}d.push(ce,M(_),Me,M(lA(F)),Ie)}}}var Pe=b(">"),te=b("/>");function Ke(d,w,_){if(w!=null){if(_!=null)throw Error(u(60));if(typeof w!="object"||!("__html"in w))throw Error(u(61));w=w.__html,w!=null&&d.push(M(""+w))}}function $e(d){var w="";return a.Children.forEach(d,function(_){_!=null&&(w+=_)}),w}var At=b(' selected=""');function it(d,w,_,F){d.push(ke(_));var rA=_=null,AA;for(AA in w)if(O.call(w,AA)){var hA=w[AA];if(hA!=null)switch(AA){case"children":_=hA;break;case"dangerouslySetInnerHTML":rA=hA;break;default:fe(d,F,AA,hA)}}return d.push(Pe),Ke(d,rA,_),typeof _=="string"?(d.push(M(lA(_))),null):_}var St=b(`
`),Ve=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,We=new Map;function ke(d){var w=We.get(d);if(w===void 0){if(!Ve.test(d))throw Error(u(65,d));w=b("<"+d),We.set(d,w)}return w}var Ze=b("<!DOCTYPE html>");function at(d,w,_,F,rA){switch(w){case"select":d.push(ke("select"));var AA=null,hA=null;for(we in _)if(O.call(_,we)){var DA=_[we];if(DA!=null)switch(we){case"children":AA=DA;break;case"dangerouslySetInnerHTML":hA=DA;break;case"defaultValue":case"value":break;default:fe(d,F,we,DA)}}return d.push(Pe),Ke(d,hA,AA),AA;case"option":hA=rA.selectedValue,d.push(ke("option"));var re=DA=null,Ce=null,we=null;for(AA in _)if(O.call(_,AA)){var ze=_[AA];if(ze!=null)switch(AA){case"children":DA=ze;break;case"selected":Ce=ze;break;case"dangerouslySetInnerHTML":we=ze;break;case"value":re=ze;default:fe(d,F,AA,ze)}}if(hA!=null)if(_=re!==null?""+re:$e(DA),bA(hA)){for(F=0;F<hA.length;F++)if(""+hA[F]===_){d.push(At);break}}else""+hA===_&&d.push(At);else Ce&&d.push(At);return d.push(Pe),Ke(d,we,DA),DA;case"textarea":d.push(ke("textarea")),we=hA=AA=null;for(DA in _)if(O.call(_,DA)&&(re=_[DA],re!=null))switch(DA){case"children":we=re;break;case"value":AA=re;break;case"defaultValue":hA=re;break;case"dangerouslySetInnerHTML":throw Error(u(91));default:fe(d,F,DA,re)}if(AA===null&&hA!==null&&(AA=hA),d.push(Pe),we!=null){if(AA!=null)throw Error(u(92));if(bA(we)&&1<we.length)throw Error(u(93));AA=""+we}return typeof AA=="string"&&AA[0]===`
`&&d.push(St),AA!==null&&d.push(M(lA(""+AA))),null;case"input":d.push(ke("input")),re=we=DA=AA=null;for(hA in _)if(O.call(_,hA)&&(Ce=_[hA],Ce!=null))switch(hA){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,"input"));case"defaultChecked":re=Ce;break;case"defaultValue":DA=Ce;break;case"checked":we=Ce;break;case"value":AA=Ce;break;default:fe(d,F,hA,Ce)}return we!==null?fe(d,F,"checked",we):re!==null&&fe(d,F,"checked",re),AA!==null?fe(d,F,"value",AA):DA!==null&&fe(d,F,"value",DA),d.push(te),null;case"menuitem":d.push(ke("menuitem"));for(var Tt in _)if(O.call(_,Tt)&&(AA=_[Tt],AA!=null))switch(Tt){case"children":case"dangerouslySetInnerHTML":throw Error(u(400));default:fe(d,F,Tt,AA)}return d.push(Pe),null;case"title":d.push(ke("title")),AA=null;for(ze in _)if(O.call(_,ze)&&(hA=_[ze],hA!=null))switch(ze){case"children":AA=hA;break;case"dangerouslySetInnerHTML":throw Error(u(434));default:fe(d,F,ze,hA)}return d.push(Pe),AA;case"listing":case"pre":d.push(ke(w)),hA=AA=null;for(re in _)if(O.call(_,re)&&(DA=_[re],DA!=null))switch(re){case"children":AA=DA;break;case"dangerouslySetInnerHTML":hA=DA;break;default:fe(d,F,re,DA)}if(d.push(Pe),hA!=null){if(AA!=null)throw Error(u(60));if(typeof hA!="object"||!("__html"in hA))throw Error(u(61));_=hA.__html,_!=null&&(typeof _=="string"&&0<_.length&&_[0]===`
`?d.push(St,M(_)):d.push(M(""+_)))}return typeof AA=="string"&&AA[0]===`
`&&d.push(St),AA;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":d.push(ke(w));for(var It in _)if(O.call(_,It)&&(AA=_[It],AA!=null))switch(It){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,w));default:fe(d,F,It,AA)}return d.push(te),null;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 it(d,_,w,F);case"html":return rA.insertionMode===0&&d.push(Ze),it(d,_,w,F);default:if(w.indexOf("-")===-1&&typeof _.is!="string")return it(d,_,w,F);d.push(ke(w)),hA=AA=null;for(Ce in _)if(O.call(_,Ce)&&(DA=_[Ce],DA!=null))switch(Ce){case"children":AA=DA;break;case"dangerouslySetInnerHTML":hA=DA;break;case"style":pe(d,F,DA);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:J(Ce)&&typeof DA!="function"&&typeof DA!="symbol"&&d.push(ce,M(Ce),Me,M(lA(DA)),Ie)}return d.push(Pe),Ke(d,hA,AA),AA}}var Bt=b("</"),Jt=b(">"),Xt=b('<template id="'),Dr=b('"></template>'),Ar=b("<!--$-->"),on=b('<!--$?--><template id="'),_r=b('"></template>'),gr=b("<!--$!-->"),yr=b("<!--/$-->"),jr=b("<template"),Rr=b('"'),Kr=b(' data-dgst="');b(' data-msg="'),b(' data-stck="');var ln=b("></template>");function gA(d,w,_){if(x(d,on),_===null)throw Error(u(395));return x(d,_),k(d,_r)}var xr=b('<div hidden id="'),er=b('">'),Se=b("</div>"),fr=b('<svg aria-hidden="true" style="display:none" id="'),tr=b('">'),Ye=b("</svg>"),ct=b('<math aria-hidden="true" style="display:none" id="'),hr=b('">'),kt=b("</math>"),wr=b('<table hidden id="'),dt=b('">'),tA=b("</table>"),yA=b('<table hidden><tbody id="'),TA=b('">'),mA=b("</tbody></table>"),t=b('<table hidden><tr id="'),C=b('">'),xe=b("</tr></table>"),Be=b('<table hidden><colgroup id="'),Ue=b('">'),qA=b("</colgroup></table>");function be(d,w,_,F){switch(_.insertionMode){case 0:case 1:return x(d,xr),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,er);case 2:return x(d,fr),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,tr);case 3:return x(d,ct),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,hr);case 4:return x(d,wr),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,dt);case 5:return x(d,yA),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,TA);case 6:return x(d,t),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,C);case 7:return x(d,Be),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,Ue);default:throw Error(u(397))}}function mt(d,w){switch(w.insertionMode){case 0:case 1:return k(d,Se);case 2:return k(d,Ye);case 3:return k(d,kt);case 4:return k(d,tA);case 5:return k(d,mA);case 6:return k(d,xe);case 7:return k(d,qA);default:throw Error(u(397))}}var ue=b('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),ie=b('$RS("'),rt=b('","'),Dt=b('")<\/script>'),rr=b('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'),Ct=b('$RC("'),nt=b('","'),Qt=b('")<\/script>'),pt=b('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'),ot=b('$RX("'),Tr=b('"'),Et=b(")<\/script>"),JA=b(","),S=/[<\u2028\u2029]/g;function PA(d){return JSON.stringify(d).replace(S,function(w){switch(w){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}var ft=Object.assign,qe=Symbol.for("react.element"),Ut=Symbol.for("react.portal"),dr=Symbol.for("react.fragment"),Ir=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),Ot=Symbol.for("react.provider"),nr=Symbol.for("react.context"),Lr=Symbol.for("react.forward_ref"),Nr=Symbol.for("react.suspense"),Fr=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),j=Symbol.for("react.scope"),P=Symbol.for("react.debug_trace_mode"),X=Symbol.for("react.legacy_hidden"),K=Symbol.for("react.default_value"),fA=Symbol.iterator;function _A(d){if(d==null)return null;if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case dr:return"Fragment";case Ut:return"Portal";case E:return"Profiler";case Ir:return"StrictMode";case Nr:return"Suspense";case Fr:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case nr:return(d.displayName||"Context")+".Consumer";case Ot:return(d._context.displayName||"Context")+".Provider";case Lr:var w=d.render;return d=d.displayName,d||(d=w.displayName||w.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case h:return w=d.displayName||null,w!==null?w:_A(d.type)||"Memo";case v:w=d._payload,d=d._init;try{return _A(d(w))}catch{}}return null}var XA={};function Ae(d,w){if(d=d.contextTypes,!d)return XA;var _={},F;for(F in d)_[F]=w[F];return _}var he=null;function Oe(d,w){if(d!==w){d.context._currentValue=d.parentValue,d=d.parent;var _=w.parent;if(d===null){if(_!==null)throw Error(u(401))}else{if(_===null)throw Error(u(401));Oe(d,_)}w.context._currentValue=w.value}}function ht(d){d.context._currentValue=d.parentValue,d=d.parent,d!==null&&ht(d)}function _t(d){var w=d.parent;w!==null&&_t(w),d.context._currentValue=d.value}function Je(d,w){if(d.context._currentValue=d.parentValue,d=d.parent,d===null)throw Error(u(402));d.depth===w.depth?Oe(d,w):Je(d,w)}function je(d,w){var _=w.parent;if(_===null)throw Error(u(402));d.depth===_.depth?Oe(d,_):je(d,_),w.context._currentValue=w.value}function jt(d){var w=he;w!==d&&(w===null?_t(d):d===null?ht(w):w.depth===d.depth?Oe(w,d):w.depth>d.depth?Je(w,d):je(w,d),he=d)}var vr={isMounted:function(){return!1},enqueueSetState:function(d,w){d=d._reactInternals,d.queue!==null&&d.queue.push(w)},enqueueReplaceState:function(d,w){d=d._reactInternals,d.replace=!0,d.queue=[w]},enqueueForceUpdate:function(){}};function mr(d,w,_,F){var rA=d.state!==void 0?d.state:null;d.updater=vr,d.props=_,d.state=rA;var AA={queue:[],replace:!1};d._reactInternals=AA;var hA=w.contextType;if(d.context=typeof hA=="object"&&hA!==null?hA._currentValue:F,hA=w.getDerivedStateFromProps,typeof hA=="function"&&(hA=hA(_,rA),rA=hA==null?rA:ft({},rA,hA),d.state=rA),typeof w.getDerivedStateFromProps!="function"&&typeof d.getSnapshotBeforeUpdate!="function"&&(typeof d.UNSAFE_componentWillMount=="function"||typeof d.componentWillMount=="function"))if(w=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),w!==d.state&&vr.enqueueReplaceState(d,d.state,null),AA.queue!==null&&0<AA.queue.length)if(w=AA.queue,hA=AA.replace,AA.queue=null,AA.replace=!1,hA&&w.length===1)d.state=w[0];else{for(AA=hA?w[0]:d.state,rA=!0,hA=hA?1:0;hA<w.length;hA++){var DA=w[hA];DA=typeof DA=="function"?DA.call(d,AA,_,F):DA,DA!=null&&(rA?(rA=!1,AA=ft({},AA,DA)):ft(AA,DA))}d.state=AA}else AA.queue=null}var Pr={id:1,overflow:""};function sr(d,w,_){var F=d.id;d=d.overflow;var rA=32-Qr(F)-1;F&=~(1<<rA),_+=1;var AA=32-Qr(w)+rA;if(30<AA){var hA=rA-rA%5;return AA=(F&(1<<hA)-1).toString(32),F>>=hA,rA-=hA,{id:1<<32-Qr(w)+rA|_<<rA|F,overflow:AA+d}}return{id:1<<AA|_<<rA|F,overflow:d}}var Qr=Math.clz32?Math.clz32:Kn,an=Math.log,un=Math.LN2;function Kn(d){return d>>>=0,d===0?32:31-(an(d)/un|0)|0}function $n(d,w){return d===w&&(d!==0||1/d===1/w)||d!==d&&w!==w}var Zn=typeof Object.is=="function"?Object.is:$n,zt=null,cn=null,br=null,Ne=null,Or=!1,zr=!1,kr=0,Vt=null,$r=0;function pr(){if(zt===null)throw Error(u(321));return zt}function Bn(){if(0<$r)throw Error(u(312));return{memoizedState:null,queue:null,next:null}}function Hr(){return Ne===null?br===null?(Or=!1,br=Ne=Bn()):(Or=!0,Ne=br):Ne.next===null?(Or=!1,Ne=Ne.next=Bn()):(Or=!0,Ne=Ne.next),Ne}function et(){cn=zt=null,zr=!1,br=null,$r=0,Ne=Vt=null}function ir(d,w){return typeof w=="function"?w(d):w}function H(d,w,_){if(zt=pr(),Ne=Hr(),Or){var F=Ne.queue;if(w=F.dispatch,Vt!==null&&(_=Vt.get(F),_!==void 0)){Vt.delete(F),F=Ne.memoizedState;do F=d(F,_.action),_=_.next;while(_!==null);return Ne.memoizedState=F,[F,w]}return[Ne.memoizedState,w]}return d=d===ir?typeof w=="function"?w():w:_!==void 0?_(w):w,Ne.memoizedState=d,d=Ne.queue={last:null,dispatch:null},d=d.dispatch=pA.bind(null,zt,d),[Ne.memoizedState,d]}function oA(d,w){if(zt=pr(),Ne=Hr(),w=w===void 0?null:w,Ne!==null){var _=Ne.memoizedState;if(_!==null&&w!==null){var F=_[1];A:if(F===null)F=!1;else{for(var rA=0;rA<F.length&&rA<w.length;rA++)if(!Zn(w[rA],F[rA])){F=!1;break A}F=!0}if(F)return _[0]}}return d=d(),Ne.memoizedState=[d,w],d}function pA(d,w,_){if(25<=$r)throw Error(u(301));if(d===zt)if(zr=!0,d={action:_,next:null},Vt===null&&(Vt=new Map),_=Vt.get(w),_===void 0)Vt.set(w,d);else{for(w=_;w.next!==null;)w=w.next;w.next=d}}function NA(){throw Error(u(394))}function HA(){}var oe={readContext:function(d){return d._currentValue},useContext:function(d){return pr(),d._currentValue},useMemo:oA,useReducer:H,useRef:function(d){zt=pr(),Ne=Hr();var w=Ne.memoizedState;return w===null?(d={current:d},Ne.memoizedState=d):w},useState:function(d){return H(ir,d)},useInsertionEffect:HA,useLayoutEffect:function(){},useCallback:function(d,w){return oA(function(){return d},w)},useImperativeHandle:HA,useEffect:HA,useDebugValue:HA,useDeferredValue:function(d){return pr(),d},useTransition:function(){return pr(),[!1,NA]},useId:function(){var d=cn.treeContext,w=d.overflow;d=d.id,d=(d&~(1<<32-Qr(d)-1)).toString(32)+w;var _=De;if(_===null)throw Error(u(404));return w=kr++,d=":"+_.idPrefix+"R"+d,0<w&&(d+="H"+w.toString(32)),d+":"},useMutableSource:function(d,w){return pr(),w(d._source)},useSyncExternalStore:function(d,w,_){if(_===void 0)throw Error(u(407));return _()}},De=null,Qe=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function st(d){return console.error(d),null}function Xe(){}function gt(d,w,_,F,rA,AA,hA,DA,re){var Ce=[],we=new Set;return w={destination:null,responseState:w,progressiveChunkSize:F===void 0?12800:F,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:we,pingedTasks:Ce,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:rA===void 0?st:rA,onAllReady:AA===void 0?Xe:AA,onShellReady:hA===void 0?Xe:hA,onShellError:DA===void 0?Xe:DA,onFatalError:re===void 0?Xe:re},_=yt(w,0,null,_,!1,!1),_.parentFlushed=!0,d=tt(w,d,null,_,we,XA,null,Pr),Ce.push(d),w}function tt(d,w,_,F,rA,AA,hA,DA){d.allPendingTasks++,_===null?d.pendingRootTasks++:_.pendingTasks++;var re={node:w,ping:function(){var Ce=d.pingedTasks;Ce.push(re),Ce.length===1&&t0(d)},blockedBoundary:_,blockedSegment:F,abortSet:rA,legacyContext:AA,context:hA,treeContext:DA};return rA.add(re),re}function yt(d,w,_,F,rA,AA){return{status:0,id:-1,index:w,parentFlushed:!1,chunks:[],children:[],formatContext:F,boundary:_,lastPushedText:rA,textEmbedded:AA}}function Wt(d,w){if(d=d.onError(w),d!=null&&typeof d!="string")throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "'+typeof d+'" instead');return d}function Yt(d,w){var _=d.onShellError;_(w),_=d.onFatalError,_(w),d.destination!==null?(d.status=2,T(d.destination,w)):(d.status=1,d.fatalError=w)}function qn(d,w,_,F,rA){for(zt={},cn=w,kr=0,d=_(F,rA);zr;)zr=!1,kr=0,$r+=1,Ne=null,d=_(F,rA);return et(),d}function Jn(d,w,_,F){var rA=_.render(),AA=F.childContextTypes;if(AA!=null){var hA=w.legacyContext;if(typeof _.getChildContext!="function")F=hA;else{_=_.getChildContext();for(var DA in _)if(!(DA in AA))throw Error(u(108,_A(F)||"Unknown",DA));F=ft({},hA,_)}w.legacyContext=F,Rt(d,w,rA),w.legacyContext=hA}else Rt(d,w,rA)}function Dn(d,w){if(d&&d.defaultProps){w=ft({},w),d=d.defaultProps;for(var _ in d)w[_]===void 0&&(w[_]=d[_]);return w}return w}function Xn(d,w,_,F,rA){if(typeof _=="function")if(_.prototype&&_.prototype.isReactComponent){rA=Ae(_,w.legacyContext);var AA=_.contextType;AA=new _(F,typeof AA=="object"&&AA!==null?AA._currentValue:rA),mr(AA,_,F,rA),Jn(d,w,AA,_)}else{AA=Ae(_,w.legacyContext),rA=qn(d,w,_,F,AA);var hA=kr!==0;if(typeof rA=="object"&&rA!==null&&typeof rA.render=="function"&&rA.$$typeof===void 0)mr(rA,_,F,AA),Jn(d,w,rA,_);else if(hA){F=w.treeContext,w.treeContext=sr(F,1,0);try{Rt(d,w,rA)}finally{w.treeContext=F}}else Rt(d,w,rA)}else if(typeof _=="string"){switch(rA=w.blockedSegment,AA=at(rA.chunks,_,F,d.responseState,rA.formatContext),rA.lastPushedText=!1,hA=rA.formatContext,rA.formatContext=zA(hA,_,F),e0(d,w,AA),rA.formatContext=hA,_){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":break;default:rA.chunks.push(Bt,M(_),Jt)}rA.lastPushedText=!1}else{switch(_){case X:case P:case Ir:case E:case dr:Rt(d,w,F.children);return;case Fr:Rt(d,w,F.children);return;case j:throw Error(u(343));case Nr:A:{_=w.blockedBoundary,rA=w.blockedSegment,AA=F.fallback,F=F.children,hA=new Set;var DA={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:hA,errorDigest:null},re=yt(d,rA.chunks.length,DA,rA.formatContext,!1,!1);rA.children.push(re),rA.lastPushedText=!1;var Ce=yt(d,0,null,rA.formatContext,!1,!1);Ce.parentFlushed=!0,w.blockedBoundary=DA,w.blockedSegment=Ce;try{if(e0(d,w,F),Ce.lastPushedText&&Ce.textEmbedded&&Ce.chunks.push(de),Ce.status=1,_n(DA,Ce),DA.pendingTasks===0)break A}catch(we){Ce.status=4,DA.forceClientRender=!0,DA.errorDigest=Wt(d,we)}finally{w.blockedBoundary=_,w.blockedSegment=rA}w=tt(d,AA,_,re,hA,w.legacyContext,w.context,w.treeContext),d.pingedTasks.push(w)}return}if(typeof _=="object"&&_!==null)switch(_.$$typeof){case Lr:if(F=qn(d,w,_.render,F,rA),kr!==0){_=w.treeContext,w.treeContext=sr(_,1,0);try{Rt(d,w,F)}finally{w.treeContext=_}}else Rt(d,w,F);return;case h:_=_.type,F=Dn(_,F),Xn(d,w,_,F,rA);return;case Ot:if(rA=F.children,_=_._context,F=F.value,AA=_._currentValue,_._currentValue=F,hA=he,he=F={parent:hA,depth:hA===null?0:hA.depth+1,context:_,parentValue:AA,value:F},w.context=F,Rt(d,w,rA),d=he,d===null)throw Error(u(403));F=d.parentValue,d.context._currentValue=F===K?d.context._defaultValue:F,d=he=d.parent,w.context=d;return;case nr:F=F.children,F=F(_._currentValue),Rt(d,w,F);return;case v:rA=_._init,_=rA(_._payload),F=Dn(_,F),Xn(d,w,_,F,void 0);return}throw Error(u(130,_==null?_:typeof _,""))}}function Rt(d,w,_){if(w.node=_,typeof _=="object"&&_!==null){switch(_.$$typeof){case qe:Xn(d,w,_.type,_.props,_.ref);return;case Ut:throw Error(u(257));case v:var F=_._init;_=F(_._payload),Rt(d,w,_);return}if(bA(_)){A0(d,w,_);return}if(_===null||typeof _!="object"?F=null:(F=fA&&_[fA]||_["@@iterator"],F=typeof F=="function"?F:null),F&&(F=F.call(_))){if(_=F.next(),!_.done){var rA=[];do rA.push(_.value),_=F.next();while(!_.done);A0(d,w,rA)}return}throw d=Object.prototype.toString.call(_),Error(u(31,d==="[object Object]"?"object with keys {"+Object.keys(_).join(", ")+"}":d))}typeof _=="string"?(F=w.blockedSegment,F.lastPushedText=ZA(w.blockedSegment.chunks,_,d.responseState,F.lastPushedText)):typeof _=="number"&&(F=w.blockedSegment,F.lastPushedText=ZA(w.blockedSegment.chunks,""+_,d.responseState,F.lastPushedText))}function A0(d,w,_){for(var F=_.length,rA=0;rA<F;rA++){var AA=w.treeContext;w.treeContext=sr(AA,F,rA);try{e0(d,w,_[rA])}finally{w.treeContext=AA}}}function e0(d,w,_){var F=w.blockedSegment.formatContext,rA=w.legacyContext,AA=w.context;try{return Rt(d,w,_)}catch(re){if(et(),typeof re=="object"&&re!==null&&typeof re.then=="function"){_=re;var hA=w.blockedSegment,DA=yt(d,hA.chunks.length,null,hA.formatContext,hA.lastPushedText,!0);hA.children.push(DA),hA.lastPushedText=!1,d=tt(d,w.node,w.blockedBoundary,DA,w.abortSet,w.legacyContext,w.context,w.treeContext).ping,_.then(d,d),w.blockedSegment.formatContext=F,w.legacyContext=rA,w.context=AA,jt(AA)}else throw w.blockedSegment.formatContext=F,w.legacyContext=rA,w.context=AA,jt(AA),re}}function ts(d){var w=d.blockedBoundary;d=d.blockedSegment,d.status=3,b0(this,w,d)}function v0(d,w,_){var F=d.blockedBoundary;d.blockedSegment.status=3,F===null?(w.allPendingTasks--,w.status!==2&&(w.status=2,w.destination!==null&&w.destination.close())):(F.pendingTasks--,F.forceClientRender||(F.forceClientRender=!0,d=_===void 0?Error(u(432)):_,F.errorDigest=w.onError(d),F.parentFlushed&&w.clientRenderedBoundaries.push(F)),F.fallbackAbortableTasks.forEach(function(rA){return v0(rA,w,_)}),F.fallbackAbortableTasks.clear(),w.allPendingTasks--,w.allPendingTasks===0&&(F=w.onAllReady,F()))}function _n(d,w){if(w.chunks.length===0&&w.children.length===1&&w.children[0].boundary===null){var _=w.children[0];_.id=w.id,_.parentFlushed=!0,_.status===1&&_n(d,_)}else d.completedSegments.push(w)}function b0(d,w,_){if(w===null){if(_.parentFlushed){if(d.completedRootSegment!==null)throw Error(u(389));d.completedRootSegment=_}d.pendingRootTasks--,d.pendingRootTasks===0&&(d.onShellError=Xe,w=d.onShellReady,w())}else w.pendingTasks--,w.forceClientRender||(w.pendingTasks===0?(_.parentFlushed&&_.status===1&&_n(w,_),w.parentFlushed&&d.completedBoundaries.push(w),w.fallbackAbortableTasks.forEach(ts,d),w.fallbackAbortableTasks.clear()):_.parentFlushed&&_.status===1&&(_n(w,_),w.completedSegments.length===1&&w.parentFlushed&&d.partialBoundaries.push(w)));d.allPendingTasks--,d.allPendingTasks===0&&(d=d.onAllReady,d())}function t0(d){if(d.status!==2){var w=he,_=Qe.current;Qe.current=oe;var F=De;De=d.responseState;try{var rA=d.pingedTasks,AA;for(AA=0;AA<rA.length;AA++){var hA=rA[AA],DA=d,re=hA.blockedSegment;if(re.status===0){jt(hA.context);try{Rt(DA,hA,hA.node),re.lastPushedText&&re.textEmbedded&&re.chunks.push(de),hA.abortSet.delete(hA),re.status=1,b0(DA,hA.blockedBoundary,re)}catch(Lt){if(et(),typeof Lt=="object"&&Lt!==null&&typeof Lt.then=="function"){var Ce=hA.ping;Lt.then(Ce,Ce)}else{hA.abortSet.delete(hA),re.status=4;var we=hA.blockedBoundary,ze=Lt,Tt=Wt(DA,ze);if(we===null?Yt(DA,ze):(we.pendingTasks--,we.forceClientRender||(we.forceClientRender=!0,we.errorDigest=Tt,we.parentFlushed&&DA.clientRenderedBoundaries.push(we))),DA.allPendingTasks--,DA.allPendingTasks===0){var It=DA.onAllReady;It()}}}finally{}}}rA.splice(0,AA),d.destination!==null&&r0(d,d.destination)}catch(Lt){Wt(d,Lt),Yt(d,Lt)}finally{De=F,Qe.current=_,_===oe&&jt(w)}}}function jn(d,w,_){switch(_.parentFlushed=!0,_.status){case 0:var F=_.id=d.nextSegmentId++;return _.lastPushedText=!1,_.textEmbedded=!1,d=d.responseState,x(w,Xt),x(w,d.placeholderPrefix),d=M(F.toString(16)),x(w,d),k(w,Dr);case 1:_.status=2;var rA=!0;F=_.chunks;var AA=0;_=_.children;for(var hA=0;hA<_.length;hA++){for(rA=_[hA];AA<rA.index;AA++)x(w,F[AA]);rA=Rn(d,w,rA)}for(;AA<F.length-1;AA++)x(w,F[AA]);return AA<F.length&&(rA=k(w,F[AA])),rA;default:throw Error(u(390))}}function Rn(d,w,_){var F=_.boundary;if(F===null)return jn(d,w,_);if(F.parentFlushed=!0,F.forceClientRender)F=F.errorDigest,k(w,gr),x(w,jr),F&&(x(w,Kr),x(w,M(lA(F))),x(w,Rr)),k(w,ln),jn(d,w,_);else if(0<F.pendingTasks){F.rootSegmentID=d.nextSegmentId++,0<F.completedSegments.length&&d.partialBoundaries.push(F);var rA=d.responseState,AA=rA.nextSuspenseID++;rA=b(rA.boundaryPrefix+AA.toString(16)),F=F.id=rA,gA(w,d.responseState,F),jn(d,w,_)}else if(F.byteSize>d.progressiveChunkSize)F.rootSegmentID=d.nextSegmentId++,d.completedBoundaries.push(F),gA(w,d.responseState,F.id),jn(d,w,_);else{if(k(w,Ar),_=F.completedSegments,_.length!==1)throw Error(u(391));Rn(d,w,_[0])}return k(w,yr)}function fn(d,w,_){return be(w,d.responseState,_.formatContext,_.id),Rn(d,w,_),mt(w,_.formatContext)}function k0(d,w,_){for(var F=_.completedSegments,rA=0;rA<F.length;rA++)C0(d,w,_,F[rA]);if(F.length=0,d=d.responseState,F=_.id,_=_.rootSegmentID,x(w,d.startInlineScript),d.sentCompleteBoundaryFunction?x(w,Ct):(d.sentCompleteBoundaryFunction=!0,x(w,rr)),F===null)throw Error(u(395));return _=M(_.toString(16)),x(w,F),x(w,nt),x(w,d.segmentPrefix),x(w,_),k(w,Qt)}function C0(d,w,_,F){if(F.status===2)return!0;var rA=F.id;if(rA===-1){if((F.id=_.rootSegmentID)===-1)throw Error(u(392));return fn(d,w,F)}return fn(d,w,F),d=d.responseState,x(w,d.startInlineScript),d.sentCompleteSegmentFunction?x(w,ie):(d.sentCompleteSegmentFunction=!0,x(w,ue)),x(w,d.segmentPrefix),rA=M(rA.toString(16)),x(w,rA),x(w,rt),x(w,d.placeholderPrefix),x(w,rA),k(w,Dt)}function r0(d,w){g=new Uint8Array(512),y=0;try{var _=d.completedRootSegment;if(_!==null&&d.pendingRootTasks===0){Rn(d,w,_),d.completedRootSegment=null;var F=d.responseState.bootstrapChunks;for(_=0;_<F.length-1;_++)x(w,F[_]);_<F.length&&k(w,F[_])}var rA=d.clientRenderedBoundaries,AA;for(AA=0;AA<rA.length;AA++){var hA=rA[AA];F=w;var DA=d.responseState,re=hA.id,Ce=hA.errorDigest,we=hA.errorMessage,ze=hA.errorComponentStack;if(x(F,DA.startInlineScript),DA.sentClientRenderFunction?x(F,ot):(DA.sentClientRenderFunction=!0,x(F,pt)),re===null)throw Error(u(395));x(F,re),x(F,Tr),(Ce||we||ze)&&(x(F,JA),x(F,M(PA(Ce||"")))),(we||ze)&&(x(F,JA),x(F,M(PA(we||"")))),ze&&(x(F,JA),x(F,M(PA(ze)))),k(F,Et)}rA.splice(0,AA);var Tt=d.completedBoundaries;for(AA=0;AA<Tt.length;AA++)k0(d,w,Tt[AA]);Tt.splice(0,AA),D(w),g=new Uint8Array(512),y=0;var It=d.partialBoundaries;for(AA=0;AA<It.length;AA++){var Lt=It[AA];A:{rA=d,hA=w;var Cr=Lt.completedSegments;for(DA=0;DA<Cr.length;DA++)if(!C0(rA,hA,Lt,Cr[DA])){DA++,Cr.splice(0,DA);var Fe=!1;break A}Cr.splice(0,DA),Fe=!0}if(!Fe){d.destination=null,AA++,It.splice(0,AA);return}}It.splice(0,AA);var n0=d.completedBoundaries;for(AA=0;AA<n0.length;AA++)k0(d,w,n0[AA]);n0.splice(0,AA)}finally{D(w),d.allPendingTasks===0&&d.pingedTasks.length===0&&d.clientRenderedBoundaries.length===0&&d.completedBoundaries.length===0&&w.close()}}function Zr(d,w){try{var _=d.abortableTasks;_.forEach(function(F){return v0(F,d,w)}),_.clear(),d.destination!==null&&r0(d,d.destination)}catch(F){Wt(d,F),Yt(d,F)}}return G0.renderToReadableStream=function(d,w){return new Promise(function(_,F){var rA,AA,hA=new Promise(function(we,ze){AA=we,rA=ze}),DA=gt(d,dA(w?w.identifierPrefix:void 0,w?w.nonce:void 0,w?w.bootstrapScriptContent:void 0,w?w.bootstrapScripts:void 0,w?w.bootstrapModules:void 0),LA(w?w.namespaceURI:void 0),w?w.progressiveChunkSize:void 0,w?w.onError:void 0,AA,function(){var we=new ReadableStream({type:"bytes",pull:function(ze){if(DA.status===1)DA.status=2,T(ze,DA.fatalError);else if(DA.status!==2&&DA.destination===null){DA.destination=ze;try{r0(DA,ze)}catch(Tt){Wt(DA,Tt),Yt(DA,Tt)}}},cancel:function(){Zr(DA)}},{highWaterMark:0});we.allReady=hA,_(we)},function(we){hA.catch(function(){}),F(we)},rA);if(w&&w.signal){var re=w.signal,Ce=function(){Zr(DA,re.reason),re.removeEventListener("abort",Ce)};re.addEventListener("abort",Ce)}t0(DA)})},G0.version="18.3.1",G0}var uo;function X1(){if(uo)return nn;uo=1;var a,u;return a=q1(),u=J1(),nn.version=a.version,nn.renderToString=a.renderToString,nn.renderToStaticMarkup=a.renderToStaticMarkup,nn.renderToNodeStream=a.renderToNodeStream,nn.renderToStaticNodeStream=a.renderToStaticNodeStream,nn.renderToReadableStream=u.renderToReadableStream,nn}X1();const p0="node-markers-native",Qs="node-markers-layer",Os="node-markers-layer-local",Re={standard:"marker-standard",standardNeighbor:"marker-standard-neighbor",hub:"marker-hub",hubNeighbor:"marker-hub-neighbor",gateway:"marker-gateway",gatewayNeighbor:"marker-gateway-neighbor",mobile:"marker-mobile",mobileNeighbor:"marker-mobile-neighbor",roomServer:"marker-room-server",roomServerNeighbor:"marker-room-server-neighbor",local:"marker-local",stale5Day:"marker-stale-5day",stale10Day:"marker-stale-10day",blinkBlack:"marker-blink-black",blinkBlackLocal:"marker-blink-black-local",blink:"marker-blink",blinkLocal:"marker-blink-local"},co=10,fo=6,Ah=5,eh=10,ho={tier1:vn[500],tier2:vn[700]};function th(a){if(!a)return 0;const u=Date.now(),g=a*1e3,y=(u-g)/(1e3*60*60*24);return y>=eh?2:y>=Ah?1:0}const $t=2,rh=nl*$t,mo=Ts*$t;function nh(a){const u=J0(),g=(Q,M,b=0,T=!1)=>{const O=rh,z=document.createElement("canvas");z.width=O,z.height=O;const W=z.getContext("2d",T?{colorSpace:"display-p3"}:void 0),V=O/2,J=O/2,iA=O/2-2-b/2;return W.beginPath(),W.arc(V,J,iA,0,Math.PI*2),W.fillStyle=Q,W.fill(),M&&b>0&&(W.strokeStyle=M,W.lineWidth=b*$t,W.stroke()),W.shadowColor="rgba(0,0,0,0.3)",W.shadowBlur=2*$t,W.shadowOffsetY=1*$t,{data:W.getImageData(0,0,O,O),pixelRatio:$t}},y=(Q,M=!1)=>{const b=mo,T=document.createElement("canvas");T.width=b,T.height=b;const O=T.getContext("2d",M?{colorSpace:"display-p3"}:void 0),z=b/2,W=b/2,V=Ts*.35*$t;return O.strokeStyle=Q,O.lineWidth=2.5*$t,O.lineCap="round",O.lineJoin="round",O.beginPath(),O.moveTo(z-V,W),O.lineTo(z,W-V),O.lineTo(z+V,W),O.stroke(),O.beginPath(),O.moveTo(z-V*.7,W),O.lineTo(z-V*.7,W+V*.7),O.lineTo(z+V*.7,W+V*.7),O.lineTo(z+V*.7,W),O.stroke(),O.beginPath(),O.moveTo(z-V*.2,W+V*.7),O.lineTo(z-V*.2,W+V*.2),O.lineTo(z+V*.2,W+V*.2),O.lineTo(z+V*.2,W+V*.7),O.stroke(),{data:O.getImageData(0,0,b,b),pixelRatio:$t}},x=(Q,M)=>{const b=mo,T=document.createElement("canvas");T.width=b,T.height=b;const O=T.getContext("2d"),z=b/2,W=b/2,V=Ts*.35*$t;return O.strokeStyle=Q,O.lineWidth=2.5*$t,O.lineCap="round",O.lineJoin="round",M&&(O.fillStyle=M),O.beginPath(),O.roundRect(z-V,W-V*.6,V*1.6,V*1.2,3*$t),M&&O.fill(),O.stroke(),O.beginPath(),O.moveTo(z-V*.3,W+V*.6),O.lineTo(z-V*.6,W+V),O.lineTo(z,W+V*.6),O.stroke(),{data:O.getImageData(0,0,b,b),pixelRatio:$t}},k="#00FF00",D={[Re.standard]:g(u.nodeFill),[Re.standardNeighbor]:g(u.neighborColor),[Re.hub]:g(u.hubColor),[Re.hubNeighbor]:g(u.neighborColor),[Re.gateway]:g(u.gatewayColor),[Re.gatewayNeighbor]:g(u.neighborColor),[Re.mobile]:g("transparent",u.mobileColor,2.5),[Re.mobileNeighbor]:g(u.neighborColor),[Re.roomServer]:x(u.roomColor),[Re.roomServerNeighbor]:x(u.neighborColor,"#1a1a1c"),[Re.local]:y(u.localColor),[Re.stale5Day]:g(ho.tier1),[Re.stale10Day]:g(ho.tier2),[Re.blinkBlack]:g("#000000"),[Re.blinkBlackLocal]:y("#000000"),[Re.blink]:g(k,void 0,0,!0),[Re.blinkLocal]:y(k,!0)};for(const[Q,M]of Object.entries(D))try{a.hasImage(Q)&&a.removeImage(Q),a.addImage(Q,M.data,{pixelRatio:M.pixelRatio})}catch{}}function po(a){var g;const u=(g=a.contact_type)==null?void 0:g.toLowerCase();return u==="room server"||u==="room_server"||u==="room"||u==="server"}function sh({neighborsWithLocation:a,localNode:u,localHash:g,zeroHopNeighbors:y,lastHopNeighborMap:x,meshTopology:k,hoveredMarker:D,onMarkerHover:Q,getNodeOpacity:M,shouldShowNode:b,openPopupId:T,onOpenPopup:O,onClosePopup:z,onNodeClick:W,blinkingNodes:V}){const{current:J}=Yr(),iA=R.useRef(!1),[eA,Z]=R.useState(!1);R.useEffect(()=>{var KA;const uA=(KA=J==null?void 0:J.getMap)==null?void 0:KA.call(J);if(!uA)return;const dA=()=>{try{nh(uA),iA.current=!0,eA||Z(!0)}catch(VA){console.warn("Failed to load node marker icons:",VA)}};uA.isStyleLoaded()?dA():uA.once("style.load",dA);const jA=()=>{uA.hasImage(Re.standard)||dA()};uA.on("styledata",jA);const LA=()=>{iA.current=!1,dA()},zA=new MutationObserver(VA=>{for(const Te of VA)if(Te.attributeName==="data-theme"){setTimeout(LA,100);break}});zA.observe(document.documentElement,{attributes:!0});const de=document.querySelector("[data-basemap]");let ZA=null;return de&&(ZA=new MutationObserver(VA=>{for(const Te of VA)if(Te.attributeName==="data-basemap"){setTimeout(LA,100);break}}),ZA.observe(de,{attributes:!0})),()=>{uA.off("styledata",jA),zA.disconnect(),ZA==null||ZA.disconnect()}},[J,eA]);const aA=R.useMemo(()=>{var jA;const uA=[],dA=[...a].sort(([LA,zA],[de,ZA])=>{const KA=(VA,Te)=>{var _e;return po(Te)?5e3:y.has(VA)?3e3:k.hubNodes.includes(VA)?2e3:(_e=k.gatewayNodes)!=null&&_e.includes(VA)?1e3:0};return KA(LA,zA)-KA(de,ZA)});for(const[LA,zA]of dA){if(!zA.latitude||!zA.longitude)continue;if(g){const Ke=Mr(g),$e=Mr(LA);if(Ho(Ke,$e)||LA===g)continue}const de=b(LA),ZA=M(LA,de);if(ZA<=.01)continue;const KA=y.has(LA),VA=k.hubNodes.includes(LA),Te=((jA=k.gatewayNodes)==null?void 0:jA.includes(LA))??!1,_e=k.mobileNodes.includes(LA),pe=po(zA),ce=k.centrality.get(LA)||0,Me=x.get(LA),Ie=zA.last_seen||(Me==null?void 0:Me.lastSeen),Le=th(Ie),fe=Le>0;let Pe=ZA;Le===2?Pe=Math.min(ZA,.25):Le===1&&(Pe=Math.min(ZA,.5));let te="standard";pe?te="roomServer":VA?te="hub":Te?te="gateway":_e&&(te="mobile"),uA.push({type:"Feature",geometry:{type:"Point",coordinates:[zA.longitude,zA.latitude]},properties:{hash:LA,name:zA.node_name||zA.name||"Unknown",hashPrefix:Mr(LA),iconType:te,isNeighbor:KA,isHub:VA,isGateway:Te,isMobile:_e,isRoomServer:pe,isStale:fe,staleTier:Le,isZeroHop:KA,opacity:Pe,blinkIntensity:0,lastSeenTimestamp:Ie,centrality:ce}})}return{type:"FeatureCollection",features:uA}},[a,g,y,x,k,M,b]),cA=R.useMemo(()=>!(u!=null&&u.latitude)||!(u!=null&&u.longitude)?{type:"FeatureCollection",features:[]}:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[u.longitude,u.latitude]},properties:{hash:"local",name:u.name,hashPrefix:g?Mr(g):"",iconType:"local",isNeighbor:!1,isHub:!1,isGateway:!1,isMobile:!1,isRoomServer:!1,isStale:!1,staleTier:0,isZeroHop:!1,opacity:1,blinkIntensity:0,centrality:0}}]},[u,g]),RA=R.useRef(T);R.useEffect(()=>{RA.current=T},[T]);const sA=R.useCallback(uA=>{var LA;if(!uA.features||uA.features.length===0)return;const jA=(LA=uA.features[0].properties)==null?void 0:LA.hash;jA&&(RA.current===jA?z==null||z():O&&O(jA),W&&jA!=="local"&&W(jA))},[O,z,W]),lA=R.useCallback(uA=>{var LA,zA;if(!uA.features||uA.features.length===0)return;const dA=(LA=J==null?void 0:J.getMap)==null?void 0:LA.call(J);dA&&(dA.getCanvas().style.cursor="pointer");const jA=(zA=uA.features[0].properties)==null?void 0:zA.hash;jA&&Q(jA)},[J,Q]),BA=R.useCallback(()=>{var dA;const uA=(dA=J==null?void 0:J.getMap)==null?void 0:dA.call(J);uA&&(uA.getCanvas().style.cursor=""),Q(null)},[J,Q]);R.useEffect(()=>{var jA;const uA=(jA=J==null?void 0:J.getMap)==null?void 0:jA.call(J);if(!uA||!eA)return;const dA=[Qs,Os];for(const LA of dA)uA.on("click",LA,sA),uA.on("mouseenter",LA,lA),uA.on("mouseleave",LA,BA);return()=>{for(const LA of dA)uA.off("click",LA,sA),uA.off("mouseenter",LA,lA),uA.off("mouseleave",LA,BA)}},[J,eA,sA,lA,BA]);const SA=R.useRef(aA),bA=R.useRef(cA);R.useEffect(()=>{SA.current=aA,bA.current=cA},[aA,cA]),R.useEffect(()=>{var LA;const uA=(LA=J==null?void 0:J.getMap)==null?void 0:LA.call(J);if(!uA||!eA||!V||V.size===0)return;const dA=uA.getSource(p0),jA=uA.getSource(`${p0}-local`);if(!(!dA&&!jA)){if(dA){const zA=SA.current;let de=!1;const ZA=zA.features.map(KA=>{const VA=V.get(KA.properties.hash)??0;return VA!==KA.properties.blinkIntensity?(de=!0,{...KA,properties:{...KA.properties,blinkIntensity:VA}}):KA});de&&dA.setData({type:"FeatureCollection",features:ZA})}if(jA&&g){const zA=V.get(g)??0,de=bA.current;de.features.length>0&&de.features[0].properties.blinkIntensity!==zA&&jA.setData({type:"FeatureCollection",features:[{...de.features[0],properties:{...de.features[0].properties,blinkIntensity:zA}}]})}}},[J,eA,V,g]);const kA=R.useMemo(()=>{if(!T)return{type:"FeatureCollection",features:[]};if(T==="local"&&(u!=null&&u.latitude)&&(u!=null&&u.longitude))return{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[u.longitude,u.latitude]},properties:{hash:"local"}}]};const uA=aA.features.find(dA=>dA.properties.hash===T);return uA?{type:"FeatureCollection",features:[{type:"Feature",geometry:uA.geometry,properties:{hash:uA.properties.hash}}]}:{type:"FeatureCollection",features:[]}},[T,u,aA]);if(!eA)return null;const FA=J0().localColor||"#F59E0B",IA=["case",[">",["get","blinkIntensity"],.66],Re.blink,[">",["get","blinkIntensity"],.33],Re.blinkBlack,["==",["get","staleTier"],2],Re.stale10Day,["==",["get","staleTier"],1],Re.stale5Day,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],Re.roomServerNeighbor,Re.roomServer],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],Re.hubNeighbor,Re.hub],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],Re.gatewayNeighbor,Re.gateway],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],Re.mobileNeighbor,Re.mobile],["case",["get","isNeighbor"],Re.standardNeighbor,Re.standard]],WA=["interpolate",["linear"],["zoom"],fo,.25,co,1],wA=["get","opacity"];return m.jsxs(m.Fragment,{children:[m.jsx(Vr,{id:p0,type:"geojson",data:aA,children:m.jsx(Zt,{id:Qs,type:"symbol",layout:{"icon-image":IA,"icon-size":WA,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":wA}})}),m.jsx(Vr,{id:`${p0}-local`,type:"geojson",data:cA,children:m.jsx(Zt,{id:Os,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],Re.blinkLocal,[">",["get","blinkIntensity"],.33],Re.blinkBlackLocal,Re.local],"icon-size":WA,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),m.jsx(Vr,{id:`${p0}-selection`,type:"geojson",data:kA,children:m.jsx(Zt,{id:"node-markers-selection-ring",type:"circle",paint:{"circle-radius":["interpolate",["linear"],["zoom"],fo,4,co,14],"circle-color":"transparent","circle-stroke-color":FA,"circle-stroke-width":2.5,"circle-stroke-opacity":.85}})})]})}const ih=[Qs,Os],zs="topology-validated-edges-native",Hs="topology-weak-edges-native",Gs="neighbor-edges-native",go="topology-weak-edges-native",U0="topology-validated-edges-native",Ss="neighbor-edges-native",Ms={type:"FeatureCollection",features:[]},g0={"line-cap":"round","line-join":"round"},yo={"line-color":"transparent","line-width":16,"line-opacity":0};function oh(a,u,g,y,x,k){const D=Ks(),Q=a!==null,M=x&&x.size>0,b=k&&k.size>0,T=M?Array.from(x):[],O=b?Array.from(k):[],z=u,W=.5,J=(()=>{if(z<=0)return["get","baseColor"];const vA=1-z*.5;return["case",[">=",["get","brightnessScore"],vA],"#FFFFFF",["get","baseColor"]]})(),eA=z<=0?1:["max",.1,["+",1,["*",z,3,["-",["get","brightnessScore"],W]]]],aA=M?["in",["get","key"],["literal",T]]:b?["in",["get","key"],["literal",O]]:Q?["==",["get","key"],a]:!1,cA=Q||M||b,RA=D.edges.hoverLoop,sA=D.edges.highlight;return{"line-color":cA?["case",aA,M?RA:b?sA:["get","hoverColor"],J]:J,"line-width":cA?["case",aA,["max",["*",["get","baseWidth"],g,1.3],3.5],["*",["get","baseWidth"],g]]:["*",["get","baseWidth"],g],"line-opacity":["case",["<",["get","brightnessScore"],y],0,cA?["case",aA,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],eA,.35]]:["*",["get","baseOpacity"],eA]]}}const lh=10,ah=6;function uh(a){const u=a!==null,{YELLOW:g,GREEN:y,RED:x,GRAY:k}=V0,D=["to-number",["get","listenerScore"],0],Q=["to-number",["get","loudScore"],0],b=["/",D,["max",["+",D,Q],1]],T=["case",["all",["==",D,0],["==",Q,0]],k,[">=",b,.97],y,["<=",b,.03],x,["interpolate",["linear"],b,.03,x,.5,g,.97,y]],O=.2,iA=["*",["+",O,["*",["to-number",["get","trafficWeight"],0],1-O]],8],eA=5,Z=u?["case",["==",["get","key"],a],["max",iA,eA],iA]:iA,aA=u?["case",["==",["get","key"],a],["max",["*",iA,.25],eA*.25],["*",iA,.25]]:["*",iA,.25];return{"line-color":T,"line-width":["interpolate",["linear"],["zoom"],ah,aA,lh,Z],"line-opacity":u?["case",["==",["get","key"],a],1,.35]:.9}}function ch({showTopology:a,isExiting:u,hoveredEdgeKey:g,highlightedLoopEdges:y,highlightedFocusEdges:x,onEdgeHover:k,onLoopHover:D,loops:Q=[],neighborNames:M={},opacityBias:b=.5,widthMultiplier:T=1,trafficFilter:O=0,showNeighborLines:z=!0,disableHover:W=!1}){const{current:V}=Yr(),J=a||u,iA=!0,eA=z?"visible":"none",Z=W||u,aA=R.useRef(null),cA=R.useRef(Z),RA=R.useRef(new Map),sA=R.useRef(M),lA=R.useRef(D);R.useLayoutEffect(()=>{cA.current=Z,sA.current=M,lA.current=D});const BA=R.useMemo(()=>cc(Q),[Q]);R.useLayoutEffect(()=>{RA.current=BA},[BA]);const SA=R.useCallback(wA=>{var LA,zA;if(cA.current||!wA.features||wA.features.length===0)return;const dA=wA.features[0].properties;if(!(dA!=null&&dA.key))return;const jA=dA.key;if(jA!==aA.current){aA.current=jA;const de=dA.isNeighborEdge===!0||dA.isNeighborEdge==="true",ZA=dA.isLoopEdge===!0||dA.isLoopEdge==="true";if(de){const KA={key:jA,fromName:"Local",toName:dA.name,certainCount:Number(dA.packetCount)||0,confidence:1,isBackbone:!1,isLoopEdge:!1,isDirectPath:!0,isZeroHop:!0,symmetryRatio:1,dominantDirection:"balanced",isHubConnection:!1};k(jA,[wA.lngLat.lng,wA.lngLat.lat],KA),(LA=lA.current)==null||LA.call(lA,null)}else if(ZA&&lA.current){const KA=RA.current.get(jA)??[];if(KA.length>0){const VA=new Set;for(const ce of KA)for(const Me of ce.edgeKeys)VA.add(Me);const _e=KA[0].nodes.map(ce=>sA.current[ce]||ce.substring(0,4)),pe={loops:KA,highlightedEdgeKeys:VA,hoveredEdgeKey:jA,nodeNames:_e};lA.current(pe,[wA.lngLat.lng,wA.lngLat.lat]),k(jA)}else{const VA={key:jA,fromName:dA.fromName,toName:dA.toName,certainCount:Number(dA.certainCount),confidence:Number(dA.confidence),isBackbone:dA.isBackbone===!0||dA.isBackbone==="true",isLoopEdge:!0,isDirectPath:dA.isDirectPath===!0||dA.isDirectPath==="true",isZeroHop:dA.isZeroHop===!0||dA.isZeroHop==="true",symmetryRatio:Number(dA.symmetryRatio),dominantDirection:dA.dominantDirection,isHubConnection:dA.isHubConnection===!0||dA.isHubConnection==="true"};k(jA,[wA.lngLat.lng,wA.lngLat.lat],VA)}}else{const KA={key:jA,fromName:dA.fromName,toName:dA.toName,certainCount:Number(dA.certainCount),confidence:Number(dA.confidence),isBackbone:dA.isBackbone===!0||dA.isBackbone==="true",isLoopEdge:ZA,isDirectPath:dA.isDirectPath===!0||dA.isDirectPath==="true",isZeroHop:dA.isZeroHop===!0||dA.isZeroHop==="true",symmetryRatio:Number(dA.symmetryRatio),dominantDirection:dA.dominantDirection,isHubConnection:dA.isHubConnection===!0||dA.isHubConnection==="true"};k(jA,[wA.lngLat.lng,wA.lngLat.lat],KA),(zA=lA.current)==null||zA.call(lA,null)}}},[k]),bA=R.useCallback(()=>{var wA;aA.current!==null&&(aA.current=null,k(null),(wA=lA.current)==null||wA.call(lA,null))},[k]);R.useEffect(()=>{var LA;const wA=(LA=V==null?void 0:V.getMap)==null?void 0:LA.call(V);if(!wA||!J)return;const uA="topology-validated-edges-hitarea-native",dA=()=>{try{return wA.getStyle()&&wA.getLayer(uA)}catch{return!1}},jA=()=>dA()?(wA.on("mousemove",uA,SA),wA.on("mouseleave",uA,bA),!0):!1;if(!jA()){const zA=()=>{jA()&&wA.off("styledata",zA)};return wA.on("styledata",zA),()=>{try{wA.off("styledata",zA),dA()&&(wA.off("mousemove",uA,SA),wA.off("mouseleave",uA,bA))}catch{}}}return()=>{try{dA()&&(wA.off("mousemove",uA,SA),wA.off("mouseleave",uA,bA))}catch{}}},[V,J,SA,bA]),R.useEffect(()=>{var LA;const wA=(LA=V==null?void 0:V.getMap)==null?void 0:LA.call(V);if(!wA||!iA||!z)return;const uA="neighbor-edges-hitarea-native",dA=()=>{try{return wA.getStyle()&&wA.getLayer(uA)}catch{return!1}},jA=()=>dA()?(wA.on("mousemove",uA,SA),wA.on("mouseleave",uA,bA),!0):!1;if(!jA()){const zA=()=>{jA()&&wA.off("styledata",zA)};return wA.on("styledata",zA),()=>{try{wA.off("styledata",zA),dA()&&(wA.off("mousemove",uA,SA),wA.off("mouseleave",uA,bA))}catch{}}}return()=>{try{dA()&&(wA.off("mousemove",uA,SA),wA.off("mouseleave",uA,bA))}catch{}}},[V,iA,z,SA,bA]),R.useEffect(()=>{var ZA;const wA=(ZA=V==null?void 0:V.getMap)==null?void 0:ZA.call(V);if(!wA)return;let uA=null;const dA=(KA,VA)=>{try{if(wA.getLayer(KA)&&wA.getLayer(VA))return wA.moveLayer(KA,VA),!0}catch{}return!1},jA=()=>{try{if(!wA.getLayer("node-markers-layer"))return;dA(Ss,"node-markers-layer"),dA("neighbor-edges-hitarea-native",Ss),(dA(U0,"neighbor-edges-hitarea-native")||dA(U0,"node-markers-layer"))&&dA("topology-validated-edges-hitarea-native",U0),dA(go,"topology-validated-edges-hitarea-native")}catch{}},LA=()=>{uA&&clearTimeout(uA),uA=setTimeout(jA,50)},zA=setTimeout(jA,100);wA.on("styledata",LA);const de=KA=>{(KA.sourceId===zs||KA.sourceId===Hs||KA.sourceId===Gs)&&LA()};return wA.on("sourcedata",de),()=>{clearTimeout(zA),uA&&clearTimeout(uA);try{wA.off("styledata",LA),wA.off("sourcedata",de)}catch{}}},[V,J,iA,z]);const kA=Z?null:g,IA=oh(kA,b,T,O,Z?null:y,x??null),WA=uh(kA);return m.jsxs(m.Fragment,{children:[J&&m.jsx(Vr,{id:Hs,type:"geojson",data:Ms,children:m.jsx(Zt,{id:go,type:"line",paint:IA,layout:{...g0,visibility:eA}})}),J&&m.jsxs(Vr,{id:zs,type:"geojson",data:Ms,children:[m.jsx(Zt,{id:"topology-validated-edges-hitarea-native",type:"line",paint:yo,layout:{...g0,visibility:eA}}),m.jsx(Zt,{id:U0,type:"line",paint:IA,layout:{...g0,visibility:eA}})]}),m.jsxs(Vr,{id:Gs,type:"geojson",data:Ms,children:[m.jsx(Zt,{id:"neighbor-edges-hitarea-native",type:"line",paint:yo,layout:{...g0,visibility:eA}}),m.jsx(Zt,{id:Ss,type:"line",paint:WA,layout:{...g0,visibility:eA}})]})]})}const fh=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function hh({targetHash:a,nodeCoordinates:u,onComplete:g}){const{current:y}=Yr(),x=R.useRef(null);return R.useEffect(()=>{if(!y||!a||a===x.current)return;const k=u.get(a);if(!k)return;const D=y.getMap();D.isMoving()&&D.stop(),x.current=a;const[Q,M]=k;y.flyTo({center:[M,Q],zoom:10,duration:2500,essential:!0}),setTimeout(()=>{g==null||g()},2600)},[a,u,y,g]),null}function dh({highlightedEdgeKey:a,validatedPolylines:u,weakPolylines:g,onEnsureTopology:y}){const{current:x}=Yr(),k=R.useRef(null);return R.useEffect(()=>{if(!x||!a||a===k.current)return;k.current=a,y();const D=u.find(z=>z.edge.key===a)||g.find(z=>z.edge.key===a);if(!D||x.getMap().isMoving())return;const M=(D.from[0]+D.to[0])/2,b=(D.from[1]+D.to[1])/2,T=x.getZoom(),O=Math.max(T,11);x.easeTo({center:[b,M],zoom:O,duration:500})},[a,u,g,x,y]),null}const xo="link-quality-edges",mh="link-quality-edges-layer",Y0="link-quality-edges-hitarea",wo={type:"FeatureCollection",features:[]};function ph(a,u){return a<u?`${a}|${u}`:`${u}|${a}`}function gh(a,u,g,y,x){const k=[];for(const D of a){if(g&&D.nodeA.hash!==g&&D.nodeB.hash!==g)continue;const Q=u.get(D.nodeA.hash),M=u.get(D.nodeB.hash);if(!Q||!M)continue;const b=Za(D.composite.mean,x),T=y[b]||"#888888",O=2+D.confidence*2,z=ph(D.nodeA.hash,D.nodeB.hash);k.push({type:"Feature",geometry:{type:"LineString",coordinates:[[Q[1],Q[0]],[M[1],M[0]]]},properties:{key:z,color:T,width:O,quality:D.quality,compositeMeanSnr:D.composite.mean,confidence:D.confidence,fromHash:D.nodeA.hash,toHash:D.nodeB.hash,fromPrefix:D.nodeA.prefix,toPrefix:D.nodeB.prefix,fromName:D.nodeA.name||D.nodeA.prefix,toName:D.nodeB.name||D.nodeB.prefix,asymmetryDb:D.asymmetryDb}})}return{type:"FeatureCollection",features:k}}const vo={"line-cap":"round","line-join":"round"},yh={"line-color":["get","color"],"line-width":["get","width"],"line-opacity":.85},xh={"line-color":"transparent","line-width":16,"line-opacity":0};function wh({visible:a,nodeCoordinates:u,focusedNodeHash:g=null,basemapMode:y}){const{current:x}=Yr(),k=Uo(),D=Fo(),Q=Ka(),M=R.useMemo(()=>$a(),[]),b=R.useMemo(()=>!a||k.length===0||D.size===0?wo:gh(k,u,g,M,Q),[a,k,D.size,u,g,M,Q]);R.useEffect(()=>{if(!x)return;const O=x.getMap();if(O)try{const z=O.getSource(xo);z&&"setData"in z&&(z.setData(b),O.triggerRepaint())}catch{}},[b,x]);const T=a?"visible":"none";return m.jsxs(Vr,{id:xo,type:"geojson",data:wo,children:[m.jsx(Zt,{id:mh,type:"line",layout:{...vo,visibility:T},paint:yh}),m.jsx(Zt,{id:Y0,type:"line",layout:{...vo,visibility:T},paint:xh})]})}const vh="rgba(167, 139, 250, 0.15)",bo=500,bh=.5,ko=2e3,Co=1500,kh=1e3;function Ch(a,u,g,y=64){const x=[],D=g/6371e3*(180/Math.PI),Q=D/Math.cos(u*Math.PI/180);for(let M=0;M<=y;M++){const b=M/y*2*Math.PI,T=a+Q*Math.cos(b),O=u+D*Math.sin(b);x.push([T,O])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[x]}}}function Eh({ghost:a,neighborCoordinates:u,onHighlightedNeighborsChange:g}){const{current:y}=Yr(),x=R.useRef(null),k=R.useRef(null),D=R.useMemo(()=>a?new Set(a.commonNeighbors):new Set,[a]);R.useEffect(()=>{g==null||g(D)},[D,g]);const Q=R.useMemo(()=>{if(!(a!=null&&a.commonNeighbors)||a.commonNeighbors.length<2)return ko*4;let T=0;const O=[];for(const z of a.commonNeighbors){const W=u.get(z);W&&O.push(W)}a.estimatedLocation&&O.push([a.estimatedLocation.lat,a.estimatedLocation.lon]);for(let z=0;z<O.length;z++)for(let W=z+1;W<O.length;W++){const V=Vo(O[z][0],O[z][1],O[W][0],O[W][1]);V>T&&(T=V)}return Math.max(T,bo*4)},[a,u]),M=R.useMemo(()=>{if(!(a!=null&&a.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:T,lon:O,uncertaintyM:z}=a.estimatedLocation,W=Q*bh,V=z>0?z:ko,J=Math.max(bo,Math.min(V,W));return{type:"FeatureCollection",features:[Ch(O,T,J)]}},[a,Q]);if(R.useEffect(()=>{if(!y)return;const T=y.getMap();if(a&&a.prefix!==k.current){if(k.current=a.prefix,!x.current&&T.getZoom()>3){const z=T.getCenter();x.current={center:[z.lng,z.lat],zoom:T.getZoom(),pitch:T.getPitch(),bearing:T.getBearing()}}const O=[];for(const z of a.commonNeighbors){const W=u.get(z);W&&O.push([W[1],W[0]])}if(a.estimatedLocation&&O.push([a.estimatedLocation.lon,a.estimatedLocation.lat]),O.length>0){const z=()=>{var W;if(T.isMoving()){setTimeout(z,100);return}if(O.length===1)y.flyTo({center:O[0],zoom:13,duration:Co});else{let V=1/0,J=-1/0,iA=1/0,eA=-1/0;for(const[Z,aA]of O)V=Math.min(V,Z),J=Math.max(J,Z),iA=Math.min(iA,aA),eA=Math.max(eA,aA);if((W=a.estimatedLocation)!=null&&W.uncertaintyM){const Z=a.estimatedLocation.uncertaintyM/111e3;V-=Z,J+=Z,iA-=Z,eA+=Z}y.fitBounds([[V,iA],[J,eA]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:Co})}};setTimeout(z,50)}}if(!a&&k.current!==null&&(k.current=null,x.current)){const O=x.current,z=()=>{if(T.isMoving()){setTimeout(z,100);return}y.flyTo({center:O.center,zoom:O.zoom,pitch:O.pitch,bearing:O.bearing,duration:kh}),x.current=null};setTimeout(z,50)}},[a,y,u]),!(a!=null&&a.estimatedLocation))return null;const b={"fill-color":vh,"fill-opacity":.8};return m.jsx(Vr,{id:"ghost-uncertainty-circle",type:"geojson",data:M,children:m.jsx(Zt,{id:"ghost-uncertainty-fill",type:"fill",paint:b})})}const bl=[{target:"Map",fn:"gps",minStage:1,when:bi},{target:"Map",fn:"_advertNodeType",minStage:1,when:bi},{target:"Topology",fn:"traceHops",minStage:1,when:ki},{target:"Topology",fn:"path.entries",minStage:1,when:iu},{target:"Topology",fn:"traceSrc",minStage:1,when:ki}];Yo(bl);const Sh={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},Mh={longitude:0,latitude:0,zoom:2};function Bh(a){return!!a&&Number.isFinite(a.longitude)&&Number.isFinite(a.latitude)&&Number.isFinite(a.zoom)&&Math.abs(a.longitude)<=180&&Math.abs(a.latitude)<=90&&a.zoom>=0}function Mt(a,u){return typeof a=="number"&&typeof u=="number"&&Number.isFinite(a)&&Number.isFinite(u)&&Math.abs(a)<=90&&Math.abs(u)<=180&&!(a===0&&u===0)}function Dh(a,u,g,y){return Vo(a,u,g,y)/1e3}function _h(a,u){if(a.length<=2)return a;let g,y;if(Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude))g=u.latitude,y=u.longitude;else{let b=0,T=0;for(const[O,z]of a)b+=O,T+=z;g=b/a.length,y=T/a.length}const x=a.map(([b,T])=>({pos:[b,T],dist:Dh(g,y,b,T)}));x.sort((b,T)=>b.dist-T.dist);const k=Math.floor(x.length/2),D=x[k].dist,Q=Math.max(D*3,50),M=x.filter(b=>b.dist<=Q).map(b=>b.pos);return M.length<a.length*.5?a:M}function jh(a,u){let g=a.filter(([W,V])=>Mt(W,V));if(Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude)&&g.push([u.latitude,u.longitude]),g.length===0)return null;if(g.length===1){const[W,V]=g[0];return{longitude:V,latitude:W,zoom:14}}g=_h(g,u);let y=1/0,x=-1/0,k=1/0,D=-1/0;for(const[W,V]of g)y=Math.min(y,V),x=Math.max(x,V),k=Math.min(k,W),D=Math.max(D,W);const Q=(y+x)/2,M=(k+D)/2,b=D-k,T=x-y,O=Math.max(b,T);let z=16;return O>0&&(z=Math.floor(Math.log2(360/O*1.2)),z=Math.max(1,Math.min(14,z))),z=Math.min(z+1,12),{longitude:Q,latitude:M,zoom:z}}function Rh(a,u,g,y){var x;if(u){const k=u.loops[0],D=u.loops.length,Q=[{label:"hops",value:k.size},{label:"seen",value:k.minCertainCount}],M=[];return k.includesLocal&&M.push({text:"★ Includes your node",color:"text-sys-amber"}),D>1&&M.push({text:`+${D-1} overlapping`,color:"text-sys-indigo/70"}),{type:"loop",title:{icon:"⟳",text:`Redundant Path${D>1?"s":""}`,color:"text-sys-indigo"},subtitle:{text:`${u.nodeNames.join(" → ")} → ${u.nodeNames[0]}`,color:"text-fg-secondary",mono:!0},stats:Q,badges:M}}if((a==null?void 0:a.type)==="neighbor"){const k=a.properties,D=[];k.rssi!==void 0&&k.rssi!==null&&D.push({label:"RSSI",value:`${Math.round(k.rssi)} dBm`,unit:k.hasAvgRssi?"avg":void 0}),k.snr!==void 0&&k.snr!==null&&D.push({label:"SNR",value:`${Number(k.snr).toFixed(1)} dB`,unit:k.hasAvgSnr?"avg":void 0});const Q=k.listenerScore??0,M=k.loudScore??0,b=Q>0||M>0;return b&&(D.push({label:"listener",value:Q,color:"text-sys-green"}),D.push({label:"loud",value:M,color:"text-sys-red"})),k.packetCount!==void 0&&!b&&D.push({label:"packets",value:Number(k.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:k.prefix?`${k.name} (${k.prefix})`:k.name,color:"text-sys-amber"},subtitle:{text:"Direct RF Neighbor",color:"text-sys-amber/70"},stats:D,badges:[]}}if((a==null?void 0:a.type)==="topology"){const k=a.properties,D=g>0?Number(k.certainCount)/g:0,Q=[{label:"validations",value:k.certainCount},{label:"of max traffic",value:`${Math.round(D*100)}%`},{label:"confidence",value:`${Math.round(Number(k.confidence)*100)}%`}];if(k.symmetryRatio!==void 0&&k.symmetryRatio<1){const T=k.dominantDirection==="forward"?"→":k.dominantDirection==="reverse"?"←":"↔";Q.push({label:"symmetric",value:`${T} ${Math.round(k.symmetryRatio*100)}%`,color:"text-fg-muted"})}const M=(x=y==null?void 0:y.get(k.key))==null?void 0:x.traceQuality;if(M!=null&&M.composite){const T=M.composite;Q.push({label:"trace SNR",value:`${T.mean.toFixed(1)} dB`,unit:`n=${T.count}`,color:T.mean>=10?"text-sys-green":T.mean>=0?"text-sys-amber":"text-sys-red"}),M.asymmetryDb!=null&&M.asymmetryDb>1&&Q.push({label:"asymmetry",value:`${M.asymmetryDb.toFixed(1)} dB`,color:M.asymmetryDb>5?"text-sys-red":"text-sys-amber"})}const b=[];if(k.isBackbone&&b.push({text:"Backbone",color:"text-zinc-300"}),k.isLoopEdge&&b.push({text:"Redundant",color:"text-sys-indigo"}),k.isDirectPath&&b.push({text:"Direct Path",color:"text-sys-teal"}),M){const T=M.quality==="excellent"||M.quality==="good"?"text-sys-green":M.quality==="fair"?"text-sys-amber":M.quality==="poor"||M.quality==="critical"?"text-sys-red":"text-fg-muted";M.quality!=="unknown"&&b.push({text:`TRACE ${M.quality}`,color:T})}return{type:"topology",title:{icon:"",text:`${k.fromName} ↔ ${k.toName}`,color:"text-fg-primary"},stats:Q,badges:b}}return null}function Th({data:a}){const u=a.subtitle&&a.type==="loop",g=a.subtitle&&a.type!=="loop";return m.jsxs("div",{className:"w-[540px]",children:[m.jsxs("div",{className:"flex items-center justify-between h-5",children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.title.icon&&m.jsx("span",{className:`${a.title.color} text-base leading-none flex-shrink-0`,children:a.title.icon}),m.jsx("span",{className:`${a.title.color} font-semibold text-[13px] truncate`,children:a.title.text}),g&&m.jsx("span",{className:`${a.subtitle.color} text-[11px] flex-shrink-0`,children:a.subtitle.text})]}),a.badges.length>0&&m.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:a.badges.map((y,x)=>m.jsx("span",{className:`${y.color} text-[11px] font-medium`,children:y.text},x))})]}),u&&m.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:m.jsx("span",{className:"type-data-xs text-fg-muted truncate block",children:a.subtitle.text})}),m.jsx("div",{className:`flex items-center gap-4 h-4 ${u?"mt-1":"mt-1.5"} text-[11px]`,children:a.stats.map((y,x)=>m.jsxs("span",{className:"whitespace-nowrap",children:[m.jsx("span",{className:`font-mono tabular-nums font-semibold ${y.color??"text-fg-primary"}`,children:y.value}),m.jsx("span",{className:"text-fg-muted ml-1",children:y.label}),y.unit&&m.jsx("span",{className:"text-fg-muted/50 ml-0.5",children:y.unit})]},x))})]})}function Dd({neighbors:a,localNode:u,localHash:g,onRemoveNode:y,selectedNodeHash:x,onNodeSelected:k,highlightedEdgeKey:D,highlightedGhost:Q}){Wo(bl);const M=R.useRef(null),b=qa(),T=Ja(),O=Oo(),z=Xa(),W=Au(),V=Uo(),[J,iA]=R.useState(!1),eA=mn(H=>H.viewState),Z=Bh(eA)?eA:null,aA=mn(H=>H.toggles),cA=mn(H=>H.hasAnalyzed),RA=mn(H=>H.setViewState),sA=mn(H=>H.setToggle),lA=mn(H=>H.setHasAnalyzed),BA=mn(H=>H.modalMapOpen),SA=gs(H=>H.preloadFromNodes),bA=gs(H=>H.isLoading),kA=gs(H=>H.terrainGrid),vA=g??z,FA=R.useMemo(()=>{const H=[];for(const[,oA]of Object.entries(a))Mt(oA.latitude,oA.longitude)&&H.push([oA.latitude,oA.longitude]);return H},[a]),IA=R.useMemo(()=>jh(FA,u),[FA,u]),[WA,wA]=R.useState(()=>Z??IA??Mh),uA=R.useCallback(H=>{wA(H),queueMicrotask(()=>RA(H))},[RA]),dA=R.useRef(!!Z);R.useEffect(()=>{!dA.current&&IA&&!Z?(wA(IA),queueMicrotask(()=>RA(IA)),dA.current=!0,setTimeout(()=>iA(!0),50)):Z?setTimeout(()=>iA(!0),50):FA.length===0&&!Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude)&&iA(!0)},[IA,Z,RA,FA.length,u]);const[jA,LA]=R.useState(!1),[zA,de]=R.useState(()=>aA.showTopology&&!O.topologyLoadComplete?!1:aA.showTopology),[ZA,KA]=R.useState(aA.showNeighborLines),[VA,Te]=R.useState(!1),[_e,pe]=R.useState(aA.showMinCut),[ce,Me]=R.useState(If),[Ie,Le]=R.useState(aA.show3DTerrain),[fe,Pe]=R.useState(aA.showLinkQuality),[te,Ke]=R.useState(()=>aA.nodeFilters.length>0?aA.nodeFilters:[...y0]),$e=R.useCallback(H=>{de(oA=>{const pA=typeof H=="function"?H(oA):H;return queueMicrotask(()=>sA("showTopology",pA)),pA})},[sA]),At=R.useCallback(H=>{KA(oA=>{const pA=typeof H=="function"?H(oA):H;return queueMicrotask(()=>sA("showNeighborLines",pA)),pA})},[sA]),it=R.useCallback(H=>{pe(oA=>{const pA=typeof H=="function"?H(oA):H;return queueMicrotask(()=>sA("showMinCut",pA)),pA})},[sA]),St=R.useCallback(H=>{Le(oA=>{const pA=typeof H=="function"?H(oA):H;return queueMicrotask(()=>sA("show3DTerrain",pA)),pA})},[sA]),Ve=R.useCallback(H=>{Pe(oA=>{const pA=typeof H=="function"?H(oA):H;return queueMicrotask(()=>sA("showLinkQuality",pA)),pA})},[sA]),We=R.useCallback(H=>{Ke(H),queueMicrotask(()=>sA("nodeFilters",H))},[sA]),[ke,Ze]=R.useState(null),[at,Bt]=R.useState(null),[Jt,Xt]=R.useState(null),[Dr,Ar]=R.useState(null),[on]=R.useState(0),[_r]=R.useState(.5),[gr]=R.useState(0),[yr,jr]=R.useState(null),[Rr,Kr]=R.useState(""),[ln,gA]=R.useState(!1),[xr,er]=R.useState(!1),[Se,fr]=R.useState(()=>cA&&!O.topologyLoadComplete?!1:cA);R.useEffect(()=>{if(O.topologyLoadComplete)return;const H=cA&&!Se,oA=aA.showTopology&&!zA;!H&&!oA||queueMicrotask(()=>{H&&lA(!1),oA&&sA("showTopology",!1)})},[cA,aA.showTopology,O.topologyLoadComplete,Se,zA,lA,sA]);const tr=R.useCallback(H=>{fr(H),queueMicrotask(()=>lA(H))},[lA]),[Ye,ct]=R.useState(null),hr=R.useCallback(H=>ct(H),[]),kt=R.useCallback(()=>ct(null),[]),[,wr]=R.useState(new Set),dt=x0(H=>H.coveragePoints),tA=x0(H=>H.isVisible),yA=x0(H=>H.brightness),TA=x0(H=>H.openModal),mA=Ws(),t=Zo(),C=qo(),xe=Pu(),Be=eu(),Ue=tu(H=>H.messages);Qu();const qA=R.useRef(null);R.useEffect(()=>{if(!t||!M.current){qA.current&&(clearInterval(qA.current),qA.current=null);return}return qA.current=setInterval(()=>{var Qe;const H=Jo();if(!H)return;const oA=(Qe=M.current)==null?void 0:Qe.getMap();if(!oA)return;const pA=oA.project([H.lon,H.lat]),{width:NA,height:HA}=oA.getCanvas(),oe=.2;pA.x>NA*oe&&pA.x<NA*(1-oe)&&pA.y>HA*oe&&pA.y<HA*(1-oe)||oA.easeTo({center:[H.lon,H.lat],duration:1500,easing:st=>st*(2-st)})},2e3),()=>{qA.current&&(clearInterval(qA.current),qA.current=null)}},[t]);const be=Jf(),mt=Xf(),ue=Lo(),ie=ru(),rt=R.useRef(!1);R.useEffect(()=>{dt.length>0&&tA&&!rt.current&&(At(!1),rt.current=!0)},[dt.length,tA]);const Dt=R.useRef(null);R.useEffect(()=>{if(x&&x!==Dt.current){Dt.current=x;const H=setTimeout(()=>{ct(x)},1250);return()=>clearTimeout(H)}},[x]);const[rr,Ct]=R.useState(null),[nt,Qt]=R.useState(null),pt=R.useCallback((H,oA,pA)=>{Bt(H),H&&oA&&pA?Ct({longitude:oA[0],latitude:oA[1],type:"topology",properties:{key:pA.key,fromName:pA.fromName,toName:pA.toName,certainCount:pA.certainCount,confidence:pA.confidence,isBackbone:pA.isBackbone,isLoopEdge:pA.isLoopEdge,isDirectPath:pA.isDirectPath,isHubConnection:pA.isHubConnection,symmetryRatio:pA.symmetryRatio,dominantDirection:pA.dominantDirection}}):H||Ct(null)},[]),ot=R.useCallback((H,oA)=>{Qt(H),H&&Ct(null)},[]),Tr=R.useMemo(()=>{var HA;if(!zA||!ke||at)return null;const H=b.loops;if(H.length===0)return null;const oA=uc(ke,H,b.edgeMap);if(oA.loops.length===0)return null;const NA=oA.loops[0].nodes.map(oe=>{var De,Qe;return oe===vA?"You":((De=a[oe])==null?void 0:De.node_name)||((Qe=a[oe])==null?void 0:Qe.name)||oe.substring(0,4)});return{loops:oA.loops,highlightedEdgeKeys:oA.highlightedEdgeKeys,hoveredEdgeKey:((HA=oA.sortedEdges[0])==null?void 0:HA.key)||"",nodeNames:NA}},[zA,ke,at,b.loops,b.edgeMap,a,vA]);R.useEffect(()=>{at||Qt(Tr)},[Tr,at]);const Et=R.useMemo(()=>{const H={};for(const[oA,pA]of Object.entries(a))H[oA]=pA.node_name||pA.name||oA.substring(0,4);return vA&&(H[vA]="You"),H},[a,vA]),JA=R.useMemo(()=>{const H=new Map;for(const[oA,pA]of Object.entries(a)){const NA=oA.slice(0,2).toUpperCase(),HA=pA.node_name||pA.name||NA;H.set(NA,HA)}return vA&&H.set(vA.slice(0,2).toUpperCase(),"You"),H},[a,vA]),S=R.useMemo(()=>Object.entries(a).filter(([,H])=>Mt(H.latitude,H.longitude)),[a]),PA=R.useMemo(()=>{const H=new Map;vA&&Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude)&&H.set(vA,[u.latitude,u.longitude]);for(const[oA,pA]of S)Mt(pA.latitude,pA.longitude)&&H.set(oA,[pA.latitude,pA.longitude]);return H},[vA,u,S]),ft=R.useMemo(()=>{const H=new Map;for(const oA of T)oA.status!=="expired"&&H.set(oA.hash,{hash:oA.hash,prefix:oA.prefix,count:oA.count,avgRssi:oA.avgRssi,avgSnr:oA.avgSnr,lastSeen:oA.lastSeen,confidence:1,status:oA.status});return H},[T]),qe=R.useMemo(()=>{var oA,pA;const H=new Set;for(const NA of ft.keys())Mt((oA=a[NA])==null?void 0:oA.latitude,(pA=a[NA])==null?void 0:pA.longitude)&&H.add(NA);return H},[ft,a]),Ut=Rs(),dr=R.useMemo(()=>{if(qe.size===0||!vA)return new Map;if(Ut.length===0)return new Map;const H=Mr(vA);return ou(Ut,qe,H).scores},[qe,vA,Ut]),Ir=R.useMemo(()=>{var Xe;if(!Ye)return null;if(Ye==="local"&&u)return{isLocal:!0,name:u.name,hash:vA,hashPrefix:vA?Mr(vA):"",longitude:u.longitude,latitude:u.latitude};const H=a[Ye];if(!H)return null;const oA=qe.has(Ye),pA=b.hubNodes.includes(Ye),NA=((Xe=b.gatewayNodes)==null?void 0:Xe.includes(Ye))??!1,HA=b.mobileNodes.includes(Ye),oe=Mi(H),De=ft.get(Ye),Qe=b.fullAffinity.get(Ye),st=b.txDelayRecommendations.get(Ye);return{isLocal:!1,hash:Ye,hashPrefix:Mr(Ye),name:H.node_name||H.name||"Unknown",isHub:pA,isGateway:NA,isBackbone:(st==null?void 0:st.networkRole)==="backbone",isZeroHop:oA,isMobile:HA,isRoomServer:oe.isRoomServer,isStale:(()=>{const gt=H.last_seen||(De==null?void 0:De.lastSeen);return gt?(Date.now()-gt*1e3)/(1e3*60*60*24)>=5:!1})(),lastSeenTimestamp:H.last_seen||(De==null?void 0:De.lastSeen),centrality:b.centrality.get(Ye)||0,affinity:Qe,meanSnr:(De==null?void 0:De.avgSnr)??void 0,meanRssi:(De==null?void 0:De.avgRssi)??void 0,neighbor:H,txDelayRec:st}},[Ye,u,vA,a,qe,b,ft]),E=R.useCallback(H=>vA?!!(H.fromHash===vA&&qe.has(H.toHash)||H.toHash===vA&&qe.has(H.fromHash)):!1,[vA,qe]),Ot=R.useMemo(()=>{var oA,pA;if(T.length===0||!vA)return[];if(O.backgroundLoadComplete)return[];const H=[];for(const NA of T){if(NA.status==="expired"||!Mt((oA=a[NA.hash])==null?void 0:oA.latitude,(pA=a[NA.hash])==null?void 0:pA.longitude))continue;const HA=[vA,NA.hash].sort(),oe=`${HA[0]}~${HA[1]}`;H.push({fromHash:vA,toHash:NA.hash,key:oe,packetCount:NA.count,avgConfidence:1,strength:.8,avgRecency:1,hopDistanceFromLocal:0,isHubConnection:!1,isCertain:!0,certainCount:NA.count,isLoopEdge:!1,forwardCount:NA.count,reverseCount:0,symmetryRatio:0,dominantDirection:"forward",floodCount:NA.count,directCount:0,isDirectPathEdge:!1,isZeroHop:!0,avgRssi:NA.avgRssi,avgSnr:NA.avgSnr})}return H},[T,vA,O.backgroundLoadComplete,a]),nr=R.useMemo(()=>{const H=[];if(Ot.length>0&&!O.backgroundLoadComplete){for(const oA of Ot){const pA=PA.get(oA.fromHash),NA=PA.get(oA.toHash);pA&&NA&&H.push({from:pA,to:NA,edge:oA})}return H}for(const oA of b.validatedEdges){if(E(oA))continue;const pA=PA.get(oA.fromHash),NA=PA.get(oA.toHash);pA&&NA&&H.push({from:pA,to:NA,edge:oA})}return H},[b.validatedEdges,PA,E,Ot,O.backgroundLoadComplete]),Lr=R.useMemo(()=>{const H=[];for(const oA of b.weakEdges){if(E(oA))continue;const pA=PA.get(oA.fromHash),NA=PA.get(oA.toHash);pA&&NA&&H.push({from:pA,to:NA,edge:oA})}return H},[b.weakEdges,PA,E]),Nr=R.useMemo(()=>{if(!Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude))return[];const H=[],oA=[u.latitude,u.longitude],pA=new Map;for(const HA of b.lastHopNeighbors)pA.set(HA.hash,HA.count);const NA=new Map;for(const HA of T)NA.set(HA.hash,HA.count);for(const HA of qe){const oe=a[HA];if(!Mt(oe==null?void 0:oe.latitude,oe==null?void 0:oe.longitude))continue;const De=NA.get(HA),Qe=pA.get(HA);H.push({from:oA,to:[oe.latitude,oe.longitude],hash:HA,neighbor:oe,lastHopData:ft.get(HA)??null,rxAdvertCount:De,txProxyCount:Qe})}return H},[u,qe,a,ft,b.lastHopNeighbors,T]),Fr=R.useMemo(()=>new Set(b.loopEdgeKeys),[b.loopEdgeKeys]),h=R.useMemo(()=>new Set(b.backboneEdges),[b.backboneEdges]),v=R.useMemo(()=>{if(!Jt)return null;const H=b.validatedEdges.filter(HA=>HA.fromHash===Jt||HA.toHash===Jt);if(H.length===0)return null;const oA=[...H].sort((HA,oe)=>oe.certainCount-HA.certainCount),pA=Math.max(1,Math.ceil(oA.length*.2)),NA=oA.slice(0,pA);return new Set(NA.map(HA=>HA.key))},[Jt,b.validatedEdges]),j=R.useMemo(()=>{let H=0;if(Ot.length>0&&!O.backgroundLoadComplete){for(const oA of Ot)oA.certainCount>H&&(H=oA.certainCount);return H||1}for(const oA of b.validatedEdges)oA.certainCount>H&&(H=oA.certainCount);return H||1},[b.validatedEdges,Ot,O.backgroundLoadComplete]),P=R.useMemo(()=>{if(b.validatedEdges.length===0)return null;const H=new Set;for(const NA of b.validatedEdges)H.add(NA.fromHash),H.add(NA.toHash);const oA=Array.from(H).filter(NA=>PA.has(NA)).sort();if(oA.length<3)return null;const pA=new Map;for(const NA of oA){const HA=PA.get(NA);HA&&pA.set(NA,HA)}return Su(b.validatedEdges,oA,pA,b.edgeBetweenness)},[b.validatedEdges,PA,b.edgeBetweenness]),X=R.useCallback(()=>{it(H=>{const oA=!H;if(oA&&P&&M.current){const pA=M.current.getMap();if(!pA)return oA;let NA=1/0,HA=-1/0,oe=1/0,De=-1/0,Qe=!1;for(const[,st]of P.communities)for(const Xe of st){const gt=PA.get(Xe);if(gt){const[tt,yt]=gt;oe=Math.min(oe,tt),De=Math.max(De,tt),NA=Math.min(NA,yt),HA=Math.max(HA,yt),Qe=!0}}Qe&&pA.fitBounds([[NA,oe],[HA,De]],{padding:{top:60,bottom:100,left:60,right:320},duration:800,maxZoom:14})}return oA})},[P,PA]),K=R.useRef(null);R.useLayoutEffect(()=>{var H,oA;K.current=((oA=(H=M.current)==null?void 0:H.getMap)==null?void 0:oA.call(H))??null});const fA=Rs();Z1({map:K,nodeCoordinates:PA,packets:fA,localHash:vA,neighbors:a,meshTopology:b,enabled:be});const{isExiting:_A,isAnimating:XA,resetAnimationState:Ae}=T1({map:K,showTopology:zA,validatedPolylines:nr,weakPolylines:Lr,maxCertainCount:j,loopEdgeKeys:Fr,backboneEdgeKeys:h,highlightedEdgeKey:D,neighbors:a,validatedSourceId:zs,weakSourceId:Hs,neighborPolylines:Nr,showNeighborLines:ZA,neighborSourceId:Gs,neighborLinkScores:dr,basemapMode:ue}),he=R.useMemo(()=>{const H=new Set;for(const oA of b.hubNodes){H.add(oA);for(const pA of b.validatedEdges)pA.fromHash===oA&&H.add(pA.toHash),pA.toHash===oA&&H.add(pA.fromHash)}return H},[b.hubNodes,b.validatedEdges]),Oe=R.useMemo(()=>{const H=new Set;if(!g)return H;for(const oA of b.validatedEdges)oA.fromHash===g&&H.add(oA.toHash),oA.toHash===g&&H.add(oA.fromHash);return H},[g,b.validatedEdges]),ht=R.useMemo(()=>{const H=new Map;for(const[oA,pA]of S)H.set(oA,Mi(pA).type);return H},[S]),_t=R.useMemo(()=>{let H=0,oA=0,pA=0;for(const[,NA]of ht)NA==="repeater"?H++:NA==="companion"||NA==="unknown"?oA++:NA==="room_server"&&pA++;return{repeater:H,companion:oA,room_server:pA,hubs:b.hubNodes.length,direct:qe.size}},[ht,b.hubNodes.length,qe.size]),Je=R.useMemo(()=>new Set(te),[te]),{getNodeOpacity:je}=I1({activeFilters:Je,neighborHashes:S.map(([H])=>H),hubConnectedNodes:he,directNodeSet:qe,localConnectedNodes:Oe,nodeTypeMap:ht,showTopology:zA}),{blinkingNodes:jt,blinkColor:vr}=P1({neighbors:a,localHash:g,enabled:be}),mr=R.useCallback(H=>{if(Je.size===0)return!1;const oA=ht.get(H)??"unknown";return!!(Je.has("repeater")&&oA==="repeater"||Je.has("companion")&&(oA==="companion"||oA==="unknown")||Je.has("room_server")&&oA==="room_server"||Je.has("direct")&&qe.has(H)||Je.has("hubs")&&he.has(H))},[Je,ht,qe,he]),Pr=R.useCallback(()=>{er(!0),gA(!0)},[]),sr=R.useCallback(()=>{Se?$e(H=>!H):Pr()},[Se,Pr]),Qr=R.useCallback(H=>{uA(H.viewState),(H.viewState.pitch??0)>10&&!Ie&&St(!0)},[Ie]),an=R.useCallback(()=>{LA(H=>{var NA,HA,oe,De,Qe,st,Xe;const oA=!H,pA=(oe=(HA=(NA=M.current)==null?void 0:NA.getContainer())==null?void 0:HA.closest(".map-container-fullscreen, .map-container-16-9"))==null?void 0:oe.parentElement;return oA?pA&&document.fullscreenEnabled?(De=pA.requestFullscreen)==null||De.call(pA).catch(()=>{}):pA&&document.webkitFullscreenEnabled&&((Qe=pA.webkitRequestFullscreen)==null||Qe.call(pA)):document.fullscreenElement?(st=document.exitFullscreen)==null||st.call(document).catch(()=>{}):document.webkitFullscreenElement&&((Xe=document.webkitExitFullscreen)==null||Xe.call(document)),oA})},[]),un=R.useCallback(()=>{const H=te.length>=y0.length;We(H?[]:[...y0])},[te,We]),Kn=R.useCallback(H=>{te.length>=y0.length?We([H]):te.includes(H)?We(te.filter(pA=>pA!==H)):We([...te,H])},[te,We]),$n=R.useCallback(()=>{At(H=>!H)},[]),Zn=R.useCallback(()=>{Te(H=>!H)},[]),zt=R.useCallback(()=>{Ve(H=>{const oA=!H;return oA||Ar(null),oA})},[]),cn=R.useCallback(()=>{St(H=>{const oA=!H;if(M.current){const pA=M.current.getMap();pA&&pA.stop()}if(oA&&M.current){const pA=M.current.getMap();pA&&pA.easeTo({pitch:45,duration:1500,easing:Al})}if(!oA&&M.current){const pA=M.current.getMap();pA&&pA.easeTo({pitch:0,bearing:0,duration:800,easing:Yu})}return oA})},[]),br=R.useCallback(()=>{zA||$e(!0)},[zA]),Ne=R.useCallback((H,oA)=>{jr(H),Kr(oA)},[]),Or=R.useCallback(()=>{yr&&y&&y(yr),jr(null),Kr("")},[yr,y]),zr=R.useMemo(()=>[...fh,...ih,...fe?[Y0]:[]],[fe]),kr=R.useCallback(H=>{var pA;if((pA=H.features)==null?void 0:pA.some(NA=>{var HA,oe;return(oe=(HA=NA.layer)==null?void 0:HA.id)==null?void 0:oe.startsWith("node-markers-")})){Ct(null),Bt(null);return}if(fe&&H.features&&H.features.length>0){const NA=H.features.find(HA=>{var oe;return((oe=HA.layer)==null?void 0:oe.id)===Y0});if(NA!=null&&NA.properties){const{fromHash:HA,toHash:oe}=NA.properties;if(HA&&oe){const De=V.find(Qe=>Qe.nodeA.hash===HA&&Qe.nodeB.hash===oe||Qe.nodeA.hash===oe&&Qe.nodeB.hash===HA);if(De){Ar(De),ct(null);return}}}}ct(null),Ct(null),Bt(null),Xt(null),Ar(null)},[fe,V]),Vt=R.useCallback(H=>{Xt(oA=>oA===H?null:H),Ar(null)},[]),$r=R.useCallback(H=>{var Qe,st,Xe;if(!H.features||H.features.length===0)return;if(H.features.some(gt=>{var tt,yt;return(yt=(tt=gt.layer)==null?void 0:tt.id)==null?void 0:yt.startsWith("node-markers-")})){at&&(Bt(null),Ct(null));return}if(fe&&H.features.some(gt=>{var tt;return((tt=gt.layer)==null?void 0:tt.id)===Y0})){try{(Qe=M.current)!=null&&Qe.getCanvas()&&(M.current.getCanvas().style.cursor="pointer")}catch{}return}const pA=H.features.find(gt=>{var yt;const tt=(yt=gt.layer)==null?void 0:yt.id;return(tt==null?void 0:tt.startsWith("topology-"))||(tt==null?void 0:tt.startsWith("neighbor-"))});if(!pA)return;const NA=(st=pA.layer)==null?void 0:st.id,HA=pA.properties;if(!(HA!=null&&HA.key))return;const oe=NA==null?void 0:NA.startsWith("topology-"),De=NA==null?void 0:NA.startsWith("neighbor-");if(oe||De){const gt=HA.key.replace(/-loop[12]$/,"");Bt(gt),H.lngLat&&Ct({longitude:H.lngLat.lng,latitude:H.lngLat.lat,type:oe?"topology":"neighbor",properties:HA})}try{(Xe=M.current)!=null&&Xe.getCanvas()&&(M.current.getCanvas().style.cursor="pointer")}catch{}},[at,fe]),pr=R.useCallback(()=>{var H;Bt(null),Ct(null);try{(H=M.current)!=null&&H.getCanvas()&&(M.current.getCanvas().style.cursor="")}catch{}},[]),Bn=jA?"map-container-fullscreen":"map-container-16-9",Hr=FA.length>0||Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude),et=!J||!Hr,ir=Hr;return m.jsxs("div",{className:`relative ${Bn} ${jA?"":"rounded-2xl overflow-hidden"}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":ue,children:[m.jsx("span",{id:"map-instructions",className:"sr-only",children:"Interactive map showing mesh network contacts. Use mouse or touch to pan and zoom. Press Tab to navigate map controls. Press Escape to exit fullscreen mode."}),et&&m.jsx("div",{className:"absolute inset-0 z-50 surface-base rounded-2xl flex items-center justify-center","aria-hidden":"true",children:m.jsx("div",{className:"flex flex-col items-center gap-3",children:Hr?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),m.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-sm font-medium text-fg-secondary",children:"No mappable contacts"}),m.jsx("span",{className:"text-xs text-fg-muted text-center max-w-xs",children:"Contacts with GPS coordinates will appear here as they are seen."})]})})}),ir&&m.jsx("div",{className:`relative w-full h-full ${jA?"":"rounded-[1.125rem] overflow-hidden"} ${et?"opacity-0":"opacity-100 transition-opacity duration-300"}`,style:BA?{visibility:"hidden"}:void 0,children:m.jsxs(nu,{ref:M,...WA,onMove:Qr,mapStyle:Sh,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:zr,onMouseMove:$r,onMouseLeave:pr,onClick:kr,onError:H=>{console.error("MapLibre error:",H.error)},onIdle:()=>{if(!kA&&!bA&&M.current){const H=M.current.getMap();if(H){const oA=Object.values(a).filter(pA=>Mt(pA.latitude,pA.longitude)).map(pA=>({latitude:pA.latitude,longitude:pA.longitude}));Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude)&&oA.push({latitude:u.latitude,longitude:u.longitude}),oA.length>0&&SA(oA,H)}}},children:[m.jsx(su,{position:"bottom-right"}),m.jsx(Wu,{mode:ue}),m.jsx(n1,{enabled:Ie,exaggeration:4}),m.jsx(q2,{coveragePoints:dt,visible:dt.length>0&&tA||mA,terrainEnabled:Ie,brightness:mA?.5:yA,basemapMode:ue,replaySamples:mA?xe:void 0,replayTimeS:mA?C:void 0}),m.jsx(B1,{partition:P,nodeCoordinates:PA,visible:_e&&Se,opacity:ce.opacity,bandwidth:ce.bandwidth,threshold:ce.threshold,strokeWidth:ce.strokeWidth}),m.jsx(ch,{showTopology:zA,isExiting:_A,hoveredEdgeKey:at,highlightedLoopEdges:nt==null?void 0:nt.highlightedEdgeKeys,highlightedFocusEdges:v,onEdgeHover:pt,onLoopHover:ot,loops:b.loops,neighborNames:Et,opacityBias:on,widthMultiplier:_r,trafficFilter:gr,showNeighborLines:ZA,disableHover:XA||xr}),m.jsx(wh,{visible:fe,nodeCoordinates:PA,focusedNodeHash:Jt,basemapMode:ue}),x&&m.jsx(hh,{targetHash:x,nodeCoordinates:PA,onComplete:k}),D&&m.jsx(dh,{highlightedEdgeKey:D,validatedPolylines:nr,weakPolylines:Lr,onEnsureTopology:br}),m.jsx(Eh,{ghost:Q??null,neighborCoordinates:PA,onHighlightedNeighborsChange:wr}),mA&&m.jsx(t1,{neighbors:a}),m.jsx(sh,{neighborsWithLocation:S,localNode:u,localHash:g,zeroHopNeighbors:qe,lastHopNeighborMap:ft,meshTopology:b,hoveredMarker:ke,onMarkerHover:Ze,getNodeOpacity:je,shouldShowNode:mr,openPopupId:Ye,onOpenPopup:hr,onClosePopup:kt,onNodeClick:Vt,blinkingNodes:jt,blinkColor:vr})]})}),(()=>{const H=Rh(rr?{type:rr.type,properties:rr.properties}:null,nt,j,b.edgeMap);return H&&m.jsx("div",{className:"map-edge-tooltip",children:m.jsx("div",{className:"map-control-surface map-edge-tooltip-inner",children:m.jsx(Th,{data:H})})})})(),m.jsx(Kc,{mapRef:M,showNeighborLines:ZA,onToggleNeighborLines:$n,hasNeighborPolylines:Nr.length>0,nodeFilters:te,onToggleFilter:Kn,onToggleAll:un,filterCounts:_t,showCoverage:VA,onToggleCoverage:Zn,showMinCut:_e,onToggleMinCut:X,hasMinCutData:Se&&P!==null&&P.numCommunities>1,show3DTerrain:Ie,onToggle3DTerrain:cn,basemapMode:ue,onToggleBasemap:ie,isFullscreen:jA,onToggleFullscreen:an,showLinkQuality:fe,onToggleLinkQuality:zt,hasTraceLinks:W}),m.jsx(Zf,{data:Ir,localNode:u,localColor:J0().localColor,onClose:kt,onRemove:y?Ne:void 0}),fe&&Dr&&m.jsx(Hf,{pair:Dr,onClose:()=>Ar(null),prefixToName:JA}),m.jsxs("div",{className:"map-legend-stack",children:[m.jsxs("div",{className:"map-tool-row",children:[m.jsx(ef,{isActive:zA,hasAnalyzed:Se,isLoading:xr,onClick:sr,basemapMode:ue}),m.jsx(lf,{isActive:be,onClick:mt,basemapMode:ue}),m.jsx(df,{isActive:dt.length>0&&tA,onClick:TA,basemapMode:ue}),!mA&&m.jsx(Gf,{channels:Be,messages:Ue,basemapMode:ue})]}),m.jsx(Vc,{showTopology:zA,validatedPolylineCount:nr.length,filteredNeighborCount:S.length,hasLocalNode:Mt(u==null?void 0:u.latitude,u==null?void 0:u.longitude),meshTopology:b,zeroHopNeighbors:qe,neighborsWithLocation:S,basemapMode:ue})]}),m.jsx(Uf,{}),m.jsx(lu,{isOpen:yr!==null,onCancel:()=>jr(null),onConfirm:Or,title:"Remove Node?",message:`Remove "${Rr}" from the contacts list? The node will reappear if it advertises again.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),m.jsx(Lc,{isOpen:ln,onClose:()=>{gA(!1),er(!1),Ae(),tr(!0),setTimeout(()=>$e(!0),Oc)}}),m.jsx(Tf,{}),m.jsx(Lf,{visible:_e&&Se,onClose:()=>it(!1),settings:ce,onSettingsChange:Me,partition:P,totalNodes:Object.keys(a).length,basemapMode:ue})]})}export{Dd as default};
