import{e as Sr,an as xa,r as j,gz as wa,cu as va,dp as ba,dq as ka,j as m,aC as Co,dr as Ca,aD as Eo,m as Jt,a0 as Wn,dK as So,c as Cn,a2 as Z0,O as lr,Z as vn,gA as q0,gB as Mo,gC as Ea,cj as Sa,cq as Ma,cs as Ba,dV as Bo,ap as Do,aE as _o,d as Cr,b as En,B as Nt,dG as Da,cl as ms,E as Gs,S as Us,dx as To,t as jo,c$ as Ro,aa as Io,bM as Sn,bI as xi,gD as Lo,Q as _a,a6 as Ta,dF as ja,gE as Ra,az as No,bT as wi,bV as Ia,a1 as J0,a3 as X0,cn as La,b9 as Na,f1 as Fo,gF as Fa,gG as Pa,dH as Qa,dI as Oa,gH as za,gI as Ha,aR as Po,V as gt,gJ as Ga,gK as Qo,gL as Ua,ao as Er,bP as Oo,dw as Va,gM as zo,gN as Ho,cb as Wa,gx as Ya,ce as $a,du as Go,dy as Ka,ab as Za,gO as qa,fd as Ja,gP as ps,ga as Xa,fJ as Au,gQ as eu}from"./index-BuFgUdF6.js";import{u as Or,S as Qr,L as qt,M as tu,b as ru}from"./maplibre-gl-CiCFUTvH.js";import{u as Uo,r as Vo,e as vi,f as bi,g as nu}from"./consumer-registry-YGO4kl9s.js";import{L as U0,c as su}from"./link-scoring-DMBYgePn.js";import{C as iu}from"./ConfirmModal-nA8_-uZY.js";import{s as ou,a as lu,M as au}from"./variants-DM-hs1OK.js";import{G as Ms}from"./git-branch-CfbKq2-d.js";import{D as uu}from"./database-6NHqXCMW.js";import{H as cu,A as g0,D as ki,p as fu,c as hu,u as mn}from"./useMapViewStore-CYTMhi1e.js";import{E as Wo}from"./target-DIUvz3Tq.js";import{F as du}from"./funnel-DqVoB6_M.js";import{P as mu}from"./plus-DzDLhCtU.js";import{C as pu}from"./compass-DF0afhxw.js";import{Z as gu}from"./zap-CcGk7ixp.js";import{b as yu,e as xu,a as Yo,m as Ci,E as wu,u as vu,G as bu,g as ku,d as Cu,f as Eu}from"./max-2s8xWRMa.js";import{T as Su}from"./trash-2-BxJacC3X.js";import{W as Mu}from"./wifi-off-UIVfR54a.js";import{W as Bu}from"./wifi-i97D3b-F.js";import{C as Du}from"./circle-alert-DzBa7wxQ.js";import{C as $o}from"./clock-CiO_tPRQ.js";import{C as _u}from"./chevron-right-Bn33xBBB.js";import{u as Vs,a as Ko,b as Zo,c as Tu,d as ju,e as Ws,f as Ei,R as Ru,g as Iu,h as qo,t as Lu,i as Nu,j as Fu,k as Pu}from"./useReplayTick-5QafLbi4.js";import{L as Qu}from"./LightSparkline-D-p7t3p_.js";import{P as Jo,R as Ou}from"./Contacts-BQZoptn8.js";import{H as Y0,C as ar,N as zu,a as Hu}from"./badge-colors-Dl76Mz8m.js";import{M as Gu}from"./map-pin-DUIK7gpx.js";import{c as Si}from"./node-types-DgK-t_34.js";import{B as Uu}from"./BasemapLayer-9KgDoniZ.js";import{a as Xo,b as Bs,c as Vu}from"./easing-DkQiIJc0.js";import"./index-tC-yebOi.js";import"./index-CjY609r3.js";import"./payload-detail-C-jD4akC.js";import"./usePipelineStore-Chyk9TCr.js";import"./PageLayout-DKfh0Blq.js";import"./listbox-CJH36T5I.js";import"./element-movement-BCAtukIF.js";import"./use-text-value-CNy_lL-R.js";import"./frozen-CKj5jrk2.js";import"./MqttModeBadge-BeRzf62U.js";import"./chat-utils-DXcrFuPC.js";import"./SignalIndicator-DlCNJ53K.js";import"./CollisionExplorerModal-ggc1GI4m.js";import"./share-2-Rt2CcEoP.js";import"./circle-question-mark-NwPFAIxO.js";import"./map-pin-off-MHnLeyVX.js";import"./activity-CU9M_dkq.js";import"./search-s6rZk7pl.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 Wu=[["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"}]],Ds=Sr("boxes",Wu);/**
 * @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 Yu=[["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"}]],Al=Sr("ghost",Yu);/**
 * @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:"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"}]],Ku=Sr("map",$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:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],qu=Sr("mountain",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=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],Xu=Sr("navigation",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=[["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"}]],el=Sr("nfc",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 ec=[["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"}]],tc=Sr("sigma",ec);/**
 * @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=[["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"}]],nc=Sr("swords",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=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],ic=Sr("trending-down",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:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],lc=Sr("wrench",oc);function ac(a,c){return c.filter(y=>y.nodes.includes(a)).sort((y,x)=>x.avgCertainCount-y.avgCertainCount)}function uc(a,c,g){const y=ac(a,c),x=new Set,k=[];for(const D of y)for(const P of D.edgeKeys)if(!x.has(P)){x.add(P);const M=g.get(P);k.push({key:P,certainCount:(M==null?void 0:M.certainCount)??0})}return k.sort((D,P)=>P.certainCount-D.certainCount),{loops:y,highlightedEdgeKeys:x,sortedEdges:k}}function cc(a){const c=new Map;for(const g of a)for(const y of g.edgeKeys){const x=c.get(y)??[];x.push(g),c.set(y,x)}return c}const D0={MAX_THICKNESS_AT:300,MIN_VALIDATIONS:5},fc=6,Mi=1;function _s(a,c){const g=Math.max(D0.MIN_VALIDATIONS,Math.min(a,D0.MAX_THICKNESS_AT)),y=Math.log(D0.MIN_VALIDATIONS),x=Math.log(D0.MAX_THICKNESS_AT),D=(Math.log(g)-y)/(x-y);return Mi+(fc-Mi)*D}const hc=dc(mc);function dc(a){return function(c,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}=c;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 c;const P=g&&a(g),M=y&&a(y),b=x.slice();return P&&M?(Pn(P,b,x,k,D),Pn(P,x,b,k,D),Pn(P,b,x,k,D),Qn(M,x,b,k,D),Qn(M,b,x,k,D),Qn(M,x,b,k,D)):P?(Pn(P,x,b,k,D),Pn(P,b,x,k,D),Pn(P,x,b,k,D)):M&&(Qn(M,x,b,k,D),Qn(M,b,x,k,D),Qn(M,x,b,k,D)),c}}function Pn(a,c,g,y,x){for(let k=0,D=y*x;k<D;)a(c,g,k,k+=y,1)}function Qn(a,c,g,y,x){for(let k=0,D=y*x;k<y;++k)a(c,g,k,k+D,y)}function mc(a){const c=Math.floor(a);if(c===a)return pc(a);const g=a-c,y=2*a+1;return(x,k,D,P,M)=>{if(!((P-=M)>=D))return;let b=c*k[D];const R=M*c,O=R+M;for(let z=D,W=D+R;z<W;z+=M)b+=k[Math.min(P,z)];for(let z=D,W=P;z<=W;z+=M)b+=k[Math.min(P,z+R)],x[z]=(b+g*(k[Math.max(D,z-O)]+k[Math.min(P,z+O)]))/y,b-=k[Math.max(D,z-R)]}}function pc(a){const c=2*a+1;return(g,y,x,k,D)=>{if(!((k-=D)>=x))return;let P=a*y[x];const M=D*a;for(let b=x,R=x+M;b<R;b+=D)P+=y[Math.min(k,b)];for(let b=x,R=k;b<=R;b+=D)P+=y[Math.min(k,b+M)],g[b]=P/c,P-=y[Math.max(x,b-M)]}}function gc(a,c){let g=0;for(let y of a)y!=null&&(y=+y)>=y&&++g;return g}function yc(a,c,g){let y;for(;;){const x=yu(a,c,g);if(x===y||x===0||!isFinite(x))return[a,c];x>0?(a=Math.floor(a/x)*x,c=Math.ceil(c/x)*x):x<0&&(a=Math.ceil(a*x)/x,c=Math.floor(c*x)/x),y=x}}function xc(a){return Math.max(1,Math.ceil(Math.log(gc(a))/Math.LN2)+1)}var wc=Array.prototype,tl=wc.slice;function vc(a,c){return a-c}function bc(a){for(var c=0,g=a.length,y=a[g-1][1]*a[0][0]-a[g-1][0]*a[0][1];++c<g;)y+=a[c-1][1]*a[c][0]-a[c-1][0]*a[c][1];return y}const rn=a=>()=>a;function kc(a,c){for(var g=-1,y=c.length,x;++g<y;)if(x=Cc(a,c[g]))return x;return 0}function Cc(a,c){for(var g=c[0],y=c[1],x=-1,k=0,D=a.length,P=D-1;k<D;P=k++){var M=a[k],b=M[0],R=M[1],O=a[P],z=O[0],W=O[1];if(Ec(M,O,c))return 0;R>y!=W>y&&g<(z-b)*(y-R)/(W-R)+b&&(x=-x)}return x}function Ec(a,c,g){var y;return Sc(a,c,g)&&Mc(a[y=+(a[0]===c[0])],g[y],c[y])}function Sc(a,c,g){return(c[0]-a[0])*(g[1]-a[1])===(g[0]-a[0])*(c[1]-a[1])}function Mc(a,c,g){return a<=c&&c<=g||g<=c&&c<=a}function Bc(){}var Pr=[[],[[[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 Bi(){var a=1,c=1,g=xc,y=M;function x(b){var R=g(b);if(Array.isArray(R))R=R.slice().sort(vc);else{const O=xu(b,Dc);for(R=Yo(...yc(O[0],O[1],R),R);R[R.length-1]>=O[1];)R.pop();for(;R[1]<O[0];)R.shift()}return R.map(O=>k(b,O))}function k(b,R){const O=R==null?NaN:+R;if(isNaN(O))throw new Error(`invalid value: ${R}`);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 X=0,iA=z.length,AA;X<iA;++X)if(kc((AA=z[X])[0],V)!==-1){AA.push(V);return}}),{type:"MultiPolygon",value:R,coordinates:z}}function D(b,R,O){var z=new Array,W=new Array,V,X,iA,AA,K,hA;for(V=X=-1,AA=pn(b[0],R),Pr[AA<<1].forEach(uA);++V<a-1;)iA=AA,AA=pn(b[V+1],R),Pr[iA|AA<<1].forEach(uA);for(Pr[AA<<0].forEach(uA);++X<c-1;){for(V=-1,AA=pn(b[X*a+a],R),K=pn(b[X*a],R),Pr[AA<<1|K<<2].forEach(uA);++V<a-1;)iA=AA,AA=pn(b[X*a+a+V+1],R),hA=K,K=pn(b[X*a+V+1],R),Pr[iA|AA<<1|K<<2|hA<<3].forEach(uA);Pr[AA|K<<3].forEach(uA)}for(V=-1,K=b[X*a]>=R,Pr[K<<2].forEach(uA);++V<a-1;)hA=K,K=pn(b[X*a+V+1],R),Pr[K<<2|hA<<3].forEach(uA);Pr[K<<3].forEach(uA);function uA(EA){var oA=[EA[0][0]+V,EA[0][1]+X],lA=[EA[1][0]+V,EA[1][1]+X],BA=P(oA),SA=P(lA),bA,cA;(bA=W[BA])?(cA=z[SA])?(delete W[bA.end],delete z[cA.start],bA===cA?(bA.ring.push(lA),O(bA.ring)):z[bA.start]=W[cA.end]={start:bA.start,end:cA.end,ring:bA.ring.concat(cA.ring)}):(delete W[bA.end],bA.ring.push(lA),W[bA.end=SA]=bA):(bA=z[SA])?(cA=W[BA])?(delete z[bA.start],delete W[cA.end],bA===cA?(bA.ring.push(lA),O(bA.ring)):z[cA.start]=W[bA.end]={start:cA.start,end:bA.end,ring:cA.ring.concat(bA.ring)}):(delete z[bA.start],bA.ring.unshift(oA),z[bA.start=BA]=bA):z[BA]=W[SA]={start:BA,end:SA,ring:[oA,lA]}}}function P(b){return b[0]*2+b[1]*(a+1)*4}function M(b,R,O){b.forEach(function(z){var W=z[0],V=z[1],X=W|0,iA=V|0,AA=gs(R[iA*a+X]);W>0&&W<a&&X===W&&(z[0]=Di(W,gs(R[iA*a+X-1]),AA,O)),V>0&&V<c&&iA===V&&(z[1]=Di(V,gs(R[(iA-1)*a+X]),AA,O))})}return x.contour=k,x.size=function(b){if(!arguments.length)return[a,c];var R=Math.floor(b[0]),O=Math.floor(b[1]);if(!(R>=0&&O>=0))throw new Error("invalid size");return a=R,c=O,x},x.thresholds=function(b){return arguments.length?(g=typeof b=="function"?b:Array.isArray(b)?rn(tl.call(b)):rn(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,c){return a==null?!1:+a>=c}function gs(a){return a==null||isNaN(a=+a)?-1/0:a}function Di(a,c,g,y){const x=y-c,k=g-c,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 Tc(a){return a[1]}function jc(){return 1}function Rc(){var a=_c,c=Tc,g=jc,y=960,x=500,k=20,D=2,P=k*3,M=y+P*2>>D,b=x+P*2>>D,R=rn(20);function O(K){var hA=new Float32Array(M*b),uA=Math.pow(2,-D),EA=-1;for(const LA of K){var oA=(a(LA,++EA,K)+P)*uA,lA=(c(LA,EA,K)+P)*uA,BA=+g(LA,EA,K);if(BA&&oA>=0&&oA<M&&lA>=0&&lA<b){var SA=Math.floor(oA),bA=Math.floor(lA),cA=oA-SA-.5,IA=lA-bA-.5;hA[SA+bA*M]+=(1-cA)*(1-IA)*BA,hA[SA+1+bA*M]+=cA*(1-IA)*BA,hA[SA+1+(bA+1)*M]+=cA*IA*BA,hA[SA+(bA+1)*M]+=(1-cA)*IA*BA}}return hc({data:hA,width:M,height:b},k*uA),hA}function z(K){var hA=O(K),uA=R(hA),EA=Math.pow(2,2*D);return Array.isArray(uA)||(uA=Yo(Number.MIN_VALUE,Ci(hA)/EA,uA)),Bi().size([M,b]).thresholds(uA.map(oA=>oA*EA))(hA).map((oA,lA)=>(oA.value=+uA[lA],W(oA)))}z.contours=function(K){var hA=O(K),uA=Bi().size([M,b]),EA=Math.pow(2,2*D),oA=lA=>{lA=+lA;var BA=W(uA.contour(hA,lA*EA));return BA.value=lA,BA};return Object.defineProperty(oA,"max",{get:()=>Ci(hA)/EA}),oA};function W(K){return K.coordinates.forEach(V),K}function V(K){K.forEach(X)}function X(K){K.forEach(iA)}function iA(K){K[0]=K[0]*Math.pow(2,D)-P,K[1]=K[1]*Math.pow(2,D)-P}function AA(){return P=k*3,M=y+P*2>>D,b=x+P*2>>D,z}return z.x=function(K){return arguments.length?(a=typeof K=="function"?K:rn(+K),z):a},z.y=function(K){return arguments.length?(c=typeof K=="function"?K:rn(+K),z):c},z.weight=function(K){return arguments.length?(g=typeof K=="function"?K:rn(+K),z):g},z.size=function(K){if(!arguments.length)return[y,x];var hA=+K[0],uA=+K[1];if(!(hA>=0&&uA>=0))throw new Error("invalid size");return y=hA,x=uA,AA()},z.cellSize=function(K){if(!arguments.length)return 1<<D;if(!((K=+K)>=1))throw new Error("invalid cell size");return D=Math.floor(Math.log(K)/Math.LN2),AA()},z.thresholds=function(K){return arguments.length?(R=typeof K=="function"?K:Array.isArray(K)?rn(tl.call(K)):rn(K),z):R},z.bandwidth=function(K){if(!arguments.length)return Math.sqrt(k*(k+1));if(!((K=+K)>=0))throw new Error("invalid bandwidth");return k=(Math.sqrt(4*K*K+1)-1)/2,AA()},z}function Ts(){const a=xa();return j.useMemo(()=>wa.getPackets(),[a])}function _0({label:a,icon:c,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(Wn,{className:"w-4 h-4 text-sys-blue"}):g==="active"?m.jsx(Z0,{className:"w-4 h-4 animate-spin text-sys-blue"}):m.jsx("span",{className:"text-fg-muted",children:c})}),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:c}){const{packetCacheState:g,triggerDeepAnalysis:y}=va(),x=ba(),k=ka(),D=g.packetCount,[P,M]=j.useState("fetching");j.useEffect(()=>{a&&y()},[a,y]),j.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(()=>{c()},1500);return()=>clearTimeout(V)}}},[a,g.isTopologyLoading,x,k,c]);const b=P==="complete",R=g.loadProgress,O=j.useMemo(()=>{if(R&&R.target>0){const V=(R.loaded/1e3).toFixed(1),X=(R.target/1e3).toFixed(1);return`Loading... ${V}k / ${X}k packets (${R.percent}%)`}return D>0?`${D.toLocaleString()} packets loaded`:"Connecting to database..."},[R,D]),z=V=>{const X=["fetching","analyzing","building","discovering","complete"],iA=X.indexOf(P),AA=X.indexOf(V);return AA<iA?"complete":AA===iA?"active":"pending"},W=b?c:()=>{};return m.jsx(Co,{open:a,onClose:W,size:"sm",bottomSheet:!1,children:m.jsx(Ca,{isLoading:!b,borderRadius:16,children:m.jsx(Eo,{className:"p-6 radius-card overflow-hidden",children:b?m.jsxs("div",{className:"flex flex-col items-center py-6",children:[m.jsx(Jt.div,{variants:ou,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(Wn,{className:"w-8 h-8 text-sys-blue"})}),m.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),m.jsx("button",{onClick:c,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(Ms,{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(_0,{label:"Fetching Packets",icon:m.jsx(So,{className:"w-4 h-4"}),status:z("fetching"),detail:O}),m.jsx(_0,{label:"Analyzing Database",icon:m.jsx(uu,{className:"w-4 h-4"}),status:z("analyzing"),detail:"Processing packet paths"}),m.jsx(_0,{label:"Building Topology",icon:m.jsx(Ms,{className:"w-4 h-4"}),status:z("building"),detail:"Computing mesh edges"}),m.jsx(_0,{label:"Discovering Nodes",icon:m.jsx(Al,{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=j.memo(Ic),rl=16,js=24,Nc=rl,Fc=5,bn={nodeFill:lr.blue,nodeStroke:"rgba(255,255,255,0.9)",nodeColor:lr.indigo,localColor:lr.amber,hubColor:lr.purple,gatewayColor:lr.indigo,mobileColor:lr.orange,roomServerColor:lr.pink,neighborColor:lr.amber,edges:{rest:vn[700],restBright:vn[600],restDim:vn[800],hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:vn[400],hoverNeighbor:lr.amber,neighborRest:vn[500],neighborHover:lr.amber,highlight:"#FFD700"},edgeOpacity:.82};function Ys(){if(typeof window>"u")return bn;const a=q0(),c=Mo();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:c.rest,restBright:c.restBright,restDim:c.restDim,hoverDirect:c.hoverDirect,hoverLoop:c.hoverLoop,hoverStandard:c.hoverStandard,hoverNeighbor:c.hoverNeighbor,neighborRest:bn.edges.neighborRest,neighborHover:bn.edges.neighborHover,highlight:c.highlight},edgeOpacity:bn.edgeOpacity}}const T0=2e3,j0=750,Pc="#00FF00",Qc=500,_i=500,Ti=250,Oc=150,nl=200,zc=En.snappy;function On({color:a,ring:c}){const g=Nc-2;return m.jsx("span",{className:"shrink-0 rounded-full","aria-hidden":"true",style:{width:g,height:g,backgroundColor:c?"transparent":a,border:c?`${Fc-1}px solid ${a}`:void 0,boxSizing:"border-box"}})}function ys({color:a,pattern:c="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:c==="dashed"?"5,3":c==="dotted"?"2,3":void 0})})}function or({indicator:a,label:c,tooltip:g}){return m.jsxs("div",{className:"flex items-center gap-1.5",children:[a,m.jsx("span",{className:"text-fg-secondary",children:c}),g&&m.jsx(Do,{content:g,delay:nl,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 xs({title:a,tooltip:c,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(Do,{content:c,delay:nl,children:m.jsx("span",{className:"cursor-help text-[11px] text-fg-muted opacity-75 group-hover:opacity-100 transition-opacity",children:"ⓘ"})})]}),m.jsx(Jt.span,{animate:{rotate:g?0:-90},transition:{duration:.15},"aria-hidden":"true",children:m.jsx(_o,{className:"w-3 h-3 text-fg-muted"})})]}),m.jsx(Cr,{initial:!1,children:g&&m.jsx(Jt.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 ji({label:a,value:c,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:c})]})}function Ri({icon:a,color:c,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:c},children:a}),m.jsxs("div",{className:"flex flex-col min-w-0",children:[m.jsx("span",{className:"font-medium truncate",style:{color:c},children:g}),m.jsx("span",{className:"text-[10px] leading-tight text-fg-muted",children:y})]})]})})}function Gc(a){return a.some(([,c])=>{var y;const g=(y=c.contact_type)==null?void 0:y.toLowerCase();return g==="room server"||g==="room_server"||g==="room"||g==="server"})}function Uc(a){let c=0;for(const g of a.txDelayRecommendations.values())g.networkRole==="backbone"&&c++;return c}function Vc({showTopology:a,validatedPolylineCount:c,filteredNeighborCount:g,hasLocalNode:y,meshTopology:x,zeroHopNeighbors:k,neighborsWithLocation:D,basemapMode:P="dark"}){const M=Ea(),b=Sa(),R=Ma(),O=b.filter(uA=>uA.isLikelyReal).length,z=Uc(x),W=k.size>0,[V,X]=j.useState(!0),[iA,AA]=j.useState(!0),[K,hA]=j.useState(!0);return m.jsxs("div",{className:"map-control-surface p-2.5 text-xs",children:[m.jsxs(xs,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:V,onToggle:()=>X(uA=>!uA),children:[m.jsx(or,{indicator:m.jsx(On,{color:M.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),m.jsx(or,{indicator:m.jsx(On,{color:M.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),Gc(D)&&m.jsx(or,{indicator:m.jsx(Ba,{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(or,{indicator:m.jsx(cu,{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(or,{indicator:m.jsx(On,{color:M.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),x.gatewayNodes.length>0&&m.jsx(or,{indicator:m.jsx(On,{color:M.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),z>0&&m.jsx(or,{indicator:m.jsx(On,{color:M.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),x.mobileNodes.length>0&&m.jsx(or,{indicator:m.jsx(On,{color:M.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),O>0&&m.jsx(or,{indicator:m.jsx(Al,{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(xs,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:iA,onToggle:()=>AA(uA=>!uA),showDivider:!0,children:[m.jsx(or,{indicator:m.jsx(ys,{color:U0.YELLOW,pattern:"solid"}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),m.jsx(or,{indicator:m.jsx(ys,{color:U0.GREEN,pattern:"dashed"}),label:"Listener",tooltip:">67% listener. They hear us well."}),m.jsx(or,{indicator:m.jsx(ys,{color:U0.RED,pattern:"dotted"}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),a&&c>0&&m.jsxs(xs,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:K,onToggle:()=>hA(uA=>!uA),showDivider:!0,children:[m.jsx(ji,{label:"Nodes",value:g+(y?1:0)}),x.hubNodes.length>0&&m.jsx(ji,{label:"Hubs",value:x.hubNodes.length,color:bn.hubColor}),x.loops.length>0&&m.jsx(Ri,{icon:m.jsx(Bo,{className:"w-3 h-3"}),color:bn.edges.hoverLoop,title:`${x.loops.length} ${x.loops.length===1?"Loop":"Loops"}`,subtitle:"Redundant paths"}),R.totalPaths>0&&m.jsx(Ri,{icon:m.jsx(Wo,{className:"w-3 h-3"}),color:M.ghostColor,title:`${R.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]})}const Ii={repeater:"blue",companion:"cyan",room_server:"pink",hubs:"indigo",direct:"green"},R0={repeater:"Repeaters",companion:"Companions",room_server:"Rooms",hubs:"Hubs",direct:"Direct"},Li={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"],Ni=["hubs","direct"],zn="!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",I0="!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 $c({mapRef:a,showNeighborLines:c,onToggleNeighborLines:g,hasNeighborPolylines:y,nodeFilters:x,onToggleFilter:k,onToggleAll:D,filterCounts:P,showCoverage:M,onToggleCoverage:b,showMinCut:R=!1,onToggleMinCut:O,hasMinCutData:z=!1,show3DTerrain:W,onToggle3DTerrain:V,basemapMode:X,onToggleBasemap:iA,isFullscreen:AA,onToggleFullscreen:K,showLinkQuality:hA=!1,onToggleLinkQuality:uA,hasTraceLinks:EA=!1}){const[oA,lA]=j.useState(()=>!Yc()),BA=()=>{var FA,UA;(UA=(FA=a.current)==null?void 0:FA.getMap())==null||UA.zoomIn()},SA=()=>{var FA,UA;(UA=(FA=a.current)==null?void 0:FA.getMap())==null||UA.zoomOut()},bA=()=>{var UA;const FA=(UA=a.current)==null?void 0:UA.getMap();FA&&FA.easeTo({bearing:0,pitch:0,duration:300})},cA="w-4 h-4",IA=X==="light"?"#525252":"var(--fg-secondary)",LA=x.length>=g0.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)]",children:[m.jsxs("div",{className:"map-control-surface flex flex-nowrap items-center gap-0.5 sm:gap-1 p-1 overflow-hidden",children:[y&&m.jsx(Nt,{plain:!0,color:c?"warning":"muted",onClick:g,title:c?"Hide edge lines":"Show edge lines","aria-label":c?"Hide edge lines":"Show edge lines","aria-pressed":c,className:zn,"data-tint":c?"warning":void 0,children:m.jsx(Da,{className:cA})}),m.jsx(Nt,{plain:!0,color:"muted",onClick:()=>lA(FA=>!FA),title:oA?"Hide node filters":"Show node filters","aria-label":oA?"Collapse node filters":"Expand node filters","aria-expanded":oA,className:zn,children:m.jsx(du,{className:cA})}),m.jsx(Cr,{initial:!1,children:oA&&m.jsxs(Jt.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(ms,{color:LA?"green":"zinc",customColor:LA?void 0:IA,onClick:D,title:"Show all nodes","aria-pressed":LA,"aria-label":"Show all node types",className:"shrink-0",children:"All"}),Wc.map(FA=>{const UA=P[FA];if(UA===0)return null;const vA=!LA&&x.includes(FA);return m.jsx(ms,{color:vA?Ii[FA]:"zinc",customColor:vA?void 0:IA,onClick:()=>k(FA),title:Li[FA],"aria-pressed":vA,"aria-label":`${R0[FA]} (${UA})`,className:"shrink-0",children:R0[FA]},FA)}),Ni.some(FA=>P[FA]>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"}),Ni.map(FA=>{const UA=P[FA];if(UA===0)return null;const vA=!LA&&x.includes(FA);return m.jsx(ms,{color:vA?Ii[FA]:"zinc",customColor:vA?void 0:IA,onClick:()=>k(FA),title:Li[FA],"aria-pressed":vA,"aria-label":`${R0[FA]} (${UA})`,className:"shrink-0",children:R0[FA]},FA)})]})}),z&&O&&m.jsx(Nt,{plain:!0,color:R?"primary":"muted",onClick:O,title:R?"Hide community partition":"Show community partition","aria-label":R?"Hide community partition":"Show community partition","aria-pressed":R,className:zn,"data-tint":R?"primary":void 0,children:m.jsx(Ds,{className:cA})}),m.jsx(Nt,{plain:!0,color:X==="light"?"primary":"muted",onClick:iA,title:X==="light"?"Switch to dark map":"Switch to light map","aria-label":X==="light"?"Switch to dark map":"Switch to light map","aria-pressed":X==="light",className:zn,"data-tint":X==="light"?"primary":void 0,children:X==="light"?m.jsx(Gs,{className:cA}):m.jsx(Us,{className:cA})}),m.jsx(Nt,{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:zn,"data-tint":W?"success":void 0,children:m.jsx(qu,{className:cA})}),m.jsx(Nt,{plain:!0,color:"muted",onClick:K,title:AA?"Exit fullscreen":"Fullscreen","aria-label":AA?"Exit fullscreen":"Enter fullscreen","aria-pressed":AA,className:zn,children:AA?m.jsx(lu,{className:cA}):m.jsx(au,{className:cA})})]}),m.jsxs("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:[m.jsx(Nt,{plain:!0,color:"muted",onClick:BA,title:"Zoom in","aria-label":"Zoom in",className:I0,children:m.jsx(mu,{className:cA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Nt,{plain:!0,color:"muted",onClick:SA,title:"Zoom out","aria-label":"Zoom out",className:I0,children:m.jsx(To,{className:cA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Nt,{plain:!0,color:"muted",onClick:bA,title:"Reset bearing to north","aria-label":"Reset bearing to north",className:I0,children:m.jsx(pu,{className:cA})})]}),EA&&uA&&m.jsx("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:m.jsx(Nt,{plain:!0,color:hA?"success":"muted",onClick:uA,title:hA?"Hide link quality overlay":"Show link quality overlay","aria-label":hA?"Hide link quality overlay":"Show link quality overlay","aria-pressed":hA,className:I0,"data-tint":hA?"success":void 0,children:m.jsx(el,{className:cA})})})]})})}const Kc="#4ADE80",Zc="#16A34A",qc="rgba(10, 26, 10, 1)",Jc="rgba(220, 252, 231, 1)",gn="DeepAnalysis",Xc=700,Fi="abcdefghijklmnopqrstuvwxyz0123456789";function Af(){return Fi[Math.floor(Math.random()*Fi.length)]}function ef({isActive:a,hasAnalyzed:c,isLoading:g,onClick:y,basemapMode:x="dark"}){const k=x==="light",D=k?Zc:Kc,[P,M]=j.useState(!1),[b,R]=j.useState(gn),O=j.useRef(!1),z=j.useRef(null),[W]=j.useState(()=>{var AA;return typeof window<"u"&&(((AA=window.matchMedia)==null?void 0:AA.call(window,"(hover: hover)").matches)??!1)}),V=P&&!a&&!g&&W;j.useEffect(()=>{if(P&&!a&&!g&&!O.current){O.current=!0;const AA=performance.now(),K=hA=>{const uA=hA-AA,EA=Math.min(uA/Xc,1),oA=Math.floor(EA*gn.length);let lA="";for(let BA=0;BA<gn.length;BA++)BA<oA?lA+=gn[BA]:gn[BA]===" "?lA+=" ":lA+=Af();R(lA),EA<1?z.current=requestAnimationFrame(K):R(gn)};z.current=requestAnimationFrame(K)}return P||(z.current&&(cancelAnimationFrame(z.current),z.current=null),O.current=!1,R(gn)),()=>{z.current&&cancelAnimationFrame(z.current)}},[P,a,g]);const X=g?"Analyzing...":b,iA=g?"Analyzing packet history":c?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(Z0,{className:"w-3.5 h-3.5 shrink-0 animate-spin",style:{color:D}}):m.jsx(Ms,{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:X})]})}const tf=lr.teal,rf="#0D7377",nf="rgba(10, 36, 32, 1)",sf="rgba(204, 251, 241, 1)",Pi="LiveTrace",of=400,Qi=100;function lf({isActive:a,onClick:c,basemapMode:g="dark"}){const y=g==="light",x=y?rf:tf,[k,D]=j.useState(!1),[P,M]=j.useState(0),b=j.useRef(!1),R=j.useRef(null),[O,z]=j.useState(0),W=j.useRef(!1),[V]=j.useState(()=>{var K;return typeof window<"u"&&(((K=window.matchMedia)==null?void 0:K.call(window,"(hover: hover)").matches)??!1)}),X=k&&!a&&V;j.useEffect(()=>{X&&!W.current&&(W.current=!0,z(1),setTimeout(()=>z(2),Qi),setTimeout(()=>z(3),Qi*2)),k||(W.current=!1,z(0))},[X,k]),j.useEffect(()=>{if(k&&!a&&!b.current){b.current=!0;const K=performance.now(),hA=uA=>{const EA=uA-K,oA=Math.min(EA/of,1);M(oA),oA<1&&(R.current=requestAnimationFrame(hA))};R.current=requestAnimationFrame(hA)}return k||(R.current&&(cancelAnimationFrame(R.current),R.current=null),b.current=!1,M(0)),()=>{R.current&&cancelAnimationFrame(R.current)}},[k,a]);const iA=K=>{if(a)return x;if(!X)return;const hA=Pi.length,uA=P*(hA+2);return K>=uA-2&&K<uA?"#FFFFFF":x},AA=a?"Disable live packet tracing":"Enable live packet tracing";return m.jsxs("button",{onClick:c,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":AA,"aria-pressed":a,children:[m.jsx(gu,{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||X?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||X?700:500,letterSpacing:"-0.01em",lineHeight:1},children:Pi.split("").map((K,hA)=>m.jsx("span",{style:{color:iA(hA)||void 0},children:K},hA))})]})}const Oi=.2,af="rgba(26, 20, 8, 1)",uf="rgba(254, 243, 199, 1)",ws=.01,vs=1,zi="#fe8019",cf="'Wardrive', serif",Rs=1.45,ff=Rs*1.1,hf=80;function df({isActive:a,onClick:c,brightness:g=.7,onBrightnessChange:y,basemapMode:x="dark"}){const k=x==="light",[D,P]=j.useState(!1),[M,b]=j.useState(!1),[R]=j.useState(()=>{var K;return typeof window<"u"&&(((K=window.matchMedia)==null?void 0:K.call(window,"(hover: hover)").matches)??!1)});j.useEffect(()=>{if(!D||a)return;const K=requestAnimationFrame(()=>b(!0)),hA=setTimeout(()=>b(!1),hf);return()=>{cancelAnimationFrame(K),clearTimeout(hA)}},[D,a]);const O=Math.max(ws,Math.min(vs,g)),z=K=>{K.stopPropagation();const hA=Math.min(vs,O+Oi);y==null||y(hA)},W=K=>{K.stopPropagation();const hA=Math.max(ws,O-Oi);y==null||y(hA)},V=O<vs-.001,X=O>ws+.001,iA=D&&!a&&R,AA=a?"Configure wardriving coverage":"Show wardriving coverage";return m.jsxs("button",{onClick:c,onMouseEnter:()=>R&&P(!0),onMouseLeave:()=>R&&P(!1),onPointerEnter:()=>R&&P(!0),onPointerLeave:()=>R&&P(!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:AA,"aria-label":AA,"aria-pressed":a,children:[m.jsx(nc,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${a?"text-sys-amber":"text-fg-secondary"}`,style:iA?{color:zi}: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(${Rs})`:iA?`scale(${M?ff:Rs})`:void 0,transformOrigin:"left center",...iA?{color:zi}:{}},children:"Wardrive"}),a&&y&&m.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m.jsx("button",{onClick:W,disabled:!X,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 ${X?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:X?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(Gs,{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(Us,{className:"w-3.5 h-3.5"})})]})]})}const mf="0123456789bcdefghjkmnpqrstuvwxyz";function pf(a){let c=!0,g=-90,y=90,x=-180,k=180;for(const D of a.toLowerCase()){const P=mf.indexOf(D);if(P!==-1)for(let M=4;M>=0;M--){const b=P>>M&1;if(c){const R=(x+k)/2;b?x=R:k=R}else{const R=(g+y)/2;b?g=R:y=R}c=!c}}return{lat:(g+y)/2,lon:(x+k)/2}}function gf(a){return Math.exp(-a*Math.LN2/7)}const Is="pymc-wardriving-url",sl="pymc-wardriving-enabled",il="pymc-wardriving-brightness",Hi=.7;function yf(){return typeof localStorage>"u"?"":localStorage.getItem(Is)||""}function Gi(a){typeof localStorage>"u"||(a?localStorage.setItem(Is,a):localStorage.removeItem(Is))}function xf(){return typeof localStorage>"u"?!1:localStorage.getItem(sl)==="true"}function L0(a){typeof localStorage>"u"||localStorage.setItem(sl,String(a))}function wf(){if(typeof localStorage>"u")return Hi;const a=localStorage.getItem(il);if(a){const c=parseFloat(a);if(!isNaN(c)&&c>=.01&&c<=1)return c}return Hi}function vf(a){if(typeof localStorage>"u")return;const c=Math.max(.01,Math.min(1,a));localStorage.setItem(il,String(c))}const bf=8e3;async function kf(a,c={},g=bf){const y=new AbortController,x=setTimeout(()=>y.abort(),g);try{return await fetch(a,{...c,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,c=null){if(a!==null){const y=(Math.max(-12,Math.min(12,a))+12)/24;if(c!==null){const k=(Math.max(-120,Math.min(-50,c))+120)/70;return y*.8+k*.2}return y}return c!==null?(Math.max(-120,Math.min(-50,c))+120)/70:.5}function Sf(a){var g;const c=[];for(const y of a.keys){if(!y.observed)continue;const{lat:x,lon:k}=pf(y.hash),D=parseInt(y.time,10),P=isNaN(D)?30:(Date.now()-D)/(1e3*60*60*24),M=gf(P),R=Ef(y.snr,y.rssi)*(.3+M*.7);c.push({lat:x,lon:k,successRate:y.observed?1:0,weight:R,totalSamples:1,ageDays:P,geohash:y.hash,repeaters:((g=y.path)==null?void 0:g.map(O=>O.toLowerCase()))||[]})}return c}const y0=jo((a,c)=>({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=!c().isVisible;L0(g),a({isVisible:g})},setVisible:g=>{L0(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()}),Gi(g.trim()),L0(!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:""}),Gi(""),L0(!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"},ol={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)"},ll=j.createContext({theme:ol,isLight:!1});function Mn(){return j.useContext(ll)}function Bf({status:a,hasData:c}){const{theme:g,isLight:y}=Mn(),x=j.useMemo(()=>a==="connecting"||a==="loading"||a==="processing"?{icon:m.jsx(Z0,{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(Mu,{className:"w-3.5 h-3.5"}),label:"Disconnected",color:g.error,bg:g.errorBg}:c?{icon:m.jsx(Bu,{className:"w-3.5 h-3.5"}),label:"Connected",color:g.success,bg:g.successBg}:{icon:m.jsx(Io,{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,c,g,y]);return m.jsxs(Jt.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:c}=Mn(),g=j.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(Jt.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:c.sliderTrack},children:m.jsx(Jt.div,{className:"h-full rounded-full",style:{backgroundColor:c.primary},initial:{width:0},animate:{width:`${g}%`},transition:{duration:.4,ease:"easeOut"}})})}function Ui({variant:a,title:c,description:g,onDismiss:y}){const{theme:x}=Mn(),k=j.useMemo(()=>{switch(a){case"success":return{icon:m.jsx(Wn,{className:"w-4 h-4"}),color:x.success,bg:x.successBg,border:x.successBorder};case"error":return{icon:m.jsx(Du,{className:"w-4 h-4"}),color:x.error,bg:x.errorBg,border:x.errorBorder};case"info":return{icon:m.jsx(Ku,{className:"w-4 h-4"}),color:x.info,bg:x.infoBg,border:x.infoBorder}}},[a,x]);return m.jsxs(Jt.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:c}),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:c,onSubmit:g,disabled:y}){const{theme:x,isLight:k}=Mn(),[D,P]=j.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=>c(b.target.value),onKeyDown:M,onFocus:()=>P(!0),onBlur:()=>P(!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:()=>c(""),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 Tf({value:a,onChange:c}){const{theme:g,isLight:y}=Mn(),x=Math.round(a*100);return m.jsx(Jt.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(Gs,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.textMuted,opacity:a<.5?1:0}}),m.jsx(Us,{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=>c(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 jf({coverageCount:a,repeaterCount:c,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(ki,{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(ki,{value:c,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 Vi({icon:a,label:c,onClick:g,disabled:y,variant:x="default",active:k}){const{theme:D,isLight:P}=Mn(),M=j.useMemo(()=>x==="danger"?{text:D.error,hoverBg:P?"rgba(220, 38, 38, 0.08)":"rgba(239, 68, 68, 0.15)"}:{text:k?D.primary:D.textSecondary,hoverBg:D.hoverBg},[x,k,D,P]);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:c})]})}function Rf(){const a=Ro(),c=a==="light",g=c?Mf:ol,{isModalOpen:y,closeModal:x,status:k,isVisible:D,stats:P,error:M,url:b,brightness:R,loadCoverage:O,clearCoverage:z,toggleVisibility:W,setUrl:V,setBrightness:X}=y0(),iA=k==="connecting"||k==="loading"||k==="processing",AA=P.coverageCount>0,[K,hA]=j.useState(!0),[uA,EA]=j.useState(b);j.useEffect(()=>{EA(b)},[b]),j.useEffect(()=>{k==="error"&&hA(!0)},[k]);const oA=j.useCallback(async()=>{await O(uA)},[uA,O]),lA=j.useCallback(()=>{EA(""),z()},[z]),BA=j.useCallback(cA=>{EA(cA),V(cA)},[V]),SA=j.useCallback(()=>{iA||x()},[iA,x]),bA=uA.trim().length>0&&!iA;return m.jsx(ll.Provider,{value:{theme:g,isLight:c},children:m.jsxs(Co,{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(Io,{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:AA}),!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:cA=>{cA.currentTarget.style.color=g.text,cA.currentTarget.style.backgroundColor=g.hoverBg},onMouseLeave:cA=>{cA.currentTarget.style.color=g.textMuted,cA.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:m.jsx(Sn,{className:"w-5 h-5"})})]})]})]}),m.jsx(Cr,{children:iA&&m.jsx(Df,{status:k})}),m.jsxs(Eo,{className:"space-y-4",children:[m.jsx(_f,{value:uA,onChange:BA,onSubmit:oA,disabled:iA}),m.jsx(Cr,{children:k==="error"&&M&&K&&m.jsx(Ui,{variant:"error",title:"Connection Failed",description:M,onDismiss:()=>hA(!1)})}),m.jsx(Cr,{children:k==="success"&&AA&&m.jsx(Ui,{variant:"success",title:"Coverage Data Loaded",description:"Adjust opacity below, then close to view on map"})}),m.jsx(Cr,{children:AA&&!iA&&m.jsx(Jt.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:En.snappy,children:m.jsx(jf,{coverageCount:P.coverageCount,repeaterCount:P.repeaterCount,lastUpdated:P.lastUpdated})})}),m.jsx(Cr,{children:AA&&!iA&&m.jsx(Tf,{value:R,onChange:X})})]}),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(Cr,{children:AA&&m.jsxs(Jt.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(Vi,{icon:D?m.jsx(wu,{className:"w-4 h-4"}):m.jsx(Wo,{className:"w-4 h-4"}),label:D?"Hide":"Show",onClick:W,disabled:iA,active:D}),m.jsx(Vi,{icon:m.jsx(Su,{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(Nt,{plain:!0,color:"muted",onClick:SA,disabled:iA,children:AA?"Done":"Cancel"}),m.jsx(Nt,{color:"warning",onClick:oA,disabled:!bA,children:iA?m.jsxs(m.Fragment,{children:[m.jsx(Z0,{"data-slot":"icon",className:"animate-spin"}),k==="connecting"?"Connecting...":k==="loading"?"Loading...":"Processing..."]}):AA?m.jsxs(m.Fragment,{children:[m.jsx(Bo,{"data-slot":"icon"}),"Refresh"]}):m.jsxs(m.Fragment,{children:[m.jsx(So,{"data-slot":"icon"}),"Connect"]})})]})]})]})})}const If={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5};function N0({label:a,value:c,min:g,max:y,step:x,unit:k,formatValue:D,onChange:P}){const M=D?D(c):c.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:c,onChange:b=>P(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 F0({icon:a,label:c,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:c})}),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:c,settings:g,onSettingsChange:y,partition:x,totalNodes:k,basemapMode:D="dark"}){const P=vu(),M=j.useRef(null),b=j.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,X)=>V+X,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]),R=(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(Cr,{children:a&&m.jsx(Jt.div,{drag:!0,dragControls:P,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=>P.start(z),children:[m.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5",children:[m.jsx(bu,{className:"w-4 h-4 sm:w-3 sm:h-3 text-fg-muted"}),m.jsx(Ds,{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(Nt,{plain:!0,color:"muted",onClick:c,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(F0,{icon:m.jsx(Ds,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Communities",value:b.numCommunities}),m.jsx(F0,{icon:m.jsx(xi,{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(F0,{icon:m.jsx(tc,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Fiedler λ₂",value:b.fiedlerValue.toFixed(3)}),m.jsx(F0,{icon:m.jsx(xi,{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(N0,{label:"Bandwidth",value:g.bandwidth,min:.01,max:.15,step:.005,formatValue:()=>O,unit:"km",onChange:z=>R("bandwidth",z)}),m.jsx(N0,{label:"Threshold",value:g.threshold,min:.05,max:.5,step:.01,formatValue:z=>`${Math.round((1-z)*100)}%`,unit:"cov",onChange:z=>R("threshold",z)}),m.jsx(N0,{label:"Opacity",value:g.opacity,min:.1,max:1,step:.05,formatValue:z=>`${Math.round(z*100)}%`,onChange:z=>R("opacity",z)}),m.jsx(N0,{label:"Stroke",value:g.strokeWidth,min:0,max:5,step:.5,unit:"px",formatValue:z=>z.toFixed(1),onChange:z=>R("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 x0(a,c){return Nf[Fo(a,c)]}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 Hn({prefix:a,name:c}){const g=j.useRef(null),[y,x]=j.useState(!1),[k,D]=j.useState({top:0,left:0}),P=()=>{if(!c||!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:P,onMouseLeave:()=>x(!1),children:a}),c&&y&&Na.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:c}),document.body)]})}function al(a){if(a._tracePathHashes)return a._tracePathHashes;if(a.payload&&a.payload.length>=20){const c=parseInt(a.payload.slice(16,18),16),y=(isNaN(c)?1:1<<(c&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 ul(a,c){return a.src_hash?[a.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase(),...c.map(y=>y.toUpperCase())]:c.map(g=>g.toUpperCase())}function Qf(a,c,g,y=15){const x=[],k=c.toUpperCase(),D=g.toUpperCase();for(const P of a){if((P.type??P.payload_type)!==La.TRACE)continue;const b=al(P);if(!b||b.length<1)continue;const R=ul(P,b);if(!(R.length<2)){for(let O=0;O<R.length-1;O++)if(R[O]===k&&R[O+1]===D||R[O]===D&&R[O+1]===k){x.push(P);break}if(x.length>=y)break}}return x}function Of(a){switch(a){case"improving":return m.jsx(Pa,{className:"w-3 h-3 text-sys-green"});case"degrading":return m.jsx(ic,{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 V0({label:a,value:c,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:[c,g&&m.jsx("span",{className:"text-fg-muted ml-0.5",children:g})]})]})}function Wi({stats:a,direction:c,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:c})}),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=Fa(g),P=a.mean-D,M=Fo(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: ${P>=0?"+":""}${P.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:c}),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(V0,{label:"Mean",value:a.mean.toFixed(1),unit:"dB",color:x0(a.mean,g),tooltip:b.join(`
`)}),m.jsx(V0,{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(V0,{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:c,prefixToName:g}){var EA,oA,lA,BA,SA,bA,cA,IA,LA,FA,UA,vA;const y=Lo(),x=_a(),k=Ta(),D=ja(),[P,M]=j.useState(null),b=((oA=(EA=k==null?void 0:k.config)==null?void 0:EA.radio)==null?void 0:oA.spreading_factor)??Ra,R=j.useMemo(()=>{const aA=`${a.nodeA.hash}>${a.nodeB.hash}`,dA=`${a.nodeB.hash}>${a.nodeA.hash}`;return{forward:y.get(aA)??null,reverse:y.get(dA)??null}},[y,a.nodeA.hash,a.nodeB.hash]),O=j.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=R.forward)==null?void 0:lA.trend)??((BA=R.reverse)==null?void 0:BA.trend)??"insufficient",X=Math.max(((SA=R.forward)==null?void 0:SA.lastSeen)??0,((bA=R.reverse)==null?void 0:bA.lastSeen)??0),iA=(((cA=R.forward)==null?void 0:cA.uniqueTraceCount)??0)+(((IA=R.reverse)==null?void 0:IA.uniqueTraceCount)??0),AA=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.`,K=((LA=R.forward)==null?void 0:LA.uniqueTraceCount)??0,hA=((FA=R.reverse)==null?void 0:FA.uniqueTraceCount)??0,uA=["Number of trace packets that traveled through this link.",`${a.nodeA.prefix}→${a.nodeB.prefix}: ${K}`,`${a.nodeB.prefix}→${a.nodeA.prefix}: ${hA}`].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(el,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-green shrink-0"}),m.jsx(Hn,{prefix:a.nodeA.prefix,name:z}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"↔"}),m.jsx(Hn,{prefix:a.nodeB.prefix,name:W})]}),m.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[X>0&&m.jsx("span",{className:"type-data-xs text-fg-muted",title:wi(X),children:No(X)}),m.jsx(Nt,{plain:!0,color:"muted",onClick:c,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 ${((UA=a.aToB)==null?void 0:UA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Hn,{prefix:a.nodeA.prefix,name:z}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Hn,{prefix:a.nodeB.prefix,name:W})]}),a.aToB?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${x0(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 ${((vA=a.bToA)==null?void 0:vA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Hn,{prefix:a.nodeB.prefix,name:W}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Hn,{prefix:a.nodeA.prefix,name:z})]}),a.bToA?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${x0(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(Wi,{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(Wi,{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:AA,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(V0,{label:"Unique traces",value:iA.toString(),tooltip:uA})]}),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((aA,dA)=>{const RA=al(aA),_A=RA?ul(aA,RA):null,YA=_A?Math.max(0,_A.length-1):0,ue=_A?_A.map(VA=>(g==null?void 0:g.get(VA))??VA).join(" → "):null,JA=P===dA,KA=aA.id??`${aA.packet_hash}-${aA.timestamp}`;return m.jsxs("div",{className:"rounded-sm",style:dA%2===1?zf:void 0,children:[m.jsxs("button",{onClick:()=>M(JA?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:[JA?m.jsx(_o,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"}):m.jsx(_u,{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:wi(aA.timestamp)}),ue?m.jsx("span",{className:"text-fg-secondary truncate min-w-0",title:_A.join(" → "),children:ue}):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:[YA,"h"]}),aA.snr!=null&&m.jsx("span",{className:`shrink-0 tabular-nums ${x0(aA.snr,b)}`,children:aA.snr.toFixed(1)})]}),JA&&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:[aA.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:[aA.rssi," dBm"]})]}),aA.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 ${x0(aA.snr,b)}`,children:[aA.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:Ia(aA.route??aA.route_type)})]}),aA.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(),X0(aA.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:aA.packet_hash}),m.jsx(J0,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"})]})]}),aA.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:aA.src_hash,children:aA.src_hash})]}),_A&&_A.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:_A.join(" → "),children:_A.join(" → ")})]})]})]},KA)})})]})]})})}function Gf({channels:a,messages:c}){const g=j.useMemo(()=>a.find(k=>k.name.toLowerCase().includes("wardrive"))??null,[a]),y=j.useMemo(()=>g?c.get(`ch:${g.index}`)??[]:[],[g,c]);if(!g||y.length===0)return null;const x=()=>{const k=Iu(y);k.length>=2&&Ws.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(Xu,{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=Vs(),c=Ko(),g=Zo(),y=Tu(),x=ju(),{togglePlay:k,setSpeed:D,seek:P,stopRewind:M}=Ws.getState(),b=x.end-x.start,R=x.end-g,O=b>0?(g-x.start)/b:1,z=j.useCallback(W=>{const V=parseFloat(W.target.value)/100;P(x.start+V*b)},[P,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:c?"Pause":"Rewind","aria-label":c?"Pause rewind":"Rewind",children:c?m.jsx(Qa,{className:"w-3.5 h-3.5"}):m.jsx(Oa,{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:["-",Ei(R)," / ",Ei(b)]}),m.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:Ru.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 cl=[{target:"Sparklines",fn:"sparklines",minStage:2}];Vo(cl);const fl=j.memo(function({nodeHash:c,width:g=60,height:y=20,color:x,showArea:k=!0,showTooltip:D=!1,className:P=""}){Uo(cl);const M=za(c),b=Ha(),O=!Po().backgroundLoadComplete||b,z=typeof g=="number"?g:60;return m.jsx(Qu,{data:M,width:z,height:y,color:x,isLoading:O,className:P})});function Vf(a){return a===null?"—":a<1e3?`${Math.round(a)}m`:`${(a/1e3).toFixed(1)}km`}function Wf(a){const c=new Date(a*1e3);return`${(c.getMonth()+1).toString().padStart(2,"0")}/${c.getDate().toString().padStart(2,"0")}`}function Yf({txDelayRec:a,networkRole:c,roleTitles:g,dataConfidence:y,dataQualityTitles:x}){const[k,D]=j.useState(!1),P=a.floodFactor??a.txDelayFactor,M=a.directFactor??a.directTxDelayFactor,b=async()=>{const R=`set txdelay ${P.toFixed(1)}
set direct.txdelay ${M.toFixed(1)}`;await X0(R),D(!0),setTimeout(()=>D(!1),1500)};return m.jsxs("div",{className:"flex flex-col gap-1.5 text-sm",children:[(c||y)&&m.jsxs("div",{className:"flex items-center gap-2",children:[c&&m.jsx(gt,{color:zu[c],compact:!0,title:g[c],children:c}),y&&m.jsxs(gt,{color:Hu[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(lc,{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:["×",P.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(Wn,{className:"w-3.5 h-3.5 text-sys-green ml-auto"}):m.jsx(J0,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]})]})}function $f({hash:a,hashPrefix:c,name:g,isHub:y,isGateway:x,isBackbone:k,isZeroHop:D,isMobile:P,isRoomServer:M,isStale:b,lastSeenTimestamp:R,centrality:O,affinity:z,meanSnr:W,meanRssi:V,neighbor:X,onRemove:iA,txDelayRec:AA,hideHeader:K=!1}){const[hA,uA]=j.useState(!1),EA=async()=>{await X0(a),uA(!0),setTimeout(()=>uA(!1),1500)},oA=D?"Direct":z!=null&&z.typicalHopPosition?`${z.typicalHopPosition}-hop`:null,lA=AA&&!AA.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:[!K&&m.jsx("div",{className:"text-[14px] font-semibold text-fg-primary leading-tight truncate mb-1",children:g}),!K&&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:c}),m.jsx("button",{onClick:EA,className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:hA?m.jsx(Wn,{className:"w-3 h-3 text-sys-green"}):m.jsx(J0,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(Jo,{hash:a,size:"sm"}),oA&&m.jsx(gt,{color:D?Y0.direct:Y0.multihop,compact:!0,children:oA}),X.is_repeater&&m.jsx(gt,{color:ar.repeater,compact:!0,children:"Rptr"}),y&&m.jsx(gt,{color:ar.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),x&&!y&&m.jsx(gt,{color:ar.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),k&&m.jsx(gt,{color:ar.backbone,compact:!0,title:"Backbone",children:"Bone"}),P&&m.jsx(gt,{color:ar.mobile,compact:!0,children:"Mobile"}),M&&m.jsx(gt,{color:ar.room,compact:!0,children:"Room"}),b&&R&&m.jsxs(gt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",Wf(R)]})]}),m.jsx("div",{title:"7-day activity trend (6-hour buckets)",children:m.jsx(fl,{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:X.last_seen?`Last heard: ${new Date(X.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:No(X.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(Ou,{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)})]}),X.latitude&&X.longitude&&X.latitude!==0&&X.longitude!==0&&m.jsxs("span",{className:"flex items-center gap-0.5",title:"GPS coordinates (lat, lon)",children:[m.jsx(Gu,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsxs("span",{className:"font-mono text-fg-muted",children:[X.latitude.toFixed(2),", ",X.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:X.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:AA,networkRole:AA.networkRole,roleTitles:BA,dataConfidence:AA.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 Kf(a){const c=new Date(a*1e3);return`${(c.getMonth()+1).toString().padStart(2,"0")}/${c.getDate().toString().padStart(2,"0")}`}function Zf({data:a,localNode:c,localColor:g,onClose:y,onRemove:x}){var b,R,O,z;const[k,D]=j.useState(!1);j.useEffect(()=>{if(!a)return;const W=V=>{V.key==="Escape"&&y()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[a,y]);const P=async()=>{a!=null&&a.hash&&(await X0(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(Cr,{children:a&&m.jsx(Jt.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:P,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(Wn,{className:"w-3 h-3 text-sys-green"}):m.jsx(J0,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(Jo,{hash:a.hash,size:"sm"})]})]}),m.jsx(Nt,{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||((R=a.neighbor)==null?void 0:R.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(gt,{color:a.isZeroHop?Y0.direct:Y0.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(gt,{color:ar.repeater,compact:!0,title:"Repeater node (forwards packets)",children:"Rptr"}),a.isHub&&m.jsx(gt,{color:ar.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),a.isGateway&&!a.isHub&&m.jsx(gt,{color:ar.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),a.isBackbone&&m.jsx(gt,{color:ar.backbone,compact:!0,title:"Backbone: critical relay with high traffic",children:"Bone"}),a.isMobile&&m.jsx(gt,{color:ar.mobile,compact:!0,title:"Mobile repeater (path volatility detected)",children:"Mobile"}),a.isRoomServer&&m.jsx(gt,{color:ar.room,compact:!0,title:"Room server node",children:"Room"}),a.isStale&&a.lastSeenTimestamp&&m.jsxs(gt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",Kf(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(fl,{nodeHash:a.hash,width:224,height:28,showArea:!0,showTooltip:!0,className:"w-full"})}),c&&m.jsxs("div",{className:"text-xs text-fg-muted font-mono border-t border-edge-subtle pt-2",children:[c.latitude.toFixed(5),", ",c.longitude.toFixed(5)]})]}):a.neighbor&&a.hash?m.jsx($f,{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,c)=>{try{localStorage.setItem(a,c)}catch{}},removeItem:a=>{try{localStorage.removeItem(a)}catch{}}},hl=jo()(fu(a=>({isEnabled:!1,toggle:()=>a(c=>({isEnabled:!c.isEnabled})),setEnabled:c=>a({isEnabled:c})}),{name:"pymc-live-trace",storage:hu(()=>qf)})),Jf=()=>hl(a=>a.isEnabled),Xf=()=>hl(a=>a.toggle);var Ft=(function(a){a=a||{};var c=typeof a<"u"?a:{},g={},y;for(y in c)c.hasOwnProperty(y)&&(g[y]=c[y]);var x="";function k(nA){return c.locateFile?c.locateFile(nA,x):x+nA}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,jA,xA){var t=new XMLHttpRequest;t.open("GET",yA,!0),t.responseType="arraybuffer",t.onload=function(){if(t.status==200||t.status==0&&t.response){jA(t.response);return}var ge=pr(yA);if(ge){jA(ge.buffer);return}xA()},t.onerror=xA,t.send(null)};var P=c.print||console.log.bind(console),M=c.printErr||console.warn.bind(console);for(y in g)g.hasOwnProperty(y)&&(c[y]=g[y]);g=null,c.arguments&&c.arguments;var b=0,R=function(nA){b=nA},O=function(){return b},z=8;function W(nA,yA,jA,xA){switch(jA=jA||"i8",jA.charAt(jA.length-1)==="*"&&(jA="i32"),jA){case"i1":IA[nA>>0]=yA;break;case"i8":IA[nA>>0]=yA;break;case"i16":FA[nA>>1]=yA;break;case"i32":UA[nA>>2]=yA;break;case"i64":ct=[yA>>>0,(ze=yA,+ke(ze)>=1?ze>0?(Ke(+pe(ze/4294967296),4294967295)|0)>>>0:~~+Se((ze-+(~~ze>>>0))/4294967296)>>>0:0)],UA[nA>>2]=ct[0],UA[nA+4>>2]=ct[1];break;case"float":vA[nA>>2]=yA;break;case"double":aA[nA>>3]=yA;break;default:yt("invalid type for setValue: "+jA)}}function V(nA,yA,jA){switch(yA=yA||"i8",yA.charAt(yA.length-1)==="*"&&(yA="i32"),yA){case"i1":return IA[nA>>0];case"i8":return IA[nA>>0];case"i16":return FA[nA>>1];case"i32":return UA[nA>>2];case"i64":return UA[nA>>2];case"float":return vA[nA>>2];case"double":return aA[nA>>3];default:yt("invalid type for getValue: "+yA)}return null}var X=!1;function iA(nA,yA){nA||yt("Assertion failed: "+yA)}function AA(nA){var yA=c["_"+nA];return iA(yA,"Cannot call unknown function "+nA+", make sure it is exported"),yA}function K(nA,yA,jA,xA,t){var C={string:function(se){var et=0;if(se!=null&&se!==0){var Et=(se.length<<2)+1;et=ft(Et),BA(se,et,Et)}return et},array:function(se){var et=ft(se.length);return SA(se,et),et}};function ge(se){return yA==="string"?oA(se):yA==="boolean"?!!se:se}var De=AA(nA),Le=[],ee=0;if(xA)for(var Ce=0;Ce<xA.length;Ce++){var Ge=C[jA[Ce]];Ge?(ee===0&&(ee=ur()),Le[Ce]=Ge(xA[Ce])):Le[Ce]=xA[Ce]}var Be=De.apply(null,Le);return Be=ge(Be),ee!==0&&Fe(ee),Be}function hA(nA,yA,jA,xA){jA=jA||[];var t=jA.every(function(ge){return ge==="number"}),C=yA!=="string";return C&&t&&!xA?AA(nA):function(){return K(nA,yA,jA,arguments)}}var uA=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function EA(nA,yA,jA){for(var xA=yA+jA,t=yA;nA[t]&&!(t>=xA);)++t;if(t-yA>16&&nA.subarray&&uA)return uA.decode(nA.subarray(yA,t));for(var C="";yA<t;){var ge=nA[yA++];if(!(ge&128)){C+=String.fromCharCode(ge);continue}var De=nA[yA++]&63;if((ge&224)==192){C+=String.fromCharCode((ge&31)<<6|De);continue}var Le=nA[yA++]&63;if((ge&240)==224?ge=(ge&15)<<12|De<<6|Le:ge=(ge&7)<<18|De<<12|Le<<6|nA[yA++]&63,ge<65536)C+=String.fromCharCode(ge);else{var ee=ge-65536;C+=String.fromCharCode(55296|ee>>10,56320|ee&1023)}}return C}function oA(nA,yA){return nA?EA(LA,nA,yA):""}function lA(nA,yA,jA,xA){if(!(xA>0))return 0;for(var t=jA,C=jA+xA-1,ge=0;ge<nA.length;++ge){var De=nA.charCodeAt(ge);if(De>=55296&&De<=57343){var Le=nA.charCodeAt(++ge);De=65536+((De&1023)<<10)|Le&1023}if(De<=127){if(jA>=C)break;yA[jA++]=De}else if(De<=2047){if(jA+1>=C)break;yA[jA++]=192|De>>6,yA[jA++]=128|De&63}else if(De<=65535){if(jA+2>=C)break;yA[jA++]=224|De>>12,yA[jA++]=128|De>>6&63,yA[jA++]=128|De&63}else{if(jA+3>=C)break;yA[jA++]=240|De>>18,yA[jA++]=128|De>>12&63,yA[jA++]=128|De>>6&63,yA[jA++]=128|De&63}}return yA[jA]=0,jA-t}function BA(nA,yA,jA){return lA(nA,LA,yA,jA)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function SA(nA,yA){IA.set(nA,yA)}function bA(nA,yA){return nA%yA>0&&(nA+=yA-nA%yA),nA}var cA,IA,LA,FA,UA,vA,aA;function dA(nA){cA=nA,c.HEAP8=IA=new Int8Array(nA),c.HEAP16=FA=new Int16Array(nA),c.HEAP32=UA=new Int32Array(nA),c.HEAPU8=LA=new Uint8Array(nA),c.HEAPU16=new Uint16Array(nA),c.HEAPU32=new Uint32Array(nA),c.HEAPF32=vA=new Float32Array(nA),c.HEAPF64=aA=new Float64Array(nA)}var RA=5271536,_A=28624,YA=c.TOTAL_MEMORY||33554432;c.buffer?cA=c.buffer:cA=new ArrayBuffer(YA),YA=cA.byteLength,dA(cA),UA[_A>>2]=RA;function ue(nA){for(;nA.length>0;){var yA=nA.shift();if(typeof yA=="function"){yA();continue}var jA=yA.func;typeof jA=="number"?yA.arg===void 0?c.dynCall_v(jA):c.dynCall_vi(jA,yA.arg):jA(yA.arg===void 0?null:yA.arg)}}var JA=[],KA=[],VA=[],Re=[];function Ie(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)$e(c.preRun.shift());ue(JA)}function oe(){ue(KA)}function me(){ue(VA)}function we(){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)be(c.postRun.shift());ue(Re)}function $e(nA){JA.unshift(nA)}function be(nA){Re.unshift(nA)}var ke=Math.abs,Se=Math.ceil,pe=Math.floor,Ke=Math.min,Je=0,At=null;function it(nA){Je++,c.monitorRunDependencies&&c.monitorRunDependencies(Je)}function St(nA){if(Je--,c.monitorRunDependencies&&c.monitorRunDependencies(Je),Je==0&&At){var yA=At;At=null,yA()}}c.preloadedImages={},c.preloadedAudios={};var Qe=null,Xe="data:application/octet-stream;base64,";function Me(nA){return String.prototype.startsWith?nA.startsWith(Xe):nA.indexOf(Xe)===0}var ze,ct;Qe="data:application/octet-stream;base64,[encoded data, 37208 characters]";var Pt=28640;function Br(nA,yA,jA,xA){yt("Assertion failed: "+oA(nA)+", at: "+[yA?oA(yA):"unknown filename",jA,xA?oA(xA):"unknown function"])}function Xt(){return IA.length}function Ar(nA,yA,jA){LA.set(LA.subarray(yA,yA+jA),nA)}function zr(nA){return c.___errno_location&&(UA[c.___errno_location()>>2]=nA),nA}function nn(nA){yt("OOM")}function Dr(nA){try{var yA=new ArrayBuffer(nA);return yA.byteLength!=nA?void 0:(new Int8Array(yA).set(IA),gr(yA),dA(yA),1)}catch{}}function Gt(nA){var yA=Xt(),jA=16777216,xA=2147483648-jA;if(nA>xA)return!1;for(var t=16777216,C=Math.max(yA,t);C<nA;)C<=536870912?C=bA(2*C,jA):C=Math.min(bA((3*C+2147483648)/4,jA),xA);var ge=Dr(C);return!!ge}var _r=typeof atob=="function"?atob:function(nA){var yA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",jA="",xA,t,C,ge,De,Le,ee,Ce=0;nA=nA.replace(/[^A-Za-z0-9\+\/\=]/g,"");do ge=yA.indexOf(nA.charAt(Ce++)),De=yA.indexOf(nA.charAt(Ce++)),Le=yA.indexOf(nA.charAt(Ce++)),ee=yA.indexOf(nA.charAt(Ce++)),xA=ge<<2|De>>4,t=(De&15)<<4|Le>>2,C=(Le&3)<<6|ee,jA=jA+String.fromCharCode(xA),Le!==64&&(jA=jA+String.fromCharCode(t)),ee!==64&&(jA=jA+String.fromCharCode(C));while(Ce<nA.length);return jA};function sn(nA){try{for(var yA=_r(nA),jA=new Uint8Array(yA.length),xA=0;xA<yA.length;++xA)jA[xA]=yA.charCodeAt(xA);return jA}catch{throw new Error("Converting base64 string to bytes failed.")}}function pr(nA){if(Me(nA))return sn(nA.slice(Xe.length))}var on={Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},Hr={b:R,c:O,d:Br,e:zr,f:Xt,g:Ar,h:Gt,i:nn,o:Pt,p:_A},gA=(function(nA,yA,jA){"almost asm";var xA=new nA.Int8Array(jA),t=new nA.Int32Array(jA);new nA.Uint8Array(jA),new nA.Float32Array(jA);var C=new nA.Float64Array(jA),ge=yA.o|0,De=yA.p|0,Le=nA.Math.floor,ee=nA.Math.abs,Ce=nA.Math.sqrt,Ge=nA.Math.pow,Be=nA.Math.cos,se=nA.Math.sin,et=nA.Math.tan,Et=nA.Math.acos,xt=nA.Math.asin,Ut=nA.Math.atan,at=nA.Math.atan2,Vt=nA.Math.ceil,ht=nA.Math.imul,tt=nA.Math.min,Gr=nA.Math.max,wt=nA.Math.clz32,WA=yA.b,S=yA.c,OA=yA.d,Ue=yA.e,yr=yA.f,cr=yA.g,fr=yA.h,tr=yA.i,E=28656;function hr(e){return xA=new Int8Array(e),t=new Int32Array(e),C=new Float64Array(e),jA=e,!0}function dr(e){e=e|0;var A=0;return A=E,E=E+e|0,E=E+15&-16,A|0}function Tr(){return E|0}function Ur(e){e=e|0,E=e}function jr(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=C0(15,A)|0,A|0):(r=((e|0)<0)<<31>>31,s=mt(e|0,r|0,3,0)|0,n=S()|0,r=$A(e|0,r|0,1,0)|0,r=mt(s|0,n|0,r|0,S()|0)|0,r=$A(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,T(e,A,r,n,0)|0}function T(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,u=0,f=0;if(u=E,E=E+16|0,o=u,!(Q(e,A,r,n,s)|0))return n=0,E=u,n|0;do if((r|0)>=0){if((r|0)>13780509){if(i=C0(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=mt(r|0,i|0,3,0)|0,l=S()|0,i=$A(r|0,i|0,1,0)|0,i=mt(f|0,l|0,i|0,S()|0)|0,i=$A(i|0,S()|0,1,0)|0,l=S()|0,t[o>>2]=i,t[o+4>>2]=l,o=i;if(Jr(n|0,0,o<<3|0)|0,s|0){Jr(s|0,0,o<<2|0)|0,i=J(e,A,r,n,s,o,l,0)|0;break}i=Ht(o,4)|0,i?(f=J(e,A,r,n,i,o,l,0)|0,ZA(i),i=f):i=13}else i=2;while(!1);return f=i,E=u,f|0}function Q(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,u=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),Oe(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=$(i,A,4,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=$(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,u=(l|0)==6,Oe(i,A)|0){i=9;break A}if(I=I+(u&o&1)|0,(I|0)>(r|0)){i=0;break}else p=p+1|0,f=o?0:e,B=o?u?0:l:B}else for(p=1,f=0,B=0,I=1,i=e;;){if(!(f|B)){if(i=$(i,A,4,N,L)|0,i|0)break A;if(A=L,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=$(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,u=(l|0)==6,Oe(i,A)|0){i=9;break A}if(I=I+(u&o&1)|0,(I|0)>(r|0)){i=0;break}else p=p+1|0,f=o?0:e,B=o?u?0:l:B}else i=0;while(!1);return N=i,E=G,N|0}function J(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 u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0;if(G=E,E=E+16|0,L=G+8|0,N=G,u=Nn(e|0,A|0,i|0,o|0)|0,p=S()|0,B=n+(u<<3)|0,Y=B,sA=t[Y>>2]|0,Y=t[Y+4>>2]|0,f=(sA|0)==(e|0)&(Y|0)==(A|0),!((sA|0)==0&(Y|0)==0|f))do u=$A(u|0,p|0,1,0)|0,u=Ln(u|0,S()|0,i|0,o|0)|0,p=S()|0,B=n+(u<<3)|0,sA=B,Y=t[sA>>2]|0,sA=t[sA+4>>2]|0,f=(Y|0)==(e|0)&(sA|0)==(A|0);while(!((Y|0)==0&(sA|0)==0|f));if(u=s+(u<<2)|0,f&&(t[u>>2]|0)<=(l|0)||(sA=B,t[sA>>2]=e,t[sA+4>>2]=A,t[u>>2]=l,(l|0)>=(r|0)))return sA=0,E=G,sA|0;switch(f=l+1|0,t[L>>2]=0,u=$(e,A,2,L,N)|0,u|0){case 9:{I=9;break}case 0:{u=N,u=J(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u||(I=9);break}}A:do if((I|0)==9){switch(t[L>>2]=0,u=$(e,A,3,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=J(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=$(e,A,1,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=J(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=$(e,A,5,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=J(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=$(e,A,4,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=J(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}switch(t[L>>2]=0,u=$(e,A,6,L,N)|0,u|0){case 9:break;case 0:{if(u=N,u=J(t[u>>2]|0,t[u+4>>2]|0,r,n,s,i,o,f)|0,u|0)break A;break}default:break A}return sA=0,E=G,sA|0}while(!1);return sA=u,E=G,sA|0}function $(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,u=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=Yt(r)|0,i=i+1|0;while((i|0)<(t[n>>2]|0))}if(B=wA(e|0,A|0,45)|0,S()|0,p=B&127,p>>>0>121)return s=5,s|0;u=zt(e,A)|0,i=wA(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=wA(e|0,A|0,o|0)|0,S()|0,l=l&7,(l|0)==7){A=5;break}if(N=(sr(i)|0)==0,i=i+-1|0,I=kA(7,0,o|0)|0,A=A&~(S()|0),L=kA(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=kA(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=kA(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=wA(e|0,A|0,45)|0,S()|0,l=l&127;A:do if(_e(l)|0){e:do if((zt(e,A)|0)==1){if((p|0)!=(l|0))if(Rr(l,t[7696+(p*28|0)>>2]|0)|0){e=rs(e,A)|0,o=1,A=S()|0;break}else OA(27795,26864,533,26872);switch(u|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=rs(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=ts(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}if((p|0)!=(l|0)){if(!(Dt(l)|0)){if((o|0)!=0|(zt(e,A)|0)!=5)break;t[n>>2]=(t[n>>2]|0)+1;break}switch(B&127){case 8:case 118:break A}(zt(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,TA(e,A,r,n)|0?(Jr(n|0,0,r*48|0)|0,n=XA(e,A,r,n)|0,n|0):(n=0,n|0)}function TA(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,u=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(Oe(e,A)|0)e=9;else{s=0,B=e;do{if(e=$(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,Oe(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=$(t[e>>2]|0,t[e+4>>2]|0,o,L,I)|0,e|0)break A;if((i|0)!=(p|0))if(u=I,l=t[u>>2]|0,u=t[u+4>>2]|0,e=n+(s<<3)|0,t[e>>2]=l,t[e+4>>2]=u,!(Oe(l,u)|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,u=t[s>>2]|0,l=0,s=e,i=t[o>>2]|0,o=t[o+4>>2]|0;;){if(e=$(i,o,u,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,Oe(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,u=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=C0(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=mt(r|0,s|0,3,0)|0,i=S()|0,s=$A(r|0,s|0,1,0)|0,s=mt(p|0,i|0,s|0,S()|0)|0,s=$A(s|0,S()|0,1,0)|0,i=S()|0,p=o,t[p>>2]=s,t[p+4>>2]=i;if(f=Ht(s,8)|0,!f)s=13;else{if(p=Ht(s,4)|0,!p){ZA(f),s=13;break}if(s=J(e,A,r,f,p,s,i,0)|0,s|0){ZA(f),ZA(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,u=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=$A(l|0,u|0,1,0)|0,u=S()|0;while((u|0)<(o|0)|(u|0)==(o|0)&l>>>0<A>>>0)}ZA(f),ZA(p),s=0}}else s=2;while(!1);return I=s,E=B,I|0}function qA(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,u=0,f=0;for(l=E,E=E+16|0,i=l,o=l+8|0,s=(Oe(e,A)|0)==0,s=s?1:2;;){if(t[o>>2]=0,f=($(e,A,s,o,i)|0)==0,u=i,f&((t[u>>2]|0)==(r|0)?(t[u+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 fe(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,u=0,f=0;if(l=E,E=E+48|0,s=l+16|0,i=l+8|0,o=l,r=o0(r)|0,r|0)return o=r,E=l,o|0;if(f=e,u=t[f+4>>2]|0,r=i,t[r>>2]=t[f>>2],t[r+4>>2]=u,ni(i,s),r=Wt(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,u=$A(A|0,r|0,12,0)|0,f=S()|0,r=o,t[r>>2]=u,t[r+4>>2]=f,r=n,t[r>>2]=u,t[r+4>>2]=f,r=0}return f=r,E=l,f|0}function Ne(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0,he=0,Ee=0,ie=0,GA=0,CA=0,xe=0,We=0,de=0,Ye=0,Lt=0,yi=0;if(We=E,E=E+64|0,ie=We+48|0,GA=We+32|0,CA=We+24|0,MA=We+8|0,HA=We,u=t[e>>2]|0,(u|0)<=0)return xe=0,E=We,xe|0;for(QA=e+4|0,ce=ie+8|0,he=GA+8|0,Ee=MA+8|0,l=0,Z=0;;){f=t[QA>>2]|0,q=f+(Z<<4)|0,t[ie>>2]=t[q>>2],t[ie+4>>2]=t[q+4>>2],t[ie+8>>2]=t[q+8>>2],t[ie+12>>2]=t[q+12>>2],(Z|0)==(u+-1|0)?(t[GA>>2]=t[f>>2],t[GA+4>>2]=t[f+4>>2],t[GA+8>>2]=t[f+8>>2],t[GA+12>>2]=t[f+12>>2]):(q=f+(Z+1<<4)|0,t[GA>>2]=t[q>>2],t[GA+4>>2]=t[q+4>>2],t[GA+8>>2]=t[q+8>>2],t[GA+12>>2]=t[q+12>>2]),u=Wr(ie,GA,n,CA)|0;A:do if(u)f=0,l=u;else if(u=CA,f=t[u>>2]|0,u=t[u+4>>2]|0,(u|0)>0|(u|0)==0&f>>>0>0){sA=0,q=0;e:for(;;){if(Ye=1/(+(f>>>0)+4294967296*+(u|0)),yi=+C[ie>>3],u=dt(f|0,u|0,sA|0,q|0)|0,Lt=+(u>>>0)+4294967296*+(S()|0),de=+(sA>>>0)+4294967296*+(q|0),C[MA>>3]=Ye*(yi*Lt)+Ye*(+C[GA>>3]*de),C[Ee>>3]=Ye*(+C[ce>>3]*Lt)+Ye*(+C[he>>3]*de),u=ns(MA,n,HA)|0,u|0){l=u;break}Y=HA,G=t[Y>>2]|0,Y=t[Y+4>>2]|0,I=Nn(G|0,Y|0,A|0,r|0)|0,p=S()|0,u=o+(I<<3)|0,B=u,f=t[B>>2]|0,B=t[B+4>>2]|0;t:do if((f|0)==0&(B|0)==0)U=u,xe=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(u=$A(I|0,p|0,1,0)|0,I=Ln(u|0,S()|0,A|0,r|0)|0,p=S()|0,N=$A(N|0,L|0,1,0)|0,L=S()|0,u=o+(I<<3)|0,B=u,f=t[B>>2]|0,B=t[B+4>>2]|0,(f|0)==0&(B|0)==0){U=u,xe=16;break}}while(!1);if((xe|0)==16&&(xe=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=$A(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),sA=$A(sA|0,q|0,1,0)|0,q=S()|0,u=CA,f=t[u>>2]|0,u=t[u+4>>2]|0,!((u|0)>(q|0)|(u|0)==(q|0)&f>>>0>sA>>>0)){f=1;break A}}f=0}else f=1;while(!1);if(Z=Z+1|0,!f){xe=21;break}if(u=t[e>>2]|0,(Z|0)>=(u|0)){l=0,xe=21;break}}return(xe|0)==21?(E=We,l|0):0}function Bt(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0,he=0,Ee=0,ie=0,GA=0,CA=0,xe=0,We=0,de=0,Ye=0,Lt=0;if(Lt=E,E=E+112|0,xe=Lt+80|0,u=Lt+72|0,We=Lt,de=Lt+56|0,s=o0(r)|0,s|0)return Ye=s,E=Lt,Ye|0;if(f=e+8|0,Ye=kr((t[f>>2]<<5)+32|0)|0,!Ye)return Ye=13,E=Lt,Ye|0;if(cs(e,Ye),s=o0(r)|0,!s){if(GA=e,CA=t[GA+4>>2]|0,s=u,t[s>>2]=t[GA>>2],t[s+4>>2]=CA,ni(u,xe),s=Wt(xe,A,We)|0,s)GA=0,CA=0;else{if(s=t[u>>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=We,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=We,t[s>>2]=r,t[s+4>>2]=o,s=o):r=i,GA=$A(r|0,s|0,12,0)|0,CA=S()|0,s=We,t[s>>2]=GA,t[s+4>>2]=CA,s=0}if(!s){if(r=Ht(GA,8)|0,!r)return ZA(Ye),Ye=13,E=Lt,Ye|0;if(l=Ht(GA,8)|0,!l)return ZA(Ye),ZA(r),Ye=13,E=Lt,Ye|0;Ee=xe,t[Ee>>2]=0,t[Ee+4>>2]=0,Ee=e,ie=t[Ee+4>>2]|0,s=u,t[s>>2]=t[Ee>>2],t[s+4>>2]=ie,s=Ne(u,GA,CA,A,xe,r,l)|0;A:do if(s)ZA(r),ZA(l),ZA(Ye);else{e:do if((t[f>>2]|0)>0){for(o=e+12|0,i=0;s=Ne((t[o>>2]|0)+(i<<3)|0,GA,CA,A,xe,r,l)|0,i=i+1|0,!(s|0);)if((i|0)>=(t[f>>2]|0))break e;ZA(r),ZA(l),ZA(Ye);break A}while(!1);(CA|0)>0|(CA|0)==0&GA>>>0>0&&Jr(l|0,0,GA<<3|0)|0,ie=xe,Ee=t[ie+4>>2]|0;e:do if((Ee|0)>0|(Ee|0)==0&(t[ie>>2]|0)>>>0>0){QA=r,ce=l,he=r,Ee=l,ie=r,s=r,U=r,MA=l,HA=l,r=l;t:for(;;){for(Y=0,sA=0,q=0,Z=0,i=0,o=0;;){l=We,u=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(u|0));if(A=QA+(Y<<3)|0,f=t[A>>2]|0,A=t[A+4>>2]|0,Q(f,A,1,We,0)|0){l=We,u=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(u|0));l=Ht(7,4)|0,l|0&&(J(f,A,1,We,l,7,0,0)|0,ZA(l))}for(G=0;;){N=We+(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,u=o;else{if(p=Nn(L|0,N|0,GA|0,CA|0)|0,f=S()|0,l=n+(p<<3)|0,A=l,u=t[A>>2]|0,A=t[A+4>>2]|0,!((u|0)==0&(A|0)==0)){B=0,I=0;do{if((B|0)>(CA|0)|(B|0)==(CA|0)&I>>>0>GA>>>0)break t;if((u|0)==(L|0)&(A|0)==(N|0)){l=i,u=o;break r}l=$A(p|0,f|0,1,0)|0,p=Ln(l|0,S()|0,GA|0,CA|0)|0,f=S()|0,I=$A(I|0,B|0,1,0)|0,B=S()|0,l=n+(p<<3)|0,A=l,u=t[A>>2]|0,A=t[A+4>>2]|0}while(!((u|0)==0&(A|0)==0))}if((L|0)==0&(N|0)==0){l=i,u=o;break}dn(L,N,de)|0,fs(e,Ye,de)|0&&(I=$A(i|0,o|0,1,0)|0,o=S()|0,B=l,t[B>>2]=L,t[B+4>>2]=N,i=ce+(i<<3)|0,t[i>>2]=L,t[i+4>>2]=N,i=I),l=i,u=o}while(!1);if(G=G+1|0,G>>>0>=7)break;i=l,o=u}if(Y=$A(Y|0,sA|0,1,0)|0,sA=S()|0,q=$A(q|0,Z|0,1,0)|0,Z=S()|0,o=xe,i=t[o>>2]|0,o=t[o+4>>2]|0,(Z|0)<(o|0)|(Z|0)==(o|0)&q>>>0<i>>>0)i=l,o=u;else break}if((o|0)>0|(o|0)==0&i>>>0>0){i=0,o=0;do Z=QA+(i<<3)|0,t[Z>>2]=0,t[Z+4>>2]=0,i=$A(i|0,o|0,1,0)|0,o=S()|0,Z=xe,q=t[Z+4>>2]|0;while((o|0)<(q|0)|((o|0)==(q|0)?i>>>0<(t[Z>>2]|0)>>>0:0))}if(Z=xe,t[Z>>2]=l,t[Z+4>>2]=u,(u|0)>0|(u|0)==0&l>>>0>0)G=r,Y=HA,sA=ie,q=MA,Z=ce,r=U,HA=s,MA=he,U=G,s=Y,ie=Ee,Ee=sA,he=q,ce=QA,QA=Z;else break e}ZA(he),ZA(Ee),ZA(Ye),s=1;break A}else s=l;while(!1);ZA(Ye),ZA(r),ZA(s),s=0}while(!1);return Ye=s,E=Lt,Ye|0}}return ZA(Ye),Ye=s,E=Lt,Ye|0}function rt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(p=E,E=E+176|0,u=p,(A|0)<1)return ui(r,0,0),f=0,E=p,f|0;for(l=e,l=wA(t[l>>2]|0,t[l+4>>2]|0,52)|0,S()|0,ui(r,(A|0)>6?A:6,l&15),l=0;n=e+(l<<3)|0,n=Rn(t[n>>2]|0,t[n+4>>2]|0,u)|0,!(n|0);){if(n=t[u>>2]|0,(n|0)>0){o=0;do i=u+8+(o<<4)|0,o=o+1|0,n=u+8+(((o|0)%(n|0)|0)<<4)|0,s=ma(r,n,i)|0,s?hi(r,s)|0:da(r,i,n)|0,n=t[u>>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):(ci(r),f=n,E=p,f|0)}function vt(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=rt(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=fi(s)|0,e|0)do{A=Ul(r)|0;do Vl(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],hi(s,e)|0,e=pa(s,n)|0;while((e|0)!=0);e=fi(s)|0}while((e|0)!=0);return ci(s),e=Wl(r)|0,e?(Ai(r),o=e,E=i,o|0):(o=0,E=i,o|0)}function _e(e){return e=e|0,e>>>0>121?(e=0,e|0):(e=t[7696+(e*28|0)+16>>2]|0,e|0)}function Dt(e){return e=e|0,(e|0)==4|(e|0)==117|0}function xr(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 rr(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 Vr(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 nr(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 Rr(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 ln(e,A){return e=e|0,A=A|0,t[848+(e*28|0)+(A<<2)>>2]|0}function an(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 Yn(){return 122}function $n(e){e=e|0;var A=0,r=0,n=0;A=0;do kA(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 Kn(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 Ot(e){return e=e|0,+C[e+16>>3]<+C[e+24>>3]|0}function un(e){return e=e|0,+(+C[e>>3]-+C[e+8>>3])}function wr(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 Pe(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=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,u=+C[s>>3],l=f<u,A=p-f<u-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 Ir(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,u=0;i=+C[e+16>>3],u=+C[e+24>>3],e=i<u,l=+C[A+16>>3],o=+C[A+24>>3],s=l<o,A=u-l<o-i,t[r>>2]=e?s|A?1:2:0,t[n>>2]=s?e?1:A?2:1:0}function Lr(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=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,u=+C[n>>3],i=+C[e+24>>3],o=u<i,r=A+16|0,p=+C[r>>3],s=A+24|0,f=+C[s>>3],l=p<f,A=i-p<f-u,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 vr(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));Fn(e|0,n|0,168)|0,E=s}function Wt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=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,u=l+96|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(u|0));return A=is(A,f)|0,A|0?(L=A,E=N,L|0):(u=f,f=t[u>>2]|0,u=t[u+4>>2]|0,dn(f,u,p)|0,Rn(f,u,B)|0,o=+s0(p,B+8|0),C[p>>3]=+C[e>>3],u=p+8|0,C[u>>3]=+C[e+16>>3],C[B>>3]=+C[e+8>>3],f=B+8|0,C[f>>3]=+C[e+24>>3],s=+s0(p,B),Y=+C[u>>3]-+C[f>>3],i=+ee(+Y),G=+C[p>>3]-+C[B>>3],n=+ee(+G),!(Y==0|G==0)&&(Y=+pi(+i,+n),Y=+Vt(+(s*s/+M0(+(Y/+M0(+i,+n)),3)/(o*(o*2.59807621135)*.8))),C[ge>>3]=Y,I=~~Y>>>0,L=+ee(Y)>=1?Y>0?~~+tt(+Le(Y/4294967296),4294967295)>>>0:~~+Vt((Y-+(~~Y>>>0))/4294967296)>>>0:0,(t[ge+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 Wr(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,u=0,f=0,p=0;f=E,E=E+288|0,o=f+264|0,l=f+96|0,u=f,s=u,i=s+96|0;do t[s>>2]=0,s=s+4|0;while((s|0)<(i|0));return r=is(r,u)|0,r|0?(n=r,E=f,n|0):(r=u,s=t[r>>2]|0,r=t[r+4>>2]|0,dn(s,r,o)|0,Rn(s,r,l)|0,p=+s0(o,l+8|0),p=+Vt(+(+s0(e,A)/(p*2))),C[ge>>3]=p,r=~~p>>>0,s=+ee(p)>=1?p>0?~~+tt(+Le(p/4294967296),4294967295)>>>0:~~+Vt((p-+(~~p>>>0))/4294967296)>>>0:0,(t[ge+4>>2]&2146435072|0)==2146435072?(n=1,E=f,n|0):(u=(r|0)==0&(s|0)==0,t[n>>2]=u?1:r,t[n+4>>2]=u?0:s,n=0,E=f,n|0))}function mr(e,A){e=e|0,A=+A;var r=0,n=0,s=0,i=0,o=0,l=0,u=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,u=+C[l>>3],p=f-u,n=(n*A-n)*.5,A=(p*A-p)*.5,f=f+A,C[e>>3]=f>1.5707963267948966?1.5707963267948966:f,A=u-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 cn(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 Yr(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0;B=A+8|0,t[B>>2]=0,u=+C[e>>3],o=+ee(+u),f=+C[e+8>>3],l=+ee(+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(u<0)if(e&1){p=(e+1|0)/2|0,p=dt(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=dt(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 nt(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 H(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 tA(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 mA(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 NA(e,A){e=e|0,A=A|0;var r=0,n=0;r=ht(t[e>>2]|0,A)|0,t[e>>2]=r,r=e+4|0,n=ht(t[r>>2]|0,A)|0,t[r>>2]=n,e=e+8|0,A=ht(t[e>>2]|0,A)|0,t[e>>2]=A}function zA(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 te(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0;if(u=e+8|0,o=t[u>>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=Zr(+(A-o|0)*.14285714285714285)|0,t[e>>2]=n,s=Zr(+(r+l|0)*.14285714285714285)|0,t[f>>2]=s,t[u>>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)))&&OA(27795,26892,354,26903),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(27795,26892,354,26903)),A=s-n|0,(n|0)<0?(r=0-n|0,t[f>>2]=A,t[u>>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[u>>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[u>>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[u>>2]=r-n,f=0,f|0)}function Te(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=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(u=s<<1,(n?(2147483647-u|0)<(s|0):(-2147483648-u|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 u=1,u|0}else r=s*3|0,A=i<<1;return n=Zr(+(A+s|0)*.14285714285714285)|0,t[e>>2]=n,s=Zr(+(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)))&&OA(27795,26892,402,26917),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(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?(u=0,u|0):(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n,u=0,u|0)}function He(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=Zr(+((A*3|0)-r|0)*.14285714285714285)|0,t[e>>2]=n,A=Zr(+((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 st(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=Zr(+((A<<1)+r|0)*.14285714285714285)|0,t[e>>2]=n,A=Zr(+((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 bt(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 Ze(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 ot(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 _t(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 Nr(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 Yt(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 $t(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 Zn(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 qn(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 Bn(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 Jn(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 Tt(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 Xn(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 A0(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 es(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,u=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=wA(e|0,A|0,52)|0,S()|0,o=o&15,f=wA(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){It(e,A,i,p)|0,It(r,n,i,l)|0,f=p,u=t[f>>2]|0,f=t[f+4>>2]|0;A:do if((u|0)==(t[l>>2]|0)&&(f|0)==(t[l+4>>2]|0)){o=(o^15)*3|0,i=wA(e|0,A|0,o|0)|0,S()|0,i=i&7,o=wA(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&&Oe(u,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 w0(e,A,r,n,s){return e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,r=qA(e,A,r,n)|0,(r|0)==7?(s=11,s|0):(n=kA(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 Dn(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 v0(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=wA(e|0,A|0,56)|0,S()|0,n=$(e,A&-2130706433|134217728,i&7,n,r)|0,E=s,n|0):(n=6,E=s,n|0)}function e0(e,A){e=e|0,A=A|0;var r=0;switch(r=wA(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&(Oe(e,r)|0)!=0?(r=0,r|0):(r=Ve(e,r)|0,r|0)}function _n(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=wA(e|0,A|0,56)|0,S()|0,n=$(e,i,A&7,n,r+8|0)|0,E=s,n|0):(n=6,E=s,n|0)}function Tn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;return s=(Oe(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=wA(e|0,A|0,56)|0,S()|0,n=ca(e,i,n&7)|0,(n|0)==-1?(t[r>>2]=0,i=6,E=o,i|0):(jn(e,i,s)|0&&OA(27795,26932,282,26947),A=wA(e|0,A|0,52)|0,S()|0,A=A&15,Oe(e,i)|0?w(s,A,n,2,r):eA(s,A,n,2,r),i=0,E=o,i|0)):(i=6,E=o,i|0)}function b0(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,k0(e,A,r,s),Yr(s,r+4|0),E=n}function k0(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,u=0;if(l=E,E=E+16|0,u=l,t0(e,r,u),i=+Et(+(1-+C[u>>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(u=t[r>>2]|0,s=+C[15920+(u*24|0)>>3],s=+n0(s-+n0(+Il(15600+(u<<4)|0,e))),sr(A)|0?o=+n0(s+-.3334731722518321):o=s,s=+et(+i)*2.618033988749896,(A|0)>0){e=0;do s=s*2.6457513110645907,e=e+1|0;while((e|0)!=(A|0))}i=+Be(+o)*s,C[n>>3]=i,o=+se(+o)*s,C[n+8>>3]=o,E=l}function t0(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,ua(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 $r(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=+aa(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=+at(+ +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=(sr(r)|0)==0,i=+Ut(+((r?l:l*.37796447300922725)*.381966011250105))):(i=+Ut(+(i*.381966011250105)),sr(r)|0&&(o=+n0(o+.3334731722518321))),Ll(15600+(A<<4)|0,+n0(+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,H(e+4|0,s),$r(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0,he=0,Ee=0,ie=0,GA=0,CA=0,xe=0,We=0,de=0;if(xe=E,E=E+272|0,i=xe+256|0,q=xe+240|0,ie=xe,GA=xe+224|0,CA=xe+208|0,Z=xe+176|0,U=xe+160|0,MA=xe+192|0,HA=xe+144|0,QA=xe+128|0,ce=xe+112|0,he=xe+96|0,Ee=xe+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,ie),t[s>>2]=0,q=n+r+((n|0)==5&1)|0,(q|0)<=(r|0)){E=xe;return}u=t[i>>2]|0,f=GA+4|0,p=Z+4|0,B=r+5|0,I=16880+(u<<2)|0,L=16960+(u<<2)|0,N=QA+8|0,G=ce+8|0,Y=he+8|0,sA=CA+4|0,l=r;A:for(;;){o=ie+(((l|0)%5|0)<<4)|0,t[CA>>2]=t[o>>2],t[CA+4>>2]=t[o+4>>2],t[CA+8>>2]=t[o+8>>2],t[CA+12>>2]=t[o+12>>2];do;while((F(CA,u,0,1)|0)==2);if((l|0)>(r|0)&(sr(A)|0)!=0){if(t[Z>>2]=t[CA>>2],t[Z+4>>2]=t[CA+4>>2],t[Z+8>>2]=t[CA+8>>2],t[Z+12>>2]=t[CA+12>>2],H(f,U),n=t[Z>>2]|0,i=t[17040+(n*80|0)+(t[GA>>2]<<2)>>2]|0,t[Z>>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 _t(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],NA(MA,(t[I>>2]|0)*3|0),tA(p,MA,p),nt(p),H(p,HA),We=+(t[L>>2]|0),C[QA>>3]=We*3,C[N>>3]=0,de=We*-1.5,C[ce>>3]=de,C[G>>3]=We*2.598076211353316,C[he>>3]=de,C[Y>>3]=We*-2.598076211353316,t[17040+((t[Z>>2]|0)*80|0)+(t[CA>>2]<<2)>>2]|0){case 1:{e=ce,n=QA;break}case 3:{e=he,n=ce;break}case 2:{e=QA,n=he;break}default:{e=12;break A}}oi(U,HA,n,e,Ee),$r(Ee,t[Z>>2]|0,u,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1}if((l|0)<(B|0)&&(H(sA,Z),$r(Z,t[CA>>2]|0,u,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1),t[GA>>2]=t[CA>>2],t[GA+4>>2]=t[CA+4>>2],t[GA+8>>2]=t[CA+8>>2],t[GA+12>>2]=t[CA+12>>2],l=l+1|0,(l|0)>=(q|0)){e=3;break}}if((e|0)==3){E=xe;return}else(e|0)==12&&OA(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,u=0;u=E,E=E+128|0,n=u+64|0,s=u,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=(sr(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,Zn(s),qn(s),sr(t[A>>2]|0)|0&&(Ze(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,tA(s,n,A),nt(A),t[r+16>>2]=t[e>>2],A=r+20|0,tA(s,n+12|0,A),nt(A),t[r+32>>2]=t[e>>2],A=r+36|0,tA(s,n+24|0,A),nt(A),t[r+48>>2]=t[e>>2],A=r+52|0,tA(s,n+36|0,A),nt(A),t[r+64>>2]=t[e>>2],r=r+68|0,tA(s,n+48|0,r),nt(r),E=u}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,u=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;u=i}else u=e+12|0,n=t[u>>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?(cn(I,B,0,0),mA(L,I,l),Nr(l),tA(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 _t(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,NA(I,p?A*3|0:A),tA(L,I,L),nt(L),p?n=((t[f>>2]|0)+(t[L>>2]|0)+(t[u>>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 eA(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0,he=0,Ee=0,ie=0;if(he=E,E=E+240|0,i=he+224|0,MA=he+208|0,HA=he,QA=he+192|0,ce=he+176|0,Y=he+160|0,sA=he+144|0,q=he+128|0,Z=he+112|0,U=he+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],pA(MA,i,HA),t[s>>2]=0,G=n+r+((n|0)==6&1)|0,(G|0)<=(r|0)){E=he;return}u=t[i>>2]|0,f=r+6|0,p=16960+(u<<2)|0,B=sA+8|0,I=q+8|0,L=Z+8|0,N=QA+4|0,o=0,l=r,n=-1;A:for(;;){if(i=(l|0)%6|0,e=HA+(i<<4)|0,t[QA>>2]=t[e>>2],t[QA+4>>2]=t[e+4>>2],t[QA+8>>2]=t[e+8>>2],t[QA+12>>2]=t[e+12>>2],e=o,o=F(QA,u,0,1)|0,(l|0)>(r|0)&(sr(A)|0)!=0&&(e|0)!=1&&(t[QA>>2]|0)!=(n|0)){switch(H(HA+(((i+5|0)%6|0)<<4)+4|0,ce),H(HA+(i<<4)+4|0,Y),Ee=+(t[p>>2]|0),C[sA>>3]=Ee*3,C[B>>3]=0,ie=Ee*-1.5,C[q>>3]=ie,C[I>>3]=Ee*2.598076211353316,C[Z>>3]=ie,C[L>>3]=Ee*-2.598076211353316,i=t[MA>>2]|0,t[17040+(i*80|0)+(((n|0)==(i|0)?t[QA>>2]|0:n)<<2)>>2]|0){case 1:{e=q,n=sA;break}case 3:{e=Z,n=q;break}case 2:{e=sA,n=Z;break}default:{e=8;break A}}oi(ce,Y,n,e,U),!(li(ce,U)|0)&&!(li(Y,U)|0)&&($r(U,t[MA>>2]|0,u,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1)}if((l|0)<(f|0)&&(H(N,ce),$r(ce,t[QA>>2]|0,u,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[QA>>2]|0}if((e|0)==3){E=he;return}else(e|0)==8&&OA(27054,27017,737,27099)}function pA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0;u=E,E=E+160|0,n=u+80|0,s=u,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=(sr(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,Zn(s),qn(s),sr(t[A>>2]|0)|0&&(Ze(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,tA(s,n,A),nt(A),t[r+16>>2]=t[e>>2],A=r+20|0,tA(s,n+12|0,A),nt(A),t[r+32>>2]=t[e>>2],A=r+36|0,tA(s,n+24|0,A),nt(A),t[r+48>>2]=t[e>>2],A=r+52|0,tA(s,n+36|0,A),nt(A),t[r+64>>2]=t[e>>2],A=r+68|0,tA(s,n+48|0,A),nt(A),t[r+80>>2]=t[e>>2],r=r+84|0,tA(s,n+60|0,r),nt(r),E=u}function DA(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&15|0}function re(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,45)|0,S()|0,A&127|0}function ve(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=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,t[n>>2]=r&7,n=0,n|0)}function ye(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,u=0,f=0;if(e>>>0>15)return n=4,n|0;if(A>>>0>121)return n=17,n|0;o=kA(e|0,0,52)|0,s=S()|0,l=kA(A|0,0,45)|0,s=s|(S()|0)|134225919;A:do if((e|0)>=1){for(l=1,o=(xA[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,u=kA(7,0,f|0)|0,s=s&~(S()|0),A=kA(A|0,((A|0)<0)<<31>>31|0,f|0)|0,i=A|i&~u,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 Ve(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=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0>121)?(e=0,e|0):(o=(n^15)*3|0,s=wA(e|0,A|0,o|0)|0,o=kA(s|0,S()|0,o|0)|0,s=S()|0,i=dt(-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=kA(~e|0,~A|0,o|0)|0,o=wA(i|0,S()|0,o|0)|0,!((n|0)==15|(o|0)==0&(S()|0)==0))?(o=0,o|0):!(xA[20528+r>>0]|0)||(A=A&8191,(e|0)==0&(A|0)==0)?(o=1,o|0):(o=ds(e|0,A|0)|0,S()|0,((63-o|0)%3|0|0)!=0|0))}function jt(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=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0<=121)&&(o=(n^15)*3|0,s=wA(e|0,A|0,o|0)|0,o=kA(s|0,S()|0,o|0)|0,s=S()|0,i=dt(-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=kA(~e|0,~A|0,o|0)|0,o=wA(i|0,S()|0,o|0)|0,(n|0)==15|(o|0)==0&(S()|0)==0)&&(!(xA[20528+r>>0]|0)||(r=A&8191,(e|0)==0&(r|0)==0)||(o=ds(e|0,r|0)|0,S()|0,(63-o|0)%3|0|0))||e0(e,A)|0?(o=1,o|0):(o=(ai(e,A)|0)!=0&1,o|0)}function Rt(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=kA(A|0,0,52)|0,i=S()|0,r=kA(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=kA(7,0,o|0)|0,r=r&~(S()|0),o=kA(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 It(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;if(i=wA(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=kA(r|0,0,52)|0,s=s|e,e=S()|0|A&-15728641,(i|0)>(r|0))do A=kA(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 br(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=wA(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=wA(e|0,A|0,45)|0,S()|0;A:do if(!(_e(r&127)|0))r=Kr(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;else{e:do if(i|0){for(r=1;o=kA(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=Kr(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;break A}while(!1);r=Kr(7,0,s,((s|0)<0)<<31>>31)|0,r=mt(r|0,S()|0,5,0)|0,r=$A(r|0,S()|0,-5,-1)|0,r=qr(r|0,S()|0,6,0)|0,r=$A(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 Oe(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;if(s=wA(e|0,A|0,45)|0,S()|0,!(_e(s&127)|0))return s=0,s|0;s=wA(e|0,A|0,52)|0,S()|0,s=s&15;A:do if(!s)r=0;else for(n=1;;){if(r=wA(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 r0(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,os(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=$A(s|0,r|0,1,0)|0,r=S()|0,ls(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,WA(r|0),n|0):(r=kA(-1,-1,((n-r|0)*3|0)+3|0)|0,n=kA(~r|0,~(S()|0)|0,(15-n|0)*3|0)|0,r=~(S()|0)&A,n=~n&e,WA(r|0),n|0)}function Ks(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0;return s=wA(e|0,A|0,52)|0,S()|0,s=s&15,(r|0)<16&(s|0)<=(r|0)?((s|0)<(r|0)&&(s=kA(-1,-1,((r+-1-s|0)*3|0)+3|0)|0,s=kA(~s|0,~(S()|0)|0,(15-r|0)*3|0)|0,A=~(S()|0)&A,e=~s&e),s=kA(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 bl(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0,he=0,Ee=0,ie=0,GA=0,CA=0;if((r|0)==0&(n|0)==0)return CA=0,CA|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)||(CA=A,t[CA>>2]=i,t[CA+4>>2]=s,(r|0)==1&(n|0)==0))return CA=0,CA|0;s=1,i=0;do ie=e+(s<<3)|0,GA=t[ie+4>>2]|0,CA=A+(s<<3)|0,t[CA>>2]=t[ie>>2],t[CA+4>>2]=GA,s=$A(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,GA=kr(Ee)|0,!GA)return CA=13,CA|0;if(Fn(GA|0,e|0,Ee|0)|0,ie=Ht(r,8)|0,!ie)return ZA(GA),CA=13,CA|0;A:for(;;){s=GA,f=t[s>>2]|0,s=t[s+4>>2]|0,ce=wA(f|0,s|0,52)|0,S()|0,ce=ce&15,he=ce+-1|0,QA=(ce|0)!=0,HA=(n|0)>0|(n|0)==0&r>>>0>0;e:do if(QA&HA){if(q=kA(he|0,0,52)|0,Z=S()|0,he>>>0>15){if(!((f|0)==0&(s|0)==0)){CA=16;break A}for(i=0,e=0;;){if(i=$A(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=GA+(i<<3)|0,MA=t[o>>2]|0,o=t[o+4>>2]|0,!((MA|0)==0&(o|0)==0)){s=o,CA=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)){CA=21;break A}if(p=wA(l|0,e|0,52)|0,S()|0,p=p&15,(p|0)<(he|0)){s=12,CA=27;break A}if((p|0)!=(he|0)&&(l=l|q,e=e&-15728641|Z,p>>>0>=ce>>>0)){u=he;do MA=kA(7,0,(14-u|0)*3|0)|0,u=u+1|0,l=MA|l,e=S()|0|e;while(u>>>0<p>>>0)}if(I=Nn(l|0,e|0,r|0,n|0)|0,L=S()|0,u=ie+(I<<3)|0,p=u,B=t[p>>2]|0,p=t[p+4>>2]|0,!((B|0)==0&(p|0)==0)){Y=0,sA=0;do{if((Y|0)>(n|0)|(Y|0)==(n|0)&sA>>>0>r>>>0){CA=31;break A}if((B|0)==(l|0)&(p&-117440513|0)==(e|0)){N=wA(B|0,p|0,56)|0,S()|0,N=N&7,G=N+1|0,MA=wA(B|0,p|0,45)|0,S()|0;t:do if(!(_e(MA&127)|0))p=7;else{if(B=wA(B|0,p|0,52)|0,S()|0,B=B&15,!B){p=6;break}for(p=1;;){if(MA=kA(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){CA=41;break A}MA=kA(G|0,0,56)|0,e=S()|0|e&-117440513,U=u,t[U>>2]=0,t[U+4>>2]=0,l=MA|l}else I=$A(I|0,L|0,1,0)|0,I=Ln(I|0,S()|0,r|0,n|0)|0,L=S()|0;sA=$A(sA|0,Y|0,1,0)|0,Y=S()|0,u=ie+(I<<3)|0,p=u,B=t[p>>2]|0,p=t[p+4>>2]|0}while(!((B|0)==0&(p|0)==0))}MA=u,t[MA>>2]=l,t[MA+4>>2]=e}if(i=$A(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=GA+(i<<3)|0,l=t[e>>2]|0,e=t[e+4>>2]|0}}while(!1);if(MA=$A(r|0,n|0,5,0)|0,U=S()|0,U>>>0<0|(U|0)==0&MA>>>0<11){CA=85;break}if(MA=qr(r|0,n|0,6,0)|0,S()|0,MA=Ht(MA,8)|0,!MA){CA=48;break}do if(HA){for(G=0,e=0,N=0,Y=0;;){if(p=ie+(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=wA(i|0,o|0,56)|0,S()|0,B=B&7,l=B+1|0,I=o&-117440513,U=wA(i|0,o|0,45)|0,S()|0;e:do if(_e(U&127)|0){if(L=wA(i|0,o|0,52)|0,S()|0,L=L&15,L|0)for(u=1;;){if(U=kA(7,0,(15-u|0)*3|0)|0,!((i&U|0)==0&(I&(S()|0)|0)==0))break e;if(u>>>0<L>>>0)u=u+1|0;else break}o=kA(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=$A(e|0,N|0,1,0)|0,U=S()|0):U=N}if(G=$A(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(HA){if(sA=he>>>0>15,q=kA(he|0,0,52)|0,Z=S()|0,!QA){for(i=0,u=0,l=0,o=0;(f|0)==0&(s|0)==0||(he=A+(i<<3)|0,t[he>>2]=f,t[he+4>>2]=s,i=$A(i|0,u|0,1,0)|0,u=S()|0),l=$A(l|0,o|0,1,0)|0,o=S()|0,!!((o|0)<(n|0)|(o|0)==(n|0)&l>>>0<r>>>0);)s=GA+(l<<3)|0,f=t[s>>2]|0,s=t[s+4>>2]|0;s=U;break}for(i=0,u=0,o=0,l=0;;){do if(!((f|0)==0&(s|0)==0)){if(L=wA(f|0,s|0,52)|0,S()|0,L=L&15,sA|(L|0)<(he|0)){CA=80;break A}if((L|0)!=(he|0)){if(p=f|q,B=s&-15728641|Z,L>>>0>=ce>>>0){I=he;do QA=kA(7,0,(14-I|0)*3|0)|0,I=I+1|0,p=QA|p,B=S()|0|B;while(I>>>0<L>>>0)}}else p=f,B=s;N=Nn(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){CA=81;break A}if(QA=ie+(N<<3)|0,G=t[QA+4>>2]|0,(G&-117440513|0)==(B|0)&&(t[QA>>2]|0)==(p|0)){CA=65;break}QA=$A(N|0,Y|0,1,0)|0,N=Ln(QA|0,S()|0,r|0,n|0)|0,Y=S()|0,L=$A(L|0,I|0,1,0)|0,I=S()|0,QA=ie+(N<<3)|0}while(!((t[QA>>2]|0)==(p|0)&&(t[QA+4>>2]|0)==(B|0)));if((CA|0)==65&&(CA=0,!0&(G&117440512|0)==100663296))break;QA=A+(i<<3)|0,t[QA>>2]=f,t[QA+4>>2]=s,i=$A(i|0,u|0,1,0)|0,u=S()|0}while(!1);if(o=$A(o|0,l|0,1,0)|0,l=S()|0,!((l|0)<(n|0)|(l|0)==(n|0)&o>>>0<r>>>0))break;s=GA+(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(Jr(ie|0,0,Ee|0)|0,Fn(GA|0,MA|0,e<<3|0)|0,ZA(MA),(e|0)==0&(s|0)==0){CA=89;break}else A=A+(i<<3)|0,n=s,r=e}if((CA|0)==16)!0&(s&117440512|0)==0?(s=4,CA=27):CA=21;else if((CA|0)==31)OA(27795,27122,620,27132);else{if((CA|0)==41)return ZA(GA),ZA(ie),CA=10,CA|0;if((CA|0)==48)return ZA(GA),ZA(ie),CA=13,CA|0;(CA|0)==80?OA(27795,27122,711,27132):(CA|0)==81?OA(27795,27122,723,27132):(CA|0)==85&&(Fn(A|0,GA|0,r<<3|0)|0,CA=89)}return(CA|0)==21?(ZA(GA),ZA(ie),CA=5,CA|0):(CA|0)==27?(ZA(GA),ZA(ie),CA=s,CA|0):(CA|0)==89?(ZA(GA),ZA(ie),CA=0,CA|0):0}function kl(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,u=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,u=t[f>>2]|0,f=t[f+4>>2]|0,p=wA(u|0,f|0,52)|0,S()|0,(p&15|0)>(o|0)){l=12,u=11;break}if(os(N,u,f,o),p=N,f=t[p>>2]|0,p=t[p+4>>2]|0,(f|0)==0&(p|0)==0)u=B;else{u=B;do{if(!((l|0)<(i|0)|(l|0)==(i|0)&u>>>0<s>>>0)){u=10;break A}B=n+(u<<3)|0,t[B>>2]=f,t[B+4>>2]=p,u=$A(u|0,l|0,1,0)|0,l=S()|0,ls(N),B=N,f=t[B>>2]|0,p=t[B+4>>2]|0}while(!((f|0)==0&(p|0)==0))}if(I=$A(I|0,L|0,1,0)|0,L=S()|0,(L|0)<(r|0)|(L|0)==(r|0)&I>>>0<A>>>0)B=u;else{l=0,u=11;break}}return(u|0)==10?(N=14,E=G,N|0):(u|0)==11?(E=G,l|0):0}function Cl(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,u=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(u=e+(f<<3)|0,l=t[u>>2]|0,u=t[u+4>>2]|0,!((l|0)==0&(u|0)==0)&&(u=(br(l,u,n,B)|0)==0,l=B,o=$A(t[l>>2]|0,t[l+4>>2]|0,o|0,i|0)|0,i=S()|0,!u)){i=12;break}if(f=$A(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 El(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&1|0}function zt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;if(s=wA(e|0,A|0,52)|0,S()|0,s=s&15,!s)return s=0,s|0;for(n=1;;){if(r=wA(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 ts(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(u=wA(e|0,A|0,52)|0,S()|0,u=u&15,!u)return l=A,u=e,WA(l|0),u|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=kA(7,0,i|0)|0,s=S()|0,o=wA(e|0,A|0,i|0)|0,S()|0,i=kA(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=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(o=wA(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=wA(e|0,A|0,o|0)|0,S()|0,i=kA(7,0,o|0)|0,A=A&~(S()|0),o=kA(Yt(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<u>>>0)l=l+1|0;else break}return WA(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=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,WA(r|0),n|0;for(r=1;i=(15-r|0)*3|0,o=wA(e|0,A|0,i|0)|0,S()|0,s=kA(7,0,i|0)|0,A=A&~(S()|0),i=kA(Yt(o&7)|0,0,i|0)|0,e=i|e&~s,A=S()|0|A,r>>>0<n>>>0;)r=r+1|0;return WA(A|0),e|0}function Sl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(u=wA(e|0,A|0,52)|0,S()|0,u=u&15,!u)return l=A,u=e,WA(l|0),u|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=kA(7,0,i|0)|0,s=S()|0,o=wA(e|0,A|0,i|0)|0,S()|0,i=kA($t(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=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(o=wA(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=kA(7,0,s|0)|0,o=A&~(S()|0),A=wA(e|0,A|0,s|0)|0,S()|0,A=kA($t(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<u>>>0)l=l+1|0;else break}return WA(A|0),e|0}function rs(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,WA(r|0),n|0;for(r=1;o=(15-r|0)*3|0,i=kA(7,0,o|0)|0,s=A&~(S()|0),A=wA(e|0,A|0,o|0)|0,S()|0,A=kA($t(A&7)|0,0,o|0)|0,e=A|e&~i,A=S()|0|s,r>>>0<n>>>0;)r=r+1|0;return WA(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,u=0,f=0,p=0;if(u=E,E=E+64|0,l=u+40|0,n=u+24|0,s=u+12|0,i=u,kA(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,WA(o|0),E=u,l|0):(kA(xr(e)|0,0,45)|0,o=S()|0|r,l=-1,WA(o|0),E=u,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?(He(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],bt(s)):(st(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],Ze(s)),mA(n,s,i),nt(i),p=(15-A|0)*3|0,f=kA(7,0,p|0)|0,r=r&~(S()|0),p=kA(zA(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=xr(l)|0,A=kA(n|0,0,45)|0,A=A|e,e=S()|0|r&-1040385,i=rr(l)|0,!(_e(n)|0)){if((i|0)<=0)break;for(s=0;;){if(n=wA(A|0,e|0,52)|0,S()|0,n=n&15,n)for(r=1;p=(15-r|0)*3|0,l=wA(A|0,e|0,p|0)|0,S()|0,f=kA(7,0,p|0)|0,e=e&~(S()|0),p=kA(Yt(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=wA(A|0,e|0,52)|0,S()|0,s=s&15;e:do if(s){r=1;t:for(;;){switch(p=wA(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(Rr(n,t[l>>2]|0)|0)for(r=1;l=(15-r|0)*3|0,f=kA(7,0,l|0)|0,p=e&~(S()|0),e=wA(A|0,e|0,l|0)|0,S()|0,e=kA($t(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=wA(A|0,e|0,p|0)|0,S()|0,f=kA(7,0,p|0)|0,e=e&~(S()|0),p=kA(Yt(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=ts(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,WA(f|0),E=u,p|0}function sr(e){return e=e|0,(e|0)%2|0|0}function ns(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):(b0(e,A,n),A=Ml(n,A)|0,n=S()|0,t[r>>2]=A,t[r+4>>2]=n,(A|0)==0&(n|0)==0&&OA(27795,27122,1050,27145),n=0,E=s,n|0)}function ss(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=wA(e|0,A|0,52)|0,S()|0,i=i&15,o=wA(e|0,A|0,45)|0,S()|0,n=(i|0)==0,_e(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?bt(s):Ze(s),o=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,ot(s,o&7),r>>>0<i>>>0;)r=r+1|0;return n|0}function jn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(p=E,E=E+16|0,u=p,f=wA(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((_e(f)|0)!=0&&(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,(i|0)!=0)){n=1;e:for(;;){switch(l=wA(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=kA(7,0,A|0)|0,l=n&~(S()|0),n=wA(e|0,n|0,A|0)|0,S()|0,n=kA($t(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],!(ss(e,n,r)|0))return f=0,E=p,f|0;if(o=r+4|0,t[u>>2]=t[o>>2],t[u+4>>2]=t[o+4>>2],t[u+8>>2]=t[o+8>>2],i=wA(e|0,n|0,52)|0,S()|0,l=i&15,i&1?(Ze(o),i=l+1|0):i=l,!(_e(f)|0))n=0;else{A:do if(!l)n=0;else for(A=1;;){if(s=wA(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[u>>2],t[o+4>>2]=t[u+4>>2],t[o+8>>2]=t[u+8>>2]);else{if(_e(f)|0)do;while((F(r,i,0,0)|0)!=0);(i|0)!=(l|0)&&st(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=jn(e,A,n)|0,s|0?(E=i,s|0):(s=wA(e|0,A|0,52)|0,S()|0,d(n,s&15,r),s=0,E=i,s|0)}function Rn(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=jn(e,A,i)|0,n|0)return i=n,E=o,i|0;n=wA(e|0,A|0,45)|0,S()|0,n=(_e(n&127)|0)==0,s=wA(e|0,A|0,52)|0,S()|0,s=s&15;A:do if(!n){if(s|0)for(n=1;;){if(l=kA(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 eA(i,s,0,6,r),l=0,E=o,l|0}function Bl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(s=wA(e|0,A|0,45)|0,S()|0,!(_e(s&127)|0))return s=2,t[r>>2]=s,0;if(s=wA(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=kA(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 Zs(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0;B=E,E=E+128|0,f=B+112|0,i=B+96|0,p=B,s=wA(e|0,A|0,52)|0,S()|0,l=s&15,t[f>>2]=l,o=wA(e|0,A|0,45)|0,S()|0,o=o&127;A:do if(_e(o)|0){if(l|0)for(n=1;;){if(u=kA(7,0,(15-n|0)*3|0)|0,!((u&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 u=kA(l+1|0,0,52)|0,p=S()|0|A&-15728641,f=kA(7,0,(14-l|0)*3|0)|0,p=Zs((u|e)&~f,p&~(S()|0),r)|0,E=B,p|0}else s=0;while(!1);if(n=jn(e,A,i)|0,!n){s?(_(i,f,p),u=5):(pA(i,f,p),u=6);A:do if(_e(o)|0)if(!l)e=5;else for(n=1;;){if(o=kA(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);Jr(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>=u>>>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>=u>>>0){n=0;break}}while(!1)}return p=n,E=B,p|0}function Dl(){return 12}function is(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(e>>>0>15)return l=4,l|0;if(kA(e|0,0,52)|0,l=S()|0|134225919,!e){r=0,n=0;do _e(n)|0&&(kA(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(_e(o)|0){for(kA(o|0,0,45)|0,n=1,s=-1,i=l|(S()|0);u=kA(7,0,(15-n|0)*3|0)|0,s=s&~u,i=i&~(S()|0),(n|0)!=(e|0);)n=n+1|0;u=A+(r<<3)|0,t[u>>2]=s,t[u+4>>2]=i,r=r+1|0}o=o+1|0}while((o|0)!=122);return r=0,r|0}function _l(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0;if(q=E,E=E+16|0,Y=q,sA=wA(e|0,A|0,52)|0,S()|0,sA=sA&15,r>>>0>15)return sA=4,E=q,sA|0;if((sA|0)<(r|0))return sA=12,E=q,sA|0;if((sA|0)!=(r|0))if(i=kA(r|0,0,52)|0,i=i|e,l=S()|0|A&-15728641,(sA|0)>(r|0)){u=r;do G=kA(7,0,(14-u|0)*3|0)|0,u=u+1|0,i=G|i,l=S()|0|l;while((u|0)<(sA|0));G=i}else G=i;else G=e,l=A;N=wA(G|0,l|0,45)|0,S()|0;A:do if(_e(N&127)|0){if(u=wA(G|0,l|0,52)|0,S()|0,u=u&15,u|0)for(i=1;;){if(N=kA(7,0,(15-i|0)*3|0)|0,!((N&G|0)==0&((S()|0)&l|0)==0)){f=33;break A}if(i>>>0<u>>>0)i=i+1|0;else break}if(N=n,t[N>>2]=0,t[N+4>>2]=0,(sA|0)>(r|0)){for(N=A&-15728641,L=sA;;){if(I=L,L=L+-1|0,L>>>0>15|(sA|0)<(L|0)){f=19;break}if((sA|0)!=(L|0))if(i=kA(L|0,0,52)|0,i=i|e,u=S()|0|N,(sA|0)<(I|0))B=i;else{f=L;do B=kA(7,0,(14-f|0)*3|0)|0,f=f+1|0,i=B|i,u=S()|0|u;while((f|0)<(sA|0));B=i}else B=e,u=A;if(p=wA(B|0,u|0,45)|0,S()|0,!(_e(p&127)|0))i=0;else{p=wA(B|0,u|0,52)|0,S()|0,p=p&15;e:do if(!p)i=0;else for(f=1;;){if(i=wA(B|0,u|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(u=wA(e|0,A|0,(15-I|0)*3|0)|0,S()|0,u=u&7,(u|0)==7){s=5,f=42;break}if(i=(i|0)!=0,(u|0)==1&i){s=5,f=42;break}if(B=u+(((u|0)!=0&i)<<31>>31)|0,B|0&&(f=sA-I|0,f=Kr(7,0,f,((f|0)<0)<<31>>31)|0,p=S()|0,i?(i=mt(f|0,p|0,5,0)|0,i=$A(i|0,S()|0,-5,-1)|0,i=qr(i|0,S()|0,6,0)|0,i=$A(i|0,S()|0,1,0)|0,u=S()|0):(i=f,u=p),I=B+-1|0,I=mt(f|0,p|0,I|0,((I|0)<0)<<31>>31|0)|0,I=$A(i|0,u|0,I|0,S()|0)|0,B=S()|0,p=n,p=$A(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)OA(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,(sA|0)>(r|0)){for(i=sA;;){if(s=wA(e|0,A|0,(15-i|0)*3|0)|0,S()|0,s=s&7,(s|0)==7){s=5;break}if(o=sA-i|0,o=Kr(7,0,o,((o|0)<0)<<31>>31)|0,s=mt(o|0,S()|0,s|0,0)|0,o=S()|0,N=n,o=$A(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 br(G,l,sA,Y)|0&&OA(27795,27122,1327,27173),sA=Y,Y=t[sA+4>>2]|0,((s|0)>-1|(s|0)==-1&o>>>0>4294967295)&((Y|0)>(s|0)|((Y|0)==(s|0)?(t[sA>>2]|0)>>>0>o>>>0:0))?(sA=0,E=q,sA|0):(OA(27795,27122,1407,27158),0)}function Tl(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,u=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=wA(r|0,n|0,52)|0,S()|0,l=l&15,(l|0)>(s|0))return i=12,E=B,i|0;if(br(r,n,s,o)|0&&OA(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=kA(s|0,0,52)|0,u=S()|0|n&-15728641,f=i,t[f>>2]=s|r,t[f+4>>2]=u,f=wA(r|0,n|0,45)|0,S()|0;A:do if(_e(f&127)|0){if(l|0)for(o=1;;){if(f=kA(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,u=1,o=1;;){l=p-u|0,l=Kr(7,0,l,((l|0)<0)<<31>>31)|0,r=S()|0;do if(o)if(o=mt(l|0,r|0,5,0)|0,o=$A(o|0,S()|0,-5,-1)|0,o=qr(o|0,S()|0,6,0)|0,s=S()|0,(A|0)>(s|0)|(A|0)==(s|0)&e>>>0>o>>>0){A=$A(e|0,A|0,-1,-1)|0,A=dt(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=kA(7,0,G|0)|0,I=I&~(S()|0),n=qr(A|0,o|0,l|0,r|0)|0,e=S()|0,s=$A(n|0,e|0,2,0)|0,G=kA(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=mt(n|0,e|0,l|0,r|0)|0,e=dt(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=kA(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=kA(7,0,n|0)|0,L=L&~(S()|0),G=qr(e|0,A|0,l|0,r|0)|0,o=S()|0,n=kA(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=mt(G|0,o|0,l|0,r|0)|0,e=dt(e|0,A|0,o|0,S()|0)|0,o=0,A=S()|0;while(!1);if((p|0)>(u|0))n=~u,u=u+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=Kr(7,0,N,((N|0)<0)<<31>>31)|0,G=S()|0,u=i,r=t[u>>2]|0,u=t[u+4>>2]|0,l=(s-o|0)*3|0,n=kA(7,0,l|0)|0,u=u&~(S()|0),I=qr(e|0,A|0,N|0,G|0)|0,L=S()|0,l=kA(I|0,L|0,l|0)|0,u=S()|0|u,f=i,t[f>>2]=l|r&~n,t[f+4>>2]=u,G=mt(I|0,L|0,N|0,G|0)|0,e=dt(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 os(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0;s=wA(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=kA(n|0,0,52)|0,r=A|r,o=o|(S()|0),A=(Oe(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 qs(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;if(s=wA(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=kA(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,Oe(s,i)|0){t[e>>2]=r;return}else{t[e>>2]=-1;return}}function ls(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0;if(r=e,A=t[r>>2]|0,r=t[r+4>>2]|0,!((A|0)==0&(r|0)==0)&&(n=wA(A|0,r|0,52)|0,S()|0,n=n&15,l=kA(1,0,(n^15)*3|0)|0,A=$A(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(u=e+12|0,i=n;;){if((i|0)==(o|0)){n=5;break}if(f=(i|0)==(t[u>>2]|0),s=(15-i|0)*3|0,n=wA(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=kA(1,0,s|0)|0,A=$A(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[u>>2]=-1;return}else if((n|0)==7){o=kA(1,0,s|0)|0,o=$A(A|0,r|0,o|0,S()|0)|0,l=S()|0,f=e,t[f>>2]=o,t[f+4>>2]=l,t[u>>2]=i+-1;return}else if((n|0)==10)return}}function n0(e){e=+e;var A=0;return A=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?A+-6.283185307179586:A)}function In(e,A){return e=e|0,A=A|0,+ee(+(+C[e>>3]-+C[A>>3]))<17453292519943298e-27?(A=+ee(+(+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 jl(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=+se(+((s-n)*.5)),r=+se(+((+C[A+8>>3]-+C[e+8>>3])*.5)),r=i*i+r*(+Be(+s)*+Be(+n)*r),+(+at(+ +Ce(+r),+ +Ce(+(1-r)))*2)}function s0(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=+se(+((s-n)*.5)),r=+se(+((+C[A+8>>3]-+C[e+8>>3])*.5)),r=i*i+r*(+Be(+s)*+Be(+n)*r),+(+at(+ +Ce(+r),+ +Ce(+(1-r)))*2*6371.007180918475)}function Rl(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=+se(+((s-n)*.5)),r=+se(+((+C[A+8>>3]-+C[e+8>>3])*.5)),r=i*i+r*(+Be(+s)*+Be(+n)*r),+(+at(+ +Ce(+r),+ +Ce(+(1-r)))*2*6371.007180918475*1e3)}function Il(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=+Be(+i),s=+C[A+8>>3]-+C[e+8>>3],o=n*+se(+s),r=+C[e>>3],+ +at(+o,+(+se(+i)*+Be(+r)-+Be(+s)*(n*+se(+r))))}function Ll(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=+ee(+(i+-3.141592653589793))<1e-16,A=+C[e>>3],s){A=A-r,C[n>>3]=A,s=n;break}if(o=+Be(+r),r=+se(+r),A=o*+se(+A)+ +Be(+i)*(r*+Be(+A)),A=A>1?1:A,A=+xt(+(A<-1?-1:A)),C[n>>3]=A,+ee(+(A+-1.5707963267948966))<1e-16){C[n>>3]=1.5707963267948966,C[n+8>>3]=0;return}if(+ee(+(A+1.5707963267948966))<1e-16){C[n>>3]=-1.5707963267948966,C[n+8>>3]=0;return}if(l=1/+Be(+A),i=r*+se(+i)*l,r=+C[e>>3],A=l*((o-+se(+A)*+se(+r))/+Be(+r)),o=i>1?1:i,A=A>1?1:A,A=+C[e+8>>3]+ +at(+(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(+ee(+(A+-1.5707963267948966))<1e-16){C[s>>3]=1.5707963267948966,C[n+8>>3]=0;return}if(+ee(+(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 Js(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 Nl(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 Fl(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 Pl(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 C0(e,A){e=e|0,A=A|0;var r=0;return e>>>0>15?(A=4,A|0):(r=Kr(7,0,e,((e|0)<0)<<31>>31)|0,r=mt(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 Xs(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0;return I=+C[A>>3],p=+C[e>>3],u=+se(+((I-p)*.5)),i=+C[A+8>>3],f=+C[e+8>>3],o=+se(+((i-f)*.5)),l=+Be(+p),B=+Be(+I),o=u*u+o*(B*l*o),o=+at(+ +Ce(+o),+ +Ce(+(1-o)))*2,u=+C[r>>3],I=+se(+((u-I)*.5)),n=+C[r+8>>3],i=+se(+((n-i)*.5)),s=+Be(+u),i=I*I+i*(B*s*i),i=+at(+ +Ce(+i),+ +Ce(+(1-i)))*2,u=+se(+((p-u)*.5)),n=+se(+((f-n)*.5)),n=u*u+n*(l*s*n),n=+at(+ +Ce(+n),+ +Ce(+(1-n)))*2,s=(o+i+n)*.5,+(+Ut(+ +Ce(+(+et(+(s*.5))*+et(+((s-o)*.5))*+et(+((s-i)*.5))*+et(+((s-n)*.5)))))*4)}function as(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(Rn(e,A,o)|0&&OA(27795,27190,415,27199),A=t[o>>2]|0,(A|0)>0){if(n=+Xs(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+ +Xs(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 Ql(e,A,r){return e=e|0,A=A|0,r=r|0,e=as(e,A,r)|0,e|0||(C[r>>3]=+C[r>>3]*6371.007180918475*6371.007180918475),e|0}function Ol(e,A,r){return e=e|0,A=A|0,r=r|0,e=as(e,A,r)|0,e|0||(C[r>>3]=+C[r>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function zl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=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=+se(+((n-f)*.5)),u=s,s=+C[o+8+(e<<4)+8>>3],u=+se(+((s-u)*.5)),u=p*p+u*(+Be(+n)*+Be(+f)*u),i=i+ +at(+ +Ce(+u),+ +Ce(+(1-u)))*2;while((e|0)<(A|0));return C[r>>3]=i,o=0,E=l,o|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,u=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=+se(+((n-f)*.5)),u=s,s=+C[o+8+(e<<4)+8>>3],u=+se(+((s-u)*.5)),u=p*p+u*(+Be(+f)*+Be(+n)*u),i=i+ +at(+ +Ce(+u),+ +Ce(+(1-u)))*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 Gl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=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=+se(+((n-f)*.5)),u=s,s=+C[o+8+(e<<4)+8>>3],u=+se(+((s-u)*.5)),u=p*p+u*(+Be(+f)*+Be(+n)*u),i=i+ +at(+ +Ce(+u),+ +Ce(+(1-u)))*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 Ul(e){e=e|0;var A=0,r=0,n=0;return A=Ht(1,12)|0,A||OA(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&&OA(27310,27235,61,27333),n=e,t[n>>2]=A,t[r>>2]=A,A|0)}function Vl(e,A){e=e|0,A=A|0;var r=0,n=0;return n=kr(24)|0,n||OA(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&&OA(27376,27235,82,27361),t[e>>2]=n,t[A>>2]=n,n|0)}function Ai(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,ZA(s);while((r|0)!=0);s=A,A=t[A+8>>2]|0,ZA(s)}while((A|0)!=0);if(A=e,e=t[e+8>>2]|0,n||ZA(A),e)n=0;else break}}function Wl(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0,he=0,Ee=0,ie=0,GA=0,CA=0,xe=0,We=0,de=0;if(s=e+8|0,t[s>>2]|0)return de=1,de|0;if(n=t[e>>2]|0,!n)return de=0,de|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 de=0,de|0;xe=kr(r<<2)|0,xe||OA(27396,27235,317,27415),CA=kr(r<<5)|0,CA||OA(27437,27235,321,27415),t[e>>2]=0,HA=e+4|0,t[HA>>2]=0,t[s>>2]=0,r=0,GA=0,MA=0,B=0;A:for(;;){if(p=t[n>>2]|0,p){i=0,o=p;do{if(u=+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],+ee(+(u-l))>3.141592653589793){de=14;break}i=i+(l-u)*(+C[A>>3]+ +C[s>>3])}while(!f);if((de|0)==14){de=0,i=0,A=p;do U=+C[A+8>>3],ie=A+16|0,Ee=t[ie>>2]|0,Ee=(Ee|0)==0?p:Ee,Z=+C[Ee+8>>3],i=i+(+C[A>>3]+ +C[Ee>>3])*((Z<0?Z+6.283185307179586:Z)-(U<0?U+6.283185307179586:U)),A=t[((A|0)==0?n:ie)>>2]|0;while((A|0)!=0)}i>0?(t[xe+(GA<<2)>>2]=n,GA=GA+1|0,s=MA,A=B):de=19}else de=19;if((de|0)==19){de=0;do if(r){if(A=r+8|0,t[A>>2]|0){de=21;break A}if(r=Ht(1,12)|0,!r){de=23;break A}t[A>>2]=r,s=r+4|0,o=r,A=B}else if(B){s=HA,o=B+8|0,A=n,r=e;break}else if(t[e>>2]|0){de=27;break A}else{s=HA,o=e,A=n,r=e;break}while(!1);if(t[o>>2]=n,t[s>>2]=n,o=CA+(MA<<5)|0,f=t[n>>2]|0,f){for(p=CA+(MA<<5)+8|0,C[p>>3]=17976931348623157e292,B=CA+(MA<<5)+24|0,C[B>>3]=17976931348623157e292,C[o>>3]=-17976931348623157e292,I=CA+(MA<<5)+16|0,C[I>>3]=-17976931348623157e292,sA=17976931348623157e292,q=-17976931348623157e292,s=0,L=f,u=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,Z=+C[(N?f:L)+8>>3],i<u&&(C[p>>3]=i,u=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),sA=U>0&U<sA?U:sA,q=U<0&U>q?U:q,s=s|+ee(+(U-Z))>3.141592653589793,!N;)Y=i;s&&(C[I>>3]=q,C[B>>3]=sA)}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(ie=n+8|0,n=t[ie>>2]|0,t[ie>>2]=0,n)MA=s,B=A;else{de=45;break}}if((de|0)==21)OA(27213,27235,35,27247);else if((de|0)==23)OA(27267,27235,37,27247);else if((de|0)==27)OA(27310,27235,61,27333);else if((de|0)==45){A:do if((GA|0)>0){for(ie=(s|0)==0,he=s<<2,Ee=(e|0)==0,ce=0,A=0;;){if(QA=t[xe+(ce<<2)>>2]|0,ie)de=73;else{if(MA=kr(he)|0,!MA){de=50;break}if(HA=kr(he)|0,!HA){de=52;break}e:do if(Ee)r=0;else{for(s=0,r=0,o=e;n=CA+(s<<5)|0,ei(t[o>>2]|0,n,t[QA>>2]|0)|0?(t[MA+(r<<2)>>2]=o,t[HA+(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+((ei(s,t[HA+(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(ZA(MA),ZA(HA),r){if(s=r+4|0,n=t[s>>2]|0,n)r=n+8|0;else if(t[r>>2]|0){de=70;break}t[r>>2]=QA,t[s>>2]=QA}else de=73}if((de|0)==73){if(de=0,A=t[QA>>2]|0,A|0)do HA=A,A=t[A+16>>2]|0,ZA(HA);while((A|0)!=0);ZA(QA),A=1}if(ce=ce+1|0,(ce|0)>=(GA|0)){We=A;break A}}(de|0)==50?OA(27452,27235,249,27471):(de|0)==52?OA(27490,27235,252,27471):(de|0)==70&&OA(27310,27235,61,27333)}else We=0;while(!1);return ZA(xe),ZA(CA),de=We,de|0}return 0}function ei(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(!(wr(A,r)|0)||(A=Ot(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?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(n<i|n>u);)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,u=l+(o-l)*((n-i)/(u-i)),(u<0?u+6.283185307179586:u)>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?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(n<i|n>u);)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)/(u-i))>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}return 0}function Fr(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0;if(q=E,E=E+32|0,sA=q+16|0,Y=q,i=wA(e|0,A|0,52)|0,S()|0,i=i&15,L=wA(r|0,n|0,52)|0,S()|0,(i|0)!=(L&15|0))return sA=12,E=q,sA|0;if(f=wA(e|0,A|0,45)|0,S()|0,f=f&127,p=wA(r|0,n|0,45)|0,S()|0,p=p&127,f>>>0>121|p>>>0>121)return sA=5,E=q,sA|0;if(L=(f|0)!=(p|0),L){if(l=an(f,p)|0,(l|0)==7)return sA=1,E=q,sA|0;u=an(p,f)|0,(u|0)==7?OA(27514,27538,161,27548):(N=l,o=u)}else N=0,o=0;B=_e(f)|0,I=_e(p)|0,t[sA>>2]=0,t[sA+4>>2]=0,t[sA+8>>2]=0,t[sA+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,u=r,l=n;do u=Sl(u,l)|0,l=S()|0,o=$t(o)|0,(o|0)==1&&(o=$t(1)|0),f=f+1|0;while((f|0)!=(p|0));p=o,f=u,u=l}else p=o,f=r,u=n;else if(l){f=0,u=r,l=n;do u=rs(u,l)|0,l=S()|0,o=$t(o)|0,f=f+1|0;while((f|0)!=(p|0));p=o,f=u,u=l}else p=o,f=r,u=n;if(ss(f,u,sA)|0,L||OA(27563,27538,191,27548),l=(B|0)!=0,o=(I|0)!=0,l&o&&OA(27590,27538,192,27548),l){if(o=zt(e,A)|0,(o|0)==7){i=5;break}if(xA[22e3+(o*7|0)+N>>0]|0){i=1;break}u=t[21168+(o*28|0)+(N<<2)>>2]|0,f=u}else if(o){if(o=zt(f,u)|0,(o|0)==7){i=5;break}if(xA[22e3+(o*7|0)+p>>0]|0){i=1;break}f=0,u=t[21168+(p*28|0)+(o<<2)>>2]|0}else f=0,u=0;if((f|u|0)<0)i=5;else{if((u|0)>0){l=sA+4|0,o=0;do Nr(l),o=o+1|0;while((o|0)!=(u|0))}if(t[Y>>2]=0,t[Y+4>>2]=0,t[Y+8>>2]=0,ot(Y,N),i|0)for(;sr(i)|0?bt(Y):Ze(Y),(i|0)>1;)i=i+-1|0;if((f|0)>0){i=0;do Nr(Y),i=i+1|0;while((i|0)!=(f|0))}G=sA+4|0,tA(G,Y,G),nt(G),G=51}}else if(ss(r,n,sA)|0,(B|0)!=0&(I|0)!=0)if((p|0)!=(f|0)&&OA(27621,27538,261,27548),o=zt(e,A)|0,i=zt(r,n)|0,(o|0)==7|(i|0)==7)i=5;else if(xA[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=sA+4|0,i=0;do Nr(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=sA+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),sA=i,E=q,sA|0}function ti(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0;if(G=E,E=E+48|0,f=G+36|0,o=G+24|0,l=G+12|0,u=G,s=wA(e|0,A|0,52)|0,S()|0,s=s&15,I=wA(e|0,A|0,45)|0,S()|0,I=I&127,I>>>0>121)return n=5,E=G,n|0;if(p=_e(I)|0,kA(s|0,0,52)|0,Y=S()|0|134225919,i=n,t[i>>2]=-1,t[i+4>>2]=Y,!s)return s=zA(r)|0,(s|0)==7||(s=ln(I,s)|0,(s|0)==127)?(Y=1,E=G,Y|0):(L=kA(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],sr(i)|0){if(s=te(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],bt(l)}else{if(s=Te(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],Ze(l)}if(mA(o,l,u),nt(u),s=n,q=t[s>>2]|0,s=t[s+4>>2]|0,Z=(15-i|0)*3|0,sA=kA(7,0,Z|0)|0,s=s&~(S()|0),Z=kA(zA(u)|0,0,Z|0)|0,s=S()|0|s,Y=n,t[Y>>2]=Z|q&~sA,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=zA(f)|0,s=ln(I,r)|0,(s|0)==127?u=0:u=_e(s)|0;e:do if(r){if(p){if(s=zt(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=Yt(s)|0,r=r+1|0;while((r|0)!=(i|0))}else s=r;if((s|0)==1){s=9;break A}r=ln(I,s)|0,(r|0)==127&&OA(27648,27538,411,27678),_e(r)|0?OA(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&&OA(27724,27538,419,27678),!u){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,Z=n,t[Z>>2]=r,t[Z+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,Z=n,t[Z>>2]=r,t[Z+4>>2]=i,s=s+1|0,(s|0)==(l|0)){s=N,r=58;break e}}if(o=an(N,I)|0,(o|0)==7&&OA(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,Z=n,t[Z>>2]=r,t[Z+4>>2]=s,i=i+1|0;while((i|0)!=(l|0))}if(s=zt(r,s)|0,(s|0)==7&&OA(27795,27538,440,27678),r=Dt(N)|0,r=t[(r?21792:21584)+(o*28|0)+(s<<2)>>2]|0,(r|0)<0&&OA(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=ts(i,o)|0,o=S()|0,Z=n,t[Z>>2]=i,t[Z+4>>2]=o,s=s+1|0;while((s|0)<(r|0));s=N,r=58}}else if((p|0)!=0&(u|0)!=0){if(r=zt(e,A)|0,i=n,i=zt(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,Z=n,t[Z>>2]=o,t[Z+4>>2]=l,r=r+1|0;while((r|0)<(i|0));r=58}}else r=58;while(!1);if((r|0)==58&&u&&(r=59),(r|0)==59&&(Z=n,(zt(t[Z>>2]|0,t[Z+4>>2]|0)|0)==1)){s=9;break}Z=n,sA=t[Z>>2]|0,Z=t[Z+4>>2]&-1040385,q=kA(s|0,0,45)|0,Z=Z|(S()|0),s=n,t[s>>2]=sA|q,t[s+4>>2]=Z,s=0}else s=1;while(!1);return Z=s,E=G,Z|0}function Yl(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=Fr(e,A,r,n,o)|0,e||(Jn(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=Tt(r,i)|0,r||(r=ti(e,A,i,s)|0)),E=o,r|0}function Kl(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,u=0;return u=E,E=E+32|0,o=u+12|0,l=u,i=Fr(e,A,e,A,o)|0,i|0?(l=i,E=u,l|0):(e=Fr(e,A,r,n,l)|0,e|0?(l=e,E=u,l|0):(o=Bn(o,l)|0,l=s,t[l>>2]=o,t[l+4>>2]=((o|0)<0)<<31>>31,l=0,E=u,l|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,u=0;return u=E,E=E+32|0,o=u+12|0,l=u,i=Fr(e,A,e,A,o)|0,!i&&(i=Fr(e,A,r,n,l)|0,!i)?(n=Bn(o,l)|0,n=$A(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=u,l|0):(l=i,E=u,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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0;if(QA=E,E=E+48|0,MA=QA+24|0,o=QA+12|0,HA=QA,i=Fr(e,A,e,A,MA)|0,!i&&(i=Fr(e,A,r,n,o)|0,!i)){Z=Bn(MA,o)|0,U=((Z|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,Fr(e,A,e,A,MA)|0&&OA(27795,27538,692,27747),Fr(e,A,r,n,o)|0&&OA(27795,27538,697,27747),Xn(MA),Xn(o),p=(Z|0)==0?0:1/+(Z|0),r=t[MA>>2]|0,G=p*+((t[o>>2]|0)-r|0),Y=MA+4|0,n=t[Y>>2]|0,sA=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[HA>>2]=r,B=HA+4|0,t[B>>2]=n,I=HA+8|0,t[I>>2]=i;A:do if((Z|0)<0)i=0;else for(L=0,N=0;;){u=+(N>>>0)+4294967296*+(L|0),ce=G*u+ +(r|0),l=sA*u+ +(n|0),u=p*u+ +(i|0),r=~~+B0(+ce),o=~~+B0(+l),i=~~+B0(+u),ce=+ee(+(+(r|0)-ce)),l=+ee(+(+(o|0)-l)),u=+ee(+(+(i|0)-u));do if(ce>l&ce>u)r=0-(o+i)|0,n=o;else if(f=0-r|0,l>u){n=f-i|0;break}else{n=o,i=f-o|0;break}while(!1);if(t[HA>>2]=r,t[B>>2]=n,t[I>>2]=i,A0(HA),i=ti(e,A,HA,s+(N<<3)|0)|0,i|0)break A;if(!((L|0)<(U|0)|(L|0)==(U|0)&N>>>0<Z>>>0)){i=0;break A}r=$A(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 HA=i,E=QA,HA|0}return HA=i,E=QA,HA|0}function Kr(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,WA(s|0),i|0;i=e,s=A,e=1,A=0;do o=(r&1|0)==0&!0,e=mt((o?1:i)|0,(o?0:s)|0,e|0,A|0)|0,A=S()|0,r=mi(r|0,n|0,1)|0,n=S()|0,i=mt(i|0,s|0,i|0,s|0)|0,s=S()|0;while(!((r|0)==0&(n|0)==0));return WA(A|0),e|0}function us(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,u=0,f=0,p=0;l=E,E=E+16|0,i=l,o=wA(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],u=1/+Be(+f),p=+C[25968+(o<<3)>>3],C[r>>3]=f+p,C[r+8>>3]=f-p,f=+C[i+8>>3],u=p*u,C[r+16>>3]=u+f,C[r+24>>3]=f-u;break}return o=s,E=l,o|0}else{if(s=wA(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 mr(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 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,u=0,f=0,p=0;f=E,E=E+48|0,o=f+32|0,i=f+40|0,l=f,Rt(o,0,0,0),u=t[o>>2]|0,o=t[o+4>>2]|0;do if(r>>>0<=15){if(s=o0(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,u=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[u>>0]=xA[i>>0]|0,xA[u+1>>0]=xA[i+1>>0]|0,xA[u+2>>0]=xA[i+2>>0]|0;break}if(s=Ht((t[A+8>>2]|0)+1|0,32)|0,s){cs(A,s),p=l,t[p>>2]=u,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,xA[l+28>>0]=0,u=l+29|0,xA[u>>0]=xA[i>>0]|0,xA[u+1>>0]=xA[i+1>>0]|0,xA[u+2>>0]=xA[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,u=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[u>>0]=xA[i>>0]|0,xA[u+1>>0]=xA[i+1>>0]|0,xA[u+2>>0]=xA[i+2>>0]|0;break}}else u=l,t[u>>2]=0,t[u+4>>2]=0,t[l+8>>2]=4,t[l+12>>2]=-1,u=l+16|0,p=l+29|0,t[u>>2]=0,t[u+4>>2]=0,t[u+8>>2]=0,xA[u+12>>0]=0,xA[p>>0]=xA[i>>0]|0,xA[p+1>>0]=xA[i+1>>0]|0,xA[p+2>>0]=xA[i+2>>0]|0;while(!1);E0(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 E0(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=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,xA[A>>0]|0?(r=ri(r,n)|0,n=S()|0):xA[A>>0]=1,Z=e+20|0,!(t[t[Z>>2]>>2]|0)){A=e+24|0,r=t[A>>2]|0,r|0&&ZA(r),q=e,t[q>>2]=0,t[q+4>>2]=0,t[e+8>>2]=0,t[Z>>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)sA=e+24|0;else{G=e+12|0,B=(s|0)==3,p=A&255,u=(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=wA(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(fs(t[Z>>2]|0,t[I>>2]|0,L)|0){Y=19;break e}break}}if(u&&(s=t[(t[Z>>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],wr(26832,L)|0)){if(ns(t[(t[Z>>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=Rn(r,n,L)|0,s|0){Y=32;break}if(us(r,n,N,0)|0){Y=36;break}if(o&&si(t[Z>>2]|0,t[I>>2]|0,L,N)|0){Y=42;break}if(u&&ii(t[Z>>2]|0,t[I>>2]|0,L,N)|0){Y=42;break}}if(B){if(A=us(r,n,L,1)|0,s=t[I>>2]|0,A|0){Y=45;break}if(Pe(s,L)|0){if(vr(N,L),Lr(L,t[I>>2]|0)|0){Y=53;break}if(fs(t[Z>>2]|0,t[I>>2]|0,l)|0){Y=53;break}if(ii(t[Z>>2]|0,t[I>>2]|0,N,L)|0){Y=53;break}}}}do if((i|0)<(t[G>>2]|0)){if(A=us(r,n,L,1)|0,s=t[I>>2]|0,A|0){Y=58;break e}if(!(Pe(s,L)|0)){Y=73;break}if(Lr(t[I>>2]|0,L)|0&&(vr(N,L),si(t[Z>>2]|0,t[I>>2]|0,N,L)|0)){Y=65;break e}if(r=Ks(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=ri(r,n)|0,n=S()|0),(r|0)==0&(n|0)==0){sA=I;break A}}switch(Y|0){case 15:{A=t[I>>2]|0,A|0&&ZA(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[Z>>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:{OA(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&&ZA(A),sA=e,t[sA>>2]=0,t[sA+4>>2]=0,t[Z>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[I>>2]=0,t[e+8>>2]=s,E=U;return}case 36:{OA(27795,27761,493,27772);break}case 42:{t[e>>2]=r,t[e+4>>2]=n,E=U;return}case 45:{s|0&&ZA(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[Z>>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&&ZA(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[Z>>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&&ZA(A),sA=e,t[sA>>2]=0,t[sA+4>>2]=0,t[Z>>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[sA>>2]|0,A|0&&ZA(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[e+8>>2]=0,t[Z>>2]=0,t[e+12>>2]=-1,t[q>>2]=0,t[sA>>2]=0,E=U}function ri(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0;B=E,E=E+16|0,p=B,n=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0;do if(n){for(;r=kA(n+4095|0,0,52)|0,s=S()|0|A&-15728641,i=(15-n|0)*3|0,o=kA(7,0,i|0)|0,l=S()|0,r=r|e|o,s=s|l,u=wA(e|0,A|0,i|0)|0,S()|0,u=u&7,n=n+-1|0,!(u>>>0<6);)if(n)A=s,e=r;else{f=4;break}if((f|0)==4){r=wA(r|0,s|0,45)|0,S()|0;break}return p=(u|0)==0&(Oe(r,s)|0)!=0,p=kA((p?2:1)+u|0,0,i|0)|0,f=S()|0|A&~l,p=p|e&~o,WA(f|0),E=B,p|0}while(!1);return r=r&127,r>>>0>120?(f=0,p=0,WA(f|0),E=B,p|0):(Rt(p,0,r+1|0,0),f=t[p+4>>2]|0,p=t[p>>2]|0,WA(f|0),E=B,p|0)}function Xl(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,u=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,Jl(B,e,A,r),f=B,os(l,t[f>>2]|0,t[f+4>>2]|0,A),f=l,u=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]=u,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],(u|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=u,e=f;do{if(!((o|0)<(s|0)|(o|0)==(s|0)&l>>>0<n>>>0)){N=4;break}if(f=l,l=$A(l|0,o|0,1,0)|0,o=S()|0,f=i+(f<<3)|0,t[f>>2]=A,t[f+4>>2]=e,ls(I),e=I,A=t[e>>2]|0,e=t[e+4>>2]|0,(A|0)==0&(e|0)==0){if(E0(r),A=r,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0){N=10;break}qs(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&&ZA(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,qs(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 Aa(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,u=0,f=0,p=0,B=0,I=0,L=0;if(B=E,E=E+48|0,u=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;Rt(u,0,0,0),o=u,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,xA[p+12>>0]=0,xA[r>>0]=xA[l>>0]|0,xA[r+1>>0]=xA[l+1>>0]|0,xA[r+2>>0]=xA[l+2>>0]|0,r=4,p=9;else{if(r=o0(r)|0,r|0){u=f,t[u>>2]=0,t[u+4>>2]=0,t[f+8>>2]=r,t[f+12>>2]=-1,u=f+16|0,p=f+29|0,t[u>>2]=0,t[u+4>>2]=0,t[u+8>>2]=0,xA[u+12>>0]=0,xA[p>>0]=xA[l>>0]|0,xA[p+1>>0]=xA[l+1>>0]|0,xA[p+2>>0]=xA[l+2>>0]|0,p=9;break}if(r=Ht((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,xA[p+12>>0]=0,xA[r>>0]=xA[l>>0]|0,xA[r+1>>0]=xA[l+1>>0]|0,xA[r+2>>0]=xA[l+2>>0]|0,r=13,p=9;break}cs(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,xA[f+28>>0]=0,s=f+29|0,xA[s>>0]=xA[l>>0]|0,xA[s+1>>0]=xA[l+1>>0]|0,xA[s+2>>0]=xA[l+2>>0]|0,t[f+16>>2]=3,I=+un(r),I=I*+Kn(r),i=+ee(+ +C[r>>3]),i=I/+Be(+ +M0(+i,+ +ee(+ +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(Js(r+-1|0,u)|0,!(i/+C[u>>3]>10))break A;L=t[s>>2]|0,r=L+-1|0,t[s>>2]=r}while((L|0)>1);while(!1);if(E0(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 br(r,s,A,u)|0,l=u,e=n,l=$A(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,E0(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 i0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0;if(!(wr(A,r)|0)||(A=Ot(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?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(n<i|n>u);)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,u=l+(o-l)*((n-i)/(u-i)),(u<0?u+6.283185307179586:u)>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?(u=o,o=l):(u=i,i=o,o=s,s=l),n=n==i|n==u?n+2220446049250313e-31:n,!!(n<i|n>u);)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)/(u-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 ni(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=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,sA=A+16|0,C[sA>>3]=-17976931348623157e292,!((N|0)<=0)){for(I=t[e+4>>2]|0,f=17976931348623157e292,p=-17976931348623157e292,B=0,e=-1,i=17976931348623157e292,o=17976931348623157e292,u=-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>u?C[A>>3]=r:r=u,l>n&&(C[sA>>3]=l,n=l),f=l>0&l<f?l:f,p=l<0&l>p?l:p,B=B|+ee(+(l-s))>3.141592653589793,e=L+1|0,(e|0)!=(N|0);)q=L,u=r,L=e,e=q;B&&(C[sA>>3]=p,C[Y>>3]=f)}}function o0(e){return e=e|0,(e>>>0<4?0:15)|0}function cs(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=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,sA=A+16|0,C[sA>>3]=-17976931348623157e292,(N|0)>0){for(s=t[e+4>>2]|0,I=17976931348623157e292,L=-17976931348623157e292,n=0,r=-1,u=17976931348623157e292,f=17976931348623157e292,B=-17976931348623157e292,o=-17976931348623157e292,q=0;i=+C[s+(q<<4)>>3],p=+C[s+(q<<4)+8>>3],HA=r+2|0,l=+C[s+(((HA|0)==(N|0)?0:HA)<<4)+8>>3],i<u&&(C[G>>3]=i,u=i),p<f&&(C[Y>>3]=p,f=p),i>B?C[A>>3]=i:i=B,p>o&&(C[sA>>3]=p,o=p),I=p>0&p<I?p:I,L=p<0&p>L?p:L,n=n|+ee(+(p-l))>3.141592653589793,r=q+1|0,(r|0)!=(N|0);)HA=q,B=i,q=r,r=HA;n&&(C[sA>>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(HA=e+8|0,r=t[HA>>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,sA=t[s+(n<<3)>>2]|0,sA){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,Z=A+(U<<5)+16|0,C[Z>>3]=-17976931348623157e292,(sA|0)>0){for(N=t[s+(n<<3)+4>>2]|0,I=17976931348623157e292,L=-17976931348623157e292,s=0,n=-1,G=0,u=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)==(sA|0)?0:n)<<4)+8>>3],i<u&&(C[q>>3]=i,u=i),B<f&&(C[e>>3]=B,f=B),i>p?C[Y>>3]=i:i=p,B>o&&(C[Z>>3]=B,o=B),I=B>0&B<I?B:I,L=B<0&B>L?B:L,s=s|+ee(+(B-l))>3.141592653589793,n=G+1|0,(n|0)!=(sA|0);)QA=G,G=n,p=i,n=QA;s&&(C[Z>>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[HA>>2]|0;while((U|0)<(r|0))}}function fs(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(!(i0(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,i0((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 si(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,u=0,f=0,p=0;if(f=E,E=E+16|0,l=f,o=r+8|0,!(i0(e,A,o)|0))return u=0,E=f,u|0;u=e+8|0;A:do if((t[u>>2]|0)>0){for(i=e+12|0,s=0;;){if(p=s,s=s+1|0,i0((t[i>>2]|0)+(p<<3)|0,A+(s<<5)|0,o)|0){s=0;break}if((s|0)>=(t[u>>2]|0))break A}return E=f,s|0}while(!1);if(S0(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[u>>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(i0(l,n,t[s+(o<<3)+4>>2]|0)|0){s=0;break A}if(s=o+1|0,S0((t[e>>2]|0)+(o<<3)|0,A+(s<<5)|0,r,n)|0){s=0;break A}i=t[u>>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 S0(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0,U=0,MA=0,HA=0,QA=0,ce=0;if(HA=E,E=E+176|0,q=HA+172|0,s=HA+168|0,Z=HA,!(Pe(A,n)|0))return e=0,E=HA,e|0;if(Ir(A,n,q,s),Fn(Z|0,r|0,168)|0,(t[r>>2]|0)>0){A=0;do QA=Z+8+(A<<4)+8|0,sA=+Kt(+C[QA>>3],t[s>>2]|0),C[QA>>3]=sA,A=A+1|0;while((A|0)<(t[r>>2]|0))}G=+C[n>>3],Y=+C[n+8>>3],sA=+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[Z>>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,QA=(r|0)%(t[e>>2]|0)|0,i=+C[A+(QA<<4)>>3],o=+Kt(+C[A+(QA<<4)+8>>3],t[q>>2]|0),!(I>=G)|!(i>=G)&&!(I<=Y)|!(i<=Y)&&!(N<=L)|!(o<=L)&&!(N>=sA)|!(o>=sA)){B=i-I,f=o-N,A=0;do if(ce=A,A=A+1|0,QA=(A|0)==(s|0)?0:A,i=+C[Z+8+(ce<<4)+8>>3],o=+C[Z+8+(QA<<4)+8>>3]-i,l=+C[Z+8+(ce<<4)>>3],u=+C[Z+8+(QA<<4)>>3]-l,p=B*o-f*u,p!=0&&(U=N-i,MA=I-l,u=(U*u-o*MA)/p,!(u<0|u>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 ce=A,E=HA,ce|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;if(S0(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,S0((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 ea(){return 8}function ta(){return 16}function ra(){return 168}function na(){return 8}function sa(){return 16}function ia(){return 12}function oa(){return 8}function la(e){return e=e|0,+(+((t[e>>2]|0)>>>0)+4294967296*+(t[e+4>>2]|0))}function aa(e){e=e|0;var A=0,r=0;return r=+C[e>>3],A=+C[e+8>>3],+ +Ce(+(r*r+A*A))}function oi(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,u=0,f=0,p=0,B=0,I=0;f=+C[e>>3],u=+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)/(u*p-o*i),C[s>>3]=f+u*i,C[s+8>>3]=l+o*i}function li(e,A){return e=e|0,A=A|0,+ee(+(+C[e>>3]-+C[A>>3]))<11920928955078125e-23?(A=+ee(+(+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 ua(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;r=+C[e>>3],n=+Be(+r),r=+se(+r),C[A+16>>3]=r,r=+C[e+8>>3],s=n*+Be(+r),C[A>>3]=s,r=n*+se(+r),C[A+8>>3]=r}function ca(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=Oe(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(l0(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 l0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0;if(p=E,E=E+32|0,l=p+16|0,u=p,n=jn(e,A,l)|0,n|0)return r=n,E=p,r|0;i=re(e,A)|0,f=zt(e,A)|0,Vr(i,u),n=nr(i,t[l>>2]|0)|0;do if(_e(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:OA(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[u>>2]|0)&&(u=Dt(i)|0,e=t[l>>2]|0,u|(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 ir(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=0;if(Z=E,E=E+32|0,q=Z+24|0,Y=Z+20|0,N=Z+8|0,L=Z+16|0,I=Z,u=(Oe(e,A)|0)==0,u=u?6:5,p=wA(e|0,A|0,52)|0,S()|0,p=p&15,u>>>0<=r>>>0)return n=2,E=Z,n|0;B=(p|0)==0,!B&&(G=kA(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=(Oe(e,A)|0)!=0,((s?4:5)|0)<(r|0)||l0(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=Z,n|0;t[Y>>2]=0,s=$(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=kA(7,0,(p^15)*3|0)|0,(f&B|0)==0&(l&(S()|0)|0)==0))s=r;else{if(l=(r+-1+u|0)%(u|0)|0,s=Oe(e,A)|0,(l|0)<0&&OA(27795,27797,248,27822),u=(s|0)!=0,((u?4:5)|0)<(l|0)&&OA(27795,27797,248,27822),l0(e,A,q)|0&&OA(27795,27797,248,27822),s=(t[q>>2]|0)+l|0,u?s=26704+(((s|0)%5|0)<<2)|0:s=26736+(((s|0)%6|0)<<2)|0,l=t[s>>2]|0,(l|0)==7&&OA(27795,27797,248,27822),t[L>>2]=0,s=$(e,A,l,L,I)|0,s|0)break;f=I,u=t[f>>2]|0,f=t[f+4>>2]|0;do if(f>>>0<o>>>0|(f|0)==(o|0)&u>>>0<i>>>0){if(Oe(u,f)|0?i=qA(u,f,e,A)|0:i=t[26800+((((t[L>>2]|0)+(t[26768+(l<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,s=Oe(u,f)|0,(i+-1|0)>>>0>5){s=-1,i=u,o=f;break}if(s=(s|0)!=0,(i|0)==1&s){s=-1,i=u,o=f;break}do if(l0(u,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=u,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(u=(Oe(f,l)|0)!=0,u?e=qA(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=Oe(f,l)|0,(e+-1|0)>>>0<=5&&(sA=(s|0)!=0,!((e|0)==1&sA)))do if(l0(f,l,q)|0)s=-1;else if(sA){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|u&(s|0)==5?0:s}A=o,e=i;break A}while(!1);return n=s,E=Z,n|0}while(!1);return sA=kA(s|0,0,56)|0,q=S()|0|A&-2130706433|536870912,t[n>>2]=sA|e,t[n+4>>2]=q,n=0,E=Z,n|0}function fa(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return i=(Oe(e,A)|0)==0,n=ir(e,A,0,r)|0,s=(n|0)==0,i?!s||(n=ir(e,A,1,r+8|0)|0,n|0)||(n=ir(e,A,2,r+16|0)|0,n|0)||(n=ir(e,A,3,r+24|0)|0,n|0)||(n=ir(e,A,4,r+32|0)|0,n)?(i=n,i|0):ir(e,A,5,r+40|0)|0:!s||(n=ir(e,A,1,r+8|0)|0,n|0)||(n=ir(e,A,2,r+16|0)|0,n|0)||(n=ir(e,A,3,r+24|0)|0,n|0)||(n=ir(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 ha(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,u=0;return u=E,E=E+192|0,s=u,i=u+168|0,o=wA(e|0,A|0,56)|0,S()|0,o=o&7,l=A&-2130706433|134217728,n=jn(e,l,i)|0,n|0?(l=n,E=u,l|0):(A=wA(e|0,A|0,52)|0,S()|0,A=A&15,Oe(e,l)|0?w(i,A,o,1,s):eA(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=u,l|0)}function ai(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,!(Ve(e,n)|0))?(n=0,E=s,n|0):(i=wA(e|0,A|0,56)|0,S()|0,i=(ir(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 ui(e,A,r){e=e|0,A=A|0,r=r|0;var n=0;(A|0)>0?(n=Ht(A,4)|0,t[e>>2]=n,n||OA(27835,27858,40,27872)):t[e>>2]=0,t[e+4>>2]=A,t[e+8>>2]=0,t[e+12>>2]=r}function ci(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+(~~(+ee(+(+Ge(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]}ZA(l),t[o>>2]=(t[o>>2]|0)+-1}while(!1)}ZA(t[e>>2]|0)}function fi(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 hi(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;if(r=~~(+ee(+(+Ge(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 ZA(A),i=e+8|0,t[i>>2]=(t[i>>2]|0)+-1,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;i=kr(40)|0,i||OA(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=~~(+ee(+(+Ge(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(;!(In(n,A)|0&&In(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 ZA(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 ma(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;if(s=~~(+ee(+(+Ge(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(In(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(In(e,A)|0&&In(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 pa(e,A){e=e|0,A=A|0;var r=0;if(r=~~(+ee(+(+Ge(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(In(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 ga(){return 27920}function Zr(e){return e=+e,~~+gi(+e)|0}function kr(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0,f=0,p=0,B=0,I=0,L=0,N=0,G=0,Y=0,sA=0,q=0,Z=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,u=r>>>1&1,u=t[28228+((n|s|o|l|u)+(r>>>u)<<2)>>2]|0,r=u,l=u,u=(t[u+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<u>>>0,r=e,l=s?e:l,u=s?o:u;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 u>>>0<16?(U=u+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]=u|1,t[o+u>>2]=u,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]=u,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?u=31:(B=(e+1048320|0)>>>16&8,G=e<<B,l=(G+520192|0)>>>16&4,G=G<<l,u=(G+245760|0)>>>16&2,u=14-(l|B|u)+(G<<u>>>15)|0,u=f>>>(u+7|0)&1|u<<1):u=0,r=t[28228+(u<<2)>>2]|0;A:do if(!r)r=0,e=0,G=61;else for(e=0,l=f<<((u|0)==31?0:25-(u>>>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<<u,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,u=B>>>1&2,B=B>>>u,r=B>>>1&1,e=0,r=t[28228+((i|o|l|u|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:(Z=(A+1048320|0)>>>16&8,U=A<<Z,q=(U+520192|0)>>>16&4,U=U<<q,r=(U+245760|0)>>>16&2,r=14-(q|Z|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);Z=A+8|0,U=t[Z>>2]|0,t[U+12>>2]=p,t[Z>>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,Z=U+B|0,t[6987]=Z,t[Z+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,u=B+47|0,i=e+u|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=Xr(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=Xr(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=Xr(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=u-A+e&0-e,e>>>0>=2147483647){o=A,i=n,G=145;break A}if((Xr(e|0)|0)==-1){Xr(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=Xr(f|0)|0,N=Xr(0)|0,Y=N-q|0,sA=Y>>>0>(B+40|0)>>>0,!((q|0)==-1|sA^1|q>>>0<N>>>0&((q|0)!=-1&(N|0)!=-1)^1))&&(o=sA?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),u=t[6987]|0;A:do if(u){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&&(Z=A+4|0,(t[A+12>>2]&8|0)==0)&&i>>>0>u>>>0&e>>>0<=u>>>0){t[Z>>2]=r+o,U=(t[6984]|0)+o|0,q=u+8|0,q=(q&7|0)==0?0:0-q&7,Z=u+q|0,q=U-q|0,t[6987]=Z,t[6984]=q,t[Z+4>>2]=q|1,t[u+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((u|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}Z=(A+1048320|0)>>>16&8,U=A<<Z,q=(U+520192|0)>>>16&4,U=U<<q,n=(U+245760|0)>>>16&2,n=14-(q|Z|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);Z=A+8|0,U=t[Z>>2]|0,t[U+12>>2]=f,t[Z>>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<=u>>>0&&(U=e+(t[A+4>>2]|0)|0,U>>>0>u>>>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=u+16|0,e=e>>>0<s>>>0?u:e,A=e+8|0,r=o+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,Z=i+q|0,q=r-q|0,t[6987]=Z,t[6984]=q,t[Z+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 Z=A,A=A+4|0,t[A>>2]=7;while((Z+8|0)>>>0<U>>>0);if((e|0)!=(u|0)){if(i=e-u|0,t[r>>2]=t[r>>2]&-2,t[u+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]=u,t[A+12>>2]=u,t[u+8>>2]=A,t[u+12>>2]=r;break}if(A=i>>>8,A?i>>>0>16777215?n=31:(Z=(A+1048320|0)>>>16&8,U=A<<Z,q=(U+520192|0)>>>16&4,U=U<<q,n=(U+245760|0)>>>16&2,n=14-(q|Z|n)+(U<<n>>>15)|0,n=i>>>(n+7|0)&1|n<<1):n=0,r=28228+(n<<2)|0,t[u+28>>2]=n,t[u+20>>2]=0,t[s>>2]=0,A=t[6982]|0,e=1<<n,!(A&e)){t[6982]=A|e,t[r>>2]=u,t[u+24>>2]=r,t[u+12>>2]=u,t[u+8>>2]=u;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]=u,t[u+24>>2]=A,t[u+12>>2]=u,t[u+8>>2]=u;break A}while(!1);Z=A+8|0,U=t[Z>>2]|0,t[U+12>>2]=u,t[Z>>2]=u,t[u+8>>2]=U,t[u+12>>2]=A,t[u+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,Z=i+q|0,q=U-q|0,t[6987]=Z,t[6984]=q,t[Z+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,Z=U+B|0,t[6987]=Z,t[Z+4>>2]=q|1,t[U+4>>2]=B|3,U=U+8|0,E=MA,U|0}return U=ga()|0,t[U>>2]=12,U=0,E=MA,U|0}function ZA(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,u=0;if(e){r=e+-8|0,s=t[6985]|0,e=t[e+-4>>2]|0,A=e&-8,u=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=u+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>=u>>>0)&&(e=u+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)==(u|0)){if(u=(t[6984]|0)+A|0,t[6984]=u,t[6987]=l,t[l+4>>2]=u|1,(l|0)!=(t[6986]|0))return;t[6986]=0,t[6983]=0;return}if((t[6986]|0)==(u|0)){u=(t[6983]|0)+A|0,t[6983]=u,t[6986]=o,t[l+4>>2]=u|1,t[o+u>>2]=u;return}s=(n&-8)+A|0,r=n>>>3;do if(n>>>0<256)if(A=t[u+8>>2]|0,e=t[u+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[u+24>>2]|0,e=t[u+12>>2]|0;do if((e|0)==(u|0)){if(A=u+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[u+8>>2]|0,t[r+12>>2]=e,t[e+8>>2]=r,r=e;while(!1);if(i|0){if(e=t[u+28>>2]|0,A=28228+(e<<2)|0,(t[A>>2]|0)==(u|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)==(u|0)?n:i+20|0)>>2]=r,!r)break;t[r+24>>2]=i,e=u+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,u=e<<o,i=(u+520192|0)>>>16&4,u=u<<i,n=(u+245760|0)>>>16&2,n=14-(i|o|n)+(u<<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,u=t[o>>2]|0,t[u+12>>2]=l,t[o>>2]=l,t[l+8>>2]=u,t[l+12>>2]=e,t[l+24>>2]=0}while(!1);if(u=(t[6989]|0)+-1|0,t[6989]=u,!(u|0)){for(e=28380;e=t[e>>2]|0,e;)e=e+8|0;t[6989]=-1}}}}function Ht(e,A){e=e|0,A=A|0;var r=0;return e?(r=ht(A,e)|0,(A|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0|0)==(A|0)?r:-1)):r=0,e=kr(r)|0,!e||!(t[e+-4>>2]&3)||Jr(e|0,0,r|0)|0,e|0}function $A(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,r=e+r>>>0,WA(A+n+(r>>>0<e>>>0|0)>>>0|0),r|0|0}function dt(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,WA(n|0),e-r>>>0|0|0}function di(e){return e=e|0,(e?31-(wt(e^e-1)|0)|0:32)|0}function hs(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,u=0,f=0,p=0,B=0,I=0,L=0,N=0;if(p=e,u=A,f=u,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,WA(I|0),s|0):(I=0,s=0,WA(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,WA(I|0),s|0);i=(l|0)==0;do if(o){if(!i){if(i=(wt(l|0)|0)-(wt(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]=u|A&0,I=0,s=0,WA(I|0),s|0):(I=0,s=0,WA(I|0),s|0)}if(i=o-1|0,i&o|0){l=(wt(o|0)|0)+33-(wt(f|0)|0)|0,N=64-l|0,B=32-l|0,u=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&u,l=(f<<N|p>>>(L>>>0))&u|p<<B&l-33>>31;break}return s|0&&(t[s>>2]=i&p,t[s+4>>2]=0),(o|0)==1?(L=u|A&0,N=e|0|0,WA(L|0),N|0):(N=di(o|0)|0,L=f>>>(N>>>0)|0,N=f<<32-N|p>>>(N>>>0)|0,WA(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,WA(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,WA(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>>>((di(l|0)|0)>>>0),WA(L|0),N|0;if(i=(wt(l|0)|0)-(wt(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]=u|A&0,L=0,N=0,WA(L|0),N|0):(L=0,N=0,WA(L|0),N|0)}while(!1);if(!o)f=l,u=0,l=0;else{B=r|0|0,p=I|n&0,f=$A(B|0,p|0,-1,-1)|0,r=S()|0,u=l,l=0;do n=u,u=i>>>31|u<<1,i=l|i<<1,n=e<<1|n>>>31|0,I=e>>>31|A<<1|0,dt(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=dt(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=u,u=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|u,N=(i<<1|0)&-2|l,WA(L|0),N|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,l=0,u=0,f=0;return f=A>>31|((A|0)<0?-1:0)<<1,u=((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=dt(f^e|0,u^A|0,f|0,u|0)|0,o=S()|0,e=i^f,A=s^u,dt((hs(l,o,dt(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 ya(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=ht(s,i)|0,n=e>>>16,e=(r>>>16)+(ht(s,n)|0)|0,s=A>>>16,A=ht(s,i)|0,WA((e>>>16)+(ht(s,n)|0)+(((e&65535)+A|0)>>>16)|0),e+A<<16|r&65535|0|0}function mt(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=ya(s,i)|0,e=S()|0,WA((ht(A,i)|0)+(ht(n,s)|0)+e|e&0|0),r|0|0|0}function Ln(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,u=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,u=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,e=dt(o^e|0,i^A|0,o|0,i|0)|0,A=S()|0,hs(e,A,dt(f^r|0,u^n|0,f|0,u|0)|0,S()|0,l)|0,n=dt(t[l>>2]^o|0,t[l+4>>2]^i|0,o|0,i|0)|0,r=S()|0,E=s,WA(r|0),n|0}function Nn(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,hs(e,A,r,n,s)|0,E=i,WA(t[s+4>>2]|0),t[s>>2]|0|0}function mi(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(WA(A>>r|0),e>>>r|(A&(1<<r)-1)<<32-r):(WA(((A|0)<0?-1:0)|0),A>>r-32|0)}function wA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(WA(A>>>r|0),e>>>r|(A&(1<<r)-1)<<32-r):(WA(0),A>>>r-32|0)}function kA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(WA(A<<r|(e&(1<<r)-1<<32-r)>>>32-r|0),e<<r):(WA(e<<r-32|0),0)}function ds(e,A,r){return e=e|0,A=A|0,A=wt(A)|0,(A|0)==32&&(A=A+(wt(e)|0)|0),WA(0),A|0}function pi(e,A){return e=+e,A=+A,e!=e?+A:A!=A?+e:+Gr(+e,+A)}function M0(e,A){return e=+e,A=+A,e!=e?+A:A!=A?+e:+tt(+e,+A)}function B0(e){return e=+e,e>=0?+Le(e+.5):+Vt(e-.5)}function Fn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if((r|0)>=8192)return cr(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;xA[e>>0]=xA[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);)xA[e>>0]=xA[A>>0]|0,xA[e+1>>0]=xA[A+1>>0]|0,xA[e+2>>0]=xA[A+2>>0]|0,xA[e+3>>0]=xA[A+3>>0]|0,e=e+4|0,A=A+4|0;for(;(e|0)<(s|0);)xA[e>>0]=xA[A>>0]|0,e=e+1|0,A=A+1|0;return i|0}function Jr(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;)xA[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);)xA[e>>0]=A,e=e+1|0;return i-r|0}function gi(e){return e=+e,e>=0?+Le(e+.5):+Vt(e-.5)}function Xr(e){e=e|0;var A=0,r=0,n=0;return n=yr()|0,r=t[De>>2]|0,A=r+e|0,(e|0)>0&(A|0)<(r|0)|(A|0)<0?(tr(A|0)|0,Ue(12),-1):(A|0)>(n|0)&&!(fr(A|0)|0)?(Ue(12),-1):(t[De>>2]=A,r|0)}return{___divdi3:qr,___muldi3:mt,___remdi3:Ln,___uremdi3:Nn,_areNeighborCells:es,_bitshift64Ashr:mi,_bitshift64Lshr:wA,_bitshift64Shl:kA,_calloc:Ht,_cellAreaKm2:Ql,_cellAreaM2:Ol,_cellAreaRads2:as,_cellToBoundary:Rn,_cellToCenterChild:Ks,_cellToChildPos:_l,_cellToChildren:r0,_cellToChildrenSize:br,_cellToLatLng:dn,_cellToLocalIj:Yl,_cellToParent:It,_cellToVertex:ir,_cellToVertexes:fa,_cellsToDirectedEdge:w0,_cellsToLinkedMultiPolygon:vt,_childPosToCell:Tl,_compactCells:bl,_constructCell:ye,_destroyLinkedMultiPolygon:Ai,_directedEdgeToBoundary:fn,_directedEdgeToCells:_n,_edgeLengthKm:Hl,_edgeLengthM:Gl,_edgeLengthRads:zl,_emscripten_replace_memory:hr,_free:ZA,_getBaseCellNumber:re,_getDirectedEdgeDestination:v0,_getDirectedEdgeOrigin:Dn,_getHexagonAreaAvgKm2:Js,_getHexagonAreaAvgM2:Nl,_getHexagonEdgeLengthAvgKm:Fl,_getHexagonEdgeLengthAvgM:Pl,_getIcosahedronFaces:Zs,_getIndexDigit:ve,_getNumCells:C0,_getPentagons:is,_getRes0Cells:$n,_getResolution:DA,_greatCircleDistanceKm:s0,_greatCircleDistanceM:Rl,_greatCircleDistanceRads:jl,_gridDisk:v,_gridDiskDistances:T,_gridDistance:Kl,_gridPathCells:ql,_gridPathCellsSize:Zl,_gridRing:fA,_gridRingUnsafe:TA,_i64Add:$A,_i64Subtract:dt,_isPentagon:Oe,_isResClassIII:El,_isValidCell:Ve,_isValidDirectedEdge:e0,_isValidIndex:jt,_isValidVertex:ai,_latLngToCell:ns,_llvm_ctlz_i64:ds,_llvm_maxnum_f64:pi,_llvm_minnum_f64:M0,_llvm_round_f64:B0,_localIjToCell:$l,_malloc:kr,_maxFaceCount:Bl,_maxGridDiskSize:h,_maxPolygonToCellsSize:fe,_maxPolygonToCellsSizeExperimental:Aa,_memcpy:Fn,_memset:Jr,_originToDirectedEdges:Tn,_pentagonCount:Dl,_polygonToCells:Bt,_polygonToCellsExperimental:Xl,_readInt64AsDoubleFromPointer:la,_res0CellCount:Yn,_round:gi,_sbrk:Xr,_sizeOfCellBoundary:ra,_sizeOfCoordIJ:oa,_sizeOfGeoLoop:na,_sizeOfGeoPolygon:sa,_sizeOfH3Index:ea,_sizeOfLatLng:ta,_sizeOfLinkedGeoPolygon:ia,_uncompactCells:kl,_uncompactCellsSize:Cl,_vertexToLatLng:ha,establishStackSpace:jr,stackAlloc:dr,stackRestore:Ur,stackSave:Tr}})(on,Hr,cA);c.___divdi3=gA.___divdi3,c.___muldi3=gA.___muldi3,c.___remdi3=gA.___remdi3,c.___uremdi3=gA.___uremdi3,c._areNeighborCells=gA._areNeighborCells,c._bitshift64Ashr=gA._bitshift64Ashr,c._bitshift64Lshr=gA._bitshift64Lshr,c._bitshift64Shl=gA._bitshift64Shl,c._calloc=gA._calloc,c._cellAreaKm2=gA._cellAreaKm2,c._cellAreaM2=gA._cellAreaM2,c._cellAreaRads2=gA._cellAreaRads2,c._cellToBoundary=gA._cellToBoundary,c._cellToCenterChild=gA._cellToCenterChild,c._cellToChildPos=gA._cellToChildPos,c._cellToChildren=gA._cellToChildren,c._cellToChildrenSize=gA._cellToChildrenSize,c._cellToLatLng=gA._cellToLatLng,c._cellToLocalIj=gA._cellToLocalIj,c._cellToParent=gA._cellToParent,c._cellToVertex=gA._cellToVertex,c._cellToVertexes=gA._cellToVertexes,c._cellsToDirectedEdge=gA._cellsToDirectedEdge,c._cellsToLinkedMultiPolygon=gA._cellsToLinkedMultiPolygon,c._childPosToCell=gA._childPosToCell,c._compactCells=gA._compactCells,c._constructCell=gA._constructCell,c._destroyLinkedMultiPolygon=gA._destroyLinkedMultiPolygon,c._directedEdgeToBoundary=gA._directedEdgeToBoundary,c._directedEdgeToCells=gA._directedEdgeToCells,c._edgeLengthKm=gA._edgeLengthKm,c._edgeLengthM=gA._edgeLengthM,c._edgeLengthRads=gA._edgeLengthRads;var gr=c._emscripten_replace_memory=gA._emscripten_replace_memory;c._free=gA._free,c._getBaseCellNumber=gA._getBaseCellNumber,c._getDirectedEdgeDestination=gA._getDirectedEdgeDestination,c._getDirectedEdgeOrigin=gA._getDirectedEdgeOrigin,c._getHexagonAreaAvgKm2=gA._getHexagonAreaAvgKm2,c._getHexagonAreaAvgM2=gA._getHexagonAreaAvgM2,c._getHexagonEdgeLengthAvgKm=gA._getHexagonEdgeLengthAvgKm,c._getHexagonEdgeLengthAvgM=gA._getHexagonEdgeLengthAvgM,c._getIcosahedronFaces=gA._getIcosahedronFaces,c._getIndexDigit=gA._getIndexDigit,c._getNumCells=gA._getNumCells,c._getPentagons=gA._getPentagons,c._getRes0Cells=gA._getRes0Cells,c._getResolution=gA._getResolution,c._greatCircleDistanceKm=gA._greatCircleDistanceKm,c._greatCircleDistanceM=gA._greatCircleDistanceM,c._greatCircleDistanceRads=gA._greatCircleDistanceRads,c._gridDisk=gA._gridDisk,c._gridDiskDistances=gA._gridDiskDistances,c._gridDistance=gA._gridDistance,c._gridPathCells=gA._gridPathCells,c._gridPathCellsSize=gA._gridPathCellsSize,c._gridRing=gA._gridRing,c._gridRingUnsafe=gA._gridRingUnsafe,c._i64Add=gA._i64Add,c._i64Subtract=gA._i64Subtract,c._isPentagon=gA._isPentagon,c._isResClassIII=gA._isResClassIII,c._isValidCell=gA._isValidCell,c._isValidDirectedEdge=gA._isValidDirectedEdge,c._isValidIndex=gA._isValidIndex,c._isValidVertex=gA._isValidVertex,c._latLngToCell=gA._latLngToCell,c._llvm_ctlz_i64=gA._llvm_ctlz_i64,c._llvm_maxnum_f64=gA._llvm_maxnum_f64,c._llvm_minnum_f64=gA._llvm_minnum_f64,c._llvm_round_f64=gA._llvm_round_f64,c._localIjToCell=gA._localIjToCell,c._malloc=gA._malloc,c._maxFaceCount=gA._maxFaceCount,c._maxGridDiskSize=gA._maxGridDiskSize,c._maxPolygonToCellsSize=gA._maxPolygonToCellsSize,c._maxPolygonToCellsSizeExperimental=gA._maxPolygonToCellsSizeExperimental,c._memcpy=gA._memcpy,c._memset=gA._memset,c._originToDirectedEdges=gA._originToDirectedEdges,c._pentagonCount=gA._pentagonCount,c._polygonToCells=gA._polygonToCells,c._polygonToCellsExperimental=gA._polygonToCellsExperimental,c._readInt64AsDoubleFromPointer=gA._readInt64AsDoubleFromPointer,c._res0CellCount=gA._res0CellCount,c._round=gA._round,c._sbrk=gA._sbrk,c._sizeOfCellBoundary=gA._sizeOfCellBoundary,c._sizeOfCoordIJ=gA._sizeOfCoordIJ,c._sizeOfGeoLoop=gA._sizeOfGeoLoop,c._sizeOfGeoPolygon=gA._sizeOfGeoPolygon,c._sizeOfH3Index=gA._sizeOfH3Index,c._sizeOfLatLng=gA._sizeOfLatLng,c._sizeOfLinkedGeoPolygon=gA._sizeOfLinkedGeoPolygon,c._uncompactCells=gA._uncompactCells,c._uncompactCellsSize=gA._uncompactCellsSize,c._vertexToLatLng=gA._vertexToLatLng,c.establishStackSpace=gA.establishStackSpace;var ft=c.stackAlloc=gA.stackAlloc,Fe=c.stackRestore=gA.stackRestore,ur=c.stackSave=gA.stackSave;if(c.asm=gA,c.cwrap=hA,c.setValue=W,c.getValue=V,Qe){Me(Qe)||(Qe=k(Qe));{it();var qe=function(nA){nA.byteLength&&(nA=new Uint8Array(nA)),LA.set(nA,z),c.memoryInitializerRequest&&delete c.memoryInitializerRequest.response,St()},kt=function(){D(Qe,qe,function(){throw"could not load memory initializer "+Qe})},Mt=pr(Qe);if(Mt)qe(Mt.buffer);else if(c.memoryInitializerRequest){var er=function(){var nA=c.memoryInitializerRequest,yA=nA.response;if(nA.status!==200&&nA.status!==0){var jA=pr(c.memoryInitializerRequestURL);if(jA)yA=jA.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+nA.status+", retrying "+Qe),kt();return}}qe(yA)};c.memoryInitializerRequest.response?setTimeout(er,0):c.memoryInitializerRequest.addEventListener("load",er)}else kt()}}var Ct;At=function nA(){Ct||Qt(),Ct||(At=nA)};function Qt(nA){if(Je>0||(Ie(),Je>0))return;function yA(){Ct||(Ct=!0,!X&&(oe(),me(),c.onRuntimeInitialized&&c.onRuntimeInitialized(),we()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),yA()},1)):yA()}c.run=Qt;function yt(nA){throw c.onAbort&&c.onAbort(nA),nA+="",P(nA),M(nA),X=!0,"abort("+nA+"). Build with -s ASSERTIONS=1 for more info."}if(c.abort=yt,c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();return Qt(),a})(typeof Ft=="object"?Ft:{}),ne="number",Ae=ne,Gn=ne,le=ne,ae=ne,pt=ne,PA=ne,A2=[["sizeOfH3Index",ne],["sizeOfLatLng",ne],["sizeOfCellBoundary",ne],["sizeOfGeoLoop",ne],["sizeOfGeoPolygon",ne],["sizeOfLinkedGeoPolygon",ne],["sizeOfCoordIJ",ne],["readInt64AsDoubleFromPointer",ne],["isValidCell",Gn,[le,ae]],["isValidIndex",Gn,[le,ae]],["latLngToCell",Ae,[ne,ne,pt,PA]],["cellToLatLng",Ae,[le,ae,PA]],["cellToBoundary",Ae,[le,ae,PA]],["maxGridDiskSize",Ae,[ne,PA]],["gridDisk",Ae,[le,ae,ne,PA]],["gridDiskDistances",Ae,[le,ae,ne,PA,PA]],["gridRing",Ae,[le,ae,ne,PA]],["gridRingUnsafe",Ae,[le,ae,ne,PA]],["maxPolygonToCellsSize",Ae,[PA,pt,ne,PA]],["polygonToCells",Ae,[PA,pt,ne,PA]],["maxPolygonToCellsSizeExperimental",Ae,[PA,pt,ne,PA]],["polygonToCellsExperimental",Ae,[PA,pt,ne,ne,ne,PA]],["cellsToLinkedMultiPolygon",Ae,[PA,ne,PA]],["destroyLinkedMultiPolygon",null,[PA]],["compactCells",Ae,[PA,PA,ne,ne]],["uncompactCells",Ae,[PA,ne,ne,PA,ne,pt]],["uncompactCellsSize",Ae,[PA,ne,ne,pt,PA]],["isPentagon",Gn,[le,ae]],["isResClassIII",Gn,[le,ae]],["getBaseCellNumber",ne,[le,ae]],["getResolution",ne,[le,ae]],["getIndexDigit",ne,[le,ae,ne]],["constructCell",Ae,[ne,ne,PA,PA]],["maxFaceCount",Ae,[le,ae,PA]],["getIcosahedronFaces",Ae,[le,ae,PA]],["cellToParent",Ae,[le,ae,pt,PA]],["cellToChildren",Ae,[le,ae,pt,PA]],["cellToCenterChild",Ae,[le,ae,pt,PA]],["cellToChildrenSize",Ae,[le,ae,pt,PA]],["cellToChildPos",Ae,[le,ae,pt,PA]],["childPosToCell",Ae,[ne,ne,le,ae,pt,PA]],["areNeighborCells",Ae,[le,ae,le,ae,PA]],["cellsToDirectedEdge",Ae,[le,ae,le,ae,PA]],["getDirectedEdgeOrigin",Ae,[le,ae,PA]],["getDirectedEdgeDestination",Ae,[le,ae,PA]],["isValidDirectedEdge",Gn,[le,ae]],["directedEdgeToCells",Ae,[le,ae,PA]],["originToDirectedEdges",Ae,[le,ae,PA]],["directedEdgeToBoundary",Ae,[le,ae,PA]],["gridDistance",Ae,[le,ae,le,ae,PA]],["gridPathCells",Ae,[le,ae,le,ae,PA]],["gridPathCellsSize",Ae,[le,ae,le,ae,PA]],["cellToLocalIj",Ae,[le,ae,le,ae,ne,PA]],["localIjToCell",Ae,[le,ae,PA,ne,PA]],["getHexagonAreaAvgM2",Ae,[pt,PA]],["getHexagonAreaAvgKm2",Ae,[pt,PA]],["getHexagonEdgeLengthAvgM",Ae,[pt,PA]],["getHexagonEdgeLengthAvgKm",Ae,[pt,PA]],["greatCircleDistanceM",ne,[PA,PA]],["greatCircleDistanceKm",ne,[PA,PA]],["greatCircleDistanceRads",ne,[PA,PA]],["cellAreaM2",Ae,[le,ae,PA]],["cellAreaKm2",Ae,[le,ae,PA]],["cellAreaRads2",Ae,[le,ae,PA]],["edgeLengthM",Ae,[le,ae,PA]],["edgeLengthKm",Ae,[le,ae,PA]],["edgeLengthRads",Ae,[le,ae,PA]],["getNumCells",Ae,[pt,PA]],["getRes0Cells",Ae,[PA]],["res0CellCount",ne],["getPentagons",Ae,[ne,PA]],["pentagonCount",ne],["cellToVertex",Ae,[le,ae,ne,PA]],["cellToVertexes",Ae,[le,ae,PA]],["vertexToLatLng",Ae,[le,ae,PA]],["isValidVertex",Gn,[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,dl=1002,As={};As[v2]="Unknown unit";As[b2]="Array length out of bounds";As[dl]="Got unexpected null value for H3 index";var k2="Unknown error";function ml(a,c,g){var y=g&&"value"in g,x=new Error((a[c]||k2)+" (code: "+c+(y?", value: "+g.value:"")+")");return x.code=c,x}function C2(a,c){var g=arguments.length===2?{value:c}:{};return ml(lt,a,g)}function E2(a,c){var g=arguments.length===2?{value:c}:{};return ml(As,a,g)}function pl(a){if(a!==0)throw C2(a)}var Mr={};A2.forEach(function(c){Mr[c[0]]=Ft.cwrap.apply(Ft,c)});var Vn=16,S2=4,$0=8,Ls=Mr.sizeOfH3Index(),M2=Mr.sizeOfLatLng(),B2=Mr.sizeOfCellBoundary();Mr.sizeOfGeoPolygon();Mr.sizeOfGeoLoop();Mr.sizeOfLinkedGeoPolygon();Mr.sizeOfCoordIJ();function D2(a){if(!a)throw E2(dl);return a}var _2=/[^0-9a-fA-F]/;function T2(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 c=parseInt(a.substring(0,a.length-8),Vn),g=parseInt(a.substring(a.length-8),Vn);return[g,c]}function Yi(a){if(a>=0)return a.toString(Vn);a=a&2147483647;var c=gl(8,a.toString(Vn)),g=(parseInt(c[0],Vn)+8).toString(Vn);return c=g+c.substring(1),c}function j2(a,c){return Yi(c)+gl(8,Yi(a))}function gl(a,c){for(var g=a-c.length,y="",x=0;x<g;x++)y+="0";return y=y+c,y}function R2(a,c){c===void 0&&(c=0);var g=Ft.getValue(a+Ls*c,"i32"),y=Ft.getValue(a+Ls*c+S2,"i32");return y?j2(g,y):null}function $i(a){return P2(Ft.getValue(a,"double"))}function I2(a){return[$i(a),$i(a+$0)]}function L2(a,c,g){for(var y=Ft.getValue(a,"i32"),x=a+$0,k=[],D=I2,P=0;P<y*2;P+=2)k.push(D(x+$0*P));return k}function N2(a,c,g){var y=Ft._malloc(M2);Ft.HEAPF64.set([a,c].map(F2),y/$0);var x=Ft._malloc(Ls);try{return pl(Mr.latLngToCell(y,g,x)),D2(R2(x))}finally{Ft._free(x),Ft._free(y)}}function yl(a,c){var g=Ft._malloc(B2),y=T2(a),x=y[0],k=y[1];try{return pl(Mr.cellToBoundary(x,k,g)),L2(g,c,c)}finally{Ft._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,xl=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 c=Ga();return c.length===24&&((g=c[0])==null?void 0:g[0])!==0?c:H2}function Ki(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 wl(a,c,g,y){const x=g-c;if(x<.001)return Ki(y[12]);const k=Math.max(0,Math.min(1,(a-c)/x)),D=V2(k),P=Math.min(23,Math.floor(D*24));return Ki(y[P])}function W2(a){const c=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),P=c.get(D),M=k.weight;P?(P.count++,P.qualitySum+=M):c.set(D,{count:1,qualitySum:M})}const g=[];let y=1/0,x=-1/0;for(const[k,D]of c.entries()){const P=D.qualitySum/D.count;g.push({hexId:k,count:D.count,avgQuality:P}),y=Math.min(y,P),x=Math.max(x,P)}return{cells:g,minQuality:g.length>0?y:0,maxQuality:g.length>0?x:0}}function Y2(a,c,g,y){const x=[];for(const k of a){const P=yl(k.hexId).map(([b,R])=>[R,b]);P.push(P[0]);const M=wl(k.avgQuality,c,g,y);x.push({type:"Feature",properties:{color:M,quality:k.avgQuality,count:k.count},geometry:{type:"Polygon",coordinates:[P]}})}return{type:"FeatureCollection",features:x}}async function $2(a,c,g,y,x){const k=[];let D=0;for(;D<a.length;){if(x.aborted)return null;const P=Math.min(D+xl,a.length);for(;D<P;D++){const M=a[D],R=yl(M.hexId).map(([z,W])=>[W,z]);R.push(R[0]);const O=wl(M.avgQuality,c,g,y);k.push({type:"Feature",properties:{color:O,quality:M.avgQuality,count:M.count},geometry:{type:"Polygon",coordinates:[R]}})}D<a.length&&await new Promise(M=>requestAnimationFrame(M))}return{type:"FeatureCollection",features:k}}function K2(a,c){const[g,y]=j.useState(a);return j.useEffect(()=>{const x=setTimeout(()=>y(a),c);return()=>clearTimeout(x)},[a,c]),g}function Z2(a,c){const g=[];for(const y of a){if(y.timestampS>c)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:c,terrainEnabled:g=!1,brightness:y=O2,basemapMode:x="dark",replaySamples:k,replayTimeS:D}){const P=j.useMemo(()=>k&&k.length>0&&D!=null?Z2(k,D):a,[k,D,a]),{current:M}=Or(),[b,R]=j.useState(null);j.useEffect(()=>{const oA=()=>{var bA;const SA=(bA=M==null?void 0:M.getMap)==null?void 0:bA.call(M);SA&&!b&&R(SA)};oA();const lA=setInterval(oA,50),BA=setTimeout(()=>clearInterval(lA),5e3);return()=>{clearInterval(lA),clearTimeout(BA)}},[M,b]);const[O,z]=j.useState(null),[W,V]=j.useState(!1),X=j.useRef({aborted:!1}),iA=j.useRef(0),AA=j.useRef(x),hA=K2(P,k?100:z2),uA=j.useMemo(()=>U2(x),[x]);j.useEffect(()=>{if(!hA||!Array.isArray(hA)||hA.length===0){queueMicrotask(()=>{z(null),iA.current=0});return}const oA=AA.current!==x;if(hA.length===iA.current&&O&&!oA)return;iA.current=hA.length,AA.current=x,X.current.aborted=!0,X.current={aborted:!1};const lA=X.current;V(!0);const{cells:BA,minQuality:SA,maxQuality:bA}=W2(hA);if(BA.length===0){z(null),V(!1);return}if(BA.length<xl){const cA=Y2(BA,SA,bA,uA);lA.aborted||(z(cA),V(!1));return}return $2(BA,SA,bA,uA,lA).then(cA=>{!lA.aborted&&cA&&z(cA)}).finally(()=>{lA.aborted||V(!1)}),()=>{lA.aborted=!0}},[hA,uA]),j.useEffect(()=>{if(!b)return;const oA=()=>{var lA,BA;try{const SA=b.getLayer(xn),bA=b.getSource(yn);if(c&&O&&O.features.length>0){if(bA?b.getSource(yn).setData(O):b.addSource(yn,{type:"geojson",data:O}),!SA){const cA=b.getLayer("topology-weak-edges-native"),IA=(BA=(lA=b.getStyle())==null?void 0:lA.layers)==null?void 0:BA.find(FA=>FA.type==="symbol"),LA=cA?"topology-weak-edges-native":IA==null?void 0:IA.id;b.addLayer({id:xn,type:"fill",source:yn,paint:{"fill-color":["get","color"],"fill-opacity":y}},LA)}}else SA&&b.removeLayer(xn),bA&&b.removeSource(yn)}catch(SA){console.warn("[WardrivingHexLayerMapLibre] Layer update error:",SA)}};b.isStyleLoaded()?oA():b.once("style.load",oA)},[b,c,O,g]),j.useEffect(()=>{if(!(!b||!c))try{b.getLayer(xn)&&b.setPaintProperty(xn,"fill-opacity",y)}catch{}},[b,y,c]),j.useEffect(()=>()=>{if(b)try{b.getLayer(xn)&&b.removeLayer(xn),b.getSource(yn)&&b.removeSource(yn)}catch{}},[b]);const EA=(O==null?void 0:O.features.length)??0;return EA>0&&c?m.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(a==null?void 0:a.length)||0,"data-cell-count":EA,"data-terrain-enabled":g,"data-is-processing":W,style:{display:"none"}}):null}const a0="replay-marker",P0="replay-marker-circle",u0="replay-trail",Q0="replay-trail-line",c0="replay-trace",bs="replay-trace-line",f0="replay-marker-icon",Zi=7,J2=2.5,X2=1.5;function A1(){const a=Zi*2*2,c=document.createElement("canvas");c.width=a,c.height=a;const g=c.getContext("2d");if(!g)return c;const y=a/2,x=a/2,k=Zi*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(),c}const e1={type:"FeatureCollection",features:[]},h0={type:"FeatureCollection",features:[]};function t1({neighbors:a}){const{current:c}=Or(),g=Vs(),y=j.useRef(null),x=j.useRef(0),k=j.useRef(!1);return j.useEffect(()=>{const D=c==null?void 0:c.getMap();if(!D||!g)return;const P=()=>{if(!k.current){if(!D.hasImage(f0)){const M=A1(),b=M.getContext("2d");if(b){const R=b.getImageData(0,0,M.width,M.height);D.addImage(f0,R,{pixelRatio:2})}}D.getSource(a0)||D.addSource(a0,{type:"geojson",data:e1}),D.getLayer(P0)||D.addLayer({id:P0,type:"symbol",source:a0,layout:{"icon-image":f0,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}),D.getSource(u0)||D.addSource(u0,{type:"geojson",data:h0}),D.getLayer(Q0)||D.addLayer({id:Q0,type:"line",source:u0,paint:{"line-color":"rgba(59, 130, 246, 0.4)","line-width":J2},layout:{"line-cap":"round","line-join":"round"}},P0),D.getSource(c0)||D.addSource(c0,{type:"geojson",data:h0}),D.getLayer(bs)||D.addLayer({id:bs,type:"line",source:c0,paint:{"line-color":"rgba(251, 191, 36, 0.6)","line-width":X2,"line-dasharray":[4,4]},layout:{"line-cap":"round"}},Q0),k.current=!0}};return D.isStyleLoaded()?P():D.once("styledata",P),()=>{if(cancelAnimationFrame(x.current),y.current=null,!D.isStyleLoaded()){k.current=!1;return}for(const M of[P0,Q0,bs])D.getLayer(M)&&D.removeLayer(M);for(const M of[a0,u0,c0])D.getSource(M)&&D.removeSource(M);D.hasImage(f0)&&D.removeImage(f0),k.current=!1}},[c,g]),j.useEffect(()=>{const D=c==null?void 0:c.getMap();if(!D||!g)return;const P=()=>{if(!k.current){x.current=requestAnimationFrame(P);return}const M=Ws.getState();if(!M.isActive)return;const{samples:b,currentTimeS:R}=M,O=qo(),z=D.getSource(a0);z&&O&&z.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[O.lon,O.lat]},properties:{}}]});const W=D.getSource(u0);if(W){const X=Lu(b,R);X.length>=2?W.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:X},properties:{}}]}):W.setData(h0)}const V=D.getSource(c0);if(V&&O){const X=Nu(),iA=(X==null?void 0:X[0])??null;if(iA!==y.current||iA)if(y.current=iA,iA&&a){const AA=r1(iA,a);AA?V.setData({type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:[[O.lon,O.lat],[AA.lon,AA.lat]]},properties:{}}]}):V.setData(h0)}else V.setData(h0)}x.current=requestAnimationFrame(P)};return x.current=requestAnimationFrame(P),()=>cancelAnimationFrame(x.current)},[c,g,a]),null}function r1(a,c){const g=a.toLowerCase();for(const[y,x]of Object.entries(c))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 qi="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Ji="terrarium",Xi=256,Ao=14,d0={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},An="terrain-dem",Un="hillshade-dem",O0="terrain-hillshade";function n1({enabled:a,exaggeration:c=4}){const{current:g}=Or(),[y,x]=j.useState(null),k=j.useRef(null);return j.useEffect(()=>{const D=()=>{var R;const b=(R=g==null?void 0:g.getMap)==null?void 0:R.call(g);b&&!y&&x(b)};D();const P=setInterval(D,50),M=setTimeout(()=>clearInterval(P),5e3);return()=>{clearInterval(P),clearTimeout(M)}},[g,y]),j.useEffect(()=>{if(!y)return;let D=!0;const P=()=>{var M,b;if(D)try{if(y.getSource(Un)||y.addSource(Un,{type:"raster-dem",tiles:[qi],encoding:Ji,tileSize:Xi,maxzoom:Ao}),!y.getLayer(O0)){const R=(b=(M=y.getStyle())==null?void 0:M.layers)==null?void 0:b.find(O=>O.type==="symbol");y.addLayer({id:O0,type:"hillshade",source:Un,paint:{"hillshade-shadow-color":d0.shadowColor,"hillshade-highlight-color":d0.highlightColor,"hillshade-accent-color":d0.accentColor,"hillshade-illumination-direction":d0.illuminationDirection,"hillshade-exaggeration":d0.exaggeration}},R==null?void 0:R.id)}y.getSource(An)||y.addSource(An,{type:"raster-dem",tiles:[qi],encoding:Ji,tileSize:Xi,maxzoom:Ao})}catch(R){console.error("[TerrainLayer] Source/layer setup error:",R)}};return y.isStyleLoaded()?P():(y.once("style.load",P),y.once("load",()=>{D&&!y.getSource(Un)&&P()})),()=>{D=!1}},[y]),j.useEffect(()=>{if(!y)return;let D=!0,P=!1;const M=()=>{if(!(!D||!y.getSource(An)))try{a?(y.setCenterClampedToGround(!1),y.setTerrain({source:An,exaggeration:c}),y.setMaxPitch(70),!P&&y.getPitch()<30&&!y.isMoving()&&(P=!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(An))M();else{const b=()=>{y.getSource(An)&&M()};y.once("idle",b)}return()=>{D=!1,k.current!==null&&(clearTimeout(k.current),k.current=null)}},[y,a,c]),j.useEffect(()=>()=>{var D;try{(D=y==null?void 0:y.getStyle)!=null&&D.call(y)&&y.isStyleLoaded()&&(y.setTerrain(null),y.getLayer(O0)&&y.removeLayer(O0),y.getSource(Un)&&y.removeSource(Un),y.getSource(An)&&y.removeSource(An))}catch{}},[y]),null}const s1=.03,i1=.1,o1=2,l1=3,a1=.02,u1=3;function c1(a,c=u1){if(a.length<3||c<=0)return a;let g=a;for(let y=0;y<c;y++){const x=[],k=g.length,D=g[0][0]===g[k-1][0]&&g[0][1]===g[k-1][1],P=D?k-1:k;for(let M=0;M<P;M++){const b=g[M],R=g[(M+1)%P],O=.75*b[0]+.25*R[0],z=.75*b[1]+.25*R[1],W=.25*b[0]+.75*R[0],V=.25*b[1]+.75*R[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,c){let g=1/0,y=-1/0,x=1/0,k=-1/0;for(const[D,P]of a)D<g&&(g=D),D>y&&(y=D),P<x&&(x=P),P>k&&(k=P);return g-=c,y+=c,x-=c,k+=c,{minX:g,minY:x,maxX:y,maxY:k,width:y-g,height:k-x}}function h1(a,c={}){if(a.length<l1)return{coordinates:[],valid:!1};const{bandwidth:g=s1,threshold:y=i1,cellSize:x=o1}=c,k=f1(a,a1),D=Math.ceil(k.width/(g/2)),P=Math.ceil(k.height/(g/2)),b=Math.min(1,200/Math.max(D,P)),R=Math.max(10,Math.ceil(D*b)),O=Math.max(10,Math.ceil(P*b)),z=AA=>(AA-k.minX)/k.width*R,W=AA=>(AA-k.minY)/k.height*O,V=AA=>AA/R*k.width+k.minX,X=AA=>AA/O*k.height+k.minY,iA=g/k.width*R;try{const K=Rc().x(SA=>z(SA[0])).y(SA=>W(SA[1])).size([R,O]).bandwidth(Math.max(5,iA)).cellSize(x)(a);if(K.length===0)return{coordinates:[],valid:!1};const uA=Math.max(...K.map(SA=>SA.value))*y;let EA=K[0],oA=1/0;for(const SA of K){const bA=Math.abs(SA.value-uA);bA<oA&&(oA=bA,EA=SA)}const lA=[];for(const SA of EA.coordinates){const bA=[];for(const cA of SA){const IA=[];for(const LA of cA){const FA=V(LA[0]),UA=X(LA[1]);IA.push([FA,UA])}if(IA.length>0){const LA=IA[0],FA=IA[IA.length-1];(LA[0]!==FA[0]||LA[1]!==FA[1])&&IA.push([LA[0],LA[1]])}if(IA.length>=4){const LA=c1(IA);bA.push(LA)}}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(AA){return console.warn("[KDE Contour] Failed to generate contour:",AA),{coordinates:[],valid:!1}}}function d1(a,c={}){const g=h1(a,c);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,eo=12;function to(a,c,g){return(c[0]-a[0])*(g[1]-a[1])-(c[1]-a[1])*(g[0]-a[0])}function b1(a){if(a.length<3)return a;const c=[...a].sort((x,k)=>x[0]-k[0]||x[1]-k[1]),g=[];for(const x of c){for(;g.length>=2&&to(g[g.length-2],g[g.length-1],x)<=0;)g.pop();g.push(x)}const y=[];for(let x=c.length-1;x>=0;x--){const k=c[x];for(;y.length>=2&&to(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,c){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,P=k-y,M=Math.sqrt(D*D+P*P);if(M<1e-4)return[x,k];const b=(M+c)/M;return[g+D*b,y+P*b]})}function C1(a,c,g,y,x){const k=x*x,D=k*x;return[.5*(2*c[0]+(-a[0]+g[0])*x+(2*a[0]-5*c[0]+4*g[0]-y[0])*k+(-a[0]+3*c[0]-3*g[0]+y[0])*D),.5*(2*c[1]+(-a[1]+g[1])*x+(2*a[1]-5*c[1]+4*g[1]-y[1])*k+(-a[1]+3*c[1]-3*g[1]+y[1])*D)]}function E1(a){if(a.length<3)return a;const c=[],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],P=a[(y+2)%g];for(let M=0;M<eo;M++)c.push(C1(x,k,D,P,M/eo))}return c}function S1(a){let c=b1(a);if(c.length<3)return null;c=k1(c,v1);const g=E1(c);return{type:"Polygon",coordinates:[[...g,g[0]]]}}function M1(a,c,g,y){const x=[];for(const[k,D]of a.communities){const P=[];for(const b of D){const R=c.get(b);R&&P.push([R[1],R[0]])}if(P.length<y1)continue;let M=d1(P,{bandwidth:g,threshold:y});M||(M=S1(P)),M&&x.push({type:"Feature",properties:{community:k,color:Cu(k),borderColor:ku(k),nodeCount:D.length},geometry:M})}return{type:"FeatureCollection",features:x}}function B1({partition:a,nodeCoordinates:c,visible:g,opacity:y=.7,bandwidth:x=x1,threshold:k=w1,strokeWidth:D=2}){const P=j.useMemo(()=>a?M1(a,c,x,k):{type:"FeatureCollection",features:[]},[a,c,x,k]),M=g?y:0,b={"fill-color":["get","color"],"fill-opacity":M},R={"line-color":["get","borderColor"],"line-width":D,"line-opacity":M};return m.jsxs(Qr,{id:m1,type:"geojson",data:P,children:[m.jsx(qt,{id:p1,type:"fill",paint:b}),m.jsx(qt,{id:g1,type:"line",paint:R})]})}function D1(a,c=!1,g=!1,y=!1,x=.7,k){const D=Mo(k);return y?x>=.75?D.restBright:D.rest:x>=.85?D.rest:(x>=.7,D.restDim)}function ro(a){return[a[1],a[0]]}function _1(a,c,g,y=12){const[x,k]=a,[D,P]=c,M=[];for(let b=0;b<=y;b++){const R=b/y,O=k+(P-k)*R,z=x+(D-x)*R,W=4*g*R*(1-R);M.push([O,z,W])}return M}function no(a,c,g,y,x,k,D,P,M,b,R,O="dark"){const z=Ys(),W=[];let V=1/0,X=-1/0;const iA=[];for(const K of a){const hA=K.edge.avgConfidence??(c?.7:.5),uA=K.edge.certainCount/Math.max(D,1),EA=hA*.7+uA*.3+(c?.5:0);iA.push({polyline:K,brightnessScore:EA}),V=Math.min(V,EA),X=Math.max(X,EA)}if(iA.length===0)return{type:"FeatureCollection",features:[]};const AA=X-V||1;iA.sort((K,hA)=>K.brightnessScore-hA.brightnessScore);for(const{polyline:K,brightnessScore:hA}of iA){const{from:uA,to:EA,edge:oA}=K,lA=g.get(oA.key)??0;if(lA<=0)continue;const BA=P.has(oA.key),SA=M.has(oA.key),bA=oA.avgConfidence??(c?.7:.5),cA=b===oA.key,IA=R[oA.fromHash],LA=R[oA.toHash],FA=(IA==null?void 0:IA.node_name)||(IA==null?void 0:IA.name)||oA.fromHash.slice(0,8),UA=(LA==null?void 0:LA.node_name)||(LA==null?void 0:LA.name)||oA.toHash.slice(0,8),vA=[uA[0]+(EA[0]-uA[0])*lA,uA[1]+(EA[1]-uA[1])*lA];let aA;if(!c)aA=1.5;else{const ue=k.get(oA.key)??_s(oA.certainCount),JA=x.get(oA.key)??ue;aA=JA+(ue-JA)*y,cA?aA=Math.max(aA*1.6,4.5):SA&&(aA=aA*1.3)}let dA;cA?dA=z.edges.highlight:dA=D1(!1,oA.isDirectPathEdge??!1,BA,SA,bA,O);let RA;cA?RA=z.edges.highlight:oA.isDirectPathEdge?RA=z.edges.hoverDirect:BA?RA=z.edges.hoverLoop:RA=z.edges.hoverStandard;let _A;if(!c)_A=(.3+bA*.3)*lA;else{const ue=Math.min(lA*1.5,1)*z.edgeOpacity;_A=SA?ue*1.15:ue}cA&&(_A=.95);const YA=(hA-V)/AA;W.push({type:"Feature",properties:{key:oA.key,baseColor:dA,hoverColor:RA,baseWidth:aA,baseOpacity:_A,brightnessScore:YA,isLoopEdge:BA,isBackbone:SA,isDirectPath:oA.isDirectPathEdge??!1,isHubConnection:oA.isHubConnection??!1,isZeroHop:oA.isZeroHop??!1,isValidated:c,certainCount:oA.certainCount,confidence:bA,symmetryRatio:oA.symmetryRatio??1,dominantDirection:oA.dominantDirection??"balanced",fromName:FA,toName:UA,fromHash:oA.fromHash,toHash:oA.toHash},geometry:{type:"LineString",coordinates:[ro(uA),ro(vA)]}})}return{type:"FeatureCollection",features:W}}const T1=150,j1=8;function so(a,c){const g=Ys(),y=[];let x=0;for(const k of a){const D=c.get(k.hash);D&&D.blendedScore>x&&(x=D.blendedScore)}for(const k of a){const{from:D,to:P,hash:M,neighbor:b,lastHopData:R}=k,O=`neighbor-${M}`,z=(R==null?void 0:R.avgRssi)??b.rssi??null,W=(R==null?void 0:R.avgSnr)??b.snr??null,V=(R==null?void 0:R.count)??0,X=(R==null?void 0:R.confidence)??1,iA=c.get(M),AA=(iA==null?void 0:iA.listenerScore)??0,K=(iA==null?void 0:iA.loudScore)??0,hA=(iA==null?void 0:iA.blendedScore)??0,uA=x>0?hA/x:0,EA=k.rxAdvertCount??0,oA=k.txProxyCount??0,lA=EA+oA,BA=lA>0?(oA-EA)/lA:0,SA=_1(D,P,T1,j1);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:X,hasAvgRssi:(R==null?void 0:R.avgRssi)!==void 0,hasAvgSnr:(R==null?void 0:R.avgSnr)!==void 0,isNeighborEdge:!0,listenerScore:AA,loudScore:K,blendedScore:hA,trafficWeight:uA,linkAsymmetry:BA,rxAdvertCount:EA,txProxyCount:oA},geometry:{type:"LineString",coordinates:SA}})}return{type:"FeatureCollection",features:y}}function R1({map:a,showTopology:c,validatedPolylines:g,weakPolylines:y,maxCertainCount:x,loopEdgeKeys:k,backboneEdgeKeys:D,highlightedEdgeKey:P,neighbors:M,validatedSourceId:b,weakSourceId:R,neighborPolylines:O=[],showNeighborLines:z=!0,neighborSourceId:W,neighborLinkScores:V=new Map,basemapMode:X}){const iA=j.useRef(null);j.useEffect(()=>{const oe=a&&"current"in a?a.current:a;iA.current=oe});const AA=j.useRef(new Map),K=j.useRef(1),hA=j.useRef(new Map),uA=j.useRef(new Map),EA=j.useRef(!1),oA=j.useRef(null),lA=j.useRef(c),BA=j.useRef(new Set),SA=j.useRef(""),bA=j.useRef(new Map),cA=j.useRef(""),IA=j.useRef(""),LA=j.useRef(""),FA=j.useRef(g),UA=j.useRef(y),vA=j.useRef(x),aA=j.useRef(k),dA=j.useRef(D),RA=j.useRef(P),_A=j.useRef(M),YA=j.useRef(O),ue=j.useRef(z),JA=j.useRef(V),KA=j.useRef(X);j.useEffect(()=>{FA.current=g,UA.current=y,vA.current=x,aA.current=k,dA.current=D,RA.current=P,_A.current=M,YA.current=O,ue.current=z,JA.current=V,KA.current=X},[g,y,x,k,D,P,M,O,z,V,X]);const VA=j.useCallback((oe=!1)=>{var ke,Se,pe,Ke,Je,At,it,St,Qe,Xe;const me=iA.current;if(!me)return;const we=me.getSource(b),$e=me.getSource(R),be=me.getSource(W);if(we){const Me=no(FA.current,!0,AA.current,K.current,hA.current,uA.current,vA.current,aA.current,dA.current,RA.current,_A.current,KA.current),ze=`${Me.features.length}:${((Se=(ke=Me.features[0])==null?void 0:ke.properties)==null?void 0:Se.key)??""}:${((Ke=(pe=Me.features[Me.features.length-1])==null?void 0:pe.properties)==null?void 0:Ke.key)??""}:${Array.from(AA.current.values()).reduce((ct,Pt)=>ct+Pt,0).toFixed(2)}`;(oe||ze!==cA.current)&&(we.setData(Me),cA.current=ze)}if($e){const Me=no(UA.current,!1,AA.current,K.current,hA.current,uA.current,vA.current,aA.current,dA.current,RA.current,_A.current,KA.current),ze=`${Me.features.length}:${((At=(Je=Me.features[0])==null?void 0:Je.properties)==null?void 0:At.key)??""}:${((St=(it=Me.features[Me.features.length-1])==null?void 0:it.properties)==null?void 0:St.key)??""}`;(oe||ze!==IA.current)&&($e.setData(Me),IA.current=ze)}if(be&&YA.current.length>0){const Me=so(YA.current,JA.current),ze=`${Me.features.length}:${((Xe=(Qe=Me.features[0])==null?void 0:Qe.properties)==null?void 0:Xe.hash)??""}`;(oe||ze!==LA.current)&&(be.setData(Me),LA.current=ze)}},[b,R,W]),Re=j.useCallback(()=>{oA.current&&(cancelAnimationFrame(oA.current),oA.current=null),AA.current=new Map,K.current=1,hA.current=new Map,uA.current=new Map,EA.current=!1,BA.current=new Set,SA.current="",bA.current=new Map},[]);j.useEffect(()=>{const oe=lA.current,me=c;if(lA.current=c,!!iA.current){if(oA.current&&(cancelAnimationFrame(oA.current),oA.current=null),oe&&!me&&!EA.current){EA.current=!0;const $e=new Map(AA.current);let be=null;const ke=Se=>{be||(be=Se);const pe=Se-be,Ke=Math.min(pe/Qc,1),Je=Xo(Ke);for(const[At,it]of $e)AA.current.set(At,it*(1-Je));VA(!0),Ke<1?oA.current=requestAnimationFrame(ke):(EA.current=!1,AA.current=new Map,BA.current=new Set,SA.current="",hA.current=new Map,uA.current=new Map,oA.current=null,VA(!0))};oA.current=requestAnimationFrame(ke)}!oe&&me&&(AA.current=new Map,BA.current=new Set,SA.current="")}},[c,VA]),j.useEffect(()=>{const oe=iA.current;if(!c||EA.current||!oe)return;const me=[...g,...y],we=me.map(pe=>`${pe.edge.key}:${pe.edge.certainCount}`).sort().join(","),$e=BA.current.size===0,be=SA.current!==""&&SA.current!==we;if(!$e&&!be){VA();return}const ke=[],Se=[];for(const{edge:pe}of me)BA.current.has(pe.key)?Se.push(pe.key):ke.push(pe.key);be&&Se.length>0&&(hA.current=new Map(bA.current),K.current=0),uA.current=new Map;for(const{edge:pe}of g){const Ke=_s(pe.certainCount);uA.current.set(pe.key,Ke)}for(const pe of ke)AA.current.set(pe,0);for(const pe of Se)AA.current.has(pe)||AA.current.set(pe,1);if(ke.length>0||be&&Se.length>0){oA.current&&(cancelAnimationFrame(oA.current),oA.current=null);let pe=null;const Ke=Math.min(100,T0/Math.max(ke.length,1)/2),Je=At=>{pe||(pe=At);const it=At-pe;for(let Qe=0;Qe<ke.length;Qe++){const Xe=ke[Qe],Me=Qe*Ke,ze=Math.max(0,it-Me),ct=Math.min(ze/T0,1);AA.current.set(Xe,Bs(ct))}if(be&&Se.length>0){const Qe=Math.min(it/T0,1);K.current=Bs(Qe)}VA(!0);const St=T0+(ke.length-1)*Ke;it<St?oA.current=requestAnimationFrame(Je):oA.current=null};oA.current=requestAnimationFrame(Je)}else VA();for(const pe of ke)BA.current.add(pe);for(const{edge:pe}of g){const Ke=_s(pe.certainCount);bA.current.set(pe.key,Ke)}SA.current=we},[c,g,y,x,VA]),j.useEffect(()=>{const oe=iA.current;if(!oe||!W)return;const me=()=>{const be=oe.getSource(W);if(!be)return!1;if(O.length>0){const ke=so(O,V);be.setData(ke)}else be.setData({type:"FeatureCollection",features:[]});return!0};if(me())return;const we=be=>{be.sourceId===W&&me()&&oe.off("sourcedata",we)};oe.on("sourcedata",we);const $e=()=>{me()&&(oe.off("styledata",$e),oe.off("sourcedata",we))};return oe.on("styledata",$e),()=>{oe.off("sourcedata",we),oe.off("styledata",$e)}},[W,O,V]);const Ie=j.useRef(X);return j.useEffect(()=>{X!==Ie.current&&(Ie.current=X,cA.current="",IA.current="",LA.current="",VA(!0))},[X,VA]),j.useEffect(()=>()=>{oA.current&&(cancelAnimationFrame(oA.current),oA.current=null)},[]),{isExiting:EA.current,isAnimating:oA.current!==null,resetAnimationState:Re,weightAnimProgress:K.current,animStartWeights:hA.current,animTargetWeights:uA.current}}function I1({activeFilters:a,neighborHashes:c,hubConnectedNodes:g,directNodeSet:y,localConnectedNodes:x,nodeTypeMap:k,showTopology:D}){const[P,M]=j.useState(new Map),b=j.useMemo(()=>[...a].sort().join(","),[a]),R=j.useRef(b),O=j.useRef(!1),z=j.useRef(new Map),W=j.useRef(null),V=j.useRef(g),X=j.useRef(y),iA=j.useRef(x),AA=j.useRef(k),K=j.useRef(D);return j.useEffect(()=>{V.current=g,X.current=y,iA.current=x,AA.current=k,K.current=D},[g,y,x,k,D]),j.useEffect(()=>{const uA=R.current,EA=b;if(R.current=b,uA===EA)return;W.current&&(cancelAnimationFrame(W.current),W.current=null);const oA=new Set(uA?uA.split(",").filter(Boolean):[]),lA=a,BA=V.current,SA=X.current,bA=AA.current;for(const vA of c)z.current.has(vA)||z.current.set(vA,Math.random());const cA=(vA,aA)=>{if(aA.size===0)return!1;const dA=bA.get(vA)??"unknown";return!!(aA.has("repeater")&&dA==="repeater"||aA.has("companion")&&(dA==="companion"||dA==="unknown")||aA.has("room_server")&&dA==="room_server"||aA.has("direct")&&SA.has(vA)||aA.has("hubs")&&BA.has(vA))},IA=[];for(const vA of c){const aA=cA(vA,oA),dA=cA(vA,lA);aA!==dA&&IA.push({hash:vA,startOpacity:aA?1:0,targetOpacity:dA?1:0})}if(IA.length===0)return;O.current=!0,M(vA=>{const aA=new Map(vA);for(const{hash:dA,startOpacity:RA}of IA)aA.set(dA,RA);return aA});const LA=IA;let FA=null;const UA=vA=>{FA||(FA=vA);const aA=vA-FA;let dA=!0;M(()=>{const _A=new Map;for(const{hash:YA,startOpacity:ue,targetOpacity:JA}of LA){const KA=(z.current.get(YA)??0)*Ti,VA=Math.max(0,aA-KA),Re=Math.min(VA/_i,1),Ie=Bs(Re),oe=ue+(JA-ue)*Ie;_A.set(YA,oe),Re<1&&(dA=!1)}return _A});const RA=_i+Ti;aA<RA&&!dA?W.current=requestAnimationFrame(UA):(W.current=null,O.current=!1,M(new Map))};return W.current=requestAnimationFrame(UA),()=>{W.current&&(cancelAnimationFrame(W.current),W.current=null),O.current=!1}},[b,a,c]),{nodeOpacities:P,getNodeOpacity:(uA,EA)=>O.current&&P.has(uA)?P.get(uA):EA?1:0}}const ks=240,io=240;function L1(a,c){if(a<ks)return .5;if(a<ks+io)return 1;const g=ks+io,y=c-g,x=(a-g)/y;return Math.max(0,.33*(1-x))}function N1(a){return Ua(Object.keys(a).map(c=>[c,c]))}function F1(a,c,g){const y=g?Er(g):null,x=[];for(const k of a){if(y&&Oo(k.toUpperCase(),y)){g&&x.push(g);continue}const D=c.get(k.toUpperCase());D&&x.push(D)}return x}function P1({neighbors:a,localHash:c,enabled:g=!0}){const[y,x]=j.useState(new Map),k=Ts(),D=j.useRef(k);j.useEffect(()=>{D.current=k},[k]);const P=j.useRef(0),M=j.useRef(null),b=j.useRef(new Map),R=j.useRef(new Map);j.useEffect(()=>{R.current=N1(a)},[a]);const O=j.useRef(null);return j.useEffect(()=>{const z=()=>{const W=performance.now(),V=b.current;if(V.size===0){M.current=null,x(new Map);return}const X=new Map,iA=[];for(const[AA,{startTime:K,staggerDelay:hA}]of V){const uA=W-K-hA;if(!(uA<0))if(uA>=j0)iA.push(AA);else{const EA=L1(uA,j0);EA>0&&X.set(AA,EA)}}for(const AA of iA)V.delete(AA);x(X),V.size>0&&O.current?M.current=requestAnimationFrame(O.current):M.current=null};O.current=z},[]),j.useEffect(()=>{if(!g)return;const z=D.current;if(z.length===0)return;const W=P.current,V=z.filter(K=>(K.timestamp??0)>W);if(W===0){const K=z.reduce((hA,uA)=>Math.max(hA,uA.timestamp??0),0);P.current=K;return}if(V.length===0)return;const X=V.reduce((K,hA)=>Math.max(K,hA.timestamp??0),0);P.current=X;const iA=performance.now();let AA=0;for(const K of V){const hA=Qo(K,c);if(!hA||hA.original.length===0)continue;const uA=F1(hA.original,R.current,c);if(uA.length===0)continue;const EA=j0*.5;for(let oA=0;oA<uA.length;oA++){const lA=uA[oA];b.current.has(lA)||b.current.set(lA,{startTime:iA,staggerDelay:AA+oA*EA})}AA+=j0*.3}M.current===null&&O.current&&(M.current=requestAnimationFrame(O.current))},[k,c,g]),j.useEffect(()=>()=>{M.current!==null&&(cancelAnimationFrame(M.current),M.current=null)},[]),{blinkingNodes:y,blinkColor:Pc}}const en="edge-blink-source",kn="edge-blink-layer",Ns=1e3,Fs=1e3,Cs=150,Q1=175,O1=3e4,z1=lr.teal,H1="#8B7BAD",G1=2.5,U1=1.875,V1=.5,K0="node-markers-layer";function W1(a){if(!a.getLayer(kn))return;const c=a.getLayer(K0)?K0:void 0;try{a.moveLayer(kn,c)}catch{}}function Y1(a,c){const g=new Map;for(const y of Object.keys(a)){const x=Er(y);g.has(x)||g.set(x,y)}if(c){const y=Er(c);g.set(y,c)}return g}function $1(a){return a<0||a>=Ns?0:1-a/Ns}function K1(a){if(a<0||a>=Fs)return 0;const c=a/Fs;return Math.pow(1-c,3)}function z0(a){return[a[1],a[0]]}function Z1({map:a,nodeCoordinates:c,packets:g,localHash:y,neighbors:x,meshTopology:k,enabled:D=!0}){const P=j.useRef(null),M=a&&"current"in a?a.current:a;j.useEffect(()=>{P.current=M},[M]);const b=j.useRef(!1),R=j.useRef(null),O=j.useRef([]),z=j.useRef(0),W=j.useRef(!1),[V,X]=j.useState(!1),iA=j.useRef(null),AA=j.useRef([]),K=j.useRef(new Map),hA=j.useRef(c);j.useEffect(()=>{hA.current=c},[c]),j.useEffect(()=>{K.current=Y1(x,y)},[x,y]),j.useEffect(()=>{if(!D){iA.current&&(clearTimeout(iA.current),iA.current=null),AA.current=[],R.current!==null&&(cancelAnimationFrame(R.current),R.current=null),O.current=[];const lA=P.current;if(lA&&b.current){const BA=lA.getSource(en);BA&&BA.setData({type:"FeatureCollection",features:[]})}W.current=!1,z.current=0}},[D]),j.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(en)&&lA.removeSource(en),lA.addSource(en,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const cA=lA.getLayer(K0)?K0:void 0;lA.addLayer({id:kn,type:"line",source:en,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]]}},cA),b.current=!0,X(!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),R.current!==null&&(cancelAnimationFrame(R.current),R.current=null);const cA=P.current;if(cA&&b.current){try{cA.getLayer(kn)&&cA.removeLayer(kn),cA.getSource(en)&&cA.removeSource(en)}catch{}b.current=!1,X(!1)}}},[M]);const uA=j.useRef(()=>{});j.useEffect(()=>{uA.current=()=>{const lA=P.current;if(!lA)return;const BA=lA.getSource(en);if(!BA)return;const SA=performance.now(),bA=O.current,cA=[],IA=[];for(const LA of bA){const FA=SA-LA.startTime-LA.delay,UA=LA.isSpeculative?Fs:Ns;if(FA<UA){IA.push(LA);const vA=LA.isSpeculative?K1(FA):$1(FA);vA>0&&cA.push({type:"Feature",properties:{intensity:vA,opacityMult:LA.isSpeculative?V1:1,isSpeculative:LA.isSpeculative??!1},geometry:{type:"LineString",coordinates:[LA.fromCoord,LA.toCoord]}})}}BA.setData({type:"FeatureCollection",features:cA}),O.current=IA,IA.length>0?R.current=requestAnimationFrame(()=>uA.current()):R.current=null}},[]);const EA=j.useCallback(()=>{const lA=P.current;lA&&W1(lA),R.current===null&&(R.current=requestAnimationFrame(()=>uA.current()))},[]),oA=j.useCallback(()=>{if(!P.current||!b.current)return;const BA=AA.current;if(AA.current=[],iA.current=null,BA.length===0)return;const SA=K.current,bA=hA.current;if(SA.size===0)return;const cA=performance.now();let IA=0,LA=!1;const FA=new Set;for(const UA of BA){const vA=Qo(UA,y);if(!vA||vA.original.length<2)continue;const aA=vA.original;let dA=0,RA=null;for(let JA=0;JA<aA.length-1;JA++){const KA=aA[JA].toUpperCase(),VA=aA[JA+1].toUpperCase(),Re=SA.get(KA),Ie=SA.get(VA);if(!Re||!Ie)continue;const oe=bA.get(Re),me=bA.get(Ie);if(!oe||!me)continue;const we=[Re,Ie].sort().join("-");O.current.push({edgeKey:we,fromCoord:z0(oe),toCoord:z0(me),startTime:cA,delay:IA+dA*Cs}),FA.add(we),RA=Ie,dA++,LA=!0}const _A=UA.route??UA.route_type;if(Va(_A)&&RA&&!(RA===y)&&(k!=null&&k.edgeMap)){const JA=[];for(const[KA,VA]of k.edgeMap){if(!(VA.fromHash===RA||VA.toHash===RA)||FA.has(KA))continue;const Ie=VA.fromHash===RA?VA.toHash:VA.fromHash,oe=bA.get(RA),me=bA.get(Ie);!oe||!me||JA.push({edgeKey:KA,otherHash:Ie,confidence:VA.avgConfidence??0})}if(JA.length>0){JA.sort((Ie,oe)=>oe.confidence-Ie.confidence);const KA=Math.max(1,Math.ceil(JA.length*.25)),VA=JA.slice(0,KA),Re=IA+dA*Cs;for(const{edgeKey:Ie,otherHash:oe}of VA){const me=bA.get(RA),we=bA.get(oe);O.current.push({edgeKey:Ie,fromCoord:z0(me),toCoord:z0(we),startTime:cA,delay:Re,isSpeculative:!0}),FA.add(Ie),LA=!0}}}dA>0&&(IA+=dA*Cs*.5)}LA&&EA()},[y,k,EA]);j.useEffect(()=>{const lA=P.current;if(!D||!lA||!V||g.length===0)return;const BA=Date.now(),SA=z.current;if(!W.current){W.current=!0;const IA=(BA-O1)/1e3,LA=g.filter(UA=>(UA.timestamp??0)>=IA);let FA=0;for(const UA of g){const vA=UA.timestamp??0;vA>FA&&(FA=vA)}if(z.current=FA,LA.length>0){LA.sort((vA,aA)=>(vA.timestamp??0)-(aA.timestamp??0));const UA=LA.slice(-20);AA.current.push(...UA),oA()}return}const bA=g.filter(IA=>(IA.timestamp??0)>SA);if(bA.length===0)return;let cA=0;for(const IA of bA){const LA=IA.timestamp??0;LA>cA&&(cA=LA)}z.current=cA,AA.current.push(...bA),iA.current&&clearTimeout(iA.current),iA.current=setTimeout(oA,Q1)},[D,g,oA,V]),j.useEffect(()=>()=>{iA.current&&clearTimeout(iA.current)},[])}var tn={},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 oo;function q1(){if(oo)return wn;oo=1;var a=zo();function c(h){for(var v="https://reactjs.org/docs/error-decoder.html?invariant="+h,T=1;T<arguments.length;T++)v+="&args[]="+encodeURIComponent(arguments[T]);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 P(h,v,T,Q,J,$,fA){this.acceptsBooleans=v===2||v===3||v===4,this.attributeName=Q,this.attributeNamespace=J,this.mustUseProperty=T,this.propertyName=h,this.type=v,this.sanitizeURL=$,this.removeEmptyString=fA}var M={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(h){M[h]=new P(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 P(v,1,!1,h[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(h){M[h]=new P(h,2,!1,h.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(h){M[h]=new P(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 P(h,3,!1,h.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(h){M[h]=new P(h,3,!0,h,null,!1,!1)}),["capture","download"].forEach(function(h){M[h]=new P(h,4,!1,h,null,!1,!1)}),["cols","rows","size","span"].forEach(function(h){M[h]=new P(h,6,!1,h,null,!1,!1)}),["rowSpan","start"].forEach(function(h){M[h]=new P(h,5,!1,h.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function R(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,R);M[v]=new P(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,R);M[v]=new P(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,R);M[v]=new P(v,1,!1,h,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(h){M[h]=new P(h,1,!1,h.toLowerCase(),null,!1,!1)}),M.xlinkHref=new P("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(h){M[h]=new P(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 T="",Q,J=0;for(Q=v.index;Q<h.length;Q++){switch(h.charCodeAt(Q)){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}J!==Q&&(T+=h.substring(J,Q)),J=Q+1,T+=v}h=J!==Q?T+h.substring(J,Q):T}return h}var X=/([A-Z])/g,iA=/^ms-/,AA=Array.isArray;function K(h,v){return{insertionMode:h,selectedValue:v}}function hA(h,v,T){switch(v){case"select":return K(1,T.value!=null?T.value:T.defaultValue);case"svg":return K(2,null);case"math":return K(3,null);case"foreignObject":return K(1,null);case"table":return K(4,null);case"thead":case"tbody":case"tfoot":return K(5,null);case"colgroup":return K(7,null);case"tr":return K(6,null)}return 4<=h.insertionMode||h.insertionMode===0?K(1,null):h}var uA=new Map;function EA(h,v,T){if(typeof T!="object")throw Error(c(62));v=!0;for(var Q in T)if(g.call(T,Q)){var J=T[Q];if(J!=null&&typeof J!="boolean"&&J!==""){if(Q.indexOf("--")===0){var $=V(Q);J=V((""+J).trim())}else{$=Q;var fA=uA.get($);fA!==void 0||(fA=V($.replace(X,"-$1").toLowerCase().replace(iA,"-ms-")),uA.set($,fA)),$=fA,J=typeof J=="number"?J===0||g.call(O,Q)?""+J:J+"px":V((""+J).trim())}v?(v=!1,h.push(' style="',$,":",J)):h.push(";",$,":",J)}}v||h.push('"')}function oA(h,v,T,Q){switch(T){case"style":EA(h,v,Q);return;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<T.length)||T[0]!=="o"&&T[0]!=="O"||T[1]!=="n"&&T[1]!=="N"){if(v=M.hasOwnProperty(T)?M[T]:null,v!==null){switch(typeof Q){case"function":case"symbol":return;case"boolean":if(!v.acceptsBooleans)return}switch(T=v.attributeName,v.type){case 3:Q&&h.push(" ",T,'=""');break;case 4:Q===!0?h.push(" ",T,'=""'):Q!==!1&&h.push(" ",T,'="',V(Q),'"');break;case 5:isNaN(Q)||h.push(" ",T,'="',V(Q),'"');break;case 6:!isNaN(Q)&&1<=Q&&h.push(" ",T,'="',V(Q),'"');break;default:v.sanitizeURL&&(Q=""+Q),h.push(" ",T,'="',V(Q),'"')}}else if(D(T)){switch(typeof Q){case"function":case"symbol":return;case"boolean":if(v=T.toLowerCase().slice(0,5),v!=="data-"&&v!=="aria-")return}h.push(" ",T,'="',V(Q),'"')}}}function lA(h,v,T){if(v!=null){if(T!=null)throw Error(c(60));if(typeof v!="object"||!("__html"in v))throw Error(c(61));v=v.__html,v!=null&&h.push(""+v)}}function BA(h){var v="";return a.Children.forEach(h,function(T){T!=null&&(v+=T)}),v}function SA(h,v,T,Q){h.push(IA(T));var J=T=null,$;for($ in v)if(g.call(v,$)){var fA=v[$];if(fA!=null)switch($){case"children":T=fA;break;case"dangerouslySetInnerHTML":J=fA;break;default:oA(h,Q,$,fA)}}return h.push(">"),lA(h,J,T),typeof T=="string"?(h.push(V(T)),null):T}var bA=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,cA=new Map;function IA(h){var v=cA.get(h);if(v===void 0){if(!bA.test(h))throw Error(c(65,h));v="<"+h,cA.set(h,v)}return v}function LA(h,v,T,Q,J){switch(v){case"select":h.push(IA("select"));var $=null,fA=null;for(fe in T)if(g.call(T,fe)){var TA=T[fe];if(TA!=null)switch(fe){case"children":$=TA;break;case"dangerouslySetInnerHTML":fA=TA;break;case"defaultValue":case"value":break;default:oA(h,Q,fe,TA)}}return h.push(">"),lA(h,fA,$),$;case"option":fA=J.selectedValue,h.push(IA("option"));var XA=TA=null,qA=null,fe=null;for($ in T)if(g.call(T,$)){var Ne=T[$];if(Ne!=null)switch($){case"children":TA=Ne;break;case"selected":qA=Ne;break;case"dangerouslySetInnerHTML":fe=Ne;break;case"value":XA=Ne;default:oA(h,Q,$,Ne)}}if(fA!=null)if(T=XA!==null?""+XA:BA(TA),AA(fA)){for(Q=0;Q<fA.length;Q++)if(""+fA[Q]===T){h.push(' selected=""');break}}else""+fA===T&&h.push(' selected=""');else qA&&h.push(' selected=""');return h.push(">"),lA(h,fe,TA),TA;case"textarea":h.push(IA("textarea")),fe=fA=$=null;for(TA in T)if(g.call(T,TA)&&(XA=T[TA],XA!=null))switch(TA){case"children":fe=XA;break;case"value":$=XA;break;case"defaultValue":fA=XA;break;case"dangerouslySetInnerHTML":throw Error(c(91));default:oA(h,Q,TA,XA)}if($===null&&fA!==null&&($=fA),h.push(">"),fe!=null){if($!=null)throw Error(c(92));if(AA(fe)&&1<fe.length)throw Error(c(93));$=""+fe}return typeof $=="string"&&$[0]===`
`&&h.push(`
`),$!==null&&h.push(V(""+$)),null;case"input":h.push(IA("input")),XA=fe=TA=$=null;for(fA in T)if(g.call(T,fA)&&(qA=T[fA],qA!=null))switch(fA){case"children":case"dangerouslySetInnerHTML":throw Error(c(399,"input"));case"defaultChecked":XA=qA;break;case"defaultValue":TA=qA;break;case"checked":fe=qA;break;case"value":$=qA;break;default:oA(h,Q,fA,qA)}return fe!==null?oA(h,Q,"checked",fe):XA!==null&&oA(h,Q,"checked",XA),$!==null?oA(h,Q,"value",$):TA!==null&&oA(h,Q,"value",TA),h.push("/>"),null;case"menuitem":h.push(IA("menuitem"));for(var Bt in T)if(g.call(T,Bt)&&($=T[Bt],$!=null))switch(Bt){case"children":case"dangerouslySetInnerHTML":throw Error(c(400));default:oA(h,Q,Bt,$)}return h.push(">"),null;case"title":h.push(IA("title")),$=null;for(Ne in T)if(g.call(T,Ne)&&(fA=T[Ne],fA!=null))switch(Ne){case"children":$=fA;break;case"dangerouslySetInnerHTML":throw Error(c(434));default:oA(h,Q,Ne,fA)}return h.push(">"),$;case"listing":case"pre":h.push(IA(v)),fA=$=null;for(XA in T)if(g.call(T,XA)&&(TA=T[XA],TA!=null))switch(XA){case"children":$=TA;break;case"dangerouslySetInnerHTML":fA=TA;break;default:oA(h,Q,XA,TA)}if(h.push(">"),fA!=null){if($!=null)throw Error(c(60));if(typeof fA!="object"||!("__html"in fA))throw Error(c(61));T=fA.__html,T!=null&&(typeof T=="string"&&0<T.length&&T[0]===`
`?h.push(`
`,T):h.push(""+T))}return typeof $=="string"&&$[0]===`
`&&h.push(`
`),$;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(IA(v));for(var rt in T)if(g.call(T,rt)&&($=T[rt],$!=null))switch(rt){case"children":case"dangerouslySetInnerHTML":throw Error(c(399,v));default:oA(h,Q,rt,$)}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,T,v,Q);case"html":return J.insertionMode===0&&h.push("<!DOCTYPE html>"),SA(h,T,v,Q);default:if(v.indexOf("-")===-1&&typeof T.is!="string")return SA(h,T,v,Q);h.push(IA(v)),fA=$=null;for(qA in T)if(g.call(T,qA)&&(TA=T[qA],TA!=null))switch(qA){case"children":$=TA;break;case"dangerouslySetInnerHTML":fA=TA;break;case"style":EA(h,Q,TA);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:D(qA)&&typeof TA!="function"&&typeof TA!="symbol"&&h.push(" ",qA,'="',V(TA),'"')}return h.push(">"),lA(h,fA,$),$}}function FA(h,v,T){if(h.push('<!--$?--><template id="'),T===null)throw Error(c(395));return h.push(T),h.push('"></template>')}function UA(h,v,T,Q){switch(T.insertionMode){case 0:case 1:return h.push('<div hidden id="'),h.push(v.segmentPrefix),v=Q.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=Q.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=Q.toString(16),h.push(v),h.push('">');case 4:return h.push('<table hidden id="'),h.push(v.segmentPrefix),v=Q.toString(16),h.push(v),h.push('">');case 5:return h.push('<table hidden><tbody id="'),h.push(v.segmentPrefix),v=Q.toString(16),h.push(v),h.push('">');case 6:return h.push('<table hidden><tr id="'),h.push(v.segmentPrefix),v=Q.toString(16),h.push(v),h.push('">');case 7:return h.push('<table hidden><colgroup id="'),h.push(v.segmentPrefix),v=Q.toString(16),h.push(v),h.push('">');default:throw Error(c(397))}}function vA(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(c(397))}}var aA=/[<\u2028\u2029]/g;function dA(h){return JSON.stringify(h).replace(aA,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 RA(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 _A(h,v,T,Q){return T.generateStaticMarkup?(h.push(V(v)),!1):(v===""?h=Q:(Q&&h.push("<!-- -->"),h.push(V(v)),h=!0),h)}var YA=Object.assign,ue=Symbol.for("react.element"),JA=Symbol.for("react.portal"),KA=Symbol.for("react.fragment"),VA=Symbol.for("react.strict_mode"),Re=Symbol.for("react.profiler"),Ie=Symbol.for("react.provider"),oe=Symbol.for("react.context"),me=Symbol.for("react.forward_ref"),we=Symbol.for("react.suspense"),$e=Symbol.for("react.suspense_list"),be=Symbol.for("react.memo"),ke=Symbol.for("react.lazy"),Se=Symbol.for("react.scope"),pe=Symbol.for("react.debug_trace_mode"),Ke=Symbol.for("react.legacy_hidden"),Je=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 JA:return"Portal";case Re:return"Profiler";case VA:return"StrictMode";case we:return"Suspense";case $e:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case oe:return(h.displayName||"Context")+".Consumer";case Ie:return(h._context.displayName||"Context")+".Provider";case me:var v=h.render;return h=h.displayName,h||(h=v.displayName||v.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case be:return v=h.displayName||null,v!==null?v:it(h.type)||"Memo";case ke:v=h._payload,h=h._init;try{return it(h(v))}catch{}}return null}var St={};function Qe(h,v){if(h=h.contextTypes,!h)return St;var T={},Q;for(Q in h)T[Q]=v[Q];return T}var Xe=null;function Me(h,v){if(h!==v){h.context._currentValue2=h.parentValue,h=h.parent;var T=v.parent;if(h===null){if(T!==null)throw Error(c(401))}else{if(T===null)throw Error(c(401));Me(h,T)}v.context._currentValue2=v.value}}function ze(h){h.context._currentValue2=h.parentValue,h=h.parent,h!==null&&ze(h)}function ct(h){var v=h.parent;v!==null&&ct(v),h.context._currentValue2=h.value}function Pt(h,v){if(h.context._currentValue2=h.parentValue,h=h.parent,h===null)throw Error(c(402));h.depth===v.depth?Me(h,v):Pt(h,v)}function Br(h,v){var T=v.parent;if(T===null)throw Error(c(402));h.depth===T.depth?Me(h,T):Br(h,T),v.context._currentValue2=v.value}function Xt(h){var v=Xe;v!==h&&(v===null?ct(h):h===null?ze(v):v.depth===h.depth?Me(v,h):v.depth>h.depth?Pt(v,h):Br(v,h),Xe=h)}var Ar={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 zr(h,v,T,Q){var J=h.state!==void 0?h.state:null;h.updater=Ar,h.props=T,h.state=J;var $={queue:[],replace:!1};h._reactInternals=$;var fA=v.contextType;if(h.context=typeof fA=="object"&&fA!==null?fA._currentValue2:Q,fA=v.getDerivedStateFromProps,typeof fA=="function"&&(fA=fA(T,J),J=fA==null?J:YA({},J,fA),h.state=J),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&&Ar.enqueueReplaceState(h,h.state,null),$.queue!==null&&0<$.queue.length)if(v=$.queue,fA=$.replace,$.queue=null,$.replace=!1,fA&&v.length===1)h.state=v[0];else{for($=fA?v[0]:h.state,J=!0,fA=fA?1:0;fA<v.length;fA++){var TA=v[fA];TA=typeof TA=="function"?TA.call(h,$,T,Q):TA,TA!=null&&(J?(J=!1,$=YA({},$,TA)):YA($,TA))}h.state=$}else $.queue=null}var nn={id:1,overflow:""};function Dr(h,v,T){var Q=h.id;h=h.overflow;var J=32-Gt(Q)-1;Q&=~(1<<J),T+=1;var $=32-Gt(v)+J;if(30<$){var fA=J-J%5;return $=(Q&(1<<fA)-1).toString(32),Q>>=fA,J-=fA,{id:1<<32-Gt(v)+J|T<<J|Q,overflow:$+h}}return{id:1<<$|T<<J|Q,overflow:h}}var Gt=Math.clz32?Math.clz32:pr,_r=Math.log,sn=Math.LN2;function pr(h){return h>>>=0,h===0?32:31-(_r(h)/sn|0)|0}function on(h,v){return h===v&&(h!==0||1/h===1/v)||h!==h&&v!==v}var Hr=typeof Object.is=="function"?Object.is:on,gA=null,gr=null,ft=null,Fe=null,ur=!1,qe=!1,kt=0,Mt=null,er=0;function Ct(){if(gA===null)throw Error(c(321));return gA}function Qt(){if(0<er)throw Error(c(312));return{memoizedState:null,queue:null,next:null}}function yt(){return Fe===null?ft===null?(ur=!1,ft=Fe=Qt()):(ur=!0,Fe=ft):Fe.next===null?(ur=!1,Fe=Fe.next=Qt()):(ur=!0,Fe=Fe.next),Fe}function nA(){gr=gA=null,qe=!1,ft=null,er=0,Fe=Mt=null}function yA(h,v){return typeof v=="function"?v(h):v}function jA(h,v,T){if(gA=Ct(),Fe=yt(),ur){var Q=Fe.queue;if(v=Q.dispatch,Mt!==null&&(T=Mt.get(Q),T!==void 0)){Mt.delete(Q),Q=Fe.memoizedState;do Q=h(Q,T.action),T=T.next;while(T!==null);return Fe.memoizedState=Q,[Q,v]}return[Fe.memoizedState,v]}return h=h===yA?typeof v=="function"?v():v:T!==void 0?T(v):v,Fe.memoizedState=h,h=Fe.queue={last:null,dispatch:null},h=h.dispatch=t.bind(null,gA,h),[Fe.memoizedState,h]}function xA(h,v){if(gA=Ct(),Fe=yt(),v=v===void 0?null:v,Fe!==null){var T=Fe.memoizedState;if(T!==null&&v!==null){var Q=T[1];A:if(Q===null)Q=!1;else{for(var J=0;J<Q.length&&J<v.length;J++)if(!Hr(v[J],Q[J])){Q=!1;break A}Q=!0}if(Q)return T[0]}}return h=h(),Fe.memoizedState=[h,v],h}function t(h,v,T){if(25<=er)throw Error(c(301));if(h===gA)if(qe=!0,h={action:T,next:null},Mt===null&&(Mt=new Map),T=Mt.get(v),T===void 0)Mt.set(v,h);else{for(v=T;v.next!==null;)v=v.next;v.next=h}}function C(){throw Error(c(394))}function ge(){}var De={readContext:function(h){return h._currentValue2},useContext:function(h){return Ct(),h._currentValue2},useMemo:xA,useReducer:jA,useRef:function(h){gA=Ct(),Fe=yt();var v=Fe.memoizedState;return v===null?(h={current:h},Fe.memoizedState=h):v},useState:function(h){return jA(yA,h)},useInsertionEffect:ge,useLayoutEffect:function(){},useCallback:function(h,v){return xA(function(){return h},v)},useImperativeHandle:ge,useEffect:ge,useDebugValue:ge,useDeferredValue:function(h){return Ct(),h},useTransition:function(){return Ct(),[!1,C]},useId:function(){var h=gr.treeContext,v=h.overflow;h=h.id,h=(h&~(1<<32-Gt(h)-1)).toString(32)+v;var T=Le;if(T===null)throw Error(c(404));return v=kt++,h=":"+T.idPrefix+"R"+h,0<v&&(h+="H"+v.toString(32)),h+":"},useMutableSource:function(h,v){return Ct(),v(h._source)},useSyncExternalStore:function(h,v,T){if(T===void 0)throw Error(c(407));return T()}},Le=null,ee=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function Ce(h){return console.error(h),null}function Ge(){}function Be(h,v,T,Q,J,$,fA,TA,XA){var qA=[],fe=new Set;return v={destination:null,responseState:v,progressiveChunkSize:Q===void 0?12800:Q,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:fe,pingedTasks:qA,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:J===void 0?Ce:J,onAllReady:Ge,onShellReady:fA===void 0?Ge:fA,onShellError:Ge,onFatalError:Ge},T=et(v,0,null,T,!1,!1),T.parentFlushed=!0,h=se(v,h,null,T,fe,St,null,nn),qA.push(h),v}function se(h,v,T,Q,J,$,fA,TA){h.allPendingTasks++,T===null?h.pendingRootTasks++:T.pendingTasks++;var XA={node:v,ping:function(){var qA=h.pingedTasks;qA.push(XA),qA.length===1&&yr(h)},blockedBoundary:T,blockedSegment:Q,abortSet:J,legacyContext:$,context:fA,treeContext:TA};return J.add(XA),XA}function et(h,v,T,Q,J,$){return{status:0,id:-1,index:v,parentFlushed:!1,chunks:[],children:[],formatContext:Q,boundary:T,lastPushedText:J,textEmbedded:$}}function Et(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 xt(h,v){var T=h.onShellError;T(v),T=h.onFatalError,T(v),h.destination!==null?(h.status=2,h.destination.destroy(v)):(h.status=1,h.fatalError=v)}function Ut(h,v,T,Q,J){for(gA={},gr=v,kt=0,h=T(Q,J);qe;)qe=!1,kt=0,er+=1,Fe=null,h=T(Q,J);return nA(),h}function at(h,v,T,Q){var J=T.render(),$=Q.childContextTypes;if($!=null){var fA=v.legacyContext;if(typeof T.getChildContext!="function")Q=fA;else{T=T.getChildContext();for(var TA in T)if(!(TA in $))throw Error(c(108,it(Q)||"Unknown",TA));Q=YA({},fA,T)}v.legacyContext=Q,tt(h,v,J),v.legacyContext=fA}else tt(h,v,J)}function Vt(h,v){if(h&&h.defaultProps){v=YA({},v),h=h.defaultProps;for(var T in h)v[T]===void 0&&(v[T]=h[T]);return v}return v}function ht(h,v,T,Q,J){if(typeof T=="function")if(T.prototype&&T.prototype.isReactComponent){J=Qe(T,v.legacyContext);var $=T.contextType;$=new T(Q,typeof $=="object"&&$!==null?$._currentValue2:J),zr($,T,Q,J),at(h,v,$,T)}else{$=Qe(T,v.legacyContext),J=Ut(h,v,T,Q,$);var fA=kt!==0;if(typeof J=="object"&&J!==null&&typeof J.render=="function"&&J.$$typeof===void 0)zr(J,T,Q,$),at(h,v,J,T);else if(fA){Q=v.treeContext,v.treeContext=Dr(Q,1,0);try{tt(h,v,J)}finally{v.treeContext=Q}}else tt(h,v,J)}else if(typeof T=="string"){switch(J=v.blockedSegment,$=LA(J.chunks,T,Q,h.responseState,J.formatContext),J.lastPushedText=!1,fA=J.formatContext,J.formatContext=hA(fA,T,Q),wt(h,v,$),J.formatContext=fA,T){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:J.chunks.push("</",T,">")}J.lastPushedText=!1}else{switch(T){case Ke:case pe:case VA:case Re:case KA:tt(h,v,Q.children);return;case $e:tt(h,v,Q.children);return;case Se:throw Error(c(343));case we:A:{T=v.blockedBoundary,J=v.blockedSegment,$=Q.fallback,Q=Q.children,fA=new Set;var TA={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:fA,errorDigest:null},XA=et(h,J.chunks.length,TA,J.formatContext,!1,!1);J.children.push(XA),J.lastPushedText=!1;var qA=et(h,0,null,J.formatContext,!1,!1);qA.parentFlushed=!0,v.blockedBoundary=TA,v.blockedSegment=qA;try{if(wt(h,v,Q),h.responseState.generateStaticMarkup||qA.lastPushedText&&qA.textEmbedded&&qA.chunks.push("<!-- -->"),qA.status=1,OA(TA,qA),TA.pendingTasks===0)break A}catch(fe){qA.status=4,TA.forceClientRender=!0,TA.errorDigest=Et(h,fe)}finally{v.blockedBoundary=T,v.blockedSegment=J}v=se(h,$,T,XA,fA,v.legacyContext,v.context,v.treeContext),h.pingedTasks.push(v)}return}if(typeof T=="object"&&T!==null)switch(T.$$typeof){case me:if(Q=Ut(h,v,T.render,Q,J),kt!==0){T=v.treeContext,v.treeContext=Dr(T,1,0);try{tt(h,v,Q)}finally{v.treeContext=T}}else tt(h,v,Q);return;case be:T=T.type,Q=Vt(T,Q),ht(h,v,T,Q,J);return;case Ie:if(J=Q.children,T=T._context,Q=Q.value,$=T._currentValue2,T._currentValue2=Q,fA=Xe,Xe=Q={parent:fA,depth:fA===null?0:fA.depth+1,context:T,parentValue:$,value:Q},v.context=Q,tt(h,v,J),h=Xe,h===null)throw Error(c(403));Q=h.parentValue,h.context._currentValue2=Q===Je?h.context._defaultValue:Q,h=Xe=h.parent,v.context=h;return;case oe:Q=Q.children,Q=Q(T._currentValue2),tt(h,v,Q);return;case ke:J=T._init,T=J(T._payload),Q=Vt(T,Q),ht(h,v,T,Q,void 0);return}throw Error(c(130,T==null?T:typeof T,""))}}function tt(h,v,T){if(v.node=T,typeof T=="object"&&T!==null){switch(T.$$typeof){case ue:ht(h,v,T.type,T.props,T.ref);return;case JA:throw Error(c(257));case ke:var Q=T._init;T=Q(T._payload),tt(h,v,T);return}if(AA(T)){Gr(h,v,T);return}if(T===null||typeof T!="object"?Q=null:(Q=At&&T[At]||T["@@iterator"],Q=typeof Q=="function"?Q:null),Q&&(Q=Q.call(T))){if(T=Q.next(),!T.done){var J=[];do J.push(T.value),T=Q.next();while(!T.done);Gr(h,v,J)}return}throw h=Object.prototype.toString.call(T),Error(c(31,h==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":h))}typeof T=="string"?(Q=v.blockedSegment,Q.lastPushedText=_A(v.blockedSegment.chunks,T,h.responseState,Q.lastPushedText)):typeof T=="number"&&(Q=v.blockedSegment,Q.lastPushedText=_A(v.blockedSegment.chunks,""+T,h.responseState,Q.lastPushedText))}function Gr(h,v,T){for(var Q=T.length,J=0;J<Q;J++){var $=v.treeContext;v.treeContext=Dr($,Q,J);try{wt(h,v,T[J])}finally{v.treeContext=$}}}function wt(h,v,T){var Q=v.blockedSegment.formatContext,J=v.legacyContext,$=v.context;try{return tt(h,v,T)}catch(XA){if(nA(),typeof XA=="object"&&XA!==null&&typeof XA.then=="function"){T=XA;var fA=v.blockedSegment,TA=et(h,fA.chunks.length,null,fA.formatContext,fA.lastPushedText,!0);fA.children.push(TA),fA.lastPushedText=!1,h=se(h,v.node,v.blockedBoundary,TA,v.abortSet,v.legacyContext,v.context,v.treeContext).ping,T.then(h,h),v.blockedSegment.formatContext=Q,v.legacyContext=J,v.context=$,Xt($)}else throw v.blockedSegment.formatContext=Q,v.legacyContext=J,v.context=$,Xt($),XA}}function WA(h){var v=h.blockedBoundary;h=h.blockedSegment,h.status=3,Ue(this,v,h)}function S(h,v,T){var Q=h.blockedBoundary;h.blockedSegment.status=3,Q===null?(v.allPendingTasks--,v.status!==2&&(v.status=2,v.destination!==null&&v.destination.push(null))):(Q.pendingTasks--,Q.forceClientRender||(Q.forceClientRender=!0,h=T===void 0?Error(c(432)):T,Q.errorDigest=v.onError(h),Q.parentFlushed&&v.clientRenderedBoundaries.push(Q)),Q.fallbackAbortableTasks.forEach(function(J){return S(J,v,T)}),Q.fallbackAbortableTasks.clear(),v.allPendingTasks--,v.allPendingTasks===0&&(Q=v.onAllReady,Q()))}function OA(h,v){if(v.chunks.length===0&&v.children.length===1&&v.children[0].boundary===null){var T=v.children[0];T.id=v.id,T.parentFlushed=!0,T.status===1&&OA(h,T)}else h.completedSegments.push(v)}function Ue(h,v,T){if(v===null){if(T.parentFlushed){if(h.completedRootSegment!==null)throw Error(c(389));h.completedRootSegment=T}h.pendingRootTasks--,h.pendingRootTasks===0&&(h.onShellError=Ge,v=h.onShellReady,v())}else v.pendingTasks--,v.forceClientRender||(v.pendingTasks===0?(T.parentFlushed&&T.status===1&&OA(v,T),v.parentFlushed&&h.completedBoundaries.push(v),v.fallbackAbortableTasks.forEach(WA,h),v.fallbackAbortableTasks.clear()):T.parentFlushed&&T.status===1&&(OA(v,T),v.completedSegments.length===1&&v.parentFlushed&&h.partialBoundaries.push(v)));h.allPendingTasks--,h.allPendingTasks===0&&(h=h.onAllReady,h())}function yr(h){if(h.status!==2){var v=Xe,T=ee.current;ee.current=De;var Q=Le;Le=h.responseState;try{var J=h.pingedTasks,$;for($=0;$<J.length;$++){var fA=J[$],TA=h,XA=fA.blockedSegment;if(XA.status===0){Xt(fA.context);try{tt(TA,fA,fA.node),TA.responseState.generateStaticMarkup||XA.lastPushedText&&XA.textEmbedded&&XA.chunks.push("<!-- -->"),fA.abortSet.delete(fA),XA.status=1,Ue(TA,fA.blockedBoundary,XA)}catch(vt){if(nA(),typeof vt=="object"&&vt!==null&&typeof vt.then=="function"){var qA=fA.ping;vt.then(qA,qA)}else{fA.abortSet.delete(fA),XA.status=4;var fe=fA.blockedBoundary,Ne=vt,Bt=Et(TA,Ne);if(fe===null?xt(TA,Ne):(fe.pendingTasks--,fe.forceClientRender||(fe.forceClientRender=!0,fe.errorDigest=Bt,fe.parentFlushed&&TA.clientRenderedBoundaries.push(fe))),TA.allPendingTasks--,TA.allPendingTasks===0){var rt=TA.onAllReady;rt()}}}finally{}}}J.splice(0,$),h.destination!==null&&dr(h,h.destination)}catch(vt){Et(h,vt),xt(h,vt)}finally{Le=Q,ee.current=T,T===De&&Xt(v)}}}function cr(h,v,T){switch(T.parentFlushed=!0,T.status){case 0:var Q=T.id=h.nextSegmentId++;return T.lastPushedText=!1,T.textEmbedded=!1,h=h.responseState,v.push('<template id="'),v.push(h.placeholderPrefix),h=Q.toString(16),v.push(h),v.push('"></template>');case 1:T.status=2;var J=!0;Q=T.chunks;var $=0;T=T.children;for(var fA=0;fA<T.length;fA++){for(J=T[fA];$<J.index;$++)v.push(Q[$]);J=fr(h,v,J)}for(;$<Q.length-1;$++)v.push(Q[$]);return $<Q.length&&(J=v.push(Q[$])),J;default:throw Error(c(390))}}function fr(h,v,T){var Q=T.boundary;if(Q===null)return cr(h,v,T);if(Q.parentFlushed=!0,Q.forceClientRender)return h.responseState.generateStaticMarkup||(Q=Q.errorDigest,v.push("<!--$!-->"),v.push("<template"),Q&&(v.push(' data-dgst="'),Q=V(Q),v.push(Q),v.push('"')),v.push("></template>")),cr(h,v,T),h=h.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),h;if(0<Q.pendingTasks){Q.rootSegmentID=h.nextSegmentId++,0<Q.completedSegments.length&&h.partialBoundaries.push(Q);var J=h.responseState,$=J.nextSuspenseID++;return J=J.boundaryPrefix+$.toString(16),Q=Q.id=J,FA(v,h.responseState,Q),cr(h,v,T),v.push("<!--/$-->")}if(Q.byteSize>h.progressiveChunkSize)return Q.rootSegmentID=h.nextSegmentId++,h.completedBoundaries.push(Q),FA(v,h.responseState,Q.id),cr(h,v,T),v.push("<!--/$-->");if(h.responseState.generateStaticMarkup||v.push("<!--$-->"),T=Q.completedSegments,T.length!==1)throw Error(c(391));return fr(h,v,T[0]),h=h.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),h}function tr(h,v,T){return UA(v,h.responseState,T.formatContext,T.id),fr(h,v,T),vA(v,T.formatContext)}function E(h,v,T){for(var Q=T.completedSegments,J=0;J<Q.length;J++)hr(h,v,T,Q[J]);if(Q.length=0,h=h.responseState,Q=T.id,T=T.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("')),Q===null)throw Error(c(395));return T=T.toString(16),v.push(Q),v.push('","'),v.push(h.segmentPrefix),v.push(T),v.push('")<\/script>')}function hr(h,v,T,Q){if(Q.status===2)return!0;var J=Q.id;if(J===-1){if((Q.id=T.rootSegmentID)===-1)throw Error(c(392));return tr(h,v,Q)}return tr(h,v,Q),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),J=J.toString(16),v.push(J),v.push('","'),v.push(h.placeholderPrefix),v.push(J),v.push('")<\/script>')}function dr(h,v){try{var T=h.completedRootSegment;if(T!==null&&h.pendingRootTasks===0){fr(h,v,T),h.completedRootSegment=null;var Q=h.responseState.bootstrapChunks;for(T=0;T<Q.length-1;T++)v.push(Q[T]);T<Q.length&&v.push(Q[T])}var J=h.clientRenderedBoundaries,$;for($=0;$<J.length;$++){var fA=J[$];Q=v;var TA=h.responseState,XA=fA.id,qA=fA.errorDigest,fe=fA.errorMessage,Ne=fA.errorComponentStack;if(Q.push(TA.startInlineScript),TA.sentClientRenderFunction?Q.push('$RX("'):(TA.sentClientRenderFunction=!0,Q.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(c(395));if(Q.push(XA),Q.push('"'),qA||fe||Ne){Q.push(",");var Bt=dA(qA||"");Q.push(Bt)}if(fe||Ne){Q.push(",");var rt=dA(fe||"");Q.push(rt)}if(Ne){Q.push(",");var vt=dA(Ne);Q.push(vt)}if(!Q.push(")<\/script>")){h.destination=null,$++,J.splice(0,$);return}}J.splice(0,$);var _e=h.completedBoundaries;for($=0;$<_e.length;$++)if(!E(h,v,_e[$])){h.destination=null,$++,_e.splice(0,$);return}_e.splice(0,$);var Dt=h.partialBoundaries;for($=0;$<Dt.length;$++){var xr=Dt[$];A:{J=h,fA=v;var rr=xr.completedSegments;for(TA=0;TA<rr.length;TA++)if(!hr(J,fA,xr,rr[TA])){TA++,rr.splice(0,TA);var Vr=!1;break A}rr.splice(0,TA),Vr=!0}if(!Vr){h.destination=null,$++,Dt.splice(0,$);return}}Dt.splice(0,$);var nr=h.completedBoundaries;for($=0;$<nr.length;$++)if(!E(h,v,nr[$])){h.destination=null,$++,nr.splice(0,$);return}nr.splice(0,$)}finally{h.allPendingTasks===0&&h.pingedTasks.length===0&&h.clientRenderedBoundaries.length===0&&h.completedBoundaries.length===0&&v.push(null)}}function Tr(h,v){try{var T=h.abortableTasks;T.forEach(function(Q){return S(Q,h,v)}),T.clear(),h.destination!==null&&dr(h,h.destination)}catch(Q){Et(h,Q),xt(h,Q)}}function Ur(){}function jr(h,v,T,Q){var J=!1,$=null,fA="",TA={push:function(qA){return qA!==null&&(fA+=qA),!0},destroy:function(qA){J=!0,$=qA}},XA=!1;if(h=Be(h,RA(T,v?v.identifierPrefix:void 0),{insertionMode:1,selectedValue:null},1/0,Ur,void 0,function(){XA=!0}),yr(h),Tr(h,Q),h.status===1)h.status=2,TA.destroy(h.fatalError);else if(h.status!==2&&h.destination===null){h.destination=TA;try{dr(h,TA)}catch(qA){Et(h,qA),xt(h,qA)}}if(J)throw $;if(!XA)throw Error(c(426));return fA}return wn.renderToNodeStream=function(){throw Error(c(207))},wn.renderToStaticMarkup=function(h,v){return jr(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(c(208))},wn.renderToString=function(h,v){return jr(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 H0={};/**
 * @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 lo;function J1(){if(lo)return H0;lo=1;var a=zo();function c(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 P=new TextEncoder;function M(d){return P.encode(d)}function b(d){return P.encode(d)}function R(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 X(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,eA,pA){this.acceptsBooleans=w===2||w===3||w===4,this.attributeName=F,this.attributeNamespace=rA,this.mustUseProperty=_,this.propertyName=d,this.type=w,this.sanitizeURL=eA,this.removeEmptyString=pA}var AA={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(d){AA[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];AA[w]=new iA(w,1,!1,d[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(d){AA[d]=new iA(d,2,!1,d.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(d){AA[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){AA[d]=new iA(d,3,!1,d.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(d){AA[d]=new iA(d,3,!0,d,null,!1,!1)}),["capture","download"].forEach(function(d){AA[d]=new iA(d,4,!1,d,null,!1,!1)}),["cols","rows","size","span"].forEach(function(d){AA[d]=new iA(d,6,!1,d,null,!1,!1)}),["rowSpan","start"].forEach(function(d){AA[d]=new iA(d,5,!1,d.toLowerCase(),null,!1,!1)});var K=/[\-:]([a-z])/g;function hA(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(K,hA);AA[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(K,hA);AA[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(K,hA);AA[w]=new iA(w,1,!1,d,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(d){AA[d]=new iA(d,1,!1,d.toLowerCase(),null,!1,!1)}),AA.xlinkHref=new iA("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(d){AA[d]=new iA(d,1,!1,d.toLowerCase(),null,!0,!0)});var uA={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},EA=["Webkit","ms","Moz","O"];Object.keys(uA).forEach(function(d){EA.forEach(function(w){w=w+d.charAt(0).toUpperCase()+d.substring(1),uA[w]=uA[d]})});var oA=/["'&<>]/;function lA(d){if(typeof d=="boolean"||typeof d=="number")return""+d;d=""+d;var w=oA.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,cA=b("<script>"),IA=b("<\/script>"),LA=b('<script src="'),FA=b('<script type="module" src="'),UA=b('" async=""><\/script>'),vA=/(<\/|<)(s)(cript)/gi;function aA(d,w,_,F){return""+w+(_==="s"?"\\u0073":"\\u0053")+F}function dA(d,w,_,F,rA){d=d===void 0?"":d,w=w===void 0?cA:b('<script nonce="'+lA(w)+'">');var eA=[];if(_!==void 0&&eA.push(w,M((""+_).replace(vA,aA)),IA),F!==void 0)for(_=0;_<F.length;_++)eA.push(LA,M(lA(F[_])),UA);if(rA!==void 0)for(F=0;F<rA.length;F++)eA.push(FA,M(lA(rA[F])),UA);return{bootstrapChunks:eA,startInlineScript:w,placeholderPrefix:b(d+"P:"),segmentPrefix:b(d+"S:"),boundaryPrefix:d+"B:",idPrefix:d,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1}}function RA(d,w){return{insertionMode:d,selectedValue:w}}function _A(d){return RA(d==="http://www.w3.org/2000/svg"?2:d==="http://www.w3.org/1998/Math/MathML"?3:0,null)}function YA(d,w,_){switch(w){case"select":return RA(1,_.value!=null?_.value:_.defaultValue);case"svg":return RA(2,null);case"math":return RA(3,null);case"foreignObject":return RA(1,null);case"table":return RA(4,null);case"thead":case"tbody":case"tfoot":return RA(5,null);case"colgroup":return RA(7,null);case"tr":return RA(6,null)}return 4<=d.insertionMode||d.insertionMode===0?RA(1,null):d}var ue=b("<!-- -->");function JA(d,w,_,F){return w===""?F:(F&&d.push(ue),d.push(M(lA(w))),!0)}var KA=new Map,VA=b(' style="'),Re=b(":"),Ie=b(";");function oe(d,w,_){if(typeof _!="object")throw Error(c(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 eA=M(lA(F));rA=M(lA((""+rA).trim()))}else{eA=F;var pA=KA.get(eA);pA!==void 0||(pA=b(lA(eA.replace(BA,"-$1").toLowerCase().replace(SA,"-ms-"))),KA.set(eA,pA)),eA=pA,rA=typeof rA=="number"?rA===0||O.call(uA,F)?M(""+rA):M(rA+"px"):M(lA((""+rA).trim()))}w?(w=!1,d.push(VA,eA,Re,rA)):d.push(Ie,eA,Re,rA)}}w||d.push($e)}var me=b(" "),we=b('="'),$e=b('"'),be=b('=""');function ke(d,w,_,F){switch(_){case"style":oe(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=AA.hasOwnProperty(_)?AA[_]: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(me,_,be);break;case 4:F===!0?d.push(me,_,be):F!==!1&&d.push(me,_,we,M(lA(F)),$e);break;case 5:isNaN(F)||d.push(me,_,we,M(lA(F)),$e);break;case 6:!isNaN(F)&&1<=F&&d.push(me,_,we,M(lA(F)),$e);break;default:w.sanitizeURL&&(F=""+F),d.push(me,_,we,M(lA(F)),$e)}}else if(X(_)){switch(typeof F){case"function":case"symbol":return;case"boolean":if(w=_.toLowerCase().slice(0,5),w!=="data-"&&w!=="aria-")return}d.push(me,M(_),we,M(lA(F)),$e)}}}var Se=b(">"),pe=b("/>");function Ke(d,w,_){if(w!=null){if(_!=null)throw Error(c(60));if(typeof w!="object"||!("__html"in w))throw Error(c(61));w=w.__html,w!=null&&d.push(M(""+w))}}function Je(d){var w="";return a.Children.forEach(d,function(_){_!=null&&(w+=_)}),w}var At=b(' selected=""');function it(d,w,_,F){d.push(Me(_));var rA=_=null,eA;for(eA in w)if(O.call(w,eA)){var pA=w[eA];if(pA!=null)switch(eA){case"children":_=pA;break;case"dangerouslySetInnerHTML":rA=pA;break;default:ke(d,F,eA,pA)}}return d.push(Se),Ke(d,rA,_),typeof _=="string"?(d.push(M(lA(_))),null):_}var St=b(`
`),Qe=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Xe=new Map;function Me(d){var w=Xe.get(d);if(w===void 0){if(!Qe.test(d))throw Error(c(65,d));w=b("<"+d),Xe.set(d,w)}return w}var ze=b("<!DOCTYPE html>");function ct(d,w,_,F,rA){switch(w){case"select":d.push(Me("select"));var eA=null,pA=null;for(ye in _)if(O.call(_,ye)){var DA=_[ye];if(DA!=null)switch(ye){case"children":eA=DA;break;case"dangerouslySetInnerHTML":pA=DA;break;case"defaultValue":case"value":break;default:ke(d,F,ye,DA)}}return d.push(Se),Ke(d,pA,eA),eA;case"option":pA=rA.selectedValue,d.push(Me("option"));var re=DA=null,ve=null,ye=null;for(eA in _)if(O.call(_,eA)){var Ve=_[eA];if(Ve!=null)switch(eA){case"children":DA=Ve;break;case"selected":ve=Ve;break;case"dangerouslySetInnerHTML":ye=Ve;break;case"value":re=Ve;default:ke(d,F,eA,Ve)}}if(pA!=null)if(_=re!==null?""+re:Je(DA),bA(pA)){for(F=0;F<pA.length;F++)if(""+pA[F]===_){d.push(At);break}}else""+pA===_&&d.push(At);else ve&&d.push(At);return d.push(Se),Ke(d,ye,DA),DA;case"textarea":d.push(Me("textarea")),ye=pA=eA=null;for(DA in _)if(O.call(_,DA)&&(re=_[DA],re!=null))switch(DA){case"children":ye=re;break;case"value":eA=re;break;case"defaultValue":pA=re;break;case"dangerouslySetInnerHTML":throw Error(c(91));default:ke(d,F,DA,re)}if(eA===null&&pA!==null&&(eA=pA),d.push(Se),ye!=null){if(eA!=null)throw Error(c(92));if(bA(ye)&&1<ye.length)throw Error(c(93));eA=""+ye}return typeof eA=="string"&&eA[0]===`
`&&d.push(St),eA!==null&&d.push(M(lA(""+eA))),null;case"input":d.push(Me("input")),re=ye=DA=eA=null;for(pA in _)if(O.call(_,pA)&&(ve=_[pA],ve!=null))switch(pA){case"children":case"dangerouslySetInnerHTML":throw Error(c(399,"input"));case"defaultChecked":re=ve;break;case"defaultValue":DA=ve;break;case"checked":ye=ve;break;case"value":eA=ve;break;default:ke(d,F,pA,ve)}return ye!==null?ke(d,F,"checked",ye):re!==null&&ke(d,F,"checked",re),eA!==null?ke(d,F,"value",eA):DA!==null&&ke(d,F,"value",DA),d.push(pe),null;case"menuitem":d.push(Me("menuitem"));for(var jt in _)if(O.call(_,jt)&&(eA=_[jt],eA!=null))switch(jt){case"children":case"dangerouslySetInnerHTML":throw Error(c(400));default:ke(d,F,jt,eA)}return d.push(Se),null;case"title":d.push(Me("title")),eA=null;for(Ve in _)if(O.call(_,Ve)&&(pA=_[Ve],pA!=null))switch(Ve){case"children":eA=pA;break;case"dangerouslySetInnerHTML":throw Error(c(434));default:ke(d,F,Ve,pA)}return d.push(Se),eA;case"listing":case"pre":d.push(Me(w)),pA=eA=null;for(re in _)if(O.call(_,re)&&(DA=_[re],DA!=null))switch(re){case"children":eA=DA;break;case"dangerouslySetInnerHTML":pA=DA;break;default:ke(d,F,re,DA)}if(d.push(Se),pA!=null){if(eA!=null)throw Error(c(60));if(typeof pA!="object"||!("__html"in pA))throw Error(c(61));_=pA.__html,_!=null&&(typeof _=="string"&&0<_.length&&_[0]===`
`?d.push(St,M(_)):d.push(M(""+_)))}return typeof eA=="string"&&eA[0]===`
`&&d.push(St),eA;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(Me(w));for(var Rt in _)if(O.call(_,Rt)&&(eA=_[Rt],eA!=null))switch(Rt){case"children":case"dangerouslySetInnerHTML":throw Error(c(399,w));default:ke(d,F,Rt,eA)}return d.push(pe),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(Me(w)),pA=eA=null;for(ve in _)if(O.call(_,ve)&&(DA=_[ve],DA!=null))switch(ve){case"children":eA=DA;break;case"dangerouslySetInnerHTML":pA=DA;break;case"style":oe(d,F,DA);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:X(ve)&&typeof DA!="function"&&typeof DA!="symbol"&&d.push(me,M(ve),we,M(lA(DA)),$e)}return d.push(Se),Ke(d,pA,eA),eA}}var Pt=b("</"),Br=b(">"),Xt=b('<template id="'),Ar=b('"></template>'),zr=b("<!--$-->"),nn=b('<!--$?--><template id="'),Dr=b('"></template>'),Gt=b("<!--$!-->"),_r=b("<!--/$-->"),sn=b("<template"),pr=b('"'),on=b(' data-dgst="');b(' data-msg="'),b(' data-stck="');var Hr=b("></template>");function gA(d,w,_){if(x(d,nn),_===null)throw Error(c(395));return x(d,_),k(d,Dr)}var gr=b('<div hidden id="'),ft=b('">'),Fe=b("</div>"),ur=b('<svg aria-hidden="true" style="display:none" id="'),qe=b('">'),kt=b("</svg>"),Mt=b('<math aria-hidden="true" style="display:none" id="'),er=b('">'),Ct=b("</math>"),Qt=b('<table hidden id="'),yt=b('">'),nA=b("</table>"),yA=b('<table hidden><tbody id="'),jA=b('">'),xA=b("</tbody></table>"),t=b('<table hidden><tr id="'),C=b('">'),ge=b("</tr></table>"),De=b('<table hidden><colgroup id="'),Le=b('">'),ee=b("</colgroup></table>");function Ce(d,w,_,F){switch(_.insertionMode){case 0:case 1:return x(d,gr),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,ft);case 2:return x(d,ur),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,qe);case 3:return x(d,Mt),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,er);case 4:return x(d,Qt),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,yt);case 5:return x(d,yA),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,jA);case 6:return x(d,t),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,C);case 7:return x(d,De),x(d,w.segmentPrefix),x(d,M(F.toString(16))),k(d,Le);default:throw Error(c(397))}}function Ge(d,w){switch(w.insertionMode){case 0:case 1:return k(d,Fe);case 2:return k(d,kt);case 3:return k(d,Ct);case 4:return k(d,nA);case 5:return k(d,xA);case 6:return k(d,ge);case 7:return k(d,ee);default:throw Error(c(397))}}var Be=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("'),se=b('$RS("'),et=b('","'),Et=b('")<\/script>'),xt=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("'),Ut=b('$RC("'),at=b('","'),Vt=b('")<\/script>'),ht=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("'),tt=b('$RX("'),Gr=b('"'),wt=b(")<\/script>"),WA=b(","),S=/[<\u2028\u2029]/g;function OA(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 Ue=Object.assign,yr=Symbol.for("react.element"),cr=Symbol.for("react.portal"),fr=Symbol.for("react.fragment"),tr=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),hr=Symbol.for("react.provider"),dr=Symbol.for("react.context"),Tr=Symbol.for("react.forward_ref"),Ur=Symbol.for("react.suspense"),jr=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),T=Symbol.for("react.scope"),Q=Symbol.for("react.debug_trace_mode"),J=Symbol.for("react.legacy_hidden"),$=Symbol.for("react.default_value"),fA=Symbol.iterator;function TA(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 fr:return"Fragment";case cr:return"Portal";case E:return"Profiler";case tr:return"StrictMode";case Ur:return"Suspense";case jr:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case dr:return(d.displayName||"Context")+".Consumer";case hr:return(d._context.displayName||"Context")+".Provider";case Tr: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:TA(d.type)||"Memo";case v:w=d._payload,d=d._init;try{return TA(d(w))}catch{}}return null}var XA={};function qA(d,w){if(d=d.contextTypes,!d)return XA;var _={},F;for(F in d)_[F]=w[F];return _}var fe=null;function Ne(d,w){if(d!==w){d.context._currentValue=d.parentValue,d=d.parent;var _=w.parent;if(d===null){if(_!==null)throw Error(c(401))}else{if(_===null)throw Error(c(401));Ne(d,_)}w.context._currentValue=w.value}}function Bt(d){d.context._currentValue=d.parentValue,d=d.parent,d!==null&&Bt(d)}function rt(d){var w=d.parent;w!==null&&rt(w),d.context._currentValue=d.value}function vt(d,w){if(d.context._currentValue=d.parentValue,d=d.parent,d===null)throw Error(c(402));d.depth===w.depth?Ne(d,w):vt(d,w)}function _e(d,w){var _=w.parent;if(_===null)throw Error(c(402));d.depth===_.depth?Ne(d,_):_e(d,_),w.context._currentValue=w.value}function Dt(d){var w=fe;w!==d&&(w===null?rt(d):d===null?Bt(w):w.depth===d.depth?Ne(w,d):w.depth>d.depth?vt(w,d):_e(w,d),fe=d)}var xr={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 rr(d,w,_,F){var rA=d.state!==void 0?d.state:null;d.updater=xr,d.props=_,d.state=rA;var eA={queue:[],replace:!1};d._reactInternals=eA;var pA=w.contextType;if(d.context=typeof pA=="object"&&pA!==null?pA._currentValue:F,pA=w.getDerivedStateFromProps,typeof pA=="function"&&(pA=pA(_,rA),rA=pA==null?rA:Ue({},rA,pA),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&&xr.enqueueReplaceState(d,d.state,null),eA.queue!==null&&0<eA.queue.length)if(w=eA.queue,pA=eA.replace,eA.queue=null,eA.replace=!1,pA&&w.length===1)d.state=w[0];else{for(eA=pA?w[0]:d.state,rA=!0,pA=pA?1:0;pA<w.length;pA++){var DA=w[pA];DA=typeof DA=="function"?DA.call(d,eA,_,F):DA,DA!=null&&(rA?(rA=!1,eA=Ue({},eA,DA)):Ue(eA,DA))}d.state=eA}else eA.queue=null}var Vr={id:1,overflow:""};function nr(d,w,_){var F=d.id;d=d.overflow;var rA=32-Rr(F)-1;F&=~(1<<rA),_+=1;var eA=32-Rr(w)+rA;if(30<eA){var pA=rA-rA%5;return eA=(F&(1<<pA)-1).toString(32),F>>=pA,rA-=pA,{id:1<<32-Rr(w)+rA|_<<rA|F,overflow:eA+d}}return{id:1<<eA|_<<rA|F,overflow:d}}var Rr=Math.clz32?Math.clz32:Yn,ln=Math.log,an=Math.LN2;function Yn(d){return d>>>=0,d===0?32:31-(ln(d)/an|0)|0}function $n(d,w){return d===w&&(d!==0||1/d===1/w)||d!==d&&w!==w}var Kn=typeof Object.is=="function"?Object.is:$n,Ot=null,un=null,wr=null,Pe=null,Ir=!1,Lr=!1,vr=0,Wt=null,Wr=0;function mr(){if(Ot===null)throw Error(c(321));return Ot}function cn(){if(0<Wr)throw Error(c(312));return{memoizedState:null,queue:null,next:null}}function Yr(){return Pe===null?wr===null?(Ir=!1,wr=Pe=cn()):(Ir=!0,Pe=wr):Pe.next===null?(Ir=!1,Pe=Pe.next=cn()):(Ir=!0,Pe=Pe.next),Pe}function nt(){un=Ot=null,Lr=!1,wr=null,Wr=0,Pe=Wt=null}function H(d,w){return typeof w=="function"?w(d):w}function tA(d,w,_){if(Ot=mr(),Pe=Yr(),Ir){var F=Pe.queue;if(w=F.dispatch,Wt!==null&&(_=Wt.get(F),_!==void 0)){Wt.delete(F),F=Pe.memoizedState;do F=d(F,_.action),_=_.next;while(_!==null);return Pe.memoizedState=F,[F,w]}return[Pe.memoizedState,w]}return d=d===H?typeof w=="function"?w():w:_!==void 0?_(w):w,Pe.memoizedState=d,d=Pe.queue={last:null,dispatch:null},d=d.dispatch=NA.bind(null,Ot,d),[Pe.memoizedState,d]}function mA(d,w){if(Ot=mr(),Pe=Yr(),w=w===void 0?null:w,Pe!==null){var _=Pe.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(!Kn(w[rA],F[rA])){F=!1;break A}F=!0}if(F)return _[0]}}return d=d(),Pe.memoizedState=[d,w],d}function NA(d,w,_){if(25<=Wr)throw Error(c(301));if(d===Ot)if(Lr=!0,d={action:_,next:null},Wt===null&&(Wt=new Map),_=Wt.get(w),_===void 0)Wt.set(w,d);else{for(w=_;w.next!==null;)w=w.next;w.next=d}}function zA(){throw Error(c(394))}function te(){}var Te={readContext:function(d){return d._currentValue},useContext:function(d){return mr(),d._currentValue},useMemo:mA,useReducer:tA,useRef:function(d){Ot=mr(),Pe=Yr();var w=Pe.memoizedState;return w===null?(d={current:d},Pe.memoizedState=d):w},useState:function(d){return tA(H,d)},useInsertionEffect:te,useLayoutEffect:function(){},useCallback:function(d,w){return mA(function(){return d},w)},useImperativeHandle:te,useEffect:te,useDebugValue:te,useDeferredValue:function(d){return mr(),d},useTransition:function(){return mr(),[!1,zA]},useId:function(){var d=un.treeContext,w=d.overflow;d=d.id,d=(d&~(1<<32-Rr(d)-1)).toString(32)+w;var _=He;if(_===null)throw Error(c(404));return w=vr++,d=":"+_.idPrefix+"R"+d,0<w&&(d+="H"+w.toString(32)),d+":"},useMutableSource:function(d,w){return mr(),w(d._source)},useSyncExternalStore:function(d,w,_){if(_===void 0)throw Error(c(407));return _()}},He=null,st=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function bt(d){return console.error(d),null}function Ze(){}function ot(d,w,_,F,rA,eA,pA,DA,re){var ve=[],ye=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:ye,pingedTasks:ve,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:rA===void 0?bt:rA,onAllReady:eA===void 0?Ze:eA,onShellReady:pA===void 0?Ze:pA,onShellError:DA===void 0?Ze:DA,onFatalError:re===void 0?Ze:re},_=Nr(w,0,null,_,!1,!1),_.parentFlushed=!0,d=_t(w,d,null,_,ye,XA,null,Vr),ve.push(d),w}function _t(d,w,_,F,rA,eA,pA,DA){d.allPendingTasks++,_===null?d.pendingRootTasks++:_.pendingTasks++;var re={node:w,ping:function(){var ve=d.pingedTasks;ve.push(re),ve.length===1&&e0(d)},blockedBoundary:_,blockedSegment:F,abortSet:rA,legacyContext:eA,context:pA,treeContext:DA};return rA.add(re),re}function Nr(d,w,_,F,rA,eA){return{status:0,id:-1,index:w,parentFlushed:!1,chunks:[],children:[],formatContext:F,boundary:_,lastPushedText:rA,textEmbedded:eA}}function Yt(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 $t(d,w){var _=d.onShellError;_(w),_=d.onFatalError,_(w),d.destination!==null?(d.status=2,R(d.destination,w)):(d.status=1,d.fatalError=w)}function Zn(d,w,_,F,rA){for(Ot={},un=w,vr=0,d=_(F,rA);Lr;)Lr=!1,vr=0,Wr+=1,Pe=null,d=_(F,rA);return nt(),d}function qn(d,w,_,F){var rA=_.render(),eA=F.childContextTypes;if(eA!=null){var pA=w.legacyContext;if(typeof _.getChildContext!="function")F=pA;else{_=_.getChildContext();for(var DA in _)if(!(DA in eA))throw Error(c(108,TA(F)||"Unknown",DA));F=Ue({},pA,_)}w.legacyContext=F,Tt(d,w,rA),w.legacyContext=pA}else Tt(d,w,rA)}function Bn(d,w){if(d&&d.defaultProps){w=Ue({},w),d=d.defaultProps;for(var _ in d)w[_]===void 0&&(w[_]=d[_]);return w}return w}function Jn(d,w,_,F,rA){if(typeof _=="function")if(_.prototype&&_.prototype.isReactComponent){rA=qA(_,w.legacyContext);var eA=_.contextType;eA=new _(F,typeof eA=="object"&&eA!==null?eA._currentValue:rA),rr(eA,_,F,rA),qn(d,w,eA,_)}else{eA=qA(_,w.legacyContext),rA=Zn(d,w,_,F,eA);var pA=vr!==0;if(typeof rA=="object"&&rA!==null&&typeof rA.render=="function"&&rA.$$typeof===void 0)rr(rA,_,F,eA),qn(d,w,rA,_);else if(pA){F=w.treeContext,w.treeContext=nr(F,1,0);try{Tt(d,w,rA)}finally{w.treeContext=F}}else Tt(d,w,rA)}else if(typeof _=="string"){switch(rA=w.blockedSegment,eA=ct(rA.chunks,_,F,d.responseState,rA.formatContext),rA.lastPushedText=!1,pA=rA.formatContext,rA.formatContext=YA(pA,_,F),A0(d,w,eA),rA.formatContext=pA,_){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(Pt,M(_),Br)}rA.lastPushedText=!1}else{switch(_){case J:case Q:case tr:case E:case fr:Tt(d,w,F.children);return;case jr:Tt(d,w,F.children);return;case T:throw Error(c(343));case Ur:A:{_=w.blockedBoundary,rA=w.blockedSegment,eA=F.fallback,F=F.children,pA=new Set;var DA={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:pA,errorDigest:null},re=Nr(d,rA.chunks.length,DA,rA.formatContext,!1,!1);rA.children.push(re),rA.lastPushedText=!1;var ve=Nr(d,0,null,rA.formatContext,!1,!1);ve.parentFlushed=!0,w.blockedBoundary=DA,w.blockedSegment=ve;try{if(A0(d,w,F),ve.lastPushedText&&ve.textEmbedded&&ve.chunks.push(ue),ve.status=1,Dn(DA,ve),DA.pendingTasks===0)break A}catch(ye){ve.status=4,DA.forceClientRender=!0,DA.errorDigest=Yt(d,ye)}finally{w.blockedBoundary=_,w.blockedSegment=rA}w=_t(d,eA,_,re,pA,w.legacyContext,w.context,w.treeContext),d.pingedTasks.push(w)}return}if(typeof _=="object"&&_!==null)switch(_.$$typeof){case Tr:if(F=Zn(d,w,_.render,F,rA),vr!==0){_=w.treeContext,w.treeContext=nr(_,1,0);try{Tt(d,w,F)}finally{w.treeContext=_}}else Tt(d,w,F);return;case h:_=_.type,F=Bn(_,F),Jn(d,w,_,F,rA);return;case hr:if(rA=F.children,_=_._context,F=F.value,eA=_._currentValue,_._currentValue=F,pA=fe,fe=F={parent:pA,depth:pA===null?0:pA.depth+1,context:_,parentValue:eA,value:F},w.context=F,Tt(d,w,rA),d=fe,d===null)throw Error(c(403));F=d.parentValue,d.context._currentValue=F===$?d.context._defaultValue:F,d=fe=d.parent,w.context=d;return;case dr:F=F.children,F=F(_._currentValue),Tt(d,w,F);return;case v:rA=_._init,_=rA(_._payload),F=Bn(_,F),Jn(d,w,_,F,void 0);return}throw Error(c(130,_==null?_:typeof _,""))}}function Tt(d,w,_){if(w.node=_,typeof _=="object"&&_!==null){switch(_.$$typeof){case yr:Jn(d,w,_.type,_.props,_.ref);return;case cr:throw Error(c(257));case v:var F=_._init;_=F(_._payload),Tt(d,w,_);return}if(bA(_)){Xn(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);Xn(d,w,rA)}return}throw d=Object.prototype.toString.call(_),Error(c(31,d==="[object Object]"?"object with keys {"+Object.keys(_).join(", ")+"}":d))}typeof _=="string"?(F=w.blockedSegment,F.lastPushedText=JA(w.blockedSegment.chunks,_,d.responseState,F.lastPushedText)):typeof _=="number"&&(F=w.blockedSegment,F.lastPushedText=JA(w.blockedSegment.chunks,""+_,d.responseState,F.lastPushedText))}function Xn(d,w,_){for(var F=_.length,rA=0;rA<F;rA++){var eA=w.treeContext;w.treeContext=nr(eA,F,rA);try{A0(d,w,_[rA])}finally{w.treeContext=eA}}}function A0(d,w,_){var F=w.blockedSegment.formatContext,rA=w.legacyContext,eA=w.context;try{return Tt(d,w,_)}catch(re){if(nt(),typeof re=="object"&&re!==null&&typeof re.then=="function"){_=re;var pA=w.blockedSegment,DA=Nr(d,pA.chunks.length,null,pA.formatContext,pA.lastPushedText,!0);pA.children.push(DA),pA.lastPushedText=!1,d=_t(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=eA,Dt(eA)}else throw w.blockedSegment.formatContext=F,w.legacyContext=rA,w.context=eA,Dt(eA),re}}function es(d){var w=d.blockedBoundary;d=d.blockedSegment,d.status=3,v0(this,w,d)}function w0(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(c(432)):_,F.errorDigest=w.onError(d),F.parentFlushed&&w.clientRenderedBoundaries.push(F)),F.fallbackAbortableTasks.forEach(function(rA){return w0(rA,w,_)}),F.fallbackAbortableTasks.clear(),w.allPendingTasks--,w.allPendingTasks===0&&(F=w.onAllReady,F()))}function Dn(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&&Dn(d,_)}else d.completedSegments.push(w)}function v0(d,w,_){if(w===null){if(_.parentFlushed){if(d.completedRootSegment!==null)throw Error(c(389));d.completedRootSegment=_}d.pendingRootTasks--,d.pendingRootTasks===0&&(d.onShellError=Ze,w=d.onShellReady,w())}else w.pendingTasks--,w.forceClientRender||(w.pendingTasks===0?(_.parentFlushed&&_.status===1&&Dn(w,_),w.parentFlushed&&d.completedBoundaries.push(w),w.fallbackAbortableTasks.forEach(es,d),w.fallbackAbortableTasks.clear()):_.parentFlushed&&_.status===1&&(Dn(w,_),w.completedSegments.length===1&&w.parentFlushed&&d.partialBoundaries.push(w)));d.allPendingTasks--,d.allPendingTasks===0&&(d=d.onAllReady,d())}function e0(d){if(d.status!==2){var w=fe,_=st.current;st.current=Te;var F=He;He=d.responseState;try{var rA=d.pingedTasks,eA;for(eA=0;eA<rA.length;eA++){var pA=rA[eA],DA=d,re=pA.blockedSegment;if(re.status===0){Dt(pA.context);try{Tt(DA,pA,pA.node),re.lastPushedText&&re.textEmbedded&&re.chunks.push(ue),pA.abortSet.delete(pA),re.status=1,v0(DA,pA.blockedBoundary,re)}catch(It){if(nt(),typeof It=="object"&&It!==null&&typeof It.then=="function"){var ve=pA.ping;It.then(ve,ve)}else{pA.abortSet.delete(pA),re.status=4;var ye=pA.blockedBoundary,Ve=It,jt=Yt(DA,Ve);if(ye===null?$t(DA,Ve):(ye.pendingTasks--,ye.forceClientRender||(ye.forceClientRender=!0,ye.errorDigest=jt,ye.parentFlushed&&DA.clientRenderedBoundaries.push(ye))),DA.allPendingTasks--,DA.allPendingTasks===0){var Rt=DA.onAllReady;Rt()}}}finally{}}}rA.splice(0,eA),d.destination!==null&&t0(d,d.destination)}catch(It){Yt(d,It),$t(d,It)}finally{He=F,st.current=_,_===Te&&Dt(w)}}}function _n(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,Ar);case 1:_.status=2;var rA=!0;F=_.chunks;var eA=0;_=_.children;for(var pA=0;pA<_.length;pA++){for(rA=_[pA];eA<rA.index;eA++)x(w,F[eA]);rA=Tn(d,w,rA)}for(;eA<F.length-1;eA++)x(w,F[eA]);return eA<F.length&&(rA=k(w,F[eA])),rA;default:throw Error(c(390))}}function Tn(d,w,_){var F=_.boundary;if(F===null)return _n(d,w,_);if(F.parentFlushed=!0,F.forceClientRender)F=F.errorDigest,k(w,Gt),x(w,sn),F&&(x(w,on),x(w,M(lA(F))),x(w,pr)),k(w,Hr),_n(d,w,_);else if(0<F.pendingTasks){F.rootSegmentID=d.nextSegmentId++,0<F.completedSegments.length&&d.partialBoundaries.push(F);var rA=d.responseState,eA=rA.nextSuspenseID++;rA=b(rA.boundaryPrefix+eA.toString(16)),F=F.id=rA,gA(w,d.responseState,F),_n(d,w,_)}else if(F.byteSize>d.progressiveChunkSize)F.rootSegmentID=d.nextSegmentId++,d.completedBoundaries.push(F),gA(w,d.responseState,F.id),_n(d,w,_);else{if(k(w,zr),_=F.completedSegments,_.length!==1)throw Error(c(391));Tn(d,w,_[0])}return k(w,_r)}function fn(d,w,_){return Ce(w,d.responseState,_.formatContext,_.id),Tn(d,w,_),Ge(w,_.formatContext)}function b0(d,w,_){for(var F=_.completedSegments,rA=0;rA<F.length;rA++)k0(d,w,_,F[rA]);if(F.length=0,d=d.responseState,F=_.id,_=_.rootSegmentID,x(w,d.startInlineScript),d.sentCompleteBoundaryFunction?x(w,Ut):(d.sentCompleteBoundaryFunction=!0,x(w,xt)),F===null)throw Error(c(395));return _=M(_.toString(16)),x(w,F),x(w,at),x(w,d.segmentPrefix),x(w,_),k(w,Vt)}function k0(d,w,_,F){if(F.status===2)return!0;var rA=F.id;if(rA===-1){if((F.id=_.rootSegmentID)===-1)throw Error(c(392));return fn(d,w,F)}return fn(d,w,F),d=d.responseState,x(w,d.startInlineScript),d.sentCompleteSegmentFunction?x(w,se):(d.sentCompleteSegmentFunction=!0,x(w,Be)),x(w,d.segmentPrefix),rA=M(rA.toString(16)),x(w,rA),x(w,et),x(w,d.placeholderPrefix),x(w,rA),k(w,Et)}function t0(d,w){g=new Uint8Array(512),y=0;try{var _=d.completedRootSegment;if(_!==null&&d.pendingRootTasks===0){Tn(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,eA;for(eA=0;eA<rA.length;eA++){var pA=rA[eA];F=w;var DA=d.responseState,re=pA.id,ve=pA.errorDigest,ye=pA.errorMessage,Ve=pA.errorComponentStack;if(x(F,DA.startInlineScript),DA.sentClientRenderFunction?x(F,tt):(DA.sentClientRenderFunction=!0,x(F,ht)),re===null)throw Error(c(395));x(F,re),x(F,Gr),(ve||ye||Ve)&&(x(F,WA),x(F,M(OA(ve||"")))),(ye||Ve)&&(x(F,WA),x(F,M(OA(ye||"")))),Ve&&(x(F,WA),x(F,M(OA(Ve)))),k(F,wt)}rA.splice(0,eA);var jt=d.completedBoundaries;for(eA=0;eA<jt.length;eA++)b0(d,w,jt[eA]);jt.splice(0,eA),D(w),g=new Uint8Array(512),y=0;var Rt=d.partialBoundaries;for(eA=0;eA<Rt.length;eA++){var It=Rt[eA];A:{rA=d,pA=w;var br=It.completedSegments;for(DA=0;DA<br.length;DA++)if(!k0(rA,pA,It,br[DA])){DA++,br.splice(0,DA);var Oe=!1;break A}br.splice(0,DA),Oe=!0}if(!Oe){d.destination=null,eA++,Rt.splice(0,eA);return}}Rt.splice(0,eA);var r0=d.completedBoundaries;for(eA=0;eA<r0.length;eA++)b0(d,w,r0[eA]);r0.splice(0,eA)}finally{D(w),d.allPendingTasks===0&&d.pingedTasks.length===0&&d.clientRenderedBoundaries.length===0&&d.completedBoundaries.length===0&&w.close()}}function $r(d,w){try{var _=d.abortableTasks;_.forEach(function(F){return w0(F,d,w)}),_.clear(),d.destination!==null&&t0(d,d.destination)}catch(F){Yt(d,F),$t(d,F)}}return H0.renderToReadableStream=function(d,w){return new Promise(function(_,F){var rA,eA,pA=new Promise(function(ye,Ve){eA=ye,rA=Ve}),DA=ot(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),_A(w?w.namespaceURI:void 0),w?w.progressiveChunkSize:void 0,w?w.onError:void 0,eA,function(){var ye=new ReadableStream({type:"bytes",pull:function(Ve){if(DA.status===1)DA.status=2,R(Ve,DA.fatalError);else if(DA.status!==2&&DA.destination===null){DA.destination=Ve;try{t0(DA,Ve)}catch(jt){Yt(DA,jt),$t(DA,jt)}}},cancel:function(){$r(DA)}},{highWaterMark:0});ye.allReady=pA,_(ye)},function(ye){pA.catch(function(){}),F(ye)},rA);if(w&&w.signal){var re=w.signal,ve=function(){$r(DA,re.reason),re.removeEventListener("abort",ve)};re.addEventListener("abort",ve)}e0(DA)})},H0.version="18.3.1",H0}var ao;function X1(){if(ao)return tn;ao=1;var a,c;return a=q1(),c=J1(),tn.version=a.version,tn.renderToString=a.renderToString,tn.renderToStaticMarkup=a.renderToStaticMarkup,tn.renderToNodeStream=a.renderToNodeStream,tn.renderToStaticNodeStream=a.renderToStaticNodeStream,tn.renderToReadableStream=c.renderToReadableStream,tn}X1();const m0="node-markers-native",Ps="node-markers-layer",Qs="node-markers-layer-local",je={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"},uo=10,co=6,Ah=5,eh=10,fo={tier1:vn[500],tier2:vn[700]};function th(a){if(!a)return 0;const c=Date.now(),g=a*1e3,y=(c-g)/(1e3*60*60*24);return y>=eh?2:y>=Ah?1:0}const Zt=2,rh=rl*Zt,ho=js*Zt;function nh(a){const c=q0(),g=(P,M,b=0,R=!1)=>{const O=rh,z=document.createElement("canvas");z.width=O,z.height=O;const W=z.getContext("2d",R?{colorSpace:"display-p3"}:void 0),V=O/2,X=O/2,iA=O/2-2-b/2;return W.beginPath(),W.arc(V,X,iA,0,Math.PI*2),W.fillStyle=P,W.fill(),M&&b>0&&(W.strokeStyle=M,W.lineWidth=b*Zt,W.stroke()),W.shadowColor="rgba(0,0,0,0.3)",W.shadowBlur=2*Zt,W.shadowOffsetY=1*Zt,{data:W.getImageData(0,0,O,O),pixelRatio:Zt}},y=(P,M=!1)=>{const b=ho,R=document.createElement("canvas");R.width=b,R.height=b;const O=R.getContext("2d",M?{colorSpace:"display-p3"}:void 0),z=b/2,W=b/2,V=js*.35*Zt;return O.strokeStyle=P,O.lineWidth=2.5*Zt,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:Zt}},x=(P,M)=>{const b=ho,R=document.createElement("canvas");R.width=b,R.height=b;const O=R.getContext("2d"),z=b/2,W=b/2,V=js*.35*Zt;return O.strokeStyle=P,O.lineWidth=2.5*Zt,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*Zt),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:Zt}},k="#00FF00",D={[je.standard]:g(c.nodeFill),[je.standardNeighbor]:g(c.neighborColor),[je.hub]:g(c.hubColor),[je.hubNeighbor]:g(c.neighborColor),[je.gateway]:g(c.gatewayColor),[je.gatewayNeighbor]:g(c.neighborColor),[je.mobile]:g("transparent",c.mobileColor,2.5),[je.mobileNeighbor]:g(c.neighborColor),[je.roomServer]:x(c.roomColor),[je.roomServerNeighbor]:x(c.neighborColor,"#1a1a1c"),[je.local]:y(c.localColor),[je.stale5Day]:g(fo.tier1),[je.stale10Day]:g(fo.tier2),[je.blinkBlack]:g("#000000"),[je.blinkBlackLocal]:y("#000000"),[je.blink]:g(k,void 0,0,!0),[je.blinkLocal]:y(k,!0)};for(const[P,M]of Object.entries(D))try{a.hasImage(P)&&a.removeImage(P),a.addImage(P,M.data,{pixelRatio:M.pixelRatio})}catch{}}function mo(a){var g;const c=(g=a.contact_type)==null?void 0:g.toLowerCase();return c==="room server"||c==="room_server"||c==="room"||c==="server"}function sh({neighborsWithLocation:a,localNode:c,localHash:g,zeroHopNeighbors:y,lastHopNeighborMap:x,meshTopology:k,hoveredMarker:D,onMarkerHover:P,getNodeOpacity:M,shouldShowNode:b,openPopupId:R,onOpenPopup:O,onClosePopup:z,onNodeClick:W,blinkingNodes:V}){const{current:X}=Or(),iA=j.useRef(!1),[AA,K]=j.useState(!1);j.useEffect(()=>{var KA;const aA=(KA=X==null?void 0:X.getMap)==null?void 0:KA.call(X);if(!aA)return;const dA=()=>{try{nh(aA),iA.current=!0,AA||K(!0)}catch(VA){console.warn("Failed to load node marker icons:",VA)}};aA.isStyleLoaded()?dA():aA.once("style.load",dA);const RA=()=>{aA.hasImage(je.standard)||dA()};aA.on("styledata",RA);const _A=()=>{iA.current=!1,dA()},YA=new MutationObserver(VA=>{for(const Re of VA)if(Re.attributeName==="data-theme"){setTimeout(_A,100);break}});YA.observe(document.documentElement,{attributes:!0});const ue=document.querySelector("[data-basemap]");let JA=null;return ue&&(JA=new MutationObserver(VA=>{for(const Re of VA)if(Re.attributeName==="data-basemap"){setTimeout(_A,100);break}}),JA.observe(ue,{attributes:!0})),()=>{aA.off("styledata",RA),YA.disconnect(),JA==null||JA.disconnect()}},[X,AA]);const hA=j.useMemo(()=>{var RA;const aA=[],dA=[...a].sort(([_A,YA],[ue,JA])=>{const KA=(VA,Re)=>{var Ie;return mo(Re)?5e3:y.has(VA)?3e3:k.hubNodes.includes(VA)?2e3:(Ie=k.gatewayNodes)!=null&&Ie.includes(VA)?1e3:0};return KA(_A,YA)-KA(ue,JA)});for(const[_A,YA]of dA){if(!YA.latitude||!YA.longitude)continue;if(g){const Ke=Er(g),Je=Er(_A);if(Oo(Ke,Je)||_A===g)continue}const ue=b(_A),JA=M(_A,ue);if(JA<=.01)continue;const KA=y.has(_A),VA=k.hubNodes.includes(_A),Re=((RA=k.gatewayNodes)==null?void 0:RA.includes(_A))??!1,Ie=k.mobileNodes.includes(_A),oe=mo(YA),me=k.centrality.get(_A)||0,we=x.get(_A),$e=YA.last_seen||(we==null?void 0:we.lastSeen),be=th($e),ke=be>0;let Se=JA;be===2?Se=Math.min(JA,.25):be===1&&(Se=Math.min(JA,.5));let pe="standard";oe?pe="roomServer":VA?pe="hub":Re?pe="gateway":Ie&&(pe="mobile"),aA.push({type:"Feature",geometry:{type:"Point",coordinates:[YA.longitude,YA.latitude]},properties:{hash:_A,name:YA.node_name||YA.name||"Unknown",hashPrefix:Er(_A),iconType:pe,isNeighbor:KA,isHub:VA,isGateway:Re,isMobile:Ie,isRoomServer:oe,isStale:ke,staleTier:be,isZeroHop:KA,opacity:Se,blinkIntensity:0,lastSeenTimestamp:$e,centrality:me}})}return{type:"FeatureCollection",features:aA}},[a,g,y,x,k,M,b]),uA=j.useMemo(()=>!(c!=null&&c.latitude)||!(c!=null&&c.longitude)?{type:"FeatureCollection",features:[]}:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[c.longitude,c.latitude]},properties:{hash:"local",name:c.name,hashPrefix:g?Er(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}}]},[c,g]),EA=j.useRef(R);j.useEffect(()=>{EA.current=R},[R]);const oA=j.useCallback(aA=>{var _A;if(!aA.features||aA.features.length===0)return;const RA=(_A=aA.features[0].properties)==null?void 0:_A.hash;RA&&(EA.current===RA?z==null||z():O&&O(RA),W&&RA!=="local"&&W(RA))},[O,z,W]),lA=j.useCallback(aA=>{var _A,YA;if(!aA.features||aA.features.length===0)return;const dA=(_A=X==null?void 0:X.getMap)==null?void 0:_A.call(X);dA&&(dA.getCanvas().style.cursor="pointer");const RA=(YA=aA.features[0].properties)==null?void 0:YA.hash;RA&&P(RA)},[X,P]),BA=j.useCallback(()=>{var dA;const aA=(dA=X==null?void 0:X.getMap)==null?void 0:dA.call(X);aA&&(aA.getCanvas().style.cursor=""),P(null)},[X,P]);j.useEffect(()=>{var RA;const aA=(RA=X==null?void 0:X.getMap)==null?void 0:RA.call(X);if(!aA||!AA)return;const dA=[Ps,Qs];for(const _A of dA)aA.on("click",_A,oA),aA.on("mouseenter",_A,lA),aA.on("mouseleave",_A,BA);return()=>{for(const _A of dA)aA.off("click",_A,oA),aA.off("mouseenter",_A,lA),aA.off("mouseleave",_A,BA)}},[X,AA,oA,lA,BA]);const SA=j.useRef(hA),bA=j.useRef(uA);j.useEffect(()=>{SA.current=hA,bA.current=uA},[hA,uA]),j.useEffect(()=>{var _A;const aA=(_A=X==null?void 0:X.getMap)==null?void 0:_A.call(X);if(!aA||!AA||!V||V.size===0)return;const dA=aA.getSource(m0),RA=aA.getSource(`${m0}-local`);if(!(!dA&&!RA)){if(dA){const YA=SA.current;let ue=!1;const JA=YA.features.map(KA=>{const VA=V.get(KA.properties.hash)??0;return VA!==KA.properties.blinkIntensity?(ue=!0,{...KA,properties:{...KA.properties,blinkIntensity:VA}}):KA});ue&&dA.setData({type:"FeatureCollection",features:JA})}if(RA&&g){const YA=V.get(g)??0,ue=bA.current;ue.features.length>0&&ue.features[0].properties.blinkIntensity!==YA&&RA.setData({type:"FeatureCollection",features:[{...ue.features[0],properties:{...ue.features[0].properties,blinkIntensity:YA}}]})}}},[X,AA,V,g]);const cA=j.useMemo(()=>{if(!R)return{type:"FeatureCollection",features:[]};if(R==="local"&&(c!=null&&c.latitude)&&(c!=null&&c.longitude))return{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[c.longitude,c.latitude]},properties:{hash:"local"}}]};const aA=hA.features.find(dA=>dA.properties.hash===R);return aA?{type:"FeatureCollection",features:[{type:"Feature",geometry:aA.geometry,properties:{hash:aA.properties.hash}}]}:{type:"FeatureCollection",features:[]}},[R,c,hA]);if(!AA)return null;const LA=q0().localColor||"#F59E0B",FA=["case",[">",["get","blinkIntensity"],.66],je.blink,[">",["get","blinkIntensity"],.33],je.blinkBlack,["==",["get","staleTier"],2],je.stale10Day,["==",["get","staleTier"],1],je.stale5Day,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],je.roomServerNeighbor,je.roomServer],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],je.hubNeighbor,je.hub],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],je.gatewayNeighbor,je.gateway],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],je.mobileNeighbor,je.mobile],["case",["get","isNeighbor"],je.standardNeighbor,je.standard]],UA=["interpolate",["linear"],["zoom"],co,.25,uo,1],vA=["get","opacity"];return m.jsxs(m.Fragment,{children:[m.jsx(Qr,{id:m0,type:"geojson",data:hA,children:m.jsx(qt,{id:Ps,type:"symbol",layout:{"icon-image":FA,"icon-size":UA,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":vA}})}),m.jsx(Qr,{id:`${m0}-local`,type:"geojson",data:uA,children:m.jsx(qt,{id:Qs,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],je.blinkLocal,[">",["get","blinkIntensity"],.33],je.blinkBlackLocal,je.local],"icon-size":UA,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),m.jsx(Qr,{id:`${m0}-selection`,type:"geojson",data:cA,children:m.jsx(qt,{id:"node-markers-selection-ring",type:"circle",paint:{"circle-radius":["interpolate",["linear"],["zoom"],co,4,uo,14],"circle-color":"transparent","circle-stroke-color":LA,"circle-stroke-width":2.5,"circle-stroke-opacity":.85}})})]})}const ih=[Ps,Qs],Os="topology-validated-edges-native",zs="topology-weak-edges-native",Hs="neighbor-edges-native",po="topology-weak-edges-native",G0="topology-validated-edges-native",Es="neighbor-edges-native",Ss={type:"FeatureCollection",features:[]},p0={"line-cap":"round","line-join":"round"},go={"line-color":"transparent","line-width":16,"line-opacity":0};function oh(a,c,g,y,x,k){const D=Ys(),P=a!==null,M=x&&x.size>0,b=k&&k.size>0,R=M?Array.from(x):[],O=b?Array.from(k):[],z=c,W=.5,X=(()=>{if(z<=0)return["get","baseColor"];const IA=1-z*.5;return["case",[">=",["get","brightnessScore"],IA],"#FFFFFF",["get","baseColor"]]})(),AA=z<=0?1:["max",.1,["+",1,["*",z,3,["-",["get","brightnessScore"],W]]]],hA=M?["in",["get","key"],["literal",R]]:b?["in",["get","key"],["literal",O]]:P?["==",["get","key"],a]:!1,uA=P||M||b,EA=D.edges.hoverLoop,oA=D.edges.highlight;return{"line-color":uA?["case",hA,M?EA:b?oA:["get","hoverColor"],X]:X,"line-width":uA?["case",hA,["max",["*",["get","baseWidth"],g,1.3],3.5],["*",["get","baseWidth"],g]]:["*",["get","baseWidth"],g],"line-opacity":["case",["<",["get","brightnessScore"],y],0,uA?["case",hA,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],AA,.35]]:["*",["get","baseOpacity"],AA]]}}const lh=10,ah=6;function uh(a){const c=a!==null,{YELLOW:g,GREEN:y,RED:x,GRAY:k}=U0,D=["to-number",["get","listenerScore"],0],P=["to-number",["get","loudScore"],0],b=["/",D,["max",["+",D,P],1]],R=["case",["all",["==",D,0],["==",P,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],AA=5,K=c?["case",["==",["get","key"],a],["max",iA,AA],iA]:iA,hA=c?["case",["==",["get","key"],a],["max",["*",iA,.25],AA*.25],["*",iA,.25]]:["*",iA,.25];return{"line-color":R,"line-width":["interpolate",["linear"],["zoom"],ah,hA,lh,K],"line-opacity":c?["case",["==",["get","key"],a],1,.35]:.9}}function ch({showTopology:a,isExiting:c,hoveredEdgeKey:g,highlightedLoopEdges:y,highlightedFocusEdges:x,onEdgeHover:k,onLoopHover:D,loops:P=[],neighborNames:M={},opacityBias:b=.5,widthMultiplier:R=1,trafficFilter:O=0,showNeighborLines:z=!0,disableHover:W=!1}){const{current:V}=Or(),X=a||c,iA=!0,AA=z?"visible":"none",K=W||c,hA=j.useRef(null),uA=j.useRef(K),EA=j.useRef(new Map),oA=j.useRef(M),lA=j.useRef(D);j.useLayoutEffect(()=>{uA.current=K,oA.current=M,lA.current=D});const BA=j.useMemo(()=>cc(P),[P]);j.useLayoutEffect(()=>{EA.current=BA},[BA]);const SA=j.useCallback(vA=>{var _A,YA;if(uA.current||!vA.features||vA.features.length===0)return;const dA=vA.features[0].properties;if(!(dA!=null&&dA.key))return;const RA=dA.key;if(RA!==hA.current){hA.current=RA;const ue=dA.isNeighborEdge===!0||dA.isNeighborEdge==="true",JA=dA.isLoopEdge===!0||dA.isLoopEdge==="true";if(ue){const KA={key:RA,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(RA,[vA.lngLat.lng,vA.lngLat.lat],KA),(_A=lA.current)==null||_A.call(lA,null)}else if(JA&&lA.current){const KA=EA.current.get(RA)??[];if(KA.length>0){const VA=new Set;for(const me of KA)for(const we of me.edgeKeys)VA.add(we);const Ie=KA[0].nodes.map(me=>oA.current[me]||me.substring(0,4)),oe={loops:KA,highlightedEdgeKeys:VA,hoveredEdgeKey:RA,nodeNames:Ie};lA.current(oe,[vA.lngLat.lng,vA.lngLat.lat]),k(RA)}else{const VA={key:RA,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(RA,[vA.lngLat.lng,vA.lngLat.lat],VA)}}else{const KA={key:RA,fromName:dA.fromName,toName:dA.toName,certainCount:Number(dA.certainCount),confidence:Number(dA.confidence),isBackbone:dA.isBackbone===!0||dA.isBackbone==="true",isLoopEdge:JA,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(RA,[vA.lngLat.lng,vA.lngLat.lat],KA),(YA=lA.current)==null||YA.call(lA,null)}}},[k]),bA=j.useCallback(()=>{var vA;hA.current!==null&&(hA.current=null,k(null),(vA=lA.current)==null||vA.call(lA,null))},[k]);j.useEffect(()=>{var _A;const vA=(_A=V==null?void 0:V.getMap)==null?void 0:_A.call(V);if(!vA||!X)return;const aA="topology-validated-edges-hitarea-native",dA=()=>{try{return vA.getStyle()&&vA.getLayer(aA)}catch{return!1}},RA=()=>dA()?(vA.on("mousemove",aA,SA),vA.on("mouseleave",aA,bA),!0):!1;if(!RA()){const YA=()=>{RA()&&vA.off("styledata",YA)};return vA.on("styledata",YA),()=>{try{vA.off("styledata",YA),dA()&&(vA.off("mousemove",aA,SA),vA.off("mouseleave",aA,bA))}catch{}}}return()=>{try{dA()&&(vA.off("mousemove",aA,SA),vA.off("mouseleave",aA,bA))}catch{}}},[V,X,SA,bA]),j.useEffect(()=>{var _A;const vA=(_A=V==null?void 0:V.getMap)==null?void 0:_A.call(V);if(!vA||!iA||!z)return;const aA="neighbor-edges-hitarea-native",dA=()=>{try{return vA.getStyle()&&vA.getLayer(aA)}catch{return!1}},RA=()=>dA()?(vA.on("mousemove",aA,SA),vA.on("mouseleave",aA,bA),!0):!1;if(!RA()){const YA=()=>{RA()&&vA.off("styledata",YA)};return vA.on("styledata",YA),()=>{try{vA.off("styledata",YA),dA()&&(vA.off("mousemove",aA,SA),vA.off("mouseleave",aA,bA))}catch{}}}return()=>{try{dA()&&(vA.off("mousemove",aA,SA),vA.off("mouseleave",aA,bA))}catch{}}},[V,iA,z,SA,bA]),j.useEffect(()=>{var JA;const vA=(JA=V==null?void 0:V.getMap)==null?void 0:JA.call(V);if(!vA)return;let aA=null;const dA=(KA,VA)=>{try{if(vA.getLayer(KA)&&vA.getLayer(VA))return vA.moveLayer(KA,VA),!0}catch{}return!1},RA=()=>{try{if(!vA.getLayer("node-markers-layer"))return;dA(Es,"node-markers-layer"),dA("neighbor-edges-hitarea-native",Es),(dA(G0,"neighbor-edges-hitarea-native")||dA(G0,"node-markers-layer"))&&dA("topology-validated-edges-hitarea-native",G0),dA(po,"topology-validated-edges-hitarea-native")}catch{}},_A=()=>{aA&&clearTimeout(aA),aA=setTimeout(RA,50)},YA=setTimeout(RA,100);vA.on("styledata",_A);const ue=KA=>{(KA.sourceId===Os||KA.sourceId===zs||KA.sourceId===Hs)&&_A()};return vA.on("sourcedata",ue),()=>{clearTimeout(YA),aA&&clearTimeout(aA);try{vA.off("styledata",_A),vA.off("sourcedata",ue)}catch{}}},[V,X,iA,z]);const cA=K?null:g,FA=oh(cA,b,R,O,K?null:y,x??null),UA=uh(cA);return m.jsxs(m.Fragment,{children:[X&&m.jsx(Qr,{id:zs,type:"geojson",data:Ss,children:m.jsx(qt,{id:po,type:"line",paint:FA,layout:{...p0,visibility:AA}})}),X&&m.jsxs(Qr,{id:Os,type:"geojson",data:Ss,children:[m.jsx(qt,{id:"topology-validated-edges-hitarea-native",type:"line",paint:go,layout:{...p0,visibility:AA}}),m.jsx(qt,{id:G0,type:"line",paint:FA,layout:{...p0,visibility:AA}})]}),m.jsxs(Qr,{id:Hs,type:"geojson",data:Ss,children:[m.jsx(qt,{id:"neighbor-edges-hitarea-native",type:"line",paint:go,layout:{...p0,visibility:AA}}),m.jsx(qt,{id:Es,type:"line",paint:UA,layout:{...p0,visibility:AA}})]})]})}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:c,onComplete:g}){const{current:y}=Or(),x=j.useRef(null);return j.useEffect(()=>{if(!y||!a||a===x.current)return;const k=c.get(a);if(!k)return;const D=y.getMap();D.isMoving()&&D.stop(),x.current=a;const[P,M]=k;y.flyTo({center:[M,P],zoom:10,duration:2500,essential:!0}),setTimeout(()=>{g==null||g()},2600)},[a,c,y,g]),null}function dh({highlightedEdgeKey:a,validatedPolylines:c,weakPolylines:g,onEnsureTopology:y}){const{current:x}=Or(),k=j.useRef(null);return j.useEffect(()=>{if(!x||!a||a===k.current)return;k.current=a,y();const D=c.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,R=x.getZoom(),O=Math.max(R,11);x.easeTo({center:[b,M],zoom:O,duration:500})},[a,c,g,x,y]),null}const yo="link-quality-edges",mh="link-quality-edges-layer",W0="link-quality-edges-hitarea",xo={type:"FeatureCollection",features:[]};function ph(a,c){return a<c?`${a}|${c}`:`${c}|${a}`}function gh(a,c,g,y,x){const k=[];for(const D of a){if(g&&D.nodeA.hash!==g&&D.nodeB.hash!==g)continue;const P=c.get(D.nodeA.hash),M=c.get(D.nodeB.hash);if(!P||!M)continue;const b=$a(D.composite.mean,x),R=y[b]||"#888888",O=2+D.confidence*2,z=ph(D.nodeA.hash,D.nodeB.hash);k.push({type:"Feature",geometry:{type:"LineString",coordinates:[[P[1],P[0]],[M[1],M[0]]]},properties:{key:z,color:R,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 wo={"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:c,focusedNodeHash:g=null,basemapMode:y}){const{current:x}=Or(),k=Ho(),D=Lo(),P=Wa(),M=j.useMemo(()=>Ya(),[]),b=j.useMemo(()=>!a||k.length===0||D.size===0?xo:gh(k,c,g,M,P),[a,k,D.size,c,g,M,P]);j.useEffect(()=>{if(!x)return;const O=x.getMap();if(O)try{const z=O.getSource(yo);z&&"setData"in z&&(z.setData(b),O.triggerRepaint())}catch{}},[b,x]);const R=a?"visible":"none";return m.jsxs(Qr,{id:yo,type:"geojson",data:xo,children:[m.jsx(qt,{id:mh,type:"line",layout:{...wo,visibility:R},paint:yh}),m.jsx(qt,{id:W0,type:"line",layout:{...wo,visibility:R},paint:xh})]})}const vh="rgba(167, 139, 250, 0.15)",vo=500,bh=.5,bo=2e3,ko=1500,kh=1e3;function Ch(a,c,g,y=64){const x=[],D=g/6371e3*(180/Math.PI),P=D/Math.cos(c*Math.PI/180);for(let M=0;M<=y;M++){const b=M/y*2*Math.PI,R=a+P*Math.cos(b),O=c+D*Math.sin(b);x.push([R,O])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[x]}}}function Eh({ghost:a,neighborCoordinates:c,onHighlightedNeighborsChange:g}){const{current:y}=Or(),x=j.useRef(null),k=j.useRef(null),D=j.useMemo(()=>a?new Set(a.commonNeighbors):new Set,[a]);j.useEffect(()=>{g==null||g(D)},[D,g]);const P=j.useMemo(()=>{if(!(a!=null&&a.commonNeighbors)||a.commonNeighbors.length<2)return bo*4;let R=0;const O=[];for(const z of a.commonNeighbors){const W=c.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=Go(O[z][0],O[z][1],O[W][0],O[W][1]);V>R&&(R=V)}return Math.max(R,vo*4)},[a,c]),M=j.useMemo(()=>{if(!(a!=null&&a.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:R,lon:O,uncertaintyM:z}=a.estimatedLocation,W=P*bh,V=z>0?z:bo,X=Math.max(vo,Math.min(V,W));return{type:"FeatureCollection",features:[Ch(O,R,X)]}},[a,P]);if(j.useEffect(()=>{if(!y)return;const R=y.getMap();if(a&&a.prefix!==k.current){if(k.current=a.prefix,!x.current&&R.getZoom()>3){const z=R.getCenter();x.current={center:[z.lng,z.lat],zoom:R.getZoom(),pitch:R.getPitch(),bearing:R.getBearing()}}const O=[];for(const z of a.commonNeighbors){const W=c.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(R.isMoving()){setTimeout(z,100);return}if(O.length===1)y.flyTo({center:O[0],zoom:13,duration:ko});else{let V=1/0,X=-1/0,iA=1/0,AA=-1/0;for(const[K,hA]of O)V=Math.min(V,K),X=Math.max(X,K),iA=Math.min(iA,hA),AA=Math.max(AA,hA);if((W=a.estimatedLocation)!=null&&W.uncertaintyM){const K=a.estimatedLocation.uncertaintyM/111e3;V-=K,X+=K,iA-=K,AA+=K}y.fitBounds([[V,iA],[X,AA]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:ko})}};setTimeout(z,50)}}if(!a&&k.current!==null&&(k.current=null,x.current)){const O=x.current,z=()=>{if(R.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,c]),!(a!=null&&a.estimatedLocation))return null;const b={"fill-color":vh,"fill-opacity":.8};return m.jsx(Qr,{id:"ghost-uncertainty-circle",type:"geojson",data:M,children:m.jsx(qt,{id:"ghost-uncertainty-fill",type:"fill",paint:b})})}const vl=[{target:"Map",fn:"gps",minStage:1,when:vi},{target:"Map",fn:"_advertNodeType",minStage:1,when:vi},{target:"Topology",fn:"traceHops",minStage:1,when:bi},{target:"Topology",fn:"path.entries",minStage:1,when:nu},{target:"Topology",fn:"traceSrc",minStage:1,when:bi}];Vo(vl);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,c,g,y){return Go(a,c,g,y)/1e3}function Dh(a,c){if(a.length<=2)return a;let g,y;if(c!=null&&c.latitude&&(c!=null&&c.longitude))g=c.latitude,y=c.longitude;else{let b=0,R=0;for(const[O,z]of a)b+=O,R+=z;g=b/a.length,y=R/a.length}const x=a.map(([b,R])=>({pos:[b,R],dist:Bh(g,y,b,R)}));x.sort((b,R)=>b.dist-R.dist);const k=Math.floor(x.length/2),D=x[k].dist,P=Math.max(D*3,50),M=x.filter(b=>b.dist<=P).map(b=>b.pos);return M.length<a.length*.5?a:M}function _h(a,c){let g=[...a];if(c!=null&&c.latitude&&(c!=null&&c.longitude)&&g.push([c.latitude,c.longitude]),g.length===0)return null;if(g.length===1){const[W,V]=g[0];return{longitude:V,latitude:W,zoom:14}}g=Dh(g,c);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 P=(y+x)/2,M=(k+D)/2,b=D-k,R=x-y,O=Math.max(b,R);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:P,latitude:M,zoom:z}}function Th(a,c,g,y){var x;if(c){const k=c.loops[0],D=c.loops.length,P=[{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:`${c.nodeNames.join(" → ")} → ${c.nodeNames[0]}`,color:"text-fg-secondary",mono:!0},stats:P,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 P=k.listenerScore??0,M=k.loudScore??0,b=P>0||M>0;return b&&(D.push({label:"listener",value:P,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,P=[{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 R=k.dominantDirection==="forward"?"→":k.dominantDirection==="reverse"?"←":"↔";P.push({label:"symmetric",value:`${R} ${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 R=M.composite;P.push({label:"trace SNR",value:`${R.mean.toFixed(1)} dB`,unit:`n=${R.count}`,color:R.mean>=10?"text-sys-green":R.mean>=0?"text-sys-amber":"text-sys-red"}),M.asymmetryDb!=null&&M.asymmetryDb>1&&P.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 R=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:R})}return{type:"topology",title:{icon:"",text:`${k.fromName} ↔ ${k.toName}`,color:"text-fg-primary"},stats:P,badges:b}}return null}function jh({data:a}){const c=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))})]}),c&&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 ${c?"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 Sd({neighbors:a,localNode:c,localHash:g,onRemoveNode:y,selectedNodeHash:x,onNodeSelected:k,highlightedEdgeKey:D,highlightedGhost:P}){Uo(vl);const M=j.useRef(null),b=Ka(),R=Za(),O=Po(),z=qa(),W=Ja(),V=Ho(),[X,iA]=j.useState(!1),AA=mn(H=>H.viewState),K=mn(H=>H.toggles),hA=mn(H=>H.hasAnalyzed),uA=mn(H=>H.setViewState),EA=mn(H=>H.setToggle),oA=mn(H=>H.setHasAnalyzed),lA=mn(H=>H.modalMapOpen),BA=ps(H=>H.preloadFromNodes),SA=ps(H=>H.isLoading),bA=ps(H=>H.terrainGrid),cA=g??z,IA=j.useMemo(()=>{const H=[];for(const[,tA]of Object.entries(a))tA.latitude&&tA.longitude&&H.push([tA.latitude,tA.longitude]);return H},[a]),LA=j.useMemo(()=>_h(IA,c),[IA,c]),[FA,UA]=j.useState(()=>AA??LA??Mh),vA=j.useCallback(H=>{UA(H),queueMicrotask(()=>uA(H))},[uA]),aA=j.useRef(!!AA);j.useEffect(()=>{!aA.current&&LA&&!AA?(UA(LA),queueMicrotask(()=>uA(LA)),aA.current=!0,setTimeout(()=>iA(!0),50)):AA&&setTimeout(()=>iA(!0),50)},[LA,AA,uA]);const[dA,RA]=j.useState(!1),[_A,YA]=j.useState(()=>K.showTopology&&!O.topologyLoadComplete?!1:K.showTopology),[ue,JA]=j.useState(K.showNeighborLines),[KA,VA]=j.useState(!1),[Re,Ie]=j.useState(K.showMinCut),[oe,me]=j.useState(If),[we,$e]=j.useState(K.show3DTerrain),[be,ke]=j.useState(K.showLinkQuality),[Se,pe]=j.useState(()=>K.nodeFilters.length>0?K.nodeFilters:[...g0]),Ke=j.useCallback(H=>{YA(tA=>{const mA=typeof H=="function"?H(tA):H;return queueMicrotask(()=>EA("showTopology",mA)),mA})},[EA]),Je=j.useCallback(H=>{JA(tA=>{const mA=typeof H=="function"?H(tA):H;return queueMicrotask(()=>EA("showNeighborLines",mA)),mA})},[EA]),At=j.useCallback(H=>{Ie(tA=>{const mA=typeof H=="function"?H(tA):H;return queueMicrotask(()=>EA("showMinCut",mA)),mA})},[EA]),it=j.useCallback(H=>{$e(tA=>{const mA=typeof H=="function"?H(tA):H;return queueMicrotask(()=>EA("show3DTerrain",mA)),mA})},[EA]),St=j.useCallback(H=>{ke(tA=>{const mA=typeof H=="function"?H(tA):H;return queueMicrotask(()=>EA("showLinkQuality",mA)),mA})},[EA]),Qe=j.useCallback(H=>{pe(H),queueMicrotask(()=>EA("nodeFilters",H))},[EA]),[Xe,Me]=j.useState(null),[ze,ct]=j.useState(null),[Pt,Br]=j.useState(null),[Xt,Ar]=j.useState(null),[zr]=j.useState(0),[nn]=j.useState(.5),[Dr]=j.useState(0),[Gt,_r]=j.useState(null),[sn,pr]=j.useState(""),[on,Hr]=j.useState(!1),[gA,gr]=j.useState(!1),[ft,Fe]=j.useState(()=>hA&&!O.topologyLoadComplete?!1:hA);j.useEffect(()=>{if(O.topologyLoadComplete)return;const H=hA&&!ft,tA=K.showTopology&&!_A;!H&&!tA||queueMicrotask(()=>{H&&oA(!1),tA&&EA("showTopology",!1)})},[hA,K.showTopology,O.topologyLoadComplete,ft,_A,oA,EA]);const ur=j.useCallback(H=>{Fe(H),queueMicrotask(()=>oA(H))},[oA]),[qe,kt]=j.useState(null),Mt=j.useCallback(H=>kt(H),[]),er=j.useCallback(()=>kt(null),[]),[,Ct]=j.useState(new Set),Qt=y0(H=>H.coveragePoints),yt=y0(H=>H.isVisible),nA=y0(H=>H.brightness),yA=y0(H=>H.openModal),jA=Vs(),xA=Ko(),t=Zo(),C=Fu(),ge=Xa(),De=Au(H=>H.messages);Pu();const Le=j.useRef(null);j.useEffect(()=>{if(!xA||!M.current){Le.current&&(clearInterval(Le.current),Le.current=null);return}return Le.current=setInterval(()=>{var He;const H=qo();if(!H)return;const tA=(He=M.current)==null?void 0:He.getMap();if(!tA)return;const mA=tA.project([H.lon,H.lat]),{width:NA,height:zA}=tA.getCanvas(),te=.2;mA.x>NA*te&&mA.x<NA*(1-te)&&mA.y>zA*te&&mA.y<zA*(1-te)||tA.easeTo({center:[H.lon,H.lat],duration:1500,easing:st=>st*(2-st)})},2e3),()=>{Le.current&&(clearInterval(Le.current),Le.current=null)}},[xA]);const ee=Jf(),Ce=Xf(),Ge=Ro(),Be=eu(),se=j.useRef(!1);j.useEffect(()=>{Qt.length>0&&yt&&!se.current&&(Je(!1),se.current=!0)},[Qt.length,yt]);const et=j.useRef(null);j.useEffect(()=>{if(x&&x!==et.current){et.current=x;const H=setTimeout(()=>{kt(x)},1250);return()=>clearTimeout(H)}},[x]);const[Et,xt]=j.useState(null),[Ut,at]=j.useState(null),Vt=j.useCallback((H,tA,mA)=>{ct(H),H&&tA&&mA?xt({longitude:tA[0],latitude:tA[1],type:"topology",properties:{key:mA.key,fromName:mA.fromName,toName:mA.toName,certainCount:mA.certainCount,confidence:mA.confidence,isBackbone:mA.isBackbone,isLoopEdge:mA.isLoopEdge,isDirectPath:mA.isDirectPath,isHubConnection:mA.isHubConnection,symmetryRatio:mA.symmetryRatio,dominantDirection:mA.dominantDirection}}):H||xt(null)},[]),ht=j.useCallback((H,tA)=>{at(H),H&&xt(null)},[]),tt=j.useMemo(()=>{var zA;if(!_A||!Xe||ze)return null;const H=b.loops;if(H.length===0)return null;const tA=uc(Xe,H,b.edgeMap);if(tA.loops.length===0)return null;const NA=tA.loops[0].nodes.map(te=>{var Te,He;return te===cA?"You":((Te=a[te])==null?void 0:Te.node_name)||((He=a[te])==null?void 0:He.name)||te.substring(0,4)});return{loops:tA.loops,highlightedEdgeKeys:tA.highlightedEdgeKeys,hoveredEdgeKey:((zA=tA.sortedEdges[0])==null?void 0:zA.key)||"",nodeNames:NA}},[_A,Xe,ze,b.loops,b.edgeMap,a,cA]);j.useEffect(()=>{ze||at(tt)},[tt,ze]);const Gr=j.useMemo(()=>{const H={};for(const[tA,mA]of Object.entries(a))H[tA]=mA.node_name||mA.name||tA.substring(0,4);return cA&&(H[cA]="You"),H},[a,cA]),wt=j.useMemo(()=>{const H=new Map;for(const[tA,mA]of Object.entries(a)){const NA=tA.slice(0,2).toUpperCase(),zA=mA.node_name||mA.name||NA;H.set(NA,zA)}return cA&&H.set(cA.slice(0,2).toUpperCase(),"You"),H},[a,cA]),WA=j.useMemo(()=>Object.entries(a).filter(([,H])=>H.latitude&&H.longitude),[a]),S=j.useMemo(()=>{const H=new Map;cA&&(c!=null&&c.latitude)&&(c!=null&&c.longitude)&&H.set(cA,[c.latitude,c.longitude]);for(const[tA,mA]of WA)mA.latitude&&mA.longitude&&H.set(tA,[mA.latitude,mA.longitude]);return H},[cA,c,WA]),OA=j.useMemo(()=>{const H=new Map;for(const tA of R)tA.status!=="expired"&&H.set(tA.hash,{hash:tA.hash,prefix:tA.prefix,count:tA.count,avgRssi:tA.avgRssi,avgSnr:tA.avgSnr,lastSeen:tA.lastSeen,confidence:1,status:tA.status});return H},[R]),Ue=j.useMemo(()=>{var tA,mA;const H=new Set;for(const NA of OA.keys())(tA=a[NA])!=null&&tA.latitude&&((mA=a[NA])!=null&&mA.longitude)&&H.add(NA);return H},[OA,a]),yr=Ts(),cr=j.useMemo(()=>{if(Ue.size===0||!cA)return new Map;if(yr.length===0)return new Map;const H=Er(cA);return su(yr,Ue,H).scores},[Ue,cA,yr]),fr=j.useMemo(()=>{var bt;if(!qe)return null;if(qe==="local"&&c)return{isLocal:!0,name:c.name,hash:cA,hashPrefix:cA?Er(cA):"",longitude:c.longitude,latitude:c.latitude};const H=a[qe];if(!H)return null;const tA=Ue.has(qe),mA=b.hubNodes.includes(qe),NA=((bt=b.gatewayNodes)==null?void 0:bt.includes(qe))??!1,zA=b.mobileNodes.includes(qe),te=Si(H),Te=OA.get(qe),He=b.fullAffinity.get(qe),st=b.txDelayRecommendations.get(qe);return{isLocal:!1,hash:qe,hashPrefix:Er(qe),name:H.node_name||H.name||"Unknown",isHub:mA,isGateway:NA,isBackbone:(st==null?void 0:st.networkRole)==="backbone",isZeroHop:tA,isMobile:zA,isRoomServer:te.isRoomServer,isStale:(()=>{const Ze=H.last_seen||(Te==null?void 0:Te.lastSeen);return Ze?(Date.now()-Ze*1e3)/(1e3*60*60*24)>=5:!1})(),lastSeenTimestamp:H.last_seen||(Te==null?void 0:Te.lastSeen),centrality:b.centrality.get(qe)||0,affinity:He,meanSnr:(Te==null?void 0:Te.avgSnr)??void 0,meanRssi:(Te==null?void 0:Te.avgRssi)??void 0,neighbor:H,txDelayRec:st}},[qe,c,cA,a,Ue,b,OA]),tr=j.useCallback(H=>cA?!!(H.fromHash===cA&&Ue.has(H.toHash)||H.toHash===cA&&Ue.has(H.fromHash)):!1,[cA,Ue]),E=j.useMemo(()=>{var tA,mA;if(R.length===0||!cA)return[];if(O.backgroundLoadComplete)return[];const H=[];for(const NA of R){if(NA.status==="expired"||!((tA=a[NA.hash])!=null&&tA.latitude)||!((mA=a[NA.hash])!=null&&mA.longitude))continue;const zA=[cA,NA.hash].sort(),te=`${zA[0]}~${zA[1]}`;H.push({fromHash:cA,toHash:NA.hash,key:te,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},[R,cA,O.backgroundLoadComplete,a]),hr=j.useMemo(()=>{const H=[];if(E.length>0&&!O.backgroundLoadComplete){for(const tA of E){const mA=S.get(tA.fromHash),NA=S.get(tA.toHash);mA&&NA&&H.push({from:mA,to:NA,edge:tA})}return H}for(const tA of b.validatedEdges){if(tr(tA))continue;const mA=S.get(tA.fromHash),NA=S.get(tA.toHash);mA&&NA&&H.push({from:mA,to:NA,edge:tA})}return H},[b.validatedEdges,S,tr,E,O.backgroundLoadComplete]),dr=j.useMemo(()=>{const H=[];for(const tA of b.weakEdges){if(tr(tA))continue;const mA=S.get(tA.fromHash),NA=S.get(tA.toHash);mA&&NA&&H.push({from:mA,to:NA,edge:tA})}return H},[b.weakEdges,S,tr]),Tr=j.useMemo(()=>{if(!(c!=null&&c.latitude)||!(c!=null&&c.longitude))return[];const H=[],tA=[c.latitude,c.longitude],mA=new Map;for(const zA of b.lastHopNeighbors)mA.set(zA.hash,zA.count);const NA=new Map;for(const zA of R)NA.set(zA.hash,zA.count);for(const zA of Ue){const te=a[zA];if(!(te!=null&&te.latitude)||!(te!=null&&te.longitude))continue;const Te=NA.get(zA),He=mA.get(zA);H.push({from:tA,to:[te.latitude,te.longitude],hash:zA,neighbor:te,lastHopData:OA.get(zA)??null,rxAdvertCount:Te,txProxyCount:He})}return H},[c,Ue,a,OA,b.lastHopNeighbors,R]),Ur=j.useMemo(()=>new Set(b.loopEdgeKeys),[b.loopEdgeKeys]),jr=j.useMemo(()=>new Set(b.backboneEdges),[b.backboneEdges]),h=j.useMemo(()=>{if(!Pt)return null;const H=b.validatedEdges.filter(zA=>zA.fromHash===Pt||zA.toHash===Pt);if(H.length===0)return null;const tA=[...H].sort((zA,te)=>te.certainCount-zA.certainCount),mA=Math.max(1,Math.ceil(tA.length*.2)),NA=tA.slice(0,mA);return new Set(NA.map(zA=>zA.key))},[Pt,b.validatedEdges]),v=j.useMemo(()=>{let H=0;if(E.length>0&&!O.backgroundLoadComplete){for(const tA of E)tA.certainCount>H&&(H=tA.certainCount);return H||1}for(const tA of b.validatedEdges)tA.certainCount>H&&(H=tA.certainCount);return H||1},[b.validatedEdges,E,O.backgroundLoadComplete]),T=j.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 tA=Array.from(H).filter(NA=>S.has(NA)).sort();if(tA.length<3)return null;const mA=new Map;for(const NA of tA){const zA=S.get(NA);zA&&mA.set(NA,zA)}return Eu(b.validatedEdges,tA,mA,b.edgeBetweenness)},[b.validatedEdges,S,b.edgeBetweenness]),Q=j.useCallback(()=>{At(H=>{const tA=!H;if(tA&&T&&M.current){const mA=M.current.getMap();if(!mA)return tA;let NA=1/0,zA=-1/0,te=1/0,Te=-1/0,He=!1;for(const[,st]of T.communities)for(const bt of st){const Ze=S.get(bt);if(Ze){const[ot,_t]=Ze;te=Math.min(te,ot),Te=Math.max(Te,ot),NA=Math.min(NA,_t),zA=Math.max(zA,_t),He=!0}}He&&mA.fitBounds([[NA,te],[zA,Te]],{padding:{top:60,bottom:100,left:60,right:320},duration:800,maxZoom:14})}return tA})},[T,S]),J=j.useRef(null);j.useLayoutEffect(()=>{var H,tA;J.current=((tA=(H=M.current)==null?void 0:H.getMap)==null?void 0:tA.call(H))??null});const $=Ts();Z1({map:J,nodeCoordinates:S,packets:$,localHash:cA,neighbors:a,meshTopology:b,enabled:ee});const{isExiting:fA,isAnimating:TA,resetAnimationState:XA}=R1({map:J,showTopology:_A,validatedPolylines:hr,weakPolylines:dr,maxCertainCount:v,loopEdgeKeys:Ur,backboneEdgeKeys:jr,highlightedEdgeKey:D,neighbors:a,validatedSourceId:Os,weakSourceId:zs,neighborPolylines:Tr,showNeighborLines:ue,neighborSourceId:Hs,neighborLinkScores:cr,basemapMode:Ge}),qA=j.useMemo(()=>{const H=new Set;for(const tA of b.hubNodes){H.add(tA);for(const mA of b.validatedEdges)mA.fromHash===tA&&H.add(mA.toHash),mA.toHash===tA&&H.add(mA.fromHash)}return H},[b.hubNodes,b.validatedEdges]),fe=j.useMemo(()=>{const H=new Set;if(!g)return H;for(const tA of b.validatedEdges)tA.fromHash===g&&H.add(tA.toHash),tA.toHash===g&&H.add(tA.fromHash);return H},[g,b.validatedEdges]),Ne=j.useMemo(()=>{const H=new Map;for(const[tA,mA]of WA)H.set(tA,Si(mA).type);return H},[WA]),Bt=j.useMemo(()=>{let H=0,tA=0,mA=0;for(const[,NA]of Ne)NA==="repeater"?H++:NA==="companion"||NA==="unknown"?tA++:NA==="room_server"&&mA++;return{repeater:H,companion:tA,room_server:mA,hubs:b.hubNodes.length,direct:Ue.size}},[Ne,b.hubNodes.length,Ue.size]),rt=j.useMemo(()=>new Set(Se),[Se]),{getNodeOpacity:vt}=I1({activeFilters:rt,neighborHashes:WA.map(([H])=>H),hubConnectedNodes:qA,directNodeSet:Ue,localConnectedNodes:fe,nodeTypeMap:Ne,showTopology:_A}),{blinkingNodes:_e,blinkColor:Dt}=P1({neighbors:a,localHash:g,enabled:ee}),xr=j.useCallback(H=>{if(rt.size===0)return!1;const tA=Ne.get(H)??"unknown";return!!(rt.has("repeater")&&tA==="repeater"||rt.has("companion")&&(tA==="companion"||tA==="unknown")||rt.has("room_server")&&tA==="room_server"||rt.has("direct")&&Ue.has(H)||rt.has("hubs")&&qA.has(H))},[rt,Ne,Ue,qA]),rr=j.useCallback(()=>{gr(!0),Hr(!0)},[]),Vr=j.useCallback(()=>{ft?Ke(H=>!H):rr()},[ft,rr]),nr=j.useCallback(H=>{vA(H.viewState),(H.viewState.pitch??0)>10&&!we&&it(!0)},[we]),Rr=j.useCallback(()=>{RA(H=>{var NA,zA,te,Te,He,st,bt;const tA=!H,mA=(te=(zA=(NA=M.current)==null?void 0:NA.getContainer())==null?void 0:zA.closest(".map-container-fullscreen, .map-container-16-9"))==null?void 0:te.parentElement;return tA?mA&&document.fullscreenEnabled?(Te=mA.requestFullscreen)==null||Te.call(mA).catch(()=>{}):mA&&document.webkitFullscreenEnabled&&((He=mA.webkitRequestFullscreen)==null||He.call(mA)):document.fullscreenElement?(st=document.exitFullscreen)==null||st.call(document).catch(()=>{}):document.webkitFullscreenElement&&((bt=document.webkitExitFullscreen)==null||bt.call(document)),tA})},[]),ln=j.useCallback(()=>{const H=Se.length>=g0.length;Qe(H?[]:[...g0])},[Se,Qe]),an=j.useCallback(H=>{Se.length>=g0.length?Qe([H]):Se.includes(H)?Qe(Se.filter(mA=>mA!==H)):Qe([...Se,H])},[Se,Qe]),Yn=j.useCallback(()=>{Je(H=>!H)},[]),$n=j.useCallback(()=>{VA(H=>!H)},[]),Kn=j.useCallback(()=>{St(H=>{const tA=!H;return tA||Ar(null),tA})},[]),Ot=j.useCallback(()=>{it(H=>{const tA=!H;if(M.current){const mA=M.current.getMap();mA&&mA.stop()}if(tA&&M.current){const mA=M.current.getMap();mA&&mA.easeTo({pitch:45,duration:1500,easing:Xo})}if(!tA&&M.current){const mA=M.current.getMap();mA&&mA.easeTo({pitch:0,bearing:0,duration:800,easing:Vu})}return tA})},[]),un=j.useCallback(()=>{_A||Ke(!0)},[_A]),wr=j.useCallback((H,tA)=>{_r(H),pr(tA)},[]),Pe=j.useCallback(()=>{Gt&&y&&y(Gt),_r(null),pr("")},[Gt,y]),Ir=j.useMemo(()=>[...fh,...ih,...be?[W0]:[]],[be]),Lr=j.useCallback(H=>{var mA;if((mA=H.features)==null?void 0:mA.some(NA=>{var zA,te;return(te=(zA=NA.layer)==null?void 0:zA.id)==null?void 0:te.startsWith("node-markers-")})){xt(null),ct(null);return}if(be&&H.features&&H.features.length>0){const NA=H.features.find(zA=>{var te;return((te=zA.layer)==null?void 0:te.id)===W0});if(NA!=null&&NA.properties){const{fromHash:zA,toHash:te}=NA.properties;if(zA&&te){const Te=V.find(He=>He.nodeA.hash===zA&&He.nodeB.hash===te||He.nodeA.hash===te&&He.nodeB.hash===zA);if(Te){Ar(Te),kt(null);return}}}}kt(null),xt(null),ct(null),Br(null),Ar(null)},[be,V]),vr=j.useCallback(H=>{Br(tA=>tA===H?null:H),Ar(null)},[]),Wt=j.useCallback(H=>{var He,st,bt;if(!H.features||H.features.length===0)return;if(H.features.some(Ze=>{var ot,_t;return(_t=(ot=Ze.layer)==null?void 0:ot.id)==null?void 0:_t.startsWith("node-markers-")})){ze&&(ct(null),xt(null));return}if(be&&H.features.some(Ze=>{var ot;return((ot=Ze.layer)==null?void 0:ot.id)===W0})){try{(He=M.current)!=null&&He.getCanvas()&&(M.current.getCanvas().style.cursor="pointer")}catch{}return}const mA=H.features.find(Ze=>{var _t;const ot=(_t=Ze.layer)==null?void 0:_t.id;return(ot==null?void 0:ot.startsWith("topology-"))||(ot==null?void 0:ot.startsWith("neighbor-"))});if(!mA)return;const NA=(st=mA.layer)==null?void 0:st.id,zA=mA.properties;if(!(zA!=null&&zA.key))return;const te=NA==null?void 0:NA.startsWith("topology-"),Te=NA==null?void 0:NA.startsWith("neighbor-");if(te||Te){const Ze=zA.key.replace(/-loop[12]$/,"");ct(Ze),H.lngLat&&xt({longitude:H.lngLat.lng,latitude:H.lngLat.lat,type:te?"topology":"neighbor",properties:zA})}try{(bt=M.current)!=null&&bt.getCanvas()&&(M.current.getCanvas().style.cursor="pointer")}catch{}},[ze,be]),Wr=j.useCallback(()=>{var H;ct(null),xt(null);try{(H=M.current)!=null&&H.getCanvas()&&(M.current.getCanvas().style.cursor="")}catch{}},[]),mr=dA?"map-container-fullscreen":"map-container-16-9",cn=IA.length>0||(c==null?void 0:c.latitude)&&(c==null?void 0:c.longitude),Yr=!X||!cn,nt=cn;return m.jsxs("div",{className:`relative ${mr} ${dA?"":"rounded-2xl overflow-hidden"}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":Ge,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."}),Yr&&m.jsx("div",{className:"absolute inset-0 z-50 surface-base rounded-2xl flex items-center justify-center","aria-hidden":"true",children:m.jsxs("div",{className:"flex flex-col items-center gap-3",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..."})]})}),nt&&m.jsx("div",{className:`relative w-full h-full ${dA?"":"rounded-[1.125rem] overflow-hidden"} ${Yr?"opacity-0":"opacity-100 transition-opacity duration-300"}`,style:lA?{visibility:"hidden"}:void 0,children:m.jsxs(tu,{ref:M,...FA,onMove:nr,mapStyle:Sh,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:Ir,onMouseMove:Wt,onMouseLeave:Wr,onClick:Lr,onError:H=>{console.error("MapLibre error:",H.error)},onIdle:()=>{if(!bA&&!SA&&M.current){const H=M.current.getMap();if(H){const tA=Object.values(a).filter(mA=>mA.latitude&&mA.longitude).map(mA=>({latitude:mA.latitude,longitude:mA.longitude}));c!=null&&c.latitude&&(c!=null&&c.longitude)&&tA.push({latitude:c.latitude,longitude:c.longitude}),tA.length>0&&BA(tA,H)}}},children:[m.jsx(ru,{position:"bottom-right"}),m.jsx(Uu,{mode:Ge}),m.jsx(n1,{enabled:we,exaggeration:4}),m.jsx(q2,{coveragePoints:Qt,visible:Qt.length>0&&yt||jA,terrainEnabled:we,brightness:jA?.5:nA,basemapMode:Ge,replaySamples:jA?C:void 0,replayTimeS:jA?t:void 0}),m.jsx(B1,{partition:T,nodeCoordinates:S,visible:Re&&ft,opacity:oe.opacity,bandwidth:oe.bandwidth,threshold:oe.threshold,strokeWidth:oe.strokeWidth}),m.jsx(ch,{showTopology:_A,isExiting:fA,hoveredEdgeKey:ze,highlightedLoopEdges:Ut==null?void 0:Ut.highlightedEdgeKeys,highlightedFocusEdges:h,onEdgeHover:Vt,onLoopHover:ht,loops:b.loops,neighborNames:Gr,opacityBias:zr,widthMultiplier:nn,trafficFilter:Dr,showNeighborLines:ue,disableHover:TA||gA}),m.jsx(wh,{visible:be,nodeCoordinates:S,focusedNodeHash:Pt,basemapMode:Ge}),x&&m.jsx(hh,{targetHash:x,nodeCoordinates:S,onComplete:k}),D&&m.jsx(dh,{highlightedEdgeKey:D,validatedPolylines:hr,weakPolylines:dr,onEnsureTopology:un}),m.jsx(Eh,{ghost:P??null,neighborCoordinates:S,onHighlightedNeighborsChange:Ct}),jA&&m.jsx(t1,{neighbors:a}),m.jsx(sh,{neighborsWithLocation:WA,localNode:c,localHash:g,zeroHopNeighbors:Ue,lastHopNeighborMap:OA,meshTopology:b,hoveredMarker:Xe,onMarkerHover:Me,getNodeOpacity:vt,shouldShowNode:xr,openPopupId:qe,onOpenPopup:Mt,onClosePopup:er,onNodeClick:vr,blinkingNodes:_e,blinkColor:Dt})]})}),(()=>{const H=Th(Et?{type:Et.type,properties:Et.properties}:null,Ut,v,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(jh,{data:H})})})})(),m.jsx($c,{mapRef:M,showNeighborLines:ue,onToggleNeighborLines:Yn,hasNeighborPolylines:Tr.length>0,nodeFilters:Se,onToggleFilter:an,onToggleAll:ln,filterCounts:Bt,showCoverage:KA,onToggleCoverage:$n,showMinCut:Re,onToggleMinCut:Q,hasMinCutData:ft&&T!==null&&T.numCommunities>1,show3DTerrain:we,onToggle3DTerrain:Ot,basemapMode:Ge,onToggleBasemap:Be,isFullscreen:dA,onToggleFullscreen:Rr,showLinkQuality:be,onToggleLinkQuality:Kn,hasTraceLinks:W}),m.jsx(Zf,{data:fr,localNode:c,localColor:q0().localColor,onClose:er,onRemove:y?wr:void 0}),be&&Xt&&m.jsx(Hf,{pair:Xt,onClose:()=>Ar(null),prefixToName:wt}),m.jsxs("div",{className:"map-legend-stack",children:[m.jsxs("div",{className:"map-tool-row",children:[m.jsx(ef,{isActive:_A,hasAnalyzed:ft,isLoading:gA,onClick:Vr,basemapMode:Ge}),m.jsx(lf,{isActive:ee,onClick:Ce,basemapMode:Ge}),m.jsx(df,{isActive:Qt.length>0&&yt,onClick:yA,basemapMode:Ge}),!jA&&m.jsx(Gf,{channels:ge,messages:De,basemapMode:Ge})]}),m.jsx(Vc,{showTopology:_A,validatedPolylineCount:hr.length,filteredNeighborCount:WA.length,hasLocalNode:!!(c!=null&&c.latitude&&(c!=null&&c.longitude)),meshTopology:b,zeroHopNeighbors:Ue,neighborsWithLocation:WA,basemapMode:Ge})]}),m.jsx(Uf,{}),m.jsx(iu,{isOpen:Gt!==null,onCancel:()=>_r(null),onConfirm:Pe,title:"Remove Node?",message:`Remove "${sn}" from the contacts list? The node will reappear if it advertises again.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),m.jsx(Lc,{isOpen:on,onClose:()=>{Hr(!1),gr(!1),XA(),ur(!0),setTimeout(()=>Ke(!0),Oc)}}),m.jsx(Rf,{}),m.jsx(Lf,{visible:Re&&ft,onClose:()=>At(!1),settings:oe,onSettingsChange:me,partition:T,totalNodes:Object.keys(a).length,basemapMode:Ge})]})}export{Sd as default};
