@aibee/crc-bmap 0.8.43 → 0.8.44
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 +3 -3
- package/lib/bmap.esm.min.js +1 -1
- package/lib/bmap.min.js +1 -1
- package/lib/src/plugins/car-inertial-position/car-inertial-position.d.ts +1 -1
- package/lib/src/plugins/car-inertial-position/car-inertial-position.js +3 -3
- package/package.json +1 -1
package/lib/bmap.cjs.min.js
CHANGED
|
@@ -7734,4 +7734,4 @@ void main() {
|
|
|
7734
7734
|
|
|
7735
7735
|
}\`,zf=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 Fi,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 go({extensions:{fragDepth:!0},vertexShader:Xb,fragmentShader:Yb,uniforms:{depthColor:{value:this.texture},depthWidth:{value:o.z},depthHeight:{value:o.w}}});this.mesh=new to(new mc(20,20),a)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},kf=class extends gs{constructor(t,e){super();let o=this,a=null,l=1,h=null,f="local-floor",p=1,d=null,g=null,x=null,_=null,M=null,A=null,I=new zf,v=e.getContextAttributes(),y=null,P=null,w=[],D=[],B=new nn,z=null,U=new Si;U.layers.enable(1),U.viewport=new Pr;let R=new Si;R.layers.enable(2),R.viewport=new Pr;let nt=[U,R],O=new Bf;O.layers.enable(1),O.layers.enable(2);let q=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let _t=w[K];return _t===void 0&&(_t=new Wu,w[K]=_t),_t.getTargetRaySpace()},this.getControllerGrip=function(K){let _t=w[K];return _t===void 0&&(_t=new Wu,w[K]=_t),_t.getGripSpace()},this.getHand=function(K){let _t=w[K];return _t===void 0&&(_t=new Wu,w[K]=_t),_t.getHandSpace()};function vt(K){let _t=D.indexOf(K.inputSource);if(_t===-1)return;let Rt=w[_t];Rt!==void 0&&(Rt.update(K.inputSource,K.frame,d||h),Rt.dispatchEvent({type:K.type,data:K.inputSource}))}function Y(){a.removeEventListener("select",vt),a.removeEventListener("selectstart",vt),a.removeEventListener("selectend",vt),a.removeEventListener("squeeze",vt),a.removeEventListener("squeezestart",vt),a.removeEventListener("squeezeend",vt),a.removeEventListener("end",Y),a.removeEventListener("inputsourceschange",at);for(let K=0;K<w.length;K++){let _t=D[K];_t!==null&&(D[K]=null,w[K].disconnect(_t))}q=null,G=null,I.reset(),t.setRenderTarget(y),M=null,_=null,x=null,a=null,P=null,$t.stop(),o.isPresenting=!1,t.setPixelRatio(z),t.setSize(B.width,B.height,!1),o.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){l=K,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){f=K,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||h},this.setReferenceSpace=function(K){d=K},this.getBaseLayer=function(){return _!==null?_:M},this.getBinding=function(){return x},this.getFrame=function(){return A},this.getSession=function(){return a},this.setSession=function(K){return ym(this,null,function*(){if(a=K,a!==null){if(y=t.getRenderTarget(),a.addEventListener("select",vt),a.addEventListener("selectstart",vt),a.addEventListener("selectend",vt),a.addEventListener("squeeze",vt),a.addEventListener("squeezestart",vt),a.addEventListener("squeezeend",vt),a.addEventListener("end",Y),a.addEventListener("inputsourceschange",at),v.xrCompatible!==!0&&(yield e.makeXRCompatible()),z=t.getPixelRatio(),t.getSize(B),a.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let _t={antialias:a.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:l};M=new XRWebGLLayer(a,e,_t),a.updateRenderState({baseLayer:M}),t.setPixelRatio(1),t.setSize(M.framebufferWidth,M.framebufferHeight,!1),P=new Xo(M.framebufferWidth,M.framebufferHeight,{format:ji,type:ds,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil})}else{let _t=null,Rt=null,qt=null;v.depth&&(qt=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,_t=v.stencil?Ka:Js,Rt=v.stencil?Zs:hs);let Tt={colorFormat:e.RGBA8,depthFormat:qt,scaleFactor:l};x=new XRWebGLBinding(a,e),_=x.createProjectionLayer(Tt),a.updateRenderState({layers:[_]}),t.setPixelRatio(1),t.setSize(_.textureWidth,_.textureHeight,!1),P=new Xo(_.textureWidth,_.textureHeight,{format:ji,type:ds,depthTexture:new yc(_.textureWidth,_.textureHeight,Rt,void 0,void 0,void 0,void 0,void 0,void 0,_t),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0});let Ct=t.properties.get(P);Ct.__ignoreDepthValues=_.ignoreDepthValues}P.isXRRenderTarget=!0,this.setFoveation(p),d=null,h=yield a.requestReferenceSpace(f),$t.setContext(a),$t.start(),o.isPresenting=!0,o.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(a!==null)return a.environmentBlendMode};function at(K){for(let _t=0;_t<K.removed.length;_t++){let Rt=K.removed[_t],qt=D.indexOf(Rt);qt>=0&&(D[qt]=null,w[qt].disconnect(Rt))}for(let _t=0;_t<K.added.length;_t++){let Rt=K.added[_t],qt=D.indexOf(Rt);if(qt===-1){for(let Ct=0;Ct<w.length;Ct++)if(Ct>=D.length){D.push(Rt),qt=Ct;break}else if(D[Ct]===null){D[Ct]=Rt,qt=Ct;break}if(qt===-1)break}let Tt=w[qt];Tt&&Tt.connect(Rt)}}let lt=new dt,pt=new dt;function Q(K,_t,Rt){lt.setFromMatrixPosition(_t.matrixWorld),pt.setFromMatrixPosition(Rt.matrixWorld);let qt=lt.distanceTo(pt),Tt=_t.projectionMatrix.elements,Ct=Rt.projectionMatrix.elements,wt=Tt[14]/(Tt[10]-1),Wt=Tt[14]/(Tt[10]+1),j=(Tt[9]+1)/Tt[5],je=(Tt[9]-1)/Tt[5],Bt=(Tt[8]-1)/Tt[0],te=(Ct[8]+1)/Ct[0],Vt=wt*Bt,J=wt*te,N=qt/(-Bt+te),T=N*-Bt;_t.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(T),K.translateZ(N),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert();let L=wt+N,b=Wt+N,S=Vt-T,V=J+(qt-T),Z=j*Wt/b*L,X=je*Wt/b*L;K.projectionMatrix.makePerspective(S,V,Z,X,L,b),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}function rt(K,_t){_t===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(_t.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(a===null)return;I.texture!==null&&(K.near=I.depthNear,K.far=I.depthFar),O.near=R.near=U.near=K.near,O.far=R.far=U.far=K.far,(q!==O.near||G!==O.far)&&(a.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,G=O.far,U.near=q,U.far=G,R.near=q,R.far=G,U.updateProjectionMatrix(),R.updateProjectionMatrix(),K.updateProjectionMatrix());let _t=K.parent,Rt=O.cameras;rt(O,_t);for(let qt=0;qt<Rt.length;qt++)rt(Rt[qt],_t);Rt.length===2?Q(O,U,R):O.projectionMatrix.copy(U.projectionMatrix),W(K,O,_t)};function W(K,_t,Rt){Rt===null?K.matrix.copy(_t.matrixWorld):(K.matrix.copy(Rt.matrixWorld),K.matrix.invert(),K.matrix.multiply(_t.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(_t.projectionMatrix),K.projectionMatrixInverse.copy(_t.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Mf*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(_===null&&M===null))return p},this.setFoveation=function(K){p=K,_!==null&&(_.fixedFoveation=K),M!==null&&M.fixedFoveation!==void 0&&(M.fixedFoveation=K)},this.hasDepthSensing=function(){return I.texture!==null};let xt=null;function Mt(K,_t){if(g=_t.getViewerPose(d||h),A=_t,g!==null){let Rt=g.views;M!==null&&(t.setRenderTargetFramebuffer(P,M.framebuffer),t.setRenderTarget(P));let qt=!1;Rt.length!==O.cameras.length&&(O.cameras.length=0,qt=!0);for(let Ct=0;Ct<Rt.length;Ct++){let wt=Rt[Ct],Wt=null;if(M!==null)Wt=M.getViewport(wt);else{let je=x.getViewSubImage(_,wt);Wt=je.viewport,Ct===0&&(t.setRenderTargetTextures(P,je.colorTexture,_.ignoreDepthValues?void 0:je.depthStencilTexture),t.setRenderTarget(P))}let j=nt[Ct];j===void 0&&(j=new Si,j.layers.enable(Ct),j.viewport=new Pr,nt[Ct]=j),j.matrix.fromArray(wt.transform.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale),j.projectionMatrix.fromArray(wt.projectionMatrix),j.projectionMatrixInverse.copy(j.projectionMatrix).invert(),j.viewport.set(Wt.x,Wt.y,Wt.width,Wt.height),Ct===0&&(O.matrix.copy(j.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),qt===!0&&O.cameras.push(j)}let Tt=a.enabledFeatures;if(Tt&&Tt.includes("depth-sensing")){let Ct=x.getDepthInformation(Rt[0]);Ct&&Ct.isValid&&Ct.texture&&I.init(t,Ct,a.renderState)}}for(let Rt=0;Rt<w.length;Rt++){let qt=D[Rt],Tt=w[Rt];qt!==null&&Tt!==void 0&&Tt.update(qt,_t,d||h)}I.render(t,O),xt&&xt(K,_t),_t.detectedPlanes&&o.dispatchEvent({type:"planesdetected",data:_t}),A=null}let $t=new y0;$t.setAnimationLoop(Mt),this.setAnimationLoop=function(K){xt=K},this.dispose=function(){}}},Ws=new Qs,$b=new vr;function Zb(r,t){function e(v,y){v.matrixAutoUpdate===!0&&v.updateMatrix(),y.value.copy(v.matrix)}function o(v,y){y.color.getRGB(v.fogColor.value,g0(r)),y.isFog?(v.fogNear.value=y.near,v.fogFar.value=y.far):y.isFogExp2&&(v.fogDensity.value=y.density)}function a(v,y,P,w,D){y.isMeshBasicMaterial||y.isMeshLambertMaterial?l(v,y):y.isMeshToonMaterial?(l(v,y),x(v,y)):y.isMeshPhongMaterial?(l(v,y),g(v,y)):y.isMeshStandardMaterial?(l(v,y),_(v,y),y.isMeshPhysicalMaterial&&M(v,y,D)):y.isMeshMatcapMaterial?(l(v,y),A(v,y)):y.isMeshDepthMaterial?l(v,y):y.isMeshDistanceMaterial?(l(v,y),I(v,y)):y.isMeshNormalMaterial?l(v,y):y.isLineBasicMaterial?(h(v,y),y.isLineDashedMaterial&&f(v,y)):y.isPointsMaterial?p(v,y,P,w):y.isSpriteMaterial?d(v,y):y.isShadowMaterial?(v.color.value.copy(y.color),v.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function l(v,y){v.opacity.value=y.opacity,y.color&&v.diffuse.value.copy(y.color),y.emissive&&v.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(v.map.value=y.map,e(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,e(y.alphaMap,v.alphaMapTransform)),y.bumpMap&&(v.bumpMap.value=y.bumpMap,e(y.bumpMap,v.bumpMapTransform),v.bumpScale.value=y.bumpScale,y.side===fi&&(v.bumpScale.value*=-1)),y.normalMap&&(v.normalMap.value=y.normalMap,e(y.normalMap,v.normalMapTransform),v.normalScale.value.copy(y.normalScale),y.side===fi&&v.normalScale.value.negate()),y.displacementMap&&(v.displacementMap.value=y.displacementMap,e(y.displacementMap,v.displacementMapTransform),v.displacementScale.value=y.displacementScale,v.displacementBias.value=y.displacementBias),y.emissiveMap&&(v.emissiveMap.value=y.emissiveMap,e(y.emissiveMap,v.emissiveMapTransform)),y.specularMap&&(v.specularMap.value=y.specularMap,e(y.specularMap,v.specularMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest);let P=t.get(y),w=P.envMap,D=P.envMapRotation;if(w&&(v.envMap.value=w,Ws.copy(D),Ws.x*=-1,Ws.y*=-1,Ws.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Ws.y*=-1,Ws.z*=-1),v.envMapRotation.value.setFromMatrix4($b.makeRotationFromEuler(Ws)),v.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=y.reflectivity,v.ior.value=y.ior,v.refractionRatio.value=y.refractionRatio),y.lightMap){v.lightMap.value=y.lightMap;let B=r._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=y.lightMapIntensity*B,e(y.lightMap,v.lightMapTransform)}y.aoMap&&(v.aoMap.value=y.aoMap,v.aoMapIntensity.value=y.aoMapIntensity,e(y.aoMap,v.aoMapTransform))}function h(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,y.map&&(v.map.value=y.map,e(y.map,v.mapTransform))}function f(v,y){v.dashSize.value=y.dashSize,v.totalSize.value=y.dashSize+y.gapSize,v.scale.value=y.scale}function p(v,y,P,w){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.size.value=y.size*P,v.scale.value=w*.5,y.map&&(v.map.value=y.map,e(y.map,v.uvTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,e(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function d(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.rotation.value=y.rotation,y.map&&(v.map.value=y.map,e(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,e(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function g(v,y){v.specular.value.copy(y.specular),v.shininess.value=Math.max(y.shininess,1e-4)}function x(v,y){y.gradientMap&&(v.gradientMap.value=y.gradientMap)}function _(v,y){v.metalness.value=y.metalness,y.metalnessMap&&(v.metalnessMap.value=y.metalnessMap,e(y.metalnessMap,v.metalnessMapTransform)),v.roughness.value=y.roughness,y.roughnessMap&&(v.roughnessMap.value=y.roughnessMap,e(y.roughnessMap,v.roughnessMapTransform)),t.get(y).envMap&&(v.envMapIntensity.value=y.envMapIntensity)}function M(v,y,P){v.ior.value=y.ior,y.sheen>0&&(v.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),v.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(v.sheenColorMap.value=y.sheenColorMap,e(y.sheenColorMap,v.sheenColorMapTransform)),y.sheenRoughnessMap&&(v.sheenRoughnessMap.value=y.sheenRoughnessMap,e(y.sheenRoughnessMap,v.sheenRoughnessMapTransform))),y.clearcoat>0&&(v.clearcoat.value=y.clearcoat,v.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(v.clearcoatMap.value=y.clearcoatMap,e(y.clearcoatMap,v.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,e(y.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(v.clearcoatNormalMap.value=y.clearcoatNormalMap,e(y.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===fi&&v.clearcoatNormalScale.value.negate())),y.iridescence>0&&(v.iridescence.value=y.iridescence,v.iridescenceIOR.value=y.iridescenceIOR,v.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(v.iridescenceMap.value=y.iridescenceMap,e(y.iridescenceMap,v.iridescenceMapTransform)),y.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=y.iridescenceThicknessMap,e(y.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),y.transmission>0&&(v.transmission.value=y.transmission,v.transmissionSamplerMap.value=P.texture,v.transmissionSamplerSize.value.set(P.width,P.height),y.transmissionMap&&(v.transmissionMap.value=y.transmissionMap,e(y.transmissionMap,v.transmissionMapTransform)),v.thickness.value=y.thickness,y.thicknessMap&&(v.thicknessMap.value=y.thicknessMap,e(y.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=y.attenuationDistance,v.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(v.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(v.anisotropyMap.value=y.anisotropyMap,e(y.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=y.specularIntensity,v.specularColor.value.copy(y.specularColor),y.specularColorMap&&(v.specularColorMap.value=y.specularColorMap,e(y.specularColorMap,v.specularColorMapTransform)),y.specularIntensityMap&&(v.specularIntensityMap.value=y.specularIntensityMap,e(y.specularIntensityMap,v.specularIntensityMapTransform))}function A(v,y){y.matcap&&(v.matcap.value=y.matcap)}function I(v,y){let P=t.get(y).light;v.referencePosition.value.setFromMatrixPosition(P.matrixWorld),v.nearDistance.value=P.shadow.camera.near,v.farDistance.value=P.shadow.camera.far}return{refreshFogUniforms:o,refreshMaterialUniforms:a}}function Jb(r,t,e,o){let a={},l={},h=[],f=e.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function p(P,w){let D=w.program;o.uniformBlockBinding(P,D)}function d(P,w){let D=a[P.id];D===void 0&&(A(P),D=g(P),a[P.id]=D,P.addEventListener("dispose",v));let B=w.program;o.updateUBOMapping(P,B);let z=t.render.frame;l[P.id]!==z&&(_(P),l[P.id]=z)}function g(P){let w=x();P.__bindingPointIndex=w;let D=r.createBuffer(),B=P.__size,z=P.usage;return r.bindBuffer(r.UNIFORM_BUFFER,D),r.bufferData(r.UNIFORM_BUFFER,B,z),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,w,D),D}function x(){for(let P=0;P<f;P++)if(h.indexOf(P)===-1)return h.push(P),P;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function _(P){let w=a[P.id],D=P.uniforms,B=P.__cache;r.bindBuffer(r.UNIFORM_BUFFER,w);for(let z=0,U=D.length;z<U;z++){let R=Array.isArray(D[z])?D[z]:[D[z]];for(let nt=0,O=R.length;nt<O;nt++){let q=R[nt];if(M(q,z,nt,B)===!0){let G=q.__offset,vt=Array.isArray(q.value)?q.value:[q.value],Y=0;for(let at=0;at<vt.length;at++){let lt=vt[at],pt=I(lt);typeof lt=="number"||typeof lt=="boolean"?(q.__data[0]=lt,r.bufferSubData(r.UNIFORM_BUFFER,G+Y,q.__data)):lt.isMatrix3?(q.__data[0]=lt.elements[0],q.__data[1]=lt.elements[1],q.__data[2]=lt.elements[2],q.__data[3]=0,q.__data[4]=lt.elements[3],q.__data[5]=lt.elements[4],q.__data[6]=lt.elements[5],q.__data[7]=0,q.__data[8]=lt.elements[6],q.__data[9]=lt.elements[7],q.__data[10]=lt.elements[8],q.__data[11]=0):(lt.toArray(q.__data,Y),Y+=pt.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,G,q.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function M(P,w,D,B){let z=P.value,U=w+"_"+D;if(B[U]===void 0)return typeof z=="number"||typeof z=="boolean"?B[U]=z:B[U]=z.clone(),!0;{let R=B[U];if(typeof z=="number"||typeof z=="boolean"){if(R!==z)return B[U]=z,!0}else if(R.equals(z)===!1)return R.copy(z),!0}return!1}function A(P){let w=P.uniforms,D=0,B=16;for(let U=0,R=w.length;U<R;U++){let nt=Array.isArray(w[U])?w[U]:[w[U]];for(let O=0,q=nt.length;O<q;O++){let G=nt[O],vt=Array.isArray(G.value)?G.value:[G.value];for(let Y=0,at=vt.length;Y<at;Y++){let lt=vt[Y],pt=I(lt),Q=D%B;Q!==0&&B-Q<pt.boundary&&(D+=B-Q),G.__data=new Float32Array(pt.storage/Float32Array.BYTES_PER_ELEMENT),G.__offset=D,D+=pt.storage}}}let z=D%B;return z>0&&(D+=B-z),P.__size=D,P.__cache={},this}function I(P){let w={boundary:0,storage:0};return typeof P=="number"||typeof P=="boolean"?(w.boundary=4,w.storage=4):P.isVector2?(w.boundary=8,w.storage=8):P.isVector3||P.isColor?(w.boundary=16,w.storage=12):P.isVector4?(w.boundary=16,w.storage=16):P.isMatrix3?(w.boundary=48,w.storage=48):P.isMatrix4?(w.boundary=64,w.storage=64):P.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",P),w}function v(P){let w=P.target;w.removeEventListener("dispose",v);let D=h.indexOf(w.__bindingPointIndex);h.splice(D,1),r.deleteBuffer(a[w.id]),delete a[w.id],delete l[w.id]}function y(){for(let P in a)r.deleteBuffer(a[P]);h=[],a={},l={}}return{bind:p,update:d,dispose:y}}var Gf=class{constructor(t={}){let{canvas:e=jx(),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 _;o!==null?_=o.getContextAttributes().alpha:_=h;let M=new Uint32Array(4),A=new Int32Array(4),I=null,v=null,y=[],P=[];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=fo,this._useLegacyLights=!1,this.toneMapping=ps,this.toneMappingExposure=1;let w=this,D=!1,B=0,z=0,U=null,R=-1,nt=null,O=new Pr,q=new Pr,G=null,vt=new pn(0),Y=0,at=e.width,lt=e.height,pt=1,Q=null,rt=null,W=new Pr(0,0,at,lt),xt=new Pr(0,0,at,lt),Mt=!1,$t=new dc,K=!1,_t=!1,Rt=null,qt=new vr,Tt=new nn,Ct=new dt,wt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Wt(){return U===null?pt:1}let j=o;function je(k,tt){for(let ft=0;ft<k.length;ft++){let ot=k[ft],et=e.getContext(ot,tt);if(et!==null)return et}return null}try{let k={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\${jf}\`),e.addEventListener("webglcontextlost",ce,!1),e.addEventListener("webglcontextrestored",H,!1),e.addEventListener("webglcontextcreationerror",It,!1),j===null){let tt=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&tt.shift(),j=je(tt,k),j===null)throw je(tt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&j instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),j.getShaderPrecisionFormat===void 0&&(j.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let Bt,te,Vt,J,N,T,L,b,S,V,Z,X,it,bt,ht,yt,Et,Ft,gt,ie,jt,zt,Ut,Ot;function Xt(){Bt=new fS(j),te=new sS(j,Bt,t),Bt.init(te),zt=new Wb(j,Bt,te),Vt=new Vb(j,Bt,te),J=new mS(j),N=new Ib,T=new Hb(j,Bt,Vt,N,te,zt,J),L=new uS(w),b=new hS(w),S=new EE(j,te),Ut=new iS(j,Bt,S,te),V=new pS(j,S,J,Ut),Z=new _S(j,V,S,J),gt=new vS(j,te,T),yt=new aS(N),X=new Pb(w,L,b,Bt,te,Ut,yt),it=new Zb(w,N),bt=new Lb,ht=new Bb(Bt,te),Ft=new rS(w,L,b,Vt,Z,_,p),Et=new Gb(w,Z,te),Ot=new Jb(j,J,te,Vt),ie=new oS(j,Bt,J,te),jt=new dS(j,Bt,J,te),J.programs=X.programs,w.capabilities=te,w.extensions=Bt,w.properties=N,w.renderLists=bt,w.shadowMap=Et,w.state=Vt,w.info=J}Xt();let ne=new kf(w,j);this.xr=ne,this.getContext=function(){return j},this.getContextAttributes=function(){return j.getContextAttributes()},this.forceContextLoss=function(){let k=Bt.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){let k=Bt.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return pt},this.setPixelRatio=function(k){k!==void 0&&(pt=k,this.setSize(at,lt,!1))},this.getSize=function(k){return k.set(at,lt)},this.setSize=function(k,tt,ft=!0){if(ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}at=k,lt=tt,e.width=Math.floor(k*pt),e.height=Math.floor(tt*pt),ft===!0&&(e.style.width=k+"px",e.style.height=tt+"px"),this.setViewport(0,0,k,tt)},this.getDrawingBufferSize=function(k){return k.set(at*pt,lt*pt).floor()},this.setDrawingBufferSize=function(k,tt,ft){at=k,lt=tt,pt=ft,e.width=Math.floor(k*ft),e.height=Math.floor(tt*ft),this.setViewport(0,0,k,tt)},this.getCurrentViewport=function(k){return k.copy(O)},this.getViewport=function(k){return k.copy(W)},this.setViewport=function(k,tt,ft,ot){k.isVector4?W.set(k.x,k.y,k.z,k.w):W.set(k,tt,ft,ot),Vt.viewport(O.copy(W).multiplyScalar(pt).round())},this.getScissor=function(k){return k.copy(xt)},this.setScissor=function(k,tt,ft,ot){k.isVector4?xt.set(k.x,k.y,k.z,k.w):xt.set(k,tt,ft,ot),Vt.scissor(q.copy(xt).multiplyScalar(pt).round())},this.getScissorTest=function(){return Mt},this.setScissorTest=function(k){Vt.setScissorTest(Mt=k)},this.setOpaqueSort=function(k){Q=k},this.setTransparentSort=function(k){rt=k},this.getClearColor=function(k){return k.copy(Ft.getClearColor())},this.setClearColor=function(){Ft.setClearColor.apply(Ft,arguments)},this.getClearAlpha=function(){return Ft.getClearAlpha()},this.setClearAlpha=function(){Ft.setClearAlpha.apply(Ft,arguments)},this.clear=function(k=!0,tt=!0,ft=!0){let ot=0;if(k){let et=!1;if(U!==null){let Gt=U.texture.format;et=Gt===h0||Gt===c0||Gt===l0}if(et){let Gt=U.texture.type,Ht=Gt===ds||Gt===hs||Gt===tp||Gt===Zs||Gt===a0||Gt===u0,ee=Ft.getClearColor(),Yt=Ft.getClearAlpha(),he=ee.r,re=ee.g,oe=ee.b;Ht?(M[0]=he,M[1]=re,M[2]=oe,M[3]=Yt,j.clearBufferuiv(j.COLOR,0,M)):(A[0]=he,A[1]=re,A[2]=oe,A[3]=Yt,j.clearBufferiv(j.COLOR,0,A))}else ot|=j.COLOR_BUFFER_BIT}tt&&(ot|=j.DEPTH_BUFFER_BIT),ft&&(ot|=j.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),j.clear(ot)},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",ce,!1),e.removeEventListener("webglcontextrestored",H,!1),e.removeEventListener("webglcontextcreationerror",It,!1),bt.dispose(),ht.dispose(),N.dispose(),L.dispose(),b.dispose(),Z.dispose(),Ut.dispose(),Ot.dispose(),X.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",si),ne.removeEventListener("sessionend",fn),Rt&&(Rt.dispose(),Rt=null),Sr.stop()};function ce(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),D=!0}function H(){console.log("THREE.WebGLRenderer: Context Restored."),D=!1;let k=J.autoReset,tt=Et.enabled,ft=Et.autoUpdate,ot=Et.needsUpdate,et=Et.type;Xt(),J.autoReset=k,Et.enabled=tt,Et.autoUpdate=ft,Et.needsUpdate=ot,Et.type=et}function It(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function ut(k){let tt=k.target;tt.removeEventListener("dispose",ut),mt(tt)}function mt(k){Lt(k),N.remove(k)}function Lt(k){let tt=N.get(k).programs;tt!==void 0&&(tt.forEach(function(ft){X.releaseProgram(ft)}),k.isShaderMaterial&&X.releaseShaderCache(k))}this.renderBufferDirect=function(k,tt,ft,ot,et,Gt){tt===null&&(tt=wt);let Ht=et.isMesh&&et.matrixWorld.determinant()<0,ee=Wn(k,tt,ft,ot,et);Vt.setMaterial(ot,Ht);let Yt=ft.index,he=1;if(ot.wireframe===!0){if(Yt=V.getWireframeAttribute(ft),Yt===void 0)return;he=2}let re=ft.drawRange,oe=ft.attributes.position,tn=re.start*he,ur=(re.start+re.count)*he;Gt!==null&&(tn=Math.max(tn,Gt.start*he),ur=Math.min(ur,(Gt.start+Gt.count)*he)),Yt!==null?(tn=Math.max(tn,0),ur=Math.min(ur,Yt.count)):oe!=null&&(tn=Math.max(tn,0),ur=Math.min(ur,oe.count));let Tn=ur-tn;if(Tn<0||Tn===1/0)return;Ut.setup(et,ot,ee,ft,Yt);let qr,mn=ie;if(Yt!==null&&(qr=S.get(Yt),mn=jt,mn.setIndex(qr)),et.isMesh)ot.wireframe===!0?(Vt.setLineWidth(ot.wireframeLinewidth*Wt()),mn.setMode(j.LINES)):mn.setMode(j.TRIANGLES);else if(et.isLine){let Zt=ot.linewidth;Zt===void 0&&(Zt=1),Vt.setLineWidth(Zt*Wt()),et.isLineSegments?mn.setMode(j.LINES):et.isLineLoop?mn.setMode(j.LINE_LOOP):mn.setMode(j.LINE_STRIP)}else et.isPoints?mn.setMode(j.POINTS):et.isSprite&&mn.setMode(j.TRIANGLES);if(et.isBatchedMesh)mn.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)mn.renderInstances(tn,Tn,et.count);else if(ft.isInstancedBufferGeometry){let Zt=ft._maxInstanceCount!==void 0?ft._maxInstanceCount:1/0,fa=Math.min(ft.instanceCount,Zt);mn.renderInstances(tn,Tn,fa)}else mn.render(tn,Tn)};function ue(k,tt,ft){k.transparent===!0&&k.side===Vo&&k.forceSinglePass===!1?(k.side=fi,k.needsUpdate=!0,ar(k,tt,ft),k.side=ms,k.needsUpdate=!0,ar(k,tt,ft),k.side=Vo):ar(k,tt,ft)}this.compile=function(k,tt,ft=null){ft===null&&(ft=k),v=ht.get(ft),v.init(),P.push(v),ft.traverseVisible(function(et){et.isLight&&et.layers.test(tt.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),k!==ft&&k.traverseVisible(function(et){et.isLight&&et.layers.test(tt.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),v.setupLights(w._useLegacyLights);let ot=new Set;return k.traverse(function(et){let Gt=et.material;if(Gt)if(Array.isArray(Gt))for(let Ht=0;Ht<Gt.length;Ht++){let ee=Gt[Ht];ue(ee,ft,et),ot.add(ee)}else ue(Gt,ft,et),ot.add(Gt)}),P.pop(),v=null,ot},this.compileAsync=function(k,tt,ft=null){let ot=this.compile(k,tt,ft);return new Promise(et=>{function Gt(){if(ot.forEach(function(Ht){N.get(Ht).currentProgram.isReady()&&ot.delete(Ht)}),ot.size===0){et(k);return}setTimeout(Gt,10)}Bt.get("KHR_parallel_shader_compile")!==null?Gt():setTimeout(Gt,10)})};let ye=null;function dn(k){ye&&ye(k)}function si(){Sr.stop()}function fn(){Sr.start()}let Sr=new y0;Sr.setAnimationLoop(dn),typeof self!="undefined"&&Sr.setContext(self),this.setAnimationLoop=function(k){ye=k,ne.setAnimationLoop(k),k===null?Sr.stop():Sr.start()},ne.addEventListener("sessionstart",si),ne.addEventListener("sessionend",fn),this.render=function(k,tt){if(tt!==void 0&&tt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),tt.parent===null&&tt.matrixWorldAutoUpdate===!0&&tt.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(tt),tt=ne.getCamera()),k.isScene===!0&&k.onBeforeRender(w,k,tt,U),v=ht.get(k,P.length),v.init(),P.push(v),qt.multiplyMatrices(tt.projectionMatrix,tt.matrixWorldInverse),$t.setFromProjectionMatrix(qt),_t=this.localClippingEnabled,K=yt.init(this.clippingPlanes,_t),I=bt.get(k,y.length),I.init(),y.push(I),kn(k,tt,0,w.sortObjects),I.finish(),w.sortObjects===!0&&I.sort(Q,rt),this.info.render.frame++,K===!0&&yt.beginShadows();let ft=v.state.shadowsArray;if(Et.render(ft,k,tt),K===!0&&yt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ne.enabled===!1||ne.isPresenting===!1||ne.hasDepthSensing()===!1)&&Ft.render(I,k),v.setupLights(w._useLegacyLights),tt.isArrayCamera){let ot=tt.cameras;for(let et=0,Gt=ot.length;et<Gt;et++){let Ht=ot[et];$o(I,k,Ht,Ht.viewport)}}else $o(I,k,tt);U!==null&&(T.updateMultisampleRenderTarget(U),T.updateRenderTargetMipmap(U)),k.isScene===!0&&k.onAfterRender(w,k,tt),Ut.resetDefaultState(),R=-1,nt=null,P.pop(),P.length>0?v=P[P.length-1]:v=null,y.pop(),y.length>0?I=y[y.length-1]:I=null};function kn(k,tt,ft,ot){if(k.visible===!1)return;if(k.layers.test(tt.layers)){if(k.isGroup)ft=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(tt);else if(k.isLight)v.pushLight(k),k.castShadow&&v.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||$t.intersectsSprite(k)){ot&&Ct.setFromMatrixPosition(k.matrixWorld).applyMatrix4(qt);let Ht=Z.update(k),ee=k.material;ee.visible&&I.push(k,Ht,ee,ft,Ct.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||$t.intersectsObject(k))){let Ht=Z.update(k),ee=k.material;if(ot&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),Ct.copy(k.boundingSphere.center)):(Ht.boundingSphere===null&&Ht.computeBoundingSphere(),Ct.copy(Ht.boundingSphere.center)),Ct.applyMatrix4(k.matrixWorld).applyMatrix4(qt)),Array.isArray(ee)){let Yt=Ht.groups;for(let he=0,re=Yt.length;he<re;he++){let oe=Yt[he],tn=ee[oe.materialIndex];tn&&tn.visible&&I.push(k,Ht,tn,ft,Ct.z,oe)}}else ee.visible&&I.push(k,Ht,ee,ft,Ct.z,null)}}let Gt=k.children;for(let Ht=0,ee=Gt.length;Ht<ee;Ht++)kn(Gt[Ht],tt,ft,ot)}function $o(k,tt,ft,ot){let et=k.opaque,Gt=k.transmissive,Ht=k.transparent;v.setupLightsView(ft),K===!0&&yt.setGlobalState(w.clippingPlanes,ft),Gt.length>0&&ha(et,Gt,tt,ft),ot&&Vt.viewport(O.copy(ot)),et.length>0&&gi(et,tt,ft),Gt.length>0&&gi(Gt,tt,ft),Ht.length>0&&gi(Ht,tt,ft),Vt.buffers.depth.setTest(!0),Vt.buffers.depth.setMask(!0),Vt.buffers.color.setMask(!0),Vt.setPolygonOffset(!1)}function ha(k,tt,ft,ot){if((ft.isScene===!0?ft.overrideMaterial:null)!==null)return;let Gt=te.isWebGL2;Rt===null&&(Rt=new Xo(1,1,{generateMipmaps:!0,type:Bt.has("EXT_color_buffer_half_float")?qu:ds,minFilter:$s,samples:Gt?4:0})),w.getDrawingBufferSize(Tt),Gt?Rt.setSize(Tt.x,Tt.y):Rt.setSize(wf(Tt.x),wf(Tt.y));let Ht=w.getRenderTarget();w.setRenderTarget(Rt),w.getClearColor(vt),Y=w.getClearAlpha(),Y<1&&w.setClearColor(16777215,.5),w.clear();let ee=w.toneMapping;w.toneMapping=ps,gi(k,ft,ot),T.updateMultisampleRenderTarget(Rt),T.updateRenderTargetMipmap(Rt);let Yt=!1;for(let he=0,re=tt.length;he<re;he++){let oe=tt[he],tn=oe.object,ur=oe.geometry,Tn=oe.material,qr=oe.group;if(Tn.side===Vo&&tn.layers.test(ot.layers)){let mn=Tn.side;Tn.side=fi,Tn.needsUpdate=!0,me(tn,ft,ot,ur,Tn,qr),Tn.side=mn,Tn.needsUpdate=!0,Yt=!0}}Yt===!0&&(T.updateMultisampleRenderTarget(Rt),T.updateRenderTargetMipmap(Rt)),w.setRenderTarget(Ht),w.setClearColor(vt,Y),w.toneMapping=ee}function gi(k,tt,ft){let ot=tt.isScene===!0?tt.overrideMaterial:null;for(let et=0,Gt=k.length;et<Gt;et++){let Ht=k[et],ee=Ht.object,Yt=Ht.geometry,he=ot===null?Ht.material:ot,re=Ht.group;ee.layers.test(ft.layers)&&me(ee,tt,ft,Yt,he,re)}}function me(k,tt,ft,ot,et,Gt){k.onBeforeRender(w,tt,ft,ot,et,Gt),k.modelViewMatrix.multiplyMatrices(ft.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),et.onBeforeRender(w,tt,ft,ot,k,Gt),et.transparent===!0&&et.side===Vo&&et.forceSinglePass===!1?(et.side=fi,et.needsUpdate=!0,w.renderBufferDirect(ft,tt,ot,et,k,Gt),et.side=ms,et.needsUpdate=!0,w.renderBufferDirect(ft,tt,ot,et,k,Gt),et.side=Vo):w.renderBufferDirect(ft,tt,ot,et,k,Gt),k.onAfterRender(w,tt,ft,ot,et,Gt)}function ar(k,tt,ft){tt.isScene!==!0&&(tt=wt);let ot=N.get(k),et=v.state.lights,Gt=v.state.shadowsArray,Ht=et.state.version,ee=X.getParameters(k,et.state,Gt,tt,ft),Yt=X.getProgramCacheKey(ee),he=ot.programs;ot.environment=k.isMeshStandardMaterial?tt.environment:null,ot.fog=tt.fog,ot.envMap=(k.isMeshStandardMaterial?b:L).get(k.envMap||ot.environment),ot.envMapRotation=ot.environment!==null&&k.envMap===null?tt.environmentRotation:k.envMapRotation,he===void 0&&(k.addEventListener("dispose",ut),he=new Map,ot.programs=he);let re=he.get(Yt);if(re!==void 0){if(ot.currentProgram===re&&ot.lightsStateVersion===Ht)return Or(k,ee),re}else ee.uniforms=X.getUniforms(k),k.onBuild(ft,ee,w),k.onBeforeCompile(ee,w),re=X.acquireProgram(ee,Yt),he.set(Yt,re),ot.uniforms=ee.uniforms;let oe=ot.uniforms;return(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(oe.clippingPlanes=yt.uniform),Or(k,ee),ot.needsLights=Dr(k),ot.lightsStateVersion=Ht,ot.needsLights&&(oe.ambientLightColor.value=et.state.ambient,oe.lightProbe.value=et.state.probe,oe.directionalLights.value=et.state.directional,oe.directionalLightShadows.value=et.state.directionalShadow,oe.spotLights.value=et.state.spot,oe.spotLightShadows.value=et.state.spotShadow,oe.rectAreaLights.value=et.state.rectArea,oe.ltc_1.value=et.state.rectAreaLTC1,oe.ltc_2.value=et.state.rectAreaLTC2,oe.pointLights.value=et.state.point,oe.pointLightShadows.value=et.state.pointShadow,oe.hemisphereLights.value=et.state.hemi,oe.directionalShadowMap.value=et.state.directionalShadowMap,oe.directionalShadowMatrix.value=et.state.directionalShadowMatrix,oe.spotShadowMap.value=et.state.spotShadowMap,oe.spotLightMatrix.value=et.state.spotLightMatrix,oe.spotLightMap.value=et.state.spotLightMap,oe.pointShadowMap.value=et.state.pointShadowMap,oe.pointShadowMatrix.value=et.state.pointShadowMatrix),ot.currentProgram=re,ot.uniformsList=null,re}function Wr(k){if(k.uniformsList===null){let tt=k.currentProgram.getUniforms();k.uniformsList=$a.seqWithValue(tt.seq,k.uniforms)}return k.uniformsList}function Or(k,tt){let ft=N.get(k);ft.outputColorSpace=tt.outputColorSpace,ft.batching=tt.batching,ft.instancing=tt.instancing,ft.instancingColor=tt.instancingColor,ft.instancingMorph=tt.instancingMorph,ft.skinning=tt.skinning,ft.morphTargets=tt.morphTargets,ft.morphNormals=tt.morphNormals,ft.morphColors=tt.morphColors,ft.morphTargetsCount=tt.morphTargetsCount,ft.numClippingPlanes=tt.numClippingPlanes,ft.numIntersection=tt.numClipIntersection,ft.vertexAlphas=tt.vertexAlphas,ft.vertexTangents=tt.vertexTangents,ft.toneMapping=tt.toneMapping}function Wn(k,tt,ft,ot,et){tt.isScene!==!0&&(tt=wt),T.resetTextureUnits();let Gt=tt.fog,Ht=ot.isMeshStandardMaterial?tt.environment:null,ee=U===null?w.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:vs,Yt=(ot.isMeshStandardMaterial?b:L).get(ot.envMap||Ht),he=ot.vertexColors===!0&&!!ft.attributes.color&&ft.attributes.color.itemSize===4,re=!!ft.attributes.tangent&&(!!ot.normalMap||ot.anisotropy>0),oe=!!ft.morphAttributes.position,tn=!!ft.morphAttributes.normal,ur=!!ft.morphAttributes.color,Tn=ps;ot.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(Tn=w.toneMapping);let qr=ft.morphAttributes.position||ft.morphAttributes.normal||ft.morphAttributes.color,mn=qr!==void 0?qr.length:0,Zt=N.get(ot),fa=v.state.lights;if(K===!0&&(_t===!0||k!==nt)){let Xr=k===nt&&ot.id===R;yt.setState(ot,k,Xr)}let en=!1;ot.version===Zt.__version?(Zt.needsLights&&Zt.lightsStateVersion!==fa.state.version||Zt.outputColorSpace!==ee||et.isBatchedMesh&&Zt.batching===!1||!et.isBatchedMesh&&Zt.batching===!0||et.isInstancedMesh&&Zt.instancing===!1||!et.isInstancedMesh&&Zt.instancing===!0||et.isSkinnedMesh&&Zt.skinning===!1||!et.isSkinnedMesh&&Zt.skinning===!0||et.isInstancedMesh&&Zt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&Zt.instancingColor===!1&&et.instanceColor!==null||et.isInstancedMesh&&Zt.instancingMorph===!0&&et.morphTexture===null||et.isInstancedMesh&&Zt.instancingMorph===!1&&et.morphTexture!==null||Zt.envMap!==Yt||ot.fog===!0&&Zt.fog!==Gt||Zt.numClippingPlanes!==void 0&&(Zt.numClippingPlanes!==yt.numPlanes||Zt.numIntersection!==yt.numIntersection)||Zt.vertexAlphas!==he||Zt.vertexTangents!==re||Zt.morphTargets!==oe||Zt.morphNormals!==tn||Zt.morphColors!==ur||Zt.toneMapping!==Tn||te.isWebGL2===!0&&Zt.morphTargetsCount!==mn)&&(en=!0):(en=!0,Zt.__version=ot.version);let Bi=Zt.currentProgram;en===!0&&(Bi=ar(ot,tt,et));let bu=!1,fe=!1,Ts=!1,gn=Bi.getUniforms(),zi=Zt.uniforms;if(Vt.useProgram(Bi.program)&&(bu=!0,fe=!0,Ts=!0),ot.id!==R&&(R=ot.id,fe=!0),bu||nt!==k){gn.setValue(j,"projectionMatrix",k.projectionMatrix),gn.setValue(j,"viewMatrix",k.matrixWorldInverse);let Xr=gn.map.cameraPosition;Xr!==void 0&&Xr.setValue(j,Ct.setFromMatrixPosition(k.matrixWorld)),te.logarithmicDepthBuffer&&gn.setValue(j,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),(ot.isMeshPhongMaterial||ot.isMeshToonMaterial||ot.isMeshLambertMaterial||ot.isMeshBasicMaterial||ot.isMeshStandardMaterial||ot.isShaderMaterial)&&gn.setValue(j,"isOrthographic",k.isOrthographicCamera===!0),nt!==k&&(nt=k,fe=!0,Ts=!0)}if(et.isSkinnedMesh){gn.setOptional(j,et,"bindMatrix"),gn.setOptional(j,et,"bindMatrixInverse");let Xr=et.skeleton;Xr&&(te.floatVertexTextures?(Xr.boneTexture===null&&Xr.computeBoneTexture(),gn.setValue(j,"boneTexture",Xr.boneTexture,T)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&(gn.setOptional(j,et,"batchingTexture"),gn.setValue(j,"batchingTexture",et._matricesTexture,T));let le=ft.morphAttributes;if((le.position!==void 0||le.normal!==void 0||le.color!==void 0&&te.isWebGL2===!0)&>.update(et,ft,Bi),(fe||Zt.receiveShadow!==et.receiveShadow)&&(Zt.receiveShadow=et.receiveShadow,gn.setValue(j,"receiveShadow",et.receiveShadow)),ot.isMeshGouraudMaterial&&ot.envMap!==null&&(zi.envMap.value=Yt,zi.flipEnvMap.value=Yt.isCubeTexture&&Yt.isRenderTargetTexture===!1?-1:1),fe&&(gn.setValue(j,"toneMappingExposure",w.toneMappingExposure),Zt.needsLights&&oo(zi,Ts),Gt&&ot.fog===!0&&it.refreshFogUniforms(zi,Gt),it.refreshMaterialUniforms(zi,ot,pt,lt,Rt),$a.upload(j,Wr(Zt),zi,T)),ot.isShaderMaterial&&ot.uniformsNeedUpdate===!0&&($a.upload(j,Wr(Zt),zi,T),ot.uniformsNeedUpdate=!1),ot.isSpriteMaterial&&gn.setValue(j,"center",et.center),gn.setValue(j,"modelViewMatrix",et.modelViewMatrix),gn.setValue(j,"normalMatrix",et.normalMatrix),gn.setValue(j,"modelMatrix",et.matrixWorld),ot.isShaderMaterial||ot.isRawShaderMaterial){let Xr=ot.uniformsGroups;for(let Au=0,pa=Xr.length;Au<pa;Au++)if(te.isWebGL2){let Yr=Xr[Au];Ot.update(Yr,Bi),Ot.bind(Yr,Bi)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Bi}function oo(k,tt){k.ambientLightColor.needsUpdate=tt,k.lightProbe.needsUpdate=tt,k.directionalLights.needsUpdate=tt,k.directionalLightShadows.needsUpdate=tt,k.pointLights.needsUpdate=tt,k.pointLightShadows.needsUpdate=tt,k.spotLights.needsUpdate=tt,k.spotLightShadows.needsUpdate=tt,k.rectAreaLights.needsUpdate=tt,k.hemisphereLights.needsUpdate=tt}function Dr(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(k,tt,ft){N.get(k.texture).__webglTexture=tt,N.get(k.depthTexture).__webglTexture=ft;let ot=N.get(k);ot.__hasExternalTextures=!0,ot.__autoAllocateDepthBuffer=ft===void 0,ot.__autoAllocateDepthBuffer||Bt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ot.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(k,tt){let ft=N.get(k);ft.__webglFramebuffer=tt,ft.__useDefaultFramebuffer=tt===void 0},this.setRenderTarget=function(k,tt=0,ft=0){U=k,B=tt,z=ft;let ot=!0,et=null,Gt=!1,Ht=!1;if(k){let Yt=N.get(k);Yt.__useDefaultFramebuffer!==void 0?(Vt.bindFramebuffer(j.FRAMEBUFFER,null),ot=!1):Yt.__webglFramebuffer===void 0?T.setupRenderTarget(k):Yt.__hasExternalTextures&&T.rebindTextures(k,N.get(k.texture).__webglTexture,N.get(k.depthTexture).__webglTexture);let he=k.texture;(he.isData3DTexture||he.isDataArrayTexture||he.isCompressedArrayTexture)&&(Ht=!0);let re=N.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(Array.isArray(re[tt])?et=re[tt][ft]:et=re[tt],Gt=!0):te.isWebGL2&&k.samples>0&&T.useMultisampledRTT(k)===!1?et=N.get(k).__webglMultisampledFramebuffer:Array.isArray(re)?et=re[ft]:et=re,O.copy(k.viewport),q.copy(k.scissor),G=k.scissorTest}else O.copy(W).multiplyScalar(pt).floor(),q.copy(xt).multiplyScalar(pt).floor(),G=Mt;if(Vt.bindFramebuffer(j.FRAMEBUFFER,et)&&te.drawBuffers&&ot&&Vt.drawBuffers(k,et),Vt.viewport(O),Vt.scissor(q),Vt.setScissorTest(G),Gt){let Yt=N.get(k.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_CUBE_MAP_POSITIVE_X+tt,Yt.__webglTexture,ft)}else if(Ht){let Yt=N.get(k.texture),he=tt||0;j.framebufferTextureLayer(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,Yt.__webglTexture,ft||0,he)}R=-1},this.readRenderTargetPixels=function(k,tt,ft,ot,et,Gt,Ht){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ee=N.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Ht!==void 0&&(ee=ee[Ht]),ee){Vt.bindFramebuffer(j.FRAMEBUFFER,ee);try{let Yt=k.texture,he=Yt.format,re=Yt.type;if(he!==ji&&zt.convert(he)!==j.getParameter(j.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let oe=re===qu&&(Bt.has("EXT_color_buffer_half_float")||te.isWebGL2&&Bt.has("EXT_color_buffer_float"));if(re!==ds&&zt.convert(re)!==j.getParameter(j.IMPLEMENTATION_COLOR_READ_TYPE)&&!(re===Ho&&(te.isWebGL2||Bt.has("OES_texture_float")||Bt.has("WEBGL_color_buffer_float")))&&!oe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}tt>=0&&tt<=k.width-ot&&ft>=0&&ft<=k.height-et&&j.readPixels(tt,ft,ot,et,zt.convert(he),zt.convert(re),Gt)}finally{let Yt=U!==null?N.get(U).__webglFramebuffer:null;Vt.bindFramebuffer(j.FRAMEBUFFER,Yt)}}},this.copyFramebufferToTexture=function(k,tt,ft=0){let ot=Math.pow(2,-ft),et=Math.floor(tt.image.width*ot),Gt=Math.floor(tt.image.height*ot);T.setTexture2D(tt,0),j.copyTexSubImage2D(j.TEXTURE_2D,ft,0,0,k.x,k.y,et,Gt),Vt.unbindTexture()},this.copyTextureToTexture=function(k,tt,ft,ot=0){let et=tt.image.width,Gt=tt.image.height,Ht=zt.convert(ft.format),ee=zt.convert(ft.type);T.setTexture2D(ft,0),j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,ft.flipY),j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ft.premultiplyAlpha),j.pixelStorei(j.UNPACK_ALIGNMENT,ft.unpackAlignment),tt.isDataTexture?j.texSubImage2D(j.TEXTURE_2D,ot,k.x,k.y,et,Gt,Ht,ee,tt.image.data):tt.isCompressedTexture?j.compressedTexSubImage2D(j.TEXTURE_2D,ot,k.x,k.y,tt.mipmaps[0].width,tt.mipmaps[0].height,Ht,tt.mipmaps[0].data):j.texSubImage2D(j.TEXTURE_2D,ot,k.x,k.y,Ht,ee,tt.image),ot===0&&ft.generateMipmaps&&j.generateMipmap(j.TEXTURE_2D),Vt.unbindTexture()},this.copyTextureToTexture3D=function(k,tt,ft,ot,et=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Gt=Math.round(k.max.x-k.min.x),Ht=Math.round(k.max.y-k.min.y),ee=k.max.z-k.min.z+1,Yt=zt.convert(ot.format),he=zt.convert(ot.type),re;if(ot.isData3DTexture)T.setTexture3D(ot,0),re=j.TEXTURE_3D;else if(ot.isDataArrayTexture||ot.isCompressedArrayTexture)T.setTexture2DArray(ot,0),re=j.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,ot.flipY),j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ot.premultiplyAlpha),j.pixelStorei(j.UNPACK_ALIGNMENT,ot.unpackAlignment);let oe=j.getParameter(j.UNPACK_ROW_LENGTH),tn=j.getParameter(j.UNPACK_IMAGE_HEIGHT),ur=j.getParameter(j.UNPACK_SKIP_PIXELS),Tn=j.getParameter(j.UNPACK_SKIP_ROWS),qr=j.getParameter(j.UNPACK_SKIP_IMAGES),mn=ft.isCompressedTexture?ft.mipmaps[et]:ft.image;j.pixelStorei(j.UNPACK_ROW_LENGTH,mn.width),j.pixelStorei(j.UNPACK_IMAGE_HEIGHT,mn.height),j.pixelStorei(j.UNPACK_SKIP_PIXELS,k.min.x),j.pixelStorei(j.UNPACK_SKIP_ROWS,k.min.y),j.pixelStorei(j.UNPACK_SKIP_IMAGES,k.min.z),ft.isDataTexture||ft.isData3DTexture?j.texSubImage3D(re,et,tt.x,tt.y,tt.z,Gt,Ht,ee,Yt,he,mn.data):ot.isCompressedArrayTexture?j.compressedTexSubImage3D(re,et,tt.x,tt.y,tt.z,Gt,Ht,ee,Yt,mn.data):j.texSubImage3D(re,et,tt.x,tt.y,tt.z,Gt,Ht,ee,Yt,he,mn),j.pixelStorei(j.UNPACK_ROW_LENGTH,oe),j.pixelStorei(j.UNPACK_IMAGE_HEIGHT,tn),j.pixelStorei(j.UNPACK_SKIP_PIXELS,ur),j.pixelStorei(j.UNPACK_SKIP_ROWS,Tn),j.pixelStorei(j.UNPACK_SKIP_IMAGES,qr),et===0&&ot.generateMipmaps&&j.generateMipmap(re),Vt.unbindTexture()},this.initTexture=function(k){k.isCubeTexture?T.setTextureCube(k,0):k.isData3DTexture?T.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?T.setTexture2DArray(k,0):T.setTexture2D(k,0),Vt.unbindTexture()},this.resetState=function(){B=0,z=0,U=null,Vt.reset(),Ut.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===ep?"display-p3":"srgb",e.unpackColorSpace=_n.workingColorSpace===_c?"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}},Vf=class extends Gf{};Vf.prototype.isWebGL1Renderer=!0;function Jl(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 Kb(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var tu=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_(){}},Hf=class extends tu{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:hg,endingEnd:hg}}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 fg:l=t,f=2*e-o;break;case pg: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 fg:h=t,p=2*o-e;break;case pg: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,_=this._weightPrev,M=this._weightNext,A=(o-e)/(a-e),I=A*A,v=I*A,y=-_*v+2*_*I-_*A,P=(1+_)*v+(-1.5-2*_)*I+(-.5+_)*A+1,w=(-1-M)*v+(1.5+M)*I+.5*A,D=M*v-M*I;for(let B=0;B!==f;++B)l[B]=y*h[g+B]+P*h[d+B]+w*h[p+B]+D*h[x+B];return l}},Wf=class extends tu{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 _=0;_!==f;++_)l[_]=h[d+_]*x+h[p+_]*g;return l}},qf=class extends tu{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t){return this.copySampleValue_(t-1)}},eo=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=Jl(e,this.TimeBufferType),this.values=Jl(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:Jl(t.times,Array),values:Jl(t.values,Array)};let a=t.getInterpolation();a!==t.DefaultInterpolation&&(o.interpolation=a)}return o.type=t.ValueTypeName,o}InterpolantFactoryMethodDiscrete(t){return new qf(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Wf(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Hf(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ql:e=this.InterpolantFactoryMethodDiscrete;break;case jl:e=this.InterpolantFactoryMethodLinear;break;case Gh: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 Ql;case this.InterpolantFactoryMethodLinear:return jl;case this.InterpolantFactoryMethodSmooth:return Gh}}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&&Kb(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()===Gh,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,_=x-o,M=x+o;for(let A=0;A!==o;++A){let I=e[x+A];if(I!==e[_+A]||I!==e[M+A]){p=!0;break}}}if(p){if(f!==h){t[h]=t[f];let x=f*o,_=h*o;for(let M=0;M!==o;++M)e[_+M]=e[x+M]}++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}};eo.prototype.TimeBufferType=Float32Array;eo.prototype.ValueBufferType=Float32Array;eo.prototype.DefaultInterpolation=jl;var ta=class extends eo{};ta.prototype.ValueTypeName="bool";ta.prototype.ValueBufferType=Array;ta.prototype.DefaultInterpolation=Ql;ta.prototype.InterpolantFactoryMethodLinear=void 0;ta.prototype.InterpolantFactoryMethodSmooth=void 0;var Xf=class extends eo{};Xf.prototype.ValueTypeName="color";var Yf=class extends eo{};Yf.prototype.ValueTypeName="number";var $f=class extends tu{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)ys.slerpFlat(l,0,h,d-f,h,d,p);return l}},$u=class extends eo{InterpolantFactoryMethodLinear(t){return new $f(this.times,this.values,this.getValueSize(),t)}};$u.prototype.ValueTypeName="quaternion";$u.prototype.DefaultInterpolation=jl;$u.prototype.InterpolantFactoryMethodSmooth=void 0;var ea=class extends eo{};ea.prototype.ValueTypeName="string";ea.prototype.ValueBufferType=Array;ea.prototype.DefaultInterpolation=Ql;ea.prototype.InterpolantFactoryMethodLinear=void 0;ea.prototype.InterpolantFactoryMethodSmooth=void 0;var Zf=class extends eo{};Zf.prototype.ValueTypeName="vector";var Jf=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,_=d.length;x<_;x+=2){let M=d[x],A=d[x+1];if(M.global&&(M.lastIndex=0),M.test(g))return A}return null}}},Qb=new Jf,Kf=class{constructor(t){this.manager=t!==void 0?t:Qb,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}};Kf.DEFAULT_MATERIAL_NAME="__DEFAULT";var rp="\\\\[\\\\]\\\\.:\\\\/",jb=new RegExp("["+rp+"]","g"),ip="[^"+rp+"]",tA="[^"+rp.replace("\\\\.","")+"]",eA=/((?:WC+[\\/:])*)/.source.replace("WC",ip),nA=/(WCOD+)?/.source.replace("WCOD",tA),rA=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",ip),iA=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",ip),oA=new RegExp("^"+eA+nA+rA+iA+"$"),sA=["material","materials","bones","map"],Qf=class{constructor(t,e,o){let a=o||Ln.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()}},Ln=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(jb,"")}static parseTrackName(t){let e=oA.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);sA.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}};Ln.Composite=Qf;Ln.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ln.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ln.prototype.GetterByBindingType=[Ln.prototype._getValue_direct,Ln.prototype._getValue_array,Ln.prototype._getValue_arrayElement,Ln.prototype._getValue_toArray];Ln.prototype.SetterByBindingTypeAndVersioning=[[Ln.prototype._setValue_direct,Ln.prototype._setValue_direct_setNeedsUpdate,Ln.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ln.prototype._setValue_array,Ln.prototype._setValue_array_setNeedsUpdate,Ln.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ln.prototype._setValue_arrayElement,Ln.prototype._setValue_arrayElement_setNeedsUpdate,Ln.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ln.prototype._setValue_fromArray,Ln.prototype._setValue_fromArray_setNeedsUpdate,Ln.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var zR=new Float32Array(1);typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:jf}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jf);var _r=63710088e-1,VR={centimeters:_r*100,centimetres:_r*100,degrees:_r/111325,feet:_r*3.28084,inches:_r*39.37,kilometers:_r/1e3,kilometres:_r/1e3,meters:_r,metres:_r,miles:_r/1609.344,millimeters:_r*1e3,millimetres:_r*1e3,nauticalmiles:_r/1852,radians:1,yards:_r*1.0936},HR={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/_r,yards:1.0936133};function ni(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 wn(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(!yo(r[0])||!yo(r[1]))throw new Error("coordinates must contain numbers");var o={type:"Point",coordinates:r};return ni(o,t,e)}function Nn(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 ni(f,t,e)}function xr(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 ni(o,t,e)}function op(r,t,e){e===void 0&&(e={});var o={type:"MultiPoint",coordinates:r};return ni(o,t,e)}function yo(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function rr(r,t,e){if(r!==null)for(var o,a,l,h,f,p,d,g=0,x=0,_,M=r.type,A=M==="FeatureCollection",I=M==="Feature",v=A?r.features.length:1,y=0;y<v;y++){d=A?r.features[y].geometry:I?r.geometry:r,_=d?d.type==="GeometryCollection":!1,f=_?d.geometries.length:1;for(var P=0;P<f;P++){var w=0,D=0;if(h=_?d.geometries[P]:d,h!==null){p=h.coordinates;var B=h.type;switch(g=e&&(B==="Polygon"||B==="MultiPolygon")?1:0,B){case null:break;case"Point":if(t(p,x,y,w,D)===!1)return!1;x++,w++;break;case"LineString":case"MultiPoint":for(o=0;o<p.length;o++){if(t(p[o],x,y,w,D)===!1)return!1;x++,B==="MultiPoint"&&w++}B==="LineString"&&w++;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,w,D)===!1)return!1;x++}B==="MultiLineString"&&w++,B==="Polygon"&&D++}B==="Polygon"&&w++;break;case"MultiPolygon":for(o=0;o<p.length;o++){for(D=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,w,D)===!1)return!1;x++}D++}w++}break;case"GeometryCollection":for(o=0;o<h.geometries.length;o++)if(rr(h.geometries[o],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function w0(r,t,e,o){var a=e;return rr(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 _s(r,t){var e,o,a,l,h,f,p,d,g,x,_=0,M=r.type==="FeatureCollection",A=r.type==="Feature",I=M?r.features.length:1;for(e=0;e<I;e++){for(f=M?r.features[e].geometry:A?r.geometry:r,d=M?r.features[e].properties:A?r.properties:{},g=M?r.features[e].bbox:A?r.bbox:void 0,x=M?r.features[e].id:A?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,_,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,_,d,g,x)===!1)return!1;break}case"GeometryCollection":{for(o=0;o<l.geometries.length;o++)if(t(l.geometries[o],_,d,g,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}_++}}function bi(r,t){_s(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(ni(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(ni(x,a),o,d)===!1)return!1}})}function sp(r){var t=[1/0,1/0,-1/0,-1/0];return rr(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}sp.default=sp;var ri=sp;function Ir(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 ap(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 Rr(r){return r.type==="Feature"?r.geometry:r}var dA=Dn(Ec(),1);var SA=Dn(G0(),1);function Er(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=Ir(r),a=Rr(t),l=a.type,h=t.bbox,f=a.coordinates;if(h&&bA(o,h)===!1)return!1;l==="Polygon"&&(f=[f]);for(var p=!1,d=0;d<f.length&&!p;d++)if(V0(o,f[d][0],e.ignoreBoundary)){for(var g=!1,x=1;x<f[d].length&&!g;)V0(o,f[d][x],!e.ignoreBoundary)&&(g=!0),x++;g||(p=!0)}return p}function V0(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 bA(r,t){return t[0]<=r[0]&&t[1]<=r[1]&&t[2]>=r[0]&&t[3]>=r[1]}var q0=new ArrayBuffer(16),vN=new Float64Array(q0),_N=new Uint32Array(q0);var kA=Dn(wp(),1);var q2=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 GA(l,this.points[a],this.controls[a][1],this.controls[a+1][0],this.points[a+1])},r}();function GA(r,t,e,o,a){var l=VA(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 VA(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 ju(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 Nn([[h,d,p,f,h]],t.properties,{bbox:r,id:t.id})}function HA(r){return ju(ri(r))}var Sp=HA;var sT=Dn(ny(),1);var NT=Dn(Bc(),1);var DT=Dn(Ec(),1);var BT=Dn(wp(),1);var xy=Math.PI/180,Ey=180/Math.PI,sl=function(r,t){this.lon=r,this.lat=t,this.x=xy*r,this.y=xy*t};sl.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)};sl.prototype.antipode=function(){var r=-1*this.lat,t=this.lon<0?180+this.lon:(180-this.lon)*-1;return new sl(t,r)};var My=function(){this.coords=[],this.length=0};My.prototype.move_to=function(r){this.length++,this.coords.push(r)};var Wp=function(r){this.properties=r||{},this.geometries=[]};Wp.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}};Wp.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 wy=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 sl(r.x,r.y),this.end=new sl(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)};wy.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=Ey*Math.atan2(l,Math.sqrt(Math.pow(o,2)+Math.pow(a,2))),f=Ey*Math.atan2(a,o);return[f,h]};wy.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,_=360-d,M=1;M<e.length;++M){var A=e[M-1][0],I=e[M][0],v=Math.abs(I-A);v>_&&(I>g&&A<x||A>g&&I<x)?f=!0:v>p&&(p=v)}var y=[];if(f&&p<d){var P=[];y.push(P);for(var w=0;w<e.length;++w){var D=parseFloat(e[w][0]);if(w>0&&Math.abs(D-e[w-1][0])>_){var B=parseFloat(e[w-1][0]),z=parseFloat(e[w-1][1]),U=parseFloat(e[w][0]),R=parseFloat(e[w][1]);if(B>-180&&B<x&&U===180&&w+1<e.length&&e[w-1][0]>-180&&e[w-1][0]<x){P.push([-180,e[w][1]]),w++,P.push([e[w][0],e[w][1]]);continue}else if(B>g&&B<180&&U===-180&&w+1<e.length&&e[w-1][0]>g&&e[w-1][0]<180){P.push([180,e[w][1]]),w++,P.push([e[w][0],e[w][1]]);continue}if(B<x&&U>g){var nt=B;B=U,U=nt;var O=z;z=R,R=O}if(B>g&&U<x&&(U+=360),B<=180&&U>=180&&B<U){var q=(180-B)/(U-B),G=q*R+(1-q)*z;P.push([e[w-1][0]>g?180:-180,G]),P=[],P.push([e[w-1][0]>g?-180:180,G]),y.push(P)}else P=[],y.push(P);P.push([D,e[w][1]])}else P.push([e[w][0],e[w][1]])}}else{var vt=[];y.push(vt);for(var Y=0;Y<e.length;++Y)vt.push([e[Y][0],e[Y][1]])}for(var at=new Wp(this.properties),lt=0;lt<y.length;++lt){var pt=new My;at.geometries.push(pt);for(var Q=y[lt],rt=0;rt<Q.length;++rt)pt.move_to(Q[rt])}return at};var GT=Dn(Bc(),1);var mP=Dn(Bc(),1);var gP=Dn(fd(),1);var _P=Dn(Ec(),1);var _e=[],xe=[],Ee=[],Me=[],we=[],Se=[],be=[],Ae=[],Te=[],Ce=[],Pe=[],Ie=[],Re=[],Le=[],Ne=[],Oe=[],De=[],Fe=[],Ue=[],Be=[],ze=[],ke=[],Ge=[],Ve=[];be[85]=Ce[85]=-1;Ae[85]=Pe[85]=0;Te[85]=Ie[85]=1;Ue[85]=ke[85]=1;Be[85]=Ge[85]=0;ze[85]=Ve[85]=1;_e[85]=Me[85]=0;xe[85]=we[85]=-1;Ee[85]=Ne[85]=0;Oe[85]=Re[85]=0;De[85]=Le[85]=1;Se[85]=Fe[85]=1;ke[1]=ke[169]=0;Ge[1]=Ge[169]=-1;Ve[1]=Ve[169]=0;Re[1]=Re[169]=-1;Le[1]=Le[169]=0;Ne[1]=Ne[169]=0;Ce[4]=Ce[166]=0;Pe[4]=Pe[166]=-1;Ie[4]=Ie[166]=1;Oe[4]=Oe[166]=1;De[4]=De[166]=0;Fe[4]=Fe[166]=0;be[16]=be[154]=0;Ae[16]=Ae[154]=1;Te[16]=Te[154]=1;Me[16]=Me[154]=1;we[16]=we[154]=0;Se[16]=Se[154]=1;Ue[64]=Ue[106]=0;Be[64]=Be[106]=1;ze[64]=ze[106]=0;_e[64]=_e[106]=-1;xe[64]=xe[106]=0;Ee[64]=Ee[106]=1;Ue[2]=Ue[168]=0;Be[2]=Be[168]=-1;ze[2]=ze[168]=1;ke[2]=ke[168]=0;Ge[2]=Ge[168]=-1;Ve[2]=Ve[168]=0;Re[2]=Re[168]=-1;Le[2]=Le[168]=0;Ne[2]=Ne[168]=0;Oe[2]=Oe[168]=-1;De[2]=De[168]=0;Fe[2]=Fe[168]=1;be[8]=be[162]=0;Ae[8]=Ae[162]=-1;Te[8]=Te[162]=0;Ce[8]=Ce[162]=0;Pe[8]=Pe[162]=-1;Ie[8]=Ie[162]=1;Re[8]=Re[162]=1;Le[8]=Le[162]=0;Ne[8]=Ne[162]=1;Oe[8]=Oe[162]=1;De[8]=De[162]=0;Fe[8]=Fe[162]=0;be[32]=be[138]=0;Ae[32]=Ae[138]=1;Te[32]=Te[138]=1;Ce[32]=Ce[138]=0;Pe[32]=Pe[138]=1;Ie[32]=Ie[138]=0;_e[32]=_e[138]=1;xe[32]=xe[138]=0;Ee[32]=Ee[138]=0;Me[32]=Me[138]=1;we[32]=we[138]=0;Se[32]=Se[138]=1;ke[128]=ke[42]=0;Ge[128]=Ge[42]=1;Ve[128]=Ve[42]=1;Ue[128]=Ue[42]=0;Be[128]=Be[42]=1;ze[128]=ze[42]=0;_e[128]=_e[42]=-1;xe[128]=xe[42]=0;Ee[128]=Ee[42]=1;Me[128]=Me[42]=-1;we[128]=we[42]=0;Se[128]=Se[42]=0;Ce[5]=Ce[165]=-1;Pe[5]=Pe[165]=0;Ie[5]=Ie[165]=0;ke[5]=ke[165]=1;Ge[5]=Ge[165]=0;Ve[5]=Ve[165]=0;Oe[20]=Oe[150]=0;De[20]=De[150]=1;Fe[20]=Fe[150]=1;Me[20]=Me[150]=0;we[20]=we[150]=-1;Se[20]=Se[150]=1;be[80]=be[90]=-1;Ae[80]=Ae[90]=0;Te[80]=Te[90]=1;Ue[80]=Ue[90]=1;Be[80]=Be[90]=0;ze[80]=ze[90]=1;Re[65]=Re[105]=0;Le[65]=Le[105]=1;Ne[65]=Ne[105]=0;_e[65]=_e[105]=0;xe[65]=xe[105]=-1;Ee[65]=Ee[105]=0;be[160]=be[10]=-1;Ae[160]=Ae[10]=0;Te[160]=Te[10]=1;Ce[160]=Ce[10]=-1;Pe[160]=Pe[10]=0;Ie[160]=Ie[10]=0;ke[160]=ke[10]=1;Ge[160]=Ge[10]=0;Ve[160]=Ve[10]=0;Ue[160]=Ue[10]=1;Be[160]=Be[10]=0;ze[160]=ze[10]=1;Oe[130]=Oe[40]=0;De[130]=De[40]=1;Fe[130]=Fe[40]=1;Re[130]=Re[40]=0;Le[130]=Le[40]=1;Ne[130]=Ne[40]=0;_e[130]=_e[40]=0;xe[130]=xe[40]=-1;Ee[130]=Ee[40]=0;Me[130]=Me[40]=0;we[130]=we[40]=-1;Se[130]=Se[40]=1;Ce[37]=Ce[133]=0;Pe[37]=Pe[133]=1;Ie[37]=Ie[133]=1;ke[37]=ke[133]=0;Ge[37]=Ge[133]=1;Ve[37]=Ve[133]=0;_e[37]=_e[133]=-1;xe[37]=xe[133]=0;Ee[37]=Ee[133]=0;Me[37]=Me[133]=1;we[37]=we[133]=0;Se[37]=Se[133]=0;Oe[148]=Oe[22]=-1;De[148]=De[22]=0;Fe[148]=Fe[22]=0;ke[148]=ke[22]=0;Ge[148]=Ge[22]=-1;Ve[148]=Ve[22]=1;Ue[148]=Ue[22]=0;Be[148]=Be[22]=1;ze[148]=ze[22]=1;Me[148]=Me[22]=-1;we[148]=we[22]=0;Se[148]=Se[22]=1;be[82]=be[88]=0;Ae[82]=Ae[88]=-1;Te[82]=Te[88]=1;Oe[82]=Oe[88]=1;De[82]=De[88]=0;Fe[82]=Fe[88]=1;Re[82]=Re[88]=-1;Le[82]=Le[88]=0;Ne[82]=Ne[88]=1;Ue[82]=Ue[88]=0;Be[82]=Be[88]=-1;ze[82]=ze[88]=0;be[73]=be[97]=0;Ae[73]=Ae[97]=1;Te[73]=Te[97]=0;Ce[73]=Ce[97]=0;Pe[73]=Pe[97]=-1;Ie[73]=Ie[97]=0;Re[73]=Re[97]=1;Le[73]=Le[97]=0;Ne[73]=Ne[97]=0;_e[73]=_e[97]=1;xe[73]=xe[97]=0;Ee[73]=Ee[97]=1;be[145]=be[25]=0;Ae[145]=Ae[25]=-1;Te[145]=Te[25]=0;Re[145]=Re[25]=1;Le[145]=Le[25]=0;Ne[145]=Ne[25]=1;ke[145]=ke[25]=0;Ge[145]=Ge[25]=1;Ve[145]=Ve[25]=1;Me[145]=Me[25]=-1;we[145]=we[25]=0;Se[145]=Se[25]=0;Ce[70]=Ce[100]=0;Pe[70]=Pe[100]=1;Ie[70]=Ie[100]=0;Oe[70]=Oe[100]=-1;De[70]=De[100]=0;Fe[70]=Fe[100]=1;Ue[70]=Ue[100]=0;Be[70]=Be[100]=-1;ze[70]=ze[100]=1;_e[70]=_e[100]=1;xe[70]=xe[100]=0;Ee[70]=Ee[100]=0;Ce[101]=Ce[69]=0;Pe[101]=Pe[69]=1;Ie[101]=Ie[69]=0;_e[101]=_e[69]=1;xe[101]=xe[69]=0;Ee[101]=Ee[69]=0;ke[149]=ke[21]=0;Ge[149]=Ge[21]=1;Ve[149]=Ve[21]=1;Me[149]=Me[21]=-1;we[149]=we[21]=0;Se[149]=Se[21]=0;Oe[86]=Oe[84]=-1;De[86]=De[84]=0;Fe[86]=Fe[84]=1;Ue[86]=Ue[84]=0;Be[86]=Be[84]=-1;ze[86]=ze[84]=1;be[89]=be[81]=0;Ae[89]=Ae[81]=-1;Te[89]=Te[81]=0;Re[89]=Re[81]=1;Le[89]=Le[81]=0;Ne[89]=Ne[81]=1;be[96]=be[74]=0;Ae[96]=Ae[74]=1;Te[96]=Te[74]=0;Ce[96]=Ce[74]=-1;Pe[96]=Pe[74]=0;Ie[96]=Ie[74]=1;Ue[96]=Ue[74]=1;Be[96]=Be[74]=0;ze[96]=ze[74]=0;_e[96]=_e[74]=1;xe[96]=xe[74]=0;Ee[96]=Ee[74]=1;be[24]=be[146]=0;Ae[24]=Ae[146]=-1;Te[24]=Te[146]=1;Oe[24]=Oe[146]=1;De[24]=De[146]=0;Fe[24]=Fe[146]=1;Re[24]=Re[146]=0;Le[24]=Le[146]=1;Ne[24]=Ne[146]=1;Me[24]=Me[146]=0;we[24]=we[146]=-1;Se[24]=Se[146]=0;Ce[6]=Ce[164]=-1;Pe[6]=Pe[164]=0;Ie[6]=Ie[164]=1;Oe[6]=Oe[164]=-1;De[6]=De[164]=0;Fe[6]=Fe[164]=0;ke[6]=ke[164]=0;Ge[6]=Ge[164]=-1;Ve[6]=Ve[164]=1;Ue[6]=Ue[164]=1;Be[6]=Be[164]=0;ze[6]=ze[164]=0;Re[129]=Re[41]=0;Le[129]=Le[41]=1;Ne[129]=Ne[41]=1;ke[129]=ke[41]=0;Ge[129]=Ge[41]=1;Ve[129]=Ve[41]=0;_e[129]=_e[41]=-1;xe[129]=xe[41]=0;Ee[129]=Ee[41]=0;Me[129]=Me[41]=0;we[129]=we[41]=-1;Se[129]=Se[41]=0;Oe[66]=Oe[104]=0;De[66]=De[104]=1;Fe[66]=Fe[104]=0;Re[66]=Re[104]=-1;Le[66]=Le[104]=0;Ne[66]=Ne[104]=1;Ue[66]=Ue[104]=0;Be[66]=Be[104]=-1;ze[66]=ze[104]=0;_e[66]=_e[104]=0;xe[66]=xe[104]=-1;Ee[66]=Ee[104]=1;be[144]=be[26]=-1;Ae[144]=Ae[26]=0;Te[144]=Te[26]=0;ke[144]=ke[26]=1;Ge[144]=Ge[26]=0;Ve[144]=Ve[26]=1;Ue[144]=Ue[26]=0;Be[144]=Be[26]=1;ze[144]=ze[26]=1;Me[144]=Me[26]=-1;we[144]=we[26]=0;Se[144]=Se[26]=1;Ce[36]=Ce[134]=0;Pe[36]=Pe[134]=1;Ie[36]=Ie[134]=1;Oe[36]=Oe[134]=0;De[36]=De[134]=1;Fe[36]=Fe[134]=0;_e[36]=_e[134]=0;xe[36]=xe[134]=-1;Ee[36]=Ee[134]=1;Me[36]=Me[134]=1;we[36]=we[134]=0;Se[36]=Se[134]=0;be[9]=be[161]=-1;Ae[9]=Ae[161]=0;Te[9]=Te[161]=0;Ce[9]=Ce[161]=0;Pe[9]=Pe[161]=-1;Ie[9]=Ie[161]=0;Re[9]=Re[161]=1;Le[9]=Le[161]=0;Ne[9]=Ne[161]=0;ke[9]=ke[161]=1;Ge[9]=Ge[161]=0;Ve[9]=Ve[161]=1;be[136]=0;Ae[136]=1;Te[136]=1;Ce[136]=0;Pe[136]=1;Ie[136]=0;Oe[136]=-1;De[136]=0;Fe[136]=1;Re[136]=-1;Le[136]=0;Ne[136]=0;ke[136]=0;Ge[136]=-1;Ve[136]=0;Ue[136]=0;Be[136]=-1;ze[136]=1;_e[136]=1;xe[136]=0;Ee[136]=0;Me[136]=1;we[136]=0;Se[136]=1;be[34]=0;Ae[34]=-1;Te[34]=0;Ce[34]=0;Pe[34]=-1;Ie[34]=1;Oe[34]=1;De[34]=0;Fe[34]=0;Re[34]=1;Le[34]=0;Ne[34]=1;ke[34]=0;Ge[34]=1;Ve[34]=1;Ue[34]=0;Be[34]=1;ze[34]=0;_e[34]=-1;xe[34]=0;Ee[34]=1;Me[34]=-1;we[34]=0;Se[34]=0;be[35]=0;Ae[35]=1;Te[35]=1;Ce[35]=0;Pe[35]=-1;Ie[35]=1;Oe[35]=1;De[35]=0;Fe[35]=0;Re[35]=-1;Le[35]=0;Ne[35]=0;ke[35]=0;Ge[35]=-1;Ve[35]=0;Ue[35]=0;Be[35]=1;ze[35]=0;_e[35]=-1;xe[35]=0;Ee[35]=1;Me[35]=1;we[35]=0;Se[35]=1;be[153]=0;Ae[153]=1;Te[153]=1;Re[153]=-1;Le[153]=0;Ne[153]=0;ke[153]=0;Ge[153]=-1;Ve[153]=0;Me[153]=1;we[153]=0;Se[153]=1;Ce[102]=0;Pe[102]=-1;Ie[102]=1;Oe[102]=1;De[102]=0;Fe[102]=0;Ue[102]=0;Be[102]=1;ze[102]=0;_e[102]=-1;xe[102]=0;Ee[102]=1;be[155]=0;Ae[155]=-1;Te[155]=0;Re[155]=1;Le[155]=0;Ne[155]=1;ke[155]=0;Ge[155]=1;Ve[155]=1;Me[155]=-1;we[155]=0;Se[155]=0;Ce[103]=0;Pe[103]=1;Ie[103]=0;Oe[103]=-1;De[103]=0;Fe[103]=1;Ue[103]=0;Be[103]=-1;ze[103]=1;_e[103]=1;xe[103]=0;Ee[103]=0;be[152]=0;Ae[152]=1;Te[152]=1;Oe[152]=-1;De[152]=0;Fe[152]=1;Re[152]=-1;Le[152]=0;Ne[152]=0;ke[152]=0;Ge[152]=-1;Ve[152]=0;Ue[152]=0;Be[152]=-1;ze[152]=1;Me[152]=1;we[152]=0;Se[152]=1;be[156]=0;Ae[156]=-1;Te[156]=1;Oe[156]=1;De[156]=0;Fe[156]=1;Re[156]=-1;Le[156]=0;Ne[156]=0;ke[156]=0;Ge[156]=-1;Ve[156]=0;Ue[156]=0;Be[156]=1;ze[156]=1;Me[156]=-1;we[156]=0;Se[156]=1;be[137]=0;Ae[137]=1;Te[137]=1;Ce[137]=0;Pe[137]=1;Ie[137]=0;Re[137]=-1;Le[137]=0;Ne[137]=0;ke[137]=0;Ge[137]=-1;Ve[137]=0;_e[137]=1;xe[137]=0;Ee[137]=0;Me[137]=1;we[137]=0;Se[137]=1;be[139]=0;Ae[139]=1;Te[139]=1;Ce[139]=0;Pe[139]=-1;Ie[139]=0;Re[139]=1;Le[139]=0;Ne[139]=0;ke[139]=0;Ge[139]=1;Ve[139]=0;_e[139]=-1;xe[139]=0;Ee[139]=0;Me[139]=1;we[139]=0;Se[139]=1;be[98]=0;Ae[98]=-1;Te[98]=0;Ce[98]=0;Pe[98]=-1;Ie[98]=1;Oe[98]=1;De[98]=0;Fe[98]=0;Re[98]=1;Le[98]=0;Ne[98]=1;Ue[98]=0;Be[98]=1;ze[98]=0;_e[98]=-1;xe[98]=0;Ee[98]=1;be[99]=0;Ae[99]=1;Te[99]=0;Ce[99]=0;Pe[99]=-1;Ie[99]=1;Oe[99]=1;De[99]=0;Fe[99]=0;Re[99]=-1;Le[99]=0;Ne[99]=1;Ue[99]=0;Be[99]=-1;ze[99]=0;_e[99]=1;xe[99]=0;Ee[99]=1;Ce[38]=0;Pe[38]=-1;Ie[38]=1;Oe[38]=1;De[38]=0;Fe[38]=0;ke[38]=0;Ge[38]=1;Ve[38]=1;Ue[38]=0;Be[38]=1;ze[38]=0;_e[38]=-1;xe[38]=0;Ee[38]=1;Me[38]=-1;we[38]=0;Se[38]=0;Ce[39]=0;Pe[39]=1;Ie[39]=1;Oe[39]=-1;De[39]=0;Fe[39]=0;ke[39]=0;Ge[39]=-1;Ve[39]=1;Ue[39]=0;Be[39]=1;ze[39]=0;_e[39]=-1;xe[39]=0;Ee[39]=1;Me[39]=1;we[39]=0;Se[39]=0;var pd=function(r){return[[r.bottomleft,0],[0,0],[0,r.leftbottom]]},dd=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0]]},md=function(r){return[[r.topright,1],[1,1],[1,r.righttop]]},gd=function(r){return[[0,r.lefttop],[0,1],[r.topleft,1]]},yd=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop]]},vd=function(r){return[[r.bottomright,0],[r.bottomleft,0],[1,r.righttop],[1,r.rightbottom]]},_d=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.topleft,1],[r.topright,1]]},xd=function(r){return[[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},xP=function(r){return[[0,0],[0,r.leftbottom],[1,r.rightbottom],[1,0]]},EP=function(r){return[[1,0],[r.bottomright,0],[r.topright,1],[1,1]]},MP=function(r){return[[1,1],[1,r.righttop],[0,r.lefttop],[0,1]]},wP=function(r){return[[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},SP=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.leftbottom],[0,r.lefttop]]},bP=function(r){return[[r.topleft,1],[r.topright,1],[r.bottomright,0],[r.bottomleft,0]]},AP=function(){return[[0,0],[0,1],[1,1],[1,0]]},TP=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,1],[r.topleft,1]]},CP=function(r){return[[r.topright,1],[1,1],[1,0],[0,0],[0,r.leftbottom]]},PP=function(r){return[[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[1,1]]},IP=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,1]]},RP=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.lefttop],[0,1],[r.topleft,1]]},LP=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[r.topright,1]]},NP=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop]]},OP=function(r){return[[r.topright,1],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1]]},DP=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},FP=function(r){return[[1,1],[1,r.righttop],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},UP=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[r.topleft,1],[r.topright,1]]},BP=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom]]},zP=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},kP=function(r){return[[1,1],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},GP=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1]]},VP=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},HP=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},WP=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},qP=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]]},XP=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},YP=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},$P=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},ZP=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},JP=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},KP=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},qe=[],Xe=[],Ye=[],$e=[],Ze=[],Je=[],Ke=[],Qe=[];$e[1]=Ze[1]=18;$e[169]=Ze[169]=18;Ye[4]=Xe[4]=12;Ye[166]=Xe[166]=12;qe[16]=Qe[16]=4;qe[154]=Qe[154]=4;Je[64]=Ke[64]=22;Je[106]=Ke[106]=22;Ye[2]=Je[2]=17;$e[2]=Ze[2]=18;Ye[168]=Je[168]=17;$e[168]=Ze[168]=18;qe[8]=$e[8]=9;Xe[8]=Ye[8]=12;qe[162]=$e[162]=9;Xe[162]=Ye[162]=12;qe[32]=Qe[32]=4;Xe[32]=Ke[32]=1;qe[138]=Qe[138]=4;Xe[138]=Ke[138]=1;Ze[128]=Qe[128]=21;Je[128]=Ke[128]=22;Ze[42]=Qe[42]=21;Je[42]=Ke[42]=22;Xe[5]=Ze[5]=14;Xe[165]=Ze[165]=14;Ye[20]=Qe[20]=6;Ye[150]=Qe[150]=6;qe[80]=Je[80]=11;qe[90]=Je[90]=11;$e[65]=Ke[65]=3;$e[105]=Ke[105]=3;qe[160]=Je[160]=11;Xe[160]=Ze[160]=14;qe[10]=Je[10]=11;Xe[10]=Ze[10]=14;Ye[130]=Qe[130]=6;$e[130]=Ke[130]=3;Ye[40]=Qe[40]=6;$e[40]=Ke[40]=3;Xe[101]=Ke[101]=1;Xe[69]=Ke[69]=1;Ze[149]=Qe[149]=21;Ze[21]=Qe[21]=21;Ye[86]=Je[86]=17;Ye[84]=Je[84]=17;qe[89]=$e[89]=9;qe[81]=$e[81]=9;qe[96]=Ke[96]=0;Xe[96]=Je[96]=15;qe[74]=Ke[74]=0;Xe[74]=Je[74]=15;qe[24]=Ye[24]=8;$e[24]=Qe[24]=7;qe[146]=Ye[146]=8;$e[146]=Qe[146]=7;Xe[6]=Je[6]=15;Ye[6]=Ze[6]=16;Xe[164]=Je[164]=15;Ye[164]=Ze[164]=16;$e[129]=Qe[129]=7;Ze[129]=Ke[129]=20;$e[41]=Qe[41]=7;Ze[41]=Ke[41]=20;Ye[66]=Ke[66]=2;$e[66]=Je[66]=19;Ye[104]=Ke[104]=2;$e[104]=Je[104]=19;qe[144]=Ze[144]=10;Je[144]=Qe[144]=23;qe[26]=Ze[26]=10;Je[26]=Qe[26]=23;Xe[36]=Qe[36]=5;Ye[36]=Ke[36]=2;Xe[134]=Qe[134]=5;Ye[134]=Ke[134]=2;qe[9]=Ze[9]=10;Xe[9]=$e[9]=13;qe[161]=Ze[161]=10;Xe[161]=$e[161]=13;Xe[37]=Qe[37]=5;Ze[37]=Ke[37]=20;Xe[133]=Qe[133]=5;Ze[133]=Ke[133]=20;Ye[148]=Ze[148]=16;Je[148]=Qe[148]=23;Ye[22]=Ze[22]=16;Je[22]=Qe[22]=23;qe[82]=Ye[82]=8;$e[82]=Je[82]=19;qe[88]=Ye[88]=8;$e[88]=Je[88]=19;qe[73]=Ke[73]=0;Xe[73]=$e[73]=13;qe[97]=Ke[97]=0;Xe[97]=$e[97]=13;qe[145]=$e[145]=9;Ze[145]=Qe[145]=21;qe[25]=$e[25]=9;Ze[25]=Qe[25]=21;Xe[70]=Ke[70]=1;Ye[70]=Je[70]=17;Xe[100]=Ke[100]=1;Ye[100]=Je[100]=17;qe[34]=$e[34]=9;Xe[34]=Ye[34]=12;Ze[34]=Qe[34]=21;Je[34]=Ke[34]=22;qe[136]=Qe[136]=4;Xe[136]=Ke[136]=1;Ye[136]=Je[136]=17;$e[136]=Ze[136]=18;qe[35]=Qe[35]=4;Xe[35]=Ye[35]=12;$e[35]=Ze[35]=18;Je[35]=Ke[35]=22;qe[153]=Qe[153]=4;$e[153]=Ze[153]=18;Xe[102]=Ye[102]=12;Je[102]=Ke[102]=22;qe[155]=$e[155]=9;Ze[155]=Qe[155]=23;Xe[103]=Ke[103]=1;Ye[103]=Je[103]=17;qe[152]=Qe[152]=4;Ye[152]=Je[152]=17;$e[152]=Ze[152]=18;qe[156]=Ye[156]=8;$e[156]=Ze[156]=18;Je[156]=Qe[156]=23;qe[137]=Qe[137]=4;Xe[137]=Ke[137]=1;$e[137]=Ze[137]=18;qe[139]=Qe[139]=4;Xe[139]=$e[139]=13;Ze[139]=Ke[139]=20;qe[98]=$e[98]=9;Xe[98]=Ye[98]=12;Je[98]=Ke[98]=22;qe[99]=Ke[99]=0;Xe[99]=Ye[99]=12;$e[99]=Je[99]=19;Xe[38]=Ye[38]=12;Ze[38]=Qe[38]=21;Je[38]=Ke[38]=22;Xe[39]=Qe[39]=5;Ye[39]=Ze[39]=16;Je[39]=Ke[39]=22;var Nt=[];Nt[1]=Nt[169]=pd;Nt[4]=Nt[166]=dd;Nt[16]=Nt[154]=md;Nt[64]=Nt[106]=gd;Nt[168]=Nt[2]=yd;Nt[162]=Nt[8]=vd;Nt[138]=Nt[32]=_d;Nt[42]=Nt[128]=xd;Nt[5]=Nt[165]=xP;Nt[20]=Nt[150]=EP;Nt[80]=Nt[90]=MP;Nt[65]=Nt[105]=wP;Nt[160]=Nt[10]=SP;Nt[130]=Nt[40]=bP;Nt[85]=AP;Nt[101]=Nt[69]=TP;Nt[149]=Nt[21]=CP;Nt[86]=Nt[84]=PP;Nt[89]=Nt[81]=IP;Nt[96]=Nt[74]=RP;Nt[24]=Nt[146]=LP;Nt[6]=Nt[164]=NP;Nt[129]=Nt[41]=OP;Nt[66]=Nt[104]=DP;Nt[144]=Nt[26]=FP;Nt[36]=Nt[134]=UP;Nt[9]=Nt[161]=BP;Nt[37]=Nt[133]=zP;Nt[148]=Nt[22]=kP;Nt[82]=Nt[88]=GP;Nt[73]=Nt[97]=VP;Nt[145]=Nt[25]=HP;Nt[70]=Nt[100]=WP;Nt[34]=function(r){return[xd(r),vd(r)]};Nt[35]=qP;Nt[136]=function(r){return[_d(r),yd(r)]};Nt[153]=function(r){return[md(r),pd(r)]};Nt[102]=function(r){return[dd(r),gd(r)]};Nt[155]=XP;Nt[103]=YP;Nt[152]=function(r){return[md(r),yd(r)]};Nt[156]=$P;Nt[137]=function(r){return[_d(r),pd(r)]};Nt[139]=ZP;Nt[98]=function(r){return[vd(r),gd(r)]};Nt[99]=JP;Nt[38]=function(r){return[dd(r),xd(r)]};Nt[39]=KP;function jP(r){return(r>0)-(r<0)||+r}function yu(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 jP(o*h-l*a)}function m_(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 Ed(r,t){return t.geometry.coordinates[0].every(function(e){return Er(wn(e),r)})}function g_(r,t){return r[0]===t[0]&&r[1]===t[1]}var tI=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=yu(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}(),Md=tI;var eI=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 xr([this.from.coordinates,this.to.coordinates])},r.prototype.compareTo=function(t){return yu(t.from.coordinates,t.to.coordinates,this.to.coordinates)},r}(),y_=eI;var nI=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=yu(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 op(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=Nn([t])},r.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=Sp(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()),!m_(f,o)&&Ed(f,o)){for(var p=t.map(function(A){return A.from.coordinates}),d=void 0,g=function(A){h.some(function(I){return g_(A,I.from.coordinates)})||(d=A)},x=0,_=p;x<_.length;x++){var M=_[x];g(M)}d&&h.inside(wn(d))&&(!l||Ed(a,f))&&(l=h)}}),l},r.prototype.inside=function(t){return Er(t,this.toPolygon())},r}(),wd=nI;function rI(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 AB=function(){function r(){this.edges=[],this.nodes={}}return r.fromGeoJson=function(t){rI(t);var e=new r;return bi(t,function(o){ap(o,"LineString","Graph::fromGeoJson"),w0(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=Md.buildId(t),o=this.nodes[e];return o||(o=this.nodes[e]=new Md(t)),o},r.prototype.addEdge=function(t,e){var o=new y_(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 wd;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 aI=Dn(Sd(),1);var uI=Dn(Sd(),1);var cI=Dn(A_(),1);var yI=Dn(F_(),1);function B_(r){for(var t=r,e=[];t.parent;)e.unshift(t),t=t.parent;return e}function _I(){return new z_(function(r){return r.f})}var Cd={search:function(r,t,e,o){r.cleanDirty(),o=o||{};var a=o.heuristic||Cd.heuristics.manhattan,l=o.closest||!1,h=_I(),f=t;for(t.h=a(t,e),h.push(t);h.size()>0;){var p=h.pop();if(p===e)return B_(p);p.closed=!0;for(var d=r.neighbors(p),g=0,x=d.length;g<x;++g){var _=d[g];if(!(_.closed||_.isWall())){var M=p.g+_.getCost(p),A=_.visited;(!A||M<_.g)&&(_.visited=!0,_.parent=p,_.h=_.h||a(_,e),_.g=M,_.f=_.g+_.h,r.markDirty(_),l&&(_.h<f.h||_.h===f.h&&_.g<f.g)&&(f=_),A?h.rescoreElement(_):h.push(_))}}}return l?B_(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 ml(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 ah(e,o,a[o]);this.grid[e][o]=l,this.nodes.push(l)}}this.init()}ml.prototype.init=function(){this.dirtyNodes=[];for(var r=0;r<this.nodes.length;r++)Cd.cleanNode(this.nodes[r])};ml.prototype.cleanDirty=function(){for(var r=0;r<this.dirtyNodes.length;r++)Cd.cleanNode(this.dirtyNodes[r]);this.dirtyNodes=[]};ml.prototype.markDirty=function(r){this.dirtyNodes.push(r)};ml.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};ml.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(\`
|
|
7736
7736
|
\`)};function ah(r,t,e){this.x=r,this.y=t,this.weight=e}ah.prototype.toString=function(){return"["+this.x+" "+this.y+"]"};ah.prototype.getCost=function(r){return r&&r.x!==this.x&&r.y!==this.y?this.weight*1.41421:this.weight};ah.prototype.isWall=function(){return this.weight===0};function z_(r){this.content=[],this.scoreFunction=r}z_.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 Pd(){this._=null}function _u(r){r.U=r.C=r.L=r.R=r.P=r.N=null}Pd.prototype={constructor:Pd,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=k_(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&&(gl(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,gl(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=k_(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,gl(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,gl(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,gl(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 gl(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 k_(r){for(;r.L;)r=r.L;return r}var Id=Pd;function xu(r,t,e,o){var a=[null,null],l=wr.push(a)-1;return a.left=r,a.right=t,e&&vl(a,r,t,e),o&&vl(a,t,r,o),ii[r.index].halfedges.push(l),ii[t.index].halfedges.push(l),a}function Eu(r,t,e){var o=[t,e];return o.left=r,o}function vl(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 xI(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,_=1,M=d-f,A=g-p,I;if(I=t-f,!(!M&&I>0)){if(I/=M,M<0){if(I<x)return;I<_&&(_=I)}else if(M>0){if(I>_)return;I>x&&(x=I)}if(I=o-f,!(!M&&I<0)){if(I/=M,M<0){if(I>_)return;I>x&&(x=I)}else if(M>0){if(I<x)return;I<_&&(_=I)}if(I=e-p,!(!A&&I>0)){if(I/=A,A<0){if(I<x)return;I<_&&(_=I)}else if(A>0){if(I>_)return;I>x&&(x=I)}if(I=a-p,!(!A&&I<0)){if(I/=A,A<0){if(I>_)return;I>x&&(x=I)}else if(A>0){if(I<x)return;I<_&&(_=I)}return!(x>0)&&!(_<1)||(x>0&&(r[0]=[f+x*M,p+x*A]),_<1&&(r[1]=[f+_*M,p+_*A])),!0}}}}}function EI(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],_=p[1],M=(d+x)/2,A=(g+_)/2,I,v;if(_===g){if(M<t||M>=o)return;if(d>x){if(!h)h=[M,e];else if(h[1]>=a)return;l=[M,a]}else{if(!h)h=[M,a];else if(h[1]<e)return;l=[M,e]}}else if(I=(d-x)/(_-g),v=A-I*M,I<-1||I>1)if(d>x){if(!h)h=[(e-v)/I,e];else if(h[1]>=a)return;l=[(a-v)/I,a]}else{if(!h)h=[(a-v)/I,a];else if(h[1]<e)return;l=[(e-v)/I,e]}else if(g<_){if(!h)h=[t,I*t+v];else if(h[0]>=o)return;l=[o,I*o+v]}else{if(!h)h=[o,I*o+v];else if(h[0]<t)return;l=[t,I*t+v]}return r[0]=h,r[1]=l,!0}function G_(r,t,e,o){for(var a=wr.length,l;a--;)(!EI(l=wr[a],r,t,e,o)||!xI(l,r,t,e,o)||!(Math.abs(l[0][0]-l[1][0])>xn||Math.abs(l[0][1]-l[1][1])>xn))&&delete wr[a]}function V_(r){return ii[r.index]={site:r,halfedges:[]}}function MI(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 Rd(r,t){return t[+(t.left!==r.site)]}function wI(r,t){return t[+(t.left===r.site)]}function H_(){for(var r=0,t=ii.length,e,o,a,l;r<t;++r)if((e=ii[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]=MI(e,wr[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 W_(r,t,e,o){var a=ii.length,l,h,f,p,d,g,x,_,M,A,I,v,y=!0;for(l=0;l<a;++l)if(h=ii[l]){for(f=h.site,d=h.halfedges,p=d.length;p--;)wr[d[p]]||d.splice(p,1);for(p=0,g=d.length;p<g;)A=wI(h,wr[d[p]]),I=A[0],v=A[1],x=Rd(h,wr[d[++p%g]]),_=x[0],M=x[1],(Math.abs(I-_)>xn||Math.abs(v-M)>xn)&&(d.splice(p,0,wr.push(Eu(f,A,Math.abs(I-r)<xn&&o-v>xn?[r,Math.abs(_-r)<xn?M:o]:Math.abs(v-o)<xn&&e-I>xn?[Math.abs(M-o)<xn?_:e,o]:Math.abs(I-e)<xn&&v-t>xn?[e,Math.abs(_-e)<xn?M:t]:Math.abs(v-t)<xn&&I-r>xn?[Math.abs(M-t)<xn?_:r,t]:null))-1),++g);g&&(y=!1)}if(y){var P,w,D,B=1/0;for(l=0,y=null;l<a;++l)(h=ii[l])&&(f=h.site,P=f[0]-r,w=f[1]-t,D=P*P+w*w,D<B&&(B=D,y=h));if(y){var z=[r,t],U=[r,o],R=[e,o],nt=[e,t];y.halfedges.push(wr.push(Eu(f=y.site,z,U))-1,wr.push(Eu(f,U,R))-1,wr.push(Eu(f,R,nt))-1,wr.push(Eu(f,nt,z))-1)}}for(l=0;l<a;++l)(h=ii[l])&&(h.halfedges.length||delete ii[l])}var q_=[],uh;function SI(){_u(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,_=2*(p*x-d*g);if(!(_>=-X_)){var M=p*p+d*d,A=g*g+x*x,I=(x*M-d*A)/_,v=(p*A-g*M)/_,y=q_.pop()||new SI;y.arc=r,y.site=a,y.x=I+h,y.y=(y.cy=v+f)+Math.sqrt(I*I+v*v),r.circle=y;for(var P=null,w=Mu._;w;)if(y.y<w.y||y.y===w.y&&y.x<=w.x)if(w.L)w=w.L;else{P=w.P;break}else if(w.R)w=w.R;else{P=w;break}Mu.insert(P,y),P||(uh=y)}}}}function aa(r){var t=r.circle;t&&(t.P||(uh=t.N),Mu.remove(t),q_.push(t),_u(t),r.circle=null)}var $_=[];function bI(){_u(this),this.edge=this.site=this.circle=null}function Y_(r){var t=$_.pop()||new bI;return t.site=r,t}function Ld(r){aa(r),ua.remove(r),$_.push(r),_u(r)}function Z_(r){var t=r.circle,e=t.x,o=t.cy,a=[e,o],l=r.P,h=r.N,f=[r];Ld(r);for(var p=l;p.circle&&Math.abs(e-p.circle.x)<xn&&Math.abs(o-p.circle.cy)<xn;)l=p.P,f.unshift(p),Ld(p),p=l;f.unshift(p),aa(p);for(var d=h;d.circle&&Math.abs(e-d.circle.x)<xn&&Math.abs(o-d.circle.cy)<xn;)h=d.N,f.push(d),Ld(d),d=h;f.push(d),aa(d);var g=f.length,x;for(x=1;x<g;++x)d=f[x],p=f[x-1],vl(d.edge,p.site,d.site,a);p=f[0],d=f[g-1],d.edge=xu(p.site,d.site,null,a),sa(p),sa(d)}function J_(r){for(var t=r[0],e=r[1],o,a,l,h,f=ua._;f;)if(l=K_(f,e)-t,l>xn)f=f.L;else if(h=t-AI(f,e),h>xn){if(!f.R){o=f;break}f=f.R}else{l>-xn?(o=f.P,a=f):h>-xn?(o=f,a=f.N):o=a=f;break}V_(r);var p=Y_(r);if(ua.insert(o,p),!(!o&&!a)){if(o===a){aa(o),a=Y_(o.site),ua.insert(p,a),p.edge=a.edge=xu(o.site,p.site),sa(o),sa(a);return}if(!a){p.edge=xu(o.site,p.site);return}aa(o),aa(a);var d=o.site,g=d[0],x=d[1],_=r[0]-g,M=r[1]-x,A=a.site,I=A[0]-g,v=A[1]-x,y=2*(_*v-M*I),P=_*_+M*M,w=I*I+v*v,D=[(v*P-M*w)/y+g,(_*w-I*P)/y+x];vl(a.edge,d,A,D),p.edge=xu(d,r,null,D),a.edge=xu(r,A,null,D),sa(o),sa(a)}}function K_(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,_=g/d;return x?(-_+Math.sqrt(_*_-2*x*(g*g/(-2*d)-p+d/2+a-l/2)))/x+o:(o+f)/2}function AI(r,t){var e=r.N;if(e)return K_(e,t);var o=r.site;return o[1]===t?o[0]:1/0}var xn=1e-6,X_=1e-12,ua,ii,Mu,wr;function TI(r,t,e){return(r[0]-e[0])*(t[1]-r[1])-(r[0]-t[0])*(e[1]-r[1])}function CI(r,t){return t[1]-r[1]||t[0]-r[0]}function lh(r,t){var e=r.sort(CI).pop(),o,a,l;for(wr=[],ii=new Array(r.length),ua=new Id,Mu=new Id;;)if(l=uh,e&&(!l||e[1]<l.y||e[1]===l.y&&e[0]<l.x))(e[0]!==o||e[1]!==a)&&(J_(e),o=e[0],a=e[1]),e=r.pop();else if(l)Z_(l.arc);else break;if(H_(),t){var h=+t[0][0],f=+t[0][1],p=+t[1][0],d=+t[1][1];G_(h,f,p,d),W_(h,f,p,d)}this.edges=wr,this.cells=ii,ua=Mu=wr=ii=null}lh.prototype={constructor:lh,polygons:function(){var r=this.edges;return this.cells.map(function(t){var e=t.halfedges.map(function(o){return Rd(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&&TI(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 _=o.edges[x],M=_.left;if(!((M===f.site||!M)&&!(M=_.right))){var A=r-M[0],I=t-M[1],v=A*A+I*I;v<g&&(g=v,l=M.index)}});while(l!==null);return o._found=a,e==null||g<=e*e?f.site:null}};var FI=Dn(wu(),1);var Yd=Dn(e1(),1);function pi(){return new fh}function fh(){this.reset()}fh.prototype={constructor:fh,reset:function(){this.s=this.t=0},add:function(r){n1(hh,r,this.t),n1(this,hh.s,this.s),this.s?this.t+=hh.t:this.s=hh.t},valueOf:function(){return this.s}};var hh=new fh;function n1(r,t,e){var o=r.s=t+e,a=o-t,l=o-a;r.t=t-l+(e-a)}var cn=1e-6;var vn=Math.PI,sr=vn/2,ph=vn/4,Eo=vn*2,la=180/vn,di=vn/180,zn=Math.abs,ro=Math.atan,mi=Math.atan2,on=Math.cos;var dh=Math.exp;var _l=Math.log;var ve=Math.sin;var Nr=Math.sqrt,xl=Math.tan;function Dd(r){return r>1?0:r<-1?vn:Math.acos(r)}function oi(r){return r>1?sr:r<-1?-sr:Math.asin(r)}function io(){}var UI=pi(),xG=pi();function ca(r){var t=r[0],e=r[1],o=on(e);return[o*on(t),o*ve(t),ve(e)]}function El(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 Ml(r){var t=Nr(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=t,r[1]/=t,r[2]/=t}var IG=pi();function i1(r,t){return[r>vn?r-Eo:r<-vn?r+Eo:r,t]}i1.invert=i1;function Fd(){var r=[],t;return{point:function(e,o){t.push([e,o])},lineStart:function(){r.push(t=[])},lineEnd:io,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var e=r;return r=[],t=null,e}}}function Ud(r,t){return zn(r[0]-t[0])<cn&&zn(r[1]-t[1])<cn}function mh(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 Bd(r,t,e,o,a){var l=[],h=[],f,p;if(r.forEach(function(A){if(!((I=A.length-1)<=0)){var I,v=A[0],y=A[I],P;if(Ud(v,y)){for(a.lineStart(),f=0;f<I;++f)a.point((v=A[f])[0],v[1]);a.lineEnd();return}l.push(P=new mh(v,A,null,!0)),h.push(P.o=new mh(v,null,P,!1)),l.push(P=new mh(y,A,null,!1)),h.push(P.o=new mh(y,null,P,!0))}}),!!l.length){for(h.sort(t),o1(l),o1(h),f=0,p=h.length;f<p;++f)h[f].e=e=!e;for(var d=l[0],g,x;;){for(var _=d,M=!0;_.v;)if((_=_.n)===d)return;g=_.z,a.lineStart();do{if(_.v=_.o.v=!0,_.e){if(M)for(f=0,p=g.length;f<p;++f)a.point((x=g[f])[0],x[1]);else o(_.x,_.n.x,1,a);_=_.n}else{if(M)for(g=_.p.z,f=g.length-1;f>=0;--f)a.point((x=g[f])[0],x[1]);else o(_.x,_.p.x,-1,a);_=_.p}_=_.o,g=_.z,M=!M}while(!_.v);a.lineEnd()}}}function o1(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 Ss(r,t){return r<t?-1:r>t?1:r>=t?0:NaN}function zd(r){return r.length===1&&(r=kI(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 kI(r){return function(t,e){return Ss(r(t),e)}}var s1=zd(Ss),GI=s1.right,VI=s1.left;var a1=Array.prototype,WI=a1.slice,qI=a1.map;var M4=Math.sqrt(50),w4=Math.sqrt(10),S4=Math.sqrt(2);function yh(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 jI=1e9,aV=-jI;var kd=pi();function Gd(r,t){var e=t[0],o=t[1],a=[ve(e),-on(e),0],l=0,h=0;kd.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],_=x[0],M=x[1]/2+ph,A=ve(M),I=on(M),v=0;v<g;++v,_=P,A=D,I=B,x=y){var y=d[v],P=y[0],w=y[1]/2+ph,D=ve(w),B=on(w),z=P-_,U=z>=0?1:-1,R=U*z,nt=R>vn,O=A*D;if(kd.add(mi(O*U*ve(R),I*B+O*on(R))),l+=nt?z+U*Eo:z,nt^_>=e^P>=e){var q=El(ca(x),ca(y));Ml(q);var G=El(a,q);Ml(G);var vt=(nt^z>=0?-1:1)*oi(G[2]);(o>vt||o===vt&&(q[0]||q[1]))&&(h+=nt^z>=0?1:-1)}}return(l<-cn||l<cn&&kd<-cn)^h&1}var yV=pi();var FV=pi(),UV=pi();var nR=1/0;var kV=-nR;function Vd(r){this._context=r}Vd.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,Eo);break}}},result:io};var JV=pi();function Hd(){this._string=[]}Hd.prototype={_radius:4.5,_circle:c1(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=c1(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 c1(r){return"m0,"+r+"a"+r+","+r+" 0 1,1 0,"+-2*r+"a"+r+","+r+" 0 1,1 0,"+2*r+"z"}function Wd(r,t,e,o){return function(a,l){var h=t(l),f=a.invert(o[0],o[1]),p=Fd(),d=t(p),g=!1,x,_,M,A={point:I,lineStart:y,lineEnd:P,polygonStart:function(){A.point=w,A.lineStart=D,A.lineEnd=B,_=[],x=[]},polygonEnd:function(){A.point=I,A.lineStart=y,A.lineEnd=P,_=yh(_);var z=Gd(x,f);_.length?(g||(l.polygonStart(),g=!0),Bd(_,oR,z,e,l)):z&&(g||(l.polygonStart(),g=!0),l.lineStart(),e(null,null,1,l),l.lineEnd()),g&&(l.polygonEnd(),g=!1),_=x=null},sphere:function(){l.polygonStart(),l.lineStart(),e(null,null,1,l),l.lineEnd(),l.polygonEnd()}};function I(z,U){var R=a(z,U);r(z=R[0],U=R[1])&&l.point(z,U)}function v(z,U){var R=a(z,U);h.point(R[0],R[1])}function y(){A.point=v,h.lineStart()}function P(){A.point=I,h.lineEnd()}function w(z,U){M.push([z,U]);var R=a(z,U);d.point(R[0],R[1])}function D(){d.lineStart(),M=[]}function B(){w(M[0][0],M[0][1]),d.lineEnd();var z=d.clean(),U=p.result(),R,nt=U.length,O,q,G;if(M.pop(),x.push(M),M=null,!!nt){if(z&1){if(q=U[0],(O=q.length-1)>0){for(g||(l.polygonStart(),g=!0),l.lineStart(),R=0;R<O;++R)l.point((G=q[R])[0],G[1]);l.lineEnd()}return}nt>1&&z&2&&U.push(U.pop().concat(U.shift())),_.push(U.filter(iR))}}return A}}function iR(r){return r.length>1}function oR(r,t){return((r=r.x)[0]<0?r[1]-sr-cn:sr-r[1])-((t=t.x)[0]<0?t[1]-sr-cn:sr-t[1])}var sR=Wd(function(){return!0},aR,lR,[-vn,-sr]);function aR(r){var t=NaN,e=NaN,o=NaN,a;return{lineStart:function(){r.lineStart(),a=1},point:function(l,h){var f=l>0?vn:-vn,p=zn(l-t);zn(p-vn)<cn?(r.point(t,e=(e+h)/2>0?sr:-sr),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(f,e),r.point(l,e),a=0):o!==f&&p>=vn&&(zn(t-o)<cn&&(t-=o*cn),zn(l-f)<cn&&(l-=f*cn),e=uR(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 uR(r,t,e,o){var a,l,h=ve(r-e);return zn(h)>cn?ro((ve(t)*(l=on(o))*ve(e)-ve(o)*(a=on(t))*ve(r))/(a*l*h)):(t+o)/2}function lR(r,t,e,o){var a;if(r==null)a=e*sr,o.point(-vn,a),o.point(0,a),o.point(vn,a),o.point(vn,0),o.point(vn,-a),o.point(0,-a),o.point(-vn,-a),o.point(-vn,0),o.point(-vn,a);else if(zn(r[0]-t[0])>cn){var l=r[0]<t[0]?vn:-vn;a=e*l/2,o.point(-l,a),o.point(0,a),o.point(l,a)}else o.point(t[0],t[1])}function vh(r){return function(t){var e=new qd;for(var o in r)e[o]=r[o];return e.stream=t,e}}function qd(){}qd.prototype={constructor:qd,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 UH=on(30*di);var KH=vh({point:function(r,t){this.stream.point(r*di,t*di)}});function _h(r){return function(t,e){var o=on(t),a=on(e),l=r(o*a);return[l*a*ve(t),l*ve(e)]}}function Mo(r){return function(t,e){var o=Nr(t*t+e*e),a=r(o),l=ve(a),h=on(a);return[mi(t*l,o*h),oi(o&&e*l/o)]}}var y1=_h(function(r){return Nr(2/(1+r))});y1.invert=Mo(function(r){return 2*oi(r/2)});var v1=_h(function(r){return(r=Dd(r))&&r/ve(r)});v1.invert=Mo(function(r){return r});function Xd(r,t){return[r,_l(xl((sr+t)/2))]}Xd.invert=function(r,t){return[r,2*ro(dh(t))-sr]};function xh(r,t){return[r,t]}xh.invert=xh;function _1(r,t){var e=on(t),o=on(r)*e;return[e*ve(r)/o,ve(t)/o]}_1.invert=Mo(ro);function x1(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)))]}x1.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(zn(a)>cn&&--o>0);return[r/(.8707+(l=e*e)*(-.131979+l*(-.013791+l*l*l*(.003971-.001529*l)))),e]};function E1(r,t){return[on(t)*ve(r),ve(t)]}E1.invert=Mo(oi);function M1(r,t){var e=on(t),o=1+on(r)*e;return[e*ve(r)/o,ve(t)/o]}M1.invert=Mo(function(r){return 2*ro(r)});function w1(r,t){return[_l(xl((sr+t)/2)),-r]}w1.invert=function(r,t){return[-t,2*ro(dh(r))-sr]};var mR=Dn(wu(),1);var gR=Dn(wu(),1);var vR=Dn(wu(),1);var _R=Dn(wu(),1);function As(r,t){return Math.sqrt((t[0]-r[0])**2+(t[1]-r[1])**2)}function $d(r){let t=0;for(let e=0;e<r.length-1;e++)t+=As(r[e],r[e+1]);return t}function b1(r,t,e){let o=new nn(t[0]-r[0],t[1]-r[1]),a=new nn(t[0]-e[0],t[1]-e[1]),h=o.angleTo(a)*180/Math.PI,f=new nn(t[0]-r[0],t[1]-r[1]);return new nn(e[0]-r[0],e[1]-r[1]).cross(f)>0?h:-h}var Ui="___",Eh=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(o=>{let a=\`\${e.floor}\${Ui}\${o.id}\`;if(this.pointMap.set(a,o),this.nodeMap.set(\`\${o.floor}\${Ui}\${o.nodeId}\`,a),o.type==="straightLadder"){let l=this.straightLadderMap.get(o.name)||[];l.push(ba({},o)),this.straightLadderMap.set(o.name,l)}if(o.type==="staircase"){let l=this.staircaseMap.get(o.name)||[];l.push(ba({},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(ba({},o)),this.facilityMap.set(o.targetId,l)}}),e.lines.filter(o=>o.direction!=="no").forEach(o=>{var a,l;let h=\`\${e.floor}\${Ui}\${o.from}\`,f=\`\${e.floor}\${Ui}\${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=As(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=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,h])=>{if(!(h.length<2))for(let d=0;d<h.length;d++){let g=\`\${h[d].floor}\${Ui}\${h[d].id}\`;for(let x=0;x<h.length;x++)if(d!==x){var f,p;let _=\`\${h[x].floor}\${Ui}\${h[x].id}\`,M=(f=this.pointMap.get(g))==null?void 0:f.cds,A=(p=this.pointMap.get(_))==null?void 0:p.cds;if(M!=null&&M.length&&(A!=null&&A.length))if(h[d].type==="straightLadder"){let I=e;this.addLineItem(g,_,I,a)}else{let I=o;this.addLineItem(g,_,I,a)}}}}),this.escalatorMap.forEach((l,h)=>{if(l.start&&l.end){var f,p;let d=\`\${l.start.floor}\${Ui}\${l.start.id}\`,g=\`\${l.end.floor}\${Ui}\${l.end.id}\`,x=(f=this.pointMap.get(d))==null?void 0:f.cds,_=(p=this.pointMap.get(g))==null?void 0:p.cds;if(x!=null&&x.length&&(_!=null&&_.length)){let M=t;this.addLineItem(d,g,M,a)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new wo.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 wo.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new wo.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}\${Ui}\${t.nodeId}\`);if(o){let[a,l]=o.split(Ui);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=As(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(!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((_,M)=>_+$d(M.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}\${Ui}\${t.id}\`,l=\`\${e.floor}\${Ui}\${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 _=f[f.length-1];_.points.push(d.cds),_.endType=d.type,_.destId=d.nodeId,_.distance=$d(_.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 wo.default,this.escalatorRoute=new wo.default,this.straightLadderRoute=new wo.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 wo.default,this.escalatorRoute=new wo.default,this.straightLadderRoute=new wo.default}};var CR=Dn(I1(),1);function PR(r,t,e){let o=b1(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 R1(r){if(!r.length)return[];if(r.length===1)return[{direction:"start",distance:0,points:r}];let t=[{direction:"start",distance:As(r[0],r[1]),points:[r[0],r[1]]}];for(let e=2;e<r.length;e++){let o=PR(r[e-2],r[e-1],r[e]);if(o==="front"){let a=t[t.length-1],l=As(r[e-1],r[e]);a.distance+=l,e!==2&&a.points.push(r[e-1])}else t.push({direction:o,distance:As(r[e-1],r[e]),points:[r[e-1],r[e]]})}return t.push({direction:"end",distance:0,points:[r[r.length-1]]}),t}function L1(r,t,e,o,a,l,h){try{var f=r[l](h),p=f.value}catch(d){e(d);return}f.done?t(p):Promise.resolve(p).then(o,a)}function N1(r){return function(){var t=this,e=arguments;return new Promise(function(o,a){var l=r.apply(t,e);function h(p){L1(l,o,a,h,f,"next",p)}function f(p){L1(l,o,a,h,f,"throw",p)}h(void 0)})}}function O1(r){return r.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function D1(r){let t={};for(let o in r)o.startsWith("on")&&(t[O1(o.slice(2))]=r[o]);let e=N1(function*({data:o}){if(t[o.type])try{let a=yield t[o.type](o.data);self.postMessage({type:\`\${o.type}_result\`,key:o.key,data:a})}catch(a){self.postMessage({type:\`\${o.type}_result\`,key:o.key,error:a})}else self.postMessage({type:\`\${o.type}_result\`,key:o.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}var Zd=new Eh;D1({onSetRoadInfo({roadData:r}){Zd.initRoute(r)},onGetPath({start:r,end:t,type:e}){return Zd.getPath(r,t,e)},onGetDirectionPath(r){return R1(r)},onClear(){Zd.clear()}});
|
|
7737
|
-
`],{type:"text/javascript"}),t=URL.createObjectURL(a),n=new Worker(t);return URL.revokeObjectURL(t),n}var Ri=class extends To.EventDispatcher{setRoadData(t){var n=this;return g(function*(){n.initRoadStatus=!1,n.dispatchEvent({type:"init-road-status",status:!1}),yield Pt(n.worker,"set_road_info",{roadData:t}),n.initRoadStatus=!0,n.dispatchEvent({type:"init-road-status",status:!0})})()}getPath(t,n,e=""){var i=this;return g(function*(){return new Promise((r,o)=>{let s=()=>{Pt(i.worker,"get_path",{start:t,end:n,type:e}).then(u=>{u?typeof u=="string"?o(u):r(u):o("no-path")})};if(i.initRoadStatus)s();else{let u=({status:l})=>{l&&(i.removeEventListener("init-road-status",u),s())};i.addEventListener("init-road-status",u)}})})()}getDirectionPath(t){return Pt(this.worker,"get_direction_path",t)}dispose(){var t=this;return g(function*(){Pt(t.worker,"clear",""),t.worker.terminate()})()}constructor(){super(),this.worker=Ii(),this.initRoadStatus=!1}};var Io=require("three"),Pn=class extends gt{setEnable(t){super.setEnable(t),Z(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:n,container:{clientWidth:e,clientHeight:i}}}=this,r=A(this.startPoint,n,e,i),o=A(this.endPoint,n,e,i),s={x:Math.min(r.x,o.x),y:Math.min(r.y,o.y)},u={x:Math.max(r.x,o.x),y:Math.max(r.y,o.y)},l=this.searchMapInFrustum(s,u);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,n){var e;let{context:i}=this;return((e=i.currentFloor)==null?void 0:e.graphicLayer.children.filter(r=>r instanceof H&&this.searchChildInFrustum(r,t,n)))||[]}searchChildInFrustum(t,n,e){let{context:{camera:i,container:{clientWidth:r,clientHeight:o}}}=this;if(!t)return!1;if(!t.mesh){let h=t.getPosition();if(h){let f=A(h,i,r,o);return Ht(f,n,e)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let s=t.mesh.geometry.boundingBox;if(!s)return!1;let{min:u,max:l}=s,c=A(u,i,r,o),p=A(l,i,r,o);return!(!Ht(c,n,e)||!Ht(p,n,e))}dispose(){this.unRegistryEvent()}constructor(t){super(t),this.frustum=new Io.Frustum,this.onPointerDown=i=>{if(!this.enable)return;let r=this.getIntersectByPointerEvent(i);r&&(this.startPoint=r),this.endPoint=void 0},this.onPointerMove=i=>{if(!this.enable||!this.startPoint)return;let r=this.getIntersectByPointerEvent(i);r&&(this.endPoint=r)},this.onPointerUp=i=>{if(!this.enable)return;let r=this.getIntersectByPointerEvent(i);r&&(this.endPoint=r),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let i=this.getSvgCoordinate(this.startPoint),r=v({},i);this.endPoint&&(r=this.getSvgCoordinate(this.endPoint));let o={x:Math.min(i.x,r.x),y:Math.min(i.y,r.y)},s=Math.abs(r.x-i.x),u=Math.abs(r.y-i.y);Z(this.rect,o.x,o.y,s,u)}else Z(this.rect,0,0,0,0)};let{config:{selectBox:{fill:n,stroke:e}}}=t;this.rect=Xt(e,n),this.svg.appendChild(this.rect),this.registryEvent()}};var Hs={boxSelection:!1,elements:["graphic","poi"]},Pi=class extends Mt{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()}constructor(t,n={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=e=>{this.downPoint={x:e.offsetX,y:e.offsetY}},this.onPointerUp=e=>{if(!this.downPoint)return;let{offsetX:i,offsetY:r}=e,{x:o,y:s}=this.downPoint;if(Math.sqrt((o-i)**2+(s-r)**2)>3)return;let u=new Set,l=[],c=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(i,r);p.map(h=>u.add(h.options.id)),l.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(i,r);c.push(...p),p.forEach(h=>{if(!u.has(h.options.id)){var f;let m=((f=this.bmap.context.currentFloor)==null?void 0:f.graphicLayer.graphicMap.get(h.options.id))||null;m&&(u.add(h.options.id),l.push(m))}})}(!this.options.boxSelection||!(re?e.metaKey:e.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=e=>{this.disableBoxSelection()},this.onKeyDown=e=>{oe(e.key)&&this.enableBoxSelection()},this.onKeyUp=e=>{oe(e.key)&&this.disableBoxSelection()},this.onBoxSelected=({list:e})=>{this._list.clear(),this._poiList.clear(),e.forEach(i=>{if(this.options.elements.includes("graphic")&&this._list.add(i),this.options.elements.includes("poi")){let r=this.bmap.getPoiById(i.options.id);r&&this._poiList.add(r)}}),this.selectEnd()},this.options=v({},Hs,n),this.boxSelection=new Pn(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var ut=require("lodash");var Ro=require("three");var O=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var Vs={time:1e3,elements:[O.COMPASS,O.DEVICE_MOTION,O.ACCELERATION,O.GPS]},en=class extends Ro.EventDispatcher{start(){this.options.elements.some(t=>[O.DEVICE_MOTION,O.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(O.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(O.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,ut.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){It?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:O.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(){var t=this;return g(function*(){return{deviceOrientation:yield t.checkDeviceOrientation()}})()}checkDeviceOrientation(){return g(function*(){var t;if(!It)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var n;return(yield(n=window.DeviceOrientationEvent)==null?void 0:n.requestPermission())==="granted"}catch(e){return!1}return!1})()}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),It?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,ut.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 G,this.dispatchTimer=null,this.addAcceleration=(0,ut.throttle)(n=>{this.addDataItem(n)},20),this.deviceOrientationAbsHandler=(0,ut.throttle)(n=>{let e=Date.now(),{alpha:i,beta:r,gamma:o}=n;if((0,ut.isNil)(i)||(0,ut.isNil)(r)||(0,ut.isNil)(o))return;let s;It?s=n.webkitCompassHeading:s=360-i,this.options.elements.includes(O.DEVICE_MOTION)&&this.addDataItem({type:O.DEVICE_MOTION,timestamp:e,res:[i,r,o]}),this.options.elements.includes(O.COMPASS)&&this.addDataItem({type:O.COMPASS,timestamp:e,res:s})},200),this.handleAcceleration=n=>{let e=n.accelerationIncludingGravity;(0,ut.isNil)(e)||(0,ut.isNil)(e.x)||(0,ut.isNil)(e.y)||(0,ut.isNil)(e.z)||this.addAcceleration({type:O.ACCELERATION,timestamp:Date.now(),res:[e.x,e.y,e.z]})},this.options=v({},Vs,t)}};var Lo=require("three");function Ln(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function nn(a){return(a+360)%360}function Po(a,t){let e=6378137*a*Math.PI/180,i=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:e,y:i}}function be(a,t,n,e){return Math.sqrt(Math.pow(Math.abs(a-n),2)+Math.pow(Math.abs(t-e),2))}var Nn=require("mathjs"),Bn=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=nn(this.last_yaw_compass+t);for(let n=0;n<this.NumParticle;n++){let e=Math.random()*this.yaw_noise_sigma;this.particleX[2][n]=this.particleX[2][n]+t+e,this.particleX[2][n]=nn(this.particleX[2][n])}}}motionModelStepLength(t,n){if(t===0)return;for(let i=0;i<this.NumParticle;i++){let r=Math.random()*this.step_noise_sigma;this.particleX[0][i]+=(.65+r)*Math.sin(-this.particleX[2][i]/180*Math.PI),this.particleX[1][i]+=(.65+r)*Math.cos(this.particleX[2][i]/180*Math.PI),n(this.particleX[0][i],this.particleX[1][i])||(this.particleWeight[0][i]*=this.unaccess_weight)}let e=this.particleWeight[0].reduce((i,r)=>i+r,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/e)}motionModelCompassYaw(t,n){if(n-this.last_compass_time>this.compass_update_interval){let e=360-t;e+=this.delta_yaw,e=nn(e),Math.abs(e-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let r=0;r<this.NumParticle;r++){let o=Math.abs(this.particleX[2][r]-e);o>180&&(o=360-o),this.particleWeight[0][r]*=Ln(o,this.sigmaCompass)}let i=this.particleWeight[0].reduce((r,o)=>r+o,0);this.particleWeight[0]=this.particleWeight[0].map(r=>r/i),this.setLastCompassTime(n)}}resampling(){if(1/this.particleWeight[0].reduce((n,e)=>n+e*e,0)<this.reSampNumParticle){let n=this.particleWeight[0].reduce((s,u,l)=>s.concat(s[l]+u),[0]),i=this.particleWeight[0].map(()=>1/this.NumParticle).map((s,u)=>s+Math.random()/this.NumParticle),r=[],o=0;for(let s=0;s<this.NumParticle;s++){for(;i[s]>n[o];)o++;r.push(o)}this.particleX=this.particleX.map((s,u)=>r.map(l=>s[l])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,n){for(let i=0;i<this.NumParticle;i++){let r=be(this.particleX[0][i],this.particleX[1][i],t.x,t.y);this.particleWeight[0][i]=Math.max(1e-7,this.particleWeight[0][i]*Ln(r,n))}let e=this.particleWeight[0].reduce((i,r)=>i+r,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/e)}updateCar(t,n){let e=t.x-this.xEst[0][0],i=t.y-this.xEst[1][0];for(let o=0;o<this.NumParticle;o++){let s=be(this.particleX[0][o],this.particleX[1][o],t.x,t.y);this.particleWeight[0][o]=Math.max(1e-7,this.particleWeight[0][o]*Ln(s,n)),this.particleX[0][o]+=e,this.particleX[1][o]+=i}let r=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/r)}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,Nn.reshape)(this.particleWeight,[this.NumParticle,1]),n=(0,Nn.multiply)(this.particleX,t);return this.xEst=n,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])),n=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),e=[this.particleX[0][t],this.particleX[1][t]],i=[this.particleX[0][n],this.particleX[1][n]],r=be(e[0],e[1],i[0],i[1]),o=r*.67;return console.log(r,o),o}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,n,e){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let i=0;for(;i<this.NumParticle;){let o=(2*Math.random()-1)*this.initial_xy_uncertainty,s=(2*Math.random()-1)*this.initial_xy_uncertainty;e(t+o,n+s)||(this.particleWeight[0][i]*=this.unaccess_weight),this.particleX[0][i]=t+o,this.particleX[1][i]=n+s,i++}let r=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/r),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=n,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log(`Init compass: ${t}`);let n=360-t;n+=this.delta_yaw,n=nn(n),console.log(`Init Yaw: ${n}`);for(let e=0;e<this.NumParticle;e++){let i=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][e]=n+i}this.particle_yawInitFlag=!0,this.xEst[2][0]=n,this.last_yaw_compass=n,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 On=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=[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=0){this.last_yaw=t}getPos(t,n,e){let i=0;return e.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,e)),n.length===3&&(i=this.getStepLength(t,n)),i!==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,n){if(n.length<3)return console.warn("acc data less than 3"),0;let e=!1,i=Math.sqrt(Math.pow(n[0],2)+Math.pow(n[1],2)+Math.pow(n[2],2));if(this.accH_fifo.push(i),this.accH_time_fifo.push(t),this.imuFreUpdate(),this.accH_fifo.length<this.accH_fifo_len+1)e=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let r=this.PVStepDetec(),o=this.FFTStepDetec(),s=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),r&&o&&s?(this.step_count+=1,this.last_step_time=u,e=!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,e=!0):(u-this.last_step_time>2&&(this.state_count=0),e=!1)}if(e){let r=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(r),this.delta_py=this.const_step_length*Math.sin(r),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,n=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),e=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=n[Math.floor(n.length/2)],r=e[Math.floor(e.length/2)],o=Math.max(...n),s=Math.min(...n),u=!1,l=!1;return Math.abs(i-s)<.01&&i<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?l=!0:l=r-this.last_valley_time>this.min_step_time,l&&(this.last_valley_time=r,this.valley_num+=1)),Math.abs(i-o)<.01&&i>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?u=!0:u=r-this.last_peak_time>this.min_step_time,u&&(this.last_peak_time=r,this.peak_num+=1)),i===o&&i>this.min_peak&&(this.abnor_peak_time=r,this.abnor_peak_accH=i),this.peak_num===this.valley_num&&(u||l)&&(t=!0),t}FFTStepDetec(){return!0}getDeltaYawFromRot(t,n){if(n.length<3)return console.warn("rot data less than 3"),0;let e=[0,0,0];this.last_rot.length===3&&(e=n.map((s,u)=>s-this.last_rot[u]));for(let s=0;s<n.length;s++)e[s]<-180?e[s]+=360:e[s]>180&&(e[s]-=360);let i=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((s,u)=>i*s+(1-i)*e[u]):this.delta_rot=e,this.last_rot=n,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let r=this.delta_rot.reduce((s,u)=>s+Math.abs(u),0);this.delta_rot_sum_fifo.push(r),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 o=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(o=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,o):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 Xs={using_gps:!0},Dn=class{pfFusionPDRiBeacon(t){let{type:n,timestamp:e,res:i}=t,r=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(n===O.ACCELERATION){let o=i,s=this.pdr.getStepLength(e/1e3,o);s!==0&&(this.particleFilter.motionModelStepLength(s,()=>!0),this.particleFilter.resampling(),this.position_count+=1,r=!0)}if(this.using_gps&&n===O.GPS&&(this.last_beacon_time===null||e-this.last_beacon_time>5e3)){let o=this.getGpsPosition(i);r=o!==null,o&&(this.particleFilter.update(o,this.gps_horizontalAccuracy),this.resetParticleFilterDist(o,"gps",i[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}if(n===O.DEVICE_MOTION){let o=this.pdr.getDeltaYawFromRot(e/1e3,i);o!==null&&this.particleFilter.motionModelRotYaw(o)}n===O.COMPASS&&this.particleFilter.motionModelCompassYaw(i,e),this.last_pos_time&&e-this.last_pos_time>500&&(this.position_count+=1,r=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&n===O.GPS){let o=this.getGpsPosition(i);r=o!==null,console.log("gps_pos",o,i),o?(this.particleFilter.initParticlesByPos(o.x,o.y,()=>!0),this.last_pos_time=e,console.log(`init Pos by gps success time ${e}`),this.cacheSensorData.length=0):console.log(`init Pos by gps fail time ${e}`)}else if(!this.particleFilter.getYawInitFlag()&&n===O.COMPASS){let o=i;this.particleFilter.initParticlesByCompass(o),this.particleFilter.setLastCompassTime(e),console.log(`init yaw by compass success time ${e}`)}return r&&(this.last_pos_time=e),[r,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,n){return this.last_beacon_time=n,this.particleFilter.getPosInitFlag()?this.particleFilter.update(t,this.sigmaBeacon):(this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0),this.cacheSensorData.filter(i=>i.timestamp>n).map(i=>this.pfFusionPDRiBeacon(i))),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:Po(t[0],t[1])}resetParticleFilterDist(t,n,e){let i=this.particleFilter.getResultX(),r=this.particleFilter.getResultY(),o=be(i,r,t.x,t.y);(n==="gps"?e&&o>e||o>this.GpsMaxEstimateErr:o>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 n=v({},Xs,t);this.using_gps=n.using_gps,this.particleFilter=new Bn({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 On}};var Li=class extends Lo.EventDispatcher{checkSensor(){return this.sensor.checkSensor()}start(){this.sensor.start(),this.sensor.addEventListener("add-data-item",({item:t})=>{this.getPositionBySensorItem(t,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,n=!0){let[e,i,r]=this.pdr.pfFusionPDRiBeacon(t);return e&&n&&this.dispatchEvent({type:"position",x:i,y:r,_type:t.type===O.GPS?"gps":"pdr"}),[e,i,r]}setBeaconPosition(t,n){let[e,i]=this.pdr.setBeaconPosition(t,n);this.dispatchEvent({type:"position",x:e,y:i,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t={}){super(),this._pause=!1,this.sensor=new en(t.sensor),this.pdr=new Dn(t.pdr||{})}};var j=require("three");var Bo={texture_url:Tn,lineWidth:8,color:16777215},Un=class extends j.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:n,clientSize:{width:e,height:i}}}}}=this,r=t.map(([s,u,l])=>A(new j.Vector3(s,u,l),n,e,i)).map(({x:s,y:u})=>[s,u]);return pt(r)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new j.Vector2(t,1)}loadTexture(t){return new Promise((n,e)=>{new j.TextureLoader().load(t,n,void 0,e)})}transformPoints(t){let n=[];for(let e=0;e<t.length;e++)n.push(...t[e]);return n}updatePoints(t){this.points=t,this.changeRepeat();let n=this.transformPoints(t);this.geometry&&this.geometry.setPoints(n)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){var n=this;return g(function*(){let e=n.geometry=new st;if(n.updatePoints(t),!n.texture){let o=n.texture=yield n.loadTexture(n.config.texture_url);o.wrapS=o.wrapT=j.RepeatWrapping}let i=n.material=new de({useMap:!0,color:new j.Color(n.config.color),transparent:!0,resolution:new j.Vector2(n.navigation.bmap.context.clientSize.width,n.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:n.config.lineWidth*2,map:n.texture,blending:j.NormalBlending,repeat:new j.Vector2(n.getRepeat(),1)}),r=n.mesh=new j.Mesh(e,i);return r.renderOrder=9,n.add(r),r})()}dispose(){var t,n,e;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(n=this.material)==null||n.dispose(),(e=this.texture)==null||e.dispose()}constructor(t,n){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=Bo,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let e=this.navigation.bmap.context.camera.zoom;e!==this.prevCameraZoom&&(this.prevCameraZoom=e,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:e,height:i}=this.navigation.bmap.context.clientSize;this.material.resolution.set(e,i)}},this.config=Object.assign({},Bo,n),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};var No=require("@tweenjs/tween.js");var z=require("three"),Fn=class extends z.Object3D{getBaseScale(t){let{clientSize:{width:n,height:e},camera:i}=this.bmap.context,r=new z.Box3().setFromObject(t),{max:o,min:s}=r,u=new z.Vector3(s.x,o.y,o.z),l=new z.Vector3(o.x,o.y,o.z),c=new z.Vector3(o.x,s.y,s.z),p=new z.Vector3(s.x,s.y,s.z),h=A(u,i,n,e),f=A(l,i,n,e),m=A(p,i,n,e),_=A(c,i,n,e),S=new z.Box2().setFromPoints([new z.Vector2(h.x,h.y),new z.Vector2(f.x,f.y),new z.Vector2(m.x,m.y),new z.Vector2(_.x,_.y)]).getSize(new z.Vector2),w=40/S.x,B=40/S.y,N=Math.min(w,B),T=i.zoom;return N*T}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(n=>this.printGraph(n)),console.groupEnd()}setClips(t){this.clearClips(),t.length&&(this.mixer=new z.AnimationMixer(this.model.scene),t.forEach(n=>this.mixer.clipAction(n).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&&q(this.model.scene)}constructor(t,n){super(),this.bmap=t,this.group=new z.Object3D,this.mixer=null,this.previewTime=0,this.basicScale=1,this._update=()=>{let e=Date.now();if(!this.previewTime)this.previewTime=e;else{var i;let r=e-this.previewTime;this.previewTime=e,(i=this.mixer)==null||i.update(r/1e3)}},this._onChangeZoom=({zoom:e})=>{var i;let r=this.basicScale/e;(i=this.model)==null||i.scene.scale.set(r,r,r)},this.add(this.group),At.loadModel(n,!1).then(e=>{this.model=e;let i=this.getBaseScale(e.scene);this.basicScale=i;let r=this.bmap.context.camera.zoom;e.scene.scale.set(i/r,i/r,i/r),this.group.add(e.scene),this.setClips(e.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};var rn=require("three"),Oo=require("lodash");var Bi=class extends Mt{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 n=t.map(e=>v({},e,{points:this.translatePoints(e.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(n);else{let e=()=>{this.bmap.removeEventListener("center-change",e),this.renderPath(n)};this.bmap.addEventListener("center-change",e)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[n,e]=this.bmap.buildingCenter;return t.map(i=>[i[0]-n,i[1]-e])}renderPath(t){if(!t.length)return this.clearPath();let n=[];t.forEach((e,i,r)=>{let o=this.catmullRomCurve3(e.points),s=this.mulFloor.floors.find(u=>u.name===e.floor);if(n.push(...o.map(([u,l])=>[u,l,s.position.z+s.groundMaxHeight])),i!==r.length-1){let u=this.mulFloor.floors.find(l=>l.name===r[i+1].floor);n.push([...r[i+1].points[0],u.position.z])}}),this.cPath=n,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(n):(this.path=new Un(this),this.path.create(n),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(n[0][0],n[0][1],n[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return Ue(t,!1,!0,.1,170,2.5)}getPathDirection(t,n){if(t.length<2)return null;let e=Vt(t,n),i=t[e],r=t[e+1],o=new rn.Vector3(r[0]-i[0],r[1]-i[1],0).normalize(),s=new rn.Vector3(0,1,0).normalize(),u=o.angleTo(s),l=new rn.Vector3().crossVectors(s,o);return(Object.is(l.y,0)?-1:1)*u}startSimulation(t=1){var n=this;return g(function*(){let{paths:e,movedDistance:i}=n;if(!e.length)return;let r=e.reduce((s,u)=>s+u.distance,0);if(!r||i>=r)return;n.simulationTween&&n.tweenUtil.remove(n.simulationTween);let o=r/t;return n.startModel.startClips(),new Promise(s=>{let u=n.simulationTween=new No.Tween({distance:n.movedDistance},n.tweenUtil.group).to({distance:r},o*1e3).onUpdate(l=>{var c;n.movedDistance=l.distance;let p=l.distance,h=0;for(let w=0;w<e.length;w++)if(e[w].distance>=p){h=w;break}else p-=e[w].distance;let f=ae(e[h].points,p);if(f===null)return;n.currentPathPosition=f;let m=n.translatePoints([f])[0],_=n.mulFloor.floors.find(w=>w.name===e[h].floor),b=_?_.position.z+_.groundMaxHeight:(c=n.startModel)==null?void 0:c.position.z;n.startModel&&n.startModel.position.set(m[0],m[1],b);let S=n.getPathDirection(e[h].points,f);(0,Oo.isNil)(S)||n.startModel.setRotationFromAxisAngle(new rn.Vector3(0,0,1),S)}).onComplete(()=>{n.tweenUtil.remove(u),n.startModel.clearClips(),s(!0)}).start()})})()}setStartPoiRotate(t){if(this.startPoi){let e=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-e)%360}}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,n){super(t),this.mulFloor=n,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 Wt,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Fn(t,Ao),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};var we=require("three");var Ni=class extends we.EventDispatcher{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose()}constructor(t,n){super(),this.bmap=t,this.mulFloors=n,this._click=({e})=>{if(!this.mulFloors.showStatus)return;let i=new we.Vector2,{offsetX:r,offsetY:o}=e,{clientSize:s}=this.bmap.context;i.x=r/s.width*2-1,i.y=o/s.height*-2+1;let u=new we.Raycaster;u.setFromCamera(i,this.bmap.context.camera),u.ray.origin.sub(u.ray.direction.clone().multiplyScalar(1e4));let c=this.mulFloors.poiLayer.pois.map(h=>{if(!h.canSelect)return null;let f=u.intersectObjects(h.children,!0);return f.length?f[0]:null}).reduce((h,f)=>f&&(!h||f.distance<h.distance)?f:h,null),p=c==null?void 0:c.object;c&&c.object.isSprite&&(p=c.object.parent),p&&p instanceof V&&this.dispatchEvent({type:"select",pois:[p]})},this.clickHelper=new Fe(this.bmap.context.container),this.registryEvent()}};var Fo=require("three");var zn=require("lodash");var Uo=require("three");var Te=require("three");function Ws(a){let t=a.length,n=0,e=0,i=0,r=0;a.forEach(u=>{n+=u[0],e+=u[1],i+=u[0]*u[1],r+=u[0]*u[0]});let o=(t*i-n*e)/(t*r-n*n),s=(e-o*n)/t;return{m:o,b:s}}function js(a,t,n){let e=n[0][0],i=n.slice(-1)[0][0],r=a*e+t,o=a*i+t;return{start:[e,r],end:[i,o]}}function Oi(a){if(a.length<2)return null;let t=a.filter((u,l)=>{let c=[...a];return c.splice(l,1),c.every(p=>p[0]!==u[0]&&p[1]!==u[1])});if(t.length<2)return null;let{m:n,b:e}=Ws(t),{start:i,end:r}=js(n,e,t),s=360-(new Te.Vector2().subVectors(new Te.Vector2(r[0],r[1]),new Te.Vector2(i[0],i[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(s)?null:s}function qs(a){let t=[];for(let n=1;n<a.length;n++){let e=a[n-1],i=a[n],r=i.position[0]-e.position[0],o=i.position[1]-e.position[1],s=Math.sqrt(r**2+o**2),u=i.time-e.time;if(u>0){let l=s/u;console.log("speedDelta",e.type,i.type,$n(l),s,u),t.push(l)}else t.push(0)}return t}function Di(a,t){let n=a[0],e=a.slice(-1)[0],i=a.slice(1).reduce((o,s,u)=>{let l=U(s.position,a[u].position);return o+l},0),r=e.time-n.time;return i/r}function $n(a){return a*60*60}function Ui(a,t,n,e){let i=(n+90)%360*(Math.PI/180),r=t*e,o=new Te.Vector2(a[0],a[1]),s=Math.cos(i),u=Math.sin(i),l=new Te.Vector2(s,u);return o.add(l.normalize().multiplyScalar(r+2)),[o.x,o.y]}function Fi(a){let t=[...a].sort((l,c)=>l-c),n=Do(t,25),e=Do(t,75),i=e-n,r=n-1.5*i,o=e+1.5*i,s=t.filter(l=>l>=r&&l<=o);return a.filter(l=>s.includes(l))}function Do(a,t){let n=t/100*(a.length-1),e=Math.floor(n),i=Math.ceil(n);if(e===i)return a[e];let r=n-e;return a[e]*(1-r)+a[i]*r}var Gn=class extends Uo.EventDispatcher{start(){this.listenDeviceOrientation(),this.dispatchEvent({type:"start"})}setAbsoluteCompass(t,n){if(this.delta||this.emitCompass(t),!this.compassData.length)return;this.absoluteCompass={compass:t,time:n};let e=this.compassData.findIndex(l=>l.timestamp>=n);e===-1&&(e=this.compassData.length-1);let i=this.compassData[e-1],r=this.compassData[e],o;if(!i)o=r;else if(r)o=r.timestamp-n>i.timestamp-n?i:r;else return;let s=t-o.res;this.deltas.push(s);let u=Fi(this.deltas);u.length&&(this.delta=u.reduce((l,c)=>l+c,0)/u.length)}emitCompass(t){console.log("compass delta",this.delta,t),this.dispatchEvent({type:"compass",value:(t+this.delta+360)%360})}listenDeviceOrientation(){It?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}checkSensor(){var t=this;return g(function*(){return{deviceOrientation:yield t.checkDeviceOrientation()}})()}checkDeviceOrientation(){return g(function*(){var t;if(!It)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var n;return(yield(n=window.DeviceOrientationEvent)==null?void 0:n.requestPermission())==="granted"}catch(e){return!1}return!1})()}stop(){It?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),this.compassData=[],this.dispatchEvent({type:"stop"})}constructor(){super(),this.compassData=[],this.absoluteCompass=null,this.delta=0,this.deltas=[],this.deviceOrientationAbsHandler=t=>{let n=Date.now(),{alpha:e,beta:i,gamma:r}=t;if((0,zn.isNil)(e)||(0,zn.isNil)(i)||(0,zn.isNil)(r))return;let o=It?t.webkitCompassHeading:360-e;this.compassData.push({timestamp:n,res:o}),this.emitCompass(o)}}};var $i=class extends Fo.EventDispatcher{startCompass(){this.compass.start()}setPosition(t,n,e){this.history.push({position:t,time:n,clientTime:Date.now(),type:"vision"});let i=5;for(let o=0;o<this.history.length;o++){let s=this.history[o];if(U(s.position,t)>i)this.history.shift(),o--;else break}let r=this.getPosition("vision");this.dispatchEvent({type:"change-pos",value:r}),this.startPositionTimer()}setBeaconPosition(t,n){this.history.push({position:t,time:n,clientTime:Date.now(),type:"beacon"});let e=this.getPosition("beacon");this.dispatchEvent({type:"change-pos",value:e}),this.startPositionTimer()}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.autoCleanTimer&&this.timer.clearTimeout(this.autoCleanTimer),this.positionTimer=this.timer.setInterval(()=>{let t=this.getPosition("pdr");this.dispatchEvent({type:"change-pos",value:t})},20),this.autoCleanTimer=this.timer.setTimeout(()=>{this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=null},1e3)}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let n=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:n.position,compass:null,speed:0};let e=this.history.filter(l=>l.type==="vision"),i=Oi(e.map(l=>l.position));i!==null&&(this.compassAngle=i,this.dispatchEvent({type:"change-compass",value:i}));let r=n.clientTime,o=Date.now()-r,s=Di(this.history,o);return{success:!0,pos:this.compassAngle?Ui(n.position,s,360-this.compassAngle,o):n.position,compass:this.compassAngle,speed:$n(s)}}dispose(){this.compass.stop(),this.timer.dispose()}constructor(){super(),this.history=[],this.compass=new Gn,this.compassAngle=0,this.timer=new G,this.positionTimer=null,this.autoCleanTimer=null}};function Vi(a,t){return zi.apply(this,arguments)}function zi(){return zi=g(function*({brand:a,project:t},n){let{apiDomain:e,apiPath:{floorRange:i},apiInfo:r}=n,o=`${e}${i}?brand=${a}&project=${t}&phase=${t}&building=${t}`;return yield fetch(o,r).then(u=>u.json()).then(u=>u.data).then(u=>{let l=(u||[])[0];return l&&(l.info=JSON.parse(l.info)),l})}),zi.apply(this,arguments)}function Xi(a,t){return Gi.apply(this,arguments)}function Gi(){return Gi=g(function*({brand:a,project:t,floor:n,ts:e,resource_type_list:i},r){let{apiDomain:o,apiPath:{floorGraphic:s},apiInfo:u}=r,l=`${o}${s}?brand=${a}&project=${t}&phase=${t}&building=${t}&floor=${n}&ts=${e}&resource_type_list=${i}`;return yield fetch(l,u).then(p=>p.json()).then(p=>p.data).then(p=>((p||[]).map(h=>h.info=JSON.parse(h.info)),p||[]))}),Gi.apply(this,arguments)}function Qs(a,t){return ki.apply(this,arguments)}function ki(){return ki=g(function*({project:a,floor:t},n){let{apiDomain:e,apiInfo:i}=n,r=`${e}/api/inception-map/external_street/get?projectCode=${a}&floorCode=${t}`;return yield fetch(r,i).then(s=>s.json()).then(s=>s.data).then(s=>JSON.parse(s[0].streetInfo||"{}")).then(s=>s.fileId?Ys(s.fileId,n):null)}),ki.apply(this,arguments)}function Ys(a,t){return Hi.apply(this,arguments)}function Hi(){return Hi=g(function*(a,t){let{apiDomain:n,apiInfo:e}=t;return fetch(`${n}/api/inception-map/file/getFileStream?fileId=${a}`,e).then(i=>i.arrayBuffer()).then(i=>{let o=new TextDecoder("utf-8").decode(i);return o?JSON.parse(o):null})}),Hi.apply(this,arguments)}var Bt;function $o(a="aibee_map",t=1){return new Promise((n,e)=>{if(Bt)return n({db:Bt,type:"success"});let i=indexedDB.open(a,t);i.onupgradeneeded=function(r){Bt=r.target.result,console.log("onupgradeneeded"),n({db:Bt,type:"onupgradeneeded"})},i.onsuccess=r=>{Bt=r.target.result,n({db:Bt,type:"success"})},i.onerror=r=>{e(r)}})}function Wi(a,t,n=Bt){return new Promise((e,i)=>{n||i("\u6CA1\u6709db");let o=n.transaction([a],"readonly").objectStore(a).get(t);o.onsuccess=()=>{o.result?e(o.result.value):e(null)},o.onerror=s=>{console.log("[getVersionByKey]",s),e(null)}})}function zo(a,t,n,e=Bt){return new Promise((i,r)=>(e||r("\u6CA1\u6709db"),new Promise(g(function*(o,s){let u=yield Wi(a,t),l=e.transaction([a],"readwrite").objectStore(a),c=u!==null?l.put({key:t,value:n}):l.add({key:t,value:n});c.onsuccess=function(p){o(p)},c.onerror=function(p){s(p)}}))))}function me(a,t=Bt){t&&(t.objectStoreNames.contains(a)||t.createObjectStore(a,{keyPath:"key"}))}function Go(a=Bt){a==null||a.close(),Bt=null}var Hn=require("three");function ko(a,t){switch(a.l_type){case"graph":return Ks(a,t);case"wall":return Js(a,t);case"lane":return Zs(a,t);case"texture2d":case"texture3d":return ta(a,t);case"glb":return ea(a,t);case"store":return na(a,t);case"facility":return ia(a,t);case"parkingSpace":return ra(a,t);case"text":return oa(a,t)}}function Ks(a,t){let n=t.userData.center;it(a.elements,n);let e=[];a.elements.forEach(r=>{r.group==="ground"?t.createGround(r):e.push(r)});let i=e.reduce((r,o)=>{let{fillColor:s,fillOpacity:u,strokeColor:l,strokeOpacity:c,height:p,airHeight:h}=o,f=`${s.toLowerCase()}-${u}-${l.toLowerCase()}-${c}-${p}-${h}`;return c===0&&(f=`${s.toLowerCase()}-${u}-${p}-${h}`),r[f]?r[f].push(o):r[f]=[o],r},{});Object.values(i).forEach(r=>{let o=new Ye(t.context,r);t.mergeGraphicLayer.add(o)})}function Js(a,t){let n=t.userData.center;it(a.elements,n);let e=a.elements.reduce((i,r)=>{let{fillColor:o,fillOpacity:s,strokeColor:u,strokeOpacity:l,height:c}=r,p=`${o.toLowerCase()}-${s}-${u.toLowerCase()}-${l}-${c}`;return l===0&&(p=`${o.toLowerCase()}-${s}-${c}`),i[p]?i[p].push(r):i[p]=[r],i},{});Object.values(e).forEach(i=>{let r=new je(t.context,i);t.wallLayer.add(r)})}function Zs(a,t){let n=t.userData.center;it(a.elements,n);let e=a.elements.reduce((i,r)=>{let{fillColor:o,fillOpacity:s,strokeColor:u,strokeOpacity:l}=r,c=`${o.toLowerCase()}-${s}-${u.toLowerCase()}-${l}`;return l===0&&(c=`${o.toLowerCase()}-${s}`),i[c]?i[c].push(r):i[c]=[r],i},{});Object.values(e).forEach(i=>{let r=new Qe(t.context,i);t.laneLayer.add(r)})}function ta(a,t){let n=t.userData.center;if(it(a.elements,n),a.elements.length){let e=new Ae(t.context,a.elements);t.textureLayer.add(e)}}function ea(a,t){let n=t.userData.center;it(a.elements,n),a.elements.forEach(e=>{let i=Ct([e.center_x,e.center_y],n),r=new qe(t.context,v({},e,{url:e.secondUrl,rotate:e.secondRotate,width:e.secondWidth,center_x:i[0],center_y:i[1]}));t.glbModelLayer.add(r)})}function na(a,t){let n=t.userData.center;it(a.elements,n),a.elements.map(e=>{let i=Ct([e.center_x,e.center_y],n),r=t.addGraphic(e);t.userData.graphics.push(r),t.userData.graphicMap.set(e.id,r);try{let o=new V(t.context,{id:e.id,icon:e.poi_info.icon,text:e.poi_info.showName||e.store_name||e.poi_info.text,position:{x:i[0],y:i[1],z:e.airHeight+e.height},icon_size:[24,24],level:e.poi_info.level||0});t.poiLayer2.pushPoi(o),o&&(o.userData.type="store",o.userData.data=e,o.userData.floor=t.name)}catch(o){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",o,e)}})}function ia(a,t){let n=t.userData.center;it(a.elements,n),a.elements.map(e=>{let i=Ct([e.center_x,e.center_y],n),r=t.addGraphic(e);if(t.userData.graphics.push(r),t.userData.graphicMap.set(e.id,r),e.poi_info){let o=new V(t.context,{id:e.id,icon:e.poi_info.icon,text:e.poi_info.showName||e.store_name||e.poi_info.text,position:{x:i[0],y:i[1],z:e.airHeight+e.height},icon_size:[24,24],level:e.poi_info.level||0});t.poiLayer2.pushPoi(o),o.userData.type="facility",o.userData.data=e,o.userData.floor=t.name}else console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info",e)})}function ra(a,t){let n=t.userData.center;it(a.elements,n);let e=[],i=new Map;a.elements.forEach(o=>{let s=t.addGraphic(o);e.push(s),i.set(o.id,s);let u=Ct([o.center_x,o.center_y],n);if(o.texts[0]){let l=new V(t.context,{id:o.id,text:o.texts[0],position:{x:u[0],y:u[1],z:o.airHeight+o.height}});l&&(l.userData.type="parkingSpace",l.userData.data=o,l.userData.floor=t.name),t.poiLayer2.pushPoi(l)}});let r=a.elements.filter(o=>Si[o.parkingType]).map(o=>{let s=Ct([o.center_x,o.center_y],n),u=Jn(o.geometry.coords,s);return{uuid:o.id,iconUrl:Si[o.parkingType],name:o.texts[0],deltaHeight:o.deltaHeight,airHeight:o.airHeight,height:o.height,geometry:v({},o.geometry,{coords:u}),opacity:o.fillOpacity,visible:!0}});if(r.length){let o=new Ae(t.context,r);t.textureLayer.add(o)}t.userData.parkingSpaces=e,t.userData.parkingSpacesGraphicMap=i}function oa(a,t){let n=t.userData.center;it(a.elements,n);let e=new Ke(t.context,a.elements.map(i=>{let r=Ct([i.center_x,i.center_y],n);return v({},i,{center_x:r[0],center_y:r[1]})}));t.textTextureLayer.add(e)}var sa={loadRoadNetwork:!1},ji="map_version",qi="route_version",Qi="facility_version",Yi="map_data",kn="road_network_data",Ki="facility_data",Ji=class extends Hn.EventDispatcher{initDb(){var t=this;return g(function*(){try{let{db:n,type:e}=yield $o("aibee_map",2);e==="onupgradeneeded"&&(me(ji),me(qi),me(Qi),me(Yi),me(kn),me(Ki)),t.db=n}catch(n){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",n)}})()}load(t){var n=this;return g(function*(){if(Array.isArray(t))n.floors=t;else{let e=yield fetch(t).then(i=>i.json());e.code==="0"&&(n.floors=e.data.list)}})()}setCacheData(t,n,e){return this.initDbPromise.then(()=>zo(t,`${n}`,e,this.db))}getCacheData(t,n){return this.initDbPromise.then(()=>Wi(t,`${n}`,this.db))}getFloorCacheKey(t){return`${t.floor_id}`}getFloorData(t){var n=this;return g(function*(){let e=yield n.getFloorJsonData(t);return e?n.getDataByJson(e):null})()}getFloorDataByFloorInfo(t){var n=this;return g(function*(){let e=yield n.getFloorJsonDataByFloorInfo(t);return n.getDataByJson(e)})()}getFloorJsonDataByFloorInfo(t){var n=this;return g(function*(){let e=n.getFloorCacheKey(t);console.time("zstd_json");let i=yield fetch(t.map_url).then(r=>r.json());return i.floor=t.floor,console.timeEnd("zstd_json"),n.setCacheData(Yi,e,i),n.setCacheData(ji,e,t.version_id),i})()}getFloorJsonData(t){var n=this;return g(function*(){let e=n.floors.find(r=>r.floor===t);if(!e)return null;let i=n.getFloorCacheKey(e);try{if((yield n.getCacheData(ji,i))===e.version_id){let o=yield n.getCacheData(Yi,i);if(o)return o}return n.getFloorJsonDataByFloorInfo(e)}catch(r){return console.log("[get floor data error]",r),n.getFloorJsonDataByFloorInfo(e)}})()}getRoadNetworkData(){var t=this;return g(function*(){return(yield Promise.all(t.floors.map(g(function*(e){let i=t.getFloorCacheKey(e);try{if((yield t.getCacheData(qi,i))===e.version_id){let s=yield t.getCacheData(kn,i);if(s)return s}let o=yield fetch(e.route_url).then(s=>s.json());return t.setCacheData(kn,i,o),t.setCacheData(qi,i,e.version_id),o}catch(r){let o=yield fetch(e.route_url).then(s=>s.json());return t.setCacheData(kn,i,o),o}})))).filter(e=>e.points)})()}getFacilitiesData(){var t=this;return g(function*(){let n=t.floors.reduce((r,o)=>r.updated_at>o.updated_at?r:o,t.floors[0]);if(!n)return null;let e=t.getFloorCacheKey(n),i=g(function*(){let r=yield fetch(n.entry_infra_url).then(o=>o.json());return r&&(t.setCacheData(Ki,e,r),t.setCacheData(Qi,e,n.version_id)),r});try{if((yield t.getCacheData(Qi,e))===n.version_id){let o=yield t.getCacheData(Ki,e);if(o)return o}return i()}catch(r){return console.log("[get facility error]",r),i()}})()}getOtherDataByFreeTime(){return g(function*(){})()}getMulFloorsData(t){var n=this;return g(function*(){return Promise.all(t.map(e=>n.getFloorData(e))).then(e=>e.filter(i=>i))})()}getDataByUrl(t){var n=this;return g(function*(){let e=yield fetch(t).then(i=>i.json());return n.getDataByJson(e)})()}getDataByJson(t,n){var e=this;return g(function*(){return n=e.getFloorBaseLayer(t,n),yield e.getFloorContentLayer(t,n),e.changeFloorBox(t,n),n})()}changeFloorBox(t,n){n.updateBox();let e=n.box.getSize(new Hn.Vector3),i=Math.max(e.x,e.y,e.z);n.userData.height=i/4+t.floorHeight}switchFloor(t){var n=this;return g(function*(){return new Promise(e=>{let i={run:()=>n._switchFloor(t),meta:{type:"switchFloor"}},r=n.taskQueue.replaceByMetaType(i),o=({task:s,res:u})=>{s.tid===r&&(n.taskQueue.removeEventListener("active-task-end",o),e(u))};n.taskQueue.addEventListener("active-task-end",o)})})()}_switchFloor(t){var n=this;return g(function*(){var e;let i=t;if(typeof t=="string"){let l=yield n.getFloorJsonData(t);if(l)i=l;else return null}let r=new mt(n.bmap.context),o=n.floors.find(l=>l.floor===i.floor);var s;let u=(s=o==null?void 0:o.map_angle)!=null?s:0;return n.bmap.dispatchEvent({type:tt.SWITCH_FLOOR_BEFORE,data:{curFloor:r,graphics:[]}}),n.dispatchEvent({type:"switch-floor-before",data:{curFloor:r,graphics:[]}}),n.bmap.context.control.setAzimuthalAngle(u/180*Math.PI,!0),n.getFloorBaseLayer(i,r),n.changeFloorBox(i,r),n.bmap.buildingCenter=r.userData.center,n.bmap.currentBuildGround=(e=r.userData.data.layers.find(l=>l.l_type==="range"))==null?void 0:e.elements[0],n.bmap.context.switchFloor(r),n.bmap.initialFloorCamera(),yield un(),n.dispatchEvent({type:"switch-floor-ground",data:{curFloor:r,graphics:[]}}),yield n.getFloorContentLayer(i,r),n.changeFloorBox(i,r),n.bmap.initialFloorCamera(),n.bmap.context.cameraBound.updateBox(),n.dispatchEvent({type:"switch-floor-after",data:{curFloor:r,graphics:r.graphicLayer.children}}),n.bmap.dispatchEvent({type:tt.SWITCH_FLOOR_AFTER,data:{curFloor:r,graphics:r.graphicLayer.children}}),r})()}getFloorBaseLayer(t,n){n||(n=new mt(this.bmap.context));let e=[0,0];return t.layers.forEach(i=>{switch(i.l_type){case"range":let r=i.elements[0];e=[r.center_x,r.center_y];break;case"ground":it(i.elements,e);let o=i.elements.map(s=>new H(this.bmap.context,s));n.addGrounds(o),console.log("grounds",o);break;default:break}}),n.userData.center=e,n.name=t.floor,n.userData.data=t,n}getFloorContentLayer(t,n){var e=this;return g(function*(){n||(n=new mt(e.bmap.context)),n.userData.graphics=[],n.userData.graphicMap=new Map;let i=Date.now();for(let r=0;r<t.layers.length;r++){let o=t.layers[r];["range","ground"].includes(o.l_type)||(ko(o,n),console.log("time",Date.now()-i,o.l_type),Date.now()-i>16&&(yield un(),i=Date.now()))}return n})()}clear(){var t=this;return g(function*(){var n;Go((n=t.db)!=null?n:void 0)})()}dispose(){this.clear()}constructor(t){super(),this.bmap=t,this.floors=[],this.initDbPromise=Promise.resolve(),this.db=null,this.taskQueue=new ue,this.initDbPromise=this.initDb()}};var Zi=class{load(t){var n=this;return g(function*(){let e=se(t);if(n.cacheData.has(e))return n.cacheData.get(e);let[,i]=yield Promise.all([n.loadBuildGround(t),Xi(t,n.bmap.config)]),r=se({floor:t.floor,ts:t.ts});it(i.map(s=>s.info),n.bmap.buildingCenter,n.floorDataLengthMap.get(r)||0),i.forEach(s=>s.info.transformToBuildingGround=!1),n.cacheData.set(e,i);let o=n.floorDataLengthMap.get(r)||0;return n.floorDataLengthMap.set(r,o+i.length),n.loadExternalStreet(t),i})()}loadExternalStreet(t){return g(function*(){})()}switchFloorByData(t,n){if(!t.length)return;let e=n.userData.legacyToGraphicMap||new Map,i=n.userData.graphicMap||new Map,{ground:r,markGraphic:o,graphic:s}=this.bmap.config;for(let u=0;u<t.length;u++){let l=t[u];l.info.group==="ground"?(l.info.fillColor=r.color,l.info.fillOpacity=r.opacity,l.info.height=r.height,l.info.stroke=r.stroke,l.info.strokeColor=r.strokeColor,l.info.strokeOpacity=r.strokeOpacity):l.info.userData.mark?(l.info.height=o.height,l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity):(l.info.fillOpacity=s.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=o.height,l.info.fillColor=o.color,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity))}for(let u of t){if(u.info.group==="ground")n.createGround(u.info);else{let l=n.addGraphic(u.info);l.userData.data=u,e.set(u.legacy_id,l)}i.set(u.element_uuid,u)}n.userData.legacyToGraphicMap=e,n.userData.graphicMap=i,n.updateBox(),n===this.bmap.context.currentFloor?(this.bmap.triggerHooks(tt.SWITCH_FLOOR_BEFORE,{curFloor:n,graphics:n.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(tt.SWITCH_FLOOR_AFTER,{curFloor:n,graphics:n.graphicLayer.children})):this.bmap.switchFloorByFloor(n)}filterData(t,n){let e=n.userData.graphicMap||new Map;return t.filter(i=>!e.has(i.element_uuid))}switchFloorByStoreData(t,n){var e=this;return g(function*(){let i=yield e.load(v({},t,{resource_type_list:"6"})),r=e.filterData(i,n);e.switchFloorByData(r,n)})()}switchFloorByOtherData(t,n){var e=this;return g(function*(){let i=yield e.load(v({},t,{resource_type_list:"1,2,3,4"})),r=e.filterData(i,n);e.switchFloorByData(r,n)})()}loadBuildGround({brand:t,project:n}){var e=this;return g(function*(){let i=yield e.loadBuildingGround({brand:t,project:n});return e.bmap.currentBuildGround=i,e.bmap.changeBuildingCenter(i,{brand:t,project:n}),e.bmap.currentBuildGround})()}loadBuildingGround({brand:t,project:n}){var e=this;return g(function*(){let i=se({brand:t,project:n});if(e.buildingGroundMap.has(i))return e.buildingGroundMap.get(i);let r=Vi({brand:t,project:n},e.bmap.config).then(o=>(e.buildingGroundMap.set(i,o),o));return e.buildingGroundMap.set(i,r),r})()}switchFloor(t){var n=this;return g(function*(){let e=new mt(n.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([n.switchFloorByStoreData(t,e),n.switchFloorByOtherData(t,e)])}catch(i){console.log(i)}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}};
|
|
7737
|
+
`],{type:"text/javascript"}),t=URL.createObjectURL(a),n=new Worker(t);return URL.revokeObjectURL(t),n}var Ri=class extends To.EventDispatcher{setRoadData(t){var n=this;return g(function*(){n.initRoadStatus=!1,n.dispatchEvent({type:"init-road-status",status:!1}),yield Pt(n.worker,"set_road_info",{roadData:t}),n.initRoadStatus=!0,n.dispatchEvent({type:"init-road-status",status:!0})})()}getPath(t,n,e=""){var i=this;return g(function*(){return new Promise((r,o)=>{let s=()=>{Pt(i.worker,"get_path",{start:t,end:n,type:e}).then(u=>{u?typeof u=="string"?o(u):r(u):o("no-path")})};if(i.initRoadStatus)s();else{let u=({status:l})=>{l&&(i.removeEventListener("init-road-status",u),s())};i.addEventListener("init-road-status",u)}})})()}getDirectionPath(t){return Pt(this.worker,"get_direction_path",t)}dispose(){var t=this;return g(function*(){Pt(t.worker,"clear",""),t.worker.terminate()})()}constructor(){super(),this.worker=Ii(),this.initRoadStatus=!1}};var Io=require("three"),Pn=class extends gt{setEnable(t){super.setEnable(t),Z(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:n,container:{clientWidth:e,clientHeight:i}}}=this,r=A(this.startPoint,n,e,i),o=A(this.endPoint,n,e,i),s={x:Math.min(r.x,o.x),y:Math.min(r.y,o.y)},u={x:Math.max(r.x,o.x),y:Math.max(r.y,o.y)},l=this.searchMapInFrustum(s,u);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,n){var e;let{context:i}=this;return((e=i.currentFloor)==null?void 0:e.graphicLayer.children.filter(r=>r instanceof H&&this.searchChildInFrustum(r,t,n)))||[]}searchChildInFrustum(t,n,e){let{context:{camera:i,container:{clientWidth:r,clientHeight:o}}}=this;if(!t)return!1;if(!t.mesh){let h=t.getPosition();if(h){let f=A(h,i,r,o);return Ht(f,n,e)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let s=t.mesh.geometry.boundingBox;if(!s)return!1;let{min:u,max:l}=s,c=A(u,i,r,o),p=A(l,i,r,o);return!(!Ht(c,n,e)||!Ht(p,n,e))}dispose(){this.unRegistryEvent()}constructor(t){super(t),this.frustum=new Io.Frustum,this.onPointerDown=i=>{if(!this.enable)return;let r=this.getIntersectByPointerEvent(i);r&&(this.startPoint=r),this.endPoint=void 0},this.onPointerMove=i=>{if(!this.enable||!this.startPoint)return;let r=this.getIntersectByPointerEvent(i);r&&(this.endPoint=r)},this.onPointerUp=i=>{if(!this.enable)return;let r=this.getIntersectByPointerEvent(i);r&&(this.endPoint=r),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let i=this.getSvgCoordinate(this.startPoint),r=v({},i);this.endPoint&&(r=this.getSvgCoordinate(this.endPoint));let o={x:Math.min(i.x,r.x),y:Math.min(i.y,r.y)},s=Math.abs(r.x-i.x),u=Math.abs(r.y-i.y);Z(this.rect,o.x,o.y,s,u)}else Z(this.rect,0,0,0,0)};let{config:{selectBox:{fill:n,stroke:e}}}=t;this.rect=Xt(e,n),this.svg.appendChild(this.rect),this.registryEvent()}};var Hs={boxSelection:!1,elements:["graphic","poi"]},Pi=class extends Mt{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()}constructor(t,n={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=e=>{this.downPoint={x:e.offsetX,y:e.offsetY}},this.onPointerUp=e=>{if(!this.downPoint)return;let{offsetX:i,offsetY:r}=e,{x:o,y:s}=this.downPoint;if(Math.sqrt((o-i)**2+(s-r)**2)>3)return;let u=new Set,l=[],c=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(i,r);p.map(h=>u.add(h.options.id)),l.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(i,r);c.push(...p),p.forEach(h=>{if(!u.has(h.options.id)){var f;let m=((f=this.bmap.context.currentFloor)==null?void 0:f.graphicLayer.graphicMap.get(h.options.id))||null;m&&(u.add(h.options.id),l.push(m))}})}(!this.options.boxSelection||!(re?e.metaKey:e.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=e=>{this.disableBoxSelection()},this.onKeyDown=e=>{oe(e.key)&&this.enableBoxSelection()},this.onKeyUp=e=>{oe(e.key)&&this.disableBoxSelection()},this.onBoxSelected=({list:e})=>{this._list.clear(),this._poiList.clear(),e.forEach(i=>{if(this.options.elements.includes("graphic")&&this._list.add(i),this.options.elements.includes("poi")){let r=this.bmap.getPoiById(i.options.id);r&&this._poiList.add(r)}}),this.selectEnd()},this.options=v({},Hs,n),this.boxSelection=new Pn(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var ut=require("lodash");var Ro=require("three");var O=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var Vs={time:1e3,elements:[O.COMPASS,O.DEVICE_MOTION,O.ACCELERATION,O.GPS]},en=class extends Ro.EventDispatcher{start(){this.options.elements.some(t=>[O.DEVICE_MOTION,O.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(O.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(O.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,ut.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){It?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:O.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(){var t=this;return g(function*(){return{deviceOrientation:yield t.checkDeviceOrientation()}})()}checkDeviceOrientation(){return g(function*(){var t;if(!It)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var n;return(yield(n=window.DeviceOrientationEvent)==null?void 0:n.requestPermission())==="granted"}catch(e){return!1}return!1})()}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),It?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,ut.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 G,this.dispatchTimer=null,this.addAcceleration=(0,ut.throttle)(n=>{this.addDataItem(n)},20),this.deviceOrientationAbsHandler=(0,ut.throttle)(n=>{let e=Date.now(),{alpha:i,beta:r,gamma:o}=n;if((0,ut.isNil)(i)||(0,ut.isNil)(r)||(0,ut.isNil)(o))return;let s;It?s=n.webkitCompassHeading:s=360-i,this.options.elements.includes(O.DEVICE_MOTION)&&this.addDataItem({type:O.DEVICE_MOTION,timestamp:e,res:[i,r,o]}),this.options.elements.includes(O.COMPASS)&&this.addDataItem({type:O.COMPASS,timestamp:e,res:s})},200),this.handleAcceleration=n=>{let e=n.accelerationIncludingGravity;(0,ut.isNil)(e)||(0,ut.isNil)(e.x)||(0,ut.isNil)(e.y)||(0,ut.isNil)(e.z)||this.addAcceleration({type:O.ACCELERATION,timestamp:Date.now(),res:[e.x,e.y,e.z]})},this.options=v({},Vs,t)}};var Lo=require("three");function Ln(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function nn(a){return(a+360)%360}function Po(a,t){let e=6378137*a*Math.PI/180,i=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:e,y:i}}function be(a,t,n,e){return Math.sqrt(Math.pow(Math.abs(a-n),2)+Math.pow(Math.abs(t-e),2))}var Nn=require("mathjs"),Bn=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=nn(this.last_yaw_compass+t);for(let n=0;n<this.NumParticle;n++){let e=Math.random()*this.yaw_noise_sigma;this.particleX[2][n]=this.particleX[2][n]+t+e,this.particleX[2][n]=nn(this.particleX[2][n])}}}motionModelStepLength(t,n){if(t===0)return;for(let i=0;i<this.NumParticle;i++){let r=Math.random()*this.step_noise_sigma;this.particleX[0][i]+=(.65+r)*Math.sin(-this.particleX[2][i]/180*Math.PI),this.particleX[1][i]+=(.65+r)*Math.cos(this.particleX[2][i]/180*Math.PI),n(this.particleX[0][i],this.particleX[1][i])||(this.particleWeight[0][i]*=this.unaccess_weight)}let e=this.particleWeight[0].reduce((i,r)=>i+r,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/e)}motionModelCompassYaw(t,n){if(n-this.last_compass_time>this.compass_update_interval){let e=360-t;e+=this.delta_yaw,e=nn(e),Math.abs(e-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let r=0;r<this.NumParticle;r++){let o=Math.abs(this.particleX[2][r]-e);o>180&&(o=360-o),this.particleWeight[0][r]*=Ln(o,this.sigmaCompass)}let i=this.particleWeight[0].reduce((r,o)=>r+o,0);this.particleWeight[0]=this.particleWeight[0].map(r=>r/i),this.setLastCompassTime(n)}}resampling(){if(1/this.particleWeight[0].reduce((n,e)=>n+e*e,0)<this.reSampNumParticle){let n=this.particleWeight[0].reduce((s,u,l)=>s.concat(s[l]+u),[0]),i=this.particleWeight[0].map(()=>1/this.NumParticle).map((s,u)=>s+Math.random()/this.NumParticle),r=[],o=0;for(let s=0;s<this.NumParticle;s++){for(;i[s]>n[o];)o++;r.push(o)}this.particleX=this.particleX.map((s,u)=>r.map(l=>s[l])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,n){for(let i=0;i<this.NumParticle;i++){let r=be(this.particleX[0][i],this.particleX[1][i],t.x,t.y);this.particleWeight[0][i]=Math.max(1e-7,this.particleWeight[0][i]*Ln(r,n))}let e=this.particleWeight[0].reduce((i,r)=>i+r,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/e)}updateCar(t,n){let e=t.x-this.xEst[0][0],i=t.y-this.xEst[1][0];for(let o=0;o<this.NumParticle;o++){let s=be(this.particleX[0][o],this.particleX[1][o],t.x,t.y);this.particleWeight[0][o]=Math.max(1e-7,this.particleWeight[0][o]*Ln(s,n)),this.particleX[0][o]+=e,this.particleX[1][o]+=i}let r=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/r)}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,Nn.reshape)(this.particleWeight,[this.NumParticle,1]),n=(0,Nn.multiply)(this.particleX,t);return this.xEst=n,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])),n=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),e=[this.particleX[0][t],this.particleX[1][t]],i=[this.particleX[0][n],this.particleX[1][n]],r=be(e[0],e[1],i[0],i[1]),o=r*.67;return console.log(r,o),o}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,n,e){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let i=0;for(;i<this.NumParticle;){let o=(2*Math.random()-1)*this.initial_xy_uncertainty,s=(2*Math.random()-1)*this.initial_xy_uncertainty;e(t+o,n+s)||(this.particleWeight[0][i]*=this.unaccess_weight),this.particleX[0][i]=t+o,this.particleX[1][i]=n+s,i++}let r=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/r),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=n,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log(`Init compass: ${t}`);let n=360-t;n+=this.delta_yaw,n=nn(n),console.log(`Init Yaw: ${n}`);for(let e=0;e<this.NumParticle;e++){let i=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][e]=n+i}this.particle_yawInitFlag=!0,this.xEst[2][0]=n,this.last_yaw_compass=n,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 On=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=[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=0){this.last_yaw=t}getPos(t,n,e){let i=0;return e.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,e)),n.length===3&&(i=this.getStepLength(t,n)),i!==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,n){if(n.length<3)return console.warn("acc data less than 3"),0;let e=!1,i=Math.sqrt(Math.pow(n[0],2)+Math.pow(n[1],2)+Math.pow(n[2],2));if(this.accH_fifo.push(i),this.accH_time_fifo.push(t),this.imuFreUpdate(),this.accH_fifo.length<this.accH_fifo_len+1)e=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let r=this.PVStepDetec(),o=this.FFTStepDetec(),s=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),r&&o&&s?(this.step_count+=1,this.last_step_time=u,e=!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,e=!0):(u-this.last_step_time>2&&(this.state_count=0),e=!1)}if(e){let r=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(r),this.delta_py=this.const_step_length*Math.sin(r),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,n=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),e=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=n[Math.floor(n.length/2)],r=e[Math.floor(e.length/2)],o=Math.max(...n),s=Math.min(...n),u=!1,l=!1;return Math.abs(i-s)<.01&&i<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?l=!0:l=r-this.last_valley_time>this.min_step_time,l&&(this.last_valley_time=r,this.valley_num+=1)),Math.abs(i-o)<.01&&i>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?u=!0:u=r-this.last_peak_time>this.min_step_time,u&&(this.last_peak_time=r,this.peak_num+=1)),i===o&&i>this.min_peak&&(this.abnor_peak_time=r,this.abnor_peak_accH=i),this.peak_num===this.valley_num&&(u||l)&&(t=!0),t}FFTStepDetec(){return!0}getDeltaYawFromRot(t,n){if(n.length<3)return console.warn("rot data less than 3"),0;let e=[0,0,0];this.last_rot.length===3&&(e=n.map((s,u)=>s-this.last_rot[u]));for(let s=0;s<n.length;s++)e[s]<-180?e[s]+=360:e[s]>180&&(e[s]-=360);let i=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((s,u)=>i*s+(1-i)*e[u]):this.delta_rot=e,this.last_rot=n,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let r=this.delta_rot.reduce((s,u)=>s+Math.abs(u),0);this.delta_rot_sum_fifo.push(r),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 o=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(o=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,o):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 Xs={using_gps:!0},Dn=class{pfFusionPDRiBeacon(t){let{type:n,timestamp:e,res:i}=t,r=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(n===O.ACCELERATION){let o=i,s=this.pdr.getStepLength(e/1e3,o);s!==0&&(this.particleFilter.motionModelStepLength(s,()=>!0),this.particleFilter.resampling(),this.position_count+=1,r=!0)}if(this.using_gps&&n===O.GPS&&(this.last_beacon_time===null||e-this.last_beacon_time>5e3)){let o=this.getGpsPosition(i);r=o!==null,o&&(this.particleFilter.update(o,this.gps_horizontalAccuracy),this.resetParticleFilterDist(o,"gps",i[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}if(n===O.DEVICE_MOTION){let o=this.pdr.getDeltaYawFromRot(e/1e3,i);o!==null&&this.particleFilter.motionModelRotYaw(o)}n===O.COMPASS&&this.particleFilter.motionModelCompassYaw(i,e),this.last_pos_time&&e-this.last_pos_time>500&&(this.position_count+=1,r=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&n===O.GPS){let o=this.getGpsPosition(i);r=o!==null,console.log("gps_pos",o,i),o?(this.particleFilter.initParticlesByPos(o.x,o.y,()=>!0),this.last_pos_time=e,console.log(`init Pos by gps success time ${e}`),this.cacheSensorData.length=0):console.log(`init Pos by gps fail time ${e}`)}else if(!this.particleFilter.getYawInitFlag()&&n===O.COMPASS){let o=i;this.particleFilter.initParticlesByCompass(o),this.particleFilter.setLastCompassTime(e),console.log(`init yaw by compass success time ${e}`)}return r&&(this.last_pos_time=e),[r,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,n){return this.last_beacon_time=n,this.particleFilter.getPosInitFlag()?this.particleFilter.update(t,this.sigmaBeacon):(this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0),this.cacheSensorData.filter(i=>i.timestamp>n).map(i=>this.pfFusionPDRiBeacon(i))),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:Po(t[0],t[1])}resetParticleFilterDist(t,n,e){let i=this.particleFilter.getResultX(),r=this.particleFilter.getResultY(),o=be(i,r,t.x,t.y);(n==="gps"?e&&o>e||o>this.GpsMaxEstimateErr:o>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 n=v({},Xs,t);this.using_gps=n.using_gps,this.particleFilter=new Bn({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 On}};var Li=class extends Lo.EventDispatcher{checkSensor(){return this.sensor.checkSensor()}start(){this.sensor.start(),this.sensor.addEventListener("add-data-item",({item:t})=>{this.getPositionBySensorItem(t,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,n=!0){let[e,i,r]=this.pdr.pfFusionPDRiBeacon(t);return e&&n&&this.dispatchEvent({type:"position",x:i,y:r,_type:t.type===O.GPS?"gps":"pdr"}),[e,i,r]}setBeaconPosition(t,n){let[e,i]=this.pdr.setBeaconPosition(t,n);this.dispatchEvent({type:"position",x:e,y:i,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t={}){super(),this._pause=!1,this.sensor=new en(t.sensor),this.pdr=new Dn(t.pdr||{})}};var j=require("three");var Bo={texture_url:Tn,lineWidth:8,color:16777215},Un=class extends j.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:n,clientSize:{width:e,height:i}}}}}=this,r=t.map(([s,u,l])=>A(new j.Vector3(s,u,l),n,e,i)).map(({x:s,y:u})=>[s,u]);return pt(r)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new j.Vector2(t,1)}loadTexture(t){return new Promise((n,e)=>{new j.TextureLoader().load(t,n,void 0,e)})}transformPoints(t){let n=[];for(let e=0;e<t.length;e++)n.push(...t[e]);return n}updatePoints(t){this.points=t,this.changeRepeat();let n=this.transformPoints(t);this.geometry&&this.geometry.setPoints(n)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){var n=this;return g(function*(){let e=n.geometry=new st;if(n.updatePoints(t),!n.texture){let o=n.texture=yield n.loadTexture(n.config.texture_url);o.wrapS=o.wrapT=j.RepeatWrapping}let i=n.material=new de({useMap:!0,color:new j.Color(n.config.color),transparent:!0,resolution:new j.Vector2(n.navigation.bmap.context.clientSize.width,n.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:n.config.lineWidth*2,map:n.texture,blending:j.NormalBlending,repeat:new j.Vector2(n.getRepeat(),1)}),r=n.mesh=new j.Mesh(e,i);return r.renderOrder=9,n.add(r),r})()}dispose(){var t,n,e;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(n=this.material)==null||n.dispose(),(e=this.texture)==null||e.dispose()}constructor(t,n){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=Bo,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let e=this.navigation.bmap.context.camera.zoom;e!==this.prevCameraZoom&&(this.prevCameraZoom=e,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:e,height:i}=this.navigation.bmap.context.clientSize;this.material.resolution.set(e,i)}},this.config=Object.assign({},Bo,n),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};var No=require("@tweenjs/tween.js");var z=require("three"),Fn=class extends z.Object3D{getBaseScale(t){let{clientSize:{width:n,height:e},camera:i}=this.bmap.context,r=new z.Box3().setFromObject(t),{max:o,min:s}=r,u=new z.Vector3(s.x,o.y,o.z),l=new z.Vector3(o.x,o.y,o.z),c=new z.Vector3(o.x,s.y,s.z),p=new z.Vector3(s.x,s.y,s.z),h=A(u,i,n,e),f=A(l,i,n,e),m=A(p,i,n,e),_=A(c,i,n,e),S=new z.Box2().setFromPoints([new z.Vector2(h.x,h.y),new z.Vector2(f.x,f.y),new z.Vector2(m.x,m.y),new z.Vector2(_.x,_.y)]).getSize(new z.Vector2),w=40/S.x,B=40/S.y,N=Math.min(w,B),T=i.zoom;return N*T}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(n=>this.printGraph(n)),console.groupEnd()}setClips(t){this.clearClips(),t.length&&(this.mixer=new z.AnimationMixer(this.model.scene),t.forEach(n=>this.mixer.clipAction(n).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&&q(this.model.scene)}constructor(t,n){super(),this.bmap=t,this.group=new z.Object3D,this.mixer=null,this.previewTime=0,this.basicScale=1,this._update=()=>{let e=Date.now();if(!this.previewTime)this.previewTime=e;else{var i;let r=e-this.previewTime;this.previewTime=e,(i=this.mixer)==null||i.update(r/1e3)}},this._onChangeZoom=({zoom:e})=>{var i;let r=this.basicScale/e;(i=this.model)==null||i.scene.scale.set(r,r,r)},this.add(this.group),At.loadModel(n,!1).then(e=>{this.model=e;let i=this.getBaseScale(e.scene);this.basicScale=i;let r=this.bmap.context.camera.zoom;e.scene.scale.set(i/r,i/r,i/r),this.group.add(e.scene),this.setClips(e.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};var rn=require("three"),Oo=require("lodash");var Bi=class extends Mt{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 n=t.map(e=>v({},e,{points:this.translatePoints(e.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(n);else{let e=()=>{this.bmap.removeEventListener("center-change",e),this.renderPath(n)};this.bmap.addEventListener("center-change",e)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[n,e]=this.bmap.buildingCenter;return t.map(i=>[i[0]-n,i[1]-e])}renderPath(t){if(!t.length)return this.clearPath();let n=[];t.forEach((e,i,r)=>{let o=this.catmullRomCurve3(e.points),s=this.mulFloor.floors.find(u=>u.name===e.floor);if(n.push(...o.map(([u,l])=>[u,l,s.position.z+s.groundMaxHeight])),i!==r.length-1){let u=this.mulFloor.floors.find(l=>l.name===r[i+1].floor);n.push([...r[i+1].points[0],u.position.z])}}),this.cPath=n,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(n):(this.path=new Un(this),this.path.create(n),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(n[0][0],n[0][1],n[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return Ue(t,!1,!0,.1,170,2.5)}getPathDirection(t,n){if(t.length<2)return null;let e=Vt(t,n),i=t[e],r=t[e+1],o=new rn.Vector3(r[0]-i[0],r[1]-i[1],0).normalize(),s=new rn.Vector3(0,1,0).normalize(),u=o.angleTo(s),l=new rn.Vector3().crossVectors(s,o);return(Object.is(l.y,0)?-1:1)*u}startSimulation(t=1){var n=this;return g(function*(){let{paths:e,movedDistance:i}=n;if(!e.length)return;let r=e.reduce((s,u)=>s+u.distance,0);if(!r||i>=r)return;n.simulationTween&&n.tweenUtil.remove(n.simulationTween);let o=r/t;return n.startModel.startClips(),new Promise(s=>{let u=n.simulationTween=new No.Tween({distance:n.movedDistance},n.tweenUtil.group).to({distance:r},o*1e3).onUpdate(l=>{var c;n.movedDistance=l.distance;let p=l.distance,h=0;for(let w=0;w<e.length;w++)if(e[w].distance>=p){h=w;break}else p-=e[w].distance;let f=ae(e[h].points,p);if(f===null)return;n.currentPathPosition=f;let m=n.translatePoints([f])[0],_=n.mulFloor.floors.find(w=>w.name===e[h].floor),b=_?_.position.z+_.groundMaxHeight:(c=n.startModel)==null?void 0:c.position.z;n.startModel&&n.startModel.position.set(m[0],m[1],b);let S=n.getPathDirection(e[h].points,f);(0,Oo.isNil)(S)||n.startModel.setRotationFromAxisAngle(new rn.Vector3(0,0,1),S)}).onComplete(()=>{n.tweenUtil.remove(u),n.startModel.clearClips(),s(!0)}).start()})})()}setStartPoiRotate(t){if(this.startPoi){let e=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-e)%360}}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,n){super(t),this.mulFloor=n,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 Wt,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Fn(t,Ao),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};var we=require("three");var Ni=class extends we.EventDispatcher{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose()}constructor(t,n){super(),this.bmap=t,this.mulFloors=n,this._click=({e})=>{if(!this.mulFloors.showStatus)return;let i=new we.Vector2,{offsetX:r,offsetY:o}=e,{clientSize:s}=this.bmap.context;i.x=r/s.width*2-1,i.y=o/s.height*-2+1;let u=new we.Raycaster;u.setFromCamera(i,this.bmap.context.camera),u.ray.origin.sub(u.ray.direction.clone().multiplyScalar(1e4));let c=this.mulFloors.poiLayer.pois.map(h=>{if(!h.canSelect)return null;let f=u.intersectObjects(h.children,!0);return f.length?f[0]:null}).reduce((h,f)=>f&&(!h||f.distance<h.distance)?f:h,null),p=c==null?void 0:c.object;c&&c.object.isSprite&&(p=c.object.parent),p&&p instanceof V&&this.dispatchEvent({type:"select",pois:[p]})},this.clickHelper=new Fe(this.bmap.context.container),this.registryEvent()}};var Fo=require("three");var zn=require("lodash");var Uo=require("three");var Te=require("three");function Ws(a){let t=a.length,n=0,e=0,i=0,r=0;a.forEach(u=>{n+=u[0],e+=u[1],i+=u[0]*u[1],r+=u[0]*u[0]});let o=(t*i-n*e)/(t*r-n*n),s=(e-o*n)/t;return{m:o,b:s}}function js(a,t,n){let e=n[0][0],i=n.slice(-1)[0][0],r=a*e+t,o=a*i+t;return{start:[e,r],end:[i,o]}}function Oi(a){if(a.length<2)return null;let t=a.filter((u,l)=>{let c=[...a];return c.splice(l,1),c.every(p=>p[0]!==u[0]&&p[1]!==u[1])});if(t.length<2)return null;let{m:n,b:e}=Ws(t),{start:i,end:r}=js(n,e,t),s=360-(new Te.Vector2().subVectors(new Te.Vector2(r[0],r[1]),new Te.Vector2(i[0],i[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(s)?null:s}function qs(a){let t=[];for(let n=1;n<a.length;n++){let e=a[n-1],i=a[n],r=i.position[0]-e.position[0],o=i.position[1]-e.position[1],s=Math.sqrt(r**2+o**2),u=i.time-e.time;if(u>0){let l=s/u;console.log("speedDelta",e.type,i.type,$n(l),s,u),t.push(l)}else t.push(0)}return t}function Di(a,t){let n=a[0],e=a.slice(-1)[0],i=a.slice(1).reduce((o,s,u)=>{let l=U(s.position,a[u].position);return o+l},0),r=e.time-n.time;return i/r}function $n(a){return a*60*60}function Ui(a,t,n,e){let i=(n+90)%360*(Math.PI/180),r=t*e,o=new Te.Vector2(a[0],a[1]),s=Math.cos(i),u=Math.sin(i),l=new Te.Vector2(s,u);return o.add(l.normalize().multiplyScalar(r+2)),[o.x,o.y]}function Fi(a){let t=[...a].sort((l,c)=>l-c),n=Do(t,25),e=Do(t,75),i=e-n,r=n-1.5*i,o=e+1.5*i,s=t.filter(l=>l>=r&&l<=o);return a.filter(l=>s.includes(l))}function Do(a,t){let n=t/100*(a.length-1),e=Math.floor(n),i=Math.ceil(n);if(e===i)return a[e];let r=n-e;return a[e]*(1-r)+a[i]*r}var Gn=class extends Uo.EventDispatcher{start(){this.listenDeviceOrientation(),this.dispatchEvent({type:"start"})}setAbsoluteCompass(t,n){if(this.delta||this.emitCompass(t),!this.compassData.length)return;this.absoluteCompass={compass:t,time:n};let e=this.compassData.findIndex(l=>l.timestamp>=n);e===-1&&(e=this.compassData.length-1);let i=this.compassData[e-1],r=this.compassData[e],o;if(!i)o=r;else if(r)o=r.timestamp-n>i.timestamp-n?i:r;else return;let s=t-o.res;this.deltas.push(s);let u=Fi(this.deltas);u.length&&(this.delta=u.reduce((l,c)=>l+c,0)/u.length)}emitCompass(t){console.log("compass delta",this.delta,t),this.dispatchEvent({type:"compass",value:(t+this.delta+360)%360})}listenDeviceOrientation(){It?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}checkSensor(){var t=this;return g(function*(){return{deviceOrientation:yield t.checkDeviceOrientation()}})()}checkDeviceOrientation(){return g(function*(){var t;if(!It)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var n;return(yield(n=window.DeviceOrientationEvent)==null?void 0:n.requestPermission())==="granted"}catch(e){return!1}return!1})()}stop(){It?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),this.compassData=[],this.dispatchEvent({type:"stop"})}constructor(){super(),this.compassData=[],this.absoluteCompass=null,this.delta=0,this.deltas=[],this.deviceOrientationAbsHandler=t=>{let n=Date.now(),{alpha:e,beta:i,gamma:r}=t;if((0,zn.isNil)(e)||(0,zn.isNil)(i)||(0,zn.isNil)(r))return;let o=It?t.webkitCompassHeading:360-e;this.compassData.push({timestamp:n,res:o}),this.emitCompass(o)}}};var $i=class extends Fo.EventDispatcher{startCompass(){this.compass.start()}setPosition(t,n,e){this.history.push({position:t,time:n,clientTime:Date.now()-e,type:"vision"});let i=5;for(let o=0;o<this.history.length;o++){let s=this.history[o];if(U(s.position,t)>i)this.history.shift(),o--;else break}let r=this.getPosition("vision");this.dispatchEvent({type:"change-pos",value:r}),this.startPositionTimer()}setBeaconPosition(t,n,e){this.history.push({position:t,time:n,clientTime:Date.now()-e,type:"beacon"});let i=this.getPosition("beacon");this.dispatchEvent({type:"change-pos",value:i}),this.startPositionTimer()}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.autoCleanTimer&&this.timer.clearTimeout(this.autoCleanTimer),this.positionTimer=this.timer.setInterval(()=>{let t=this.getPosition("pdr");this.dispatchEvent({type:"change-pos",value:t})},20),this.autoCleanTimer=this.timer.setTimeout(()=>{this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=null},1e3)}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let n=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:n.position,compass:null,speed:0};let e=this.history.filter(l=>l.type==="vision"),i=Oi(e.map(l=>l.position));i!==null&&(this.compassAngle=i,this.dispatchEvent({type:"change-compass",value:i}));let r=n.clientTime,o=Date.now()-r,s=Di(this.history,o);return{success:!0,pos:this.compassAngle?Ui(n.position,s,360-this.compassAngle,o):n.position,compass:this.compassAngle,speed:$n(s)}}dispose(){this.compass.stop(),this.timer.dispose()}constructor(){super(),this.history=[],this.compass=new Gn,this.compassAngle=0,this.timer=new G,this.positionTimer=null,this.autoCleanTimer=null}};function Vi(a,t){return zi.apply(this,arguments)}function zi(){return zi=g(function*({brand:a,project:t},n){let{apiDomain:e,apiPath:{floorRange:i},apiInfo:r}=n,o=`${e}${i}?brand=${a}&project=${t}&phase=${t}&building=${t}`;return yield fetch(o,r).then(u=>u.json()).then(u=>u.data).then(u=>{let l=(u||[])[0];return l&&(l.info=JSON.parse(l.info)),l})}),zi.apply(this,arguments)}function Xi(a,t){return Gi.apply(this,arguments)}function Gi(){return Gi=g(function*({brand:a,project:t,floor:n,ts:e,resource_type_list:i},r){let{apiDomain:o,apiPath:{floorGraphic:s},apiInfo:u}=r,l=`${o}${s}?brand=${a}&project=${t}&phase=${t}&building=${t}&floor=${n}&ts=${e}&resource_type_list=${i}`;return yield fetch(l,u).then(p=>p.json()).then(p=>p.data).then(p=>((p||[]).map(h=>h.info=JSON.parse(h.info)),p||[]))}),Gi.apply(this,arguments)}function Qs(a,t){return ki.apply(this,arguments)}function ki(){return ki=g(function*({project:a,floor:t},n){let{apiDomain:e,apiInfo:i}=n,r=`${e}/api/inception-map/external_street/get?projectCode=${a}&floorCode=${t}`;return yield fetch(r,i).then(s=>s.json()).then(s=>s.data).then(s=>JSON.parse(s[0].streetInfo||"{}")).then(s=>s.fileId?Ys(s.fileId,n):null)}),ki.apply(this,arguments)}function Ys(a,t){return Hi.apply(this,arguments)}function Hi(){return Hi=g(function*(a,t){let{apiDomain:n,apiInfo:e}=t;return fetch(`${n}/api/inception-map/file/getFileStream?fileId=${a}`,e).then(i=>i.arrayBuffer()).then(i=>{let o=new TextDecoder("utf-8").decode(i);return o?JSON.parse(o):null})}),Hi.apply(this,arguments)}var Bt;function $o(a="aibee_map",t=1){return new Promise((n,e)=>{if(Bt)return n({db:Bt,type:"success"});let i=indexedDB.open(a,t);i.onupgradeneeded=function(r){Bt=r.target.result,console.log("onupgradeneeded"),n({db:Bt,type:"onupgradeneeded"})},i.onsuccess=r=>{Bt=r.target.result,n({db:Bt,type:"success"})},i.onerror=r=>{e(r)}})}function Wi(a,t,n=Bt){return new Promise((e,i)=>{n||i("\u6CA1\u6709db");let o=n.transaction([a],"readonly").objectStore(a).get(t);o.onsuccess=()=>{o.result?e(o.result.value):e(null)},o.onerror=s=>{console.log("[getVersionByKey]",s),e(null)}})}function zo(a,t,n,e=Bt){return new Promise((i,r)=>(e||r("\u6CA1\u6709db"),new Promise(g(function*(o,s){let u=yield Wi(a,t),l=e.transaction([a],"readwrite").objectStore(a),c=u!==null?l.put({key:t,value:n}):l.add({key:t,value:n});c.onsuccess=function(p){o(p)},c.onerror=function(p){s(p)}}))))}function me(a,t=Bt){t&&(t.objectStoreNames.contains(a)||t.createObjectStore(a,{keyPath:"key"}))}function Go(a=Bt){a==null||a.close(),Bt=null}var Hn=require("three");function ko(a,t){switch(a.l_type){case"graph":return Ks(a,t);case"wall":return Js(a,t);case"lane":return Zs(a,t);case"texture2d":case"texture3d":return ta(a,t);case"glb":return ea(a,t);case"store":return na(a,t);case"facility":return ia(a,t);case"parkingSpace":return ra(a,t);case"text":return oa(a,t)}}function Ks(a,t){let n=t.userData.center;it(a.elements,n);let e=[];a.elements.forEach(r=>{r.group==="ground"?t.createGround(r):e.push(r)});let i=e.reduce((r,o)=>{let{fillColor:s,fillOpacity:u,strokeColor:l,strokeOpacity:c,height:p,airHeight:h}=o,f=`${s.toLowerCase()}-${u}-${l.toLowerCase()}-${c}-${p}-${h}`;return c===0&&(f=`${s.toLowerCase()}-${u}-${p}-${h}`),r[f]?r[f].push(o):r[f]=[o],r},{});Object.values(i).forEach(r=>{let o=new Ye(t.context,r);t.mergeGraphicLayer.add(o)})}function Js(a,t){let n=t.userData.center;it(a.elements,n);let e=a.elements.reduce((i,r)=>{let{fillColor:o,fillOpacity:s,strokeColor:u,strokeOpacity:l,height:c}=r,p=`${o.toLowerCase()}-${s}-${u.toLowerCase()}-${l}-${c}`;return l===0&&(p=`${o.toLowerCase()}-${s}-${c}`),i[p]?i[p].push(r):i[p]=[r],i},{});Object.values(e).forEach(i=>{let r=new je(t.context,i);t.wallLayer.add(r)})}function Zs(a,t){let n=t.userData.center;it(a.elements,n);let e=a.elements.reduce((i,r)=>{let{fillColor:o,fillOpacity:s,strokeColor:u,strokeOpacity:l}=r,c=`${o.toLowerCase()}-${s}-${u.toLowerCase()}-${l}`;return l===0&&(c=`${o.toLowerCase()}-${s}`),i[c]?i[c].push(r):i[c]=[r],i},{});Object.values(e).forEach(i=>{let r=new Qe(t.context,i);t.laneLayer.add(r)})}function ta(a,t){let n=t.userData.center;if(it(a.elements,n),a.elements.length){let e=new Ae(t.context,a.elements);t.textureLayer.add(e)}}function ea(a,t){let n=t.userData.center;it(a.elements,n),a.elements.forEach(e=>{let i=Ct([e.center_x,e.center_y],n),r=new qe(t.context,v({},e,{url:e.secondUrl,rotate:e.secondRotate,width:e.secondWidth,center_x:i[0],center_y:i[1]}));t.glbModelLayer.add(r)})}function na(a,t){let n=t.userData.center;it(a.elements,n),a.elements.map(e=>{let i=Ct([e.center_x,e.center_y],n),r=t.addGraphic(e);t.userData.graphics.push(r),t.userData.graphicMap.set(e.id,r);try{let o=new V(t.context,{id:e.id,icon:e.poi_info.icon,text:e.poi_info.showName||e.store_name||e.poi_info.text,position:{x:i[0],y:i[1],z:e.airHeight+e.height},icon_size:[24,24],level:e.poi_info.level||0});t.poiLayer2.pushPoi(o),o&&(o.userData.type="store",o.userData.data=e,o.userData.floor=t.name)}catch(o){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",o,e)}})}function ia(a,t){let n=t.userData.center;it(a.elements,n),a.elements.map(e=>{let i=Ct([e.center_x,e.center_y],n),r=t.addGraphic(e);if(t.userData.graphics.push(r),t.userData.graphicMap.set(e.id,r),e.poi_info){let o=new V(t.context,{id:e.id,icon:e.poi_info.icon,text:e.poi_info.showName||e.store_name||e.poi_info.text,position:{x:i[0],y:i[1],z:e.airHeight+e.height},icon_size:[24,24],level:e.poi_info.level||0});t.poiLayer2.pushPoi(o),o.userData.type="facility",o.userData.data=e,o.userData.floor=t.name}else console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info",e)})}function ra(a,t){let n=t.userData.center;it(a.elements,n);let e=[],i=new Map;a.elements.forEach(o=>{let s=t.addGraphic(o);e.push(s),i.set(o.id,s);let u=Ct([o.center_x,o.center_y],n);if(o.texts[0]){let l=new V(t.context,{id:o.id,text:o.texts[0],position:{x:u[0],y:u[1],z:o.airHeight+o.height}});l&&(l.userData.type="parkingSpace",l.userData.data=o,l.userData.floor=t.name),t.poiLayer2.pushPoi(l)}});let r=a.elements.filter(o=>Si[o.parkingType]).map(o=>{let s=Ct([o.center_x,o.center_y],n),u=Jn(o.geometry.coords,s);return{uuid:o.id,iconUrl:Si[o.parkingType],name:o.texts[0],deltaHeight:o.deltaHeight,airHeight:o.airHeight,height:o.height,geometry:v({},o.geometry,{coords:u}),opacity:o.fillOpacity,visible:!0}});if(r.length){let o=new Ae(t.context,r);t.textureLayer.add(o)}t.userData.parkingSpaces=e,t.userData.parkingSpacesGraphicMap=i}function oa(a,t){let n=t.userData.center;it(a.elements,n);let e=new Ke(t.context,a.elements.map(i=>{let r=Ct([i.center_x,i.center_y],n);return v({},i,{center_x:r[0],center_y:r[1]})}));t.textTextureLayer.add(e)}var sa={loadRoadNetwork:!1},ji="map_version",qi="route_version",Qi="facility_version",Yi="map_data",kn="road_network_data",Ki="facility_data",Ji=class extends Hn.EventDispatcher{initDb(){var t=this;return g(function*(){try{let{db:n,type:e}=yield $o("aibee_map",2);e==="onupgradeneeded"&&(me(ji),me(qi),me(Qi),me(Yi),me(kn),me(Ki)),t.db=n}catch(n){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",n)}})()}load(t){var n=this;return g(function*(){if(Array.isArray(t))n.floors=t;else{let e=yield fetch(t).then(i=>i.json());e.code==="0"&&(n.floors=e.data.list)}})()}setCacheData(t,n,e){return this.initDbPromise.then(()=>zo(t,`${n}`,e,this.db))}getCacheData(t,n){return this.initDbPromise.then(()=>Wi(t,`${n}`,this.db))}getFloorCacheKey(t){return`${t.floor_id}`}getFloorData(t){var n=this;return g(function*(){let e=yield n.getFloorJsonData(t);return e?n.getDataByJson(e):null})()}getFloorDataByFloorInfo(t){var n=this;return g(function*(){let e=yield n.getFloorJsonDataByFloorInfo(t);return n.getDataByJson(e)})()}getFloorJsonDataByFloorInfo(t){var n=this;return g(function*(){let e=n.getFloorCacheKey(t);console.time("zstd_json");let i=yield fetch(t.map_url).then(r=>r.json());return i.floor=t.floor,console.timeEnd("zstd_json"),n.setCacheData(Yi,e,i),n.setCacheData(ji,e,t.version_id),i})()}getFloorJsonData(t){var n=this;return g(function*(){let e=n.floors.find(r=>r.floor===t);if(!e)return null;let i=n.getFloorCacheKey(e);try{if((yield n.getCacheData(ji,i))===e.version_id){let o=yield n.getCacheData(Yi,i);if(o)return o}return n.getFloorJsonDataByFloorInfo(e)}catch(r){return console.log("[get floor data error]",r),n.getFloorJsonDataByFloorInfo(e)}})()}getRoadNetworkData(){var t=this;return g(function*(){return(yield Promise.all(t.floors.map(g(function*(e){let i=t.getFloorCacheKey(e);try{if((yield t.getCacheData(qi,i))===e.version_id){let s=yield t.getCacheData(kn,i);if(s)return s}let o=yield fetch(e.route_url).then(s=>s.json());return t.setCacheData(kn,i,o),t.setCacheData(qi,i,e.version_id),o}catch(r){let o=yield fetch(e.route_url).then(s=>s.json());return t.setCacheData(kn,i,o),o}})))).filter(e=>e.points)})()}getFacilitiesData(){var t=this;return g(function*(){let n=t.floors.reduce((r,o)=>r.updated_at>o.updated_at?r:o,t.floors[0]);if(!n)return null;let e=t.getFloorCacheKey(n),i=g(function*(){let r=yield fetch(n.entry_infra_url).then(o=>o.json());return r&&(t.setCacheData(Ki,e,r),t.setCacheData(Qi,e,n.version_id)),r});try{if((yield t.getCacheData(Qi,e))===n.version_id){let o=yield t.getCacheData(Ki,e);if(o)return o}return i()}catch(r){return console.log("[get facility error]",r),i()}})()}getOtherDataByFreeTime(){return g(function*(){})()}getMulFloorsData(t){var n=this;return g(function*(){return Promise.all(t.map(e=>n.getFloorData(e))).then(e=>e.filter(i=>i))})()}getDataByUrl(t){var n=this;return g(function*(){let e=yield fetch(t).then(i=>i.json());return n.getDataByJson(e)})()}getDataByJson(t,n){var e=this;return g(function*(){return n=e.getFloorBaseLayer(t,n),yield e.getFloorContentLayer(t,n),e.changeFloorBox(t,n),n})()}changeFloorBox(t,n){n.updateBox();let e=n.box.getSize(new Hn.Vector3),i=Math.max(e.x,e.y,e.z);n.userData.height=i/4+t.floorHeight}switchFloor(t){var n=this;return g(function*(){return new Promise(e=>{let i={run:()=>n._switchFloor(t),meta:{type:"switchFloor"}},r=n.taskQueue.replaceByMetaType(i),o=({task:s,res:u})=>{s.tid===r&&(n.taskQueue.removeEventListener("active-task-end",o),e(u))};n.taskQueue.addEventListener("active-task-end",o)})})()}_switchFloor(t){var n=this;return g(function*(){var e;let i=t;if(typeof t=="string"){let l=yield n.getFloorJsonData(t);if(l)i=l;else return null}let r=new mt(n.bmap.context),o=n.floors.find(l=>l.floor===i.floor);var s;let u=(s=o==null?void 0:o.map_angle)!=null?s:0;return n.bmap.dispatchEvent({type:tt.SWITCH_FLOOR_BEFORE,data:{curFloor:r,graphics:[]}}),n.dispatchEvent({type:"switch-floor-before",data:{curFloor:r,graphics:[]}}),n.bmap.context.control.setAzimuthalAngle(u/180*Math.PI,!0),n.getFloorBaseLayer(i,r),n.changeFloorBox(i,r),n.bmap.buildingCenter=r.userData.center,n.bmap.currentBuildGround=(e=r.userData.data.layers.find(l=>l.l_type==="range"))==null?void 0:e.elements[0],n.bmap.context.switchFloor(r),n.bmap.initialFloorCamera(),yield un(),n.dispatchEvent({type:"switch-floor-ground",data:{curFloor:r,graphics:[]}}),yield n.getFloorContentLayer(i,r),n.changeFloorBox(i,r),n.bmap.initialFloorCamera(),n.bmap.context.cameraBound.updateBox(),n.dispatchEvent({type:"switch-floor-after",data:{curFloor:r,graphics:r.graphicLayer.children}}),n.bmap.dispatchEvent({type:tt.SWITCH_FLOOR_AFTER,data:{curFloor:r,graphics:r.graphicLayer.children}}),r})()}getFloorBaseLayer(t,n){n||(n=new mt(this.bmap.context));let e=[0,0];return t.layers.forEach(i=>{switch(i.l_type){case"range":let r=i.elements[0];e=[r.center_x,r.center_y];break;case"ground":it(i.elements,e);let o=i.elements.map(s=>new H(this.bmap.context,s));n.addGrounds(o),console.log("grounds",o);break;default:break}}),n.userData.center=e,n.name=t.floor,n.userData.data=t,n}getFloorContentLayer(t,n){var e=this;return g(function*(){n||(n=new mt(e.bmap.context)),n.userData.graphics=[],n.userData.graphicMap=new Map;let i=Date.now();for(let r=0;r<t.layers.length;r++){let o=t.layers[r];["range","ground"].includes(o.l_type)||(ko(o,n),console.log("time",Date.now()-i,o.l_type),Date.now()-i>16&&(yield un(),i=Date.now()))}return n})()}clear(){var t=this;return g(function*(){var n;Go((n=t.db)!=null?n:void 0)})()}dispose(){this.clear()}constructor(t){super(),this.bmap=t,this.floors=[],this.initDbPromise=Promise.resolve(),this.db=null,this.taskQueue=new ue,this.initDbPromise=this.initDb()}};var Zi=class{load(t){var n=this;return g(function*(){let e=se(t);if(n.cacheData.has(e))return n.cacheData.get(e);let[,i]=yield Promise.all([n.loadBuildGround(t),Xi(t,n.bmap.config)]),r=se({floor:t.floor,ts:t.ts});it(i.map(s=>s.info),n.bmap.buildingCenter,n.floorDataLengthMap.get(r)||0),i.forEach(s=>s.info.transformToBuildingGround=!1),n.cacheData.set(e,i);let o=n.floorDataLengthMap.get(r)||0;return n.floorDataLengthMap.set(r,o+i.length),n.loadExternalStreet(t),i})()}loadExternalStreet(t){return g(function*(){})()}switchFloorByData(t,n){if(!t.length)return;let e=n.userData.legacyToGraphicMap||new Map,i=n.userData.graphicMap||new Map,{ground:r,markGraphic:o,graphic:s}=this.bmap.config;for(let u=0;u<t.length;u++){let l=t[u];l.info.group==="ground"?(l.info.fillColor=r.color,l.info.fillOpacity=r.opacity,l.info.height=r.height,l.info.stroke=r.stroke,l.info.strokeColor=r.strokeColor,l.info.strokeOpacity=r.strokeOpacity):l.info.userData.mark?(l.info.height=o.height,l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity):(l.info.fillOpacity=s.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=o.height,l.info.fillColor=o.color,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity))}for(let u of t){if(u.info.group==="ground")n.createGround(u.info);else{let l=n.addGraphic(u.info);l.userData.data=u,e.set(u.legacy_id,l)}i.set(u.element_uuid,u)}n.userData.legacyToGraphicMap=e,n.userData.graphicMap=i,n.updateBox(),n===this.bmap.context.currentFloor?(this.bmap.triggerHooks(tt.SWITCH_FLOOR_BEFORE,{curFloor:n,graphics:n.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(tt.SWITCH_FLOOR_AFTER,{curFloor:n,graphics:n.graphicLayer.children})):this.bmap.switchFloorByFloor(n)}filterData(t,n){let e=n.userData.graphicMap||new Map;return t.filter(i=>!e.has(i.element_uuid))}switchFloorByStoreData(t,n){var e=this;return g(function*(){let i=yield e.load(v({},t,{resource_type_list:"6"})),r=e.filterData(i,n);e.switchFloorByData(r,n)})()}switchFloorByOtherData(t,n){var e=this;return g(function*(){let i=yield e.load(v({},t,{resource_type_list:"1,2,3,4"})),r=e.filterData(i,n);e.switchFloorByData(r,n)})()}loadBuildGround({brand:t,project:n}){var e=this;return g(function*(){let i=yield e.loadBuildingGround({brand:t,project:n});return e.bmap.currentBuildGround=i,e.bmap.changeBuildingCenter(i,{brand:t,project:n}),e.bmap.currentBuildGround})()}loadBuildingGround({brand:t,project:n}){var e=this;return g(function*(){let i=se({brand:t,project:n});if(e.buildingGroundMap.has(i))return e.buildingGroundMap.get(i);let r=Vi({brand:t,project:n},e.bmap.config).then(o=>(e.buildingGroundMap.set(i,o),o));return e.buildingGroundMap.set(i,r),r})()}switchFloor(t){var n=this;return g(function*(){let e=new mt(n.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([n.switchFloorByStoreData(t,e),n.switchFloorByOtherData(t,e)])}catch(i){console.log(i)}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}};
|