import{d as X0,a5 as aa,r as j,eZ as ua,b_ as ca,cT as fa,cU as da,j as g,ak as xo,cV as ha,al as wo,m as s0,D as hn,c as n0,L as Yn,d7 as e0,Z as I0,e_ as Os,e$ as vo,f0 as ma,bQ as ga,bW as pa,bY as ya,a7 as bo,am as ko,A as R0,b as Ur,B as Ot,d8 as xa,bS as us,M as zs,S as Hs,c_ as Co,e as Eo,R as So,bk as mn,bf as yi,f1 as Mo,G as wa,K as va,d6 as ba,f2 as ka,ah as Bo,bs as xi,bu as Ca,E as Gs,F as Us,bU as Ea,aK as Sa,el as Do,f3 as Ma,bZ as Ba,f4 as Da,f5 as _o,a6 as dn,c7 as _a,f6 as To,f7 as Ta,f8 as ja,ap as jo,x as x0,f9 as Ro,bI as Ra,eX as Ia,bL as La,cY as Io,c$ as Na,P as Fa,fa as Pa,ex as Qa,fb as cs}from"./index-BOwCLZTK.js";import{u as Lo,b as Ar,S as J0,L as t0,P as Oa,c as za,M as Ha,d as Ga,B as Ua}from"./BasemapLayer-B-5TmAfZ.js";import{u as No,r as Fo,e as wi,f as vi,g as Va}from"./consumer-registry-CTjikLma.js";import{L as Hn,c as Wa}from"./link-scoring-CgjOR3NF.js";import{C as Ya}from"./ConfirmModal-DpSKXZ01.js";import{b as Ka,e as Za,a as Po,m as bi,s as $a,G as Cs,c as Qo,g as qa,M as Ja,E as Xa,u as Au,d as eu,i as tu,j as ru,k as nu}from"./max-vSbldOSt.js";import{D as Oo}from"./download-B9g5-0oH.js";import{D as su}from"./database-C6oOGn9y.js";import{H as iu,A as un,D as ki,p as ou,c as lu,u as ur}from"./useMapViewStore-DpXuD1iT.js";import{R as zo}from"./refresh-cw-C9txhqc9.js";import{E as Ho}from"./target-vmW1ltA0.js";import{F as au}from"./funnel-CWx99rlN.js";import{P as uu}from"./plus-ClrHVFhr.js";import{C as cu,a as Go,b as Es,c as fu}from"./easing-CsgXD0uy.js";import{Z as du}from"./zap-Bd-kARJ1.js";import{T as Vs}from"./trash-2-qMD09ppP.js";import{W as hu}from"./wifi-off-DC4jBRps.js";import{W as mu}from"./wifi-CI57D5A3.js";import{C as Uo,H as Ci,a as Lr,N as gu,b as pu}from"./badge-colors-DCbxcv7o.js";import{C as yu}from"./chevron-right-DJVm4pVP.js";import{T as xu,P as wu,R as vu}from"./Contacts-nDnNtpiy.js";import{c as bu}from"./node-types-C6okL8rE.js";import{L as ku}from"./LightSparkline-C68RXWon.js";import{M as Cu}from"./map-pin-C2z_C0J3.js";import"./triangle-alert-SO3tIa8w.js";import"./index-2RIoVPos.js";import"./usePipelineStore-Cw6U5jyB.js";import"./ping-LiBbR-Oy.js";import"./PageLayout-QKntxcnp.js";import"./listbox-C1tUi7YC.js";import"./element-movement-BLnr83nT.js";import"./MqttModeBadge-CSj5wNzF.js";import"./chat-utils-D21OFED5.js";import"./SignalIndicator-Calk-LyB.js";import"./CollisionExplorerModal-Cudk5ace.js";import"./monitor-smartphone-Dd11JEL9.js";import"./DataBox-BVnEv6Au.js";import"./circle-question-mark-XDnZ1ChV.js";import"./network-D0Fgg1y-.js";import"./activity-D5uH2SFx.js";import"./search-Ba9CRHru.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 Eu=[["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"}]],Ss=X0("boxes",Eu);/**
 * @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 Su=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Mu=X0("circle-alert",Su);/**
 * @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 Bu=[["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"}]],Du=X0("map",Bu);/**
 * @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:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],Tu=X0("mountain",_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 ju=[["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"}]],Vo=X0("nfc",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 Ru=[["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"}]],Iu=X0("sigma",Ru);/**
 * @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 Lu=[["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"}]],Nu=X0("swords",Lu);/**
 * @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 Fu=[["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"}]],Pu=X0("wrench",Fu);function Qu(c,u){return u.filter(y=>y.nodes.includes(c)).sort((y,x)=>x.avgCertainCount-y.avgCertainCount)}function Ou(c,u,p){const y=Qu(c,u),x=new Set,C=[];for(const T of y)for(const Q of T.edgeKeys)if(!x.has(Q)){x.add(Q);const D=p.get(Q);C.push({key:Q,certainCount:(D==null?void 0:D.certainCount)??0})}return C.sort((T,Q)=>Q.certainCount-T.certainCount),{loops:y,highlightedEdgeKeys:x,sortedEdges:C}}function zu(c){const u=new Map;for(const p of c)for(const y of p.edgeKeys){const x=u.get(y)??[];x.push(p),u.set(y,x)}return u}const Mn={MAX_THICKNESS_AT:300,MIN_VALIDATIONS:5},Hu=6,Ei=1;function Ms(c,u){const p=Math.max(Mn.MIN_VALIDATIONS,Math.min(c,Mn.MAX_THICKNESS_AT)),y=Math.log(Mn.MIN_VALIDATIONS),x=Math.log(Mn.MAX_THICKNESS_AT),T=(Math.log(p)-y)/(x-y);return Ei+(Hu-Ei)*T}const Gu=Uu(Vu);function Uu(c){return function(u,p,y=p){if(!((p=+p)>=0))throw new RangeError("invalid rx");if(!((y=+y)>=0))throw new RangeError("invalid ry");let{data:x,width:C,height:T}=u;if(!((C=Math.floor(C))>=0))throw new RangeError("invalid width");if(!((T=Math.floor(T!==void 0?T:x.length/C))>=0))throw new RangeError("invalid height");if(!C||!T||!p&&!y)return u;const Q=p&&c(p),D=y&&c(y),E=x.slice();return Q&&D?(Nr(Q,E,x,C,T),Nr(Q,x,E,C,T),Nr(Q,E,x,C,T),Fr(D,x,E,C,T),Fr(D,E,x,C,T),Fr(D,x,E,C,T)):Q?(Nr(Q,x,E,C,T),Nr(Q,E,x,C,T),Nr(Q,x,E,C,T)):D&&(Fr(D,x,E,C,T),Fr(D,E,x,C,T),Fr(D,x,E,C,T)),u}}function Nr(c,u,p,y,x){for(let C=0,T=y*x;C<T;)c(u,p,C,C+=y,1)}function Fr(c,u,p,y,x){for(let C=0,T=y*x;C<y;++C)c(u,p,C,C+T,y)}function Vu(c){const u=Math.floor(c);if(u===c)return Wu(c);const p=c-u,y=2*c+1;return(x,C,T,Q,D)=>{if(!((Q-=D)>=T))return;let E=u*C[T];const P=D*u,O=P+D;for(let z=T,V=T+P;z<V;z+=D)E+=C[Math.min(Q,z)];for(let z=T,V=Q;z<=V;z+=D)E+=C[Math.min(Q,z+P)],x[z]=(E+p*(C[Math.max(T,z-O)]+C[Math.min(Q,z+O)]))/y,E-=C[Math.max(T,z-P)]}}function Wu(c){const u=2*c+1;return(p,y,x,C,T)=>{if(!((C-=T)>=x))return;let Q=c*y[x];const D=T*c;for(let E=x,P=x+D;E<P;E+=T)Q+=y[Math.min(C,E)];for(let E=x,P=C;E<=P;E+=T)Q+=y[Math.min(C,E+D)],p[E]=Q/u,Q-=y[Math.max(x,E-D)]}}function Yu(c,u){let p=0;for(let y of c)y!=null&&(y=+y)>=y&&++p;return p}function Ku(c,u,p){let y;for(;;){const x=Ka(c,u,p);if(x===y||x===0||!isFinite(x))return[c,u];x>0?(c=Math.floor(c/x)*x,u=Math.ceil(u/x)*x):x<0&&(c=Math.ceil(c*x)/x,u=Math.floor(u*x)/x),y=x}}function Zu(c){return Math.max(1,Math.ceil(Math.log(Yu(c))/Math.LN2)+1)}var $u=Array.prototype,Wo=$u.slice;function qu(c,u){return c-u}function Ju(c){for(var u=0,p=c.length,y=c[p-1][1]*c[0][0]-c[p-1][0]*c[0][1];++u<p;)y+=c[u-1][1]*c[u][0]-c[u-1][0]*c[u][1];return y}const q0=c=>()=>c;function Xu(c,u){for(var p=-1,y=u.length,x;++p<y;)if(x=Ac(c,u[p]))return x;return 0}function Ac(c,u){for(var p=u[0],y=u[1],x=-1,C=0,T=c.length,Q=T-1;C<T;Q=C++){var D=c[C],E=D[0],P=D[1],O=c[Q],z=O[0],V=O[1];if(ec(D,O,u))return 0;P>y!=V>y&&p<(z-E)*(y-P)/(V-P)+E&&(x=-x)}return x}function ec(c,u,p){var y;return tc(c,u,p)&&rc(c[y=+(c[0]===u[0])],p[y],u[y])}function tc(c,u,p){return(u[0]-c[0])*(p[1]-c[1])===(p[0]-c[0])*(u[1]-c[1])}function rc(c,u,p){return c<=u&&u<=p||p<=u&&u<=c}function nc(){}var T0=[[],[[[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 Si(){var c=1,u=1,p=Zu,y=D;function x(E){var P=p(E);if(Array.isArray(P))P=P.slice().sort(qu);else{const O=Za(E,sc);for(P=Po(...Ku(O[0],O[1],P),P);P[P.length-1]>=O[1];)P.pop();for(;P[1]<O[0];)P.shift()}return P.map(O=>C(E,O))}function C(E,P){const O=P==null?NaN:+P;if(isNaN(O))throw new Error(`invalid value: ${P}`);var z=[],V=[];return T(E,O,function(W){y(W,E,O),Ju(W)>0?z.push([W]):V.push(W)}),V.forEach(function(W){for(var oA=0,J=z.length,eA;oA<J;++oA)if(Xu((eA=z[oA])[0],W)!==-1){eA.push(W);return}}),{type:"MultiPolygon",value:P,coordinates:z}}function T(E,P,O){var z=new Array,V=new Array,W,oA,J,eA,Z,uA;for(W=oA=-1,eA=cr(E[0],P),T0[eA<<1].forEach(sA);++W<c-1;)J=eA,eA=cr(E[W+1],P),T0[J|eA<<1].forEach(sA);for(T0[eA<<0].forEach(sA);++oA<u-1;){for(W=-1,eA=cr(E[oA*c+c],P),Z=cr(E[oA*c],P),T0[eA<<1|Z<<2].forEach(sA);++W<c-1;)J=eA,eA=cr(E[oA*c+c+W+1],P),uA=Z,Z=cr(E[oA*c+W+1],P),T0[J|eA<<1|Z<<2|uA<<3].forEach(sA);T0[eA|Z<<3].forEach(sA)}for(W=-1,Z=E[oA*c]>=P,T0[Z<<2].forEach(sA);++W<c-1;)uA=Z,Z=cr(E[oA*c+W+1],P),T0[Z<<2|uA<<3].forEach(sA);T0[Z<<3].forEach(sA);function sA(vA){var iA=[vA[0][0]+W,vA[0][1]+oA],fA=[vA[1][0]+W,vA[1][1]+oA],RA=Q(iA),DA=Q(fA),EA,yA;(EA=V[RA])?(yA=z[DA])?(delete V[EA.end],delete z[yA.start],EA===yA?(EA.ring.push(fA),O(EA.ring)):z[EA.start]=V[yA.end]={start:EA.start,end:yA.end,ring:EA.ring.concat(yA.ring)}):(delete V[EA.end],EA.ring.push(fA),V[EA.end=DA]=EA):(EA=z[DA])?(yA=V[RA])?(delete z[EA.start],delete V[yA.end],EA===yA?(EA.ring.push(fA),O(EA.ring)):z[yA.start]=V[EA.end]={start:yA.start,end:EA.end,ring:yA.ring.concat(EA.ring)}):(delete z[EA.start],EA.ring.unshift(iA),z[EA.start=RA]=EA):z[RA]=V[DA]={start:RA,end:DA,ring:[iA,fA]}}}function Q(E){return E[0]*2+E[1]*(c+1)*4}function D(E,P,O){E.forEach(function(z){var V=z[0],W=z[1],oA=V|0,J=W|0,eA=fs(P[J*c+oA]);V>0&&V<c&&oA===V&&(z[0]=Mi(V,fs(P[J*c+oA-1]),eA,O)),W>0&&W<u&&J===W&&(z[1]=Mi(W,fs(P[(J-1)*c+oA]),eA,O))})}return x.contour=C,x.size=function(E){if(!arguments.length)return[c,u];var P=Math.floor(E[0]),O=Math.floor(E[1]);if(!(P>=0&&O>=0))throw new Error("invalid size");return c=P,u=O,x},x.thresholds=function(E){return arguments.length?(p=typeof E=="function"?E:Array.isArray(E)?q0(Wo.call(E)):q0(E),x):p},x.smooth=function(E){return arguments.length?(y=E?D:nc,x):y===D},x}function sc(c){return isFinite(c)?c:NaN}function cr(c,u){return c==null?!1:+c>=u}function fs(c){return c==null||isNaN(c=+c)?-1/0:c}function Mi(c,u,p,y){const x=y-u,C=p-u,T=isFinite(x)||isFinite(C)?x/C:Math.sign(x)/Math.sign(C);return isNaN(T)?c:c+T-.5}function ic(c){return c[0]}function oc(c){return c[1]}function lc(){return 1}function ac(){var c=ic,u=oc,p=lc,y=960,x=500,C=20,T=2,Q=C*3,D=y+Q*2>>T,E=x+Q*2>>T,P=q0(20);function O(Z){var uA=new Float32Array(D*E),sA=Math.pow(2,-T),vA=-1;for(const LA of Z){var iA=(c(LA,++vA,Z)+Q)*sA,fA=(u(LA,vA,Z)+Q)*sA,RA=+p(LA,vA,Z);if(RA&&iA>=0&&iA<D&&fA>=0&&fA<E){var DA=Math.floor(iA),EA=Math.floor(fA),yA=iA-DA-.5,bA=fA-EA-.5;uA[DA+EA*D]+=(1-yA)*(1-bA)*RA,uA[DA+1+EA*D]+=yA*(1-bA)*RA,uA[DA+1+(EA+1)*D]+=yA*bA*RA,uA[DA+(EA+1)*D]+=(1-yA)*bA*RA}}return Gu({data:uA,width:D,height:E},C*sA),uA}function z(Z){var uA=O(Z),sA=P(uA),vA=Math.pow(2,2*T);return Array.isArray(sA)||(sA=Po(Number.MIN_VALUE,bi(uA)/vA,sA)),Si().size([D,E]).thresholds(sA.map(iA=>iA*vA))(uA).map((iA,fA)=>(iA.value=+sA[fA],V(iA)))}z.contours=function(Z){var uA=O(Z),sA=Si().size([D,E]),vA=Math.pow(2,2*T),iA=fA=>{fA=+fA;var RA=V(sA.contour(uA,fA*vA));return RA.value=fA,RA};return Object.defineProperty(iA,"max",{get:()=>bi(uA)/vA}),iA};function V(Z){return Z.coordinates.forEach(W),Z}function W(Z){Z.forEach(oA)}function oA(Z){Z.forEach(J)}function J(Z){Z[0]=Z[0]*Math.pow(2,T)-Q,Z[1]=Z[1]*Math.pow(2,T)-Q}function eA(){return Q=C*3,D=y+Q*2>>T,E=x+Q*2>>T,z}return z.x=function(Z){return arguments.length?(c=typeof Z=="function"?Z:q0(+Z),z):c},z.y=function(Z){return arguments.length?(u=typeof Z=="function"?Z:q0(+Z),z):u},z.weight=function(Z){return arguments.length?(p=typeof Z=="function"?Z:q0(+Z),z):p},z.size=function(Z){if(!arguments.length)return[y,x];var uA=+Z[0],sA=+Z[1];if(!(uA>=0&&sA>=0))throw new Error("invalid size");return y=uA,x=sA,eA()},z.cellSize=function(Z){if(!arguments.length)return 1<<T;if(!((Z=+Z)>=1))throw new Error("invalid cell size");return T=Math.floor(Math.log(Z)/Math.LN2),eA()},z.thresholds=function(Z){return arguments.length?(P=typeof Z=="function"?Z:Array.isArray(Z)?q0(Wo.call(Z)):q0(Z),z):P},z.bandwidth=function(Z){if(!arguments.length)return Math.sqrt(C*(C+1));if(!((Z=+Z)>=0))throw new Error("invalid bandwidth");return C=(Math.sqrt(4*Z*Z+1)-1)/2,eA()},z}function Bs(){const c=aa();return j.useMemo(()=>ua.getPackets(),[c])}function Bn({label:c,icon:u,status:p,detail:y}){return g.jsxs("div",{className:n0("flex items-center gap-3 py-3 px-4 radius-inset transition-base",p==="active"&&"bg-sys-blue/10",p==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",p==="pending"&&"opacity-40"),children:[g.jsx("div",{className:n0("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",p==="active"&&"bg-sys-blue/20",p==="complete"&&"bg-sys-blue/20",p==="pending"&&"bg-subtle-fill"),children:p==="complete"?g.jsx(hn,{className:"w-4 h-4 text-sys-blue"}):p==="active"?g.jsx(Yn,{className:"w-4 h-4 animate-spin text-sys-blue"}):g.jsx("span",{className:"text-fg-muted",children:u})}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("div",{className:n0("text-sm font-medium transition-colors",p==="active"&&"text-sys-blue",p==="complete"&&"text-sys-blue",p==="pending"&&"text-fg-muted"),children:c}),y&&p!=="pending"&&g.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:y})]})]})}function uc({isOpen:c,onClose:u}){const{packetCacheState:p,triggerDeepAnalysis:y}=ca(),x=fa(),C=da(),T=p.packetCount,[Q,D]=j.useState("fetching");j.useEffect(()=>{c&&y()},[c,y]),j.useEffect(()=>{if(c){if(p.isTopologyLoading)D("fetching");else if(x)D("analyzing"),setTimeout(()=>D("building"),500),setTimeout(()=>D("discovering"),1e3);else if(C>0&&!p.isTopologyLoading){D("complete");const W=setTimeout(()=>{u()},1500);return()=>clearTimeout(W)}}},[c,p.isTopologyLoading,x,C,u]);const E=Q==="complete",P=p.loadProgress,O=j.useMemo(()=>{if(P&&P.target>0){const W=(P.loaded/1e3).toFixed(1),oA=(P.target/1e3).toFixed(1);return`Loading... ${W}k / ${oA}k packets (${P.percent}%)`}return T>0?`${T.toLocaleString()} packets loaded`:"Connecting to database..."},[P,T]),z=W=>{const oA=["fetching","analyzing","building","discovering","complete"],J=oA.indexOf(Q),eA=oA.indexOf(W);return eA<J?"complete":eA===J?"active":"pending"},V=E?u:()=>{};return g.jsx(xo,{open:c,onClose:V,size:"sm",bottomSheet:!1,children:g.jsx(ha,{isLoading:!E,borderRadius:16,children:g.jsx(wo,{className:"p-6 radius-card overflow-hidden",children:E?g.jsxs("div",{className:"flex flex-col items-center py-6",children:[g.jsx(s0.div,{variants:$a,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:g.jsx(hn,{className:"w-8 h-8 text-sys-blue"})}),g.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),g.jsx("button",{onClick:u,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[g.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:g.jsx(Cs,{className:"w-5 h-5 text-sys-blue"})}),g.jsxs("div",{children:[g.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),g.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx(Bn,{label:"Fetching Packets",icon:g.jsx(Oo,{className:"w-4 h-4"}),status:z("fetching"),detail:O}),g.jsx(Bn,{label:"Analyzing Database",icon:g.jsx(su,{className:"w-4 h-4"}),status:z("analyzing"),detail:"Processing packet paths"}),g.jsx(Bn,{label:"Building Topology",icon:g.jsx(Cs,{className:"w-4 h-4"}),status:z("building"),detail:"Computing mesh edges"}),g.jsx(Bn,{label:"Discovering Nodes",icon:g.jsx(Qo,{className:"w-4 h-4"}),status:z("discovering"),detail:"Viterbi HMM ghost detection"})]}),g.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const cc=j.memo(uc),Yo=16,Ds=24,j0=Yo,fc=5,yr={textPrimary:I0[900],textSecondary:"#4A4A4A",textMuted:I0[500],border:"rgba(0, 0, 0, 0.12)",hoverBg:"rgba(0, 0, 0, 0.06)",disabledText:"rgba(0, 0, 0, 0.25)"},gr={nodeFill:e0.blue,nodeStroke:"rgba(255,255,255,0.9)",nodeColor:e0.indigo,localColor:e0.amber,hubColor:e0.purple,gatewayColor:e0.indigo,mobileColor:e0.orange,roomServerColor:e0.pink,neighborColor:e0.amber,edges:{rest:I0[700],restBright:I0[600],restDim:I0[800],hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:I0[400],hoverNeighbor:e0.amber,neighborRest:I0[500],neighborHover:e0.amber,highlight:"#FFD700"},edgeOpacity:.82};function Ws(){if(typeof window>"u")return gr;const c=Os(),u=vo();return{nodeFill:c.nodeFill,nodeStroke:c.nodeStroke,nodeColor:gr.nodeColor,localColor:c.localColor,hubColor:c.hubColor,gatewayColor:c.gatewayColor,mobileColor:c.mobileColor,roomServerColor:c.roomColor,neighborColor:c.neighborColor,edges:{rest:u.rest,restBright:u.restBright,restDim:u.restDim,hoverDirect:u.hoverDirect,hoverLoop:u.hoverLoop,hoverStandard:u.hoverStandard,hoverNeighbor:u.hoverNeighbor,neighborRest:gr.edges.neighborRest,neighborHover:gr.edges.neighborHover,highlight:u.highlight},edgeOpacity:gr.edgeOpacity}}const Dn=2e3,_n=750,dc="#00FF00",hc=500,Bi=500,Di=250,mc=150,Ko=200,gc=Ur.snappy,w0=yr,Zo=j.createContext("dark"),Kn=()=>j.useContext(Zo);function Pr({color:c,ring:u}){const p=j0-2;return g.jsx("span",{className:"shrink-0 rounded-full","aria-hidden":"true",style:{width:p,height:p,backgroundColor:u?"transparent":c,border:u?`${fc-1}px solid ${c}`:void 0,boxSizing:"border-box"}})}function ds({color:c,pattern:u="solid"}){return g.jsx("svg",{className:"shrink-0","aria-hidden":"true",width:18,height:6,viewBox:"0 0 18 6",children:g.jsx("line",{x1:0,y1:3,x2:18,y2:3,stroke:c,strokeWidth:3,strokeLinecap:"round",strokeDasharray:u==="dashed"?"5,3":u==="dotted"?"2,3":void 0})})}function A0({indicator:c,label:u,tooltip:p}){const y=Kn()==="light";return g.jsxs("div",{className:"flex items-center gap-1.5",children:[c,g.jsx("span",{className:n0(!y&&"text-fg-secondary"),style:y?{color:w0.textSecondary}:void 0,children:u}),p&&g.jsx(bo,{content:p,delay:Ko,children:g.jsx("span",{className:n0("cursor-help text-[11px] opacity-75 hover:opacity-100 transition-opacity",!y&&"text-fg-muted"),style:y?{color:w0.textMuted}:void 0,children:"ⓘ"})})]})}function pc(c){return`legend-section-${c.toLowerCase().replace(/\s+/g,"-")}`}function hs({title:c,tooltip:u,isOpen:p,onToggle:y,showDivider:x,children:C}){const T=Kn()==="light",Q=pc(c);return g.jsxs("div",{className:x?"mt-2 pt-2 border-t":"",style:x?{borderColor:T?w0.border:"var(--map-ui-border)"}:void 0,children:[g.jsxs("button",{type:"button",onClick:y,"aria-expanded":p,"aria-controls":Q,className:n0("group w-full flex items-center justify-between py-1 min-h-[44px] sm:min-h-0 font-medium transition-colors",!T&&"text-fg-secondary hover:text-fg-primary"),style:T?{color:w0.textSecondary}:void 0,children:[g.jsxs("span",{className:"flex items-center gap-1",children:[c,g.jsx(bo,{content:u,delay:Ko,children:g.jsx("span",{className:n0("cursor-help text-[11px] opacity-75 group-hover:opacity-100 transition-opacity",!T&&"text-fg-muted"),style:T?{color:w0.textMuted}:void 0,children:"ⓘ"})})]}),g.jsx(s0.span,{animate:{rotate:p?0:-90},transition:{duration:.15},"aria-hidden":"true",children:g.jsx(ko,{className:"w-3 h-3",style:T?{color:w0.textMuted}:{color:"var(--fg-muted)"}})})]}),g.jsx(R0,{initial:!1,children:p&&g.jsx(s0.div,{id:Q,role:"region","aria-label":c,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:gc,className:"overflow-hidden",children:g.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:C})})})]})}function _i({label:c,value:u,color:p}){const y=Kn()==="light";return g.jsxs("div",{className:n0("flex justify-between tabular-nums",!y&&"text-fg-muted"),style:y?{color:w0.textMuted}:void 0,children:[g.jsx("span",{children:c}),g.jsx("span",{style:p?{color:p}:y?{color:w0.textSecondary}:{color:"var(--fg-secondary)"},children:u})]})}function Ti({icon:c,color:u,title:p,subtitle:y}){const x=Kn()==="light";return g.jsx("div",{className:"mt-1.5 pt-1.5 border-t",style:{borderColor:x?w0.border:"var(--map-ui-border)"},children:g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"shrink-0",style:{color:u},children:c}),g.jsxs("div",{className:"flex flex-col min-w-0",children:[g.jsx("span",{className:"font-medium truncate",style:{color:u},children:p}),g.jsx("span",{className:n0("text-[10px] leading-tight",!x&&"text-fg-muted"),style:x?{color:w0.textMuted}:void 0,children:y})]})]})})}function yc(c){return c.some(([,u])=>{var y;const p=(y=u.contact_type)==null?void 0:y.toLowerCase();return p==="room server"||p==="room_server"||p==="room"||p==="server"})}function xc(c){let u=0;for(const p of c.txDelayRecommendations.values())p.networkRole==="backbone"&&u++;return u}function wc({showTopology:c,validatedPolylineCount:u,filteredNeighborCount:p,hasLocalNode:y,meshTopology:x,zeroHopNeighbors:C,neighborsWithLocation:T,basemapMode:Q="dark"}){const D=ma(),E=ga(),P=pa(),O=E.filter(sA=>sA.isLikelyReal).length,z=xc(x),V=C.size>0,[W,oA]=j.useState(!0),[J,eA]=j.useState(!0),[Z,uA]=j.useState(!0);return g.jsx(Zo.Provider,{value:Q,children:g.jsxs("div",{className:"map-control-surface p-2.5 text-xs",children:[g.jsxs(hs,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:W,onToggle:()=>oA(sA=>!sA),children:[g.jsx(A0,{indicator:g.jsx(Pr,{color:D.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),g.jsx(A0,{indicator:g.jsx(Pr,{color:D.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),yc(T)&&g.jsx(A0,{indicator:g.jsx(ya,{className:"w-3 h-3 shrink-0",style:{color:D.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."}),g.jsx(A0,{indicator:g.jsx(iu,{className:"w-3 h-3 shrink-0",style:{color:D.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running pyMC_Repeater."}),V&&g.jsx(A0,{indicator:g.jsx(Pr,{color:D.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),x.gatewayNodes.length>0&&g.jsx(A0,{indicator:g.jsx(Pr,{color:D.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),z>0&&g.jsx(A0,{indicator:g.jsx(Pr,{color:D.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),x.mobileNodes.length>0&&g.jsx(A0,{indicator:g.jsx(Pr,{color:D.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),O>0&&g.jsx(A0,{indicator:g.jsx(Qo,{className:"w-3 h-3 shrink-0",style:{color:D.ghostColor},strokeWidth:2.5}),label:`Ghost (${O})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),V&&g.jsxs(hs,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:J,onToggle:()=>eA(sA=>!sA),showDivider:!0,children:[g.jsx(A0,{indicator:g.jsx(ds,{color:Hn.YELLOW,pattern:"solid"}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),g.jsx(A0,{indicator:g.jsx(ds,{color:Hn.GREEN,pattern:"dashed"}),label:"Listener",tooltip:">67% listener. They hear us well."}),g.jsx(A0,{indicator:g.jsx(ds,{color:Hn.RED,pattern:"dotted"}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),c&&u>0&&g.jsxs(hs,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:Z,onToggle:()=>uA(sA=>!sA),showDivider:!0,children:[g.jsx(_i,{label:"Nodes",value:p+(y?1:0)}),x.hubNodes.length>0&&g.jsx(_i,{label:"Hubs",value:x.hubNodes.length,color:gr.hubColor}),x.loops.length>0&&g.jsx(Ti,{icon:g.jsx(zo,{className:"w-3 h-3"}),color:gr.edges.hoverLoop,title:`${x.loops.length} ${x.loops.length===1?"Loop":"Loops"}`,subtitle:"Redundant paths"}),P.totalPaths>0&&g.jsx(Ti,{icon:g.jsx(Ho,{className:"w-3 h-3"}),color:D.ghostColor,title:`${P.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]})})}const ji={repeater:"blue",companion:"cyan",room_server:"pink",hubs:"indigo",direct:"green"},Tn={repeater:"Repeaters",companion:"Companions",room_server:"Rooms",hubs:"Hubs",direct:"Direct"},Ri={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"},vc=["repeater","companion","room_server"],Ii=["hubs","direct"],Qr="!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",jn="!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",bc=()=>typeof window>"u"?!1:window.innerWidth<640;function kc({mapRef:c,showNeighborLines:u,onToggleNeighborLines:p,hasNeighborPolylines:y,nodeFilters:x,onToggleFilter:C,onToggleAll:T,filterCounts:Q,showCoverage:D,onToggleCoverage:E,showMinCut:P=!1,onToggleMinCut:O,hasMinCutData:z=!1,show3DTerrain:V,onToggle3DTerrain:W,basemapMode:oA,onToggleBasemap:J,isFullscreen:eA,onToggleFullscreen:Z,showLinkQuality:uA=!1,onToggleLinkQuality:sA,hasTraceLinks:vA=!1}){const[iA,fA]=j.useState(()=>!bc()),RA=()=>{var NA,GA;(GA=(NA=c.current)==null?void 0:NA.getMap())==null||GA.zoomIn()},DA=()=>{var NA,GA;(GA=(NA=c.current)==null?void 0:NA.getMap())==null||GA.zoomOut()},EA=()=>{var GA;const NA=(GA=c.current)==null?void 0:GA.getMap();NA&&NA.easeTo({bearing:0,pitch:0,duration:300})},yA="w-4 h-4",bA=oA==="light"?"#525252":"var(--fg-secondary)",LA=x.length>=un.length;return g.jsx(g.Fragment,{children:g.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:[g.jsxs("div",{className:"map-control-surface flex flex-nowrap items-center gap-0.5 sm:gap-1 p-1 overflow-hidden",children:[y&&g.jsx(Ot,{plain:!0,color:u?"warning":"muted",onClick:p,title:u?"Hide edge lines":"Show edge lines","aria-label":u?"Hide edge lines":"Show edge lines","aria-pressed":u,className:Qr,"data-tint":u?"warning":void 0,children:g.jsx(xa,{className:yA})}),g.jsx(Ot,{plain:!0,color:"muted",onClick:()=>fA(NA=>!NA),title:iA?"Hide node filters":"Show node filters","aria-label":iA?"Collapse node filters":"Expand node filters","aria-expanded":iA,className:Qr,children:g.jsx(au,{className:yA})}),g.jsx(R0,{initial:!1,children:iA&&g.jsxs(s0.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:[g.jsx(us,{color:LA?"green":"zinc",customColor:LA?void 0:bA,onClick:T,title:"Show all nodes","aria-pressed":LA,"aria-label":"Show all node types",className:"shrink-0",children:"All"}),vc.map(NA=>{const GA=Q[NA];if(GA===0)return null;const kA=!LA&&x.includes(NA);return g.jsx(us,{color:kA?ji[NA]:"zinc",customColor:kA?void 0:bA,onClick:()=>C(NA),title:Ri[NA],"aria-pressed":kA,"aria-label":`${Tn[NA]} (${GA})`,className:"shrink-0",children:Tn[NA]},NA)}),Ii.some(NA=>Q[NA]>0)&&g.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"}),Ii.map(NA=>{const GA=Q[NA];if(GA===0)return null;const kA=!LA&&x.includes(NA);return g.jsx(us,{color:kA?ji[NA]:"zinc",customColor:kA?void 0:bA,onClick:()=>C(NA),title:Ri[NA],"aria-pressed":kA,"aria-label":`${Tn[NA]} (${GA})`,className:"shrink-0",children:Tn[NA]},NA)})]})}),z&&O&&g.jsx(Ot,{plain:!0,color:P?"primary":"muted",onClick:O,title:P?"Hide community partition":"Show community partition","aria-label":P?"Hide community partition":"Show community partition","aria-pressed":P,className:Qr,"data-tint":P?"primary":void 0,children:g.jsx(Ss,{className:yA})}),g.jsx(Ot,{plain:!0,color:oA==="light"?"primary":"muted",onClick:J,title:oA==="light"?"Switch to dark map":"Switch to light map","aria-label":oA==="light"?"Switch to dark map":"Switch to light map","aria-pressed":oA==="light",className:Qr,"data-tint":oA==="light"?"primary":void 0,children:oA==="light"?g.jsx(zs,{className:yA}):g.jsx(Hs,{className:yA})}),g.jsx(Ot,{plain:!0,color:V?"success":"muted",onClick:W,title:V?"Disable 3D terrain":"Enable 3D terrain","aria-label":V?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":V,className:Qr,"data-tint":V?"success":void 0,children:g.jsx(Tu,{className:yA})}),g.jsx(Ot,{plain:!0,color:"muted",onClick:Z,title:eA?"Exit fullscreen":"Fullscreen","aria-label":eA?"Exit fullscreen":"Enter fullscreen","aria-pressed":eA,className:Qr,children:eA?g.jsx(qa,{className:yA}):g.jsx(Ja,{className:yA})})]}),g.jsxs("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:[g.jsx(Ot,{plain:!0,color:"muted",onClick:RA,title:"Zoom in","aria-label":"Zoom in",className:jn,children:g.jsx(uu,{className:yA})}),g.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),g.jsx(Ot,{plain:!0,color:"muted",onClick:DA,title:"Zoom out","aria-label":"Zoom out",className:jn,children:g.jsx(Co,{className:yA})}),g.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),g.jsx(Ot,{plain:!0,color:"muted",onClick:EA,title:"Reset bearing to north","aria-label":"Reset bearing to north",className:jn,children:g.jsx(cu,{className:yA})})]}),vA&&sA&&g.jsx("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:g.jsx(Ot,{plain:!0,color:uA?"success":"muted",onClick:sA,title:uA?"Hide link quality overlay":"Show link quality overlay","aria-label":uA?"Hide link quality overlay":"Show link quality overlay","aria-pressed":uA,className:jn,"data-tint":uA?"success":void 0,children:g.jsx(Vo,{className:yA})})})]})})}const Cc="#4ADE80",Ec="#16A34A",Sc="rgba(10, 26, 10, 1)",Mc="rgba(220, 252, 231, 1)",ms={text:yr.textSecondary,activeText:Ec,activeBg:Mc},Bc={activeBg:Sc},fr="DeepAnalysis",Dc=700,Li="abcdefghijklmnopqrstuvwxyz0123456789";function _c(){return Li[Math.floor(Math.random()*Li.length)]}function Tc({isActive:c,hasAnalyzed:u,isLoading:p,onClick:y,basemapMode:x="dark"}){const C=x==="light",T=C?ms.text:void 0,Q=C?ms.activeText:Cc,[D,E]=j.useState(!1),[P,O]=j.useState(fr),z=j.useRef(!1),V=j.useRef(null),[W]=j.useState(()=>{var Z;return typeof window<"u"&&(((Z=window.matchMedia)==null?void 0:Z.call(window,"(hover: hover)").matches)??!1)}),oA=D&&!c&&!p&&W;j.useEffect(()=>{if(D&&!c&&!p&&!z.current){z.current=!0;const Z=performance.now(),uA=sA=>{const vA=sA-Z,iA=Math.min(vA/Dc,1),fA=Math.floor(iA*fr.length);let RA="";for(let DA=0;DA<fr.length;DA++)DA<fA?RA+=fr[DA]:fr[DA]===" "?RA+=" ":RA+=_c();O(RA),iA<1?V.current=requestAnimationFrame(uA):O(fr)};V.current=requestAnimationFrame(uA)}return D||(V.current&&(cancelAnimationFrame(V.current),V.current=null),z.current=!1,O(fr)),()=>{V.current&&cancelAnimationFrame(V.current)}},[D,c,p]);const J=p?"Analyzing...":P,eA=p?"Analyzing packet history":u?c?"Hide topology edges":"Show topology edges":"Load full packet history and build topology";return g.jsxs("button",{onClick:y,onMouseEnter:()=>W&&E(!0),onMouseLeave:()=>W&&E(!1),onPointerEnter:()=>W&&E(!0),onPointerLeave:()=>W&&E(!1),disabled:p,className:`map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base ${p?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:C?ms.activeBg:Bc.activeBg}},title:eA,"aria-label":eA,"aria-pressed":c,children:[p?g.jsx(Yn,{className:"w-3.5 h-3.5 shrink-0 animate-spin",style:{color:Q}}):g.jsx(Cs,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${c?"":"text-fg-secondary"}`,style:{...c&&{color:Q},...oA&&{color:Q},...!c&&!oA&&T&&{color:T}}}),g.jsx("span",{className:`${c?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:c||oA?700:500,letterSpacing:"-0.01em",lineHeight:1,...c&&{color:Q},...oA&&{color:Q},...!c&&!oA&&T&&{color:T}},children:J})]})}const jc=e0.teal,Rc="#0D7377",Ic="rgba(10, 36, 32, 1)",Lc="rgba(204, 251, 241, 1)",gs={text:yr.textSecondary,activeTeal:Rc,activeBg:Lc},Nc={activeBg:Ic},Ni="LiveTrace",Fc=400,Fi=100;function Pc({isActive:c,onClick:u,basemapMode:p="dark"}){const y=p==="light",x=y?gs.text:void 0,C=y?gs.activeTeal:jc,[T,Q]=j.useState(!1),[D,E]=j.useState(0),P=j.useRef(!1),O=j.useRef(null),[z,V]=j.useState(0),W=j.useRef(!1),[oA]=j.useState(()=>{var uA;return typeof window<"u"&&(((uA=window.matchMedia)==null?void 0:uA.call(window,"(hover: hover)").matches)??!1)}),J=T&&!c&&oA;j.useEffect(()=>{J&&!W.current&&(W.current=!0,V(1),setTimeout(()=>V(2),Fi),setTimeout(()=>V(3),Fi*2)),T||(W.current=!1,V(0))},[J,T]),j.useEffect(()=>{if(T&&!c&&!P.current){P.current=!0;const uA=performance.now(),sA=vA=>{const iA=vA-uA,fA=Math.min(iA/Fc,1);E(fA),fA<1&&(O.current=requestAnimationFrame(sA))};O.current=requestAnimationFrame(sA)}return T||(O.current&&(cancelAnimationFrame(O.current),O.current=null),P.current=!1,E(0)),()=>{O.current&&cancelAnimationFrame(O.current)}},[T,c]);const eA=uA=>{if(c)return C;if(!J)return x;const sA=Ni.length,vA=D*(sA+2);return uA>=vA-2&&uA<vA?"#FFFFFF":C},Z=c?"Disable live packet tracing":"Enable live packet tracing";return g.jsxs("button",{onClick:u,onMouseEnter:()=>oA&&Q(!0),onMouseLeave:()=>oA&&Q(!1),onPointerEnter:()=>oA&&Q(!0),onPointerLeave:()=>oA&&Q(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:y?gs.activeBg:Nc.activeBg}},title:c?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing","aria-label":Z,"aria-pressed":c,children:[g.jsx(du,{className:`w-3.5 h-3.5 shrink-0 ${c?"":"text-fg-secondary"}`,fill:z===1?"#FFFFFF":z===3?C:"none",stroke:z===1||z===2?"#FFFFFF":c||J?C:x||"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),g.jsx("span",{className:`${c?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:c||J?700:500,letterSpacing:"-0.01em",lineHeight:1},children:Ni.split("").map((uA,sA)=>g.jsx("span",{style:{color:eA(sA)||void 0},children:uA},sA))})]})}const Pi=.2,Qc="rgba(26, 20, 8, 1)",Oc="rgba(254, 243, 199, 1)",Rn={text:yr.textSecondary,activeBg:Oc,disabledText:yr.disabledText},zc={activeBg:Qc},ps=.01,ys=1,Qi="#fe8019",Hc="'Wardrive', serif",_s=1.45,Gc=_s*1.1,Uc=80;function Vc({isActive:c,onClick:u,brightness:p=.7,onBrightnessChange:y,basemapMode:x="dark"}){const C=x==="light",T=C?Rn.text:void 0,[Q,D]=j.useState(!1),[E,P]=j.useState(!1),[O]=j.useState(()=>{var uA;return typeof window<"u"&&(((uA=window.matchMedia)==null?void 0:uA.call(window,"(hover: hover)").matches)??!1)});j.useEffect(()=>{if(!Q||c)return;const uA=requestAnimationFrame(()=>P(!0)),sA=setTimeout(()=>P(!1),Uc);return()=>{cancelAnimationFrame(uA),clearTimeout(sA)}},[Q,c]);const z=Math.max(ps,Math.min(ys,p)),V=uA=>{uA.stopPropagation();const sA=Math.min(ys,z+Pi);y==null||y(sA)},W=uA=>{uA.stopPropagation();const sA=Math.max(ps,z-Pi);y==null||y(sA)},oA=z<ys-.001,J=z>ps+.001,eA=Q&&!c&&O,Z=c?"Configure wardriving coverage":"Show wardriving coverage";return g.jsxs("button",{onClick:u,onMouseEnter:()=>O&&D(!0),onMouseLeave:()=>O&&D(!1),onPointerEnter:()=>O&&D(!0),onPointerLeave:()=>O&&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",...c&&{backgroundColor:C?Rn.activeBg:zc.activeBg}},title:Z,"aria-label":Z,"aria-pressed":c,children:[g.jsx(Nu,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${c?"text-sys-amber":"text-fg-secondary"}`,style:eA?{color:Qi}:!c&&T?{color:T}:void 0}),g.jsx("span",{className:`${c?"text-sys-amber":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:c||eA?Hc:"ui-monospace, SFMono-Regular, monospace",fontSize:c||eA?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:c?`scale(${_s})`:eA?`scale(${E?Gc:_s})`:void 0,transformOrigin:"left center",...eA?{color:Qi}:!c&&T?{color:T}:{}},children:"Wardrive"}),c&&y&&g.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[g.jsx("button",{onClick:W,disabled:!J,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${J?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:J?void 0:{color:C?Rn.disabledText:"rgba(251, 191, 36, 0.3)"},title:`Decrease opacity (${Math.round(z*100)}%)`,"aria-label":`Decrease opacity, currently ${Math.round(z*100)}%`,children:g.jsx(zs,{className:"w-3.5 h-3.5"})}),g.jsx("button",{onClick:V,disabled:!oA,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 ${oA?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:oA?void 0:{color:C?Rn.disabledText:"rgba(251, 191, 36, 0.3)"},title:`Increase opacity (${Math.round(z*100)}%)`,"aria-label":`Increase opacity, currently ${Math.round(z*100)}%`,children:g.jsx(Hs,{className:"w-3.5 h-3.5"})})]})]})}const Wc="0123456789bcdefghjkmnpqrstuvwxyz";function Yc(c){let u=!0,p=-90,y=90,x=-180,C=180;for(const T of c.toLowerCase()){const Q=Wc.indexOf(T);if(Q!==-1)for(let D=4;D>=0;D--){const E=Q>>D&1;if(u){const P=(x+C)/2;E?x=P:C=P}else{const P=(p+y)/2;E?p=P:y=P}u=!u}}return{lat:(p+y)/2,lon:(x+C)/2}}function Kc(c){return Math.exp(-c*Math.LN2/7)}const Ts="pymc-wardriving-url",$o="pymc-wardriving-enabled",qo="pymc-wardriving-brightness",Oi=.7;function Zc(){return typeof localStorage>"u"?"":localStorage.getItem(Ts)||""}function zi(c){typeof localStorage>"u"||(c?localStorage.setItem(Ts,c):localStorage.removeItem(Ts))}function $c(){return typeof localStorage>"u"?!1:localStorage.getItem($o)==="true"}function In(c){typeof localStorage>"u"||localStorage.setItem($o,String(c))}function qc(){if(typeof localStorage>"u")return Oi;const c=localStorage.getItem(qo);if(c){const u=parseFloat(c);if(!isNaN(u)&&u>=.01&&u<=1)return u}return Oi}function Jc(c){if(typeof localStorage>"u")return;const u=Math.max(.01,Math.min(1,c));localStorage.setItem(qo,String(u))}const Xc=8e3;async function Af(c,u={},p=Xc){const y=new AbortController,x=setTimeout(()=>y.abort(),p);try{return await fetch(c,{...u,signal:y.signal})}catch(C){throw C instanceof Error&&C.name==="AbortError"?new Error(`Connection timed out after ${p/1e3}s`):C}finally{clearTimeout(x)}}async function ef(c){const p=`${c.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,y=await Af(p,{headers:{Accept:"application/json"}});if(!y.ok)throw new Error(`Failed to fetch precise samples: ${y.status}`);return y.json()}function tf(c,u=null){if(c!==null){const y=(Math.max(-12,Math.min(12,c))+12)/24;if(u!==null){const C=(Math.max(-120,Math.min(-50,u))+120)/70;return y*.8+C*.2}return y}return u!==null?(Math.max(-120,Math.min(-50,u))+120)/70:.5}function rf(c){var p;const u=[];for(const y of c.keys){if(!y.observed)continue;const{lat:x,lon:C}=Yc(y.hash),T=parseInt(y.time,10),Q=isNaN(T)?30:(Date.now()-T)/(1e3*60*60*24),D=Kc(Q),P=tf(y.snr,y.rssi)*(.3+D*.7);u.push({lat:x,lon:C,successRate:y.observed?1:0,weight:P,totalSamples:1,ageDays:Q,geohash:y.hash,repeaters:((p=y.path)==null?void 0:p.map(O=>O.toLowerCase()))||[]})}return u}const cn=Eo((c,u)=>({status:"idle",isVisible:$c(),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:Zc(),brightness:qc(),isModalOpen:!1,openModal:()=>c({isModalOpen:!0}),closeModal:()=>c({isModalOpen:!1}),setUrl:p=>c({url:p}),setBrightness:p=>{const y=Math.max(.01,Math.min(1,p));Jc(y),c({brightness:y})},toggleVisibility:()=>{const p=!u().isVisible;In(p),c({isVisible:p})},setVisible:p=>{In(p),c({isVisible:p})},loadCoverage:async p=>{if(!p.trim())return c({error:"Please enter a URL",status:"error"}),!1;try{new URL(p.trim())}catch{return c({error:"Invalid URL format",status:"error"}),!1}c({error:null,status:"connecting"});try{c({status:"loading"});const y=await ef(p.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");c({status:"processing"});const x=rf(y);if(x.length===0)throw new Error("No valid coverage points found");return c({coveragePoints:x,repeaters:[],stats:{coverageCount:x.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:p.trim()}),zi(p.trim()),In(!0),!0}catch(y){const x=y instanceof Error?y.message:"Failed to load coverage data";let C=x;return x.includes("timed out")?C="Connection timed out. Server may be unreachable or slow.":x.includes("Failed to fetch")||x.includes("NetworkError")?C="Could not connect to server. Check the URL and try again.":x.includes("CORS")?C="Server does not allow cross-origin requests.":x.includes("404")?C="Coverage endpoint not found. Check the URL.":(x.includes("ERR_NAME_NOT_RESOLVED")||x.includes("DNS"))&&(C="Server not found. Check the URL for typos."),c({error:C,status:"error"}),!1}},clearCoverage:()=>{c({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),zi(""),In(!1)}})),nf={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"},Jo={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)"},Xo=j.createContext({theme:Jo,isLight:!1});function xr(){return j.useContext(Xo)}function sf({status:c,hasData:u}){const{theme:p,isLight:y}=xr(),x=j.useMemo(()=>c==="connecting"||c==="loading"||c==="processing"?{icon:g.jsx(Yn,{className:"w-3.5 h-3.5 animate-spin"}),label:c==="connecting"?"Connecting...":c==="loading"?"Loading...":"Processing...",color:p.warning,bg:p.warningBg}:c==="error"?{icon:g.jsx(hu,{className:"w-3.5 h-3.5"}),label:"Disconnected",color:p.error,bg:p.errorBg}:u?{icon:g.jsx(mu,{className:"w-3.5 h-3.5"}),label:"Connected",color:p.success,bg:p.successBg}:{icon:g.jsx(So,{className:"w-3.5 h-3.5"}),label:"Ready",color:p.textMuted,bg:y?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},[c,u,p,y]);return g.jsxs(s0.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,g.jsx("span",{children:x.label})]},x.label)}function of({status:c}){const{theme:u}=xr(),p=j.useMemo(()=>{switch(c){case"connecting":return 25;case"loading":return 60;case"processing":return 90;default:return 0}},[c]);return p===0?null:g.jsx(s0.div,{initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},exit:{opacity:0,scaleY:0},className:"h-1 rounded-full overflow-hidden origin-top",style:{backgroundColor:u.sliderTrack},children:g.jsx(s0.div,{className:"h-full rounded-full",style:{backgroundColor:u.primary},initial:{width:0},animate:{width:`${p}%`},transition:{duration:.4,ease:"easeOut"}})})}function Hi({variant:c,title:u,description:p,onDismiss:y}){const{theme:x}=xr(),C=j.useMemo(()=>{switch(c){case"success":return{icon:g.jsx(hn,{className:"w-4 h-4"}),color:x.success,bg:x.successBg,border:x.successBorder};case"error":return{icon:g.jsx(Mu,{className:"w-4 h-4"}),color:x.error,bg:x.errorBg,border:x.errorBorder};case"info":return{icon:g.jsx(Du,{className:"w-4 h-4"}),color:x.info,bg:x.infoBg,border:x.infoBorder}}},[c,x]);return g.jsxs(s0.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:Ur.snappy,className:"flex items-start gap-3 p-3 rounded-lg border",style:{backgroundColor:C.bg,borderColor:C.border,color:C.color},children:[g.jsx("div",{className:"shrink-0 mt-0.5",children:C.icon}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"text-sm font-medium",children:u}),p&&g.jsx("p",{className:"text-xs mt-0.5 opacity-80",children:p})]}),y&&g.jsx("button",{onClick:y,className:"shrink-0 p-1 rounded hover:bg-black/10 transition-colors","aria-label":"Dismiss",children:g.jsx(mn,{className:"w-3.5 h-3.5"})})]})}function lf({value:c,onChange:u,onSubmit:p,disabled:y}){const{theme:x,isLight:C}=xr(),[T,Q]=j.useState(!1),D=E=>{E.key==="Enter"&&!E.shiftKey&&!y&&(E.preventDefault(),p())};return g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("label",{className:"block text-sm font-medium",style:{color:x.textSecondary},children:"Coverage Server URL"}),g.jsxs("div",{className:"relative",children:[g.jsx("input",{type:"url",value:c,onChange:E=>u(E.target.value),onKeyDown:D,onFocus:()=>Q(!0),onBlur:()=>Q(!1),placeholder:"https://coverage.wcmesh.com",disabled:y,className:n0("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:T?x.borderFocus:x.border,color:x.text,boxShadow:T?`0 0 0 3px ${C?"rgba(59, 130, 246, 0.15)":"rgba(139, 92, 246, 0.15)"}`:"none"}}),c&&!y&&g.jsx("button",{onClick:()=>u(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 rounded transition-colors",style:{color:x.textMuted},onMouseEnter:E=>E.currentTarget.style.color=x.text,onMouseLeave:E=>E.currentTarget.style.color=x.textMuted,"aria-label":"Clear URL",children:g.jsx(mn,{className:"w-4 h-4"})})]}),g.jsx("p",{className:"text-xs",style:{color:x.textMuted},children:"Press Enter to connect, or use the Connect button below"})]})}function af({value:c,onChange:u}){const{theme:p,isLight:y}=xr(),x=Math.round(c*100);return g.jsx(s0.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:Ur.gentle,className:"overflow-hidden",children:g.jsx("div",{className:"p-3 rounded-lg border",style:{backgroundColor:p.bgSubtle,borderColor:p.border},children:g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsxs("div",{className:"relative w-4 h-4",children:[g.jsx(zs,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:p.textMuted,opacity:c<.5?1:0}}),g.jsx(Hs,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:p.primary,opacity:c>=.5?1:0}})]}),g.jsxs("div",{className:"flex-1",children:[g.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[g.jsx("span",{className:"text-xs font-medium",style:{color:p.textSecondary},children:"Layer Opacity"}),g.jsxs("span",{className:"text-xs font-mono tabular-nums px-1.5 py-0.5 rounded",style:{color:p.text,backgroundColor:y?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)"},children:[x,"%"]})]}),g.jsx("input",{type:"range",min:5,max:100,value:x,onChange:C=>u(Number(C.target.value)/100),className:n0("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, ${p.primary} ${x}%, ${p.sliderTrack} ${x}%)`,"--thumb-color":p.sliderThumb}}),g.jsx("style",{children:`
              input[type="range"]::-webkit-slider-thumb {
                background-color: ${p.sliderThumb};
              }
              input[type="range"]::-moz-range-thumb {
                background-color: ${p.sliderThumb};
              }
            `})]})]})})})}function uf({coverageCount:c,repeaterCount:u,lastUpdated:p}){const{theme:y}=xr();return g.jsxs("div",{className:"grid grid-cols-3 gap-2 p-3 rounded-lg border",style:{backgroundColor:y.bgSubtle,borderColor:y.border},children:[g.jsxs("div",{className:"text-center",children:[g.jsx(ki,{value:c,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),g.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Points"})]}),g.jsxs("div",{className:"text-center border-x",style:{borderColor:y.border},children:[g.jsx(ki,{value:u,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),g.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Repeaters"})]}),g.jsxs("div",{className:"text-center",children:[g.jsxs("div",{className:"flex items-center justify-center gap-1",children:[g.jsx(Uo,{className:"w-3.5 h-3.5",style:{color:y.textMuted}}),g.jsx("span",{className:"text-lg font-semibold tabular-nums",style:{color:y.text},children:p?p.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"—"})]}),g.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Updated"})]})]})}function Gi({icon:c,label:u,onClick:p,disabled:y,variant:x="default",active:C}){const{theme:T,isLight:Q}=xr(),D=j.useMemo(()=>x==="danger"?{text:T.error,hoverBg:Q?"rgba(220, 38, 38, 0.08)":"rgba(239, 68, 68, 0.15)"}:{text:C?T.primary:T.textSecondary,hoverBg:T.hoverBg},[x,C,T,Q]);return g.jsxs("button",{onClick:p,disabled:y,className:n0("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:D.text},onMouseEnter:E=>!y&&(E.currentTarget.style.backgroundColor=D.hoverBg),onMouseLeave:E=>E.currentTarget.style.backgroundColor="transparent",children:[c,g.jsx("span",{children:u})]})}function cf(){const c=Lo(),u=c==="light",p=u?nf:Jo,{isModalOpen:y,closeModal:x,status:C,isVisible:T,stats:Q,error:D,url:E,brightness:P,loadCoverage:O,clearCoverage:z,toggleVisibility:V,setUrl:W,setBrightness:oA}=cn(),J=C==="connecting"||C==="loading"||C==="processing",eA=Q.coverageCount>0,[Z,uA]=j.useState(!0),[sA,vA]=j.useState(E);j.useEffect(()=>{vA(E)},[E]),j.useEffect(()=>{C==="error"&&uA(!0)},[C]);const iA=j.useCallback(async()=>{await O(sA)},[sA,O]),fA=j.useCallback(()=>{vA(""),z()},[z]),RA=j.useCallback(yA=>{vA(yA),W(yA)},[W]),DA=j.useCallback(()=>{J||x()},[J,x]),EA=sA.trim().length>0&&!J;return g.jsx(Xo.Provider,{value:{theme:p,isLight:u},children:g.jsxs(xo,{open:y,onClose:DA,size:"md",bottomSheet:!0,basemapMode:c,children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:p.border},children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:p.bgSubtle,color:p.primary},children:g.jsx(So,{className:"w-5 h-5"})}),g.jsxs("div",{children:[g.jsx("h2",{className:"type-micro",style:{color:p.text},children:"Wardriving Coverage"}),g.jsx("p",{className:"text-xs",style:{color:p.textMuted},children:"RF coverage heatmap overlay"})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(sf,{status:C,hasData:eA}),!J&&g.jsxs(g.Fragment,{children:[g.jsx("button",{onClick:DA,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:p.primary},children:"Done"}),g.jsx("button",{onClick:DA,className:"hidden sm:flex items-center justify-center p-2 rounded-lg transition-colors",style:{color:p.textMuted},onMouseEnter:yA=>{yA.currentTarget.style.color=p.text,yA.currentTarget.style.backgroundColor=p.hoverBg},onMouseLeave:yA=>{yA.currentTarget.style.color=p.textMuted,yA.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:g.jsx(mn,{className:"w-5 h-5"})})]})]})]}),g.jsx(R0,{children:J&&g.jsx(of,{status:C})}),g.jsxs(wo,{className:"space-y-4",children:[g.jsx(lf,{value:sA,onChange:RA,onSubmit:iA,disabled:J}),g.jsx(R0,{children:C==="error"&&D&&Z&&g.jsx(Hi,{variant:"error",title:"Connection Failed",description:D,onDismiss:()=>uA(!1)})}),g.jsx(R0,{children:C==="success"&&eA&&g.jsx(Hi,{variant:"success",title:"Coverage Data Loaded",description:"Adjust opacity below, then close to view on map"})}),g.jsx(R0,{children:eA&&!J&&g.jsx(s0.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:Ur.snappy,children:g.jsx(uf,{coverageCount:Q.coverageCount,repeaterCount:Q.repeaterCount,lastUpdated:Q.lastUpdated})})}),g.jsx(R0,{children:eA&&!J&&g.jsx(af,{value:P,onChange:oA})})]}),g.jsxs("div",{className:"flex items-center justify-between p-4 border-t",style:{borderColor:p.border},children:[g.jsx("div",{className:"flex items-center gap-1",children:g.jsx(R0,{children:eA&&g.jsxs(s0.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:Ur.snappy,className:"flex items-center gap-1",children:[g.jsx(Gi,{icon:T?g.jsx(Xa,{className:"w-4 h-4"}):g.jsx(Ho,{className:"w-4 h-4"}),label:T?"Hide":"Show",onClick:V,disabled:J,active:T}),g.jsx(Gi,{icon:g.jsx(Vs,{className:"w-4 h-4"}),label:"Clear",onClick:fA,disabled:J,variant:"danger"})]})})}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Ot,{plain:!0,color:"muted",onClick:DA,disabled:J,children:eA?"Done":"Cancel"}),g.jsx(Ot,{color:"warning",onClick:iA,disabled:!EA,children:J?g.jsxs(g.Fragment,{children:[g.jsx(Yn,{"data-slot":"icon",className:"animate-spin"}),C==="connecting"?"Connecting...":C==="loading"?"Loading...":"Processing..."]}):eA?g.jsxs(g.Fragment,{children:[g.jsx(zo,{"data-slot":"icon"}),"Refresh"]}):g.jsxs(g.Fragment,{children:[g.jsx(Oo,{"data-slot":"icon"}),"Connect"]})})]})]})]})})}const ff={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5},r0={...yr,trackBg:yr.border};function Ln({label:c,value:u,min:p,max:y,step:x,unit:C,formatValue:T,onChange:Q,isLightMode:D}){const E=T?T(u):u.toFixed(2);return g.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[g.jsx("span",{className:"text-xs font-medium w-14 sm:w-16 shrink-0",style:D?{color:r0.textSecondary}:{color:"var(--fg-secondary)"},children:c}),g.jsx("input",{type:"range",min:p,max:y,step:x,value:u,onChange:P=>Q(parseFloat(P.target.value)),className:`flex-1 h-1.5 rounded-full appearance-none cursor-pointer
                   [&::-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`,style:D?{backgroundColor:r0.trackBg}:{backgroundColor:"var(--elevated)"}}),g.jsxs("span",{className:"text-xs font-mono tabular-nums w-12 sm:w-14 text-right shrink-0",style:D?{color:r0.textPrimary}:{color:"var(--fg-muted)"},children:[E,C&&g.jsx("span",{className:"ml-0.5 opacity-70",style:D?{color:r0.textMuted}:void 0,children:C})]})]})}function Nn({icon:c,label:u,value:p,subtext:y,isLightMode:x}){return g.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 py-0.5 sm:py-1",children:[g.jsx("div",{style:x?{color:r0.textMuted}:{color:"var(--fg-muted)"},children:c}),g.jsx("div",{className:"flex-1 min-w-0",children:g.jsx("div",{className:"text-[10px] sm:text-xs truncate",style:x?{color:r0.textSecondary}:{color:"var(--fg-secondary)"},children:u})}),g.jsxs("div",{className:"text-right",children:[g.jsx("div",{className:"text-xs font-mono tabular-nums",style:x?{color:r0.textPrimary}:{color:"var(--fg-primary)"},children:p}),y&&g.jsx("div",{className:"text-[9px] leading-tight opacity-70",style:x?{color:r0.textMuted}:{color:"var(--fg-muted)"},children:y})]})]})}function df({visible:c,onClose:u,settings:p,onSettingsChange:y,partition:x,totalNodes:C,basemapMode:T="dark"}){const Q=Au(),D=j.useRef(null),E=T==="light",P=j.useMemo(()=>{if(!x)return{numCommunities:0,avgCommunitySize:0,minCommunitySize:0,maxCommunitySize:0,fiedlerValue:0,modularity:0,coveragePercent:0};const V=Array.from(x.communities.values()).map(oA=>oA.length),W=V.reduce((oA,J)=>oA+J,0);return{numCommunities:x.numCommunities,avgCommunitySize:V.length>0?Math.round(W/V.length):0,minCommunitySize:V.length>0?Math.min(...V):0,maxCommunitySize:V.length>0?Math.max(...V):0,fiedlerValue:x.fiedlerValue,modularity:0,coveragePercent:C>0?Math.round(W/C*100):0}},[x,C]),O=(V,W)=>{y({...p,[V]:W})},z=(p.bandwidth*111).toFixed(1);return g.jsx("div",{ref:D,className:"absolute inset-0 z-[600] pointer-events-none",children:g.jsx(R0,{children:c&&g.jsx(s0.div,{drag:!0,dragControls:Q,dragConstraints:D,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:Ur.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:g.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:[g.jsxs("div",{className:`
                  flex items-center justify-between 
                  px-3 py-2 sm:px-2.5 sm:py-1.5 
                  border-b 
                  cursor-grab active:cursor-grabbing
                  /* Larger touch target on mobile */
                  min-h-[44px] sm:min-h-0
                `,style:E?{borderColor:r0.border}:void 0,onPointerDown:V=>Q.start(V),children:[g.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5",children:[g.jsx(eu,{className:"w-4 h-4 sm:w-3 sm:h-3",style:E?{color:r0.textMuted}:void 0}),g.jsx(Ss,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-blue"}),g.jsx("span",{className:"text-sm sm:text-xs font-medium",style:E?{color:r0.textPrimary}:void 0,children:"Partition"})]}),g.jsx(Ot,{plain:!0,color:"muted",onClick:u,className:"!p-1.5 sm:!p-0.5 !rounded min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close toolbox",children:g.jsx(mn,{className:"w-4 h-4 sm:w-3 sm:h-3"})})]}),g.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5 border-b",style:E?{borderColor:r0.border}:void 0,children:g.jsxs("div",{className:"grid grid-cols-2 gap-x-4 sm:gap-x-3 gap-y-1 sm:gap-y-0.5",children:[g.jsx(Nn,{icon:g.jsx(Ss,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Communities",value:P.numCommunities,isLightMode:E}),g.jsx(Nn,{icon:g.jsx(yi,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Avg Size",value:P.avgCommunitySize,subtext:`${P.minCommunitySize}–${P.maxCommunitySize}`,isLightMode:E}),g.jsx(Nn,{icon:g.jsx(Iu,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Fiedler λ₂",value:P.fiedlerValue.toFixed(3),isLightMode:E}),g.jsx(Nn,{icon:g.jsx(yi,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Coverage",value:`${P.coveragePercent}%`,subtext:`of ${C}`,isLightMode:E})]})}),g.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5",children:g.jsxs("div",{className:"space-y-3 sm:space-y-1.5",children:[g.jsx(Ln,{label:"Bandwidth",value:p.bandwidth,min:.01,max:.15,step:.005,formatValue:()=>z,unit:"km",onChange:V=>O("bandwidth",V),isLightMode:E}),g.jsx(Ln,{label:"Threshold",value:p.threshold,min:.05,max:.5,step:.01,formatValue:V=>`${Math.round((1-V)*100)}%`,unit:"cov",onChange:V=>O("threshold",V),isLightMode:E}),g.jsx(Ln,{label:"Opacity",value:p.opacity,min:.1,max:1,step:.05,formatValue:V=>`${Math.round(V*100)}%`,onChange:V=>O("opacity",V),isLightMode:E}),g.jsx(Ln,{label:"Stroke",value:p.strokeWidth,min:0,max:5,step:.5,unit:"px",formatValue:V=>V.toFixed(1),onChange:V=>O("strokeWidth",V),isLightMode:E})]})})]})})})})}const hf={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-signal-poor",critical:"text-signal-critical"};function fn(c,u){return hf[Do(c,u)]}const mf={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))"},gf={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 Or({prefix:c,name:u}){const p=j.useRef(null),[y,x]=j.useState(!1),[C,T]=j.useState({top:0,left:0}),Q=()=>{if(!u||!p.current)return;const D=p.current.getBoundingClientRect();T({top:D.top-4,left:D.left+D.width/2}),x(!0)};return g.jsxs(g.Fragment,{children:[g.jsx("span",{ref:p,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:mf,onMouseEnter:Q,onMouseLeave:()=>x(!1),children:c}),u&&y&&Sa.createPortal(g.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:{...gf,top:C.top,left:C.left},children:u}),document.body)]})}function Al(c){if(c._tracePathHashes)return c._tracePathHashes;if(c.payload&&c.payload.length>=20){const u=c.payload.slice(18),p=[];for(let y=0;y<u.length;y+=2){const x=u.slice(y,y+2).toUpperCase();x.length===2&&p.push(x)}return p.length>0?p:null}return null}function el(c,u){return c.src_hash?[c.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase(),...u.map(y=>y.toUpperCase())]:u.map(p=>p.toUpperCase())}function pf(c,u,p,y=15){const x=[],C=u.toUpperCase(),T=p.toUpperCase();for(const Q of c){if((Q.type??Q.payload_type)!==Ea.TRACE)continue;const E=Al(Q);if(!E||E.length<1)continue;const P=el(Q,E);if(!(P.length<2)){for(let O=0;O<P.length-1;O++)if(P[O]===C&&P[O+1]===T||P[O]===T&&P[O+1]===C){x.push(Q);break}if(x.length>=y)break}}return x}function yf(c){switch(c){case"improving":return g.jsx(Ba,{className:"w-3 h-3 text-sys-green"});case"degrading":return g.jsx(xu,{className:"w-3 h-3 text-sys-red"});case"stable":return g.jsx(Co,{className:"w-3 h-3 text-fg-muted"});default:return null}}const xf={backgroundColor:"var(--map-ui-stripe)"};function Gn({label:c,value:u,unit:p,color:y,tooltip:x}){return g.jsxs("div",{className:`flex items-center justify-between gap-2 py-[3px] ${x?"cursor-help":""}`,title:x,children:[g.jsx("span",{className:"type-data-xs text-fg-muted",children:c}),g.jsxs("span",{className:`data-box data-box-compact ${y||""}`,children:[u,p&&g.jsx("span",{className:"text-fg-muted ml-0.5",children:p})]})]})}function Ui({stats:c,direction:u,sf:p,noiseFloor:y}){if(!c)return g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"flex items-center justify-between mb-1.5",children:g.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:u})}),g.jsx("p",{className:"type-data-xs text-fg-muted italic px-1.5",children:"No data"})]});const x=c.max-c.min,C=c.median-c.mean,T=Ma(p),Q=c.mean-T,D=Do(c.mean,p),E=[`Mean SNR: ${c.mean.toFixed(1)} dB (${D}) from ${c.count} measurement${c.count!==1?"s":""}`,`Variability: ±${c.stdDev.toFixed(1)} dB`,"",`Link budget (SF${p}, 3.5 dBi omni):`,`  Demod threshold: ${T.toFixed(1)} dB`,`  SNR margin: ${Q>=0?"+":""}${Q.toFixed(1)} dB`];return y!=null&&E.push(`  Noise floor: ${y} dBm`),g.jsxs("div",{className:"min-w-0",children:[g.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[g.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:u}),g.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",title:`${c.count} measurement${c.count!==1?"s":""}`,children:["n=",c.count]})]}),g.jsx(Gn,{label:"Mean",value:c.mean.toFixed(1),unit:"dB",color:fn(c.mean,p),tooltip:E.join(`
`)}),g.jsx(Gn,{label:"Median",value:c.median.toFixed(1),unit:"dB",tooltip:`Middle value — less affected by unusual readings than the average.${Math.abs(C)>=.15?`
Differs from mean by ${C>0?"+":""}${C.toFixed(1)} dB`:""}`}),g.jsx(Gn,{label:"Range",value:`${c.min.toFixed(1)}–${c.max.toFixed(1)}`,unit:"dB",tooltip:`Best to worst signal observed. Total spread: ${x.toFixed(1)} dB.`})]})}function wf({pair:c,onClose:u,prefixToName:p}){var vA,iA,fA,RA,DA,EA,yA,bA,LA,NA,GA,kA;const y=Mo(),x=wa(),C=va(),T=ba(),[Q,D]=j.useState(null),E=((iA=(vA=C==null?void 0:C.config)==null?void 0:vA.radio)==null?void 0:iA.spreading_factor)??ka,P=j.useMemo(()=>{const cA=`${c.nodeA.hash}>${c.nodeB.hash}`,lA=`${c.nodeB.hash}>${c.nodeA.hash}`;return{forward:y.get(cA)??null,reverse:y.get(lA)??null}},[y,c.nodeA.hash,c.nodeB.hash]),O=j.useMemo(()=>!x||x.length===0?[]:pf(x,c.nodeA.prefix,c.nodeB.prefix),[x,c.nodeA.prefix,c.nodeB.prefix]),z=c.nodeA.name||(p==null?void 0:p.get(c.nodeA.prefix.toUpperCase()))||null,V=c.nodeB.name||(p==null?void 0:p.get(c.nodeB.prefix.toUpperCase()))||null,W=((fA=P.forward)==null?void 0:fA.trend)??((RA=P.reverse)==null?void 0:RA.trend)??"insufficient",oA=Math.max(((DA=P.forward)==null?void 0:DA.lastSeen)??0,((EA=P.reverse)==null?void 0:EA.lastSeen)??0),J=(((yA=P.forward)==null?void 0:yA.uniqueTraceCount)??0)+(((bA=P.reverse)==null?void 0:bA.uniqueTraceCount)??0),eA=W==="insufficient"?"Not enough data to determine trend (need at least 4 measurements).":`Whether signal quality is getting better or worse over time.
Compares older measurements to newer ones.`,Z=((LA=P.forward)==null?void 0:LA.uniqueTraceCount)??0,uA=((NA=P.reverse)==null?void 0:NA.uniqueTraceCount)??0,sA=["Number of trace packets that traveled through this link.",`${c.nodeA.prefix}→${c.nodeB.prefix}: ${Z}`,`${c.nodeB.prefix}→${c.nodeA.prefix}: ${uA}`].join(`
`);return g.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:g.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:[g.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:[g.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[g.jsx(Vo,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-green shrink-0"}),g.jsx(Or,{prefix:c.nodeA.prefix,name:z}),g.jsx("span",{className:"type-data-xs text-fg-muted",children:"↔"}),g.jsx(Or,{prefix:c.nodeB.prefix,name:V})]}),g.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[oA>0&&g.jsx("span",{className:"type-data-xs text-fg-muted",title:xi(oA),children:Bo(oA)}),g.jsx(Ot,{plain:!0,color:"muted",onClick:u,className:"!p-1.5 sm:!p-0.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:g.jsx(mn,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"})})]})]}),g.jsxs("div",{className:"px-3 py-2.5 border-b border-edge-subtle",children:[g.jsxs("div",{className:"space-y-1.5 mb-2",children:[g.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${c.nodeA.prefix}→${c.nodeB.prefix}: mean of ${((GA=c.aToB)==null?void 0:GA.count)??0} measurements`,children:[g.jsxs("span",{className:"flex items-center gap-1",children:[g.jsx(Or,{prefix:c.nodeA.prefix,name:z}),g.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),g.jsx(Or,{prefix:c.nodeB.prefix,name:V})]}),c.aToB?g.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(c.aToB.mean,E)}`,children:[c.aToB.mean.toFixed(1),g.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):g.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]}),g.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${c.nodeB.prefix}→${c.nodeA.prefix}: mean of ${((kA=c.bToA)==null?void 0:kA.count)??0} measurements`,children:[g.jsxs("span",{className:"flex items-center gap-1",children:[g.jsx(Or,{prefix:c.nodeB.prefix,name:V}),g.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),g.jsx(Or,{prefix:c.nodeA.prefix,name:z})]}),c.bToA?g.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(c.bToA.mean,E)}`,children:[c.bToA.mean.toFixed(1),g.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):g.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]})]}),g.jsxs("div",{className:"grid grid-cols-2 gap-0 -mx-3 border-t border-edge-subtle",children:[g.jsx("div",{className:"px-3 pt-2 pb-1 border-r border-edge-subtle",children:g.jsx(Ui,{stats:c.aToB,direction:`${c.nodeA.prefix}→${c.nodeB.prefix}`,sf:E,noiseFloor:T})}),g.jsx("div",{className:"px-3 pt-2 pb-1",children:g.jsx(Ui,{stats:c.bToA,direction:`${c.nodeB.prefix}→${c.nodeA.prefix}`,sf:E,noiseFloor:T})})]})]}),g.jsxs("div",{className:"px-3 py-1.5 border-b border-edge-subtle",children:[W!=="insufficient"&&g.jsxs("div",{className:"flex items-center justify-between gap-2 py-[3px] cursor-help",title:eA,children:[g.jsx("span",{className:"type-data-xs text-fg-muted",children:"Trend"}),g.jsx("span",{className:"data-box data-box-compact",children:g.jsxs("span",{className:"flex items-center gap-1",children:[yf(W),g.jsx("span",{className:"text-fg-secondary capitalize",children:W})]})})]}),J>0&&g.jsx(Gn,{label:"Unique traces",value:J.toString(),tooltip:sA})]}),O.length>0&&g.jsxs("div",{className:"px-3 py-2 flex-1 min-h-0 flex flex-col",children:[g.jsxs("p",{className:"type-micro text-fg-secondary mb-1 shrink-0",children:["Source packets (",O.length,")"]}),g.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain",style:{scrollbarGutter:"stable"},children:O.map((cA,lA)=>{const TA=Al(cA),MA=TA?el(cA,TA):null,WA=MA?Math.max(0,MA.length-1):0,ae=MA?MA.map(UA=>(p==null?void 0:p.get(UA))??UA).join(" → "):null,JA=Q===lA,ZA=cA.id??`${cA.packet_hash}-${cA.timestamp}`;return g.jsxs("div",{className:"rounded-sm",style:lA%2===1?xf:void 0,children:[g.jsxs("button",{onClick:()=>D(JA?null:lA),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?g.jsx(ko,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"}):g.jsx(yu,{className:"w-2.5 h-2.5 text-fg-muted shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),g.jsx("span",{className:"text-fg-muted w-[52px] shrink-0",children:xi(cA.timestamp)}),ae?g.jsx("span",{className:"text-fg-secondary truncate min-w-0",title:MA.join(" → "),children:ae}):g.jsx("span",{className:"text-fg-muted truncate min-w-0 italic",children:"path n/a"}),g.jsxs("span",{className:"text-fg-muted shrink-0",children:[WA,"h"]}),cA.snr!=null&&g.jsx("span",{className:`shrink-0 tabular-nums ${fn(cA.snr,E)}`,children:cA.snr.toFixed(1)})]}),JA&&g.jsxs("div",{className:"mb-1 mt-0.5 mx-1 pl-2 border-l border-edge-subtle space-y-0.5 text-[10px]",children:[cA.rssi!=null&&g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"RSSI"}),g.jsxs("span",{className:"font-mono tabular-nums text-fg-secondary",children:[cA.rssi," dBm"]})]}),cA.snr!=null&&g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"SNR"}),g.jsxs("span",{className:`font-mono tabular-nums ${fn(cA.snr,E)}`,children:[cA.snr.toFixed(1)," dB"]})]}),g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Route"}),g.jsx("span",{className:"font-mono text-fg-secondary",children:Ca(cA.route??cA.route_type)})]}),cA.packet_hash&&g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Hash"}),g.jsxs("button",{onClick:UA=>{UA.stopPropagation(),Us(cA.packet_hash)},className:"flex items-center gap-1 font-mono text-fg-secondary hover:text-fg-primary transition-colors",title:"Copy packet hash",children:[g.jsx("span",{className:"truncate max-w-[120px]",children:cA.packet_hash}),g.jsx(Gs,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"})]})]}),cA.src_hash&&g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Source"}),g.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:cA.src_hash,children:cA.src_hash})]}),MA&&MA.length>0&&g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Path"}),g.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:MA.join(" → "),children:MA.join(" → ")})]})]})]},ZA)})})]})]})})}const vf={getItem:c=>{try{return localStorage.getItem(c)}catch{return null}},setItem:(c,u)=>{try{localStorage.setItem(c,u)}catch{}},removeItem:c=>{try{localStorage.removeItem(c)}catch{}}},tl=Eo()(ou(c=>({isEnabled:!1,toggle:()=>c(u=>({isEnabled:!u.isEnabled})),setEnabled:u=>c({isEnabled:u})}),{name:"pymc-live-trace",storage:lu(()=>vf)})),bf=()=>tl(c=>c.isEnabled),kf=()=>tl(c=>c.toggle);var jt=(function(c){c=c||{};var u=typeof c<"u"?c:{},p={},y;for(y in u)u.hasOwnProperty(y)&&(p[y]=u[y]);var x="";function C(rA){return u.locateFile?u.locateFile(rA,x):x+rA}var T;typeof document<"u"&&document.currentScript&&(x=document.currentScript.src),x.indexOf("blob:")!==0?x=x.substr(0,x.lastIndexOf("/")+1):x="",T=function(pA,IA,xA){var t=new XMLHttpRequest;t.open("GET",pA,!0),t.responseType="arraybuffer",t.onload=function(){if(t.status==200||t.status==0&&t.response){IA(t.response);return}var ge=f0(pA);if(ge){IA(ge.buffer);return}xA()},t.onerror=xA,t.send(null)};var Q=u.print||console.log.bind(console),D=u.printErr||console.warn.bind(console);for(y in p)p.hasOwnProperty(y)&&(u[y]=p[y]);p=null,u.arguments&&u.arguments;var E=0,P=function(rA){E=rA},O=function(){return E},z=8;function V(rA,pA,IA,xA){switch(IA=IA||"i8",IA.charAt(IA.length-1)==="*"&&(IA="i32"),IA){case"i1":bA[rA>>0]=pA;break;case"i8":bA[rA>>0]=pA;break;case"i16":NA[rA>>1]=pA;break;case"i32":GA[rA>>2]=pA;break;case"i64":ot=[pA>>>0,(ze=pA,+Ce(ze)>=1?ze>0?(Ke(+pe(ze/4294967296),4294967295)|0)>>>0:~~+Se((ze-+(~~ze>>>0))/4294967296)>>>0:0)],GA[rA>>2]=ot[0],GA[rA+4>>2]=ot[1];break;case"float":kA[rA>>2]=pA;break;case"double":cA[rA>>3]=pA;break;default:ht("invalid type for setValue: "+IA)}}function W(rA,pA,IA){switch(pA=pA||"i8",pA.charAt(pA.length-1)==="*"&&(pA="i32"),pA){case"i1":return bA[rA>>0];case"i8":return bA[rA>>0];case"i16":return NA[rA>>1];case"i32":return GA[rA>>2];case"i64":return GA[rA>>2];case"float":return kA[rA>>2];case"double":return cA[rA>>3];default:ht("invalid type for getValue: "+pA)}return null}var oA=!1;function J(rA,pA){rA||ht("Assertion failed: "+pA)}function eA(rA){var pA=u["_"+rA];return J(pA,"Cannot call unknown function "+rA+", make sure it is exported"),pA}function Z(rA,pA,IA,xA,t){var k={string:function(ie){var et=0;if(ie!=null&&ie!==0){var Lt=(ie.length<<2)+1;et=at(Lt),RA(ie,et,Lt)}return et},array:function(ie){var et=at(ie.length);return DA(ie,et),et}};function ge(ie){return pA==="string"?iA(ie):pA==="boolean"?!!ie:ie}var De=eA(rA),He=[],$A=0;if(xA)for(var ye=0;ye<xA.length;ye++){var lt=k[IA[ye]];lt?($A===0&&($A=i0()),He[ye]=lt(xA[ye])):He[ye]=xA[ye]}var _e=De.apply(null,He);return _e=ge(_e),$A!==0&&Fe($A),_e}function uA(rA,pA,IA,xA){IA=IA||[];var t=IA.every(function(ge){return ge==="number"}),k=pA!=="string";return k&&t&&!xA?eA(rA):function(){return Z(rA,pA,IA,arguments)}}var sA=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function vA(rA,pA,IA){for(var xA=pA+IA,t=pA;rA[t]&&!(t>=xA);)++t;if(t-pA>16&&rA.subarray&&sA)return sA.decode(rA.subarray(pA,t));for(var k="";pA<t;){var ge=rA[pA++];if(!(ge&128)){k+=String.fromCharCode(ge);continue}var De=rA[pA++]&63;if((ge&224)==192){k+=String.fromCharCode((ge&31)<<6|De);continue}var He=rA[pA++]&63;if((ge&240)==224?ge=(ge&15)<<12|De<<6|He:ge=(ge&7)<<18|De<<12|He<<6|rA[pA++]&63,ge<65536)k+=String.fromCharCode(ge);else{var $A=ge-65536;k+=String.fromCharCode(55296|$A>>10,56320|$A&1023)}}return k}function iA(rA,pA){return rA?vA(LA,rA,pA):""}function fA(rA,pA,IA,xA){if(!(xA>0))return 0;for(var t=IA,k=IA+xA-1,ge=0;ge<rA.length;++ge){var De=rA.charCodeAt(ge);if(De>=55296&&De<=57343){var He=rA.charCodeAt(++ge);De=65536+((De&1023)<<10)|He&1023}if(De<=127){if(IA>=k)break;pA[IA++]=De}else if(De<=2047){if(IA+1>=k)break;pA[IA++]=192|De>>6,pA[IA++]=128|De&63}else if(De<=65535){if(IA+2>=k)break;pA[IA++]=224|De>>12,pA[IA++]=128|De>>6&63,pA[IA++]=128|De&63}else{if(IA+3>=k)break;pA[IA++]=240|De>>18,pA[IA++]=128|De>>12&63,pA[IA++]=128|De>>6&63,pA[IA++]=128|De&63}}return pA[IA]=0,IA-t}function RA(rA,pA,IA){return fA(rA,LA,pA,IA)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function DA(rA,pA){bA.set(rA,pA)}function EA(rA,pA){return rA%pA>0&&(rA+=pA-rA%pA),rA}var yA,bA,LA,NA,GA,kA,cA;function lA(rA){yA=rA,u.HEAP8=bA=new Int8Array(rA),u.HEAP16=NA=new Int16Array(rA),u.HEAP32=GA=new Int32Array(rA),u.HEAPU8=LA=new Uint8Array(rA),u.HEAPU16=new Uint16Array(rA),u.HEAPU32=new Uint32Array(rA),u.HEAPF32=kA=new Float32Array(rA),u.HEAPF64=cA=new Float64Array(rA)}var TA=5271536,MA=28624,WA=u.TOTAL_MEMORY||33554432;u.buffer?yA=u.buffer:yA=new ArrayBuffer(WA),WA=yA.byteLength,lA(yA),GA[MA>>2]=TA;function ae(rA){for(;rA.length>0;){var pA=rA.shift();if(typeof pA=="function"){pA();continue}var IA=pA.func;typeof IA=="number"?pA.arg===void 0?u.dynCall_v(IA):u.dynCall_vi(IA,pA.arg):IA(pA.arg===void 0?null:pA.arg)}}var JA=[],ZA=[],UA=[],Ie=[];function Le(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Ye(u.preRun.shift());ae(JA)}function se(){ae(ZA)}function me(){ae(UA)}function ue(){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)ke(u.postRun.shift());ae(Ie)}function Ye(rA){JA.unshift(rA)}function ke(rA){Ie.unshift(rA)}var Ce=Math.abs,Se=Math.ceil,pe=Math.floor,Ke=Math.min,$e=0,qe=null;function Xe(rA){$e++,u.monitorRunDependencies&&u.monitorRunDependencies($e)}function vt(rA){if($e--,u.monitorRunDependencies&&u.monitorRunDependencies($e),$e==0&&qe){var pA=qe;qe=null,pA()}}u.preloadedImages={},u.preloadedAudios={};var Qe=null,Je="data:application/octet-stream;base64,";function Be(rA){return String.prototype.startsWith?rA.startsWith(Je):rA.indexOf(Je)===0}var ze,ot;Qe="data:application/octet-stream;base64,[encoded data, 37208 characters]";var Rt=28640;function b0(rA,pA,IA,xA){ht("Assertion failed: "+iA(rA)+", at: "+[pA?iA(pA):"unknown filename",IA,xA?iA(xA):"unknown function"])}function Yt(){return bA.length}function Kt(rA,pA,IA){LA.set(LA.subarray(pA,pA+IA),rA)}function L0(rA){return u.___errno_location&&(GA[u.___errno_location()>>2]=rA),rA}function er(rA){ht("OOM")}function k0(rA){try{var pA=new ArrayBuffer(rA);return pA.byteLength!=rA?void 0:(new Int8Array(pA).set(bA),d0(pA),lA(pA),1)}catch{}}function zt(rA){var pA=Yt(),IA=16777216,xA=2147483648-IA;if(rA>xA)return!1;for(var t=16777216,k=Math.max(pA,t);k<rA;)k<=536870912?k=EA(2*k,IA):k=Math.min(EA((3*k+2147483648)/4,IA),xA);var ge=k0(k);return!!ge}var C0=typeof atob=="function"?atob:function(rA){var pA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",IA="",xA,t,k,ge,De,He,$A,ye=0;rA=rA.replace(/[^A-Za-z0-9\+\/\=]/g,"");do ge=pA.indexOf(rA.charAt(ye++)),De=pA.indexOf(rA.charAt(ye++)),He=pA.indexOf(rA.charAt(ye++)),$A=pA.indexOf(rA.charAt(ye++)),xA=ge<<2|De>>4,t=(De&15)<<4|He>>2,k=(He&3)<<6|$A,IA=IA+String.fromCharCode(xA),He!==64&&(IA=IA+String.fromCharCode(t)),$A!==64&&(IA=IA+String.fromCharCode(k));while(ye<rA.length);return IA};function tr(rA){try{for(var pA=C0(rA),IA=new Uint8Array(pA.length),xA=0;xA<pA.length;++xA)IA[xA]=pA.charCodeAt(xA);return IA}catch{throw new Error("Converting base64 string to bytes failed.")}}function f0(rA){if(Be(rA))return tr(rA.slice(Je.length))}var rr={Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},N0={b:P,c:O,d:b0,e:L0,f:Yt,g:Kt,h:zt,i:er,o:Rt,p:MA},gA=(function(rA,pA,IA){"almost asm";var xA=new rA.Int8Array(IA),t=new rA.Int32Array(IA);new rA.Uint8Array(IA),new rA.Float32Array(IA);var k=new rA.Float64Array(IA),ge=pA.o|0,De=pA.p|0,He=rA.Math.floor,$A=rA.Math.abs,ye=rA.Math.sqrt,lt=rA.Math.pow,_e=rA.Math.cos,ie=rA.Math.sin,et=rA.Math.tan,Lt=rA.Math.acos,h0=rA.Math.asin,mt=rA.Math.atan,Te=rA.Math.atan2,gt=rA.Math.ceil,Pe=rA.Math.imul,At=rA.Math.min,F0=rA.Math.max,nt=rA.Math.clz32,YA=pA.b,S=pA.c,OA=pA.d,Nt=pA.e,P0=pA.f,l0=pA.g,a0=pA.h,m0=pA.i,b=28656;function E0(e){return xA=new Int8Array(e),t=new Int32Array(e),k=new Float64Array(e),IA=e,!0}function $t(e){e=e|0;var A=0;return A=b,b=b+e|0,b=b+15&-16,A|0}function Q0(){return b|0}function O0(e){e=e|0,b=e}function S0(e,A){e=e|0,b=e}function d(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=bn(15,A)|0,A|0):(r=((e|0)<0)<<31>>31,s=ft(e|0,r|0,3,0)|0,n=S()|0,r=KA(e|0,r|0,1,0)|0,r=ft(s|0,n|0,r|0,S()|0)|0,r=KA(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,_(e,A,r,n,0)|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,a=0,f=0;if(a=b,b=b+16|0,o=a,!(F(e,A,r,n,s)|0))return n=0,b=a,n|0;do if((r|0)>=0){if((r|0)>13780509){if(i=bn(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=ft(r|0,i|0,3,0)|0,l=S()|0,i=KA(r|0,i|0,1,0)|0,i=ft(f|0,l|0,i|0,S()|0)|0,i=KA(i|0,S()|0,1,0)|0,l=S()|0,t[o>>2]=i,t[o+4>>2]=l,o=i;if(W0(n|0,0,o<<3|0)|0,s|0){W0(s|0,0,o<<2|0)|0,i=X(e,A,r,n,s,o,l,0)|0;break}i=Qt(o,4)|0,i?(f=X(e,A,r,n,i,o,l,0)|0,qA(i),i=f):i=13}else i=2;while(!1);return f=i,b=a,f|0}function F(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0;if(G=b,b=b+16|0,I=G,L=G+8|0,R=I,t[R>>2]=e,t[R+4>>2]=A,(r|0)<0)return L=2,b=G,L|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 L=9,b=G,L|0;t[L>>2]=0;A:do if((r|0)>=1)if(i)for(m=1,f=0,M=0,R=1,i=e;;){if(!(f|M)){if(i=K(i,A,4,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=K(i,A,t[26800+(M<<2)>>2]|0,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(m<<3)|0,t[e>>2]=i,t[e+4>>2]=A,t[s+(m<<2)>>2]=R,e=f+1|0,o=(e|0)==(R|0),l=M+1|0,a=(l|0)==6,Oe(i,A)|0){i=9;break A}if(R=R+(a&o&1)|0,(R|0)>(r|0)){i=0;break}else m=m+1|0,f=o?0:e,M=o?a?0:l:M}else for(m=1,f=0,M=0,R=1,i=e;;){if(!(f|M)){if(i=K(i,A,4,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=K(i,A,t[26800+(M<<2)>>2]|0,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(m<<3)|0,t[e>>2]=i,t[e+4>>2]=A,e=f+1|0,o=(e|0)==(R|0),l=M+1|0,a=(l|0)==6,Oe(i,A)|0){i=9;break A}if(R=R+(a&o&1)|0,(R|0)>(r|0)){i=0;break}else m=m+1|0,f=o?0:e,M=o?a?0:l:M}else i=0;while(!1);return L=i,b=G,L|0}function X(e,A,r,n,s,i,o,l){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,i=i|0,o=o|0,l=l|0;var a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0;if(G=b,b=b+16|0,I=G+8|0,L=G,a=Rr(e|0,A|0,i|0,o|0)|0,m=S()|0,M=n+(a<<3)|0,Y=M,nA=t[Y>>2]|0,Y=t[Y+4>>2]|0,f=(nA|0)==(e|0)&(Y|0)==(A|0),!((nA|0)==0&(Y|0)==0|f))do a=KA(a|0,m|0,1,0)|0,a=jr(a|0,S()|0,i|0,o|0)|0,m=S()|0,M=n+(a<<3)|0,nA=M,Y=t[nA>>2]|0,nA=t[nA+4>>2]|0,f=(Y|0)==(e|0)&(nA|0)==(A|0);while(!((Y|0)==0&(nA|0)==0|f));if(a=s+(a<<2)|0,f&&(t[a>>2]|0)<=(l|0)||(nA=M,t[nA>>2]=e,t[nA+4>>2]=A,t[a>>2]=l,(l|0)>=(r|0)))return nA=0,b=G,nA|0;switch(f=l+1|0,t[I>>2]=0,a=K(e,A,2,I,L)|0,a|0){case 9:{R=9;break}case 0:{a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,s,i,o,f)|0,a||(R=9);break}}A:do if((R|0)==9){switch(t[I>>2]=0,a=K(e,A,3,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,s,i,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,1,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,s,i,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,5,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,s,i,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,4,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,s,i,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,6,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,s,i,o,f)|0,a|0)break A;break}default:break A}return nA=0,b=G,nA|0}while(!1);return nA=a,b=G,nA|0}function K(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0;if(r>>>0>6)return s=1,s|0;if(M=(t[n>>2]|0)%6|0,t[n>>2]=M,(M|0)>0){i=0;do r=Gt(r)|0,i=i+1|0;while((i|0)<(t[n>>2]|0))}if(M=wA(e|0,A|0,45)|0,S()|0,m=M&127,m>>>0>121)return s=5,s|0;a=Pt(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(L=(Jt(i)|0)==0,i=i+-1|0,R=CA(7,0,o|0)|0,A=A&~(S()|0),I=CA(t[(L?432:16)+(l*28|0)+(r<<2)>>2]|0,0,o|0)|0,o=S()|0,r=t[(L?640:224)+(l*28|0)+(r<<2)>>2]|0,e=I|e&~R,A=o|A,!r){r=0;break A}if(!i){f=8;break A}}return A|0}while(!1);(f|0)==8&&(L=t[848+(m*28|0)+(r<<2)>>2]|0,I=CA(L|0,0,45)|0,e=I|e,A=S()|0|A&-1040385,r=t[4272+(m*28|0)+(r<<2)>>2]|0,(L&127|0)==127&&(L=CA(t[848+(m*28|0)+20>>2]|0,0,45)|0,A=S()|0|A&-1040385,r=t[4272+(m*28|0)+20>>2]|0,e=lr(L|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(je(l)|0){e:do if((Pt(e,A)|0)==1){if((m|0)!=(l|0))if(M0(l,t[7696+(m*28|0)>>2]|0)|0){e=Jn(e,A)|0,o=1,A=S()|0;break}else OA(27795,26864,533,26872);switch(a|0){case 3:{e=lr(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1,o=0;break e}case 5:{e=Jn(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+5,o=0;break e}case 0:return L=9,L|0;default:return L=1,L|0}}else o=0;while(!1);if((r|0)>0){i=0;do e=qn(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}if((m|0)!=(l|0)){if(!(Et(l)|0)){if((o|0)!=0|(Pt(e,A)|0)!=5)break;t[n>>2]=(t[n>>2]|0)+1;break}switch(M&127){case 8:case 118:break A}(Pt(e,A)|0)!=3&&(t[n>>2]=(t[n>>2]|0)+1)}}else if((r|0)>0){i=0;do e=lr(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,L=s,t[L>>2]=e,t[L+4>>2]=A,L=0,L|0}function dA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,jA(e,A,r,n)|0?(W0(n|0,0,r*48|0)|0,n=XA(e,A,r,n)|0,n|0):(n=0,n|0)}function jA(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0;if(L=b,b=b+16|0,R=L,I=L+8|0,M=R,t[M>>2]=e,t[M+4>>2]=A,(r|0)<0)return I=2,b=L,I|0;if(!r)return I=n,t[I>>2]=e,t[I+4>>2]=A,I=0,b=L,I|0;t[I>>2]=0;A:do if(Oe(e,A)|0)e=9;else{s=0,M=e;do{if(e=K(M,A,4,I,R)|0,e|0)break A;if(A=R,M=t[A>>2]|0,A=t[A+4>>2]|0,s=s+1|0,Oe(M,A)|0){e=9;break A}}while((s|0)<(r|0));m=n,t[m>>2]=M,t[m+4>>2]=A,m=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=R,e=K(t[e>>2]|0,t[e+4>>2]|0,o,I,R)|0,e|0)break A;if((i|0)!=(m|0))if(a=R,l=t[a>>2]|0,a=t[a+4>>2]|0,e=n+(s<<3)|0,t[e>>2]=l,t[e+4>>2]=a,!(Oe(l,a)|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=R,a=t[s>>2]|0,l=0,s=e,i=t[o>>2]|0,o=t[o+4>>2]|0;;){if(e=K(i,o,a,I,R)|0,e|0)break A;if(o=R,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=R,e=(M|0)==(t[e>>2]|0)&&(A|0)==(t[e+4>>2]|0)?0:9}while(!1);return I=e,b=L,I|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,a=0,f=0,m=0,M=0,R=0;if(M=b,b=b+16|0,o=M,!r)return t[n>>2]=e,t[n+4>>2]=A,n=0,b=M,n|0;do if((r|0)>=0){if((r|0)>13780509){if(s=bn(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,m=ft(r|0,s|0,3,0)|0,i=S()|0,s=KA(r|0,s|0,1,0)|0,s=ft(m|0,i|0,s|0,S()|0)|0,s=KA(s|0,S()|0,1,0)|0,i=S()|0,m=o,t[m>>2]=s,t[m+4>>2]=i;if(f=Qt(s,8)|0,!f)s=13;else{if(m=Qt(s,4)|0,!m){qA(f),s=13;break}if(s=X(e,A,r,f,m,s,i,0)|0,s|0){qA(f),qA(m);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,a=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[m+(l<<2)>>2]|0)==(r|0)&&(R=n+(s<<3)|0,t[R>>2]=i,t[R+4>>2]=e,s=s+1|0),l=KA(l|0,a|0,1,0)|0,a=S()|0;while((a|0)<(o|0)|(a|0)==(o|0)&l>>>0<A>>>0)}qA(f),qA(m),s=0}}else s=2;while(!1);return R=s,b=M,R|0}function Ae(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,a=0,f=0;for(l=b,b=b+16|0,i=l,o=l+8|0,s=(Oe(e,A)|0)==0,s=s?1:2;;){if(t[o>>2]=0,f=(K(e,A,s,o,i)|0)==0,a=i,f&((t[a>>2]|0)==(r|0)?(t[a+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?(b=l,s|0):0}function ce(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,a=0,f=0;if(l=b,b=b+48|0,s=l+16|0,i=l+8|0,o=l,r=sn(r)|0,r|0)return o=r,b=l,o|0;if(f=e,a=t[f+4>>2]|0,r=i,t[r>>2]=t[f>>2],t[r+4>>2]=a,ri(i,s),r=mA(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,a=KA(A|0,r|0,12,0)|0,f=S()|0,r=o,t[r>>2]=a,t[r+4>>2]=f,r=n,t[r>>2]=a,t[r+4>>2]=f,r=0}return f=r,b=l,f|0}function Ge(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,de=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,he=0,We=0,Tt=0,pi=0;if(Ve=b,b=b+64|0,ne=Ve+48|0,HA=Ve+32|0,SA=Ve+24|0,BA=Ve+8|0,zA=Ve,a=t[e>>2]|0,(a|0)<=0)return ve=0,b=Ve,ve|0;for(QA=e+4|0,fe=ne+8|0,de=HA+8|0,Ee=BA+8|0,l=0,$=0;;){f=t[QA>>2]|0,q=f+($<<4)|0,t[ne>>2]=t[q>>2],t[ne+4>>2]=t[q+4>>2],t[ne+8>>2]=t[q+8>>2],t[ne+12>>2]=t[q+12>>2],($|0)==(a+-1|0)?(t[HA>>2]=t[f>>2],t[HA+4>>2]=t[f+4>>2],t[HA+8>>2]=t[f+8>>2],t[HA+12>>2]=t[f+12>>2]):(q=f+($+1<<4)|0,t[HA>>2]=t[q>>2],t[HA+4>>2]=t[q+4>>2],t[HA+8>>2]=t[q+8>>2],t[HA+12>>2]=t[q+12>>2]),a=FA(ne,HA,n,SA)|0;A:do if(a)f=0,l=a;else if(a=SA,f=t[a>>2]|0,a=t[a+4>>2]|0,(a|0)>0|(a|0)==0&f>>>0>0){nA=0,q=0;e:for(;;){if(We=1/(+(f>>>0)+4294967296*+(a|0)),pi=+k[ne>>3],a=ct(f|0,a|0,nA|0,q|0)|0,Tt=+(a>>>0)+4294967296*+(S()|0),he=+(nA>>>0)+4294967296*+(q|0),k[BA>>3]=We*(pi*Tt)+We*(+k[HA>>3]*he),k[Ee>>3]=We*(+k[fe>>3]*Tt)+We*(+k[de>>3]*he),a=Xn(BA,n,zA)|0,a|0){l=a;break}Y=zA,G=t[Y>>2]|0,Y=t[Y+4>>2]|0,R=Rr(G|0,Y|0,A|0,r|0)|0,m=S()|0,a=o+(R<<3)|0,M=a,f=t[M>>2]|0,M=t[M+4>>2]|0;t:do if((f|0)==0&(M|0)==0)U=a,ve=16;else for(I=0,L=0;;){if((I|0)>(r|0)|(I|0)==(r|0)&L>>>0>A>>>0){l=1;break e}if((f|0)==(G|0)&(M|0)==(Y|0))break t;if(a=KA(R|0,m|0,1,0)|0,R=jr(a|0,S()|0,A|0,r|0)|0,m=S()|0,L=KA(L|0,I|0,1,0)|0,I=S()|0,a=o+(R<<3)|0,M=a,f=t[M>>2]|0,M=t[M+4>>2]|0,(f|0)==0&(M|0)==0){U=a,ve=16;break}}while(!1);if((ve|0)==16&&(ve=0,!((G|0)==0&(Y|0)==0))&&(L=U,t[L>>2]=G,t[L+4>>2]=Y,L=i+(t[s>>2]<<3)|0,t[L>>2]=G,t[L+4>>2]=Y,L=s,L=KA(t[L>>2]|0,t[L+4>>2]|0,1,0)|0,G=S()|0,Y=s,t[Y>>2]=L,t[Y+4>>2]=G),nA=KA(nA|0,q|0,1,0)|0,q=S()|0,a=SA,f=t[a>>2]|0,a=t[a+4>>2]|0,!((a|0)>(q|0)|(a|0)==(q|0)&f>>>0>nA>>>0)){f=1;break A}}f=0}else f=1;while(!1);if($=$+1|0,!f){ve=21;break}if(a=t[e>>2]|0,($|0)>=(a|0)){l=0,ve=21;break}}return(ve|0)==21?(b=Ve,l|0):0}function kt(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,de=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,he=0,We=0,Tt=0;if(Tt=b,b=b+112|0,ve=Tt+80|0,a=Tt+72|0,Ve=Tt,he=Tt+56|0,s=sn(r)|0,s|0)return We=s,b=Tt,We|0;if(f=e+8|0,We=y0((t[f>>2]<<5)+32|0)|0,!We)return We=13,b=Tt,We|0;if(is(e,We),s=sn(r)|0,!s){if(HA=e,SA=t[HA+4>>2]|0,s=a,t[s>>2]=t[HA>>2],t[s+4>>2]=SA,ri(a,ve),s=mA(ve,A,Ve)|0,s)HA=0,SA=0;else{if(s=t[a>>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=Ve,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=Ve,t[s>>2]=r,t[s+4>>2]=o,s=o):r=i,HA=KA(r|0,s|0,12,0)|0,SA=S()|0,s=Ve,t[s>>2]=HA,t[s+4>>2]=SA,s=0}if(!s){if(r=Qt(HA,8)|0,!r)return qA(We),We=13,b=Tt,We|0;if(l=Qt(HA,8)|0,!l)return qA(We),qA(r),We=13,b=Tt,We|0;Ee=ve,t[Ee>>2]=0,t[Ee+4>>2]=0,Ee=e,ne=t[Ee+4>>2]|0,s=a,t[s>>2]=t[Ee>>2],t[s+4>>2]=ne,s=Ge(a,HA,SA,A,ve,r,l)|0;A:do if(s)qA(r),qA(l),qA(We);else{e:do if((t[f>>2]|0)>0){for(o=e+12|0,i=0;s=Ge((t[o>>2]|0)+(i<<3)|0,HA,SA,A,ve,r,l)|0,i=i+1|0,!(s|0);)if((i|0)>=(t[f>>2]|0))break e;qA(r),qA(l),qA(We);break A}while(!1);(SA|0)>0|(SA|0)==0&HA>>>0>0&&W0(l|0,0,HA<<3|0)|0,ne=ve,Ee=t[ne+4>>2]|0;e:do if((Ee|0)>0|(Ee|0)==0&(t[ne>>2]|0)>>>0>0){QA=r,fe=l,de=r,Ee=l,ne=r,s=r,U=r,BA=l,zA=l,r=l;t:for(;;){for(Y=0,nA=0,q=0,$=0,i=0,o=0;;){l=Ve,a=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));if(A=QA+(Y<<3)|0,f=t[A>>2]|0,A=t[A+4>>2]|0,F(f,A,1,Ve,0)|0){l=Ve,a=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));l=Qt(7,4)|0,l|0&&(X(f,A,1,Ve,l,7,0,0)|0,qA(l))}for(G=0;;){L=Ve+(G<<3)|0,I=t[L>>2]|0,L=t[L+4>>2]|0;r:do if((I|0)==0&(L|0)==0)l=i,a=o;else{if(m=Rr(I|0,L|0,HA|0,SA|0)|0,f=S()|0,l=n+(m<<3)|0,A=l,a=t[A>>2]|0,A=t[A+4>>2]|0,!((a|0)==0&(A|0)==0)){M=0,R=0;do{if((M|0)>(SA|0)|(M|0)==(SA|0)&R>>>0>HA>>>0)break t;if((a|0)==(I|0)&(A|0)==(L|0)){l=i,a=o;break r}l=KA(m|0,f|0,1,0)|0,m=jr(l|0,S()|0,HA|0,SA|0)|0,f=S()|0,R=KA(R|0,M|0,1,0)|0,M=S()|0,l=n+(m<<3)|0,A=l,a=t[A>>2]|0,A=t[A+4>>2]|0}while(!((a|0)==0&(A|0)==0))}if((I|0)==0&(L|0)==0){l=i,a=o;break}ar(I,L,he)|0,os(e,We,he)|0&&(R=KA(i|0,o|0,1,0)|0,o=S()|0,M=l,t[M>>2]=I,t[M+4>>2]=L,i=fe+(i<<3)|0,t[i>>2]=I,t[i+4>>2]=L,i=R),l=i,a=o}while(!1);if(G=G+1|0,G>>>0>=7)break;i=l,o=a}if(Y=KA(Y|0,nA|0,1,0)|0,nA=S()|0,q=KA(q|0,$|0,1,0)|0,$=S()|0,o=ve,i=t[o>>2]|0,o=t[o+4>>2]|0,($|0)<(o|0)|($|0)==(o|0)&q>>>0<i>>>0)i=l,o=a;else break}if((o|0)>0|(o|0)==0&i>>>0>0){i=0,o=0;do $=QA+(i<<3)|0,t[$>>2]=0,t[$+4>>2]=0,i=KA(i|0,o|0,1,0)|0,o=S()|0,$=ve,q=t[$+4>>2]|0;while((o|0)<(q|0)|((o|0)==(q|0)?i>>>0<(t[$>>2]|0)>>>0:0))}if($=ve,t[$>>2]=l,t[$+4>>2]=a,(a|0)>0|(a|0)==0&l>>>0>0)G=r,Y=zA,nA=ne,q=BA,$=fe,r=U,zA=s,BA=de,U=G,s=Y,ne=Ee,Ee=nA,de=q,fe=QA,QA=$;else break e}qA(de),qA(Ee),qA(We),s=1;break A}else s=l;while(!1);qA(We),qA(r),qA(s),s=0}while(!1);return We=s,b=Tt,We|0}}return qA(We),We=s,b=Tt,We|0}function Ct(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(m=b,b=b+176|0,a=m,(A|0)<1)return ai(r,0,0),f=0,b=m,f|0;for(l=e,l=wA(t[l>>2]|0,t[l+4>>2]|0,52)|0,S()|0,ai(r,(A|0)>6?A:6,l&15),l=0;n=e+(l<<3)|0,n=_r(t[n>>2]|0,t[n+4>>2]|0,a)|0,!(n|0);){if(n=t[a>>2]|0,(n|0)>0){o=0;do i=a+8+(o<<4)|0,o=o+1|0,n=a+8+(((o|0)%(n|0)|0)<<4)|0,s=sa(r,n,i)|0,s?fi(r,s)|0:na(r,i,n)|0,n=t[a>>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?(b=m,n|0):(ui(r),f=n,b=m,f|0)}function pt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;if(i=b,b=b+32|0,n=i,s=i+16|0,e=Ct(e,A,s)|0,e|0)return r=e,b=i,r|0;if(t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,e=ci(s)|0,e|0)do{A=Il(r)|0;do Ll(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],fi(s,e)|0,e=ia(s,n)|0;while((e|0)!=0);e=ci(s)|0}while((e|0)!=0);return ui(s),e=Nl(r)|0,e?(Xs(r),o=e,b=i,o|0):(o=0,b=i,o|0)}function je(e){return e=e|0,e>>>0>121?(e=0,e|0):(e=t[7696+(e*28|0)+16>>2]|0,e|0)}function Et(e){return e=e|0,(e|0)==4|(e|0)==117|0}function g0(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 u0(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 z0(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 qt(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 M0(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 nr(e,A){return e=e|0,A=A|0,t[848+(e*28|0)+(A<<2)>>2]|0}function sr(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 Vr(){return 122}function Wr(e){e=e|0;var A=0,r=0,n=0;A=0;do CA(A|0,0,45)|0,n=S()|0|134225919,r=e+(A<<3)|0,t[r>>2]=-1,t[r+4>>2]=n,A=A+1|0;while((A|0)!=122);return 0}function Yr(e){e=e|0;var A=0,r=0,n=0;return n=+k[e+16>>3],r=+k[e+24>>3],A=n-r,+(n<r?A+6.283185307179586:A)}function Ft(e){return e=e|0,+k[e+16>>3]<+k[e+24>>3]|0}function ir(e){return e=e|0,+(+k[e>>3]-+k[e+8>>3])}function c0(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;return r=+k[A>>3],!(r>=+k[e+8>>3])||!(r<=+k[e>>3])?(A=0,A|0):(n=+k[e+16>>3],r=+k[e+24>>3],s=+k[A+8>>3],A=s>=r,e=s<=n&1,n<r?A&&(e=1):A||(e=0),A=(e|0)!=0,A|0)}function Ne(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;return+k[e>>3]<+k[A+8>>3]||+k[e+8>>3]>+k[A>>3]?(n=0,n|0):(i=+k[e+16>>3],r=e+24|0,m=+k[r>>3],o=i<m,n=A+16|0,f=+k[n>>3],s=A+24|0,a=+k[s>>3],l=f<a,A=m-f<a-i,e=o?l|A?1:2:0,A=l?o?1:A?2:1:0,i=+Vt(i,e),i<+Vt(+k[s>>3],A)||(m=+Vt(+k[r>>3],e),m>+Vt(+k[n>>3],A))?(l=0,l|0):(l=1,l|0))}function B0(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,a=0;i=+k[e+16>>3],a=+k[e+24>>3],e=i<a,l=+k[A+16>>3],o=+k[A+24>>3],s=l<o,A=a-l<o-i,t[r>>2]=e?s|A?1:2:0,t[n>>2]=s?e?1:A?2:1:0}function H(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;return+k[e>>3]<+k[A>>3]||+k[e+8>>3]>+k[A+8>>3]?(n=0,n|0):(n=e+16|0,a=+k[n>>3],i=+k[e+24>>3],o=a<i,r=A+16|0,m=+k[r>>3],s=A+24|0,f=+k[s>>3],l=m<f,A=i-m<f-a,e=o?l|A?1:2:0,A=l?o?1:A?2:1:0,i=+Vt(i,e),i<=+Vt(+k[s>>3],A)?(m=+Vt(+k[n>>3],e),l=m>=+Vt(+k[r>>3],A),l|0):(l=0,l|0))}function aA(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0;s=b,b=b+176|0,n=s,t[n>>2]=4,l=+k[A>>3],k[n+8>>3]=l,i=+k[A+16>>3],k[n+16>>3]=i,k[n+24>>3]=l,l=+k[A+24>>3],k[n+32>>3]=l,o=+k[A+8>>3],k[n+40>>3]=o,k[n+48>>3]=l,k[n+56>>3]=o,k[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));Ir(e|0,n|0,168)|0,b=s}function mA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0;L=b,b=b+288|0,m=L+264|0,M=L+96|0,f=L,l=f,a=l+96|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));return A=es(A,f)|0,A|0?(I=A,b=L,I|0):(a=f,f=t[a>>2]|0,a=t[a+4>>2]|0,ar(f,a,m)|0,_r(f,a,M)|0,o=+rn(m,M+8|0),k[m>>3]=+k[e>>3],a=m+8|0,k[a>>3]=+k[e+16>>3],k[M>>3]=+k[e+8>>3],f=M+8|0,k[f>>3]=+k[e+24>>3],s=+rn(m,M),Y=+k[a>>3]-+k[f>>3],i=+$A(+Y),G=+k[m>>3]-+k[M>>3],n=+$A(+G),!(Y==0|G==0)&&(Y=+mi(+i,+n),Y=+gt(+(s*s/+En(+(Y/+En(+i,+n)),3)/(o*(o*2.59807621135)*.8))),k[ge>>3]=Y,R=~~Y>>>0,I=+$A(Y)>=1?Y>0?~~+At(+He(Y/4294967296),4294967295)>>>0:~~+gt((Y-+(~~Y>>>0))/4294967296)>>>0:0,(t[ge+4>>2]&2146435072|0)!=2146435072)?(M=(R|0)==0&(I|0)==0,A=r,t[A>>2]=M?1:R,t[A+4>>2]=M?0:I,A=0):A=1,I=A,b=L,I|0)}function FA(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,a=0,f=0,m=0;f=b,b=b+288|0,o=f+264|0,l=f+96|0,a=f,s=a,i=s+96|0;do t[s>>2]=0,s=s+4|0;while((s|0)<(i|0));return r=es(r,a)|0,r|0?(n=r,b=f,n|0):(r=a,s=t[r>>2]|0,r=t[r+4>>2]|0,ar(s,r,o)|0,_r(s,r,l)|0,m=+rn(o,l+8|0),m=+gt(+(+rn(e,A)/(m*2))),k[ge>>3]=m,r=~~m>>>0,s=+$A(m)>=1?m>0?~~+At(+He(m/4294967296),4294967295)>>>0:~~+gt((m-+(~~m>>>0))/4294967296)>>>0:0,(t[ge+4>>2]&2146435072|0)==2146435072?(n=1,b=f,n|0):(a=(r|0)==0&(s|0)==0,t[n>>2]=a?1:r,t[n+4>>2]=a?0:s,n=0,b=f,n|0))}function VA(e,A){e=e|0,A=+A;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;i=e+16|0,o=+k[i>>3],r=e+24|0,s=+k[r>>3],n=o-s,n=o<s?n+6.283185307179586:n,f=+k[e>>3],l=e+8|0,a=+k[l>>3],m=f-a,n=(n*A-n)*.5,A=(m*A-m)*.5,f=f+A,k[e>>3]=f>1.5707963267948966?1.5707963267948966:f,A=a-A,k[l>>3]=A<-1.5707963267948966?-1.5707963267948966:A,A=o+n,A=A>3.141592653589793?A+-6.283185307179586:A,k[i>>3]=A<-3.141592653589793?A+6.283185307179586:A,A=s-n,A=A>3.141592653589793?A+-6.283185307179586:A,k[r>>3]=A<-3.141592653589793?A+6.283185307179586:A}function xe(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 tt(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0;M=A+8|0,t[M>>2]=0,a=+k[e>>3],o=+$A(+a),f=+k[e+8>>3],l=+$A(+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(R=1-o,e=(!(l<R)&1)+e|0,t[A+4>>2]=e,R<=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(a<0)if(e&1){m=(e+1|0)/2|0,m=ct(r|0,((r|0)<0)<<31>>31|0,m|0,((m|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-((+(m>>>0)+4294967296*+(S()|0))*2+1)),t[A>>2]=r;break}else{m=(e|0)/2|0,m=ct(r|0,((r|0)<0)<<31>>31|0,m|0,((m|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-(+(m>>>0)+4294967296*+(S()|0))*2),t[A>>2]=r;break}while(!1);m=A+4|0,f<0&&(r=r-((e<<1|1|0)/2|0)|0,t[A>>2]=r,e=0-e|0,t[m>>2]=e),n=e-r|0,(r|0)<0?(s=0-r|0,t[m>>2]=n,t[M>>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[M>>2]=s,t[m>>2]=0,e=0),i=r-s|0,n=e-s|0,(s|0)<0&&(t[A>>2]=i,t[m>>2]=n,t[M>>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[m>>2]=e-n,t[M>>2]=s-n)}function Me(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 ut(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),k[A>>3]=+((t[e>>2]|0)-n|0)-r*.5,k[A+8>>3]=r*.8660254037844386}function Ze(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 yt(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 st(e,A){e=e|0,A=A|0;var r=0,n=0;r=Pe(t[e>>2]|0,A)|0,t[e>>2]=r,r=e+4|0,n=Pe(t[r>>2]|0,A)|0,t[r>>2]=n,e=e+8|0,A=Pe(t[e>>2]|0,A)|0,t[e>>2]=A}function St(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 wr(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0;if(a=e+8|0,o=t[a>>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=U0(+(A-o|0)*.14285714285714285)|0,t[e>>2]=n,s=U0(+(r+l|0)*.14285714285714285)|0,t[f>>2]=s,t[a>>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[a>>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[a>>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[a>>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[a>>2]=r-n,f=0,f|0)}function gn(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,a=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(a=s<<1,(n?(2147483647-a|0)<(s|0):(-2147483648-a|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 a=1,a|0}else r=s*3|0,A=i<<1;return n=U0(+(A+s|0)*.14285714285714285)|0,t[e>>2]=n,s=U0(+(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?(a=0,a|0):(t[e>>2]=s-n,t[l>>2]=A-n,t[o>>2]=r-n,a=0,a|0)}function vr(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=U0(+((A*3|0)-r|0)*.14285714285714285)|0,t[e>>2]=n,A=U0(+((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 br(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=U0(+((A<<1)+r|0)*.14285714285714285)|0,t[e>>2]=n,A=U0(+((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 kr(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 Ht(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 pn(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 Cr(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 D0(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 Gt(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 Ut(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 Kr(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 Zr(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 Er(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 $r(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 Mt(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 qr(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 Jr(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 $n(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,a=0,f=0,m=0,M=0;if(M=b,b=b+64|0,m=M,l=M+56|0,!(!0&(A&2013265920|0)==134217728&(!0&(n&2013265920|0)==134217728)))return s=5,b=M,s|0;if((e|0)==(r|0)&(A|0)==(n|0))return t[s>>2]=0,s=0,b=M,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,b=M,s|0;if(i=o+-1|0,o>>>0>1){_t(e,A,i,m)|0,_t(r,n,i,l)|0,f=m,a=t[f>>2]|0,f=t[f+4>>2]|0;A:do if((a|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(a,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,b=M,s|0}while(!1)}i=m,o=i+56|0;do t[i>>2]=0,i=i+4|0;while((i|0)<(o|0));return v(e,A,1,m)|0,A=m,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0))&&(A=m+8|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+16|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+24|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+32|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+40|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))?(i=m+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,b=M,s|0}function yn(e,A,r,n,s){return e=e|0,A=A|0,r=r|0,n=n|0,s=s|0,r=Ae(e,A,r,n)|0,(r|0)==7?(s=11,s|0):(n=CA(r|0,0,56)|0,A=A&-2130706433|(S()|0)|268435456,t[s>>2]=e|n,t[s+4>>2]=A,s=0,s|0)}function Sr(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 xn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return s=b,b=b+16|0,n=s,t[n>>2]=0,!0&(A&2013265920|0)==268435456?(i=wA(e|0,A|0,56)|0,S()|0,n=K(e,A&-2130706433|134217728,i&7,n,r)|0,b=s,n|0):(n=6,b=s,n|0)}function Xr(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=Ue(e,r)|0,r|0)}function Mr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;return s=b,b=b+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=K(e,i,A&7,n,r+8|0)|0,b=s,n|0):(n=6,b=s,n|0)}function Br(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 or(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;return o=b,b=b+16|0,s=o,i=A&-2130706433|134217728,!0&(A&2013265920|0)==268435456?(n=wA(e|0,A|0,56)|0,S()|0,n=ea(e,i,n&7)|0,(n|0)==-1?(t[r>>2]=0,i=6,b=o,i|0):(Dr(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):AA(s,A,n,2,r),i=0,b=o,i|0)):(i=6,b=o,i|0)}function wn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;n=b,b=b+16|0,s=n,vn(e,A,r,s),tt(s,r+4|0),b=n}function vn(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,a=0;if(l=b,b=b+16|0,a=l,An(e,r,a),i=+Lt(+(1-+k[a>>3]*.5)),i<1e-16){t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,t[n+12>>2]=0,b=l;return}if(a=t[r>>2]|0,s=+k[15920+(a*24|0)>>3],s=+tn(s-+tn(+Cl(15600+(a<<4)|0,e))),Jt(A)|0?o=+tn(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=+_e(+o)*s,k[n>>3]=i,o=+ie(+o)*s,k[n+8>>3]=o,b=l}function An(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(i=b,b=b+32|0,s=i,Aa(e,s),t[A>>2]=0,k[r>>3]=5,n=+it(16400,s),n<+k[r>>3]&&(t[A>>2]=0,k[r>>3]=n),n=+it(16424,s),n<+k[r>>3]&&(t[A>>2]=1,k[r>>3]=n),n=+it(16448,s),n<+k[r>>3]&&(t[A>>2]=2,k[r>>3]=n),n=+it(16472,s),n<+k[r>>3]&&(t[A>>2]=3,k[r>>3]=n),n=+it(16496,s),n<+k[r>>3]&&(t[A>>2]=4,k[r>>3]=n),n=+it(16520,s),n<+k[r>>3]&&(t[A>>2]=5,k[r>>3]=n),n=+it(16544,s),n<+k[r>>3]&&(t[A>>2]=6,k[r>>3]=n),n=+it(16568,s),n<+k[r>>3]&&(t[A>>2]=7,k[r>>3]=n),n=+it(16592,s),n<+k[r>>3]&&(t[A>>2]=8,k[r>>3]=n),n=+it(16616,s),n<+k[r>>3]&&(t[A>>2]=9,k[r>>3]=n),n=+it(16640,s),n<+k[r>>3]&&(t[A>>2]=10,k[r>>3]=n),n=+it(16664,s),n<+k[r>>3]&&(t[A>>2]=11,k[r>>3]=n),n=+it(16688,s),n<+k[r>>3]&&(t[A>>2]=12,k[r>>3]=n),n=+it(16712,s),n<+k[r>>3]&&(t[A>>2]=13,k[r>>3]=n),n=+it(16736,s),n<+k[r>>3]&&(t[A>>2]=14,k[r>>3]=n),n=+it(16760,s),n<+k[r>>3]&&(t[A>>2]=15,k[r>>3]=n),n=+it(16784,s),n<+k[r>>3]&&(t[A>>2]=16,k[r>>3]=n),n=+it(16808,s),n<+k[r>>3]&&(t[A>>2]=17,k[r>>3]=n),n=+it(16832,s),n<+k[r>>3]&&(t[A>>2]=18,k[r>>3]=n),n=+it(16856,s),!(n<+k[r>>3])){b=i;return}t[A>>2]=19,k[r>>3]=n,b=i}function H0(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=+Xl(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=+Te(+ +k[e+8>>3],+ +k[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=(Jt(r)|0)==0,i=+mt(+((r?l:l*.37796447300922725)*.381966011250105))):(i=+mt(+(i*.381966011250105)),Jt(r)|0&&(o=+tn(o+.3334731722518321))),El(15600+(A<<4)|0,+tn(+k[15920+(A*24|0)>>3]-o),i,s)}function h(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;n=b,b=b+16|0,s=n,ut(e+4|0,s),H0(s,t[e>>2]|0,A,0,r),b=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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,de=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,he=0;if(ve=b,b=b+272|0,i=ve+256|0,q=ve+240|0,ne=ve,HA=ve+224|0,SA=ve+208|0,$=ve+176|0,U=ve+160|0,BA=ve+192|0,zA=ve+144|0,QA=ve+128|0,fe=ve+112|0,de=ve+96|0,Ee=ve+80|0,t[i>>2]=A,t[q>>2]=t[e>>2],t[q+4>>2]=t[e+4>>2],t[q+8>>2]=t[e+8>>2],t[q+12>>2]=t[e+12>>2],B(q,i,ne),t[s>>2]=0,q=n+r+((n|0)==5&1)|0,(q|0)<=(r|0)){b=ve;return}a=t[i>>2]|0,f=HA+4|0,m=$+4|0,M=r+5|0,R=16880+(a<<2)|0,I=16960+(a<<2)|0,L=QA+8|0,G=fe+8|0,Y=de+8|0,nA=SA+4|0,l=r;A:for(;;){o=ne+(((l|0)%5|0)<<4)|0,t[SA>>2]=t[o>>2],t[SA+4>>2]=t[o+4>>2],t[SA+8>>2]=t[o+8>>2],t[SA+12>>2]=t[o+12>>2];do;while((N(SA,a,0,1)|0)==2);if((l|0)>(r|0)&(Jt(A)|0)!=0){if(t[$>>2]=t[SA>>2],t[$+4>>2]=t[SA+4>>2],t[$+8>>2]=t[SA+8>>2],t[$+12>>2]=t[SA+12>>2],ut(f,U),n=t[$>>2]|0,i=t[17040+(n*80|0)+(t[HA>>2]<<2)>>2]|0,t[$>>2]=t[18640+(n*80|0)+(i*20|0)>>2],o=t[18640+(n*80|0)+(i*20|0)+16>>2]|0,(o|0)>0){e=0;do Cr(m),e=e+1|0;while((e|0)<(o|0))}switch(o=18640+(n*80|0)+(i*20|0)+4|0,t[BA>>2]=t[o>>2],t[BA+4>>2]=t[o+4>>2],t[BA+8>>2]=t[o+8>>2],st(BA,(t[R>>2]|0)*3|0),Ze(m,BA,m),Me(m),ut(m,zA),Ve=+(t[I>>2]|0),k[QA>>3]=Ve*3,k[L>>3]=0,he=Ve*-1.5,k[fe>>3]=he,k[G>>3]=Ve*2.598076211353316,k[de>>3]=he,k[Y>>3]=Ve*-2.598076211353316,t[17040+((t[$>>2]|0)*80|0)+(t[SA>>2]<<2)>>2]|0){case 1:{e=fe,n=QA;break}case 3:{e=de,n=fe;break}case 2:{e=QA,n=de;break}default:{e=12;break A}}ii(U,zA,n,e,Ee),H0(Ee,t[$>>2]|0,a,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1}if((l|0)<(M|0)&&(ut(nA,$),H0($,t[SA>>2]|0,a,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1),t[HA>>2]=t[SA>>2],t[HA+4>>2]=t[SA+4>>2],t[HA+8>>2]=t[SA+8>>2],t[HA+12>>2]=t[SA+12>>2],l=l+1|0,(l|0)>=(q|0)){e=3;break}}if((e|0)==3){b=ve;return}else(e|0)==12&&OA(26970,27017,572,27027)}function B(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0;a=b,b=b+128|0,n=a+64|0,s=a,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=(Jt(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,Kr(s),Zr(s),Jt(t[A>>2]|0)|0&&(Ht(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,Ze(s,n,A),Me(A),t[r+16>>2]=t[e>>2],A=r+20|0,Ze(s,n+12|0,A),Me(A),t[r+32>>2]=t[e>>2],A=r+36|0,Ze(s,n+24|0,A),Me(A),t[r+48>>2]=t[e>>2],A=r+52|0,Ze(s,n+36|0,A),Me(A),t[r+64>>2]=t[e>>2],r=r+68|0,Ze(s,n+48|0,r),Me(r),b=a}function N(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0;if(L=b,b=b+32|0,R=L+12|0,l=L,I=e+4|0,M=t[16960+(A<<2)>>2]|0,m=(n|0)!=0,M=m?M*3|0:M,s=t[I>>2]|0,f=e+8|0,o=t[f>>2]|0,m){if(i=e+12|0,n=t[i>>2]|0,s=o+s+n|0,(s|0)==(M|0))return I=1,b=L,I|0;a=i}else a=e+12|0,n=t[a>>2]|0,s=o+s+n|0;if((s|0)<=(M|0))return I=0,b=L,I|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?(xe(R,M,0,0),yt(I,R,l),D0(l),Ze(l,R,I),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 Cr(I),n=n+1|0;while((n|0)<(t[s>>2]|0))}return e=i+4|0,t[R>>2]=t[e>>2],t[R+4>>2]=t[e+4>>2],t[R+8>>2]=t[e+8>>2],A=t[16880+(A<<2)>>2]|0,st(R,m?A*3|0:A),Ze(I,R,I),Me(I),m?n=((t[f>>2]|0)+(t[I>>2]|0)+(t[a>>2]|0)|0)==(M|0)?1:2:n=2,I=n,b=L,I|0}function tA(e,A){e=e|0,A=A|0;var r=0;do r=N(e,A,0,1)|0;while((r|0)==2);return r|0}function AA(e,A,r,n,s){e=e|0,A=A|0,r=r|0,n=n|0,s=s|0;var i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,de=0,Ee=0,ne=0;if(de=b,b=b+240|0,i=de+224|0,BA=de+208|0,zA=de,QA=de+192|0,fe=de+176|0,Y=de+160|0,nA=de+144|0,q=de+128|0,$=de+112|0,U=de+96|0,t[i>>2]=A,t[BA>>2]=t[e>>2],t[BA+4>>2]=t[e+4>>2],t[BA+8>>2]=t[e+8>>2],t[BA+12>>2]=t[e+12>>2],hA(BA,i,zA),t[s>>2]=0,G=n+r+((n|0)==6&1)|0,(G|0)<=(r|0)){b=de;return}a=t[i>>2]|0,f=r+6|0,m=16960+(a<<2)|0,M=nA+8|0,R=q+8|0,I=$+8|0,L=QA+4|0,o=0,l=r,n=-1;A:for(;;){if(i=(l|0)%6|0,e=zA+(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=N(QA,a,0,1)|0,(l|0)>(r|0)&(Jt(A)|0)!=0&&(e|0)!=1&&(t[QA>>2]|0)!=(n|0)){switch(ut(zA+(((i+5|0)%6|0)<<4)+4|0,fe),ut(zA+(i<<4)+4|0,Y),Ee=+(t[m>>2]|0),k[nA>>3]=Ee*3,k[M>>3]=0,ne=Ee*-1.5,k[q>>3]=ne,k[R>>3]=Ee*2.598076211353316,k[$>>3]=ne,k[I>>3]=Ee*-2.598076211353316,i=t[BA>>2]|0,t[17040+(i*80|0)+(((n|0)==(i|0)?t[QA>>2]|0:n)<<2)>>2]|0){case 1:{e=q,n=nA;break}case 3:{e=$,n=q;break}case 2:{e=nA,n=$;break}default:{e=8;break A}}ii(fe,Y,n,e,U),!(oi(fe,U)|0)&&!(oi(Y,U)|0)&&(H0(U,t[BA>>2]|0,a,1,s+8+(t[s>>2]<<4)|0),t[s>>2]=(t[s>>2]|0)+1)}if((l|0)<(f|0)&&(ut(L,fe),H0(fe,t[QA>>2]|0,a,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){b=de;return}else(e|0)==8&&OA(27054,27017,737,27099)}function hA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0;a=b,b=b+160|0,n=a+80|0,s=a,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=(Jt(t[A>>2]|0)|0)==0,n=l?n:s,s=e+4|0,Kr(s),Zr(s),Jt(t[A>>2]|0)|0&&(Ht(s),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,Ze(s,n,A),Me(A),t[r+16>>2]=t[e>>2],A=r+20|0,Ze(s,n+12|0,A),Me(A),t[r+32>>2]=t[e>>2],A=r+36|0,Ze(s,n+24|0,A),Me(A),t[r+48>>2]=t[e>>2],A=r+52|0,Ze(s,n+36|0,A),Me(A),t[r+64>>2]=t[e>>2],A=r+68|0,Ze(s,n+48|0,A),Me(A),t[r+80>>2]=t[e>>2],r=r+84|0,Ze(s,n+60|0,r),Me(r),b=a}function _A(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&15|0}function te(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,45)|0,S()|0,A&127|0}function be(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 we(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0,a=0,f=0;if(e>>>0>15)return n=4,n|0;if(A>>>0>121)return n=17,n|0;o=CA(e|0,0,52)|0,s=S()|0,l=CA(A|0,0,45)|0,s=s|(S()|0)|134225919;A:do if((e|0)>=1){for(l=1,o=(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,a=CA(7,0,f|0)|0,s=s&~(S()|0),A=CA(A|0,((A|0)<0)<<31>>31|0,f|0)|0,i=A|i&~a,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 Ue(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=CA(s|0,S()|0,o|0)|0,s=S()|0,i=ct(-1227133514,-1171,o|0,s|0)|0,!((o&613566756&i|0)==0&(s&4681&(S()|0)|0)==0)||(o=(n*3|0)+19|0,i=CA(~e|0,~A|0,o|0)|0,o=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=as(e|0,A|0)|0,S()|0,((63-o|0)%3|0|0)!=0|0))}function Bt(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=CA(s|0,S()|0,o|0)|0,s=S()|0,i=ct(-1227133514,-1171,o|0,s|0)|0,(o&613566756&i|0)==0&(s&4681&(S()|0)|0)==0)&&(o=(n*3|0)+19|0,i=CA(~e|0,~A|0,o|0)|0,o=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=as(e|0,r|0)|0,S()|0,(63-o|0)%3|0|0))||Xr(e,A)|0?(o=1,o|0):(o=(li(e,A)|0)!=0&1,o|0)}function Dt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0,o=0,l=0;if(s=CA(A|0,0,52)|0,i=S()|0,r=CA(r|0,0,45)|0,r=i|(S()|0)|134225919,(A|0)<1){i=-1,n=r,A=e,t[A>>2]=i,e=e+4|0,t[e>>2]=n;return}for(i=1,s=-1;o=(15-i|0)*3|0,l=CA(7,0,o|0)|0,r=r&~(S()|0),o=CA(n|0,0,o|0)|0,s=s&~l|o,r=r|(S()|0),(i|0)!=(A|0);)i=i+1|0;l=e,o=l,t[o>>2]=s,l=l+4|0,t[l>>2]=r}function _t(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=CA(r|0,0,52)|0,s=s|e,e=S()|0|A&-15728641,(i|0)>(r|0))do A=CA(7,0,(14-r|0)*3|0)|0,r=r+1|0,s=A|s,e=S()|0|e;while((r|0)<(i|0));return t[n>>2]=s,t[n+4>>2]=e,n=0,n|0}function p0(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(!(je(r&127)|0))r=G0(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;else{e:do if(i|0){for(r=1;o=CA(7,0,(15-r|0)*3|0)|0,!!((o&e|0)==0&((S()|0)&A|0)==0);)if(r>>>0<i>>>0)r=r+1|0;else break e;r=G0(7,0,s,((s|0)<0)<<31>>31)|0,s=S()|0;break A}while(!1);r=G0(7,0,s,((s|0)<0)<<31>>31)|0,r=ft(r|0,S()|0,5,0)|0,r=KA(r|0,S()|0,-5,-1)|0,r=V0(r|0,S()|0,6,0)|0,r=KA(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,!(je(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 en(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=b,b=b+16|0,i=o,ts(i,e,A,r),A=i,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0)return b=o,0;s=0,r=0;do l=n+(s<<3)|0,t[l>>2]=e,t[l+4>>2]=A,s=KA(s|0,r|0,1,0)|0,r=S()|0,rs(i),l=i,e=t[l>>2]|0,A=t[l+4>>2]|0;while(!((e|0)==0&(A|0)==0));return b=o,0}function Ys(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,YA(r|0),n|0):(r=CA(-1,-1,((n-r|0)*3|0)+3|0)|0,n=CA(~r|0,~(S()|0)|0,(15-n|0)*3|0)|0,r=~(S()|0)&A,n=~n&e,YA(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=CA(-1,-1,((r+-1-s|0)*3|0)+3|0)|0,s=CA(~s|0,~(S()|0)|0,(15-r|0)*3|0)|0,A=~(S()|0)&A,e=~s&e),s=CA(r|0,0,52)|0,r=A&-15728641|(S()|0),t[n>>2]=e|s,t[n+4>>2]=r,n=0,n|0):(n=4,n|0)}function fl(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,de=0,Ee=0,ne=0,HA=0,SA=0;if((r|0)==0&(n|0)==0)return SA=0,SA|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)||(SA=A,t[SA>>2]=i,t[SA+4>>2]=s,(r|0)==1&(n|0)==0))return SA=0,SA|0;s=1,i=0;do ne=e+(s<<3)|0,HA=t[ne+4>>2]|0,SA=A+(s<<3)|0,t[SA>>2]=t[ne>>2],t[SA+4>>2]=HA,s=KA(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,HA=y0(Ee)|0,!HA)return SA=13,SA|0;if(Ir(HA|0,e|0,Ee|0)|0,ne=Qt(r,8)|0,!ne)return qA(HA),SA=13,SA|0;A:for(;;){s=HA,f=t[s>>2]|0,s=t[s+4>>2]|0,fe=wA(f|0,s|0,52)|0,S()|0,fe=fe&15,de=fe+-1|0,QA=(fe|0)!=0,zA=(n|0)>0|(n|0)==0&r>>>0>0;e:do if(QA&zA){if(q=CA(de|0,0,52)|0,$=S()|0,de>>>0>15){if(!((f|0)==0&(s|0)==0)){SA=16;break A}for(i=0,e=0;;){if(i=KA(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=HA+(i<<3)|0,BA=t[o>>2]|0,o=t[o+4>>2]|0,!((BA|0)==0&(o|0)==0)){s=o,SA=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)){SA=21;break A}if(m=wA(l|0,e|0,52)|0,S()|0,m=m&15,(m|0)<(de|0)){s=12,SA=27;break A}if((m|0)!=(de|0)&&(l=l|q,e=e&-15728641|$,m>>>0>=fe>>>0)){a=de;do BA=CA(7,0,(14-a|0)*3|0)|0,a=a+1|0,l=BA|l,e=S()|0|e;while(a>>>0<m>>>0)}if(R=Rr(l|0,e|0,r|0,n|0)|0,I=S()|0,a=ne+(R<<3)|0,m=a,M=t[m>>2]|0,m=t[m+4>>2]|0,!((M|0)==0&(m|0)==0)){Y=0,nA=0;do{if((Y|0)>(n|0)|(Y|0)==(n|0)&nA>>>0>r>>>0){SA=31;break A}if((M|0)==(l|0)&(m&-117440513|0)==(e|0)){L=wA(M|0,m|0,56)|0,S()|0,L=L&7,G=L+1|0,BA=wA(M|0,m|0,45)|0,S()|0;t:do if(!(je(BA&127)|0))m=7;else{if(M=wA(M|0,m|0,52)|0,S()|0,M=M&15,!M){m=6;break}for(m=1;;){if(BA=CA(7,0,(15-m|0)*3|0)|0,!((BA&l|0)==0&((S()|0)&e|0)==0)){m=7;break t}if(m>>>0<M>>>0)m=m+1|0;else{m=6;break}}}while(!1);if((L+2|0)>>>0>m>>>0){SA=41;break A}BA=CA(G|0,0,56)|0,e=S()|0|e&-117440513,U=a,t[U>>2]=0,t[U+4>>2]=0,l=BA|l}else R=KA(R|0,I|0,1,0)|0,R=jr(R|0,S()|0,r|0,n|0)|0,I=S()|0;nA=KA(nA|0,Y|0,1,0)|0,Y=S()|0,a=ne+(R<<3)|0,m=a,M=t[m>>2]|0,m=t[m+4>>2]|0}while(!((M|0)==0&(m|0)==0))}BA=a,t[BA>>2]=l,t[BA+4>>2]=e}if(i=KA(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=HA+(i<<3)|0,l=t[e>>2]|0,e=t[e+4>>2]|0}}while(!1);if(BA=KA(r|0,n|0,5,0)|0,U=S()|0,U>>>0<0|(U|0)==0&BA>>>0<11){SA=85;break}if(BA=V0(r|0,n|0,6,0)|0,S()|0,BA=Qt(BA,8)|0,!BA){SA=48;break}do if(zA){for(G=0,e=0,L=0,Y=0;;){if(m=ne+(G<<3)|0,o=m,i=t[o>>2]|0,o=t[o+4>>2]|0,(i|0)==0&(o|0)==0)U=L;else{M=wA(i|0,o|0,56)|0,S()|0,M=M&7,l=M+1|0,R=o&-117440513,U=wA(i|0,o|0,45)|0,S()|0;e:do if(je(U&127)|0){if(I=wA(i|0,o|0,52)|0,S()|0,I=I&15,I|0)for(a=1;;){if(U=CA(7,0,(15-a|0)*3|0)|0,!((i&U|0)==0&(R&(S()|0)|0)==0))break e;if(a>>>0<I>>>0)a=a+1|0;else break}o=CA(l|0,0,56)|0,i=o|i,o=S()|0|R,l=m,t[l>>2]=i,t[l+4>>2]=o,l=M+2|0}while(!1);(l|0)==7?(U=BA+(e<<3)|0,t[U>>2]=i,t[U+4>>2]=o&-117440513,e=KA(e|0,L|0,1,0)|0,U=S()|0):U=L}if(G=KA(G|0,Y|0,1,0)|0,Y=S()|0,(Y|0)<(n|0)|(Y|0)==(n|0)&G>>>0<r>>>0)L=U;else break}if(zA){if(nA=de>>>0>15,q=CA(de|0,0,52)|0,$=S()|0,!QA){for(i=0,a=0,l=0,o=0;(f|0)==0&(s|0)==0||(de=A+(i<<3)|0,t[de>>2]=f,t[de+4>>2]=s,i=KA(i|0,a|0,1,0)|0,a=S()|0),l=KA(l|0,o|0,1,0)|0,o=S()|0,!!((o|0)<(n|0)|(o|0)==(n|0)&l>>>0<r>>>0);)s=HA+(l<<3)|0,f=t[s>>2]|0,s=t[s+4>>2]|0;s=U;break}for(i=0,a=0,o=0,l=0;;){do if(!((f|0)==0&(s|0)==0)){if(I=wA(f|0,s|0,52)|0,S()|0,I=I&15,nA|(I|0)<(de|0)){SA=80;break A}if((I|0)!=(de|0)){if(m=f|q,M=s&-15728641|$,I>>>0>=fe>>>0){R=de;do QA=CA(7,0,(14-R|0)*3|0)|0,R=R+1|0,m=QA|m,M=S()|0|M;while(R>>>0<I>>>0)}}else m=f,M=s;L=Rr(m|0,M|0,r|0,n|0)|0,R=0,I=0,Y=S()|0;do{if((R|0)>(n|0)|(R|0)==(n|0)&I>>>0>r>>>0){SA=81;break A}if(QA=ne+(L<<3)|0,G=t[QA+4>>2]|0,(G&-117440513|0)==(M|0)&&(t[QA>>2]|0)==(m|0)){SA=65;break}QA=KA(L|0,Y|0,1,0)|0,L=jr(QA|0,S()|0,r|0,n|0)|0,Y=S()|0,I=KA(I|0,R|0,1,0)|0,R=S()|0,QA=ne+(L<<3)|0}while(!((t[QA>>2]|0)==(m|0)&&(t[QA+4>>2]|0)==(M|0)));if((SA|0)==65&&(SA=0,!0&(G&117440512|0)==100663296))break;QA=A+(i<<3)|0,t[QA>>2]=f,t[QA+4>>2]=s,i=KA(i|0,a|0,1,0)|0,a=S()|0}while(!1);if(o=KA(o|0,l|0,1,0)|0,l=S()|0,!((l|0)<(n|0)|(l|0)==(n|0)&o>>>0<r>>>0))break;s=HA+(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(W0(ne|0,0,Ee|0)|0,Ir(HA|0,BA|0,e<<3|0)|0,qA(BA),(e|0)==0&(s|0)==0){SA=89;break}else A=A+(i<<3)|0,n=s,r=e}if((SA|0)==16)!0&(s&117440512|0)==0?(s=4,SA=27):SA=21;else if((SA|0)==31)OA(27795,27122,620,27132);else{if((SA|0)==41)return qA(HA),qA(ne),SA=10,SA|0;if((SA|0)==48)return qA(HA),qA(ne),SA=13,SA|0;(SA|0)==80?OA(27795,27122,711,27132):(SA|0)==81?OA(27795,27122,723,27132):(SA|0)==85&&(Ir(A|0,HA|0,r<<3|0)|0,SA=89)}return(SA|0)==21?(qA(HA),qA(ne),SA=5,SA|0):(SA|0)==27?(qA(HA),qA(ne),SA=s,SA|0):(SA|0)==89?(qA(HA),qA(ne),SA=0,SA|0):0}function dl(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0;if(G=b,b=b+16|0,L=G,!((r|0)>0|(r|0)==0&A>>>0>0))return L=0,b=G,L|0;if((o|0)>=16)return L=12,b=G,L|0;R=0,I=0,M=0,l=0;A:for(;;){if(f=e+(R<<3)|0,a=t[f>>2]|0,f=t[f+4>>2]|0,m=wA(a|0,f|0,52)|0,S()|0,(m&15|0)>(o|0)){l=12,a=11;break}if(ts(L,a,f,o),m=L,f=t[m>>2]|0,m=t[m+4>>2]|0,(f|0)==0&(m|0)==0)a=M;else{a=M;do{if(!((l|0)<(i|0)|(l|0)==(i|0)&a>>>0<s>>>0)){a=10;break A}M=n+(a<<3)|0,t[M>>2]=f,t[M+4>>2]=m,a=KA(a|0,l|0,1,0)|0,l=S()|0,rs(L),M=L,f=t[M>>2]|0,m=t[M+4>>2]|0}while(!((f|0)==0&(m|0)==0))}if(R=KA(R|0,I|0,1,0)|0,I=S()|0,(I|0)<(r|0)|(I|0)==(r|0)&R>>>0<A>>>0)M=a;else{l=0,a=11;break}}return(a|0)==10?(L=14,b=G,L|0):(a|0)==11?(b=G,l|0):0}function hl(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,a=0,f=0,m=0,M=0,R=0;R=b,b=b+16|0,M=R;A:do if((r|0)>0|(r|0)==0&A>>>0>0){for(f=0,o=0,i=0,m=0;;){if(a=e+(f<<3)|0,l=t[a>>2]|0,a=t[a+4>>2]|0,!((l|0)==0&(a|0)==0)&&(a=(p0(l,a,n,M)|0)==0,l=M,o=KA(t[l>>2]|0,t[l+4>>2]|0,o|0,i|0)|0,i=S()|0,!a)){i=12;break}if(f=KA(f|0,m|0,1,0)|0,m=S()|0,!((m|0)<(r|0)|(m|0)==(r|0)&f>>>0<A>>>0))break A}return b=R,i|0}else o=0,i=0;while(!1);return t[s>>2]=o,t[s+4>>2]=i,s=0,b=R,s|0}function ml(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&1|0}function Pt(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 qn(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0;if(a=wA(e|0,A|0,52)|0,S()|0,a=a&15,!a)return l=A,a=e,YA(l|0),a|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=CA(7,0,i|0)|0,s=S()|0,o=wA(e|0,A|0,i|0)|0,S()|0,i=CA(Gt(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=CA(7,0,o|0)|0,A=A&~(S()|0),o=CA(Gt(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<a>>>0)l=l+1|0;else break}return YA(A|0),e|0}function lr(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,YA(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=CA(7,0,i|0)|0,A=A&~(S()|0),i=CA(Gt(o&7)|0,0,i|0)|0,e=i|e&~s,A=S()|0|A,r>>>0<n>>>0;)r=r+1|0;return YA(A|0),e|0}function gl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0;if(a=wA(e|0,A|0,52)|0,S()|0,a=a&15,!a)return l=A,a=e,YA(l|0),a|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=CA(7,0,i|0)|0,s=S()|0,o=wA(e|0,A|0,i|0)|0,S()|0,i=CA(Ut(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=CA(7,0,s|0)|0,o=A&~(S()|0),A=wA(e|0,A|0,s|0)|0,S()|0,A=CA(Ut(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<a>>>0)l=l+1|0;else break}return YA(A|0),e|0}function Jn(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,YA(r|0),n|0;for(r=1;o=(15-r|0)*3|0,i=CA(7,0,o|0)|0,s=A&~(S()|0),A=wA(e|0,A|0,o|0)|0,S()|0,A=CA(Ut(A&7)|0,0,o|0)|0,e=A|e&~i,A=S()|0|s,r>>>0<n>>>0;)r=r+1|0;return YA(A|0),e|0}function pl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(a=b,b=b+64|0,l=a+40|0,n=a+24|0,s=a+12|0,i=a,CA(A|0,0,52)|0,r=S()|0|134225919,!A)return(t[e+4>>2]|0)>2||(t[e+8>>2]|0)>2||(t[e+12>>2]|0)>2?(o=0,l=0,YA(o|0),b=a,l|0):(CA(g0(e)|0,0,45)|0,o=S()|0|r,l=-1,YA(o|0),b=a,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?(vr(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],kr(s)):(br(o),t[s>>2]=t[o>>2],t[s+4>>2]=t[o+4>>2],t[s+8>>2]=t[o+8>>2],Ht(s)),yt(n,s,i),Me(i),m=(15-A|0)*3|0,f=CA(7,0,m|0)|0,r=r&~(S()|0),m=CA(St(i)|0,0,m|0)|0,e=m|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=g0(l)|0,A=CA(n|0,0,45)|0,A=A|e,e=S()|0|r&-1040385,i=u0(l)|0,!(je(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;m=(15-r|0)*3|0,l=wA(A|0,e|0,m|0)|0,S()|0,f=CA(7,0,m|0)|0,e=e&~(S()|0),m=CA(Gt(l&7)|0,0,m|0)|0,A=A&~f|m,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(m=wA(A|0,e|0,(15-r|0)*3|0)|0,S()|0,m&7){case 1:break t;case 0:break;default:break e}if(r>>>0<s>>>0)r=r+1|0;else break e}if(M0(n,t[l>>2]|0)|0)for(r=1;l=(15-r|0)*3|0,f=CA(7,0,l|0)|0,m=e&~(S()|0),e=wA(A|0,e|0,l|0)|0,S()|0,e=CA(Ut(e&7)|0,0,l|0)|0,A=A&~f|e,e=m|(S()|0),r>>>0<s>>>0;)r=r+1|0;else for(r=1;m=(15-r|0)*3|0,l=wA(A|0,e|0,m|0)|0,S()|0,f=CA(7,0,m|0)|0,e=e&~(S()|0),m=CA(Gt(l&7)|0,0,m|0)|0,A=A&~f|m,e=e|(S()|0),r>>>0<s>>>0;)r=r+1|0}while(!1);if((i|0)>0){r=0;do A=qn(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,m=A,YA(f|0),b=a,m|0}function Jt(e){return e=e|0,(e|0)%2|0|0}function Xn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;return s=b,b=b+16|0,n=s,A>>>0>15?(n=4,b=s,n|0):(t[e+4>>2]&2146435072|0)==2146435072||(t[e+8+4>>2]&2146435072|0)==2146435072?(n=3,b=s,n|0):(wn(e,A,n),A=pl(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,b=s,n|0)}function As(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,je(o&127)|0){if(n)return o=1,o|0;n=1}else{if(n)return o=0,o|0;(t[s>>2]|0)==0&&(t[r+8>>2]|0)==0?n=(t[r+12>>2]|0)!=0&1:n=1}for(r=1;r&1?kr(s):Ht(s),o=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,pn(s,o&7),r>>>0<i>>>0;)r=r+1|0;return n|0}function Dr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(m=b,b=b+16|0,a=m,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,b=m,f|0;A:do if((je(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=CA(7,0,A|0)|0,l=n&~(S()|0),n=wA(e|0,n|0,A|0)|0,S()|0,n=CA(Ut(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],!(As(e,n,r)|0))return f=0,b=m,f|0;if(o=r+4|0,t[a>>2]=t[o>>2],t[a+4>>2]=t[o+4>>2],t[a+8>>2]=t[o+8>>2],i=wA(e|0,n|0,52)|0,S()|0,l=i&15,i&1?(Ht(o),i=l+1|0):i=l,!(je(f)|0))n=0;else{A:do if(!l)n=0;else for(A=1;;){if(s=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(!(N(r,i,n,0)|0))(i|0)!=(l|0)&&(t[o>>2]=t[a>>2],t[o+4>>2]=t[a+4>>2],t[o+8>>2]=t[a+8>>2]);else{if(je(f)|0)do;while((N(r,i,0,0)|0)!=0);(i|0)!=(l|0)&&br(o)}return f=0,b=m,f|0}function ar(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;return i=b,b=b+16|0,n=i,s=Dr(e,A,n)|0,s|0?(b=i,s|0):(s=wA(e|0,A|0,52)|0,S()|0,h(n,s&15,r),s=0,b=i,s|0)}function _r(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=b,b=b+16|0,i=o,n=Dr(e,A,i)|0,n|0)return i=n,b=o,i|0;n=wA(e|0,A|0,45)|0,S()|0,n=(je(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=CA(7,0,(15-n|0)*3|0)|0,!((l&e|0)==0&((S()|0)&A|0)==0))break A;if(n>>>0<s>>>0)n=n+1|0;else break}return w(i,s,0,5,r),l=0,b=o,l|0}while(!1);return AA(i,s,0,6,r),l=0,b=o,l|0}function yl(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,!(je(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=CA(7,0,(15-n|0)*3|0)|0,!((i&e|0)==0&((S()|0)&A|0)==0)){n=2,e=6;break}if(n>>>0<s>>>0)n=n+1|0;else{n=5,e=6;break}}return(e|0)==6&&(t[r>>2]=n),0}function Zs(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0;M=b,b=b+128|0,f=M+112|0,i=M+96|0,m=M,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(je(o)|0){if(l|0)for(n=1;;){if(a=CA(7,0,(15-n|0)*3|0)|0,!((a&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 a=CA(l+1|0,0,52)|0,m=S()|0|A&-15728641,f=CA(7,0,(14-l|0)*3|0)|0,m=Zs((a|e)&~f,m&~(S()|0),r)|0,b=M,m|0}else s=0;while(!1);if(n=Dr(e,A,i)|0,!n){s?(B(i,f,m),a=5):(hA(i,f,m),a=6);A:do if(je(o)|0)if(!l)e=5;else for(n=1;;){if(o=CA(7,0,(15-n|0)*3|0)|0,!((o&e|0)==0&((S()|0)&A|0)==0)){e=2;break A}if(n>>>0<l>>>0)n=n+1|0;else{e=5;break}}else e=2;while(!1);W0(r|0,-1,e<<2|0)|0;A:do if(s)for(i=0;;){if(o=m+(i<<4)|0,tA(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>=a>>>0){n=0;break}}else for(i=0;;){if(o=m+(i<<4)|0,N(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>=a>>>0){n=0;break}}while(!1)}return m=n,b=M,m|0}function xl(){return 12}function es(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0;if(e>>>0>15)return l=4,l|0;if(CA(e|0,0,52)|0,l=S()|0|134225919,!e){r=0,n=0;do je(n)|0&&(CA(n|0,0,45)|0,o=l|(S()|0),e=A+(r<<3)|0,t[e>>2]=-1,t[e+4>>2]=o,r=r+1|0),n=n+1|0;while((n|0)!=122);return r=0,r|0}r=0,o=0;do{if(je(o)|0){for(CA(o|0,0,45)|0,n=1,s=-1,i=l|(S()|0);a=CA(7,0,(15-n|0)*3|0)|0,s=s&~a,i=i&~(S()|0),(n|0)!=(e|0);)n=n+1|0;a=A+(r<<3)|0,t[a>>2]=s,t[a+4>>2]=i,r=r+1|0}o=o+1|0}while((o|0)!=122);return r=0,r|0}function wl(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0;if(q=b,b=b+16|0,Y=q,nA=wA(e|0,A|0,52)|0,S()|0,nA=nA&15,r>>>0>15)return nA=4,b=q,nA|0;if((nA|0)<(r|0))return nA=12,b=q,nA|0;if((nA|0)!=(r|0))if(i=CA(r|0,0,52)|0,i=i|e,l=S()|0|A&-15728641,(nA|0)>(r|0)){a=r;do G=CA(7,0,(14-a|0)*3|0)|0,a=a+1|0,i=G|i,l=S()|0|l;while((a|0)<(nA|0));G=i}else G=i;else G=e,l=A;L=wA(G|0,l|0,45)|0,S()|0;A:do if(je(L&127)|0){if(a=wA(G|0,l|0,52)|0,S()|0,a=a&15,a|0)for(i=1;;){if(L=CA(7,0,(15-i|0)*3|0)|0,!((L&G|0)==0&((S()|0)&l|0)==0)){f=33;break A}if(i>>>0<a>>>0)i=i+1|0;else break}if(L=n,t[L>>2]=0,t[L+4>>2]=0,(nA|0)>(r|0)){for(L=A&-15728641,I=nA;;){if(R=I,I=I+-1|0,I>>>0>15|(nA|0)<(I|0)){f=19;break}if((nA|0)!=(I|0))if(i=CA(I|0,0,52)|0,i=i|e,a=S()|0|L,(nA|0)<(R|0))M=i;else{f=I;do M=CA(7,0,(14-f|0)*3|0)|0,f=f+1|0,i=M|i,a=S()|0|a;while((f|0)<(nA|0));M=i}else M=e,a=A;if(m=wA(M|0,a|0,45)|0,S()|0,!(je(m&127)|0))i=0;else{m=wA(M|0,a|0,52)|0,S()|0,m=m&15;e:do if(!m)i=0;else for(f=1;;){if(i=wA(M|0,a|0,(15-f|0)*3|0)|0,S()|0,i=i&7,i|0)break e;if(f>>>0<m>>>0)f=f+1|0;else{i=0;break}}while(!1);i=(i|0)==0&1}if(a=wA(e|0,A|0,(15-R|0)*3|0)|0,S()|0,a=a&7,(a|0)==7){s=5,f=42;break}if(i=(i|0)!=0,(a|0)==1&i){s=5,f=42;break}if(M=a+(((a|0)!=0&i)<<31>>31)|0,M|0&&(f=nA-R|0,f=G0(7,0,f,((f|0)<0)<<31>>31)|0,m=S()|0,i?(i=ft(f|0,m|0,5,0)|0,i=KA(i|0,S()|0,-5,-1)|0,i=V0(i|0,S()|0,6,0)|0,i=KA(i|0,S()|0,1,0)|0,a=S()|0):(i=f,a=m),R=M+-1|0,R=ft(f|0,m|0,R|0,((R|0)<0)<<31>>31|0)|0,R=KA(i|0,a|0,R|0,S()|0)|0,M=S()|0,m=n,m=KA(R|0,M|0,t[m>>2]|0,t[m+4>>2]|0)|0,M=S()|0,R=n,t[R>>2]=m,t[R+4>>2]=M),(I|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 b=q,s|0}else s=0,o=0}else f=33;while(!1);A:do if((f|0)==33)if(L=n,t[L>>2]=0,t[L+4>>2]=0,(nA|0)>(r|0)){for(i=nA;;){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=nA-i|0,o=G0(7,0,o,((o|0)<0)<<31>>31)|0,s=ft(o|0,S()|0,s|0,0)|0,o=S()|0,L=n,o=KA(t[L>>2]|0,t[L+4>>2]|0,s|0,o|0)|0,s=S()|0,L=n,t[L>>2]=o,t[L+4>>2]=s,i=i+-1|0,(i|0)<=(r|0))break A}return b=q,s|0}else s=0,o=0;while(!1);return p0(G,l,nA,Y)|0&&OA(27795,27122,1327,27173),nA=Y,Y=t[nA+4>>2]|0,((s|0)>-1|(s|0)==-1&o>>>0>4294967295)&((Y|0)>(s|0)|((Y|0)==(s|0)?(t[nA>>2]|0)>>>0>o>>>0:0))?(nA=0,b=q,nA|0):(OA(27795,27122,1407,27158),0)}function vl(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0;if(M=b,b=b+16|0,o=M,s>>>0>15)return i=4,b=M,i|0;if(l=wA(r|0,n|0,52)|0,S()|0,l=l&15,(l|0)>(s|0))return i=12,b=M,i|0;if(p0(r,n,s,o)|0&&OA(27795,27122,1327,27173),m=o,f=t[m+4>>2]|0,!(((A|0)>-1|(A|0)==-1&e>>>0>4294967295)&((f|0)>(A|0)|((f|0)==(A|0)?(t[m>>2]|0)>>>0>e>>>0:0))))return i=2,b=M,i|0;m=s-l|0,s=CA(s|0,0,52)|0,a=S()|0|n&-15728641,f=i,t[f>>2]=s|r,t[f+4>>2]=a,f=wA(r|0,n|0,45)|0,S()|0;A:do if(je(f&127)|0){if(l|0)for(o=1;;){if(f=CA(7,0,(15-o|0)*3|0)|0,!((f&r|0)==0&((S()|0)&n|0)==0))break A;if(o>>>0<l>>>0)o=o+1|0;else break}if((m|0)<1)return i=0,b=M,i|0;for(f=l^15,n=-1,a=1,o=1;;){l=m-a|0,l=G0(7,0,l,((l|0)<0)<<31>>31)|0,r=S()|0;do if(o)if(o=ft(l|0,r|0,5,0)|0,o=KA(o|0,S()|0,-5,-1)|0,o=V0(o|0,S()|0,6,0)|0,s=S()|0,(A|0)>(s|0)|(A|0)==(s|0)&e>>>0>o>>>0){A=KA(e|0,A|0,-1,-1)|0,A=ct(A|0,S()|0,o|0,s|0)|0,o=S()|0,R=i,L=t[R>>2]|0,R=t[R+4>>2]|0,G=(f+n|0)*3|0,I=CA(7,0,G|0)|0,R=R&~(S()|0),n=V0(A|0,o|0,l|0,r|0)|0,e=S()|0,s=KA(n|0,e|0,2,0)|0,G=CA(s|0,S()|0,G|0)|0,R=S()|0|R,s=i,t[s>>2]=G|L&~I,t[s+4>>2]=R,e=ft(n|0,e|0,l|0,r|0)|0,e=ct(A|0,o|0,e|0,S()|0)|0,o=0,A=S()|0;break}else{G=i,I=t[G>>2]|0,G=t[G+4>>2]|0,L=CA(7,0,(f+n|0)*3|0)|0,G=G&~(S()|0),o=i,t[o>>2]=I&~L,t[o+4>>2]=G,o=1;break}else I=i,s=t[I>>2]|0,I=t[I+4>>2]|0,n=(f+n|0)*3|0,R=CA(7,0,n|0)|0,I=I&~(S()|0),G=V0(e|0,A|0,l|0,r|0)|0,o=S()|0,n=CA(G|0,o|0,n|0)|0,I=S()|0|I,L=i,t[L>>2]=n|s&~R,t[L+4>>2]=I,o=ft(G|0,o|0,l|0,r|0)|0,e=ct(e|0,A|0,o|0,S()|0)|0,o=0,A=S()|0;while(!1);if((m|0)>(a|0))n=~a,a=a+1|0;else{A=0;break}}return b=M,A|0}while(!1);if((m|0)<1)return G=0,b=M,G|0;for(s=l^15,o=1;;)if(L=m-o|0,L=G0(7,0,L,((L|0)<0)<<31>>31)|0,G=S()|0,a=i,r=t[a>>2]|0,a=t[a+4>>2]|0,l=(s-o|0)*3|0,n=CA(7,0,l|0)|0,a=a&~(S()|0),R=V0(e|0,A|0,L|0,G|0)|0,I=S()|0,l=CA(R|0,I|0,l|0)|0,a=S()|0|a,f=i,t[f>>2]=l|r&~n,t[f+4>>2]=a,G=ft(R|0,I|0,L|0,G|0)|0,e=ct(e|0,A|0,G|0,S()|0)|0,A=S()|0,(m|0)<=(o|0)){A=0;break}else o=o+1|0;return b=M,A|0}function ts(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=Ys(A,r,s+1|0,n)|0,o=(S()|0)&-15728641,r=CA(n|0,0,52)|0,r=A|r,o=o|(S()|0),A=(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 $s(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=Ys(e,A,s+1|0,r)|0,i=(S()|0)&-15728641,s=CA(r|0,0,52)|0,s=e|s,i=i|(S()|0),e=n,t[e>>2]=s,t[e+4>>2]=i,e=n+12|0,Oe(s,i)|0){t[e>>2]=r;return}else{t[e>>2]=-1;return}}function rs(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,a=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=CA(1,0,(n^15)*3|0)|0,A=KA(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(a=e+12|0,i=n;;){if((i|0)==(o|0)){n=5;break}if(f=(i|0)==(t[a>>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=CA(1,0,s|0)|0,A=KA(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[a>>2]=-1;return}else if((n|0)==7){o=CA(1,0,s|0)|0,o=KA(A|0,r|0,o|0,S()|0)|0,l=S()|0,f=e,t[f>>2]=o,t[f+4>>2]=l,t[a>>2]=i+-1;return}else if((n|0)==10)return}}function tn(e){e=+e;var A=0;return A=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?A+-6.283185307179586:A)}function Tr(e,A){return e=e|0,A=A|0,+$A(+(+k[e>>3]-+k[A>>3]))<17453292519943298e-27?(A=+$A(+(+k[e+8>>3]-+k[A+8>>3]))<17453292519943298e-27,A|0):(A=0,A|0)}function Vt(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 bl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+k[A>>3],n=+k[e>>3],i=+ie(+((s-n)*.5)),r=+ie(+((+k[A+8>>3]-+k[e+8>>3])*.5)),r=i*i+r*(+_e(+s)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2)}function rn(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+k[A>>3],n=+k[e>>3],i=+ie(+((s-n)*.5)),r=+ie(+((+k[A+8>>3]-+k[e+8>>3])*.5)),r=i*i+r*(+_e(+s)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2*6371.007180918475)}function kl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=+k[A>>3],n=+k[e>>3],i=+ie(+((s-n)*.5)),r=+ie(+((+k[A+8>>3]-+k[e+8>>3])*.5)),r=i*i+r*(+_e(+s)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2*6371.007180918475*1e3)}function Cl(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0;return i=+k[A>>3],n=+_e(+i),s=+k[A+8>>3]-+k[e+8>>3],o=n*+ie(+s),r=+k[e>>3],+ +Te(+o,+(+ie(+i)*+_e(+r)-+_e(+s)*(n*+ie(+r))))}function El(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=+k[e>>3]+r,k[n>>3]=A,s=n;else{if(s=+$A(+(i+-3.141592653589793))<1e-16,A=+k[e>>3],s){A=A-r,k[n>>3]=A,s=n;break}if(o=+_e(+r),r=+ie(+r),A=o*+ie(+A)+ +_e(+i)*(r*+_e(+A)),A=A>1?1:A,A=+h0(+(A<-1?-1:A)),k[n>>3]=A,+$A(+(A+-1.5707963267948966))<1e-16){k[n>>3]=1.5707963267948966,k[n+8>>3]=0;return}if(+$A(+(A+1.5707963267948966))<1e-16){k[n>>3]=-1.5707963267948966,k[n+8>>3]=0;return}if(l=1/+_e(+A),i=r*+ie(+i)*l,r=+k[e>>3],A=l*((o-+ie(+A)*+ie(+r))/+_e(+r)),o=i>1?1:i,A=A>1?1:A,A=+k[e+8>>3]+ +Te(+(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);k[n+8>>3]=A;return}while(!1);if(+$A(+(A+-1.5707963267948966))<1e-16){k[s>>3]=1.5707963267948966,k[n+8>>3]=0;return}if(+$A(+(A+1.5707963267948966))<1e-16){k[s>>3]=-1.5707963267948966,k[n+8>>3]=0;return}if(A=+k[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);k[n+8>>3]=A}function qs(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[20656+(e<<3)>>3],A=0,A|0)}function Sl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[20784+(e<<3)>>3],A=0,A|0)}function Ml(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[20912+(e<<3)>>3],A=0,A|0)}function Bl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(k[A>>3]=+k[21040+(e<<3)>>3],A=0,A|0)}function bn(e,A){e=e|0,A=A|0;var r=0;return e>>>0>15?(A=4,A|0):(r=G0(7,0,e,((e|0)<0)<<31>>31)|0,r=ft(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 Js(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0;return R=+k[A>>3],m=+k[e>>3],a=+ie(+((R-m)*.5)),i=+k[A+8>>3],f=+k[e+8>>3],o=+ie(+((i-f)*.5)),l=+_e(+m),M=+_e(+R),o=a*a+o*(M*l*o),o=+Te(+ +ye(+o),+ +ye(+(1-o)))*2,a=+k[r>>3],R=+ie(+((a-R)*.5)),n=+k[r+8>>3],i=+ie(+((n-i)*.5)),s=+_e(+a),i=R*R+i*(M*s*i),i=+Te(+ +ye(+i),+ +ye(+(1-i)))*2,a=+ie(+((m-a)*.5)),n=+ie(+((f-n)*.5)),n=a*a+n*(l*s*n),n=+Te(+ +ye(+n),+ +ye(+(1-n)))*2,s=(o+i+n)*.5,+(+mt(+ +ye(+(+et(+(s*.5))*+et(+((s-o)*.5))*+et(+((s-i)*.5))*+et(+((s-n)*.5)))))*4)}function ns(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=b,b=b+192|0,i=l+168|0,o=l,s=ar(e,A,i)|0,s|0)return r=s,b=l,r|0;if(_r(e,A,o)|0&&OA(27795,27190,415,27199),A=t[o>>2]|0,(A|0)>0){if(n=+Js(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+ +Js(o+8+(s<<4)|0,o+8+(((e|0)%(A|0)|0)<<4)|0,i);while((e|0)<(A|0))}}else n=0;return k[r>>3]=n,r=0,b=l,r|0}function Dl(e,A,r){return e=e|0,A=A|0,r=r|0,e=ns(e,A,r)|0,e|0||(k[r>>3]=+k[r>>3]*6371.007180918475*6371.007180918475),e|0}function _l(e,A,r){return e=e|0,A=A|0,r=r|0,e=ns(e,A,r)|0,e|0||(k[r>>3]=+k[r>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function Tl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(l=b,b=b+176|0,o=l,e=or(e,A,o)|0,e|0)return o=e,b=l,o|0;if(k[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,b=l,o|0;A=e+-1|0,e=0,n=+k[o+8>>3],s=+k[o+16>>3],i=0;do e=e+1|0,f=n,n=+k[o+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=s,s=+k[o+8+(e<<4)+8>>3],a=+ie(+((s-a)*.5)),a=m*m+a*(+_e(+n)*+_e(+f)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)<(A|0));return k[r>>3]=i,o=0,b=l,o|0}function jl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(l=b,b=b+176|0,o=l,e=or(e,A,o)|0,e|0)return o=e,i=+k[r>>3],i=i*6371.007180918475,k[r>>3]=i,b=l,o|0;if(k[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,i=0,i=i*6371.007180918475,k[r>>3]=i,b=l,o|0;A=e+-1|0,e=0,n=+k[o+8>>3],s=+k[o+16>>3],i=0;do e=e+1|0,f=n,n=+k[o+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=s,s=+k[o+8+(e<<4)+8>>3],a=+ie(+((s-a)*.5)),a=m*m+a*(+_e(+f)*+_e(+n)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)!=(A|0));return k[r>>3]=i,o=0,m=i,m=m*6371.007180918475,k[r>>3]=m,b=l,o|0}function Rl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(l=b,b=b+176|0,o=l,e=or(e,A,o)|0,e|0)return o=e,i=+k[r>>3],i=i*6371.007180918475,i=i*1e3,k[r>>3]=i,b=l,o|0;if(k[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,i=0,i=i*6371.007180918475,i=i*1e3,k[r>>3]=i,b=l,o|0;A=e+-1|0,e=0,n=+k[o+8>>3],s=+k[o+16>>3],i=0;do e=e+1|0,f=n,n=+k[o+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=s,s=+k[o+8+(e<<4)+8>>3],a=+ie(+((s-a)*.5)),a=m*m+a*(+_e(+f)*+_e(+n)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)!=(A|0));return k[r>>3]=i,o=0,m=i,m=m*6371.007180918475,m=m*1e3,k[r>>3]=m,b=l,o|0}function Il(e){e=e|0;var A=0,r=0,n=0;return A=Qt(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 Ll(e,A){e=e|0,A=A|0;var r=0,n=0;return n=y0(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 Xs(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,qA(s);while((r|0)!=0);s=A,A=t[A+8>>2]|0,qA(s)}while((A|0)!=0);if(A=e,e=t[e+8>>2]|0,n||qA(A),e)n=0;else break}}function Nl(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,de=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,he=0;if(s=e+8|0,t[s>>2]|0)return he=1,he|0;if(n=t[e>>2]|0,!n)return he=0,he|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 he=0,he|0;ve=y0(r<<2)|0,ve||OA(27396,27235,317,27415),SA=y0(r<<5)|0,SA||OA(27437,27235,321,27415),t[e>>2]=0,zA=e+4|0,t[zA>>2]=0,t[s>>2]=0,r=0,HA=0,BA=0,M=0;A:for(;;){if(m=t[n>>2]|0,m){i=0,o=m;do{if(a=+k[o+8>>3],A=o,o=t[o+16>>2]|0,f=(o|0)==0,s=f?m:o,l=+k[s+8>>3],+$A(+(a-l))>3.141592653589793){he=14;break}i=i+(l-a)*(+k[A>>3]+ +k[s>>3])}while(!f);if((he|0)==14){he=0,i=0,A=m;do U=+k[A+8>>3],ne=A+16|0,Ee=t[ne>>2]|0,Ee=(Ee|0)==0?m:Ee,$=+k[Ee+8>>3],i=i+(+k[A>>3]+ +k[Ee>>3])*(($<0?$+6.283185307179586:$)-(U<0?U+6.283185307179586:U)),A=t[((A|0)==0?n:ne)>>2]|0;while((A|0)!=0)}i>0?(t[ve+(HA<<2)>>2]=n,HA=HA+1|0,s=BA,A=M):he=19}else he=19;if((he|0)==19){he=0;do if(r){if(A=r+8|0,t[A>>2]|0){he=21;break A}if(r=Qt(1,12)|0,!r){he=23;break A}t[A>>2]=r,s=r+4|0,o=r,A=M}else if(M){s=zA,o=M+8|0,A=n,r=e;break}else if(t[e>>2]|0){he=27;break A}else{s=zA,o=e,A=n,r=e;break}while(!1);if(t[o>>2]=n,t[s>>2]=n,o=SA+(BA<<5)|0,f=t[n>>2]|0,f){for(m=SA+(BA<<5)+8|0,k[m>>3]=17976931348623157e292,M=SA+(BA<<5)+24|0,k[M>>3]=17976931348623157e292,k[o>>3]=-17976931348623157e292,R=SA+(BA<<5)+16|0,k[R>>3]=-17976931348623157e292,nA=17976931348623157e292,q=-17976931348623157e292,s=0,I=f,a=17976931348623157e292,G=17976931348623157e292,Y=-17976931348623157e292,l=-17976931348623157e292;i=+k[I>>3],U=+k[I+8>>3],I=t[I+16>>2]|0,L=(I|0)==0,$=+k[(L?f:I)+8>>3],i<a&&(k[m>>3]=i,a=i),U<G&&(k[M>>3]=U,G=U),i>Y?k[o>>3]=i:i=Y,U>l&&(k[R>>3]=U,l=U),nA=U>0&U<nA?U:nA,q=U<0&U>q?U:q,s=s|+$A(+(U-$))>3.141592653589793,!L;)Y=i;s&&(k[R>>3]=q,k[M>>3]=nA)}else t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,t[o+12>>2]=0,t[o+16>>2]=0,t[o+20>>2]=0,t[o+24>>2]=0,t[o+28>>2]=0;s=BA+1|0}if(ne=n+8|0,n=t[ne>>2]|0,t[ne>>2]=0,n)BA=s,M=A;else{he=45;break}}if((he|0)==21)OA(27213,27235,35,27247);else if((he|0)==23)OA(27267,27235,37,27247);else if((he|0)==27)OA(27310,27235,61,27333);else if((he|0)==45){A:do if((HA|0)>0){for(ne=(s|0)==0,de=s<<2,Ee=(e|0)==0,fe=0,A=0;;){if(QA=t[ve+(fe<<2)>>2]|0,ne)he=73;else{if(BA=y0(de)|0,!BA){he=50;break}if(zA=y0(de)|0,!zA){he=52;break}e:do if(Ee)r=0;else{for(s=0,r=0,o=e;n=SA+(s<<5)|0,Ai(t[o>>2]|0,n,t[QA>>2]|0)|0?(t[BA+(r<<2)>>2]=o,t[zA+(r<<2)>>2]=n,L=r+1|0):L=r,o=t[o+8>>2]|0,o;)s=s+1|0,r=L;if((L|0)>0)if(n=t[BA>>2]|0,(L|0)==1)r=n;else for(R=0,I=-1,r=n,M=n;;){for(f=t[M>>2]|0,n=0,o=0;s=t[t[BA+(o<<2)>>2]>>2]|0,(s|0)==(f|0)?m=n:m=n+((Ai(s,t[zA+(o<<2)>>2]|0,t[f>>2]|0)|0)&1)|0,o=o+1|0,(o|0)!=(L|0);)n=m;if(s=(m|0)>(I|0),r=s?M:r,n=R+1|0,(n|0)==(L|0))break e;R=n,I=s?m:I,M=t[BA+(n<<2)>>2]|0}else r=0}while(!1);if(qA(BA),qA(zA),r){if(s=r+4|0,n=t[s>>2]|0,n)r=n+8|0;else if(t[r>>2]|0){he=70;break}t[r>>2]=QA,t[s>>2]=QA}else he=73}if((he|0)==73){if(he=0,A=t[QA>>2]|0,A|0)do zA=A,A=t[A+16>>2]|0,qA(zA);while((A|0)!=0);qA(QA),A=1}if(fe=fe+1|0,(fe|0)>=(HA|0)){Ve=A;break A}}(he|0)==50?OA(27452,27235,249,27471):(he|0)==52?OA(27490,27235,252,27471):(he|0)==70&&OA(27310,27235,61,27333)}else Ve=0;while(!1);return qA(ve),qA(SA),he=Ve,he|0}return 0}function Ai(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(!(c0(A,r)|0)||(A=Ft(A)|0,n=+k[r>>3],s=+k[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=+k[r>>3],s=+k[r+8>>3],r=r+16|0,m=t[r>>2]|0,m=(m|0)==0?e:m,i=+k[m>>3],l=+k[m+8>>3],o>i?(a=o,o=l):(a=i,i=o,o=s,s=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(n<i|n>a);)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,a=l+(o-l)*((n-i)/(a-i)),(a<0?a+6.283185307179586:a)>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=+k[r>>3],s=+k[r+8>>3],r=r+16|0,m=t[r>>2]|0,m=(m|0)==0?e:m,i=+k[m>>3],l=+k[m+8>>3],o>i?(a=o,o=l):(a=i,i=o,o=s,s=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(n<i|n>a);)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)/(a-i))>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}return 0}function _0(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0;if(q=b,b=b+32|0,nA=q+16|0,Y=q,i=wA(e|0,A|0,52)|0,S()|0,i=i&15,I=wA(r|0,n|0,52)|0,S()|0,(i|0)!=(I&15|0))return nA=12,b=q,nA|0;if(f=wA(e|0,A|0,45)|0,S()|0,f=f&127,m=wA(r|0,n|0,45)|0,S()|0,m=m&127,f>>>0>121|m>>>0>121)return nA=5,b=q,nA|0;if(I=(f|0)!=(m|0),I){if(l=sr(f,m)|0,(l|0)==7)return nA=1,b=q,nA|0;a=sr(m,f)|0,(a|0)==7?OA(27514,27538,161,27548):(L=l,o=a)}else L=0,o=0;M=je(f)|0,R=je(m)|0,t[nA>>2]=0,t[nA+4>>2]=0,t[nA+8>>2]=0,t[nA+12>>2]=0;do if(L){if(m=t[4272+(f*28|0)+(L<<2)>>2]|0,l=(m|0)>0,R)if(l){f=0,a=r,l=n;do a=gl(a,l)|0,l=S()|0,o=Ut(o)|0,(o|0)==1&&(o=Ut(1)|0),f=f+1|0;while((f|0)!=(m|0));m=o,f=a,a=l}else m=o,f=r,a=n;else if(l){f=0,a=r,l=n;do a=Jn(a,l)|0,l=S()|0,o=Ut(o)|0,f=f+1|0;while((f|0)!=(m|0));m=o,f=a,a=l}else m=o,f=r,a=n;if(As(f,a,nA)|0,I||OA(27563,27538,191,27548),l=(M|0)!=0,o=(R|0)!=0,l&o&&OA(27590,27538,192,27548),l){if(o=Pt(e,A)|0,(o|0)==7){i=5;break}if(xA[22e3+(o*7|0)+L>>0]|0){i=1;break}a=t[21168+(o*28|0)+(L<<2)>>2]|0,f=a}else if(o){if(o=Pt(f,a)|0,(o|0)==7){i=5;break}if(xA[22e3+(o*7|0)+m>>0]|0){i=1;break}f=0,a=t[21168+(m*28|0)+(o<<2)>>2]|0}else f=0,a=0;if((f|a|0)<0)i=5;else{if((a|0)>0){l=nA+4|0,o=0;do D0(l),o=o+1|0;while((o|0)!=(a|0))}if(t[Y>>2]=0,t[Y+4>>2]=0,t[Y+8>>2]=0,pn(Y,L),i|0)for(;Jt(i)|0?kr(Y):Ht(Y),(i|0)>1;)i=i+-1|0;if((f|0)>0){i=0;do D0(Y),i=i+1|0;while((i|0)!=(f|0))}G=nA+4|0,Ze(G,Y,G),Me(G),G=51}}else if(As(r,n,nA)|0,(M|0)!=0&(R|0)!=0)if((m|0)!=(f|0)&&OA(27621,27538,261,27548),o=Pt(e,A)|0,i=Pt(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=nA+4|0,i=0;do D0(l),i=i+1|0;while((i|0)!=(o|0));G=51}else G=51;else G=51;while(!1);return(G|0)==51&&(i=nA+4|0,t[s>>2]=t[i>>2],t[s+4>>2]=t[i+4>>2],t[s+8>>2]=t[i+8>>2],i=0),nA=i,b=q,nA|0}function ei(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0;if(G=b,b=b+48|0,f=G+36|0,o=G+24|0,l=G+12|0,a=G,s=wA(e|0,A|0,52)|0,S()|0,s=s&15,R=wA(e|0,A|0,45)|0,S()|0,R=R&127,R>>>0>121)return n=5,b=G,n|0;if(m=je(R)|0,CA(s|0,0,52)|0,Y=S()|0|134225919,i=n,t[i>>2]=-1,t[i+4>>2]=Y,!s)return s=St(r)|0,(s|0)==7||(s=nr(R,s)|0,(s|0)==127)?(Y=1,b=G,Y|0):(I=CA(s|0,0,45)|0,L=S()|0,R=n,L=t[R+4>>2]&-1040385|L,Y=n,t[Y>>2]=t[R>>2]|I,t[Y+4>>2]=L,Y=0,b=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],Jt(i)|0){if(s=wr(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],kr(l)}else{if(s=gn(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],Ht(l)}if(yt(o,l,a),Me(a),s=n,q=t[s>>2]|0,s=t[s+4>>2]|0,$=(15-i|0)*3|0,nA=CA(7,0,$|0)|0,s=s&~(S()|0),$=CA(St(a)|0,0,$|0)|0,s=S()|0|s,Y=n,t[Y>>2]=$|q&~nA,t[Y+4>>2]=s,(i|0)<=1){r=14;break}}A:do if((r|0)!=13&&(r|0)==14)if((t[f>>2]|0)<=1&&(t[f+4>>2]|0)<=1&&(t[f+8>>2]|0)<=1){r=St(f)|0,s=nr(R,r)|0,(s|0)==127?a=0:a=je(s)|0;e:do if(r){if(m){if(s=Pt(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=Gt(s)|0,r=r+1|0;while((r|0)!=(i|0))}else s=r;if((s|0)==1){s=9;break A}r=nr(R,s)|0,(r|0)==127&&OA(27648,27538,411,27678),je(r)|0?OA(27693,27538,412,27678):(L=r,I=i,M=s)}else L=s,I=0,M=r;if(l=t[4272+(R*28|0)+(M<<2)>>2]|0,(l|0)<=-1&&OA(27724,27538,419,27678),!a){if((I|0)<0){s=5;break A}if(I|0){i=n,s=0,r=t[i>>2]|0,i=t[i+4>>2]|0;do r=lr(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,s=s+1|0;while((s|0)<(I|0))}if((l|0)<=0){s=L,r=58;break}for(i=n,s=0,r=t[i>>2]|0,i=t[i+4>>2]|0;;)if(r=lr(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,s=s+1|0,(s|0)==(l|0)){s=L,r=58;break e}}if(o=sr(L,R)|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=lr(r,s)|0,s=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=s,i=i+1|0;while((i|0)!=(l|0))}if(s=Pt(r,s)|0,(s|0)==7&&OA(27795,27538,440,27678),r=Et(L)|0,r=t[(r?21792:21584)+(o*28|0)+(s<<2)>>2]|0,(r|0)<0&&OA(27795,27538,454,27678),!r)s=L,r=58;else{o=n,s=0,i=t[o>>2]|0,o=t[o+4>>2]|0;do i=qn(i,o)|0,o=S()|0,$=n,t[$>>2]=i,t[$+4>>2]=o,s=s+1|0;while((s|0)<(r|0));s=L,r=58}}else if((m|0)!=0&(a|0)!=0){if(r=Pt(e,A)|0,i=n,i=Pt(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=lr(o,l)|0,l=S()|0,$=n,t[$>>2]=o,t[$+4>>2]=l,r=r+1|0;while((r|0)<(i|0));r=58}}else r=58;while(!1);if((r|0)==58&&a&&(r=59),(r|0)==59&&($=n,(Pt(t[$>>2]|0,t[$+4>>2]|0)|0)==1)){s=9;break}$=n,nA=t[$>>2]|0,$=t[$+4>>2]&-1040385,q=CA(s|0,0,45)|0,$=$|(S()|0),s=n,t[s>>2]=nA|q,t[s+4>>2]=$,s=0}else s=1;while(!1);return $=s,b=G,$|0}function Fl(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=b,b=b+16|0,o=l,s?e=15:(e=_0(e,A,r,n,o)|0,e||($r(o,i),e=0)),b=l,e|0}function Pl(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=b,b=b+16|0,i=o,n?r=15:(r=Mt(r,i)|0,r||(r=ei(e,A,i,s)|0)),b=o,r|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,a=0;return a=b,b=b+32|0,o=a+12|0,l=a,i=_0(e,A,e,A,o)|0,i|0?(l=i,b=a,l|0):(e=_0(e,A,r,n,l)|0,e|0?(l=e,b=a,l|0):(o=Er(o,l)|0,l=s,t[l>>2]=o,t[l+4>>2]=((o|0)<0)<<31>>31,l=0,b=a,l|0))}function Ol(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,a=0;return a=b,b=b+32|0,o=a+12|0,l=a,i=_0(e,A,e,A,o)|0,!i&&(i=_0(e,A,r,n,l)|0,!i)?(n=Er(o,l)|0,n=KA(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,b=a,l|0):(l=i,b=a,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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0;if(QA=b,b=b+48|0,BA=QA+24|0,o=QA+12|0,zA=QA,i=_0(e,A,e,A,BA)|0,!i&&(i=_0(e,A,r,n,o)|0,!i)){$=Er(BA,o)|0,U=(($|0)<0)<<31>>31,t[BA>>2]=0,t[BA+4>>2]=0,t[BA+8>>2]=0,t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,_0(e,A,e,A,BA)|0&&OA(27795,27538,692,27747),_0(e,A,r,n,o)|0&&OA(27795,27538,697,27747),qr(BA),qr(o),m=($|0)==0?0:1/+($|0),r=t[BA>>2]|0,G=m*+((t[o>>2]|0)-r|0),Y=BA+4|0,n=t[Y>>2]|0,nA=m*+((t[o+4>>2]|0)-n|0),q=BA+8|0,i=t[q>>2]|0,m=m*+((t[o+8>>2]|0)-i|0),t[zA>>2]=r,M=zA+4|0,t[M>>2]=n,R=zA+8|0,t[R>>2]=i;A:do if(($|0)<0)i=0;else for(I=0,L=0;;){a=+(L>>>0)+4294967296*+(I|0),fe=G*a+ +(r|0),l=nA*a+ +(n|0),a=m*a+ +(i|0),r=~~+Sn(+fe),o=~~+Sn(+l),i=~~+Sn(+a),fe=+$A(+(+(r|0)-fe)),l=+$A(+(+(o|0)-l)),a=+$A(+(+(i|0)-a));do if(fe>l&fe>a)r=0-(o+i)|0,n=o;else if(f=0-r|0,l>a){n=f-i|0;break}else{n=o,i=f-o|0;break}while(!1);if(t[zA>>2]=r,t[M>>2]=n,t[R>>2]=i,Jr(zA),i=ei(e,A,zA,s+(L<<3)|0)|0,i|0)break A;if(!((I|0)<(U|0)|(I|0)==(U|0)&L>>>0<$>>>0)){i=0;break A}r=KA(L|0,I|0,1,0)|0,n=S()|0,I=n,L=r,r=t[BA>>2]|0,n=t[Y>>2]|0,i=t[q>>2]|0}while(!1);return zA=i,b=QA,zA|0}return zA=i,b=QA,zA|0}function G0(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,YA(s|0),i|0;i=e,s=A,e=1,A=0;do o=(r&1|0)==0&!0,e=ft((o?1:i)|0,(o?0:s)|0,e|0,A|0)|0,A=S()|0,r=hi(r|0,n|0,1)|0,n=S()|0,i=ft(i|0,s|0,i|0,s|0)|0,s=S()|0;while(!((r|0)==0&(n|0)==0));return YA(A|0),e|0}function ss(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,a=0,f=0,m=0;l=b,b=b+16|0,i=l,o=wA(e|0,A|0,52)|0,S()|0,o=o&15;do if(o){if(s=ar(e,A,i)|0,!s){f=+k[i>>3],a=1/+_e(+f),m=+k[25968+(o<<3)>>3],k[r>>3]=f+m,k[r+8>>3]=f-m,f=+k[i+8>>3],a=m*a,k[r+16>>3]=a+f,k[r+24>>3]=f-a;break}return o=s,b=l,o|0}else{if(s=wA(e|0,A|0,45)|0,S()|0,s=s&127,s>>>0>121)return o=5,b=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 VA(r,n?1.4:1.1),n=26096+(o<<3)|0,(t[n>>2]|0)==(e|0)&&(t[n+4>>2]|0)==(A|0)&&(k[r>>3]=1.5707963267948966),o=26224+(o<<3)|0,(t[o>>2]|0)==(e|0)&&(t[o+4>>2]|0)==(A|0)&&(k[r+8>>3]=-1.5707963267948966),+k[r>>3]!=1.5707963267948966&&+k[r+8>>3]!=-1.5707963267948966?(o=0,b=l,o|0):(k[r+16>>3]=3.141592653589793,k[r+24>>3]=-3.141592653589793,o=0,b=l,o|0)}function Hl(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,a=0,f=0,m=0;f=b,b=b+48|0,o=f+32|0,i=f+40|0,l=f,Dt(o,0,0,0),a=t[o>>2]|0,o=t[o+4>>2]|0;do if(r>>>0<=15){if(s=sn(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,a=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}if(s=Qt((t[A+8>>2]|0)+1|0,32)|0,s){is(A,s),m=l,t[m>>2]=a,t[m+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,a=l+29|0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+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,a=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}}else a=l,t[a>>2]=0,t[a+4>>2]=0,t[l+8>>2]=4,t[l+12>>2]=-1,a=l+16|0,m=l+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[m>>0]=xA[i>>0]|0,xA[m+1>>0]=xA[i+1>>0]|0,xA[m+2>>0]=xA[i+2>>0]|0;while(!1);kn(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],b=f}function kn(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0;if(U=b,b=b+336|0,I=U+168|0,L=U,n=e,r=t[n>>2]|0,n=t[n+4>>2]|0,(r|0)==0&(n|0)==0){b=U;return}if(A=e+28|0,xA[A>>0]|0?(r=ti(r,n)|0,n=S()|0):xA[A>>0]=1,$=e+20|0,!(t[t[$>>2]>>2]|0)){A=e+24|0,r=t[A>>2]|0,r|0&&qA(r),q=e,t[q>>2]=0,t[q+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[e+16>>2]=0,t[A>>2]=0,b=U;return}q=e+16|0,A=t[q>>2]|0,s=A&15;A:do if((r|0)==0&(n|0)==0)nA=e+24|0;else{G=e+12|0,M=(s|0)==3,m=A&255,a=(s|1|0)==3,R=e+24|0,f=(s+-1|0)>>>0<3,o=(s|2|0)==3,l=L+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(m&15){case 0:case 2:case 3:{if(s=ar(r,n,I)|0,s|0){Y=15;break e}if(os(t[$>>2]|0,t[R>>2]|0,I)|0){Y=19;break e}break}}if(a&&(s=t[(t[$>>2]|0)+4>>2]|0,t[I>>2]=t[s>>2],t[I+4>>2]=t[s+4>>2],t[I+8>>2]=t[s+8>>2],t[I+12>>2]=t[s+12>>2],c0(26832,I)|0)){if(Xn(t[(t[$>>2]|0)+4>>2]|0,i,L)|0){Y=25;break}if(s=L,(t[s>>2]|0)==(r|0)&&(t[s+4>>2]|0)==(n|0)){Y=29;break}}if(f){if(s=_r(r,n,I)|0,s|0){Y=32;break}if(ss(r,n,L,0)|0){Y=36;break}if(o&&ni(t[$>>2]|0,t[R>>2]|0,I,L)|0){Y=42;break}if(a&&si(t[$>>2]|0,t[R>>2]|0,I,L)|0){Y=42;break}}if(M){if(A=ss(r,n,I,1)|0,s=t[R>>2]|0,A|0){Y=45;break}if(Ne(s,I)|0){if(aA(L,I),H(I,t[R>>2]|0)|0){Y=53;break}if(os(t[$>>2]|0,t[R>>2]|0,l)|0){Y=53;break}if(si(t[$>>2]|0,t[R>>2]|0,L,I)|0){Y=53;break}}}}do if((i|0)<(t[G>>2]|0)){if(A=ss(r,n,I,1)|0,s=t[R>>2]|0,A|0){Y=58;break e}if(!(Ne(s,I)|0)){Y=73;break}if(H(t[R>>2]|0,I)|0&&(aA(L,I),ni(t[$>>2]|0,t[R>>2]|0,L,I)|0)){Y=65;break e}if(r=Ks(r,n,i+1|0,L)|0,r|0){Y=67;break e}n=L,r=t[n>>2]|0,n=t[n+4>>2]|0}else Y=73;while(!1);if((Y|0)==73&&(Y=0,r=ti(r,n)|0,n=S()|0),(r|0)==0&(n|0)==0){nA=R;break A}}switch(Y|0){case 15:{A=t[R>>2]|0,A|0&&qA(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[R>>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,b=U;return}case 32:{A=t[R>>2]|0,A|0&&qA(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[R>>2]=0,t[e+8>>2]=s,b=U;return}case 36:{OA(27795,27761,493,27772);break}case 42:{t[e>>2]=r,t[e+4>>2]=n,b=U;return}case 45:{s|0&&qA(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[R>>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&&qA(s),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[R>>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[R>>2]|0,A|0&&qA(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[R>>2]=0,t[e+8>>2]=r,b=U;return}}if((Y|0)==20){b=U;return}else if((Y|0)==55){b=U;return}else if((Y|0)==71){b=U;return}}while(!1);A=t[nA>>2]|0,A|0&&qA(A),Y=e,t[Y>>2]=0,t[Y+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[q>>2]=0,t[nA>>2]=0,b=U}function ti(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0;M=b,b=b+16|0,m=M,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=CA(n+4095|0,0,52)|0,s=S()|0|A&-15728641,i=(15-n|0)*3|0,o=CA(7,0,i|0)|0,l=S()|0,r=r|e|o,s=s|l,a=wA(e|0,A|0,i|0)|0,S()|0,a=a&7,n=n+-1|0,!(a>>>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 m=(a|0)==0&(Oe(r,s)|0)!=0,m=CA((m?2:1)+a|0,0,i|0)|0,f=S()|0|A&~l,m=m|e&~o,YA(f|0),b=M,m|0}while(!1);return r=r&127,r>>>0>120?(f=0,m=0,YA(f|0),b=M,m|0):(Dt(m,0,r+1|0,0),f=t[m+4>>2]|0,m=t[m>>2]|0,YA(f|0),b=M,m|0)}function Gl(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0;Y=b,b=b+160|0,M=Y+80|0,l=Y+64|0,R=Y+112|0,G=Y,Hl(M,e,A,r),f=M,ts(l,t[f>>2]|0,t[f+4>>2]|0,A),f=l,a=t[f>>2]|0,f=t[f+4>>2]|0,o=t[M+8>>2]|0,I=R+4|0,t[I>>2]=t[M>>2],t[I+4>>2]=t[M+4>>2],t[I+8>>2]=t[M+8>>2],t[I+12>>2]=t[M+12>>2],t[I+16>>2]=t[M+16>>2],t[I+20>>2]=t[M+20>>2],t[I+24>>2]=t[M+24>>2],t[I+28>>2]=t[M+28>>2],I=G,t[I>>2]=a,t[I+4>>2]=f,I=G+8|0,t[I>>2]=o,e=G+12|0,A=R,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(R=G+48|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],(a|0)==0&(f|0)==0)return G=o,b=Y,G|0;r=G+16|0,m=G+24|0,M=G+28|0,o=0,l=0,A=a,e=f;do{if(!((o|0)<(s|0)|(o|0)==(s|0)&l>>>0<n>>>0)){L=4;break}if(f=l,l=KA(l|0,o|0,1,0)|0,o=S()|0,f=i+(f<<3)|0,t[f>>2]=A,t[f+4>>2]=e,rs(R),e=R,A=t[e>>2]|0,e=t[e+4>>2]|0,(A|0)==0&(e|0)==0){if(kn(r),A=r,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0){L=10;break}$s(e,A,t[M>>2]|0,R),e=R,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(L|0)==4?(e=G+40|0,A=t[e>>2]|0,A|0&&qA(A),L=G+16|0,t[L>>2]=0,t[L+4>>2]=0,t[m>>2]=0,t[G+36>>2]=0,t[M>>2]=-1,t[G+32>>2]=0,t[e>>2]=0,$s(0,0,0,R),t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=0,G=14,b=Y,G|0):((L|0)==10&&(t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=t[m>>2]),G=t[I>>2]|0,b=Y,G|0)}function Ul(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,a=0,f=0,m=0,M=0,R=0,I=0;if(M=b,b=b+48|0,a=M+32|0,l=M+40|0,f=M,!(t[e>>2]|0))return m=n,t[m>>2]=0,t[m+4>>2]=0,m=0,b=M,m|0;Dt(a,0,0,0),o=a,s=t[o>>2]|0,o=t[o+4>>2]|0;do if(A>>>0>15)m=f,t[m>>2]=0,t[m+4>>2]=0,t[f+8>>2]=4,t[f+12>>2]=-1,m=f+16|0,r=f+29|0,t[m>>2]=0,t[m+4>>2]=0,t[m+8>>2]=0,xA[m+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,m=9;else{if(r=sn(r)|0,r|0){a=f,t[a>>2]=0,t[a+4>>2]=0,t[f+8>>2]=r,t[f+12>>2]=-1,a=f+16|0,m=f+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[m>>0]=xA[l>>0]|0,xA[m+1>>0]=xA[l+1>>0]|0,xA[m+2>>0]=xA[l+2>>0]|0,m=9;break}if(r=Qt((t[e+8>>2]|0)+1|0,32)|0,!r){m=f,t[m>>2]=0,t[m+4>>2]=0,t[f+8>>2]=13,t[f+12>>2]=-1,m=f+16|0,r=f+29|0,t[m>>2]=0,t[m+4>>2]=0,t[m+8>>2]=0,xA[m+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,m=9;break}is(e,r),I=f,t[I>>2]=s,t[I+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,R=+ir(r),R=R*+Yr(r),i=+$A(+ +k[r>>3]),i=R/+_e(+ +En(+i,+ +$A(+ +k[r+8>>3])))*6371.007180918475*6371.007180918475,s=f+12|0,r=t[s>>2]|0;A:do if((r|0)>0)do{if(qs(r+-1|0,a)|0,!(i/+k[a>>3]>10))break A;I=t[s>>2]|0,r=I+-1|0,t[s>>2]=r}while((I|0)>1);while(!1);if(kn(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 p0(r,s,A,a)|0,l=a,e=n,l=KA(t[e>>2]|0,t[e+4>>2]|0,t[l>>2]|0,t[l+4>>2]|0)|0,e=S()|0,I=n,t[I>>2]=l,t[I+4>>2]=e,kn(f),I=f,r=t[I>>2]|0,s=t[I+4>>2]|0;while(!((r|0)==0&(s|0)==0));r=t[o>>2]|0}while(!1);return I=r,b=M,I|0}function nn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0;if(!(c0(A,r)|0)||(A=Ft(A)|0,n=+k[r>>3],s=+k[r+8>>3],s=A&s<0?s+6.283185307179586:s,R=t[e>>2]|0,(R|0)<=0))return R=0,R|0;if(M=t[e+4>>2]|0,A){A=0,m=s,r=-1,e=0;A:for(;;){for(f=e;o=+k[M+(f<<4)>>3],s=+k[M+(f<<4)+8>>3],e=(r+2|0)%(R|0)|0,i=+k[M+(e<<4)>>3],l=+k[M+(e<<4)+8>>3],o>i?(a=o,o=l):(a=i,i=o,o=s,s=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(n<i|n>a);)if(r=f+1|0,(r|0)>=(R|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,m=l==m|o==m?m+-2220446049250313e-31:m,a=l+(o-l)*((n-i)/(a-i)),(a<0?a+6.283185307179586:a)>m&&(A=A^1),e=f+1|0,(e|0)>=(R|0)){r=22;break}else r=f}if((r|0)==22)return A|0}else{A=0,m=s,r=-1,e=0;A:for(;;){for(f=e;o=+k[M+(f<<4)>>3],s=+k[M+(f<<4)+8>>3],e=(r+2|0)%(R|0)|0,i=+k[M+(e<<4)>>3],l=+k[M+(e<<4)+8>>3],o>i?(a=o,o=l):(a=i,i=o,o=s,s=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(n<i|n>a);)if(r=f+1|0,(r|0)>=(R|0)){r=22;break A}else e=f,f=r,r=e;if(m=o==m|s==m?m+-2220446049250313e-31:m,o+(s-o)*((n-i)/(a-i))>m&&(A=A^1),e=f+1|0,(e|0)>=(R|0)){r=22;break}else r=f}if((r|0)==22)return A|0}return 0}function ri(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0;if(L=t[e>>2]|0,!L){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,k[G>>3]=17976931348623157e292,Y=A+24|0,k[Y>>3]=17976931348623157e292,k[A>>3]=-17976931348623157e292,nA=A+16|0,k[nA>>3]=-17976931348623157e292,!((L|0)<=0)){for(R=t[e+4>>2]|0,f=17976931348623157e292,m=-17976931348623157e292,M=0,e=-1,i=17976931348623157e292,o=17976931348623157e292,a=-17976931348623157e292,n=-17976931348623157e292,I=0;r=+k[R+(I<<4)>>3],l=+k[R+(I<<4)+8>>3],e=e+2|0,s=+k[R+(((e|0)==(L|0)?0:e)<<4)+8>>3],r<i&&(k[G>>3]=r,i=r),l<o&&(k[Y>>3]=l,o=l),r>a?k[A>>3]=r:r=a,l>n&&(k[nA>>3]=l,n=l),f=l>0&l<f?l:f,m=l<0&l>m?l:m,M=M|+$A(+(l-s))>3.141592653589793,e=I+1|0,(e|0)!=(L|0);)q=I,a=r,I=e,e=q;M&&(k[nA>>3]=m,k[Y>>3]=f)}}function sn(e){return e=e|0,(e>>>0<4?0:15)|0}function is(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0;if(L=t[e>>2]|0,L){if(G=A+8|0,k[G>>3]=17976931348623157e292,Y=A+24|0,k[Y>>3]=17976931348623157e292,k[A>>3]=-17976931348623157e292,nA=A+16|0,k[nA>>3]=-17976931348623157e292,(L|0)>0){for(s=t[e+4>>2]|0,R=17976931348623157e292,I=-17976931348623157e292,n=0,r=-1,a=17976931348623157e292,f=17976931348623157e292,M=-17976931348623157e292,o=-17976931348623157e292,q=0;i=+k[s+(q<<4)>>3],m=+k[s+(q<<4)+8>>3],zA=r+2|0,l=+k[s+(((zA|0)==(L|0)?0:zA)<<4)+8>>3],i<a&&(k[G>>3]=i,a=i),m<f&&(k[Y>>3]=m,f=m),i>M?k[A>>3]=i:i=M,m>o&&(k[nA>>3]=m,o=m),R=m>0&m<R?m:R,I=m<0&m>I?m:I,n=n|+$A(+(m-l))>3.141592653589793,r=q+1|0,(r|0)!=(L|0);)zA=q,M=i,q=r,r=zA;n&&(k[nA>>3]=I,k[Y>>3]=R)}}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(zA=e+8|0,r=t[zA>>2]|0,!((r|0)<=0)){BA=e+12|0,U=0;do if(s=t[BA>>2]|0,n=U,U=U+1|0,Y=A+(U<<5)|0,nA=t[s+(n<<3)>>2]|0,nA){if(q=A+(U<<5)+8|0,k[q>>3]=17976931348623157e292,e=A+(U<<5)+24|0,k[e>>3]=17976931348623157e292,k[Y>>3]=-17976931348623157e292,$=A+(U<<5)+16|0,k[$>>3]=-17976931348623157e292,(nA|0)>0){for(L=t[s+(n<<3)+4>>2]|0,R=17976931348623157e292,I=-17976931348623157e292,s=0,n=-1,G=0,a=17976931348623157e292,f=17976931348623157e292,m=-17976931348623157e292,o=-17976931348623157e292;i=+k[L+(G<<4)>>3],M=+k[L+(G<<4)+8>>3],n=n+2|0,l=+k[L+(((n|0)==(nA|0)?0:n)<<4)+8>>3],i<a&&(k[q>>3]=i,a=i),M<f&&(k[e>>3]=M,f=M),i>m?k[Y>>3]=i:i=m,M>o&&(k[$>>3]=M,o=M),R=M>0&M<R?M:R,I=M<0&M>I?M:I,s=s|+$A(+(M-l))>3.141592653589793,n=G+1|0,(n|0)!=(nA|0);)QA=G,G=n,m=i,n=QA;s&&(k[$>>3]=I,k[e>>3]=R)}}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[zA>>2]|0;while((U|0)<(r|0))}}function os(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(!(nn(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,nn((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 ni(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,a=0,f=0,m=0;if(f=b,b=b+16|0,l=f,o=r+8|0,!(nn(e,A,o)|0))return a=0,b=f,a|0;a=e+8|0;A:do if((t[a>>2]|0)>0){for(i=e+12|0,s=0;;){if(m=s,s=s+1|0,nn((t[i>>2]|0)+(m<<3)|0,A+(s<<5)|0,o)|0){s=0;break}if((s|0)>=(t[a>>2]|0))break A}return b=f,s|0}while(!1);if(Cn(e,A,r,n)|0)return m=0,b=f,m|0;t[l>>2]=t[r>>2],t[l+4>>2]=o,s=t[a>>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(nn(l,n,t[s+(o<<3)+4>>2]|0)|0){s=0;break A}if(s=o+1|0,Cn((t[e>>2]|0)+(o<<3)|0,A+(s<<5)|0,r,n)|0){s=0;break A}i=t[a>>2]|0}else s=o+1|0;if((s|0)<(i|0))o=s;else{s=1;break}}else s=1;while(!1);return m=s,b=f,m|0}function Cn(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0;if(zA=b,b=b+176|0,q=zA+172|0,s=zA+168|0,$=zA,!(Ne(A,n)|0))return e=0,b=zA,e|0;if(B0(A,n,q,s),Ir($|0,r|0,168)|0,(t[r>>2]|0)>0){A=0;do QA=$+8+(A<<4)+8|0,nA=+Vt(+k[QA>>3],t[s>>2]|0),k[QA>>3]=nA,A=A+1|0;while((A|0)<(t[r>>2]|0))}G=+k[n>>3],Y=+k[n+8>>3],nA=+Vt(+k[n+16>>3],t[s>>2]|0),I=+Vt(+k[n+24>>3],t[s>>2]|0);A:do if((t[e>>2]|0)>0){if(n=e+4|0,s=t[$>>2]|0,(s|0)<=0){for(A=0;;)if(A=A+1|0,(A|0)>=(t[e>>2]|0)){A=0;break A}}for(r=0;;){if(A=t[n>>2]|0,R=+k[A+(r<<4)>>3],L=+Vt(+k[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=+k[A+(QA<<4)>>3],o=+Vt(+k[A+(QA<<4)+8>>3],t[q>>2]|0),!(R>=G)|!(i>=G)&&!(R<=Y)|!(i<=Y)&&!(L<=I)|!(o<=I)&&!(L>=nA)|!(o>=nA)){M=i-R,f=o-L,A=0;do if(fe=A,A=A+1|0,QA=(A|0)==(s|0)?0:A,i=+k[$+8+(fe<<4)+8>>3],o=+k[$+8+(QA<<4)+8>>3]-i,l=+k[$+8+(fe<<4)>>3],a=+k[$+8+(QA<<4)>>3]-l,m=M*o-f*a,m!=0&&(U=L-i,BA=R-l,a=(U*a-o*BA)/m,!(a<0|a>1))&&(m=(M*U-f*BA)/m,m>=0&m<=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 fe=A,b=zA,fe|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;if(Cn(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,Cn((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 Vl(){return 8}function Wl(){return 16}function Yl(){return 168}function Kl(){return 8}function Zl(){return 16}function $l(){return 12}function ql(){return 8}function Jl(e){return e=e|0,+(+((t[e>>2]|0)>>>0)+4294967296*+(t[e+4>>2]|0))}function Xl(e){e=e|0;var A=0,r=0;return r=+k[e>>3],A=+k[e+8>>3],+ +ye(+(r*r+A*A))}function ii(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,a=0,f=0,m=0,M=0,R=0;f=+k[e>>3],a=+k[A>>3]-f,l=+k[e+8>>3],o=+k[A+8>>3]-l,M=+k[r>>3],i=+k[n>>3]-M,R=+k[r+8>>3],m=+k[n+8>>3]-R,i=(i*(l-R)-(f-M)*m)/(a*m-o*i),k[s>>3]=f+a*i,k[s+8>>3]=l+o*i}function oi(e,A){return e=e|0,A=A|0,+$A(+(+k[e>>3]-+k[A>>3]))<11920928955078125e-23?(A=+$A(+(+k[e+8>>3]-+k[A+8>>3]))<11920928955078125e-23,A|0):(A=0,A|0)}function it(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;return s=+k[e>>3]-+k[A>>3],n=+k[e+8>>3]-+k[A+8>>3],r=+k[e+16>>3]-+k[A+16>>3],+(s*s+n*n+r*r)}function Aa(e,A){e=e|0,A=A|0;var r=0,n=0,s=0;r=+k[e>>3],n=+_e(+r),r=+ie(+r),k[A+16>>3]=r,r=+k[e+8>>3],s=n*+_e(+r),k[A>>3]=s,r=n*+ie(+r),k[A+8>>3]=r}function ea(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if(i=b,b=b+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,b=i,s|0;do if(on(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,b=i,s|0}function on(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0;if(m=b,b=b+32|0,l=m+16|0,a=m,n=Dr(e,A,l)|0,n|0)return r=n,b=m,r|0;i=te(e,A)|0,f=Pt(e,A)|0,z0(i,a),n=qt(i,t[l>>2]|0)|0;do if(je(i)|0){do switch(i|0){case 4:{s=0;break}case 14:{s=1;break}case 24:{s=2;break}case 38:{s=3;break}case 49:{s=4;break}case 58:{s=5;break}case 63:{s=6;break}case 72:{s=7;break}case 83:{s=8;break}case 97:{s=9;break}case 107:{s=10;break}case 117:{s=11;break}default: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[a>>2]|0)&&(a=Et(i)|0,e=t[l>>2]|0,a|(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,b=m,r|0}function Xt(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0;if($=b,b=b+32|0,q=$+24|0,Y=$+20|0,L=$+8|0,I=$+16|0,R=$,a=(Oe(e,A)|0)==0,a=a?6:5,m=wA(e|0,A|0,52)|0,S()|0,m=m&15,a>>>0<=r>>>0)return n=2,b=$,n|0;M=(m|0)==0,!M&&(G=CA(7,0,(m^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)||on(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,b=$,n|0;t[Y>>2]=0,s=K(e,A,G,Y,L)|0;do if(!s){if(l=L,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,!M&&(M=CA(7,0,(m^15)*3|0)|0,(f&M|0)==0&(l&(S()|0)|0)==0))s=r;else{if(l=(r+-1+a|0)%(a|0)|0,s=Oe(e,A)|0,(l|0)<0&&OA(27795,27797,248,27822),a=(s|0)!=0,((a?4:5)|0)<(l|0)&&OA(27795,27797,248,27822),on(e,A,q)|0&&OA(27795,27797,248,27822),s=(t[q>>2]|0)+l|0,a?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[I>>2]=0,s=K(e,A,l,I,R)|0,s|0)break;f=R,a=t[f>>2]|0,f=t[f+4>>2]|0;do if(f>>>0<o>>>0|(f|0)==(o|0)&a>>>0<i>>>0){if(Oe(a,f)|0?i=Ae(a,f,e,A)|0:i=t[26800+((((t[I>>2]|0)+(t[26768+(l<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,s=Oe(a,f)|0,(i+-1|0)>>>0>5){s=-1,i=a,o=f;break}if(s=(s|0)!=0,(i|0)==1&s){s=-1,i=a,o=f;break}do if(on(a,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=a,o=f}else s=r;while(!1);l=L,f=t[l>>2]|0,l=t[l+4>>2]|0}if((i|0)==(f|0)&(o|0)==(l|0)){if(a=(Oe(f,l)|0)!=0,a?e=Ae(f,l,e,A)|0:e=t[26800+((((t[Y>>2]|0)+(t[26768+(G<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,s=Oe(f,l)|0,(e+-1|0)>>>0<=5&&(nA=(s|0)!=0,!((e|0)==1&nA)))do if(on(f,l,q)|0)s=-1;else if(nA){s=((t[26352+(e<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{s=((t[26384+(e<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);else s=-1;s=s+1|0,s=(s|0)==6|a&(s|0)==5?0:s}A=o,e=i;break A}while(!1);return n=s,b=$,n|0}while(!1);return nA=CA(s|0,0,56)|0,q=S()|0|A&-2130706433|536870912,t[n>>2]=nA|e,t[n+4>>2]=q,n=0,b=$,n|0}function ta(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=Xt(e,A,0,r)|0,s=(n|0)==0,i?!s||(n=Xt(e,A,1,r+8|0)|0,n|0)||(n=Xt(e,A,2,r+16|0)|0,n|0)||(n=Xt(e,A,3,r+24|0)|0,n|0)||(n=Xt(e,A,4,r+32|0)|0,n)?(i=n,i|0):Xt(e,A,5,r+40|0)|0:!s||(n=Xt(e,A,1,r+8|0)|0,n|0)||(n=Xt(e,A,2,r+16|0)|0,n|0)||(n=Xt(e,A,3,r+24|0)|0,n|0)||(n=Xt(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 ra(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0,l=0,a=0;return a=b,b=b+192|0,s=a,i=a+168|0,o=wA(e|0,A|0,56)|0,S()|0,o=o&7,l=A&-2130706433|134217728,n=Dr(e,l,i)|0,n|0?(l=n,b=a,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):AA(i,A,o,1,s),l=s+8|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],l=0,b=a,l|0)}function li(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;return s=b,b=b+16|0,r=s,!(!0&(A&2013265920|0)==536870912)||(n=A&-2130706433|134217728,!(Ue(e,n)|0))?(n=0,b=s,n|0):(i=wA(e|0,A|0,56)|0,S()|0,i=(Xt(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,b=s,n|0)}function ai(e,A,r){e=e|0,A=A|0,r=r|0;var n=0;(A|0)>0?(n=Qt(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 ui(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+(~~(+$A(+(+lt(10,+ +(15-(t[i>>2]|0)|0))*(+k[l>>3]+ +k[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]}qA(l),t[o>>2]=(t[o>>2]|0)+-1}while(!1)}qA(t[e>>2]|0)}function ci(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 fi(e,A){e=e|0,A=A|0;var r=0,n=0,s=0,i=0;if(r=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[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 qA(A),i=e+8|0,t[i>>2]=(t[i>>2]|0)+-1,i=0,i|0}function na(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0,o=0;i=y0(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=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[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(;!(Tr(n,A)|0&&Tr(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 qA(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 sa(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0;if(s=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[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(Tr(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(Tr(e,A)|0&&Tr(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 ia(e,A){e=e|0,A=A|0;var r=0;if(r=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+k[A>>3]+ +k[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(Tr(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 oa(){return 27920}function U0(e){return e=+e,~~+gi(+e)|0}function y0(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,a=0,f=0,m=0,M=0,R=0,I=0,L=0,G=0,Y=0,nA=0,q=0,$=0,U=0,BA=0;BA=b,b=b+16|0,R=BA;do if(e>>>0<245){if(f=e>>>0<11?16:e+11&-8,e=f>>>3,M=t[6981]|0,r=M>>>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]=M&~(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,b=BA,U|0;if(m=t[6983]|0,f>>>0>m>>>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=M&~(1<<n),t[6981]=e):(t[r+12>>2]=A,t[e>>2]=r,e=M),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,m|0&&(n=t[6986]|0,A=m>>>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,b=BA,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,a=r>>>1&1,a=t[28228+((n|s|o|l|a)+(r>>>a)<<2)>>2]|0,r=a,l=a,a=(t[a+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<a>>>0,r=e,l=s?e:l,a=s?o:a;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 a>>>0<16?(U=a+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]=a|1,t[o+a>>2]=a,m|0&&(n=t[6986]|0,A=m>>>3,r=27964+(A<<1<<2)|0,A=1<<A,A&M?(e=r+8|0,A=t[e>>2]|0):(t[6981]=A|M,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]=a,t[6986]=o),U=l+8|0,b=BA,U|0}else M=f}else M=f}else M=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?a=31:(M=(e+1048320|0)>>>16&8,G=e<<M,l=(G+520192|0)>>>16&4,G=G<<l,a=(G+245760|0)>>>16&2,a=14-(l|M|a)+(G<<a>>>15)|0,a=f>>>(a+7|0)&1|a<<1):a=0,r=t[28228+(a<<2)>>2]|0;A:do if(!r)r=0,e=0,G=61;else for(e=0,l=f<<((a|0)==31?0:25-(a>>>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<<a,e=(e|0-e)&n,!e){M=f;break}M=(e&0-e)+-1|0,o=M>>>12&16,M=M>>>o,i=M>>>5&8,M=M>>>i,l=M>>>2&4,M=M>>>l,a=M>>>1&2,M=M>>>a,r=M>>>1&1,e=0,r=t[28228+((i|o|l|a|r)+(M>>>r)<<2)>>2]|0}r?G=65:(l=e,o=s)}if((G|0)==65)for(i=r;;)if(M=(t[i+4>>2]&-8)-f|0,r=M>>>0<s>>>0,s=r?M: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&&(m=l+f|0,m>>>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[m+4>>2]=o|1,t[m+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]=m,t[A+12>>2]=m,t[m+8>>2]=A,t[m+12>>2]=r;break}if(A=o>>>8,A?o>>>0>16777215?r=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<<q,r=(U+245760|0)>>>16&2,r=14-(q|$|r)+(U<<r>>>15)|0,r=o>>>(r+7|0)&1|r<<1):r=0,A=28228+(r<<2)|0,t[m+28>>2]=r,e=m+16|0,t[e+4>>2]=0,t[e>>2]=0,e=1<<r,!(n&e)){t[6982]=n|e,t[A>>2]=m,t[m+24>>2]=A,t[m+12>>2]=m,t[m+8>>2]=m;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]=m,t[m+24>>2]=A,t[m+12>>2]=m,t[m+8>>2]=m;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=m,t[$>>2]=m,t[m+8>>2]=U,t[m+12>>2]=A,t[m+24>>2]=0}while(!1);return U=l+8|0,b=BA,U|0}else M=f}else M=f;else M=-1;while(!1);if(r=t[6983]|0,r>>>0>=M>>>0)return A=r-M|0,e=t[6986]|0,A>>>0>15?(U=e+M|0,t[6986]=U,t[6983]=A,t[U+4>>2]=A|1,t[e+r>>2]=A,t[e+4>>2]=M|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,b=BA,U|0;if(o=t[6984]|0,o>>>0>M>>>0)return q=o-M|0,t[6984]=q,U=t[6987]|0,$=U+M|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=M|3,U=U+8|0,b=BA,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]=R&-16^1431655768,e=4096),l=M+48|0,a=M+47|0,i=e+a|0,s=0-e|0,f=i&s,f>>>0<=M>>>0||(e=t[7091]|0,e|0&&(m=t[7089]|0,R=m+f|0,R>>>0<=m>>>0|R>>>0>e>>>0)))return U=0,b=BA,U|0;A:do if(t[7092]&4)A=0,G=143;else{r=t[6987]|0;e:do if(r){for(n=28372;R=t[n>>2]|0,!(R>>>0<=r>>>0&&(R+(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=Y0(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=Y0(0)|0,(r|0)!=-1&&(A=r,I=t[7100]|0,L=I+-1|0,A=((L&A|0)==0?0:(L+A&0-I)-A|0)+f|0,I=t[7089]|0,L=A+I|0,A>>>0>M>>>0&A>>>0<2147483647)){if(R=t[7091]|0,R|0&&L>>>0<=I>>>0|L>>>0>R>>>0){A=0;break}if(e=Y0(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=a-A+e&0-e,e>>>0>=2147483647){o=A,i=n,G=145;break A}if((Y0(e|0)|0)==-1){Y0(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=Y0(f|0)|0,L=Y0(0)|0,Y=L-q|0,nA=Y>>>0>(M+40|0)>>>0,!((q|0)==-1|nA^1|q>>>0<L>>>0&((q|0)!=-1&(L|0)!=-1)^1))&&(o=nA?Y:A,i=q,G=145),(G|0)==145){A=(t[7089]|0)+o|0,t[7089]=A,A>>>0>(t[7090]|0)>>>0&&(t[7090]=A),a=t[6987]|0;A:do if(a){for(A=28372;;){if(e=t[A>>2]|0,r=t[A+4>>2]|0,(i|0)==(e+r|0)){G=154;break}if(n=t[A+8>>2]|0,n)A=n;else break}if((G|0)==154&&($=A+4|0,(t[A+12>>2]&8|0)==0)&&i>>>0>a>>>0&e>>>0<=a>>>0){t[$>>2]=r+o,U=(t[6984]|0)+o|0,q=a+8|0,q=(q&7|0)==0?0:0-q&7,$=a+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[a+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,m=A+4|0,t[m>>2]=(t[m>>2]|0)+o,m=i+8|0,m=i+((m&7|0)==0?0:0-m&7)|0,A=r+8|0,A=r+((A&7|0)==0?0:0-A&7)|0,f=m+M|0,l=A-m-M|0,t[m+4>>2]=M|3;e:do if((a|0)==(A|0))U=(t[6984]|0)+l|0,t[6984]=U,t[6987]=f,t[f+4>>2]=U|1;else{if((t[6986]|0)==(A|0)){U=(t[6983]|0)+l|0,t[6983]=U,t[6986]=f,t[f+4>>2]=U|1,t[f+U>>2]=U;break}if(e=t[A+4>>2]|0,(e&3|0)==1){o=e&-8,n=e>>>3;t:do if(e>>>0<256)if(e=t[A+8>>2]|0,r=t[A+12>>2]|0,(r|0)==(e|0)){t[6981]=t[6981]&~(1<<n);break}else{t[e+12>>2]=r,t[r+8>>2]=e;break}else{i=t[A+24>>2]|0,e=t[A+12>>2]|0;do if((e|0)==(A|0)){if(r=A+16|0,n=r+4|0,e=t[n>>2]|0,e)r=n;else if(e=t[r>>2]|0,!e){e=0;break}for(;;)if(s=e+20|0,n=t[s>>2]|0,n)e=n,r=s;else if(s=e+16|0,n=t[s>>2]|0,n)e=n,r=s;else break;t[r>>2]=0}else U=t[A+8>>2]|0,t[U+12>>2]=e,t[e+8>>2]=U;while(!1);if(!i)break;r=t[A+28>>2]|0,n=28228+(r<<2)|0;do if((t[n>>2]|0)!=(A|0)){if(U=i+16|0,t[((t[U>>2]|0)==(A|0)?U:i+20|0)>>2]=e,!e)break t}else{if(t[n>>2]=e,e|0)break;t[6982]=t[6982]&~(1<<r);break t}while(!1);if(t[e+24>>2]=i,r=A+16|0,n=t[r>>2]|0,n|0&&(t[e+16>>2]=n,t[n+24>>2]=e),r=t[r+4>>2]|0,!r)break;t[e+20>>2]=r,t[r+24>>2]=e}while(!1);A=A+o|0,s=o+l|0}else s=l;if(A=A+4|0,t[A>>2]=t[A>>2]&-2,t[f+4>>2]=s|1,t[f+s>>2]=s,A=s>>>3,s>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<<A,e&A?(e=r+8|0,A=t[e>>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=f,t[A+12>>2]=f,t[f+8>>2]=A,t[f+12>>2]=r;break}A=s>>>8;do if(!A)n=0;else{if(s>>>0>16777215){n=31;break}$=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<<q,n=(U+245760|0)>>>16&2,n=14-(q|$|n)+(U<<n>>>15)|0,n=s>>>(n+7|0)&1|n<<1}while(!1);if(A=28228+(n<<2)|0,t[f+28>>2]=n,e=f+16|0,t[e+4>>2]=0,t[e>>2]=0,e=t[6982]|0,r=1<<n,!(e&r)){t[6982]=e|r,t[A>>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break}A=t[A>>2]|0;t:do if((t[A+4>>2]&-8|0)!=(s|0)){for(n=s<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(s|0)){A=e;break t}else n=n<<1,A=e;t[r>>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break e}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=f,t[$>>2]=f,t[f+8>>2]=U,t[f+12>>2]=A,t[f+24>>2]=0}while(!1);return U=m+8|0,b=BA,U|0}for(A=28372;e=t[A>>2]|0,!(e>>>0<=a>>>0&&(U=e+(t[A+4>>2]|0)|0,U>>>0>a>>>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=a+16|0,e=e>>>0<s>>>0?a:e,A=e+8|0,r=o+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=r-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+r+4>>2]=40,t[6988]=t[7103],r=e+4|0,t[r>>2]=27,t[A>>2]=t[7093],t[A+4>>2]=t[7094],t[A+8>>2]=t[7095],t[A+12>>2]=t[7096],t[7093]=i,t[7094]=o,t[7096]=0,t[7095]=A,A=e+24|0;do $=A,A=A+4|0,t[A>>2]=7;while(($+8|0)>>>0<U>>>0);if((e|0)!=(a|0)){if(i=e-a|0,t[r>>2]=t[r>>2]&-2,t[a+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]=a,t[A+12>>2]=a,t[a+8>>2]=A,t[a+12>>2]=r;break}if(A=i>>>8,A?i>>>0>16777215?n=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<<q,n=(U+245760|0)>>>16&2,n=14-(q|$|n)+(U<<n>>>15)|0,n=i>>>(n+7|0)&1|n<<1):n=0,r=28228+(n<<2)|0,t[a+28>>2]=n,t[a+20>>2]=0,t[s>>2]=0,A=t[6982]|0,e=1<<n,!(A&e)){t[6982]=A|e,t[r>>2]=a,t[a+24>>2]=r,t[a+12>>2]=a,t[a+8>>2]=a;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]=a,t[a+24>>2]=A,t[a+12>>2]=a,t[a+8>>2]=a;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=a,t[$>>2]=a,t[a+8>>2]=U,t[a+12>>2]=A,t[a+24>>2]=0}}else U=t[6985]|0,(U|0)==0|i>>>0<U>>>0&&(t[6985]=i),t[7093]=i,t[7094]=o,t[7096]=0,t[6990]=t[7099],t[6989]=-1,t[6994]=27964,t[6993]=27964,t[6996]=27972,t[6995]=27972,t[6998]=27980,t[6997]=27980,t[7e3]=27988,t[6999]=27988,t[7002]=27996,t[7001]=27996,t[7004]=28004,t[7003]=28004,t[7006]=28012,t[7005]=28012,t[7008]=28020,t[7007]=28020,t[7010]=28028,t[7009]=28028,t[7012]=28036,t[7011]=28036,t[7014]=28044,t[7013]=28044,t[7016]=28052,t[7015]=28052,t[7018]=28060,t[7017]=28060,t[7020]=28068,t[7019]=28068,t[7022]=28076,t[7021]=28076,t[7024]=28084,t[7023]=28084,t[7026]=28092,t[7025]=28092,t[7028]=28100,t[7027]=28100,t[7030]=28108,t[7029]=28108,t[7032]=28116,t[7031]=28116,t[7034]=28124,t[7033]=28124,t[7036]=28132,t[7035]=28132,t[7038]=28140,t[7037]=28140,t[7040]=28148,t[7039]=28148,t[7042]=28156,t[7041]=28156,t[7044]=28164,t[7043]=28164,t[7046]=28172,t[7045]=28172,t[7048]=28180,t[7047]=28180,t[7050]=28188,t[7049]=28188,t[7052]=28196,t[7051]=28196,t[7054]=28204,t[7053]=28204,t[7056]=28212,t[7055]=28212,U=o+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+U+4>>2]=40,t[6988]=t[7103];while(!1);if(A=t[6984]|0,A>>>0>M>>>0)return q=A-M|0,t[6984]=q,U=t[6987]|0,$=U+M|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=M|3,U=U+8|0,b=BA,U|0}return U=oa()|0,t[U>>2]=12,U=0,b=BA,U|0}function qA(e){e=e|0;var A=0,r=0,n=0,s=0,i=0,o=0,l=0,a=0;if(e){r=e+-8|0,s=t[6985]|0,e=t[e+-4>>2]|0,A=e&-8,a=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=a+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>=a>>>0)&&(e=a+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)==(a|0)){if(a=(t[6984]|0)+A|0,t[6984]=a,t[6987]=l,t[l+4>>2]=a|1,(l|0)!=(t[6986]|0))return;t[6986]=0,t[6983]=0;return}if((t[6986]|0)==(a|0)){a=(t[6983]|0)+A|0,t[6983]=a,t[6986]=o,t[l+4>>2]=a|1,t[o+a>>2]=a;return}s=(n&-8)+A|0,r=n>>>3;do if(n>>>0<256)if(A=t[a+8>>2]|0,e=t[a+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[a+24>>2]|0,e=t[a+12>>2]|0;do if((e|0)==(a|0)){if(A=a+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[a+8>>2]|0,t[r+12>>2]=e,t[e+8>>2]=r,r=e;while(!1);if(i|0){if(e=t[a+28>>2]|0,A=28228+(e<<2)|0,(t[A>>2]|0)==(a|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)==(a|0)?n:i+20|0)>>2]=r,!r)break;t[r+24>>2]=i,e=a+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,a=e<<o,i=(a+520192|0)>>>16&4,a=a<<i,n=(a+245760|0)>>>16&2,n=14-(i|o|n)+(a<<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,a=t[o>>2]|0,t[a+12>>2]=l,t[o>>2]=l,t[l+8>>2]=a,t[l+12>>2]=e,t[l+24>>2]=0}while(!1);if(a=(t[6989]|0)+-1|0,t[6989]=a,!(a|0)){for(e=28380;e=t[e>>2]|0,e;)e=e+8|0;t[6989]=-1}}}}function Qt(e,A){e=e|0,A=A|0;var r=0;return e?(r=Pe(A,e)|0,(A|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0|0)==(A|0)?r:-1)):r=0,e=y0(r)|0,!e||!(t[e+-4>>2]&3)||W0(e|0,0,r|0)|0,e|0}function KA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,r=e+r>>>0,YA(A+n+(r>>>0<e>>>0|0)>>>0|0),r|0|0}function ct(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,YA(n|0),e-r>>>0|0|0}function di(e){return e=e|0,(e?31-(nt(e^e-1)|0)|0:32)|0}function ls(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,a=0,f=0,m=0,M=0,R=0,I=0,L=0;if(m=e,a=A,f=a,o=r,R=n,l=R,!f)return i=(s|0)!=0,l?i?(t[s>>2]=e|0,t[s+4>>2]=A&0,R=0,s=0,YA(R|0),s|0):(R=0,s=0,YA(R|0),s|0):(i&&(t[s>>2]=(m>>>0)%(o>>>0),t[s+4>>2]=0),R=0,s=(m>>>0)/(o>>>0)>>>0,YA(R|0),s|0);i=(l|0)==0;do if(o){if(!i){if(i=(nt(l|0)|0)-(nt(f|0)|0)|0,i>>>0<=31){M=i+1|0,l=31-i|0,A=i-31>>31,o=M,e=m>>>(M>>>0)&A|f<<l,A=f>>>(M>>>0)&A,i=0,l=m<<l;break}return s?(t[s>>2]=e|0,t[s+4>>2]=a|A&0,R=0,s=0,YA(R|0),s|0):(R=0,s=0,YA(R|0),s|0)}if(i=o-1|0,i&o|0){l=(nt(o|0)|0)+33-(nt(f|0)|0)|0,L=64-l|0,M=32-l|0,a=M>>31,I=l-32|0,A=I>>31,o=l,e=M-1>>31&f>>>(I>>>0)|(f<<M|m>>>(l>>>0))&A,A=A&f>>>(l>>>0),i=m<<L&a,l=(f<<L|m>>>(I>>>0))&a|m<<M&l-33>>31;break}return s|0&&(t[s>>2]=i&m,t[s+4>>2]=0),(o|0)==1?(I=a|A&0,L=e|0|0,YA(I|0),L|0):(L=di(o|0)|0,I=f>>>(L>>>0)|0,L=f<<32-L|m>>>(L>>>0)|0,YA(I|0),L|0)}else{if(i)return s|0&&(t[s>>2]=(f>>>0)%(o>>>0),t[s+4>>2]=0),I=0,L=(f>>>0)/(o>>>0)>>>0,YA(I|0),L|0;if(!m)return s|0&&(t[s>>2]=0,t[s+4>>2]=(f>>>0)%(l>>>0)),I=0,L=(f>>>0)/(l>>>0)>>>0,YA(I|0),L|0;if(i=l-1|0,!(i&l))return s|0&&(t[s>>2]=e|0,t[s+4>>2]=i&f|A&0),I=0,L=f>>>((di(l|0)|0)>>>0),YA(I|0),L|0;if(i=(nt(l|0)|0)-(nt(f|0)|0)|0,i>>>0<=30){A=i+1|0,l=31-i|0,o=A,e=f<<l|m>>>(A>>>0),A=f>>>(A>>>0),i=0,l=m<<l;break}return s?(t[s>>2]=e|0,t[s+4>>2]=a|A&0,I=0,L=0,YA(I|0),L|0):(I=0,L=0,YA(I|0),L|0)}while(!1);if(!o)f=l,a=0,l=0;else{M=r|0|0,m=R|n&0,f=KA(M|0,m|0,-1,-1)|0,r=S()|0,a=l,l=0;do n=a,a=i>>>31|a<<1,i=l|i<<1,n=e<<1|n>>>31|0,R=e>>>31|A<<1|0,ct(f|0,r|0,n|0,R|0)|0,L=S()|0,I=L>>31|((L|0)<0?-1:0)<<1,l=I&1,e=ct(n|0,R|0,I&M|0,(((L|0)<0?-1:0)>>31|((L|0)<0?-1:0)<<1)&m|0)|0,A=S()|0,o=o-1|0;while((o|0)!=0);f=a,a=0}return o=0,s|0&&(t[s>>2]=e,t[s+4>>2]=A),I=(i|0)>>>31|(f|o)<<1|(o<<1|i>>>31)&0|a,L=(i<<1|0)&-2|l,YA(I|0),L|0}function V0(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,a=0,f=0;return f=A>>31|((A|0)<0?-1:0)<<1,a=((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=ct(f^e|0,a^A|0,f|0,a|0)|0,o=S()|0,e=i^f,A=s^a,ct((ls(l,o,ct(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 la(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=Pe(s,i)|0,n=e>>>16,e=(r>>>16)+(Pe(s,n)|0)|0,s=A>>>16,A=Pe(s,i)|0,YA((e>>>16)+(Pe(s,n)|0)+(((e&65535)+A|0)>>>16)|0),e+A<<16|r&65535|0|0}function ft(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=la(s,i)|0,e=S()|0,YA((Pe(A,i)|0)+(Pe(n,s)|0)+e|e&0|0),r|0|0|0}function jr(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,a=0,f=0;return s=b,b=b+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,a=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,e=ct(o^e|0,i^A|0,o|0,i|0)|0,A=S()|0,ls(e,A,ct(f^r|0,a^n|0,f|0,a|0)|0,S()|0,l)|0,n=ct(t[l>>2]^o|0,t[l+4>>2]^i|0,o|0,i|0)|0,r=S()|0,b=s,YA(r|0),n|0}function Rr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var s=0,i=0;return i=b,b=b+16|0,s=i|0,ls(e,A,r,n,s)|0,b=i,YA(t[s+4>>2]|0),t[s>>2]|0|0}function hi(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A>>r|0),e>>>r|(A&(1<<r)-1)<<32-r):(YA(((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?(YA(A>>>r|0),e>>>r|(A&(1<<r)-1)<<32-r):(YA(0),A>>>r-32|0)}function CA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A<<r|(e&(1<<r)-1<<32-r)>>>32-r|0),e<<r):(YA(e<<r-32|0),0)}function as(e,A,r){return e=e|0,A=A|0,A=nt(A)|0,(A|0)==32&&(A=A+(nt(e)|0)|0),YA(0),A|0}function mi(e,A){return e=+e,A=+A,e!=e?+A:A!=A?+e:+F0(+e,+A)}function En(e,A){return e=+e,A=+A,e!=e?+A:A!=A?+e:+At(+e,+A)}function Sn(e){return e=+e,e>=0?+He(e+.5):+gt(e-.5)}function Ir(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,s=0,i=0;if((r|0)>=8192)return l0(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 W0(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?+He(e+.5):+gt(e-.5)}function Y0(e){e=e|0;var A=0,r=0,n=0;return n=P0()|0,r=t[De>>2]|0,A=r+e|0,(e|0)>0&(A|0)<(r|0)|(A|0)<0?(m0(A|0)|0,Nt(12),-1):(A|0)>(n|0)&&!(a0(A|0)|0)?(Nt(12),-1):(t[De>>2]=A,r|0)}return{___divdi3:V0,___muldi3:ft,___remdi3:jr,___uremdi3:Rr,_areNeighborCells:$n,_bitshift64Ashr:hi,_bitshift64Lshr:wA,_bitshift64Shl:CA,_calloc:Qt,_cellAreaKm2:Dl,_cellAreaM2:_l,_cellAreaRads2:ns,_cellToBoundary:_r,_cellToCenterChild:Ks,_cellToChildPos:wl,_cellToChildren:en,_cellToChildrenSize:p0,_cellToLatLng:ar,_cellToLocalIj:Fl,_cellToParent:_t,_cellToVertex:Xt,_cellToVertexes:ta,_cellsToDirectedEdge:yn,_cellsToLinkedMultiPolygon:pt,_childPosToCell:vl,_compactCells:fl,_constructCell:we,_destroyLinkedMultiPolygon:Xs,_directedEdgeToBoundary:or,_directedEdgeToCells:Mr,_edgeLengthKm:jl,_edgeLengthM:Rl,_edgeLengthRads:Tl,_emscripten_replace_memory:E0,_free:qA,_getBaseCellNumber:te,_getDirectedEdgeDestination:xn,_getDirectedEdgeOrigin:Sr,_getHexagonAreaAvgKm2:qs,_getHexagonAreaAvgM2:Sl,_getHexagonEdgeLengthAvgKm:Ml,_getHexagonEdgeLengthAvgM:Bl,_getIcosahedronFaces:Zs,_getIndexDigit:be,_getNumCells:bn,_getPentagons:es,_getRes0Cells:Wr,_getResolution:_A,_greatCircleDistanceKm:rn,_greatCircleDistanceM:kl,_greatCircleDistanceRads:bl,_gridDisk:v,_gridDiskDistances:_,_gridDistance:Ql,_gridPathCells:zl,_gridPathCellsSize:Ol,_gridRing:dA,_gridRingUnsafe:jA,_i64Add:KA,_i64Subtract:ct,_isPentagon:Oe,_isResClassIII:ml,_isValidCell:Ue,_isValidDirectedEdge:Xr,_isValidIndex:Bt,_isValidVertex:li,_latLngToCell:Xn,_llvm_ctlz_i64:as,_llvm_maxnum_f64:mi,_llvm_minnum_f64:En,_llvm_round_f64:Sn,_localIjToCell:Pl,_malloc:y0,_maxFaceCount:yl,_maxGridDiskSize:d,_maxPolygonToCellsSize:ce,_maxPolygonToCellsSizeExperimental:Ul,_memcpy:Ir,_memset:W0,_originToDirectedEdges:Br,_pentagonCount:xl,_polygonToCells:kt,_polygonToCellsExperimental:Gl,_readInt64AsDoubleFromPointer:Jl,_res0CellCount:Vr,_round:gi,_sbrk:Y0,_sizeOfCellBoundary:Yl,_sizeOfCoordIJ:ql,_sizeOfGeoLoop:Kl,_sizeOfGeoPolygon:Zl,_sizeOfH3Index:Vl,_sizeOfLatLng:Wl,_sizeOfLinkedGeoPolygon:$l,_uncompactCells:dl,_uncompactCellsSize:hl,_vertexToLatLng:ra,establishStackSpace:S0,stackAlloc:$t,stackRestore:O0,stackSave:Q0}})(rr,N0,yA);u.___divdi3=gA.___divdi3,u.___muldi3=gA.___muldi3,u.___remdi3=gA.___remdi3,u.___uremdi3=gA.___uremdi3,u._areNeighborCells=gA._areNeighborCells,u._bitshift64Ashr=gA._bitshift64Ashr,u._bitshift64Lshr=gA._bitshift64Lshr,u._bitshift64Shl=gA._bitshift64Shl,u._calloc=gA._calloc,u._cellAreaKm2=gA._cellAreaKm2,u._cellAreaM2=gA._cellAreaM2,u._cellAreaRads2=gA._cellAreaRads2,u._cellToBoundary=gA._cellToBoundary,u._cellToCenterChild=gA._cellToCenterChild,u._cellToChildPos=gA._cellToChildPos,u._cellToChildren=gA._cellToChildren,u._cellToChildrenSize=gA._cellToChildrenSize,u._cellToLatLng=gA._cellToLatLng,u._cellToLocalIj=gA._cellToLocalIj,u._cellToParent=gA._cellToParent,u._cellToVertex=gA._cellToVertex,u._cellToVertexes=gA._cellToVertexes,u._cellsToDirectedEdge=gA._cellsToDirectedEdge,u._cellsToLinkedMultiPolygon=gA._cellsToLinkedMultiPolygon,u._childPosToCell=gA._childPosToCell,u._compactCells=gA._compactCells,u._constructCell=gA._constructCell,u._destroyLinkedMultiPolygon=gA._destroyLinkedMultiPolygon,u._directedEdgeToBoundary=gA._directedEdgeToBoundary,u._directedEdgeToCells=gA._directedEdgeToCells,u._edgeLengthKm=gA._edgeLengthKm,u._edgeLengthM=gA._edgeLengthM,u._edgeLengthRads=gA._edgeLengthRads;var d0=u._emscripten_replace_memory=gA._emscripten_replace_memory;u._free=gA._free,u._getBaseCellNumber=gA._getBaseCellNumber,u._getDirectedEdgeDestination=gA._getDirectedEdgeDestination,u._getDirectedEdgeOrigin=gA._getDirectedEdgeOrigin,u._getHexagonAreaAvgKm2=gA._getHexagonAreaAvgKm2,u._getHexagonAreaAvgM2=gA._getHexagonAreaAvgM2,u._getHexagonEdgeLengthAvgKm=gA._getHexagonEdgeLengthAvgKm,u._getHexagonEdgeLengthAvgM=gA._getHexagonEdgeLengthAvgM,u._getIcosahedronFaces=gA._getIcosahedronFaces,u._getIndexDigit=gA._getIndexDigit,u._getNumCells=gA._getNumCells,u._getPentagons=gA._getPentagons,u._getRes0Cells=gA._getRes0Cells,u._getResolution=gA._getResolution,u._greatCircleDistanceKm=gA._greatCircleDistanceKm,u._greatCircleDistanceM=gA._greatCircleDistanceM,u._greatCircleDistanceRads=gA._greatCircleDistanceRads,u._gridDisk=gA._gridDisk,u._gridDiskDistances=gA._gridDiskDistances,u._gridDistance=gA._gridDistance,u._gridPathCells=gA._gridPathCells,u._gridPathCellsSize=gA._gridPathCellsSize,u._gridRing=gA._gridRing,u._gridRingUnsafe=gA._gridRingUnsafe,u._i64Add=gA._i64Add,u._i64Subtract=gA._i64Subtract,u._isPentagon=gA._isPentagon,u._isResClassIII=gA._isResClassIII,u._isValidCell=gA._isValidCell,u._isValidDirectedEdge=gA._isValidDirectedEdge,u._isValidIndex=gA._isValidIndex,u._isValidVertex=gA._isValidVertex,u._latLngToCell=gA._latLngToCell,u._llvm_ctlz_i64=gA._llvm_ctlz_i64,u._llvm_maxnum_f64=gA._llvm_maxnum_f64,u._llvm_minnum_f64=gA._llvm_minnum_f64,u._llvm_round_f64=gA._llvm_round_f64,u._localIjToCell=gA._localIjToCell,u._malloc=gA._malloc,u._maxFaceCount=gA._maxFaceCount,u._maxGridDiskSize=gA._maxGridDiskSize,u._maxPolygonToCellsSize=gA._maxPolygonToCellsSize,u._maxPolygonToCellsSizeExperimental=gA._maxPolygonToCellsSizeExperimental,u._memcpy=gA._memcpy,u._memset=gA._memset,u._originToDirectedEdges=gA._originToDirectedEdges,u._pentagonCount=gA._pentagonCount,u._polygonToCells=gA._polygonToCells,u._polygonToCellsExperimental=gA._polygonToCellsExperimental,u._readInt64AsDoubleFromPointer=gA._readInt64AsDoubleFromPointer,u._res0CellCount=gA._res0CellCount,u._round=gA._round,u._sbrk=gA._sbrk,u._sizeOfCellBoundary=gA._sizeOfCellBoundary,u._sizeOfCoordIJ=gA._sizeOfCoordIJ,u._sizeOfGeoLoop=gA._sizeOfGeoLoop,u._sizeOfGeoPolygon=gA._sizeOfGeoPolygon,u._sizeOfH3Index=gA._sizeOfH3Index,u._sizeOfLatLng=gA._sizeOfLatLng,u._sizeOfLinkedGeoPolygon=gA._sizeOfLinkedGeoPolygon,u._uncompactCells=gA._uncompactCells,u._uncompactCellsSize=gA._uncompactCellsSize,u._vertexToLatLng=gA._vertexToLatLng,u.establishStackSpace=gA.establishStackSpace;var at=u.stackAlloc=gA.stackAlloc,Fe=u.stackRestore=gA.stackRestore,i0=u.stackSave=gA.stackSave;if(u.asm=gA,u.cwrap=uA,u.setValue=V,u.getValue=W,Qe){Be(Qe)||(Qe=C(Qe));{Xe();var Zt=function(rA){rA.byteLength&&(rA=new Uint8Array(rA)),LA.set(rA,z),u.memoryInitializerRequest&&delete u.memoryInitializerRequest.response,vt()},xt=function(){T(Qe,Zt,function(){throw"could not load memory initializer "+Qe})},bt=f0(Qe);if(bt)Zt(bt.buffer);else if(u.memoryInitializerRequest){var o0=function(){var rA=u.memoryInitializerRequest,pA=rA.response;if(rA.status!==200&&rA.status!==0){var IA=f0(u.memoryInitializerRequestURL);if(IA)pA=IA.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+rA.status+", retrying "+Qe),xt();return}}Zt(pA)};u.memoryInitializerRequest.response?setTimeout(o0,0):u.memoryInitializerRequest.addEventListener("load",o0)}else xt()}}var wt;qe=function rA(){wt||It(),wt||(qe=rA)};function It(rA){if($e>0||(Le(),$e>0))return;function pA(){wt||(wt=!0,!oA&&(se(),me(),u.onRuntimeInitialized&&u.onRuntimeInitialized(),ue()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),pA()},1)):pA()}u.run=It;function ht(rA){throw u.onAbort&&u.onAbort(rA),rA+="",Q(rA),D(rA),oA=!0,"abort("+rA+"). Build with -s ASSERTIONS=1 for more info."}if(u.abort=ht,u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();return It(),c})(typeof jt=="object"?jt:{}),re="number",ee=re,zr=re,oe=re,le=re,dt=re,PA=re,Cf=[["sizeOfH3Index",re],["sizeOfLatLng",re],["sizeOfCellBoundary",re],["sizeOfGeoLoop",re],["sizeOfGeoPolygon",re],["sizeOfLinkedGeoPolygon",re],["sizeOfCoordIJ",re],["readInt64AsDoubleFromPointer",re],["isValidCell",zr,[oe,le]],["isValidIndex",zr,[oe,le]],["latLngToCell",ee,[re,re,dt,PA]],["cellToLatLng",ee,[oe,le,PA]],["cellToBoundary",ee,[oe,le,PA]],["maxGridDiskSize",ee,[re,PA]],["gridDisk",ee,[oe,le,re,PA]],["gridDiskDistances",ee,[oe,le,re,PA,PA]],["gridRing",ee,[oe,le,re,PA]],["gridRingUnsafe",ee,[oe,le,re,PA]],["maxPolygonToCellsSize",ee,[PA,dt,re,PA]],["polygonToCells",ee,[PA,dt,re,PA]],["maxPolygonToCellsSizeExperimental",ee,[PA,dt,re,PA]],["polygonToCellsExperimental",ee,[PA,dt,re,re,re,PA]],["cellsToLinkedMultiPolygon",ee,[PA,re,PA]],["destroyLinkedMultiPolygon",null,[PA]],["compactCells",ee,[PA,PA,re,re]],["uncompactCells",ee,[PA,re,re,PA,re,dt]],["uncompactCellsSize",ee,[PA,re,re,dt,PA]],["isPentagon",zr,[oe,le]],["isResClassIII",zr,[oe,le]],["getBaseCellNumber",re,[oe,le]],["getResolution",re,[oe,le]],["getIndexDigit",re,[oe,le,re]],["constructCell",ee,[re,re,PA,PA]],["maxFaceCount",ee,[oe,le,PA]],["getIcosahedronFaces",ee,[oe,le,PA]],["cellToParent",ee,[oe,le,dt,PA]],["cellToChildren",ee,[oe,le,dt,PA]],["cellToCenterChild",ee,[oe,le,dt,PA]],["cellToChildrenSize",ee,[oe,le,dt,PA]],["cellToChildPos",ee,[oe,le,dt,PA]],["childPosToCell",ee,[re,re,oe,le,dt,PA]],["areNeighborCells",ee,[oe,le,oe,le,PA]],["cellsToDirectedEdge",ee,[oe,le,oe,le,PA]],["getDirectedEdgeOrigin",ee,[oe,le,PA]],["getDirectedEdgeDestination",ee,[oe,le,PA]],["isValidDirectedEdge",zr,[oe,le]],["directedEdgeToCells",ee,[oe,le,PA]],["originToDirectedEdges",ee,[oe,le,PA]],["directedEdgeToBoundary",ee,[oe,le,PA]],["gridDistance",ee,[oe,le,oe,le,PA]],["gridPathCells",ee,[oe,le,oe,le,PA]],["gridPathCellsSize",ee,[oe,le,oe,le,PA]],["cellToLocalIj",ee,[oe,le,oe,le,re,PA]],["localIjToCell",ee,[oe,le,PA,re,PA]],["getHexagonAreaAvgM2",ee,[dt,PA]],["getHexagonAreaAvgKm2",ee,[dt,PA]],["getHexagonEdgeLengthAvgM",ee,[dt,PA]],["getHexagonEdgeLengthAvgKm",ee,[dt,PA]],["greatCircleDistanceM",re,[PA,PA]],["greatCircleDistanceKm",re,[PA,PA]],["greatCircleDistanceRads",re,[PA,PA]],["cellAreaM2",ee,[oe,le,PA]],["cellAreaKm2",ee,[oe,le,PA]],["cellAreaRads2",ee,[oe,le,PA]],["edgeLengthM",ee,[oe,le,PA]],["edgeLengthKm",ee,[oe,le,PA]],["edgeLengthRads",ee,[oe,le,PA]],["getNumCells",ee,[dt,PA]],["getRes0Cells",ee,[PA]],["res0CellCount",re],["getPentagons",ee,[re,PA]],["pentagonCount",re],["cellToVertex",ee,[oe,le,re,PA]],["cellToVertexes",ee,[oe,le,PA]],["vertexToLatLng",ee,[oe,le,PA]],["isValidVertex",zr,[oe,le]]],Ef=0,Sf=1,Mf=2,Bf=3,Df=4,_f=5,Tf=6,jf=7,Rf=8,If=9,Lf=10,Nf=11,Ff=12,Pf=13,Qf=14,Of=15,zf=16,Hf=17,Gf=18,Uf=19,rt={};rt[Ef]="Success";rt[Sf]="The operation failed but a more specific error is not available";rt[Mf]="Argument was outside of acceptable range";rt[Bf]="Latitude or longitude arguments were outside of acceptable range";rt[Df]="Resolution argument was outside of acceptable range";rt[_f]="Cell argument was not valid";rt[Tf]="Directed edge argument was not valid";rt[jf]="Undirected edge argument was not valid";rt[Rf]="Vertex argument was not valid";rt[If]="Pentagon distortion was encountered";rt[Lf]="Duplicate input";rt[Nf]="Cell arguments were not neighbors";rt[Ff]="Cell arguments had incompatible resolutions";rt[Pf]="Memory allocation failed";rt[Qf]="Bounds of provided memory were insufficient";rt[Of]="Mode or flags argument was not valid";rt[zf]="Index argument was not valid";rt[Hf]="Base cell number was outside of acceptable range";rt[Gf]="Child indexing digits invalid";rt[Uf]="Child indexing digits refer to a deleted subsequence";var Vf=1e3,Wf=1001,rl=1002,Zn={};Zn[Vf]="Unknown unit";Zn[Wf]="Array length out of bounds";Zn[rl]="Got unexpected null value for H3 index";var Yf="Unknown error";function nl(c,u,p){var y=p&&"value"in p,x=new Error((c[u]||Yf)+" (code: "+u+(y?", value: "+p.value:"")+")");return x.code=u,x}function Kf(c,u){var p=arguments.length===2?{value:u}:{};return nl(rt,c,p)}function Zf(c,u){var p=arguments.length===2?{value:u}:{};return nl(Zn,c,p)}function sl(c){if(c!==0)throw Kf(c)}var v0={};Cf.forEach(function(u){v0[u[0]]=jt.cwrap.apply(jt,u)});var Gr=16,$f=4,Vn=8,js=v0.sizeOfH3Index(),qf=v0.sizeOfLatLng(),Jf=v0.sizeOfCellBoundary();v0.sizeOfGeoPolygon();v0.sizeOfGeoLoop();v0.sizeOfLinkedGeoPolygon();v0.sizeOfCoordIJ();function Xf(c){if(!c)throw Zf(rl);return c}var A2=/[^0-9a-fA-F]/;function e2(c){if(Array.isArray(c)&&c.length===2&&Number.isInteger(c[0])&&Number.isInteger(c[1]))return c;if(typeof c!="string"||A2.test(c))return[0,0];var u=parseInt(c.substring(0,c.length-8),Gr),p=parseInt(c.substring(c.length-8),Gr);return[p,u]}function Vi(c){if(c>=0)return c.toString(Gr);c=c&2147483647;var u=il(8,c.toString(Gr)),p=(parseInt(u[0],Gr)+8).toString(Gr);return u=p+u.substring(1),u}function t2(c,u){return Vi(u)+il(8,Vi(c))}function il(c,u){for(var p=c-u.length,y="",x=0;x<p;x++)y+="0";return y=y+u,y}function r2(c,u){u===void 0&&(u=0);var p=jt.getValue(c+js*u,"i32"),y=jt.getValue(c+js*u+$f,"i32");return y?t2(p,y):null}function Wi(c){return l2(jt.getValue(c,"double"))}function n2(c){return[Wi(c),Wi(c+Vn)]}function s2(c,u,p){for(var y=jt.getValue(c,"i32"),x=c+Vn,C=[],T=n2,Q=0;Q<y*2;Q+=2)C.push(T(x+Vn*Q));return C}function i2(c,u,p){var y=jt._malloc(qf);jt.HEAPF64.set([c,u].map(o2),y/Vn);var x=jt._malloc(js);try{return sl(v0.latLngToCell(y,p,x)),Xf(r2(x))}finally{jt._free(x),jt._free(y)}}function ol(c,u){var p=jt._malloc(Jf),y=e2(c),x=y[0],C=y[1];try{return sl(v0.cellToBoundary(x,C,p)),s2(p,u,u)}finally{jt._free(p)}}function o2(c){return c*Math.PI/180}function l2(c){return c*180/Math.PI}const dr="wardriving-hexagons",hr="wardriving-hexagons-fill",a2=8,u2=.7,c2=300,ll=500,f2=[[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]],d2=[[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 h2(c="dark"){var p;if(c==="light")return d2;const u=Da();return u.length===24&&((p=u[0])==null?void 0:p[0])!==0?u:f2}function Yi(c){return`rgb(${c[0]}, ${c[1]}, ${c[2]})`}function m2(c){return c<.15?c/.15*.1:c>.85?.9+(c-.85)/.15*.1:.1+(c-.15)/.7*.8}function al(c,u,p,y){const x=p-u;if(x<.001)return Yi(y[12]);const C=Math.max(0,Math.min(1,(c-u)/x)),T=m2(C),Q=Math.min(23,Math.floor(T*24));return Yi(y[Q])}function g2(c){const u=new Map;for(const C of c){if(typeof C.lat!="number"||typeof C.lon!="number"||isNaN(C.lat)||isNaN(C.lon))continue;const T=i2(C.lat,C.lon,a2),Q=u.get(T),D=C.weight;Q?(Q.count++,Q.qualitySum+=D):u.set(T,{count:1,qualitySum:D})}const p=[];let y=1/0,x=-1/0;for(const[C,T]of u.entries()){const Q=T.qualitySum/T.count;p.push({hexId:C,count:T.count,avgQuality:Q}),y=Math.min(y,Q),x=Math.max(x,Q)}return{cells:p,minQuality:p.length>0?y:0,maxQuality:p.length>0?x:0}}function p2(c,u,p,y){const x=[];for(const C of c){const Q=ol(C.hexId).map(([E,P])=>[P,E]);Q.push(Q[0]);const D=al(C.avgQuality,u,p,y);x.push({type:"Feature",properties:{color:D,quality:C.avgQuality,count:C.count},geometry:{type:"Polygon",coordinates:[Q]}})}return{type:"FeatureCollection",features:x}}async function y2(c,u,p,y,x){const C=[];let T=0;for(;T<c.length;){if(x.aborted)return null;const Q=Math.min(T+ll,c.length);for(;T<Q;T++){const D=c[T],P=ol(D.hexId).map(([z,V])=>[V,z]);P.push(P[0]);const O=al(D.avgQuality,u,p,y);C.push({type:"Feature",properties:{color:O,quality:D.avgQuality,count:D.count},geometry:{type:"Polygon",coordinates:[P]}})}T<c.length&&await new Promise(D=>requestAnimationFrame(D))}return{type:"FeatureCollection",features:C}}function x2(c,u){const[p,y]=j.useState(c);return j.useEffect(()=>{const x=setTimeout(()=>y(c),u);return()=>clearTimeout(x)},[c,u]),p}function w2({coveragePoints:c,visible:u,terrainEnabled:p=!1,brightness:y=u2,basemapMode:x="dark"}){const{current:C}=Ar(),[T,Q]=j.useState(null);j.useEffect(()=>{const Z=()=>{var iA;const vA=(iA=C==null?void 0:C.getMap)==null?void 0:iA.call(C);vA&&!T&&Q(vA)};Z();const uA=setInterval(Z,50),sA=setTimeout(()=>clearInterval(uA),5e3);return()=>{clearInterval(uA),clearTimeout(sA)}},[C,T]);const[D,E]=j.useState(null),[P,O]=j.useState(!1),z=j.useRef({aborted:!1}),V=j.useRef(0),W=j.useRef(x),oA=x2(c,c2),J=j.useMemo(()=>h2(x),[x]);j.useEffect(()=>{if(!oA||!Array.isArray(oA)||oA.length===0){queueMicrotask(()=>{E(null),V.current=0});return}const Z=W.current!==x;if(oA.length===V.current&&D&&!Z)return;V.current=oA.length,W.current=x,z.current.aborted=!0,z.current={aborted:!1};const uA=z.current;O(!0);const{cells:sA,minQuality:vA,maxQuality:iA}=g2(oA);if(sA.length===0){E(null),O(!1);return}if(sA.length<ll){const fA=p2(sA,vA,iA,J);uA.aborted||(E(fA),O(!1));return}return y2(sA,vA,iA,J,uA).then(fA=>{!uA.aborted&&fA&&E(fA)}).finally(()=>{uA.aborted||O(!1)}),()=>{uA.aborted=!0}},[oA,J]),j.useEffect(()=>{if(!T)return;const Z=()=>{var uA,sA;try{const vA=T.getLayer(hr),iA=T.getSource(dr);if(u&&D&&D.features.length>0){if(iA?T.getSource(dr).setData(D):T.addSource(dr,{type:"geojson",data:D}),!vA){const fA=T.getLayer("topology-weak-edges-native"),RA=(sA=(uA=T.getStyle())==null?void 0:uA.layers)==null?void 0:sA.find(EA=>EA.type==="symbol"),DA=fA?"topology-weak-edges-native":RA==null?void 0:RA.id;T.addLayer({id:hr,type:"fill",source:dr,paint:{"fill-color":["get","color"],"fill-opacity":y}},DA)}}else vA&&T.removeLayer(hr),iA&&T.removeSource(dr)}catch(vA){console.warn("[WardrivingHexLayerMapLibre] Layer update error:",vA)}};T.isStyleLoaded()?Z():T.once("style.load",Z)},[T,u,D,p]),j.useEffect(()=>{if(!(!T||!u))try{T.getLayer(hr)&&T.setPaintProperty(hr,"fill-opacity",y)}catch{}},[T,y,u]),j.useEffect(()=>()=>{if(T)try{T.getLayer(hr)&&T.removeLayer(hr),T.getSource(dr)&&T.removeSource(dr)}catch{}},[T]);const eA=(D==null?void 0:D.features.length)??0;return eA>0&&u?g.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(c==null?void 0:c.length)||0,"data-cell-count":eA,"data-terrain-enabled":p,"data-is-processing":P,style:{display:"none"}}):null}const Ki="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Zi="terrarium",$i=256,qi=14,ln={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},K0="terrain-dem",Hr="hillshade-dem",Fn="terrain-hillshade";function v2({enabled:c,exaggeration:u=4}){const{current:p}=Ar(),[y,x]=j.useState(null),C=j.useRef(null);return j.useEffect(()=>{const T=()=>{var P;const E=(P=p==null?void 0:p.getMap)==null?void 0:P.call(p);E&&!y&&x(E)};T();const Q=setInterval(T,50),D=setTimeout(()=>clearInterval(Q),5e3);return()=>{clearInterval(Q),clearTimeout(D)}},[p,y]),j.useEffect(()=>{if(!y)return;let T=!0;const Q=()=>{var D,E;if(T)try{if(y.getSource(Hr)||y.addSource(Hr,{type:"raster-dem",tiles:[Ki],encoding:Zi,tileSize:$i,maxzoom:qi}),!y.getLayer(Fn)){const P=(E=(D=y.getStyle())==null?void 0:D.layers)==null?void 0:E.find(O=>O.type==="symbol");y.addLayer({id:Fn,type:"hillshade",source:Hr,paint:{"hillshade-shadow-color":ln.shadowColor,"hillshade-highlight-color":ln.highlightColor,"hillshade-accent-color":ln.accentColor,"hillshade-illumination-direction":ln.illuminationDirection,"hillshade-exaggeration":ln.exaggeration}},P==null?void 0:P.id)}y.getSource(K0)||y.addSource(K0,{type:"raster-dem",tiles:[Ki],encoding:Zi,tileSize:$i,maxzoom:qi})}catch(P){console.error("[TerrainLayer] Source/layer setup error:",P)}};return y.isStyleLoaded()?Q():(y.once("style.load",Q),y.once("load",()=>{T&&!y.getSource(Hr)&&Q()})),()=>{T=!1}},[y]),j.useEffect(()=>{if(!y)return;let T=!0,Q=!1;const D=()=>{if(!(!T||!y.getSource(K0)))try{c?(y.setCenterClampedToGround(!1),y.setTerrain({source:K0,exaggeration:u}),y.setMaxPitch(70),!Q&&y.getPitch()<30&&!y.isMoving()&&(Q=!0,C.current!==null&&clearTimeout(C.current),C.current=window.setTimeout(()=>{C.current=null,T&&!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(E){console.error("[TerrainLayer] Terrain state error:",E)}};if(y.isStyleLoaded()&&y.getSource(K0))D();else{const E=()=>{y.getSource(K0)&&D()};y.once("idle",E)}return()=>{T=!1,C.current!==null&&(clearTimeout(C.current),C.current=null)}},[y,c,u]),j.useEffect(()=>()=>{var T;try{(T=y==null?void 0:y.getStyle)!=null&&T.call(y)&&y.isStyleLoaded()&&(y.setTerrain(null),y.getLayer(Fn)&&y.removeLayer(Fn),y.getSource(Hr)&&y.removeSource(Hr),y.getSource(K0)&&y.removeSource(K0))}catch{}},[y]),null}const b2=.03,k2=.1,C2=2,E2=3,S2=.02,M2=3;function B2(c,u=M2){if(c.length<3||u<=0)return c;let p=c;for(let y=0;y<u;y++){const x=[],C=p.length,T=p[0][0]===p[C-1][0]&&p[0][1]===p[C-1][1],Q=T?C-1:C;for(let D=0;D<Q;D++){const E=p[D],P=p[(D+1)%Q],O=.75*E[0]+.25*P[0],z=.75*E[1]+.25*P[1],V=.25*E[0]+.75*P[0],W=.25*E[1]+.75*P[1];x.push([O,z]),x.push([V,W])}T&&x.length>0&&x.push([x[0][0],x[0][1]]),p=x}return p}function D2(c,u){let p=1/0,y=-1/0,x=1/0,C=-1/0;for(const[T,Q]of c)T<p&&(p=T),T>y&&(y=T),Q<x&&(x=Q),Q>C&&(C=Q);return p-=u,y+=u,x-=u,C+=u,{minX:p,minY:x,maxX:y,maxY:C,width:y-p,height:C-x}}function _2(c,u={}){if(c.length<E2)return{coordinates:[],valid:!1};const{bandwidth:p=b2,threshold:y=k2,cellSize:x=C2}=u,C=D2(c,S2),T=Math.ceil(C.width/(p/2)),Q=Math.ceil(C.height/(p/2)),E=Math.min(1,200/Math.max(T,Q)),P=Math.max(10,Math.ceil(T*E)),O=Math.max(10,Math.ceil(Q*E)),z=eA=>(eA-C.minX)/C.width*P,V=eA=>(eA-C.minY)/C.height*O,W=eA=>eA/P*C.width+C.minX,oA=eA=>eA/O*C.height+C.minY,J=p/C.width*P;try{const Z=ac().x(DA=>z(DA[0])).y(DA=>V(DA[1])).size([P,O]).bandwidth(Math.max(5,J)).cellSize(x)(c);if(Z.length===0)return{coordinates:[],valid:!1};const sA=Math.max(...Z.map(DA=>DA.value))*y;let vA=Z[0],iA=1/0;for(const DA of Z){const EA=Math.abs(DA.value-sA);EA<iA&&(iA=EA,vA=DA)}const fA=[];for(const DA of vA.coordinates){const EA=[];for(const yA of DA){const bA=[];for(const LA of yA){const NA=W(LA[0]),GA=oA(LA[1]);bA.push([NA,GA])}if(bA.length>0){const LA=bA[0],NA=bA[bA.length-1];(LA[0]!==NA[0]||LA[1]!==NA[1])&&bA.push([LA[0],LA[1]])}if(bA.length>=4){const LA=B2(bA);EA.push(LA)}}EA.length>0&&fA.push(EA)}const RA=[];for(const DA of fA)for(const EA of DA)RA.push(EA);return{coordinates:fA,valid:fA.length>0}}catch(eA){return console.warn("[KDE Contour] Failed to generate contour:",eA),{coordinates:[],valid:!1}}}function T2(c,u={}){const p=_2(c,u);return!p.valid||p.coordinates.length===0?null:p.coordinates.length===1?{type:"Polygon",coordinates:p.coordinates[0]}:{type:"MultiPolygon",coordinates:p.coordinates}}const j2="mincut-partition",R2="mincut-partition-fill",I2="mincut-partition-stroke",L2=3,N2=.05,F2=.15,P2=.008,Ji=12;function Xi(c,u,p){return(u[0]-c[0])*(p[1]-c[1])-(u[1]-c[1])*(p[0]-c[0])}function Q2(c){if(c.length<3)return c;const u=[...c].sort((x,C)=>x[0]-C[0]||x[1]-C[1]),p=[];for(const x of u){for(;p.length>=2&&Xi(p[p.length-2],p[p.length-1],x)<=0;)p.pop();p.push(x)}const y=[];for(let x=u.length-1;x>=0;x--){const C=u[x];for(;y.length>=2&&Xi(y[y.length-2],y[y.length-1],C)<=0;)y.pop();y.push(C)}return p.pop(),y.pop(),p.concat(y)}function O2(c,u){if(c.length<3)return c;let p=0,y=0;for(const[x,C]of c)p+=x,y+=C;return p/=c.length,y/=c.length,c.map(([x,C])=>{const T=x-p,Q=C-y,D=Math.sqrt(T*T+Q*Q);if(D<1e-4)return[x,C];const E=(D+u)/D;return[p+T*E,y+Q*E]})}function z2(c,u,p,y,x){const C=x*x,T=C*x;return[.5*(2*u[0]+(-c[0]+p[0])*x+(2*c[0]-5*u[0]+4*p[0]-y[0])*C+(-c[0]+3*u[0]-3*p[0]+y[0])*T),.5*(2*u[1]+(-c[1]+p[1])*x+(2*c[1]-5*u[1]+4*p[1]-y[1])*C+(-c[1]+3*u[1]-3*p[1]+y[1])*T)]}function H2(c){if(c.length<3)return c;const u=[],p=c.length;for(let y=0;y<p;y++){const x=c[(y-1+p)%p],C=c[y],T=c[(y+1)%p],Q=c[(y+2)%p];for(let D=0;D<Ji;D++)u.push(z2(x,C,T,Q,D/Ji))}return u}function G2(c){let u=Q2(c);if(u.length<3)return null;u=O2(u,P2);const p=H2(u);return{type:"Polygon",coordinates:[[...p,p[0]]]}}function U2(c,u,p,y){const x=[];for(const[C,T]of c.communities){const Q=[];for(const E of T){const P=u.get(E);P&&Q.push([P[1],P[0]])}if(Q.length<L2)continue;let D=T2(Q,{bandwidth:p,threshold:y});D||(D=G2(Q)),D&&x.push({type:"Feature",properties:{community:C,color:ru(C),borderColor:tu(C),nodeCount:T.length},geometry:D})}return{type:"FeatureCollection",features:x}}function V2({partition:c,nodeCoordinates:u,visible:p,opacity:y=.7,bandwidth:x=N2,threshold:C=F2,strokeWidth:T=2}){const Q=j.useMemo(()=>c?U2(c,u,x,C):{type:"FeatureCollection",features:[]},[c,u,x,C]),D=p?y:0,E={"fill-color":["get","color"],"fill-opacity":D},P={"line-color":["get","borderColor"],"line-width":T,"line-opacity":D};return g.jsxs(J0,{id:j2,type:"geojson",data:Q,children:[g.jsx(t0,{id:R2,type:"fill",paint:E}),g.jsx(t0,{id:I2,type:"line",paint:P})]})}function W2(c,u=!1,p=!1,y=!1,x=.7,C){const T=vo(C);return y?x>=.75?T.restBright:T.rest:x>=.85?T.rest:(x>=.7,T.restDim)}function Ao(c){return[c[1],c[0]]}function Y2(c,u,p,y=12){const[x,C]=c,[T,Q]=u,D=[];for(let E=0;E<=y;E++){const P=E/y,O=C+(Q-C)*P,z=x+(T-x)*P,V=4*p*P*(1-P);D.push([O,z,V])}return D}function eo(c,u,p,y,x,C,T,Q,D,E,P,O="dark"){const z=Ws(),V=[];let W=1/0,oA=-1/0;const J=[];for(const Z of c){const uA=Z.edge.avgConfidence??(u?.7:.5),sA=Z.edge.certainCount/Math.max(T,1),vA=uA*.7+sA*.3+(u?.5:0);J.push({polyline:Z,brightnessScore:vA}),W=Math.min(W,vA),oA=Math.max(oA,vA)}if(J.length===0)return{type:"FeatureCollection",features:[]};const eA=oA-W||1;J.sort((Z,uA)=>Z.brightnessScore-uA.brightnessScore);for(const{polyline:Z,brightnessScore:uA}of J){const{from:sA,to:vA,edge:iA}=Z,fA=p.get(iA.key)??0;if(fA<=0)continue;const RA=Q.has(iA.key),DA=D.has(iA.key),EA=iA.avgConfidence??(u?.7:.5),yA=E===iA.key,bA=P[iA.fromHash],LA=P[iA.toHash],NA=(bA==null?void 0:bA.node_name)||(bA==null?void 0:bA.name)||iA.fromHash.slice(0,8),GA=(LA==null?void 0:LA.node_name)||(LA==null?void 0:LA.name)||iA.toHash.slice(0,8),kA=[sA[0]+(vA[0]-sA[0])*fA,sA[1]+(vA[1]-sA[1])*fA];let cA;if(!u)cA=1.5;else{const ae=C.get(iA.key)??Ms(iA.certainCount),JA=x.get(iA.key)??ae;cA=JA+(ae-JA)*y,yA?cA=Math.max(cA*1.6,4.5):DA&&(cA=cA*1.3)}let lA;yA?lA=z.edges.highlight:lA=W2(!1,iA.isDirectPathEdge??!1,RA,DA,EA,O);let TA;yA?TA=z.edges.highlight:iA.isDirectPathEdge?TA=z.edges.hoverDirect:RA?TA=z.edges.hoverLoop:TA=z.edges.hoverStandard;let MA;if(!u)MA=(.3+EA*.3)*fA;else{const ae=Math.min(fA*1.5,1)*z.edgeOpacity;MA=DA?ae*1.15:ae}yA&&(MA=.95);const WA=(uA-W)/eA;V.push({type:"Feature",properties:{key:iA.key,baseColor:lA,hoverColor:TA,baseWidth:cA,baseOpacity:MA,brightnessScore:WA,isLoopEdge:RA,isBackbone:DA,isDirectPath:iA.isDirectPathEdge??!1,isHubConnection:iA.isHubConnection??!1,isZeroHop:iA.isZeroHop??!1,isValidated:u,certainCount:iA.certainCount,confidence:EA,symmetryRatio:iA.symmetryRatio??1,dominantDirection:iA.dominantDirection??"balanced",fromName:NA,toName:GA,fromHash:iA.fromHash,toHash:iA.toHash},geometry:{type:"LineString",coordinates:[Ao(sA),Ao(kA)]}})}return{type:"FeatureCollection",features:V}}const K2=150,Z2=8;function to(c,u){const p=Ws(),y=[];let x=0;for(const C of c){const T=u.get(C.hash);T&&T.blendedScore>x&&(x=T.blendedScore)}for(const C of c){const{from:T,to:Q,hash:D,neighbor:E,lastHopData:P}=C,O=`neighbor-${D}`,z=(P==null?void 0:P.avgRssi)??E.rssi??null,V=(P==null?void 0:P.avgSnr)??E.snr??null,W=(P==null?void 0:P.count)??0,oA=(P==null?void 0:P.confidence)??1,J=u.get(D),eA=(J==null?void 0:J.listenerScore)??0,Z=(J==null?void 0:J.loudScore)??0,uA=(J==null?void 0:J.blendedScore)??0,sA=x>0?uA/x:0,vA=C.rxAdvertCount??0,iA=C.txProxyCount??0,fA=vA+iA,RA=fA>0?(iA-vA)/fA:0,DA=Y2(T,Q,K2,Z2);y.push({type:"Feature",properties:{key:O,hash:D,name:E.node_name||E.name||D.slice(0,8),prefix:D.slice(2,4).toUpperCase(),color:p.neighborColor,width:2.5,opacity:.85,rssi:z,snr:V,packetCount:W,confidence:oA,hasAvgRssi:(P==null?void 0:P.avgRssi)!==void 0,hasAvgSnr:(P==null?void 0:P.avgSnr)!==void 0,isNeighborEdge:!0,listenerScore:eA,loudScore:Z,blendedScore:uA,trafficWeight:sA,linkAsymmetry:RA,rxAdvertCount:vA,txProxyCount:iA},geometry:{type:"LineString",coordinates:DA}})}return{type:"FeatureCollection",features:y}}function $2({map:c,showTopology:u,validatedPolylines:p,weakPolylines:y,maxCertainCount:x,loopEdgeKeys:C,backboneEdgeKeys:T,highlightedEdgeKey:Q,neighbors:D,validatedSourceId:E,weakSourceId:P,neighborPolylines:O=[],showNeighborLines:z=!0,neighborSourceId:V,neighborLinkScores:W=new Map,basemapMode:oA}){const J=j.useRef(null);j.useEffect(()=>{const se=c&&"current"in c?c.current:c;J.current=se});const eA=j.useRef(new Map),Z=j.useRef(1),uA=j.useRef(new Map),sA=j.useRef(new Map),vA=j.useRef(!1),iA=j.useRef(null),fA=j.useRef(u),RA=j.useRef(new Set),DA=j.useRef(""),EA=j.useRef(new Map),yA=j.useRef(""),bA=j.useRef(""),LA=j.useRef(""),NA=j.useRef(p),GA=j.useRef(y),kA=j.useRef(x),cA=j.useRef(C),lA=j.useRef(T),TA=j.useRef(Q),MA=j.useRef(D),WA=j.useRef(O),ae=j.useRef(z),JA=j.useRef(W),ZA=j.useRef(oA);j.useEffect(()=>{NA.current=p,GA.current=y,kA.current=x,cA.current=C,lA.current=T,TA.current=Q,MA.current=D,WA.current=O,ae.current=z,JA.current=W,ZA.current=oA},[p,y,x,C,T,Q,D,O,z,W,oA]);const UA=j.useCallback((se=!1)=>{var Ce,Se,pe,Ke,$e,qe,Xe,vt,Qe,Je;const me=J.current;if(!me)return;const ue=me.getSource(E),Ye=me.getSource(P),ke=me.getSource(V);if(ue){const Be=eo(NA.current,!0,eA.current,Z.current,uA.current,sA.current,kA.current,cA.current,lA.current,TA.current,MA.current,ZA.current),ze=`${Be.features.length}:${((Se=(Ce=Be.features[0])==null?void 0:Ce.properties)==null?void 0:Se.key)??""}:${((Ke=(pe=Be.features[Be.features.length-1])==null?void 0:pe.properties)==null?void 0:Ke.key)??""}:${Array.from(eA.current.values()).reduce((ot,Rt)=>ot+Rt,0).toFixed(2)}`;(se||ze!==yA.current)&&(ue.setData(Be),yA.current=ze)}if(Ye){const Be=eo(GA.current,!1,eA.current,Z.current,uA.current,sA.current,kA.current,cA.current,lA.current,TA.current,MA.current,ZA.current),ze=`${Be.features.length}:${((qe=($e=Be.features[0])==null?void 0:$e.properties)==null?void 0:qe.key)??""}:${((vt=(Xe=Be.features[Be.features.length-1])==null?void 0:Xe.properties)==null?void 0:vt.key)??""}`;(se||ze!==bA.current)&&(Ye.setData(Be),bA.current=ze)}if(ke&&WA.current.length>0){const Be=to(WA.current,JA.current),ze=`${Be.features.length}:${((Je=(Qe=Be.features[0])==null?void 0:Qe.properties)==null?void 0:Je.hash)??""}`;(se||ze!==LA.current)&&(ke.setData(Be),LA.current=ze)}},[E,P,V]),Ie=j.useCallback(()=>{iA.current&&(cancelAnimationFrame(iA.current),iA.current=null),eA.current=new Map,Z.current=1,uA.current=new Map,sA.current=new Map,vA.current=!1,RA.current=new Set,DA.current="",EA.current=new Map},[]);j.useEffect(()=>{const se=fA.current,me=u;if(fA.current=u,!!J.current){if(iA.current&&(cancelAnimationFrame(iA.current),iA.current=null),se&&!me&&!vA.current){vA.current=!0;const Ye=new Map(eA.current);let ke=null;const Ce=Se=>{ke||(ke=Se);const pe=Se-ke,Ke=Math.min(pe/hc,1),$e=Go(Ke);for(const[qe,Xe]of Ye)eA.current.set(qe,Xe*(1-$e));UA(!0),Ke<1?iA.current=requestAnimationFrame(Ce):(vA.current=!1,eA.current=new Map,RA.current=new Set,DA.current="",uA.current=new Map,sA.current=new Map,iA.current=null,UA(!0))};iA.current=requestAnimationFrame(Ce)}!se&&me&&(eA.current=new Map,RA.current=new Set,DA.current="")}},[u,UA]),j.useEffect(()=>{const se=J.current;if(!u||vA.current||!se)return;const me=[...p,...y],ue=me.map(pe=>`${pe.edge.key}:${pe.edge.certainCount}`).sort().join(","),Ye=RA.current.size===0,ke=DA.current!==""&&DA.current!==ue;if(!Ye&&!ke){UA();return}const Ce=[],Se=[];for(const{edge:pe}of me)RA.current.has(pe.key)?Se.push(pe.key):Ce.push(pe.key);ke&&Se.length>0&&(uA.current=new Map(EA.current),Z.current=0),sA.current=new Map;for(const{edge:pe}of p){const Ke=Ms(pe.certainCount);sA.current.set(pe.key,Ke)}for(const pe of Ce)eA.current.set(pe,0);for(const pe of Se)eA.current.has(pe)||eA.current.set(pe,1);if(Ce.length>0||ke&&Se.length>0){iA.current&&(cancelAnimationFrame(iA.current),iA.current=null);let pe=null;const Ke=Math.min(100,Dn/Math.max(Ce.length,1)/2),$e=qe=>{pe||(pe=qe);const Xe=qe-pe;for(let Qe=0;Qe<Ce.length;Qe++){const Je=Ce[Qe],Be=Qe*Ke,ze=Math.max(0,Xe-Be),ot=Math.min(ze/Dn,1);eA.current.set(Je,Es(ot))}if(ke&&Se.length>0){const Qe=Math.min(Xe/Dn,1);Z.current=Es(Qe)}UA(!0);const vt=Dn+(Ce.length-1)*Ke;Xe<vt?iA.current=requestAnimationFrame($e):iA.current=null};iA.current=requestAnimationFrame($e)}else UA();for(const pe of Ce)RA.current.add(pe);for(const{edge:pe}of p){const Ke=Ms(pe.certainCount);EA.current.set(pe.key,Ke)}DA.current=ue},[u,p,y,x,UA]),j.useEffect(()=>{const se=J.current;if(!se||!V)return;const me=()=>{const ke=se.getSource(V);if(!ke)return!1;if(O.length>0){const Ce=to(O,W);ke.setData(Ce)}else ke.setData({type:"FeatureCollection",features:[]});return!0};if(me())return;const ue=ke=>{ke.sourceId===V&&me()&&se.off("sourcedata",ue)};se.on("sourcedata",ue);const Ye=()=>{me()&&(se.off("styledata",Ye),se.off("sourcedata",ue))};return se.on("styledata",Ye),()=>{se.off("sourcedata",ue),se.off("styledata",Ye)}},[V,O,W]);const Le=j.useRef(oA);return j.useEffect(()=>{oA!==Le.current&&(Le.current=oA,yA.current="",bA.current="",LA.current="",UA(!0))},[oA,UA]),j.useEffect(()=>()=>{iA.current&&(cancelAnimationFrame(iA.current),iA.current=null)},[]),{isExiting:vA.current,isAnimating:iA.current!==null,resetAnimationState:Ie,weightAnimProgress:Z.current,animStartWeights:uA.current,animTargetWeights:sA.current}}function q2({activeFilters:c,neighborHashes:u,hubConnectedNodes:p,directNodeSet:y,localConnectedNodes:x,nodeTypeMap:C,showTopology:T}){const[Q,D]=j.useState(new Map),E=j.useMemo(()=>[...c].sort().join(","),[c]),P=j.useRef(E),O=j.useRef(!1),z=j.useRef(new Map),V=j.useRef(null),W=j.useRef(p),oA=j.useRef(y),J=j.useRef(x),eA=j.useRef(C),Z=j.useRef(T);return j.useEffect(()=>{W.current=p,oA.current=y,J.current=x,eA.current=C,Z.current=T},[p,y,x,C,T]),j.useEffect(()=>{const sA=P.current,vA=E;if(P.current=E,sA===vA)return;V.current&&(cancelAnimationFrame(V.current),V.current=null);const iA=new Set(sA?sA.split(",").filter(Boolean):[]),fA=c,RA=W.current,DA=oA.current,EA=eA.current;for(const kA of u)z.current.has(kA)||z.current.set(kA,Math.random());const yA=(kA,cA)=>{if(cA.size===0)return!1;const lA=EA.get(kA)??"unknown";return!!(cA.has("repeater")&&lA==="repeater"||cA.has("companion")&&(lA==="companion"||lA==="unknown")||cA.has("room_server")&&lA==="room_server"||cA.has("direct")&&DA.has(kA)||cA.has("hubs")&&RA.has(kA))},bA=[];for(const kA of u){const cA=yA(kA,iA),lA=yA(kA,fA);cA!==lA&&bA.push({hash:kA,startOpacity:cA?1:0,targetOpacity:lA?1:0})}if(bA.length===0)return;O.current=!0,D(kA=>{const cA=new Map(kA);for(const{hash:lA,startOpacity:TA}of bA)cA.set(lA,TA);return cA});const LA=bA;let NA=null;const GA=kA=>{NA||(NA=kA);const cA=kA-NA;let lA=!0;D(()=>{const MA=new Map;for(const{hash:WA,startOpacity:ae,targetOpacity:JA}of LA){const ZA=(z.current.get(WA)??0)*Di,UA=Math.max(0,cA-ZA),Ie=Math.min(UA/Bi,1),Le=Es(Ie),se=ae+(JA-ae)*Le;MA.set(WA,se),Ie<1&&(lA=!1)}return MA});const TA=Bi+Di;cA<TA&&!lA?V.current=requestAnimationFrame(GA):(V.current=null,O.current=!1,D(new Map))};return V.current=requestAnimationFrame(GA),()=>{V.current&&(cancelAnimationFrame(V.current),V.current=null),O.current=!1}},[E,c,u]),{nodeOpacities:Q,getNodeOpacity:(sA,vA)=>O.current&&Q.has(sA)?Q.get(sA):vA?1:0}}const xs=240,ro=240;function J2(c,u){if(c<xs)return .5;if(c<xs+ro)return 1;const p=xs+ro,y=u-p,x=(c-p)/y;return Math.max(0,.33*(1-x))}function X2(c){const u=new Map;for(const p of Object.keys(c)){const y=dn(p);u.has(y)||u.set(y,p)}return u}function A1(c,u,p){const y=p?dn(p):null,x=[];for(const C of c){if(y&&C.toUpperCase()===y){p&&x.push(p);continue}const T=u.get(C.toUpperCase());T&&x.push(T)}return x}function e1({neighbors:c,localHash:u,enabled:p=!0}){const[y,x]=j.useState(new Map),C=Bs(),T=j.useRef(C);j.useEffect(()=>{T.current=C},[C]);const Q=j.useRef(0),D=j.useRef(null),E=j.useRef(new Map),P=j.useRef(new Map);j.useEffect(()=>{P.current=X2(c)},[c]);const O=j.useRef(null);return j.useEffect(()=>{const z=()=>{const V=performance.now(),W=E.current;if(W.size===0){D.current=null,x(new Map);return}const oA=new Map,J=[];for(const[eA,{startTime:Z,staggerDelay:uA}]of W){const sA=V-Z-uA;if(!(sA<0))if(sA>=_n)J.push(eA);else{const vA=J2(sA,_n);vA>0&&oA.set(eA,vA)}}for(const eA of J)W.delete(eA);x(oA),W.size>0&&O.current?D.current=requestAnimationFrame(O.current):D.current=null};O.current=z},[]),j.useEffect(()=>{if(!p)return;const z=T.current;if(z.length===0)return;const V=Q.current,W=z.filter(Z=>(Z.timestamp??0)>V);if(V===0){const Z=z.reduce((uA,sA)=>Math.max(uA,sA.timestamp??0),0);Q.current=Z;return}if(W.length===0)return;const oA=W.reduce((Z,uA)=>Math.max(Z,uA.timestamp??0),0);Q.current=oA;const J=performance.now();let eA=0;for(const Z of W){const uA=_o(Z,u);if(!uA||uA.original.length===0)continue;const sA=A1(uA.original,P.current,u);if(sA.length===0)continue;const vA=_n*.5;for(let iA=0;iA<sA.length;iA++){const fA=sA[iA];E.current.has(fA)||E.current.set(fA,{startTime:J,staggerDelay:eA+iA*vA})}eA+=_n*.3}D.current===null&&O.current&&(D.current=requestAnimationFrame(O.current))},[C,u,p]),j.useEffect(()=>()=>{D.current!==null&&(cancelAnimationFrame(D.current),D.current=null)},[]),{blinkingNodes:y,blinkColor:dc}}const Z0="edge-blink-source",pr="edge-blink-layer",Rs=1e3,Is=1e3,ws=150,t1=175,r1=3e4,n1=e0.teal,s1="#8B7BAD",i1=2.5,o1=1.875,l1=.5,Wn="node-markers-layer";function a1(c){if(!c.getLayer(pr))return;const u=c.getLayer(Wn)?Wn:void 0;try{c.moveLayer(pr,u)}catch{}}function u1(c,u){const p=new Map;for(const y of Object.keys(c)){const x=dn(y);p.has(x)||p.set(x,y)}if(u){const y=dn(u);p.set(y,u)}return p}function c1(c){return c<0||c>=Rs?0:1-c/Rs}function f1(c){if(c<0||c>=Is)return 0;const u=c/Is;return Math.pow(1-u,3)}function Pn(c){return[c[1],c[0]]}function d1({map:c,nodeCoordinates:u,packets:p,localHash:y,neighbors:x,meshTopology:C,enabled:T=!0}){const Q=j.useRef(null),D=c&&"current"in c?c.current:c;j.useEffect(()=>{Q.current=D},[D]);const E=j.useRef(!1),P=j.useRef(null),O=j.useRef([]),z=j.useRef(0),V=j.useRef(!1),[W,oA]=j.useState(!1),J=j.useRef(null),eA=j.useRef([]),Z=j.useRef(new Map),uA=j.useRef(u);j.useEffect(()=>{uA.current=u},[u]),j.useEffect(()=>{Z.current=u1(x,y)},[x,y]),j.useEffect(()=>{if(!T){J.current&&(clearTimeout(J.current),J.current=null),eA.current=[],P.current!==null&&(cancelAnimationFrame(P.current),P.current=null),O.current=[];const fA=Q.current;if(fA&&E.current){const RA=fA.getSource(Z0);RA&&RA.setData({type:"FeatureCollection",features:[]})}V.current=!1,z.current=0}},[T]),j.useEffect(()=>{const fA=D;if(!fA)return;let RA=null,DA=!1;const EA=()=>{if(!DA&&!E.current)try{fA.getLayer(pr)&&fA.removeLayer(pr),fA.getSource(Z0)&&fA.removeSource(Z0),fA.addSource(Z0,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const yA=fA.getLayer(Wn)?Wn:void 0;fA.addLayer({id:pr,type:"line",source:Z0,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],s1,n1],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],o1,i1],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},yA),E.current=!0,oA(!0),RA&&(clearInterval(RA),RA=null)}catch{}};return fA.isStyleLoaded()&&EA(),fA.once("style.load",()=>{EA()}),E.current||(RA=setInterval(()=>{if(E.current){RA&&clearInterval(RA);return}EA()},100),setTimeout(()=>{RA&&(clearInterval(RA),RA=null)},5e3)),()=>{DA=!0,RA&&clearInterval(RA),P.current!==null&&(cancelAnimationFrame(P.current),P.current=null);const yA=Q.current;if(yA&&E.current){try{yA.getLayer(pr)&&yA.removeLayer(pr),yA.getSource(Z0)&&yA.removeSource(Z0)}catch{}E.current=!1,oA(!1)}}},[D]);const sA=j.useRef(()=>{});j.useEffect(()=>{sA.current=()=>{const fA=Q.current;if(!fA)return;const RA=fA.getSource(Z0);if(!RA)return;const DA=performance.now(),EA=O.current,yA=[],bA=[];for(const LA of EA){const NA=DA-LA.startTime-LA.delay,GA=LA.isSpeculative?Is:Rs;if(NA<GA){bA.push(LA);const kA=LA.isSpeculative?f1(NA):c1(NA);kA>0&&yA.push({type:"Feature",properties:{intensity:kA,opacityMult:LA.isSpeculative?l1:1,isSpeculative:LA.isSpeculative??!1},geometry:{type:"LineString",coordinates:[LA.fromCoord,LA.toCoord]}})}}RA.setData({type:"FeatureCollection",features:yA}),O.current=bA,bA.length>0?P.current=requestAnimationFrame(()=>sA.current()):P.current=null}},[]);const vA=j.useCallback(()=>{const fA=Q.current;fA&&a1(fA),P.current===null&&(P.current=requestAnimationFrame(()=>sA.current()))},[]),iA=j.useCallback(()=>{if(!Q.current||!E.current)return;const RA=eA.current;if(eA.current=[],J.current=null,RA.length===0)return;const DA=Z.current,EA=uA.current;if(DA.size===0)return;const yA=performance.now();let bA=0,LA=!1;const NA=new Set;for(const GA of RA){const kA=_o(GA,y);if(!kA||kA.original.length<2)continue;const cA=kA.original;let lA=0,TA=null;for(let JA=0;JA<cA.length-1;JA++){const ZA=cA[JA].toUpperCase(),UA=cA[JA+1].toUpperCase(),Ie=DA.get(ZA),Le=DA.get(UA);if(!Ie||!Le)continue;const se=EA.get(Ie),me=EA.get(Le);if(!se||!me)continue;const ue=[Ie,Le].sort().join("-");O.current.push({edgeKey:ue,fromCoord:Pn(se),toCoord:Pn(me),startTime:yA,delay:bA+lA*ws}),NA.add(ue),TA=Le,lA++,LA=!0}const MA=GA.route??GA.route_type;if(_a(MA)&&TA&&!(TA===y)&&(C!=null&&C.edgeMap)){const JA=[];for(const[ZA,UA]of C.edgeMap){if(!(UA.fromHash===TA||UA.toHash===TA)||NA.has(ZA))continue;const Le=UA.fromHash===TA?UA.toHash:UA.fromHash,se=EA.get(TA),me=EA.get(Le);!se||!me||JA.push({edgeKey:ZA,otherHash:Le,confidence:UA.avgConfidence??0})}if(JA.length>0){JA.sort((Le,se)=>se.confidence-Le.confidence);const ZA=Math.max(1,Math.ceil(JA.length*.25)),UA=JA.slice(0,ZA),Ie=bA+lA*ws;for(const{edgeKey:Le,otherHash:se}of UA){const me=EA.get(TA),ue=EA.get(se);O.current.push({edgeKey:Le,fromCoord:Pn(me),toCoord:Pn(ue),startTime:yA,delay:Ie,isSpeculative:!0}),NA.add(Le),LA=!0}}}lA>0&&(bA+=lA*ws*.5)}LA&&vA()},[y,C,vA]);j.useEffect(()=>{const fA=Q.current;if(!T||!fA||!W||p.length===0)return;const RA=Date.now(),DA=z.current;if(!V.current){V.current=!0;const bA=(RA-r1)/1e3,LA=p.filter(GA=>(GA.timestamp??0)>=bA);let NA=0;for(const GA of p){const kA=GA.timestamp??0;kA>NA&&(NA=kA)}if(z.current=NA,LA.length>0){LA.sort((kA,cA)=>(kA.timestamp??0)-(cA.timestamp??0));const GA=LA.slice(-20);eA.current.push(...GA),iA()}return}const EA=p.filter(bA=>(bA.timestamp??0)>DA);if(EA.length===0)return;let yA=0;for(const bA of EA){const LA=bA.timestamp??0;LA>yA&&(yA=LA)}z.current=yA,eA.current.push(...EA),J.current&&clearTimeout(J.current),J.current=setTimeout(iA,t1)},[T,p,iA,W]),j.useEffect(()=>()=>{J.current&&clearTimeout(J.current)},[])}var $0={},mr={};/**
 * @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 no;function h1(){if(no)return mr;no=1;var c=To();function u(d){for(var v="https://reactjs.org/docs/error-decoder.html?invariant="+d,_=1;_<arguments.length;_++)v+="&args[]="+encodeURIComponent(arguments[_]);return"Minified React error #"+d+"; visit "+v+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var p=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={},C={};function T(d){return p.call(C,d)?!0:p.call(x,d)?!1:y.test(d)?C[d]=!0:(x[d]=!0,!1)}function Q(d,v,_,F,X,K,dA){this.acceptsBooleans=v===2||v===3||v===4,this.attributeName=F,this.attributeNamespace=X,this.mustUseProperty=_,this.propertyName=d,this.type=v,this.sanitizeURL=K,this.removeEmptyString=dA}var D={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(d){D[d]=new Q(d,0,!1,d,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(d){var v=d[0];D[v]=new Q(v,1,!1,d[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(d){D[d]=new Q(d,2,!1,d.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(d){D[d]=new Q(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){D[d]=new Q(d,3,!1,d.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(d){D[d]=new Q(d,3,!0,d,null,!1,!1)}),["capture","download"].forEach(function(d){D[d]=new Q(d,4,!1,d,null,!1,!1)}),["cols","rows","size","span"].forEach(function(d){D[d]=new Q(d,6,!1,d,null,!1,!1)}),["rowSpan","start"].forEach(function(d){D[d]=new Q(d,5,!1,d.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function P(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 v=d.replace(E,P);D[v]=new Q(v,1,!1,d,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(d){var v=d.replace(E,P);D[v]=new Q(v,1,!1,d,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(d){var v=d.replace(E,P);D[v]=new Q(v,1,!1,d,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(d){D[d]=new Q(d,1,!1,d.toLowerCase(),null,!1,!1)}),D.xlinkHref=new Q("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(d){D[d]=new Q(d,1,!1,d.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(d){z.forEach(function(v){v=v+d.charAt(0).toUpperCase()+d.substring(1),O[v]=O[d]})});var V=/["'&<>]/;function W(d){if(typeof d=="boolean"||typeof d=="number")return""+d;d=""+d;var v=V.exec(d);if(v){var _="",F,X=0;for(F=v.index;F<d.length;F++){switch(d.charCodeAt(F)){case 34:v="&quot;";break;case 38:v="&amp;";break;case 39:v="&#x27;";break;case 60:v="&lt;";break;case 62:v="&gt;";break;default:continue}X!==F&&(_+=d.substring(X,F)),X=F+1,_+=v}d=X!==F?_+d.substring(X,F):_}return d}var oA=/([A-Z])/g,J=/^ms-/,eA=Array.isArray;function Z(d,v){return{insertionMode:d,selectedValue:v}}function uA(d,v,_){switch(v){case"select":return Z(1,_.value!=null?_.value:_.defaultValue);case"svg":return Z(2,null);case"math":return Z(3,null);case"foreignObject":return Z(1,null);case"table":return Z(4,null);case"thead":case"tbody":case"tfoot":return Z(5,null);case"colgroup":return Z(7,null);case"tr":return Z(6,null)}return 4<=d.insertionMode||d.insertionMode===0?Z(1,null):d}var sA=new Map;function vA(d,v,_){if(typeof _!="object")throw Error(u(62));v=!0;for(var F in _)if(p.call(_,F)){var X=_[F];if(X!=null&&typeof X!="boolean"&&X!==""){if(F.indexOf("--")===0){var K=W(F);X=W((""+X).trim())}else{K=F;var dA=sA.get(K);dA!==void 0||(dA=W(K.replace(oA,"-$1").toLowerCase().replace(J,"-ms-")),sA.set(K,dA)),K=dA,X=typeof X=="number"?X===0||p.call(O,F)?""+X:X+"px":W((""+X).trim())}v?(v=!1,d.push(' style="',K,":",X)):d.push(";",K,":",X)}}v||d.push('"')}function iA(d,v,_,F){switch(_){case"style":vA(d,v,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(v=D.hasOwnProperty(_)?D[_]:null,v!==null){switch(typeof F){case"function":case"symbol":return;case"boolean":if(!v.acceptsBooleans)return}switch(_=v.attributeName,v.type){case 3:F&&d.push(" ",_,'=""');break;case 4:F===!0?d.push(" ",_,'=""'):F!==!1&&d.push(" ",_,'="',W(F),'"');break;case 5:isNaN(F)||d.push(" ",_,'="',W(F),'"');break;case 6:!isNaN(F)&&1<=F&&d.push(" ",_,'="',W(F),'"');break;default:v.sanitizeURL&&(F=""+F),d.push(" ",_,'="',W(F),'"')}}else if(T(_)){switch(typeof F){case"function":case"symbol":return;case"boolean":if(v=_.toLowerCase().slice(0,5),v!=="data-"&&v!=="aria-")return}d.push(" ",_,'="',W(F),'"')}}}function fA(d,v,_){if(v!=null){if(_!=null)throw Error(u(60));if(typeof v!="object"||!("__html"in v))throw Error(u(61));v=v.__html,v!=null&&d.push(""+v)}}function RA(d){var v="";return c.Children.forEach(d,function(_){_!=null&&(v+=_)}),v}function DA(d,v,_,F){d.push(bA(_));var X=_=null,K;for(K in v)if(p.call(v,K)){var dA=v[K];if(dA!=null)switch(K){case"children":_=dA;break;case"dangerouslySetInnerHTML":X=dA;break;default:iA(d,F,K,dA)}}return d.push(">"),fA(d,X,_),typeof _=="string"?(d.push(W(_)),null):_}var EA=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,yA=new Map;function bA(d){var v=yA.get(d);if(v===void 0){if(!EA.test(d))throw Error(u(65,d));v="<"+d,yA.set(d,v)}return v}function LA(d,v,_,F,X){switch(v){case"select":d.push(bA("select"));var K=null,dA=null;for(ce in _)if(p.call(_,ce)){var jA=_[ce];if(jA!=null)switch(ce){case"children":K=jA;break;case"dangerouslySetInnerHTML":dA=jA;break;case"defaultValue":case"value":break;default:iA(d,F,ce,jA)}}return d.push(">"),fA(d,dA,K),K;case"option":dA=X.selectedValue,d.push(bA("option"));var XA=jA=null,Ae=null,ce=null;for(K in _)if(p.call(_,K)){var Ge=_[K];if(Ge!=null)switch(K){case"children":jA=Ge;break;case"selected":Ae=Ge;break;case"dangerouslySetInnerHTML":ce=Ge;break;case"value":XA=Ge;default:iA(d,F,K,Ge)}}if(dA!=null)if(_=XA!==null?""+XA:RA(jA),eA(dA)){for(F=0;F<dA.length;F++)if(""+dA[F]===_){d.push(' selected=""');break}}else""+dA===_&&d.push(' selected=""');else Ae&&d.push(' selected=""');return d.push(">"),fA(d,ce,jA),jA;case"textarea":d.push(bA("textarea")),ce=dA=K=null;for(jA in _)if(p.call(_,jA)&&(XA=_[jA],XA!=null))switch(jA){case"children":ce=XA;break;case"value":K=XA;break;case"defaultValue":dA=XA;break;case"dangerouslySetInnerHTML":throw Error(u(91));default:iA(d,F,jA,XA)}if(K===null&&dA!==null&&(K=dA),d.push(">"),ce!=null){if(K!=null)throw Error(u(92));if(eA(ce)&&1<ce.length)throw Error(u(93));K=""+ce}return typeof K=="string"&&K[0]===`
`&&d.push(`
`),K!==null&&d.push(W(""+K)),null;case"input":d.push(bA("input")),XA=ce=jA=K=null;for(dA in _)if(p.call(_,dA)&&(Ae=_[dA],Ae!=null))switch(dA){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,"input"));case"defaultChecked":XA=Ae;break;case"defaultValue":jA=Ae;break;case"checked":ce=Ae;break;case"value":K=Ae;break;default:iA(d,F,dA,Ae)}return ce!==null?iA(d,F,"checked",ce):XA!==null&&iA(d,F,"checked",XA),K!==null?iA(d,F,"value",K):jA!==null&&iA(d,F,"value",jA),d.push("/>"),null;case"menuitem":d.push(bA("menuitem"));for(var kt in _)if(p.call(_,kt)&&(K=_[kt],K!=null))switch(kt){case"children":case"dangerouslySetInnerHTML":throw Error(u(400));default:iA(d,F,kt,K)}return d.push(">"),null;case"title":d.push(bA("title")),K=null;for(Ge in _)if(p.call(_,Ge)&&(dA=_[Ge],dA!=null))switch(Ge){case"children":K=dA;break;case"dangerouslySetInnerHTML":throw Error(u(434));default:iA(d,F,Ge,dA)}return d.push(">"),K;case"listing":case"pre":d.push(bA(v)),dA=K=null;for(XA in _)if(p.call(_,XA)&&(jA=_[XA],jA!=null))switch(XA){case"children":K=jA;break;case"dangerouslySetInnerHTML":dA=jA;break;default:iA(d,F,XA,jA)}if(d.push(">"),dA!=null){if(K!=null)throw Error(u(60));if(typeof dA!="object"||!("__html"in dA))throw Error(u(61));_=dA.__html,_!=null&&(typeof _=="string"&&0<_.length&&_[0]===`
`?d.push(`
`,_):d.push(""+_))}return typeof K=="string"&&K[0]===`
`&&d.push(`
`),K;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":d.push(bA(v));for(var Ct in _)if(p.call(_,Ct)&&(K=_[Ct],K!=null))switch(Ct){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,v));default:iA(d,F,Ct,K)}return d.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 DA(d,_,v,F);case"html":return X.insertionMode===0&&d.push("<!DOCTYPE html>"),DA(d,_,v,F);default:if(v.indexOf("-")===-1&&typeof _.is!="string")return DA(d,_,v,F);d.push(bA(v)),dA=K=null;for(Ae in _)if(p.call(_,Ae)&&(jA=_[Ae],jA!=null))switch(Ae){case"children":K=jA;break;case"dangerouslySetInnerHTML":dA=jA;break;case"style":vA(d,F,jA);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:T(Ae)&&typeof jA!="function"&&typeof jA!="symbol"&&d.push(" ",Ae,'="',W(jA),'"')}return d.push(">"),fA(d,dA,K),K}}function NA(d,v,_){if(d.push('<!--$?--><template id="'),_===null)throw Error(u(395));return d.push(_),d.push('"></template>')}function GA(d,v,_,F){switch(_.insertionMode){case 0:case 1:return d.push('<div hidden id="'),d.push(v.segmentPrefix),v=F.toString(16),d.push(v),d.push('">');case 2:return d.push('<svg aria-hidden="true" style="display:none" id="'),d.push(v.segmentPrefix),v=F.toString(16),d.push(v),d.push('">');case 3:return d.push('<math aria-hidden="true" style="display:none" id="'),d.push(v.segmentPrefix),v=F.toString(16),d.push(v),d.push('">');case 4:return d.push('<table hidden id="'),d.push(v.segmentPrefix),v=F.toString(16),d.push(v),d.push('">');case 5:return d.push('<table hidden><tbody id="'),d.push(v.segmentPrefix),v=F.toString(16),d.push(v),d.push('">');case 6:return d.push('<table hidden><tr id="'),d.push(v.segmentPrefix),v=F.toString(16),d.push(v),d.push('">');case 7:return d.push('<table hidden><colgroup id="'),d.push(v.segmentPrefix),v=F.toString(16),d.push(v),d.push('">');default:throw Error(u(397))}}function kA(d,v){switch(v.insertionMode){case 0:case 1:return d.push("</div>");case 2:return d.push("</svg>");case 3:return d.push("</math>");case 4:return d.push("</table>");case 5:return d.push("</tbody></table>");case 6:return d.push("</tr></table>");case 7:return d.push("</colgroup></table>");default:throw Error(u(397))}}var cA=/[<\u2028\u2029]/g;function lA(d){return JSON.stringify(d).replace(cA,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 TA(d,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:d}}function MA(d,v,_,F){return _.generateStaticMarkup?(d.push(W(v)),!1):(v===""?d=F:(F&&d.push("<!-- -->"),d.push(W(v)),d=!0),d)}var WA=Object.assign,ae=Symbol.for("react.element"),JA=Symbol.for("react.portal"),ZA=Symbol.for("react.fragment"),UA=Symbol.for("react.strict_mode"),Ie=Symbol.for("react.profiler"),Le=Symbol.for("react.provider"),se=Symbol.for("react.context"),me=Symbol.for("react.forward_ref"),ue=Symbol.for("react.suspense"),Ye=Symbol.for("react.suspense_list"),ke=Symbol.for("react.memo"),Ce=Symbol.for("react.lazy"),Se=Symbol.for("react.scope"),pe=Symbol.for("react.debug_trace_mode"),Ke=Symbol.for("react.legacy_hidden"),$e=Symbol.for("react.default_value"),qe=Symbol.iterator;function Xe(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 ZA:return"Fragment";case JA:return"Portal";case Ie:return"Profiler";case UA:return"StrictMode";case ue:return"Suspense";case Ye:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case se:return(d.displayName||"Context")+".Consumer";case Le:return(d._context.displayName||"Context")+".Provider";case me:var v=d.render;return d=d.displayName,d||(d=v.displayName||v.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case ke:return v=d.displayName||null,v!==null?v:Xe(d.type)||"Memo";case Ce:v=d._payload,d=d._init;try{return Xe(d(v))}catch{}}return null}var vt={};function Qe(d,v){if(d=d.contextTypes,!d)return vt;var _={},F;for(F in d)_[F]=v[F];return _}var Je=null;function Be(d,v){if(d!==v){d.context._currentValue2=d.parentValue,d=d.parent;var _=v.parent;if(d===null){if(_!==null)throw Error(u(401))}else{if(_===null)throw Error(u(401));Be(d,_)}v.context._currentValue2=v.value}}function ze(d){d.context._currentValue2=d.parentValue,d=d.parent,d!==null&&ze(d)}function ot(d){var v=d.parent;v!==null&&ot(v),d.context._currentValue2=d.value}function Rt(d,v){if(d.context._currentValue2=d.parentValue,d=d.parent,d===null)throw Error(u(402));d.depth===v.depth?Be(d,v):Rt(d,v)}function b0(d,v){var _=v.parent;if(_===null)throw Error(u(402));d.depth===_.depth?Be(d,_):b0(d,_),v.context._currentValue2=v.value}function Yt(d){var v=Je;v!==d&&(v===null?ot(d):d===null?ze(v):v.depth===d.depth?Be(v,d):v.depth>d.depth?Rt(v,d):b0(v,d),Je=d)}var Kt={isMounted:function(){return!1},enqueueSetState:function(d,v){d=d._reactInternals,d.queue!==null&&d.queue.push(v)},enqueueReplaceState:function(d,v){d=d._reactInternals,d.replace=!0,d.queue=[v]},enqueueForceUpdate:function(){}};function L0(d,v,_,F){var X=d.state!==void 0?d.state:null;d.updater=Kt,d.props=_,d.state=X;var K={queue:[],replace:!1};d._reactInternals=K;var dA=v.contextType;if(d.context=typeof dA=="object"&&dA!==null?dA._currentValue2:F,dA=v.getDerivedStateFromProps,typeof dA=="function"&&(dA=dA(_,X),X=dA==null?X:WA({},X,dA),d.state=X),typeof v.getDerivedStateFromProps!="function"&&typeof d.getSnapshotBeforeUpdate!="function"&&(typeof d.UNSAFE_componentWillMount=="function"||typeof d.componentWillMount=="function"))if(v=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),v!==d.state&&Kt.enqueueReplaceState(d,d.state,null),K.queue!==null&&0<K.queue.length)if(v=K.queue,dA=K.replace,K.queue=null,K.replace=!1,dA&&v.length===1)d.state=v[0];else{for(K=dA?v[0]:d.state,X=!0,dA=dA?1:0;dA<v.length;dA++){var jA=v[dA];jA=typeof jA=="function"?jA.call(d,K,_,F):jA,jA!=null&&(X?(X=!1,K=WA({},K,jA)):WA(K,jA))}d.state=K}else K.queue=null}var er={id:1,overflow:""};function k0(d,v,_){var F=d.id;d=d.overflow;var X=32-zt(F)-1;F&=~(1<<X),_+=1;var K=32-zt(v)+X;if(30<K){var dA=X-X%5;return K=(F&(1<<dA)-1).toString(32),F>>=dA,X-=dA,{id:1<<32-zt(v)+X|_<<X|F,overflow:K+d}}return{id:1<<K|_<<X|F,overflow:d}}var zt=Math.clz32?Math.clz32:f0,C0=Math.log,tr=Math.LN2;function f0(d){return d>>>=0,d===0?32:31-(C0(d)/tr|0)|0}function rr(d,v){return d===v&&(d!==0||1/d===1/v)||d!==d&&v!==v}var N0=typeof Object.is=="function"?Object.is:rr,gA=null,d0=null,at=null,Fe=null,i0=!1,Zt=!1,xt=0,bt=null,o0=0;function wt(){if(gA===null)throw Error(u(321));return gA}function It(){if(0<o0)throw Error(u(312));return{memoizedState:null,queue:null,next:null}}function ht(){return Fe===null?at===null?(i0=!1,at=Fe=It()):(i0=!0,Fe=at):Fe.next===null?(i0=!1,Fe=Fe.next=It()):(i0=!0,Fe=Fe.next),Fe}function rA(){d0=gA=null,Zt=!1,at=null,o0=0,Fe=bt=null}function pA(d,v){return typeof v=="function"?v(d):v}function IA(d,v,_){if(gA=wt(),Fe=ht(),i0){var F=Fe.queue;if(v=F.dispatch,bt!==null&&(_=bt.get(F),_!==void 0)){bt.delete(F),F=Fe.memoizedState;do F=d(F,_.action),_=_.next;while(_!==null);return Fe.memoizedState=F,[F,v]}return[Fe.memoizedState,v]}return d=d===pA?typeof v=="function"?v():v:_!==void 0?_(v):v,Fe.memoizedState=d,d=Fe.queue={last:null,dispatch:null},d=d.dispatch=t.bind(null,gA,d),[Fe.memoizedState,d]}function xA(d,v){if(gA=wt(),Fe=ht(),v=v===void 0?null:v,Fe!==null){var _=Fe.memoizedState;if(_!==null&&v!==null){var F=_[1];A:if(F===null)F=!1;else{for(var X=0;X<F.length&&X<v.length;X++)if(!N0(v[X],F[X])){F=!1;break A}F=!0}if(F)return _[0]}}return d=d(),Fe.memoizedState=[d,v],d}function t(d,v,_){if(25<=o0)throw Error(u(301));if(d===gA)if(Zt=!0,d={action:_,next:null},bt===null&&(bt=new Map),_=bt.get(v),_===void 0)bt.set(v,d);else{for(v=_;v.next!==null;)v=v.next;v.next=d}}function k(){throw Error(u(394))}function ge(){}var De={readContext:function(d){return d._currentValue2},useContext:function(d){return wt(),d._currentValue2},useMemo:xA,useReducer:IA,useRef:function(d){gA=wt(),Fe=ht();var v=Fe.memoizedState;return v===null?(d={current:d},Fe.memoizedState=d):v},useState:function(d){return IA(pA,d)},useInsertionEffect:ge,useLayoutEffect:function(){},useCallback:function(d,v){return xA(function(){return d},v)},useImperativeHandle:ge,useEffect:ge,useDebugValue:ge,useDeferredValue:function(d){return wt(),d},useTransition:function(){return wt(),[!1,k]},useId:function(){var d=d0.treeContext,v=d.overflow;d=d.id,d=(d&~(1<<32-zt(d)-1)).toString(32)+v;var _=He;if(_===null)throw Error(u(404));return v=xt++,d=":"+_.idPrefix+"R"+d,0<v&&(d+="H"+v.toString(32)),d+":"},useMutableSource:function(d,v){return wt(),v(d._source)},useSyncExternalStore:function(d,v,_){if(_===void 0)throw Error(u(407));return _()}},He=null,$A=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function ye(d){return console.error(d),null}function lt(){}function _e(d,v,_,F,X,K,dA,jA,XA){var Ae=[],ce=new Set;return v={destination:null,responseState:v,progressiveChunkSize:F===void 0?12800:F,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:ce,pingedTasks:Ae,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:X===void 0?ye:X,onAllReady:lt,onShellReady:dA===void 0?lt:dA,onShellError:lt,onFatalError:lt},_=et(v,0,null,_,!1,!1),_.parentFlushed=!0,d=ie(v,d,null,_,ce,vt,null,er),Ae.push(d),v}function ie(d,v,_,F,X,K,dA,jA){d.allPendingTasks++,_===null?d.pendingRootTasks++:_.pendingTasks++;var XA={node:v,ping:function(){var Ae=d.pingedTasks;Ae.push(XA),Ae.length===1&&P0(d)},blockedBoundary:_,blockedSegment:F,abortSet:X,legacyContext:K,context:dA,treeContext:jA};return X.add(XA),XA}function et(d,v,_,F,X,K){return{status:0,id:-1,index:v,parentFlushed:!1,chunks:[],children:[],formatContext:F,boundary:_,lastPushedText:X,textEmbedded:K}}function Lt(d,v){if(d=d.onError(v),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 h0(d,v){var _=d.onShellError;_(v),_=d.onFatalError,_(v),d.destination!==null?(d.status=2,d.destination.destroy(v)):(d.status=1,d.fatalError=v)}function mt(d,v,_,F,X){for(gA={},d0=v,xt=0,d=_(F,X);Zt;)Zt=!1,xt=0,o0+=1,Fe=null,d=_(F,X);return rA(),d}function Te(d,v,_,F){var X=_.render(),K=F.childContextTypes;if(K!=null){var dA=v.legacyContext;if(typeof _.getChildContext!="function")F=dA;else{_=_.getChildContext();for(var jA in _)if(!(jA in K))throw Error(u(108,Xe(F)||"Unknown",jA));F=WA({},dA,_)}v.legacyContext=F,At(d,v,X),v.legacyContext=dA}else At(d,v,X)}function gt(d,v){if(d&&d.defaultProps){v=WA({},v),d=d.defaultProps;for(var _ in d)v[_]===void 0&&(v[_]=d[_]);return v}return v}function Pe(d,v,_,F,X){if(typeof _=="function")if(_.prototype&&_.prototype.isReactComponent){X=Qe(_,v.legacyContext);var K=_.contextType;K=new _(F,typeof K=="object"&&K!==null?K._currentValue2:X),L0(K,_,F,X),Te(d,v,K,_)}else{K=Qe(_,v.legacyContext),X=mt(d,v,_,F,K);var dA=xt!==0;if(typeof X=="object"&&X!==null&&typeof X.render=="function"&&X.$$typeof===void 0)L0(X,_,F,K),Te(d,v,X,_);else if(dA){F=v.treeContext,v.treeContext=k0(F,1,0);try{At(d,v,X)}finally{v.treeContext=F}}else At(d,v,X)}else if(typeof _=="string"){switch(X=v.blockedSegment,K=LA(X.chunks,_,F,d.responseState,X.formatContext),X.lastPushedText=!1,dA=X.formatContext,X.formatContext=uA(dA,_,F),nt(d,v,K),X.formatContext=dA,_){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":break;default:X.chunks.push("</",_,">")}X.lastPushedText=!1}else{switch(_){case Ke:case pe:case UA:case Ie:case ZA:At(d,v,F.children);return;case Ye:At(d,v,F.children);return;case Se:throw Error(u(343));case ue:A:{_=v.blockedBoundary,X=v.blockedSegment,K=F.fallback,F=F.children,dA=new Set;var jA={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:dA,errorDigest:null},XA=et(d,X.chunks.length,jA,X.formatContext,!1,!1);X.children.push(XA),X.lastPushedText=!1;var Ae=et(d,0,null,X.formatContext,!1,!1);Ae.parentFlushed=!0,v.blockedBoundary=jA,v.blockedSegment=Ae;try{if(nt(d,v,F),d.responseState.generateStaticMarkup||Ae.lastPushedText&&Ae.textEmbedded&&Ae.chunks.push("<!-- -->"),Ae.status=1,OA(jA,Ae),jA.pendingTasks===0)break A}catch(ce){Ae.status=4,jA.forceClientRender=!0,jA.errorDigest=Lt(d,ce)}finally{v.blockedBoundary=_,v.blockedSegment=X}v=ie(d,K,_,XA,dA,v.legacyContext,v.context,v.treeContext),d.pingedTasks.push(v)}return}if(typeof _=="object"&&_!==null)switch(_.$$typeof){case me:if(F=mt(d,v,_.render,F,X),xt!==0){_=v.treeContext,v.treeContext=k0(_,1,0);try{At(d,v,F)}finally{v.treeContext=_}}else At(d,v,F);return;case ke:_=_.type,F=gt(_,F),Pe(d,v,_,F,X);return;case Le:if(X=F.children,_=_._context,F=F.value,K=_._currentValue2,_._currentValue2=F,dA=Je,Je=F={parent:dA,depth:dA===null?0:dA.depth+1,context:_,parentValue:K,value:F},v.context=F,At(d,v,X),d=Je,d===null)throw Error(u(403));F=d.parentValue,d.context._currentValue2=F===$e?d.context._defaultValue:F,d=Je=d.parent,v.context=d;return;case se:F=F.children,F=F(_._currentValue2),At(d,v,F);return;case Ce:X=_._init,_=X(_._payload),F=gt(_,F),Pe(d,v,_,F,void 0);return}throw Error(u(130,_==null?_:typeof _,""))}}function At(d,v,_){if(v.node=_,typeof _=="object"&&_!==null){switch(_.$$typeof){case ae:Pe(d,v,_.type,_.props,_.ref);return;case JA:throw Error(u(257));case Ce:var F=_._init;_=F(_._payload),At(d,v,_);return}if(eA(_)){F0(d,v,_);return}if(_===null||typeof _!="object"?F=null:(F=qe&&_[qe]||_["@@iterator"],F=typeof F=="function"?F:null),F&&(F=F.call(_))){if(_=F.next(),!_.done){var X=[];do X.push(_.value),_=F.next();while(!_.done);F0(d,v,X)}return}throw d=Object.prototype.toString.call(_),Error(u(31,d==="[object Object]"?"object with keys {"+Object.keys(_).join(", ")+"}":d))}typeof _=="string"?(F=v.blockedSegment,F.lastPushedText=MA(v.blockedSegment.chunks,_,d.responseState,F.lastPushedText)):typeof _=="number"&&(F=v.blockedSegment,F.lastPushedText=MA(v.blockedSegment.chunks,""+_,d.responseState,F.lastPushedText))}function F0(d,v,_){for(var F=_.length,X=0;X<F;X++){var K=v.treeContext;v.treeContext=k0(K,F,X);try{nt(d,v,_[X])}finally{v.treeContext=K}}}function nt(d,v,_){var F=v.blockedSegment.formatContext,X=v.legacyContext,K=v.context;try{return At(d,v,_)}catch(XA){if(rA(),typeof XA=="object"&&XA!==null&&typeof XA.then=="function"){_=XA;var dA=v.blockedSegment,jA=et(d,dA.chunks.length,null,dA.formatContext,dA.lastPushedText,!0);dA.children.push(jA),dA.lastPushedText=!1,d=ie(d,v.node,v.blockedBoundary,jA,v.abortSet,v.legacyContext,v.context,v.treeContext).ping,_.then(d,d),v.blockedSegment.formatContext=F,v.legacyContext=X,v.context=K,Yt(K)}else throw v.blockedSegment.formatContext=F,v.legacyContext=X,v.context=K,Yt(K),XA}}function YA(d){var v=d.blockedBoundary;d=d.blockedSegment,d.status=3,Nt(this,v,d)}function S(d,v,_){var F=d.blockedBoundary;d.blockedSegment.status=3,F===null?(v.allPendingTasks--,v.status!==2&&(v.status=2,v.destination!==null&&v.destination.push(null))):(F.pendingTasks--,F.forceClientRender||(F.forceClientRender=!0,d=_===void 0?Error(u(432)):_,F.errorDigest=v.onError(d),F.parentFlushed&&v.clientRenderedBoundaries.push(F)),F.fallbackAbortableTasks.forEach(function(X){return S(X,v,_)}),F.fallbackAbortableTasks.clear(),v.allPendingTasks--,v.allPendingTasks===0&&(F=v.onAllReady,F()))}function OA(d,v){if(v.chunks.length===0&&v.children.length===1&&v.children[0].boundary===null){var _=v.children[0];_.id=v.id,_.parentFlushed=!0,_.status===1&&OA(d,_)}else d.completedSegments.push(v)}function Nt(d,v,_){if(v===null){if(_.parentFlushed){if(d.completedRootSegment!==null)throw Error(u(389));d.completedRootSegment=_}d.pendingRootTasks--,d.pendingRootTasks===0&&(d.onShellError=lt,v=d.onShellReady,v())}else v.pendingTasks--,v.forceClientRender||(v.pendingTasks===0?(_.parentFlushed&&_.status===1&&OA(v,_),v.parentFlushed&&d.completedBoundaries.push(v),v.fallbackAbortableTasks.forEach(YA,d),v.fallbackAbortableTasks.clear()):_.parentFlushed&&_.status===1&&(OA(v,_),v.completedSegments.length===1&&v.parentFlushed&&d.partialBoundaries.push(v)));d.allPendingTasks--,d.allPendingTasks===0&&(d=d.onAllReady,d())}function P0(d){if(d.status!==2){var v=Je,_=$A.current;$A.current=De;var F=He;He=d.responseState;try{var X=d.pingedTasks,K;for(K=0;K<X.length;K++){var dA=X[K],jA=d,XA=dA.blockedSegment;if(XA.status===0){Yt(dA.context);try{At(jA,dA,dA.node),jA.responseState.generateStaticMarkup||XA.lastPushedText&&XA.textEmbedded&&XA.chunks.push("<!-- -->"),dA.abortSet.delete(dA),XA.status=1,Nt(jA,dA.blockedBoundary,XA)}catch(pt){if(rA(),typeof pt=="object"&&pt!==null&&typeof pt.then=="function"){var Ae=dA.ping;pt.then(Ae,Ae)}else{dA.abortSet.delete(dA),XA.status=4;var ce=dA.blockedBoundary,Ge=pt,kt=Lt(jA,Ge);if(ce===null?h0(jA,Ge):(ce.pendingTasks--,ce.forceClientRender||(ce.forceClientRender=!0,ce.errorDigest=kt,ce.parentFlushed&&jA.clientRenderedBoundaries.push(ce))),jA.allPendingTasks--,jA.allPendingTasks===0){var Ct=jA.onAllReady;Ct()}}}finally{}}}X.splice(0,K),d.destination!==null&&$t(d,d.destination)}catch(pt){Lt(d,pt),h0(d,pt)}finally{He=F,$A.current=_,_===De&&Yt(v)}}}function l0(d,v,_){switch(_.parentFlushed=!0,_.status){case 0:var F=_.id=d.nextSegmentId++;return _.lastPushedText=!1,_.textEmbedded=!1,d=d.responseState,v.push('<template id="'),v.push(d.placeholderPrefix),d=F.toString(16),v.push(d),v.push('"></template>');case 1:_.status=2;var X=!0;F=_.chunks;var K=0;_=_.children;for(var dA=0;dA<_.length;dA++){for(X=_[dA];K<X.index;K++)v.push(F[K]);X=a0(d,v,X)}for(;K<F.length-1;K++)v.push(F[K]);return K<F.length&&(X=v.push(F[K])),X;default:throw Error(u(390))}}function a0(d,v,_){var F=_.boundary;if(F===null)return l0(d,v,_);if(F.parentFlushed=!0,F.forceClientRender)return d.responseState.generateStaticMarkup||(F=F.errorDigest,v.push("<!--$!-->"),v.push("<template"),F&&(v.push(' data-dgst="'),F=W(F),v.push(F),v.push('"')),v.push("></template>")),l0(d,v,_),d=d.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),d;if(0<F.pendingTasks){F.rootSegmentID=d.nextSegmentId++,0<F.completedSegments.length&&d.partialBoundaries.push(F);var X=d.responseState,K=X.nextSuspenseID++;return X=X.boundaryPrefix+K.toString(16),F=F.id=X,NA(v,d.responseState,F),l0(d,v,_),v.push("<!--/$-->")}if(F.byteSize>d.progressiveChunkSize)return F.rootSegmentID=d.nextSegmentId++,d.completedBoundaries.push(F),NA(v,d.responseState,F.id),l0(d,v,_),v.push("<!--/$-->");if(d.responseState.generateStaticMarkup||v.push("<!--$-->"),_=F.completedSegments,_.length!==1)throw Error(u(391));return a0(d,v,_[0]),d=d.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),d}function m0(d,v,_){return GA(v,d.responseState,_.formatContext,_.id),a0(d,v,_),kA(v,_.formatContext)}function b(d,v,_){for(var F=_.completedSegments,X=0;X<F.length;X++)E0(d,v,_,F[X]);if(F.length=0,d=d.responseState,F=_.id,_=_.rootSegmentID,v.push(d.startInlineScript),d.sentCompleteBoundaryFunction?v.push('$RC("'):(d.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("')),F===null)throw Error(u(395));return _=_.toString(16),v.push(F),v.push('","'),v.push(d.segmentPrefix),v.push(_),v.push('")<\/script>')}function E0(d,v,_,F){if(F.status===2)return!0;var X=F.id;if(X===-1){if((F.id=_.rootSegmentID)===-1)throw Error(u(392));return m0(d,v,F)}return m0(d,v,F),d=d.responseState,v.push(d.startInlineScript),d.sentCompleteSegmentFunction?v.push('$RS("'):(d.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(d.segmentPrefix),X=X.toString(16),v.push(X),v.push('","'),v.push(d.placeholderPrefix),v.push(X),v.push('")<\/script>')}function $t(d,v){try{var _=d.completedRootSegment;if(_!==null&&d.pendingRootTasks===0){a0(d,v,_),d.completedRootSegment=null;var F=d.responseState.bootstrapChunks;for(_=0;_<F.length-1;_++)v.push(F[_]);_<F.length&&v.push(F[_])}var X=d.clientRenderedBoundaries,K;for(K=0;K<X.length;K++){var dA=X[K];F=v;var jA=d.responseState,XA=dA.id,Ae=dA.errorDigest,ce=dA.errorMessage,Ge=dA.errorComponentStack;if(F.push(jA.startInlineScript),jA.sentClientRenderFunction?F.push('$RX("'):(jA.sentClientRenderFunction=!0,F.push('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("')),XA===null)throw Error(u(395));if(F.push(XA),F.push('"'),Ae||ce||Ge){F.push(",");var kt=lA(Ae||"");F.push(kt)}if(ce||Ge){F.push(",");var Ct=lA(ce||"");F.push(Ct)}if(Ge){F.push(",");var pt=lA(Ge);F.push(pt)}if(!F.push(")<\/script>")){d.destination=null,K++,X.splice(0,K);return}}X.splice(0,K);var je=d.completedBoundaries;for(K=0;K<je.length;K++)if(!b(d,v,je[K])){d.destination=null,K++,je.splice(0,K);return}je.splice(0,K);var Et=d.partialBoundaries;for(K=0;K<Et.length;K++){var g0=Et[K];A:{X=d,dA=v;var u0=g0.completedSegments;for(jA=0;jA<u0.length;jA++)if(!E0(X,dA,g0,u0[jA])){jA++,u0.splice(0,jA);var z0=!1;break A}u0.splice(0,jA),z0=!0}if(!z0){d.destination=null,K++,Et.splice(0,K);return}}Et.splice(0,K);var qt=d.completedBoundaries;for(K=0;K<qt.length;K++)if(!b(d,v,qt[K])){d.destination=null,K++,qt.splice(0,K);return}qt.splice(0,K)}finally{d.allPendingTasks===0&&d.pingedTasks.length===0&&d.clientRenderedBoundaries.length===0&&d.completedBoundaries.length===0&&v.push(null)}}function Q0(d,v){try{var _=d.abortableTasks;_.forEach(function(F){return S(F,d,v)}),_.clear(),d.destination!==null&&$t(d,d.destination)}catch(F){Lt(d,F),h0(d,F)}}function O0(){}function S0(d,v,_,F){var X=!1,K=null,dA="",jA={push:function(Ae){return Ae!==null&&(dA+=Ae),!0},destroy:function(Ae){X=!0,K=Ae}},XA=!1;if(d=_e(d,TA(_,v?v.identifierPrefix:void 0),{insertionMode:1,selectedValue:null},1/0,O0,void 0,function(){XA=!0}),P0(d),Q0(d,F),d.status===1)d.status=2,jA.destroy(d.fatalError);else if(d.status!==2&&d.destination===null){d.destination=jA;try{$t(d,jA)}catch(Ae){Lt(d,Ae),h0(d,Ae)}}if(X)throw K;if(!XA)throw Error(u(426));return dA}return mr.renderToNodeStream=function(){throw Error(u(207))},mr.renderToStaticMarkup=function(d,v){return S0(d,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')},mr.renderToStaticNodeStream=function(){throw Error(u(208))},mr.renderToString=function(d,v){return S0(d,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')},mr.version="18.3.1",mr}var Qn={};/**
 * @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 so;function m1(){if(so)return Qn;so=1;var c=To();function u(h){for(var w="https://reactjs.org/docs/error-decoder.html?invariant="+h,B=1;B<arguments.length;B++)w+="&args[]="+encodeURIComponent(arguments[B]);return"Minified React error #"+h+"; visit "+w+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var p=null,y=0;function x(h,w){if(w.length!==0)if(512<w.length)0<y&&(h.enqueue(new Uint8Array(p.buffer,0,y)),p=new Uint8Array(512),y=0),h.enqueue(w);else{var B=p.length-y;B<w.length&&(B===0?h.enqueue(p):(p.set(w.subarray(0,B),y),h.enqueue(p),w=w.subarray(B)),p=new Uint8Array(512),y=0),p.set(w,y),y+=w.length}}function C(h,w){return x(h,w),!0}function T(h){p&&0<y&&(h.enqueue(new Uint8Array(p.buffer,0,y)),p=null,y=0)}var Q=new TextEncoder;function D(h){return Q.encode(h)}function E(h){return Q.encode(h)}function P(h,w){typeof h.error=="function"?h.error(w):h.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]*$/,V={},W={};function oA(h){return O.call(W,h)?!0:O.call(V,h)?!1:z.test(h)?W[h]=!0:(V[h]=!0,!1)}function J(h,w,B,N,tA,AA,hA){this.acceptsBooleans=w===2||w===3||w===4,this.attributeName=N,this.attributeNamespace=tA,this.mustUseProperty=B,this.propertyName=h,this.type=w,this.sanitizeURL=AA,this.removeEmptyString=hA}var eA={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(h){eA[h]=new J(h,0,!1,h,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(h){var w=h[0];eA[w]=new J(w,1,!1,h[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(h){eA[h]=new J(h,2,!1,h.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(h){eA[h]=new J(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){eA[h]=new J(h,3,!1,h.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(h){eA[h]=new J(h,3,!0,h,null,!1,!1)}),["capture","download"].forEach(function(h){eA[h]=new J(h,4,!1,h,null,!1,!1)}),["cols","rows","size","span"].forEach(function(h){eA[h]=new J(h,6,!1,h,null,!1,!1)}),["rowSpan","start"].forEach(function(h){eA[h]=new J(h,5,!1,h.toLowerCase(),null,!1,!1)});var Z=/[\-:]([a-z])/g;function uA(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 w=h.replace(Z,uA);eA[w]=new J(w,1,!1,h,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(h){var w=h.replace(Z,uA);eA[w]=new J(w,1,!1,h,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(h){var w=h.replace(Z,uA);eA[w]=new J(w,1,!1,h,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(h){eA[h]=new J(h,1,!1,h.toLowerCase(),null,!1,!1)}),eA.xlinkHref=new J("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(h){eA[h]=new J(h,1,!1,h.toLowerCase(),null,!0,!0)});var sA={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},vA=["Webkit","ms","Moz","O"];Object.keys(sA).forEach(function(h){vA.forEach(function(w){w=w+h.charAt(0).toUpperCase()+h.substring(1),sA[w]=sA[h]})});var iA=/["'&<>]/;function fA(h){if(typeof h=="boolean"||typeof h=="number")return""+h;h=""+h;var w=iA.exec(h);if(w){var B="",N,tA=0;for(N=w.index;N<h.length;N++){switch(h.charCodeAt(N)){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}tA!==N&&(B+=h.substring(tA,N)),tA=N+1,B+=w}h=tA!==N?B+h.substring(tA,N):B}return h}var RA=/([A-Z])/g,DA=/^ms-/,EA=Array.isArray,yA=E("<script>"),bA=E("<\/script>"),LA=E('<script src="'),NA=E('<script type="module" src="'),GA=E('" async=""><\/script>'),kA=/(<\/|<)(s)(cript)/gi;function cA(h,w,B,N){return""+w+(B==="s"?"\\u0073":"\\u0053")+N}function lA(h,w,B,N,tA){h=h===void 0?"":h,w=w===void 0?yA:E('<script nonce="'+fA(w)+'">');var AA=[];if(B!==void 0&&AA.push(w,D((""+B).replace(kA,cA)),bA),N!==void 0)for(B=0;B<N.length;B++)AA.push(LA,D(fA(N[B])),GA);if(tA!==void 0)for(N=0;N<tA.length;N++)AA.push(NA,D(fA(tA[N])),GA);return{bootstrapChunks:AA,startInlineScript:w,placeholderPrefix:E(h+"P:"),segmentPrefix:E(h+"S:"),boundaryPrefix:h+"B:",idPrefix:h,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1}}function TA(h,w){return{insertionMode:h,selectedValue:w}}function MA(h){return TA(h==="http://www.w3.org/2000/svg"?2:h==="http://www.w3.org/1998/Math/MathML"?3:0,null)}function WA(h,w,B){switch(w){case"select":return TA(1,B.value!=null?B.value:B.defaultValue);case"svg":return TA(2,null);case"math":return TA(3,null);case"foreignObject":return TA(1,null);case"table":return TA(4,null);case"thead":case"tbody":case"tfoot":return TA(5,null);case"colgroup":return TA(7,null);case"tr":return TA(6,null)}return 4<=h.insertionMode||h.insertionMode===0?TA(1,null):h}var ae=E("<!-- -->");function JA(h,w,B,N){return w===""?N:(N&&h.push(ae),h.push(D(fA(w))),!0)}var ZA=new Map,UA=E(' style="'),Ie=E(":"),Le=E(";");function se(h,w,B){if(typeof B!="object")throw Error(u(62));w=!0;for(var N in B)if(O.call(B,N)){var tA=B[N];if(tA!=null&&typeof tA!="boolean"&&tA!==""){if(N.indexOf("--")===0){var AA=D(fA(N));tA=D(fA((""+tA).trim()))}else{AA=N;var hA=ZA.get(AA);hA!==void 0||(hA=E(fA(AA.replace(RA,"-$1").toLowerCase().replace(DA,"-ms-"))),ZA.set(AA,hA)),AA=hA,tA=typeof tA=="number"?tA===0||O.call(sA,N)?D(""+tA):D(tA+"px"):D(fA((""+tA).trim()))}w?(w=!1,h.push(UA,AA,Ie,tA)):h.push(Le,AA,Ie,tA)}}w||h.push(Ye)}var me=E(" "),ue=E('="'),Ye=E('"'),ke=E('=""');function Ce(h,w,B,N){switch(B){case"style":se(h,w,N);return;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<B.length)||B[0]!=="o"&&B[0]!=="O"||B[1]!=="n"&&B[1]!=="N"){if(w=eA.hasOwnProperty(B)?eA[B]:null,w!==null){switch(typeof N){case"function":case"symbol":return;case"boolean":if(!w.acceptsBooleans)return}switch(B=D(w.attributeName),w.type){case 3:N&&h.push(me,B,ke);break;case 4:N===!0?h.push(me,B,ke):N!==!1&&h.push(me,B,ue,D(fA(N)),Ye);break;case 5:isNaN(N)||h.push(me,B,ue,D(fA(N)),Ye);break;case 6:!isNaN(N)&&1<=N&&h.push(me,B,ue,D(fA(N)),Ye);break;default:w.sanitizeURL&&(N=""+N),h.push(me,B,ue,D(fA(N)),Ye)}}else if(oA(B)){switch(typeof N){case"function":case"symbol":return;case"boolean":if(w=B.toLowerCase().slice(0,5),w!=="data-"&&w!=="aria-")return}h.push(me,D(B),ue,D(fA(N)),Ye)}}}var Se=E(">"),pe=E("/>");function Ke(h,w,B){if(w!=null){if(B!=null)throw Error(u(60));if(typeof w!="object"||!("__html"in w))throw Error(u(61));w=w.__html,w!=null&&h.push(D(""+w))}}function $e(h){var w="";return c.Children.forEach(h,function(B){B!=null&&(w+=B)}),w}var qe=E(' selected=""');function Xe(h,w,B,N){h.push(Be(B));var tA=B=null,AA;for(AA in w)if(O.call(w,AA)){var hA=w[AA];if(hA!=null)switch(AA){case"children":B=hA;break;case"dangerouslySetInnerHTML":tA=hA;break;default:Ce(h,N,AA,hA)}}return h.push(Se),Ke(h,tA,B),typeof B=="string"?(h.push(D(fA(B))),null):B}var vt=E(`
`),Qe=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Je=new Map;function Be(h){var w=Je.get(h);if(w===void 0){if(!Qe.test(h))throw Error(u(65,h));w=E("<"+h),Je.set(h,w)}return w}var ze=E("<!DOCTYPE html>");function ot(h,w,B,N,tA){switch(w){case"select":h.push(Be("select"));var AA=null,hA=null;for(we in B)if(O.call(B,we)){var _A=B[we];if(_A!=null)switch(we){case"children":AA=_A;break;case"dangerouslySetInnerHTML":hA=_A;break;case"defaultValue":case"value":break;default:Ce(h,N,we,_A)}}return h.push(Se),Ke(h,hA,AA),AA;case"option":hA=tA.selectedValue,h.push(Be("option"));var te=_A=null,be=null,we=null;for(AA in B)if(O.call(B,AA)){var Ue=B[AA];if(Ue!=null)switch(AA){case"children":_A=Ue;break;case"selected":be=Ue;break;case"dangerouslySetInnerHTML":we=Ue;break;case"value":te=Ue;default:Ce(h,N,AA,Ue)}}if(hA!=null)if(B=te!==null?""+te:$e(_A),EA(hA)){for(N=0;N<hA.length;N++)if(""+hA[N]===B){h.push(qe);break}}else""+hA===B&&h.push(qe);else be&&h.push(qe);return h.push(Se),Ke(h,we,_A),_A;case"textarea":h.push(Be("textarea")),we=hA=AA=null;for(_A in B)if(O.call(B,_A)&&(te=B[_A],te!=null))switch(_A){case"children":we=te;break;case"value":AA=te;break;case"defaultValue":hA=te;break;case"dangerouslySetInnerHTML":throw Error(u(91));default:Ce(h,N,_A,te)}if(AA===null&&hA!==null&&(AA=hA),h.push(Se),we!=null){if(AA!=null)throw Error(u(92));if(EA(we)&&1<we.length)throw Error(u(93));AA=""+we}return typeof AA=="string"&&AA[0]===`
`&&h.push(vt),AA!==null&&h.push(D(fA(""+AA))),null;case"input":h.push(Be("input")),te=we=_A=AA=null;for(hA in B)if(O.call(B,hA)&&(be=B[hA],be!=null))switch(hA){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,"input"));case"defaultChecked":te=be;break;case"defaultValue":_A=be;break;case"checked":we=be;break;case"value":AA=be;break;default:Ce(h,N,hA,be)}return we!==null?Ce(h,N,"checked",we):te!==null&&Ce(h,N,"checked",te),AA!==null?Ce(h,N,"value",AA):_A!==null&&Ce(h,N,"value",_A),h.push(pe),null;case"menuitem":h.push(Be("menuitem"));for(var Bt in B)if(O.call(B,Bt)&&(AA=B[Bt],AA!=null))switch(Bt){case"children":case"dangerouslySetInnerHTML":throw Error(u(400));default:Ce(h,N,Bt,AA)}return h.push(Se),null;case"title":h.push(Be("title")),AA=null;for(Ue in B)if(O.call(B,Ue)&&(hA=B[Ue],hA!=null))switch(Ue){case"children":AA=hA;break;case"dangerouslySetInnerHTML":throw Error(u(434));default:Ce(h,N,Ue,hA)}return h.push(Se),AA;case"listing":case"pre":h.push(Be(w)),hA=AA=null;for(te in B)if(O.call(B,te)&&(_A=B[te],_A!=null))switch(te){case"children":AA=_A;break;case"dangerouslySetInnerHTML":hA=_A;break;default:Ce(h,N,te,_A)}if(h.push(Se),hA!=null){if(AA!=null)throw Error(u(60));if(typeof hA!="object"||!("__html"in hA))throw Error(u(61));B=hA.__html,B!=null&&(typeof B=="string"&&0<B.length&&B[0]===`
`?h.push(vt,D(B)):h.push(D(""+B)))}return typeof AA=="string"&&AA[0]===`
`&&h.push(vt),AA;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":h.push(Be(w));for(var Dt in B)if(O.call(B,Dt)&&(AA=B[Dt],AA!=null))switch(Dt){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,w));default:Ce(h,N,Dt,AA)}return h.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 Xe(h,B,w,N);case"html":return tA.insertionMode===0&&h.push(ze),Xe(h,B,w,N);default:if(w.indexOf("-")===-1&&typeof B.is!="string")return Xe(h,B,w,N);h.push(Be(w)),hA=AA=null;for(be in B)if(O.call(B,be)&&(_A=B[be],_A!=null))switch(be){case"children":AA=_A;break;case"dangerouslySetInnerHTML":hA=_A;break;case"style":se(h,N,_A);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:oA(be)&&typeof _A!="function"&&typeof _A!="symbol"&&h.push(me,D(be),ue,D(fA(_A)),Ye)}return h.push(Se),Ke(h,hA,AA),AA}}var Rt=E("</"),b0=E(">"),Yt=E('<template id="'),Kt=E('"></template>'),L0=E("<!--$-->"),er=E('<!--$?--><template id="'),k0=E('"></template>'),zt=E("<!--$!-->"),C0=E("<!--/$-->"),tr=E("<template"),f0=E('"'),rr=E(' data-dgst="');E(' data-msg="'),E(' data-stck="');var N0=E("></template>");function gA(h,w,B){if(x(h,er),B===null)throw Error(u(395));return x(h,B),C(h,k0)}var d0=E('<div hidden id="'),at=E('">'),Fe=E("</div>"),i0=E('<svg aria-hidden="true" style="display:none" id="'),Zt=E('">'),xt=E("</svg>"),bt=E('<math aria-hidden="true" style="display:none" id="'),o0=E('">'),wt=E("</math>"),It=E('<table hidden id="'),ht=E('">'),rA=E("</table>"),pA=E('<table hidden><tbody id="'),IA=E('">'),xA=E("</tbody></table>"),t=E('<table hidden><tr id="'),k=E('">'),ge=E("</tr></table>"),De=E('<table hidden><colgroup id="'),He=E('">'),$A=E("</colgroup></table>");function ye(h,w,B,N){switch(B.insertionMode){case 0:case 1:return x(h,d0),x(h,w.segmentPrefix),x(h,D(N.toString(16))),C(h,at);case 2:return x(h,i0),x(h,w.segmentPrefix),x(h,D(N.toString(16))),C(h,Zt);case 3:return x(h,bt),x(h,w.segmentPrefix),x(h,D(N.toString(16))),C(h,o0);case 4:return x(h,It),x(h,w.segmentPrefix),x(h,D(N.toString(16))),C(h,ht);case 5:return x(h,pA),x(h,w.segmentPrefix),x(h,D(N.toString(16))),C(h,IA);case 6:return x(h,t),x(h,w.segmentPrefix),x(h,D(N.toString(16))),C(h,k);case 7:return x(h,De),x(h,w.segmentPrefix),x(h,D(N.toString(16))),C(h,He);default:throw Error(u(397))}}function lt(h,w){switch(w.insertionMode){case 0:case 1:return C(h,Fe);case 2:return C(h,xt);case 3:return C(h,wt);case 4:return C(h,rA);case 5:return C(h,xA);case 6:return C(h,ge);case 7:return C(h,$A);default:throw Error(u(397))}}var _e=E('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),ie=E('$RS("'),et=E('","'),Lt=E('")<\/script>'),h0=E('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("'),mt=E('$RC("'),Te=E('","'),gt=E('")<\/script>'),Pe=E('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("'),At=E('$RX("'),F0=E('"'),nt=E(")<\/script>"),YA=E(","),S=/[<\u2028\u2029]/g;function OA(h){return JSON.stringify(h).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 Nt=Object.assign,P0=Symbol.for("react.element"),l0=Symbol.for("react.portal"),a0=Symbol.for("react.fragment"),m0=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),E0=Symbol.for("react.provider"),$t=Symbol.for("react.context"),Q0=Symbol.for("react.forward_ref"),O0=Symbol.for("react.suspense"),S0=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),_=Symbol.for("react.scope"),F=Symbol.for("react.debug_trace_mode"),X=Symbol.for("react.legacy_hidden"),K=Symbol.for("react.default_value"),dA=Symbol.iterator;function jA(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 a0:return"Fragment";case l0:return"Portal";case b:return"Profiler";case m0:return"StrictMode";case O0:return"Suspense";case S0:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case $t:return(h.displayName||"Context")+".Consumer";case E0:return(h._context.displayName||"Context")+".Provider";case Q0:var w=h.render;return h=h.displayName,h||(h=w.displayName||w.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case d:return w=h.displayName||null,w!==null?w:jA(h.type)||"Memo";case v:w=h._payload,h=h._init;try{return jA(h(w))}catch{}}return null}var XA={};function Ae(h,w){if(h=h.contextTypes,!h)return XA;var B={},N;for(N in h)B[N]=w[N];return B}var ce=null;function Ge(h,w){if(h!==w){h.context._currentValue=h.parentValue,h=h.parent;var B=w.parent;if(h===null){if(B!==null)throw Error(u(401))}else{if(B===null)throw Error(u(401));Ge(h,B)}w.context._currentValue=w.value}}function kt(h){h.context._currentValue=h.parentValue,h=h.parent,h!==null&&kt(h)}function Ct(h){var w=h.parent;w!==null&&Ct(w),h.context._currentValue=h.value}function pt(h,w){if(h.context._currentValue=h.parentValue,h=h.parent,h===null)throw Error(u(402));h.depth===w.depth?Ge(h,w):pt(h,w)}function je(h,w){var B=w.parent;if(B===null)throw Error(u(402));h.depth===B.depth?Ge(h,B):je(h,B),w.context._currentValue=w.value}function Et(h){var w=ce;w!==h&&(w===null?Ct(h):h===null?kt(w):w.depth===h.depth?Ge(w,h):w.depth>h.depth?pt(w,h):je(w,h),ce=h)}var g0={isMounted:function(){return!1},enqueueSetState:function(h,w){h=h._reactInternals,h.queue!==null&&h.queue.push(w)},enqueueReplaceState:function(h,w){h=h._reactInternals,h.replace=!0,h.queue=[w]},enqueueForceUpdate:function(){}};function u0(h,w,B,N){var tA=h.state!==void 0?h.state:null;h.updater=g0,h.props=B,h.state=tA;var AA={queue:[],replace:!1};h._reactInternals=AA;var hA=w.contextType;if(h.context=typeof hA=="object"&&hA!==null?hA._currentValue:N,hA=w.getDerivedStateFromProps,typeof hA=="function"&&(hA=hA(B,tA),tA=hA==null?tA:Nt({},tA,hA),h.state=tA),typeof w.getDerivedStateFromProps!="function"&&typeof h.getSnapshotBeforeUpdate!="function"&&(typeof h.UNSAFE_componentWillMount=="function"||typeof h.componentWillMount=="function"))if(w=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),w!==h.state&&g0.enqueueReplaceState(h,h.state,null),AA.queue!==null&&0<AA.queue.length)if(w=AA.queue,hA=AA.replace,AA.queue=null,AA.replace=!1,hA&&w.length===1)h.state=w[0];else{for(AA=hA?w[0]:h.state,tA=!0,hA=hA?1:0;hA<w.length;hA++){var _A=w[hA];_A=typeof _A=="function"?_A.call(h,AA,B,N):_A,_A!=null&&(tA?(tA=!1,AA=Nt({},AA,_A)):Nt(AA,_A))}h.state=AA}else AA.queue=null}var z0={id:1,overflow:""};function qt(h,w,B){var N=h.id;h=h.overflow;var tA=32-M0(N)-1;N&=~(1<<tA),B+=1;var AA=32-M0(w)+tA;if(30<AA){var hA=tA-tA%5;return AA=(N&(1<<hA)-1).toString(32),N>>=hA,tA-=hA,{id:1<<32-M0(w)+tA|B<<tA|N,overflow:AA+h}}return{id:1<<AA|B<<tA|N,overflow:h}}var M0=Math.clz32?Math.clz32:Vr,nr=Math.log,sr=Math.LN2;function Vr(h){return h>>>=0,h===0?32:31-(nr(h)/sr|0)|0}function Wr(h,w){return h===w&&(h!==0||1/h===1/w)||h!==h&&w!==w}var Yr=typeof Object.is=="function"?Object.is:Wr,Ft=null,ir=null,c0=null,Ne=null,B0=!1,H=!1,aA=0,mA=null,FA=0;function VA(){if(Ft===null)throw Error(u(321));return Ft}function xe(){if(0<FA)throw Error(u(312));return{memoizedState:null,queue:null,next:null}}function tt(){return Ne===null?c0===null?(B0=!1,c0=Ne=xe()):(B0=!0,Ne=c0):Ne.next===null?(B0=!1,Ne=Ne.next=xe()):(B0=!0,Ne=Ne.next),Ne}function Me(){ir=Ft=null,H=!1,c0=null,FA=0,Ne=mA=null}function ut(h,w){return typeof w=="function"?w(h):w}function Ze(h,w,B){if(Ft=VA(),Ne=tt(),B0){var N=Ne.queue;if(w=N.dispatch,mA!==null&&(B=mA.get(N),B!==void 0)){mA.delete(N),N=Ne.memoizedState;do N=h(N,B.action),B=B.next;while(B!==null);return Ne.memoizedState=N,[N,w]}return[Ne.memoizedState,w]}return h=h===ut?typeof w=="function"?w():w:B!==void 0?B(w):w,Ne.memoizedState=h,h=Ne.queue={last:null,dispatch:null},h=h.dispatch=st.bind(null,Ft,h),[Ne.memoizedState,h]}function yt(h,w){if(Ft=VA(),Ne=tt(),w=w===void 0?null:w,Ne!==null){var B=Ne.memoizedState;if(B!==null&&w!==null){var N=B[1];A:if(N===null)N=!1;else{for(var tA=0;tA<N.length&&tA<w.length;tA++)if(!Yr(w[tA],N[tA])){N=!1;break A}N=!0}if(N)return B[0]}}return h=h(),Ne.memoizedState=[h,w],h}function st(h,w,B){if(25<=FA)throw Error(u(301));if(h===Ft)if(H=!0,h={action:B,next:null},mA===null&&(mA=new Map),B=mA.get(w),B===void 0)mA.set(w,h);else{for(w=B;w.next!==null;)w=w.next;w.next=h}}function St(){throw Error(u(394))}function wr(){}var gn={readContext:function(h){return h._currentValue},useContext:function(h){return VA(),h._currentValue},useMemo:yt,useReducer:Ze,useRef:function(h){Ft=VA(),Ne=tt();var w=Ne.memoizedState;return w===null?(h={current:h},Ne.memoizedState=h):w},useState:function(h){return Ze(ut,h)},useInsertionEffect:wr,useLayoutEffect:function(){},useCallback:function(h,w){return yt(function(){return h},w)},useImperativeHandle:wr,useEffect:wr,useDebugValue:wr,useDeferredValue:function(h){return VA(),h},useTransition:function(){return VA(),[!1,St]},useId:function(){var h=ir.treeContext,w=h.overflow;h=h.id,h=(h&~(1<<32-M0(h)-1)).toString(32)+w;var B=vr;if(B===null)throw Error(u(404));return w=aA++,h=":"+B.idPrefix+"R"+h,0<w&&(h+="H"+w.toString(32)),h+":"},useMutableSource:function(h,w){return VA(),w(h._source)},useSyncExternalStore:function(h,w,B){if(B===void 0)throw Error(u(407));return B()}},vr=null,br=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function kr(h){return console.error(h),null}function Ht(){}function pn(h,w,B,N,tA,AA,hA,_A,te){var be=[],we=new Set;return w={destination:null,responseState:w,progressiveChunkSize:N===void 0?12800:N,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:we,pingedTasks:be,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:tA===void 0?kr:tA,onAllReady:AA===void 0?Ht:AA,onShellReady:hA===void 0?Ht:hA,onShellError:_A===void 0?Ht:_A,onFatalError:te===void 0?Ht:te},B=D0(w,0,null,B,!1,!1),B.parentFlushed=!0,h=Cr(w,h,null,B,we,XA,null,z0),be.push(h),w}function Cr(h,w,B,N,tA,AA,hA,_A){h.allPendingTasks++,B===null?h.pendingRootTasks++:B.pendingTasks++;var te={node:w,ping:function(){var be=h.pingedTasks;be.push(te),be.length===1&&Xr(h)},blockedBoundary:B,blockedSegment:N,abortSet:tA,legacyContext:AA,context:hA,treeContext:_A};return tA.add(te),te}function D0(h,w,B,N,tA,AA){return{status:0,id:-1,index:w,parentFlushed:!1,chunks:[],children:[],formatContext:N,boundary:B,lastPushedText:tA,textEmbedded:AA}}function Gt(h,w){if(h=h.onError(w),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 Ut(h,w){var B=h.onShellError;B(w),B=h.onFatalError,B(w),h.destination!==null?(h.status=2,P(h.destination,w)):(h.status=1,h.fatalError=w)}function Kr(h,w,B,N,tA){for(Ft={},ir=w,aA=0,h=B(N,tA);H;)H=!1,aA=0,FA+=1,Ne=null,h=B(N,tA);return Me(),h}function Zr(h,w,B,N){var tA=B.render(),AA=N.childContextTypes;if(AA!=null){var hA=w.legacyContext;if(typeof B.getChildContext!="function")N=hA;else{B=B.getChildContext();for(var _A in B)if(!(_A in AA))throw Error(u(108,jA(N)||"Unknown",_A));N=Nt({},hA,B)}w.legacyContext=N,Mt(h,w,tA),w.legacyContext=hA}else Mt(h,w,tA)}function Er(h,w){if(h&&h.defaultProps){w=Nt({},w),h=h.defaultProps;for(var B in h)w[B]===void 0&&(w[B]=h[B]);return w}return w}function $r(h,w,B,N,tA){if(typeof B=="function")if(B.prototype&&B.prototype.isReactComponent){tA=Ae(B,w.legacyContext);var AA=B.contextType;AA=new B(N,typeof AA=="object"&&AA!==null?AA._currentValue:tA),u0(AA,B,N,tA),Zr(h,w,AA,B)}else{AA=Ae(B,w.legacyContext),tA=Kr(h,w,B,N,AA);var hA=aA!==0;if(typeof tA=="object"&&tA!==null&&typeof tA.render=="function"&&tA.$$typeof===void 0)u0(tA,B,N,AA),Zr(h,w,tA,B);else if(hA){N=w.treeContext,w.treeContext=qt(N,1,0);try{Mt(h,w,tA)}finally{w.treeContext=N}}else Mt(h,w,tA)}else if(typeof B=="string"){switch(tA=w.blockedSegment,AA=ot(tA.chunks,B,N,h.responseState,tA.formatContext),tA.lastPushedText=!1,hA=tA.formatContext,tA.formatContext=WA(hA,B,N),Jr(h,w,AA),tA.formatContext=hA,B){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:tA.chunks.push(Rt,D(B),b0)}tA.lastPushedText=!1}else{switch(B){case X:case F:case m0:case b:case a0:Mt(h,w,N.children);return;case S0:Mt(h,w,N.children);return;case _:throw Error(u(343));case O0:A:{B=w.blockedBoundary,tA=w.blockedSegment,AA=N.fallback,N=N.children,hA=new Set;var _A={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:hA,errorDigest:null},te=D0(h,tA.chunks.length,_A,tA.formatContext,!1,!1);tA.children.push(te),tA.lastPushedText=!1;var be=D0(h,0,null,tA.formatContext,!1,!1);be.parentFlushed=!0,w.blockedBoundary=_A,w.blockedSegment=be;try{if(Jr(h,w,N),be.lastPushedText&&be.textEmbedded&&be.chunks.push(ae),be.status=1,Sr(_A,be),_A.pendingTasks===0)break A}catch(we){be.status=4,_A.forceClientRender=!0,_A.errorDigest=Gt(h,we)}finally{w.blockedBoundary=B,w.blockedSegment=tA}w=Cr(h,AA,B,te,hA,w.legacyContext,w.context,w.treeContext),h.pingedTasks.push(w)}return}if(typeof B=="object"&&B!==null)switch(B.$$typeof){case Q0:if(N=Kr(h,w,B.render,N,tA),aA!==0){B=w.treeContext,w.treeContext=qt(B,1,0);try{Mt(h,w,N)}finally{w.treeContext=B}}else Mt(h,w,N);return;case d:B=B.type,N=Er(B,N),$r(h,w,B,N,tA);return;case E0:if(tA=N.children,B=B._context,N=N.value,AA=B._currentValue,B._currentValue=N,hA=ce,ce=N={parent:hA,depth:hA===null?0:hA.depth+1,context:B,parentValue:AA,value:N},w.context=N,Mt(h,w,tA),h=ce,h===null)throw Error(u(403));N=h.parentValue,h.context._currentValue=N===K?h.context._defaultValue:N,h=ce=h.parent,w.context=h;return;case $t:N=N.children,N=N(B._currentValue),Mt(h,w,N);return;case v:tA=B._init,B=tA(B._payload),N=Er(B,N),$r(h,w,B,N,void 0);return}throw Error(u(130,B==null?B:typeof B,""))}}function Mt(h,w,B){if(w.node=B,typeof B=="object"&&B!==null){switch(B.$$typeof){case P0:$r(h,w,B.type,B.props,B.ref);return;case l0:throw Error(u(257));case v:var N=B._init;B=N(B._payload),Mt(h,w,B);return}if(EA(B)){qr(h,w,B);return}if(B===null||typeof B!="object"?N=null:(N=dA&&B[dA]||B["@@iterator"],N=typeof N=="function"?N:null),N&&(N=N.call(B))){if(B=N.next(),!B.done){var tA=[];do tA.push(B.value),B=N.next();while(!B.done);qr(h,w,tA)}return}throw h=Object.prototype.toString.call(B),Error(u(31,h==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":h))}typeof B=="string"?(N=w.blockedSegment,N.lastPushedText=JA(w.blockedSegment.chunks,B,h.responseState,N.lastPushedText)):typeof B=="number"&&(N=w.blockedSegment,N.lastPushedText=JA(w.blockedSegment.chunks,""+B,h.responseState,N.lastPushedText))}function qr(h,w,B){for(var N=B.length,tA=0;tA<N;tA++){var AA=w.treeContext;w.treeContext=qt(AA,N,tA);try{Jr(h,w,B[tA])}finally{w.treeContext=AA}}}function Jr(h,w,B){var N=w.blockedSegment.formatContext,tA=w.legacyContext,AA=w.context;try{return Mt(h,w,B)}catch(te){if(Me(),typeof te=="object"&&te!==null&&typeof te.then=="function"){B=te;var hA=w.blockedSegment,_A=D0(h,hA.chunks.length,null,hA.formatContext,hA.lastPushedText,!0);hA.children.push(_A),hA.lastPushedText=!1,h=Cr(h,w.node,w.blockedBoundary,_A,w.abortSet,w.legacyContext,w.context,w.treeContext).ping,B.then(h,h),w.blockedSegment.formatContext=N,w.legacyContext=tA,w.context=AA,Et(AA)}else throw w.blockedSegment.formatContext=N,w.legacyContext=tA,w.context=AA,Et(AA),te}}function $n(h){var w=h.blockedBoundary;h=h.blockedSegment,h.status=3,xn(this,w,h)}function yn(h,w,B){var N=h.blockedBoundary;h.blockedSegment.status=3,N===null?(w.allPendingTasks--,w.status!==2&&(w.status=2,w.destination!==null&&w.destination.close())):(N.pendingTasks--,N.forceClientRender||(N.forceClientRender=!0,h=B===void 0?Error(u(432)):B,N.errorDigest=w.onError(h),N.parentFlushed&&w.clientRenderedBoundaries.push(N)),N.fallbackAbortableTasks.forEach(function(tA){return yn(tA,w,B)}),N.fallbackAbortableTasks.clear(),w.allPendingTasks--,w.allPendingTasks===0&&(N=w.onAllReady,N()))}function Sr(h,w){if(w.chunks.length===0&&w.children.length===1&&w.children[0].boundary===null){var B=w.children[0];B.id=w.id,B.parentFlushed=!0,B.status===1&&Sr(h,B)}else h.completedSegments.push(w)}function xn(h,w,B){if(w===null){if(B.parentFlushed){if(h.completedRootSegment!==null)throw Error(u(389));h.completedRootSegment=B}h.pendingRootTasks--,h.pendingRootTasks===0&&(h.onShellError=Ht,w=h.onShellReady,w())}else w.pendingTasks--,w.forceClientRender||(w.pendingTasks===0?(B.parentFlushed&&B.status===1&&Sr(w,B),w.parentFlushed&&h.completedBoundaries.push(w),w.fallbackAbortableTasks.forEach($n,h),w.fallbackAbortableTasks.clear()):B.parentFlushed&&B.status===1&&(Sr(w,B),w.completedSegments.length===1&&w.parentFlushed&&h.partialBoundaries.push(w)));h.allPendingTasks--,h.allPendingTasks===0&&(h=h.onAllReady,h())}function Xr(h){if(h.status!==2){var w=ce,B=br.current;br.current=gn;var N=vr;vr=h.responseState;try{var tA=h.pingedTasks,AA;for(AA=0;AA<tA.length;AA++){var hA=tA[AA],_A=h,te=hA.blockedSegment;if(te.status===0){Et(hA.context);try{Mt(_A,hA,hA.node),te.lastPushedText&&te.textEmbedded&&te.chunks.push(ae),hA.abortSet.delete(hA),te.status=1,xn(_A,hA.blockedBoundary,te)}catch(_t){if(Me(),typeof _t=="object"&&_t!==null&&typeof _t.then=="function"){var be=hA.ping;_t.then(be,be)}else{hA.abortSet.delete(hA),te.status=4;var we=hA.blockedBoundary,Ue=_t,Bt=Gt(_A,Ue);if(we===null?Ut(_A,Ue):(we.pendingTasks--,we.forceClientRender||(we.forceClientRender=!0,we.errorDigest=Bt,we.parentFlushed&&_A.clientRenderedBoundaries.push(we))),_A.allPendingTasks--,_A.allPendingTasks===0){var Dt=_A.onAllReady;Dt()}}}finally{}}}tA.splice(0,AA),h.destination!==null&&An(h,h.destination)}catch(_t){Gt(h,_t),Ut(h,_t)}finally{vr=N,br.current=B,B===gn&&Et(w)}}}function Mr(h,w,B){switch(B.parentFlushed=!0,B.status){case 0:var N=B.id=h.nextSegmentId++;return B.lastPushedText=!1,B.textEmbedded=!1,h=h.responseState,x(w,Yt),x(w,h.placeholderPrefix),h=D(N.toString(16)),x(w,h),C(w,Kt);case 1:B.status=2;var tA=!0;N=B.chunks;var AA=0;B=B.children;for(var hA=0;hA<B.length;hA++){for(tA=B[hA];AA<tA.index;AA++)x(w,N[AA]);tA=Br(h,w,tA)}for(;AA<N.length-1;AA++)x(w,N[AA]);return AA<N.length&&(tA=C(w,N[AA])),tA;default:throw Error(u(390))}}function Br(h,w,B){var N=B.boundary;if(N===null)return Mr(h,w,B);if(N.parentFlushed=!0,N.forceClientRender)N=N.errorDigest,C(w,zt),x(w,tr),N&&(x(w,rr),x(w,D(fA(N))),x(w,f0)),C(w,N0),Mr(h,w,B);else if(0<N.pendingTasks){N.rootSegmentID=h.nextSegmentId++,0<N.completedSegments.length&&h.partialBoundaries.push(N);var tA=h.responseState,AA=tA.nextSuspenseID++;tA=E(tA.boundaryPrefix+AA.toString(16)),N=N.id=tA,gA(w,h.responseState,N),Mr(h,w,B)}else if(N.byteSize>h.progressiveChunkSize)N.rootSegmentID=h.nextSegmentId++,h.completedBoundaries.push(N),gA(w,h.responseState,N.id),Mr(h,w,B);else{if(C(w,L0),B=N.completedSegments,B.length!==1)throw Error(u(391));Br(h,w,B[0])}return C(w,C0)}function or(h,w,B){return ye(w,h.responseState,B.formatContext,B.id),Br(h,w,B),lt(w,B.formatContext)}function wn(h,w,B){for(var N=B.completedSegments,tA=0;tA<N.length;tA++)vn(h,w,B,N[tA]);if(N.length=0,h=h.responseState,N=B.id,B=B.rootSegmentID,x(w,h.startInlineScript),h.sentCompleteBoundaryFunction?x(w,mt):(h.sentCompleteBoundaryFunction=!0,x(w,h0)),N===null)throw Error(u(395));return B=D(B.toString(16)),x(w,N),x(w,Te),x(w,h.segmentPrefix),x(w,B),C(w,gt)}function vn(h,w,B,N){if(N.status===2)return!0;var tA=N.id;if(tA===-1){if((N.id=B.rootSegmentID)===-1)throw Error(u(392));return or(h,w,N)}return or(h,w,N),h=h.responseState,x(w,h.startInlineScript),h.sentCompleteSegmentFunction?x(w,ie):(h.sentCompleteSegmentFunction=!0,x(w,_e)),x(w,h.segmentPrefix),tA=D(tA.toString(16)),x(w,tA),x(w,et),x(w,h.placeholderPrefix),x(w,tA),C(w,Lt)}function An(h,w){p=new Uint8Array(512),y=0;try{var B=h.completedRootSegment;if(B!==null&&h.pendingRootTasks===0){Br(h,w,B),h.completedRootSegment=null;var N=h.responseState.bootstrapChunks;for(B=0;B<N.length-1;B++)x(w,N[B]);B<N.length&&C(w,N[B])}var tA=h.clientRenderedBoundaries,AA;for(AA=0;AA<tA.length;AA++){var hA=tA[AA];N=w;var _A=h.responseState,te=hA.id,be=hA.errorDigest,we=hA.errorMessage,Ue=hA.errorComponentStack;if(x(N,_A.startInlineScript),_A.sentClientRenderFunction?x(N,At):(_A.sentClientRenderFunction=!0,x(N,Pe)),te===null)throw Error(u(395));x(N,te),x(N,F0),(be||we||Ue)&&(x(N,YA),x(N,D(OA(be||"")))),(we||Ue)&&(x(N,YA),x(N,D(OA(we||"")))),Ue&&(x(N,YA),x(N,D(OA(Ue)))),C(N,nt)}tA.splice(0,AA);var Bt=h.completedBoundaries;for(AA=0;AA<Bt.length;AA++)wn(h,w,Bt[AA]);Bt.splice(0,AA),T(w),p=new Uint8Array(512),y=0;var Dt=h.partialBoundaries;for(AA=0;AA<Dt.length;AA++){var _t=Dt[AA];A:{tA=h,hA=w;var p0=_t.completedSegments;for(_A=0;_A<p0.length;_A++)if(!vn(tA,hA,_t,p0[_A])){_A++,p0.splice(0,_A);var Oe=!1;break A}p0.splice(0,_A),Oe=!0}if(!Oe){h.destination=null,AA++,Dt.splice(0,AA);return}}Dt.splice(0,AA);var en=h.completedBoundaries;for(AA=0;AA<en.length;AA++)wn(h,w,en[AA]);en.splice(0,AA)}finally{T(w),h.allPendingTasks===0&&h.pingedTasks.length===0&&h.clientRenderedBoundaries.length===0&&h.completedBoundaries.length===0&&w.close()}}function H0(h,w){try{var B=h.abortableTasks;B.forEach(function(N){return yn(N,h,w)}),B.clear(),h.destination!==null&&An(h,h.destination)}catch(N){Gt(h,N),Ut(h,N)}}return Qn.renderToReadableStream=function(h,w){return new Promise(function(B,N){var tA,AA,hA=new Promise(function(we,Ue){AA=we,tA=Ue}),_A=pn(h,lA(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),MA(w?w.namespaceURI:void 0),w?w.progressiveChunkSize:void 0,w?w.onError:void 0,AA,function(){var we=new ReadableStream({type:"bytes",pull:function(Ue){if(_A.status===1)_A.status=2,P(Ue,_A.fatalError);else if(_A.status!==2&&_A.destination===null){_A.destination=Ue;try{An(_A,Ue)}catch(Bt){Gt(_A,Bt),Ut(_A,Bt)}}},cancel:function(){H0(_A)}},{highWaterMark:0});we.allReady=hA,B(we)},function(we){hA.catch(function(){}),N(we)},tA);if(w&&w.signal){var te=w.signal,be=function(){H0(_A,te.reason),te.removeEventListener("abort",be)};te.addEventListener("abort",be)}Xr(_A)})},Qn.version="18.3.1",Qn}var io;function g1(){if(io)return $0;io=1;var c,u;return c=h1(),u=m1(),$0.version=c.version,$0.renderToString=c.renderToString,$0.renderToStaticMarkup=c.renderToStaticMarkup,$0.renderToNodeStream=c.renderToNodeStream,$0.renderToStaticNodeStream=c.renderToStaticNodeStream,$0.renderToReadableStream=u.renderToReadableStream,$0}g1();const ul=[{target:"Sparklines",fn:"sparklines",minStage:2}];Fo(ul);const p1=j.memo(function({nodeHash:u,width:p=60,height:y=20,color:x,showArea:C=!0,showTooltip:T=!1,className:Q=""}){No(ul);const D=Ta(u),E=ja(),O=!jo().backgroundLoadComplete||E,z=typeof p=="number"?p:60;return g.jsx(ku,{data:D,width:z,height:y,color:x,isLoading:O,className:Q})});function y1(c){return c===null?"—":c<1e3?`${Math.round(c)}m`:`${(c/1e3).toFixed(1)}km`}function x1(c){const u=new Date(c*1e3);return`${(u.getMonth()+1).toString().padStart(2,"0")}/${u.getDate().toString().padStart(2,"0")}`}function w1({txDelayRec:c,onRemove:u}){const[p,y]=j.useState(!1),x=c.floodFactor??c.txDelayFactor,C=c.directFactor??c.directTxDelayFactor,T=async()=>{const Q=`set txdelay ${x.toFixed(1)}
set direct.txdelay ${C.toFixed(1)}`;await Us(Q),y(!0),setTimeout(()=>y(!1),1500)};return g.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[g.jsxs("button",{onClick:T,className:"flex items-center gap-2 flex-1 py-1 px-1.5 bg-sys-amber/5 hover:bg-sys-amber/10 rounded transition-colors group",title:"Click to copy CLI commands",children:[g.jsx(Pu,{className:"w-3 h-3 text-sys-amber shrink-0"}),g.jsx("span",{className:"text-fg-muted",children:"TxDelay"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("span",{className:"text-fg-muted",children:"F"}),g.jsxs("span",{className:"data-box data-box-compact text-sys-amber",children:["×",x.toFixed(1)]})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("span",{className:"text-fg-muted",children:"D"}),g.jsxs("span",{className:"data-box data-box-compact text-sys-amber",children:["×",C.toFixed(1)]})]})]}),p?g.jsx(hn,{className:"w-3 h-3 text-sys-green ml-auto"}):g.jsx(Gs,{className:"w-3 h-3 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]}),u&&g.jsx("button",{onClick:u,className:"p-1 text-fg-secondary hover:text-sys-red hover:bg-sys-red/10 rounded transition-colors",title:"Remove from contacts",children:g.jsx(Vs,{className:"w-3.5 h-3.5"})})]})}function v1({hash:c,hashPrefix:u,name:p,isHub:y,isGateway:x,isBackbone:C,isZeroHop:T,isMobile:Q,isRoomServer:D,isStale:E,lastSeenTimestamp:P,centrality:O,affinity:z,meanSnr:V,meanRssi:W,neighbor:oA,onRemove:J,txDelayRec:eA}){const[Z,uA]=j.useState(!1),sA=async()=>{await Us(c),uA(!0),setTimeout(()=>uA(!1),1500)},vA=T?"Direct":z!=null&&z.typicalHopPosition?`${z.typicalHopPosition}-hop`:null,iA=eA&&!eA.insufficientData,fA={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"},RA={high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"};return g.jsxs("div",{className:"w-[240px] pr-2",children:[g.jsx("div",{className:"text-[14px] font-semibold text-fg-primary leading-tight truncate mb-1",children:p}),g.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[g.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded",children:u}),g.jsx("button",{onClick:sA,className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:Z?g.jsx(hn,{className:"w-3 h-3 text-sys-green"}):g.jsx(Gs,{className:"w-3 h-3 text-fg-secondary"})}),g.jsx(wu,{hash:c,size:"sm"}),vA&&g.jsx(x0,{color:T?Ci.direct:Ci.multihop,compact:!0,children:vA}),oA.is_repeater&&g.jsx(x0,{color:Lr.repeater,compact:!0,children:"Rptr"}),y&&g.jsx(x0,{color:Lr.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),x&&!y&&g.jsx(x0,{color:Lr.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),C&&g.jsx(x0,{color:Lr.backbone,compact:!0,title:"Backbone",children:"Bone"}),Q&&g.jsx(x0,{color:Lr.mobile,compact:!0,children:"Mobile"}),D&&g.jsx(x0,{color:Lr.room,compact:!0,children:"Room"}),E&&P&&g.jsxs(x0,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",x1(P)]})]}),g.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary mb-1.5",children:[g.jsxs("span",{className:"flex items-center gap-0.5",children:[g.jsx(Uo,{className:"w-3 h-3 text-fg-muted shrink-0"}),g.jsx("span",{className:"font-mono",children:Bo(oA.last_seen)})]}),(z==null?void 0:z.distanceMeters)&&g.jsxs("span",{className:"flex items-center gap-0.5",children:[g.jsx(vu,{className:"w-3 h-3 text-fg-muted shrink-0"}),g.jsx("span",{className:"font-mono font-semibold text-fg-primary",children:y1(z.distanceMeters)})]}),oA.latitude&&oA.longitude&&oA.latitude!==0&&oA.longitude!==0&&g.jsxs("span",{className:"flex items-center gap-0.5",children:[g.jsx(Cu,{className:"w-3 h-3 text-fg-muted shrink-0"}),g.jsxs("span",{className:"font-mono text-fg-muted",children:[oA.latitude.toFixed(2),", ",oA.longitude.toFixed(2)]})]})]}),g.jsx("div",{className:"mb-1.5",style:{width:224},children:g.jsx(p1,{nodeHash:c,width:224,height:26,showArea:!0,showTooltip:!0})}),g.jsxs("div",{className:"flex gap-3 text-xs mb-1.5",children:[g.jsxs("div",{className:"flex-1 space-y-1",children:[g.jsxs("div",{className:"flex justify-between items-center gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Packets"}),g.jsx("span",{className:"data-box data-box-compact",children:(z==null?void 0:z.frequency)||0})]}),T&&V!==void 0&&g.jsxs("div",{className:"flex justify-between items-center gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"SNR"}),g.jsxs("span",{className:"data-box data-box-compact",children:[V.toFixed(1)," dB"]})]}),iA&&eA.networkRole&&g.jsxs("div",{className:"flex justify-between items-center gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Role"}),g.jsx(x0,{color:gu[eA.networkRole],compact:!0,title:fA[eA.networkRole],children:eA.networkRole})]})]}),g.jsxs("div",{className:"flex-1 space-y-1",children:[g.jsxs("div",{className:"flex justify-between items-center gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Adverts"}),g.jsx("span",{className:"data-box data-box-compact",children:oA.advert_count||0})]}),T&&W!==void 0&&g.jsxs("div",{className:"flex justify-between items-center gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"RSSI"}),g.jsxs("span",{className:"data-box data-box-compact",children:[Math.round(W)," dBm"]})]}),iA&&eA.dataConfidence&&g.jsxs("div",{className:"flex justify-between items-center gap-2",children:[g.jsx("span",{className:"text-fg-muted",children:"Data"}),g.jsx(x0,{color:pu[eA.dataConfidence],compact:!0,title:RA[eA.dataConfidence],children:eA.dataConfidence})]})]}),!iA&&J&&g.jsx("button",{onClick:J,className:"p-1 self-start text-fg-secondary hover:text-sys-red hover:bg-sys-red/10 rounded transition-colors",title:"Remove from contacts",children:g.jsx(Vs,{className:"w-3.5 h-3.5"})})]}),iA&&g.jsx(w1,{txDelayRec:eA,onRemove:J})]})}const On="node-markers-native",Ls="node-markers-layer",Ns="node-markers-layer-local",Re={standard:"marker-standard",standardNeighbor:"marker-standard-neighbor",hub:"marker-hub",hubNeighbor:"marker-hub-neighbor",gateway:"marker-gateway",gatewayNeighbor:"marker-gateway-neighbor",mobile:"marker-mobile",mobileNeighbor:"marker-mobile-neighbor",roomServer:"marker-room-server",roomServerNeighbor:"marker-room-server-neighbor",local:"marker-local",stale5Day:"marker-stale-5day",stale10Day:"marker-stale-10day",blinkBlack:"marker-blink-black",blinkBlackLocal:"marker-blink-black-local",blink:"marker-blink",blinkLocal:"marker-blink-local"},b1=10,k1=6,C1=5,E1=10,oo={tier1:I0[500],tier2:I0[700]};function S1(c){if(!c)return 0;const u=Date.now(),p=c*1e3,y=(u-p)/(1e3*60*60*24);return y>=E1?2:y>=C1?1:0}const Wt=2,M1=Yo*Wt,lo=Ds*Wt;function B1(c){const u=Os(),p=(Q,D,E=0,P=!1)=>{const O=M1,z=document.createElement("canvas");z.width=O,z.height=O;const V=z.getContext("2d",P?{colorSpace:"display-p3"}:void 0),W=O/2,oA=O/2,J=O/2-2-E/2;return V.beginPath(),V.arc(W,oA,J,0,Math.PI*2),V.fillStyle=Q,V.fill(),D&&E>0&&(V.strokeStyle=D,V.lineWidth=E*Wt,V.stroke()),V.shadowColor="rgba(0,0,0,0.3)",V.shadowBlur=2*Wt,V.shadowOffsetY=1*Wt,{data:V.getImageData(0,0,O,O),pixelRatio:Wt}},y=(Q,D=!1)=>{const E=lo,P=document.createElement("canvas");P.width=E,P.height=E;const O=P.getContext("2d",D?{colorSpace:"display-p3"}:void 0),z=E/2,V=E/2,W=Ds*.35*Wt;return O.strokeStyle=Q,O.lineWidth=2.5*Wt,O.lineCap="round",O.lineJoin="round",O.beginPath(),O.moveTo(z-W,V),O.lineTo(z,V-W),O.lineTo(z+W,V),O.stroke(),O.beginPath(),O.moveTo(z-W*.7,V),O.lineTo(z-W*.7,V+W*.7),O.lineTo(z+W*.7,V+W*.7),O.lineTo(z+W*.7,V),O.stroke(),O.beginPath(),O.moveTo(z-W*.2,V+W*.7),O.lineTo(z-W*.2,V+W*.2),O.lineTo(z+W*.2,V+W*.2),O.lineTo(z+W*.2,V+W*.7),O.stroke(),{data:O.getImageData(0,0,E,E),pixelRatio:Wt}},x=(Q,D)=>{const E=lo,P=document.createElement("canvas");P.width=E,P.height=E;const O=P.getContext("2d"),z=E/2,V=E/2,W=Ds*.35*Wt;return O.strokeStyle=Q,O.lineWidth=2.5*Wt,O.lineCap="round",O.lineJoin="round",D&&(O.fillStyle=D),O.beginPath(),O.roundRect(z-W,V-W*.6,W*1.6,W*1.2,3*Wt),D&&O.fill(),O.stroke(),O.beginPath(),O.moveTo(z-W*.3,V+W*.6),O.lineTo(z-W*.6,V+W),O.lineTo(z,V+W*.6),O.stroke(),{data:O.getImageData(0,0,E,E),pixelRatio:Wt}},C="#00FF00",T={[Re.standard]:p(u.nodeFill),[Re.standardNeighbor]:p(u.neighborColor),[Re.hub]:p(u.hubColor),[Re.hubNeighbor]:p(u.neighborColor),[Re.gateway]:p(u.gatewayColor),[Re.gatewayNeighbor]:p(u.neighborColor),[Re.mobile]:p("transparent",u.mobileColor,2.5),[Re.mobileNeighbor]:p(u.neighborColor),[Re.roomServer]:x(u.roomColor),[Re.roomServerNeighbor]:x(u.neighborColor,"#1a1a1c"),[Re.local]:y(u.localColor),[Re.stale5Day]:p(oo.tier1),[Re.stale10Day]:p(oo.tier2),[Re.blinkBlack]:p("#000000"),[Re.blinkBlackLocal]:y("#000000"),[Re.blink]:p(C,void 0,0,!0),[Re.blinkLocal]:y(C,!0)};for(const[Q,D]of Object.entries(T))try{c.hasImage(Q)&&c.removeImage(Q),c.addImage(Q,D.data,{pixelRatio:D.pixelRatio})}catch{}}function ao(c){var p;const u=(p=c.contact_type)==null?void 0:p.toLowerCase();return u==="room server"||u==="room_server"||u==="room"||u==="server"}function vs(c){return c.startsWith("0x")?c.slice(2,4).toUpperCase():c.slice(0,2).toUpperCase()}function D1({neighborsWithLocation:c,localNode:u,localHash:p,zeroHopNeighbors:y,lastHopNeighborMap:x,meshTopology:C,hoveredMarker:T,onMarkerHover:Q,getNodeOpacity:D,shouldShowNode:E,onRequestRemove:P,openPopupId:O,onOpenPopup:z,onClosePopup:V,onNodeClick:W,blinkingNodes:oA}){const{current:J}=Ar(),eA=j.useRef(!1),[Z,uA]=j.useState(!1);j.useEffect(()=>{var ZA;const cA=(ZA=J==null?void 0:J.getMap)==null?void 0:ZA.call(J);if(!cA)return;const lA=()=>{try{B1(cA),eA.current=!0,Z||uA(!0)}catch(UA){console.warn("Failed to load node marker icons:",UA)}};cA.isStyleLoaded()?lA():cA.once("style.load",lA);const TA=()=>{cA.hasImage(Re.standard)||lA()};cA.on("styledata",TA);const MA=()=>{eA.current=!1,lA()},WA=new MutationObserver(UA=>{for(const Ie of UA)if(Ie.attributeName==="data-theme"){setTimeout(MA,100);break}});WA.observe(document.documentElement,{attributes:!0});const ae=document.querySelector("[data-basemap]");let JA=null;return ae&&(JA=new MutationObserver(UA=>{for(const Ie of UA)if(Ie.attributeName==="data-basemap"){setTimeout(MA,100);break}}),JA.observe(ae,{attributes:!0})),()=>{cA.off("styledata",TA),WA.disconnect(),JA==null||JA.disconnect()}},[J,Z]);const sA=j.useMemo(()=>{var TA;const cA=[],lA=[...c].sort(([MA,WA],[ae,JA])=>{const ZA=(UA,Ie)=>{var Le;return ao(Ie)?5e3:y.has(UA)?3e3:C.hubNodes.includes(UA)?2e3:(Le=C.gatewayNodes)!=null&&Le.includes(UA)?1e3:0};return ZA(MA,WA)-ZA(ae,JA)});for(const[MA,WA]of lA){if(!WA.latitude||!WA.longitude)continue;if(p){const qe=p.startsWith("0x")?p.slice(2,4).toLowerCase():p.slice(0,2).toLowerCase(),Xe=MA.startsWith("0x")?MA.slice(2,4).toLowerCase():MA.slice(0,2).toLowerCase();if(qe===Xe||MA===p)continue}const ae=E(MA),JA=D(MA,ae);if(JA<=.01)continue;const ZA=y.has(MA),UA=C.hubNodes.includes(MA),Ie=((TA=C.gatewayNodes)==null?void 0:TA.includes(MA))??!1,Le=C.mobileNodes.includes(MA),se=ao(WA),me=C.centrality.get(MA)||0,ue=x.get(MA),Ye=WA.last_seen||(ue==null?void 0:ue.lastSeen),ke=S1(Ye),Ce=ke>0;let Se=JA;ke===2?Se=Math.min(JA,.25):ke===1&&(Se=Math.min(JA,.5));let pe="standard";se?pe="roomServer":UA?pe="hub":Ie?pe="gateway":Le&&(pe="mobile");const Ke=C.fullAffinity.get(MA),$e=C.txDelayRecommendations.get(MA);cA.push({type:"Feature",geometry:{type:"Point",coordinates:[WA.longitude,WA.latitude]},properties:{hash:MA,name:WA.node_name||WA.name||"Unknown",hashPrefix:vs(MA),iconType:pe,isNeighbor:ZA,isHub:UA,isGateway:Ie,isMobile:Le,isRoomServer:se,isStale:Ce,staleTier:ke,isZeroHop:ZA,opacity:Se,blinkIntensity:0,lastSeenTimestamp:Ye,centrality:me,neighborJson:JSON.stringify(WA),affinityJson:Ke?JSON.stringify(Ke):void 0,txDelayRecJson:$e?JSON.stringify($e):void 0,meanSnr:(ue==null?void 0:ue.avgSnr)??void 0,meanRssi:(ue==null?void 0:ue.avgRssi)??void 0}})}return{type:"FeatureCollection",features:cA}},[c,p,y,x,C,D,E]),vA=j.useMemo(()=>!(u!=null&&u.latitude)||!(u!=null&&u.longitude)?{type:"FeatureCollection",features:[]}:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[u.longitude,u.latitude]},properties:{hash:"local",name:u.name,hashPrefix:p?vs(p):"",iconType:"local",isNeighbor:!1,isHub:!1,isGateway:!1,isMobile:!1,isRoomServer:!1,isStale:!1,staleTier:0,isZeroHop:!1,opacity:1,blinkIntensity:0,centrality:0}}]},[u,p]),iA=j.useRef(O);j.useEffect(()=>{iA.current=O},[O]);const fA=j.useCallback(cA=>{var MA;if(!cA.features||cA.features.length===0)return;const TA=(MA=cA.features[0].properties)==null?void 0:MA.hash;TA&&(iA.current===TA?V==null||V():z&&z(TA),W&&TA!=="local"&&W(TA))},[z,V,W]),RA=j.useCallback(cA=>{var MA,WA;if(!cA.features||cA.features.length===0)return;const lA=(MA=J==null?void 0:J.getMap)==null?void 0:MA.call(J);lA&&(lA.getCanvas().style.cursor="pointer");const TA=(WA=cA.features[0].properties)==null?void 0:WA.hash;TA&&Q(TA)},[J,Q]),DA=j.useCallback(()=>{var lA;const cA=(lA=J==null?void 0:J.getMap)==null?void 0:lA.call(J);cA&&(cA.getCanvas().style.cursor=""),Q(null)},[J,Q]);j.useEffect(()=>{var TA;const cA=(TA=J==null?void 0:J.getMap)==null?void 0:TA.call(J);if(!cA||!Z)return;const lA=[Ls,Ns];for(const MA of lA)cA.on("click",MA,fA),cA.on("mouseenter",MA,RA),cA.on("mouseleave",MA,DA);return()=>{for(const MA of lA)cA.off("click",MA,fA),cA.off("mouseenter",MA,RA),cA.off("mouseleave",MA,DA)}},[J,Z,fA,RA,DA]);const EA=j.useRef(sA),yA=j.useRef(vA);j.useEffect(()=>{EA.current=sA,yA.current=vA},[sA,vA]),j.useEffect(()=>{var MA;const cA=(MA=J==null?void 0:J.getMap)==null?void 0:MA.call(J);if(!cA||!Z||!oA||oA.size===0)return;const lA=cA.getSource(On),TA=cA.getSource(`${On}-local`);if(!(!lA&&!TA)){if(lA){const WA=EA.current;let ae=!1;const JA=WA.features.map(ZA=>{const UA=oA.get(ZA.properties.hash)??0;return UA!==ZA.properties.blinkIntensity?(ae=!0,{...ZA,properties:{...ZA.properties,blinkIntensity:UA}}):ZA});ae&&lA.setData({type:"FeatureCollection",features:JA})}if(TA&&p){const WA=oA.get(p)??0,ae=yA.current;ae.features.length>0&&ae.features[0].properties.blinkIntensity!==WA&&TA.setData({type:"FeatureCollection",features:[{...ae.features[0],properties:{...ae.features[0].properties,blinkIntensity:WA}}]})}}},[J,Z,oA,p]);const bA=j.useMemo(()=>{if(!O)return null;if(O==="local"&&u)return{longitude:u.longitude,latitude:u.latitude,isLocal:!0,name:u.name,hash:p};const cA=sA.features.find(MA=>MA.properties.hash===O);if(!cA)return null;const lA=cA.properties,TA=lA.txDelayRecJson?JSON.parse(lA.txDelayRecJson):void 0;return{longitude:cA.geometry.coordinates[0],latitude:cA.geometry.coordinates[1],isLocal:!1,hash:lA.hash,hashPrefix:lA.hashPrefix,name:lA.name,isHub:lA.isHub,isGateway:lA.isGateway,isBackbone:(TA==null?void 0:TA.networkRole)==="backbone",isZeroHop:lA.isZeroHop,isMobile:lA.isMobile,isRoomServer:lA.isRoomServer,isStale:lA.isStale,lastSeenTimestamp:lA.lastSeenTimestamp,centrality:lA.centrality,neighbor:lA.neighborJson?JSON.parse(lA.neighborJson):void 0,affinity:lA.affinityJson?JSON.parse(lA.affinityJson):void 0,txDelayRec:TA,meanSnr:lA.meanSnr,meanRssi:lA.meanRssi}},[O,u,p,sA]);if(!Z)return null;const LA=Os(),NA=["case",[">",["get","blinkIntensity"],.66],Re.blink,[">",["get","blinkIntensity"],.33],Re.blinkBlack,["==",["get","staleTier"],2],Re.stale10Day,["==",["get","staleTier"],1],Re.stale5Day,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],Re.roomServerNeighbor,Re.roomServer],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],Re.hubNeighbor,Re.hub],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],Re.gatewayNeighbor,Re.gateway],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],Re.mobileNeighbor,Re.mobile],["case",["get","isNeighbor"],Re.standardNeighbor,Re.standard]],GA=["interpolate",["linear"],["zoom"],k1,.25,b1,1],kA=["get","opacity"];return g.jsxs(g.Fragment,{children:[g.jsx(J0,{id:On,type:"geojson",data:sA,children:g.jsx(t0,{id:Ls,type:"symbol",layout:{"icon-image":NA,"icon-size":GA,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":kA}})}),g.jsx(J0,{id:`${On}-local`,type:"geojson",data:vA,children:g.jsx(t0,{id:Ns,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],Re.blinkLocal,[">",["get","blinkIntensity"],.33],Re.blinkBlackLocal,Re.local],"icon-size":GA,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),bA&&V&&g.jsx(Oa,{longitude:bA.longitude,latitude:bA.latitude,offset:{center:[0,0],top:[0,j0/2+4],"top-left":[6,j0/2+4],"top-right":[-6,j0/2+4],bottom:[0,-j0/2-4],"bottom-left":[6,-j0/2-4],"bottom-right":[-6,-j0/2-4],left:[j0/2+4,0],right:[-j0/2-4,0]},maxWidth:"280px",closeOnClick:!1,onClose:V,className:"maplibre-popup",children:bA.isLocal?g.jsxs("div",{className:"text-sm",children:[g.jsx("strong",{className:"text-base",children:bA.name}),bA.hash&&g.jsx("span",{className:"ml-2 font-mono text-xs text-fg-muted surface-badge px-1.5 py-0.5 rounded",children:vs(bA.hash)}),g.jsx("br",{}),g.jsx("span",{style:{color:LA.localColor},className:"font-medium",children:"This Node (Local)"}),g.jsx("br",{}),u&&g.jsxs("span",{className:"text-xs text-fg-muted",children:[u.latitude.toFixed(5),", ",u.longitude.toFixed(5)]})]}):bA.neighbor&&bA.hash?g.jsx(v1,{hash:bA.hash,hashPrefix:bA.hashPrefix,name:bA.name,isHub:bA.isHub,isGateway:bA.isGateway,isBackbone:bA.isBackbone,isZeroHop:bA.isZeroHop,isMobile:bA.isMobile,isRoomServer:bA.isRoomServer,isStale:bA.isStale,lastSeenTimestamp:bA.lastSeenTimestamp,centrality:bA.centrality,affinity:bA.affinity,meanSnr:bA.meanSnr,meanRssi:bA.meanRssi,neighbor:bA.neighbor,txDelayRec:bA.txDelayRec,onRemove:P?()=>P(bA.hash,bA.name):void 0}):null})]})}const _1=[Ls,Ns],Fs="topology-validated-edges-native",Ps="topology-weak-edges-native",Qs="neighbor-edges-native",uo="topology-weak-edges-native",zn="topology-validated-edges-native",bs="neighbor-edges-native",ks={type:"FeatureCollection",features:[]},an={"line-cap":"round","line-join":"round"},co={"line-color":"transparent","line-width":16,"line-opacity":0};function T1(c,u,p,y,x,C){const T=Ws(),Q=c!==null,D=x&&x.size>0,E=C&&C.size>0,P=D?Array.from(x):[],O=E?Array.from(C):[],z=u,V=.5,oA=(()=>{if(z<=0)return["get","baseColor"];const bA=1-z*.5;return["case",[">=",["get","brightnessScore"],bA],"#FFFFFF",["get","baseColor"]]})(),eA=z<=0?1:["max",.1,["+",1,["*",z,3,["-",["get","brightnessScore"],V]]]],uA=D?["in",["get","key"],["literal",P]]:E?["in",["get","key"],["literal",O]]:Q?["==",["get","key"],c]:!1,sA=Q||D||E,vA=T.edges.hoverLoop,iA=T.edges.highlight;return{"line-color":sA?["case",uA,D?vA:E?iA:["get","hoverColor"],oA]:oA,"line-width":sA?["case",uA,["max",["*",["get","baseWidth"],p,1.3],3.5],["*",["get","baseWidth"],p]]:["*",["get","baseWidth"],p],"line-opacity":["case",["<",["get","brightnessScore"],y],0,sA?["case",uA,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],eA,.35]]:["*",["get","baseOpacity"],eA]]}}const j1=10,R1=6;function I1(c){const u=c!==null,{YELLOW:p,GREEN:y,RED:x,GRAY:C}=Hn,T=["to-number",["get","listenerScore"],0],Q=["to-number",["get","loudScore"],0],E=["/",T,["max",["+",T,Q],1]],P=["case",["all",["==",T,0],["==",Q,0]],C,[">=",E,.97],y,["<=",E,.03],x,["interpolate",["linear"],E,.03,x,.5,p,.97,y]],O=.2,J=["*",["+",O,["*",["to-number",["get","trafficWeight"],0],1-O]],8],eA=5,Z=u?["case",["==",["get","key"],c],["max",J,eA],J]:J,uA=u?["case",["==",["get","key"],c],["max",["*",J,.25],eA*.25],["*",J,.25]]:["*",J,.25];return{"line-color":P,"line-width":["interpolate",["linear"],["zoom"],R1,uA,j1,Z],"line-opacity":u?["case",["==",["get","key"],c],1,.35]:.9}}function L1({showTopology:c,isExiting:u,hoveredEdgeKey:p,highlightedLoopEdges:y,highlightedFocusEdges:x,onEdgeHover:C,onLoopHover:T,loops:Q=[],neighborNames:D={},opacityBias:E=.5,widthMultiplier:P=1,trafficFilter:O=0,showNeighborLines:z=!0,disableHover:V=!1}){const{current:W}=Ar(),oA=c||u,J=!0,eA=z?"visible":"none",Z=V||u,uA=j.useRef(null),sA=j.useRef(Z),vA=j.useRef(new Map),iA=j.useRef(D),fA=j.useRef(T);j.useLayoutEffect(()=>{sA.current=Z,iA.current=D,fA.current=T});const RA=j.useMemo(()=>zu(Q),[Q]);j.useLayoutEffect(()=>{vA.current=RA},[RA]);const DA=j.useCallback(kA=>{var MA,WA;if(sA.current||!kA.features||kA.features.length===0)return;const lA=kA.features[0].properties;if(!(lA!=null&&lA.key))return;const TA=lA.key;if(TA!==uA.current){uA.current=TA;const ae=lA.isNeighborEdge===!0||lA.isNeighborEdge==="true",JA=lA.isLoopEdge===!0||lA.isLoopEdge==="true";if(ae){const ZA={key:TA,fromName:"Local",toName:lA.name,certainCount:Number(lA.packetCount)||0,confidence:1,isBackbone:!1,isLoopEdge:!1,isDirectPath:!0,isZeroHop:!0,symmetryRatio:1,dominantDirection:"balanced",isHubConnection:!1};C(TA,[kA.lngLat.lng,kA.lngLat.lat],ZA),(MA=fA.current)==null||MA.call(fA,null)}else if(JA&&fA.current){const ZA=vA.current.get(TA)??[];if(ZA.length>0){const UA=new Set;for(const me of ZA)for(const ue of me.edgeKeys)UA.add(ue);const Le=ZA[0].nodes.map(me=>iA.current[me]||me.substring(0,4)),se={loops:ZA,highlightedEdgeKeys:UA,hoveredEdgeKey:TA,nodeNames:Le};fA.current(se,[kA.lngLat.lng,kA.lngLat.lat]),C(TA)}else{const UA={key:TA,fromName:lA.fromName,toName:lA.toName,certainCount:Number(lA.certainCount),confidence:Number(lA.confidence),isBackbone:lA.isBackbone===!0||lA.isBackbone==="true",isLoopEdge:!0,isDirectPath:lA.isDirectPath===!0||lA.isDirectPath==="true",isZeroHop:lA.isZeroHop===!0||lA.isZeroHop==="true",symmetryRatio:Number(lA.symmetryRatio),dominantDirection:lA.dominantDirection,isHubConnection:lA.isHubConnection===!0||lA.isHubConnection==="true"};C(TA,[kA.lngLat.lng,kA.lngLat.lat],UA)}}else{const ZA={key:TA,fromName:lA.fromName,toName:lA.toName,certainCount:Number(lA.certainCount),confidence:Number(lA.confidence),isBackbone:lA.isBackbone===!0||lA.isBackbone==="true",isLoopEdge:JA,isDirectPath:lA.isDirectPath===!0||lA.isDirectPath==="true",isZeroHop:lA.isZeroHop===!0||lA.isZeroHop==="true",symmetryRatio:Number(lA.symmetryRatio),dominantDirection:lA.dominantDirection,isHubConnection:lA.isHubConnection===!0||lA.isHubConnection==="true"};C(TA,[kA.lngLat.lng,kA.lngLat.lat],ZA),(WA=fA.current)==null||WA.call(fA,null)}}},[C]),EA=j.useCallback(()=>{var kA;uA.current!==null&&(uA.current=null,C(null),(kA=fA.current)==null||kA.call(fA,null))},[C]);j.useEffect(()=>{var MA;const kA=(MA=W==null?void 0:W.getMap)==null?void 0:MA.call(W);if(!kA||!oA)return;const cA="topology-validated-edges-hitarea-native",lA=()=>{try{return kA.getStyle()&&kA.getLayer(cA)}catch{return!1}},TA=()=>lA()?(kA.on("mousemove",cA,DA),kA.on("mouseleave",cA,EA),!0):!1;if(!TA()){const WA=()=>{TA()&&kA.off("styledata",WA)};return kA.on("styledata",WA),()=>{try{kA.off("styledata",WA),lA()&&(kA.off("mousemove",cA,DA),kA.off("mouseleave",cA,EA))}catch{}}}return()=>{try{lA()&&(kA.off("mousemove",cA,DA),kA.off("mouseleave",cA,EA))}catch{}}},[W,oA,DA,EA]),j.useEffect(()=>{var MA;const kA=(MA=W==null?void 0:W.getMap)==null?void 0:MA.call(W);if(!kA||!J||!z)return;const cA="neighbor-edges-hitarea-native",lA=()=>{try{return kA.getStyle()&&kA.getLayer(cA)}catch{return!1}},TA=()=>lA()?(kA.on("mousemove",cA,DA),kA.on("mouseleave",cA,EA),!0):!1;if(!TA()){const WA=()=>{TA()&&kA.off("styledata",WA)};return kA.on("styledata",WA),()=>{try{kA.off("styledata",WA),lA()&&(kA.off("mousemove",cA,DA),kA.off("mouseleave",cA,EA))}catch{}}}return()=>{try{lA()&&(kA.off("mousemove",cA,DA),kA.off("mouseleave",cA,EA))}catch{}}},[W,J,z,DA,EA]),j.useEffect(()=>{var JA;const kA=(JA=W==null?void 0:W.getMap)==null?void 0:JA.call(W);if(!kA)return;let cA=null;const lA=(ZA,UA)=>{try{if(kA.getLayer(ZA)&&kA.getLayer(UA))return kA.moveLayer(ZA,UA),!0}catch{}return!1},TA=()=>{try{if(!kA.getLayer("node-markers-layer"))return;lA(bs,"node-markers-layer"),lA("neighbor-edges-hitarea-native",bs),(lA(zn,"neighbor-edges-hitarea-native")||lA(zn,"node-markers-layer"))&&lA("topology-validated-edges-hitarea-native",zn),lA(uo,"topology-validated-edges-hitarea-native")}catch{}},MA=()=>{cA&&clearTimeout(cA),cA=setTimeout(TA,50)},WA=setTimeout(TA,100);kA.on("styledata",MA);const ae=ZA=>{(ZA.sourceId===Fs||ZA.sourceId===Ps||ZA.sourceId===Qs)&&MA()};return kA.on("sourcedata",ae),()=>{clearTimeout(WA),cA&&clearTimeout(cA);try{kA.off("styledata",MA),kA.off("sourcedata",ae)}catch{}}},[W,oA,J,z]);const yA=Z?null:p,NA=T1(yA,E,P,O,Z?null:y,x??null),GA=I1(yA);return g.jsxs(g.Fragment,{children:[oA&&g.jsx(J0,{id:Ps,type:"geojson",data:ks,children:g.jsx(t0,{id:uo,type:"line",paint:NA,layout:{...an,visibility:eA}})}),oA&&g.jsxs(J0,{id:Fs,type:"geojson",data:ks,children:[g.jsx(t0,{id:"topology-validated-edges-hitarea-native",type:"line",paint:co,layout:{...an,visibility:eA}}),g.jsx(t0,{id:zn,type:"line",paint:NA,layout:{...an,visibility:eA}})]}),g.jsxs(J0,{id:Qs,type:"geojson",data:ks,children:[g.jsx(t0,{id:"neighbor-edges-hitarea-native",type:"line",paint:co,layout:{...an,visibility:eA}}),g.jsx(t0,{id:bs,type:"line",paint:GA,layout:{...an,visibility:eA}})]})]})}const N1=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function F1({targetHash:c,nodeCoordinates:u,onComplete:p}){const{current:y}=Ar(),x=j.useRef(null);return j.useEffect(()=>{if(!y||!c||c===x.current)return;const C=u.get(c);if(!C)return;const T=y.getMap();T.isMoving()&&T.stop(),x.current=c;const[Q,D]=C;y.flyTo({center:[D,Q],zoom:10,duration:2500,essential:!0}),setTimeout(()=>{p==null||p()},2600)},[c,u,y,p]),null}function P1({highlightedEdgeKey:c,validatedPolylines:u,weakPolylines:p,onEnsureTopology:y}){const{current:x}=Ar(),C=j.useRef(null);return j.useEffect(()=>{if(!x||!c||c===C.current)return;C.current=c,y();const T=u.find(z=>z.edge.key===c)||p.find(z=>z.edge.key===c);if(!T||x.getMap().isMoving())return;const D=(T.from[0]+T.to[0])/2,E=(T.from[1]+T.to[1])/2,P=x.getZoom(),O=Math.max(P,11);x.easeTo({center:[E,D],zoom:O,duration:500})},[c,u,p,x,y]),null}const fo="link-quality-edges",Q1="link-quality-edges-layer",Un="link-quality-edges-hitarea",ho={type:"FeatureCollection",features:[]};function O1(c,u){return c<u?`${c}|${u}`:`${u}|${c}`}function z1(c,u,p,y,x){const C=[];for(const T of c){if(p&&T.nodeA.hash!==p&&T.nodeB.hash!==p)continue;const Q=u.get(T.nodeA.hash),D=u.get(T.nodeB.hash);if(!Q||!D)continue;const E=La(T.composite.mean,x),P=y[E]||"#888888",O=2+T.confidence*2,z=O1(T.nodeA.hash,T.nodeB.hash);C.push({type:"Feature",geometry:{type:"LineString",coordinates:[[Q[1],Q[0]],[D[1],D[0]]]},properties:{key:z,color:P,width:O,quality:T.quality,compositeMeanSnr:T.composite.mean,confidence:T.confidence,fromHash:T.nodeA.hash,toHash:T.nodeB.hash,fromPrefix:T.nodeA.prefix,toPrefix:T.nodeB.prefix,fromName:T.nodeA.name||T.nodeA.prefix,toName:T.nodeB.name||T.nodeB.prefix,asymmetryDb:T.asymmetryDb}})}return{type:"FeatureCollection",features:C}}const mo={"line-cap":"round","line-join":"round"},H1={"line-color":["get","color"],"line-width":["get","width"],"line-opacity":.85},G1={"line-color":"transparent","line-width":16,"line-opacity":0};function U1({visible:c,nodeCoordinates:u,focusedNodeHash:p=null,basemapMode:y}){const{current:x}=Ar(),C=Ro(),T=Mo(),Q=Ra(),D=j.useMemo(()=>Ia(),[]),E=j.useMemo(()=>!c||C.length===0||T.size===0?ho:z1(C,u,p,D,Q),[c,C,T.size,u,p,D,Q]);j.useEffect(()=>{if(!x)return;const O=x.getMap();if(O)try{const z=O.getSource(fo);z&&"setData"in z&&(z.setData(E),O.triggerRepaint())}catch{}},[E,x]);const P=c?"visible":"none";return g.jsxs(J0,{id:fo,type:"geojson",data:ho,children:[g.jsx(t0,{id:Q1,type:"line",layout:{...mo,visibility:P},paint:H1}),g.jsx(t0,{id:Un,type:"line",layout:{...mo,visibility:P},paint:G1})]})}const V1="rgba(167, 139, 250, 0.15)",go=500,W1=.5,po=2e3,yo=1500,Y1=1e3;function K1(c,u,p,y=64){const x=[],T=p/6371e3*(180/Math.PI),Q=T/Math.cos(u*Math.PI/180);for(let D=0;D<=y;D++){const E=D/y*2*Math.PI,P=c+Q*Math.cos(E),O=u+T*Math.sin(E);x.push([P,O])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[x]}}}function Z1({ghost:c,neighborCoordinates:u,onHighlightedNeighborsChange:p}){const{current:y}=Ar(),x=j.useRef(null),C=j.useRef(null),T=j.useMemo(()=>c?new Set(c.commonNeighbors):new Set,[c]);j.useEffect(()=>{p==null||p(T)},[T,p]);const Q=j.useMemo(()=>{if(!(c!=null&&c.commonNeighbors)||c.commonNeighbors.length<2)return po*4;let P=0;const O=[];for(const z of c.commonNeighbors){const V=u.get(z);V&&O.push(V)}c.estimatedLocation&&O.push([c.estimatedLocation.lat,c.estimatedLocation.lon]);for(let z=0;z<O.length;z++)for(let V=z+1;V<O.length;V++){const W=Io(O[z][0],O[z][1],O[V][0],O[V][1]);W>P&&(P=W)}return Math.max(P,go*4)},[c,u]),D=j.useMemo(()=>{if(!(c!=null&&c.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:P,lon:O,uncertaintyM:z}=c.estimatedLocation,V=Q*W1,W=z>0?z:po,oA=Math.max(go,Math.min(W,V));return{type:"FeatureCollection",features:[K1(O,P,oA)]}},[c,Q]);if(j.useEffect(()=>{if(!y)return;const P=y.getMap();if(c&&c.prefix!==C.current){if(C.current=c.prefix,!x.current&&P.getZoom()>3){const z=P.getCenter();x.current={center:[z.lng,z.lat],zoom:P.getZoom(),pitch:P.getPitch(),bearing:P.getBearing()}}const O=[];for(const z of c.commonNeighbors){const V=u.get(z);V&&O.push([V[1],V[0]])}if(c.estimatedLocation&&O.push([c.estimatedLocation.lon,c.estimatedLocation.lat]),O.length>0){const z=()=>{var V;if(P.isMoving()){setTimeout(z,100);return}if(O.length===1)y.flyTo({center:O[0],zoom:13,duration:yo});else{let W=1/0,oA=-1/0,J=1/0,eA=-1/0;for(const[Z,uA]of O)W=Math.min(W,Z),oA=Math.max(oA,Z),J=Math.min(J,uA),eA=Math.max(eA,uA);if((V=c.estimatedLocation)!=null&&V.uncertaintyM){const Z=c.estimatedLocation.uncertaintyM/111e3;W-=Z,oA+=Z,J-=Z,eA+=Z}y.fitBounds([[W,J],[oA,eA]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:yo})}};setTimeout(z,50)}}if(!c&&C.current!==null&&(C.current=null,x.current)){const O=x.current,z=()=>{if(P.isMoving()){setTimeout(z,100);return}y.flyTo({center:O.center,zoom:O.zoom,pitch:O.pitch,bearing:O.bearing,duration:Y1}),x.current=null};setTimeout(z,50)}},[c,y,u]),!(c!=null&&c.estimatedLocation))return null;const E={"fill-color":V1,"fill-opacity":.8};return g.jsx(J0,{id:"ghost-uncertainty-circle",type:"geojson",data:D,children:g.jsx(t0,{id:"ghost-uncertainty-fill",type:"fill",paint:E})})}const cl=[{target:"Map",fn:"gps",minStage:1,when:wi},{target:"Map",fn:"_advertNodeType",minStage:1,when:wi},{target:"Topology",fn:"traceHops",minStage:1,when:vi},{target:"Topology",fn:"path.entries",minStage:1,when:Va},{target:"Topology",fn:"traceSrc",minStage:1,when:vi}];Fo(cl);const $1={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},q1={longitude:0,latitude:0,zoom:2};function J1(c,u,p,y){return Io(c,u,p,y)/1e3}function X1(c,u){if(c.length<=2)return c;let p,y;if(u!=null&&u.latitude&&(u!=null&&u.longitude))p=u.latitude,y=u.longitude;else{let E=0,P=0;for(const[O,z]of c)E+=O,P+=z;p=E/c.length,y=P/c.length}const x=c.map(([E,P])=>({pos:[E,P],dist:J1(p,y,E,P)}));x.sort((E,P)=>E.dist-P.dist);const C=Math.floor(x.length/2),T=x[C].dist,Q=Math.max(T*3,50),D=x.filter(E=>E.dist<=Q).map(E=>E.pos);return D.length<c.length*.5?c:D}function Ad(c,u){let p=[...c];if(u!=null&&u.latitude&&(u!=null&&u.longitude)&&p.push([u.latitude,u.longitude]),p.length===0)return null;if(p.length===1){const[V,W]=p[0];return{longitude:W,latitude:V,zoom:14}}p=X1(p,u);let y=1/0,x=-1/0,C=1/0,T=-1/0;for(const[V,W]of p)y=Math.min(y,W),x=Math.max(x,W),C=Math.min(C,V),T=Math.max(T,V);const Q=(y+x)/2,D=(C+T)/2,E=T-C,P=x-y,O=Math.max(E,P);let z=16;return O>0&&(z=Math.floor(Math.log2(360/O*1.2)),z=Math.max(1,Math.min(14,z))),z=Math.min(z+1,12),{longitude:Q,latitude:D,zoom:z}}function ed(c,u,p,y){var x;if(u){const C=u.loops[0],T=u.loops.length,Q=[{label:"hops",value:C.size},{label:"seen",value:C.minCertainCount}],D=[];return C.includesLocal&&D.push({text:"★ Includes your node",color:"text-sys-amber"}),T>1&&D.push({text:`+${T-1} overlapping`,color:"text-sys-indigo/70"}),{type:"loop",title:{icon:"⟳",text:`Redundant Path${T>1?"s":""}`,color:"text-sys-indigo"},subtitle:{text:`${u.nodeNames.join(" → ")} → ${u.nodeNames[0]}`,color:"text-fg-secondary",mono:!0},stats:Q,badges:D}}if((c==null?void 0:c.type)==="neighbor"){const C=c.properties,T=[];C.rssi!==void 0&&C.rssi!==null&&T.push({label:"RSSI",value:`${Math.round(C.rssi)} dBm`,unit:C.hasAvgRssi?"avg":void 0}),C.snr!==void 0&&C.snr!==null&&T.push({label:"SNR",value:`${Number(C.snr).toFixed(1)} dB`,unit:C.hasAvgSnr?"avg":void 0});const Q=C.listenerScore??0,D=C.loudScore??0,E=Q>0||D>0;return E&&(T.push({label:"listener",value:Q,color:"text-sys-green"}),T.push({label:"loud",value:D,color:"text-sys-red"})),C.packetCount!==void 0&&!E&&T.push({label:"packets",value:Number(C.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:C.prefix?`${C.name} (${C.prefix})`:C.name,color:"text-sys-amber"},subtitle:{text:"Direct RF Neighbor",color:"text-sys-amber/70"},stats:T,badges:[]}}if((c==null?void 0:c.type)==="topology"){const C=c.properties,T=p>0?Number(C.certainCount)/p:0,Q=[{label:"validations",value:C.certainCount},{label:"of max traffic",value:`${Math.round(T*100)}%`},{label:"confidence",value:`${Math.round(Number(C.confidence)*100)}%`}];if(C.symmetryRatio!==void 0&&C.symmetryRatio<1){const P=C.dominantDirection==="forward"?"→":C.dominantDirection==="reverse"?"←":"↔";Q.push({label:"symmetric",value:`${P} ${Math.round(C.symmetryRatio*100)}%`,color:"text-fg-muted"})}const D=(x=y==null?void 0:y.get(C.key))==null?void 0:x.traceQuality;if(D!=null&&D.composite){const P=D.composite;Q.push({label:"trace SNR",value:`${P.mean.toFixed(1)} dB`,unit:`n=${P.count}`,color:P.mean>=10?"text-sys-green":P.mean>=0?"text-sys-amber":"text-sys-red"}),D.asymmetryDb!=null&&D.asymmetryDb>1&&Q.push({label:"asymmetry",value:`${D.asymmetryDb.toFixed(1)} dB`,color:D.asymmetryDb>5?"text-sys-red":"text-sys-amber"})}const E=[];if(C.isBackbone&&E.push({text:"Backbone",color:"text-zinc-300"}),C.isLoopEdge&&E.push({text:"Redundant",color:"text-sys-indigo"}),C.isDirectPath&&E.push({text:"Direct Path",color:"text-sys-teal"}),D){const P=D.quality==="excellent"||D.quality==="good"?"text-sys-green":D.quality==="fair"?"text-sys-amber":D.quality==="poor"||D.quality==="critical"?"text-sys-red":"text-fg-muted";D.quality!=="unknown"&&E.push({text:`TRACE ${D.quality}`,color:P})}return{type:"topology",title:{icon:"",text:`${C.fromName} ↔ ${C.toName}`,color:"text-fg-primary"},stats:Q,badges:E}}return null}function td({data:c}){const u=c.subtitle&&c.type==="loop",p=c.subtitle&&c.type!=="loop";return g.jsxs("div",{className:"w-[540px]",children:[g.jsxs("div",{className:"flex items-center justify-between h-5",children:[g.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.title.icon&&g.jsx("span",{className:`${c.title.color} text-base leading-none flex-shrink-0`,children:c.title.icon}),g.jsx("span",{className:`${c.title.color} font-semibold text-[13px] truncate`,children:c.title.text}),p&&g.jsx("span",{className:`${c.subtitle.color} text-[11px] flex-shrink-0`,children:c.subtitle.text})]}),c.badges.length>0&&g.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:c.badges.map((y,x)=>g.jsx("span",{className:`${y.color} text-[11px] font-medium`,children:y.text},x))})]}),u&&g.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:g.jsx("span",{className:"type-data-xs text-fg-muted truncate block",children:c.subtitle.text})}),g.jsx("div",{className:`flex items-center gap-4 h-4 ${u?"mt-1":"mt-1.5"} text-[11px]`,children:c.stats.map((y,x)=>g.jsxs("span",{className:"whitespace-nowrap",children:[g.jsx("span",{className:`font-mono tabular-nums font-semibold ${y.color??"text-fg-primary"}`,children:y.value}),g.jsx("span",{className:"text-fg-muted ml-1",children:y.label}),y.unit&&g.jsx("span",{className:"text-fg-muted/50 ml-0.5",children:y.unit})]},x))})]})}function Ud({neighbors:c,localNode:u,localHash:p,onRemoveNode:y,selectedNodeHash:x,onNodeSelected:C,highlightedEdgeKey:T,highlightedGhost:Q}){No(cl);const D=j.useRef(null),E=Na(),P=Fa(),O=jo(),z=Pa(),V=Qa(),W=Ro(),[oA,J]=j.useState(!1),eA=ur(H=>H.viewState),Z=ur(H=>H.toggles),uA=ur(H=>H.hasAnalyzed),sA=ur(H=>H.setViewState),vA=ur(H=>H.setToggle),iA=ur(H=>H.setHasAnalyzed),fA=ur(H=>H.modalMapOpen),RA=cs(H=>H.preloadFromNodes),DA=cs(H=>H.isLoading),EA=cs(H=>H.terrainGrid),yA=p??z,bA=j.useMemo(()=>{const H=[];for(const[,aA]of Object.entries(c))aA.latitude&&aA.longitude&&H.push([aA.latitude,aA.longitude]);return H},[c]),LA=j.useMemo(()=>Ad(bA,u),[bA,u]),[NA,GA]=j.useState(()=>eA??LA??q1),kA=j.useCallback(H=>{GA(H),queueMicrotask(()=>sA(H))},[sA]),cA=j.useRef(!!eA);j.useEffect(()=>{!cA.current&&LA&&!eA?(GA(LA),queueMicrotask(()=>sA(LA)),cA.current=!0,setTimeout(()=>J(!0),50)):eA&&setTimeout(()=>J(!0),50)},[LA,eA,sA]);const[lA,TA]=j.useState(!1),[MA,WA]=j.useState(()=>Z.showTopology&&!O.topologyLoadComplete?!1:Z.showTopology),[ae,JA]=j.useState(Z.showNeighborLines),[ZA,UA]=j.useState(!1),[Ie,Le]=j.useState(Z.showMinCut),[se,me]=j.useState(ff),[ue,Ye]=j.useState(Z.show3DTerrain),[ke,Ce]=j.useState(Z.showLinkQuality),[Se,pe]=j.useState(()=>Z.nodeFilters.length>0?Z.nodeFilters:[...un]),Ke=j.useCallback(H=>{WA(aA=>{const mA=typeof H=="function"?H(aA):H;return queueMicrotask(()=>vA("showTopology",mA)),mA})},[vA]),$e=j.useCallback(H=>{JA(aA=>{const mA=typeof H=="function"?H(aA):H;return queueMicrotask(()=>vA("showNeighborLines",mA)),mA})},[vA]),qe=j.useCallback(H=>{Le(aA=>{const mA=typeof H=="function"?H(aA):H;return queueMicrotask(()=>vA("showMinCut",mA)),mA})},[vA]),Xe=j.useCallback(H=>{Ye(aA=>{const mA=typeof H=="function"?H(aA):H;return queueMicrotask(()=>vA("show3DTerrain",mA)),mA})},[vA]),vt=j.useCallback(H=>{Ce(aA=>{const mA=typeof H=="function"?H(aA):H;return queueMicrotask(()=>vA("showLinkQuality",mA)),mA})},[vA]),Qe=j.useCallback(H=>{pe(H),queueMicrotask(()=>vA("nodeFilters",H))},[vA]),[Je,Be]=j.useState(null),[ze,ot]=j.useState(null),[Rt,b0]=j.useState(null),[Yt,Kt]=j.useState(null),[L0]=j.useState(0),[er]=j.useState(.5),[k0]=j.useState(0),[zt,C0]=j.useState(null),[tr,f0]=j.useState(""),[rr,N0]=j.useState(!1),[gA,d0]=j.useState(!1),[at,Fe]=j.useState(()=>uA&&!O.topologyLoadComplete?!1:uA);j.useEffect(()=>{if(O.topologyLoadComplete)return;const H=uA&&!at,aA=Z.showTopology&&!MA;!H&&!aA||queueMicrotask(()=>{H&&iA(!1),aA&&vA("showTopology",!1)})},[uA,Z.showTopology,O.topologyLoadComplete,at,MA,iA,vA]);const i0=j.useCallback(H=>{Fe(H),queueMicrotask(()=>iA(H))},[iA]),[Zt,xt]=j.useState(null),bt=j.useCallback(H=>xt(H),[]),o0=j.useCallback(()=>xt(null),[]),[,wt]=j.useState(new Set),It=cn(H=>H.coveragePoints),ht=cn(H=>H.isVisible),rA=cn(H=>H.brightness),pA=cn(H=>H.openModal),IA=bf(),xA=kf(),t=Lo(),k=za(),ge=j.useRef(!1);j.useEffect(()=>{It.length>0&&ht&&!ge.current&&($e(!1),ge.current=!0)},[It.length,ht]);const De=j.useRef(null);j.useEffect(()=>{if(x&&x!==De.current){De.current=x;const H=setTimeout(()=>{xt(x)},1250);return()=>clearTimeout(H)}},[x]);const[He,$A]=j.useState(null),[ye,lt]=j.useState(null),_e=j.useCallback((H,aA,mA)=>{ot(H),H&&aA&&mA?$A({longitude:aA[0],latitude:aA[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||$A(null)},[]),ie=j.useCallback((H,aA)=>{lt(H),H&&$A(null)},[]),et=j.useMemo(()=>{var VA;if(!MA||!Je||ze)return null;const H=E.loops;if(H.length===0)return null;const aA=Ou(Je,H,E.edgeMap);if(aA.loops.length===0)return null;const FA=aA.loops[0].nodes.map(xe=>{var tt,Me;return xe===yA?"You":((tt=c[xe])==null?void 0:tt.node_name)||((Me=c[xe])==null?void 0:Me.name)||xe.substring(0,4)});return{loops:aA.loops,highlightedEdgeKeys:aA.highlightedEdgeKeys,hoveredEdgeKey:((VA=aA.sortedEdges[0])==null?void 0:VA.key)||"",nodeNames:FA}},[MA,Je,ze,E.loops,E.edgeMap,c,yA]);j.useEffect(()=>{ze||lt(et)},[et,ze]);const Lt=j.useMemo(()=>{const H={};for(const[aA,mA]of Object.entries(c))H[aA]=mA.node_name||mA.name||aA.substring(0,4);return yA&&(H[yA]="You"),H},[c,yA]),h0=j.useMemo(()=>{const H=new Map;for(const[aA,mA]of Object.entries(c)){const FA=aA.slice(0,2).toUpperCase(),VA=mA.node_name||mA.name||FA;H.set(FA,VA)}return yA&&H.set(yA.slice(0,2).toUpperCase(),"You"),H},[c,yA]),mt=j.useMemo(()=>Object.entries(c).filter(([,H])=>H.latitude&&H.longitude),[c]),Te=j.useMemo(()=>{const H=new Map;yA&&(u!=null&&u.latitude)&&(u!=null&&u.longitude)&&H.set(yA,[u.latitude,u.longitude]);for(const[aA,mA]of mt)mA.latitude&&mA.longitude&&H.set(aA,[mA.latitude,mA.longitude]);return H},[yA,u,mt]),gt=j.useMemo(()=>{const H=new Map;for(const aA of P)aA.status!=="expired"&&H.set(aA.hash,{hash:aA.hash,prefix:aA.prefix,count:aA.count,avgRssi:aA.avgRssi,avgSnr:aA.avgSnr,lastSeen:aA.lastSeen,confidence:1,status:aA.status});return H},[P]),Pe=j.useMemo(()=>{var aA,mA;const H=new Set;for(const FA of gt.keys())(aA=c[FA])!=null&&aA.latitude&&((mA=c[FA])!=null&&mA.longitude)&&H.add(FA);return H},[gt,c]),At=Bs(),F0=j.useMemo(()=>{if(Pe.size===0||!yA)return new Map;if(At.length===0)return new Map;const H=dn(yA);return Wa(At,Pe,H).scores},[Pe,yA,At]),nt=j.useCallback(H=>yA?!!(H.fromHash===yA&&Pe.has(H.toHash)||H.toHash===yA&&Pe.has(H.fromHash)):!1,[yA,Pe]),YA=j.useMemo(()=>{var aA,mA;if(P.length===0||!yA)return[];if(O.backgroundLoadComplete)return[];const H=[];for(const FA of P){if(FA.status==="expired"||!((aA=c[FA.hash])!=null&&aA.latitude)||!((mA=c[FA.hash])!=null&&mA.longitude))continue;const VA=[yA,FA.hash].sort(),xe=`${VA[0]}~${VA[1]}`;H.push({fromHash:yA,toHash:FA.hash,key:xe,packetCount:FA.count,avgConfidence:1,strength:.8,avgRecency:1,hopDistanceFromLocal:0,isHubConnection:!1,isCertain:!0,certainCount:FA.count,isLoopEdge:!1,forwardCount:FA.count,reverseCount:0,symmetryRatio:0,dominantDirection:"forward",floodCount:FA.count,directCount:0,isDirectPathEdge:!1,isZeroHop:!0,avgRssi:FA.avgRssi,avgSnr:FA.avgSnr})}return H},[P,yA,O.backgroundLoadComplete,c]),S=j.useMemo(()=>{const H=[];if(YA.length>0&&!O.backgroundLoadComplete){for(const aA of YA){const mA=Te.get(aA.fromHash),FA=Te.get(aA.toHash);mA&&FA&&H.push({from:mA,to:FA,edge:aA})}return H}for(const aA of E.validatedEdges){if(nt(aA))continue;const mA=Te.get(aA.fromHash),FA=Te.get(aA.toHash);mA&&FA&&H.push({from:mA,to:FA,edge:aA})}return H},[E.validatedEdges,Te,nt,YA,O.backgroundLoadComplete]),OA=j.useMemo(()=>{const H=[];for(const aA of E.weakEdges){if(nt(aA))continue;const mA=Te.get(aA.fromHash),FA=Te.get(aA.toHash);mA&&FA&&H.push({from:mA,to:FA,edge:aA})}return H},[E.weakEdges,Te,nt]),Nt=j.useMemo(()=>{if(!(u!=null&&u.latitude)||!(u!=null&&u.longitude))return[];const H=[],aA=[u.latitude,u.longitude],mA=new Map;for(const VA of E.lastHopNeighbors)mA.set(VA.hash,VA.count);const FA=new Map;for(const VA of P)FA.set(VA.hash,VA.count);for(const VA of Pe){const xe=c[VA];if(!(xe!=null&&xe.latitude)||!(xe!=null&&xe.longitude))continue;const tt=FA.get(VA),Me=mA.get(VA);H.push({from:aA,to:[xe.latitude,xe.longitude],hash:VA,neighbor:xe,lastHopData:gt.get(VA)??null,rxAdvertCount:tt,txProxyCount:Me})}return H},[u,Pe,c,gt,E.lastHopNeighbors,P]),P0=j.useMemo(()=>new Set(E.loopEdgeKeys),[E.loopEdgeKeys]),l0=j.useMemo(()=>new Set(E.backboneEdges),[E.backboneEdges]),a0=j.useMemo(()=>{if(!Rt)return null;const H=E.validatedEdges.filter(VA=>VA.fromHash===Rt||VA.toHash===Rt);if(H.length===0)return null;const aA=[...H].sort((VA,xe)=>xe.certainCount-VA.certainCount),mA=Math.max(1,Math.ceil(aA.length*.2)),FA=aA.slice(0,mA);return new Set(FA.map(VA=>VA.key))},[Rt,E.validatedEdges]),m0=j.useMemo(()=>{let H=0;if(YA.length>0&&!O.backgroundLoadComplete){for(const aA of YA)aA.certainCount>H&&(H=aA.certainCount);return H||1}for(const aA of E.validatedEdges)aA.certainCount>H&&(H=aA.certainCount);return H||1},[E.validatedEdges,YA,O.backgroundLoadComplete]),b=j.useMemo(()=>{if(E.validatedEdges.length===0)return null;const H=new Set;for(const FA of E.validatedEdges)H.add(FA.fromHash),H.add(FA.toHash);const aA=Array.from(H).filter(FA=>Te.has(FA)).sort();if(aA.length<3)return null;const mA=new Map;for(const FA of aA){const VA=Te.get(FA);VA&&mA.set(FA,VA)}return nu(E.validatedEdges,aA,mA,E.edgeBetweenness)},[E.validatedEdges,Te,E.edgeBetweenness]),E0=j.useCallback(()=>{qe(H=>{const aA=!H;if(aA&&b&&D.current){const mA=D.current.getMap();if(!mA)return aA;let FA=1/0,VA=-1/0,xe=1/0,tt=-1/0,Me=!1;for(const[,ut]of b.communities)for(const Ze of ut){const yt=Te.get(Ze);if(yt){const[st,St]=yt;xe=Math.min(xe,st),tt=Math.max(tt,st),FA=Math.min(FA,St),VA=Math.max(VA,St),Me=!0}}Me&&mA.fitBounds([[FA,xe],[VA,tt]],{padding:{top:60,bottom:100,left:60,right:320},duration:800,maxZoom:14})}return aA})},[b,Te]),$t=j.useRef(null);j.useLayoutEffect(()=>{var H,aA;$t.current=((aA=(H=D.current)==null?void 0:H.getMap)==null?void 0:aA.call(H))??null});const Q0=Bs();d1({map:$t,nodeCoordinates:Te,packets:Q0,localHash:yA,neighbors:c,meshTopology:E,enabled:IA});const{isExiting:O0,isAnimating:S0,resetAnimationState:d}=$2({map:$t,showTopology:MA,validatedPolylines:S,weakPolylines:OA,maxCertainCount:m0,loopEdgeKeys:P0,backboneEdgeKeys:l0,highlightedEdgeKey:T,neighbors:c,validatedSourceId:Fs,weakSourceId:Ps,neighborPolylines:Nt,showNeighborLines:ae,neighborSourceId:Qs,neighborLinkScores:F0,basemapMode:t}),v=j.useMemo(()=>{const H=new Set;for(const aA of E.hubNodes){H.add(aA);for(const mA of E.validatedEdges)mA.fromHash===aA&&H.add(mA.toHash),mA.toHash===aA&&H.add(mA.fromHash)}return H},[E.hubNodes,E.validatedEdges]),_=j.useMemo(()=>{const H=new Set;if(!p)return H;for(const aA of E.validatedEdges)aA.fromHash===p&&H.add(aA.toHash),aA.toHash===p&&H.add(aA.fromHash);return H},[p,E.validatedEdges]),F=j.useMemo(()=>{const H=new Map;for(const[aA,mA]of mt)H.set(aA,bu(mA).type);return H},[mt]),X=j.useMemo(()=>{let H=0,aA=0,mA=0;for(const[,FA]of F)FA==="repeater"?H++:FA==="companion"||FA==="unknown"?aA++:FA==="room_server"&&mA++;return{repeater:H,companion:aA,room_server:mA,hubs:E.hubNodes.length,direct:Pe.size}},[F,E.hubNodes.length,Pe.size]),K=j.useMemo(()=>new Set(Se),[Se]),{getNodeOpacity:dA}=q2({activeFilters:K,neighborHashes:mt.map(([H])=>H),hubConnectedNodes:v,directNodeSet:Pe,localConnectedNodes:_,nodeTypeMap:F,showTopology:MA}),{blinkingNodes:jA,blinkColor:XA}=e1({neighbors:c,localHash:p,enabled:IA}),Ae=j.useCallback(H=>{if(K.size===0)return!1;const aA=F.get(H)??"unknown";return!!(K.has("repeater")&&aA==="repeater"||K.has("companion")&&(aA==="companion"||aA==="unknown")||K.has("room_server")&&aA==="room_server"||K.has("direct")&&Pe.has(H)||K.has("hubs")&&v.has(H))},[K,F,Pe,v]),ce=j.useCallback(()=>{d0(!0),N0(!0)},[]),Ge=j.useCallback(()=>{at?Ke(H=>!H):ce()},[at,ce]),kt=j.useCallback(H=>{kA(H.viewState),(H.viewState.pitch??0)>10&&!ue&&Xe(!0)},[ue]),Ct=j.useCallback(()=>{TA(H=>{var FA,VA,xe,tt,Me,ut,Ze;const aA=!H,mA=(xe=(VA=(FA=D.current)==null?void 0:FA.getContainer())==null?void 0:VA.closest(".map-container-fullscreen, .map-container-16-9"))==null?void 0:xe.parentElement;return aA?mA&&document.fullscreenEnabled?(tt=mA.requestFullscreen)==null||tt.call(mA).catch(()=>{}):mA&&document.webkitFullscreenEnabled&&((Me=mA.webkitRequestFullscreen)==null||Me.call(mA)):document.fullscreenElement?(ut=document.exitFullscreen)==null||ut.call(document).catch(()=>{}):document.webkitFullscreenElement&&((Ze=document.webkitExitFullscreen)==null||Ze.call(document)),aA})},[]),pt=j.useCallback(()=>{const H=Se.length>=un.length;Qe(H?[]:[...un])},[Se,Qe]),je=j.useCallback(H=>{Se.length>=un.length?Qe([H]):Se.includes(H)?Qe(Se.filter(mA=>mA!==H)):Qe([...Se,H])},[Se,Qe]),Et=j.useCallback(()=>{$e(H=>!H)},[]),g0=j.useCallback(()=>{UA(H=>!H)},[]),u0=j.useCallback(()=>{vt(H=>{const aA=!H;return aA||Kt(null),aA})},[]),z0=j.useCallback(()=>{Xe(H=>{const aA=!H;if(D.current){const mA=D.current.getMap();mA&&mA.stop()}if(aA&&D.current){const mA=D.current.getMap();mA&&mA.easeTo({pitch:45,duration:1500,easing:Go})}if(!aA&&D.current){const mA=D.current.getMap();mA&&mA.easeTo({pitch:0,bearing:0,duration:800,easing:fu})}return aA})},[]),qt=j.useCallback(()=>{MA||Ke(!0)},[MA]),M0=j.useCallback((H,aA)=>{C0(H),f0(aA)},[]),nr=j.useCallback(()=>{zt&&y&&y(zt),C0(null),f0("")},[zt,y]),sr=j.useMemo(()=>[...N1,..._1,...ke?[Un]:[]],[ke]),Vr=j.useCallback(H=>{var mA;if((mA=H.features)==null?void 0:mA.some(FA=>{var VA,xe;return(xe=(VA=FA.layer)==null?void 0:VA.id)==null?void 0:xe.startsWith("node-markers-")})){$A(null),ot(null);return}if(ke&&H.features&&H.features.length>0){const FA=H.features.find(VA=>{var xe;return((xe=VA.layer)==null?void 0:xe.id)===Un});if(FA!=null&&FA.properties){const{fromHash:VA,toHash:xe}=FA.properties;if(VA&&xe){const tt=W.find(Me=>Me.nodeA.hash===VA&&Me.nodeB.hash===xe||Me.nodeA.hash===xe&&Me.nodeB.hash===VA);if(tt){Kt(tt),xt(null);return}}}}xt(null),$A(null),ot(null),b0(null),Kt(null)},[ke,W]),Wr=j.useCallback(H=>{b0(aA=>aA===H?null:H),Kt(null)},[]),Yr=j.useCallback(H=>{var Me,ut,Ze;if(!H.features||H.features.length===0)return;if(H.features.some(yt=>{var st,St;return(St=(st=yt.layer)==null?void 0:st.id)==null?void 0:St.startsWith("node-markers-")})){ze&&(ot(null),$A(null));return}if(ke&&H.features.some(yt=>{var st;return((st=yt.layer)==null?void 0:st.id)===Un})){try{(Me=D.current)!=null&&Me.getCanvas()&&(D.current.getCanvas().style.cursor="pointer")}catch{}return}const mA=H.features.find(yt=>{var St;const st=(St=yt.layer)==null?void 0:St.id;return(st==null?void 0:st.startsWith("topology-"))||(st==null?void 0:st.startsWith("neighbor-"))});if(!mA)return;const FA=(ut=mA.layer)==null?void 0:ut.id,VA=mA.properties;if(!(VA!=null&&VA.key))return;const xe=FA==null?void 0:FA.startsWith("topology-"),tt=FA==null?void 0:FA.startsWith("neighbor-");if(xe||tt){const yt=VA.key.replace(/-loop[12]$/,"");ot(yt),H.lngLat&&$A({longitude:H.lngLat.lng,latitude:H.lngLat.lat,type:xe?"topology":"neighbor",properties:VA})}try{(Ze=D.current)!=null&&Ze.getCanvas()&&(D.current.getCanvas().style.cursor="pointer")}catch{}},[ze,ke]),Ft=j.useCallback(()=>{var H;ot(null),$A(null);try{(H=D.current)!=null&&H.getCanvas()&&(D.current.getCanvas().style.cursor="")}catch{}},[]),ir=lA?"map-container-fullscreen":"map-container-16-9",c0=bA.length>0||(u==null?void 0:u.latitude)&&(u==null?void 0:u.longitude),Ne=!oA||!c0,B0=c0;return g.jsxs("div",{className:`relative ${ir} ${lA?"":"rounded-2xl overflow-hidden"}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":t,children:[g.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."}),Ne&&g.jsx("div",{className:"absolute inset-0 z-50 surface-base rounded-2xl flex items-center justify-center","aria-hidden":"true",children:g.jsxs("div",{className:"flex flex-col items-center gap-3",children:[g.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),g.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]})}),B0&&g.jsx("div",{className:`relative w-full h-full ${lA?"":"rounded-[1.125rem] overflow-hidden"} ${Ne?"opacity-0":"opacity-100 transition-opacity duration-300"}`,style:fA?{visibility:"hidden"}:void 0,children:g.jsxs(Ha,{ref:D,...NA,onMove:kt,mapStyle:$1,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:sr,onMouseMove:Yr,onMouseLeave:Ft,onClick:Vr,onError:H=>{console.error("MapLibre error:",H.error)},onIdle:()=>{if(!EA&&!DA&&D.current){const H=D.current.getMap();if(H){const aA=Object.values(c).filter(mA=>mA.latitude&&mA.longitude).map(mA=>({latitude:mA.latitude,longitude:mA.longitude}));u!=null&&u.latitude&&(u!=null&&u.longitude)&&aA.push({latitude:u.latitude,longitude:u.longitude}),aA.length>0&&RA(aA,H)}}},children:[g.jsx(Ga,{position:"bottom-right"}),g.jsx(Ua,{mode:t}),g.jsx(v2,{enabled:ue,exaggeration:4}),g.jsx(w2,{coveragePoints:It,visible:It.length>0&&ht,terrainEnabled:ue,brightness:rA,basemapMode:t}),g.jsx(V2,{partition:b,nodeCoordinates:Te,visible:Ie&&at,opacity:se.opacity,bandwidth:se.bandwidth,threshold:se.threshold,strokeWidth:se.strokeWidth}),g.jsx(L1,{showTopology:MA,isExiting:O0,hoveredEdgeKey:ze,highlightedLoopEdges:ye==null?void 0:ye.highlightedEdgeKeys,highlightedFocusEdges:a0,onEdgeHover:_e,onLoopHover:ie,loops:E.loops,neighborNames:Lt,opacityBias:L0,widthMultiplier:er,trafficFilter:k0,showNeighborLines:ae,disableHover:S0||gA}),g.jsx(U1,{visible:ke,nodeCoordinates:Te,focusedNodeHash:Rt,basemapMode:t}),x&&g.jsx(F1,{targetHash:x,nodeCoordinates:Te,onComplete:C}),T&&g.jsx(P1,{highlightedEdgeKey:T,validatedPolylines:S,weakPolylines:OA,onEnsureTopology:qt}),g.jsx(Z1,{ghost:Q??null,neighborCoordinates:Te,onHighlightedNeighborsChange:wt}),g.jsx(D1,{neighborsWithLocation:mt,localNode:u,localHash:p,zeroHopNeighbors:Pe,lastHopNeighborMap:gt,meshTopology:E,hoveredMarker:Je,onMarkerHover:Be,getNodeOpacity:dA,shouldShowNode:Ae,onRequestRemove:y?M0:void 0,openPopupId:Zt,onOpenPopup:bt,onClosePopup:o0,onNodeClick:Wr,blinkingNodes:jA,blinkColor:XA})]})}),(()=>{const H=ed(He?{type:He.type,properties:He.properties}:null,ye,m0,E.edgeMap);return H&&g.jsx("div",{className:"map-edge-tooltip",children:g.jsx("div",{className:"map-control-surface map-edge-tooltip-inner",children:g.jsx(td,{data:H})})})})(),g.jsx(kc,{mapRef:D,showNeighborLines:ae,onToggleNeighborLines:Et,hasNeighborPolylines:Nt.length>0,nodeFilters:Se,onToggleFilter:je,onToggleAll:pt,filterCounts:X,showCoverage:ZA,onToggleCoverage:g0,showMinCut:Ie,onToggleMinCut:E0,hasMinCutData:at&&b!==null&&b.numCommunities>1,show3DTerrain:ue,onToggle3DTerrain:z0,basemapMode:t,onToggleBasemap:k,isFullscreen:lA,onToggleFullscreen:Ct,showLinkQuality:ke,onToggleLinkQuality:u0,hasTraceLinks:V}),ke&&Yt&&g.jsx(wf,{pair:Yt,onClose:()=>Kt(null),prefixToName:h0}),g.jsxs("div",{className:"map-legend-stack",children:[g.jsxs("div",{className:"map-tool-row",children:[g.jsx(Tc,{isActive:MA,hasAnalyzed:at,isLoading:gA,onClick:Ge,basemapMode:t}),g.jsx(Pc,{isActive:IA,onClick:xA,basemapMode:t}),g.jsx(Vc,{isActive:It.length>0&&ht,onClick:pA,basemapMode:t})]}),g.jsx(wc,{showTopology:MA,validatedPolylineCount:S.length,filteredNeighborCount:mt.length,hasLocalNode:!!(u!=null&&u.latitude&&(u!=null&&u.longitude)),meshTopology:E,zeroHopNeighbors:Pe,neighborsWithLocation:mt,basemapMode:t})]}),g.jsx(Ya,{isOpen:zt!==null,onCancel:()=>C0(null),onConfirm:nr,title:"Remove Node?",message:`Remove "${tr}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),g.jsx(cc,{isOpen:rr,onClose:()=>{N0(!1),d0(!1),d(),i0(!0),setTimeout(()=>Ke(!0),mc)}}),g.jsx(cf,{}),g.jsx(df,{visible:Ie&&at,onClose:()=>qe(!1),settings:se,onSettingsChange:me,partition:b,totalNodes:Object.keys(c).length,basemapMode:t})]})}export{Ud as default};
