@aibee/crc-bmap 0.8.51 → 0.8.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.esm.js +15 -11
- package/lib/bmap.esm.min.js +1 -1
- package/lib/bmap.min.js +1 -1
- package/lib/src/plugins/pdr-position/pdr.d.ts +1 -0
- package/lib/src/plugins/pdr-position/pdr.js +15 -11
- package/lib/src/plugins/pdr-position/position.js +1 -0
- package/lib/src/utils/road2.d.ts +7 -7
- package/package.json +1 -1
package/lib/bmap.cjs.min.js
CHANGED
|
@@ -7741,4 +7741,4 @@ void main() {
|
|
|
7741
7741
|
|
|
7742
7742
|
}\`,fm=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,o){if(this.texture===null){let a=new Vi,l=t.properties.get(a);l.__webglTexture=e.texture,(e.depthNear!=o.depthNear||e.depthFar!=o.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=a}}render(t,e){if(this.texture!==null){if(this.mesh===null){let o=e.cameras[0].viewport,a=new Ao({extensions:{fragDepth:!0},vertexShader:gF,fragmentShader:yF,uniforms:{depthColor:{value:this.texture},depthWidth:{value:o.z},depthHeight:{value:o.w}}});this.mesh=new fo(new Pf(20,20),a)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},hm=class extends Rs{constructor(t,e){super();let o=this,a=null,l=1,h=null,f="local-floor",p=1,d=null,g=null,x=null,v=null,S=null,b=null,T=new fm,_=e.getContextAttributes(),y=null,A=null,M=[],L=[],G=new un,z=null,F=new Ri;F.layers.enable(1),F.viewport=new Br;let I=new Ri;I.layers.enable(2),I.viewport=new Br;let ut=[F,I],R=new cm;R.layers.enable(1),R.layers.enable(2);let W=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(tt){let wt=M[tt];return wt===void 0&&(wt=new Ml,M[tt]=wt),wt.getTargetRaySpace()},this.getControllerGrip=function(tt){let wt=M[tt];return wt===void 0&&(wt=new Ml,M[tt]=wt),wt.getGripSpace()},this.getHand=function(tt){let wt=M[tt];return wt===void 0&&(wt=new Ml,M[tt]=wt),wt.getHandSpace()};function St(tt){let wt=L.indexOf(tt.inputSource);if(wt===-1)return;let Bt=M[wt];Bt!==void 0&&(Bt.update(tt.inputSource,tt.frame,d||h),Bt.dispatchEvent({type:tt.type,data:tt.inputSource}))}function X(){a.removeEventListener("select",St),a.removeEventListener("selectstart",St),a.removeEventListener("selectend",St),a.removeEventListener("squeeze",St),a.removeEventListener("squeezestart",St),a.removeEventListener("squeezeend",St),a.removeEventListener("end",X),a.removeEventListener("inputsourceschange",mt);for(let tt=0;tt<M.length;tt++){let wt=L[tt];wt!==null&&(L[tt]=null,M[tt].disconnect(wt))}W=null,V=null,T.reset(),t.setRenderTarget(y),S=null,v=null,x=null,a=null,A=null,Yt.stop(),o.isPresenting=!1,t.setPixelRatio(z),t.setSize(G.width,G.height,!1),o.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(tt){l=tt,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(tt){f=tt,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||h},this.setReferenceSpace=function(tt){d=tt},this.getBaseLayer=function(){return v!==null?v:S},this.getBinding=function(){return x},this.getFrame=function(){return b},this.getSession=function(){return a},this.setSession=function(tt){return oc(this,null,function*(){if(a=tt,a!==null){if(y=t.getRenderTarget(),a.addEventListener("select",St),a.addEventListener("selectstart",St),a.addEventListener("selectend",St),a.addEventListener("squeeze",St),a.addEventListener("squeezestart",St),a.addEventListener("squeezeend",St),a.addEventListener("end",X),a.addEventListener("inputsourceschange",mt),_.xrCompatible!==!0&&(yield e.makeXRCompatible()),z=t.getPixelRatio(),t.getSize(G),a.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let wt={antialias:a.renderState.layers===void 0?_.antialias:!0,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:l};S=new XRWebGLLayer(a,e,wt),a.updateRenderState({baseLayer:S}),t.setPixelRatio(1),t.setSize(S.framebufferWidth,S.framebufferHeight,!1),A=new ss(S.framebufferWidth,S.framebufferHeight,{format:co,type:Ps,colorSpace:t.outputColorSpace,stencilBuffer:_.stencil})}else{let wt=null,Bt=null,$t=null;_.depth&&($t=_.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,wt=_.stencil?yu:ha,Bt=_.stencil?fa:Ts);let Ut={colorFormat:e.RGBA8,depthFormat:$t,scaleFactor:l};x=new XRWebGLBinding(a,e),v=x.createProjectionLayer(Ut),a.updateRenderState({layers:[v]}),t.setPixelRatio(1),t.setSize(v.textureWidth,v.textureHeight,!1),A=new ss(v.textureWidth,v.textureHeight,{format:co,type:Ps,depthTexture:new Rf(v.textureWidth,v.textureHeight,Bt,void 0,void 0,void 0,void 0,void 0,void 0,wt),stencilBuffer:_.stencil,colorSpace:t.outputColorSpace,samples:_.antialias?4:0});let Dt=t.properties.get(A);Dt.__ignoreDepthValues=v.ignoreDepthValues}A.isXRRenderTarget=!0,this.setFoveation(p),d=null,h=yield a.requestReferenceSpace(f),Yt.setContext(a),Yt.start(),o.isPresenting=!0,o.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(a!==null)return a.environmentBlendMode};function mt(tt){for(let wt=0;wt<tt.removed.length;wt++){let Bt=tt.removed[wt],$t=L.indexOf(Bt);$t>=0&&(L[$t]=null,M[$t].disconnect(Bt))}for(let wt=0;wt<tt.added.length;wt++){let Bt=tt.added[wt],$t=L.indexOf(Bt);if($t===-1){for(let Dt=0;Dt<M.length;Dt++)if(Dt>=L.length){L.push(Bt),$t=Dt;break}else if(L[Dt]===null){L[Dt]=Bt,$t=Dt;break}if($t===-1)break}let Ut=M[$t];Ut&&Ut.connect(Bt)}}let dt=new xt,vt=new xt;function rt(tt,wt,Bt){dt.setFromMatrixPosition(wt.matrixWorld),vt.setFromMatrixPosition(Bt.matrixWorld);let $t=dt.distanceTo(vt),Ut=wt.projectionMatrix.elements,Dt=Bt.projectionMatrix.elements,At=Ut[14]/(Ut[10]-1),te=Ut[14]/(Ut[10]+1),nt=(Ut[9]+1)/Ut[5],on=(Ut[9]-1)/Ut[5],zt=(Ut[8]-1)/Ut[0],ne=(Dt[8]+1)/Dt[0],Wt=At*zt,ie=At*ne,ce=$t/(-zt+ne),Lt=ce*-zt;wt.matrixWorld.decompose(tt.position,tt.quaternion,tt.scale),tt.translateX(Lt),tt.translateZ(ce),tt.matrixWorld.compose(tt.position,tt.quaternion,tt.scale),tt.matrixWorldInverse.copy(tt.matrixWorld).invert();let se=At+ce,Y=te+ce,N=Wt-Lt,_t=ie+($t-Lt),Et=nt*te/Y*se,it=on*te/Y*se;tt.projectionMatrix.makePerspective(N,_t,Et,it,se,Y),tt.projectionMatrixInverse.copy(tt.projectionMatrix).invert()}function lt(tt,wt){wt===null?tt.matrixWorld.copy(tt.matrix):tt.matrixWorld.multiplyMatrices(wt.matrixWorld,tt.matrix),tt.matrixWorldInverse.copy(tt.matrixWorld).invert()}this.updateCamera=function(tt){if(a===null)return;T.texture!==null&&(tt.near=T.depthNear,tt.far=T.depthFar),R.near=I.near=F.near=tt.near,R.far=I.far=F.far=tt.far,(W!==R.near||V!==R.far)&&(a.updateRenderState({depthNear:R.near,depthFar:R.far}),W=R.near,V=R.far,F.near=W,F.far=V,I.near=W,I.far=V,F.updateProjectionMatrix(),I.updateProjectionMatrix(),tt.updateProjectionMatrix());let wt=tt.parent,Bt=R.cameras;lt(R,wt);for(let $t=0;$t<Bt.length;$t++)lt(Bt[$t],wt);Bt.length===2?rt(R,F,I):R.projectionMatrix.copy(F.projectionMatrix),H(tt,R,wt)};function H(tt,wt,Bt){Bt===null?tt.matrix.copy(wt.matrixWorld):(tt.matrix.copy(Bt.matrixWorld),tt.matrix.invert(),tt.matrix.multiply(wt.matrixWorld)),tt.matrix.decompose(tt.position,tt.quaternion,tt.scale),tt.updateMatrixWorld(!0),tt.projectionMatrix.copy(wt.projectionMatrix),tt.projectionMatrixInverse.copy(wt.projectionMatrixInverse),tt.isPerspectiveCamera&&(tt.fov=$d*2*Math.atan(1/tt.projectionMatrix.elements[5]),tt.zoom=1)}this.getCamera=function(){return R},this.getFoveation=function(){if(!(v===null&&S===null))return p},this.setFoveation=function(tt){p=tt,v!==null&&(v.fixedFoveation=tt),S!==null&&S.fixedFoveation!==void 0&&(S.fixedFoveation=tt)},this.hasDepthSensing=function(){return T.texture!==null};let bt=null;function Tt(tt,wt){if(g=wt.getViewerPose(d||h),b=wt,g!==null){let Bt=g.views;S!==null&&(t.setRenderTargetFramebuffer(A,S.framebuffer),t.setRenderTarget(A));let $t=!1;Bt.length!==R.cameras.length&&(R.cameras.length=0,$t=!0);for(let Dt=0;Dt<Bt.length;Dt++){let At=Bt[Dt],te=null;if(S!==null)te=S.getViewport(At);else{let on=x.getViewSubImage(v,At);te=on.viewport,Dt===0&&(t.setRenderTargetTextures(A,on.colorTexture,v.ignoreDepthValues?void 0:on.depthStencilTexture),t.setRenderTarget(A))}let nt=ut[Dt];nt===void 0&&(nt=new Ri,nt.layers.enable(Dt),nt.viewport=new Br,ut[Dt]=nt),nt.matrix.fromArray(At.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(At.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(te.x,te.y,te.width,te.height),Dt===0&&(R.matrix.copy(nt.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),$t===!0&&R.cameras.push(nt)}let Ut=a.enabledFeatures;if(Ut&&Ut.includes("depth-sensing")){let Dt=x.getDepthInformation(Bt[0]);Dt&&Dt.isValid&&Dt.texture&&T.init(t,Dt,a.renderState)}}for(let Bt=0;Bt<M.length;Bt++){let $t=L[Bt],Ut=M[Bt];$t!==null&&Ut!==void 0&&Ut.update($t,wt,d||h)}T.render(t,R),bt&&bt(tt,wt),wt.detectedPlanes&&o.dispatchEvent({type:"planesdetected",data:wt}),b=null}let Yt=new FE;Yt.setAnimationLoop(Tt),this.setAnimationLoop=function(tt){bt=tt},this.dispose=function(){}}},sa=new da,vF=new Tr;function _F(r,t){function e(_,y){_.matrixAutoUpdate===!0&&_.updateMatrix(),y.value.copy(_.matrix)}function o(_,y){y.color.getRGB(_.fogColor.value,DE(r)),y.isFog?(_.fogNear.value=y.near,_.fogFar.value=y.far):y.isFogExp2&&(_.fogDensity.value=y.density)}function a(_,y,A,M,L){y.isMeshBasicMaterial||y.isMeshLambertMaterial?l(_,y):y.isMeshToonMaterial?(l(_,y),x(_,y)):y.isMeshPhongMaterial?(l(_,y),g(_,y)):y.isMeshStandardMaterial?(l(_,y),v(_,y),y.isMeshPhysicalMaterial&&S(_,y,L)):y.isMeshMatcapMaterial?(l(_,y),b(_,y)):y.isMeshDepthMaterial?l(_,y):y.isMeshDistanceMaterial?(l(_,y),T(_,y)):y.isMeshNormalMaterial?l(_,y):y.isLineBasicMaterial?(h(_,y),y.isLineDashedMaterial&&f(_,y)):y.isPointsMaterial?p(_,y,A,M):y.isSpriteMaterial?d(_,y):y.isShadowMaterial?(_.color.value.copy(y.color),_.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function l(_,y){_.opacity.value=y.opacity,y.color&&_.diffuse.value.copy(y.color),y.emissive&&_.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(_.map.value=y.map,e(y.map,_.mapTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,e(y.alphaMap,_.alphaMapTransform)),y.bumpMap&&(_.bumpMap.value=y.bumpMap,e(y.bumpMap,_.bumpMapTransform),_.bumpScale.value=y.bumpScale,y.side===xi&&(_.bumpScale.value*=-1)),y.normalMap&&(_.normalMap.value=y.normalMap,e(y.normalMap,_.normalMapTransform),_.normalScale.value.copy(y.normalScale),y.side===xi&&_.normalScale.value.negate()),y.displacementMap&&(_.displacementMap.value=y.displacementMap,e(y.displacementMap,_.displacementMapTransform),_.displacementScale.value=y.displacementScale,_.displacementBias.value=y.displacementBias),y.emissiveMap&&(_.emissiveMap.value=y.emissiveMap,e(y.emissiveMap,_.emissiveMapTransform)),y.specularMap&&(_.specularMap.value=y.specularMap,e(y.specularMap,_.specularMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest);let A=t.get(y),M=A.envMap,L=A.envMapRotation;if(M&&(_.envMap.value=M,sa.copy(L),sa.x*=-1,sa.y*=-1,sa.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(sa.y*=-1,sa.z*=-1),_.envMapRotation.value.setFromMatrix4(vF.makeRotationFromEuler(sa)),_.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,_.reflectivity.value=y.reflectivity,_.ior.value=y.ior,_.refractionRatio.value=y.refractionRatio),y.lightMap){_.lightMap.value=y.lightMap;let G=r._useLegacyLights===!0?Math.PI:1;_.lightMapIntensity.value=y.lightMapIntensity*G,e(y.lightMap,_.lightMapTransform)}y.aoMap&&(_.aoMap.value=y.aoMap,_.aoMapIntensity.value=y.aoMapIntensity,e(y.aoMap,_.aoMapTransform))}function h(_,y){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,y.map&&(_.map.value=y.map,e(y.map,_.mapTransform))}function f(_,y){_.dashSize.value=y.dashSize,_.totalSize.value=y.dashSize+y.gapSize,_.scale.value=y.scale}function p(_,y,A,M){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,_.size.value=y.size*A,_.scale.value=M*.5,y.map&&(_.map.value=y.map,e(y.map,_.uvTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,e(y.alphaMap,_.alphaMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest)}function d(_,y){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,_.rotation.value=y.rotation,y.map&&(_.map.value=y.map,e(y.map,_.mapTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,e(y.alphaMap,_.alphaMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest)}function g(_,y){_.specular.value.copy(y.specular),_.shininess.value=Math.max(y.shininess,1e-4)}function x(_,y){y.gradientMap&&(_.gradientMap.value=y.gradientMap)}function v(_,y){_.metalness.value=y.metalness,y.metalnessMap&&(_.metalnessMap.value=y.metalnessMap,e(y.metalnessMap,_.metalnessMapTransform)),_.roughness.value=y.roughness,y.roughnessMap&&(_.roughnessMap.value=y.roughnessMap,e(y.roughnessMap,_.roughnessMapTransform)),t.get(y).envMap&&(_.envMapIntensity.value=y.envMapIntensity)}function S(_,y,A){_.ior.value=y.ior,y.sheen>0&&(_.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),_.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(_.sheenColorMap.value=y.sheenColorMap,e(y.sheenColorMap,_.sheenColorMapTransform)),y.sheenRoughnessMap&&(_.sheenRoughnessMap.value=y.sheenRoughnessMap,e(y.sheenRoughnessMap,_.sheenRoughnessMapTransform))),y.clearcoat>0&&(_.clearcoat.value=y.clearcoat,_.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(_.clearcoatMap.value=y.clearcoatMap,e(y.clearcoatMap,_.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,e(y.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(_.clearcoatNormalMap.value=y.clearcoatNormalMap,e(y.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===xi&&_.clearcoatNormalScale.value.negate())),y.iridescence>0&&(_.iridescence.value=y.iridescence,_.iridescenceIOR.value=y.iridescenceIOR,_.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(_.iridescenceMap.value=y.iridescenceMap,e(y.iridescenceMap,_.iridescenceMapTransform)),y.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=y.iridescenceThicknessMap,e(y.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),y.transmission>0&&(_.transmission.value=y.transmission,_.transmissionSamplerMap.value=A.texture,_.transmissionSamplerSize.value.set(A.width,A.height),y.transmissionMap&&(_.transmissionMap.value=y.transmissionMap,e(y.transmissionMap,_.transmissionMapTransform)),_.thickness.value=y.thickness,y.thicknessMap&&(_.thicknessMap.value=y.thicknessMap,e(y.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=y.attenuationDistance,_.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(_.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(_.anisotropyMap.value=y.anisotropyMap,e(y.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=y.specularIntensity,_.specularColor.value.copy(y.specularColor),y.specularColorMap&&(_.specularColorMap.value=y.specularColorMap,e(y.specularColorMap,_.specularColorMapTransform)),y.specularIntensityMap&&(_.specularIntensityMap.value=y.specularIntensityMap,e(y.specularIntensityMap,_.specularIntensityMapTransform))}function b(_,y){y.matcap&&(_.matcap.value=y.matcap)}function T(_,y){let A=t.get(y).light;_.referencePosition.value.setFromMatrixPosition(A.matrixWorld),_.nearDistance.value=A.shadow.camera.near,_.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:o,refreshMaterialUniforms:a}}function xF(r,t,e,o){let a={},l={},h=[],f=e.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function p(A,M){let L=M.program;o.uniformBlockBinding(A,L)}function d(A,M){let L=a[A.id];L===void 0&&(b(A),L=g(A),a[A.id]=L,A.addEventListener("dispose",_));let G=M.program;o.updateUBOMapping(A,G);let z=t.render.frame;l[A.id]!==z&&(v(A),l[A.id]=z)}function g(A){let M=x();A.__bindingPointIndex=M;let L=r.createBuffer(),G=A.__size,z=A.usage;return r.bindBuffer(r.UNIFORM_BUFFER,L),r.bufferData(r.UNIFORM_BUFFER,G,z),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,M,L),L}function x(){for(let A=0;A<f;A++)if(h.indexOf(A)===-1)return h.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function v(A){let M=a[A.id],L=A.uniforms,G=A.__cache;r.bindBuffer(r.UNIFORM_BUFFER,M);for(let z=0,F=L.length;z<F;z++){let I=Array.isArray(L[z])?L[z]:[L[z]];for(let ut=0,R=I.length;ut<R;ut++){let W=I[ut];if(S(W,z,ut,G)===!0){let V=W.__offset,St=Array.isArray(W.value)?W.value:[W.value],X=0;for(let mt=0;mt<St.length;mt++){let dt=St[mt],vt=T(dt);typeof dt=="number"||typeof dt=="boolean"?(W.__data[0]=dt,r.bufferSubData(r.UNIFORM_BUFFER,V+X,W.__data)):dt.isMatrix3?(W.__data[0]=dt.elements[0],W.__data[1]=dt.elements[1],W.__data[2]=dt.elements[2],W.__data[3]=0,W.__data[4]=dt.elements[3],W.__data[5]=dt.elements[4],W.__data[6]=dt.elements[5],W.__data[7]=0,W.__data[8]=dt.elements[6],W.__data[9]=dt.elements[7],W.__data[10]=dt.elements[8],W.__data[11]=0):(dt.toArray(W.__data,X),X+=vt.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,V,W.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function S(A,M,L,G){let z=A.value,F=M+"_"+L;if(G[F]===void 0)return typeof z=="number"||typeof z=="boolean"?G[F]=z:G[F]=z.clone(),!0;{let I=G[F];if(typeof z=="number"||typeof z=="boolean"){if(I!==z)return G[F]=z,!0}else if(I.equals(z)===!1)return I.copy(z),!0}return!1}function b(A){let M=A.uniforms,L=0,G=16;for(let F=0,I=M.length;F<I;F++){let ut=Array.isArray(M[F])?M[F]:[M[F]];for(let R=0,W=ut.length;R<W;R++){let V=ut[R],St=Array.isArray(V.value)?V.value:[V.value];for(let X=0,mt=St.length;X<mt;X++){let dt=St[X],vt=T(dt),rt=L%G;rt!==0&&G-rt<vt.boundary&&(L+=G-rt),V.__data=new Float32Array(vt.storage/Float32Array.BYTES_PER_ELEMENT),V.__offset=L,L+=vt.storage}}}let z=L%G;return z>0&&(L+=G-z),A.__size=L,A.__cache={},this}function T(A){let M={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(M.boundary=4,M.storage=4):A.isVector2?(M.boundary=8,M.storage=8):A.isVector3||A.isColor?(M.boundary=16,M.storage=12):A.isVector4?(M.boundary=16,M.storage=16):A.isMatrix3?(M.boundary=48,M.storage=48):A.isMatrix4?(M.boundary=64,M.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),M}function _(A){let M=A.target;M.removeEventListener("dispose",_);let L=h.indexOf(M.__bindingPointIndex);h.splice(L,1),r.deleteBuffer(a[M.id]),delete a[M.id],delete l[M.id]}function y(){for(let A in a)r.deleteBuffer(a[A]);h=[],a={},l={}}return{bind:p,update:d,dispose:y}}var pm=class{constructor(t={}){let{canvas:e=MN(),context:o=null,depth:a=!0,stencil:l=!0,alpha:h=!1,antialias:f=!1,premultipliedAlpha:p=!0,preserveDrawingBuffer:d=!1,powerPreference:g="default",failIfMajorPerformanceCaveat:x=!1}=t;this.isWebGLRenderer=!0;let v;o!==null?v=o.getContextAttributes().alpha:v=h;let S=new Uint32Array(4),b=new Int32Array(4),T=null,_=null,y=[],A=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=wo,this._useLegacyLights=!1,this.toneMapping=Cs,this.toneMappingExposure=1;let M=this,L=!1,G=0,z=0,F=null,I=-1,ut=null,R=new Br,W=new Br,V=null,St=new En(0),X=0,mt=e.width,dt=e.height,vt=1,rt=null,lt=null,H=new Br(0,0,mt,dt),bt=new Br(0,0,mt,dt),Tt=!1,Yt=new Cf,tt=!1,wt=!1,Bt=null,$t=new Tr,Ut=new un,Dt=new xt,At={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function te(){return F===null?vt:1}let nt=o;function on(q,ot){for(let yt=0;yt<q.length;yt++){let ht=q[yt],at=e.getContext(ht,ot);if(at!==null)return at}return null}try{let q={alpha:!0,depth:a,stencil:l,antialias:f,premultipliedAlpha:p,preserveDrawingBuffer:d,powerPreference:g,failIfMajorPerformanceCaveat:x};if("setAttribute"in e&&e.setAttribute("data-engine",\`three.js r\${bm}\`),e.addEventListener("webglcontextlost",ct,!1),e.addEventListener("webglcontextrestored",O,!1),e.addEventListener("webglcontextcreationerror",K,!1),nt===null){let ot=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&ot.shift(),nt=on(ot,q),nt===null)throw on(ot)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&nt instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),nt.getShaderPrecisionFormat===void 0&&(nt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(q){throw console.error("THREE.WebGLRenderer: "+q.message),q}let zt,ne,Wt,ie,ce,Lt,se,Y,N,_t,Et,it,Pt,ue,Ct,Ot,qt,J,w,P,D,k,B,et;function j(){zt=new FD(nt),ne=new ID(nt,zt,t),zt.init(ne),k=new dF(nt,zt,ne),Wt=new hF(nt,zt,ne),ie=new zD(nt),ce=new tF,Lt=new pF(nt,zt,Wt,ce,ne,k,ie),se=new LD(M),Y=new DD(M),N=new WN(nt,ne),B=new CD(nt,zt,N,ne),_t=new UD(nt,N,ie,B),Et=new VD(nt,_t,N,ie),w=new qD(nt,ne,Lt),Ot=new RD(ce),it=new Q3(M,se,Y,zt,ne,B,Ot),Pt=new _F(M,ce),ue=new nF,Ct=new uF(zt,ne),J=new AD(M,se,Y,Wt,Et,v,p),qt=new fF(M,Et,ne),et=new xF(nt,ie,ne,Wt),P=new PD(nt,zt,ie,ne),D=new BD(nt,zt,ie,ne),ie.programs=it.programs,M.capabilities=ne,M.extensions=zt,M.properties=ce,M.renderLists=ue,M.shadowMap=qt,M.state=Wt,M.info=ie}j();let ft=new hm(M,nt);this.xr=ft,this.getContext=function(){return nt},this.getContextAttributes=function(){return nt.getContextAttributes()},this.forceContextLoss=function(){let q=zt.get("WEBGL_lose_context");q&&q.loseContext()},this.forceContextRestore=function(){let q=zt.get("WEBGL_lose_context");q&&q.restoreContext()},this.getPixelRatio=function(){return vt},this.setPixelRatio=function(q){q!==void 0&&(vt=q,this.setSize(mt,dt,!1))},this.getSize=function(q){return q.set(mt,dt)},this.setSize=function(q,ot,yt=!0){if(ft.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}mt=q,dt=ot,e.width=Math.floor(q*vt),e.height=Math.floor(ot*vt),yt===!0&&(e.style.width=q+"px",e.style.height=ot+"px"),this.setViewport(0,0,q,ot)},this.getDrawingBufferSize=function(q){return q.set(mt*vt,dt*vt).floor()},this.setDrawingBufferSize=function(q,ot,yt){mt=q,dt=ot,vt=yt,e.width=Math.floor(q*yt),e.height=Math.floor(ot*yt),this.setViewport(0,0,q,ot)},this.getCurrentViewport=function(q){return q.copy(R)},this.getViewport=function(q){return q.copy(H)},this.setViewport=function(q,ot,yt,ht){q.isVector4?H.set(q.x,q.y,q.z,q.w):H.set(q,ot,yt,ht),Wt.viewport(R.copy(H).multiplyScalar(vt).round())},this.getScissor=function(q){return q.copy(bt)},this.setScissor=function(q,ot,yt,ht){q.isVector4?bt.set(q.x,q.y,q.z,q.w):bt.set(q,ot,yt,ht),Wt.scissor(W.copy(bt).multiplyScalar(vt).round())},this.getScissorTest=function(){return Tt},this.setScissorTest=function(q){Wt.setScissorTest(Tt=q)},this.setOpaqueSort=function(q){rt=q},this.setTransparentSort=function(q){lt=q},this.getClearColor=function(q){return q.copy(J.getClearColor())},this.setClearColor=function(){J.setClearColor.apply(J,arguments)},this.getClearAlpha=function(){return J.getClearAlpha()},this.setClearAlpha=function(){J.setClearAlpha.apply(J,arguments)},this.clear=function(q=!0,ot=!0,yt=!0){let ht=0;if(q){let at=!1;if(F!==null){let Ht=F.texture.format;at=Ht===IE||Ht===PE||Ht===CE}if(at){let Ht=F.texture.type,Xt=Ht===Ps||Ht===Ts||Ht===Tm||Ht===fa||Ht===TE||Ht===AE,re=J.getClearColor(),Zt=J.getClearAlpha(),me=re.r,oe=re.g,ae=re.b;Xt?(S[0]=me,S[1]=oe,S[2]=ae,S[3]=Zt,nt.clearBufferuiv(nt.COLOR,0,S)):(b[0]=me,b[1]=oe,b[2]=ae,b[3]=Zt,nt.clearBufferiv(nt.COLOR,0,b))}else ht|=nt.COLOR_BUFFER_BIT}ot&&(ht|=nt.DEPTH_BUFFER_BIT),yt&&(ht|=nt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),nt.clear(ht)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ct,!1),e.removeEventListener("webglcontextrestored",O,!1),e.removeEventListener("webglcontextcreationerror",K,!1),ue.dispose(),Ct.dispose(),ce.dispose(),se.dispose(),Y.dispose(),Et.dispose(),B.dispose(),et.dispose(),it.dispose(),ft.dispose(),ft.removeEventListener("sessionstart",xe),ft.removeEventListener("sessionend",de),Bt&&(Bt.dispose(),Bt=null),Se.stop()};function ct(q){q.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),L=!0}function O(){console.log("THREE.WebGLRenderer: Context Restored."),L=!1;let q=ie.autoReset,ot=qt.enabled,yt=qt.autoUpdate,ht=qt.needsUpdate,at=qt.type;j(),ie.autoReset=q,qt.enabled=ot,qt.autoUpdate=yt,qt.needsUpdate=ht,qt.type=at}function K(q){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",q.statusMessage)}function $(q){let ot=q.target;ot.removeEventListener("dispose",$),Q(ot)}function Q(q){Mt(q),ce.remove(q)}function Mt(q){let ot=ce.get(q).programs;ot!==void 0&&(ot.forEach(function(yt){it.releaseProgram(yt)}),q.isShaderMaterial&&it.releaseShaderCache(q))}this.renderBufferDirect=function(q,ot,yt,ht,at,Ht){ot===null&&(ot=At);let Xt=at.isMesh&&at.matrixWorld.determinant()<0,re=xn(q,ot,yt,ht,at);Wt.setMaterial(ht,Xt);let Zt=yt.index,me=1;if(ht.wireframe===!0){if(Zt=_t.getWireframeAttribute(yt),Zt===void 0)return;me=2}let oe=yt.drawRange,ae=yt.attributes.position,sn=oe.start*me,gr=(oe.start+oe.count)*me;Ht!==null&&(sn=Math.max(sn,Ht.start*me),gr=Math.min(gr,(Ht.start+Ht.count)*me)),Zt!==null?(sn=Math.max(sn,0),gr=Math.min(gr,Zt.count)):ae!=null&&(sn=Math.max(sn,0),gr=Math.min(gr,ae.count));let Un=gr-sn;if(Un<0||Un===1/0)return;B.setup(at,ht,re,yt,Zt);let Qr,Sn=P;if(Zt!==null&&(Qr=N.get(Zt),Sn=D,Sn.setIndex(Qr)),at.isMesh)ht.wireframe===!0?(Wt.setLineWidth(ht.wireframeLinewidth*te()),Sn.setMode(nt.LINES)):Sn.setMode(nt.TRIANGLES);else if(at.isLine){let jt=ht.linewidth;jt===void 0&&(jt=1),Wt.setLineWidth(jt*te()),at.isLineSegments?Sn.setMode(nt.LINES):at.isLineLoop?Sn.setMode(nt.LINE_LOOP):Sn.setMode(nt.LINE_STRIP)}else at.isPoints?Sn.setMode(nt.POINTS):at.isSprite&&Sn.setMode(nt.TRIANGLES);if(at.isBatchedMesh)Sn.renderMultiDraw(at._multiDrawStarts,at._multiDrawCounts,at._multiDrawCount);else if(at.isInstancedMesh)Sn.renderInstances(sn,Un,at.count);else if(yt.isInstancedBufferGeometry){let jt=yt._maxInstanceCount!==void 0?yt._maxInstanceCount:1/0,Aa=Math.min(yt.instanceCount,jt);Sn.renderInstances(sn,Un,Aa)}else Sn.render(sn,Un)};function Nt(q,ot,yt){q.transparent===!0&&q.side===ns&&q.forceSinglePass===!1?(q.side=xi,q.needsUpdate=!0,_n(q,ot,yt),q.side=Is,q.needsUpdate=!0,_n(q,ot,yt),q.side=ns):_n(q,ot,yt)}this.compile=function(q,ot,yt=null){yt===null&&(yt=q),_=Ct.get(yt),_.init(),A.push(_),yt.traverseVisible(function(at){at.isLight&&at.layers.test(ot.layers)&&(_.pushLight(at),at.castShadow&&_.pushShadow(at))}),q!==yt&&q.traverseVisible(function(at){at.isLight&&at.layers.test(ot.layers)&&(_.pushLight(at),at.castShadow&&_.pushShadow(at))}),_.setupLights(M._useLegacyLights);let ht=new Set;return q.traverse(function(at){let Ht=at.material;if(Ht)if(Array.isArray(Ht))for(let Xt=0;Xt<Ht.length;Xt++){let re=Ht[Xt];Nt(re,yt,at),ht.add(re)}else Nt(Ht,yt,at),ht.add(Ht)}),A.pop(),_=null,ht},this.compileAsync=function(q,ot,yt=null){let ht=this.compile(q,ot,yt);return new Promise(at=>{function Ht(){if(ht.forEach(function(Xt){ce.get(Xt).currentProgram.isReady()&&ht.delete(Xt)}),ht.size===0){at(q);return}setTimeout(Ht,10)}zt.get("KHR_parallel_shader_compile")!==null?Ht():setTimeout(Ht,10)})};let Jt=null;function Kt(q){Jt&&Jt(q)}function xe(){Se.stop()}function de(){Se.start()}let Se=new FE;Se.setAnimationLoop(Kt),typeof self!="undefined"&&Se.setContext(self),this.setAnimationLoop=function(q){Jt=q,ft.setAnimationLoop(q),q===null?Se.stop():Se.start()},ft.addEventListener("sessionstart",xe),ft.addEventListener("sessionend",de),this.render=function(q,ot){if(ot!==void 0&&ot.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;q.matrixWorldAutoUpdate===!0&&q.updateMatrixWorld(),ot.parent===null&&ot.matrixWorldAutoUpdate===!0&&ot.updateMatrixWorld(),ft.enabled===!0&&ft.isPresenting===!0&&(ft.cameraAutoUpdate===!0&&ft.updateCamera(ot),ot=ft.getCamera()),q.isScene===!0&&q.onBeforeRender(M,q,ot,F),_=Ct.get(q,A.length),_.init(),A.push(_),$t.multiplyMatrices(ot.projectionMatrix,ot.matrixWorldInverse),Yt.setFromProjectionMatrix($t),wt=this.localClippingEnabled,tt=Ot.init(this.clippingPlanes,wt),T=ue.get(q,y.length),T.init(),y.push(T),Me(q,ot,0,M.sortObjects),T.finish(),M.sortObjects===!0&&T.sort(rt,lt),this.info.render.frame++,tt===!0&&Ot.beginShadows();let yt=_.state.shadowsArray;if(qt.render(yt,q,ot),tt===!0&&Ot.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ft.enabled===!1||ft.isPresenting===!1||ft.hasDepthSensing()===!1)&&J.render(T,q),_.setupLights(M._useLegacyLights),ot.isArrayCamera){let ht=ot.cameras;for(let at=0,Ht=ht.length;at<Ht;at++){let Xt=ht[at];Nn(T,q,Xt,Xt.viewport)}}else Nn(T,q,ot);F!==null&&(Lt.updateMultisampleRenderTarget(F),Lt.updateRenderTargetMipmap(F)),q.isScene===!0&&q.onAfterRender(M,q,ot),B.resetDefaultState(),I=-1,ut=null,A.pop(),A.length>0?_=A[A.length-1]:_=null,y.pop(),y.length>0?T=y[y.length-1]:T=null};function Me(q,ot,yt,ht){if(q.visible===!1)return;if(q.layers.test(ot.layers)){if(q.isGroup)yt=q.renderOrder;else if(q.isLOD)q.autoUpdate===!0&&q.update(ot);else if(q.isLight)_.pushLight(q),q.castShadow&&_.pushShadow(q);else if(q.isSprite){if(!q.frustumCulled||Yt.intersectsSprite(q)){ht&&Dt.setFromMatrixPosition(q.matrixWorld).applyMatrix4($t);let Xt=Et.update(q),re=q.material;re.visible&&T.push(q,Xt,re,yt,Dt.z,null)}}else if((q.isMesh||q.isLine||q.isPoints)&&(!q.frustumCulled||Yt.intersectsObject(q))){let Xt=Et.update(q),re=q.material;if(ht&&(q.boundingSphere!==void 0?(q.boundingSphere===null&&q.computeBoundingSphere(),Dt.copy(q.boundingSphere.center)):(Xt.boundingSphere===null&&Xt.computeBoundingSphere(),Dt.copy(Xt.boundingSphere.center)),Dt.applyMatrix4(q.matrixWorld).applyMatrix4($t)),Array.isArray(re)){let Zt=Xt.groups;for(let me=0,oe=Zt.length;me<oe;me++){let ae=Zt[me],sn=re[ae.materialIndex];sn&&sn.visible&&T.push(q,Xt,sn,yt,Dt.z,ae)}}else re.visible&&T.push(q,Xt,re,yt,Dt.z,null)}}let Ht=q.children;for(let Xt=0,re=Ht.length;Xt<re;Xt++)Me(Ht[Xt],ot,yt,ht)}function Nn(q,ot,yt,ht){let at=q.opaque,Ht=q.transmissive,Xt=q.transparent;_.setupLightsView(yt),tt===!0&&Ot.setGlobalState(M.clippingPlanes,yt),Ht.length>0&&or(at,Ht,ot,yt),ht&&Wt.viewport(R.copy(ht)),at.length>0&&vn(at,ot,yt),Ht.length>0&&vn(Ht,ot,yt),Xt.length>0&&vn(Xt,ot,yt),Wt.buffers.depth.setTest(!0),Wt.buffers.depth.setMask(!0),Wt.buffers.color.setMask(!0),Wt.setPolygonOffset(!1)}function or(q,ot,yt,ht){if((yt.isScene===!0?yt.overrideMaterial:null)!==null)return;let Ht=ne.isWebGL2;Bt===null&&(Bt=new ss(1,1,{generateMipmaps:!0,type:zt.has("EXT_color_buffer_half_float")?wl:Ps,minFilter:ca,samples:Ht?4:0})),M.getDrawingBufferSize(Ut),Ht?Bt.setSize(Ut.x,Ut.y):Bt.setSize(Zd(Ut.x),Zd(Ut.y));let Xt=M.getRenderTarget();M.setRenderTarget(Bt),M.getClearColor(St),X=M.getClearAlpha(),X<1&&M.setClearColor(16777215,.5),M.clear();let re=M.toneMapping;M.toneMapping=Cs,vn(q,yt,ht),Lt.updateMultisampleRenderTarget(Bt),Lt.updateRenderTargetMipmap(Bt);let Zt=!1;for(let me=0,oe=ot.length;me<oe;me++){let ae=ot[me],sn=ae.object,gr=ae.geometry,Un=ae.material,Qr=ae.group;if(Un.side===ns&&sn.layers.test(ht.layers)){let Sn=Un.side;Un.side=xi,Un.needsUpdate=!0,le(sn,yt,ht,gr,Un,Qr),Un.side=Sn,Un.needsUpdate=!0,Zt=!0}}Zt===!0&&(Lt.updateMultisampleRenderTarget(Bt),Lt.updateRenderTargetMipmap(Bt)),M.setRenderTarget(Xt),M.setClearColor(St,X),M.toneMapping=re}function vn(q,ot,yt){let ht=ot.isScene===!0?ot.overrideMaterial:null;for(let at=0,Ht=q.length;at<Ht;at++){let Xt=q[at],re=Xt.object,Zt=Xt.geometry,me=ht===null?Xt.material:ht,oe=Xt.group;re.layers.test(yt.layers)&&le(re,ot,yt,Zt,me,oe)}}function le(q,ot,yt,ht,at,Ht){q.onBeforeRender(M,ot,yt,ht,at,Ht),q.modelViewMatrix.multiplyMatrices(yt.matrixWorldInverse,q.matrixWorld),q.normalMatrix.getNormalMatrix(q.modelViewMatrix),at.onBeforeRender(M,ot,yt,ht,q,Ht),at.transparent===!0&&at.side===ns&&at.forceSinglePass===!1?(at.side=xi,at.needsUpdate=!0,M.renderBufferDirect(yt,ot,ht,at,q,Ht),at.side=Is,at.needsUpdate=!0,M.renderBufferDirect(yt,ot,ht,at,q,Ht),at.side=ns):M.renderBufferDirect(yt,ot,ht,at,q,Ht),q.onAfterRender(M,ot,yt,ht,at,Ht)}function _n(q,ot,yt){ot.isScene!==!0&&(ot=At);let ht=ce.get(q),at=_.state.lights,Ht=_.state.shadowsArray,Xt=at.state.version,re=it.getParameters(q,at.state,Ht,ot,yt),Zt=it.getProgramCacheKey(re),me=ht.programs;ht.environment=q.isMeshStandardMaterial?ot.environment:null,ht.fog=ot.fog,ht.envMap=(q.isMeshStandardMaterial?Y:se).get(q.envMap||ht.environment),ht.envMapRotation=ht.environment!==null&&q.envMap===null?ot.environmentRotation:q.envMapRotation,me===void 0&&(q.addEventListener("dispose",$),me=new Map,ht.programs=me);let oe=me.get(Zt);if(oe!==void 0){if(ht.currentProgram===oe&&ht.lightsStateVersion===Xt)return Tn(q,re),oe}else re.uniforms=it.getUniforms(q),q.onBuild(yt,re,M),q.onBeforeCompile(re,M),oe=it.acquireProgram(re,Zt),me.set(Zt,oe),ht.uniforms=re.uniforms;let ae=ht.uniforms;return(!q.isShaderMaterial&&!q.isRawShaderMaterial||q.clipping===!0)&&(ae.clippingPlanes=Ot.uniform),Tn(q,re),ht.needsLights=mr(q),ht.lightsStateVersion=Xt,ht.needsLights&&(ae.ambientLightColor.value=at.state.ambient,ae.lightProbe.value=at.state.probe,ae.directionalLights.value=at.state.directional,ae.directionalLightShadows.value=at.state.directionalShadow,ae.spotLights.value=at.state.spot,ae.spotLightShadows.value=at.state.spotShadow,ae.rectAreaLights.value=at.state.rectArea,ae.ltc_1.value=at.state.rectAreaLTC1,ae.ltc_2.value=at.state.rectAreaLTC2,ae.pointLights.value=at.state.point,ae.pointLightShadows.value=at.state.pointShadow,ae.hemisphereLights.value=at.state.hemi,ae.directionalShadowMap.value=at.state.directionalShadowMap,ae.directionalShadowMatrix.value=at.state.directionalShadowMatrix,ae.spotShadowMap.value=at.state.spotShadowMap,ae.spotLightMatrix.value=at.state.spotLightMatrix,ae.spotLightMap.value=at.state.spotLightMap,ae.pointShadowMap.value=at.state.pointShadowMap,ae.pointShadowMatrix.value=at.state.pointShadowMatrix),ht.currentProgram=oe,ht.uniformsList=null,oe}function Pn(q){if(q.uniformsList===null){let ot=q.currentProgram.getUniforms();q.uniformsList=du.seqWithValue(ot.seq,q.uniforms)}return q.uniformsList}function Tn(q,ot){let yt=ce.get(q);yt.outputColorSpace=ot.outputColorSpace,yt.batching=ot.batching,yt.instancing=ot.instancing,yt.instancingColor=ot.instancingColor,yt.instancingMorph=ot.instancingMorph,yt.skinning=ot.skinning,yt.morphTargets=ot.morphTargets,yt.morphNormals=ot.morphNormals,yt.morphColors=ot.morphColors,yt.morphTargetsCount=ot.morphTargetsCount,yt.numClippingPlanes=ot.numClippingPlanes,yt.numIntersection=ot.numClipIntersection,yt.vertexAlphas=ot.vertexAlphas,yt.vertexTangents=ot.vertexTangents,yt.toneMapping=ot.toneMapping}function xn(q,ot,yt,ht,at){ot.isScene!==!0&&(ot=At),Lt.resetTextureUnits();let Ht=ot.fog,Xt=ht.isMeshStandardMaterial?ot.environment:null,re=F===null?M.outputColorSpace:F.isXRRenderTarget===!0?F.texture.colorSpace:Ns,Zt=(ht.isMeshStandardMaterial?Y:se).get(ht.envMap||Xt),me=ht.vertexColors===!0&&!!yt.attributes.color&&yt.attributes.color.itemSize===4,oe=!!yt.attributes.tangent&&(!!ht.normalMap||ht.anisotropy>0),ae=!!yt.morphAttributes.position,sn=!!yt.morphAttributes.normal,gr=!!yt.morphAttributes.color,Un=Cs;ht.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(Un=M.toneMapping);let Qr=yt.morphAttributes.position||yt.morphAttributes.normal||yt.morphAttributes.color,Sn=Qr!==void 0?Qr.length:0,jt=ce.get(ht),Aa=_.state.lights;if(tt===!0&&(wt===!0||q!==ut)){let ti=q===ut&&ht.id===I;Ot.setState(ht,q,ti)}let an=!1;ht.version===jt.__version?(jt.needsLights&&jt.lightsStateVersion!==Aa.state.version||jt.outputColorSpace!==re||at.isBatchedMesh&&jt.batching===!1||!at.isBatchedMesh&&jt.batching===!0||at.isInstancedMesh&&jt.instancing===!1||!at.isInstancedMesh&&jt.instancing===!0||at.isSkinnedMesh&&jt.skinning===!1||!at.isSkinnedMesh&&jt.skinning===!0||at.isInstancedMesh&&jt.instancingColor===!0&&at.instanceColor===null||at.isInstancedMesh&&jt.instancingColor===!1&&at.instanceColor!==null||at.isInstancedMesh&&jt.instancingMorph===!0&&at.morphTexture===null||at.isInstancedMesh&&jt.instancingMorph===!1&&at.morphTexture!==null||jt.envMap!==Zt||ht.fog===!0&&jt.fog!==Ht||jt.numClippingPlanes!==void 0&&(jt.numClippingPlanes!==Ot.numPlanes||jt.numIntersection!==Ot.numIntersection)||jt.vertexAlphas!==me||jt.vertexTangents!==oe||jt.morphTargets!==ae||jt.morphNormals!==sn||jt.morphColors!==gr||jt.toneMapping!==Un||ne.isWebGL2===!0&&jt.morphTargetsCount!==Sn)&&(an=!0):(an=!0,jt.__version=ht.version);let Wi=jt.currentProgram;an===!0&&(Wi=_n(ht,ot,at));let Xu=!1,ge=!1,qs=!1,Mn=Wi.getUniforms(),Xi=jt.uniforms;if(Wt.useProgram(Wi.program)&&(Xu=!0,ge=!0,qs=!0),ht.id!==I&&(I=ht.id,ge=!0),Xu||ut!==q){Mn.setValue(nt,"projectionMatrix",q.projectionMatrix),Mn.setValue(nt,"viewMatrix",q.matrixWorldInverse);let ti=Mn.map.cameraPosition;ti!==void 0&&ti.setValue(nt,Dt.setFromMatrixPosition(q.matrixWorld)),ne.logarithmicDepthBuffer&&Mn.setValue(nt,"logDepthBufFC",2/(Math.log(q.far+1)/Math.LN2)),(ht.isMeshPhongMaterial||ht.isMeshToonMaterial||ht.isMeshLambertMaterial||ht.isMeshBasicMaterial||ht.isMeshStandardMaterial||ht.isShaderMaterial)&&Mn.setValue(nt,"isOrthographic",q.isOrthographicCamera===!0),ut!==q&&(ut=q,ge=!0,qs=!0)}if(at.isSkinnedMesh){Mn.setOptional(nt,at,"bindMatrix"),Mn.setOptional(nt,at,"bindMatrixInverse");let ti=at.skeleton;ti&&(ne.floatVertexTextures?(ti.boneTexture===null&&ti.computeBoneTexture(),Mn.setValue(nt,"boneTexture",ti.boneTexture,Lt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}at.isBatchedMesh&&(Mn.setOptional(nt,at,"batchingTexture"),Mn.setValue(nt,"batchingTexture",at._matricesTexture,Lt));let pe=yt.morphAttributes;if((pe.position!==void 0||pe.normal!==void 0||pe.color!==void 0&&ne.isWebGL2===!0)&&w.update(at,yt,Wi),(ge||jt.receiveShadow!==at.receiveShadow)&&(jt.receiveShadow=at.receiveShadow,Mn.setValue(nt,"receiveShadow",at.receiveShadow)),ht.isMeshGouraudMaterial&&ht.envMap!==null&&(Xi.envMap.value=Zt,Xi.flipEnvMap.value=Zt.isCubeTexture&&Zt.isRenderTargetTexture===!1?-1:1),ge&&(Mn.setValue(nt,"toneMappingExposure",M.toneMappingExposure),jt.needsLights&&Vr(Xi,qs),Ht&&ht.fog===!0&&Pt.refreshFogUniforms(Xi,Ht),Pt.refreshMaterialUniforms(Xi,ht,vt,dt,Bt),du.upload(nt,Pn(jt),Xi,Lt)),ht.isShaderMaterial&&ht.uniformsNeedUpdate===!0&&(du.upload(nt,Pn(jt),Xi,Lt),ht.uniformsNeedUpdate=!1),ht.isSpriteMaterial&&Mn.setValue(nt,"center",at.center),Mn.setValue(nt,"modelViewMatrix",at.modelViewMatrix),Mn.setValue(nt,"normalMatrix",at.normalMatrix),Mn.setValue(nt,"modelMatrix",at.matrixWorld),ht.isShaderMaterial||ht.isRawShaderMaterial){let ti=ht.uniformsGroups;for(let Yu=0,Ca=ti.length;Yu<Ca;Yu++)if(ne.isWebGL2){let ei=ti[Yu];et.update(ei,Wi),et.bind(ei,Wi)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Wi}function Vr(q,ot){q.ambientLightColor.needsUpdate=ot,q.lightProbe.needsUpdate=ot,q.directionalLights.needsUpdate=ot,q.directionalLightShadows.needsUpdate=ot,q.pointLights.needsUpdate=ot,q.pointLightShadows.needsUpdate=ot,q.spotLights.needsUpdate=ot,q.spotLightShadows.needsUpdate=ot,q.rectAreaLights.needsUpdate=ot,q.hemisphereLights.needsUpdate=ot}function mr(q){return q.isMeshLambertMaterial||q.isMeshToonMaterial||q.isMeshPhongMaterial||q.isMeshStandardMaterial||q.isShadowMaterial||q.isShaderMaterial&&q.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(q,ot,yt){ce.get(q.texture).__webglTexture=ot,ce.get(q.depthTexture).__webglTexture=yt;let ht=ce.get(q);ht.__hasExternalTextures=!0,ht.__autoAllocateDepthBuffer=yt===void 0,ht.__autoAllocateDepthBuffer||zt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ht.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(q,ot){let yt=ce.get(q);yt.__webglFramebuffer=ot,yt.__useDefaultFramebuffer=ot===void 0},this.setRenderTarget=function(q,ot=0,yt=0){F=q,G=ot,z=yt;let ht=!0,at=null,Ht=!1,Xt=!1;if(q){let Zt=ce.get(q);Zt.__useDefaultFramebuffer!==void 0?(Wt.bindFramebuffer(nt.FRAMEBUFFER,null),ht=!1):Zt.__webglFramebuffer===void 0?Lt.setupRenderTarget(q):Zt.__hasExternalTextures&&Lt.rebindTextures(q,ce.get(q.texture).__webglTexture,ce.get(q.depthTexture).__webglTexture);let me=q.texture;(me.isData3DTexture||me.isDataArrayTexture||me.isCompressedArrayTexture)&&(Xt=!0);let oe=ce.get(q).__webglFramebuffer;q.isWebGLCubeRenderTarget?(Array.isArray(oe[ot])?at=oe[ot][yt]:at=oe[ot],Ht=!0):ne.isWebGL2&&q.samples>0&&Lt.useMultisampledRTT(q)===!1?at=ce.get(q).__webglMultisampledFramebuffer:Array.isArray(oe)?at=oe[yt]:at=oe,R.copy(q.viewport),W.copy(q.scissor),V=q.scissorTest}else R.copy(H).multiplyScalar(vt).floor(),W.copy(bt).multiplyScalar(vt).floor(),V=Tt;if(Wt.bindFramebuffer(nt.FRAMEBUFFER,at)&&ne.drawBuffers&&ht&&Wt.drawBuffers(q,at),Wt.viewport(R),Wt.scissor(W),Wt.setScissorTest(V),Ht){let Zt=ce.get(q.texture);nt.framebufferTexture2D(nt.FRAMEBUFFER,nt.COLOR_ATTACHMENT0,nt.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Zt.__webglTexture,yt)}else if(Xt){let Zt=ce.get(q.texture),me=ot||0;nt.framebufferTextureLayer(nt.FRAMEBUFFER,nt.COLOR_ATTACHMENT0,Zt.__webglTexture,yt||0,me)}I=-1},this.readRenderTargetPixels=function(q,ot,yt,ht,at,Ht,Xt){if(!(q&&q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let re=ce.get(q).__webglFramebuffer;if(q.isWebGLCubeRenderTarget&&Xt!==void 0&&(re=re[Xt]),re){Wt.bindFramebuffer(nt.FRAMEBUFFER,re);try{let Zt=q.texture,me=Zt.format,oe=Zt.type;if(me!==co&&k.convert(me)!==nt.getParameter(nt.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ae=oe===wl&&(zt.has("EXT_color_buffer_half_float")||ne.isWebGL2&&zt.has("EXT_color_buffer_float"));if(oe!==Ps&&k.convert(oe)!==nt.getParameter(nt.IMPLEMENTATION_COLOR_READ_TYPE)&&!(oe===rs&&(ne.isWebGL2||zt.has("OES_texture_float")||zt.has("WEBGL_color_buffer_float")))&&!ae){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ot>=0&&ot<=q.width-ht&&yt>=0&&yt<=q.height-at&&nt.readPixels(ot,yt,ht,at,k.convert(me),k.convert(oe),Ht)}finally{let Zt=F!==null?ce.get(F).__webglFramebuffer:null;Wt.bindFramebuffer(nt.FRAMEBUFFER,Zt)}}},this.copyFramebufferToTexture=function(q,ot,yt=0){let ht=Math.pow(2,-yt),at=Math.floor(ot.image.width*ht),Ht=Math.floor(ot.image.height*ht);Lt.setTexture2D(ot,0),nt.copyTexSubImage2D(nt.TEXTURE_2D,yt,0,0,q.x,q.y,at,Ht),Wt.unbindTexture()},this.copyTextureToTexture=function(q,ot,yt,ht=0){let at=ot.image.width,Ht=ot.image.height,Xt=k.convert(yt.format),re=k.convert(yt.type);Lt.setTexture2D(yt,0),nt.pixelStorei(nt.UNPACK_FLIP_Y_WEBGL,yt.flipY),nt.pixelStorei(nt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,yt.premultiplyAlpha),nt.pixelStorei(nt.UNPACK_ALIGNMENT,yt.unpackAlignment),ot.isDataTexture?nt.texSubImage2D(nt.TEXTURE_2D,ht,q.x,q.y,at,Ht,Xt,re,ot.image.data):ot.isCompressedTexture?nt.compressedTexSubImage2D(nt.TEXTURE_2D,ht,q.x,q.y,ot.mipmaps[0].width,ot.mipmaps[0].height,Xt,ot.mipmaps[0].data):nt.texSubImage2D(nt.TEXTURE_2D,ht,q.x,q.y,Xt,re,ot.image),ht===0&&yt.generateMipmaps&&nt.generateMipmap(nt.TEXTURE_2D),Wt.unbindTexture()},this.copyTextureToTexture3D=function(q,ot,yt,ht,at=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ht=Math.round(q.max.x-q.min.x),Xt=Math.round(q.max.y-q.min.y),re=q.max.z-q.min.z+1,Zt=k.convert(ht.format),me=k.convert(ht.type),oe;if(ht.isData3DTexture)Lt.setTexture3D(ht,0),oe=nt.TEXTURE_3D;else if(ht.isDataArrayTexture||ht.isCompressedArrayTexture)Lt.setTexture2DArray(ht,0),oe=nt.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}nt.pixelStorei(nt.UNPACK_FLIP_Y_WEBGL,ht.flipY),nt.pixelStorei(nt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ht.premultiplyAlpha),nt.pixelStorei(nt.UNPACK_ALIGNMENT,ht.unpackAlignment);let ae=nt.getParameter(nt.UNPACK_ROW_LENGTH),sn=nt.getParameter(nt.UNPACK_IMAGE_HEIGHT),gr=nt.getParameter(nt.UNPACK_SKIP_PIXELS),Un=nt.getParameter(nt.UNPACK_SKIP_ROWS),Qr=nt.getParameter(nt.UNPACK_SKIP_IMAGES),Sn=yt.isCompressedTexture?yt.mipmaps[at]:yt.image;nt.pixelStorei(nt.UNPACK_ROW_LENGTH,Sn.width),nt.pixelStorei(nt.UNPACK_IMAGE_HEIGHT,Sn.height),nt.pixelStorei(nt.UNPACK_SKIP_PIXELS,q.min.x),nt.pixelStorei(nt.UNPACK_SKIP_ROWS,q.min.y),nt.pixelStorei(nt.UNPACK_SKIP_IMAGES,q.min.z),yt.isDataTexture||yt.isData3DTexture?nt.texSubImage3D(oe,at,ot.x,ot.y,ot.z,Ht,Xt,re,Zt,me,Sn.data):ht.isCompressedArrayTexture?nt.compressedTexSubImage3D(oe,at,ot.x,ot.y,ot.z,Ht,Xt,re,Zt,Sn.data):nt.texSubImage3D(oe,at,ot.x,ot.y,ot.z,Ht,Xt,re,Zt,me,Sn),nt.pixelStorei(nt.UNPACK_ROW_LENGTH,ae),nt.pixelStorei(nt.UNPACK_IMAGE_HEIGHT,sn),nt.pixelStorei(nt.UNPACK_SKIP_PIXELS,gr),nt.pixelStorei(nt.UNPACK_SKIP_ROWS,Un),nt.pixelStorei(nt.UNPACK_SKIP_IMAGES,Qr),at===0&&ht.generateMipmaps&&nt.generateMipmap(oe),Wt.unbindTexture()},this.initTexture=function(q){q.isCubeTexture?Lt.setTextureCube(q,0):q.isData3DTexture?Lt.setTexture3D(q,0):q.isDataArrayTexture||q.isCompressedArrayTexture?Lt.setTexture2DArray(q,0):Lt.setTexture2D(q,0),Wt.unbindTexture()},this.resetState=function(){G=0,z=0,F=null,Wt.reset(),B.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return is}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===Am?"display-p3":"srgb",e.unpackColorSpace=An.workingColorSpace===Nf?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},dm=class extends pm{};dm.prototype.isWebGL1Renderer=!0;function cf(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function EF(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var xu=class{constructor(t,e,o,a){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=a!==void 0?a:new e.constructor(o),this.sampleValues=e,this.valueSize=o,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,o=this._cachedIndex,a=e[o],l=e[o-1];n:{t:{let h;e:{r:if(!(t<a)){for(let f=o+2;;){if(a===void 0){if(t<l)break r;return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}if(o===f)break;if(l=a,a=e[++o],t<a)break t}h=e.length;break e}if(!(t>=l)){let f=e[1];t<f&&(o=2,l=f);for(let p=o-2;;){if(l===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(o===p)break;if(a=l,l=e[--o-1],t>=l)break t}h=o,o=0;break e}break n}for(;o<h;){let f=o+h>>>1;t<e[f]?h=f:o=f+1}if(a=e[o],l=e[o-1],l===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(a===void 0)return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}this._cachedIndex=o,this.intervalChanged_(o,l,a)}return this.interpolate_(o,l,t,a)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a;for(let h=0;h!==a;++h)e[h]=o[l+h];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},mm=class extends xu{constructor(t,e,o,a){super(t,e,o,a),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:I1,endingEnd:I1}}intervalChanged_(t,e,o){let a=this.parameterPositions,l=t-2,h=t+1,f=a[l],p=a[h];if(f===void 0)switch(this.getSettings_().endingStart){case R1:l=t,f=2*e-o;break;case L1:l=a.length-2,f=e+a[l]-a[l+1];break;default:l=t,f=o}if(p===void 0)switch(this.getSettings_().endingEnd){case R1:h=t,p=2*o-e;break;case L1:h=1,p=o+a[1]-a[0];break;default:h=t-1,p=e}let d=(o-e)*.5,g=this.valueSize;this._weightPrev=d/(e-f),this._weightNext=d/(p-o),this._offsetPrev=l*g,this._offsetNext=h*g}interpolate_(t,e,o,a){let l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,p=t*f,d=p-f,g=this._offsetPrev,x=this._offsetNext,v=this._weightPrev,S=this._weightNext,b=(o-e)/(a-e),T=b*b,_=T*b,y=-v*_+2*v*T-v*b,A=(1+v)*_+(-1.5-2*v)*T+(-.5+v)*b+1,M=(-1-S)*_+(1.5+S)*T+.5*b,L=S*_-S*T;for(let G=0;G!==f;++G)l[G]=y*h[g+G]+A*h[d+G]+M*h[p+G]+L*h[x+G];return l}},gm=class extends xu{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t,e,o,a){let l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,p=t*f,d=p-f,g=(o-e)/(a-e),x=1-g;for(let v=0;v!==f;++v)l[v]=h[d+v]*x+h[p+v]*g;return l}},ym=class extends xu{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t){return this.copySampleValue_(t-1)}},ho=class{constructor(t,e,o,a){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=cf(e,this.TimeBufferType),this.values=cf(o,this.ValueBufferType),this.setInterpolation(a||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,o;if(e.toJSON!==this.toJSON)o=e.toJSON(t);else{o={name:t.name,times:cf(t.times,Array),values:cf(t.values,Array)};let a=t.getInterpolation();a!==t.DefaultInterpolation&&(o.interpolation=a)}return o.type=t.ValueTypeName,o}InterpolantFactoryMethodDiscrete(t){return new ym(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new gm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new mm(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case hf:e=this.InterpolantFactoryMethodDiscrete;break;case pf:e=this.InterpolantFactoryMethodLinear;break;case dd:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let o="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(o);return console.warn("THREE.KeyframeTrack:",o),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return hf;case this.InterpolantFactoryMethodLinear:return pf;case this.InterpolantFactoryMethodSmooth:return dd}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let o=0,a=e.length;o!==a;++o)e[o]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let o=0,a=e.length;o!==a;++o)e[o]*=t}return this}trim(t,e){let o=this.times,a=o.length,l=0,h=a-1;for(;l!==a&&o[l]<t;)++l;for(;h!==-1&&o[h]>e;)--h;if(++h,l!==0||h!==a){l>=h&&(h=Math.max(h,1),l=h-1);let f=this.getValueSize();this.times=o.slice(l,h),this.values=this.values.slice(l*f,h*f)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let o=this.times,a=this.values,l=o.length;l===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let h=null;for(let f=0;f!==l;f++){let p=o[f];if(typeof p=="number"&&isNaN(p)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,p),t=!1;break}if(h!==null&&h>p){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,p,h),t=!1;break}h=p}if(a!==void 0&&EF(a))for(let f=0,p=a.length;f!==p;++f){let d=a[f];if(isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),o=this.getValueSize(),a=this.getInterpolation()===dd,l=t.length-1,h=1;for(let f=1;f<l;++f){let p=!1,d=t[f],g=t[f+1];if(d!==g&&(f!==1||d!==t[0]))if(a)p=!0;else{let x=f*o,v=x-o,S=x+o;for(let b=0;b!==o;++b){let T=e[x+b];if(T!==e[v+b]||T!==e[S+b]){p=!0;break}}}if(p){if(f!==h){t[h]=t[f];let x=f*o,v=h*o;for(let S=0;S!==o;++S)e[v+S]=e[x+S]}++h}}if(l>0){t[h]=t[l];for(let f=l*o,p=h*o,d=0;d!==o;++d)e[p+d]=e[f+d];++h}return h!==t.length?(this.times=t.slice(0,h),this.values=e.slice(0,h*o)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),o=this.constructor,a=new o(this.name,t,e);return a.createInterpolant=this.createInterpolant,a}};ho.prototype.TimeBufferType=Float32Array;ho.prototype.ValueBufferType=Float32Array;ho.prototype.DefaultInterpolation=pf;var ga=class extends ho{};ga.prototype.ValueTypeName="bool";ga.prototype.ValueBufferType=Array;ga.prototype.DefaultInterpolation=hf;ga.prototype.InterpolantFactoryMethodLinear=void 0;ga.prototype.InterpolantFactoryMethodSmooth=void 0;var vm=class extends ho{};vm.prototype.ValueTypeName="color";var _m=class extends ho{};_m.prototype.ValueTypeName="number";var xm=class extends xu{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t,e,o,a){let l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,p=(o-e)/(a-e),d=t*f;for(let g=d+f;d!==g;d+=4)Ls.slerpFlat(l,0,h,d-f,h,d,p);return l}},Al=class extends ho{InterpolantFactoryMethodLinear(t){return new xm(this.times,this.values,this.getValueSize(),t)}};Al.prototype.ValueTypeName="quaternion";Al.prototype.DefaultInterpolation=pf;Al.prototype.InterpolantFactoryMethodSmooth=void 0;var ya=class extends ho{};ya.prototype.ValueTypeName="string";ya.prototype.ValueBufferType=Array;ya.prototype.DefaultInterpolation=hf;ya.prototype.InterpolantFactoryMethodLinear=void 0;ya.prototype.InterpolantFactoryMethodSmooth=void 0;var Em=class extends ho{};Em.prototype.ValueTypeName="vector";var Sm=class{constructor(t,e,o){let a=this,l=!1,h=0,f=0,p,d=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=o,this.itemStart=function(g){f++,l===!1&&a.onStart!==void 0&&a.onStart(g,h,f),l=!0},this.itemEnd=function(g){h++,a.onProgress!==void 0&&a.onProgress(g,h,f),h===f&&(l=!1,a.onLoad!==void 0&&a.onLoad())},this.itemError=function(g){a.onError!==void 0&&a.onError(g)},this.resolveURL=function(g){return p?p(g):g},this.setURLModifier=function(g){return p=g,this},this.addHandler=function(g,x){return d.push(g,x),this},this.removeHandler=function(g){let x=d.indexOf(g);return x!==-1&&d.splice(x,2),this},this.getHandler=function(g){for(let x=0,v=d.length;x<v;x+=2){let S=d[x],b=d[x+1];if(S.global&&(S.lastIndex=0),S.test(g))return b}return null}}},SF=new Sm,Mm=class{constructor(t){this.manager=t!==void 0?t:SF,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let o=this;return new Promise(function(a,l){o.load(t,a,e,l)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};Mm.DEFAULT_MATERIAL_NAME="__DEFAULT";var Pm="\\\\[\\\\]\\\\.:\\\\/",MF=new RegExp("["+Pm+"]","g"),Im="[^"+Pm+"]",wF="[^"+Pm.replace("\\\\.","")+"]",bF=/((?:WC+[\\/:])*)/.source.replace("WC",Im),TF=/(WCOD+)?/.source.replace("WCOD",wF),AF=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",Im),CF=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",Im),PF=new RegExp("^"+bF+TF+AF+CF+"$"),IF=["material","materials","bones","map"],wm=class{constructor(t,e,o){let a=o||qn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,a)}getValue(t,e){this.bind();let o=this._targetGroup.nCachedObjects_,a=this._bindings[o];a!==void 0&&a.getValue(t,e)}setValue(t,e){let o=this._bindings;for(let a=this._targetGroup.nCachedObjects_,l=o.length;a!==l;++a)o[a].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,o=t.length;e!==o;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,o=t.length;e!==o;++e)t[e].unbind()}},qn=class r{constructor(t,e,o){this.path=e,this.parsedPath=o||r.parseTrackName(e),this.node=r.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,o){return t&&t.isAnimationObjectGroup?new r.Composite(t,e,o):new r(t,e,o)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(MF,"")}static parseTrackName(t){let e=PF.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let o={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},a=o.nodeName&&o.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){let l=o.nodeName.substring(a+1);IF.indexOf(l)!==-1&&(o.nodeName=o.nodeName.substring(0,a),o.objectName=l)}if(o.propertyName===null||o.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return o}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let o=t.skeleton.getBoneByName(e);if(o!==void 0)return o}if(t.children){let o=function(l){for(let h=0;h<l.length;h++){let f=l[h];if(f.name===e||f.uuid===e)return f;let p=o(f.children);if(p)return p}return null},a=o(t.children);if(a)return a}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)t[e++]=o[a]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)o[a]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)o[a]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)o[a]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,o=e.objectName,a=e.propertyName,l=e.propertyIndex;if(t||(t=r.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(o){let d=e.objectIndex;switch(o){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let g=0;g<t.length;g++)if(t[g].name===d){d=g;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[o]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[o]}if(d!==void 0){if(t[d]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[d]}}let h=t[a];if(h===void 0){let d=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+d+"."+a+" but it wasn't found.",t);return}let f=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?f=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(f=this.Versioning.MatrixWorldNeedsUpdate);let p=this.BindingType.Direct;if(l!==void 0){if(a==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[l]!==void 0&&(l=t.morphTargetDictionary[l])}p=this.BindingType.ArrayElement,this.resolvedProperty=h,this.propertyIndex=l}else h.fromArray!==void 0&&h.toArray!==void 0?(p=this.BindingType.HasFromToArray,this.resolvedProperty=h):Array.isArray(h)?(p=this.BindingType.EntireArray,this.resolvedProperty=h):this.propertyName=a;this.getValue=this.GetterByBindingType[p],this.setValue=this.SetterByBindingTypeAndVersioning[p][f]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};qn.Composite=wm;qn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};qn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};qn.prototype.GetterByBindingType=[qn.prototype._getValue_direct,qn.prototype._getValue_array,qn.prototype._getValue_arrayElement,qn.prototype._getValue_toArray];qn.prototype.SetterByBindingTypeAndVersioning=[[qn.prototype._setValue_direct,qn.prototype._setValue_direct_setNeedsUpdate,qn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[qn.prototype._setValue_array,qn.prototype._setValue_array_setNeedsUpdate,qn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[qn.prototype._setValue_arrayElement,qn.prototype._setValue_arrayElement_setNeedsUpdate,qn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[qn.prototype._setValue_fromArray,qn.prototype._setValue_fromArray_setNeedsUpdate,qn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Yq=new Float32Array(1);typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:bm}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=bm);var Ar=63710088e-1,Jq={centimeters:Ar*100,centimetres:Ar*100,degrees:Ar/111325,feet:Ar*3.28084,inches:Ar*39.37,kilometers:Ar/1e3,kilometres:Ar/1e3,meters:Ar,metres:Ar,miles:Ar/1609.344,millimeters:Ar*1e3,millimetres:Ar*1e3,nauticalmiles:Ar/1852,radians:1,yards:Ar*1.0936},Kq={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/Ar,yards:1.0936133};function fi(r,t,e){e===void 0&&(e={});var o={type:"Feature"};return(e.id===0||e.id)&&(o.id=e.id),e.bbox&&(o.bbox=e.bbox),o.properties=t||{},o.geometry=r,o}function Ln(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Co(r[0])||!Co(r[1]))throw new Error("coordinates must contain numbers");var o={type:"Point",coordinates:r};return fi(o,t,e)}function Vn(r,t,e){e===void 0&&(e={});for(var o=0,a=r;o<a.length;o++){var l=a[o];if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var h=0;h<l[l.length-1].length;h++)if(l[l.length-1][h]!==l[0][h])throw new Error("First and last Position are not equivalent.")}var f={type:"Polygon",coordinates:r};return fi(f,t,e)}function Cr(r,t,e){if(e===void 0&&(e={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var o={type:"LineString",coordinates:r};return fi(o,t,e)}function Rm(r,t,e){e===void 0&&(e={});var o={type:"MultiPoint",coordinates:r};return fi(o,t,e)}function Co(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function fr(r,t,e){if(r!==null)for(var o,a,l,h,f,p,d,g=0,x=0,v,S=r.type,b=S==="FeatureCollection",T=S==="Feature",_=b?r.features.length:1,y=0;y<_;y++){d=b?r.features[y].geometry:T?r.geometry:r,v=d?d.type==="GeometryCollection":!1,f=v?d.geometries.length:1;for(var A=0;A<f;A++){var M=0,L=0;if(h=v?d.geometries[A]:d,h!==null){p=h.coordinates;var G=h.type;switch(g=e&&(G==="Polygon"||G==="MultiPolygon")?1:0,G){case null:break;case"Point":if(t(p,x,y,M,L)===!1)return!1;x++,M++;break;case"LineString":case"MultiPoint":for(o=0;o<p.length;o++){if(t(p[o],x,y,M,L)===!1)return!1;x++,G==="MultiPoint"&&M++}G==="LineString"&&M++;break;case"Polygon":case"MultiLineString":for(o=0;o<p.length;o++){for(a=0;a<p[o].length-g;a++){if(t(p[o][a],x,y,M,L)===!1)return!1;x++}G==="MultiLineString"&&M++,G==="Polygon"&&L++}G==="Polygon"&&M++;break;case"MultiPolygon":for(o=0;o<p.length;o++){for(L=0,a=0;a<p[o].length;a++){for(l=0;l<p[o][a].length-g;l++){if(t(p[o][a][l],x,y,M,L)===!1)return!1;x++}L++}M++}break;case"GeometryCollection":for(o=0;o<h.geometries.length;o++)if(fr(h.geometries[o],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function qE(r,t,e,o){var a=e;return fr(r,function(l,h,f,p,d){h===0&&e===void 0?a=l:a=t(a,l,h,f,p,d)},o),a}function Os(r,t){var e,o,a,l,h,f,p,d,g,x,v=0,S=r.type==="FeatureCollection",b=r.type==="Feature",T=S?r.features.length:1;for(e=0;e<T;e++){for(f=S?r.features[e].geometry:b?r.geometry:r,d=S?r.features[e].properties:b?r.properties:{},g=S?r.features[e].bbox:b?r.bbox:void 0,x=S?r.features[e].id:b?r.id:void 0,p=f?f.type==="GeometryCollection":!1,h=p?f.geometries.length:1,a=0;a<h;a++){if(l=p?f.geometries[a]:f,l===null){if(t(null,v,d,g,x)===!1)return!1;continue}switch(l.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(t(l,v,d,g,x)===!1)return!1;break}case"GeometryCollection":{for(o=0;o<l.geometries.length;o++)if(t(l.geometries[o],v,d,g,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}v++}}function Li(r,t){Os(r,function(e,o,a,l,h){var f=e===null?null:e.type;switch(f){case null:case"Point":case"LineString":case"Polygon":return t(fi(e,a,{bbox:l,id:h}),o,0)===!1?!1:void 0}var p;switch(f){case"MultiPoint":p="Point";break;case"MultiLineString":p="LineString";break;case"MultiPolygon":p="Polygon";break}for(var d=0;d<e.coordinates.length;d++){var g=e.coordinates[d],x={type:p,coordinates:g};if(t(fi(x,a),o,d)===!1)return!1}})}function Lm(r){var t=[1/0,1/0,-1/0,-1/0];return fr(r,function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])}),t}Lm.default=Lm;var hi=Lm;function zr(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Nm(r,t,e){if(!r)throw new Error("No feature passed");if(!e)throw new Error(".featureOf() requires a name");if(!r||r.type!=="Feature"||!r.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!r.geometry||r.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+r.geometry.type)}function Gr(r){return r.type==="Feature"?r.geometry:r}var BF=yn(Df(),1);var $F=yn(sS(),1);function Pr(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("point is required");if(!t)throw new Error("polygon is required");var o=zr(r),a=Gr(t),l=a.type,h=t.bbox,f=a.coordinates;if(h&&ZF(o,h)===!1)return!1;l==="Polygon"&&(f=[f]);for(var p=!1,d=0;d<f.length&&!p;d++)if(aS(o,f[d][0],e.ignoreBoundary)){for(var g=!1,x=1;x<f[d].length&&!g;)aS(o,f[d][x],!e.ignoreBoundary)&&(g=!0),x++;g||(p=!0)}return p}function aS(r,t,e){var o=!1;t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&(t=t.slice(0,t.length-1));for(var a=0,l=t.length-1;a<t.length;l=a++){var h=t[a][0],f=t[a][1],p=t[l][0],d=t[l][1],g=r[1]*(h-p)+f*(p-r[0])+d*(r[0]-h)===0&&(h-r[0])*(p-r[0])<=0&&(f-r[1])*(d-r[1])<=0;if(g)return!e;var x=f>r[1]!=d>r[1]&&r[0]<(p-h)*(r[1]-f)/(d-f)+h;x&&(o=!o)}return o}function ZF(r,t){return t[0]<=r[0]&&t[1]<=r[1]&&t[2]>=r[0]&&t[3]>=r[1]}var cS=new ArrayBuffer(16),TH=new Float64Array(cS),AH=new Uint32Array(cS);var cU=yn(Zm(),1);var Q6=function(){function r(t){this.points=t.points||[],this.duration=t.duration||1e4,this.sharpness=t.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=t.stepLength||60,this.length=this.points.length,this.delay=0;for(var e=0;e<this.length;e++)this.points[e].z=this.points[e].z||0;for(var e=0;e<this.length-1;e++){var o=this.points[e],a=this.points[e+1];this.centers.push({x:(o.x+a.x)/2,y:(o.y+a.y)/2,z:(o.z+a.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var e=0;e<this.centers.length-1;e++){var l=this.points[e+1].x-(this.centers[e].x+this.centers[e+1].x)/2,h=this.points[e+1].y-(this.centers[e].y+this.centers[e+1].y)/2,f=this.points[e+1].z-(this.centers[e].y+this.centers[e+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e].x+l),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e].y+h),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e].z+f)},{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e+1].x+l),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e+1].y+h),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e+1].z+f)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return r.prototype.cacheSteps=function(t){var e=[],o=this.pos(0);e.push(0);for(var a=0;a<this.duration;a+=10){var l=this.pos(a),h=Math.sqrt((l.x-o.x)*(l.x-o.x)+(l.y-o.y)*(l.y-o.y)+(l.z-o.z)*(l.z-o.z));h>t&&(e.push(a),o=l)}return e},r.prototype.vector=function(t){var e=this.pos(t+10),o=this.pos(t-10);return{angle:180*Math.atan2(e.y-o.y,e.x-o.x)/3.14,speed:Math.sqrt((o.x-e.x)*(o.x-e.x)+(o.y-e.y)*(o.y-e.y)+(o.z-e.z)*(o.z-e.z))}},r.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var o=e/this.duration;if(o>=1)return this.points[this.length-1];var a=Math.floor((this.points.length-1)*o),l=(this.length-1)*o-a;return fU(l,this.points[a],this.controls[a][1],this.controls[a+1][0],this.points[a+1])},r}();function fU(r,t,e,o,a){var l=hU(r),h={x:a.x*l[0]+o.x*l[1]+e.x*l[2]+t.x*l[3],y:a.y*l[0]+o.y*l[1]+e.y*l[2]+t.y*l[3],z:a.z*l[0]+o.z*l[1]+e.z*l[2]+t.z*l[3]};return h}function hU(r){var t=r*r,e=t*r;return[e,3*t*(1-r),3*r*(1-r)*(1-r),(1-r)*(1-r)*(1-r)]}function Ll(r,t){t===void 0&&(t={});var e=Number(r[0]),o=Number(r[1]),a=Number(r[2]),l=Number(r[3]);if(r.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var h=[e,o],f=[e,l],p=[a,l],d=[a,o];return Vn([[h,d,p,f,h]],t.properties,{bbox:r,id:t.id})}function pU(r){return Ll(hi(r))}var Jm=pU;var IU=yn(ES(),1);var rB=yn(jf(),1);var oB=yn(Df(),1);var uB=yn(Zm(),1);var zS=Math.PI/180,GS=180/Math.PI,zl=function(r,t){this.lon=r,this.lat=t,this.x=zS*r,this.y=zS*t};zl.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)};zl.prototype.antipode=function(){var r=-1*this.lat,t=this.lon<0?180+this.lon:(180-this.lon)*-1;return new zl(t,r)};var kS=function(){this.coords=[],this.length=0};kS.prototype.move_to=function(r){this.length++,this.coords.push(r)};var gg=function(r){this.properties=r||{},this.geometries=[]};gg.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(this.geometries.length===1)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var r=[],t=0;t<this.geometries.length;t++)r.push(this.geometries[t].coords);return{geometry:{type:"MultiLineString",coordinates:r},type:"Feature",properties:this.properties}};gg.prototype.wkt=function(){for(var r="",t="LINESTRING(",e=function(l){t+=l[0]+" "+l[1]+","},o=0;o<this.geometries.length;o++){if(this.geometries[o].coords.length===0)return"LINESTRING(empty)";var a=this.geometries[o].coords;a.forEach(e),r+=t.substring(0,t.length-1)+")"}return r};var qS=function(r,t,e){if(!r||r.x===void 0||r.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!t||t.x===void 0||t.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new zl(r.x,r.y),this.end=new zl(t.x,t.y),this.properties=e||{};var o=this.start.x-this.end.x,a=this.start.y-this.end.y,l=Math.pow(Math.sin(a/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(o/2),2);if(this.g=2*Math.asin(Math.sqrt(l)),this.g===Math.PI)throw new Error("it appears "+r.view()+" and "+t.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+r+" and "+t)};qS.prototype.interpolate=function(r){var t=Math.sin((1-r)*this.g)/Math.sin(this.g),e=Math.sin(r*this.g)/Math.sin(this.g),o=t*Math.cos(this.start.y)*Math.cos(this.start.x)+e*Math.cos(this.end.y)*Math.cos(this.end.x),a=t*Math.cos(this.start.y)*Math.sin(this.start.x)+e*Math.cos(this.end.y)*Math.sin(this.end.x),l=t*Math.sin(this.start.y)+e*Math.sin(this.end.y),h=GS*Math.atan2(l,Math.sqrt(Math.pow(o,2)+Math.pow(a,2))),f=GS*Math.atan2(a,o);return[f,h]};qS.prototype.Arc=function(r,t){var e=[];if(!r||r<=2)e.push([this.start.lon,this.start.lat]),e.push([this.end.lon,this.end.lat]);else for(var o=1/(r-1),a=0;a<r;++a){var l=o*a,h=this.interpolate(l);e.push(h)}for(var f=!1,p=0,d=t&&t.offset?t.offset:10,g=180-d,x=-180+d,v=360-d,S=1;S<e.length;++S){var b=e[S-1][0],T=e[S][0],_=Math.abs(T-b);_>v&&(T>g&&b<x||b>g&&T<x)?f=!0:_>p&&(p=_)}var y=[];if(f&&p<d){var A=[];y.push(A);for(var M=0;M<e.length;++M){var L=parseFloat(e[M][0]);if(M>0&&Math.abs(L-e[M-1][0])>v){var G=parseFloat(e[M-1][0]),z=parseFloat(e[M-1][1]),F=parseFloat(e[M][0]),I=parseFloat(e[M][1]);if(G>-180&&G<x&&F===180&&M+1<e.length&&e[M-1][0]>-180&&e[M-1][0]<x){A.push([-180,e[M][1]]),M++,A.push([e[M][0],e[M][1]]);continue}else if(G>g&&G<180&&F===-180&&M+1<e.length&&e[M-1][0]>g&&e[M-1][0]<180){A.push([180,e[M][1]]),M++,A.push([e[M][0],e[M][1]]);continue}if(G<x&&F>g){var ut=G;G=F,F=ut;var R=z;z=I,I=R}if(G>g&&F<x&&(F+=360),G<=180&&F>=180&&G<F){var W=(180-G)/(F-G),V=W*I+(1-W)*z;A.push([e[M-1][0]>g?180:-180,V]),A=[],A.push([e[M-1][0]>g?-180:180,V]),y.push(A)}else A=[],y.push(A);A.push([L,e[M][1]])}else A.push([e[M][0],e[M][1]])}}else{var St=[];y.push(St);for(var X=0;X<e.length;++X)St.push([e[X][0],e[X][1]])}for(var mt=new gg(this.properties),dt=0;dt<y.length;++dt){var vt=new kS;mt.geometries.push(vt);for(var rt=y[dt],lt=0;lt<rt.length;++lt)vt.move_to(rt[lt])}return mt};var fB=yn(jf(),1);var Hz=yn(jf(),1);var Wz=yn(Bg(),1);var $z=yn(Df(),1);var we=[],be=[],Te=[],Ae=[],Ce=[],Pe=[],Ie=[],Re=[],Le=[],Ne=[],Oe=[],De=[],Fe=[],Ue=[],Be=[],ze=[],Ge=[],ke=[],qe=[],Ve=[],He=[],We=[],Xe=[],Ye=[];Ie[85]=Ne[85]=-1;Re[85]=Oe[85]=0;Le[85]=De[85]=1;qe[85]=We[85]=1;Ve[85]=Xe[85]=0;He[85]=Ye[85]=1;we[85]=Ae[85]=0;be[85]=Ce[85]=-1;Te[85]=Be[85]=0;ze[85]=Fe[85]=0;Ge[85]=Ue[85]=1;Pe[85]=ke[85]=1;We[1]=We[169]=0;Xe[1]=Xe[169]=-1;Ye[1]=Ye[169]=0;Fe[1]=Fe[169]=-1;Ue[1]=Ue[169]=0;Be[1]=Be[169]=0;Ne[4]=Ne[166]=0;Oe[4]=Oe[166]=-1;De[4]=De[166]=1;ze[4]=ze[166]=1;Ge[4]=Ge[166]=0;ke[4]=ke[166]=0;Ie[16]=Ie[154]=0;Re[16]=Re[154]=1;Le[16]=Le[154]=1;Ae[16]=Ae[154]=1;Ce[16]=Ce[154]=0;Pe[16]=Pe[154]=1;qe[64]=qe[106]=0;Ve[64]=Ve[106]=1;He[64]=He[106]=0;we[64]=we[106]=-1;be[64]=be[106]=0;Te[64]=Te[106]=1;qe[2]=qe[168]=0;Ve[2]=Ve[168]=-1;He[2]=He[168]=1;We[2]=We[168]=0;Xe[2]=Xe[168]=-1;Ye[2]=Ye[168]=0;Fe[2]=Fe[168]=-1;Ue[2]=Ue[168]=0;Be[2]=Be[168]=0;ze[2]=ze[168]=-1;Ge[2]=Ge[168]=0;ke[2]=ke[168]=1;Ie[8]=Ie[162]=0;Re[8]=Re[162]=-1;Le[8]=Le[162]=0;Ne[8]=Ne[162]=0;Oe[8]=Oe[162]=-1;De[8]=De[162]=1;Fe[8]=Fe[162]=1;Ue[8]=Ue[162]=0;Be[8]=Be[162]=1;ze[8]=ze[162]=1;Ge[8]=Ge[162]=0;ke[8]=ke[162]=0;Ie[32]=Ie[138]=0;Re[32]=Re[138]=1;Le[32]=Le[138]=1;Ne[32]=Ne[138]=0;Oe[32]=Oe[138]=1;De[32]=De[138]=0;we[32]=we[138]=1;be[32]=be[138]=0;Te[32]=Te[138]=0;Ae[32]=Ae[138]=1;Ce[32]=Ce[138]=0;Pe[32]=Pe[138]=1;We[128]=We[42]=0;Xe[128]=Xe[42]=1;Ye[128]=Ye[42]=1;qe[128]=qe[42]=0;Ve[128]=Ve[42]=1;He[128]=He[42]=0;we[128]=we[42]=-1;be[128]=be[42]=0;Te[128]=Te[42]=1;Ae[128]=Ae[42]=-1;Ce[128]=Ce[42]=0;Pe[128]=Pe[42]=0;Ne[5]=Ne[165]=-1;Oe[5]=Oe[165]=0;De[5]=De[165]=0;We[5]=We[165]=1;Xe[5]=Xe[165]=0;Ye[5]=Ye[165]=0;ze[20]=ze[150]=0;Ge[20]=Ge[150]=1;ke[20]=ke[150]=1;Ae[20]=Ae[150]=0;Ce[20]=Ce[150]=-1;Pe[20]=Pe[150]=1;Ie[80]=Ie[90]=-1;Re[80]=Re[90]=0;Le[80]=Le[90]=1;qe[80]=qe[90]=1;Ve[80]=Ve[90]=0;He[80]=He[90]=1;Fe[65]=Fe[105]=0;Ue[65]=Ue[105]=1;Be[65]=Be[105]=0;we[65]=we[105]=0;be[65]=be[105]=-1;Te[65]=Te[105]=0;Ie[160]=Ie[10]=-1;Re[160]=Re[10]=0;Le[160]=Le[10]=1;Ne[160]=Ne[10]=-1;Oe[160]=Oe[10]=0;De[160]=De[10]=0;We[160]=We[10]=1;Xe[160]=Xe[10]=0;Ye[160]=Ye[10]=0;qe[160]=qe[10]=1;Ve[160]=Ve[10]=0;He[160]=He[10]=1;ze[130]=ze[40]=0;Ge[130]=Ge[40]=1;ke[130]=ke[40]=1;Fe[130]=Fe[40]=0;Ue[130]=Ue[40]=1;Be[130]=Be[40]=0;we[130]=we[40]=0;be[130]=be[40]=-1;Te[130]=Te[40]=0;Ae[130]=Ae[40]=0;Ce[130]=Ce[40]=-1;Pe[130]=Pe[40]=1;Ne[37]=Ne[133]=0;Oe[37]=Oe[133]=1;De[37]=De[133]=1;We[37]=We[133]=0;Xe[37]=Xe[133]=1;Ye[37]=Ye[133]=0;we[37]=we[133]=-1;be[37]=be[133]=0;Te[37]=Te[133]=0;Ae[37]=Ae[133]=1;Ce[37]=Ce[133]=0;Pe[37]=Pe[133]=0;ze[148]=ze[22]=-1;Ge[148]=Ge[22]=0;ke[148]=ke[22]=0;We[148]=We[22]=0;Xe[148]=Xe[22]=-1;Ye[148]=Ye[22]=1;qe[148]=qe[22]=0;Ve[148]=Ve[22]=1;He[148]=He[22]=1;Ae[148]=Ae[22]=-1;Ce[148]=Ce[22]=0;Pe[148]=Pe[22]=1;Ie[82]=Ie[88]=0;Re[82]=Re[88]=-1;Le[82]=Le[88]=1;ze[82]=ze[88]=1;Ge[82]=Ge[88]=0;ke[82]=ke[88]=1;Fe[82]=Fe[88]=-1;Ue[82]=Ue[88]=0;Be[82]=Be[88]=1;qe[82]=qe[88]=0;Ve[82]=Ve[88]=-1;He[82]=He[88]=0;Ie[73]=Ie[97]=0;Re[73]=Re[97]=1;Le[73]=Le[97]=0;Ne[73]=Ne[97]=0;Oe[73]=Oe[97]=-1;De[73]=De[97]=0;Fe[73]=Fe[97]=1;Ue[73]=Ue[97]=0;Be[73]=Be[97]=0;we[73]=we[97]=1;be[73]=be[97]=0;Te[73]=Te[97]=1;Ie[145]=Ie[25]=0;Re[145]=Re[25]=-1;Le[145]=Le[25]=0;Fe[145]=Fe[25]=1;Ue[145]=Ue[25]=0;Be[145]=Be[25]=1;We[145]=We[25]=0;Xe[145]=Xe[25]=1;Ye[145]=Ye[25]=1;Ae[145]=Ae[25]=-1;Ce[145]=Ce[25]=0;Pe[145]=Pe[25]=0;Ne[70]=Ne[100]=0;Oe[70]=Oe[100]=1;De[70]=De[100]=0;ze[70]=ze[100]=-1;Ge[70]=Ge[100]=0;ke[70]=ke[100]=1;qe[70]=qe[100]=0;Ve[70]=Ve[100]=-1;He[70]=He[100]=1;we[70]=we[100]=1;be[70]=be[100]=0;Te[70]=Te[100]=0;Ne[101]=Ne[69]=0;Oe[101]=Oe[69]=1;De[101]=De[69]=0;we[101]=we[69]=1;be[101]=be[69]=0;Te[101]=Te[69]=0;We[149]=We[21]=0;Xe[149]=Xe[21]=1;Ye[149]=Ye[21]=1;Ae[149]=Ae[21]=-1;Ce[149]=Ce[21]=0;Pe[149]=Pe[21]=0;ze[86]=ze[84]=-1;Ge[86]=Ge[84]=0;ke[86]=ke[84]=1;qe[86]=qe[84]=0;Ve[86]=Ve[84]=-1;He[86]=He[84]=1;Ie[89]=Ie[81]=0;Re[89]=Re[81]=-1;Le[89]=Le[81]=0;Fe[89]=Fe[81]=1;Ue[89]=Ue[81]=0;Be[89]=Be[81]=1;Ie[96]=Ie[74]=0;Re[96]=Re[74]=1;Le[96]=Le[74]=0;Ne[96]=Ne[74]=-1;Oe[96]=Oe[74]=0;De[96]=De[74]=1;qe[96]=qe[74]=1;Ve[96]=Ve[74]=0;He[96]=He[74]=0;we[96]=we[74]=1;be[96]=be[74]=0;Te[96]=Te[74]=1;Ie[24]=Ie[146]=0;Re[24]=Re[146]=-1;Le[24]=Le[146]=1;ze[24]=ze[146]=1;Ge[24]=Ge[146]=0;ke[24]=ke[146]=1;Fe[24]=Fe[146]=0;Ue[24]=Ue[146]=1;Be[24]=Be[146]=1;Ae[24]=Ae[146]=0;Ce[24]=Ce[146]=-1;Pe[24]=Pe[146]=0;Ne[6]=Ne[164]=-1;Oe[6]=Oe[164]=0;De[6]=De[164]=1;ze[6]=ze[164]=-1;Ge[6]=Ge[164]=0;ke[6]=ke[164]=0;We[6]=We[164]=0;Xe[6]=Xe[164]=-1;Ye[6]=Ye[164]=1;qe[6]=qe[164]=1;Ve[6]=Ve[164]=0;He[6]=He[164]=0;Fe[129]=Fe[41]=0;Ue[129]=Ue[41]=1;Be[129]=Be[41]=1;We[129]=We[41]=0;Xe[129]=Xe[41]=1;Ye[129]=Ye[41]=0;we[129]=we[41]=-1;be[129]=be[41]=0;Te[129]=Te[41]=0;Ae[129]=Ae[41]=0;Ce[129]=Ce[41]=-1;Pe[129]=Pe[41]=0;ze[66]=ze[104]=0;Ge[66]=Ge[104]=1;ke[66]=ke[104]=0;Fe[66]=Fe[104]=-1;Ue[66]=Ue[104]=0;Be[66]=Be[104]=1;qe[66]=qe[104]=0;Ve[66]=Ve[104]=-1;He[66]=He[104]=0;we[66]=we[104]=0;be[66]=be[104]=-1;Te[66]=Te[104]=1;Ie[144]=Ie[26]=-1;Re[144]=Re[26]=0;Le[144]=Le[26]=0;We[144]=We[26]=1;Xe[144]=Xe[26]=0;Ye[144]=Ye[26]=1;qe[144]=qe[26]=0;Ve[144]=Ve[26]=1;He[144]=He[26]=1;Ae[144]=Ae[26]=-1;Ce[144]=Ce[26]=0;Pe[144]=Pe[26]=1;Ne[36]=Ne[134]=0;Oe[36]=Oe[134]=1;De[36]=De[134]=1;ze[36]=ze[134]=0;Ge[36]=Ge[134]=1;ke[36]=ke[134]=0;we[36]=we[134]=0;be[36]=be[134]=-1;Te[36]=Te[134]=1;Ae[36]=Ae[134]=1;Ce[36]=Ce[134]=0;Pe[36]=Pe[134]=0;Ie[9]=Ie[161]=-1;Re[9]=Re[161]=0;Le[9]=Le[161]=0;Ne[9]=Ne[161]=0;Oe[9]=Oe[161]=-1;De[9]=De[161]=0;Fe[9]=Fe[161]=1;Ue[9]=Ue[161]=0;Be[9]=Be[161]=0;We[9]=We[161]=1;Xe[9]=Xe[161]=0;Ye[9]=Ye[161]=1;Ie[136]=0;Re[136]=1;Le[136]=1;Ne[136]=0;Oe[136]=1;De[136]=0;ze[136]=-1;Ge[136]=0;ke[136]=1;Fe[136]=-1;Ue[136]=0;Be[136]=0;We[136]=0;Xe[136]=-1;Ye[136]=0;qe[136]=0;Ve[136]=-1;He[136]=1;we[136]=1;be[136]=0;Te[136]=0;Ae[136]=1;Ce[136]=0;Pe[136]=1;Ie[34]=0;Re[34]=-1;Le[34]=0;Ne[34]=0;Oe[34]=-1;De[34]=1;ze[34]=1;Ge[34]=0;ke[34]=0;Fe[34]=1;Ue[34]=0;Be[34]=1;We[34]=0;Xe[34]=1;Ye[34]=1;qe[34]=0;Ve[34]=1;He[34]=0;we[34]=-1;be[34]=0;Te[34]=1;Ae[34]=-1;Ce[34]=0;Pe[34]=0;Ie[35]=0;Re[35]=1;Le[35]=1;Ne[35]=0;Oe[35]=-1;De[35]=1;ze[35]=1;Ge[35]=0;ke[35]=0;Fe[35]=-1;Ue[35]=0;Be[35]=0;We[35]=0;Xe[35]=-1;Ye[35]=0;qe[35]=0;Ve[35]=1;He[35]=0;we[35]=-1;be[35]=0;Te[35]=1;Ae[35]=1;Ce[35]=0;Pe[35]=1;Ie[153]=0;Re[153]=1;Le[153]=1;Fe[153]=-1;Ue[153]=0;Be[153]=0;We[153]=0;Xe[153]=-1;Ye[153]=0;Ae[153]=1;Ce[153]=0;Pe[153]=1;Ne[102]=0;Oe[102]=-1;De[102]=1;ze[102]=1;Ge[102]=0;ke[102]=0;qe[102]=0;Ve[102]=1;He[102]=0;we[102]=-1;be[102]=0;Te[102]=1;Ie[155]=0;Re[155]=-1;Le[155]=0;Fe[155]=1;Ue[155]=0;Be[155]=1;We[155]=0;Xe[155]=1;Ye[155]=1;Ae[155]=-1;Ce[155]=0;Pe[155]=0;Ne[103]=0;Oe[103]=1;De[103]=0;ze[103]=-1;Ge[103]=0;ke[103]=1;qe[103]=0;Ve[103]=-1;He[103]=1;we[103]=1;be[103]=0;Te[103]=0;Ie[152]=0;Re[152]=1;Le[152]=1;ze[152]=-1;Ge[152]=0;ke[152]=1;Fe[152]=-1;Ue[152]=0;Be[152]=0;We[152]=0;Xe[152]=-1;Ye[152]=0;qe[152]=0;Ve[152]=-1;He[152]=1;Ae[152]=1;Ce[152]=0;Pe[152]=1;Ie[156]=0;Re[156]=-1;Le[156]=1;ze[156]=1;Ge[156]=0;ke[156]=1;Fe[156]=-1;Ue[156]=0;Be[156]=0;We[156]=0;Xe[156]=-1;Ye[156]=0;qe[156]=0;Ve[156]=1;He[156]=1;Ae[156]=-1;Ce[156]=0;Pe[156]=1;Ie[137]=0;Re[137]=1;Le[137]=1;Ne[137]=0;Oe[137]=1;De[137]=0;Fe[137]=-1;Ue[137]=0;Be[137]=0;We[137]=0;Xe[137]=-1;Ye[137]=0;we[137]=1;be[137]=0;Te[137]=0;Ae[137]=1;Ce[137]=0;Pe[137]=1;Ie[139]=0;Re[139]=1;Le[139]=1;Ne[139]=0;Oe[139]=-1;De[139]=0;Fe[139]=1;Ue[139]=0;Be[139]=0;We[139]=0;Xe[139]=1;Ye[139]=0;we[139]=-1;be[139]=0;Te[139]=0;Ae[139]=1;Ce[139]=0;Pe[139]=1;Ie[98]=0;Re[98]=-1;Le[98]=0;Ne[98]=0;Oe[98]=-1;De[98]=1;ze[98]=1;Ge[98]=0;ke[98]=0;Fe[98]=1;Ue[98]=0;Be[98]=1;qe[98]=0;Ve[98]=1;He[98]=0;we[98]=-1;be[98]=0;Te[98]=1;Ie[99]=0;Re[99]=1;Le[99]=0;Ne[99]=0;Oe[99]=-1;De[99]=1;ze[99]=1;Ge[99]=0;ke[99]=0;Fe[99]=-1;Ue[99]=0;Be[99]=1;qe[99]=0;Ve[99]=-1;He[99]=0;we[99]=1;be[99]=0;Te[99]=1;Ne[38]=0;Oe[38]=-1;De[38]=1;ze[38]=1;Ge[38]=0;ke[38]=0;We[38]=0;Xe[38]=1;Ye[38]=1;qe[38]=0;Ve[38]=1;He[38]=0;we[38]=-1;be[38]=0;Te[38]=1;Ae[38]=-1;Ce[38]=0;Pe[38]=0;Ne[39]=0;Oe[39]=1;De[39]=1;ze[39]=-1;Ge[39]=0;ke[39]=0;We[39]=0;Xe[39]=-1;Ye[39]=1;qe[39]=0;Ve[39]=1;He[39]=0;we[39]=-1;be[39]=0;Te[39]=1;Ae[39]=1;Ce[39]=0;Pe[39]=0;var zg=function(r){return[[r.bottomleft,0],[0,0],[0,r.leftbottom]]},Gg=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0]]},kg=function(r){return[[r.topright,1],[1,1],[1,r.righttop]]},qg=function(r){return[[0,r.lefttop],[0,1],[r.topleft,1]]},Vg=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop]]},Hg=function(r){return[[r.bottomright,0],[r.bottomleft,0],[1,r.righttop],[1,r.rightbottom]]},Wg=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.topleft,1],[r.topright,1]]},Xg=function(r){return[[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},Zz=function(r){return[[0,0],[0,r.leftbottom],[1,r.rightbottom],[1,0]]},Jz=function(r){return[[1,0],[r.bottomright,0],[r.topright,1],[1,1]]},Kz=function(r){return[[1,1],[1,r.righttop],[0,r.lefttop],[0,1]]},jz=function(r){return[[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},Qz=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.leftbottom],[0,r.lefttop]]},tG=function(r){return[[r.topleft,1],[r.topright,1],[r.bottomright,0],[r.bottomleft,0]]},eG=function(){return[[0,0],[0,1],[1,1],[1,0]]},nG=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,1],[r.topleft,1]]},rG=function(r){return[[r.topright,1],[1,1],[1,0],[0,0],[0,r.leftbottom]]},iG=function(r){return[[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[1,1]]},oG=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,1]]},sG=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.lefttop],[0,1],[r.topleft,1]]},aG=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[r.topright,1]]},uG=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop]]},lG=function(r){return[[r.topright,1],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1]]},cG=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},fG=function(r){return[[1,1],[1,r.righttop],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},hG=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[r.topleft,1],[r.topright,1]]},pG=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom]]},dG=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},mG=function(r){return[[1,1],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},gG=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1]]},yG=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},vG=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},_G=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},xG=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},EG=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},SG=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},MG=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},wG=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},bG=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},TG=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},Je=[],Ke=[],je=[],Qe=[],tn=[],en=[],nn=[],rn=[];Qe[1]=tn[1]=18;Qe[169]=tn[169]=18;je[4]=Ke[4]=12;je[166]=Ke[166]=12;Je[16]=rn[16]=4;Je[154]=rn[154]=4;en[64]=nn[64]=22;en[106]=nn[106]=22;je[2]=en[2]=17;Qe[2]=tn[2]=18;je[168]=en[168]=17;Qe[168]=tn[168]=18;Je[8]=Qe[8]=9;Ke[8]=je[8]=12;Je[162]=Qe[162]=9;Ke[162]=je[162]=12;Je[32]=rn[32]=4;Ke[32]=nn[32]=1;Je[138]=rn[138]=4;Ke[138]=nn[138]=1;tn[128]=rn[128]=21;en[128]=nn[128]=22;tn[42]=rn[42]=21;en[42]=nn[42]=22;Ke[5]=tn[5]=14;Ke[165]=tn[165]=14;je[20]=rn[20]=6;je[150]=rn[150]=6;Je[80]=en[80]=11;Je[90]=en[90]=11;Qe[65]=nn[65]=3;Qe[105]=nn[105]=3;Je[160]=en[160]=11;Ke[160]=tn[160]=14;Je[10]=en[10]=11;Ke[10]=tn[10]=14;je[130]=rn[130]=6;Qe[130]=nn[130]=3;je[40]=rn[40]=6;Qe[40]=nn[40]=3;Ke[101]=nn[101]=1;Ke[69]=nn[69]=1;tn[149]=rn[149]=21;tn[21]=rn[21]=21;je[86]=en[86]=17;je[84]=en[84]=17;Je[89]=Qe[89]=9;Je[81]=Qe[81]=9;Je[96]=nn[96]=0;Ke[96]=en[96]=15;Je[74]=nn[74]=0;Ke[74]=en[74]=15;Je[24]=je[24]=8;Qe[24]=rn[24]=7;Je[146]=je[146]=8;Qe[146]=rn[146]=7;Ke[6]=en[6]=15;je[6]=tn[6]=16;Ke[164]=en[164]=15;je[164]=tn[164]=16;Qe[129]=rn[129]=7;tn[129]=nn[129]=20;Qe[41]=rn[41]=7;tn[41]=nn[41]=20;je[66]=nn[66]=2;Qe[66]=en[66]=19;je[104]=nn[104]=2;Qe[104]=en[104]=19;Je[144]=tn[144]=10;en[144]=rn[144]=23;Je[26]=tn[26]=10;en[26]=rn[26]=23;Ke[36]=rn[36]=5;je[36]=nn[36]=2;Ke[134]=rn[134]=5;je[134]=nn[134]=2;Je[9]=tn[9]=10;Ke[9]=Qe[9]=13;Je[161]=tn[161]=10;Ke[161]=Qe[161]=13;Ke[37]=rn[37]=5;tn[37]=nn[37]=20;Ke[133]=rn[133]=5;tn[133]=nn[133]=20;je[148]=tn[148]=16;en[148]=rn[148]=23;je[22]=tn[22]=16;en[22]=rn[22]=23;Je[82]=je[82]=8;Qe[82]=en[82]=19;Je[88]=je[88]=8;Qe[88]=en[88]=19;Je[73]=nn[73]=0;Ke[73]=Qe[73]=13;Je[97]=nn[97]=0;Ke[97]=Qe[97]=13;Je[145]=Qe[145]=9;tn[145]=rn[145]=21;Je[25]=Qe[25]=9;tn[25]=rn[25]=21;Ke[70]=nn[70]=1;je[70]=en[70]=17;Ke[100]=nn[100]=1;je[100]=en[100]=17;Je[34]=Qe[34]=9;Ke[34]=je[34]=12;tn[34]=rn[34]=21;en[34]=nn[34]=22;Je[136]=rn[136]=4;Ke[136]=nn[136]=1;je[136]=en[136]=17;Qe[136]=tn[136]=18;Je[35]=rn[35]=4;Ke[35]=je[35]=12;Qe[35]=tn[35]=18;en[35]=nn[35]=22;Je[153]=rn[153]=4;Qe[153]=tn[153]=18;Ke[102]=je[102]=12;en[102]=nn[102]=22;Je[155]=Qe[155]=9;tn[155]=rn[155]=23;Ke[103]=nn[103]=1;je[103]=en[103]=17;Je[152]=rn[152]=4;je[152]=en[152]=17;Qe[152]=tn[152]=18;Je[156]=je[156]=8;Qe[156]=tn[156]=18;en[156]=rn[156]=23;Je[137]=rn[137]=4;Ke[137]=nn[137]=1;Qe[137]=tn[137]=18;Je[139]=rn[139]=4;Ke[139]=Qe[139]=13;tn[139]=nn[139]=20;Je[98]=Qe[98]=9;Ke[98]=je[98]=12;en[98]=nn[98]=22;Je[99]=nn[99]=0;Ke[99]=je[99]=12;Qe[99]=en[99]=19;Ke[38]=je[38]=12;tn[38]=rn[38]=21;en[38]=nn[38]=22;Ke[39]=rn[39]=5;je[39]=tn[39]=16;en[39]=nn[39]=22;var Gt=[];Gt[1]=Gt[169]=zg;Gt[4]=Gt[166]=Gg;Gt[16]=Gt[154]=kg;Gt[64]=Gt[106]=qg;Gt[168]=Gt[2]=Vg;Gt[162]=Gt[8]=Hg;Gt[138]=Gt[32]=Wg;Gt[42]=Gt[128]=Xg;Gt[5]=Gt[165]=Zz;Gt[20]=Gt[150]=Jz;Gt[80]=Gt[90]=Kz;Gt[65]=Gt[105]=jz;Gt[160]=Gt[10]=Qz;Gt[130]=Gt[40]=tG;Gt[85]=eG;Gt[101]=Gt[69]=nG;Gt[149]=Gt[21]=rG;Gt[86]=Gt[84]=iG;Gt[89]=Gt[81]=oG;Gt[96]=Gt[74]=sG;Gt[24]=Gt[146]=aG;Gt[6]=Gt[164]=uG;Gt[129]=Gt[41]=lG;Gt[66]=Gt[104]=cG;Gt[144]=Gt[26]=fG;Gt[36]=Gt[134]=hG;Gt[9]=Gt[161]=pG;Gt[37]=Gt[133]=dG;Gt[148]=Gt[22]=mG;Gt[82]=Gt[88]=gG;Gt[73]=Gt[97]=yG;Gt[145]=Gt[25]=vG;Gt[70]=Gt[100]=_G;Gt[34]=function(r){return[Xg(r),Hg(r)]};Gt[35]=xG;Gt[136]=function(r){return[Wg(r),Vg(r)]};Gt[153]=function(r){return[kg(r),zg(r)]};Gt[102]=function(r){return[Gg(r),qg(r)]};Gt[155]=EG;Gt[103]=SG;Gt[152]=function(r){return[kg(r),Vg(r)]};Gt[156]=MG;Gt[137]=function(r){return[Wg(r),zg(r)]};Gt[139]=wG;Gt[98]=function(r){return[Hg(r),qg(r)]};Gt[99]=bG;Gt[38]=function(r){return[Gg(r),Xg(r)]};Gt[39]=TG;function CG(r){return(r>0)-(r<0)||+r}function Uu(r,t,e){var o=t[0]-r[0],a=t[1]-r[1],l=e[0]-t[0],h=e[1]-t[1];return CG(o*h-l*a)}function $w(r,t){var e=r.geometry.coordinates[0].map(function(h){return h[0]}),o=r.geometry.coordinates[0].map(function(h){return h[1]}),a=t.geometry.coordinates[0].map(function(h){return h[0]}),l=t.geometry.coordinates[0].map(function(h){return h[1]});return Math.max.apply(null,e)===Math.max.apply(null,a)&&Math.max.apply(null,o)===Math.max.apply(null,l)&&Math.min.apply(null,e)===Math.min.apply(null,a)&&Math.min.apply(null,o)===Math.min.apply(null,l)}function Yg(r,t){return t.geometry.coordinates[0].every(function(e){return Pr(Ln(e),r)})}function Zw(r,t){return r[0]===t[0]&&r[1]===t[1]}var PG=function(){function r(t){this.id=r.buildId(t),this.coordinates=t,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}return r.buildId=function(t){return t.join(",")},r.prototype.removeInnerEdge=function(t){this.innerEdges=this.innerEdges.filter(function(e){return e.from.id!==t.from.id})},r.prototype.removeOuterEdge=function(t){this.outerEdges=this.outerEdges.filter(function(e){return e.to.id!==t.to.id})},r.prototype.addOuterEdge=function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1},r.prototype.sortOuterEdges=function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort(function(e,o){var a=e.to,l=o.to;if(a.coordinates[0]-t.coordinates[0]>=0&&l.coordinates[0]-t.coordinates[0]<0)return 1;if(a.coordinates[0]-t.coordinates[0]<0&&l.coordinates[0]-t.coordinates[0]>=0)return-1;if(a.coordinates[0]-t.coordinates[0]===0&&l.coordinates[0]-t.coordinates[0]===0)return a.coordinates[1]-t.coordinates[1]>=0||l.coordinates[1]-t.coordinates[1]>=0?a.coordinates[1]-l.coordinates[1]:l.coordinates[1]-a.coordinates[1];var h=Uu(t.coordinates,a.coordinates,l.coordinates);if(h<0)return 1;if(h>0)return-1;var f=Math.pow(a.coordinates[0]-t.coordinates[0],2)+Math.pow(a.coordinates[1]-t.coordinates[1],2),p=Math.pow(l.coordinates[0]-t.coordinates[0],2)+Math.pow(l.coordinates[1]-t.coordinates[1],2);return f-p}),this.outerEdgesSorted=!0)},r.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},r.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t]},r.prototype.addInnerEdge=function(t){this.innerEdges.push(t)},r}(),$g=PG;var IG=function(){function r(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}return r.prototype.getSymetric=function(){return this.symetric||(this.symetric=new r(this.to,this.from),this.symetric.symetric=this),this.symetric},r.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},r.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id},r.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},r.prototype.toLineString=function(){return Cr([this.from.coordinates,this.to.coordinates])},r.prototype.compareTo=function(t){return Uu(t.from.coordinates,t.to.coordinates,this.to.coordinates)},r}(),Jw=IG;var RG=function(){function r(){this.edges=[],this.polygon=void 0,this.envelope=void 0}return r.prototype.push=function(t){this.edges.push(t),this.polygon=this.envelope=void 0},r.prototype.get=function(t){return this.edges[t]},Object.defineProperty(r.prototype,"length",{get:function(){return this.edges.length},enumerable:!0,configurable:!0}),r.prototype.forEach=function(t){this.edges.forEach(t)},r.prototype.map=function(t){return this.edges.map(t)},r.prototype.some=function(t){return this.edges.some(t)},r.prototype.isValid=function(){return!0},r.prototype.isHole=function(){var t=this,e=this.edges.reduce(function(h,f,p){return f.from.coordinates[1]>t.edges[h].from.coordinates[1]&&(h=p),h},0),o=(e===0?this.length:e)-1,a=(e+1)%this.length,l=Uu(this.edges[o].from.coordinates,this.edges[e].from.coordinates,this.edges[a].from.coordinates);return l===0?this.edges[o].from.coordinates[0]>this.edges[a].from.coordinates[0]:l>0},r.prototype.toMultiPoint=function(){return Rm(this.edges.map(function(t){return t.from.coordinates}))},r.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var t=this.edges.map(function(e){return e.from.coordinates});return t.push(this.edges[0].from.coordinates),this.polygon=Vn([t])},r.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=Jm(this.toPolygon())},r.findEdgeRingContaining=function(t,e){var o=t.getEnvelope(),a,l;return e.forEach(function(h){var f=h.getEnvelope();if(l&&(a=l.getEnvelope()),!$w(f,o)&&Yg(f,o)){for(var p=t.map(function(b){return b.from.coordinates}),d=void 0,g=function(b){h.some(function(T){return Zw(b,T.from.coordinates)})||(d=b)},x=0,v=p;x<v.length;x++){var S=v[x];g(S)}d&&h.inside(Ln(d))&&(!l||Yg(a,f))&&(l=h)}}),l},r.prototype.inside=function(t){return Pr(t,this.toPolygon())},r}(),Zg=RG;function LG(r){if(!r)throw new Error("No geojson passed");if(r.type!=="FeatureCollection"&&r.type!=="GeometryCollection"&&r.type!=="MultiLineString"&&r.type!=="LineString"&&r.type!=="Feature")throw new Error("Invalid input type '"+r.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")}var qY=function(){function r(){this.edges=[],this.nodes={}}return r.fromGeoJson=function(t){LG(t);var e=new r;return Li(t,function(o){Nm(o,"LineString","Graph::fromGeoJson"),qE(o,function(a,l){if(a){var h=e.getNode(a),f=e.getNode(l);e.addEdge(h,f)}return l})}),e},r.prototype.getNode=function(t){var e=$g.buildId(t),o=this.nodes[e];return o||(o=this.nodes[e]=new $g(t)),o},r.prototype.addEdge=function(t,e){var o=new Jw(t,e),a=o.getSymetric();this.edges.push(o),this.edges.push(a)},r.prototype.deleteDangles=function(){var t=this;Object.keys(this.nodes).map(function(e){return t.nodes[e]}).forEach(function(e){return t._removeIfDangle(e)})},r.prototype._removeIfDangle=function(t){var e=this;if(t.innerEdges.length<=1){var o=t.getOuterEdges().map(function(a){return a.to});this.removeNode(t),o.forEach(function(a){return e._removeIfDangle(a)})}},r.prototype.deleteCutEdges=function(){var t=this;this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach(function(e){e.label===e.symetric.label&&(t.removeEdge(e.symetric),t.removeEdge(e))})},r.prototype._computeNextCWEdges=function(t){var e=this;typeof t=="undefined"?Object.keys(this.nodes).forEach(function(o){return e._computeNextCWEdges(e.nodes[o])}):t.getOuterEdges().forEach(function(o,a){t.getOuterEdge((a===0?t.getOuterEdges().length:a)-1).symetric.next=o})},r.prototype._computeNextCCWEdges=function(t,e){for(var o=t.getOuterEdges(),a,l,h=o.length-1;h>=0;--h){var f=o[h],p=f.symetric,d=void 0,g=void 0;f.label===e&&(d=f),p.label===e&&(g=p),!(!d||!g)&&(g&&(l=g),d&&(l&&(l.next=d,l=void 0),a||(a=d)))}l&&(l.next=a)},r.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach(function(o){if(!(o.label>=0)){t.push(o);var a=o;do a.label=e,a=a.next;while(!o.isEqual(a));e++}}),t},r.prototype.getEdgeRings=function(){var t=this;this._computeNextCWEdges(),this.edges.forEach(function(o){o.label=void 0}),this._findLabeledEdgeRings().forEach(function(o){t._findIntersectionNodes(o).forEach(function(a){t._computeNextCCWEdges(a,o.label)})});var e=[];return this.edges.forEach(function(o){o.ring||e.push(t._findEdgeRing(o))}),e},r.prototype._findIntersectionNodes=function(t){var e=[],o=t,a=function(){var l=0;o.from.getOuterEdges().forEach(function(h){h.label===t.label&&++l}),l>1&&e.push(o.from),o=o.next};do a();while(!t.isEqual(o));return e},r.prototype._findEdgeRing=function(t){var e=t,o=new Zg;do o.push(e),e.ring=o,e=e.next;while(!t.isEqual(e));return o},r.prototype.removeNode=function(t){var e=this;t.getOuterEdges().forEach(function(o){return e.removeEdge(o)}),t.innerEdges.forEach(function(o){return e.removeEdge(o)}),delete this.nodes[t.id]},r.prototype.removeEdge=function(t){this.edges=this.edges.filter(function(e){return!e.isEqual(t)}),t.deleteEdge()},r}();var FG=yn(Jg(),1);var UG=yn(Jg(),1);var zG=yn(ob(),1);var XG=yn(mb(),1);function yb(r){for(var t=r,e=[];t.parent;)e.unshift(t),t=t.parent;return e}function $G(){return new vb(function(r){return r.f})}var t0={search:function(r,t,e,o){r.cleanDirty(),o=o||{};var a=o.heuristic||t0.heuristics.manhattan,l=o.closest||!1,h=$G(),f=t;for(t.h=a(t,e),h.push(t);h.size()>0;){var p=h.pop();if(p===e)return yb(p);p.closed=!0;for(var d=r.neighbors(p),g=0,x=d.length;g<x;++g){var v=d[g];if(!(v.closed||v.isWall())){var S=p.g+v.getCost(p),b=v.visited;(!b||S<v.g)&&(v.visited=!0,v.parent=p,v.h=v.h||a(v,e),v.g=S,v.f=v.g+v.h,r.markDirty(v),l&&(v.h<f.h||v.h===f.h&&v.g<f.g)&&(f=v),b?h.rescoreElement(v):h.push(v))}}}return l?yb(f):[]},heuristics:{manhattan:function(r,t){var e=Math.abs(t.x-r.x),o=Math.abs(t.y-r.y);return e+o},diagonal:function(r,t){var e=1,o=Math.sqrt(2),a=Math.abs(t.x-r.x),l=Math.abs(t.y-r.y);return e*(a+l)+(o-2*e)*Math.min(a,l)}},cleanNode:function(r){r.f=0,r.g=0,r.h=0,r.visited=!1,r.closed=!1,r.parent=null}};function Wl(r,t){t=t||{},this.nodes=[],this.diagonal=!!t.diagonal,this.grid=[];for(var e=0;e<r.length;e++){this.grid[e]=[];for(var o=0,a=r[e];o<a.length;o++){var l=new bh(e,o,a[o]);this.grid[e][o]=l,this.nodes.push(l)}}this.init()}Wl.prototype.init=function(){this.dirtyNodes=[];for(var r=0;r<this.nodes.length;r++)t0.cleanNode(this.nodes[r])};Wl.prototype.cleanDirty=function(){for(var r=0;r<this.dirtyNodes.length;r++)t0.cleanNode(this.dirtyNodes[r]);this.dirtyNodes=[]};Wl.prototype.markDirty=function(r){this.dirtyNodes.push(r)};Wl.prototype.neighbors=function(r){var t=[],e=r.x,o=r.y,a=this.grid;return a[e-1]&&a[e-1][o]&&t.push(a[e-1][o]),a[e+1]&&a[e+1][o]&&t.push(a[e+1][o]),a[e]&&a[e][o-1]&&t.push(a[e][o-1]),a[e]&&a[e][o+1]&&t.push(a[e][o+1]),this.diagonal&&(a[e-1]&&a[e-1][o-1]&&t.push(a[e-1][o-1]),a[e+1]&&a[e+1][o-1]&&t.push(a[e+1][o-1]),a[e-1]&&a[e-1][o+1]&&t.push(a[e-1][o+1]),a[e+1]&&a[e+1][o+1]&&t.push(a[e+1][o+1])),t};Wl.prototype.toString=function(){for(var r=[],t=this.grid,e,o,a,l,h=0,f=t.length;h<f;h++){for(e=[],o=t[h],a=0,l=o.length;a<l;a++)e.push(o[a].weight);r.push(e.join(" "))}return r.join(\`
|
|
7743
7743
|
\`)};function bh(r,t,e){this.x=r,this.y=t,this.weight=e}bh.prototype.toString=function(){return"["+this.x+" "+this.y+"]"};bh.prototype.getCost=function(r){return r&&r.x!==this.x&&r.y!==this.y?this.weight*1.41421:this.weight};bh.prototype.isWall=function(){return this.weight===0};function vb(r){this.content=[],this.scoreFunction=r}vb.prototype={push:function(r){this.content.push(r),this.sinkDown(this.content.length-1)},pop:function(){var r=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),r},remove:function(r){var t=this.content.indexOf(r),e=this.content.pop();t!==this.content.length-1&&(this.content[t]=e,this.scoreFunction(e)<this.scoreFunction(r)?this.sinkDown(t):this.bubbleUp(t))},size:function(){return this.content.length},rescoreElement:function(r){this.sinkDown(this.content.indexOf(r))},sinkDown:function(r){for(var t=this.content[r];r>0;){var e=(r+1>>1)-1,o=this.content[e];if(this.scoreFunction(t)<this.scoreFunction(o))this.content[e]=t,this.content[r]=o,r=e;else break}},bubbleUp:function(r){for(var t=this.content.length,e=this.content[r],o=this.scoreFunction(e);;){var a=r+1<<1,l=a-1,h=null,f;if(l<t){var p=this.content[l];f=this.scoreFunction(p),f<o&&(h=l)}if(a<t){var d=this.content[a],g=this.scoreFunction(d);g<(h===null?o:f)&&(h=a)}if(h!==null)this.content[r]=this.content[h],this.content[h]=e,r=h;else break}}};function e0(){this._=null}function zu(r){r.U=r.C=r.L=r.R=r.P=r.N=null}e0.prototype={constructor:e0,insert:function(r,t){var e,o,a;if(r){if(t.P=r,t.N=r.N,r.N&&(r.N.P=t),r.N=t,r.R){for(r=r.R;r.L;)r=r.L;r.L=t}else r.R=t;e=r}else this._?(r=_b(this._),t.P=null,t.N=r,r.P=r.L=t,e=r):(t.P=t.N=null,this._=t,e=null);for(t.L=t.R=null,t.U=e,t.C=!0,r=t;e&&e.C;)o=e.U,e===o.L?(a=o.R,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.R&&(Xl(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Yl(this,o))):(a=o.L,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.L&&(Yl(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Xl(this,o))),e=r.U;this._.C=!1},remove:function(r){r.N&&(r.N.P=r.P),r.P&&(r.P.N=r.N),r.N=r.P=null;var t=r.U,e,o=r.L,a=r.R,l,h;if(o?a?l=_b(a):l=o:l=a,t?t.L===r?t.L=l:t.R=l:this._=l,o&&a?(h=l.C,l.C=r.C,l.L=o,o.U=l,l!==a?(t=l.U,l.U=r.U,r=l.R,t.L=r,l.R=a,a.U=l):(l.U=t,t=l,r=l.R)):(h=r.C,r=l),r&&(r.U=t),!h){if(r&&r.C){r.C=!1;return}do{if(r===this._)break;if(r===t.L){if(e=t.R,e.C&&(e.C=!1,t.C=!0,Xl(this,t),e=t.R),e.L&&e.L.C||e.R&&e.R.C){(!e.R||!e.R.C)&&(e.L.C=!1,e.C=!0,Yl(this,e),e=t.R),e.C=t.C,t.C=e.R.C=!1,Xl(this,t),r=this._;break}}else if(e=t.L,e.C&&(e.C=!1,t.C=!0,Yl(this,t),e=t.L),e.L&&e.L.C||e.R&&e.R.C){(!e.L||!e.L.C)&&(e.R.C=!1,e.C=!0,Xl(this,e),e=t.L),e.C=t.C,t.C=e.L.C=!1,Yl(this,t),r=this._;break}e.C=!0,r=t,t=t.U}while(!r.C);r&&(r.C=!1)}}};function Xl(r,t){var e=t,o=t.R,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.R=o.L,e.R&&(e.R.U=e),o.L=e}function Yl(r,t){var e=t,o=t.L,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.L=o.R,e.L&&(e.L.U=e),o.R=e}function _b(r){for(;r.L;)r=r.L;return r}var n0=e0;function Gu(r,t,e,o){var a=[null,null],l=Rr.push(a)-1;return a.left=r,a.right=t,e&&$l(a,r,t,e),o&&$l(a,t,r,o),pi[r.index].halfedges.push(l),pi[t.index].halfedges.push(l),a}function ku(r,t,e){var o=[t,e];return o.left=r,o}function $l(r,t,e,o){!r[0]&&!r[1]?(r[0]=o,r.left=t,r.right=e):r.left===e?r[1]=o:r[0]=o}function ZG(r,t,e,o,a){var l=r[0],h=r[1],f=l[0],p=l[1],d=h[0],g=h[1],x=0,v=1,S=d-f,b=g-p,T;if(T=t-f,!(!S&&T>0)){if(T/=S,S<0){if(T<x)return;T<v&&(v=T)}else if(S>0){if(T>v)return;T>x&&(x=T)}if(T=o-f,!(!S&&T<0)){if(T/=S,S<0){if(T>v)return;T>x&&(x=T)}else if(S>0){if(T<x)return;T<v&&(v=T)}if(T=e-p,!(!b&&T>0)){if(T/=b,b<0){if(T<x)return;T<v&&(v=T)}else if(b>0){if(T>v)return;T>x&&(x=T)}if(T=a-p,!(!b&&T<0)){if(T/=b,b<0){if(T>v)return;T>x&&(x=T)}else if(b>0){if(T<x)return;T<v&&(v=T)}return!(x>0)&&!(v<1)||(x>0&&(r[0]=[f+x*S,p+x*b]),v<1&&(r[1]=[f+v*S,p+v*b])),!0}}}}}function JG(r,t,e,o,a){var l=r[1];if(l)return!0;var h=r[0],f=r.left,p=r.right,d=f[0],g=f[1],x=p[0],v=p[1],S=(d+x)/2,b=(g+v)/2,T,_;if(v===g){if(S<t||S>=o)return;if(d>x){if(!h)h=[S,e];else if(h[1]>=a)return;l=[S,a]}else{if(!h)h=[S,a];else if(h[1]<e)return;l=[S,e]}}else if(T=(d-x)/(v-g),_=b-T*S,T<-1||T>1)if(d>x){if(!h)h=[(e-_)/T,e];else if(h[1]>=a)return;l=[(a-_)/T,a]}else{if(!h)h=[(a-_)/T,a];else if(h[1]<e)return;l=[(e-_)/T,e]}else if(g<v){if(!h)h=[t,T*t+_];else if(h[0]>=o)return;l=[o,T*o+_]}else{if(!h)h=[o,T*o+_];else if(h[0]<t)return;l=[t,T*t+_]}return r[0]=h,r[1]=l,!0}function xb(r,t,e,o){for(var a=Rr.length,l;a--;)(!JG(l=Rr[a],r,t,e,o)||!ZG(l,r,t,e,o)||!(Math.abs(l[0][0]-l[1][0])>Cn||Math.abs(l[0][1]-l[1][1])>Cn))&&delete Rr[a]}function Eb(r){return pi[r.index]={site:r,halfedges:[]}}function KG(r,t){var e=r.site,o=t.left,a=t.right;return e===a&&(a=o,o=e),a?Math.atan2(a[1]-o[1],a[0]-o[0]):(e===o?(o=t[1],a=t[0]):(o=t[0],a=t[1]),Math.atan2(o[0]-a[0],a[1]-o[1]))}function r0(r,t){return t[+(t.left!==r.site)]}function jG(r,t){return t[+(t.left===r.site)]}function Sb(){for(var r=0,t=pi.length,e,o,a,l;r<t;++r)if((e=pi[r])&&(l=(o=e.halfedges).length)){var h=new Array(l),f=new Array(l);for(a=0;a<l;++a)h[a]=a,f[a]=KG(e,Rr[o[a]]);for(h.sort(function(p,d){return f[d]-f[p]}),a=0;a<l;++a)f[a]=o[h[a]];for(a=0;a<l;++a)o[a]=f[a]}}function Mb(r,t,e,o){var a=pi.length,l,h,f,p,d,g,x,v,S,b,T,_,y=!0;for(l=0;l<a;++l)if(h=pi[l]){for(f=h.site,d=h.halfedges,p=d.length;p--;)Rr[d[p]]||d.splice(p,1);for(p=0,g=d.length;p<g;)b=jG(h,Rr[d[p]]),T=b[0],_=b[1],x=r0(h,Rr[d[++p%g]]),v=x[0],S=x[1],(Math.abs(T-v)>Cn||Math.abs(_-S)>Cn)&&(d.splice(p,0,Rr.push(ku(f,b,Math.abs(T-r)<Cn&&o-_>Cn?[r,Math.abs(v-r)<Cn?S:o]:Math.abs(_-o)<Cn&&e-T>Cn?[Math.abs(S-o)<Cn?v:e,o]:Math.abs(T-e)<Cn&&_-t>Cn?[e,Math.abs(v-e)<Cn?S:t]:Math.abs(_-t)<Cn&&T-r>Cn?[Math.abs(S-t)<Cn?v:r,t]:null))-1),++g);g&&(y=!1)}if(y){var A,M,L,G=1/0;for(l=0,y=null;l<a;++l)(h=pi[l])&&(f=h.site,A=f[0]-r,M=f[1]-t,L=A*A+M*M,L<G&&(G=L,y=h));if(y){var z=[r,t],F=[r,o],I=[e,o],ut=[e,t];y.halfedges.push(Rr.push(ku(f=y.site,z,F))-1,Rr.push(ku(f,F,I))-1,Rr.push(ku(f,I,ut))-1,Rr.push(ku(f,ut,z))-1)}}for(l=0;l<a;++l)(h=pi[l])&&(h.halfedges.length||delete pi[l])}var wb=[],Th;function QG(){zu(this),this.x=this.y=this.arc=this.site=this.cy=null}function Sa(r){var t=r.P,e=r.N;if(!(!t||!e)){var o=t.site,a=r.site,l=e.site;if(o!==l){var h=a[0],f=a[1],p=o[0]-h,d=o[1]-f,g=l[0]-h,x=l[1]-f,v=2*(p*x-d*g);if(!(v>=-bb)){var S=p*p+d*d,b=g*g+x*x,T=(x*S-d*b)/v,_=(p*b-g*S)/v,y=wb.pop()||new QG;y.arc=r,y.site=a,y.x=T+h,y.y=(y.cy=_+f)+Math.sqrt(T*T+_*_),r.circle=y;for(var A=null,M=qu._;M;)if(y.y<M.y||y.y===M.y&&y.x<=M.x)if(M.L)M=M.L;else{A=M.P;break}else if(M.R)M=M.R;else{A=M;break}qu.insert(A,y),A||(Th=y)}}}}function Ma(r){var t=r.circle;t&&(t.P||(Th=t.N),qu.remove(t),wb.push(t),zu(t),r.circle=null)}var Ab=[];function tk(){zu(this),this.edge=this.site=this.circle=null}function Tb(r){var t=Ab.pop()||new tk;return t.site=r,t}function i0(r){Ma(r),wa.remove(r),Ab.push(r),zu(r)}function Cb(r){var t=r.circle,e=t.x,o=t.cy,a=[e,o],l=r.P,h=r.N,f=[r];i0(r);for(var p=l;p.circle&&Math.abs(e-p.circle.x)<Cn&&Math.abs(o-p.circle.cy)<Cn;)l=p.P,f.unshift(p),i0(p),p=l;f.unshift(p),Ma(p);for(var d=h;d.circle&&Math.abs(e-d.circle.x)<Cn&&Math.abs(o-d.circle.cy)<Cn;)h=d.N,f.push(d),i0(d),d=h;f.push(d),Ma(d);var g=f.length,x;for(x=1;x<g;++x)d=f[x],p=f[x-1],$l(d.edge,p.site,d.site,a);p=f[0],d=f[g-1],d.edge=Gu(p.site,d.site,null,a),Sa(p),Sa(d)}function Pb(r){for(var t=r[0],e=r[1],o,a,l,h,f=wa._;f;)if(l=Ib(f,e)-t,l>Cn)f=f.L;else if(h=t-ek(f,e),h>Cn){if(!f.R){o=f;break}f=f.R}else{l>-Cn?(o=f.P,a=f):h>-Cn?(o=f,a=f.N):o=a=f;break}Eb(r);var p=Tb(r);if(wa.insert(o,p),!(!o&&!a)){if(o===a){Ma(o),a=Tb(o.site),wa.insert(p,a),p.edge=a.edge=Gu(o.site,p.site),Sa(o),Sa(a);return}if(!a){p.edge=Gu(o.site,p.site);return}Ma(o),Ma(a);var d=o.site,g=d[0],x=d[1],v=r[0]-g,S=r[1]-x,b=a.site,T=b[0]-g,_=b[1]-x,y=2*(v*_-S*T),A=v*v+S*S,M=T*T+_*_,L=[(_*A-S*M)/y+g,(v*M-T*A)/y+x];$l(a.edge,d,b,L),p.edge=Gu(d,r,null,L),a.edge=Gu(r,b,null,L),Sa(o),Sa(a)}}function Ib(r,t){var e=r.site,o=e[0],a=e[1],l=a-t;if(!l)return o;var h=r.P;if(!h)return-1/0;e=h.site;var f=e[0],p=e[1],d=p-t;if(!d)return f;var g=f-o,x=1/l-1/d,v=g/d;return x?(-v+Math.sqrt(v*v-2*x*(g*g/(-2*d)-p+d/2+a-l/2)))/x+o:(o+f)/2}function ek(r,t){var e=r.N;if(e)return Ib(e,t);var o=r.site;return o[1]===t?o[0]:1/0}var Cn=1e-6,bb=1e-12,wa,pi,qu,Rr;function nk(r,t,e){return(r[0]-e[0])*(t[1]-r[1])-(r[0]-t[0])*(e[1]-r[1])}function rk(r,t){return t[1]-r[1]||t[0]-r[0]}function Ah(r,t){var e=r.sort(rk).pop(),o,a,l;for(Rr=[],pi=new Array(r.length),wa=new n0,qu=new n0;;)if(l=Th,e&&(!l||e[1]<l.y||e[1]===l.y&&e[0]<l.x))(e[0]!==o||e[1]!==a)&&(Pb(e),o=e[0],a=e[1]),e=r.pop();else if(l)Cb(l.arc);else break;if(Sb(),t){var h=+t[0][0],f=+t[0][1],p=+t[1][0],d=+t[1][1];xb(h,f,p,d),Mb(h,f,p,d)}this.edges=Rr,this.cells=pi,wa=qu=Rr=pi=null}Ah.prototype={constructor:Ah,polygons:function(){var r=this.edges;return this.cells.map(function(t){var e=t.halfedges.map(function(o){return r0(t,r[o])});return e.data=t.site.data,e})},triangles:function(){var r=[],t=this.edges;return this.cells.forEach(function(e,o){if(f=(l=e.halfedges).length)for(var a=e.site,l,h=-1,f,p,d=t[l[f-1]],g=d.left===a?d.right:d.left;++h<f;)p=g,d=t[l[h]],g=d.left===a?d.right:d.left,p&&g&&o<p.index&&o<g.index&&nk(a,p,g)<0&&r.push([a.data,p.data,g.data])}),r},links:function(){return this.edges.filter(function(r){return r.right}).map(function(r){return{source:r.left.data,target:r.right.data}})},find:function(r,t,e){for(var o=this,a,l=o._found||0,h=o.cells.length,f;!(f=o.cells[l]);)if(++l>=h)return null;var p=r-f.site[0],d=t-f.site[1],g=p*p+d*d;do f=o.cells[a=l],l=null,f.halfedges.forEach(function(x){var v=o.edges[x],S=v.left;if(!((S===f.site||!S)&&!(S=v.right))){var b=r-S[0],T=t-S[1],_=b*b+T*T;_<g&&(g=_,l=S.index)}});while(l!==null);return o._found=a,e==null||g<=e*e?f.site:null}};var fk=yn(Vu(),1);var _0=yn(Ob(),1);function Ei(){return new Ih}function Ih(){this.reset()}Ih.prototype={constructor:Ih,reset:function(){this.s=this.t=0},add:function(r){Db(Ph,r,this.t),Db(this,Ph.s,this.s),this.s?this.t+=Ph.t:this.s=Ph.t},valueOf:function(){return this.s}};var Ph=new Ih;function Db(r,t,e){var o=r.s=t+e,a=o-t,l=o-a;r.t=t-l+(e-a)}var mn=1e-6;var bn=Math.PI,dr=bn/2,Rh=bn/4,Lo=bn*2,ba=180/bn,Si=bn/180,$n=Math.abs,mo=Math.atan,Mi=Math.atan2,cn=Math.cos;var Lh=Math.exp;var Zl=Math.log;var Ee=Math.sin;var qr=Math.sqrt,Jl=Math.tan;function a0(r){return r>1?0:r<-1?bn:Math.acos(r)}function di(r){return r>1?dr:r<-1?-dr:Math.asin(r)}function go(){}var hk=Ei(),FJ=Ei();function Ta(r){var t=r[0],e=r[1],o=cn(e);return[o*cn(t),o*Ee(t),Ee(e)]}function Kl(r,t){return[r[1]*t[2]-r[2]*t[1],r[2]*t[0]-r[0]*t[2],r[0]*t[1]-r[1]*t[0]]}function jl(r){var t=qr(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=t,r[1]/=t,r[2]/=t}var XJ=Ei();function Ub(r,t){return[r>bn?r-Lo:r<-bn?r+Lo:r,t]}Ub.invert=Ub;function u0(){var r=[],t;return{point:function(e,o){t.push([e,o])},lineStart:function(){r.push(t=[])},lineEnd:go,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var e=r;return r=[],t=null,e}}}function l0(r,t){return $n(r[0]-t[0])<mn&&$n(r[1]-t[1])<mn}function Nh(r,t,e,o){this.x=r,this.z=t,this.o=e,this.e=o,this.v=!1,this.n=this.p=null}function c0(r,t,e,o,a){var l=[],h=[],f,p;if(r.forEach(function(b){if(!((T=b.length-1)<=0)){var T,_=b[0],y=b[T],A;if(l0(_,y)){for(a.lineStart(),f=0;f<T;++f)a.point((_=b[f])[0],_[1]);a.lineEnd();return}l.push(A=new Nh(_,b,null,!0)),h.push(A.o=new Nh(_,null,A,!1)),l.push(A=new Nh(y,b,null,!1)),h.push(A.o=new Nh(y,null,A,!0))}}),!!l.length){for(h.sort(t),Bb(l),Bb(h),f=0,p=h.length;f<p;++f)h[f].e=e=!e;for(var d=l[0],g,x;;){for(var v=d,S=!0;v.v;)if((v=v.n)===d)return;g=v.z,a.lineStart();do{if(v.v=v.o.v=!0,v.e){if(S)for(f=0,p=g.length;f<p;++f)a.point((x=g[f])[0],x[1]);else o(v.x,v.n.x,1,a);v=v.n}else{if(S)for(g=v.p.z,f=g.length-1;f>=0;--f)a.point((x=g[f])[0],x[1]);else o(v.x,v.p.x,-1,a);v=v.p}v=v.o,g=v.z,S=!S}while(!v.v);a.lineEnd()}}}function Bb(r){if(t=r.length){for(var t,e=0,o=r[0],a;++e<t;)o.n=a=r[e],a.p=o,o=a;o.n=a=r[0],a.p=o}}function zs(r,t){return r<t?-1:r>t?1:r>=t?0:NaN}function f0(r){return r.length===1&&(r=mk(r)),{left:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var l=o+a>>>1;r(t[l],e)<0?o=l+1:a=l}return o},right:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var l=o+a>>>1;r(t[l],e)>0?a=l:o=l+1}return o}}}function mk(r){return function(t,e){return zs(r(t),e)}}var zb=f0(zs),gk=zb.right,yk=zb.left;var Gb=Array.prototype,_k=Gb.slice,xk=Gb.map;var BK=Math.sqrt(50),zK=Math.sqrt(10),GK=Math.sqrt(2);function Dh(r){for(var t=r.length,e,o=-1,a=0,l,h;++o<t;)a+=r[o].length;for(l=new Array(a);--t>=0;)for(h=r[t],e=h.length;--e>=0;)l[--a]=h[e];return l}var Ck=1e9,MQ=-Ck;var h0=Ei();function p0(r,t){var e=t[0],o=t[1],a=[Ee(e),-cn(e),0],l=0,h=0;h0.reset();for(var f=0,p=r.length;f<p;++f)if(g=(d=r[f]).length)for(var d,g,x=d[g-1],v=x[0],S=x[1]/2+Rh,b=Ee(S),T=cn(S),_=0;_<g;++_,v=A,b=L,T=G,x=y){var y=d[_],A=y[0],M=y[1]/2+Rh,L=Ee(M),G=cn(M),z=A-v,F=z>=0?1:-1,I=F*z,ut=I>bn,R=b*L;if(h0.add(Mi(R*F*Ee(I),T*G+R*cn(I))),l+=ut?z+F*Lo:z,ut^v>=e^A>=e){var W=Kl(Ta(x),Ta(y));jl(W);var V=Kl(a,W);jl(V);var St=(ut^z>=0?-1:1)*di(V[2]);(o>St||o===St&&(W[0]||W[1]))&&(h+=ut^z>=0?1:-1)}}return(l<-mn||l<mn&&h0<-mn)^h&1}var NQ=Ei();var jQ=Ei(),QQ=Ei();var Rk=1/0;var ntt=-Rk;function d0(r){this._context=r}d0.prototype={_radius:4.5,pointRadius:function(r){return this._radius=r,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._context.moveTo(r,t),this._point=1;break}case 1:{this._context.lineTo(r,t);break}default:{this._context.moveTo(r+this._radius,t),this._context.arc(r,t,this._radius,0,Lo);break}}},result:go};var htt=Ei();function m0(){this._string=[]}m0.prototype={_radius:4.5,_circle:Vb(4.5),pointRadius:function(r){return(r=+r)!==this._radius&&(this._radius=r,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._string.push("Z"),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._string.push("M",r,",",t),this._point=1;break}case 1:{this._string.push("L",r,",",t);break}default:{this._circle==null&&(this._circle=Vb(this._radius)),this._string.push("M",r,",",t,this._circle);break}}},result:function(){if(this._string.length){var r=this._string.join("");return this._string=[],r}else return null}};function Vb(r){return"m0,"+r+"a"+r+","+r+" 0 1,1 0,"+-2*r+"a"+r+","+r+" 0 1,1 0,"+2*r+"z"}function g0(r,t,e,o){return function(a,l){var h=t(l),f=a.invert(o[0],o[1]),p=u0(),d=t(p),g=!1,x,v,S,b={point:T,lineStart:y,lineEnd:A,polygonStart:function(){b.point=M,b.lineStart=L,b.lineEnd=G,v=[],x=[]},polygonEnd:function(){b.point=T,b.lineStart=y,b.lineEnd=A,v=Dh(v);var z=p0(x,f);v.length?(g||(l.polygonStart(),g=!0),c0(v,Ok,z,e,l)):z&&(g||(l.polygonStart(),g=!0),l.lineStart(),e(null,null,1,l),l.lineEnd()),g&&(l.polygonEnd(),g=!1),v=x=null},sphere:function(){l.polygonStart(),l.lineStart(),e(null,null,1,l),l.lineEnd(),l.polygonEnd()}};function T(z,F){var I=a(z,F);r(z=I[0],F=I[1])&&l.point(z,F)}function _(z,F){var I=a(z,F);h.point(I[0],I[1])}function y(){b.point=_,h.lineStart()}function A(){b.point=T,h.lineEnd()}function M(z,F){S.push([z,F]);var I=a(z,F);d.point(I[0],I[1])}function L(){d.lineStart(),S=[]}function G(){M(S[0][0],S[0][1]),d.lineEnd();var z=d.clean(),F=p.result(),I,ut=F.length,R,W,V;if(S.pop(),x.push(S),S=null,!!ut){if(z&1){if(W=F[0],(R=W.length-1)>0){for(g||(l.polygonStart(),g=!0),l.lineStart(),I=0;I<R;++I)l.point((V=W[I])[0],V[1]);l.lineEnd()}return}ut>1&&z&2&&F.push(F.pop().concat(F.shift())),v.push(F.filter(Nk))}}return b}}function Nk(r){return r.length>1}function Ok(r,t){return((r=r.x)[0]<0?r[1]-dr-mn:dr-r[1])-((t=t.x)[0]<0?t[1]-dr-mn:dr-t[1])}var Dk=g0(function(){return!0},Fk,Bk,[-bn,-dr]);function Fk(r){var t=NaN,e=NaN,o=NaN,a;return{lineStart:function(){r.lineStart(),a=1},point:function(l,h){var f=l>0?bn:-bn,p=$n(l-t);$n(p-bn)<mn?(r.point(t,e=(e+h)/2>0?dr:-dr),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(f,e),r.point(l,e),a=0):o!==f&&p>=bn&&($n(t-o)<mn&&(t-=o*mn),$n(l-f)<mn&&(l-=f*mn),e=Uk(t,e,l,h),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(f,e),a=0),r.point(t=l,e=h),o=f},lineEnd:function(){r.lineEnd(),t=e=NaN},clean:function(){return 2-a}}}function Uk(r,t,e,o){var a,l,h=Ee(r-e);return $n(h)>mn?mo((Ee(t)*(l=cn(o))*Ee(e)-Ee(o)*(a=cn(t))*Ee(r))/(a*l*h)):(t+o)/2}function Bk(r,t,e,o){var a;if(r==null)a=e*dr,o.point(-bn,a),o.point(0,a),o.point(bn,a),o.point(bn,0),o.point(bn,-a),o.point(0,-a),o.point(-bn,-a),o.point(-bn,0),o.point(-bn,a);else if($n(r[0]-t[0])>mn){var l=r[0]<t[0]?bn:-bn;a=e*l/2,o.point(-l,a),o.point(0,a),o.point(l,a)}else o.point(t[0],t[1])}function Fh(r){return function(t){var e=new y0;for(var o in r)e[o]=r[o];return e.stream=t,e}}function y0(){}y0.prototype={constructor:y0,point:function(r,t){this.stream.point(r,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Qtt=cn(30*Si);var det=Fh({point:function(r,t){this.stream.point(r*Si,t*Si)}});function Uh(r){return function(t,e){var o=cn(t),a=cn(e),l=r(o*a);return[l*a*Ee(t),l*Ee(e)]}}function No(r){return function(t,e){var o=qr(t*t+e*e),a=r(o),l=Ee(a),h=cn(a);return[Mi(t*l,o*h),di(o&&e*l/o)]}}var Jb=Uh(function(r){return qr(2/(1+r))});Jb.invert=No(function(r){return 2*di(r/2)});var Kb=Uh(function(r){return(r=a0(r))&&r/Ee(r)});Kb.invert=No(function(r){return r});function v0(r,t){return[r,Zl(Jl((dr+t)/2))]}v0.invert=function(r,t){return[r,2*mo(Lh(t))-dr]};function Bh(r,t){return[r,t]}Bh.invert=Bh;function jb(r,t){var e=cn(t),o=cn(r)*e;return[e*Ee(r)/o,Ee(t)/o]}jb.invert=No(mo);function Qb(r,t){var e=t*t,o=e*e;return[r*(.8707-.131979*e+o*(-.013791+o*(.003971*e-.001529*o))),t*(1.007226+e*(.015085+o*(-.044475+.028874*e-.005916*o)))]}Qb.invert=function(r,t){var e=t,o=25,a;do{var l=e*e,h=l*l;e-=a=(e*(1.007226+l*(.015085+h*(-.044475+.028874*l-.005916*h)))-t)/(1.007226+l*(.015085*3+h*(-.044475*7+.028874*9*l-.005916*11*h)))}while($n(a)>mn&&--o>0);return[r/(.8707+(l=e*e)*(-.131979+l*(-.013791+l*l*l*(.003971-.001529*l)))),e]};function tT(r,t){return[cn(t)*Ee(r),Ee(t)]}tT.invert=No(di);function eT(r,t){var e=cn(t),o=1+cn(r)*e;return[e*Ee(r)/o,Ee(t)/o]}eT.invert=No(function(r){return 2*mo(r)});function nT(r,t){return[Zl(Jl((dr+t)/2)),-r]}nT.invert=function(r,t){return[-t,2*mo(Lh(r))-dr]};var Hk=yn(Vu(),1);var Wk=yn(Vu(),1);var Yk=yn(Vu(),1);var $k=yn(Vu(),1);function ks(r,t){return Math.sqrt((t[0]-r[0])**2+(t[1]-r[1])**2)}function x0(r){let t=0;for(let e=0;e<r.length-1;e++)t+=ks(r[e],r[e+1]);return t}function iT(r,t,e){let o=new un(t[0]-r[0],t[1]-r[1]),a=new un(t[0]-e[0],t[1]-e[1]),h=o.angleTo(a)*180/Math.PI,f=new un(t[0]-r[0],t[1]-r[1]);return new un(e[0]-r[0],e[1]-r[1]).cross(f)>0?h:-h}var Hi="___",zh=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(o=>{let a=""+e.floor+Hi+o.id;if(this.pointMap.set(a,o),this.nodeMap.set(""+o.floor+Hi+o.nodeId,a),o.type==="straightLadder"){let l=this.straightLadderMap.get(o.name)||[];l.push(Ga({},o)),this.straightLadderMap.set(o.name,l)}if(o.type==="staircase"){let l=this.staircaseMap.get(o.name)||[];l.push(Ga({},o)),this.staircaseMap.set(o.name,l)}if(o.type==="escalator"){let l=this.escalatorMap.get(o.name)||{};o.escalatorDirection==="exit"?l.end={floor:o.floor,id:o.id}:l.start={floor:o.floor,id:o.id},this.escalatorMap.set(o.name,l)}if(o.type==="facility"){let l=this.facilityMap.get(o.targetId)||[];l.push(Ga({},o)),this.facilityMap.set(o.targetId,l)}}),e.lines.filter(o=>o.direction!=="no").forEach(o=>{var a,l;let h=""+e.floor+Hi+o.from,f=""+e.floor+Hi+o.to,p=(a=this.pointMap.get(h))==null?void 0:a.cds,d=(l=this.pointMap.get(f))==null?void 0:l.cds;if(p!=null&&p.length&&(d!=null&&d.length)){let g=ks(p,d);this.addLineItem(h,f,g),o.direction==="double"&&this.addLineItem(f,h,g)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(t,e,o,a){a===void 0&&(a=this.lineMap);let l=a.get(t)||new Map;l.set(e,o),a.set(t,l)}addFacilityToLineMap(t,e,o,a){[...this.straightLadderMap,...this.staircaseMap].forEach(l=>{let[h,f]=l;if(!(f.length<2))for(let g=0;g<f.length;g++){let x=""+f[g].floor+Hi+f[g].id;for(let v=0;v<f.length;v++)if(g!==v){var p,d;let S=""+f[v].floor+Hi+f[v].id,b=(p=this.pointMap.get(x))==null?void 0:p.cds,T=(d=this.pointMap.get(S))==null?void 0:d.cds;if(b!=null&&b.length&&(T!=null&&T.length))if(f[g].type==="straightLadder"){let _=e;this.addLineItem(x,S,_,a)}else{let _=o;this.addLineItem(x,S,_,a)}}}}),this.escalatorMap.forEach((l,h)=>{if(l.start&&l.end){var f,p;let d=""+l.start.floor+Hi+l.start.id,g=""+l.end.floor+Hi+l.end.id,x=(f=this.pointMap.get(d))==null?void 0:f.cds,v=(p=this.pointMap.get(g))==null?void 0:p.cds;if(x!=null&&x.length&&(v!=null&&v.length)){let S=t;this.addLineItem(d,g,S,a)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Oo.default(t)}initEscalatorRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Oo.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Oo.default(t)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let o=this.nodeMap.get(""+t.floor+Hi+t.nodeId);if(o){let[a,l]=o.split(Hi);return{floor:a,id:l}}}if((e=t.coord)!=null&&e.length){let o=this.roadInfo.find(l=>l.floor===t.floor);if(!o)return null;let a=o.points.reduce((l,h)=>{let f=ks(t.coord,h.cds);return f<l.min&&(l.min=f,l.point=h),l},{min:1/0,point:o.points[0]});return{floor:a.point.floor,id:a.point.id}}return null}transformEnd(t){if(t.floor){let e=this.transformStart(t);if(e)return e}if(t.facility){let e=this.facilityMap.get(t.facility);if(e!=null&&e.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,o){if(o===void 0&&(o=""),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let a=this.transformStart(t);if(!a)return"no-start";let l=this.transformEnd(e);if(!l)return"no-end";let h=this.getBasePath.bind(this);switch(o){case"escalator":h=this.getEscalatorPath.bind(this);break;case"straightLadder":h=this.getStraightLadderPath.bind(this);break;default:h=this.getBasePath.bind(this);break}if(l.id)return h(a,l);if(l.facility){let f=this.facilityMap.get(l.facility).filter(d=>l.floor?d.floor===l.floor:!0);if(!f.length)return null;let p=f.map(d=>h(a,{floor:d.floor,id:d.id})).filter(d=>!!d);return p.reduce((d,g)=>{let x=g.reduce((v,S)=>v+x0(S.points),0);return x<d.distance&&(d.distance=x,d.path=g),d},{distance:1/0,path:p[0]}).path}}getRoutePath(t,e,o){let a=""+t.floor+Hi+t.id,l=""+e.floor+Hi+e.id,h=o.path(a,l);if(!h)return null;let f=[];return h.map(p=>{let d=this.pointMap.get(p);if(d){var g;let{floor:x}=d;if(((g=f[f.length-1])==null?void 0:g.floor)===x){let v=f[f.length-1];v.points.push(d.cds),v.endType=d.type,v.destId=d.nodeId,v.distance=x0(v.points)}else f.push({floor:x,points:[d.cds],endType:d.type,destId:d.nodeId,distance:0})}}),f}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new Oo.default,this.escalatorRoute=new Oo.default,this.straightLadderRoute=new Oo.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.staircaseMap=new Map,this.lineMap=new Map,this.baseRoute=new Oo.default,this.escalatorRoute=new Oo.default,this.straightLadderRoute=new Oo.default}};var Cat=yn(Dc(),1),Pat=yn(Fp(),1);var r4=yn(lT(),1);function i4(r,t,e){let o=iT(r,t,e);return 180-Math.abs(o)<15?"front":o>135?"right_front":o<-135?"left_front":o<=135&&o>=60?"right":o>=-135&&o<=-60?"left":o<60&&o>0?"right_back":o>-60&&o<0?"left_back":"front"}function cT(r){if(!r.length)return[];if(r.length===1)return[{direction:"start",distance:0,points:r}];let t=[{direction:"start",distance:ks(r[0],r[1]),points:[r[0],r[1]]}];for(let e=2;e<r.length;e++){let o=i4(r[e-2],r[e-1],r[e]);if(o==="front"){let a=t[t.length-1],l=ks(r[e-1],r[e]);a.distance+=l,e!==2&&a.points.push(r[e-1])}else t.push({direction:o,distance:ks(r[e-1],r[e]),points:[r[e-1],r[e]]})}return t.push({direction:"end",distance:0,points:[r[r.length-1]]}),t}var Gat=yn(UT(),1),kat=yn(kc(),1);function BT(r){return r.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function zT(r){let t={};for(let o in r)o.startsWith("on")&&(t[BT(o.slice(2))]=r[o]);let e=o=>oc(this,null,function*(){let{data:a}=o;if(t[a.type])try{let l=yield t[a.type](a.data);self.postMessage({type:""+a.type+"_result",key:a.key,data:l})}catch(l){self.postMessage({type:""+a.type+"_result",key:a.key,error:l})}else self.postMessage({type:""+a.type+"_result",key:a.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}var C0=new zh;zT({onSetRoadInfo(r){let{roadData:t}=r;C0.initRoute(t)},onGetPath(r){let{start:t,end:e,type:o}=r;return C0.getPath(t,e,o)},onGetDirectionPath(r){return cT(r)},onClear(){C0.clear()}});
|
|
7744
|
-
`],{type:"text/javascript"}),t=URL.createObjectURL(i),e=new Worker(t);return URL.revokeObjectURL(t),e}var il=class extends d_.EventDispatcher{setRoadData(t){return x(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield ee(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,n){return x(this,null,function*(){return n===void 0&&(n=""),new Promise((r,o)=>{let s=()=>{ee(this.worker,"get_path",{start:t,end:e,type:n}).then(a=>{a?typeof a=="string"?o(a):r(a):o("no-path")})};if(this.initRoadStatus)s();else{let a=u=>{let{status:l}=u;l&&(this.removeEventListener("init-road-status",a),s())};this.addEventListener("init-road-status",a)}})})}getDirectionPath(t){return ee(this.worker,"get_direction_path",t)}dispose(){return x(this,null,function*(){ee(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=rl(),this.initRoadStatus=!1}};var EG=d(T(),1),SG=d(le(),1),bG=d(ce(),1),wG=d(he(),1),MG=d(pe(),1),TG=d(fe(),1),IG=d(de(),1),RG=d(ge(),1),PG=d(U(),1);var g_=require("three"),xs=class extends $t{setEnable(t){super.setEnable(t),dt(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:n,clientHeight:r}}}=this,o=I(this.startPoint,e,n,r),s=I(this.endPoint,e,n,r),a={x:Math.min(o.x,s.x),y:Math.min(o.y,s.y)},u={x:Math.max(o.x,s.x),y:Math.max(o.y,s.y)},l=this.searchMapInFrustum(a,u);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:r}=this;return((n=r.currentFloor)==null?void 0:n.graphicLayer.children.filter(o=>o instanceof K&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,n){let{context:{camera:r,container:{clientWidth:o,clientHeight:s}}}=this;if(!t)return!1;if(!t.mesh){let h=t.getPosition();if(h){let g=I(h,r,o,s);return Be(g,e,n)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let a=t.mesh.geometry.boundingBox;if(!a)return!1;let{min:u,max:l}=a,c=I(u,r,o,s),p=I(l,r,o,s);return!(!Be(c,e,n)||!Be(p,e,n))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new g_.Frustum,this.onPointerDown=r=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(r);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=r=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(r);o&&(this.endPoint=o)},this.onPointerUp=r=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(r);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let r=this.getSvgCoordinate(this.startPoint),o=E({},r);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let s={x:Math.min(r.x,o.x),y:Math.min(r.y,o.y)},a=Math.abs(o.x-r.x),u=Math.abs(o.y-r.y);dt(this.rect,s.x,s.y,a,u)}else dt(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:n}}}=t;this.rect=Ne(n,e),this.svg.appendChild(this.rect),this.registryEvent()}};var JP={boxSelection:!1,elements:["graphic","poi"]},ol=class extends wt{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=n=>{this.downPoint={x:n.offsetX,y:n.offsetY}},this.onPointerUp=n=>{if(!this.downPoint)return;let{offsetX:r,offsetY:o}=n,{x:s,y:a}=this.downPoint;if(Math.sqrt((s-r)**2+(a-o)**2)>3)return;let u=new Set,l=[],c=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(r,o);p.map(h=>u.add(h.options.id)),l.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(r,o);c.push(...p),p.forEach(h=>{if(!u.has(h.options.id)){var g;let y=((g=this.bmap.context.currentFloor)==null?void 0:g.graphicLayer.graphicMap.get(h.options.id))||null;y&&(u.add(h.options.id),l.push(y))}})}(!this.options.boxSelection||!(mn?n.metaKey:n.ctrlKey))&&(this._list.clear(),this._poiList.clear()),l.forEach(p=>this._list.add(p)),c.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=n=>{this.disableBoxSelection()},this.onKeyDown=n=>{yn(n.key)&&this.enableBoxSelection()},this.onKeyUp=n=>{yn(n.key)&&this.disableBoxSelection()},this.onBoxSelected=n=>{let{list:r}=n;this._list.clear(),this._poiList.clear(),r.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let s=this.bmap.getPoiById(o.options.id);s&&this._poiList.add(s)}}),this.selectEnd()},this.options=E({},JP,e),this.boxSelection=new xs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var FG=d(U(),1),Mt=require("lodash");var m_=require("three");var X=function(i){return i.COMPASS="compass",i.DEVICE_MOTION="deviceMotion",i.ACCELERATION="acceleration",i.GPS="gps",i}({});var ZP={time:1e3,elements:[X.COMPASS,X.DEVICE_MOTION,X.ACCELERATION,X.GPS]},mi=class extends m_.EventDispatcher{start(){this.options.elements.some(t=>[X.DEVICE_MOTION,X.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(X.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(X.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,Mt.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Jn?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{this.addDataItem({type:X.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return x(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return x(this,null,function*(){var t;if(!Jn)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(n){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Jn?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,Mt.isNil)(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new Z,this.dispatchTimer=null,this.addAcceleration=(0,Mt.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,Mt.throttle)(e=>{let n=Date.now(),{alpha:r,beta:o,gamma:s}=e;if((0,Mt.isNil)(r)||(0,Mt.isNil)(o)||(0,Mt.isNil)(s))return;let a;Jn?a=e.webkitCompassHeading:a=360-r,this.options.elements.includes(X.DEVICE_MOTION)&&this.addDataItem({type:X.DEVICE_MOTION,timestamp:n,res:[r,o,s]}),this.options.elements.includes(X.COMPASS)&&this.addDataItem({type:X.COMPASS,timestamp:n,res:a})},200),this.handleAcceleration=e=>{let n=e.accelerationIncludingGravity;(0,Mt.isNil)(n)||(0,Mt.isNil)(n.x)||(0,Mt.isNil)(n.y)||(0,Mt.isNil)(n.z)||this.addAcceleration({type:X.ACCELERATION,timestamp:Date.now(),res:[n.x,n.y,n.z]})},this.options=E({},ZP,t)}};var ik=d(T(),1),v_=require("three");var JG=d(U(),1);var VG=d(U(),1),XG=d(T(),1);function Cs(i,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(i,2)/(2*Math.pow(t,2)))}function yi(i){return(i+360)%360}function y_(i,t){let n=6378137*i*Math.PI/180,r=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:n,y:r}}function cr(i,t,e,n){return Math.sqrt(Math.pow(Math.abs(i-e),2)+Math.pow(Math.abs(t-n),2))}var Es=require("mathjs"),As=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=yi(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let n=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+n,this.particleX[2][e]=yi(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let r=0;r<this.NumParticle;r++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][r]+=(.65+o)*Math.sin(-this.particleX[2][r]/180*Math.PI),this.particleX[1][r]+=(.65+o)*Math.cos(this.particleX[2][r]/180*Math.PI),e(this.particleX[0][r],this.particleX[1][r])||(this.particleWeight[0][r]*=this.unaccess_weight)}let n=this.particleWeight[0].reduce((r,o)=>r+o,0);this.particleWeight[0]=this.particleWeight[0].map(r=>r/n)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let n=360-t;n+=this.delta_yaw,n=yi(n),Math.abs(n-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let s=Math.abs(this.particleX[2][o]-n);s>180&&(s=360-s),this.particleWeight[0][o]*=Cs(s,this.sigmaCompass)}let r=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/r),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,n)=>e+n*n,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((a,u,l)=>a.concat(a[l]+u),[0]),r=this.particleWeight[0].map(()=>1/this.NumParticle).map((a,u)=>a+Math.random()/this.NumParticle),o=[],s=0;for(let a=0;a<this.NumParticle;a++){for(;r[a]>e[s];)s++;o.push(s)}this.particleX=this.particleX.map((a,u)=>o.map(l=>a[l])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let r=0;r<this.NumParticle;r++){let o=cr(this.particleX[0][r],this.particleX[1][r],t.x,t.y);this.particleWeight[0][r]=Math.max(1e-7,this.particleWeight[0][r]*Cs(o,e))}let n=this.particleWeight[0].reduce((r,o)=>r+o,0);this.particleWeight[0]=this.particleWeight[0].map(r=>r/n)}updateCar(t,e){let n=t.x-this.xEst[0][0],r=t.y-this.xEst[1][0];for(let s=0;s<this.NumParticle;s++){let a=cr(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Cs(a,e)),this.particleX[0][s]+=n,this.particleX[1][s]+=r}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=(0,Es.reshape)(this.particleWeight,[this.NumParticle,1]),e=(0,Es.multiply)(this.particleX,t);return this.xEst=e,this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),n=[this.particleX[0][t],this.particleX[1][t]],r=[this.particleX[0][e],this.particleX[1][e]],o=cr(n[0],n[1],r[0],r[1]),s=o*.67;return console.log(o,s),s}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,n){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let r=0;for(;r<this.NumParticle;){let s=(2*Math.random()-1)*this.initial_xy_uncertainty,a=(2*Math.random()-1)*this.initial_xy_uncertainty;n(t+s,e+a)||(this.particleWeight[0][r]*=this.unaccess_weight),this.particleX[0][r]=t+s,this.particleX[1][r]=e+a,r++}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=yi(e),console.log("Init Yaw: "+e);for(let n=0;n<this.NumParticle;n++){let r=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][n]=e+r}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};var WG=d(U(),1),QG=d(T(),1),Ss=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,n){let r=0;return n.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,n)),e.length===3&&(r=this.getStepLength(t,e)),r!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let n=!1,r=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(r),this.accH_time_fifo.push(t),this.imuFreUpdate(),this.accH_fifo.length<this.accH_fifo_len+1)n=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let o=this.PVStepDetec(),s=this.FFTStepDetec(),a=this.recheckState(),u=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=u:this.abnor_fft_detected||(this.abnor_start_time=0),o&&s&&a?(this.step_count+=1,this.last_step_time=u,n=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=u,n=!0):(u-this.last_step_time>2&&(this.state_count=0),n=!1)}if(n){let o=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(o),this.delta_py=this.const_step_length*Math.sin(o),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),n=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),r=e[Math.floor(e.length/2)],o=n[Math.floor(n.length/2)],s=Math.max(...e),a=Math.min(...e),u=!1,l=!1;return Math.abs(r-a)<.01&&r<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?l=!0:l=o-this.last_valley_time>this.min_step_time,l&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(r-s)<.01&&r>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?u=!0:u=o-this.last_peak_time>this.min_step_time,u&&(this.last_peak_time=o,this.peak_num+=1)),r===s&&r>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=r),this.peak_num===this.valley_num&&(u||l)&&(t=!0),t}FFTStepDetec(){return!0}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let n=[0,0,0];this.last_rot.length===3&&(n=e.map((a,u)=>a-this.last_rot[u]));for(let a=0;a<e.length;a++)n[a]<-180?n[a]+=360:n[a]>180&&(n[a]-=360);let r=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((a,u)=>r*a+(1-r)*n[u]):this.delta_rot=n,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((a,u)=>a+Math.abs(u),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let s=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(s=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,s):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}};var tL={using_gps:!0},bs=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:n,res:r}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===X.ACCELERATION){let s=r,a=this.pdr.getStepLength(n/1e3,s);a!==0&&(this.particleFilter.motionModelStepLength(a,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===X.GPS&&(this.last_beacon_time===null||n-this.last_beacon_time>5e3)){let s=this.getGpsPosition(r);o=s!==null,s&&(this.particleFilter.update(s,this.gps_horizontalAccuracy),this.resetParticleFilterDist(s,"gps",r[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}if(e===X.DEVICE_MOTION){let s=this.pdr.getDeltaYawFromRot(n/1e3,r);s!==null&&this.particleFilter.motionModelRotYaw(s)}e===X.COMPASS&&this.particleFilter.motionModelCompassYaw(r,n),this.last_pos_time&&n-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===X.GPS){let s=this.getGpsPosition(r);o=s!==null,console.log("gps_pos",s,r),s?(this.particleFilter.initParticlesByPos(s.x,s.y,()=>!0),this.last_pos_time=n,console.log("init Pos by gps success time "+n),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+n)}else if(!this.particleFilter.getYawInitFlag()&&e===X.COMPASS){let s=r;this.particleFilter.initParticlesByCompass(s),this.particleFilter.setLastCompassTime(n),console.log("init yaw by compass success time "+n)}return o&&(this.last_pos_time=n),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let n=this.cacheSensorData.filter(r=>r.timestamp>e);console.log("\u521D\u59CBsensorData",n),n.map(r=>this.pfFusionPDRiBeacon(r))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:y_(t[0],t[1])}resetParticleFilterDist(t,e,n){let r=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),s=cr(r,o,t.x,t.y);(e==="gps"?n&&s>n||s>this.GpsMaxEstimateErr:s>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0)):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=null,this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=4,this.cacheSensorData=[];let e=E({},tL,t);this.using_gps=e.using_gps,this.particleFilter=new As({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new Ss}};var sl=class extends v_.EventDispatcher{checkSensor(){return this.sensor.checkSensor()}start(){this.sensor.start(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[n,r,o]=this.pdr.pfFusionPDRiBeacon(t);return n&&e&&this.dispatchEvent({type:"position",x:r,y:o,_type:t.type===X.GPS?"gps":"pdr"}),[n,r,o]}setBeaconPosition(t,e){let[n,r]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:n,y:r,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t={}){super(),this._pause=!1,this.sensor=new mi(t.sensor),this.pdr=new bs(t.pdr||{})}};var xk=d(T(),1),Ck=d(U(),1);var lk=d(T(),1),ck=d(U(),1),ut=require("three");var __={texture_url:is,lineWidth:8,color:16777215},ws=class extends ut.Object3D{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:n,height:r}}}}}=this,o=t.map(a=>{let[u,l,c]=a;return I(new ut.Vector3(u,l,c),e,n,r)}).map(a=>{let{x:u,y:l}=a;return[u,l]});return Nt(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new ut.Vector2(t,1)}loadTexture(t){return new Promise((e,n)=>{new ut.TextureLoader().load(t,e,void 0,n)})}transformPoints(t){let e=[];for(let n=0;n<t.length;n++)e.push(...t[n]);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return x(this,null,function*(){let e=this.geometry=new Ct;if(this.updatePoints(t),!this.texture){let o=this.texture=yield this.loadTexture(this.config.texture_url);o.wrapS=o.wrapT=ut.RepeatWrapping}let n=this.material=new Pn({useMap:!0,color:new ut.Color(this.config.color),transparent:!0,resolution:new ut.Vector2(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:this.config.lineWidth*2,map:this.texture,blending:ut.NormalBlending,repeat:new ut.Vector2(this.getRepeat(),1)}),r=this.mesh=new ut.Mesh(e,n);return r.renderOrder=9,this.add(r),r})}dispose(){var t,e,n;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(n=this.texture)==null||n.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=__,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let n=this.navigation.bmap.context.camera.zoom;n!==this.prevCameraZoom&&(this.prevCameraZoom=n,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:n,height:r}=this.navigation.bmap.context.clientSize;this.material.resolution.set(n,r)}},this.config=Object.assign({},__,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};var x_=require("@tweenjs/tween.js");var J=require("three"),Ms=class extends J.Object3D{getBaseScale(t){let{clientSize:{width:e,height:n},camera:r}=this.bmap.context,o=new J.Box3().setFromObject(t),{max:s,min:a}=o,u=new J.Vector3(a.x,s.y,s.z),l=new J.Vector3(s.x,s.y,s.z),c=new J.Vector3(s.x,a.y,a.z),p=new J.Vector3(a.x,a.y,a.z),h=I(u,r,e,n),g=I(l,r,e,n),y=I(p,r,e,n),v=I(c,r,e,n),C=new J.Box2().setFromPoints([new J.Vector2(h.x,h.y),new J.Vector2(g.x,g.y),new J.Vector2(y.x,y.y),new J.Vector2(v.x,v.y)]).getSize(new J.Vector2),b=40/C.x,R=40/C.y,B=Math.min(b,R),P=r.zoom;return B*P}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}printGraph(t){console.group(" <"+t.type+"> "+t.name),t.children.forEach(e=>this.printGraph(e)),console.groupEnd()}setClips(t){this.clearClips(),t.length&&(this.mixer=new J.AnimationMixer(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&tt(this.model.scene),this.bmap=null}constructor(t,e){super(),this.bmap=t,this.group=new J.Object3D,this.mixer=null,this.previewTime=0,this.basicScale=1,this._update=()=>{let n=Date.now();if(!this.previewTime)this.previewTime=n;else{var r;let o=n-this.previewTime;this.previewTime=n,(r=this.mixer)==null||r.update(o/1e3)}},this._onChangeZoom=n=>{let{zoom:r}=n;var o;let s=this.basicScale/r;(o=this.model)==null||o.scene.scale.set(s,s,s)},this.add(this.group),Vt.loadModel(e,!1).then(n=>{this.model=n;let r=this.getBaseScale(n.scene);this.basicScale=r;let o=this.bmap.context.camera.zoom;n.scene.scale.set(r/o,r/o,r/o),this.group.add(n.scene),this.setClips(n.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};var vi=require("three"),C_=require("lodash");var al=class extends wt{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(n=>E({},n,{points:this.translatePoints(n.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(e)};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,n]=this.bmap.buildingCenter;return t.map(r=>[r[0]-e,r[1]-n])}renderPath(t){if(!t.length)return this.clearPath();let e=[];t.forEach((n,r,o)=>{let s=this.catmullRomCurve3(n.points),a=this.mulFloor.floors.find(u=>u.name===n.floor);if(e.push(...s.map(u=>{let[l,c]=u;return[l,c,a.position.z+a.groundMaxHeight]})),r!==o.length-1){let u=this.mulFloor.floors.find(l=>l.name===o[r+1].floor);e.push([...o[r+1].points[0],u.position.z])}}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new ws(this),this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return zr(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let n=ye(t,e),r=t[n],o=t[n+1],s=new vi.Vector3(o[0]-r[0],o[1]-r[1],0).normalize(),a=new vi.Vector3(0,1,0).normalize(),u=s.angleTo(a),l=new vi.Vector3().crossVectors(a,s);return(Object.is(l.y,0)?-1:1)*u}startSimulation(t){return x(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:n}=this;if(!e.length)return;let r=e.reduce((s,a)=>s+a.distance,0);if(!r||n>=r)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=r/t;return this.startModel.startClips(),new Promise(s=>{let a=this.simulationTween=new x_.Tween({distance:this.movedDistance},this.tweenUtil.group).to({distance:r},o*1e3).onUpdate(u=>{var l;this.movedDistance=u.distance;let c=u.distance,p=0;for(let C=0;C<e.length;C++)if(e[C].distance>=c){p=C;break}else c-=e[C].distance;let h=_n(e[p].points,c);if(h===null)return;this.currentPathPosition=h;let g=this.translatePoints([h])[0],y=this.mulFloor.floors.find(C=>C.name===e[p].floor),v=y?y.position.z+y.groundMaxHeight:(l=this.startModel)==null?void 0:l.position.z;this.startModel&&this.startModel.position.set(g[0],g[1],v);let _=this.getPathDirection(e[p].points,h);(0,C_.isNil)(_)||this.startModel.setRotationFromAxisAngle(new vi.Vector3(0,0,1),_)}).onComplete(()=>{this.tweenUtil.remove(a),this.startModel.clearClips(),s(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let n=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-n)%360}}dispose(){super.dispose(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent()}constructor(t,e){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new Oe,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Ms(t,Iv),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};var Ts=require("three");var ul=class extends wt{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose(),super.dispose(),this.mulFloors=null}constructor(t,e){super(t),this.mulFloors=e,this._click=n=>{let{e:r}=n;if(!this.mulFloors.showStatus)return;let o=new Ts.Vector2,{offsetX:s,offsetY:a}=r,{clientSize:u}=this.bmap.context;o.x=s/u.width*2-1,o.y=a/u.height*-2+1;let l=new Ts.Raycaster;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.poiLayer.pois.map(g=>{if(!g.canSelect)return null;let y=l.intersectObjects(g.children,!0);return y.length?y[0]:null}).reduce((g,y)=>y&&(!g||y.distance<g.distance)?y:g,null),h=p==null?void 0:p.object;p&&p.object.isSprite&&(h=p.object.parent),h&&h instanceof ot&&this.dispatchEvent({type:"select",pois:[h]})},this.clickHelper=new Vr(this.bmap.context.container),this.registryEvent()}};var Xk=d(A_(),1),qk=d(E_(),1),jk=d(U(),1),b_=require("three");var Fk=d(T(),1),$k=d(U(),1),zk=d(mu(),1),hr=require("three");function aL(i){let t=i.length,e=0,n=0,r=0,o=0;i.forEach(u=>{e+=u[0],n+=u[1],r+=u[0]*u[1],o+=u[0]*u[0]});let s=(t*r-e*n)/(t*o-e*e),a=(n-s*e)/t;return{m:s,b:a}}function uL(i,t,e){let n=e[0][0],r=e.slice(-1)[0][0],o=i*n+t,s=i*r+t;return{start:[n,o],end:[r,s]}}function _i(i){if(i.length<2)return null;let t=i.filter((u,l)=>{let c=[...i];return c.splice(l,1),c.every(p=>p[0]!==u[0]&&p[1]!==u[1])});if(t.length<2)return null;let{m:e,b:n}=aL(t),{start:r,end:o}=uL(e,n,t),a=360-(new hr.Vector2().subVectors(new hr.Vector2(o[0],o[1]),new hr.Vector2(r[0],r[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(a)?null:a}function lL(i){let t=[];for(let e=1;e<i.length;e++){let n=i[e-1],r=i[e],o=r.position[0]-n.position[0],s=r.position[1]-n.position[1],a=Math.sqrt(o**2+s**2),u=r.time-n.time;if(u>0){let l=a/u;console.log("speedDelta",n.type,r.type,Is(l),a,u),t.push(l)}else t.push(0)}return t}function cL(i,t){let e=i[0],n=i.slice(-1)[0],r=G(n.position,e.position),o=n.time-e.time;return o<100||r<3?null:r/o}function Is(i){return i*60*60}function pr(i,t,e,n){let r=(e+90)%360*(Math.PI/180),o=t*n,s=new hr.Vector2(i[0],i[1]),a=Math.cos(r),u=Math.sin(r),l=new hr.Vector2(a,u);return s.add(l.normalize().multiplyScalar(o)),[s.x,s.y]}function hL(i){let t=[...i].sort((l,c)=>l-c),e=S_(t,25),n=S_(t,75),r=n-e,o=e-1.5*r,s=n+1.5*r,a=t.filter(l=>l>=o&&l<=s);return i.filter(l=>a.includes(l))}function S_(i,t){let e=t/100*(i.length-1),n=Math.floor(e),r=Math.ceil(e);if(n===r)return i[n];let o=e-n;return i[n]*(1-o)+i[r]*o}var Rs=class{filter(t){let e=this.estimate,n=this.errorEstimate+this.processNoise,r=n/(n+this.measurementNoise);return this.estimate=e+r*(t-e),this.errorEstimate=(1-r)*n,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};var xi=require("lodash"),ll=class extends b_.EventDispatcher{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),(0,xi.isNil)(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(u=>["vision"].includes(u.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[0],n=t.slice(-1)[0],r=G(n.position,e.position),o=n.time-e.time,s=o>0?r/o:0,a=this.speedFilter.filter(s);this.speed=a}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=_i(t.map(n=>n.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,n){let r={position:t,time:e,clientTime:Date.now()-n,type:"vision"};if(this._setVisionHistoryForAngle(r),(0,xi.isNil)(this.angle)||!this.speed){this.addHistory(r);return}let o=this.history.findLastIndex(a=>a.type==="vision"),s=this.history[o];if(s){if(s.time>e)return;let a=_i([this.history.slice(-1)[0].position,t]);if(a&&Math.abs(a-this.angle)<60){this.addHistory(r);return}let u=pr(t,this.speed,360-this.pathAngle,n);G(u,this.history.slice(-1)[0].position)>10?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(r),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=pr(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(n=>n.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(!this.visionHistory.length){this.visionHistory.push(t);return}let e=_i([this.visionHistory.slice(-1)[0].position,t.position]);if(e!==null&&(this.angle&&Math.abs(this.angle-e)>60?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))),this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63"),this.visionHistory=[t],this.angleExcessesCount=0;else{let n=G(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;n>5&&this.visionHistory.length>15;)this.visionHistory.shift(),n=G(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(a=>a.type==="vision"),n=e.length?Date.now()-e.slice(-1)[0].clientTime:0,r=G(this.history[0].position,this.history.slice(-1)[0].position),o=n>5e3?10:3,s=n>5e3?0:5;for(n>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>s&&r>o;)this.history.shift(),e=this.history.filter(a=>a.type==="vision"),r=G(this.history[0].position,this.history.slice(-1)[0].position);s===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,n){let r=Date.now()-n,o={position:t,time:e,clientTime:r,type:"beacon"},s=this.history.findLastIndex(c=>c.type!=="pdr"),a=this.history[s];if(!a){this.addHistory(o);return}if((0,xi.isNil)(this.pathAngle)||!this.speed){this.addHistory(o);return}if(a&&a.time>e)return;let u=pr(t,this.speed,360-this.pathAngle,n);G(u,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}changePosition(t){t===void 0&&(t="pdr");let e=this.getPosition(t);e.success&&(this.history.push({position:e.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:E({},e)}):this.dispatchEvent({type:"change-pos",value:e}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if((0,xi.isNil)(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let n=e.clientTime,r=Date.now()-n;return{success:!0,pos:this.pathAngle?pr(e.position,this.speed,360-this.pathAngle,r):e.position,compass:this.pathAngle,speed:Is(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new Z,this.positionTimer=null,this.speedFilter=new Rs,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.startPositionTimer()}};function cl(i,t){return x(this,null,function*(){let{brand:e,project:n}=i,{apiDomain:r,apiPath:{floorRange:o},apiInfo:s}=t,a=""+r+o+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n;return yield fetch(a,s).then(l=>l.json()).then(l=>l.data).then(l=>{let c=(l||[])[0];return c&&(c.info=JSON.parse(c.info)),c})})}function hl(i,t){return x(this,null,function*(){let{brand:e,project:n,floor:r,ts:o,resource_type_list:s}=i,{apiDomain:a,apiPath:{floorGraphic:u},apiInfo:l}=t,c=""+a+u+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n+"&floor="+r+"&ts="+o+"&resource_type_list="+s;return yield fetch(c,l).then(h=>h.json()).then(h=>h.data).then(h=>((h||[]).map(g=>g.info=JSON.parse(g.info)),h||[]))})}function pL(i,t){return x(this,null,function*(){let{project:e,floor:n}=i,{apiDomain:r,apiInfo:o}=t,s=r+"/api/inception-map/external_street/get?projectCode="+e+"&floorCode="+n;return yield fetch(s,o).then(u=>u.json()).then(u=>u.data).then(u=>JSON.parse(u[0].streetInfo||"{}")).then(u=>u.fileId?fL(u.fileId,t):null)})}function fL(i,t){return x(this,null,function*(){let{apiDomain:e,apiInfo:n}=t;return fetch(e+"/api/inception-map/file/getFileStream?fileId="+i,n).then(r=>r.arrayBuffer()).then(r=>{let s=new TextDecoder("utf-8").decode(r);return s?JSON.parse(s):null})})}var l7=d(T(),1);var oe;function w_(i,t){return i===void 0&&(i="aibee_map"),t===void 0&&(t=1),new Promise((e,n)=>{if(oe)return e({db:oe,type:"success"});let r=indexedDB.open(i,t);r.onupgradeneeded=function(o){oe=o.target.result,console.log("onupgradeneeded"),e({db:oe,type:"onupgradeneeded"})},r.onsuccess=o=>{oe=o.target.result,e({db:oe,type:"success"})},r.onerror=o=>{n(o)}})}function pl(i,t,e){return e===void 0&&(e=oe),new Promise((n,r)=>{e||r("\u6CA1\u6709db");let s=e.transaction([i],"readonly").objectStore(i).get(t);s.onsuccess=()=>{s.result?n(s.result.value):n(null)},s.onerror=a=>{console.log("[getVersionByKey]",a),n(null)}})}function M_(i,t,e,n){return n===void 0&&(n=oe),new Promise((r,o)=>(n||o("\u6CA1\u6709db"),new Promise((s,a)=>x(this,null,function*(){let u=yield pl(i,t),l=n.transaction([i],"readwrite").objectStore(i),c=u!==null?l.put({key:t,value:e}):l.add({key:t,value:e});c.onsuccess=function(p){s(p)},c.onerror=function(p){a(p)}}))))}function Ln(i,t){t===void 0&&(t=oe),t&&(t.objectStoreNames.contains(i)||t.createObjectStore(i,{keyPath:"key"}))}function T_(i){i===void 0&&(i=oe),i==null||i.close(),oe=null}var Ls=require("three");var r7=d(U(),1),i7=d(T(),1);function I_(i,t,e){switch(i.l_type){case"graph":return dL(i,t);case"wall":return gL(i,t);case"lane":return mL(i,t);case"texture2d":case"texture3d":return yL(i,t);case"glb":return vL(i,t);case"store":return _L(i,t);case"facility":return xL(i,t);case"parkingSpace":return CL(i,t,e);case"text":return AL(i,t)}}function dL(i,t){let e=t.userData.center;yt(i.elements,e);let n=[];i.elements.forEach(o=>{o.group==="ground"?t.createGround(o):n.push(o)});let r=n.reduce((o,s)=>{let{fillColor:a,fillOpacity:u,strokeColor:l,strokeOpacity:c,height:p,airHeight:h}=s,g=a.toLowerCase()+"-"+u+"-"+l.toLowerCase()+"-"+c+"-"+p+"-"+h;return c===0&&(g=a.toLowerCase()+"-"+u+"-"+p+"-"+h),o[g]?o[g].push(s):o[g]=[s],o},{});Object.values(r).forEach(o=>{let s=new Tn(t.context,o);t.mergeGraphicLayer.add(s)})}function gL(i,t){let e=t.userData.center;yt(i.elements,e);let n=i.elements.reduce((r,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l,height:c}=o,p=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l+"-"+c;return l===0&&(p=s.toLowerCase()+"-"+a+"-"+c),r[p]?r[p].push(o):r[p]=[o],r},{});Object.values(n).forEach(r=>{let o=new li(t.context,r);t.wallLayer.add(o)})}function mL(i,t){let e=t.userData.center;yt(i.elements,e);let n=i.elements.reduce((r,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l}=o,c=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l;return l===0&&(c=s.toLowerCase()+"-"+a),r[c]?r[c].push(o):r[c]=[o],r},{});Object.values(n).forEach(r=>{let o=new hi(t.context,r);t.laneLayer.add(o)})}function yL(i,t){let e=t.userData.center;if(yt(i.elements,e),i.elements.length){let n=new Mn(t.context,i.elements);t.textureLayer.add(n)}}function vL(i,t){let e=t.userData.center;yt(i.elements,e),i.elements.forEach(n=>{let r=new ci(t.context,E({},n,{url:n.secondUrl,rotate:n.secondRotate,width:n.secondWidth,center_x:n.center_coord_x,center_y:n.center_coord_y}));t.glbModelLayer.add(r)})}function _L(i,t){let e=t.userData.center;yt(i.elements,e),i.elements.map(n=>{let r=t.addGraphic(n);t.userData.graphics.push(r),t.userData.graphicMap.set(n.id,r);try{let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o&&(o.userData.type="store",o.userData.data=n,o.userData.floor=t.name)}catch(o){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",o,n)}})}function xL(i,t){let e=t.userData.center;yt(i.elements,e),i.elements.map(n=>{let r=t.addGraphic(n);if(t.userData.graphics.push(r),t.userData.graphicMap.set(n.id,r),n.poi_info){let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o.userData.type="facility",o.userData.data=n,o.userData.floor=t.name}else console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info",n)})}function CL(i,t,e){let n=t.userData.center;yt(i.elements,n),t.parkingSpaceLayer.createParkings(i.elements,e.mergeParkingSpace),i.elements.forEach(r=>{if(r.texts[0]){let o=new ot(t.context,{id:r.id,text:r.texts[0],position:{x:r.center_coord_x,y:r.center_coord_y,z:r.airHeight+r.height}});o&&(o.userData.type="parkingSpace",o.userData.data=r,o.userData.floor=t.name),t.poiLayer2.pushPoi(o)}}),t.userData.parkingSpaces=t.parkingSpaceLayer.graphicMap.values(),t.userData.parkingSpacesGraphicMap=t.parkingSpaceLayer.graphicMap}function AL(i,t){let e=t.userData.center;yt(i.elements,e);let n=new pi(t.context,i.elements.map(r=>E({},r,{center_x:r.center_coord_x,center_y:r.center_coord_y})));t.textTextureLayer.add(n)}var fl="map_version",dl="route_version",gl="facility_version",ml="map_data",Ps="road_network_data",yl="facility_data",EL={mergeParkingSpace:!0},vl=class extends Ls.EventDispatcher{initDb(){return x(this,null,function*(){try{let{db:t,type:e}=yield w_("aibee_map",2);e==="onupgradeneeded"&&(Ln(fl),Ln(dl),Ln(gl),Ln(ml),Ln(Ps),Ln(yl)),this.db=t}catch(t){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",t)}})}load(t){return x(this,null,function*(){if(Array.isArray(t))this.floors=t;else{let e=yield fetch(t).then(n=>n.json());e.code==="0"&&(this.floors=e.data.list)}})}setCacheData(t,e,n){return this.initDbPromise.then(()=>M_(t,""+e,n,this.db))}getCacheData(t,e){return this.initDbPromise.then(()=>pl(t,""+e,this.db))}getFloorCacheKey(t){return""+t.floor_id}getFloorData(t){return x(this,null,function*(){let e=yield this.getFloorJsonData(t);return e?this.getDataByJson(e):null})}getFloorDataByFloorInfo(t){return x(this,null,function*(){let e=yield this.getFloorJsonDataByFloorInfo(t);return this.getDataByJson(e)})}getFloorJsonDataByFloorInfo(t){return x(this,null,function*(){let e=this.getFloorCacheKey(t);console.time("zstd_json");let n=yield fetch(t.map_url).then(r=>r.json());return n.floor=t.floor,console.timeEnd("zstd_json"),this.setCacheData(ml,e,n),this.setCacheData(fl,e,t.version_id),n})}getFloorJsonData(t){return x(this,null,function*(){let e=this.floors.find(r=>r.floor===t);if(!e)return null;let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(fl,n))===e.version_id){let o=yield this.getCacheData(ml,n);if(o)return o}return this.getFloorJsonDataByFloorInfo(e)}catch(r){return console.log("[get floor data error]",r),this.getFloorJsonDataByFloorInfo(e)}})}getRoadNetworkData(){return x(this,null,function*(){return(yield Promise.all(this.floors.map(e=>x(this,null,function*(){let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(dl,n))===e.version_id){let s=yield this.getCacheData(Ps,n);if(s)return s}let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Ps,n,o),this.setCacheData(dl,n,e.version_id),o}catch(r){let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Ps,n,o),o}})))).filter(e=>e.points)})}getFacilitiesData(){return x(this,null,function*(){let t=this.floors.reduce((r,o)=>r.updated_at>o.updated_at?r:o,this.floors[0]);if(!t)return null;let e=this.getFloorCacheKey(t),n=()=>x(this,null,function*(){let r=yield fetch(t.entry_infra_url).then(o=>o.json());return r&&(this.setCacheData(yl,e,r),this.setCacheData(gl,e,t.version_id)),r});try{if((yield this.getCacheData(gl,e))===t.version_id){let o=yield this.getCacheData(yl,e);if(o)return o}return n()}catch(r){return console.log("[get facility error]",r),n()}})}getOtherDataByFreeTime(){return x(this,null,function*(){})}getMulFloorsData(t){return x(this,null,function*(){return Promise.all(t.map(e=>this.getFloorData(e))).then(e=>e.filter(n=>n))})}getDataByUrl(t){return x(this,null,function*(){let e=yield fetch(t).then(n=>n.json());return this.getDataByJson(e)})}getDataByJson(t,e){return x(this,null,function*(){return e=this.getFloorBaseLayer(t,e),yield this.getFloorContentLayer(t,e),this.changeFloorBox(t,e),e})}changeFloorBox(t,e){e.updateBox();let n=e.box.getSize(new Ls.Vector3),r=Math.max(n.x,n.y,n.z);e.userData.height=r/4+t.floorHeight}switchFloor(t){return x(this,null,function*(){return new Promise(e=>{let n={run:()=>this._switchFloor(t),meta:{type:"switchFloor"}},r=this.taskQueue.replaceByMetaType(n),o=s=>{let{task:a,res:u}=s;a.tid===r&&(this.taskQueue.removeEventListener("active-task-end",o),e(u))};this.taskQueue.addEventListener("active-task-end",o)})})}_switchFloor(t){return x(this,null,function*(){var e;let n=t;if(typeof t=="string"){let u=yield this.getFloorJsonData(t);if(u)n=u;else return null}let r=new Ft(this.bmap.context),o=this.floors.find(u=>u.floor===n.floor);var s;let a=(s=o==null?void 0:o.map_angle)!=null?s:0;return this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_BEFORE,data:{curFloor:r,graphics:[]}}),this.dispatchEvent({type:"switch-floor-before",data:{curFloor:r,graphics:[]}}),this.bmap.context.control.setAzimuthalAngle(a/180*Math.PI,!0),this.getFloorBaseLayer(n,r),this.changeFloorBox(n,r),this.bmap.buildingCenter=r.userData.center,this.bmap.currentBuildGround=(e=r.userData.data.layers.find(u=>u.l_type==="range"))==null?void 0:e.elements[0],this.bmap.context.switchFloor(r),this.bmap.initialFloorCamera(),yield co(),this.dispatchEvent({type:"switch-floor-ground",data:{curFloor:r,graphics:[]}}),yield this.getFloorContentLayer(n,r),this.changeFloorBox(n,r),this.bmap.initialFloorCamera(),this.bmap.context.cameraBound.updateBox(),this.dispatchEvent({type:"switch-floor-after",data:{curFloor:r,graphics:r.graphicLayer.children}}),this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_AFTER,data:{curFloor:r,graphics:r.graphicLayer.children}}),r})}getFloorBaseLayer(t,e){e||(e=new Ft(this.bmap.context));let n=[0,0];return t.layers.forEach(r=>{switch(r.l_type){case"range":let o=r.elements[0];n=[o.center_x,o.center_y];break;case"ground":yt(r.elements,n);let s=r.elements.map(a=>new K(this.bmap.context,a));e.addGrounds(s);break;default:break}}),e.userData.center=n,e.name=t.floor,e.userData.data=t,e}getFloorContentLayer(t,e){return x(this,null,function*(){e||(e=new Ft(this.bmap.context)),e.userData.graphics=[],e.userData.graphicMap=new Map;let n=Date.now();for(let r=0;r<t.layers.length;r++){let o=t.layers[r];["range","ground"].includes(o.l_type)||(I_(o,e,this.options),console.log("time",Date.now()-n,o.l_type),Date.now()-n>16&&(yield co(),n=Date.now()))}return e})}clear(){return x(this,null,function*(){var t;T_((t=this.db)!=null?t:void 0)})}dispose(){this.clear()}constructor(t,e={}){super(),this.bmap=t,this.floors=[],this.initDbPromise=Promise.resolve(),this.db=null,this.taskQueue=new Cn,this.options=E({},EL,e),this.initDbPromise=this.initDb()}};var y7=d(T(),1);var _l=class{load(t){return x(this,null,function*(){let e=vn(t);if(this.cacheData.has(e))return this.cacheData.get(e);let[,n]=yield Promise.all([this.loadBuildGround(t),hl(t,this.bmap.config)]),r=vn({floor:t.floor,ts:t.ts});yt(n.map(s=>s.info),this.bmap.buildingCenter,this.floorDataLengthMap.get(r)||0),n.forEach(s=>s.info.transformToBuildingGround=!1),this.cacheData.set(e,n);let o=this.floorDataLengthMap.get(r)||0;return this.floorDataLengthMap.set(r,o+n.length),this.loadExternalStreet(t),n})}loadExternalStreet(t){return x(this,null,function*(){})}switchFloorByData(t,e){if(!t.length)return;let n=e.userData.legacyToGraphicMap||new Map,r=e.userData.graphicMap||new Map,{ground:o,markGraphic:s,graphic:a}=this.bmap.config;for(let u=0;u<t.length;u++){let l=t[u];l.info.group==="ground"?(l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.height=o.height,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity):l.info.userData.mark?(l.info.height=s.height,l.info.fillColor=s.color,l.info.fillOpacity=s.opacity,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity):(l.info.fillOpacity=a.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=s.height,l.info.fillColor=s.color,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity))}for(let u of t){if(u.info.group==="ground")e.createGround(u.info);else{let l=e.addGraphic(u.info);l.userData.data=u,n.set(u.legacy_id,l)}r.set(u.element_uuid,u)}e.userData.legacyToGraphicMap=n,e.userData.graphicMap=r,e.updateBox(),e===this.bmap.context.currentFloor?(this.bmap.triggerHooks(gt.SWITCH_FLOOR_BEFORE,{curFloor:e,graphics:e.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(gt.SWITCH_FLOOR_AFTER,{curFloor:e,graphics:e.graphicLayer.children})):this.bmap.switchFloorByFloor(e)}filterData(t,e){let n=e.userData.graphicMap||new Map;return t.filter(r=>!n.has(r.element_uuid))}switchFloorByStoreData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"6"})),r=this.filterData(n,e);this.switchFloorByData(r,e)})}switchFloorByOtherData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"1,2,3,4"})),r=this.filterData(n,e);this.switchFloorByData(r,e)})}loadBuildGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,r=yield this.loadBuildingGround({brand:e,project:n});return this.bmap.currentBuildGround=r,this.bmap.changeBuildingCenter(r,{brand:e,project:n}),this.bmap.currentBuildGround})}loadBuildingGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,r=vn({brand:e,project:n});if(this.buildingGroundMap.has(r))return this.buildingGroundMap.get(r);let o=cl({brand:e,project:n},this.bmap.config).then(s=>(this.buildingGroundMap.set(r,s),s));return this.buildingGroundMap.set(r,o),o})}switchFloor(t){return x(this,null,function*(){let e=new Ft(this.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([this.switchFloorByStoreData(t,e),this.switchFloorByOtherData(t,e)])}catch(n){console.log(n)}return e})}dispose(){this.cacheData.clear(),this.floorDataLengthMap.clear(),this.buildingGroundMap.clear()}constructor(t){this.bmap=t,this.cacheData=new Map,this.floorDataLengthMap=new Map,this.buildingGroundMap=new Map,this.externalStreetMap=new Map}};
|
|
7744
|
+
`],{type:"text/javascript"}),t=URL.createObjectURL(i),e=new Worker(t);return URL.revokeObjectURL(t),e}var il=class extends d_.EventDispatcher{setRoadData(t){return x(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield ee(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,n){return x(this,null,function*(){return n===void 0&&(n=""),new Promise((r,o)=>{let s=()=>{ee(this.worker,"get_path",{start:t,end:e,type:n}).then(a=>{a?typeof a=="string"?o(a):r(a):o("no-path")})};if(this.initRoadStatus)s();else{let a=u=>{let{status:l}=u;l&&(this.removeEventListener("init-road-status",a),s())};this.addEventListener("init-road-status",a)}})})}getDirectionPath(t){return ee(this.worker,"get_direction_path",t)}dispose(){return x(this,null,function*(){ee(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=rl(),this.initRoadStatus=!1}};var EG=d(T(),1),SG=d(le(),1),bG=d(ce(),1),wG=d(he(),1),MG=d(pe(),1),TG=d(fe(),1),IG=d(de(),1),RG=d(ge(),1),PG=d(U(),1);var g_=require("three"),xs=class extends $t{setEnable(t){super.setEnable(t),dt(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:n,clientHeight:r}}}=this,o=I(this.startPoint,e,n,r),s=I(this.endPoint,e,n,r),a={x:Math.min(o.x,s.x),y:Math.min(o.y,s.y)},u={x:Math.max(o.x,s.x),y:Math.max(o.y,s.y)},l=this.searchMapInFrustum(a,u);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:r}=this;return((n=r.currentFloor)==null?void 0:n.graphicLayer.children.filter(o=>o instanceof K&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,n){let{context:{camera:r,container:{clientWidth:o,clientHeight:s}}}=this;if(!t)return!1;if(!t.mesh){let h=t.getPosition();if(h){let g=I(h,r,o,s);return Be(g,e,n)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let a=t.mesh.geometry.boundingBox;if(!a)return!1;let{min:u,max:l}=a,c=I(u,r,o,s),p=I(l,r,o,s);return!(!Be(c,e,n)||!Be(p,e,n))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new g_.Frustum,this.onPointerDown=r=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(r);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=r=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(r);o&&(this.endPoint=o)},this.onPointerUp=r=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(r);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let r=this.getSvgCoordinate(this.startPoint),o=E({},r);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let s={x:Math.min(r.x,o.x),y:Math.min(r.y,o.y)},a=Math.abs(o.x-r.x),u=Math.abs(o.y-r.y);dt(this.rect,s.x,s.y,a,u)}else dt(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:n}}}=t;this.rect=Ne(n,e),this.svg.appendChild(this.rect),this.registryEvent()}};var JP={boxSelection:!1,elements:["graphic","poi"]},ol=class extends wt{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=n=>{this.downPoint={x:n.offsetX,y:n.offsetY}},this.onPointerUp=n=>{if(!this.downPoint)return;let{offsetX:r,offsetY:o}=n,{x:s,y:a}=this.downPoint;if(Math.sqrt((s-r)**2+(a-o)**2)>3)return;let u=new Set,l=[],c=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(r,o);p.map(h=>u.add(h.options.id)),l.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(r,o);c.push(...p),p.forEach(h=>{if(!u.has(h.options.id)){var g;let y=((g=this.bmap.context.currentFloor)==null?void 0:g.graphicLayer.graphicMap.get(h.options.id))||null;y&&(u.add(h.options.id),l.push(y))}})}(!this.options.boxSelection||!(mn?n.metaKey:n.ctrlKey))&&(this._list.clear(),this._poiList.clear()),l.forEach(p=>this._list.add(p)),c.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=n=>{this.disableBoxSelection()},this.onKeyDown=n=>{yn(n.key)&&this.enableBoxSelection()},this.onKeyUp=n=>{yn(n.key)&&this.disableBoxSelection()},this.onBoxSelected=n=>{let{list:r}=n;this._list.clear(),this._poiList.clear(),r.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let s=this.bmap.getPoiById(o.options.id);s&&this._poiList.add(s)}}),this.selectEnd()},this.options=E({},JP,e),this.boxSelection=new xs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var FG=d(U(),1),Mt=require("lodash");var m_=require("three");var X=function(i){return i.COMPASS="compass",i.DEVICE_MOTION="deviceMotion",i.ACCELERATION="acceleration",i.GPS="gps",i}({});var ZP={time:1e3,elements:[X.COMPASS,X.DEVICE_MOTION,X.ACCELERATION,X.GPS]},mi=class extends m_.EventDispatcher{start(){this.options.elements.some(t=>[X.DEVICE_MOTION,X.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(X.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(X.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,Mt.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Jn?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{this.addDataItem({type:X.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return x(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return x(this,null,function*(){var t;if(!Jn)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(n){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Jn?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,Mt.isNil)(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new Z,this.dispatchTimer=null,this.addAcceleration=(0,Mt.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,Mt.throttle)(e=>{let n=Date.now(),{alpha:r,beta:o,gamma:s}=e;if((0,Mt.isNil)(r)||(0,Mt.isNil)(o)||(0,Mt.isNil)(s))return;let a;Jn?a=e.webkitCompassHeading:a=360-r,this.options.elements.includes(X.DEVICE_MOTION)&&this.addDataItem({type:X.DEVICE_MOTION,timestamp:n,res:[r,o,s]}),this.options.elements.includes(X.COMPASS)&&this.addDataItem({type:X.COMPASS,timestamp:n,res:a})},200),this.handleAcceleration=e=>{let n=e.accelerationIncludingGravity;(0,Mt.isNil)(n)||(0,Mt.isNil)(n.x)||(0,Mt.isNil)(n.y)||(0,Mt.isNil)(n.z)||this.addAcceleration({type:X.ACCELERATION,timestamp:Date.now(),res:[n.x,n.y,n.z]})},this.options=E({},ZP,t)}};var ik=d(T(),1),v_=require("three");var JG=d(U(),1);var VG=d(U(),1),XG=d(T(),1);function Cs(i,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(i,2)/(2*Math.pow(t,2)))}function yi(i){return(i+360)%360}function y_(i,t){let n=6378137*i*Math.PI/180,r=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:n,y:r}}function cr(i,t,e,n){return Math.sqrt(Math.pow(Math.abs(i-e),2)+Math.pow(Math.abs(t-n),2))}var Es=require("mathjs"),As=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=yi(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let n=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+n,this.particleX[2][e]=yi(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let r=0;r<this.NumParticle;r++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][r]+=(.65+o)*Math.sin(-this.particleX[2][r]/180*Math.PI),this.particleX[1][r]+=(.65+o)*Math.cos(this.particleX[2][r]/180*Math.PI),e(this.particleX[0][r],this.particleX[1][r])||(this.particleWeight[0][r]*=this.unaccess_weight)}let n=this.particleWeight[0].reduce((r,o)=>r+o,0);this.particleWeight[0]=this.particleWeight[0].map(r=>r/n)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let n=360-t;n+=this.delta_yaw,n=yi(n),Math.abs(n-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let s=Math.abs(this.particleX[2][o]-n);s>180&&(s=360-s),this.particleWeight[0][o]*=Cs(s,this.sigmaCompass)}let r=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/r),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,n)=>e+n*n,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((a,u,l)=>a.concat(a[l]+u),[0]),r=this.particleWeight[0].map(()=>1/this.NumParticle).map((a,u)=>a+Math.random()/this.NumParticle),o=[],s=0;for(let a=0;a<this.NumParticle;a++){for(;r[a]>e[s];)s++;o.push(s)}this.particleX=this.particleX.map((a,u)=>o.map(l=>a[l])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let r=0;r<this.NumParticle;r++){let o=cr(this.particleX[0][r],this.particleX[1][r],t.x,t.y);this.particleWeight[0][r]=Math.max(1e-7,this.particleWeight[0][r]*Cs(o,e))}let n=this.particleWeight[0].reduce((r,o)=>r+o,0);this.particleWeight[0]=this.particleWeight[0].map(r=>r/n)}updateCar(t,e){let n=t.x-this.xEst[0][0],r=t.y-this.xEst[1][0];for(let s=0;s<this.NumParticle;s++){let a=cr(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Cs(a,e)),this.particleX[0][s]+=n,this.particleX[1][s]+=r}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=(0,Es.reshape)(this.particleWeight,[this.NumParticle,1]),e=(0,Es.multiply)(this.particleX,t);return this.xEst=e,this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),n=[this.particleX[0][t],this.particleX[1][t]],r=[this.particleX[0][e],this.particleX[1][e]],o=cr(n[0],n[1],r[0],r[1]),s=o*.67;return console.log(o,s),s}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,n){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let r=0;for(;r<this.NumParticle;){let s=(2*Math.random()-1)*this.initial_xy_uncertainty,a=(2*Math.random()-1)*this.initial_xy_uncertainty;n(t+s,e+a)||(this.particleWeight[0][r]*=this.unaccess_weight),this.particleX[0][r]=t+s,this.particleX[1][r]=e+a,r++}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=yi(e),console.log("Init Yaw: "+e);for(let n=0;n<this.NumParticle;n++){let r=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][n]=e+r}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};var WG=d(U(),1),QG=d(T(),1),Ss=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,n){let r=0;return n.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,n)),e.length===3&&(r=this.getStepLength(t,e)),r!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let n=!1,r=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(r),this.accH_time_fifo.push(t),this.imuFreUpdate(),this.accH_fifo.length<this.accH_fifo_len+1)n=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let o=this.PVStepDetec(),s=this.FFTStepDetec(),a=this.recheckState(),u=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=u:this.abnor_fft_detected||(this.abnor_start_time=0),o&&s&&a?(this.step_count+=1,this.last_step_time=u,n=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=u,n=!0):(u-this.last_step_time>2&&(this.state_count=0),n=!1)}if(n){let o=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(o),this.delta_py=this.const_step_length*Math.sin(o),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),n=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),r=e[Math.floor(e.length/2)],o=n[Math.floor(n.length/2)],s=Math.max(...e),a=Math.min(...e),u=!1,l=!1;return Math.abs(r-a)<.01&&r<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?l=!0:l=o-this.last_valley_time>this.min_step_time,l&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(r-s)<.01&&r>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?u=!0:u=o-this.last_peak_time>this.min_step_time,u&&(this.last_peak_time=o,this.peak_num+=1)),r===s&&r>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=r),this.peak_num===this.valley_num&&(u||l)&&(t=!0),t}FFTStepDetec(){return!0}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let n=[0,0,0];this.last_rot.length===3&&(n=e.map((a,u)=>a-this.last_rot[u]));for(let a=0;a<e.length;a++)n[a]<-180?n[a]+=360:n[a]>180&&(n[a]-=360);let r=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((a,u)=>r*a+(1-r)*n[u]):this.delta_rot=n,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((a,u)=>a+Math.abs(u),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let s=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(s=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,s):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}};var tL={using_gps:!0},bs=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:n,res:r}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===X.ACCELERATION){let s=r,a=this.pdr.getStepLength(n/1e3,s);a!==0&&(this.particleFilter.motionModelStepLength(a,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===X.GPS&&(this.last_beacon_time===null||n-this.last_beacon_time>5e3)){let s=this.getGpsPosition(r);o=s!==null,s&&(this.particleFilter.update(s,this.gps_horizontalAccuracy),this.resetParticleFilterDist(s,"gps",r[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}if(e===X.DEVICE_MOTION){let s=this.pdr.getDeltaYawFromRot(n/1e3,r);s!==null&&this.particleFilter.motionModelRotYaw(s)}e===X.COMPASS&&this.particleFilter.motionModelCompassYaw(r,n),this.last_pos_time&&n-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===X.GPS){if(this.startTime&&Date.now()-this.startTime>3e3){let s=this.getGpsPosition(r);o=s!==null,console.log("gps_pos",s,r),s?(this.particleFilter.initParticlesByPos(s.x,s.y,()=>!0),this.last_pos_time=n,console.log("init Pos by gps success time "+n),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+n)}}else if(!this.particleFilter.getYawInitFlag()&&e===X.COMPASS){let s=r;this.particleFilter.initParticlesByCompass(s),this.particleFilter.setLastCompassTime(n),console.log("init yaw by compass success time "+n)}return o&&(this.last_pos_time=n),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let n=this.cacheSensorData.filter(r=>r.timestamp>e);console.log("\u521D\u59CBsensorData",n),n.map(r=>this.pfFusionPDRiBeacon(r))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:y_(t[0],t[1])}resetParticleFilterDist(t,e,n){let r=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),s=cr(r,o,t.x,t.y);(e==="gps"?n&&s>n||s>this.GpsMaxEstimateErr:s>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0)):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=4,this.cacheSensorData=[],this.startTime=null;let e=E({},tL,t);this.using_gps=e.using_gps,this.particleFilter=new As({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new Ss}};var sl=class extends v_.EventDispatcher{checkSensor(){return this.sensor.checkSensor()}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[n,r,o]=this.pdr.pfFusionPDRiBeacon(t);return n&&e&&this.dispatchEvent({type:"position",x:r,y:o,_type:t.type===X.GPS?"gps":"pdr"}),[n,r,o]}setBeaconPosition(t,e){let[n,r]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:n,y:r,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t={}){super(),this._pause=!1,this.sensor=new mi(t.sensor),this.pdr=new bs(t.pdr||{})}};var xk=d(T(),1),Ck=d(U(),1);var lk=d(T(),1),ck=d(U(),1),ut=require("three");var __={texture_url:is,lineWidth:8,color:16777215},ws=class extends ut.Object3D{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:n,height:r}}}}}=this,o=t.map(a=>{let[u,l,c]=a;return I(new ut.Vector3(u,l,c),e,n,r)}).map(a=>{let{x:u,y:l}=a;return[u,l]});return Nt(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new ut.Vector2(t,1)}loadTexture(t){return new Promise((e,n)=>{new ut.TextureLoader().load(t,e,void 0,n)})}transformPoints(t){let e=[];for(let n=0;n<t.length;n++)e.push(...t[n]);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return x(this,null,function*(){let e=this.geometry=new Ct;if(this.updatePoints(t),!this.texture){let o=this.texture=yield this.loadTexture(this.config.texture_url);o.wrapS=o.wrapT=ut.RepeatWrapping}let n=this.material=new Pn({useMap:!0,color:new ut.Color(this.config.color),transparent:!0,resolution:new ut.Vector2(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:this.config.lineWidth*2,map:this.texture,blending:ut.NormalBlending,repeat:new ut.Vector2(this.getRepeat(),1)}),r=this.mesh=new ut.Mesh(e,n);return r.renderOrder=9,this.add(r),r})}dispose(){var t,e,n;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(n=this.texture)==null||n.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=__,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let n=this.navigation.bmap.context.camera.zoom;n!==this.prevCameraZoom&&(this.prevCameraZoom=n,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:n,height:r}=this.navigation.bmap.context.clientSize;this.material.resolution.set(n,r)}},this.config=Object.assign({},__,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};var x_=require("@tweenjs/tween.js");var J=require("three"),Ms=class extends J.Object3D{getBaseScale(t){let{clientSize:{width:e,height:n},camera:r}=this.bmap.context,o=new J.Box3().setFromObject(t),{max:s,min:a}=o,u=new J.Vector3(a.x,s.y,s.z),l=new J.Vector3(s.x,s.y,s.z),c=new J.Vector3(s.x,a.y,a.z),p=new J.Vector3(a.x,a.y,a.z),h=I(u,r,e,n),g=I(l,r,e,n),y=I(p,r,e,n),v=I(c,r,e,n),C=new J.Box2().setFromPoints([new J.Vector2(h.x,h.y),new J.Vector2(g.x,g.y),new J.Vector2(y.x,y.y),new J.Vector2(v.x,v.y)]).getSize(new J.Vector2),b=40/C.x,R=40/C.y,B=Math.min(b,R),P=r.zoom;return B*P}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}printGraph(t){console.group(" <"+t.type+"> "+t.name),t.children.forEach(e=>this.printGraph(e)),console.groupEnd()}setClips(t){this.clearClips(),t.length&&(this.mixer=new J.AnimationMixer(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&tt(this.model.scene),this.bmap=null}constructor(t,e){super(),this.bmap=t,this.group=new J.Object3D,this.mixer=null,this.previewTime=0,this.basicScale=1,this._update=()=>{let n=Date.now();if(!this.previewTime)this.previewTime=n;else{var r;let o=n-this.previewTime;this.previewTime=n,(r=this.mixer)==null||r.update(o/1e3)}},this._onChangeZoom=n=>{let{zoom:r}=n;var o;let s=this.basicScale/r;(o=this.model)==null||o.scene.scale.set(s,s,s)},this.add(this.group),Vt.loadModel(e,!1).then(n=>{this.model=n;let r=this.getBaseScale(n.scene);this.basicScale=r;let o=this.bmap.context.camera.zoom;n.scene.scale.set(r/o,r/o,r/o),this.group.add(n.scene),this.setClips(n.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};var vi=require("three"),C_=require("lodash");var al=class extends wt{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(n=>E({},n,{points:this.translatePoints(n.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(e)};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,n]=this.bmap.buildingCenter;return t.map(r=>[r[0]-e,r[1]-n])}renderPath(t){if(!t.length)return this.clearPath();let e=[];t.forEach((n,r,o)=>{let s=this.catmullRomCurve3(n.points),a=this.mulFloor.floors.find(u=>u.name===n.floor);if(e.push(...s.map(u=>{let[l,c]=u;return[l,c,a.position.z+a.groundMaxHeight]})),r!==o.length-1){let u=this.mulFloor.floors.find(l=>l.name===o[r+1].floor);e.push([...o[r+1].points[0],u.position.z])}}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new ws(this),this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return zr(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let n=ye(t,e),r=t[n],o=t[n+1],s=new vi.Vector3(o[0]-r[0],o[1]-r[1],0).normalize(),a=new vi.Vector3(0,1,0).normalize(),u=s.angleTo(a),l=new vi.Vector3().crossVectors(a,s);return(Object.is(l.y,0)?-1:1)*u}startSimulation(t){return x(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:n}=this;if(!e.length)return;let r=e.reduce((s,a)=>s+a.distance,0);if(!r||n>=r)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=r/t;return this.startModel.startClips(),new Promise(s=>{let a=this.simulationTween=new x_.Tween({distance:this.movedDistance},this.tweenUtil.group).to({distance:r},o*1e3).onUpdate(u=>{var l;this.movedDistance=u.distance;let c=u.distance,p=0;for(let C=0;C<e.length;C++)if(e[C].distance>=c){p=C;break}else c-=e[C].distance;let h=_n(e[p].points,c);if(h===null)return;this.currentPathPosition=h;let g=this.translatePoints([h])[0],y=this.mulFloor.floors.find(C=>C.name===e[p].floor),v=y?y.position.z+y.groundMaxHeight:(l=this.startModel)==null?void 0:l.position.z;this.startModel&&this.startModel.position.set(g[0],g[1],v);let _=this.getPathDirection(e[p].points,h);(0,C_.isNil)(_)||this.startModel.setRotationFromAxisAngle(new vi.Vector3(0,0,1),_)}).onComplete(()=>{this.tweenUtil.remove(a),this.startModel.clearClips(),s(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let n=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-n)%360}}dispose(){super.dispose(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent()}constructor(t,e){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new Oe,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Ms(t,Iv),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};var Ts=require("three");var ul=class extends wt{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose(),super.dispose(),this.mulFloors=null}constructor(t,e){super(t),this.mulFloors=e,this._click=n=>{let{e:r}=n;if(!this.mulFloors.showStatus)return;let o=new Ts.Vector2,{offsetX:s,offsetY:a}=r,{clientSize:u}=this.bmap.context;o.x=s/u.width*2-1,o.y=a/u.height*-2+1;let l=new Ts.Raycaster;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.poiLayer.pois.map(g=>{if(!g.canSelect)return null;let y=l.intersectObjects(g.children,!0);return y.length?y[0]:null}).reduce((g,y)=>y&&(!g||y.distance<g.distance)?y:g,null),h=p==null?void 0:p.object;p&&p.object.isSprite&&(h=p.object.parent),h&&h instanceof ot&&this.dispatchEvent({type:"select",pois:[h]})},this.clickHelper=new Vr(this.bmap.context.container),this.registryEvent()}};var Xk=d(A_(),1),qk=d(E_(),1),jk=d(U(),1),b_=require("three");var Fk=d(T(),1),$k=d(U(),1),zk=d(mu(),1),hr=require("three");function aL(i){let t=i.length,e=0,n=0,r=0,o=0;i.forEach(u=>{e+=u[0],n+=u[1],r+=u[0]*u[1],o+=u[0]*u[0]});let s=(t*r-e*n)/(t*o-e*e),a=(n-s*e)/t;return{m:s,b:a}}function uL(i,t,e){let n=e[0][0],r=e.slice(-1)[0][0],o=i*n+t,s=i*r+t;return{start:[n,o],end:[r,s]}}function _i(i){if(i.length<2)return null;let t=i.filter((u,l)=>{let c=[...i];return c.splice(l,1),c.every(p=>p[0]!==u[0]&&p[1]!==u[1])});if(t.length<2)return null;let{m:e,b:n}=aL(t),{start:r,end:o}=uL(e,n,t),a=360-(new hr.Vector2().subVectors(new hr.Vector2(o[0],o[1]),new hr.Vector2(r[0],r[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(a)?null:a}function lL(i){let t=[];for(let e=1;e<i.length;e++){let n=i[e-1],r=i[e],o=r.position[0]-n.position[0],s=r.position[1]-n.position[1],a=Math.sqrt(o**2+s**2),u=r.time-n.time;if(u>0){let l=a/u;console.log("speedDelta",n.type,r.type,Is(l),a,u),t.push(l)}else t.push(0)}return t}function cL(i,t){let e=i[0],n=i.slice(-1)[0],r=G(n.position,e.position),o=n.time-e.time;return o<100||r<3?null:r/o}function Is(i){return i*60*60}function pr(i,t,e,n){let r=(e+90)%360*(Math.PI/180),o=t*n,s=new hr.Vector2(i[0],i[1]),a=Math.cos(r),u=Math.sin(r),l=new hr.Vector2(a,u);return s.add(l.normalize().multiplyScalar(o)),[s.x,s.y]}function hL(i){let t=[...i].sort((l,c)=>l-c),e=S_(t,25),n=S_(t,75),r=n-e,o=e-1.5*r,s=n+1.5*r,a=t.filter(l=>l>=o&&l<=s);return i.filter(l=>a.includes(l))}function S_(i,t){let e=t/100*(i.length-1),n=Math.floor(e),r=Math.ceil(e);if(n===r)return i[n];let o=e-n;return i[n]*(1-o)+i[r]*o}var Rs=class{filter(t){let e=this.estimate,n=this.errorEstimate+this.processNoise,r=n/(n+this.measurementNoise);return this.estimate=e+r*(t-e),this.errorEstimate=(1-r)*n,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};var xi=require("lodash"),ll=class extends b_.EventDispatcher{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),(0,xi.isNil)(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(u=>["vision"].includes(u.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[0],n=t.slice(-1)[0],r=G(n.position,e.position),o=n.time-e.time,s=o>0?r/o:0,a=this.speedFilter.filter(s);this.speed=a}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=_i(t.map(n=>n.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,n){let r={position:t,time:e,clientTime:Date.now()-n,type:"vision"};if(this._setVisionHistoryForAngle(r),(0,xi.isNil)(this.angle)||!this.speed){this.addHistory(r);return}let o=this.history.findLastIndex(a=>a.type==="vision"),s=this.history[o];if(s){if(s.time>e)return;let a=_i([this.history.slice(-1)[0].position,t]);if(a&&Math.abs(a-this.angle)<60){this.addHistory(r);return}let u=pr(t,this.speed,360-this.pathAngle,n);G(u,this.history.slice(-1)[0].position)>10?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(r),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=pr(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(n=>n.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(!this.visionHistory.length){this.visionHistory.push(t);return}let e=_i([this.visionHistory.slice(-1)[0].position,t.position]);if(e!==null&&(this.angle&&Math.abs(this.angle-e)>60?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))),this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63"),this.visionHistory=[t],this.angleExcessesCount=0;else{let n=G(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;n>5&&this.visionHistory.length>15;)this.visionHistory.shift(),n=G(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(a=>a.type==="vision"),n=e.length?Date.now()-e.slice(-1)[0].clientTime:0,r=G(this.history[0].position,this.history.slice(-1)[0].position),o=n>5e3?10:3,s=n>5e3?0:5;for(n>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>s&&r>o;)this.history.shift(),e=this.history.filter(a=>a.type==="vision"),r=G(this.history[0].position,this.history.slice(-1)[0].position);s===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,n){let r=Date.now()-n,o={position:t,time:e,clientTime:r,type:"beacon"},s=this.history.findLastIndex(c=>c.type!=="pdr"),a=this.history[s];if(!a){this.addHistory(o);return}if((0,xi.isNil)(this.pathAngle)||!this.speed){this.addHistory(o);return}if(a&&a.time>e)return;let u=pr(t,this.speed,360-this.pathAngle,n);G(u,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}changePosition(t){t===void 0&&(t="pdr");let e=this.getPosition(t);e.success&&(this.history.push({position:e.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:E({},e)}):this.dispatchEvent({type:"change-pos",value:e}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if((0,xi.isNil)(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let n=e.clientTime,r=Date.now()-n;return{success:!0,pos:this.pathAngle?pr(e.position,this.speed,360-this.pathAngle,r):e.position,compass:this.pathAngle,speed:Is(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new Z,this.positionTimer=null,this.speedFilter=new Rs,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.startPositionTimer()}};function cl(i,t){return x(this,null,function*(){let{brand:e,project:n}=i,{apiDomain:r,apiPath:{floorRange:o},apiInfo:s}=t,a=""+r+o+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n;return yield fetch(a,s).then(l=>l.json()).then(l=>l.data).then(l=>{let c=(l||[])[0];return c&&(c.info=JSON.parse(c.info)),c})})}function hl(i,t){return x(this,null,function*(){let{brand:e,project:n,floor:r,ts:o,resource_type_list:s}=i,{apiDomain:a,apiPath:{floorGraphic:u},apiInfo:l}=t,c=""+a+u+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n+"&floor="+r+"&ts="+o+"&resource_type_list="+s;return yield fetch(c,l).then(h=>h.json()).then(h=>h.data).then(h=>((h||[]).map(g=>g.info=JSON.parse(g.info)),h||[]))})}function pL(i,t){return x(this,null,function*(){let{project:e,floor:n}=i,{apiDomain:r,apiInfo:o}=t,s=r+"/api/inception-map/external_street/get?projectCode="+e+"&floorCode="+n;return yield fetch(s,o).then(u=>u.json()).then(u=>u.data).then(u=>JSON.parse(u[0].streetInfo||"{}")).then(u=>u.fileId?fL(u.fileId,t):null)})}function fL(i,t){return x(this,null,function*(){let{apiDomain:e,apiInfo:n}=t;return fetch(e+"/api/inception-map/file/getFileStream?fileId="+i,n).then(r=>r.arrayBuffer()).then(r=>{let s=new TextDecoder("utf-8").decode(r);return s?JSON.parse(s):null})})}var l7=d(T(),1);var oe;function w_(i,t){return i===void 0&&(i="aibee_map"),t===void 0&&(t=1),new Promise((e,n)=>{if(oe)return e({db:oe,type:"success"});let r=indexedDB.open(i,t);r.onupgradeneeded=function(o){oe=o.target.result,console.log("onupgradeneeded"),e({db:oe,type:"onupgradeneeded"})},r.onsuccess=o=>{oe=o.target.result,e({db:oe,type:"success"})},r.onerror=o=>{n(o)}})}function pl(i,t,e){return e===void 0&&(e=oe),new Promise((n,r)=>{e||r("\u6CA1\u6709db");let s=e.transaction([i],"readonly").objectStore(i).get(t);s.onsuccess=()=>{s.result?n(s.result.value):n(null)},s.onerror=a=>{console.log("[getVersionByKey]",a),n(null)}})}function M_(i,t,e,n){return n===void 0&&(n=oe),new Promise((r,o)=>(n||o("\u6CA1\u6709db"),new Promise((s,a)=>x(this,null,function*(){let u=yield pl(i,t),l=n.transaction([i],"readwrite").objectStore(i),c=u!==null?l.put({key:t,value:e}):l.add({key:t,value:e});c.onsuccess=function(p){s(p)},c.onerror=function(p){a(p)}}))))}function Ln(i,t){t===void 0&&(t=oe),t&&(t.objectStoreNames.contains(i)||t.createObjectStore(i,{keyPath:"key"}))}function T_(i){i===void 0&&(i=oe),i==null||i.close(),oe=null}var Ls=require("three");var r7=d(U(),1),i7=d(T(),1);function I_(i,t,e){switch(i.l_type){case"graph":return dL(i,t);case"wall":return gL(i,t);case"lane":return mL(i,t);case"texture2d":case"texture3d":return yL(i,t);case"glb":return vL(i,t);case"store":return _L(i,t);case"facility":return xL(i,t);case"parkingSpace":return CL(i,t,e);case"text":return AL(i,t)}}function dL(i,t){let e=t.userData.center;yt(i.elements,e);let n=[];i.elements.forEach(o=>{o.group==="ground"?t.createGround(o):n.push(o)});let r=n.reduce((o,s)=>{let{fillColor:a,fillOpacity:u,strokeColor:l,strokeOpacity:c,height:p,airHeight:h}=s,g=a.toLowerCase()+"-"+u+"-"+l.toLowerCase()+"-"+c+"-"+p+"-"+h;return c===0&&(g=a.toLowerCase()+"-"+u+"-"+p+"-"+h),o[g]?o[g].push(s):o[g]=[s],o},{});Object.values(r).forEach(o=>{let s=new Tn(t.context,o);t.mergeGraphicLayer.add(s)})}function gL(i,t){let e=t.userData.center;yt(i.elements,e);let n=i.elements.reduce((r,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l,height:c}=o,p=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l+"-"+c;return l===0&&(p=s.toLowerCase()+"-"+a+"-"+c),r[p]?r[p].push(o):r[p]=[o],r},{});Object.values(n).forEach(r=>{let o=new li(t.context,r);t.wallLayer.add(o)})}function mL(i,t){let e=t.userData.center;yt(i.elements,e);let n=i.elements.reduce((r,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l}=o,c=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l;return l===0&&(c=s.toLowerCase()+"-"+a),r[c]?r[c].push(o):r[c]=[o],r},{});Object.values(n).forEach(r=>{let o=new hi(t.context,r);t.laneLayer.add(o)})}function yL(i,t){let e=t.userData.center;if(yt(i.elements,e),i.elements.length){let n=new Mn(t.context,i.elements);t.textureLayer.add(n)}}function vL(i,t){let e=t.userData.center;yt(i.elements,e),i.elements.forEach(n=>{let r=new ci(t.context,E({},n,{url:n.secondUrl,rotate:n.secondRotate,width:n.secondWidth,center_x:n.center_coord_x,center_y:n.center_coord_y}));t.glbModelLayer.add(r)})}function _L(i,t){let e=t.userData.center;yt(i.elements,e),i.elements.map(n=>{let r=t.addGraphic(n);t.userData.graphics.push(r),t.userData.graphicMap.set(n.id,r);try{let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o&&(o.userData.type="store",o.userData.data=n,o.userData.floor=t.name)}catch(o){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",o,n)}})}function xL(i,t){let e=t.userData.center;yt(i.elements,e),i.elements.map(n=>{let r=t.addGraphic(n);if(t.userData.graphics.push(r),t.userData.graphicMap.set(n.id,r),n.poi_info){let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o.userData.type="facility",o.userData.data=n,o.userData.floor=t.name}else console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info",n)})}function CL(i,t,e){let n=t.userData.center;yt(i.elements,n),t.parkingSpaceLayer.createParkings(i.elements,e.mergeParkingSpace),i.elements.forEach(r=>{if(r.texts[0]){let o=new ot(t.context,{id:r.id,text:r.texts[0],position:{x:r.center_coord_x,y:r.center_coord_y,z:r.airHeight+r.height}});o&&(o.userData.type="parkingSpace",o.userData.data=r,o.userData.floor=t.name),t.poiLayer2.pushPoi(o)}}),t.userData.parkingSpaces=t.parkingSpaceLayer.graphicMap.values(),t.userData.parkingSpacesGraphicMap=t.parkingSpaceLayer.graphicMap}function AL(i,t){let e=t.userData.center;yt(i.elements,e);let n=new pi(t.context,i.elements.map(r=>E({},r,{center_x:r.center_coord_x,center_y:r.center_coord_y})));t.textTextureLayer.add(n)}var fl="map_version",dl="route_version",gl="facility_version",ml="map_data",Ps="road_network_data",yl="facility_data",EL={mergeParkingSpace:!0},vl=class extends Ls.EventDispatcher{initDb(){return x(this,null,function*(){try{let{db:t,type:e}=yield w_("aibee_map",2);e==="onupgradeneeded"&&(Ln(fl),Ln(dl),Ln(gl),Ln(ml),Ln(Ps),Ln(yl)),this.db=t}catch(t){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",t)}})}load(t){return x(this,null,function*(){if(Array.isArray(t))this.floors=t;else{let e=yield fetch(t).then(n=>n.json());e.code==="0"&&(this.floors=e.data.list)}})}setCacheData(t,e,n){return this.initDbPromise.then(()=>M_(t,""+e,n,this.db))}getCacheData(t,e){return this.initDbPromise.then(()=>pl(t,""+e,this.db))}getFloorCacheKey(t){return""+t.floor_id}getFloorData(t){return x(this,null,function*(){let e=yield this.getFloorJsonData(t);return e?this.getDataByJson(e):null})}getFloorDataByFloorInfo(t){return x(this,null,function*(){let e=yield this.getFloorJsonDataByFloorInfo(t);return this.getDataByJson(e)})}getFloorJsonDataByFloorInfo(t){return x(this,null,function*(){let e=this.getFloorCacheKey(t);console.time("zstd_json");let n=yield fetch(t.map_url).then(r=>r.json());return n.floor=t.floor,console.timeEnd("zstd_json"),this.setCacheData(ml,e,n),this.setCacheData(fl,e,t.version_id),n})}getFloorJsonData(t){return x(this,null,function*(){let e=this.floors.find(r=>r.floor===t);if(!e)return null;let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(fl,n))===e.version_id){let o=yield this.getCacheData(ml,n);if(o)return o}return this.getFloorJsonDataByFloorInfo(e)}catch(r){return console.log("[get floor data error]",r),this.getFloorJsonDataByFloorInfo(e)}})}getRoadNetworkData(){return x(this,null,function*(){return(yield Promise.all(this.floors.map(e=>x(this,null,function*(){let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(dl,n))===e.version_id){let s=yield this.getCacheData(Ps,n);if(s)return s}let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Ps,n,o),this.setCacheData(dl,n,e.version_id),o}catch(r){let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Ps,n,o),o}})))).filter(e=>e.points)})}getFacilitiesData(){return x(this,null,function*(){let t=this.floors.reduce((r,o)=>r.updated_at>o.updated_at?r:o,this.floors[0]);if(!t)return null;let e=this.getFloorCacheKey(t),n=()=>x(this,null,function*(){let r=yield fetch(t.entry_infra_url).then(o=>o.json());return r&&(this.setCacheData(yl,e,r),this.setCacheData(gl,e,t.version_id)),r});try{if((yield this.getCacheData(gl,e))===t.version_id){let o=yield this.getCacheData(yl,e);if(o)return o}return n()}catch(r){return console.log("[get facility error]",r),n()}})}getOtherDataByFreeTime(){return x(this,null,function*(){})}getMulFloorsData(t){return x(this,null,function*(){return Promise.all(t.map(e=>this.getFloorData(e))).then(e=>e.filter(n=>n))})}getDataByUrl(t){return x(this,null,function*(){let e=yield fetch(t).then(n=>n.json());return this.getDataByJson(e)})}getDataByJson(t,e){return x(this,null,function*(){return e=this.getFloorBaseLayer(t,e),yield this.getFloorContentLayer(t,e),this.changeFloorBox(t,e),e})}changeFloorBox(t,e){e.updateBox();let n=e.box.getSize(new Ls.Vector3),r=Math.max(n.x,n.y,n.z);e.userData.height=r/4+t.floorHeight}switchFloor(t){return x(this,null,function*(){return new Promise(e=>{let n={run:()=>this._switchFloor(t),meta:{type:"switchFloor"}},r=this.taskQueue.replaceByMetaType(n),o=s=>{let{task:a,res:u}=s;a.tid===r&&(this.taskQueue.removeEventListener("active-task-end",o),e(u))};this.taskQueue.addEventListener("active-task-end",o)})})}_switchFloor(t){return x(this,null,function*(){var e;let n=t;if(typeof t=="string"){let u=yield this.getFloorJsonData(t);if(u)n=u;else return null}let r=new Ft(this.bmap.context),o=this.floors.find(u=>u.floor===n.floor);var s;let a=(s=o==null?void 0:o.map_angle)!=null?s:0;return this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_BEFORE,data:{curFloor:r,graphics:[]}}),this.dispatchEvent({type:"switch-floor-before",data:{curFloor:r,graphics:[]}}),this.bmap.context.control.setAzimuthalAngle(a/180*Math.PI,!0),this.getFloorBaseLayer(n,r),this.changeFloorBox(n,r),this.bmap.buildingCenter=r.userData.center,this.bmap.currentBuildGround=(e=r.userData.data.layers.find(u=>u.l_type==="range"))==null?void 0:e.elements[0],this.bmap.context.switchFloor(r),this.bmap.initialFloorCamera(),yield co(),this.dispatchEvent({type:"switch-floor-ground",data:{curFloor:r,graphics:[]}}),yield this.getFloorContentLayer(n,r),this.changeFloorBox(n,r),this.bmap.initialFloorCamera(),this.bmap.context.cameraBound.updateBox(),this.dispatchEvent({type:"switch-floor-after",data:{curFloor:r,graphics:r.graphicLayer.children}}),this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_AFTER,data:{curFloor:r,graphics:r.graphicLayer.children}}),r})}getFloorBaseLayer(t,e){e||(e=new Ft(this.bmap.context));let n=[0,0];return t.layers.forEach(r=>{switch(r.l_type){case"range":let o=r.elements[0];n=[o.center_x,o.center_y];break;case"ground":yt(r.elements,n);let s=r.elements.map(a=>new K(this.bmap.context,a));e.addGrounds(s);break;default:break}}),e.userData.center=n,e.name=t.floor,e.userData.data=t,e}getFloorContentLayer(t,e){return x(this,null,function*(){e||(e=new Ft(this.bmap.context)),e.userData.graphics=[],e.userData.graphicMap=new Map;let n=Date.now();for(let r=0;r<t.layers.length;r++){let o=t.layers[r];["range","ground"].includes(o.l_type)||(I_(o,e,this.options),console.log("time",Date.now()-n,o.l_type),Date.now()-n>16&&(yield co(),n=Date.now()))}return e})}clear(){return x(this,null,function*(){var t;T_((t=this.db)!=null?t:void 0)})}dispose(){this.clear()}constructor(t,e={}){super(),this.bmap=t,this.floors=[],this.initDbPromise=Promise.resolve(),this.db=null,this.taskQueue=new Cn,this.options=E({},EL,e),this.initDbPromise=this.initDb()}};var y7=d(T(),1);var _l=class{load(t){return x(this,null,function*(){let e=vn(t);if(this.cacheData.has(e))return this.cacheData.get(e);let[,n]=yield Promise.all([this.loadBuildGround(t),hl(t,this.bmap.config)]),r=vn({floor:t.floor,ts:t.ts});yt(n.map(s=>s.info),this.bmap.buildingCenter,this.floorDataLengthMap.get(r)||0),n.forEach(s=>s.info.transformToBuildingGround=!1),this.cacheData.set(e,n);let o=this.floorDataLengthMap.get(r)||0;return this.floorDataLengthMap.set(r,o+n.length),this.loadExternalStreet(t),n})}loadExternalStreet(t){return x(this,null,function*(){})}switchFloorByData(t,e){if(!t.length)return;let n=e.userData.legacyToGraphicMap||new Map,r=e.userData.graphicMap||new Map,{ground:o,markGraphic:s,graphic:a}=this.bmap.config;for(let u=0;u<t.length;u++){let l=t[u];l.info.group==="ground"?(l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.height=o.height,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity):l.info.userData.mark?(l.info.height=s.height,l.info.fillColor=s.color,l.info.fillOpacity=s.opacity,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity):(l.info.fillOpacity=a.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=s.height,l.info.fillColor=s.color,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity))}for(let u of t){if(u.info.group==="ground")e.createGround(u.info);else{let l=e.addGraphic(u.info);l.userData.data=u,n.set(u.legacy_id,l)}r.set(u.element_uuid,u)}e.userData.legacyToGraphicMap=n,e.userData.graphicMap=r,e.updateBox(),e===this.bmap.context.currentFloor?(this.bmap.triggerHooks(gt.SWITCH_FLOOR_BEFORE,{curFloor:e,graphics:e.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(gt.SWITCH_FLOOR_AFTER,{curFloor:e,graphics:e.graphicLayer.children})):this.bmap.switchFloorByFloor(e)}filterData(t,e){let n=e.userData.graphicMap||new Map;return t.filter(r=>!n.has(r.element_uuid))}switchFloorByStoreData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"6"})),r=this.filterData(n,e);this.switchFloorByData(r,e)})}switchFloorByOtherData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"1,2,3,4"})),r=this.filterData(n,e);this.switchFloorByData(r,e)})}loadBuildGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,r=yield this.loadBuildingGround({brand:e,project:n});return this.bmap.currentBuildGround=r,this.bmap.changeBuildingCenter(r,{brand:e,project:n}),this.bmap.currentBuildGround})}loadBuildingGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,r=vn({brand:e,project:n});if(this.buildingGroundMap.has(r))return this.buildingGroundMap.get(r);let o=cl({brand:e,project:n},this.bmap.config).then(s=>(this.buildingGroundMap.set(r,s),s));return this.buildingGroundMap.set(r,o),o})}switchFloor(t){return x(this,null,function*(){let e=new Ft(this.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([this.switchFloorByStoreData(t,e),this.switchFloorByOtherData(t,e)])}catch(n){console.log(n)}return e})}dispose(){this.cacheData.clear(),this.floorDataLengthMap.clear(),this.buildingGroundMap.clear()}constructor(t){this.bmap=t,this.cacheData=new Map,this.floorDataLengthMap=new Map,this.buildingGroundMap=new Map,this.externalStreetMap=new Map}};
|