spacemap 0.1.5 → 0.1.7
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/README.md +22 -3
- package/dist/spacemap.iife.js +49 -38
- package/dist/spacemap.js +55 -44
- package/index.d.ts +19 -1
- package/index.js +232 -28
- package/package.json +1 -1
package/dist/spacemap.iife.js
CHANGED
|
@@ -4047,7 +4047,7 @@ void main() {
|
|
|
4047
4047
|
|
|
4048
4048
|
}
|
|
4049
4049
|
|
|
4050
|
-
}`,nh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ic(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new fu({vertexShader:eh,fragmentShader:th,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new As(new $l(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},rh=class extends mi{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new nh,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new q,C=null,w=new sd;w.viewport=new sa;let T=new sd;T.viewport=new sa;let E=[w,T],D=new Sd,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}O=null,k=null,h.reset();for(let e in g)delete g[e];e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,ae.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,A),r.addEventListener(`selectstart`,A),r.addEventListener(`selectend`,A),r.addEventListener(`squeeze`,A),r.addEventListener(`squeezestart`,A),r.addEventListener(`squeezeend`,A),r.addEventListener(`end`,j),r.addEventListener(`inputsourceschange`,M),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?$n:Qn,a=_.stencil?Kn:Vn);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new la(d.textureWidth,d.textureHeight,{format:Zn,type:In,depthTexture:new Pc(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new la(f.framebufferWidth,f.framebufferHeight,{format:Zn,type:In,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ae.setContext(r),ae.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function M(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let ee=new J,N=new J;function te(e,t,n){ee.setFromMatrixPosition(t.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);let r=ee.distanceTo(N),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ne(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;ne(D,i);for(let e=0;e<a.length;e++)ne(a[e],i);a.length===2?te(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),re(e,D,i)};function re(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=vi*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(D)},this.getCameraTexture=function(e){return g[e]};let P=null;function ie(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==D.cameras.length&&(D.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=E[n];o===void 0&&(o=new sd,o.layers.enable(n),o.viewport=new sa,E[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(D.matrix.copy(o.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),i===!0&&D.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new Ic,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}P&&P(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ae=new Yd;ae.setAnimationLoop(ie),this.setAnimationLoop=function(e){P=e},this.dispose=function(){}}},ih=new xa,ah=new Y;function oh(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,cu(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,ih.copy(o),ih.x*=-1,ih.y*=-1,ih.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(ih.y*=-1,ih.z*=-1),e.envMapRotation.value.setFromMatrix4(ah.makeRotationFromEuler(ih)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function sh(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return K(`WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?G(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):G(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var ch=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),lh=null;function uh(){return lh===null&&(lh=new Ws(ch,16,16,nr,Un),lh.name=`DFG_LUT`,lh.minFilter=Nn,lh.magFilter=Nn,lh.wrapS=On,lh.wrapT=On,lh.generateMipmaps=!1,lh.needsUpdate=!0),lh}var dh=class{constructor(e={}){let{canvas:t=oi(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=In}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([ir,rr,tr]),g=new Set([In,Vn,zn,Kn,Wn,Gn]),_=new Uint32Array(4),v=new Int32Array(4),y=null,b=null,x=[],S=[],C=null;this.domElement=t,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.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,T=!1;this._outputColorSpace=Xr;let E=0,D=0,O=null,k=-1,A=null,j=new sa,M=new sa,ee=null,N=new X(0),te=0,ne=t.width,re=t.height,P=1,ie=null,ae=null,F=new sa(0,0,ne,re),I=new sa(0,0,ne,re),oe=!1,se=new uc,ce=!1,le=!1,ue=new Y,de=new J,fe=new sa,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},me=!1;function he(){return O===null?P:1}let L=n;function ge(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r183`),t.addEventListener(`webglcontextlost`,Le,!1),t.addEventListener(`webglcontextrestored`,Re,!1),t.addEventListener(`webglcontextcreationerror`,ze,!1),L===null){let t=`webgl2`;if(L=ge(t,e),L===null)throw ge(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw K(`WebGLRenderer: `+e.message),e}let R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe;function Fe(){R=new Af(L),R.init(),Me=new $m(L,R),_e=new of(L,R,e,Me),z=new Zm(L,R),_e.reversedDepthBuffer&&d&&z.buffers.depth.setReversed(!0),ve=new Nf(L),B=new jm,V=new Qm(L,R,z,B,_e,Me,ve),ye=new kf(w),be=new Xd(L),Ne=new rf(L,be),xe=new jf(L,be,ve,Ne),Se=new Ff(L,xe,be,Ne,ve),ke=new Pf(L,_e,V),Ee=new sf(B),Ce=new Am(w,ye,R,_e,Ne,Ee),we=new oh(w,B),Te=new Fm,H=new Hm(R),Oe=new nf(w,ye,z,Se,p,s),De=new Xm(w,Se,_e),Pe=new sh(L,ve,_e,z),Ae=new af(L,R,ve),je=new Mf(L,R,ve),ve.programs=Ce.programs,w.capabilities=_e,w.extensions=R,w.properties=B,w.renderLists=Te,w.shadowMap=De,w.state=z,w.info=ve}Fe(),m!==1009&&(C=new Lf(m,t.width,t.height,r,i));let Ie=new rh(w,L);this.xr=Ie,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let e=R.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=R.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(e){e!==void 0&&(P=e,this.setSize(ne,re,!1))},this.getSize=function(e){return e.set(ne,re)},this.setSize=function(e,n,r=!0){if(Ie.isPresenting){G(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ne=e,re=n,t.width=Math.floor(e*P),t.height=Math.floor(n*P),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),C!==null&&C.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ne*P,re*P).floor()},this.setDrawingBufferSize=function(e,n,r){ne=e,re=n,P=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){console.error(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){console.warn(`THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}C.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(j)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,r){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,r),z.viewport(j.copy(F).multiplyScalar(P).round())},this.getScissor=function(e){return e.copy(I)},this.setScissor=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),z.scissor(M.copy(I).multiplyScalar(P).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){z.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor(...arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(O!==null){let t=O.texture.format;e=h.has(t)}if(e){let e=O.texture.type,t=g.has(e),n=Oe.getClearColor(),r=Oe.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,L.clearBufferuiv(L.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,L.clearBufferiv(L.COLOR,0,v))}else r|=L.COLOR_BUFFER_BIT}t&&(r|=L.DEPTH_BUFFER_BIT),n&&(r|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&L.clear(r)},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(){t.removeEventListener(`webglcontextlost`,Le,!1),t.removeEventListener(`webglcontextrestored`,Re,!1),t.removeEventListener(`webglcontextcreationerror`,ze,!1),Oe.dispose(),Te.dispose(),H.dispose(),B.dispose(),ye.dispose(),Se.dispose(),Ne.dispose(),Pe.dispose(),Ce.dispose(),Ie.dispose(),Ie.removeEventListener(`sessionstart`,Ke),Ie.removeEventListener(`sessionend`,qe),Je.stop()};function Le(e){e.preventDefault(),li(`WebGLRenderer: Context Lost.`),T=!0}function Re(){li(`WebGLRenderer: Context Restored.`),T=!1;let e=ve.autoReset,t=De.enabled,n=De.autoUpdate,r=De.needsUpdate,i=De.type;Fe(),ve.autoReset=e,De.enabled=t,De.autoUpdate=n,De.needsUpdate=r,De.type=i}function ze(e){K(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Be(e){let t=e.target;t.removeEventListener(`dispose`,Be),Ve(t)}function Ve(e){He(e),B.remove(e)}function He(e){let t=B.get(e).programs;t!==void 0&&(t.forEach(function(e){Ce.releaseProgram(e)}),e.isShaderMaterial&&Ce.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=pe);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=rt(e,t,n,r,i);z.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=xe.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ne.setup(i,r,s,n,c);let h,g=Ae;if(c!==null&&(h=be.get(c),g=je,g.setIndex(h)),i.isMesh)r.wireframe===!0?(z.setLineWidth(r.wireframeLinewidth*he()),g.setMode(L.LINES)):g.setMode(L.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),z.setLineWidth(e*he()),i.isLineSegments?g.setMode(L.LINES):i.isLineLoop?g.setMode(L.LINE_LOOP):g.setMode(L.LINE_STRIP)}else i.isPoints?g.setMode(L.POINTS):i.isSprite&&g.setMode(L.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)di(`WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(R.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?be.get(c).bytesPerElement:1,o=B.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(L,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Ue(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,et(e,t,n),e.side=0,e.needsUpdate=!0,et(e,t,n),e.side=2):et(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),b=H.get(n),b.init(t),S.push(b),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),b.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];Ue(a,n,e),r.add(a)}else Ue(t,n,e),r.add(t)}),b=S.pop(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){B.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}R.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let We=null;function Ge(e){We&&We(e)}function Ke(){Je.stop()}function qe(){Je.start()}let Je=new Yd;Je.setAnimationLoop(Ge),typeof self<`u`&&Je.setContext(self),this.setAnimationLoop=function(e){We=e,Ie.setAnimationLoop(e),e===null?Je.stop():Je.start()},Ie.addEventListener(`sessionstart`,Ke),Ie.addEventListener(`sessionend`,qe),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){K(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(T===!0)return;let n=Ie.enabled===!0&&Ie.isPresenting===!0,r=C!==null&&(O===null||n)&&C.begin(w,O);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(t),t=Ie.getCamera()),e.isScene===!0&&e.onBeforeRender(w,e,t,O),b=H.get(e,S.length),b.init(t),S.push(b),ue.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromProjectionMatrix(ue,ni,t.reversedDepth),le=this.localClippingEnabled,ce=Ee.init(this.clippingPlanes,le),y=Te.get(e,x.length),y.init(),x.push(y),Ie.enabled===!0&&Ie.isPresenting===!0){let e=w.xr.getDepthSensingMesh();e!==null&&Ye(e,t,-1/0,w.sortObjects)}Ye(e,t,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(ie,ae),me=Ie.enabled===!1||Ie.isPresenting===!1||Ie.hasDepthSensing()===!1,me&&Oe.addToRenderList(y,e),this.info.render.frame++,ce===!0&&Ee.beginShadows();let i=b.state.shadowsArray;if(De.render(i,e,t),ce===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&C.hasRenderPass())===!1){let n=y.opaque,r=y.transmissive;if(b.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];Ze(n,r,e,a)}me&&Oe.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];Xe(y,e,n,n.viewport)}}else r.length>0&&Ze(n,r,e,t),me&&Oe.render(e),Xe(y,e,t)}O!==null&&D===0&&(V.updateMultisampleRenderTarget(O),V.updateRenderTargetMipmap(O)),r&&C.end(w),e.isScene===!0&&e.onAfterRender(w,e,t),Ne.resetDefaultState(),k=-1,A=null,S.pop(),S.length>0?(b=S[S.length-1],ce===!0&&Ee.setGlobalState(w.clippingPlanes,b.state.camera)):b=null,x.pop(),y=x.length>0?x[x.length-1]:null};function Ye(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)b.pushLight(e),e.castShadow&&b.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||se.intersectsSprite(e)){r&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ue);let t=Se.update(e),i=e.material;i.visible&&y.push(e,t,i,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||se.intersectsObject(e))){let t=Se.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),fe.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),fe.copy(e.boundingSphere.center)),fe.applyMatrix4(e.matrixWorld).applyMatrix4(ue)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&y.push(e,t,s,n,fe.z,o)}}else i.visible&&y.push(e,t,i,n,fe.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Ye(i[e],t,n,r)}function Xe(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;b.setupLightsView(n),ce===!0&&Ee.setGlobalState(w.clippingPlanes,n),r&&z.viewport(j.copy(r)),i.length>0&&Qe(i,t,n),a.length>0&&Qe(a,t,n),o.length>0&&Qe(o,t,n),z.buffers.depth.setTest(!0),z.buffers.depth.setMask(!0),z.buffers.color.setMask(!0),z.setPolygonOffset(!1)}function Ze(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[r.id]===void 0){let e=R.has(`EXT_color_buffer_half_float`)||R.has(`EXT_color_buffer_float`);b.state.transmissionRenderTarget[r.id]=new la(1,1,{generateMipmaps:!0,type:e?Un:In,minFilter:Fn,samples:Math.max(4,_e.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xi.workingColorSpace})}let a=b.state.transmissionRenderTarget[r.id],o=r.viewport||j;a.setSize(o.z*w.transmissionResolutionScale,o.w*w.transmissionResolutionScale);let s=w.getRenderTarget(),c=w.getActiveCubeFace(),l=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(N),te=w.getClearAlpha(),te<1&&w.setClearColor(16777215,.5),w.clear(),me&&Oe.render(n);let u=w.toneMapping;w.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),b.setupLightsView(r),ce===!0&&Ee.setGlobalState(w.clippingPlanes,r),Qe(e,n,r),V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a),R.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,$e(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a))}w.setRenderTarget(s,c,l),w.setClearColor(N,te),d!==void 0&&(r.viewport=d),w.toneMapping=u}function Qe(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&$e(o,t,n,s,l,c)}}function $e(e,t,n,r,i,a){e.onBeforeRender(w,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(w,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=2):w.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(w,t,n,r,i,a)}function et(e,t,n){t.isScene!==!0&&(t=pe);let r=B.get(e),i=b.state.lights,a=b.state.shadowsArray,o=i.state.version,s=Ce.getParameters(e,i.state,a,t,n),c=Ce.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=ye.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Be),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return nt(e,s),d}else s.uniforms=Ce.getUniforms(e),e.onBeforeCompile(s,w),d=Ce.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Ee.uniform),nt(e,s),r.needsLights=at(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=d,r.uniformsList=null,d}function tt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Wp.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function nt(e,t){let n=B.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function rt(e,t,n,r,i){t.isScene!==!0&&(t=pe),V.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=O===null?w.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:Zr,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=ye.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(h=w.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=B.get(r),y=b.state.lights;if(ce===!0&&(le===!0||e!==A)){let t=e===A&&r.id===k;Ee.setState(r,e,t)}let x=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?x=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?x=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ee.numPlanes||v.numIntersection!==Ee.numIntersection)?x=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h?v.morphTargetsCount!==_&&(x=!0):x=!0:x=!0:x=!0:(x=!0,v.__version=r.version);let S=v.currentProgram;x===!0&&(S=et(r,t,i));let C=!1,T=!1,E=!1,D=S.getUniforms(),j=v.uniforms;if(z.useProgram(S.program)&&(C=!0,T=!0,E=!0),r.id!==k&&(k=r.id,T=!0),C||A!==e){z.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),D.setValue(L,`projectionMatrix`,e.projectionMatrix),D.setValue(L,`viewMatrix`,e.matrixWorldInverse);let t=D.map.cameraPosition;t!==void 0&&t.setValue(L,de.setFromMatrixPosition(e.matrixWorld)),_e.logarithmicDepthBuffer&&D.setValue(L,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&D.setValue(L,`isOrthographic`,e.isOrthographicCamera===!0),A!==e&&(A=e,T=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&D.setValue(L,`directionalShadowMap`,y.state.directionalShadowMap,V),y.state.spotShadowMap.length>0&&D.setValue(L,`spotShadowMap`,y.state.spotShadowMap,V),y.state.pointShadowMap.length>0&&D.setValue(L,`pointShadowMap`,y.state.pointShadowMap,V)),i.isSkinnedMesh){D.setOptional(L,i,`bindMatrix`),D.setOptional(L,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),D.setValue(L,`boneTexture`,e.boneTexture,V))}i.isBatchedMesh&&(D.setOptional(L,i,`batchingTexture`),D.setValue(L,`batchingTexture`,i._matricesTexture,V),D.setOptional(L,i,`batchingIdTexture`),D.setValue(L,`batchingIdTexture`,i._indirectTexture,V),D.setOptional(L,i,`batchingColorTexture`),i._colorsTexture!==null&&D.setValue(L,`batchingColorTexture`,i._colorsTexture,V));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&ke.update(i,n,S),(T||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,D.setValue(L,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=uh()),T&&(D.setValue(L,`toneMappingExposure`,w.toneMappingExposure),v.needsLights&&it(j,E),a&&r.fog===!0&&we.refreshFogUniforms(j,a),we.refreshMaterialUniforms(j,r,P,re,b.state.transmissionRenderTarget[e.id]),Wp.upload(L,tt(v),j,V)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Wp.upload(L,tt(v),j,V),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&D.setValue(L,`center`,i.center),D.setValue(L,`modelViewMatrix`,i.modelViewMatrix),D.setValue(L,`normalMatrix`,i.normalMatrix),D.setValue(L,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Pe.update(n,S),Pe.bind(n,S)}}return S}function it(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function at(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(e,t,n){let r=B.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),B.get(e.texture).__webglTexture=t,B.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=B.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let ot=L.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){O=e,E=t,D=n;let r=null,i=!1,a=!1;if(e){let o=B.get(e);if(o.__useDefaultFramebuffer!==void 0){z.bindFramebuffer(L.FRAMEBUFFER,o.__webglFramebuffer),j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest,z.viewport(j),z.scissor(M),z.setScissorTest(ee),k=-1;return}else if(o.__webglFramebuffer===void 0)V.setupRenderTarget(e);else if(o.__hasExternalTextures)V.rebindTextures(e,B.get(e.texture).__webglTexture,B.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&B.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);V.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=B.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&V.useMultisampledRTT(e)===!1?B.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest}else j.copy(F).multiplyScalar(P).floor(),M.copy(I).multiplyScalar(P).floor(),ee=oe;if(n!==0&&(r=ot),z.bindFramebuffer(L.FRAMEBUFFER,r)&&z.drawBuffers(e,r),z.viewport(j),z.scissor(M),z.setScissorTest(ee),i){let r=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=B.get(e.textures[t]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,t.__webglTexture,n)}k=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){z.bindFramebuffer(L.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(c)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!_e.textureTypeReadable(l)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&L.readPixels(t,n,r,i,Me.convert(c),Me.convert(l),a)}finally{let e=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){z.bindFramebuffer(L.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!_e.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.bufferData(L.PIXEL_PACK_BUFFER,a.byteLength,L.STREAM_READ),L.readPixels(t,n,r,i,Me.convert(l),Me.convert(u),0);let f=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,f);let p=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await fi(L,p,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,a),L.deleteBuffer(d),L.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;V.setTexture2D(e,0),L.copyTexSubImage2D(L.TEXTURE_2D,n,0,0,o,s,i,a),z.unbindTexture()};let st=L.createFramebuffer(),ct=L.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Me.convert(t.format),_=Me.convert(t.type),v;t.isData3DTexture?(V.setTexture3D(t,0),v=L.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(V.setTexture2DArray(t,0),v=L.TEXTURE_2D_ARRAY):(V.setTexture2D(t,0),v=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,t.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,t.unpackAlignment);let y=L.getParameter(L.UNPACK_ROW_LENGTH),b=L.getParameter(L.UNPACK_IMAGE_HEIGHT),x=L.getParameter(L.UNPACK_SKIP_PIXELS),S=L.getParameter(L.UNPACK_SKIP_ROWS),C=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,h.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,h.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,l),L.pixelStorei(L.UNPACK_SKIP_ROWS,u),L.pixelStorei(L.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=B.get(e),r=B.get(t),h=B.get(n.__renderTarget),g=B.get(r.__renderTarget);z.bindFramebuffer(L.READ_FRAMEBUFFER,h.__webglFramebuffer),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(e).__webglTexture,i,d+n),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(t).__webglTexture,a,m+n)),L.blitFramebuffer(l,u,o,s,f,p,o,s,L.DEPTH_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||B.has(e)){let n=B.get(e),r=B.get(t);z.bindFramebuffer(L.READ_FRAMEBUFFER,st),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,ct);for(let e=0;e<c;e++)w?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,n.__webglTexture,i),T?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,r.__webglTexture,a),i===0?T?L.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):L.copyTexSubImage2D(v,a,f,p,l,u,o,s):L.blitFramebuffer(l,u,o,s,f,p,o,s,L.COLOR_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?L.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h);L.pixelStorei(L.UNPACK_ROW_LENGTH,y),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,b),L.pixelStorei(L.UNPACK_SKIP_PIXELS,x),L.pixelStorei(L.UNPACK_SKIP_ROWS,S),L.pixelStorei(L.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&L.generateMipmap(v),z.unbindTexture()},this.initRenderTarget=function(e){B.get(e).__webglFramebuffer===void 0&&V.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?V.setTextureCube(e,0):e.isData3DTexture?V.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?V.setTexture2DArray(e,0):V.setTexture2D(e,0),z.unbindTexture()},this.resetState=function(){E=0,D=0,O=null,z.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return ni}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Xi._getDrawingBufferColorSpace(e),t.unpackColorSpace=Xi._getUnpackColorSpace()}},fh=-(2**40),ph=8;function mh(e,t){return e<0||e>=ph?fh:t*ph+e}function hh(e){return(e%ph+ph)%ph}function gh(e){return(e-hh(e))/ph}function _h(e){return e===fh?null:ln(hh(e),gh(e))}function vh(e){let t=e.indexOf(`-`);if(t<=0)return null;let n=cn(e.slice(0,t));if(n===void 0)return null;let r=Number(e.slice(t+1));if(!Number.isInteger(r)||r>2147483647||r<-2147483648)return null;let i=mh(n,r);return i===fh?null:i}function yh(e){let t=new Set;for(let n of e){let e=vh(n);e!==null&&t.add(e)}return t}function bh(e){return e+7&-8}function xh(e){return{subFormat:e.getUint16(24,!0),source:e.getUint8(26),idType:e.getUint8(27),rowCount:e.getUint32(28,!0)}}function Sh(e,t){return ln(e.idType,e.id[t])}function Ch(e,t){return mh(e.idType,e.id[t])}function wh(e,t){let n=Zt,r=new Int32Array(e,n,t);n+=bh(t*4);let i=new Uint8Array(e,n,t);n+=bh(t);let a=new Int32Array(e,n,t);n+=bh(t*4);let o=new Uint8Array(e,n,t);return n+=bh(t),{id:r,objectType:i,parentId:a,scale:o,offset:n}}function Th(e,t,n){let r=n,i=new Float64Array(e,r,t);r+=t*8;let a=new Float32Array(e,r,t);r+=bh(t*4);let o=new Float32Array(e,r,t);r+=bh(t*4);let s=new Float32Array(e,r,t);r+=bh(t*4);let c=new Float32Array(e,r,t);r+=bh(t*4);let l=new Float32Array(e,r,t);r+=bh(t*4);let u=new Float32Array(e,r,t);r+=bh(t*4);let d=new Float32Array(e,r,t);r+=bh(t*4);let f=new Float32Array(e,r,t);return r+=bh(t*4),{epochJd:i,a,e:o,i:s,om:c,w:l,ma:u,n:d,radiusKm:f,offset:r}}function Eh(e,t,n){let{subFormat:r,rowCount:i,source:a,idType:o}=xh(new DataView(e));if(o===an.UNKNOWN&&i>0&&console.warn(`elements payload has unknown id-type — ${i} row(s) will lack reconstructed IDs`),r===1)return Oh(e,i,t,n,a,o);if(r===2)return Dh(e,i,t,n,a,o);if(r!==0)throw Error(`Unknown elements sub-format: ${r}`);let{id:s,objectType:c,parentId:l,scale:u,offset:d}=wh(e,i),f=Th(e,i,d),p=f.offset,m=new Float32Array(e,p,i);p+=bh(i*4);let h=new Float32Array(e,p,i);p+=bh(i*4);let g=new Uint8Array(e,p,i);p+=bh(i);let _=new Uint8Array(e,p,i);p+=bh(i);let v=new Float32Array(e,p,i),y={validityStart:t,validityEnd:n,source:a,idType:o};return{kind:`keplerian`,id:s,objectType:c,parentId:l,scale:u,epochJd:f.epochJd,a:f.a,e:f.e,i:f.i,om:f.om,w:f.w,ma:f.ma,n:f.n,radiusKm:f.radiusKm,omDot:m,wDot:h,hasLocalized:g,flags:_,visibleFromDays:v,rowCount:i,...y}}function Dh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=Th(e,t,u),f=d.offset,p={validityStart:n,validityEnd:r,source:i,idType:a},m=new Float32Array(e,f,t);f+=bh(t*4);let h=new Float32Array(e,f,t);f+=bh(t*4);let g=new Float32Array(e,f,t);f+=bh(t*4);let _=new Int32Array(e,f,t);f+=bh(t*4);let v=new Int32Array(e,f,t);f+=bh(t*4);let y=new Uint8Array(e,f,t);f+=bh(t);let b=new Uint8Array(e,f,t);f+=bh(t);let x=new Float32Array(e,f,t);return{kind:`sgp4`,id:o,objectType:s,parentId:c,scale:l,epochJd:d.epochJd,a:d.a,e:d.e,i:d.i,om:d.om,w:d.w,ma:d.ma,n:d.n,radiusKm:d.radiusKm,bstar:m,meanMotionDot:h,meanMotionDdot:g,elementSetNo:_,revAtEpoch:v,hasLocalized:y,flags:b,visibleFromDays:x,rowCount:t,...p}}function Oh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=u,f={validityStart:n,validityEnd:r,source:i,idType:a},p=new Float64Array(e,d,t);d+=t*8;let m=new Float32Array(e,d,t);d+=bh(t*4);let h=new Float32Array(e,d,t);d+=bh(t*4);let g=new Float32Array(e,d,t);d+=bh(t*4);let _=new Float32Array(e,d,t);d+=bh(t*4);let v=new Float32Array(e,d,t);d+=bh(t*4);let y=new Float64Array(e,d,t);d+=t*8;let b=new Float32Array(e,d,t);d+=bh(t*4);let x=new Uint8Array(e,d,t);d+=bh(t);let S=new Uint8Array(e,d,t);return d+=bh(t),{kind:`parabolic`,id:o,objectType:s,parentId:c,scale:l,epochJd:p,q:m,e:h,i:g,om:_,w:v,tp:y,radiusKm:b,hasLocalized:x,flags:S,visibleFromDays:new Float32Array(e,d,t),rowCount:t,...f}}var kh=Math.PI,Ah=kh*2,jh=kh/180;180/kh;var Mh=398600.8,Nh=6378.135,Ph=60/Math.sqrt(Nh*Nh*Nh/Mh),Fh=Nh*Ph/60,Ih=1/Ph,Lh=.001082616,Rh=-253881e-11,zh=-165597e-11,Bh=Rh/Lh,Vh=2/3,Hh=1440/(2*kh);function Uh(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function Wh(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function Gh(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return Wh(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return Wh(e,t,n,r,i,a,o)}function Kh(e,t){let{e3:n,ee2:r,peo:i,pgho:a,pho:o,pinco:s,plo:c,se2:l,se3:u,sgh2:d,sgh3:f,sgh4:p,sh2:m,sh3:h,si2:g,si3:_,sl2:v,sl3:y,sl4:b,t:x,xgh2:S,xgh3:C,xgh4:w,xh2:T,xh3:E,xi2:D,xi3:O,xl2:k,xl3:A,xl4:j,zmol:M,zmos:ee}=e,{init:N,opsmode:te}=t,{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}=t,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye;ye=ee+119459e-10*x,N===`y`&&(ye=ee),V=ye+2*.01675*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let be=l*pe+u*me,xe=g*pe+_*me,Se=v*pe+y*me+b*z,Ce=d*pe+f*me+p*z,we=m*pe+h*me;ye=M+.00015835218*x,N===`y`&&(ye=M),V=ye+2*.0549*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let Te=r*pe+n*me,H=D*pe+O*me,Ee=k*pe+A*me+j*z,De=S*pe+C*me+w*z,Oe=T*pe+E*me;return he=be+Te,R=xe+H,_e=Se+Ee,L=Ce+De,ge=we+Oe,N===`n`&&(he-=i,R-=s,_e-=c,L-=a,ge-=o,re+=R,ne+=he,se=Math.sin(re),oe=Math.cos(re),re>=.2?(ge/=se,L-=oe*ge,ie+=L,P+=ge,ae+=_e):(le=Math.sin(P),ce=Math.cos(P),F=se*le,I=se*ce,ue=ge*ce+R*oe*le,de=-ge*le+R*oe*ce,F+=ue,I+=de,P%=Ah,P<0&&te===`a`&&(P+=Ah),ve=ae+ie+oe*P,fe=_e+L-R*P*se,ve+=fe,B=P,P=Math.atan2(F,I),P<0&&te===`a`&&(P+=Ah),Math.abs(B-P)>kh&&(P<B?P+=Ah:P-=Ah),ae+=_e,ie=ve-ae-oe*P)),{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}}function qh(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:o,np:s}=e,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe=.01675,ke=.0549,Ae=s,je=n,Me=Math.sin(o),Ne=Math.cos(o),Pe=Math.sin(r),Fe=Math.cos(r),Ie=Math.sin(a),Le=Math.cos(a),Re=je*je,ze=1-Re,Be=Math.sqrt(ze),Ve=t+18261.5+i/1440,He=(4.523602-.00092422029*Ve)%Ah,Ue=Math.sin(He),We=Math.cos(He),Ge=.91375164-.03568096*We,Ke=Math.sqrt(1-Ge*Ge),qe=.089683511*Ue/Ke,Je=Math.sqrt(1-qe*qe),Ye=5.8351514+.001944368*Ve,Xe=.39785416*Ue/Ke,Ze=Je*We+.91744867*qe*Ue;Xe=Math.atan2(Xe,Ze),Xe+=Ye-He;let Qe=Math.cos(Xe),$e=Math.sin(Xe);D=.1945905,O=-.98088458,j=.91744867,M=.39785416,k=Ne,A=Me,v=29864797e-13;let et=1/Ae,tt=0;for(;tt<2;)tt+=1,c=D*k+O*j*A,u=-O*k+D*j*A,m=-D*A+O*j*k,h=O*M,g=O*A+D*j*k,_=D*M,l=Le*m+Ie*h,d=Le*g+Ie*_,f=-Ie*m+Le*h,p=-Ie*g+Le*_,y=c*Fe+l*Pe,b=u*Fe+d*Pe,x=-c*Pe+l*Fe,S=-u*Pe+d*Fe,C=f*Pe,w=p*Pe,T=f*Fe,E=p*Fe,H=12*y*y-3*x*x,Ee=24*y*b-6*x*S,De=12*b*b-3*S*S,B=3*(c*c+l*l)+H*Re,V=6*(c*u+l*d)+Ee*Re,ye=3*(u*u+d*d)+De*Re,be=-6*c*f+Re*(-24*y*T-6*x*C),xe=-6*(c*p+u*f)+Re*(-24*(b*T+y*E)+-6*(x*w+S*C)),Se=-6*u*p+Re*(-24*b*E-6*S*w),Ce=6*l*f+Re*(24*y*C-6*x*T),we=6*(d*f+l*p)+Re*(24*(b*C+y*w)-6*(S*T+x*E)),Te=6*d*p+Re*(24*b*w-6*S*E),B=B+B+ze*H,V=V+V+ze*Ee,ye=ye+ye+ze*De,ge=v*et,L=-.5*ge/Be,R=ge*Be,he=-15*je*R,_e=y*x+b*S,z=b*x+y*S,ve=b*S-y*x,tt===1&&(ee=he,N=L,te=ge,ne=R,re=_e,P=z,ie=ve,ae=B,F=V,I=ye,oe=be,se=xe,ce=Se,le=Ce,ue=we,de=Te,fe=H,pe=Ee,me=De,D=Qe,O=$e,j=Ge,M=Ke,k=Je*Ne+qe*Me,A=Me*Je-Ne*qe,v=4.7968065e-7);let nt=(4.7199672+(.2299715*Ve-Ye))%Ah,rt=(6.2565837+.017201977*Ve)%Ah,it=2*ee*P,at=2*ee*ie,ot=2*N*se,st=2*N*(ce-oe),ct=-2*te*F,lt=-2*te*(I-ae),ut=-2*te*(-21-9*Re)*Oe,dt=2*ne*pe,ft=2*ne*(me-fe),pt=-18*ne*Oe,mt=-2*N*ue,ht=-2*N*(de-le),gt=2*he*z,_t=2*he*ve,vt=2*L*xe,yt=2*L*(Se-be),bt=-2*ge*V,xt=-2*ge*(ye-B),St=-2*ge*(-21-9*Re)*ke,Ct=2*R*Ee,wt=2*R*(De-H),Tt=-18*R*ke,Et=-2*L*we,Dt=-2*L*(Te-Ce);return{snodm:Me,cnodm:Ne,sinim:Ie,cosim:Le,sinomm:Pe,cosomm:Fe,day:Ve,e3:_t,ee2:gt,em:je,emsq:Re,gam:Ye,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Be,se2:it,se3:at,sgh2:dt,sgh3:ft,sgh4:pt,sh2:mt,sh3:ht,si2:ot,si3:st,sl2:ct,sl3:lt,sl4:ut,s1:he,s2:L,s3:ge,s4:R,s5:_e,s6:z,s7:ve,ss1:ee,ss2:N,ss3:te,ss4:ne,ss5:re,ss6:P,ss7:ie,sz1:ae,sz2:F,sz3:I,sz11:oe,sz12:se,sz13:ce,sz21:le,sz22:ue,sz23:de,sz31:fe,sz32:pe,sz33:me,xgh2:Ct,xgh3:wt,xgh4:Tt,xh2:Et,xh3:Dt,xi2:vt,xi3:yt,xl2:bt,xl3:xt,xl4:St,nm:Ae,z1:B,z2:V,z3:ye,z11:be,z12:xe,z13:Se,z21:Ce,z22:we,z23:Te,z31:H,z32:Ee,z33:De,zmol:nt,zmos:rt}}function Jh(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:a,s4:o,s5:s,sinim:c,ss1:l,ss2:u,ss3:d,ss4:f,ss5:p,sz1:m,sz3:h,sz11:g,sz13:_,sz21:v,sz23:y,sz31:b,sz33:x,t:S,tc:C,gsto:w,mo:T,mdot:E,no:D,nodeo:O,nodedot:k,xpidot:A,z1:j,z3:M,z11:ee,z13:N,z21:te,z23:ne,z31:re,z33:P,ecco:ie,eccsq:ae}=e,{emsq:F,em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}=e,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st=.0043752690880113,ct=.00015835218,lt=119459e-10;de=0,le<.0052359877&&le>.0034906585&&(de=1),le>=.00826&&le<=.00924&&I>=.5&&(de=2);let ut=l*lt*p,dt=u*lt*(g+_),ft=-lt*d*(m+h-14-6*F),pt=f*lt*(b+x-6),mt=-lt*u*(v+y);(se<.052359877||se>kh-.052359877)&&(mt=0),c!==0&&(mt/=c);let ht=pt-t*mt;V=ut+r*ct*s,ye=dt+i*ct*(ee+N),be=ft-ct*a*(j+M-14-6*F);let gt=o*ct*(re+P-6),_t=-ct*i*(te+ne);(se<.052359877||se>kh-.052359877)&&(_t=0),Se=ht+gt,xe=mt,c!==0&&(Se-=t/c*_t,xe+=_t/c);let vt=(w+C*st)%Ah;if(I+=V*S,se+=ye*S,oe+=Se*S,ue+=xe*S,ce+=be*S,de!==0){if(it=(le/Ph)**Vh,de===2){at=t*t;let e=I;I=ie;let n=F;F=ae,ot=I*F,He=-.306-(I-.64)*.44,I<=.65?(Ue=3.616-13.247*I+16.29*F,Ge=-19.302+117.39*I-228.419*F+156.591*ot,Ke=-18.9068+109.7927*I-214.6334*F+146.5816*ot,qe=-41.122+242.694*I-471.094*F+313.953*ot,Je=-146.407+841.88*I-1629.014*F+1083.435*ot,Ye=-532.114+3017.977*I-5740.032*F+3708.276*ot):(Ue=-72.099+331.819*I-508.738*F+266.724*ot,Ge=-346.844+1582.851*I-2415.925*F+1246.113*ot,Ke=-342.585+1554.908*I-2366.899*F+1215.972*ot,qe=-1052.797+4758.686*I-7193.992*F+3651.957*ot,Je=-3581.69+16178.11*I-24462.77*F+12422.52*ot,Ye=I>.715?-5149.66+29936.92*I-54087.36*F+31324.56*ot:1464.74-4664.75*I+3763.64*F),I<.7?(Qe=-919.2277+4988.61*I-9064.77*F+5542.21*ot,Xe=-822.71072+4568.6173*I-8491.4146*F+5337.524*ot,Ze=-853.666+4690.25*I-8624.77*F+5341.4*ot):(Qe=-37995.78+161616.52*I-229838.2*F+109377.94*ot,Xe=-51752.104+218913.95*I-309468.16*F+146349.42*ot,Ze=-40023.88+170470.89*I-242699.48*F+115605.82*ot),$e=c*c,ke=.75*(1+2*t+at),Ae=1.5*$e,Me=1.875*c*(1-2*t-3*at),Ne=-1.875*c*(1+2*t-3*at),Fe=35*$e*ke,Ie=39.375*$e*$e,Le=9.84375*c*($e*(1-2*t-5*at)+.33333333*(-2+4*t+6*at)),Re=c*(4.92187512*$e*(-2-4*t+10*at)+6.56250012*(1+2*t-3*at)),ze=29.53125*c*(2-8*t+at*(-12+8*t+10*at)),Be=29.53125*c*(-2-8*t+at*(12+8*t-10*at)),nt=le*le,rt=it*it,tt=3*nt*rt,et=tt*17891679e-13,pe=et*ke*He,me=et*Ae*Ue,tt*=it,et=tt*3.7393792e-7,he=et*Me*Ge,L=et*Ne*Ke,tt*=it,et=2*tt*7.3636953e-9,ge=et*Fe*qe,R=et*Ie*Je,tt*=it,et=tt*1.1428639e-7,_e=et*Le*Ye,z=et*Re*Ze,et=2*tt*2.1765803e-9,ve=et*ze*Xe,B=et*Be*Qe,Ee=(T+O+O-(vt+vt))%Ah,H=E+be+2*(k+xe-st)-D,I=e,F=n}de===1&&(Ve=1+F*(-2.5+.8125*F),Ge=1+2*F,We=1+F*(-6+6.60937*F),ke=.75*(1+t)*(1+t),je=.9375*c*c*(1+3*t)-.75*(1+t),Pe=1+t,Pe*=1.875*Pe*Pe,Ce=3*le*le*it*it,we=2*Ce*ke*Ve*17891679e-13,Te=3*Ce*Pe*We*2.2123015e-7*it,Ce=Ce*je*Ge*21460748e-13*it,Ee=(T+O+n-vt)%Ah,H=E+A+be+Se+xe-(D+st)),De=Ee,Oe=D,fe=0,le=D+0}return{em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dndt:0,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}}function Yh(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*jh/240%Ah,n<0&&(n+=Ah),n}function Xh(e,t,n,r,i,a,o){return e instanceof Date?Yh(Gh(e)):Yh(t===void 0?e:Gh(e,t,n,r,i,a,o))}function Zh(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,o=t*t,s=1-o,c=Math.sqrt(s),l=Math.cos(r),u=l*l,d=(Ph/a)**Vh,f=.75*Lh*(3*u-1)/(c*s),p=f/(d*d),m=d*(1-p*p-p*(1/3+134*p*p/81));p=f/(m*m),a/=1+p;let h=(Ph/a)**Vh,g=Math.sin(r),_=h*s,v=1-5*u,y=-v-u-u,b=1/h,x=_*_,S=h*(1-t),C;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+Ah;C=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%Ah,C<0&&(C+=Ah)}else C=Xh(n+2433281.5);return{no:a,method:`n`,ainv:b,ao:h,con41:y,con42:v,cosio:l,cosio2:u,eccsq:o,omeosq:s,posq:x,rp:S,rteosq:c,sinio:g,gsto:C}}function Qh(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:o,d4422:s,d5220:c,d5232:l,d5421:u,d5433:d,dedt:f,del1:p,del2:m,del3:h,didt:g,dmdt:_,dnodt:v,domdt:y,argpo:b,argpdot:x,t:S,tc:C,gsto:w,xfact:T,xlamo:E,no:D}=e,{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,nm:ne}=e,re=.13130908,P=2.8843198,ie=.37448087,ae=5.7686396,F=.95240898,I=1.8014998,oe=1.050833,se=4.4108898,ce=259200,le,ue,de,fe,pe,me,he,L,ge=0,R=0,_e=(w+C*.0043752690880113)%Ah;if(k+=f*S,j+=g*S,A+=y*S,te+=v*S,ee+=_*S,t!==0){(O===0||S*O<=0||Math.abs(S)<Math.abs(O))&&(O=0,N=D,M=E),le=S>0?720:-720;let e=381;for(;e===381;)t===2?(L=b+x*O,de=L+L,ue=M+M,he=n*Math.sin(de+M-ae)+r*Math.sin(M-ae)+i*Math.sin(L+M-F)+a*Math.sin(-L+M-F)+o*Math.sin(de+ue-I)+s*Math.sin(ue-I)+c*Math.sin(L+M-oe)+l*Math.sin(-L+M-oe)+u*Math.sin(L+ue-se)+d*Math.sin(-L+ue-se),pe=N+T,me=n*Math.cos(de+M-ae)+r*Math.cos(M-ae)+i*Math.cos(L+M-F)+a*Math.cos(-L+M-F)+c*Math.cos(L+M-oe)+l*Math.cos(-L+M-oe)+2*(o*Math.cos(de+ue-I)+s*Math.cos(ue-I)+u*Math.cos(L+ue-se)+d*Math.cos(-L+ue-se)),me*=pe):(he=p*Math.sin(M-re)+m*Math.sin(2*(M-P))+h*Math.sin(3*(M-ie)),pe=N+T,me=p*Math.cos(M-re)+2*m*Math.cos(2*(M-P))+3*h*Math.cos(3*(M-ie)),me*=pe),Math.abs(S-O)>=720?e=381:(R=S-O,e=0),e===381&&(M+=pe*le+he*ce,N+=he*le+me*ce,O+=le);ne=N+he*R+me*R*R*.5,fe=M+pe*R+he*R*R*.5,t===1?(ee=fe-te-A+_e,ge=ne-D):(ee=fe-2*te+2*_e,ge=ne-D),ne=D+ge}return{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,dndt:ge,nm:ne}}var $h;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})($h||={});function eg(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O;e.t=t,e.error=$h.None;let k=e.mo+e.mdot*e.t,A=e.argpo+e.argpdot*e.t,j=e.nodeo+e.nodedot*e.t;u=A,S=k;let M=e.t*e.t;if(w=j+e.nodecf*M,v=1-e.cc1*e.t,y=e.bstar*e.cc4*e.t,b=e.t2cof*M,e.isimp!==1){c=e.omgcof*e.t;let t=1+e.eta*Math.cos(k);s=e.xmcof*(t*t*t-e.delmo),_=c+s,S=k+_,u=A-_,p=M*e.t,m=p*e.t,v=v-e.d2*M-e.d3*p-e.d4*m,y+=e.bstar*e.cc5*(Math.sin(S)-e.sinmao),b=b+e.t3cof*p+m*(e.t4cof+e.t*e.t5cof)}C=e.no;let ee=e.ecco;if(x=e.inclo,e.method===`d`){h=e.t;let t=Qh({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:h,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:ee,argpm:u,inclm:x,xli:e.xli,mm:S,xni:e.xni,nodem:w,nm:C});({em:ee,argpm:u,inclm:x,mm:S,nodem:w,nm:C}=t)}if(C<=0)return e.error=$h.MeanMotionBelowZero,null;let N=(Ph/C)**Vh*v*v;if(C=Ph/N**1.5,ee-=y,ee>=1||ee<-.001)return e.error=$h.MeanEccentricityOutOfRange,null;ee<1e-6&&(ee=1e-6),S+=e.no*b,E=S+u+w,w%=Ah,u%=Ah,E%=Ah,S=(E-u-w)%Ah;let te={am:N,em:ee,im:x,Om:w,om:u,mm:S,nm:C},ne=Math.sin(x),re=Math.cos(x),P=ee;if(T=x,d=u,O=w,D=S,a=ne,i=re,e.method===`d`){let t=Kh(e,{inclo:e.inclo,init:`n`,ep:P,inclp:T,nodep:O,argpp:d,mp:D,opsmode:e.operationmode});if({ep:P,nodep:O,argpp:d,mp:D}=t,T=t.inclp,T<0&&(T=-T,O+=kh,d-=kh),P<0||P>1)return e.error=$h.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(a=Math.sin(T),i=Math.cos(T),e.aycof=-.5*Bh*a,Math.abs(i+1)>15e-13?e.xlcof=-.25*Bh*a*(3+5*i)/(1+i):e.xlcof=-.25*Bh*a*(3+5*i)/15e-13);let ie=P*Math.cos(d);_=1/(N*(1-P*P));let ae=P*Math.sin(d)+_*e.aycof,F=(D+d+O+_*e.xlcof*ie-O)%Ah;l=F,g=9999.9;let I=1;for(;Math.abs(g)>=1e-12&&I<=10;)r=Math.sin(l),n=Math.cos(l),g=1-n*ie-r*ae,g=(F-ae*n+ie*r-l)/g,Math.abs(g)>=.95&&(g=g>0?.95:-.95),l+=g,I+=1;let oe=ie*n+ae*r,se=ie*r-ae*n,ce=ie*ie+ae*ae,le=N*(1-ce);if(le<0)return e.error=$h.SemiLatusRectumBelowZero,null;let ue=N*(1-oe),de=Math.sqrt(N)*se/ue,fe=Math.sqrt(le)/ue,pe=Math.sqrt(1-ce);_=se/(1+pe);let me=N/ue*(r-ae-ie*_),he=N/ue*(n-ie+ae*_);f=Math.atan2(me,he);let L=(he+he)*me,ge=1-2*me*me;_=1/le;let R=.5*Lh*_,_e=R*_;e.method===`d`&&(o=i*i,e.con41=3*o-1,e.x1mth2=1-o,e.x7thm1=7*o-1);let z=ue*(1-1.5*_e*pe*e.con41)+.5*R*e.x1mth2*ge;if(z<1)return e.error=$h.Decayed,null;f-=.25*_e*e.x7thm1*L;let ve=O+1.5*_e*i*L,B=T+1.5*_e*i*a*ge,V=de-C*R*e.x1mth2*L/Ph,ye=fe+C*R*(e.x1mth2*ge+1.5*e.con41)/Ph,be=Math.sin(f),xe=Math.cos(f),Se=Math.sin(ve),Ce=Math.cos(ve),we=Math.sin(B),Te=Math.cos(B),H=-Se*Te,Ee=Ce*Te,De=H*be+Ce*xe,Oe=Ee*be+Se*xe,ke=we*be,Ae=H*xe-Ce*be,je=Ee*xe-Se*be,Me=we*xe;return{position:{x:z*De*Nh,y:z*Oe*Nh,z:z*ke*Nh},velocity:{x:(V*De+ye*Ae)*Fh,y:(V*Oe+ye*je)*Fh,z:(V*ke+ye*Me)*Fh},meanElements:te}}function tg(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:a,xecco:o,xargpo:s,xinclo:c,xmo:l,xno:u,xnodeo:d}=t,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H=e;H.isimp=0,H.method=`n`,H.aycof=0,H.con41=0,H.cc1=0,H.cc4=0,H.cc5=0,H.d2=0,H.d3=0,H.d4=0,H.delmo=0,H.eta=0,H.argpdot=0,H.omgcof=0,H.sinmao=0,H.t=0,H.t2cof=0,H.t3cof=0,H.t4cof=0,H.t5cof=0,H.x1mth2=0,H.x7thm1=0,H.mdot=0,H.nodedot=0,H.xlcof=0,H.xmcof=0,H.nodecf=0,H.irez=0,H.d2201=0,H.d2211=0,H.d3210=0,H.d3222=0,H.d4410=0,H.d4422=0,H.d5220=0,H.d5232=0,H.d5421=0,H.d5433=0,H.dedt=0,H.del1=0,H.del2=0,H.del3=0,H.didt=0,H.dmdt=0,H.dnodt=0,H.domdt=0,H.e3=0,H.ee2=0,H.peo=0,H.pgho=0,H.pho=0,H.pinco=0,H.plo=0,H.se2=0,H.se3=0,H.sgh2=0,H.sgh3=0,H.sgh4=0,H.sh2=0,H.sh3=0,H.si2=0,H.si3=0,H.sl2=0,H.sl3=0,H.sl4=0,H.gsto=0,H.xfact=0,H.xgh2=0,H.xgh3=0,H.xgh4=0,H.xh2=0,H.xh3=0,H.xi2=0,H.xi3=0,H.xl2=0,H.xl3=0,H.xl4=0,H.xlamo=0,H.zmol=0,H.zmos=0,H.atime=0,H.xli=0,H.xni=0,H.bstar=a,H.ecco=o,H.argpo=s,H.inclo=c,H.mo=l,H.no=u,H.nodeo=d,H.operationmode=n;let Ee=78/Nh+1,De=42/Nh,Oe=De*De*De*De;H.init=`y`,H.t=0;let ke=Zh({satn:r,ecco:H.ecco,epoch:i,inclo:H.inclo,no:H.no,method:H.method,opsmode:H.operationmode}),{ao:Ae,con42:je,cosio:Me,cosio2:Ne,eccsq:Pe,omeosq:Fe,posq:Ie,rp:Le,rteosq:Re,sinio:ze}=ke;if(H.no=ke.no,H.con41=ke.con41,H.gsto=ke.gsto,H.a=(H.no*Ih)**(-2/3),H.alta=H.a*(1+H.ecco)-1,H.altp=H.a*(1-H.ecco)-1,H.error=0,Fe>=0||H.no>=0){if(H.isimp=0,Le<1.034492841559484&&(H.isimp=1),P=Ee,M=Oe,k=(Le-1)*Nh,k<156){P=k-78,k<98&&(P=20);let e=(120-P)/Nh;M=e*e*e*e,P=P/Nh+1}A=1/Ie,z=1/(Ae-P),H.eta=Ae*H.ecco*z,C=H.eta*H.eta,S=H.ecco*H.eta,j=Math.abs(1-C),_=M*z**4,v=_/j**3.5,h=v*H.no*(Ae*(1+1.5*C+S*(4+C))+.375*Lh*z/j*H.con41*(8+3*C*(8+C))),H.cc1=H.bstar*h,g=0,H.ecco>1e-4&&(g=-2*_*z*Bh*H.no*ze/H.ecco),H.x1mth2=1-Ne,H.cc4=2*H.no*v*Ae*Fe*(H.eta*(2+.5*C)+H.ecco*(.5+2*C)-Lh*z/(Ae*j)*(-3*H.con41*(1-2*S+C*(1.5-.5*S))+.75*H.x1mth2*(2*C-S*(1+C))*Math.cos(2*H.argpo))),H.cc5=2*v*Ae*Fe*(1+2.75*(C+S)+S*C),y=Ne*Ne,ge=1.5*Lh*A*H.no,R=.5*ge*Lh*A,_e=-.46875*zh*A*A*H.no,H.mdot=H.no+.5*ge*Re*H.con41+.0625*R*Re*(13-78*Ne+137*y),H.argpdot=-.5*ge*je+.0625*R*(7-114*Ne+395*y)+_e*(3-36*Ne+49*y),B=-ge*Me,H.nodedot=B+(.5*R*(4-19*Ne)+2*_e*(3-7*Ne))*Me,ve=H.argpdot+H.nodedot,H.omgcof=H.bstar*g*Math.cos(H.argpo),H.xmcof=0,H.ecco>1e-4&&(H.xmcof=-Vh*_*H.bstar/S),H.nodecf=3.5*Fe*B*H.cc1,H.t2cof=1.5*H.cc1,Math.abs(Me+1)>15e-13?H.xlcof=-.25*Bh*ze*(3+5*Me)/(1+Me):H.xlcof=-.25*Bh*ze*(3+5*Me)/15e-13,H.aycof=-.5*Bh*ze;let e=1+H.eta*Math.cos(H.mo);if(H.delmo=e*e*e,H.sinmao=Math.sin(H.mo),H.x7thm1=7*Ne-1,2*kh/H.no>=225){H.method=`d`,H.isimp=1,he=0,E=H.inclo;let e=qh({epoch:i,ep:H.ecco,argpp:H.argpo,tc:he,inclp:H.inclo,nodep:H.nodeo,np:H.no,e3:H.e3,ee2:H.ee2,peo:H.peo,pgho:H.pgho,pho:H.pho,pinco:H.pinco,plo:H.plo,se2:H.se2,se3:H.se3,sgh2:H.sgh2,sgh3:H.sgh3,sgh4:H.sgh4,sh2:H.sh2,sh3:H.sh3,si2:H.si2,si3:H.si3,sl2:H.sl2,sl3:H.sl3,sl4:H.sl4,xgh2:H.xgh2,xgh3:H.xgh3,xgh4:H.xgh4,xh2:H.xh2,xh3:H.xh3,xi2:H.xi2,xi3:H.xi3,xl2:H.xl2,xl3:H.xl3,xl4:H.xl4,zmol:H.zmol,zmos:H.zmos});H.e3=e.e3,H.ee2=e.ee2,H.peo=e.peo,H.pgho=e.pgho,H.pho=e.pho,H.pinco=e.pinco,H.plo=e.plo,H.se2=e.se2,H.se3=e.se3,H.sgh2=e.sgh2,H.sgh3=e.sgh3,H.sgh4=e.sgh4,H.sh2=e.sh2,H.sh3=e.sh3,H.si2=e.si2,H.si3=e.si3,H.sl2=e.sl2,H.sl3=e.sl3,H.sl4=e.sl4,{sinim:p,cosim:f,em:b,emsq:x,s1:ee,s2:N,s3:te,s4:ne,s5:re,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me}=e,H.xgh2=e.xgh2,H.xgh3=e.xgh3,H.xgh4=e.xgh4,H.xh2=e.xh2,H.xh3=e.xh3,H.xi2=e.xi2,H.xi3=e.xi3,H.xl2=e.xl2,H.xl3=e.xl3,H.xl4=e.xl4,H.zmol=e.zmol,H.zmos=e.zmos,{nm:O,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te}=e;let t=Kh(H,{inclo:E,init:H.init,ep:H.ecco,inclp:H.inclo,nodep:H.nodeo,argpp:H.argpo,mp:H.mo,opsmode:H.operationmode});H.ecco=t.ep,H.inclo=t.inclp,H.nodeo=t.nodep,H.argpo=t.argpp,H.mo=t.mp,w=0,T=0,D=0;let n=Jh({cosim:f,emsq:x,argpo:H.argpo,s1:ee,s2:N,s3:te,s4:ne,s5:re,sinim:p,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me,t:H.t,tc:he,gsto:H.gsto,mo:H.mo,mdot:H.mdot,no:H.no,nodeo:H.nodeo,nodedot:H.nodedot,xpidot:ve,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te,ecco:H.ecco,eccsq:Pe,em:b,argpm:w,inclm:E,mm:D,nm:O,nodem:T,irez:H.irez,atime:H.atime,d2201:H.d2201,d2211:H.d2211,d3210:H.d3210,d3222:H.d3222,d4410:H.d4410,d4422:H.d4422,d5220:H.d5220,d5232:H.d5232,d5421:H.d5421,d5433:H.d5433,dedt:H.dedt,didt:H.didt,dmdt:H.dmdt,dnodt:H.dnodt,domdt:H.domdt,del1:H.del1,del2:H.del2,del3:H.del3,xfact:H.xfact,xlamo:H.xlamo,xli:H.xli,xni:H.xni});H.irez=n.irez,H.atime=n.atime,H.d2201=n.d2201,H.d2211=n.d2211,H.d3210=n.d3210,H.d3222=n.d3222,H.d4410=n.d4410,H.d4422=n.d4422,H.d5220=n.d5220,H.d5232=n.d5232,H.d5421=n.d5421,H.d5433=n.d5433,H.dedt=n.dedt,H.didt=n.didt,H.dmdt=n.dmdt,H.dnodt=n.dnodt,H.domdt=n.domdt,H.del1=n.del1,H.del2=n.del2,H.del3=n.del3,H.xfact=n.xfact,H.xlamo=n.xlamo,H.xli=n.xli,H.xni=n.xni}H.isimp!==1&&(m=H.cc1*H.cc1,H.d2=4*Ae*z*m,L=H.d2*z*H.cc1/3,H.d3=(17*Ae+P)*L,H.d4=.5*L*Ae*z*(221*Ae+31*P)*H.cc1,H.t3cof=H.d2+2*m,H.t4cof=.25*(3*H.d3+H.cc1*(12*H.d2+10*m)),H.t5cof=.2*(3*H.d4+12*H.cc1*H.d3+6*H.d2*H.d2+15*m*(2*H.d2+m)))}eg(H,0),H.init=`n`}function ng(e,t){let n=e.substring(2,7),r=parseInt(e.substring(18,20),10),i=parseFloat(e.substring(20,32)),a=parseFloat(e.substring(33,43)),o=parseFloat(`${e.substring(44,45)}.${e.substring(45,50)}E${e.substring(50,52)}`),s=parseFloat(`${e.substring(53,54)}.${e.substring(54,59)}E${e.substring(59,61)}`),c=parseFloat(t.substring(8,16))*jh,l=parseFloat(t.substring(17,25))*jh,u=parseFloat(`.${t.substring(26,33).replace(/\s/g,`0`)}`),d=parseFloat(t.substring(34,42))*jh,f=parseFloat(t.substring(43,51))*jh,p=parseFloat(t.substring(52,63))/Hh;a/=Hh*1440,o/=Hh*1440*1440;let m=r<57?r+2e3:r+1900,{mon:h,day:g,hr:_,minute:v,sec:y}=Uh(m,i),b=Gh(m,h,g,_,v,y),x={error:0,satnum:n,epochyr:r,epochdays:i,ndot:a,nddot:o,bstar:s,inclo:c,nodeo:l,ecco:u,argpo:d,mo:f,no:p,jdsatepoch:b};return tg(x,{opsmode:`i`,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}function rg(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,s=Number(e.MEAN_MOTION_DOT),c=Number(e.MEAN_MOTION_DDOT);s/=Hh*1440,c/=Hh*1440*1440;let l=Number(e.BSTAR),u=Number(e.INCLINATION)*jh,d=Number(e.RA_OF_ASC_NODE)*jh,f=Number(e.ECCENTRICITY),p=Number(e.ARG_OF_PERICENTER)*jh,m=Number(e.MEAN_ANOMALY)*jh,h=Number(e.MEAN_MOTION)/Hh,{mon:g,day:_,hr:v,minute:y,sec:b}=Uh(i,o),x=Gh(i,g,_,v,y,b),S={error:0,satnum:n,epochyr:a,epochdays:o,ndot:s,nddot:c,bstar:l,inclo:u,nodeo:d,ecco:f,argpo:p,mo:m,no:h,jdsatepoch:x};return tg(S,{opsmode:t,satn:S.satnum,epoch:S.jdsatepoch-2433281.5,xbstar:S.bstar,xecco:S.ecco,xargpo:S.argpo,xinclo:S.inclo,xmo:S.mo,xno:S.no,xnodeo:S.nodeo}),S}3*Float64Array.BYTES_PER_ELEMENT;var ig=149597870.7,ag=23.4392911,og=86400**2/ig**3,sg=1/ig;function Q(e){return e/ig*10}function cg(e){return e/10*ig}var lg=Math.cos(Math.PI/180*ag),ug=Math.sin(Math.PI/180*ag);function dg(e,t,n,r){let i=r??{x:0,y:0,z:0};return i.x=e,i.y=-t*ug+n*lg,i.z=-(t*lg+n*ug),i}var fg=Math.PI/180,pg=Math.cos(ag*fg),mg=Math.sin(ag*fg),hg=2440587.5;function gg(e){return new Date((e-hg)*864e5).toISOString()}function _g(e,t){let n=rg({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:gg(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===$h.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}function vg(e,t){let n=eg(e,(t-e.jdsatepoch)*1440);if(!n||e.error!==$h.None)return null;let{x:r,y:i,z:a}=n.position;return[r,i,a]}function yg(e,t,n){let r=10/ig,i=e*r,a=t*r,o=n*r,s=a*pg+o*mg,c=-a*mg+o*pg;return a=s,o=c,[i,o,-a]}function bg(e,t){let n=vg(e,t);return n?yg(n[0],n[1],n[2]):null}function xg(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}var Sg=700;function Cg(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>Sg)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function wg(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}var Tg=null,Eg=null;function Dg(){if(!Eg){Tg=[];let e=new MessageChannel;e.port1.onmessage=()=>Tg.shift()?.(),Eg=e.port2}return new Promise(e=>{Tg.push(e),Eg.postMessage(null)})}var Og=2451545,kg=86400,Ag=2440587.5,jg=864e5;function Mg(e){return e/jg+Ag}function Ng(e){return Mg(e.getTime())}function Pg(e){return new Date((e-Ag)*jg)}function Fg(e){return(e-Og)*kg}function Ig(e){return Og+e/kg}var Lg=Math.PI/180;Math.cos(ag*Lg),Math.sin(ag*Lg),10/ig;function Rg(e,t,n,r,i,a,o,s,c,l,u,d){e.a[t]=n,e.e[t]=r,e.i[t]=i,e.om[t]=a,e.w[t]=o,e.ma[t]=s,e.n[t]=c,e.epoch[t]=l,e.equatorial[t]=+!!u,e.flags[t]=d}function zg(e,t,n,r){let i=n.data;if(r?.has(i.id))return e.kind[t]=0,!1;if(i.omm)e.kind[t]=3,e.satnum[t]=i.omm.noradCatId,e.bstar[t]=i.omm.bstar,e.ndot[t]=i.omm.meanMotionDot,e.nddot[t]=i.omm.meanMotionDdot;else if(i.satrec)e.kind[t]=3,e.satrec[t]=i.satrec;else if(i.q!=null&&i.tp!=null&&isFinite(i.q)&&isFinite(i.tp))e.kind[t]=2,e.q[t]=i.q,e.tp[t]=i.tp;else if(i.a!==0&&isFinite(i.a))e.kind[t]=1;else return e.kind[t]=0,!1;return Rg(e,t,i.a,i.e,i.i,i.om,i.w,i.ma,i.n,i.epoch,i.equatorial,i.flags??0),!0}async function Bg(e,t,n=!1){let r=e.length,i=Ug(r);i.applyFlagFilter=n;let a=1/0,o=-1/0,s=performance.now();for(let n=0;n<r;n++){if((n&4095)==4095&&performance.now()-s>6&&(await Dg(),s=performance.now()),!zg(i,n,e[n],t))continue;let r=e[n].data;r.validityStart<a&&(a=r.validityStart),r.validityEnd>o&&(o=r.validityEnd)}return i.validityStart=a===1/0?-1/0:a,i.validityEnd=o===-1/0?1/0:o,i}var Vg=[{name:`kind`,make:e=>new Uint8Array(e)},{name:`equatorial`,make:e=>new Uint8Array(e)},{name:`a`,make:e=>new Float64Array(e)},{name:`e`,make:e=>new Float64Array(e)},{name:`i`,make:e=>new Float64Array(e)},{name:`om`,make:e=>new Float64Array(e)},{name:`w`,make:e=>new Float64Array(e)},{name:`ma`,make:e=>new Float64Array(e)},{name:`n`,make:e=>new Float64Array(e)},{name:`epoch`,make:e=>new Float64Array(e)},{name:`q`,make:e=>new Float64Array(e)},{name:`tp`,make:e=>new Float64Array(e)},{name:`flags`,make:e=>new Uint8Array(e)},{name:`visibleFromDays`,make:e=>new Float32Array(e).fill(NaN)},{name:`satnum`,make:e=>new Int32Array(e)},{name:`bstar`,make:e=>new Float64Array(e)},{name:`ndot`,make:e=>new Float64Array(e)},{name:`nddot`,make:e=>new Float64Array(e)},{name:`satrec`,make:e=>Array(e).fill(null),transferable:!1}];function Hg(e){let t=[];for(let n of Vg)n.transferable!==!1&&t.push(e[n.name].buffer);return t}function Ug(e){let t={count:e,applyFlagFilter:!1,validityStart:-1/0,validityEnd:1/0,pickBase:0};for(let n of Vg)t[n.name]=n.make(e);return t}function Wg(e,t){return e.get(t)?.name||null}function Gg(e,t){return e.get(t)?.isMinor??!1}function Kg(e,t){let n=e.get(t);return{name:n?.name||null,isMinor:n?.isMinor??!1}}function qg(e,t,n,r){let i=e.scale[t]===rn.PLANET,a=e.omDot[t],o=e.wDot[t],s=Sh(e,t);if(s===null)return null;let{name:c,isMinor:l}=Kg(n,s);return{id:s,name:c,isMinor:l,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:i?e.a[t]/ig:e.a[t],e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:i?e.n[t]*360:e.n[t],epoch:e.epochJd[t],omDot:a===0?void 0:a,wDot:o===0?void 0:o,equatorial:i,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}function Jg(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i);return{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:0,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:0,n:0,epoch:e.epochJd[t],q:e.q[t],tp:e.tp[t],validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}var Yg=new WeakMap,Xg=new WeakMap;function Zg(e,t){return{noradCatId:e.id[t],epochJd:e.epochJd[t],meanMotion:e.n[t],eccentricity:e.e[t],inclination:e.i[t],raOfAscNode:e.om[t],argOfPericenter:e.w[t],meanAnomaly:e.ma[t],bstar:e.bstar[t],meanMotionDot:e.meanMotionDot[t],meanMotionDdot:e.meanMotionDdot[t],elementSetNo:e.elementSetNo[t],revAtEpoch:e.revAtEpoch[t]}}var Qg={get omm(){let e=Xg.get(this);return e&&Zg(e[0],e[1])},get satrec(){let e=this,t=Yg.get(e);return t===void 0&&(t=_g(e.omm,e.name??void 0),Yg.set(e,t),t||(e.unplaceable=!0)),t??void 0}};function $g(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i),s=Object.assign(Object.create(Qg),{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:e.a[t]/ig,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:e.n[t]*360,epoch:e.epochJd[t],equatorial:!0,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]});return Xg.set(s,[e,t]),s}function e_(e,t,n,r){return e.kind===`parabolic`?Jg(e,t,n,r):e.kind===`sgp4`?$g(e,t,n,r):qg(e,t,n,r)}function t_(e,t,n,r,i,a){if(a&&i!==void 0&&a.has(i))return n.kind[r]=0,!1;if(e.kind===`parabolic`){let i=e.q[t],a=e.tp[t];return isFinite(i)&&isFinite(a)?(n.kind[r]=2,n.q[r]=i,n.tp[r]=a,Rg(n,r,0,e.e[t],e.i[t],e.om[t],e.w[t],0,0,e.epochJd[t],!1,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}if(e.kind===`sgp4`)return n.kind[r]=3,n.satrec[r]=null,n.satnum[r]=e.id[t],n.bstar[r]=e.bstar[t],n.ndot[r]=e.meanMotionDot[t],n.nddot[r]=e.meanMotionDdot[t],Rg(n,r,e.a[t]/ig,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],e.n[t]*360,e.epochJd[t],!0,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0;let o=e.scale[t]===rn.PLANET,s=o?e.a[t]/ig:e.a[t];return s!==0&&isFinite(s)?(n.kind[r]=1,Rg(n,r,s,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],o?e.n[t]*360:e.n[t],e.epochJd[t],o,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}var n_={"naif-10":`#ffdd44`,"naif-199":`#b5b5b5`,"naif-299":`#e8cda0`,"naif-399":`#4da6ff`,"naif-301":`#888888`,"naif-499":`#c1440e`,"naif-401":`#aa9988`,"naif-402":`#aa9988`,"naif-599":`#d4a66a`,"naif-501":`#8a762e`,"naif-502":`#7c7f6c`,"naif-503":`#7e6c5e`,"naif-504":`#6c6453`,"naif-699":`#e8d8a0`,"naif-601":`#aba890`,"naif-602":`#71a29f`,"naif-603":`#6c6645`,"naif-604":`#494a2a`,"naif-605":`#5c5a3c`,"naif-606":`#835422`,"naif-608":`#776b60`,"naif-799":`#87ceeb`,"naif-701":`#b0b0b0`,"naif-702":`#a8a8a8`,"naif-703":`#62534c`,"naif-704":`#626a62`,"naif-705":`#625252`,"naif-899":`#3f54ba`,"naif-801":`#7c757c`,"naif-999":`#b48977`,"naif-2000001":`#9b9087`},r_=`#cccccc`,i_=`#fcb493`,a_=`#c7ccda`,o_=`#ffe89e`,s_=`#ccb49a`,c_=`#d8ffe8`,l_=`#e8a85c`,u_=`#bed4ec`,d_=`#d5cfe7`,f_=`naif-10`,p_=`naif-399`,m_=new Set(`naif-0.naif-9.spkid-20000002.spkid-20000003.spkid-20000007.spkid-20000010.spkid-20000015.spkid-20000031.spkid-20000052.spkid-20000065.spkid-20000088.spkid-20000107.spkid-20000130.spkid-20000511.spkid-20000588.spkid-20000704.spkid-20001862.spkid-1000592.spkid-1000616.spkid-1000630.spkid-1000639.spkid-1000648.spkid-1000651.spkid-1000669.spkid-1000690.spkid-1000738.spkid-1000742.spkid-1000749.spkid-1000755.spkid-1000778.spkid-1000845.spkid-1000872.spkid-1000882.spkid-1000899.spkid-1000945.spkid-1000967.spkid-1001121`.split(`.`));function h_(e){if(n_[e.id])return n_[e.id];let{objectType:t,parentId:n}=e;if(t===W.BARYCENTER){if(e.id===`naif-0`)return n_[`naif-10`];if(e.id===`naif-9`)return n_[`naif-999`];let t=`naif-${e.id.replace(`naif-`,``)}99`;if(n_[t])return n_[t]}if(t===W.STAR)return o_;if(t===W.PLANET||t===W.DWARF_PLANET)return i_;if(t===W.MOON)return a_;if(_n(t))return s_;if(t===W.COMET)return c_;if(t===W.DEBRIS)return l_;if(t===W.SPACECRAFT){if(n===`naif-399`)return u_;if(n===`naif-0`||n===`naif-10`)return d_}return r_}var g_=`#6b6b6b`;function __(e){return e.color??g_}function v_(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t>>>0}function y_(e,t){let n=Array.from({length:t},()=>[]);for(let r of e)n[v_(r.data.id)%t].push(r);return n}function b_(e,t,n){return{buckets:y_(t,t.length>=n*600?n:1),baseWorker:v_(e)%n}}async function x_(e,t,n){let r=t.length>=n*600?n:1,i=Array.from({length:r},()=>[]),a=performance.now();for(let e=0;e<t.length;e++){(e&16383)==16383&&performance.now()-a>6&&(await Dg(),a=performance.now());let n=t[e];i[v_(n.data.id)%r].push(n)}return{buckets:i,baseWorker:v_(e)%n}}function S_(e){let t=e.indexOf(`#`);return t<0?e:e.substring(0,t)}var C_=4096,w_=.75;function T_(e){let t=(e^Math.floor(e/4294967296))>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var E_=class{table=new Uint32Array(C_);mask=C_-1;count=0;constructor(e){this.keyOfRef=e}get size(){return this.count}slot(e){let t=T_(e)&this.mask;for(;;){let n=this.table[t];if(n===0||this.keyOfRef(n-1)===e)return t;t=t+1&this.mask}}get(e){let t=this.table[this.slot(e)];return t===0?void 0:t-1}has(e){return this.table[this.slot(e)]!==0}set(e,t,n=()=>!0){let r=this.slot(e),i=this.table[r];return i===0?(this.count++,this.count>this.table.length*w_&&(this.grow(),r=this.slot(e)),this.table[r]=t+1,!0):(n(i-1)&&(this.table[r]=t+1),!1)}grow(){let e=this.table;this.table=new Uint32Array(e.length*2),this.mask=this.table.length-1;for(let t of e){if(t===0)continue;let e=T_(this.keyOfRef(t-1))&this.mask;for(;this.table[e]!==0;)e=e+1&this.mask;this.table[e]=t}}*values(){for(let e of this.table)e!==0&&(yield e-1)}*keys(){for(let e of this.values())yield this.keyOfRef(e)}},D_=2**20,O_=4096,k_=6;function A_(e){let t=e>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var j_=class{chunks=[];rowOf=new E_(e=>this.keyOfRef(e));cache=new Map;placeholders=new Map;parentIdType=`naif`;constructor(e){this.labels=e}async addChunk(e,t,n){if(this.parentIdType=t,e.rowCount>=D_)throw Error(`MinorBucket: chunk too large (${e.rowCount} rows)`);let r=this.chunks.length;this.chunks.push(e);let i=0,a=this.placeholders.size>0,o=performance.now();for(let t=0;t<e.rowCount;t++){t%O_===O_-1&&performance.now()-o>k_&&(await Dg(),o=performance.now());let s=Ch(e,t);if(!(s===fh||n&&!n.has(s))&&(this.rowOf.set(s,r*D_+t,e=>Math.floor(e/D_)<=r)&&i++,a)){let n=Sh(e,t),r=n===null?void 0:this.placeholders.get(n);if(r){let n=e_(e,t,this.labels,this.parentIdType);n&&Object.assign(r.data,n)}}}return i}addPlaceholder(e){this.placeholders.set(e.data.id,e),this.cache.set(e.data.id,e)}keyOfRef(e){let t=Math.floor(e/D_);return Ch(this.chunks[t],e-t*D_)}get size(){let e=0;for(let t of this.placeholders.keys())this.hasRow(t)||e++;return this.rowOf.size+e}hasRow(e){let t=vh(e);return t!==null&&this.rowOf.has(t)}has(e){return this.hasRow(e)||this.placeholders.has(e)}hasKey(e){if(this.rowOf.has(e))return!0;if(this.placeholders.size===0)return!1;let t=_h(e);return t!==null&&this.placeholders.has(t)}*ids(){for(let e of this.rowOf.keys()){let t=_h(e);t!==null&&(yield t)}for(let e of this.placeholders.keys())this.hasRow(e)||(yield e)}*keys(){yield*this.rowOf.keys();for(let e of this.placeholders.keys()){let t=vh(e);t!==null&&!this.rowOf.has(t)&&(yield t)}}get(e){let t=this.cache.get(e);if(t)return t;let n=vh(e),r=n===null?void 0:this.rowOf.get(n);if(r===void 0)return;let i=Math.floor(r/D_),a=e_(this.chunks[i],r-i*D_,this.labels,this.parentIdType);if(!a)return;let o={data:a,position:[0,0,0],positionUnknown:!0};return this.cache.set(e,o),o}getKey(e){let t=_h(e);return t===null?void 0:this.get(t)}*values(){for(let e of this.ids()){let t=this.get(e);t&&(yield t)}}cloudColor(){let e=this.chunks.find(e=>e.rowCount>0);if(!e)return`#888888`;let t=e_(e,0,this.labels,this.parentIdType);return t?h_(t):`#888888`}async buildWorkerGroups(e,t,n,r){let i=this.rowOf.size,a=i>=t*600?t:1,o=new Float64Array(i),s=new Uint8Array(i),c=Array(a).fill(0),l=0,u=performance.now();for(let e of this.rowOf.values()){if(l===i)break;l%16384==0&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=Math.floor(e/D_),n=a===1?0:A_(this.chunks[t].id[e-t*D_])%a;o[l]=e,s[l]=n,c[n]++,l++}let d=[];for(let e=0;e<a;e++){let t=Ug(c[e]);t.applyFlagFilter=!1,d.push({cols:t,colors:r?new Float32Array(c[e]*3):null,keys:new Float64Array(c[e]).fill(fh)})}let f=Array(a).fill(1/0),p=Array(a).fill(-1/0),m=Array(a).fill(0),h=r?new X:null;u=performance.now();for(let e=0;e<l;e++){(e&16383)==16383&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=o[e],r=Math.floor(t/D_),i=t-r*D_,a=this.chunks[r],c=s[e],l=d[c],g=m[c]++,_=Ch(a,i);if(l.keys[g]=_,t_(a,i,l.cols,g,_,n)&&(a.validityStart<f[c]&&(f[c]=a.validityStart),a.validityEnd>p[c]&&(p[c]=a.validityEnd)),l.colors&&h){let e=e_(a,i,this.labels,this.parentIdType);h.set(e?h_(e):`#ffffff`),l.colors[g*3]=h.r,l.colors[g*3+1]=h.g,l.colors[g*3+2]=h.b}}for(let e=0;e<a;e++)d[e].cols.validityStart=f[e]===1/0?-1/0:f[e],d[e].cols.validityEnd=p[e]===-1/0?1/0:p[e];return{groups:d,baseWorker:v_(e)%t}}};function M_(e){return e===`naif-0`||e===`naif-10`}function N_(e){let t=/^naif-([1-9])$/.exec(e);return t?`naif-${t[1]}99`:null}function P_(e){return e===`naif-0`?f_:N_(e)}function F_(e){if(!M_(e))return N_(e)??e}var I_=class{bodiesById=new Map;majorBodies=[];asteroidBodiesByZone=new Map;spacecraftByParent=new Map;focusFeature=null;dirtyAsteroidZones=new Set;dirtySpacecraftGroups=new Set;minorStreaming=!1;#e=qe(0);get minorBodyVersion(){return Ut(this.#e)}set minorBodyVersion(e){Je(this.#e,e,!0)}#t=qe(0);get orientationVersion(){return Ut(this.#t)}set orientationVersion(e){Je(this.#t,e,!0)}orientationRead=new Set;hostRead=new Map;hostReadVersion=0;childrenByParent=new Map;moonMaxAByParent=new Map;addListeners=new Set;onBodiesAdded(e){return this.addListeners.add(e),()=>this.addListeners.delete(e)}notifyBodiesAdded(){for(let e of this.addListeners)e()}getBody(e,t){let n=this.bodiesById.get(e);if(n)return n;if(this.focusFeature?.data.id===e)return this.focusFeature;if(t!==void 0)return this.spacecraftByParent.get(t)?.get(e)??this.asteroidBodiesByZone.get(t)?.get(e);for(let t of this.spacecraftByParent.values()){let n=t.get(e);if(n)return n}for(let t of this.asteroidBodiesByZone.values()){let n=t.get(e);if(n)return n}}addBodies(e){let t=!1;for(let n of e){this.bodiesById.has(n.data.id)||(t=!0),this.bodiesById.set(n.data.id,n);let e=this.childrenByParent.get(n.data.parentId)??new Set;if(e.add(n.data.id),this.childrenByParent.set(n.data.parentId,e),n.data.objectType===W.MOON){let e=this.moonMaxAByParent.get(n.data.parentId)??0;n.data.a>e&&this.moonMaxAByParent.set(n.data.parentId,n.data.a)}}t&&this.notifyBodiesAdded()}asteroidBucket(e,t){let n=this.asteroidBodiesByZone.get(e);return n||this.asteroidBodiesByZone.set(e,n=new j_(t)),n}spacecraftBucket(e){let t=this.spacecraftByParent.get(e);return t||this.spacecraftByParent.set(e,t=new Map),t}flushMinor(e){this.asteroidBodiesByZone=new Map(this.asteroidBodiesByZone),this.spacecraftByParent=new Map(this.spacecraftByParent),this.minorBodyVersion++,e&&this.notifyBodiesAdded()}getChildren(e){return this.childrenByParent.get(e)}findAsteroidZone(e){for(let[t,n]of this.asteroidBodiesByZone)if(n.has(e))return t}maxMoonA(e){return this.moonMaxAByParent.get(e)}getSystemExtent(e){return this.moonMaxAByParent.get(e)??.01}isSystemBody(e){return M_(e.data.parentId)?!1:this.bodiesById.get(e.data.parentId)?.data.objectType!==W.BARYCENTER}isInSystem(e,t){return t?e===t?!0:this.childrenByParent.get(t)?.has(e)??!1:!1}getObjectCounts(){let e=0,t=0,n=0;for(let r of this.bodiesById.values()){let i=r.data.objectType;i===W.PLANET||i===W.DWARF_PLANET?e++:i===W.MOON?t++:i===W.SPACECRAFT&&n++}let r=this.spacecraftByParent.get(`naif-399`)?.size??0;r+=this.asteroidBodiesByZone.get(`earth`)?.size??0;for(let[e,t]of this.spacecraftByParent)e!==`naif-399`&&(n+=t.size);let i=0;for(let[e,t]of this.asteroidBodiesByZone)e!==`earth`&&(i+=t.size);for(let e of this.bodiesById.values())(_n(e.data.objectType)||e.data.objectType===W.COMET)&&i++;return{planets:e,moons:t,probes:n,earthSatellites:r,smallBodies:i}}};function L_(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function R_(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(n*n+r*r+i*i)}function z_(e,t,n,r){let i=e[0]-n[0],a=e[1]-n[1],o=e[2]-n[2],s=t[0]-n[0],c=t[1]-n[1],l=t[2]-n[2],u=Math.sqrt(i*i+a*a+o*o),d=Math.sqrt(s*s+c*c+l*l);if(u<1e-9||d<1e-9)return L_(e,t,r);let f=i/u,p=a/u,m=o/u,h=s/d,g=c/d,_=l/d,v=Math.max(-1,Math.min(1,f*h+p*g+m*_)),y=Math.acos(v),b=u+(d-u)*r;if(y<1e-4||Math.PI-y<1e-4)return L_(e,t,r);let x=Math.sin(y),S=Math.sin((1-r)*y)/x,C=Math.sin(r*y)/x,w=S*f+C*h,T=S*p+C*g,E=S*m+C*_;return[n[0]+w*b,n[1]+T*b,n[2]+E*b]}var B_={metadata:.12,ephemeris:.55,majors:.8,labels:.92,done:1},V_=[`metadata`,`ephemeris`,`majors`,`labels`,`done`],H_=.9,U_=new class{#e=0;#t=B_.metadata;#n=0;#r=0;#i=!1;#a=qe(0);get value(){return Ut(this.#a)}set value(e){Je(this.#a,e,!0)}get active(){return this.#i}#o(){let e=this.#t-this.#e,t=this.#r>0?Math.min(this.#n/this.#r,1):0,n=this.#e+e*t*H_;n>this.value&&(this.value=n)}reset(){this.#e=0,this.#t=B_.metadata,this.#n=0,this.#r=0,this.#i=!0,this.value=0}reach(e){if(!this.#i)return;let t=B_[e];if(t<=this.#e)return;this.#e=t,this.value<t&&(this.value=t);let n=V_[V_.indexOf(e)+1];this.#t=n?B_[n]:t,this.#n=0,this.#r=0,e===`done`&&(this.value=1,this.#i=!1)}announce(e){!this.#i||e<=0||(this.#r+=e,this.#o())}addBytes(e){this.#i&&(this.#n+=e,this.#o())}},W_=3e4;function G_(e,t){if(t||!U_.active||!e.body)return e;let n=Number(e.headers.get(`content-length`));if(!Number.isFinite(n)||n<=0)return e;U_.announce(n);let r=new TransformStream({transform(e,t){U_.addBytes(e.byteLength),t.enqueue(e)}});return new Response(e.body.pipeThrough(r),{status:e.status,statusText:e.statusText,headers:e.headers})}async function K_(e,t={},n=W_){let r=new AbortController,i=setTimeout(()=>r.abort(),n),a=()=>r.abort();t.signal?.addEventListener(`abort`,a,{once:!0});try{return G_(await fetch(e,{...t,signal:r.signal}),t.priority===`low`)}catch(i){throw r.signal.aborted&&!t.signal?.aborted?Error(`Request timed out after ${n} ms: ${e}`,{cause:i}):i}finally{clearTimeout(i),t.signal?.removeEventListener(`abort`,a)}}var q_=new Map,J_=new Map,Y_=null;function X_(){if(Y_)return Y_;let e=(async()=>{let e=await K_(`${Kt()}/v1/systems/global.json`);if(!e.ok)return;let t=await e.json();if(t.gm)for(let[e,n]of Object.entries(t.gm))J_.set(parseInt(e,10),n);if(t.nut_prec_angles)for(let[e,n]of Object.entries(t.nut_prec_angles))q_.set(parseInt(e,10),n)})();return e.catch(()=>{Y_===e&&(Y_=null)}),Y_=e,e}function Z_(e){return e>=100?Math.trunc(e/100):e}function Q_(e){return q_.get(e)}function $_(e){return J_.get(e)}var ev=132712440018,tv=86400;function nv(e){if(!M_(e.parentId))return;let t=Number(e.id.replace(/^naif-/,``));if(!Number.isFinite(t))return;let n=$_(t>=1&&t<=9?t*100+99:t),r=e.a*ig;if(!(!n||!(n>0)||!(r>0)))return r*(1-(Number.isFinite(e.e)?Math.min(Math.max(e.e,0),.99):0))*Math.cbrt(n/(3*ev))/ig}var rv=`class-`,iv=`flag-`,av=`cat-`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var ov=`${av}asteroids`,sv=`${av}comets`,cv=`${av}satellites`,lv=`${av}debris`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var uv={neo:1,pha:2},dv=new Set([`ETc`,`JFc`,`JFC`,`CTc`,`HTC`,`PAR`,`HYP`,`COM`]);function fv(e){return dv.has(e)?`comet`:`asteroid`}function pv(e,t){return e===t?!0:e===null||t===null||e.kind!==t.kind?!1:e.kind===`class`&&t.kind===`class`?e.className===t.className:e.kind===`category`&&t.kind===`category`?e.category===t.category:e.kind===`flag`&&t.kind===`flag`?e.flag===t.flag:!1}var mv=null;function hv(){if(mv)return mv;let e=K_(`${Kt()}/v1/groups/__index__.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch group index: ${e.status}`);return e.json()});return mv=e,e.catch(()=>{mv===e&&(mv=null)}),mv}var gv=[`planets`,`dwarfPlanets`,`moons`,`asteroids`,`comets`,`spacecraft`,`satellites`,`debris`,`orbits`,`labels`,`nomenclature`,`stars`],_v=new Set(gv),vv={[W.PLANET]:`planets`,[W.DWARF_PLANET]:`dwarfPlanets`,[W.MOON]:`moons`,[W.ASTEROID]:`asteroids`,[W.ASTEROID_INNER]:`asteroids`,[W.ASTEROID_MAIN_BELT]:`asteroids`,[W.ASTEROID_TROJAN]:`asteroids`,[W.ASTEROID_CENTAUR]:`asteroids`,[W.ASTEROID_TNO]:`asteroids`,[W.COMET]:`comets`,[W.DEBRIS]:`debris`},yv=`small_bodies/`,bv=new Set([`COM`,`PAR`,`HYP`,`HYA`,`JFC`,`JFc`,`HTC`,`CTc`]);function xv(e){return e===`moons`||e.startsWith(`moons/`)||e===`small_body_moons`?`moons`:e.startsWith(`probes/`)?`spacecraft`:e.startsWith(yv)?bv.has(e.slice(13))?`comets`:`asteroids`:null}function Sv(e,t){return e===W.SPACECRAFT?t===`naif-399`?`satellites`:`spacecraft`:vv[e]??null}var Cv=class{skipped;hiddenIds;onChange=null;constructor(e={}){let t=new Set;for(let n of gv)e[n]===!1&&t.add(n);this.skipped=t,this.hiddenIds=new Set(t)}isVisible(e){return!this.hiddenIds.has(e)}setVisible(e,t){t!==this.isVisible(e)&&(t?this.hiddenIds.delete(e):this.hiddenIds.add(e),this.onChange?.())}static has(e){return _v.has(e)}skipsZone(e){if(e===`earth`)return this.skipped.has(`satellites`)&&this.skipped.has(`debris`);let t=xv(e);return t!==null&&this.skipped.has(t)}hidesZone(e){let t=xv(e);return t!==null&&!this.isVisible(t)}hidesBody(e,t){let n=Sv(e,t);return n!==null&&!this.isVisible(n)}hidesSpacecraftGroup(e){return e===`naif-399`?!this.isVisible(`satellites`)&&!this.isVisible(`debris`):!this.isVisible(`spacecraft`)}};function wv(e,t,n){return t!==`naif-399`||e.isVisible(`satellites`)===e.isVisible(`debris`)?n:n.filter(t=>!e.hidesBody(t.data.objectType,t.data.parentId))}var Tv=`small_bodies/`;function Ev(e,t){let n=e.findAsteroidZone(t);if(n&&n.startsWith(`small_bodies/`))return n.slice(13);let r=e.bodiesById.get(t);if(r?.data.objectType!==W.DWARF_PLANET)return null;let i=r.data.a,a=r.data.e;if(!M_(r.data.parentId)){let t=e.bodiesById.get(r.data.parentId);t?.data.a&&(i=t.data.a,a=t.data.e)}return fn(i,a)}function Dv(e,t,n){if(n.kind===`class`||n.kind===`category`){let r=Ev(e,t);return r===null?!1:n.kind===`class`?r===n.className:fv(r)===n.category}let r=e.getBody(t);return r===void 0?!1:((r.data.flags??0)&n.mask)===n.mask}var $=function(e){return e[e.CLOSE=1]=`CLOSE`,e[e.FULL=2]=`FULL`,e[e.CAPPED=3]=`CAPPED`,e[e.FAR=4]=`FAR`,e[e.HIDE=5]=`HIDE`,e}({}),Ov=1503,kv={[$.CLOSE]:.3,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},Av={[$.CLOSE]:.01,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},jv=1/3;function Mv(e,t,n,r){return e<=t[$.CLOSE]?$.CLOSE:e<=t[$.FULL]*(r?n:1)?$.FULL:e<=t[$.FAR]?$.FAR:$.HIDE}var Nv=new Cv,Pv=3,Fv=4e6/ig;function Iv(e){return _n(e)||e===W.COMET||e===W.DWARF_PLANET}var Lv=class{#e=qe($e(f_));get focusedBodyId(){return Ut(this.#e)}set focusedBodyId(e){Je(this.#e,e,!0)}#t=qe(null);get focusedSystemId(){return Ut(this.#t)}set focusedSystemId(e){Je(this.#t,e,!0)}activeSystemId=null;isZoomedIn=!1;focusedBodyIdPlain=f_;focusedSystemIdPlain=null;travelSystemActive=!1;cameraDistThreeJS=0;lastRecomputeDist=-1;currentJd=0;hideThresholdAU=0;scaledPlanetary=kv;scaledSystem=Av;fullMoonIds=new Set;moonVisibilityCache=new Map;pinned=new Set;constructor(e,t=()=>null,n=()=>null,r=()=>null,i=()=>Nv){this.bodies=e,this.getProbeStore=t,this.getEarthSatGroupFilter=n,this.getSmallBodyFilter=r,this.getLayers=i}getRequiredFlags(){let e=this.getSmallBodyFilter();return e?.kind===`flag`?e.mask:0}updateViewport(e){let t=(e/Ov)**1.5,n=e=>({...e,[$.FULL]:e[$.FULL]*t,[$.FAR]:e[$.FAR]*t});this.scaledPlanetary=n(kv),this.scaledSystem=n(Av)}updateCamera(e,t){this.cameraDistThreeJS=e,this.currentJd=t,this.moonVisibilityCache.clear(),this.travelSystemActive||this.refreshProbeFocusedSystem(),this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=e/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?this.focusedSystemIdPlain:null,Math.abs(e-this.lastRecomputeDist)>this.lastRecomputeDist*.005+.001&&(this.lastRecomputeDist=e,this.recomputeFullMoons())}refreshProbeFocusedSystem(){let e=this.getProbeStore();if(!e)return;let t=this.bodies.bodiesById.get(this.focusedBodyIdPlain);if(!t||t.data.orbitalSource!==U.SPICE_PROBE)return;let n=e.containingSystemAt(t.data.id,this.currentJd),r=n===null?e.stampedFitCenterAt(t.data.id,this.currentJd):`naif-${n}`;r!==this.focusedSystemIdPlain&&(this.focusedSystemId=r,this.focusedSystemIdPlain=r,this.lastRecomputeDist=-1)}resolveSystemId(e){let t=e.data.objectType===W.BARYCENTER&&M_(e.data.parentId)&&!M_(e.data.id),n=e.data.objectType===W.STAR||!t&&M_(e.data.parentId);if(t)return e.data.id;if(n)return Iv(e.data.objectType)?e.data.id:null;let r=this.bodies.bodiesById.get(e.data.parentId);return r&&!M_(r.data.parentId)?r.data.parentId:e.data.parentId}setTravelSystem(e){this.travelSystemActive=!0,e!==this.focusedSystemIdPlain&&(this.focusedSystemId=e,this.focusedSystemIdPlain=e,this.lastRecomputeDist=-1)}clearTravelSystem(){this.travelSystemActive=!1}setFocused(e){if(this.travelSystemActive=!1,e.data.id===this.focusedBodyIdPlain)return;this.focusedBodyId=e.data.id,this.focusedBodyIdPlain=e.data.id;let t=this.resolveSystemId(e);this.focusedSystemId=t,this.focusedSystemIdPlain=t,this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=this.cameraDistThreeJS/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?t:null,this.lastRecomputeDist=-1,this.recomputeFullMoons()}getMoonVisibility(e){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;let t=this.moonVisibilityCache.get(e.data.id);if(t!==void 0)return t;let n,r=this.bodies.getBody(e.data.parentId),i=r!==void 0&&_n(r.data.objectType);if(!this.isInFocusedSystem(e.data.parentId))n=$.HIDE;else if(i&&!this.matchesSmallBodyClass(e.data.parentId))n=$.HIDE;else{let t=this.cameraDistThreeJS/10/e.data.a,r=e.data.id===this.focusedBodyIdPlain;n=Mv(t,this.scaledPlanetary,5,r),!i&&n===$.FULL&&!this.fullMoonIds.has(e.data.id)&&!r&&(n=$.CAPPED)}return this.moonVisibilityCache.set(e.data.id,n),n}setPinned(e){this.pinned=new Set(e)}isPinned(e){return this.pinned.has(e)}getPlanetVisibility(e,t){let n=this.pinned.has(e.data.id),r=this.ratioVisibility(e,t,n);return n&&r!==$.CLOSE?$.FULL:r}ratioVisibility(e,t,n){if(!n&&this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;if(e.data.orbitalSource===U.SPICE_PROBE)return this.getProbeVisibility(e);let r=this.getEarthSatGroupFilter();if(r&&e.data.parentId===`naif-399`&&!r.has(e.data.id))return $.HIDE;let i=e.data.objectType;if((_n(i)||i===W.COMET||i===W.DWARF_PLANET)&&!this.matchesSmallBodyClass(e.data.id))return $.HIDE;if(this.bodies.isSystemBody(e)){if(!this.isInFocusedSystem(e.data.parentId))return $.HIDE;let n=e.data.a;if(!n||n<=0)return $.FULL;let r=e.data.id===this.focusedBodyIdPlain;return Mv(t/10/n,this.scaledPlanetary,5,r)}let a=e.data.a;if(!M_(e.data.parentId)){let t=this.bodies.bodiesById.get(e.data.parentId);t?.data.a&&(a=t.data.a)}if(!a||a<0)return a===0&&e.data.e<.9&&console.warn(`No semi-major axis available for body ${e.data.id} (${e.data.name}), falling back to FULL visibility`),$.FULL;let o=e.data.id===this.focusedBodyIdPlain,s=Mv(t/10/a,this.scaledSystem,50,o);return s===$.CLOSE?$.FULL:s}getProbeVisibility(e){let t=this.getProbeStore();if((t?t.containingSystemAt(e.data.id,this.currentJd):null)===Pv&&this.getEarthSatGroupFilter())return $.HIDE;let n=e.data.id===this.focusedBodyIdPlain;if(!(t&&!t.hasHeliocentricFit(e.data.id,this.currentJd))){let t=this.bodies.bodiesById.get(f_),r=t?R_(e.position,t.position)/10:0;if(r===0)return $.FULL;let i=Mv(this.cameraDistThreeJS/10/r,this.scaledSystem,50,n);return i===$.CLOSE?$.FULL:i}if(!this.isProbeInFocusedSystem(e))return $.HIDE;let r=this.bodies.bodiesById.get(e.data.parentId);if(!r)return $.FULL;let i=R_(e.position,r.position)/10;return i===0||this.cameraDistThreeJS/10/i<=this.scaledPlanetary[$.FULL]*(n?5:1)?$.FULL:$.HIDE}isProbeInFocusedSystem(e){let t=e.data.parentId;if(!M_(t)&&this.isInFocusedSystem(t))return!0;let n=this.getProbeStore();if(!n)return!1;let r=n.containingSystemAt(e.data.id,this.currentJd);return r!==null&&this.isInFocusedSystem(`naif-${r}`)}hasFullRendering(e){if(!this.activeSystemId||this.pinned.has(e.data.id)||this.isInActiveSystem(M_(e.data.parentId)?e.data.id:e.data.parentId))return!0;if(e.data.orbitalSource!==U.SPICE_PROBE)return!1;let t=this.getProbeStore();if(!t)return!1;let n=t.containingSystemAt(e.data.id,this.currentJd);return n!==null&&this.isInActiveSystem(`naif-${n}`)}isMoonGroupVisible(e){if(!this.getLayers().isVisible(`moons`)||!this.isInFocusedSystem(e))return!1;let t=this.bodies.maxMoonA(e);return t?this.cameraDistThreeJS/10/t<=this.scaledPlanetary[$.FAR]:!1}isSpacecraftGroupVisible(e){if(this.getLayers().hidesSpacecraftGroup(e))return!1;let t=this.activeSystemId;return M_(e)||this.bodies.bodiesById.get(e)?.data.objectType===W.STAR?!t:t?e===t?!0:this.bodies.getChildren(t)?.has(e)??!1:!1}isAsteroidGroupVisible(e){if(this.getLayers().hidesZone(e)||this.activeSystemId)return!1;let t=this.getSmallBodyFilter();if(t&&e.startsWith(`small_bodies/`)){let n=e.slice(Tv.length);if(t.kind===`class`&&n!==t.className||t.kind===`category`&&fv(n)!==t.category)return!1}let n=dn[e];return n?this.cameraDistThreeJS/10/n.maxA<=this.scaledSystem[$.FAR]/3:!0}isInActiveSystem(e){return this.bodies.isInSystem(e,this.activeSystemId)}debugBody(e){let t=this.bodies.getBody(e);if(!t)return{id:e,found:!1};let n=t.data.objectType,r=n===W.MOON,i=this.getProbeStore(),a=r?this.getMoonVisibility(t):this.getPlanetVisibility(t,this.cameraDistThreeJS);return{id:e,name:t.data.name,objectType:W[n],orbitalSource:t.data.orbitalSource,parentId:t.data.parentId,a:t.data.a,jd:this.currentJd,isMoon:r,isSystemBody:this.bodies.isSystemBody(t),isInFocusedSystem_parent:this.isInFocusedSystem(t.data.parentId),focusedBodyId:this.focusedBodyIdPlain,focusedSystemId:this.focusedSystemIdPlain,activeSystemId:this.activeSystemId,isZoomedIn:this.isZoomedIn,hideThresholdAU:this.hideThresholdAU,containingSystemAt:i?i.containingSystemAt(t.data.id,this.currentJd):null,camDistAU:this.cameraDistThreeJS/10,visibility:$[a],hasFullRendering:this.hasFullRendering(t)}}isBodyInSystem(e,t){return e.data.id===t||this.bodies.isInSystem(e.data.parentId,t)}isInFocusedSystem(e){return this.bodies.isInSystem(e,this.focusedSystemIdPlain)}matchesSmallBodyClass(e){let t=this.getSmallBodyFilter();return t===null?!0:Dv(this.bodies,e,t)}recomputeFullMoons(){this.fullMoonIds.clear();let e=this.focusedSystemIdPlain;if(!e)return;let t=this.cameraDistThreeJS/10,n=[];for(let r of this.bodies.getChildren(e)??[]){let e=this.bodies.bodiesById.get(r);e&&e.data.objectType===W.MOON&&t/e.data.a<=this.scaledPlanetary[$.FULL]&&n.push(e)}n.sort((e,t)=>e.data.a-t.data.a).slice(0,40).forEach(e=>this.fullMoonIds.add(e.data.id))}computeHideThreshold(){let e=this.focusedSystemIdPlain;return e?this.systemReachAU(e):1/0}systemReachAU(e){let t=this.bodies.maxMoonA(e);if(t)return 2*t;let n=this.bodies.getBody(e);if(!n)return 0;if(Iv(n.data.objectType))return Fv;let r=nv(n.data);return r?r*jv:0}},Rv=``;function zv(e){let t=new Map;if(!e)return t;for(let n of e.split(`
|
|
4050
|
+
}`,nh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ic(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new fu({vertexShader:eh,fragmentShader:th,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new As(new $l(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},rh=class extends mi{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new nh,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new q,C=null,w=new sd;w.viewport=new sa;let T=new sd;T.viewport=new sa;let E=[w,T],D=new Sd,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Va,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}O=null,k=null,h.reset();for(let e in g)delete g[e];e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,ae.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&G(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,A),r.addEventListener(`selectstart`,A),r.addEventListener(`selectend`,A),r.addEventListener(`squeeze`,A),r.addEventListener(`squeezestart`,A),r.addEventListener(`squeezeend`,A),r.addEventListener(`end`,j),r.addEventListener(`inputsourceschange`,M),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?$n:Qn,a=_.stencil?Kn:Vn);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new la(d.textureWidth,d.textureHeight,{format:Zn,type:In,depthTexture:new Pc(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new la(f.framebufferWidth,f.framebufferHeight,{format:Zn,type:In,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ae.setContext(r),ae.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function M(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let ee=new J,N=new J;function te(e,t,n){ee.setFromMatrixPosition(t.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);let r=ee.distanceTo(N),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ne(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;ne(D,i);for(let e=0;e<a.length;e++)ne(a[e],i);a.length===2?te(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),re(e,D,i)};function re(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=vi*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(D)},this.getCameraTexture=function(e){return g[e]};let P=null;function ie(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==D.cameras.length&&(D.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=E[n];o===void 0&&(o=new sd,o.layers.enable(n),o.viewport=new sa,E[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(D.matrix.copy(o.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),i===!0&&D.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new Ic,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}P&&P(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ae=new Yd;ae.setAnimationLoop(ie),this.setAnimationLoop=function(e){P=e},this.dispose=function(){}}},ih=new xa,ah=new Y;function oh(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,cu(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,ih.copy(o),ih.x*=-1,ih.y*=-1,ih.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(ih.y*=-1,ih.z*=-1),e.envMapRotation.value.setFromMatrix4(ah.makeRotationFromEuler(ih)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function sh(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return K(`WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?G(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):G(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var ch=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),lh=null;function uh(){return lh===null&&(lh=new Ws(ch,16,16,nr,Un),lh.name=`DFG_LUT`,lh.minFilter=Nn,lh.magFilter=Nn,lh.wrapS=On,lh.wrapT=On,lh.generateMipmaps=!1,lh.needsUpdate=!0),lh}var dh=class{constructor(e={}){let{canvas:t=oi(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=In}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([ir,rr,tr]),g=new Set([In,Vn,zn,Kn,Wn,Gn]),_=new Uint32Array(4),v=new Int32Array(4),y=null,b=null,x=[],S=[],C=null;this.domElement=t,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.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let w=this,T=!1;this._outputColorSpace=Xr;let E=0,D=0,O=null,k=-1,A=null,j=new sa,M=new sa,ee=null,N=new X(0),te=0,ne=t.width,re=t.height,P=1,ie=null,ae=null,F=new sa(0,0,ne,re),I=new sa(0,0,ne,re),oe=!1,se=new uc,ce=!1,le=!1,ue=new Y,de=new J,fe=new sa,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},me=!1;function he(){return O===null?P:1}let L=n;function ge(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r183`),t.addEventListener(`webglcontextlost`,Le,!1),t.addEventListener(`webglcontextrestored`,Re,!1),t.addEventListener(`webglcontextcreationerror`,ze,!1),L===null){let t=`webgl2`;if(L=ge(t,e),L===null)throw ge(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw K(`WebGLRenderer: `+e.message),e}let R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe;function Fe(){R=new Af(L),R.init(),Me=new $m(L,R),_e=new of(L,R,e,Me),z=new Zm(L,R),_e.reversedDepthBuffer&&d&&z.buffers.depth.setReversed(!0),ve=new Nf(L),B=new jm,V=new Qm(L,R,z,B,_e,Me,ve),ye=new kf(w),be=new Xd(L),Ne=new rf(L,be),xe=new jf(L,be,ve,Ne),Se=new Ff(L,xe,be,Ne,ve),ke=new Pf(L,_e,V),Ee=new sf(B),Ce=new Am(w,ye,R,_e,Ne,Ee),we=new oh(w,B),Te=new Fm,H=new Hm(R),Oe=new nf(w,ye,z,Se,p,s),De=new Xm(w,Se,_e),Pe=new sh(L,ve,_e,z),Ae=new af(L,R,ve),je=new Mf(L,R,ve),ve.programs=Ce.programs,w.capabilities=_e,w.extensions=R,w.properties=B,w.renderLists=Te,w.shadowMap=De,w.state=z,w.info=ve}Fe(),m!==1009&&(C=new Lf(m,t.width,t.height,r,i));let Ie=new rh(w,L);this.xr=Ie,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let e=R.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=R.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(e){e!==void 0&&(P=e,this.setSize(ne,re,!1))},this.getSize=function(e){return e.set(ne,re)},this.setSize=function(e,n,r=!0){if(Ie.isPresenting){G(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ne=e,re=n,t.width=Math.floor(e*P),t.height=Math.floor(n*P),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),C!==null&&C.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ne*P,re*P).floor()},this.setDrawingBufferSize=function(e,n,r){ne=e,re=n,P=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){console.error(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){console.warn(`THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}C.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(j)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,r){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,r),z.viewport(j.copy(F).multiplyScalar(P).round())},this.getScissor=function(e){return e.copy(I)},this.setScissor=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),z.scissor(M.copy(I).multiplyScalar(P).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){z.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Oe.getClearColor())},this.setClearColor=function(){Oe.setClearColor(...arguments)},this.getClearAlpha=function(){return Oe.getClearAlpha()},this.setClearAlpha=function(){Oe.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(O!==null){let t=O.texture.format;e=h.has(t)}if(e){let e=O.texture.type,t=g.has(e),n=Oe.getClearColor(),r=Oe.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,L.clearBufferuiv(L.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,L.clearBufferiv(L.COLOR,0,v))}else r|=L.COLOR_BUFFER_BIT}t&&(r|=L.DEPTH_BUFFER_BIT),n&&(r|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&L.clear(r)},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(){t.removeEventListener(`webglcontextlost`,Le,!1),t.removeEventListener(`webglcontextrestored`,Re,!1),t.removeEventListener(`webglcontextcreationerror`,ze,!1),Oe.dispose(),Te.dispose(),H.dispose(),B.dispose(),ye.dispose(),Se.dispose(),Ne.dispose(),Pe.dispose(),Ce.dispose(),Ie.dispose(),Ie.removeEventListener(`sessionstart`,Ke),Ie.removeEventListener(`sessionend`,qe),Je.stop()};function Le(e){e.preventDefault(),li(`WebGLRenderer: Context Lost.`),T=!0}function Re(){li(`WebGLRenderer: Context Restored.`),T=!1;let e=ve.autoReset,t=De.enabled,n=De.autoUpdate,r=De.needsUpdate,i=De.type;Fe(),ve.autoReset=e,De.enabled=t,De.autoUpdate=n,De.needsUpdate=r,De.type=i}function ze(e){K(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Be(e){let t=e.target;t.removeEventListener(`dispose`,Be),Ve(t)}function Ve(e){He(e),B.remove(e)}function He(e){let t=B.get(e).programs;t!==void 0&&(t.forEach(function(e){Ce.releaseProgram(e)}),e.isShaderMaterial&&Ce.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=pe);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=rt(e,t,n,r,i);z.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=xe.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ne.setup(i,r,s,n,c);let h,g=Ae;if(c!==null&&(h=be.get(c),g=je,g.setIndex(h)),i.isMesh)r.wireframe===!0?(z.setLineWidth(r.wireframeLinewidth*he()),g.setMode(L.LINES)):g.setMode(L.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),z.setLineWidth(e*he()),i.isLineSegments?g.setMode(L.LINES):i.isLineLoop?g.setMode(L.LINE_LOOP):g.setMode(L.LINE_STRIP)}else i.isPoints?g.setMode(L.POINTS):i.isSprite&&g.setMode(L.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)di(`WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(R.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?be.get(c).bytesPerElement:1,o=B.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(L,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Ue(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,et(e,t,n),e.side=0,e.needsUpdate=!0,et(e,t,n),e.side=2):et(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),b=H.get(n),b.init(t),S.push(b),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(b.pushLight(e),e.castShadow&&b.pushShadow(e))}),b.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];Ue(a,n,e),r.add(a)}else Ue(t,n,e),r.add(t)}),b=S.pop(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){B.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}R.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let We=null;function Ge(e){We&&We(e)}function Ke(){Je.stop()}function qe(){Je.start()}let Je=new Yd;Je.setAnimationLoop(Ge),typeof self<`u`&&Je.setContext(self),this.setAnimationLoop=function(e){We=e,Ie.setAnimationLoop(e),e===null?Je.stop():Je.start()},Ie.addEventListener(`sessionstart`,Ke),Ie.addEventListener(`sessionend`,qe),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){K(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(T===!0)return;let n=Ie.enabled===!0&&Ie.isPresenting===!0,r=C!==null&&(O===null||n)&&C.begin(w,O);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(t),t=Ie.getCamera()),e.isScene===!0&&e.onBeforeRender(w,e,t,O),b=H.get(e,S.length),b.init(t),S.push(b),ue.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromProjectionMatrix(ue,ni,t.reversedDepth),le=this.localClippingEnabled,ce=Ee.init(this.clippingPlanes,le),y=Te.get(e,x.length),y.init(),x.push(y),Ie.enabled===!0&&Ie.isPresenting===!0){let e=w.xr.getDepthSensingMesh();e!==null&&Ye(e,t,-1/0,w.sortObjects)}Ye(e,t,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(ie,ae),me=Ie.enabled===!1||Ie.isPresenting===!1||Ie.hasDepthSensing()===!1,me&&Oe.addToRenderList(y,e),this.info.render.frame++,ce===!0&&Ee.beginShadows();let i=b.state.shadowsArray;if(De.render(i,e,t),ce===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&C.hasRenderPass())===!1){let n=y.opaque,r=y.transmissive;if(b.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];Ze(n,r,e,a)}me&&Oe.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];Xe(y,e,n,n.viewport)}}else r.length>0&&Ze(n,r,e,t),me&&Oe.render(e),Xe(y,e,t)}O!==null&&D===0&&(V.updateMultisampleRenderTarget(O),V.updateRenderTargetMipmap(O)),r&&C.end(w),e.isScene===!0&&e.onAfterRender(w,e,t),Ne.resetDefaultState(),k=-1,A=null,S.pop(),S.length>0?(b=S[S.length-1],ce===!0&&Ee.setGlobalState(w.clippingPlanes,b.state.camera)):b=null,x.pop(),y=x.length>0?x[x.length-1]:null};function Ye(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)b.pushLight(e),e.castShadow&&b.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||se.intersectsSprite(e)){r&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ue);let t=Se.update(e),i=e.material;i.visible&&y.push(e,t,i,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||se.intersectsObject(e))){let t=Se.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),fe.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),fe.copy(e.boundingSphere.center)),fe.applyMatrix4(e.matrixWorld).applyMatrix4(ue)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&y.push(e,t,s,n,fe.z,o)}}else i.visible&&y.push(e,t,i,n,fe.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Ye(i[e],t,n,r)}function Xe(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;b.setupLightsView(n),ce===!0&&Ee.setGlobalState(w.clippingPlanes,n),r&&z.viewport(j.copy(r)),i.length>0&&Qe(i,t,n),a.length>0&&Qe(a,t,n),o.length>0&&Qe(o,t,n),z.buffers.depth.setTest(!0),z.buffers.depth.setMask(!0),z.buffers.color.setMask(!0),z.setPolygonOffset(!1)}function Ze(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[r.id]===void 0){let e=R.has(`EXT_color_buffer_half_float`)||R.has(`EXT_color_buffer_float`);b.state.transmissionRenderTarget[r.id]=new la(1,1,{generateMipmaps:!0,type:e?Un:In,minFilter:Fn,samples:Math.max(4,_e.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xi.workingColorSpace})}let a=b.state.transmissionRenderTarget[r.id],o=r.viewport||j;a.setSize(o.z*w.transmissionResolutionScale,o.w*w.transmissionResolutionScale);let s=w.getRenderTarget(),c=w.getActiveCubeFace(),l=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(N),te=w.getClearAlpha(),te<1&&w.setClearColor(16777215,.5),w.clear(),me&&Oe.render(n);let u=w.toneMapping;w.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),b.setupLightsView(r),ce===!0&&Ee.setGlobalState(w.clippingPlanes,r),Qe(e,n,r),V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a),R.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,$e(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(V.updateMultisampleRenderTarget(a),V.updateRenderTargetMipmap(a))}w.setRenderTarget(s,c,l),w.setClearColor(N,te),d!==void 0&&(r.viewport=d),w.toneMapping=u}function Qe(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&$e(o,t,n,s,l,c)}}function $e(e,t,n,r,i,a){e.onBeforeRender(w,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(w,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,w.renderBufferDirect(n,t,r,i,e,a),i.side=2):w.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(w,t,n,r,i,a)}function et(e,t,n){t.isScene!==!0&&(t=pe);let r=B.get(e),i=b.state.lights,a=b.state.shadowsArray,o=i.state.version,s=Ce.getParameters(e,i.state,a,t,n),c=Ce.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=ye.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Be),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return nt(e,s),d}else s.uniforms=Ce.getUniforms(e),e.onBeforeCompile(s,w),d=Ce.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Ee.uniform),nt(e,s),r.needsLights=at(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=d,r.uniformsList=null,d}function tt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Wp.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function nt(e,t){let n=B.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function rt(e,t,n,r,i){t.isScene!==!0&&(t=pe),V.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=O===null?w.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:Zr,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=ye.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(h=w.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=B.get(r),y=b.state.lights;if(ce===!0&&(le===!0||e!==A)){let t=e===A&&r.id===k;Ee.setState(r,e,t)}let x=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?x=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?x=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ee.numPlanes||v.numIntersection!==Ee.numIntersection)?x=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h?v.morphTargetsCount!==_&&(x=!0):x=!0:x=!0:x=!0:(x=!0,v.__version=r.version);let S=v.currentProgram;x===!0&&(S=et(r,t,i));let C=!1,T=!1,E=!1,D=S.getUniforms(),j=v.uniforms;if(z.useProgram(S.program)&&(C=!0,T=!0,E=!0),r.id!==k&&(k=r.id,T=!0),C||A!==e){z.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),D.setValue(L,`projectionMatrix`,e.projectionMatrix),D.setValue(L,`viewMatrix`,e.matrixWorldInverse);let t=D.map.cameraPosition;t!==void 0&&t.setValue(L,de.setFromMatrixPosition(e.matrixWorld)),_e.logarithmicDepthBuffer&&D.setValue(L,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&D.setValue(L,`isOrthographic`,e.isOrthographicCamera===!0),A!==e&&(A=e,T=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&D.setValue(L,`directionalShadowMap`,y.state.directionalShadowMap,V),y.state.spotShadowMap.length>0&&D.setValue(L,`spotShadowMap`,y.state.spotShadowMap,V),y.state.pointShadowMap.length>0&&D.setValue(L,`pointShadowMap`,y.state.pointShadowMap,V)),i.isSkinnedMesh){D.setOptional(L,i,`bindMatrix`),D.setOptional(L,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),D.setValue(L,`boneTexture`,e.boneTexture,V))}i.isBatchedMesh&&(D.setOptional(L,i,`batchingTexture`),D.setValue(L,`batchingTexture`,i._matricesTexture,V),D.setOptional(L,i,`batchingIdTexture`),D.setValue(L,`batchingIdTexture`,i._indirectTexture,V),D.setOptional(L,i,`batchingColorTexture`),i._colorsTexture!==null&&D.setValue(L,`batchingColorTexture`,i._colorsTexture,V));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&ke.update(i,n,S),(T||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,D.setValue(L,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=uh()),T&&(D.setValue(L,`toneMappingExposure`,w.toneMappingExposure),v.needsLights&&it(j,E),a&&r.fog===!0&&we.refreshFogUniforms(j,a),we.refreshMaterialUniforms(j,r,P,re,b.state.transmissionRenderTarget[e.id]),Wp.upload(L,tt(v),j,V)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Wp.upload(L,tt(v),j,V),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&D.setValue(L,`center`,i.center),D.setValue(L,`modelViewMatrix`,i.modelViewMatrix),D.setValue(L,`normalMatrix`,i.normalMatrix),D.setValue(L,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Pe.update(n,S),Pe.bind(n,S)}}return S}function it(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function at(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(e,t,n){let r=B.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),B.get(e.texture).__webglTexture=t,B.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=B.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let ot=L.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){O=e,E=t,D=n;let r=null,i=!1,a=!1;if(e){let o=B.get(e);if(o.__useDefaultFramebuffer!==void 0){z.bindFramebuffer(L.FRAMEBUFFER,o.__webglFramebuffer),j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest,z.viewport(j),z.scissor(M),z.setScissorTest(ee),k=-1;return}else if(o.__webglFramebuffer===void 0)V.setupRenderTarget(e);else if(o.__hasExternalTextures)V.rebindTextures(e,B.get(e.texture).__webglTexture,B.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&B.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);V.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=B.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&V.useMultisampledRTT(e)===!1?B.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest}else j.copy(F).multiplyScalar(P).floor(),M.copy(I).multiplyScalar(P).floor(),ee=oe;if(n!==0&&(r=ot),z.bindFramebuffer(L.FRAMEBUFFER,r)&&z.drawBuffers(e,r),z.viewport(j),z.scissor(M),z.setScissorTest(ee),i){let r=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=B.get(e.textures[t]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=B.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,t.__webglTexture,n)}k=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){z.bindFramebuffer(L.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(c)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!_e.textureTypeReadable(l)){K(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&L.readPixels(t,n,r,i,Me.convert(c),Me.convert(l),a)}finally{let e=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=B.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){z.bindFramebuffer(L.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!_e.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!_e.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.bufferData(L.PIXEL_PACK_BUFFER,a.byteLength,L.STREAM_READ),L.readPixels(t,n,r,i,Me.convert(l),Me.convert(u),0);let f=O===null?null:B.get(O).__webglFramebuffer;z.bindFramebuffer(L.FRAMEBUFFER,f);let p=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await fi(L,p,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,a),L.deleteBuffer(d),L.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;V.setTexture2D(e,0),L.copyTexSubImage2D(L.TEXTURE_2D,n,0,0,o,s,i,a),z.unbindTexture()};let st=L.createFramebuffer(),ct=L.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Me.convert(t.format),_=Me.convert(t.type),v;t.isData3DTexture?(V.setTexture3D(t,0),v=L.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(V.setTexture2DArray(t,0),v=L.TEXTURE_2D_ARRAY):(V.setTexture2D(t,0),v=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,t.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,t.unpackAlignment);let y=L.getParameter(L.UNPACK_ROW_LENGTH),b=L.getParameter(L.UNPACK_IMAGE_HEIGHT),x=L.getParameter(L.UNPACK_SKIP_PIXELS),S=L.getParameter(L.UNPACK_SKIP_ROWS),C=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,h.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,h.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,l),L.pixelStorei(L.UNPACK_SKIP_ROWS,u),L.pixelStorei(L.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=B.get(e),r=B.get(t),h=B.get(n.__renderTarget),g=B.get(r.__renderTarget);z.bindFramebuffer(L.READ_FRAMEBUFFER,h.__webglFramebuffer),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(e).__webglTexture,i,d+n),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,B.get(t).__webglTexture,a,m+n)),L.blitFramebuffer(l,u,o,s,f,p,o,s,L.DEPTH_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||B.has(e)){let n=B.get(e),r=B.get(t);z.bindFramebuffer(L.READ_FRAMEBUFFER,st),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,ct);for(let e=0;e<c;e++)w?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,n.__webglTexture,i),T?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,r.__webglTexture,a),i===0?T?L.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):L.copyTexSubImage2D(v,a,f,p,l,u,o,s):L.blitFramebuffer(l,u,o,s,f,p,o,s,L.COLOR_BUFFER_BIT,L.NEAREST);z.bindFramebuffer(L.READ_FRAMEBUFFER,null),z.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?L.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h);L.pixelStorei(L.UNPACK_ROW_LENGTH,y),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,b),L.pixelStorei(L.UNPACK_SKIP_PIXELS,x),L.pixelStorei(L.UNPACK_SKIP_ROWS,S),L.pixelStorei(L.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&L.generateMipmap(v),z.unbindTexture()},this.initRenderTarget=function(e){B.get(e).__webglFramebuffer===void 0&&V.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?V.setTextureCube(e,0):e.isData3DTexture?V.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?V.setTexture2DArray(e,0):V.setTexture2D(e,0),z.unbindTexture()},this.resetState=function(){E=0,D=0,O=null,z.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return ni}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Xi._getDrawingBufferColorSpace(e),t.unpackColorSpace=Xi._getUnpackColorSpace()}},fh=-(2**40),ph=8;function mh(e,t){return e<0||e>=ph?fh:t*ph+e}function hh(e){return(e%ph+ph)%ph}function gh(e){return(e-hh(e))/ph}function _h(e){return e===fh?null:ln(hh(e),gh(e))}function vh(e){let t=e.indexOf(`-`);if(t<=0)return null;let n=cn(e.slice(0,t));if(n===void 0)return null;let r=Number(e.slice(t+1));if(!Number.isInteger(r)||r>2147483647||r<-2147483648)return null;let i=mh(n,r);return i===fh?null:i}function yh(e){let t=new Set;for(let n of e){let e=vh(n);e!==null&&t.add(e)}return t}function bh(e){return e+7&-8}function xh(e){return{subFormat:e.getUint16(24,!0),source:e.getUint8(26),idType:e.getUint8(27),rowCount:e.getUint32(28,!0)}}function Sh(e,t){return ln(e.idType,e.id[t])}function Ch(e,t){return mh(e.idType,e.id[t])}function wh(e,t){let n=Zt,r=new Int32Array(e,n,t);n+=bh(t*4);let i=new Uint8Array(e,n,t);n+=bh(t);let a=new Int32Array(e,n,t);n+=bh(t*4);let o=new Uint8Array(e,n,t);return n+=bh(t),{id:r,objectType:i,parentId:a,scale:o,offset:n}}function Th(e,t,n){let r=n,i=new Float64Array(e,r,t);r+=t*8;let a=new Float32Array(e,r,t);r+=bh(t*4);let o=new Float32Array(e,r,t);r+=bh(t*4);let s=new Float32Array(e,r,t);r+=bh(t*4);let c=new Float32Array(e,r,t);r+=bh(t*4);let l=new Float32Array(e,r,t);r+=bh(t*4);let u=new Float32Array(e,r,t);r+=bh(t*4);let d=new Float32Array(e,r,t);r+=bh(t*4);let f=new Float32Array(e,r,t);return r+=bh(t*4),{epochJd:i,a,e:o,i:s,om:c,w:l,ma:u,n:d,radiusKm:f,offset:r}}function Eh(e,t,n){let{subFormat:r,rowCount:i,source:a,idType:o}=xh(new DataView(e));if(o===an.UNKNOWN&&i>0&&console.warn(`elements payload has unknown id-type — ${i} row(s) will lack reconstructed IDs`),r===1)return Oh(e,i,t,n,a,o);if(r===2)return Dh(e,i,t,n,a,o);if(r!==0)throw Error(`Unknown elements sub-format: ${r}`);let{id:s,objectType:c,parentId:l,scale:u,offset:d}=wh(e,i),f=Th(e,i,d),p=f.offset,m=new Float32Array(e,p,i);p+=bh(i*4);let h=new Float32Array(e,p,i);p+=bh(i*4);let g=new Uint8Array(e,p,i);p+=bh(i);let _=new Uint8Array(e,p,i);p+=bh(i);let v=new Float32Array(e,p,i),y={validityStart:t,validityEnd:n,source:a,idType:o};return{kind:`keplerian`,id:s,objectType:c,parentId:l,scale:u,epochJd:f.epochJd,a:f.a,e:f.e,i:f.i,om:f.om,w:f.w,ma:f.ma,n:f.n,radiusKm:f.radiusKm,omDot:m,wDot:h,hasLocalized:g,flags:_,visibleFromDays:v,rowCount:i,...y}}function Dh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=Th(e,t,u),f=d.offset,p={validityStart:n,validityEnd:r,source:i,idType:a},m=new Float32Array(e,f,t);f+=bh(t*4);let h=new Float32Array(e,f,t);f+=bh(t*4);let g=new Float32Array(e,f,t);f+=bh(t*4);let _=new Int32Array(e,f,t);f+=bh(t*4);let v=new Int32Array(e,f,t);f+=bh(t*4);let y=new Uint8Array(e,f,t);f+=bh(t);let b=new Uint8Array(e,f,t);f+=bh(t);let x=new Float32Array(e,f,t);return{kind:`sgp4`,id:o,objectType:s,parentId:c,scale:l,epochJd:d.epochJd,a:d.a,e:d.e,i:d.i,om:d.om,w:d.w,ma:d.ma,n:d.n,radiusKm:d.radiusKm,bstar:m,meanMotionDot:h,meanMotionDdot:g,elementSetNo:_,revAtEpoch:v,hasLocalized:y,flags:b,visibleFromDays:x,rowCount:t,...p}}function Oh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=wh(e,t),d=u,f={validityStart:n,validityEnd:r,source:i,idType:a},p=new Float64Array(e,d,t);d+=t*8;let m=new Float32Array(e,d,t);d+=bh(t*4);let h=new Float32Array(e,d,t);d+=bh(t*4);let g=new Float32Array(e,d,t);d+=bh(t*4);let _=new Float32Array(e,d,t);d+=bh(t*4);let v=new Float32Array(e,d,t);d+=bh(t*4);let y=new Float64Array(e,d,t);d+=t*8;let b=new Float32Array(e,d,t);d+=bh(t*4);let x=new Uint8Array(e,d,t);d+=bh(t);let S=new Uint8Array(e,d,t);return d+=bh(t),{kind:`parabolic`,id:o,objectType:s,parentId:c,scale:l,epochJd:p,q:m,e:h,i:g,om:_,w:v,tp:y,radiusKm:b,hasLocalized:x,flags:S,visibleFromDays:new Float32Array(e,d,t),rowCount:t,...f}}var kh=Math.PI,Ah=kh*2,jh=kh/180;180/kh;var Mh=398600.8,Nh=6378.135,Ph=60/Math.sqrt(Nh*Nh*Nh/Mh),Fh=Nh*Ph/60,Ih=1/Ph,Lh=.001082616,Rh=-253881e-11,zh=-165597e-11,Bh=Rh/Lh,Vh=2/3,Hh=1440/(2*kh);function Uh(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function Wh(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function Gh(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return Wh(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return Wh(e,t,n,r,i,a,o)}function Kh(e,t){let{e3:n,ee2:r,peo:i,pgho:a,pho:o,pinco:s,plo:c,se2:l,se3:u,sgh2:d,sgh3:f,sgh4:p,sh2:m,sh3:h,si2:g,si3:_,sl2:v,sl3:y,sl4:b,t:x,xgh2:S,xgh3:C,xgh4:w,xh2:T,xh3:E,xi2:D,xi3:O,xl2:k,xl3:A,xl4:j,zmol:M,zmos:ee}=e,{init:N,opsmode:te}=t,{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}=t,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye;ye=ee+119459e-10*x,N===`y`&&(ye=ee),V=ye+2*.01675*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let be=l*pe+u*me,xe=g*pe+_*me,Se=v*pe+y*me+b*z,Ce=d*pe+f*me+p*z,we=m*pe+h*me;ye=M+.00015835218*x,N===`y`&&(ye=M),V=ye+2*.0549*Math.sin(ye),z=Math.sin(V),pe=.5*z*z-.25,me=-.5*z*Math.cos(V);let Te=r*pe+n*me,H=D*pe+O*me,Ee=k*pe+A*me+j*z,De=S*pe+C*me+w*z,Oe=T*pe+E*me;return he=be+Te,R=xe+H,_e=Se+Ee,L=Ce+De,ge=we+Oe,N===`n`&&(he-=i,R-=s,_e-=c,L-=a,ge-=o,re+=R,ne+=he,se=Math.sin(re),oe=Math.cos(re),re>=.2?(ge/=se,L-=oe*ge,ie+=L,P+=ge,ae+=_e):(le=Math.sin(P),ce=Math.cos(P),F=se*le,I=se*ce,ue=ge*ce+R*oe*le,de=-ge*le+R*oe*ce,F+=ue,I+=de,P%=Ah,P<0&&te===`a`&&(P+=Ah),ve=ae+ie+oe*P,fe=_e+L-R*P*se,ve+=fe,B=P,P=Math.atan2(F,I),P<0&&te===`a`&&(P+=Ah),Math.abs(B-P)>kh&&(P<B?P+=Ah:P-=Ah),ae+=_e,ie=ve-ae-oe*P)),{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}}function qh(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:o,np:s}=e,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H,Ee,De,Oe=.01675,ke=.0549,Ae=s,je=n,Me=Math.sin(o),Ne=Math.cos(o),Pe=Math.sin(r),Fe=Math.cos(r),Ie=Math.sin(a),Le=Math.cos(a),Re=je*je,ze=1-Re,Be=Math.sqrt(ze),Ve=t+18261.5+i/1440,He=(4.523602-.00092422029*Ve)%Ah,Ue=Math.sin(He),We=Math.cos(He),Ge=.91375164-.03568096*We,Ke=Math.sqrt(1-Ge*Ge),qe=.089683511*Ue/Ke,Je=Math.sqrt(1-qe*qe),Ye=5.8351514+.001944368*Ve,Xe=.39785416*Ue/Ke,Ze=Je*We+.91744867*qe*Ue;Xe=Math.atan2(Xe,Ze),Xe+=Ye-He;let Qe=Math.cos(Xe),$e=Math.sin(Xe);D=.1945905,O=-.98088458,j=.91744867,M=.39785416,k=Ne,A=Me,v=29864797e-13;let et=1/Ae,tt=0;for(;tt<2;)tt+=1,c=D*k+O*j*A,u=-O*k+D*j*A,m=-D*A+O*j*k,h=O*M,g=O*A+D*j*k,_=D*M,l=Le*m+Ie*h,d=Le*g+Ie*_,f=-Ie*m+Le*h,p=-Ie*g+Le*_,y=c*Fe+l*Pe,b=u*Fe+d*Pe,x=-c*Pe+l*Fe,S=-u*Pe+d*Fe,C=f*Pe,w=p*Pe,T=f*Fe,E=p*Fe,H=12*y*y-3*x*x,Ee=24*y*b-6*x*S,De=12*b*b-3*S*S,B=3*(c*c+l*l)+H*Re,V=6*(c*u+l*d)+Ee*Re,ye=3*(u*u+d*d)+De*Re,be=-6*c*f+Re*(-24*y*T-6*x*C),xe=-6*(c*p+u*f)+Re*(-24*(b*T+y*E)+-6*(x*w+S*C)),Se=-6*u*p+Re*(-24*b*E-6*S*w),Ce=6*l*f+Re*(24*y*C-6*x*T),we=6*(d*f+l*p)+Re*(24*(b*C+y*w)-6*(S*T+x*E)),Te=6*d*p+Re*(24*b*w-6*S*E),B=B+B+ze*H,V=V+V+ze*Ee,ye=ye+ye+ze*De,ge=v*et,L=-.5*ge/Be,R=ge*Be,he=-15*je*R,_e=y*x+b*S,z=b*x+y*S,ve=b*S-y*x,tt===1&&(ee=he,N=L,te=ge,ne=R,re=_e,P=z,ie=ve,ae=B,F=V,I=ye,oe=be,se=xe,ce=Se,le=Ce,ue=we,de=Te,fe=H,pe=Ee,me=De,D=Qe,O=$e,j=Ge,M=Ke,k=Je*Ne+qe*Me,A=Me*Je-Ne*qe,v=4.7968065e-7);let nt=(4.7199672+(.2299715*Ve-Ye))%Ah,rt=(6.2565837+.017201977*Ve)%Ah,it=2*ee*P,at=2*ee*ie,ot=2*N*se,st=2*N*(ce-oe),ct=-2*te*F,lt=-2*te*(I-ae),ut=-2*te*(-21-9*Re)*Oe,dt=2*ne*pe,ft=2*ne*(me-fe),pt=-18*ne*Oe,mt=-2*N*ue,ht=-2*N*(de-le),gt=2*he*z,_t=2*he*ve,vt=2*L*xe,yt=2*L*(Se-be),bt=-2*ge*V,xt=-2*ge*(ye-B),St=-2*ge*(-21-9*Re)*ke,Ct=2*R*Ee,wt=2*R*(De-H),Tt=-18*R*ke,Et=-2*L*we,Dt=-2*L*(Te-Ce);return{snodm:Me,cnodm:Ne,sinim:Ie,cosim:Le,sinomm:Pe,cosomm:Fe,day:Ve,e3:_t,ee2:gt,em:je,emsq:Re,gam:Ye,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Be,se2:it,se3:at,sgh2:dt,sgh3:ft,sgh4:pt,sh2:mt,sh3:ht,si2:ot,si3:st,sl2:ct,sl3:lt,sl4:ut,s1:he,s2:L,s3:ge,s4:R,s5:_e,s6:z,s7:ve,ss1:ee,ss2:N,ss3:te,ss4:ne,ss5:re,ss6:P,ss7:ie,sz1:ae,sz2:F,sz3:I,sz11:oe,sz12:se,sz13:ce,sz21:le,sz22:ue,sz23:de,sz31:fe,sz32:pe,sz33:me,xgh2:Ct,xgh3:wt,xgh4:Tt,xh2:Et,xh3:Dt,xi2:vt,xi3:yt,xl2:bt,xl3:xt,xl4:St,nm:Ae,z1:B,z2:V,z3:ye,z11:be,z12:xe,z13:Se,z21:Ce,z22:we,z23:Te,z31:H,z32:Ee,z33:De,zmol:nt,zmos:rt}}function Jh(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:a,s4:o,s5:s,sinim:c,ss1:l,ss2:u,ss3:d,ss4:f,ss5:p,sz1:m,sz3:h,sz11:g,sz13:_,sz21:v,sz23:y,sz31:b,sz33:x,t:S,tc:C,gsto:w,mo:T,mdot:E,no:D,nodeo:O,nodedot:k,xpidot:A,z1:j,z3:M,z11:ee,z13:N,z21:te,z23:ne,z31:re,z33:P,ecco:ie,eccsq:ae}=e,{emsq:F,em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}=e,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st=.0043752690880113,ct=.00015835218,lt=119459e-10;de=0,le<.0052359877&&le>.0034906585&&(de=1),le>=.00826&&le<=.00924&&I>=.5&&(de=2);let ut=l*lt*p,dt=u*lt*(g+_),ft=-lt*d*(m+h-14-6*F),pt=f*lt*(b+x-6),mt=-lt*u*(v+y);(se<.052359877||se>kh-.052359877)&&(mt=0),c!==0&&(mt/=c);let ht=pt-t*mt;V=ut+r*ct*s,ye=dt+i*ct*(ee+N),be=ft-ct*a*(j+M-14-6*F);let gt=o*ct*(re+P-6),_t=-ct*i*(te+ne);(se<.052359877||se>kh-.052359877)&&(_t=0),Se=ht+gt,xe=mt,c!==0&&(Se-=t/c*_t,xe+=_t/c);let vt=(w+C*st)%Ah;if(I+=V*S,se+=ye*S,oe+=Se*S,ue+=xe*S,ce+=be*S,de!==0){if(it=(le/Ph)**Vh,de===2){at=t*t;let e=I;I=ie;let n=F;F=ae,ot=I*F,He=-.306-(I-.64)*.44,I<=.65?(Ue=3.616-13.247*I+16.29*F,Ge=-19.302+117.39*I-228.419*F+156.591*ot,Ke=-18.9068+109.7927*I-214.6334*F+146.5816*ot,qe=-41.122+242.694*I-471.094*F+313.953*ot,Je=-146.407+841.88*I-1629.014*F+1083.435*ot,Ye=-532.114+3017.977*I-5740.032*F+3708.276*ot):(Ue=-72.099+331.819*I-508.738*F+266.724*ot,Ge=-346.844+1582.851*I-2415.925*F+1246.113*ot,Ke=-342.585+1554.908*I-2366.899*F+1215.972*ot,qe=-1052.797+4758.686*I-7193.992*F+3651.957*ot,Je=-3581.69+16178.11*I-24462.77*F+12422.52*ot,Ye=I>.715?-5149.66+29936.92*I-54087.36*F+31324.56*ot:1464.74-4664.75*I+3763.64*F),I<.7?(Qe=-919.2277+4988.61*I-9064.77*F+5542.21*ot,Xe=-822.71072+4568.6173*I-8491.4146*F+5337.524*ot,Ze=-853.666+4690.25*I-8624.77*F+5341.4*ot):(Qe=-37995.78+161616.52*I-229838.2*F+109377.94*ot,Xe=-51752.104+218913.95*I-309468.16*F+146349.42*ot,Ze=-40023.88+170470.89*I-242699.48*F+115605.82*ot),$e=c*c,ke=.75*(1+2*t+at),Ae=1.5*$e,Me=1.875*c*(1-2*t-3*at),Ne=-1.875*c*(1+2*t-3*at),Fe=35*$e*ke,Ie=39.375*$e*$e,Le=9.84375*c*($e*(1-2*t-5*at)+.33333333*(-2+4*t+6*at)),Re=c*(4.92187512*$e*(-2-4*t+10*at)+6.56250012*(1+2*t-3*at)),ze=29.53125*c*(2-8*t+at*(-12+8*t+10*at)),Be=29.53125*c*(-2-8*t+at*(12+8*t-10*at)),nt=le*le,rt=it*it,tt=3*nt*rt,et=tt*17891679e-13,pe=et*ke*He,me=et*Ae*Ue,tt*=it,et=tt*3.7393792e-7,he=et*Me*Ge,L=et*Ne*Ke,tt*=it,et=2*tt*7.3636953e-9,ge=et*Fe*qe,R=et*Ie*Je,tt*=it,et=tt*1.1428639e-7,_e=et*Le*Ye,z=et*Re*Ze,et=2*tt*2.1765803e-9,ve=et*ze*Xe,B=et*Be*Qe,Ee=(T+O+O-(vt+vt))%Ah,H=E+be+2*(k+xe-st)-D,I=e,F=n}de===1&&(Ve=1+F*(-2.5+.8125*F),Ge=1+2*F,We=1+F*(-6+6.60937*F),ke=.75*(1+t)*(1+t),je=.9375*c*c*(1+3*t)-.75*(1+t),Pe=1+t,Pe*=1.875*Pe*Pe,Ce=3*le*le*it*it,we=2*Ce*ke*Ve*17891679e-13,Te=3*Ce*Pe*We*2.2123015e-7*it,Ce=Ce*je*Ge*21460748e-13*it,Ee=(T+O+n-vt)%Ah,H=E+A+be+Se+xe-(D+st)),De=Ee,Oe=D,fe=0,le=D+0}return{em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:ge,d4422:R,d5220:_e,d5232:z,d5421:ve,d5433:B,dedt:V,didt:ye,dmdt:be,dndt:0,dnodt:xe,domdt:Se,del1:Ce,del2:we,del3:Te,xfact:H,xlamo:Ee,xli:De,xni:Oe}}function Yh(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*jh/240%Ah,n<0&&(n+=Ah),n}function Xh(e,t,n,r,i,a,o){return e instanceof Date?Yh(Gh(e)):Yh(t===void 0?e:Gh(e,t,n,r,i,a,o))}function Zh(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,o=t*t,s=1-o,c=Math.sqrt(s),l=Math.cos(r),u=l*l,d=(Ph/a)**Vh,f=.75*Lh*(3*u-1)/(c*s),p=f/(d*d),m=d*(1-p*p-p*(1/3+134*p*p/81));p=f/(m*m),a/=1+p;let h=(Ph/a)**Vh,g=Math.sin(r),_=h*s,v=1-5*u,y=-v-u-u,b=1/h,x=_*_,S=h*(1-t),C;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+Ah;C=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%Ah,C<0&&(C+=Ah)}else C=Xh(n+2433281.5);return{no:a,method:`n`,ainv:b,ao:h,con41:y,con42:v,cosio:l,cosio2:u,eccsq:o,omeosq:s,posq:x,rp:S,rteosq:c,sinio:g,gsto:C}}function Qh(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:o,d4422:s,d5220:c,d5232:l,d5421:u,d5433:d,dedt:f,del1:p,del2:m,del3:h,didt:g,dmdt:_,dnodt:v,domdt:y,argpo:b,argpdot:x,t:S,tc:C,gsto:w,xfact:T,xlamo:E,no:D}=e,{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,nm:ne}=e,re=.13130908,P=2.8843198,ie=.37448087,ae=5.7686396,F=.95240898,I=1.8014998,oe=1.050833,se=4.4108898,ce=259200,le,ue,de,fe,pe,me,he,L,ge=0,R=0,_e=(w+C*.0043752690880113)%Ah;if(k+=f*S,j+=g*S,A+=y*S,te+=v*S,ee+=_*S,t!==0){(O===0||S*O<=0||Math.abs(S)<Math.abs(O))&&(O=0,N=D,M=E),le=S>0?720:-720;let e=381;for(;e===381;)t===2?(L=b+x*O,de=L+L,ue=M+M,he=n*Math.sin(de+M-ae)+r*Math.sin(M-ae)+i*Math.sin(L+M-F)+a*Math.sin(-L+M-F)+o*Math.sin(de+ue-I)+s*Math.sin(ue-I)+c*Math.sin(L+M-oe)+l*Math.sin(-L+M-oe)+u*Math.sin(L+ue-se)+d*Math.sin(-L+ue-se),pe=N+T,me=n*Math.cos(de+M-ae)+r*Math.cos(M-ae)+i*Math.cos(L+M-F)+a*Math.cos(-L+M-F)+c*Math.cos(L+M-oe)+l*Math.cos(-L+M-oe)+2*(o*Math.cos(de+ue-I)+s*Math.cos(ue-I)+u*Math.cos(L+ue-se)+d*Math.cos(-L+ue-se)),me*=pe):(he=p*Math.sin(M-re)+m*Math.sin(2*(M-P))+h*Math.sin(3*(M-ie)),pe=N+T,me=p*Math.cos(M-re)+2*m*Math.cos(2*(M-P))+3*h*Math.cos(3*(M-ie)),me*=pe),Math.abs(S-O)>=720?e=381:(R=S-O,e=0),e===381&&(M+=pe*le+he*ce,N+=he*le+me*ce,O+=le);ne=N+he*R+me*R*R*.5,fe=M+pe*R+he*R*R*.5,t===1?(ee=fe-te-A+_e,ge=ne-D):(ee=fe-2*te+2*_e,ge=ne-D),ne=D+ge}return{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,dndt:ge,nm:ne}}var $h;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})($h||={});function eg(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O;e.t=t,e.error=$h.None;let k=e.mo+e.mdot*e.t,A=e.argpo+e.argpdot*e.t,j=e.nodeo+e.nodedot*e.t;u=A,S=k;let M=e.t*e.t;if(w=j+e.nodecf*M,v=1-e.cc1*e.t,y=e.bstar*e.cc4*e.t,b=e.t2cof*M,e.isimp!==1){c=e.omgcof*e.t;let t=1+e.eta*Math.cos(k);s=e.xmcof*(t*t*t-e.delmo),_=c+s,S=k+_,u=A-_,p=M*e.t,m=p*e.t,v=v-e.d2*M-e.d3*p-e.d4*m,y+=e.bstar*e.cc5*(Math.sin(S)-e.sinmao),b=b+e.t3cof*p+m*(e.t4cof+e.t*e.t5cof)}C=e.no;let ee=e.ecco;if(x=e.inclo,e.method===`d`){h=e.t;let t=Qh({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:h,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:ee,argpm:u,inclm:x,xli:e.xli,mm:S,xni:e.xni,nodem:w,nm:C});({em:ee,argpm:u,inclm:x,mm:S,nodem:w,nm:C}=t)}if(C<=0)return e.error=$h.MeanMotionBelowZero,null;let N=(Ph/C)**Vh*v*v;if(C=Ph/N**1.5,ee-=y,ee>=1||ee<-.001)return e.error=$h.MeanEccentricityOutOfRange,null;ee<1e-6&&(ee=1e-6),S+=e.no*b,E=S+u+w,w%=Ah,u%=Ah,E%=Ah,S=(E-u-w)%Ah;let te={am:N,em:ee,im:x,Om:w,om:u,mm:S,nm:C},ne=Math.sin(x),re=Math.cos(x),P=ee;if(T=x,d=u,O=w,D=S,a=ne,i=re,e.method===`d`){let t=Kh(e,{inclo:e.inclo,init:`n`,ep:P,inclp:T,nodep:O,argpp:d,mp:D,opsmode:e.operationmode});if({ep:P,nodep:O,argpp:d,mp:D}=t,T=t.inclp,T<0&&(T=-T,O+=kh,d-=kh),P<0||P>1)return e.error=$h.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(a=Math.sin(T),i=Math.cos(T),e.aycof=-.5*Bh*a,Math.abs(i+1)>15e-13?e.xlcof=-.25*Bh*a*(3+5*i)/(1+i):e.xlcof=-.25*Bh*a*(3+5*i)/15e-13);let ie=P*Math.cos(d);_=1/(N*(1-P*P));let ae=P*Math.sin(d)+_*e.aycof,F=(D+d+O+_*e.xlcof*ie-O)%Ah;l=F,g=9999.9;let I=1;for(;Math.abs(g)>=1e-12&&I<=10;)r=Math.sin(l),n=Math.cos(l),g=1-n*ie-r*ae,g=(F-ae*n+ie*r-l)/g,Math.abs(g)>=.95&&(g=g>0?.95:-.95),l+=g,I+=1;let oe=ie*n+ae*r,se=ie*r-ae*n,ce=ie*ie+ae*ae,le=N*(1-ce);if(le<0)return e.error=$h.SemiLatusRectumBelowZero,null;let ue=N*(1-oe),de=Math.sqrt(N)*se/ue,fe=Math.sqrt(le)/ue,pe=Math.sqrt(1-ce);_=se/(1+pe);let me=N/ue*(r-ae-ie*_),he=N/ue*(n-ie+ae*_);f=Math.atan2(me,he);let L=(he+he)*me,ge=1-2*me*me;_=1/le;let R=.5*Lh*_,_e=R*_;e.method===`d`&&(o=i*i,e.con41=3*o-1,e.x1mth2=1-o,e.x7thm1=7*o-1);let z=ue*(1-1.5*_e*pe*e.con41)+.5*R*e.x1mth2*ge;if(z<1)return e.error=$h.Decayed,null;f-=.25*_e*e.x7thm1*L;let ve=O+1.5*_e*i*L,B=T+1.5*_e*i*a*ge,V=de-C*R*e.x1mth2*L/Ph,ye=fe+C*R*(e.x1mth2*ge+1.5*e.con41)/Ph,be=Math.sin(f),xe=Math.cos(f),Se=Math.sin(ve),Ce=Math.cos(ve),we=Math.sin(B),Te=Math.cos(B),H=-Se*Te,Ee=Ce*Te,De=H*be+Ce*xe,Oe=Ee*be+Se*xe,ke=we*be,Ae=H*xe-Ce*be,je=Ee*xe-Se*be,Me=we*xe;return{position:{x:z*De*Nh,y:z*Oe*Nh,z:z*ke*Nh},velocity:{x:(V*De+ye*Ae)*Fh,y:(V*Oe+ye*je)*Fh,z:(V*ke+ye*Me)*Fh},meanElements:te}}function tg(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:a,xecco:o,xargpo:s,xinclo:c,xmo:l,xno:u,xnodeo:d}=t,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,ge,R,_e,z,ve,B,V,ye,be,xe,Se,Ce,we,Te,H=e;H.isimp=0,H.method=`n`,H.aycof=0,H.con41=0,H.cc1=0,H.cc4=0,H.cc5=0,H.d2=0,H.d3=0,H.d4=0,H.delmo=0,H.eta=0,H.argpdot=0,H.omgcof=0,H.sinmao=0,H.t=0,H.t2cof=0,H.t3cof=0,H.t4cof=0,H.t5cof=0,H.x1mth2=0,H.x7thm1=0,H.mdot=0,H.nodedot=0,H.xlcof=0,H.xmcof=0,H.nodecf=0,H.irez=0,H.d2201=0,H.d2211=0,H.d3210=0,H.d3222=0,H.d4410=0,H.d4422=0,H.d5220=0,H.d5232=0,H.d5421=0,H.d5433=0,H.dedt=0,H.del1=0,H.del2=0,H.del3=0,H.didt=0,H.dmdt=0,H.dnodt=0,H.domdt=0,H.e3=0,H.ee2=0,H.peo=0,H.pgho=0,H.pho=0,H.pinco=0,H.plo=0,H.se2=0,H.se3=0,H.sgh2=0,H.sgh3=0,H.sgh4=0,H.sh2=0,H.sh3=0,H.si2=0,H.si3=0,H.sl2=0,H.sl3=0,H.sl4=0,H.gsto=0,H.xfact=0,H.xgh2=0,H.xgh3=0,H.xgh4=0,H.xh2=0,H.xh3=0,H.xi2=0,H.xi3=0,H.xl2=0,H.xl3=0,H.xl4=0,H.xlamo=0,H.zmol=0,H.zmos=0,H.atime=0,H.xli=0,H.xni=0,H.bstar=a,H.ecco=o,H.argpo=s,H.inclo=c,H.mo=l,H.no=u,H.nodeo=d,H.operationmode=n;let Ee=78/Nh+1,De=42/Nh,Oe=De*De*De*De;H.init=`y`,H.t=0;let ke=Zh({satn:r,ecco:H.ecco,epoch:i,inclo:H.inclo,no:H.no,method:H.method,opsmode:H.operationmode}),{ao:Ae,con42:je,cosio:Me,cosio2:Ne,eccsq:Pe,omeosq:Fe,posq:Ie,rp:Le,rteosq:Re,sinio:ze}=ke;if(H.no=ke.no,H.con41=ke.con41,H.gsto=ke.gsto,H.a=(H.no*Ih)**(-2/3),H.alta=H.a*(1+H.ecco)-1,H.altp=H.a*(1-H.ecco)-1,H.error=0,Fe>=0||H.no>=0){if(H.isimp=0,Le<1.034492841559484&&(H.isimp=1),P=Ee,M=Oe,k=(Le-1)*Nh,k<156){P=k-78,k<98&&(P=20);let e=(120-P)/Nh;M=e*e*e*e,P=P/Nh+1}A=1/Ie,z=1/(Ae-P),H.eta=Ae*H.ecco*z,C=H.eta*H.eta,S=H.ecco*H.eta,j=Math.abs(1-C),_=M*z**4,v=_/j**3.5,h=v*H.no*(Ae*(1+1.5*C+S*(4+C))+.375*Lh*z/j*H.con41*(8+3*C*(8+C))),H.cc1=H.bstar*h,g=0,H.ecco>1e-4&&(g=-2*_*z*Bh*H.no*ze/H.ecco),H.x1mth2=1-Ne,H.cc4=2*H.no*v*Ae*Fe*(H.eta*(2+.5*C)+H.ecco*(.5+2*C)-Lh*z/(Ae*j)*(-3*H.con41*(1-2*S+C*(1.5-.5*S))+.75*H.x1mth2*(2*C-S*(1+C))*Math.cos(2*H.argpo))),H.cc5=2*v*Ae*Fe*(1+2.75*(C+S)+S*C),y=Ne*Ne,ge=1.5*Lh*A*H.no,R=.5*ge*Lh*A,_e=-.46875*zh*A*A*H.no,H.mdot=H.no+.5*ge*Re*H.con41+.0625*R*Re*(13-78*Ne+137*y),H.argpdot=-.5*ge*je+.0625*R*(7-114*Ne+395*y)+_e*(3-36*Ne+49*y),B=-ge*Me,H.nodedot=B+(.5*R*(4-19*Ne)+2*_e*(3-7*Ne))*Me,ve=H.argpdot+H.nodedot,H.omgcof=H.bstar*g*Math.cos(H.argpo),H.xmcof=0,H.ecco>1e-4&&(H.xmcof=-Vh*_*H.bstar/S),H.nodecf=3.5*Fe*B*H.cc1,H.t2cof=1.5*H.cc1,Math.abs(Me+1)>15e-13?H.xlcof=-.25*Bh*ze*(3+5*Me)/(1+Me):H.xlcof=-.25*Bh*ze*(3+5*Me)/15e-13,H.aycof=-.5*Bh*ze;let e=1+H.eta*Math.cos(H.mo);if(H.delmo=e*e*e,H.sinmao=Math.sin(H.mo),H.x7thm1=7*Ne-1,2*kh/H.no>=225){H.method=`d`,H.isimp=1,he=0,E=H.inclo;let e=qh({epoch:i,ep:H.ecco,argpp:H.argpo,tc:he,inclp:H.inclo,nodep:H.nodeo,np:H.no,e3:H.e3,ee2:H.ee2,peo:H.peo,pgho:H.pgho,pho:H.pho,pinco:H.pinco,plo:H.plo,se2:H.se2,se3:H.se3,sgh2:H.sgh2,sgh3:H.sgh3,sgh4:H.sgh4,sh2:H.sh2,sh3:H.sh3,si2:H.si2,si3:H.si3,sl2:H.sl2,sl3:H.sl3,sl4:H.sl4,xgh2:H.xgh2,xgh3:H.xgh3,xgh4:H.xgh4,xh2:H.xh2,xh3:H.xh3,xi2:H.xi2,xi3:H.xi3,xl2:H.xl2,xl3:H.xl3,xl4:H.xl4,zmol:H.zmol,zmos:H.zmos});H.e3=e.e3,H.ee2=e.ee2,H.peo=e.peo,H.pgho=e.pgho,H.pho=e.pho,H.pinco=e.pinco,H.plo=e.plo,H.se2=e.se2,H.se3=e.se3,H.sgh2=e.sgh2,H.sgh3=e.sgh3,H.sgh4=e.sgh4,H.sh2=e.sh2,H.sh3=e.sh3,H.si2=e.si2,H.si3=e.si3,H.sl2=e.sl2,H.sl3=e.sl3,H.sl4=e.sl4,{sinim:p,cosim:f,em:b,emsq:x,s1:ee,s2:N,s3:te,s4:ne,s5:re,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me}=e,H.xgh2=e.xgh2,H.xgh3=e.xgh3,H.xgh4=e.xgh4,H.xh2=e.xh2,H.xh3=e.xh3,H.xi2=e.xi2,H.xi3=e.xi3,H.xl2=e.xl2,H.xl3=e.xl3,H.xl4=e.xl4,H.zmol=e.zmol,H.zmos=e.zmos,{nm:O,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te}=e;let t=Kh(H,{inclo:E,init:H.init,ep:H.ecco,inclp:H.inclo,nodep:H.nodeo,argpp:H.argpo,mp:H.mo,opsmode:H.operationmode});H.ecco=t.ep,H.inclo=t.inclp,H.nodeo=t.nodep,H.argpo=t.argpp,H.mo=t.mp,w=0,T=0,D=0;let n=Jh({cosim:f,emsq:x,argpo:H.argpo,s1:ee,s2:N,s3:te,s4:ne,s5:re,sinim:p,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me,t:H.t,tc:he,gsto:H.gsto,mo:H.mo,mdot:H.mdot,no:H.no,nodeo:H.nodeo,nodedot:H.nodedot,xpidot:ve,z1:V,z3:ye,z11:be,z13:xe,z21:Se,z23:Ce,z31:we,z33:Te,ecco:H.ecco,eccsq:Pe,em:b,argpm:w,inclm:E,mm:D,nm:O,nodem:T,irez:H.irez,atime:H.atime,d2201:H.d2201,d2211:H.d2211,d3210:H.d3210,d3222:H.d3222,d4410:H.d4410,d4422:H.d4422,d5220:H.d5220,d5232:H.d5232,d5421:H.d5421,d5433:H.d5433,dedt:H.dedt,didt:H.didt,dmdt:H.dmdt,dnodt:H.dnodt,domdt:H.domdt,del1:H.del1,del2:H.del2,del3:H.del3,xfact:H.xfact,xlamo:H.xlamo,xli:H.xli,xni:H.xni});H.irez=n.irez,H.atime=n.atime,H.d2201=n.d2201,H.d2211=n.d2211,H.d3210=n.d3210,H.d3222=n.d3222,H.d4410=n.d4410,H.d4422=n.d4422,H.d5220=n.d5220,H.d5232=n.d5232,H.d5421=n.d5421,H.d5433=n.d5433,H.dedt=n.dedt,H.didt=n.didt,H.dmdt=n.dmdt,H.dnodt=n.dnodt,H.domdt=n.domdt,H.del1=n.del1,H.del2=n.del2,H.del3=n.del3,H.xfact=n.xfact,H.xlamo=n.xlamo,H.xli=n.xli,H.xni=n.xni}H.isimp!==1&&(m=H.cc1*H.cc1,H.d2=4*Ae*z*m,L=H.d2*z*H.cc1/3,H.d3=(17*Ae+P)*L,H.d4=.5*L*Ae*z*(221*Ae+31*P)*H.cc1,H.t3cof=H.d2+2*m,H.t4cof=.25*(3*H.d3+H.cc1*(12*H.d2+10*m)),H.t5cof=.2*(3*H.d4+12*H.cc1*H.d3+6*H.d2*H.d2+15*m*(2*H.d2+m)))}eg(H,0),H.init=`n`}function ng(e,t){let n=e.substring(2,7),r=parseInt(e.substring(18,20),10),i=parseFloat(e.substring(20,32)),a=parseFloat(e.substring(33,43)),o=parseFloat(`${e.substring(44,45)}.${e.substring(45,50)}E${e.substring(50,52)}`),s=parseFloat(`${e.substring(53,54)}.${e.substring(54,59)}E${e.substring(59,61)}`),c=parseFloat(t.substring(8,16))*jh,l=parseFloat(t.substring(17,25))*jh,u=parseFloat(`.${t.substring(26,33).replace(/\s/g,`0`)}`),d=parseFloat(t.substring(34,42))*jh,f=parseFloat(t.substring(43,51))*jh,p=parseFloat(t.substring(52,63))/Hh;a/=Hh*1440,o/=Hh*1440*1440;let m=r<57?r+2e3:r+1900,{mon:h,day:g,hr:_,minute:v,sec:y}=Uh(m,i),b=Gh(m,h,g,_,v,y),x={error:0,satnum:n,epochyr:r,epochdays:i,ndot:a,nddot:o,bstar:s,inclo:c,nodeo:l,ecco:u,argpo:d,mo:f,no:p,jdsatepoch:b};return tg(x,{opsmode:`i`,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}function rg(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,s=Number(e.MEAN_MOTION_DOT),c=Number(e.MEAN_MOTION_DDOT);s/=Hh*1440,c/=Hh*1440*1440;let l=Number(e.BSTAR),u=Number(e.INCLINATION)*jh,d=Number(e.RA_OF_ASC_NODE)*jh,f=Number(e.ECCENTRICITY),p=Number(e.ARG_OF_PERICENTER)*jh,m=Number(e.MEAN_ANOMALY)*jh,h=Number(e.MEAN_MOTION)/Hh,{mon:g,day:_,hr:v,minute:y,sec:b}=Uh(i,o),x=Gh(i,g,_,v,y,b),S={error:0,satnum:n,epochyr:a,epochdays:o,ndot:s,nddot:c,bstar:l,inclo:u,nodeo:d,ecco:f,argpo:p,mo:m,no:h,jdsatepoch:x};return tg(S,{opsmode:t,satn:S.satnum,epoch:S.jdsatepoch-2433281.5,xbstar:S.bstar,xecco:S.ecco,xargpo:S.argpo,xinclo:S.inclo,xmo:S.mo,xno:S.no,xnodeo:S.nodeo}),S}3*Float64Array.BYTES_PER_ELEMENT;var ig=149597870.7,ag=23.4392911,og=86400**2/ig**3,sg=1/ig;function Q(e){return e/ig*10}function cg(e){return e/10*ig}var lg=Math.cos(Math.PI/180*ag),ug=Math.sin(Math.PI/180*ag);function dg(e,t,n,r){let i=r??{x:0,y:0,z:0};return i.x=e,i.y=-t*ug+n*lg,i.z=-(t*lg+n*ug),i}var fg=Math.PI/180,pg=Math.cos(ag*fg),mg=Math.sin(ag*fg),hg=2440587.5;function gg(e){return new Date((e-hg)*864e5).toISOString()}function _g(e,t){let n=rg({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:gg(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===$h.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}function vg(e,t){let n=eg(e,(t-e.jdsatepoch)*1440);if(!n||e.error!==$h.None)return null;let{x:r,y:i,z:a}=n.position;return[r,i,a]}function yg(e,t,n){let r=10/ig,i=e*r,a=t*r,o=n*r,s=a*pg+o*mg,c=-a*mg+o*pg;return a=s,o=c,[i,o,-a]}function bg(e,t){let n=vg(e,t);return n?yg(n[0],n[1],n[2]):null}function xg(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}var Sg=700;function Cg(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>Sg)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function wg(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}var Tg=null,Eg=null;function Dg(){if(!Eg){Tg=[];let e=new MessageChannel;e.port1.onmessage=()=>Tg.shift()?.(),Eg=e.port2}return new Promise(e=>{Tg.push(e),Eg.postMessage(null)})}var Og=2451545,kg=86400,Ag=2440587.5,jg=864e5;function Mg(e){return e/jg+Ag}function Ng(e){return Mg(e.getTime())}function Pg(e){return new Date((e-Ag)*jg)}function Fg(e){return(e-Og)*kg}function Ig(e){return Og+e/kg}var Lg=Math.PI/180;Math.cos(ag*Lg),Math.sin(ag*Lg),10/ig;function Rg(e,t,n,r,i,a,o,s,c,l,u,d){e.a[t]=n,e.e[t]=r,e.i[t]=i,e.om[t]=a,e.w[t]=o,e.ma[t]=s,e.n[t]=c,e.epoch[t]=l,e.equatorial[t]=+!!u,e.flags[t]=d}function zg(e,t,n,r){let i=n.data;if(r?.has(i.id))return e.kind[t]=0,!1;if(i.omm)e.kind[t]=3,e.satnum[t]=i.omm.noradCatId,e.bstar[t]=i.omm.bstar,e.ndot[t]=i.omm.meanMotionDot,e.nddot[t]=i.omm.meanMotionDdot;else if(i.satrec)e.kind[t]=3,e.satrec[t]=i.satrec;else if(i.q!=null&&i.tp!=null&&isFinite(i.q)&&isFinite(i.tp))e.kind[t]=2,e.q[t]=i.q,e.tp[t]=i.tp;else if(i.a!==0&&isFinite(i.a))e.kind[t]=1;else return e.kind[t]=0,!1;return Rg(e,t,i.a,i.e,i.i,i.om,i.w,i.ma,i.n,i.epoch,i.equatorial,i.flags??0),!0}async function Bg(e,t,n=!1){let r=e.length,i=Ug(r);i.applyFlagFilter=n;let a=1/0,o=-1/0,s=performance.now();for(let n=0;n<r;n++){if((n&4095)==4095&&performance.now()-s>6&&(await Dg(),s=performance.now()),!zg(i,n,e[n],t))continue;let r=e[n].data;r.validityStart<a&&(a=r.validityStart),r.validityEnd>o&&(o=r.validityEnd)}return i.validityStart=a===1/0?-1/0:a,i.validityEnd=o===-1/0?1/0:o,i}var Vg=[{name:`kind`,make:e=>new Uint8Array(e)},{name:`equatorial`,make:e=>new Uint8Array(e)},{name:`a`,make:e=>new Float64Array(e)},{name:`e`,make:e=>new Float64Array(e)},{name:`i`,make:e=>new Float64Array(e)},{name:`om`,make:e=>new Float64Array(e)},{name:`w`,make:e=>new Float64Array(e)},{name:`ma`,make:e=>new Float64Array(e)},{name:`n`,make:e=>new Float64Array(e)},{name:`epoch`,make:e=>new Float64Array(e)},{name:`q`,make:e=>new Float64Array(e)},{name:`tp`,make:e=>new Float64Array(e)},{name:`flags`,make:e=>new Uint8Array(e)},{name:`visibleFromDays`,make:e=>new Float32Array(e).fill(NaN)},{name:`satnum`,make:e=>new Int32Array(e)},{name:`bstar`,make:e=>new Float64Array(e)},{name:`ndot`,make:e=>new Float64Array(e)},{name:`nddot`,make:e=>new Float64Array(e)},{name:`satrec`,make:e=>Array(e).fill(null),transferable:!1}];function Hg(e){let t=[];for(let n of Vg)n.transferable!==!1&&t.push(e[n.name].buffer);return t}function Ug(e){let t={count:e,applyFlagFilter:!1,validityStart:-1/0,validityEnd:1/0,pickBase:0};for(let n of Vg)t[n.name]=n.make(e);return t}function Wg(e,t){return e.get(t)?.name||null}function Gg(e,t){return e.get(t)?.isMinor??!1}function Kg(e,t){let n=e.get(t);return{name:n?.name||null,isMinor:n?.isMinor??!1}}function qg(e,t,n,r){let i=e.scale[t]===rn.PLANET,a=e.omDot[t],o=e.wDot[t],s=Sh(e,t);if(s===null)return null;let{name:c,isMinor:l}=Kg(n,s);return{id:s,name:c,isMinor:l,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:i?e.a[t]/ig:e.a[t],e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:i?e.n[t]*360:e.n[t],epoch:e.epochJd[t],omDot:a===0?void 0:a,wDot:o===0?void 0:o,equatorial:i,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}function Jg(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i);return{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:0,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:0,n:0,epoch:e.epochJd[t],q:e.q[t],tp:e.tp[t],validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]}}var Yg=new WeakMap,Xg=new WeakMap;function Zg(e,t){return{noradCatId:e.id[t],epochJd:e.epochJd[t],meanMotion:e.n[t],eccentricity:e.e[t],inclination:e.i[t],raOfAscNode:e.om[t],argOfPericenter:e.w[t],meanAnomaly:e.ma[t],bstar:e.bstar[t],meanMotionDot:e.meanMotionDot[t],meanMotionDdot:e.meanMotionDdot[t],elementSetNo:e.elementSetNo[t],revAtEpoch:e.revAtEpoch[t]}}var Qg={get omm(){let e=Xg.get(this);return e&&Zg(e[0],e[1])},get satrec(){let e=this,t=Yg.get(e);return t===void 0&&(t=_g(e.omm,e.name??void 0),Yg.set(e,t),t||(e.unplaceable=!0)),t??void 0}};function $g(e,t,n,r){let i=Sh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Kg(n,i),s=Object.assign(Object.create(Qg),{id:i,name:a,isMinor:o,hasLocalized:e.hasLocalized[t]===1,flags:e.flags[t],objectType:e.objectType[t],parentId:`${r}-${e.parentId[t]}`,radiusKm:e.radiusKm[t],a:e.a[t]/ig,e:e.e[t],i:e.i[t],om:e.om[t],w:e.w[t],ma:e.ma[t],n:e.n[t]*360,epoch:e.epochJd[t],equatorial:!0,validityStart:e.validityStart,validityEnd:e.validityEnd,orbitalSource:e.source,visibleFromDays:e.visibleFromDays[t]});return Xg.set(s,[e,t]),s}function e_(e,t,n,r){return e.kind===`parabolic`?Jg(e,t,n,r):e.kind===`sgp4`?$g(e,t,n,r):qg(e,t,n,r)}function t_(e,t,n,r,i,a){if(a&&i!==void 0&&a.has(i))return n.kind[r]=0,!1;if(e.kind===`parabolic`){let i=e.q[t],a=e.tp[t];return isFinite(i)&&isFinite(a)?(n.kind[r]=2,n.q[r]=i,n.tp[r]=a,Rg(n,r,0,e.e[t],e.i[t],e.om[t],e.w[t],0,0,e.epochJd[t],!1,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}if(e.kind===`sgp4`)return n.kind[r]=3,n.satrec[r]=null,n.satnum[r]=e.id[t],n.bstar[r]=e.bstar[t],n.ndot[r]=e.meanMotionDot[t],n.nddot[r]=e.meanMotionDdot[t],Rg(n,r,e.a[t]/ig,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],e.n[t]*360,e.epochJd[t],!0,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0;let o=e.scale[t]===rn.PLANET,s=o?e.a[t]/ig:e.a[t];return s!==0&&isFinite(s)?(n.kind[r]=1,Rg(n,r,s,e.e[t],e.i[t],e.om[t],e.w[t],e.ma[t],o?e.n[t]*360:e.n[t],e.epochJd[t],o,e.flags[t]),n.visibleFromDays[r]=e.visibleFromDays[t],!0):(n.kind[r]=0,!1)}var n_={"naif-10":`#ffdd44`,"naif-199":`#b5b5b5`,"naif-299":`#e8cda0`,"naif-399":`#4da6ff`,"naif-301":`#888888`,"naif-499":`#c1440e`,"naif-401":`#aa9988`,"naif-402":`#aa9988`,"naif-599":`#d4a66a`,"naif-501":`#8a762e`,"naif-502":`#7c7f6c`,"naif-503":`#7e6c5e`,"naif-504":`#6c6453`,"naif-699":`#e8d8a0`,"naif-601":`#aba890`,"naif-602":`#71a29f`,"naif-603":`#6c6645`,"naif-604":`#494a2a`,"naif-605":`#5c5a3c`,"naif-606":`#835422`,"naif-608":`#776b60`,"naif-799":`#87ceeb`,"naif-701":`#b0b0b0`,"naif-702":`#a8a8a8`,"naif-703":`#62534c`,"naif-704":`#626a62`,"naif-705":`#625252`,"naif-899":`#3f54ba`,"naif-801":`#7c757c`,"naif-999":`#b48977`,"naif-2000001":`#9b9087`},r_=`#cccccc`,i_=`#fcb493`,a_=`#c7ccda`,o_=`#ffe89e`,s_=`#ccb49a`,c_=`#d8ffe8`,l_=`#e8a85c`,u_=`#bed4ec`,d_=`#d5cfe7`,f_=`naif-10`,p_=`naif-399`,m_=new Set(`naif-0.naif-9.spkid-20000002.spkid-20000003.spkid-20000007.spkid-20000010.spkid-20000015.spkid-20000031.spkid-20000052.spkid-20000065.spkid-20000088.spkid-20000107.spkid-20000130.spkid-20000511.spkid-20000588.spkid-20000704.spkid-20001862.spkid-1000592.spkid-1000616.spkid-1000630.spkid-1000639.spkid-1000648.spkid-1000651.spkid-1000669.spkid-1000690.spkid-1000738.spkid-1000742.spkid-1000749.spkid-1000755.spkid-1000778.spkid-1000845.spkid-1000872.spkid-1000882.spkid-1000899.spkid-1000945.spkid-1000967.spkid-1001121`.split(`.`));function h_(e){if(n_[e.id])return n_[e.id];let{objectType:t,parentId:n}=e;if(t===W.BARYCENTER){if(e.id===`naif-0`)return n_[`naif-10`];if(e.id===`naif-9`)return n_[`naif-999`];let t=`naif-${e.id.replace(`naif-`,``)}99`;if(n_[t])return n_[t]}if(t===W.STAR)return o_;if(t===W.PLANET||t===W.DWARF_PLANET)return i_;if(t===W.MOON)return a_;if(_n(t))return s_;if(t===W.COMET)return c_;if(t===W.DEBRIS)return l_;if(t===W.SPACECRAFT){if(n===`naif-399`)return u_;if(n===`naif-0`||n===`naif-10`)return d_}return r_}var g_=`#6b6b6b`;function __(e){return e.color??g_}function v_(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t>>>0}function y_(e,t){let n=Array.from({length:t},()=>[]);for(let r of e)n[v_(r.data.id)%t].push(r);return n}function b_(e,t,n){return{buckets:y_(t,t.length>=n*600?n:1),baseWorker:v_(e)%n}}async function x_(e,t,n){let r=t.length>=n*600?n:1,i=Array.from({length:r},()=>[]),a=performance.now();for(let e=0;e<t.length;e++){(e&16383)==16383&&performance.now()-a>6&&(await Dg(),a=performance.now());let n=t[e];i[v_(n.data.id)%r].push(n)}return{buckets:i,baseWorker:v_(e)%n}}function S_(e){let t=e.indexOf(`#`);return t<0?e:e.substring(0,t)}var C_=4096,w_=.75;function T_(e){let t=(e^Math.floor(e/4294967296))>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var E_=class{table=new Uint32Array(C_);mask=C_-1;count=0;constructor(e){this.keyOfRef=e}get size(){return this.count}slot(e){let t=T_(e)&this.mask;for(;;){let n=this.table[t];if(n===0||this.keyOfRef(n-1)===e)return t;t=t+1&this.mask}}get(e){let t=this.table[this.slot(e)];return t===0?void 0:t-1}has(e){return this.table[this.slot(e)]!==0}set(e,t,n=()=>!0){let r=this.slot(e),i=this.table[r];return i===0?(this.count++,this.count>this.table.length*w_&&(this.grow(),r=this.slot(e)),this.table[r]=t+1,!0):(n(i-1)&&(this.table[r]=t+1),!1)}grow(){let e=this.table;this.table=new Uint32Array(e.length*2),this.mask=this.table.length-1;for(let t of e){if(t===0)continue;let e=T_(this.keyOfRef(t-1))&this.mask;for(;this.table[e]!==0;)e=e+1&this.mask;this.table[e]=t}}*values(){for(let e of this.table)e!==0&&(yield e-1)}*keys(){for(let e of this.values())yield this.keyOfRef(e)}},D_=2**20,O_=4096,k_=6;function A_(e){let t=e>>>0;return t=Math.imul(t^t>>>16,73244475),t=Math.imul(t^t>>>16,73244475),(t^t>>>16)>>>0}var j_=class{chunks=[];rowOf=new E_(e=>this.keyOfRef(e));cache=new Map;placeholders=new Map;parentIdType=`naif`;constructor(e){this.labels=e}async addChunk(e,t,n){if(this.parentIdType=t,e.rowCount>=D_)throw Error(`MinorBucket: chunk too large (${e.rowCount} rows)`);let r=this.chunks.length;this.chunks.push(e);let i=0,a=this.placeholders.size>0,o=performance.now();for(let t=0;t<e.rowCount;t++){t%O_===O_-1&&performance.now()-o>k_&&(await Dg(),o=performance.now());let s=Ch(e,t);if(!(s===fh||n&&!n.has(s))&&(this.rowOf.set(s,r*D_+t,e=>Math.floor(e/D_)<=r)&&i++,a)){let n=Sh(e,t),r=n===null?void 0:this.placeholders.get(n);if(r){let n=e_(e,t,this.labels,this.parentIdType);n&&Object.assign(r.data,n)}}}return i}addPlaceholder(e){this.placeholders.set(e.data.id,e),this.cache.set(e.data.id,e)}keyOfRef(e){let t=Math.floor(e/D_);return Ch(this.chunks[t],e-t*D_)}get size(){let e=0;for(let t of this.placeholders.keys())this.hasRow(t)||e++;return this.rowOf.size+e}hasRow(e){let t=vh(e);return t!==null&&this.rowOf.has(t)}has(e){return this.hasRow(e)||this.placeholders.has(e)}hasKey(e){if(this.rowOf.has(e))return!0;if(this.placeholders.size===0)return!1;let t=_h(e);return t!==null&&this.placeholders.has(t)}*ids(){for(let e of this.rowOf.keys()){let t=_h(e);t!==null&&(yield t)}for(let e of this.placeholders.keys())this.hasRow(e)||(yield e)}*keys(){yield*this.rowOf.keys();for(let e of this.placeholders.keys()){let t=vh(e);t!==null&&!this.rowOf.has(t)&&(yield t)}}get(e){let t=this.cache.get(e);if(t)return t;let n=vh(e),r=n===null?void 0:this.rowOf.get(n);if(r===void 0)return;let i=Math.floor(r/D_),a=e_(this.chunks[i],r-i*D_,this.labels,this.parentIdType);if(!a)return;let o={data:a,position:[0,0,0],positionUnknown:!0};return this.cache.set(e,o),o}getKey(e){let t=_h(e);return t===null?void 0:this.get(t)}*values(){for(let e of this.ids()){let t=this.get(e);t&&(yield t)}}cloudColor(){let e=this.chunks.find(e=>e.rowCount>0);if(!e)return`#888888`;let t=e_(e,0,this.labels,this.parentIdType);return t?h_(t):`#888888`}async buildWorkerGroups(e,t,n,r){let i=this.rowOf.size,a=i>=t*600?t:1,o=new Float64Array(i),s=new Uint8Array(i),c=Array(a).fill(0),l=0,u=performance.now();for(let e of this.rowOf.values()){if(l===i)break;l%16384==0&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=Math.floor(e/D_),n=a===1?0:A_(this.chunks[t].id[e-t*D_])%a;o[l]=e,s[l]=n,c[n]++,l++}let d=[];for(let e=0;e<a;e++){let t=Ug(c[e]);t.applyFlagFilter=!1,d.push({cols:t,colors:r?new Float32Array(c[e]*3):null,keys:new Float64Array(c[e]).fill(fh)})}let f=Array(a).fill(1/0),p=Array(a).fill(-1/0),m=Array(a).fill(0),h=r?new X:null;u=performance.now();for(let e=0;e<l;e++){(e&16383)==16383&&performance.now()-u>6&&(await Dg(),u=performance.now());let t=o[e],r=Math.floor(t/D_),i=t-r*D_,a=this.chunks[r],c=s[e],l=d[c],g=m[c]++,_=Ch(a,i);if(l.keys[g]=_,t_(a,i,l.cols,g,_,n)&&(a.validityStart<f[c]&&(f[c]=a.validityStart),a.validityEnd>p[c]&&(p[c]=a.validityEnd)),l.colors&&h){let e=e_(a,i,this.labels,this.parentIdType);h.set(e?h_(e):`#ffffff`),l.colors[g*3]=h.r,l.colors[g*3+1]=h.g,l.colors[g*3+2]=h.b}}for(let e=0;e<a;e++)d[e].cols.validityStart=f[e]===1/0?-1/0:f[e],d[e].cols.validityEnd=p[e]===-1/0?1/0:p[e];return{groups:d,baseWorker:v_(e)%t}}};function M_(e){return e===`naif-0`||e===`naif-10`}function N_(e){let t=/^naif-([1-9])$/.exec(e);return t?`naif-${t[1]}99`:null}function P_(e){return e===`naif-0`?f_:N_(e)}function F_(e){if(!M_(e))return N_(e)??e}var I_=class{bodiesById=new Map;majorBodies=[];asteroidBodiesByZone=new Map;spacecraftByParent=new Map;focusFeature=null;dirtyAsteroidZones=new Set;dirtySpacecraftGroups=new Set;minorStreaming=!1;#e=qe(0);get minorBodyVersion(){return Ut(this.#e)}set minorBodyVersion(e){Je(this.#e,e,!0)}#t=qe(0);get orientationVersion(){return Ut(this.#t)}set orientationVersion(e){Je(this.#t,e,!0)}orientationRead=new Set;hostRead=new Map;hostReadVersion=0;childrenByParent=new Map;moonMaxAByParent=new Map;addListeners=new Set;onBodiesAdded(e){return this.addListeners.add(e),()=>this.addListeners.delete(e)}notifyBodiesAdded(){for(let e of this.addListeners)e()}getBody(e,t){let n=this.bodiesById.get(e);if(n)return n;if(this.focusFeature?.data.id===e)return this.focusFeature;if(t!==void 0)return this.spacecraftByParent.get(t)?.get(e)??this.asteroidBodiesByZone.get(t)?.get(e);for(let t of this.spacecraftByParent.values()){let n=t.get(e);if(n)return n}for(let t of this.asteroidBodiesByZone.values()){let n=t.get(e);if(n)return n}}addBodies(e){let t=!1;for(let n of e){this.bodiesById.has(n.data.id)||(t=!0),this.bodiesById.set(n.data.id,n);let e=this.childrenByParent.get(n.data.parentId)??new Set;if(e.add(n.data.id),this.childrenByParent.set(n.data.parentId,e),n.data.objectType===W.MOON){let e=this.moonMaxAByParent.get(n.data.parentId)??0;n.data.a>e&&this.moonMaxAByParent.set(n.data.parentId,n.data.a)}}t&&this.notifyBodiesAdded()}asteroidBucket(e,t){let n=this.asteroidBodiesByZone.get(e);return n||this.asteroidBodiesByZone.set(e,n=new j_(t)),n}spacecraftBucket(e){let t=this.spacecraftByParent.get(e);return t||this.spacecraftByParent.set(e,t=new Map),t}flushMinor(e){this.asteroidBodiesByZone=new Map(this.asteroidBodiesByZone),this.spacecraftByParent=new Map(this.spacecraftByParent),this.minorBodyVersion++,e&&this.notifyBodiesAdded()}getChildren(e){return this.childrenByParent.get(e)}findAsteroidZone(e){for(let[t,n]of this.asteroidBodiesByZone)if(n.has(e))return t}elementRow(e){let t=e.data;if(t.orbitalSource!==U.SPICE)return t;let n=this.findAsteroidZone(t.id);return n===void 0?void 0:this.asteroidBodiesByZone.get(n)?.get(t.id)?.data}maxMoonA(e){return this.moonMaxAByParent.get(e)}getSystemExtent(e){return this.moonMaxAByParent.get(e)??.01}isSystemBody(e){return M_(e.data.parentId)?!1:this.bodiesById.get(e.data.parentId)?.data.objectType!==W.BARYCENTER}isInSystem(e,t){return t?e===t?!0:this.childrenByParent.get(t)?.has(e)??!1:!1}getObjectCounts(){let e=0,t=0,n=0;for(let r of this.bodiesById.values()){let i=r.data.objectType;i===W.PLANET||i===W.DWARF_PLANET?e++:i===W.MOON?t++:i===W.SPACECRAFT&&n++}let r=this.spacecraftByParent.get(`naif-399`)?.size??0;r+=this.asteroidBodiesByZone.get(`earth`)?.size??0;for(let[e,t]of this.spacecraftByParent)e!==`naif-399`&&(n+=t.size);let i=0;for(let[e,t]of this.asteroidBodiesByZone)e!==`earth`&&(i+=t.size);for(let e of this.bodiesById.values())(_n(e.data.objectType)||e.data.objectType===W.COMET)&&i++;return{planets:e,moons:t,probes:n,earthSatellites:r,smallBodies:i}}};function L_(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function R_(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(n*n+r*r+i*i)}function z_(e,t,n,r){let i=e[0]-n[0],a=e[1]-n[1],o=e[2]-n[2],s=t[0]-n[0],c=t[1]-n[1],l=t[2]-n[2],u=Math.sqrt(i*i+a*a+o*o),d=Math.sqrt(s*s+c*c+l*l);if(u<1e-9||d<1e-9)return L_(e,t,r);let f=i/u,p=a/u,m=o/u,h=s/d,g=c/d,_=l/d,v=Math.max(-1,Math.min(1,f*h+p*g+m*_)),y=Math.acos(v),b=u+(d-u)*r;if(y<1e-4||Math.PI-y<1e-4)return L_(e,t,r);let x=Math.sin(y),S=Math.sin((1-r)*y)/x,C=Math.sin(r*y)/x,w=S*f+C*h,T=S*p+C*g,E=S*m+C*_;return[n[0]+w*b,n[1]+T*b,n[2]+E*b]}var B_={metadata:.12,ephemeris:.55,majors:.8,labels:.92,done:1},V_=[`metadata`,`ephemeris`,`majors`,`labels`,`done`],H_=.9,U_=new class{#e=0;#t=B_.metadata;#n=0;#r=0;#i=!1;#a=qe(0);get value(){return Ut(this.#a)}set value(e){Je(this.#a,e,!0)}get active(){return this.#i}#o(){let e=this.#t-this.#e,t=this.#r>0?Math.min(this.#n/this.#r,1):0,n=this.#e+e*t*H_;n>this.value&&(this.value=n)}reset(){this.#e=0,this.#t=B_.metadata,this.#n=0,this.#r=0,this.#i=!0,this.value=0}reach(e){if(!this.#i)return;let t=B_[e];if(t<=this.#e)return;this.#e=t,this.value<t&&(this.value=t);let n=V_[V_.indexOf(e)+1];this.#t=n?B_[n]:t,this.#n=0,this.#r=0,e===`done`&&(this.value=1,this.#i=!1)}announce(e){!this.#i||e<=0||(this.#r+=e,this.#o())}addBytes(e){this.#i&&(this.#n+=e,this.#o())}},W_=3e4;function G_(e,t){if(t||!U_.active||!e.body)return e;let n=Number(e.headers.get(`content-length`));if(!Number.isFinite(n)||n<=0)return e;U_.announce(n);let r=new TransformStream({transform(e,t){U_.addBytes(e.byteLength),t.enqueue(e)}});return new Response(e.body.pipeThrough(r),{status:e.status,statusText:e.statusText,headers:e.headers})}async function K_(e,t={},n=W_){let r=new AbortController,i=setTimeout(()=>r.abort(),n),a=()=>r.abort();t.signal?.addEventListener(`abort`,a,{once:!0});try{return G_(await fetch(e,{...t,signal:r.signal}),t.priority===`low`)}catch(i){throw r.signal.aborted&&!t.signal?.aborted?Error(`Request timed out after ${n} ms: ${e}`,{cause:i}):i}finally{clearTimeout(i),t.signal?.removeEventListener(`abort`,a)}}var q_=new Map,J_=new Map,Y_=null;function X_(){if(Y_)return Y_;let e=(async()=>{let e=await K_(`${Kt()}/v1/systems/global.json`);if(!e.ok)return;let t=await e.json();if(t.gm)for(let[e,n]of Object.entries(t.gm))J_.set(parseInt(e,10),n);if(t.nut_prec_angles)for(let[e,n]of Object.entries(t.nut_prec_angles))q_.set(parseInt(e,10),n)})();return e.catch(()=>{Y_===e&&(Y_=null)}),Y_=e,e}function Z_(e){return e>=100?Math.trunc(e/100):e}function Q_(e){return q_.get(e)}function $_(e){return J_.get(e)}var ev=132712440018,tv=86400;function nv(e){if(!M_(e.parentId))return;let t=Number(e.id.replace(/^naif-/,``));if(!Number.isFinite(t))return;let n=$_(t>=1&&t<=9?t*100+99:t),r=e.a*ig;if(!(!n||!(n>0)||!(r>0)))return r*(1-(Number.isFinite(e.e)?Math.min(Math.max(e.e,0),.99):0))*Math.cbrt(n/(3*ev))/ig}var rv=`class-`,iv=`flag-`,av=`cat-`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var ov=`${av}asteroids`,sv=`${av}comets`,cv=`${av}satellites`,lv=`${av}debris`;`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`,`${av}`;var uv={neo:1,pha:2},dv=new Set([`ETc`,`JFc`,`JFC`,`CTc`,`HTC`,`PAR`,`HYP`,`COM`]);function fv(e){return dv.has(e)?`comet`:`asteroid`}function pv(e,t){return e===t?!0:e===null||t===null||e.kind!==t.kind?!1:e.kind===`class`&&t.kind===`class`?e.className===t.className:e.kind===`category`&&t.kind===`category`?e.category===t.category:e.kind===`flag`&&t.kind===`flag`?e.flag===t.flag:!1}var mv=null;function hv(){if(mv)return mv;let e=K_(`${Kt()}/v1/groups/__index__.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch group index: ${e.status}`);return e.json()});return mv=e,e.catch(()=>{mv===e&&(mv=null)}),mv}var gv=[`planets`,`dwarfPlanets`,`moons`,`asteroids`,`comets`,`spacecraft`,`satellites`,`debris`,`orbits`,`labels`,`halos`,`nomenclature`,`stars`],_v=new Set(gv),vv={[W.PLANET]:`planets`,[W.DWARF_PLANET]:`dwarfPlanets`,[W.MOON]:`moons`,[W.ASTEROID]:`asteroids`,[W.ASTEROID_INNER]:`asteroids`,[W.ASTEROID_MAIN_BELT]:`asteroids`,[W.ASTEROID_TROJAN]:`asteroids`,[W.ASTEROID_CENTAUR]:`asteroids`,[W.ASTEROID_TNO]:`asteroids`,[W.COMET]:`comets`,[W.DEBRIS]:`debris`},yv=`small_bodies/`,bv=new Set([`COM`,`PAR`,`HYP`,`HYA`,`JFC`,`JFc`,`HTC`,`CTc`]);function xv(e){return e===`moons`||e.startsWith(`moons/`)||e===`small_body_moons`?`moons`:e.startsWith(`probes/`)?`spacecraft`:e.startsWith(yv)?bv.has(e.slice(13))?`comets`:`asteroids`:null}function Sv(e,t){return e===W.SPACECRAFT?t===`naif-399`?`satellites`:`spacecraft`:vv[e]??null}var Cv=class{skipped;hiddenIds;onChange=null;constructor(e={}){let t=new Set;for(let n of gv)e[n]===!1&&t.add(n);this.skipped=t,this.hiddenIds=new Set(t)}isVisible(e){return!this.hiddenIds.has(e)}setVisible(e,t){t!==this.isVisible(e)&&(t?this.hiddenIds.delete(e):this.hiddenIds.add(e),this.onChange?.())}static has(e){return _v.has(e)}skipsZone(e){if(e===`earth`)return this.skipped.has(`satellites`)&&this.skipped.has(`debris`);let t=xv(e);return t!==null&&this.skipped.has(t)}hidesZone(e){let t=xv(e);return t!==null&&!this.isVisible(t)}hidesBody(e,t){let n=Sv(e,t);return n!==null&&!this.isVisible(n)}hidesSpacecraftGroup(e){return e===`naif-399`?!this.isVisible(`satellites`)&&!this.isVisible(`debris`):!this.isVisible(`spacecraft`)}};function wv(e,t,n){return t!==`naif-399`||e.isVisible(`satellites`)===e.isVisible(`debris`)?n:n.filter(t=>!e.hidesBody(t.data.objectType,t.data.parentId))}var Tv=`small_bodies/`;function Ev(e,t){let n=e.findAsteroidZone(t);if(n&&n.startsWith(`small_bodies/`))return n.slice(13);let r=e.bodiesById.get(t);if(r?.data.objectType!==W.DWARF_PLANET)return null;let i=r.data.a,a=r.data.e;if(!M_(r.data.parentId)){let t=e.bodiesById.get(r.data.parentId);t?.data.a&&(i=t.data.a,a=t.data.e)}return fn(i,a)}function Dv(e,t,n){if(n.kind===`class`||n.kind===`category`){let r=Ev(e,t);return r===null?!1:n.kind===`class`?r===n.className:fv(r)===n.category}let r=e.getBody(t);return r===void 0?!1:((r.data.flags??0)&n.mask)===n.mask}var $=function(e){return e[e.CLOSE=1]=`CLOSE`,e[e.FULL=2]=`FULL`,e[e.CAPPED=3]=`CAPPED`,e[e.FAR=4]=`FAR`,e[e.HIDE=5]=`HIDE`,e}({}),Ov=1503,kv={[$.CLOSE]:.3,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},Av={[$.CLOSE]:.01,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},jv=1/3;function Mv(e,t,n,r){return e<=t[$.CLOSE]?$.CLOSE:e<=t[$.FULL]*(r?n:1)?$.FULL:e<=t[$.FAR]?$.FAR:$.HIDE}var Nv=new Cv,Pv=3,Fv=4e6/ig;function Iv(e){return _n(e)||e===W.COMET||e===W.DWARF_PLANET}var Lv=class{#e=qe($e(f_));get focusedBodyId(){return Ut(this.#e)}set focusedBodyId(e){Je(this.#e,e,!0)}#t=qe(null);get focusedSystemId(){return Ut(this.#t)}set focusedSystemId(e){Je(this.#t,e,!0)}activeSystemId=null;isZoomedIn=!1;focusedBodyIdPlain=f_;focusedSystemIdPlain=null;travelSystemActive=!1;cameraDistThreeJS=0;lastRecomputeDist=-1;currentJd=0;hideThresholdAU=0;scaledPlanetary=kv;scaledSystem=Av;fullMoonIds=new Set;moonVisibilityCache=new Map;pinned=new Set;constructor(e,t=()=>null,n=()=>null,r=()=>null,i=()=>Nv){this.bodies=e,this.getProbeStore=t,this.getEarthSatGroupFilter=n,this.getSmallBodyFilter=r,this.getLayers=i}getRequiredFlags(){let e=this.getSmallBodyFilter();return e?.kind===`flag`?e.mask:0}updateViewport(e){let t=(e/Ov)**1.5,n=e=>({...e,[$.FULL]:e[$.FULL]*t,[$.FAR]:e[$.FAR]*t});this.scaledPlanetary=n(kv),this.scaledSystem=n(Av)}updateCamera(e,t){this.cameraDistThreeJS=e,this.currentJd=t,this.moonVisibilityCache.clear(),this.travelSystemActive||this.refreshProbeFocusedSystem(),this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=e/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?this.focusedSystemIdPlain:null,Math.abs(e-this.lastRecomputeDist)>this.lastRecomputeDist*.005+.001&&(this.lastRecomputeDist=e,this.recomputeFullMoons())}refreshProbeFocusedSystem(){let e=this.getProbeStore();if(!e)return;let t=this.bodies.bodiesById.get(this.focusedBodyIdPlain);if(!t||t.data.orbitalSource!==U.SPICE_PROBE)return;let n=e.containingSystemAt(t.data.id,this.currentJd),r=n===null?e.stampedFitCenterAt(t.data.id,this.currentJd):`naif-${n}`;r!==this.focusedSystemIdPlain&&(this.focusedSystemId=r,this.focusedSystemIdPlain=r,this.lastRecomputeDist=-1)}resolveSystemId(e){let t=e.data.objectType===W.BARYCENTER&&M_(e.data.parentId)&&!M_(e.data.id),n=e.data.objectType===W.STAR||!t&&M_(e.data.parentId);if(t)return e.data.id;if(n)return Iv(e.data.objectType)?e.data.id:null;let r=this.bodies.bodiesById.get(e.data.parentId);return r&&!M_(r.data.parentId)?r.data.parentId:e.data.parentId}setTravelSystem(e){this.travelSystemActive=!0,e!==this.focusedSystemIdPlain&&(this.focusedSystemId=e,this.focusedSystemIdPlain=e,this.lastRecomputeDist=-1)}clearTravelSystem(){this.travelSystemActive=!1}setFocused(e){if(this.travelSystemActive=!1,e.data.id===this.focusedBodyIdPlain)return;this.focusedBodyId=e.data.id,this.focusedBodyIdPlain=e.data.id;let t=this.resolveSystemId(e);this.focusedSystemId=t,this.focusedSystemIdPlain=t,this.hideThresholdAU=this.computeHideThreshold(),this.isZoomedIn=this.cameraDistThreeJS/10<this.hideThresholdAU,this.activeSystemId=this.isZoomedIn?t:null,this.lastRecomputeDist=-1,this.recomputeFullMoons()}getMoonVisibility(e){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;let t=this.moonVisibilityCache.get(e.data.id);if(t!==void 0)return t;let n,r=this.bodies.getBody(e.data.parentId),i=r!==void 0&&_n(r.data.objectType);if(!this.isInFocusedSystem(e.data.parentId))n=$.HIDE;else if(i&&!this.matchesSmallBodyClass(e.data.parentId))n=$.HIDE;else{let t=this.cameraDistThreeJS/10/e.data.a,r=e.data.id===this.focusedBodyIdPlain;n=Mv(t,this.scaledPlanetary,5,r),!i&&n===$.FULL&&!this.fullMoonIds.has(e.data.id)&&!r&&(n=$.CAPPED)}return this.moonVisibilityCache.set(e.data.id,n),n}setPinned(e){this.pinned=new Set(e)}isPinned(e){return this.pinned.has(e)}getPlanetVisibility(e,t){let n=this.pinned.has(e.data.id),r=this.ratioVisibility(e,t,n);return n&&r!==$.CLOSE?$.FULL:r}ratioVisibility(e,t,n){if(!n&&this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;if(e.data.orbitalSource===U.SPICE_PROBE)return this.getProbeVisibility(e);let r=this.getEarthSatGroupFilter();if(r&&e.data.parentId===`naif-399`&&!r.has(e.data.id))return $.HIDE;let i=e.data.objectType;if((_n(i)||i===W.COMET||i===W.DWARF_PLANET)&&!this.matchesSmallBodyClass(e.data.id))return $.HIDE;if(this.bodies.isSystemBody(e)){if(!this.isInFocusedSystem(e.data.parentId))return $.HIDE;let n=e.data.a;if(!n||n<=0)return $.FULL;let r=e.data.id===this.focusedBodyIdPlain;return Mv(t/10/n,this.scaledPlanetary,5,r)}let a=e.data.a;if(!M_(e.data.parentId)){let t=this.bodies.bodiesById.get(e.data.parentId);t?.data.a&&(a=t.data.a)}if(!a||a<0)return a===0&&e.data.e<.9&&console.warn(`No semi-major axis available for body ${e.data.id} (${e.data.name}), falling back to FULL visibility`),$.FULL;let o=e.data.id===this.focusedBodyIdPlain,s=Mv(t/10/a,this.scaledSystem,50,o);return s===$.CLOSE?$.FULL:s}getProbeVisibility(e){let t=this.getProbeStore();if((t?t.containingSystemAt(e.data.id,this.currentJd):null)===Pv&&this.getEarthSatGroupFilter())return $.HIDE;let n=e.data.id===this.focusedBodyIdPlain;if(!(t&&!t.hasHeliocentricFit(e.data.id,this.currentJd))){let t=this.bodies.bodiesById.get(f_),r=t?R_(e.position,t.position)/10:0;if(r===0)return $.FULL;let i=Mv(this.cameraDistThreeJS/10/r,this.scaledSystem,50,n);return i===$.CLOSE?$.FULL:i}if(!this.isProbeInFocusedSystem(e))return $.HIDE;let r=this.bodies.bodiesById.get(e.data.parentId);if(!r)return $.FULL;let i=R_(e.position,r.position)/10;return i===0||this.cameraDistThreeJS/10/i<=this.scaledPlanetary[$.FULL]*(n?5:1)?$.FULL:$.HIDE}isProbeInFocusedSystem(e){let t=e.data.parentId;if(!M_(t)&&this.isInFocusedSystem(t))return!0;let n=this.getProbeStore();if(!n)return!1;let r=n.containingSystemAt(e.data.id,this.currentJd);return r!==null&&this.isInFocusedSystem(`naif-${r}`)}hasFullRendering(e){if(!this.activeSystemId||this.pinned.has(e.data.id)||this.isInActiveSystem(M_(e.data.parentId)?e.data.id:e.data.parentId))return!0;if(e.data.orbitalSource!==U.SPICE_PROBE)return!1;let t=this.getProbeStore();if(!t)return!1;let n=t.containingSystemAt(e.data.id,this.currentJd);return n!==null&&this.isInActiveSystem(`naif-${n}`)}isMoonGroupVisible(e){if(!this.getLayers().isVisible(`moons`)||!this.isInFocusedSystem(e))return!1;let t=this.bodies.maxMoonA(e);return t?this.cameraDistThreeJS/10/t<=this.scaledPlanetary[$.FAR]:!1}isSpacecraftGroupVisible(e){if(this.getLayers().hidesSpacecraftGroup(e))return!1;let t=this.activeSystemId;return M_(e)||this.bodies.bodiesById.get(e)?.data.objectType===W.STAR?!t:t?e===t?!0:this.bodies.getChildren(t)?.has(e)??!1:!1}isAsteroidGroupVisible(e){if(this.getLayers().hidesZone(e)||this.activeSystemId)return!1;let t=this.getSmallBodyFilter();if(t&&e.startsWith(`small_bodies/`)){let n=e.slice(Tv.length);if(t.kind===`class`&&n!==t.className||t.kind===`category`&&fv(n)!==t.category)return!1}let n=dn[e];return n?this.cameraDistThreeJS/10/n.maxA<=this.scaledSystem[$.FAR]/3:!0}isInActiveSystem(e){return this.bodies.isInSystem(e,this.activeSystemId)}debugBody(e){let t=this.bodies.getBody(e);if(!t)return{id:e,found:!1};let n=t.data.objectType,r=n===W.MOON,i=this.getProbeStore(),a=r?this.getMoonVisibility(t):this.getPlanetVisibility(t,this.cameraDistThreeJS);return{id:e,name:t.data.name,objectType:W[n],orbitalSource:t.data.orbitalSource,parentId:t.data.parentId,a:t.data.a,jd:this.currentJd,isMoon:r,isSystemBody:this.bodies.isSystemBody(t),isInFocusedSystem_parent:this.isInFocusedSystem(t.data.parentId),focusedBodyId:this.focusedBodyIdPlain,focusedSystemId:this.focusedSystemIdPlain,activeSystemId:this.activeSystemId,isZoomedIn:this.isZoomedIn,hideThresholdAU:this.hideThresholdAU,containingSystemAt:i?i.containingSystemAt(t.data.id,this.currentJd):null,camDistAU:this.cameraDistThreeJS/10,visibility:$[a],hasFullRendering:this.hasFullRendering(t)}}isBodyInSystem(e,t){return e.data.id===t||this.bodies.isInSystem(e.data.parentId,t)}isInFocusedSystem(e){return this.bodies.isInSystem(e,this.focusedSystemIdPlain)}matchesSmallBodyClass(e){let t=this.getSmallBodyFilter();return t===null?!0:Dv(this.bodies,e,t)}recomputeFullMoons(){this.fullMoonIds.clear();let e=this.focusedSystemIdPlain;if(!e)return;let t=this.cameraDistThreeJS/10,n=[];for(let r of this.bodies.getChildren(e)??[]){let e=this.bodies.bodiesById.get(r);e&&e.data.objectType===W.MOON&&t/e.data.a<=this.scaledPlanetary[$.FULL]&&n.push(e)}n.sort((e,t)=>e.data.a-t.data.a).slice(0,40).forEach(e=>this.fullMoonIds.add(e.data.id))}computeHideThreshold(){let e=this.focusedSystemIdPlain;return e?this.systemReachAU(e):1/0}systemReachAU(e){let t=this.bodies.maxMoonA(e);if(t)return 2*t;let n=this.bodies.getBody(e);if(!n)return 0;if(Iv(n.data.objectType))return Fv;let r=nv(n.data);return r?r*jv:0}},Rv=``;function zv(e){let t=new Map;if(!e)return t;for(let n of e.split(`
|
|
4051
4051
|
`)){let e=n.indexOf(Rv);if(e===-1)continue;let r=n.slice(0,e),i=n.slice(e+1),a=i.indexOf(Rv),o=a===-1?i:i.slice(0,a),s=a===-1?``:i.slice(a+1);t.set(r,{name:o,isMinor:s.includes(`m`)})}return t}var Bv=new Map;async function Vv(e=c()){let t=Bv.get(e);return t||(t=(async()=>{let t=Qt(e),n=await K_(t,{priority:`high`});if(!n.ok)throw Error(`Failed to fetch ${t}: ${n.status}`);let r=new DecompressionStream(`gzip`);return zv(await new Response(n.body.pipeThrough(r)).text())})(),Bv.set(e,t),t.catch(()=>{Bv.get(e)===t&&Bv.delete(e)})),t}var Hv=Math.PI/180,Uv=Math.cos(ag*Hv),Wv=Math.sin(ag*Hv);function Gv(e,t,n,r,i,a=!1){let o=Math.cos(n*Hv),s=Math.sin(n*Hv),c=Math.cos(r*Hv),l=Math.sin(r*Hv),u=Math.cos(i*Hv),d=Math.sin(i*Hv),f=(u*o-d*s*c)*e+(-u*s-d*o*c)*t,p=(d*o+u*s*c)*e+(-d*s+u*o*c)*t,m=s*l*e+o*l*t;if(a){let e=p*Uv+m*Wv,t=-p*Wv+m*Uv;p=e,m=t}return[f*10,m*10,-p*10]}function Kv(e,t){let{omDot:n,wDot:r,om:i,w:a,epoch:o}=e;if(!n&&!r)return e;let s=t-o;return{...e,om:n?i+n*s:i,w:r?a+r*s:a}}function qv(e,t=new Date){return Jv(e,Ng(t))}function Jv(e,t){let{a:n,e:r,i,ma:a,n:o,epoch:s}=e;if(!isFinite(n)||!isFinite(r)||!isFinite(a)||!isFinite(o))return console.warn(`NaN in orbital elements: a=${n} e=${r} ma=${a} n=${o}`),null;let c=(a+o*(t-s))*Hv,{om:l,w:u}=Kv(e,t),d,f;if(r<1||n>0){let e=Math.min(r,.9999999),t=xg(c,e),i=Math.sqrt(1-e*e)*Math.sin(t)/(1-e*Math.cos(t)),a=(Math.cos(t)-e)/(1-e*Math.cos(t));d=Math.atan2(i,a),f=n*(1-e*Math.cos(t))}else{let e=Cg(c,r);if(!isFinite(e))return console.warn(`solveKeplerHyperbolic overflow: M=${c} e=${r}`),null;let t=r*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return console.warn(`Hyperbolic denom near zero: H=${e} e=${r} denom=${t}`),null;let i=Math.sqrt(r*r-1)*Math.sinh(e)/t,a=(r-Math.cosh(e))/t;d=Math.atan2(i,a),f=n*(1-r*Math.cosh(e))}let p=f*Math.cos(d),m=f*Math.sin(d);return!isFinite(p)||!isFinite(m)?(console.warn(`Non-finite orbital position: r=${f} nu=${d} xOrb=${p} yOrb=${m} a=${n} e=${r}`),null):Gv(p,m,u,i,l,e.equatorial)}function Yv(e,t=new Date){return Xv(e,Ng(t))}function Xv(e,t){let{q:n,tp:r,i,om:a,w:o}=e;if(n==null||r==null||!isFinite(n)||!isFinite(r))return null;let s=wg(n,r,t);if(!s)return null;let c=s.r*Math.cos(s.nu),l=s.r*Math.sin(s.nu);return!isFinite(c)||!isFinite(l)?null:Gv(c,l,o,i,a,e.equatorial)}var Zv=class{map=new Map;constructor(e){this.capacity=e}getOrCompute(e,t){let n=this.map.get(e);if(n)return this.map.delete(e),this.map.set(e,n),n;let r=t();if(this.map.set(e,r),this.map.size>this.capacity){let e=this.map.keys().next().value;e!==void 0&&this.map.delete(e)}return r.catch(()=>{this.map.get(e)===r&&this.map.delete(e)}),r}};function Qv(e,t,n){let r=new DataView(e),i=r.getUint32(24,!0),a=(r.getUint8(28)&1)!=0,o=a?8:4,s=[],c=Zt;for(let t=0;t<i;t++){let n=r.getInt32(c,!0),i=r.getInt32(c+4,!0),l=r.getInt32(c+8,!0),u=r.getFloat32(c+12,!0),d=r.getUint16(c+16,!0),f=r.getUint8(c+18),p=r.getUint8(c+19)===1,m=r.getUint8(c+20),h=r.getUint16(c+22,!0),g=r.getFloat32(c+24,!0);c+=32;let _=ln(f,l)??``;_||console.warn(`chebyshev body[${t}] (naifId=${n}) has unknown id-type ${f}; routing keyed lookups will skip it`);let v=new Float64Array(h),y=new Float64Array(h),b=3*d,x=a?new Float64Array(b*h):new Float32Array(b*h),S=b*o;for(let t=0;t<h;t++){if(v[t]=r.getFloat64(c,!0),y[t]=r.getFloat64(c+8,!0),c+=16,a){let n=new Float64Array(e,c,b);x.set(n,t*b)}else{let n=new Float32Array(e,c,b);x.set(n,t*b)}c+=S}s.push({id:_,naifId:n,parentId:i,hasLocalized:p,objectType:m,radiusKm:u,visibleFromDays:g,coeffsPerAxis:d,startJds:v,endJds:y,coeffs:x})}return{startJd:t,endJd:n,bodies:s}}function $v(e,t,n,r){let i=n*(r?8:4),a=new(r?Float64Array:Float32Array)(n);if(r&&t%8==0)return a.set(new Float64Array(e,t,n)),a;if(!r&&t%4==0)return a.set(new Float32Array(e,t,n)),a;let o=new DataView(e,t,i);if(r)for(let e=0;e<n;e++)a[e]=o.getFloat64(e*8,!0);else for(let e=0;e<n;e++)a[e]=o.getFloat32(e*4,!0);return a}function ey(e,t,n,r){let i=$v(e,t,n===1?7:10,r);return n===1?{method:n,aKm:i[0],e:i[1],iRad:i[2],om0:i[3],w0:i[4],m0:i[5],tAnchorOffsetS:i[6]}:{method:n,aKm:i[0],e:i[1],iRad:i[2],om0:i[3],w0:i[4],m0:i[5],omDot:i[6],wDot:i[7],nMeanRadS:i[8],tAnchorOffsetS:i[9]}}var ty=1e-7,ny=.001,ry=1,iy=2,ay=16,oy=32;function sy(e,t,n){let r=new DataView(e,t,oy),i=r.getInt32(0,!0),a=r.getUint8(4),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=r.getInt32(16,!0)*ty,l=r.getInt32(20,!0)*ty,u=r.getInt32(24,!0)*ny,d=r.getUint32(28,!0),f=new Float64Array(d),p=new Float32Array(d),m=new Float32Array(d),h=new Float32Array(d);if(d>0){let r=new DataView(e,t+oy,d*ay);for(let e=0;e<d;e++){let t=e*ay;f[e]=n+r.getUint32(t,!0),p[e]=r.getInt32(t+4,!0)*ty,m[e]=r.getInt32(t+8,!0)*ty,h[e]=r.getInt32(t+12,!0)*ny}}return{bodyNaifId:i,isStatic:(a&ry)!==0,isDestroyed:(a&iy)!==0,startEt:n+o,endEt:n+s,latRefDeg:c,lngRefDeg:l,altRefM:u,sampleEt:f,sampleLatDeg:p,sampleLngDeg:m,sampleAltM:h}}function cy(e,t,n,r){let i=n/(36*(r?8:4));return{method:3,coeffsPerAxis:12,nSeg:i,coeffs:$v(e,t,i*3*12,r)}}function ly(e,t,n,r){let i=new DataView(e),a=i.getUint32(24,!0),o=i.getFloat32(28,!0),s=o*kg,c=Fg(t),l=[],u=Zt;for(let t=0;t<a;t++){let n=i.getInt32(u,!0),a=i.getUint8(u+4),o=i.getUint8(u+5),d=i.getUint8(u+6)===1,f=(i.getUint8(u+7)&1)!=0,p=i.getUint16(u+8,!0),m=i.getUint16(u+10,!0),h=i.getInt32(u+12,!0),g=i.getUint8(u+16),_=i.getUint8(u+17);u+=20;let v=ln(a,n)??``;v||console.warn(`probes payload: probe[${t}] (value=${n}) has unknown id-type ${a}; skipping`);let y=null;if(h!==-1&&g!==255){let e=ln(g,h);e?y={id:e,idType:g,idValue:h}:console.warn(`probes payload: probe[${t}] has unknown fit-center id-type ${g}; falling back to zone default`)}let b=Array(p),x=Array(p),S=Array(p);for(let n=0;n<p;n++){let a=i.getUint8(u),o=i.getUint32(u+4,!0),l=u+8,d=c+(m+n)*s;if(b[n]=d,x[n]=d+s,a===0)S[n]={method:0};else if(a===1||a===2)S[n]=ey(e,l,a,r);else if(a===3)S[n]=cy(e,l,o,r);else throw Error(`Unknown probe sub-chunk method ${a} at probe ${t} sub ${n}`);u=l+o}let C;if(f){let n=i.getUint8(u);if(n!==4)throw Error(`probe ${t}: PROBE_FLAG_HAS_LANDED_RECORD set but trailing record method = ${n}, expected 4`);let r=i.getUint32(u+4,!0),a=u+8;C=sy(e,a,c),u=a+r}let w=Array(_);for(let e=0;e<_;e++)w[e]={startEt:i.getFloat64(u,!0),endEt:i.getFloat64(u+8,!0),systemNaifId:i.getUint8(u+16)},u+=17;l.push({id:v,probeId:n,hasLocalized:d,objectType:o,fitCenter:y,subStartEt:b,subEndEt:x,subChunks:S,landed:C,systemIntervals:w})}return{startJd:t,endJd:n,subchunkDays:o,probes:l}}function uy(e,t={}){let n=new DataView(e),r=n.getUint32(0,!0);if(r!==1346456915)throw Error(`Invalid position file: bad magic 0x${r.toString(16)}`);let i=n.getUint16(4,!0);if(i!==13)throw Error(`Unsupported position file version: ${i}`);let a=n.getUint8(6),o=n.getFloat64(8,!0),s=n.getFloat64(16,!0);if(a===0)return{kind:`elements`,columns:Eh(e,o,s)};if(a===1)return{kind:`chebyshev`,chunk:Qv(e,o,s)};if(a===2)return{kind:`probes`,chunk:ly(e,o,s,t.probesFloat64??!1)};throw Error(`Unknown position-file format: ${a}`)}function dy(e,t,n){let r=e.length;if(r===0||n<e[0]||n>=t[r-1])return-1;let i=0,a=r-1;for(;i<a;){let t=i+a+1>>>1;e[t]<=n?i=t:a=t-1}return n<t[i]?i:-1}function fy(e,t){let n=dy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=e.coeffsPerAxis,s=e.coeffs,c=n*3*o,l=[0,0,0],u=2*a;for(let e=0;e<3;e++){let t=c+e*o;if(o===1){l[e]=s[t];continue}let n=0,r=0;for(let e=o-1;e>=1;e--){let i=s[t+e]+u*n-r;r=n,n=i}l[e]=s[t]+a*n-r}return l}function py(e,t){let n=fy(e,t);return n===null?null:[Q(n[0]),Q(n[2]),-Q(n[1])]}function my(e,t){let n=dy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=2/(i-r),s=e.coeffsPerAxis,c=e.coeffs,l=n*3*s,u=[0,0,0],d=[0,0,0],f=2*a;for(let e=0;e<3;e++){let t=l+e*s;if(s===1){u[e]=c[t],d[e]=0;continue}let n=0,r=0;for(let e=s-1;e>=1;e--){let i=c[t+e]+f*n-r;r=n,n=i}u[e]=c[t]+a*n-r;let i=0,p=0;for(let e=s-2;e>=0;e--){let n=c[t+e+1]*(e+1)+f*i-p;p=i,i=n}d[e]=i*o}return{position:u,velocity:d}}function hy(e,t){let n=e.subStartEt,r=e.subEndEt,i=n.length;if(i===0||t<n[0]||t>=r[i-1])return-1;let a=0,o=i-1;for(;a<o;){let e=a+o+1>>>1;n[e]<=t?a=e:o=e-1}return t<r[a]?a:-1}function gy(e,t,n,r,i){let a=Math.cos(i),o=Math.sin(i),s=Math.cos(r),c=Math.sin(r),l=Math.cos(n),u=Math.sin(n);return[(l*a-u*o*s)*e+(-l*o-u*a*s)*t,(u*a+l*o*s)*e+(-u*o+l*a*s)*t,o*c*e+a*c*t]}function _y(e,t,n,r,i,a){if(t>=1)return null;let o=xg(a,t),s=Math.sin(o),c=Math.cos(o),l=Math.sqrt(1-t*t)*s/(1-t*c),u=(c-t)/(1-t*c),d=e*(1-t*c),f=d*u,p=d*l;return!isFinite(f)||!isFinite(p)?null:gy(f,p,r,n,i)}function vy(e,t,n,r){let i=n-(t+e.tAnchorOffsetS),a=Math.sqrt(r/(e.aKm*e.aKm*e.aKm)),o=e.m0+a*i;return _y(e.aKm,e.e,e.iRad,e.om0,e.w0,o)}function yy(e,t,n){let r=n-(t+e.tAnchorOffsetS),i=e.om0+e.omDot*r,a=e.w0+e.wDot*r,o=e.m0+e.nMeanRadS*r;return _y(e.aKm,e.e,e.iRad,i,a,o)}function by(e,t,n,r){let{coeffs:i,coeffsPerAxis:a,nSeg:o}=e,s=(n-t)/o,c=Math.floor((r-t)/s);c<0?c=0:c>=o&&(c=o-1);let l=2*(r-(t+c*s))/s-1,u=2*l,d=c*3*a,f=[0,0,0];for(let e=0;e<3;e++){let t=d+e*a;if(a===1){f[e]=i[t];continue}let n=0,r=0;for(let e=a-1;e>=1;e--){let a=i[t+e]+u*n-r;r=n,n=a}f[e]=i[t]+l*n-r}return!isFinite(f[0])||!isFinite(f[1])||!isFinite(f[2])?null:f}function xy(e,t,n,r,i){switch(e.method){case 0:return null;case 1:return vy(e,t,r,i);case 2:return yy(e,t,r);case 3:return by(e,t,n,r)}}function Sy(e,t,n){let r=Fg(t),i=hy(e,r);return i<0?null:xy(e.subChunks[i],e.subStartEt[i],e.subEndEt[i],r,n)}function Cy(e,t,n){let r=Sy(e,t,n);return r===null?null:[Q(r[0]),Q(r[2]),-Q(r[1])]}function wy(e){if(!e.landed)return!1;let t=e.subEndEt.length;return t===0||e.subEndEt[t-1]<=e.landed.endEt}function Ty(e,t){if(!e.landed)return!1;let n=Fg(t);return n>=e.landed.startEt&&(n<e.landed.endEt||wy(e))}function Ey(e,t,n=!1){let r=Fg(t);if(r<e.startEt||!n&&r>=e.endEt)return null;let i=e.sampleEt.length;if(i===0||r<e.sampleEt[0])return{latDeg:e.latRefDeg,lngDeg:e.lngRefDeg,altM:e.altRefM};let a=0,o=i-1;for(;a<o;){let t=a+o+1>>>1;e.sampleEt[t]<=r?a=t:o=t-1}return{latDeg:e.sampleLatDeg[a],lngDeg:e.sampleLngDeg[a],altM:e.sampleAltM[a]}}var Dy=30/kg;function Oy(e,t,n){let r=Sy(e,t,n);if(r===null)return null;let i=Dy,a=Sy(e,t+i,n),o=Sy(e,t-i,n),s,c,l;if(a!==null&&o!==null)s=a,c=o,l=1/(2*i);else if(a!==null)s=a,c=r,l=1/i;else if(o!==null)s=r,c=o,l=1/i;else return null;return{position:r,velocity:[(s[0]-c[0])*l,(s[1]-c[1])*l,(s[2]-c[2])*l]}}Math.PI/180;var ky=180/Math.PI;ig/86400;var Ay=1e-9,jy=1e-9;function My(e,t,n){return e<t?t:e>n?n:e}function Ny(e,t,n,r){let[i,a,o]=e,[s,c,l]=t,u=Math.hypot(i,a,o),d=s*s+c*c+l*l;if(u===0||n<=0||!isFinite(u)||!isFinite(d))return null;let f=a*l-o*c,p=o*s-i*l,m=i*c-a*s,h=Math.hypot(f,p,m);if(h===0)return null;let g=Math.acos(My(m/h,-1,1)),_=Math.sin(g),v=(c*m-l*p)/n-i/u,y=(l*f-s*m)/n-a/u,b=(s*p-c*f)/n-o/u,x=Math.hypot(v,y,b),S=2/u-d/n;if(Math.abs(S)<1e-12)return null;let C=1/S,w=-p,T=f,E=Math.hypot(w,T),D;_<jy||E===0?D=0:(D=Math.acos(My(w/E,-1,1)),T<0&&(D=2*Math.PI-D));let O;if(x<Ay)O=0;else if(_<jy||E===0)O=Math.atan2(y,v),m<0&&(O=-O),O<0&&(O+=2*Math.PI);else{let e=(w*v+T*y)/(E*x);O=Math.acos(My(e,-1,1)),b<0&&(O=2*Math.PI-O)}let k,A=i*s+a*c+o*l;if(x<Ay&&(_<jy||E===0))k=Math.atan2(a,i),m<0&&(k=-k),k<0&&(k+=2*Math.PI);else if(x<Ay){let e=(w*i+T*a)/(E*u);k=Math.acos(My(e,-1,1)),o<0&&(k=2*Math.PI-k)}else{let e=(v*i+y*a+b*o)/(x*u);k=Math.acos(My(e,-1,1)),A<0&&(k=2*Math.PI-k)}let j;if(x<1){let e=2*Math.atan2(Math.sqrt(1-x)*Math.sin(k/2),Math.sqrt(1+x)*Math.cos(k/2));j=e-x*Math.sin(e)}else if(x>1){let e=2*Math.atanh(Math.sqrt((x-1)/(x+1))*Math.tan(k/2));if(!isFinite(e))return null;j=x*Math.sinh(e)-e}else return null;let M=Math.abs(C),ee=Math.sqrt(n/(M*M*M))*ky;return{a:C,e:x,i:g*ky,om:D*ky,w:O*ky,ma:j*ky,n:ee,epoch:r,equatorial:!1}}var Py=180/Math.PI;function Fy(e,t,n){if(n<=0)return null;let r=Math.sqrt(n/(e.aKm*e.aKm*e.aKm)),i=Ig(t+e.tAnchorOffsetS);return{a:e.aKm/ig,e:e.e,i:e.iRad*Py,om:e.om0*Py,w:e.w0*Py,ma:e.m0*Py,n:r*Py*kg,epoch:i,equatorial:!1}}function Iy(e,t){let n=Ig(t+e.tAnchorOffsetS);return{a:e.aKm/ig,e:e.e,i:e.iRad*Py,om:e.om0*Py,w:e.w0*Py,ma:e.m0*Py,n:e.nMeanRadS*Py*kg,omDot:e.omDot*Py*kg,wDot:e.wDot*Py*kg,epoch:n,equatorial:!1}}function Ly(e,t,n){if(n<=0)return null;let r=Oy(e,t,n);if(!r)return null;let i=n*og;return Ny([r.position[0]/ig,r.position[1]/ig,r.position[2]/ig],[r.velocity[0]*sg,r.velocity[1]*sg,r.velocity[2]*sg],i,t)}function Ry(e,t,n){let r=hy(e,Fg(t));if(r<0)return null;let i=e.subChunks[r];switch(i.method){case 0:return null;case 1:return Fy(i,e.subStartEt[r],n);case 2:return Iy(i,e.subStartEt[r]);case 3:return Ly(e,t,n)}}function zy(e,t,n,r){let i=e.fitCenter;if(!i||i.id===n||!r)return null;let a=r.body(i.id,t),o=r.body(n,t);if(!a||!o)return null;if(a.parentId!==o.parentId)return console.warn(`fit-center override: ${i.id} (parent ${a.parentId}) and zone center ${n} (parent ${o.parentId}) don't share a chebyshev parent; treating the record as unplaceable`),null;let s=my(a,t),c=my(o,t);return!s||!c?null:{id:i.id,naifId:a.naifId,positionKm:[s.position[0]-c.position[0],s.position[1]-c.position[1],s.position[2]-c.position[2]],velocityKmDay:[s.velocity[0]-c.velocity[0],s.velocity[1]-c.velocity[1],s.velocity[2]-c.velocity[2]]}}function By(e){let t=e-18e6;if(t>=2e6&&t<=2999999){let e=$_(t);if(e!==void 0)return{naifId:t,muKm3S2:e}}return{naifId:e,muKm3S2:$_(e)??0}}function Vy(e,t,n,r,i){let a=`naif-${n}`,o=e.fitCenter;if(o&&o.id!==a){let n=zy(e,t,a,r);return n?{id:n.id,naifId:n.naifId,muKm3S2:$_(n.naifId)??0}:i?.(o.id)?o.idType===an.SPKID?{id:o.id,...By(o.idValue)}:{id:o.id,naifId:o.idValue,muKm3S2:$_(o.idValue)??0}:null}return{id:a,naifId:n,muKm3S2:$_(n)??0}}var Hy=1/256,Uy=class{capacity;stepDays;epsilonScene;spanDays;needsPopulate=!1;positions;jds;head=0;_count=0;constructor(e,t,n=1/0,r){this.capacity=e,this.stepDays=t,this.epsilonScene=n,this.spanDays=r??t*e,this.positions=new Float32Array(e*3),this.jds=new Float64Array(e)}get count(){return this._count}reconfigure(e,t,n){Number.isFinite(e)&&e>0&&(this.stepDays=e),this.epsilonScene=t,this.spanDays=n??this.stepDays*this.capacity}get newestJd(){if(this._count===0)return NaN;let e=(this.head-1+this.capacity)%this.capacity;return this.jds[e]}readNewestPos(e){if(this._count===0)return!1;let t=(this.head-1+this.capacity)%this.capacity*3;return e[0]=this.positions[t],e[1]=this.positions[t+1],e[2]=this.positions[t+2],!0}append(e,t,n,r){let i=this.head;this.jds[i]=e,this.positions[i*3]=t,this.positions[i*3+1]=n,this.positions[i*3+2]=r,this.head=(i+1)%this.capacity,this._count<this.capacity&&this._count++}clear(){this.head=0,this._count=0}writeVertices(e,t,n,r,i){let a=Math.min(this._count,e.length/3|0),o=i?new Float64Array(3):null;for(let s=0;s<a;s++){let a=(this.head-1-s+this.capacity)%this.capacity,c=a*3,l=s*3;if(i&&o){o[0]=this.positions[c],o[1]=this.positions[c+1],o[2]=this.positions[c+2],i(this.jds[a],o),e[l]=o[0]+t,e[l+1]=o[1]+n,e[l+2]=o[2]+r;continue}e[l]=this.positions[c]+t,e[l+1]=this.positions[c+1]+n,e[l+2]=this.positions[c+2]+r}return a}},Wy=200;function Gy(e,t,n,r=!1){if(r)return{stepDays:Wy/n,epsilonScene:1/0,spanDays:Wy};let i=e!==null&&e.n>0,a=i?360/e.n:t,o=a>0?a/n:1,s=e?e.a*(1-e.e):0,c=s>0?s*10*1e-4:1/0;return{stepDays:o,epsilonScene:c,spanDays:!i&&isFinite(c)?1/0:o*n}}function Ky(e){let t=Number(e.slice(5));return e=>e===t}function qy(e,t,n,r){let i=Ky(r);return a=>{let o=e.probeWithCenter(n,a,i);if(!o)return null;let s=Vy(o.probe,a,o.fitCenterNaifId,t,e=>e===r);return!s||s.id!==r?null:Cy(o.probe,a,s.muKm3S2)}}function Jy(e,t,n,r,i){let a=e((t+r)/2);if(!a)return null;let o=a[0]-(n[0]+i[0])/2,s=a[1]-(n[1]+i[1])/2,c=a[2]-(n[2]+i[2])/2;return Math.sqrt(o*o+s*s+c*c)}var Yy=.005;function Xy(e,t,n,r,i,a,o){let s=(e,t)=>{if(e===null)return!1;let i=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]);return e<=Math.max(r,Yy*i)},c=t+o*a,l=e(c);if(l!==null&&s(Jy(e,t,n,c,l),l))return{jd:c,pos:l};let u=i,d=a,f=null,p=i*.25;for(let r=0;r<16;r++){let r=(u+d)/2,i=t+o*r,a=e(i);if(a===null){d=r;continue}if(s(Jy(e,t,n,i,a),a)?(u=r,f={jd:i,pos:a}):d=r,d-u<p)break}if(f)return f;let m=t+o*i,h=e(m);return h?{jd:m,pos:h}:null}function Zy(e,t,n,r,i,a){Qy(e,qy(t,n,r,i),a)}function Qy(e,t,n){let r=t(n);if(!r)return;let i=[{jd:n,pos:r}];if(isFinite(e.epsilonScene)){let r=e.stepDays*16,a=e.stepDays*Hy,o=n-e.spanDays;for(;i.length<e.capacity;){let n=i[i.length-1];if(n.jd<=o)break;let s=Xy(t,n.jd,n.pos,e.epsilonScene,a,r,-1);if(!s)break;if(s.jd<o){let e=t(o);e&&i.push({jd:o,pos:e});break}i.push(s)}}else for(let r=1;r<e.capacity;r++){let a=n-r*e.stepDays,o=t(a);o&&i.push({jd:a,pos:o})}for(let t=i.length-1;t>=0;t--){let n=i[t];e.append(n.jd,n.pos[0],n.pos[1],n.pos[2])}}function $y(e,t,n,r,i){if(!isFinite(e.epsilonScene))return;let a=e.stepDays*16,o=e.stepDays*Hy,s=n,c=r;for(let n=0;n<e.capacity&&!(i-s<=o);n++){let n=Math.min(a,i-s),r=Xy(t,s,c,e.epsilonScene,o,n,1);if(!r||r.jd<=s)break;e.append(r.jd,r.pos[0],r.pos[1],r.pos[2]),s=r.jd,c=r.pos}}function eb(e,t,n,r,i,a){if(t.length===0)return[];let o=e.trailAnchor??e.position,s=[o[0]-r,o[1]-i,o[2]-a],c=0,l=1/0;for(let e=0;e<t.length;e++){let n=(t[e][0]-s[0])**2+(t[e][1]-s[1])**2+(t[e][2]-s[2])**2;n<l&&(l=n,c=e)}let u=Math.max(c-1,0),d=Math.min(c+1,t.length-1),f=(t[u][0]-s[0])**2+(t[u][1]-s[1])**2+(t[u][2]-s[2])**2<(t[d][0]-s[0])**2+(t[d][1]-s[1])**2+(t[d][2]-s[2])**2?u:c,p=[s];if(n)for(let e=0;e<511;e++){let n=Math.max(f-e,0);if(p.push(t[n]),n===0)break}else{for(let e=0;e<511;e++)p.push(t[((f-e)%512+512)%512]);p.push(s)}return p.filter(e=>e.every(Number.isFinite))}function tb(e,t,n,r){let i=.55,a=n?0:i/3,o=e.length-1;for(let t=0;t<e.length;t++)e[t]=i-(o>0?t/o:0)*(i-a);if(r){let e=.35;t.fill(0);for(let n=0;n<Math.min(171,t.length);n++)t[n]=e-n/170*e}else t.set(e)}var nb=new Map,rb=0,ib=10;function ab(e,t,n,r){let i=$_(t);if(!i)return null;let a=my(e,n);if(!a)return null;let o=r?my(r,n):null;if(r&&!o)return null;let s=i*og;return Ny([(a.position[0]-(o?.position[0]??0))/ig,(a.position[1]-(o?.position[1]??0))/ig,(a.position[2]-(o?.position[2]??0))/ig],[(a.velocity[0]-(o?.velocity[0]??0))*sg,(a.velocity[1]-(o?.velocity[1]??0))*sg,(a.velocity[2]-(o?.velocity[2]??0))*sg],s,n)}function ob(e,t,n){return!n||e.parentId!==rb||e.naifId===ib?null:ab(e,ib,t,n)}function sb(e,t,n,r){return r?tn(e,t,r,n):en(e,t,n)}var cb=new Zv(8);async function lb(e,t,n,r,i){let a=`${e}:${t??``}:${n}:${r??``}`;return cb.getOrCompute(a,async()=>{let a=await K_(sb(e,t,n,r),{priority:i});if(!a.ok)throw Error(`Failed to fetch elements: ${a.status}`);let o=new DecompressionStream(`gzip`),s=uy(await new Response(a.body.pipeThrough(o)).arrayBuffer());if(s.kind!==`elements`)throw Error(`Expected elements payload at ${e}/${t}/${n}, got ${s.kind}`);return s.columns})}var ub=class{static prefetch(e,t,n,r=null){fetch(sb(e,t,n,r))}positions=new Map;barycenters=new Map;neededParentKeys=new Set;probeBuffers=new Map;constructor(e){this.cheb=e,this.positions.set(`naif-0`,[0,0,0])}processChebyshev(e,t){if(!this.cheb)return[];let n=Ng(e),r=this.barycenters.size===0,i=[],a=new Map,o=Array.from(this.cheb.bodiesAt(n));o.sort((e,t)=>{let n=e=>e.objectType===W.BARYCENTER?0:e.objectType===W.STAR?1:e.naifId%100==99?2:3;return n(e.body)-n(t.body)||e.body.naifId-t.body.naifId});let s=this.cheb,c=s.body(`naif-${ib}`,n);for(let{body:e,startJd:l,endJd:u}of o){let o=py(e,n);if(!o)continue;a.set(e.naifId,e);let d=`naif-${e.parentId}`,f=this.positions.get(d);if(!f){console.warn(`processChebyshev: parent ${d} not in positions for ${e.id} — hiding`);continue}let p=[f[0]+o[0],f[1]+o[1],f[2]+o[2]],m=e.objectType,h=m===W.MOON&&e.parentId>=1&&e.parentId<=9?`naif-${e.parentId*100+99}`:null,g=h?this.positions.get(h):void 0,_=ab(e,e.parentId,n,h?s.body(h,n)??void 0:void 0),v=e.id,y=e=>{let t=s.body(v,e);return t?ab(t,t.parentId,e,h?s.body(h,e)??void 0:void 0):null},b=Math.hypot(o[0],o[1],o[2])/10,x={id:e.id,name:Wg(t,e.id),isMinor:Gg(t,e.id),hasLocalized:e.hasLocalized,objectType:m,parentId:`naif-${e.parentId}`,radiusKm:e.radiusKm,a:_?Math.abs(_.a):b,e:_?.e??0,i:_?.i??0,om:_?.om??0,w:_?.w??0,ma:_?.ma??0,n:_?.n??0,epoch:_?.epoch??0,equatorial:!1,helioElements:ob(e,n,c)??void 0,validityStart:l,validityEnd:u,orbitalSource:U.SPICE,visibleFromDays:e.visibleFromDays};if(r&&this.positions.set(e.id,p),m===W.BARYCENTER||m===W.LAGRANGE_POINT){r&&_&&_.a>0&&_.e<1&&this.barycenters.set(e.id,_),i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y});continue}if(vn(m)){let t=m===W.MOON,n=this.barycenters.get(d),r=t?_:n??_,o=!t&&n!==void 0,c=a.get(e.parentId)?.id,l=o&&c?e=>{let t=s.body(c,e);return t?ab(t,t.parentId,e):null}:y;i.push({data:x,position:p,orbitElements:r??void 0,orbitCenter:o?void 0:g??f,trailAnchor:o?[f[0],f[1],f[2]]:void 0,rederiveElements:l})}else i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y})}return i}processProbes(e,t,n){let r=Ng(t),i=[],a=new Map,o=new Map,s=new Set,c=new Set;for(let{id:t,probe:l,zoneCenterNaifId:u,startJd:d,endJd:f}of e.probesAt(r)){if(!t)continue;u===void 0&&c.add(t);let p=`naif-${u}`,m=u===void 0?null:Vy(l,r,u,this.cheb,e=>this.positions.has(e)),h=m?m.id:p,g=m?.muKm3S2??0,_=m===null,v=this.positions.get(h);if(!v){let e=a.get(h);e||a.set(h,e=new Set),e.add(t)}if(g===0){let e=o.get(h);e||o.set(h,e=new Set),e.add(t)}let y=Sy(l,r,g);y||s.add(t);let b=v??[0,0,0],x=y?[Q(y[0]),Q(y[2]),-Q(y[1])]:null,S=!x||!v||_,C=x&&!_?[b[0]+x[0],b[1]+x[1],b[2]+x[2]]:[b[0],b[1],b[2]],w={id:t,name:Wg(n,t),isMinor:Gg(n,t),hasLocalized:l.hasLocalized,objectType:l.objectType,parentId:h,loadParentId:h,radiusKm:NaN,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,equatorial:!1,validityStart:d,validityEnd:f,orbitalSource:U.SPICE_PROBE},T=Ry(l,r,g),E=t,D=this.cheb,O=t=>{let n=e.probeWithCenter(E,t);if(!n)return null;let r=Vy(n.probe,t,n.fitCenterNaifId,D,()=>!0);return r?Ry(n.probe,t,r.muKm3S2):null},k;{let{stepDays:e,epsilonScene:n,spanDays:r}=Gy(T,f-d,512),i=this.probeBuffers.get(t);i&&i.parentKey===h?(k=i.buffer,!isFinite(k.epsilonScene)&&isFinite(n)&&k.reconfigure(e,n,r)):(k=new Uy(512,e,n,r),k.needsPopulate=!0,this.probeBuffers.set(t,{buffer:k,parentKey:h}))}i.push({data:w,position:C,positionUnknown:S,orbitElements:T??void 0,orbitCenter:[b[0],b[1],b[2]],rederiveElements:O,trailBuffer:k})}c.size>0&&console.error(`processProbes: ${c.size} probe(s) have undefined fit_center_naif_id — metadata.json is stale (re-export to pick up fit_center_naif_id field). Affected probe ids: ${Array.from(c).slice(0,10).join(`, `)}`+(c.size>10?` (+${c.size-10} more)`:``));for(let[e,t]of a)console.warn(`processProbes: fit-center ${e} not in positions (unplaceable, kept hidden) — ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));for(let[e,t]of o)console.warn(`processProbes: GM unavailable for ${e} — kepler_pure sub-chunks will use mu=0 (static snapshot); affected ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));return s.size>0&&console.warn(`processProbes: ${s.size} probe(s) outside sub-chunk windows at load (will stay hidden until jd enters coverage): ${Array.from(s).slice(0,5).join(`, `)}`+(s.size>5?` (+${s.size-5} more)`:``)),i}async seedNeededParents(e,t,n,r,i){let a=await lb(e,t,n,r),o=cn(i);if(o!==void 0)for(let e=0;e<a.rowCount;e++)this.neededParentKeys.add(mh(o,a.parentId[e]))}async fetchMinorColumns(e,t,n,r,i=null,a=`naif`,o){let s=await lb(e,t,n,i,o);return this.neededParentKeys.size>0&&await this.resolveNeededParents(s,r,a),s}async resolveNeededParents(e,t,n){let r=Ng(t),i=e.kind===`parabolic`,a=this.neededParentKeys,o=performance.now();for(let s=0;s<e.rowCount;s++){if((s&4095)==4095&&performance.now()-o>6&&(await Dg(),o=performance.now()),!a.has(Ch(e,s)))continue;let c=Sh(e,s);if(c===null)continue;let l=this.positions.get(`${n}-${e.parentId[s]}`);if(!l)continue;let u=e_(e,s,nb,n);if(!u)continue;let d=r>=u.validityStart&&r<=u.validityEnd?u.satrec?bg(u.satrec,r):u.q==null?u.a===0&&!i?[0,0,0]:qv(u,t):Yv(u,t):[0,0,0];d&&this.positions.set(c,[l[0]+d[0],l[1]+d[1],l[2]+d[2]])}}async process(e,t,n,r,i=null,a=`naif`,o,s){let c=this.barycenters.size===0,l=[],u=new Map,d=[],[f,p]=await Promise.all([lb(e,t,n,i,s),Vv()]),m=f.kind===`parabolic`,h=f.kind===`sgp4`,g=Ng(r),_=performance.now();for(let e=0;e<f.rowCount;e++){(e&255)==255&&performance.now()-_>6&&(await Dg(),_=performance.now());let t=f.objectType[e];if(!m&&f.a[e]===0&&t!==W.BARYCENTER&&t!==W.LAGRANGE_POINT&&!vn(t))continue;let n=`${a}-${f.parentId[e]}`,i=this.positions.get(n);if(!i){u.set(n,(u.get(n)??0)+1);continue}let s=m?Jg(f,e,p,a):h?$g(f,e,p,a):qg(f,e,p,a);if(!s)continue;if(h&&s.name===null&&!o?.has(s.id)){l.push({data:s,position:[i[0],i[1],i[2]],positionUnknown:!0});continue}if(h&&!s.satrec)continue;let v=g>=s.validityStart&&g<=s.validityEnd,y=v?s.satrec?bg(s.satrec,g):s.a===0&&!m?[0,0,0]:s.q==null?qv(s,r):Yv(s,r):[0,0,0];if(!y){d.push(s.id);continue}let b=[i[0]+y[0],i[1]+y[1],i[2]+y[2]],x=vh(s.id);if(x!==null&&this.neededParentKeys.has(x)&&this.positions.set(s.id,b),t===W.BARYCENTER||t===W.LAGRANGE_POINT){c&&(s.a>0&&s.e<1&&this.barycenters.set(s.id,s),this.positions.set(s.id,b)),l.push({data:s,position:b,positionUnknown:!v,orbitElements:s.a>0?s:void 0,orbitCenter:i});continue}if(c&&vn(t)&&this.positions.set(s.id,b),vn(t)){let e=t===W.MOON,r=this.barycenters.has(n);l.push({data:s,position:b,positionUnknown:!v,orbitElements:e?s:this.barycenters.get(n)??s,orbitCenter:e||!r?i:void 0})}else l.push({data:s,position:b,positionUnknown:!v})}if(d.length>0&&console.warn(`process(${e}/${t}/${n}): positioned ${l.length} body(ies), dropped ${d.length} the propagator refused — ${d.slice(0,5).join(`, `)}`+(d.length>5?` (+${d.length-5} more)`:``)),u.size>0){let r=Array.from(u.values()).reduce((e,t)=>e+t,0),i=Array.from(u.entries()).map(([e,t])=>`${e}×${t}`).join(`, `);console.warn(`process(${e}/${t}/${n}): hid ${r} body(ies) with unresolved parent — ${i}`)}return l}},db=new Map,fb=null,pb=null;function mb(e){if(!e)return;let t=e.ls_deg.length;if(t<2||e.dust_tau_factor.length!==t||e.dust_scale_height_km.length!==t||e.pressure_factor.length!==t){console.warn(`atmospheres: malformed seasonal table — ignored`);return}return{lsDeg:e.ls_deg,dustTauFactor:e.dust_tau_factor,dustScaleHeightKm:e.dust_scale_height_km,pressureFactor:e.pressure_factor}}function hb(e,t,n){if(t){if(!n||n<2||!(t.top_km>0)||t.flux_down.length!==3*n||t.flux_up_ratio.length!==3*n||t.extinction_per_km.length!==3*n){console.warn(`atmospheres: ${e} has a malformed deep column — ignored`);return}return{n,topKm:t.top_km,fluxDown:t.flux_down,fluxUpRatio:t.flux_up_ratio,extinctionPerKm:t.extinction_per_km}}}function gb(){if(pb)return pb;let e=(async()=>{let e=await K_(`${Kt()}/v1/atmospheres.json`);if(!e.ok){console.warn(`atmospheres: fetch failed (${e.status}) — rendering without shells`);return}let t=await e.json();fb=t.sun?.limb_darkening_alpha??null;for(let[e,n]of Object.entries(t.bodies)){let r=t.phases[n.phase];if(!r||r.length!==3*t.phase_n){console.warn(`atmospheres: ${e} has bad phase table "${n.phase}" — skipped`);continue}let i=n.mie_profile;i&&i.length!==t.profile_n&&(console.warn(`atmospheres: ${e} has a bad mie profile — falling back to exponential`),i=void 0),db.set(e,{topAltitudeKm:n.top_altitude_km,rayleighScatterPerKm:n.rayleigh_scatter_per_km,rayleighScaleHeightKm:n.rayleigh_scale_height_km,mieScatterPerKm:n.mie_scatter_per_km,mieAbsorptionPerKm:n.mie_absorption_per_km,mieScaleHeightKm:n.mie_scale_height_km,miePhase:r,absorptionPerKm:n.absorption_per_km,absorptionCenterKm:n.absorption_center_km,absorptionWidthKm:n.absorption_width_km,bakedCompensation:n.baked_compensation,multiScatterGain:n.multi_scatter_gain,sunIntensity:n.sun_intensity,sunColor:[1,1,1],realisticSunAlways:n.realistic_sun_always,refractivity:n.refractivity,groundAlbedo:n.ground_albedo,mieProfile:i,seasonal:mb(n.seasonal),referenceAltitudeKm:n.reference_altitude_km,deepColumn:hb(e,n.deep_column,t.deep_n)})}})();return e.catch(()=>{pb===e&&(pb=null)}),pb=e,e}function _b(e){return db.get(e)}function vb(){return fb}var yb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function bb(e,t){return e>>>t|e<<32-t}function xb(e){let t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=Math.ceil((e.length+9)/64),r=new Uint8Array(n*64);r.set(e),r[e.length]=128,new DataView(r.buffer).setUint32(r.length-4,e.length*8,!1);let i=new Uint32Array(64),a=new DataView(r.buffer);for(let e=0;e<n;e++){for(let t=0;t<16;t++)i[t]=a.getUint32(e*64+t*4,!1);for(let e=16;e<64;e++){let t=bb(i[e-15],7)^bb(i[e-15],18)^i[e-15]>>>3,n=bb(i[e-2],17)^bb(i[e-2],19)^i[e-2]>>>10;i[e]=i[e-16]+t+i[e-7]+n|0}let[n,r,o,s,c,l,u,d]=t;for(let e=0;e<64;e++){let t=bb(c,6)^bb(c,11)^bb(c,25),a=c&l^~c&u,f=d+t+a+yb[e]+i[e]|0,p=(bb(n,2)^bb(n,13)^bb(n,22))+(n&r^n&o^r&o)|0;d=u,u=l,l=c,c=s+f|0,s=o,o=r,r=n,n=f+p|0}t[0]=t[0]+n|0,t[1]=t[1]+r|0,t[2]=t[2]+o|0,t[3]=t[3]+s|0,t[4]=t[4]+c|0,t[5]=t[5]+l|0,t[6]=t[6]+u|0,t[7]=t[7]+d|0}let o=new Uint8Array(32),s=new DataView(o.buffer);for(let e=0;e<8;e++)s.setUint32(e*4,t[e],!1);return o}function Sb(e){return e.shape===`parted`}function Cb(e){return e.shape===`chunked-parted`&&e.label===`date`}function wb(e){return e.shape===`chunked-parted`&&e.label===`index`}function Tb(e){return e.shape===`chunked`}function Eb(e,t){let n=Math.floor((t-e.start_jd)/e.chunk_days);return Math.max(0,Math.min(e.chunks-1,n))}function Db(e){return`shape`in e&&e.shape===`probes`}function Ob(e){return`zooms`in e}function kb(e){return Db(e)?[]:Ob(e)?Object.entries(e.zooms).map(([e,t])=>({zoom:Number(e),data:t})):[{zoom:null,data:e}]}function Ab(e){return!Ob(e)&&!Db(e)?e:void 0}var jb=new WeakMap;function Mb(e){let t=jb.get(e);return t||(t=Object.keys(e.parts_by_date).map(e=>Date.parse(`${e}T00:00:00Z`)).sort((e,t)=>e-t),jb.set(e,t)),t}function Nb(e,t){let n=Mb(e),r=t.getTime(),i=e=>new Date(e).toISOString().slice(0,10);if(r<=n[0])return i(n[0]);if(r>=n[n.length-1])return i(n[n.length-1]);let a=0,o=n.length-1;for(;a<o;){let e=a+o>>1;n[e]<r?a=e+1:o=e}let s=n[a-1],c=n[a];return i(r-s<=c-r?s:c)}var Pb=14;function Fb(e,t){let n=Mb(e),r=t.getTime(),i=Pb*864e5,a=n[0],o=n[n.length-1];if(r<a)return{kind:`covered`};if(r>o+i)return{kind:`after`,lastMs:o+i};if(r>=o)return{kind:`covered`};let s=0,c=n.length-1;for(;s<c;){let e=s+c>>1;n[e]<r?s=e+1:c=e}let l=n[s],u=s>0?n[s-1]:l;return Math.min(r-u,l-r)>i?{kind:`gap`}:{kind:`covered`}}function Ib(e,t,n=0){let r=e.parts_by_date[t]??e.parts;return n>0?Math.min(r,n):r}var Lb=null;function Rb(){if(Lb)return Lb;let e=K_(`${Kt()}/v1/metadata.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch metadata: ${e.status}`);return e.json()}).then(e=>(Jt(e.versions),e));return Lb=e,e.catch(()=>{Lb===e&&(Lb=null)}),Lb}function zb(e){let t=new Map;for(let[n,r]of Object.entries(e.position.zones)){if(Db(r))continue;let e=Ob(r)?0:null,i=e===0?r.zooms[0]:r;!i||!Tb(i)||t.set(n,{zoom:e,chunks:i.chunks,chunk_days:i.chunk_days,start_jd:i.start_jd,end_jd:i.end_jd})}return t}function Bb(e){let t=new Map,n=Object.entries(e.position.zones).filter(([,e])=>Db(e)).sort(([e],[t])=>(e===`probes/interplanetary`)-+(t===`probes/interplanetary`)||e.localeCompare(t));for(let[e,r]of n)Db(r)&&t.set(e,{chunks:r.chunks,chunk_days:r.chunk_days,start_jd:r.start_jd,end_jd:r.end_jd,float64_coeffs:r.float64_coeffs,fit_center_naif_id:r.fit_center_naif_id,present:r.present});return t}async function Vb(e,t){let n=new TextEncoder().encode(e),r=crypto.subtle?await crypto.subtle.digest(`SHA-256`,n):xb(n).buffer;return new DataView(r).getUint32(0,!1)%t}async function Hb(e,t){let n=await K_(e,{priority:t});if(!n.ok)throw Error(`Failed to fetch ${e}: ${n.status}`);let r=new DecompressionStream(`gzip`);return new Response(n.body.pipeThrough(r)).arrayBuffer()}async function Ub(e,t,n,r){let i=uy(await Hb(nn(e,t,n),r));if(i.kind!==`chebyshev`)throw Error(`Expected chebyshev payload at ${e}/${n}, got ${i.kind}`);let a=new Map;for(let e of i.chunk.bodies)e.id&&a.set(e.id,e);return{...i.chunk,byId:a}}var Wb=1,Gb=Promise.resolve();function Kb(e,t){return`${e}:${t}`}var qb=class{chunks=new Map;inflight=new Map;lastEnsuredJd=NaN;constructor(e){this.zoneParams=e}zones(){return Array.from(this.zoneParams.keys())}ensure(e){if(e===this.lastEnsuredJd)return{ready:this.allCurrentChunksLoaded(e),done:this.pendingCurrent(e)};this.lastEnsuredJd=e;let t=[],n=[],r=!0;for(let[i,a]of this.zoneParams){let o=Eb(a,e);if(this.isLoadable(a,o)&&!this.isResident(i,o)){r=!1;let e=this.loadChunk(i,a,o,`high`);e&&t.push(e)}for(let e=-Wb;e<=Wb;e++){let t=o+e;e===0||t<0||t>=a.chunks||this.isLoadable(a,t)&&n.push([i,a,t])}this.evictOutsideWindow(i,o)}let i=t.length>0?Promise.all(t).then(()=>void 0):Gb;return i.catch(()=>{}).then(()=>{for(let[e,t,r]of n)this.loadChunk(e,t,r,`low`)?.catch(()=>{})}),{ready:r,done:i}}pendingCurrent(e){if(this.inflight.size===0)return Gb;let t=null;for(let[n,r]of this.zoneParams){let i=this.inflight.get(Kb(n,Eb(r,e)));i&&(t??=[]).push(i)}return t?Promise.all(t).then(()=>void 0):Gb}allCurrentChunksLoaded(e){for(let[t,n]of this.zoneParams){let r=Eb(n,e);if(this.isLoadable(n,r)&&!this.isResident(t,r))return!1}return!0}isResident(e,t){return this.chunks.get(e)?.has(t)??!1}evictOutsideWindow(e,t){let n=this.chunks.get(e);if(n)for(let e of n.keys())(e<t-Wb||e>t+Wb)&&n.delete(e)}loadChunk(e,t,n,r){if(this.isResident(e,n))return null;let i=Kb(e,n),a=this.inflight.get(i);if(a)return a;let o=this.fetchAndStore(e,t,n,r);return this.inflight.set(i,o),o.finally(()=>this.inflight.delete(i)),o}async fetchAndStore(e,t,n,r){let i=await this.fetchChunk(e,t,n,r),a=this.chunks.get(e);a||this.chunks.set(e,a=new Map),a.set(n,i),this.afterStore(e,i)}},Jb=class extends qb{idToZone=new Map;isLoadable(){return!0}fetchChunk(e,t,n,r){return Ub(e,t.zoom,n,r)}afterStore(e,t){for(let n of t.byId.keys())this.idToZone.has(n)||this.idToZone.set(n,e)}has(e){return this.idToZone.has(e)}zoneCoverage(e){let t=this.idToZone.get(e);if(t===void 0)return null;let n=this.zoneParams.get(t);return n?{start:n.start_jd,end:n.end_jd}:null}resolve(e,t){let n=this.idToZone.get(e);if(n===void 0)return null;let r=this.zoneParams.get(n);if(!r)return null;let i=Eb(r,t),a=this.chunks.get(n)?.get(i);if(!a)return null;let o=a.byId.get(e);return o?{zone:n,chunkIdx:i,body:o}:null}body(e,t){return this.resolve(e,t)?.body??null}*bodiesAt(e){for(let[t,n]of this.zoneParams){let r=Eb(n,e),i=this.chunks.get(t)?.get(r);if(i)for(let e of i.bodies)yield{zone:t,body:e,startJd:i.startJd,endJd:i.endJd}}}positionScene(e,t){let n=this.resolve(e,t);return n?py(n.body,t):null}};async function Yb(e,t,n,r){let i=nn(e,null,t),a=await K_(i,{priority:r});if(!a.ok)throw Error(`Failed to fetch ${i}: ${a.status}`);let o=new DecompressionStream(`gzip`),s=uy(await new Response(a.body.pipeThrough(o)).arrayBuffer(),{probesFloat64:n});if(s.kind!==`probes`)throw Error(`Expected probes payload at ${e}/${t}, got ${s.kind}`);return{...s.chunk,ids:s.chunk.probes.map(e=>e.id)}}var Xb=24;function Zb(e,t){for(let[n,r]of e){if(t<n)return!1;if(t<=r)return!0}return!1}var Qb=7,$b=class extends qb{fitCenterUsable=null;warmed=new Map;carried=new Map;_version=0;get version(){return this._version}zoneCenter(e){return this.zoneParams.get(e)?.fit_center_naif_id}isLoadable(e,t){return Zb(e.present,t)}fetchChunk(e,t,n,r){return Yb(e,n,t.float64_coeffs,r)}afterStore(){this._version++}async warmAt(e){let t=[];for(let[n,r]of this.zoneParams){let i=Eb(r,e);if(i<0||i>=r.chunks||!Zb(r.present,i)||this.isResident(n,i))continue;let a=Kb(n,i);if(this.warmed.has(a))continue;let o=this.inflight.get(a);if(o){t.push(o);continue}let s=this.fetchAndWarm(a,n,i,r);this.inflight.set(a,s),s.finally(()=>this.inflight.delete(a)),t.push(s)}await Promise.all(t)}async fetchAndWarm(e,t,n,r){let i=await Yb(t,n,r.float64_coeffs,`low`);for(this.warmed.set(e,i);this.warmed.size>Xb;){let e=this.warmed.keys().next().value;if(e===void 0)break;this.warmed.delete(e)}}fitCenterCovered(e){let t=e.fitCenter;return!t||!this.fitCenterUsable?!0:this.fitCenterUsable(t.id)}*probesAt(e,t){let n=new Map,r=new Set;for(let[i,a]of this.zoneParams){let o=Eb(a,e),s=this.chunks.get(i)?.get(o)??this.warmed.get(Kb(i,o));if(!s)continue;let c=t?.(a.fit_center_naif_id)??!1;for(let e=0;e<s.probes.length;e++){let t=s.probes[e],o=t.id;if(!o||r.has(o)||!this.fitCenterCovered(t))continue;let l={zone:i,zoneCenterNaifId:a.fit_center_naif_id,id:o,probe:t,startJd:s.startJd,endJd:s.endJd};c?(n.set(o,l),r.add(o)):n.has(o)||n.set(o,l)}}yield*this.withPassengers(n,e).values()}withPassengers(e,t){if(this.carried.size===0)return e;let n=[];for(let[r,{carriedFrom:i}]of this.carried){if(t<i.start_jd||t>=i.end_jd||e.has(r))continue;let a=e.get(i.object_id);a&&n.push([r,a])}for(let[t,r]of n)e.set(t,{...r,id:t});return e}registerCarried(e){this.carried.set(e.id,e)}carrierAt(e,t){if(this.carried.size===0)return null;let n=this.carried.get(e)?.carriedFrom;return!n||t<n.start_jd||t>=n.end_jd+Qb?null:n.object_id}ridesAt(e){let t=[];for(let[n,r]of this.carried){let i=r.carriedFrom;if(e<i.start_jd||e>=i.end_jd+Qb)continue;let a=e<i.end_jd;!a&&this.resolveOwn(n,e)||t.push({passengerId:n,carrierId:i.object_id,carrierName:r.carrierName,attached:a})}return t}resolve(e,t,n){let r=this.resolveOwn(e,t,n);if(r)return r;let i=this.carrierAt(e,t);return i?this.resolveOwn(i,t,n):null}resolveOwn(e,t,n){let r=Fg(t),i=null;for(let[a,o]of this.zoneParams){let s=Eb(o,t),c=this.chunks.get(a)?.get(s)??this.warmed.get(Kb(a,s));if(c)for(let t of rx(c,e)){let e=c.probes[t];if(!this.fitCenterCovered(e))break;let s=hy(e,r)>=0,l=e.landed,u=l!==void 0&&r>=l.startEt&&r<l.endEt;if(!s&&!u)continue;let d={zone:a,probe:e,params:o};if(n?.(o.fit_center_naif_id))return d;i??=d;break}}return i}stampedFitCenterAt(e,t){let n=this.stampedFitCenterAtOwn(e,t);if(n!==null)return n;let r=this.carrierAt(e,t);return r?this.stampedFitCenterAtOwn(r,t):null}stampedFitCenterAtOwn(e,t){let n=Fg(t);for(let[r,i]of this.zoneParams){let a=Eb(i,t),o=this.chunks.get(r)?.get(a)??this.warmed.get(Kb(r,a));if(o)for(let t of rx(o,e)){let e=o.probes[t];if(hy(e,n)<0)break;return e.fitCenter?.id??null}}return null}probe(e,t,n){return this.resolve(e,t,n)?.probe??null}probeWithCenter(e,t,n){let r=this.resolve(e,t,n);return r?{probe:r.probe,fitCenterNaifId:r.params.fit_center_naif_id}:null}positionKm(e,t,n,r){let i=this.resolve(e,t,r);return i?Sy(i.probe,t,n):null}positionScene(e,t,n,r){let i=this.resolve(e,t,r);return i?Cy(i.probe,t,n):null}containingSystemAt(e,t){let n=this.containingSystemAtOwn(e,t);if(n!==null)return n;let r=this.carrierAt(e,t);return r?this.containingSystemAtOwn(r,t):null}containingSystemAtOwn(e,t){let n=Fg(t),r=this.zoneParams.get(ex);if(r){let i=Eb(r,t),a=this.chunks.get(ex)?.get(i);if(a)for(let t of rx(a,e)){let e=a.probes[t];for(let t of e.systemIntervals)if(n>=t.startEt&&n<t.endEt)return t.systemNaifId;return null}}for(let[n,r]of this.zoneParams){if(n===ex||r.fit_center_naif_id===10)continue;let i=Eb(r,t),a=this.chunks.get(n)?.get(i);if(a)for(let t of rx(a,e))return Math.floor(r.fit_center_naif_id/100)}return null}hasHeliocentricFit(e,t){if(this.hasHeliocentricFitOwn(e,t))return!0;let n=this.carrierAt(e,t);return n!==null&&this.hasHeliocentricFitOwn(n,t)}hasHeliocentricFitOwn(e,t){let n=this.zoneParams.get(ex);if(!n)return!1;let r=Eb(n,t),i=this.chunks.get(ex)?.get(r);if(!i)return!1;let a=Fg(t);for(let t of rx(i,e))if(hy(i.probes[t],a)>=0)return!0;return!1}},ex=`probes/interplanetary`,tx=[],nx=new WeakMap;function rx(e,t){let n=nx.get(e);if(!n){n=new Map;for(let t=0;t<e.ids.length;t++){let r=n.get(e.ids[t]);r?r.push(t):n.set(e.ids[t],[t])}nx.set(e,n)}return n.get(t)??tx}async function ix(e){let t=new DecompressionStream(`gzip`);return await new Response(e.body.pipeThrough(t)).json()}function ax(e,t={}){let{onMissing:n,fetcher:r=e=>fetch(e),error:i=(e,t)=>`memoizedGzJson: ${t} returned ${e.status} ${e.statusText}`}=t,a=null;return()=>{if(a)return a;let t=(async()=>{let t=await e(),a=await r(t);if(!a.ok){if(a.status===404&&n)return n();throw Error(i(a,t))}return ix(a)})();return a=t,t.catch(()=>{a===t&&(a=null)}),t}}var ox=24,sx=new Map;function cx(e,t){let n=sx.get(e);if(n&&(sx.delete(e),sx.set(e,n)),!n){n=(async()=>{let n=await K_(e,t);if(!n.ok){if(n.status===404)return{};throw Error(`fetchGzipBundle: ${e} returned ${n.status} ${n.statusText}`)}return ix(n)})(),sx.set(e,n),n.catch(()=>{sx.get(e)===n&&sx.delete(e)});for(let e of sx.keys()){if(sx.size<=ox)break;sx.delete(e)}}return n}var lx={counts:`object_bundles`,globalPath:e=>`/v1/objects/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/objects/${e}/${t}.json.gz`,versionClass:`objects`},ux={counts:`group_bundles`,globalPath:e=>`/v1/groups/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/groups/${e}/${t}.json.gz`},dx=(e,t)=>cx(t?Yt(e,t):`${Kt()}${e}`);async function fx(e,t,{meta:n,lang:r,fetchBundle:i,localized:a=!0}){let o=n[e.counts],s=o?.global??0,c=a?o?.[r]??0:0,[l,u]=await Promise.all([s?Vb(t,s):-1,c?Vb(t,c):-1]),[d,f]=await Promise.all([l>=0?i(e.globalPath(l),e.versionClass):null,u>=0?i(e.localizedPath(r,u),e.versionClass):null]);return{global:d?.[t]??null,localized:f?.[t]??null}}async function px(e,t,n,r=!0){return fx(e,t,{meta:await Rb(),lang:n,localized:r,fetchBundle:dx})}function mx(e){return e.imagery!==`withheld`&&o(e.distribution)}function hx(e,t=!0,n=c()){return px(lx,e,n,t)}async function gx(e){if(e?.startsWith(`probe-`))try{let t=(await hx(e,!1)).global,n=t?.coverage?.position_from;return n?{id:e,carriedFrom:n,carrierName:t?.carried_by?.name}:void 0}catch{return}}function _x(e,t,n){let r=new Set,i=new Map;for(let a of e){let e=t===a.passengerId;if(r.add(e?a.carrierId:a.passengerId),!e||!a.attached)continue;let o=n(a.carrierId)??a.carrierName;o&&i.set(a.passengerId,o)}return{hidden:r,credits:i}}function vx(e){return W[e.toUpperCase()]??W.UNDOCUMENTED}var yx={horizons:U.HORIZONS,sbdb:U.SBDB,celestrak:U.CELESTRAK,spacetrack:U.SPACETRACK,spice:U.SPICE,sbdb_moons:U.SBDB_MOON,astersat:U.ASTERSAT};function bx(e){return e?yx[e]??U.UNKNOWN:U.UNKNOWN}var xx=14;function Sx(e,t){let n=t.global;if(!n?.orbit)return null;let r=n.orbit,i=r.scale===`planet`,a=r.q!=null,o=n.cross_refs?.norad_cat_id,s=r.bstar!=null&&r.mean_motion_dot!=null&&r.mean_motion_ddot!=null&&r.n!=null&&o!=null,c=i&&s?_g({noradCatId:o,epochJd:r.epoch_jd,meanMotion:r.n,eccentricity:r.e,inclination:r.i,raOfAscNode:r.om,argOfPericenter:r.w,meanAnomaly:r.ma??0,bstar:r.bstar,meanMotionDot:r.mean_motion_dot,meanMotionDdot:r.mean_motion_ddot,elementSetNo:r.element_set_no??0,revAtEpoch:r.rev_at_epoch??0},n.name??void 0)??void 0:void 0;return{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:vx(n.type),parentId:r.parent_id,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,a:i?(r.a??0)/ig:r.a??0,e:r.e,i:r.i,om:r.om,w:r.w,ma:r.ma??0,n:i?(r.n??0)*360:r.n??0,epoch:r.epoch_jd,equatorial:i,validityStart:c?r.epoch_jd-xx:-1/0,validityEnd:c?r.epoch_jd+xx:1/0,orbitalSource:bx(r.source),...a?{q:r.q,tp:r.tp}:{},...c?{satrec:c}:{}}}function Cx(e,t){let n=t.global;return n?{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:vx(n.type),parentId:``,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,unplaceable:!0,a:NaN,e:NaN,i:NaN,om:NaN,w:NaN,ma:NaN,n:NaN,epoch:NaN,validityStart:-1/0,validityEnd:1/0,orbitalSource:U.UNKNOWN}:null}async function wx(e,t,n,r=new Set){if(r.has(e))return console.warn(`createPlaceholderBody: cycle detected at ${e} — hiding`),[];r.add(e);let i;try{i=await hx(e)}catch{return console.warn(`createPlaceholderBody: failed to fetch global data for ${e} — hiding`),[]}let a=i.global;if(!a)return console.warn(`createPlaceholderBody: no catalogue record for ${e} — hiding`),[];let o=a.sbdb?.class??null,s=t=>{let n=t?{...t,unplaceable:!0}:Cx(e,i);return n?[{body:{data:n,position:[0,0,0],positionUnknown:!0},zone:o}]:[]},c=Sx(e,i);if(!c)return s();let l=c.satrec,u=c.q!=null,d=[],f=n.positions.get(c.parentId);if(!f){let e=await wx(c.parentId,t,n,r),i=e[e.length-1];if(!i||i.body.positionUnknown)return[...e,...s(c)];f=i.body.position,n.positions.set(c.parentId,f),d.push(...e)}let p=l?bg(l,Ng(t)):u?Yv(c,t):qv(c,t);if(!p)return console.warn(`Failed to compute position for ${e} (e=${c.e})`),[...d,...s(c)];let m=[f[0]+p[0],f[1]+p[1],f[2]+p[2]];return d.push({body:{data:c,position:m,orbitElements:c,orbitCenter:f},zone:o}),d}function Tx(e,t,n,r){let i=0;for(let a=0;a<t.length;a++){let{body:o,zone:s}=t[a];if(e.getBody(o.data.id))continue;let c=o.data.objectType;if(o.data.unplaceable)e.bodies.addBodies([o]),i++;else{let l=a>0?t[a-1]:null,u=c===W.MOON&&l&&_n(l.body.data.objectType)?`small_body_moons`:s;if(c===W.SPACECRAFT||c===W.DEBRIS){let t=o.data.parentId;e.bodies.spacecraftBucket(t).set(o.data.id,o),r?.onPlaceholder?.(o),e.bodies.dirtySpacecraftGroups.add(t),i++}else u?(e.bodies.asteroidBucket(u,n).addPlaceholder(o),e.bodies.dirtyAsteroidZones.add(u),i++):e.bodies.addBodies([o])}e.credits.recordOrbitSources([o])}return i}async function Ex(e,t,n,r){if(e.getBody(t))return;let i=await wx(t,n,r);if(i.length===0)return;let a=Tx(e,i,await Vv());e.bodies.flushMinor(a>0)}var Dx=`spacemap.atmosphere-calibration`;function Ox(){try{let e=localStorage.getItem(Dx);return e?JSON.parse(e):null}catch{return null}}function kx(e){try{e?localStorage.setItem(Dx,JSON.stringify(e)):localStorage.removeItem(Dx)}catch{}}function Ax(){return $e({resolvedReducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,viewMode:`map`,showClouds:!0,showAtmospheres:!0,atmosphereQuality:`auto`,atmosphereAutoTier:null,atmosphereCalibration:Ox(),atmoQualityOverrides:{},highAmbient:!1,realisticLighting:!1,overexposeRings:!1,showShapeMesh:!0,showSurfaceTexture:!0,showDisplacement:!0,showSelfShadow:!0,showHaloDebug:!1,maxPartsPerZone:0,setAtmosphereCalibration(e){this.atmosphereCalibration=e,kx(e)},setAtmosphereAutoTier(e){this.atmosphereAutoTier=e}})}var jx=null;function Mx(){return jx??=Ax()}function Nx(e){jx=e}var Px=2e3,Fx=3,Ix=class{zones=[];latestDate;failureStreak=0;staleNotified=!1;constructor(e,t,n,r){this.ctx=e,this.loader=n,this.latestDate=r;let i=Ng(r),a=Mx().maxPartsPerZone;for(let[n,o]of Object.entries(t.position.zones)){if(e.layers.skipsZone(n))continue;let t=o.parent_id_type??`naif`;for(let{zoom:e,data:s}of kb(o)){if(s.shape===`chunked`||s.shape===`parted`)continue;let o=a>0?Math.min(s.parts,a):s.parts;if(Cb(s)){let i={kind:`time`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentTime:Nb(s,r),inFlight:null,lastLoadStartMs:-1/0,cap:a};this.zones.push(i),this.prefetchTimeNeighbors(i,r)}else if(wb(s)){let a={kind:`chunk`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentIdx:Eb(s,i),inFlight:null,preloads:new Map};this.zones.push(a),this.preloadChunkNeighbors(a,r)}}}}recordSuccess(){this.failureStreak=0}recordFailure(){this.failureStreak++,this.failureStreak>=Fx&&!this.staleNotified&&(this.staleNotified=!0,this.ctx.onDataStale?.())}invalidateZone(e){for(let t of this.zones)t.zone!==e||t.kind!==`time`||(t.currentTime=``,t.lastLoadStartMs=-1/0);this.tick(this.latestDate)}satelliteCoverage(e){let t=this.zones.find(e=>e.kind===`time`&&e.zone===`earth`);return t?Fb(t.zoomData,Pg(e)):{kind:`covered`}}tick(e){this.latestDate=e;let t=Ng(e);for(let n of this.zones)if(n.kind===`time`){if(n.inFlight)continue;let t=Nb(n.zoomData,e);if(t===n.currentTime)continue;let r=performance.now();if(r-n.lastLoadStartMs<Px)continue;n.lastLoadStartMs=r,n.inFlight=this.loadTime(n,t,e).finally(()=>{n.inFlight=null})}else{for(;;){let r=Eb(n.zoomData,t);if(r===n.currentIdx)break;let i=n.preloads.get(r);if(i?.kind!==`ready`)break;let a=n.currentIdx;n.currentIdx=r,this.applyChunkSwap(n,a,r,i.bodies),this.preloadChunkNeighbors(n,e)}if(n.inFlight)continue;let r=Eb(n.zoomData,t);if(r===n.currentIdx)continue;n.inFlight=this.loadChunk(n,r,e).finally(()=>{n.inFlight=null})}}async ensureBody(e,t){if(!this.ctx.getBody(e)){if(e.startsWith(`probe-`)){let n=this.ctx.probeStore;if(!n)return;let r=Ng(t),i=gx(e);await n.ensure(r).done;let a=await i;a&&n.registerCarried(a);let o=n.stampedFitCenterAt(e,r);if(o){this.ctx.getBody(o)||await Ex(this.ctx,o,t,this.loader);let e=this.ctx.getBody(o);e&&!e.positionUnknown&&!this.loader.positions.has(o)&&this.loader.positions.set(o,e.position)}let s=await Vv(),c=this.loader.processProbes(n,t,s).find(t=>t.data.id===e);if(!c){await Ex(this.ctx,e,t,this.loader);return}this.ctx.bodies.addBodies([c]),this.ctx.credits.recordOrbitSources([c]),this.ctx.bodies.notifyBodiesAdded();return}await Ex(this.ctx,e,t,this.loader)}}async loadTime(e,t,n){let r=e.currentTime;try{let i=Ib(e.zoomData,t,e.cap),a=await Promise.all(Array.from({length:i},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,t,e.parentIdType))),o=e.zone===`earth`,s=o?this.ctx.earthSatFilter:null,c=o?this.ctx.earthTypeFilter:null,l=0,u=new Map;for(let t of a){this.ctx.credits.recordOrbitSources(t);for(let n of t){let t=n.data.objectType;if(t!==W.SPACECRAFT&&t!==W.DEBRIS){console.warn(`zone-refresher: unexpected non-spacecraft body in ${e.zone}: ${n.data.id} (type=${t})`);continue}if(s&&!s.has(n.data.id)){l++;continue}if(c&&!c.has(t)){l++;continue}let r=n.data.parentId,i=u.get(r);i||u.set(r,i=new Map),i.set(n.data.id,n)}}l>0&&console.log(`zone-refresher: ${e.zone}@${t}: filtered out ${l} non-member bodies`);let d=0,f=0,p=0;for(let[e,t]of u){let n=this.ctx.bodies.spacecraftBucket(e);for(let e of n.keys())t.has(e)||this.ctx.hasMeshBody?.(e)||(n.delete(e),p++);for(let[e,r]of t){let t=n.get(e);t?(t.data=r.data,t.position=r.position,r.orbitElements!==void 0&&(t.orbitElements=r.orbitElements),r.orbitCenter!==void 0&&(t.orbitCenter=r.orbitCenter),f++):(n.set(e,r),d++)}this.ctx.bodies.dirtySpacecraftGroups.add(e)}e.currentTime=t,this.ctx.bodies.minorBodyVersion++,d>0&&this.ctx.bodies.notifyBodiesAdded(),e.zone===`earth`&&this.ctx.notifyEarthSatRollover(),console.log(`zone-refresher: ${e.zone}@${r} → ${t} (+${d} ~${f} -${p})`),this.prefetchTimeNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: failed to refresh ${e.zone}@${t}:`,n),this.recordFailure()}}async loadChunk(e,t,n){let r=e.currentIdx;e.currentIdx=t;try{let i=e.preloads.get(t),a;a=i?.kind===`pending`?await i.promise:await Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,String(t),e.parentIdType))),this.applyChunkSwap(e,r,t,a),this.preloadChunkNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: ${e.zone} chunk reload failed (${r} → ${t}):`,n),e.currentIdx=r,this.recordFailure()}}applyChunkSwap(e,t,n,r){let i=0,a=0;for(let e of r){this.ctx.credits.recordOrbitSources(e);for(let t of e){let e=this.ctx.bodies.bodiesById.get(t.data.id);if(!e){this.ctx.bodies.addBodies([t]),this.ctx.bodies.majorBodies.push(t),a++;continue}e.data=t.data,e.position=t.position,t.orbitElements!==void 0&&(e.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(e.orbitCenter=t.orbitCenter),i++}}this.ctx.bodies.minorBodyVersion++,console.log(`zone-refresher: ${e.zone} chunk ${t} → ${n} (+${a} ~${i})`)}preloadChunkNeighbors(e,t){let n=Math.max(0,e.currentIdx-1),r=Math.min(e.zoomData.chunks-1,e.currentIdx+1);for(let i=n;i<=r;i++){if(e.preloads.has(i))continue;let n=String(i),r=Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,t,n,e.parentIdType)));e.preloads.set(i,{kind:`pending`,promise:r}),r.then(t=>{e.preloads.get(i)?.kind===`pending`&&e.preloads.set(i,{kind:`ready`,bodies:t})},t=>{console.warn(`zone-refresher: ${e.zone} chunk ${i} preload failed:`,t),e.preloads.get(i)?.kind===`pending`&&e.preloads.delete(i)})}for(let t of e.preloads.keys())(t<n||t>r)&&e.preloads.delete(t)}prefetchTimeNeighbors(e,t){let n=864e5,r=Nb(e.zoomData,new Date(t.getTime()-n)),i=Nb(e.zoomData,new Date(t.getTime()+n));for(let t of new Set([r,i])){if(t===e.currentTime)continue;let n=Ib(e.zoomData,t,e.cap);for(let r=0;r<n;r++)ub.prefetch(e.zone,e.zoom,r,t)}}},Lx,Rx=new Promise(e=>{Lx=e});function zx(){Lx()}var Bx=4;function Vx(){return typeof navigator>`u`?!1:navigator.connection?.saveData===!0}function Hx(){if(typeof navigator>`u`)return!1;if(Vx())return!0;let e=navigator.deviceMemory;return typeof e==`number`&&e>0&&e<=Bx}var Ux;function Wx(){return Ux===void 0&&(Ux=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches),Ux}function Gx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,2)}var Kx={low:{maxPixelRatio:1.25,shadowMapSize:1024,softShadows:!1,bloomScale:.5,pointBudget:4e5,maxTextureTier:`medium`,maxSkyboxFace:2048},medium:{maxPixelRatio:1.5,shadowMapSize:2048,softShadows:!0,bloomScale:.75,pointBudget:9e5,maxTextureTier:`medium`,maxSkyboxFace:2048},high:{maxPixelRatio:2,shadowMapSize:4096,softShadows:!0,bloomScale:1,pointBudget:1/0,maxTextureTier:`high`,maxSkyboxFace:1/0}};function qx(){return Hx()?`low`:Yx().maxTextureTier}function Jx(){let e=Mx().atmosphereCalibration?.tier;return e===`low`||e===`medium`?e:e===`high`||e===`ultra`?`high`:Wx()?Hx()?`low`:`medium`:Hx()?`medium`:`high`}function Yx(){return Kx[Jx()]}function Xx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,Yx().maxPixelRatio)}var Zx=Math.PI/180*ag,Qx=new Hi().setFromAxisAngle(new J(0,0,1),-Math.PI/2).premultiply(new Hi().setFromAxisAngle(new J(0,1,0),Math.PI/2-Zx)).premultiply(new Hi().setFromAxisAngle(new J(1,0,0),-Math.PI/2)),$x=[`px`,`nx`,`py`,`ny`,`pz`,`nz`];function eS(e,t){if(e.tiers.length===0)return null;let n=[...e.tiers].sort((t,n)=>(e.tier_face_size[n]??0)-(e.tier_face_size[t]??0));for(let r of n)if((e.tier_face_size[r]??1/0)<=t)return r;return n[n.length-1]}function tS(e,t,n){return Yt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function nS(e,t,n){return Promise.all($x.map(async r=>{let i=await fetch(tS(e,t,r),{priority:n});if(!i.ok)throw Error(`Skybox face fetch failed (${i.status}): ${t}_${r}`);let a=await i.blob();return createImageBitmap(a,{imageOrientation:`none`,premultiplyAlpha:`none`})}))}var rS=new Map,iS=new Map;function aS(e,t){return`${e}:${t}`}function oS(e,t,n,r=!0){let i=aS(e,t),a=rS.get(i);if(!a){let r=nS(e,t,n);a=r,rS.set(i,a),r.catch(()=>{rS.get(i)===r&&(rS.delete(i),iS.delete(i))})}return r&&iS.set(i,(iS.get(i)??0)+1),a}function sS(e,t,n){let r=aS(e,t),i=(iS.get(r)??1)-1;if(i>0){iS.set(r,i);return}iS.delete(r),rS.delete(r);for(let e of n)e.close()}function cS(e){let t=new Mc(e);return t.colorSpace=Xr,t.needsUpdate=!0,t}function lS(e){return e.tiers.length===0?null:[...e.tiers].sort((t,n)=>(e.tier_face_size[t]??0)-(e.tier_face_size[n]??0))[0]}function uS(e){let t=lS(e);t&&oS(e.id,t,void 0,!1).catch(()=>{})}var dS=12e3;async function fS(e,t,n,r){let i=eS(n,Math.min(t.capabilities.maxTextureSize,Yx().maxSkyboxFace));if(!i){console.warn(`Skybox ${n.id}: no tiers declared`);return}let a=lS(n),o={cube:null,bitmaps:null},s=!1;a&&a!==i&&oS(n.id,a).then(t=>{if(s||r()){sS(n.id,a,t);return}o.cube=cS(t),o.bitmaps=t,e.background=o.cube,performance.mark(`sm-skybox-low`),c&&l()}).catch(()=>{});let c=!1,l=()=>{!a||!o.cube||!o.bitmaps||(t.initTexture(o.cube),sS(n.id,a,o.bitmaps),o.bitmaps=null)};i!==a&&await Promise.race([Rx,new Promise(e=>setTimeout(e,dS))]);let u;try{u=await oS(n.id,i,i===a?void 0:`low`)}catch(e){throw c=!0,r()?a&&o.bitmaps&&(o.cube?.dispose(),sS(n.id,a,o.bitmaps),o.bitmaps=null):l(),e}if(await new Promise(e=>`requestIdleCallback`in window?requestIdleCallback(()=>e(),{timeout:2e3}):setTimeout(e,500)),r()){s=!0,o.cube?.dispose(),sS(n.id,i,u),a&&a!==i&&o.bitmaps&&sS(n.id,a,o.bitmaps);return}let d=cS(u);t.initTexture(d),s=!0;let f=e.background;e.background=d,performance.mark(`sm-skybox-high`),o.cube?.dispose(),f&&f!==o.cube&&f instanceof Mc&&f.dispose(),sS(n.id,i,u),a&&a!==i&&o.bitmaps&&sS(n.id,a,o.bitmaps)}async function pS(e,t,n,r=()=>!1){if(!n?.layers.skipped.has(`stars`))try{let i=await Rb();if(!i.skybox)return;n&&(n.credits.skybox={source:i.skybox.source,organisation:i.skybox.organisation,license:i.skybox.license,attribution:i.skybox.attribution,description:i.skybox.description}),await fS(e,t,i.skybox,r)}catch(e){console.warn(`Failed to load skybox:`,e)}}var mS=13;function hS(e,t,n){let r=Mx().maxPartsPerZone,i=[],a=[];for(let[o,s]of Object.entries(e.position.zones)){if(o===`major`||o===`moons`||o===`spacecraft`||Db(s)||n.skipsZone(o))continue;let e=s.parent_id_type??`naif`;for(let{zoom:n,data:c}of kb(s)){if(c.shape===`chunked`)continue;let s=Cb(c)?Nb(c,t):null,l=Cb(c)&&s!==null?Ib(c,s,r):r>0?Math.min(c.parts,r):c.parts;for(let t=0;t<l;t++){let r={zone:o,zoom:n,part:t,time:s,parentIdType:e};n!==null&&n>=1&&t>=mS?a.push(r):i.push(r)}}}return{eager:i,deferred:a}}async function gS(e,t,n){let r=Bb(e);for(let e of r.keys())n.skipsZone(e)&&r.delete(e);if(r.size===0)return null;console.log(`ProbeStore: ${r.size} zone(s) from metadata:\n`+Array.from(r).map(([e,t])=>` ${e}: chunks=${t.chunks} chunk_days=${t.chunk_days} fit_center=naif-${t.fit_center_naif_id} float64=${t.float64_coeffs}`).join(`
|
|
4052
4052
|
`));let i=Array.from(r).filter(([,e])=>e.fit_center_naif_id===void 0);i.length>0&&console.warn(`ProbeStore: ${i.length} zone(s) missing fit_center_naif_id in metadata — re-export to refresh: ${i.map(([e])=>e).join(`, `)}`);let a=new $b(r);return await a.ensure(t).done,a}async function _S(e,t,n,r,i,a){let o=[],s=null;e.chebStore&&(s=await Vv(),o.push(...t.processChebyshev(r,s))),e.probeStore&&(s??=await Vv(),a&&e.probeStore.registerCarried(a),o.push(...t.processProbes(e.probeStore,r,s)));let c=n.position.zones.major;if(c&&Ob(c))for(let e of[1,2]){let n=c.zooms[String(e)];if(n&&Sb(n))for(let i=0;i<n.parts;i++)o.push(...await t.process(`major`,e,i,r))}let l=e.layers.skipsZone(`moons`)?void 0:n.position.zones.moons,u=l?Ab(l):void 0,d=u&&wb(u)?String(Eb(u,i)):null;return u&&o.push(...await t.process(`moons`,null,0,r,d)),vS(o)}function vS(e){let t=new Map,n=[];for(let r of e){let e=r.data.id;t.has(e)?n.push(e):t.set(e,r)}return n.length>0&&console.warn(`majors: ${n.length} duplicate id(s) in phase 1, kept first:`,n),[...t.values()]}async function yS(e,t,n){performance.mark(`sm-load-start`),U_.reset(),X_().catch(e=>console.warn(`scene-load: systems-global (GMs/nutation) failed to load:`,e));let r=gb().catch(e=>console.warn(`scene-load: atmospheres failed to load — rendering without shells:`,e)),i=Ng(t),a=Rb();Vv().catch(()=>{}),a.then(t=>{let n=t.position.zones.moons;if(!n||e.layers.skipsZone(`moons`))return;let r=Ab(n);r&&Sb(r)&&ub.prefetch(`moons`,null,0,null)}),a.then(t=>{t.skybox&&!e.layers.skipped.has(`stars`)&&uS(t.skybox)});let o=a.then(n=>hS(n,t,e.layers)),s=a.then(async t=>{let n=zb(t);for(let t of n.keys())e.layers.skipsZone(t)&&n.delete(t);if(n.size===0)return null;let r=new Jb(n);return await r.ensure(i).done,r}),c=a.then(t=>gS(t,i,e.layers)),l=gx(n),u=await a;U_.reach(`metadata`),e.chebStore=await s,e.probeStore=await c,U_.reach(`ephemeris`);let d=new ub(e.chebStore);e.probeStore&&(e.probeStore.fitCenterUsable=t=>(e.chebStore?.has(t)??!1)||(e.hasMeshBody?.(t)??!1)||d.positions.has(t));let f=await _S(e,d,u,t,i,await l);U_.reach(`majors`),await r,e.bodies.addBodies(f),e.credits.recordOrbitSources(f);let p=await Vv();U_.reach(`labels`);let m=new Map,h=!1,g=()=>{h=!0},_=()=>{let t=h;h=!1,e.bodies.flushMinor(t)};if(n&&!e.getBody(n)){let r=await wx(n,t,d);Tx(e,r,p,{onPlaceholder:e=>m.set(e.data.id,e)})>0&&g(),r.length>0&&_()}e.bodies.majorBodies=f.filter(e=>e.data.objectType!==W.BARYCENTER&&e.data.objectType!==W.LAGRANGE_POINT&&e.data.orbitalSource!==U.SPICE_PROBE),U_.reach(`done`),e.loading=!1,performance.mark(`sm-majors-done`);let{eager:v,deferred:y}=await o,b=v.filter(e=>e.zone===`small_body_moons`),x=v.filter(e=>e.zone!==`small_body_moons`);for(let e of b)try{await d.seedNeededParents(e.zone,e.zoom,e.part,e.time,e.parentIdType)}catch(t){console.warn(`scene-load: seedNeededParents failed for ${e.zone} part ${e.part}:`,t)}e.bodies.minorStreaming=!0;let S=setInterval(_,500),C=async(t,n,r)=>{e.credits.recordOrbitSource(n.source),n.rowCount!==0&&(await e.bodies.asteroidBucket(t,p).addChunk(n,r)>0&&g(),e.bodies.dirtyAsteroidZones.add(t))},w=(t,n)=>{e.credits.recordOrbitSources(n);let r=t===`earth`,i=r?e.earthSatFilter:null,a=r?e.earthTypeFilter:null;for(let t of n){if(i&&!i.has(t.data.id)||a&&!a.has(t.data.objectType))continue;let n=m.get(t.data.id);if(n){n.data=t.data,n.position=t.position,t.orbitElements!==void 0&&(n.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(n.orbitCenter=t.orbitCenter),m.delete(t.data.id),e.bodies.dirtySpacecraftGroups.add(t.data.parentId);continue}let r=t.data.parentId,o=e.bodies.spacecraftBucket(r);o.has(t.data.id)||g(),o.set(t.data.id,t),e.bodies.dirtySpacecraftGroups.add(r)}},T=(t,n)=>{e.credits.recordOrbitSources(n);let r=e.bodies.asteroidBucket(t,p);for(let e of n)r.addPlaceholder(e),g();e.bodies.dirtyAsteroidZones.add(t)},E=x.filter(e=>e.zone.startsWith(`small_bodies/`)),D=x.filter(e=>!e.zone.startsWith(`small_bodies/`)),O=new Set,k=(e,t)=>n=>{O.add(e),console.warn(`scene-load: ${e} part ${t} failed (skipped):`,n)};try{await Promise.all([...E.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a).then(t=>C(e,t,a)).catch(k(e,r))),...D.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a,new Set(m.keys()),`high`).then(t=>w(e,t)).catch(k(e,r)))]),await Promise.all(b.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a).then(t=>T(e,t)).catch(k(e,r))))}finally{clearInterval(S),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-minors-done`),zx()}if(y.length>0&&Hx())console.info(`Low-end device: skipping ${y.length} deferred minor-belt parts to conserve memory`);else if(y.length>0){e.bodies.minorStreaming=!0;let n=setInterval(_,1e3);try{await Promise.all(y.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a,`low`).then(t=>C(e,t,a)).catch(k(e,r))))}finally{clearInterval(n),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-deferred-done`)}}try{e.refresher=new Ix(e,await a,d,t);for(let t of O)e.refresher.invalidateZone(t)}catch(e){console.error(`scene-load: ZoneRefresher init failed; hot-reload disabled:`,e)}}var bS=ax(async()=>(await Rb(),Yt(`/v1/membership/earth.json.gz`,`membership`)),{onMissing:()=>({}),error:e=>`fetchEarthMembership: ${e.status} ${e.statusText}`});async function xS(e){let t=await bS();return new Set(t[e]??[])}function SS(e,t=c()){return px(ux,e,t)}var CS={[cv]:new Set([W.SPACECRAFT]),[lv]:new Set([W.DEBRIS])},wS=class{bodies=new I_;credits=new Cn;layers=new Cv;visibility=new Lv(this.bodies,()=>this.probeStore,()=>this.earthSatFilter,()=>this.smallBodyFilter,()=>this.layers);#e=qe(!0);get loading(){return Ut(this.#e)}set loading(e){Je(this.#e,e,!0)}#t=qe(null);get error(){return Ut(this.#t)}set error(e){Je(this.#t,e,!0)}onDataStale=null;constructor(){}chebStore=null;probeStore=null;refresher=null;hasMeshBody=null;earthSatFilter=null;earthSatFilterSlug=null;earthTypeFilter=null;smallBodyFilter=null;missionMemberIds=null;currentGroupSlug=null;groupFilterListeners=new Set;smallBodyFilterListeners=new Set;earthSatRolloverListeners=new Set;onGroupFilterChange(e){return this.groupFilterListeners.add(e),()=>this.groupFilterListeners.delete(e)}onSmallBodyFilterChange(e){return this.smallBodyFilterListeners.add(e),()=>this.smallBodyFilterListeners.delete(e)}onEarthSatRollover(e){return this.earthSatRolloverListeners.add(e),()=>this.earthSatRolloverListeners.delete(e)}notifyEarthSatRollover(){for(let e of this.earthSatRolloverListeners)e()}getBody(e,t){return this.bodies.getBody(e,t)}isMemberOfActiveGroup(e){if(this.missionMemberIds?.has(e)===!0||this.earthSatFilter?.has(e)===!0)return!0;let t=this.earthTypeFilter;if(t){let n=this.bodies.getBody(e)?.data.objectType;if(n!==void 0&&t.has(n))return!0}let n=this.smallBodyFilter;return n===null?!1:Dv(this.bodies,e,n)}async load(e,t){try{await yS(this,e,t)}catch(e){throw this.loading=!1,this.error=e instanceof Error?e.message:String(e),console.error(`[scene-load]`,e),e}}refreshTick(e){this.refresher?.tick(e)}async ensureBody(e,t){await this.refresher?.ensureBody(e,t)}async applyGroupFilter(e){if(e===this.currentGroupSlug)return;if(this.currentGroupSlug=e,e?.startsWith(`mission-`)){let t=await SS(e);if(e!==this.currentGroupSlug)return;this.missionMemberIds=new Set((t.global?.notable_members??[]).map(e=>e.id).filter(e=>!!e))}else this.missionMemberIds=null;let t=e?await this.resolveIndexEntry(e):null;if(e!==this.currentGroupSlug)return;let n=this.resolveSmallBodyFilter(e,t?.applies_to,t?.n),r=t?.applies_to===`earth_sat`?e:null,i=CS[e??``]??null;if(!pv(this.smallBodyFilter,n)){this.smallBodyFilter=n;for(let e of this.smallBodyFilterListeners)e(n)}if(r===this.earthSatFilterSlug&&i===this.earthTypeFilter)return;let a=r?await xS(r):null;if(e===this.currentGroupSlug){this.earthSatFilter=a,this.earthSatFilterSlug=r,this.earthTypeFilter=i;for(let e of this.groupFilterListeners)e(a);this.loading||(this.bodies.spacecraftByParent.delete(p_),this.bodies.dirtySpacecraftGroups.add(p_),this.bodies.minorBodyVersion++,this.refresher?.invalidateZone(`earth`))}}resolveSmallBodyFilter(e,t,n){if(e===ov)return{kind:`category`,category:`asteroid`};if(e===sv)return{kind:`category`,category:`comet`};if(e===null||t!==`small_body`)return null;if(e.startsWith(`class-`))return{kind:`class`,className:e.slice(rv.length)};if(e.startsWith(`flag-`)){let t=e.slice(iv.length),r=uv[t];return r===void 0?null:{kind:`flag`,flag:t,mask:r,n:n??0}}return null}async resolveIndexEntry(e){try{return(await hv())[e]??null}catch{return null}}},TS=400,ES=class{#e=qe(0);get jd(){return Ut(this.#e)}set jd(e){Je(this.#e,e,!0)}#t=qe(1);get timeScale(){return Ut(this.#t)}set timeScale(e){Je(this.#t,e,!0)}#n=qe(1);get direction(){return Ut(this.#n)}set direction(e){Je(this.#n,e,!0)}seeked=!1;#r=qe(0);get jumps(){return Ut(this.#r)}set jumps(e){Je(this.#r,e,!0)}#i=qe(0);get settledJd(){return Ut(this.#i)}set settledJd(e){Je(this.#i,e,!0)}#a=qe(!1);get live(){return Ut(this.#a)}set live(e){Je(this.#a,e,!0)}lastRealMs=0;prevScale=1;stops=null;settleTimer=null;constructor(e,t=!1){this.jd=e,this.settledJd=e,this.live=t,this.lastRealMs=performance.now()}tick(e){let t=e-this.lastRealMs;if(this.lastRealMs=e,this.timeScale===0)return;let n=this.jd+t/jg*this.timeScale,r=this.stops;if(r!==null){if(this.timeScale>0&&r.forwardJd!==null&&n>=r.forwardJd&&this.jd<r.forwardJd){this.jd=r.forwardJd,this.pause(),r.onHit(r.forwardJd);return}if(this.timeScale<0&&r.backwardJd!==null&&n<=r.backwardJd&&this.jd>r.backwardJd){this.jd=r.backwardJd,this.pause(),r.onHit(r.backwardJd);return}}this.jd=n}setBoundaryStops(e){this.stops=e}setTimeScale(e){let t=e*this.direction;t!==0&&(this.prevScale=t),this.timeScale=t,t!==1&&(this.live=!1),this.lastRealMs=performance.now()}toggleDirection(){this.direction=this.direction===1?-1:1,this.timeScale=-this.timeScale,this.prevScale=-this.prevScale,this.live=!1,this.lastRealMs=performance.now()}setJD(e){this.jd=e,this.seeked=!0,this.live=!1,this.lastRealMs=performance.now(),this.settleAfterPause()}jumpTo(e){this.setJD(e),this.jumps++,this.settle()}settle(){this.settleTimer!==null&&clearTimeout(this.settleTimer),this.settleTimer=null,this.settledJd=this.jd}settleAfterPause(){this.settleTimer!==null&&clearTimeout(this.settleTimer),this.settleTimer=null,!this.playing&&(this.settleTimer=setTimeout(()=>this.settle(),TS))}sweepTo(e){this.jd=e,this.live=!1,this.lastRealMs=performance.now()}pause(){this.timeScale!==0&&(this.prevScale=this.timeScale),this.timeScale=0,this.live=!1,this.settle()}play(){this.timeScale===0&&(this.timeScale=this.prevScale||1,this.lastRealMs=performance.now())}now(){this.jumpTo(Ng(new Date)),this.live=this.timeScale===1}get playing(){return this.timeScale!==0}get date(){return Pg(this.jd)}setDate(e){this.jumpTo(Ng(e))}},DS={type:`change`},OS={type:`start`},kS={type:`end`},AS=new _s,jS=new oc,MS=Math.cos(70*Vi.DEG2RAD),NS=new J,PS=2*Math.PI,FS={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},IS=1e-6,LS=class extends Kd{constructor(e,t=null){super(e,t),this.state=FS.NONE,this.target=new J,this.cursor=new J,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:wn.ROTATE,MIDDLE:wn.DOLLY,RIGHT:wn.PAN},this.touches={ONE:Tn.ROTATE,TWO:Tn.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle=`auto`,this._domElementKeyEvents=null,this._lastPosition=new J,this._lastQuaternion=new Hi,this._lastTargetPosition=new J,this._quat=new Hi().setFromUnitVectors(e.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Vd,this._sphericalDelta=new Vd,this._scale=1,this._panOffset=new J,this._rotateStart=new q,this._rotateEnd=new q,this._rotateDelta=new q,this._panStart=new q,this._panEnd=new q,this._panDelta=new q,this._dollyStart=new q,this._dollyEnd=new q,this._dollyDelta=new q,this._dollyDirection=new J,this._mouse=new q,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=zS.bind(this),this._onPointerDown=RS.bind(this),this._onPointerUp=BS.bind(this),this._onContextMenu=qS.bind(this),this._onMouseWheel=US.bind(this),this._onKeyDown=WS.bind(this),this._onTouchStart=GS.bind(this),this._onTouchMove=KS.bind(this),this._onMouseDown=VS.bind(this),this._onMouseMove=HS.bind(this),this._interceptControlDown=JS.bind(this),this._interceptControlUp=YS.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e===`grab`?this.domElement.style.cursor=`grab`:this.domElement.style.cursor=`auto`}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(DS),this.update(),this.state=FS.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;NS.copy(t).sub(this.target),NS.applyQuaternion(this._quat),this._spherical.setFromVector3(NS),this.autoRotate&&this.state===FS.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=PS:n>Math.PI&&(n-=PS),r<-Math.PI?r+=PS:r>Math.PI&&(r-=PS),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(NS.setFromSpherical(this._spherical),NS.applyQuaternion(this._quatInverse),t.copy(this.target).add(NS),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=NS.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new J(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new J(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=NS.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(AS.origin.copy(this.object.position),AS.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(AS.direction))<MS?this.object.lookAt(this.target):(jS.setFromNormalAndCoplanarPoint(this.object.up,this.target),AS.intersectPlane(jS,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>IS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>IS||this._lastTargetPosition.distanceToSquared(this.target)>IS?(this.dispatchEvent(DS),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?PS/60/60*this.autoRotateSpeed:PS/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){NS.setFromMatrixColumn(t,0),NS.multiplyScalar(-e),this._panOffset.add(NS)}_panUp(e,t){this.screenSpacePanning===!0?NS.setFromMatrixColumn(t,1):(NS.setFromMatrixColumn(t,0),NS.crossVectors(this.object.up,NS)),NS.multiplyScalar(e),this._panOffset.add(NS)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;NS.copy(r).sub(this.target);let i=NS.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(PS*this._rotateDelta.x/t.clientHeight),this._rotateUp(PS*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-PS*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(PS*this._rotateDelta.x/t.clientHeight),this._rotateUp(PS*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new q,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function RS(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e),this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grabbing`)))}function zS(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function BS(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(kS),this.state=FS.NONE,this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grab`);break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function VS(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case wn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=FS.DOLLY;break;case wn.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=FS.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=FS.ROTATE}break;case wn.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=FS.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=FS.PAN}break;default:this.state=FS.NONE}this.state!==FS.NONE&&this.dispatchEvent(OS)}function HS(e){switch(this.state){case FS.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case FS.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case FS.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function US(e){this.enabled===!1||this.enableZoom===!1||this.state!==FS.NONE||(e.preventDefault(),this.dispatchEvent(OS),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(kS))}function WS(e){this.enabled!==!1&&this._handleKeyDown(e)}function GS(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Tn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=FS.TOUCH_ROTATE;break;case Tn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=FS.TOUCH_PAN;break;default:this.state=FS.NONE}break;case 2:switch(this.touches.TWO){case Tn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=FS.TOUCH_DOLLY_PAN;break;case Tn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=FS.TOUCH_DOLLY_ROTATE;break;default:this.state=FS.NONE}break;default:this.state=FS.NONE}this.state!==FS.NONE&&this.dispatchEvent(OS)}function KS(e){switch(this._trackPointer(e),this.state){case FS.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case FS.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case FS.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case FS.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=FS.NONE}}function qS(e){this.enabled!==!1&&e.preventDefault()}function JS(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function YS(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var{PI:XS,sin:ZS,cos:QS,asin:$S,atan2:eC,sqrt:tC}=Math,nC=180/XS,rC=XS/180;function iC(e,t,n){let[r,i,a]=e,[o,s,c,l]=n?[-t[0],-t[1],-t[2],t[3]]:t,u=l*r+s*a-c*i,d=l*i+c*r-o*a,f=l*a+o*i-s*r,p=-o*r-s*i-c*a;return[u*l+p*-o+d*-c-f*-s,d*l+p*-s+f*-o-u*-c,f*l+p*-c+u*-s-d*-o]}function aC(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=tC(r*r+i*i+a*a);return n&&([r,i,a]=iC([r,i,a],n,!0)),{latitude:$S(i/o)*nC,longitude:n?eC(-a,r)*nC:eC(r,a)*nC,distance:o}}function oC(e,t,n,r,i){let a=t*rC,o=n*rC,s,c,l;if(i){let e=[r*QS(a)*QS(o),r*ZS(a),-r*QS(a)*ZS(o)];[s,c,l]=iC(e,i,!1)}else s=r*QS(a)*ZS(o),c=r*ZS(a),l=r*QS(a)*QS(o);return[e[0]+s,e[1]+c,e[2]+l]}function sC(e,t,n,r){let i=e[0]-t[0],a=e[2]-t[2],o=tC(i*i+a*a);o>0?(i/=o,a/=o):(i=0,a=1);let s=n*rC,c=QS(s);return[r*c*i,r*ZS(s),r*c*a]}function cC(e){let t=(e+180)%360-180;return t<=-180?t+360:t}function lC(e,t,n){if(t===void 0&&n===void 0)return e;let r=t===void 0?-180:cC(t),i=r===180?-180:r,a=n===void 0?180:cC(n);if(i<=a?e>=i&&e<=a:e>=i||e<=a)return e;let o=(e,t)=>Math.abs(cC(e-t));return o(e,i)<=o(e,a)?i:a}var uC=p_,dC=Math.PI/180,fC=2451545,pC=36525;function mC(e,t,n){let r=t-fC,i=r/pC,a=e.pole_ra_0+e.pole_ra_1*i,o=e.pole_dec_0+e.pole_dec_1*i,s=e.w0+e.w1*r+e.w2*r*r;if(n){let{ra:e,dec:t,pm:r,angles:c}=n,l=Math.min(c.length>>1,Math.max(e.length,t.length,r.length));for(let n=0;n<l;n++){let l=(c[2*n]+c[2*n+1]*i)*dC,u=Math.sin(l);n<e.length&&(a+=e[n]*u),n<t.length&&(o+=t[n]*Math.cos(l)),n<r.length&&(s+=r[n]*u)}}let c=a*dC,l=o*dC,u=Math.cos(l),d=dg(u*Math.cos(c),u*Math.sin(c),Math.sin(l),new J).normalize(),f=dg(-Math.sin(c),Math.cos(c),0,new J).normalize(),p=new J().crossVectors(f,d).normalize(),m=new Hi().setFromRotationMatrix(new Y().makeBasis(f,d,p));return new Hi().setFromAxisAngle(d,s*dC).multiply(m)}function hC(e,t,n,r){e.quaternion.copy(mC(t,n,r))}var gC=new J(0,1,0),_C=new J;function vC(e,t,n){_C.set(t[0]-n[0],t[1]-n[1],t[2]-n[2]),!(_C.lengthSq()<1e-20)&&(_C.normalize(),e.quaternion.setFromUnitVectors(gC,_C))}function yC(e,t){e.quaternion.setFromUnitVectors(gC,t)}var bC={"+x":new J(1,0,0),"-x":new J(-1,0,0),"+y":new J(0,1,0),"-y":new J(0,-1,0),"+z":new J(0,0,1),"-z":new J(0,0,-1)};function xC(e){let t=[];for(let[n,r]of Object.entries(e)){let e=bC[n],i=bC[r];if(!e||!i)return console.warn(`frame_map: invalid axis pair ${n}→${r}; ignoring map`),null;t.push([e,i])}if(t.length<1||t.length>2)return console.warn(`frame_map: expected 1–2 axis pairs, got ${t.length}; ignoring map`),null;if(t.length===1)return new Hi().setFromUnitVectors(t[0][0],t[0][1]);let[[n,r],[i,a]]=t;if(n.dot(i)!==0||r.dot(a)!==0)return console.warn(`frame_map: the two pairs must use perpendicular axes; ignoring map`),null;let o=new J().crossVectors(n,i),s=new J().crossVectors(r,a),c=new Y().makeBasis(r,a,s),l=new Y().makeBasis(n,i,o).transpose();return new Hi().setFromRotationMatrix(c.multiply(l))}var SC=new J,CC=new J,wC=new J,TC=new J,EC=new J,DC=new J,OC=new J,kC=new J,AC=new Y,jC=new Y;function MC(e,t,n){if(e===`parent`)n.set(t.parentPos[0]-t.bodyPos[0],t.parentPos[1]-t.bodyPos[1],t.parentPos[2]-t.bodyPos[2]);else if(e===`sun`){if(!t.sunPos)return!1;n.set(t.sunPos[0]-t.bodyPos[0],t.sunPos[1]-t.bodyPos[1],t.sunPos[2]-t.bodyPos[2])}else{if(!t.velocity)return!1;n.set(t.velocity[0],t.velocity[1],t.velocity[2])}return n.lengthSq()<1e-20?!1:(n.normalize(),!0)}function NC(e,t,n){if(!MC(t.primary.target,n,SC))return;let r=bC[t.primary.axis],i=t.secondary;if(!i||!MC(i.target,n,CC)){e.quaternion.setFromUnitVectors(r,SC);return}if(EC.crossVectors(r,bC[i.axis]),kC.crossVectors(SC,CC),EC.lengthSq()<1e-20||kC.lengthSq()<1e-20){e.quaternion.setFromUnitVectors(r,SC);return}EC.normalize(),kC.normalize(),wC.copy(r),DC.copy(SC),TC.crossVectors(EC,wC),OC.crossVectors(kC,DC),AC.makeBasis(DC,OC,kC),jC.makeBasis(wC,TC,EC).transpose(),AC.multiply(jC),e.quaternion.setFromRotationMatrix(AC)}function PC(e,t){let n=e,r=n.userData.shaderMods??=[];r.includes(t)||(r.push(t),e.customProgramCacheKey=()=>r.join(`|`))}function FC(e,t,n){let r=e.onBeforeCompile;e.onBeforeCompile=(e,t)=>{r?.(e,t),n(e,t)},PC(e,t),e.needsUpdate=!0}var IC={uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new sa)}},LC=`
|
|
4053
4053
|
#define ECLIPSE_MAX_OCCLUDERS 32
|
|
@@ -4434,7 +4434,18 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4434
4434
|
|
|
4435
4435
|
#endif
|
|
4436
4436
|
|
|
4437
|
-
}`},tT=class extends Uw{constructor(){super(),this.isOutputPass=!0,this.uniforms=lu.clone(eT.uniforms),this.material=new pu({name:eT.name,uniforms:this.uniforms,vertexShader:eT.vertexShader,fragmentShader:eT.fragmentShader}),this._fsQuad=new Kw(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},Xi.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},nT=!1;function rT(e){nT=e}function iT(){return nT}function aT(e){return nT?e>=0&&e<=1:e>=-1&&e<=1}
|
|
4437
|
+
}`},tT=class extends Uw{constructor(){super(),this.isOutputPass=!0,this.uniforms=lu.clone(eT.uniforms),this.material=new pu({name:eT.name,uniforms:this.uniforms,vertexShader:eT.vertexShader,fragmentShader:eT.fragmentShader}),this._fsQuad=new Kw(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},Xi.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},nT=!1;function rT(e){nT=e}function iT(){return nT}function aT(e){return nT?e>=0&&e<=1:e>=-1&&e<=1}var oT=-44;function sT(){Zd.logdepthbuf_vertex=`
|
|
4438
|
+
#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
4439
|
+
vFragDepth = gl_Position.w;
|
|
4440
|
+
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
4441
|
+
#endif
|
|
4442
|
+
`,Zd.logdepthbuf_fragment=`
|
|
4443
|
+
#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
4444
|
+
gl_FragDepth = vIsPerspective == 0.0
|
|
4445
|
+
? gl_FragCoord.z
|
|
4446
|
+
: max( log2( vFragDepth ) - ${oT.toFixed(1)}, 0.0 ) / ( 2.0 / logDepthBufFC - ${oT.toFixed(1)} );
|
|
4447
|
+
#endif
|
|
4448
|
+
`}function cT(e,t){let n=oT.toFixed(1);return`exp2(${e} * (log2(${t} + 1.0) - ${n}) + ${n})`}function lT(e){return e.isCSS2DObject===!0}var uT=NaN,dT=class{domElement;sortObjects=!0;_w=0;_h=0;_wHalf=0;_hHalf=0;_viewMatrix=new Y;_viewProjectionMatrix=new Y;_vector=new J;_a=new J;_b=new J;_cache=new WeakMap;_visibleBuf=[];_visibleCount=0;constructor(e={}){this.domElement=e.element??document.createElement(`div`),this.domElement.style.overflow=`hidden`}getSize(){return{width:this._w,height:this._h}}setSize(e,t){this._w=e,this._h=t,this._wHalf=e/2,this._hHalf=t/2,this.domElement.style.width=e+`px`,this.domElement.style.height=t+`px`}render(e,t){e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),this._viewMatrix.copy(t.matrixWorldInverse),this._viewProjectionMatrix.multiplyMatrices(t.projectionMatrix,this._viewMatrix),this._visibleCount=0,this.renderObject(e,t),this.sortObjects&&this.zOrder();for(let e=this._visibleCount;e<this._visibleBuf.length;e++)this._visibleBuf[e]=void 0;this._visibleBuf.length=this._visibleCount}renderObject(e,t){if(e.visible===!1){e.userData.css2dHidden!==!0&&(this.hideObject(e),e.userData.css2dHidden=!0);return}if(e.userData.css2dHidden===!0&&(e.userData.css2dHidden=!1),lT(e)){let n=e.element;this._vector.setFromMatrixPosition(e.matrixWorld),this._vector.applyMatrix4(this._viewProjectionMatrix);let r=this._vector.z,i=aT(r),a=e.layers.test(t.layers),o=i&&a,s=this.cacheFor(n),c=o?``:`none`;if(s.display!==c&&(n.style.display=c,s.display=c),o){let r=Math.round((this._vector.x*this._wHalf+this._wHalf)*2)/2,i=Math.round((-this._vector.y*this._hHalf+this._hHalf)*2)/2,a=e.center.x,o=e.center.y;(s.tx!==r||s.ty!==i||s.cx!==a||s.cy!==o)&&(n.style.transform=`translate(`+-100*a+`%,`+-100*o+`%) translate(`+r+`px,`+i+`px)`,s.tx=r,s.ty=i,s.cx=a,s.cy=o),n.parentNode!==this.domElement&&this.domElement.appendChild(n),s.dist2=this.distanceToCameraSquared(t,e),this._visibleBuf[this._visibleCount++]=e}}let n=e.children;for(let e=0;e<n.length;e++)this.renderObject(n[e],t)}cacheFor(e){let t=this._cache.get(e);return t||(t={tx:uT,ty:uT,cx:uT,cy:uT,display:`__init__`,zIndex:uT,dist2:0},this._cache.set(e,t)),t}hideObject(e){if(lT(e)){let t=e.element,n=this.cacheFor(t);n.display!==`none`&&(t.style.display=`none`,n.display=`none`)}let t=e.children;for(let e=0;e<t.length;e++)this.hideObject(t[e])}distanceToCameraSquared(e,t){return this._a.setFromMatrixPosition(e.matrixWorld),this._b.setFromMatrixPosition(t.matrixWorld),this._a.distanceToSquared(this._b)}zOrder(){let e=this._visibleBuf,t=this._visibleCount;if(t===0)return;e.sort((e,t)=>e.renderOrder===t.renderOrder?this._cache.get(e.element).dist2-this._cache.get(t.element).dist2:t.renderOrder-e.renderOrder);let n=t;for(let r=0;r<t;r++){let t=e[r],i=n-r,a=this._cache.get(t.element);a.zIndex!==i&&(t.element.style.zIndex=String(i),a.zIndex=i)}}},fT=.5;function pT(e,t){return new X(e).multiplyScalar(t)}var mT=new q(1,1);function hT(e,t){mT.set(e,t)}function gT(e,t=fT){return new fu({transparent:!0,depthWrite:!1,uniforms:{uColor:{value:pT(e,t)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0}},vertexShader:`
|
|
4438
4449
|
#include <common>
|
|
4439
4450
|
#include <logdepthbuf_pars_vertex>
|
|
4440
4451
|
uniform vec3 uCenterOffset;
|
|
@@ -4458,7 +4469,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4458
4469
|
gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
|
|
4459
4470
|
#include <logdepthbuf_fragment>
|
|
4460
4471
|
}
|
|
4461
|
-
`})}function
|
|
4472
|
+
`})}function _T(e,t,n=fT,r){return new fu({defines:r?{DASHED:``}:{},transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:pT(e,n)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0},uLineWidth:{value:t},uResolution:{value:mT},uDash:{value:new q(r?.[0]??0,r?.[1]??0)}},vertexShader:`
|
|
4462
4473
|
#include <common>
|
|
4463
4474
|
#include <logdepthbuf_pars_vertex>
|
|
4464
4475
|
uniform vec3 uCenterOffset;
|
|
@@ -4518,7 +4529,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4518
4529
|
gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
|
|
4519
4530
|
#include <logdepthbuf_fragment>
|
|
4520
4531
|
}
|
|
4521
|
-
`})}var hT=class extends qa{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Lc;e.deleteAttribute(`uv`);let t=new mu({side:1}),n=new mu,r=new dd(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new As(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new nc(e,n,6),o=new Ra;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);let s=new As(e,gT(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new As(e,gT(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new As(e,gT(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new As(e,gT(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new As(e,gT(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new As(e,gT(100));f.position.set(0,20,0),f.scale.set(1,.1,1),this.add(f)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function gT(e){return new gu({color:0,emissive:16777215,emissiveIntensity:e})}var _T=.01,vT=3.5,yT=.04;function bT(e){let t=Math.max(e/10,.01);return 1/(t*t)}function xT(e,t,n=1){e.decay=t?2:0,e.intensity=(t?vT*10*10:vT)*n}function ST(e){let t=new yf(e),n=t.fromScene(new hT).texture;return t.dispose(),n}var CT=1e5;function wT(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var TT=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function ET(e,t,n){let r,i=wT();try{r=new dh(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new TT(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),rT(r.capabilities.reversedDepthBuffer);let a=Yx();r.setPixelRatio(Xx()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,fT(e.clientWidth,e.clientHeight);let o=new cT({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new qa,c=new hd(16777215,_T);s.add(c);let l=new md(16777215,0);l.castShadow=!1,l.shadow.mapSize.set(a.shadowMapSize,a.shadowMapSize),l.shadow.bias=-1e-4,s.add(l),s.add(l.target);let u=new sd(60,e.clientWidth/e.clientHeight,Q(.001),CT),d=r.capabilities.reversedDepthBuffer?new la(e.clientWidth,e.clientHeight,{type:Un,depthTexture:new Pc(e.clientWidth,e.clientHeight,Hn)}):void 0,f=new Xw(r,d);f.setPixelRatio(Xx()),f.setSize(e.clientWidth,e.clientHeight),f.addPass(new Zw(s,u));let p=new $w(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);return f.addPass(p),f.addPass(new tT),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:f,bloomPass:p,ambientLight:c,shadowLight:l}}function DT(e,t,n){let r=e.data;e.placedJd=t;let i=r.q!=null,a;if(r.parentId===`naif-0`)a=[0,0,0];else{let t=n.getBody(r.parentId)?.position;if(!t){e.positionUnknown=!0;return}a=t}if(t<r.validityStart||t>r.validityEnd){e.positionUnknown=!0;return}let o=r.a===0&&!i&&!r.satrec?[0,0,0]:r.satrec?bg(r.satrec,t):i?Xv(r,t):Jv(r,t);if(!o){e.positionUnknown=!0;return}e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1}function OT(e,t,n){let r=e.data;if(e.placedJd=t,e.positionUnknown=!0,r.unplaceable||r.visibleFromDays!==void 0&&t-2451545<r.visibleFromDays)return;let i=n.getBody(r.parentId);if(!i||!kT(i,t,n))return;let a=i.position,o=n.chebStore?.has(r.id)?n.chebStore.positionScene(r.id,t):r.a===0?[0,0,0]:Jv(r,t);o&&(e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1)}function kT(e,t,n){let r=e.data,i=e.placedJd!==t;if(r.orbitalSource===U.SPICE_PROBE){let{hostRead:t}=n.bodies;if(!i&&!t.has(r.id))return!e.positionUnknown;if(t.has(r.id)||n.bodies.hostReadVersion++,t.set(r.id,performance.now()),i)return!1}else i&&(r.objectType===W.MOON?OT(e,t,n):!n.bodies.bodiesById.has(r.id)&&!un(e)&&DT(e,t,n));return!e.positionUnknown}function AT(e,t){if(t===0)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),e;if(t===2||t===1){let n=e.getIndex();if(n===null){let t=[],r=e.getAttribute(`position`);if(r!==void 0){for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),e}let r=n.count-2,i=[];if(t===2)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let a=e.clone();return a.setIndex(i),a.clearGroups(),a}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),e}function jT(e){let t=new Map,n=new Map,r=e.clone();return MT(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function MT(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)MT(e.children[r],t.children[r],n)}var NT=class extends Hu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new BT(e)}),this.register(function(e){return new VT(e)}),this.register(function(e){return new XT(e)}),this.register(function(e){return new ZT(e)}),this.register(function(e){return new QT(e)}),this.register(function(e){return new UT(e)}),this.register(function(e){return new WT(e)}),this.register(function(e){return new GT(e)}),this.register(function(e){return new KT(e)}),this.register(function(e){return new zT(e)}),this.register(function(e){return new qT(e)}),this.register(function(e){return new HT(e)}),this.register(function(e){return new YT(e)}),this.register(function(e){return new JT(e)}),this.register(function(e){return new LT(e)}),this.register(function(e){return new $T(e,IT.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new $T(e,IT.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new eE(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=gd.extractUrlBase(e);a=gd.resolveURL(t,this.path)}else a=gd.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new Gu(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(s.decode(new Uint8Array(e,0,4))===tE){try{a[IT.KHR_BINARY_GLTF]=new iE(e)}catch(e){r&&r(e);return}i=JSON.parse(a[IT.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new AE(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case IT.KHR_MATERIALS_UNLIT:a[t]=new RT;break;case IT.KHR_DRACO_MESH_COMPRESSION:a[t]=new aE(i,this.dracoLoader);break;case IT.KHR_TEXTURE_TRANSFORM:a[t]=new oE;break;case IT.KHR_MESH_QUANTIZATION:a[t]=new sE;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function PT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function FT(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var IT={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},LT=class{constructor(e){this.parser=e,this.name=IT.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new X(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Zr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new md(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new dd(s),o.distance=c;break;case`spot`:o=new ld(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),SE(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},RT=class{constructor(){this.name=IT.KHR_MATERIALS_UNLIT}getMaterialType(){return vs}extendParams(e,t,n){let r=[];e.color=new X(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Zr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Xr))}return Promise.all(r)}},zT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},BT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new q(e,e)}return Promise.all(r)}},VT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_DISPERSION}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},HT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},UT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_SHEEN}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new X(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Zr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Xr)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},WT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},GT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_VOLUME}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new X().setRGB(i[0],i[1],i[2],Zr),Promise.all(r)}},KT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_IOR}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},qT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_SPECULAR}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new X().setRGB(i[0],i[1],i[2],Zr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Xr)),Promise.all(r)}},JT=class{constructor(e){this.parser=e,this.name=IT.EXT_MATERIALS_BUMP}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},YT=class{constructor(e){this.parser=e,this.name=IT.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return FT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=FT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},XT=class{constructor(e){this.parser=e,this.name=IT.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},ZT=class{constructor(e){this.parser=e,this.name=IT.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},QT=class{constructor(e){this.parser=e,this.name=IT.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},$T=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}else return null}},eE=class{constructor(e){this.name=IT.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==dE.TRIANGLES&&e.mode!==dE.TRIANGLE_STRIP&&e.mode!==dE.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Y,n=new J,a=new Hi,s=new J(1,1,1),c=new nc(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));for(let t in o)if(t===`_COLOR_0`){let e=o[t];c.instanceColor=new Js(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);Ra.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},tE=`glTF`,nE=12,rE={JSON:1313821514,BIN:5130562},iE=class{constructor(e){this.name=IT.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,nE),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==tE)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-nE,i=new DataView(e,nE),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===rE.JSON){let r=new Uint8Array(e,nE+a,t);this.content=n.decode(r)}else if(r===rE.BIN){let n=nE+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},aE=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=IT.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=gE[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=gE[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=fE[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Zr,n)})})}},oE=class{constructor(){this.name=IT.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0?e:(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}},sE=class{constructor(){this.name=IT.KHR_MESH_QUANTIZATION}},cE=class extends Cu{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},lE=new Hi,uE=class extends cE{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return lE.fromArray(i).normalize().toArray(i),i}},dE={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},fE={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},pE={9728:An,9729:Nn,9984:jn,9985:Pn,9986:Mn,9987:Fn},mE={33071:On,33648:kn,10497:Dn},hE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gE={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},_E={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},vE={CUBICSPLINE:void 0,LINEAR:Hr,STEP:Vr},yE={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function bE(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new mu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function xE(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function SE(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function CE(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function wE(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function TE(e){let t,n=e.extensions&&e.extensions[IT.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+EE(n.attributes):e.indices+`:`+EE(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+EE(e.targets[n]);return t}function EE(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function DE(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function OE(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var kE=new Y,AE=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new PT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?this.textureLoader=new Ju(this.options.manager):this.textureLoader=new vd(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Gu(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return xE(i,a,r),SE(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+ e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[IT.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(gd.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=hE[r.type],t=fE[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Do(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=hE[r.type],o=fE[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new Uo(f,u/s),t.cache.add(n,c)),p=new Go(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Do(f,a,d);if(r.sparse!==void 0){let t=hE.SCALAR,n=fE[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new Do(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=pE[n.magFilter]||1006,t.minFilter=pE[n.minFilter]||1008,t.wrapS=mE[n.wrapS]||1e3,t.wrapT=mE[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new oa(e);t.needsUpdate=!0,n(t)}),t.load(gd.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),SE(e,a),e.userData.mimeType=a.mimeType||OE(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[IT.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[IT.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[IT.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Tc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new dc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return mu}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[IT.KHR_MATERIALS_UNLIT]){let e=r[IT.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new X(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Zr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Xr)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||yE.OPAQUE;if(l===yE.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===yE.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new q(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==vs){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],Zr)}return i.emissiveTexture!==void 0&&a!==vs&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Xr)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),SE(n,i),t.associations.set(n,{materials:e}),i.extensions&&xE(r,n,i),n})}createUniqueName(e){let t=Id.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[IT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return ME(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=TE(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[IT.KHR_DRACO_MESH_COMPRESSION]?i(o):ME(new Ho,o,t),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?bE(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===dE.TRIANGLES||u.mode===dE.TRIANGLE_STRIP||u.mode===dE.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Hs(l,f):new As(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===dE.TRIANGLE_STRIP?d.geometry=AT(d.geometry,1):u.mode===dE.TRIANGLE_FAN&&(d.geometry=AT(d.geometry,2));else if(u.mode===dE.LINES)d=new Cc(l,f);else if(u.mode===dE.LINE_STRIP)d=new yc(l,f);else if(u.mode===dE.LINE_LOOP)d=new wc(l,f);else if(u.mode===dE.POINTS)d=new Ac(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&wE(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),SE(d,i),u.extensions&&xE(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&xE(r,c[0],i),c[0];let l=new za;i.extensions&&xE(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return n.type===`perspective`?t=new sd(Vi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new fd(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),SE(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new Y;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new qs(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new Iu(i,void 0,l);return SE(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,kE)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new J().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new Us:t.length>1?new za:t.length===1?t[0]:new Ra,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),SE(o,i),i.extensions&&xE(n,o,i),i.matrix!==void 0){let e=new Y;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new za;n.name&&(i.name=r.createUniqueName(n.name)),SE(i,n),n.extensions&&xE(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(jT(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof qo||e instanceof oa)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];_E[i.path]===_E.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(_E[i.path]){case _E.weights:c=ju;break;case _E.rotation:c=Nu;break;case _E.translation:case _E.scale:c=Fu;break;default:switch(n.itemSize){case 1:c=ju;break;default:c=Fu;break}break}let l=r.interpolation===void 0?Hr:vE[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+_E[i.path],t.array,u,l);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=DE(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Nu?uE:cE)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function jE(e,t,n){let r=t.attributes,i=new co;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new J(t[0],t[1],t[2]),new J(a[0],a[1],a[2])),e.normalized){let t=DE(fE[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new J,t=new J;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=DE(fE[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new Po;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function ME(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=gE[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return Xi.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Xi.workingColorSpace}" not supported.`),SE(e,t),jE(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:CE(e,t.targets,n)})}var NE=(function(){var e=`b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuec:W:Odkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;lZkdbk;jYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbhodnawTmbaxa8Acd4fRbbhokaocFeGh5cbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q1jjbfcj1jjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bbarcwf9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfag9c8F1:NghcKtc8F91aicdfa8J9c8N1:Nfg8KRbbG86bbarcVfcba8KahcjeGcr4fghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fag9c8F1:NgicKtc8F91aha8J9c8N1:NfghRbbG86bbarc96fcbahaicjeGcr4fgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbb83bbarcwfaicwf8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbcbaocl49Rh8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E93aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:XseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk::ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxabaiarcefciGfcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGfgkcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkabaiarcufciGfcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkabakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K1jjbgeabcifc98GfgbBd:K1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;teeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiaeydlBdlaiaeydwBdwaiaeydxBdxaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk:3eedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdxaialBdwaialBdlaialBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk81dbcjwk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:Kwkl8WNbb`,t=`b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuec:q:6dkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:Ctklbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:183lYud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxavaialfgmar9Rgoad;8qbbcj;abad9Uc;WFbGcjdadca0EhPdndndnadTmbaoadfhscbhzinaeaz9nmdamax9RaD6miabazad2fhHaxaDfhOaPaeaz9RazaPfae6EgAcsfgocl4cifcd4hCavcj;cbfaoc9WGgXcetfhQavcj;cbfaXci2fhLavcj;cbfaXfhKcbhYaoc;ab6h8AincbhodnawTmbaxaYcd4fRbbhokaocFeGhEcbh3avcj;cbfh5indndndndnaEa3cet4ciGgoc9:fPdebdkamaO9RaX6mwavcj;cbfa3aX2faOaX;8qbbaOaAfhOxdkavcj;cbfa3aX2fcbaX;8kbxekamaO9RaC6moaoclVcbawEhraOaCfhocbhidna8Ambamao9Rc;Gb6mbcbhlina5alfhidndndndndndnaOalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiczfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaicafaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaoclffaqc:q:yjjbfRbbfhoxikaic8Wfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaocwffaqc:q:yjjbfRbbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitc:q1jjbfpbibaic:q:yjjbfRbbgipsaoRbegqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqc:q:yjjbfRbbfhokalc;abfhialcjefaX0meaihlamao9Rc;Fb0mbkkdnaiaX9pmbaici4hlinamao9RcK6mwa5aifhqdndndndndndnaOaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaoclffahc:q:yjjbfRbbfhoxikaqaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaocwffahc:q:yjjbfRbbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpkbbaaaocdffahc:q:yjjbfRbbfhokalcdfhlaiczfgiaX6mbkkaohOaoTmoka5aXfh5a3cefg3cl9hmbkdndndndnawTmbasaYcd4fRbbglciGPlbedwbkaXTmdavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep9Ta8Epxeeeeeeeeeeeeeeeeg8Fp9op9Hp9rg8Eagp9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Ug8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9AbbbaladfhlaoczfgoaX6mbxikkaXTmeavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep:nea8Epxebebebebebebebebg8Fp9op:bep9rg8Eagp:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeg8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9AbbbaladfhlaoczfgoaX6mbxdkkaXTmbcbhocbalcl4gl9Rc8FGhiavcjdfaYfhravaYfpbdbh8Finaravcj;cbfaofpblbggaKaofpblbg8JpmbzeHdOiAlCvXoQrLg8KaQaofpblbg8LaLaofpblbg8MpmbzeHdOiAlCvXoQrLg8NpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ea8Fp9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Fa8Ka8NpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwKDYq8AkEx3m5P8Es8Fgga8La8MpmwKDYq8AkEx3m5P8Es8Fg8JpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9AbbbaradfhraoczfgoaX6mbkkaYclfgYad6mbkaHavcjdfaAad2;8qbbavavcjdfaAcufad2fad;8qbbaAazfhzc9:hoaOhxaOmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdaPaeao9RaoaPfae6Eaofgoae6mbkaial9Rhxkcbc99amax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbk:TseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:2Pliur97eue978Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskaipxFubbFubbFubbFubbgxpklbdnalTmbcbhvabhdinadczfgmampbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblbaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgopklbaiaopklbaiabalcitfgdaeciGglcitgv;8qbbaiaxpkladnalTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblaaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkadaiav;8qbbkk:Iwllue97euo978Jjjjjbca9Rhidnaec98GglTmbcbhvabhoinaocKfpx:ji:1S:ji:1S:ji:1S:ji:1SaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83ibawarp5bampEd:T:j83ibaocwfaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83ibaoaxp5bampEb:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiczfpxbbbbbbbbbbbbbbbbgmpklbaiampklbaiabalcitfgoaeciGgvcitgw;8qbbdnavTmbaipx:ji:1S:ji:1S:ji:1S:ji:1SaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83iKaiarp5bampEd:T:j83izaiaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83iwaiaxp5bampEb:T:j83ibkaoaiaw;8qbbkk;uddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaic8WfpxbbbbbbbbbbbbbbbbgopklbaicafaopklbaiczfaopklbaiaopklbaiabavcdtfgdalciGgecdtgv;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkadaiav;8qbbkk:CPvdue97euw97eu8Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadpbbbhradpxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpkbbadczfhdaoclfgoal6mbkkalaeSmeaiavpklaaicafabalcdtfgdaeciGglcdtgo;8qbbaiavpklbdnalTmbaipblahraipxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpklakadaicafao;8qbbskaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadczfgspxbFu9hbFu9hbFu9hbFu9hadpbbbgDaspbbbgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblbp9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpkbbadaxarpmbezHdiOAlvCXorQLpkbbadcafhdaoclfgoal6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgrpklbaiarpklbaiabalcitfgdaeciGglcitgo;8qbbaiavpkladnalTmbaipxbFu9hbFu9hbFu9hbFu9haipblbgDaipblzgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblap9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpklzaiaxarpmbezHdiOAlvCXorQLpklbkadaiao;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb`,n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),r=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=`object`)return{supported:!1};var i=WebAssembly.validate(n)?s(t):s(e),a,o=WebAssembly.instantiate(i,{}).then(function(e){a=e.instance,a.exports.__wasm_call_ctors()});function s(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;++n){var i=e.charCodeAt(n);t[n]=i>96?i-97:i>64?i-39:i+4}for(var a=0,n=0;n<e.length;++n)t[a++]=t[n]<60?r[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,a)}function c(e,t,n,r,i,a,o){var s=e.exports.sbrk,c=r+3&-4,l=s(c*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var f=t(l,r,i,u,a.length);if(f==0&&o&&o(l,c,i),n.set(d.subarray(l,l+r*i)),s(l-s(0)),f!=0)throw Error(`Malformed buffer data: `+f)}var l={NONE:``,OCTAHEDRAL:`meshopt_decodeFilterOct`,QUATERNION:`meshopt_decodeFilterQuat`,EXPONENTIAL:`meshopt_decodeFilterExp`,COLOR:`meshopt_decodeFilterColor`},u={ATTRIBUTES:`meshopt_decodeVertexBuffer`,TRIANGLES:`meshopt_decodeIndexBuffer`,INDICES:`meshopt_decodeIndexSequence`},d=[],f=0;function p(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function m(e){for(var t=`self.ready = WebAssembly.instantiate(new Uint8Array([`+new Uint8Array(i)+`]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = `+g.name+`;`+c.toString()+g.toString(),n=new Blob([t],{type:`text/javascript`}),r=URL.createObjectURL(n),a=d.length;a<e;++a)d[a]=p(r);for(var a=e;a<d.length;++a)d[a].object.postMessage({});d.length=e,URL.revokeObjectURL(r)}function h(e,t,n,r,i){for(var a=d[0],o=1;o<d.length;++o)d[o].pending<a.pending&&(a=d[o]);return new Promise(function(o,s){var c=new Uint8Array(n),l=++f;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}function g(e){var t=e.data;if(!t.id)return self.close();self.ready.then(function(e){try{var n=new Uint8Array(t.count*t.size);c(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:`resolve`,value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:`reject`,value:e})}})}return{ready:o,supported:!0,useWorkers:function(e){m(e)},decodeVertexBuffer:function(e,t,n,r,i){c(a,a.exports.meshopt_decodeVertexBuffer,e,t,n,r,a.exports[l[i]])},decodeIndexBuffer:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexBuffer,e,t,n,r)},decodeIndexSequence:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexSequence,e,t,n,r)},decodeGltfBuffer:function(e,t,n,r,i,o){c(a,a.exports[u[i]],e,t,n,r,a.exports[l[o]])},decodeGltfBufferAsync:function(e,t,n,r,i){return d.length>0?h(e,t,n,u[r],l[i]):o.then(function(){var o=new Uint8Array(e*t);return c(a,a.exports[u[r]],o,e,t,n,a.exports[l[i]]),o})}}})(),PE=1230263361,FE=2,IE=16,LE=11,RE=32767,zE=86400;function BE(e){let t=new DataView(e);if(t.getUint32(0,!0)!==PE)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==FE)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-IE)/LE),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=IE+e*LE;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/zE;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/RE,l=t.getInt16(n+7,!0)/RE,u=t.getInt16(n+9,!0)/RE,d=Math.sqrt(Math.max(0,1-c*c-l*l-u*u)),f=e*4,p=0;for(let e=0;e<4;e++)e===i?o[f+e]=d:(o[f+e]=p===0?c:p===1?l:u,p++)}return{times:a,quats:o}}var VE=86400,HE=new Hi().setFromRotationMatrix(new Y().makeBasis(dg(1,0,0,new J),dg(0,1,0,new J),dg(0,0,1,new J))),UE=new Hi,WE=new Hi,GE=new Hi,KE=new J;function qE(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var JE=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;failed=new Set;constructor(e,t){this.probeId=e,this.startJd=t.files.length?t.files[0].start_jd:0,this.endJd=t.files.length?t.files[t.files.length-1].end_jd:0,this.baselines=t.baselines,this.files=t.files}covers(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){if(!this.covers(e))return!1;let n=this.fileIndexFor(e),r=this.ensure(n);if(!r)return!1;this.ensure(n-1),this.ensure(n+1),this.sampleChunk(e,n,r);let i=this.baselines?.[this.files[n].baseline_index??0];if(i){let{axis:t,rate_rad_s:n,anchor:r,anchor_jd:a}=i,o=(e-a)*VE;KE.set(t[0],t[1],t[2]),GE.setFromAxisAngle(KE,n*o),WE.set(r[1],r[2],r[3],r[0]),GE.multiply(WE),UE.copy(GE.multiply(UE))}return UE.conjugate(),t.copy(HE).multiply(UE),!0}fileIndexFor(e){let t=this.files;if(e<=t[0].start_jd)return 0;let n=0,r=t.length-1;for(;r-n>1;){let i=n+r>>1;t[i].start_jd<=e?n=i:r=i}return t[r].start_jd<=e?r:n}sampleChunk(e,t,n){let{times:r,quats:i}=n,a=r.length;if(e<=r[0]){qE(i,0,UE);return}if(e>=r[a-1]){let n=this.chunks.get(t+1);if(this.files[t+1]?.baseline_index===this.files[t].baseline_index&&n&&n.times.length>0&&n.times[0]>r[a-1]){let t=n.times[0]-r[a-1],o=Math.min(1,(e-r[a-1])/t);qE(i,a-1,UE),qE(n.quats,0,WE),UE.slerpQuaternions(UE,WE,o)}else qE(i,a-1,UE);return}let o=0,s=a-1;for(;s-o>1;){let t=o+s>>1;r[t]<=e?o=t:s=t}let c=r[s]-r[o],l=c>0?(e-r[o])/c:0;qE(i,o,UE),qE(i,s,WE),UE.slerpQuaternions(UE,WE,l)}ensure(e){if(e<0||e>=this.files.length)return;let t=this.chunks.get(e);if(t)return t;this.inflight.has(e)||this.failed.has(e)||(this.inflight.add(e),this.load(e))}async load(e){let t=this.files[e];try{let n=await fetch(`${Kt()}/v1/attitude/${this.probeId}/${t.name}`);if(!n.ok)throw Error(`${n.status}`);let r=new DecompressionStream(`gzip`),i=await new Response(n.body.pipeThrough(r)).arrayBuffer();this.chunks.set(e,BE(i))}catch(n){this.failed.add(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function YE(e,t){return new JE(e,t)}var XE=[`carrier`,`missing`],ZE=`scene-label__annotation--visible`;function QE(e,t,n){let r=e.labelAnnotations?.[t];if(!r){if(!n||!e.label)return;r=document.createElement(`span`),r.className=`scene-label__annotation`,r.dir=`auto`,r.textContent=n,tD(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(ZE))return}else if(r.textContent===n&&r.classList.contains(ZE))return;else r.textContent=n;r.classList.toggle(ZE,n!==null),$E(e)}function $E(e){let t=e.label?.element;if(!t)return;let n=[t.querySelector(`.scene-label__name`)?.textContent||e.body.data.name];for(let t of XE){let r=e.labelAnnotations?.[t];r?.classList.contains(ZE)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function eD(e){if(!e.labelStack){let t=document.createElement(`span`);t.className=`scene-label__annotations`,e.label.element.appendChild(t),e.labelStack=t}return e.labelStack}function tD(e,t,n){for(let r of XE.slice(XE.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}eD(e).appendChild(t)}function nD(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=sD(e,t);return n.tintBase=i,n.tintKey=r,i}var rD=32,iD=16,aD=.01,oD=.001;function sD(e,t){let n=new X(16777215);if(!t)return n;let r=cD(e);if(r===null||r>aD)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<oD?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function cD(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=rD,n.height=iD;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,rD,iD);let i;try{i=r.getImageData(0,0,rD,iD).data}catch{return null}let a=0,o=i.length/4;for(let e=0;e<i.length;e+=4){let t=i[e]/255,n=i[e+1]/255,r=i[e+2]/255;a+=Math.max(t,n,r)-Math.min(t,n,r)}return a/o}var lD=`
|
|
4532
|
+
`})}var vT=class extends qa{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Lc;e.deleteAttribute(`uv`);let t=new mu({side:1}),n=new mu,r=new dd(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new As(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new nc(e,n,6),o=new Ra;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);let s=new As(e,yT(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new As(e,yT(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new As(e,yT(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new As(e,yT(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new As(e,yT(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new As(e,yT(100));f.position.set(0,20,0),f.scale.set(1,.1,1),this.add(f)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function yT(e){return new gu({color:0,emissive:16777215,emissiveIntensity:e})}var bT=.01,xT=3.5,ST=.04;function CT(e){let t=Math.max(e/10,.01);return 1/(t*t)}function wT(e,t,n=1){e.decay=t?2:0,e.intensity=(t?xT*10*10:xT)*n}function TT(e){let t=new yf(e),n=t.fromScene(new vT).texture;return t.dispose(),n}var ET=1e5;function DT(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var OT=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function kT(e,t,n){let r,i=DT();i||sT();try{r=new dh(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new OT(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),rT(r.capabilities.reversedDepthBuffer);let a=Yx();r.setPixelRatio(Xx()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,hT(e.clientWidth,e.clientHeight);let o=new dT({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new qa,c=new hd(16777215,bT);s.add(c);let l=new md(16777215,0);l.castShadow=!1,l.shadow.mapSize.set(a.shadowMapSize,a.shadowMapSize),l.shadow.bias=-1e-4,s.add(l),s.add(l.target);let u=new sd(60,e.clientWidth/e.clientHeight,Q(.001),ET),d=r.capabilities.reversedDepthBuffer?new la(e.clientWidth,e.clientHeight,{type:Un,depthTexture:new Pc(e.clientWidth,e.clientHeight,Hn)}):void 0,f=new Xw(r,d);f.setPixelRatio(Xx()),f.setSize(e.clientWidth,e.clientHeight),f.addPass(new Zw(s,u));let p=new $w(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);return f.addPass(p),f.addPass(new tT),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:f,bloomPass:p,ambientLight:c,shadowLight:l}}function AT(e,t,n){let r=e.data;e.placedJd=t;let i=r.q!=null,a;if(r.parentId===`naif-0`)a=[0,0,0];else{let t=n.getBody(r.parentId)?.position;if(!t){e.positionUnknown=!0;return}a=t}if(t<r.validityStart||t>r.validityEnd){e.positionUnknown=!0;return}let o=r.a===0&&!i&&!r.satrec?[0,0,0]:r.satrec?bg(r.satrec,t):i?Xv(r,t):Jv(r,t);if(!o){e.positionUnknown=!0;return}e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1}function jT(e,t,n){let r=e.data;if(e.placedJd=t,e.positionUnknown=!0,r.unplaceable||r.visibleFromDays!==void 0&&t-2451545<r.visibleFromDays)return;let i=n.getBody(r.parentId);if(!i||!MT(i,t,n))return;let a=i.position,o=n.chebStore?.has(r.id)?n.chebStore.positionScene(r.id,t):r.a===0?[0,0,0]:Jv(r,t);o&&(e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1)}function MT(e,t,n){let r=e.data,i=e.placedJd!==t;if(r.orbitalSource===U.SPICE_PROBE){let{hostRead:t}=n.bodies;if(!i&&!t.has(r.id))return!e.positionUnknown;if(t.has(r.id)||n.bodies.hostReadVersion++,t.set(r.id,performance.now()),i)return!1}else i&&(r.objectType===W.MOON?jT(e,t,n):!n.bodies.bodiesById.has(r.id)&&!un(e)&&AT(e,t,n));return!e.positionUnknown}function NT(e,t){if(t===0)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),e;if(t===2||t===1){let n=e.getIndex();if(n===null){let t=[],r=e.getAttribute(`position`);if(r!==void 0){for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),e}let r=n.count-2,i=[];if(t===2)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let a=e.clone();return a.setIndex(i),a.clearGroups(),a}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),e}function PT(e){let t=new Map,n=new Map,r=e.clone();return FT(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function FT(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)FT(e.children[r],t.children[r],n)}var IT=class extends Hu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new UT(e)}),this.register(function(e){return new WT(e)}),this.register(function(e){return new $T(e)}),this.register(function(e){return new eE(e)}),this.register(function(e){return new tE(e)}),this.register(function(e){return new KT(e)}),this.register(function(e){return new qT(e)}),this.register(function(e){return new JT(e)}),this.register(function(e){return new YT(e)}),this.register(function(e){return new HT(e)}),this.register(function(e){return new XT(e)}),this.register(function(e){return new GT(e)}),this.register(function(e){return new QT(e)}),this.register(function(e){return new ZT(e)}),this.register(function(e){return new BT(e)}),this.register(function(e){return new nE(e,zT.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new nE(e,zT.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new rE(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=gd.extractUrlBase(e);a=gd.resolveURL(t,this.path)}else a=gd.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new Gu(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(s.decode(new Uint8Array(e,0,4))===iE){try{a[zT.KHR_BINARY_GLTF]=new sE(e)}catch(e){r&&r(e);return}i=JSON.parse(a[zT.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new NE(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case zT.KHR_MATERIALS_UNLIT:a[t]=new VT;break;case zT.KHR_DRACO_MESH_COMPRESSION:a[t]=new cE(i,this.dracoLoader);break;case zT.KHR_TEXTURE_TRANSFORM:a[t]=new lE;break;case zT.KHR_MESH_QUANTIZATION:a[t]=new uE;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function LT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function RT(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var zT={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},BT=class{constructor(e){this.parser=e,this.name=zT.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new X(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Zr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new md(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new dd(s),o.distance=c;break;case`spot`:o=new ld(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),TE(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},VT=class{constructor(){this.name=zT.KHR_MATERIALS_UNLIT}getMaterialType(){return vs}extendParams(e,t,n){let r=[];e.color=new X(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Zr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Xr))}return Promise.all(r)}},HT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},UT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new q(e,e)}return Promise.all(r)}},WT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_DISPERSION}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},GT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},KT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_SHEEN}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new X(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Zr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Xr)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},qT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},JT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_VOLUME}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new X().setRGB(i[0],i[1],i[2],Zr),Promise.all(r)}},YT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_IOR}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},XT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_SPECULAR}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new X().setRGB(i[0],i[1],i[2],Zr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Xr)),Promise.all(r)}},ZT=class{constructor(e){this.parser=e,this.name=zT.EXT_MATERIALS_BUMP}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},QT=class{constructor(e){this.parser=e,this.name=zT.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return RT(this.parser,e,this.name)===null?null:hu}extendMaterialParams(e,t){let n=RT(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},$T=class{constructor(e){this.parser=e,this.name=zT.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},eE=class{constructor(e){this.parser=e,this.name=zT.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},tE=class{constructor(e){this.parser=e,this.name=zT.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},nE=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}else return null}},rE=class{constructor(e){this.name=zT.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==mE.TRIANGLES&&e.mode!==mE.TRIANGLE_STRIP&&e.mode!==mE.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Y,n=new J,a=new Hi,s=new J(1,1,1),c=new nc(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));for(let t in o)if(t===`_COLOR_0`){let e=o[t];c.instanceColor=new Js(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);Ra.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},iE=`glTF`,aE=12,oE={JSON:1313821514,BIN:5130562},sE=class{constructor(e){this.name=zT.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,aE),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==iE)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-aE,i=new DataView(e,aE),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===oE.JSON){let r=new Uint8Array(e,aE+a,t);this.content=n.decode(r)}else if(r===oE.BIN){let n=aE+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},cE=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=zT.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=yE[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=yE[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=hE[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Zr,n)})})}},lE=class{constructor(){this.name=zT.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0?e:(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}},uE=class{constructor(){this.name=zT.KHR_MESH_QUANTIZATION}},dE=class extends Cu{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},fE=new Hi,pE=class extends dE{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return fE.fromArray(i).normalize().toArray(i),i}},mE={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},hE={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},gE={9728:An,9729:Nn,9984:jn,9985:Pn,9986:Mn,9987:Fn},_E={33071:On,33648:kn,10497:Dn},vE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yE={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},bE={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},xE={CUBICSPLINE:void 0,LINEAR:Hr,STEP:Vr},SE={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function CE(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new mu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function wE(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function TE(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function EE(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function DE(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function OE(e){let t,n=e.extensions&&e.extensions[zT.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+kE(n.attributes):e.indices+`:`+kE(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+kE(e.targets[n]);return t}function kE(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function AE(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function jE(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var ME=new Y,NE=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new LT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?this.textureLoader=new Ju(this.options.manager):this.textureLoader=new vd(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Gu(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return wE(i,a,r),TE(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+ e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[zT.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(gd.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=vE[r.type],t=hE[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Do(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=vE[r.type],o=hE[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new Uo(f,u/s),t.cache.add(n,c)),p=new Go(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Do(f,a,d);if(r.sparse!==void 0){let t=vE.SCALAR,n=hE[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new Do(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=gE[n.magFilter]||1006,t.minFilter=gE[n.minFilter]||1008,t.wrapS=_E[n.wrapS]||1e3,t.wrapT=_E[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new oa(e);t.needsUpdate=!0,n(t)}),t.load(gd.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),TE(e,a),e.userData.mimeType=a.mimeType||jE(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[zT.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[zT.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[zT.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Tc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new dc,qo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return mu}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[zT.KHR_MATERIALS_UNLIT]){let e=r[zT.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new X(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Zr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Xr)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||SE.OPAQUE;if(l===SE.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===SE.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new q(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==vs&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==vs){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],Zr)}return i.emissiveTexture!==void 0&&a!==vs&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Xr)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),TE(n,i),t.associations.set(n,{materials:e}),i.extensions&&wE(r,n,i),n})}createUniqueName(e){let t=Id.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[zT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return FE(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=OE(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[zT.KHR_DRACO_MESH_COMPRESSION]?i(o):FE(new Ho,o,t),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?CE(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===mE.TRIANGLES||u.mode===mE.TRIANGLE_STRIP||u.mode===mE.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Hs(l,f):new As(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===mE.TRIANGLE_STRIP?d.geometry=NT(d.geometry,1):u.mode===mE.TRIANGLE_FAN&&(d.geometry=NT(d.geometry,2));else if(u.mode===mE.LINES)d=new Cc(l,f);else if(u.mode===mE.LINE_STRIP)d=new yc(l,f);else if(u.mode===mE.LINE_LOOP)d=new wc(l,f);else if(u.mode===mE.POINTS)d=new Ac(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&DE(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),TE(d,i),u.extensions&&wE(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&wE(r,c[0],i),c[0];let l=new za;i.extensions&&wE(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return n.type===`perspective`?t=new sd(Vi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new fd(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),TE(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new Y;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new qs(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new Iu(i,void 0,l);return TE(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,ME)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new J().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new Us:t.length>1?new za:t.length===1?t[0]:new Ra,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),TE(o,i),i.extensions&&wE(n,o,i),i.matrix!==void 0){let e=new Y;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new za;n.name&&(i.name=r.createUniqueName(n.name)),TE(i,n),n.extensions&&wE(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(PT(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof qo||e instanceof oa)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];bE[i.path]===bE.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(bE[i.path]){case bE.weights:c=ju;break;case bE.rotation:c=Nu;break;case bE.translation:case bE.scale:c=Fu;break;default:switch(n.itemSize){case 1:c=ju;break;default:c=Fu;break}break}let l=r.interpolation===void 0?Hr:xE[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+bE[i.path],t.array,u,l);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=AE(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Nu?pE:dE)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function PE(e,t,n){let r=t.attributes,i=new co;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new J(t[0],t[1],t[2]),new J(a[0],a[1],a[2])),e.normalized){let t=AE(hE[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new J,t=new J;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=AE(hE[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new Po;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function FE(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=yE[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return Xi.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Xi.workingColorSpace}" not supported.`),TE(e,t),PE(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:EE(e,t.targets,n)})}var IE=(function(){var e=`b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuec:W:Odkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;lZkdbk;jYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbhodnawTmbaxa8Acd4fRbbhokaocFeGh5cbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q1jjbfcj1jjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bbarcwf9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfag9c8F1:NghcKtc8F91aicdfa8J9c8N1:Nfg8KRbbG86bbarcVfcba8KahcjeGcr4fghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fag9c8F1:NgicKtc8F91aha8J9c8N1:NfghRbbG86bbarc96fcbahaicjeGcr4fgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbb83bbarcwfaicwf8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbcbaocl49Rh8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E93aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:XseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk::ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxabaiarcefciGfcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGfgkcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkabaiarcufciGfcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkabakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K1jjbgeabcifc98GfgbBd:K1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;teeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiaeydlBdlaiaeydwBdwaiaeydxBdxaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk:3eedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdxaialBdwaialBdlaialBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk81dbcjwk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:Kwkl8WNbb`,t=`b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuec:q:6dkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:Ctklbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:183lYud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxavaialfgmar9Rgoad;8qbbcj;abad9Uc;WFbGcjdadca0EhPdndndnadTmbaoadfhscbhzinaeaz9nmdamax9RaD6miabazad2fhHaxaDfhOaPaeaz9RazaPfae6EgAcsfgocl4cifcd4hCavcj;cbfaoc9WGgXcetfhQavcj;cbfaXci2fhLavcj;cbfaXfhKcbhYaoc;ab6h8AincbhodnawTmbaxaYcd4fRbbhokaocFeGhEcbh3avcj;cbfh5indndndndnaEa3cet4ciGgoc9:fPdebdkamaO9RaX6mwavcj;cbfa3aX2faOaX;8qbbaOaAfhOxdkavcj;cbfa3aX2fcbaX;8kbxekamaO9RaC6moaoclVcbawEhraOaCfhocbhidna8Ambamao9Rc;Gb6mbcbhlina5alfhidndndndndndnaOalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiczfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaicafaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaoclffaqc:q:yjjbfRbbfhoxikaic8Wfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaocwffaqc:q:yjjbfRbbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitc:q1jjbfpbibaic:q:yjjbfRbbgipsaoRbegqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqc:q:yjjbfRbbfhokalc;abfhialcjefaX0meaihlamao9Rc;Fb0mbkkdnaiaX9pmbaici4hlinamao9RcK6mwa5aifhqdndndndndndnaOaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaoclffahc:q:yjjbfRbbfhoxikaqaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaocwffahc:q:yjjbfRbbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpkbbaaaocdffahc:q:yjjbfRbbfhokalcdfhlaiczfgiaX6mbkkaohOaoTmoka5aXfh5a3cefg3cl9hmbkdndndndnawTmbasaYcd4fRbbglciGPlbedwbkaXTmdavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep9Ta8Epxeeeeeeeeeeeeeeeeg8Fp9op9Hp9rg8Eagp9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Ug8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9AbbbaladfhlaoczfgoaX6mbxikkaXTmeavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep:nea8Epxebebebebebebebebg8Fp9op:bep9rg8Eagp:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeg8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9AbbbaladfhlaoczfgoaX6mbxdkkaXTmbcbhocbalcl4gl9Rc8FGhiavcjdfaYfhravaYfpbdbh8Finaravcj;cbfaofpblbggaKaofpblbg8JpmbzeHdOiAlCvXoQrLg8KaQaofpblbg8LaLaofpblbg8MpmbzeHdOiAlCvXoQrLg8NpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ea8Fp9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Fa8Ka8NpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwKDYq8AkEx3m5P8Es8Fgga8La8MpmwKDYq8AkEx3m5P8Es8Fg8JpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9AbbbaradfhraoczfgoaX6mbkkaYclfgYad6mbkaHavcjdfaAad2;8qbbavavcjdfaAcufad2fad;8qbbaAazfhzc9:hoaOhxaOmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdaPaeao9RaoaPfae6Eaofgoae6mbkaial9Rhxkcbc99amax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbk:TseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:2Pliur97eue978Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskaipxFubbFubbFubbFubbgxpklbdnalTmbcbhvabhdinadczfgmampbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblbaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgopklbaiaopklbaiabalcitfgdaeciGglcitgv;8qbbaiaxpkladnalTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblaaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkadaiav;8qbbkk:Iwllue97euo978Jjjjjbca9Rhidnaec98GglTmbcbhvabhoinaocKfpx:ji:1S:ji:1S:ji:1S:ji:1SaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83ibawarp5bampEd:T:j83ibaocwfaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83ibaoaxp5bampEb:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiczfpxbbbbbbbbbbbbbbbbgmpklbaiampklbaiabalcitfgoaeciGgvcitgw;8qbbdnavTmbaipx:ji:1S:ji:1S:ji:1S:ji:1SaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83iKaiarp5bampEd:T:j83izaiaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83iwaiaxp5bampEb:T:j83ibkaoaiaw;8qbbkk;uddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaic8WfpxbbbbbbbbbbbbbbbbgopklbaicafaopklbaiczfaopklbaiaopklbaiabavcdtfgdalciGgecdtgv;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkadaiav;8qbbkk:CPvdue97euw97eu8Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadpbbbhradpxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpkbbadczfhdaoclfgoal6mbkkalaeSmeaiavpklaaicafabalcdtfgdaeciGglcdtgo;8qbbaiavpklbdnalTmbaipblahraipxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpklakadaicafao;8qbbskaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadczfgspxbFu9hbFu9hbFu9hbFu9hadpbbbgDaspbbbgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblbp9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpkbbadaxarpmbezHdiOAlvCXorQLpkbbadcafhdaoclfgoal6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgrpklbaiarpklbaiabalcitfgdaeciGglcitgo;8qbbaiavpkladnalTmbaipxbFu9hbFu9hbFu9hbFu9haipblbgDaipblzgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblap9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpklzaiaxarpmbezHdiOAlvCXorQLpklbkadaiao;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb`,n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),r=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=`object`)return{supported:!1};var i=WebAssembly.validate(n)?s(t):s(e),a,o=WebAssembly.instantiate(i,{}).then(function(e){a=e.instance,a.exports.__wasm_call_ctors()});function s(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;++n){var i=e.charCodeAt(n);t[n]=i>96?i-97:i>64?i-39:i+4}for(var a=0,n=0;n<e.length;++n)t[a++]=t[n]<60?r[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,a)}function c(e,t,n,r,i,a,o){var s=e.exports.sbrk,c=r+3&-4,l=s(c*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var f=t(l,r,i,u,a.length);if(f==0&&o&&o(l,c,i),n.set(d.subarray(l,l+r*i)),s(l-s(0)),f!=0)throw Error(`Malformed buffer data: `+f)}var l={NONE:``,OCTAHEDRAL:`meshopt_decodeFilterOct`,QUATERNION:`meshopt_decodeFilterQuat`,EXPONENTIAL:`meshopt_decodeFilterExp`,COLOR:`meshopt_decodeFilterColor`},u={ATTRIBUTES:`meshopt_decodeVertexBuffer`,TRIANGLES:`meshopt_decodeIndexBuffer`,INDICES:`meshopt_decodeIndexSequence`},d=[],f=0;function p(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function m(e){for(var t=`self.ready = WebAssembly.instantiate(new Uint8Array([`+new Uint8Array(i)+`]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = `+g.name+`;`+c.toString()+g.toString(),n=new Blob([t],{type:`text/javascript`}),r=URL.createObjectURL(n),a=d.length;a<e;++a)d[a]=p(r);for(var a=e;a<d.length;++a)d[a].object.postMessage({});d.length=e,URL.revokeObjectURL(r)}function h(e,t,n,r,i){for(var a=d[0],o=1;o<d.length;++o)d[o].pending<a.pending&&(a=d[o]);return new Promise(function(o,s){var c=new Uint8Array(n),l=++f;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}function g(e){var t=e.data;if(!t.id)return self.close();self.ready.then(function(e){try{var n=new Uint8Array(t.count*t.size);c(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:`resolve`,value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:`reject`,value:e})}})}return{ready:o,supported:!0,useWorkers:function(e){m(e)},decodeVertexBuffer:function(e,t,n,r,i){c(a,a.exports.meshopt_decodeVertexBuffer,e,t,n,r,a.exports[l[i]])},decodeIndexBuffer:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexBuffer,e,t,n,r)},decodeIndexSequence:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexSequence,e,t,n,r)},decodeGltfBuffer:function(e,t,n,r,i,o){c(a,a.exports[u[i]],e,t,n,r,a.exports[l[o]])},decodeGltfBufferAsync:function(e,t,n,r,i){return d.length>0?h(e,t,n,u[r],l[i]):o.then(function(){var o=new Uint8Array(e*t);return c(a,a.exports[u[r]],o,e,t,n,a.exports[l[i]]),o})}}})(),LE=1230263361,RE=2,zE=16,BE=11,VE=32767,HE=86400;function UE(e){let t=new DataView(e);if(t.getUint32(0,!0)!==LE)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==RE)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-zE)/BE),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=zE+e*BE;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/HE;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/VE,l=t.getInt16(n+7,!0)/VE,u=t.getInt16(n+9,!0)/VE,d=Math.sqrt(Math.max(0,1-c*c-l*l-u*u)),f=e*4,p=0;for(let e=0;e<4;e++)e===i?o[f+e]=d:(o[f+e]=p===0?c:p===1?l:u,p++)}return{times:a,quats:o}}var WE=86400,GE=new Hi().setFromRotationMatrix(new Y().makeBasis(dg(1,0,0,new J),dg(0,1,0,new J),dg(0,0,1,new J))),KE=new Hi,qE=new Hi,JE=new Hi,YE=new J;function XE(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var ZE=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;failed=new Set;constructor(e,t){this.probeId=e,this.startJd=t.files.length?t.files[0].start_jd:0,this.endJd=t.files.length?t.files[t.files.length-1].end_jd:0,this.baselines=t.baselines,this.files=t.files}covers(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){if(!this.covers(e))return!1;let n=this.fileIndexFor(e),r=this.ensure(n);if(!r)return!1;this.ensure(n-1),this.ensure(n+1),this.sampleChunk(e,n,r);let i=this.baselines?.[this.files[n].baseline_index??0];if(i){let{axis:t,rate_rad_s:n,anchor:r,anchor_jd:a}=i,o=(e-a)*WE;YE.set(t[0],t[1],t[2]),JE.setFromAxisAngle(YE,n*o),qE.set(r[1],r[2],r[3],r[0]),JE.multiply(qE),KE.copy(JE.multiply(KE))}return KE.conjugate(),t.copy(GE).multiply(KE),!0}fileIndexFor(e){let t=this.files;if(e<=t[0].start_jd)return 0;let n=0,r=t.length-1;for(;r-n>1;){let i=n+r>>1;t[i].start_jd<=e?n=i:r=i}return t[r].start_jd<=e?r:n}sampleChunk(e,t,n){let{times:r,quats:i}=n,a=r.length;if(e<=r[0]){XE(i,0,KE);return}if(e>=r[a-1]){let n=this.chunks.get(t+1);if(this.files[t+1]?.baseline_index===this.files[t].baseline_index&&n&&n.times.length>0&&n.times[0]>r[a-1]){let t=n.times[0]-r[a-1],o=Math.min(1,(e-r[a-1])/t);XE(i,a-1,KE),XE(n.quats,0,qE),KE.slerpQuaternions(KE,qE,o)}else XE(i,a-1,KE);return}let o=0,s=a-1;for(;s-o>1;){let t=o+s>>1;r[t]<=e?o=t:s=t}let c=r[s]-r[o],l=c>0?(e-r[o])/c:0;XE(i,o,KE),XE(i,s,qE),KE.slerpQuaternions(KE,qE,l)}ensure(e){if(e<0||e>=this.files.length)return;let t=this.chunks.get(e);if(t)return t;this.inflight.has(e)||this.failed.has(e)||(this.inflight.add(e),this.load(e))}async load(e){let t=this.files[e];try{let n=await fetch(`${Kt()}/v1/attitude/${this.probeId}/${t.name}`);if(!n.ok)throw Error(`${n.status}`);let r=new DecompressionStream(`gzip`),i=await new Response(n.body.pipeThrough(r)).arrayBuffer();this.chunks.set(e,UE(i))}catch(n){this.failed.add(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function QE(e,t){return new ZE(e,t)}var $E=[`carrier`,`missing`],eD=`scene-label__annotation--visible`;function tD(e,t,n){let r=e.labelAnnotations?.[t];if(!r){if(!n||!e.label)return;r=document.createElement(`span`),r.className=`scene-label__annotation`,r.dir=`auto`,r.textContent=n,iD(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(eD))return}else if(r.textContent===n&&r.classList.contains(eD))return;else r.textContent=n;r.classList.toggle(eD,n!==null),nD(e)}function nD(e){let t=e.label?.element;if(!t)return;let n=[t.querySelector(`.scene-label__name`)?.textContent||e.body.data.name];for(let t of $E){let r=e.labelAnnotations?.[t];r?.classList.contains(eD)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function rD(e){if(!e.labelStack){let t=document.createElement(`span`);t.className=`scene-label__annotations`,e.label.element.appendChild(t),e.labelStack=t}return e.labelStack}function iD(e,t,n){for(let r of $E.slice($E.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}rD(e).appendChild(t)}function aD(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=uD(e,t);return n.tintBase=i,n.tintKey=r,i}var oD=32,sD=16,cD=.01,lD=.001;function uD(e,t){let n=new X(16777215);if(!t)return n;let r=dD(e);if(r===null||r>cD)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<lD?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function dD(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=oD,n.height=sD;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,oD,sD);let i;try{i=r.getImageData(0,0,oD,sD).data}catch{return null}let a=0,o=i.length/4;for(let e=0;e<i.length;e+=4){let t=i[e]/255,n=i[e+1]/255,r=i[e+2]/255;a+=Math.max(t,n,r)-Math.min(t,n,r)}return a/o}var fD=`
|
|
4522
4533
|
#ifdef USE_MAP
|
|
4523
4534
|
vec3 bodyDir = normalize( vBodyDir );
|
|
4524
4535
|
float lon = atan( -bodyDir.z, bodyDir.x );
|
|
@@ -4530,14 +4541,14 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
|
|
|
4530
4541
|
vec4 sampledDiffuseColor = textureGrad( map, euv, seam ? dxB : dxA, seam ? dyB : dyA );
|
|
4531
4542
|
diffuseColor *= sampledDiffuseColor;
|
|
4532
4543
|
#endif
|
|
4533
|
-
`;function
|
|
4544
|
+
`;function pD(e){let t=new mu({color:e,roughness:1,metalness:0});return t.onBeforeCompile=e=>{e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
4534
4545
|
varying vec3 vBodyDir;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
4535
4546
|
vBodyDir = position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
4536
|
-
varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,
|
|
4547
|
+
varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,fD).replace(`#include <envmap_physical_pars_fragment>`,`
|
|
4537
4548
|
#ifdef USE_ENVMAP
|
|
4538
4549
|
vec3 getIBLIrradiance( const in vec3 normal ) { return vec3( 0.0 ); }
|
|
4539
4550
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { return vec3( 0.0 ); }
|
|
4540
|
-
#endif`)},PC(t,`shapeModel`),t}function dD(e,t){e.traverse(e=>{if(!(e instanceof As))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function fD(e,t,n,r){e.traverse(e=>{!(e instanceof As)||!(e.material instanceof mu)||(e.material.map=t,t?e.material.color.copy(nD(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function pD(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=Xr,e.map=t,e.color.copy(nD(t,n)),e.needsUpdate=!0}var mD=new Set([]);function hD(e){return e?.model_name?Hx()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!mD.has(e.id)?`dem-preferred`:null:`no-bundle`}function gD(e,t,n,r){e.body.orientation=t,n?.credits.registerOrientation({bodyId:e.body.data.id,systemId:r??e.body.data.id,source:t.source,reference:t.reference})}var _D=48,vD=96,yD=_D*vD,bD=1<<24,xD=Math.PI*2;function SD(e){let t=Math.floor((e+1)/2*_D);return Math.min(_D-1,Math.max(0,t))}function CD(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/xD*vD)%vD+vD)%vD}var wD=new J;function TD(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)wD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=wD.x,r[i*3+1]=wD.y,r[i*3+2]=wD.z,n[i]=SD(wD.y)*vD+CD(wD.x,wD.z);return{cells:n,dirs:r}}function ED(e,t){let n=e.geometry.attributes.position,r=new Y().multiplyMatrices(t,e.matrixWorld),i=new Float32Array(n.count*3);for(let e=0;e<n.count;e++)wD.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=wD.x,i[e*3+1]=wD.y,i[e*3+2]=wD.z;return i}var DD=new J,OD=new J,kD=new J,AD=new J,jD=new J,MD=new J;function ND(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function PD(e,t,n,r){return MD.crossVectors(e,n).dot(r)>=0&&MD.crossVectors(n,t).dot(r)>=0}function FD(e,t,n){AD.crossVectors(e,t);let r=AD.lengthSq();r<1e-18||(jD.set(0,1,0).addScaledVector(AD,-AD.y/r).normalize(),PD(e,t,jD,AD)&&(n.hi=Math.max(n.hi,SD(jD.y))),jD.negate(),PD(e,t,jD,AD)&&(n.lo=Math.min(n.lo,SD(jD.y))))}function ID(e,t,n,r){let i=(e.z*t.x-e.x*t.z)*r,a=(t.z*n.x-t.x*n.z)*r,o=(n.z*e.x-n.x*e.z)*r;return i>0&&a>0&&o>0||i<0&&a<0&&o<0}function LD(e,t){let n={lo:0,hi:0},r=[];for(let i=0;i<e.length;i++){let a=e[i],{cells:o,dirs:s}=t[i],c=new Int32Array(a.faces*4);r.push(c);for(let e=0;e<a.faces;e++){let t=a.idx?a.idx[e*3]:e*3,r=a.idx?a.idx[e*3+1]:e*3+1,i=a.idx?a.idx[e*3+2]:e*3+2,l=o[t],u=o[r],d=o[i],f=l/vD|0,p=u/vD|0,m=d/vD|0,h=l%vD,g=u%vD,_=d%vD,v=Math.min(f,p,m),y=Math.max(f,p,m),b=Math.min(h,g,_),x=Math.max(h,g,_),S=h+g+_-b-x,C=b+vD-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+vD):x-S>C&&(w=x,T=S+vD),(y-v>1||T-w>1)&&(ND(s,t,DD),ND(s,r,OD),ND(s,i,kD),ID(DD,OD,kD,1)?(y=_D-1,w=0,T=vD-1):ID(DD,OD,kD,-1)?(v=0,w=0,T=vD-1):(n.lo=v,n.hi=y,FD(DD,OD,n),FD(OD,kD,n),FD(kD,DD,n),v=n.lo,y=n.hi)),c[e*4]=v,c[e*4+1]=y,c[e*4+2]=w,c[e*4+3]=T}}return r}function RD(e,t){for(let n=0;n<e.length;n++){let r=e[n];for(let e=0;e*4<r.length;e++){let i=n*bD+e;for(let n=r[e*4];n<=r[e*4+1];n++)for(let a=r[e*4+2];a<=r[e*4+3];a++)t(n*vD+a%vD,i)}}}function zD(e){e.updateMatrixWorld(!0);let t=new Y().makeTranslation(-e.position.x,-e.position.y,-e.position.z),n=[];if(e.traverse(e=>{if(!(e instanceof As))return;let r=e.geometry.attributes.position;if(!r)return;let i=e.geometry.index,a=(i?i.count:r.count)/3;a<1||a>=bD||n.push({verts:ED(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=LD(n,n.map(TD)),i=new Int32Array(yD+1);RD(r,e=>i[e+1]++);for(let e=0;e<yD;e++)i[e+1]+=i[e];let a=new Int32Array(i[yD]),o=i.slice(0,yD);return RD(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var BD=new J,VD=new J,HD=new J,UD=new J,WD=new J,GD=new J,KD=new J;function qD(e,t,n){let r=e.idx?e.idx[t*3]:t*3,i=e.idx?e.idx[t*3+1]:t*3+1,a=e.idx?e.idx[t*3+2]:t*3+2;BD.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),VD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),HD.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),UD.subVectors(VD,BD),WD.subVectors(HD,BD),GD.crossVectors(n,WD);let o=UD.dot(GD);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-BD.dot(GD)*s;if(c<0||c>1)return 0;KD.crossVectors(BD,UD).negate();let l=n.dot(KD)*s;if(l<0||c+l>1)return 0;let u=WD.dot(KD)*s;return u>0?u:0}function JD(e,t,n,r){let{start:i,slots:a,meshes:o}=e;for(let e=i[t];e<i[t+1];e++){let t=a[e],i=qD(o[t/bD|0],t%bD,n);i>r&&(r=i)}return r}function YD(e,t){let n=SD(t.y),r=CD(t.x,t.z),i=JD(e,n*vD+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=_D))for(let n=-1;n<=1;n++)i=JD(e,o*vD+(r+n+vD)%vD,t,i)}if(i===0&&(n===0||n===_D-1)){let r=n===0?0:_D-2;for(let n=r;n<r+2;n++)for(let r=0;r<vD;r++)i=JD(e,n*vD+r,t,i)}return i>0?i:null}function XD(e){let t=e.data.objectType;return t===W.SPACECRAFT||t===W.DEBRIS||e.data.orbitalSource===U.SPICE_PROBE}var ZD=new NT;ZD.setMeshoptDecoder(NE);var QD=ZD,$D=new Map;function eO(e){let t=$D.get(e);return t||(t=fetch(Yt(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),$D.set(e,t)),t}function tO(e){return e.credit??e.exports.high.credit}function nO(e){return e.modelUnitOverride??e.radiusScene}var rO=new Set;function iO(e,t){let n=new za;n.scale.setScalar(nO(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,rO.add(n)}function aO(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof As))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof mu)||n.has(t)||(n.add(t),e.eclipseShadow=HC(t,e.eclipseShadow??void 0))})}function oO(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=(XD(e.body)?sO(e,t,n):cO(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function sO(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await hx(e.body.data.id,!1);e.body.pointing=i.global?.pointing;let a=i.global?.attitude;if(a&&(e.modelLoadEpoch??0)===r){let t=e.body.data.id.replace(/^probe-/,``);e.body.attitudeTrack=YE(t,a)}let o=i.global?.model_name;if(!o){e.noPhysical=`model`;return}if((e.modelLoadEpoch??0)!==r)return;e.mesh&&(e.mesh.visible=!1),uO(e,!0);let s=eO(o),c=await QD.loadAsync(Yt(`/v1/models/${o}/high.glb`,`models`)),l=null;try{l=await s}catch(e){console.warn(`Failed to load model metadata for ${o}:`,e)}if((e.modelLoadEpoch??0)!==r||!e.mesh){MO(c.scene);return}let u=l?.frame_map?xC(l.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=dO(c.scene,u),f=l?.model_anchor?new J(...l.model_anchor):null;if(fO(d,f&&u?f.applyQuaternion(u):f),jO(d),t.add(d),d.visible=!e.isCrashed,e.model=d,e.modelName=o,uO(e,!1),l){if(l.scale_meters){let t=l.scale_meters/2e3;e.body.data.radiusKm=t*(l.body_span_ratio??1),e.radiusScene=Q(gn(e.body.data)),e.modelUnitOverride=l.body_span_ratio?Q(t):void 0}n?.credits.registerModel({bodyId:e.body.data.id,source:l.exports.high.credit.url,organisation:l.exports.high.credit.name,license:l.exports.high.credit.license})}}finally{e.model||uO(e,!1)}}async function cO(e,t){if(!Mx().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await hx(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=hD(r.global);if(a){console.info(`Skipping ${r.global?.render_quality??`unrated`} shape mesh for ${e.body.data.id}: ${a}`);return}r.global?.orientation&&!e.body.orientation&&gD(e,r.global.orientation,t);let o=eO(i),s=await QD.loadAsync(Yt(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){MO(s.scene);return}let c;try{c=await o}catch(e){MO(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){MO(s.scene);return}let l=s.scene;fO(l),l.userData.radialIndex=zD(l),dD(l,uD(e.body.data.color??__(e.body.data)));let u=e.mesh?e.mesh.material.map:null;u&&fD(l,u,__(e.body.data),e.body.data.color),jO(l),aO(e,l),c.true_scale&&(e.radiusScene=Q(c.true_scale.max_extent_km/2),Number.isFinite(e.body.data.radiusKm)&&e.body.data.radiusKm>0||(e.body.data.radiusKm=c.true_scale.max_extent_km/2),e.noPhysical&&(e.noPhysical=void 0,QE(e,`missing`,null))),iO(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let d=tO(c),f=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:d.url,organisation:d.name,license:d.license,provenance:f?.provenance,technique:f?.technique,archive:f?.archive,archiveUrl:f?.archive_url,mission:f?.mission&&{name:f.mission.name,id:f.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function lO(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,uO(e,!1);let t=!XD(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=(rO.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),MO(n),e.model=null,e.modelName=void 0,e.body.pointing=void 0,e.body.attitudeTrack=void 0,e.body.modelBaseFrame=void 0,e.mesh&&t&&(e.mesh.visible=!0)}function uO(e,t){if(t){if(e.loadingEl)return;let t=document.createElement(`div`);t.className=`scene-label__loader`,t.style.display=`none`,document.body.appendChild(t),e.loadingEl=t,e.loadingShown=!1}else e.loadingEl&&(e.loadingEl.remove(),e.loadingEl=null,e.loadingShown=void 0)}function dO(e,t){if(!t)return e;let n=new za;return e.quaternion.copy(t),n.add(e),n}function fO(e,t=null){e.updateMatrixWorld(!0);let n=new co().setFromObject(e,!0),r=n.getSize(new J),i=n.getCenter(new J),a=Math.max(r.x,r.y,r.z);if(a<=0)return;let o=2/a;t&&i.addScaledVector(t,a/2),e.scale.multiplyScalar(o),e.userData.fitScale=e.scale.x,e.position.copy(i).multiplyScalar(-o),e.userData.centerOffset=i.clone().multiplyScalar(o),e.userData.feetOffset=new J(i.x,n.min.y,i.z).multiplyScalar(o),e.userData.halfExtents=r.clone().multiplyScalar(o*.5);let s=hO(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c}var pO=8,mO=4096;function hO(e,t,n,r){e.updateMatrixWorld(!0);let i=t.x>=t.y&&t.x>=t.z?0:t.y>=t.z?1:2,a=0;if(e.traverse(e=>{e instanceof As&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/mO)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof As))return;let n=t.geometry.attributes.position;if(n)for(let r=0;r<n.count;r+=o)c.fromBufferAttribute(n,r).applyMatrix4(t.matrixWorld).sub(e.position),s.push(c.clone())});let l=t.getComponent(i)*n/2+Math.abs(r.getComponent(i)),u=Array.from({length:pO},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(pO-1,Math.max(0,Math.floor(t*pO)))].push(e)}let d=1/0;for(let e of s)d=Math.min(d,e.length());let f=[];for(let e of u){if(e.length<3)continue;let t=new J;for(let n of e)t.add(n);t.divideScalar(e.length);let n=0;for(let r of e)n=Math.max(n,t.distanceToSquared(r));f.push({center:t,r:Math.sqrt(n)})}return{spheres:f,minRadius:Number.isFinite(d)?d:0}}var gO=4,_O=.05,vO=new J,yO=new J,bO=new J,xO=new J,SO=new Hi,CO=new J,wO=new Rd;function TO(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(xO).x;if(!(a>0))return null;let o=Math.cos(t);vO.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),yO.copy(vO).applyQuaternion(e.quaternion),bO.copy(e.position).addScaledVector(yO,gO),i.localToWorld(bO),wO.set(bO,yO.negate());let s=wO.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(SO.copy(e.quaternion).invert()),Math.max(gO-s.distance/a,_O)):null}function EO(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=YD(n,CO.set(t[0],t[1],t[2]));return r===null?null:cg(r*nO(e))}function DO(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function OO(e){if(!DO(e))return;let t=e.model.position,n=nO(e);return[t.x*n,t.y*n,t.z*n]}function kO(e){if(DO(e))return cg(e.model.userData.maxRadius*nO(e))}function AO(e){if(DO(e))return cg(e.model.userData.minRadius*nO(e))}function jO(e){e.traverse(e=>{e instanceof As&&(e.castShadow=!0,e.receiveShadow=!0)})}function MO(e){e.traverse(e=>{if(!(e instanceof As))return;e.geometry?.dispose();let t=e.material,n=Array.isArray(t)?t:[t];for(let e of n)if(e){for(let t of Object.values(e))t instanceof oa&&t.dispose();e.dispose()}})}function NO(e,t,n,r,i,a,o,s,c,l){let u=c===`touch`||c===`pen`?48:24,d=(e.x+1)*.5*i,f=(1-e.y)*.5*a,p=o,[m,h,g]=r,_=t.position,v,y=u,b=1/0,x=e=>{DT(e,s,n),p.set(e.position[0]-m,e.position[1]-h,e.position[2]-g);let r=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!aT(p.z))return;let o=(p.x+1)*.5*i,c=(1-p.y)*.5*a,u=Math.hypot(o-d,c-f);(u<y||u===y&&r<b)&&(l&&!l(p.x,p.y,r)||(y=u,b=r,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===W.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var PO=9,FO=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Rd;_tmpV3=new J;constructor(e,t,n,r,i,a,o,s,c,l,u,d){this.canvas=e,this.camera=t,this.ctx=n,this.clock=r,this.focus=i,this.clickables=a,this.meshToBody=o,this.onPick=s,this.modelPick=c,this.gpuPick=l,this.getClouds=u,this.pickRegistry=d}attach(){this.canvas.addEventListener(`pointerdown`,this.onDown),this.canvas.addEventListener(`pointerup`,this.onUp)}detach(){this.canvas.removeEventListener(`pointerdown`,this.onDown),this.canvas.removeEventListener(`pointerup`,this.onUp)}onDown=e=>{this.downPos.set(e.clientX,e.clientY)};onUp=e=>{let t=e.clientX-this.downPos.x,n=e.clientY-this.downPos.y;if(t*t+n*n>PO)return;let r=this.canvas.getBoundingClientRect();this.pointer.set((e.clientX-r.left)/r.width*2-1,-((e.clientY-r.top)/r.height)*2+1);let i=this.modelPick(this.pointer.x,this.pointer.y);if(i){this.onPick(i);return}this.raycaster.setFromCamera(this.pointer,this.camera);let a=this.resolveMeshHit(this.raycaster.intersectObjects([...this.clickables,...rO]))?.body,o=NO(this.pointer,this.camera,this.ctx,this.focus.focusTruePos,this.canvas.clientWidth,this.canvas.clientHeight,this._tmpV3,this.clock.jd,e.pointerType,this.isDotVisible),s=this.gpuPickCloud(e,r),c=this.nearer(o,s)?.body??a;c&&this.onPick(c)};nearer(e,t){return e?t&&(t.screenDist<e.screenDist||t.screenDist===e.screenDist&&t.distance<e.distance)?t:e:t}gpuPickCloud(e,t){let n=e.pointerType===`touch`||e.pointerType===`pen`?48:24,r=this.clock.jd,i=this.gpuPick.pick(this.getClouds(),this.camera,e.clientX,e.clientY,t,n);for(let e of i){let t=this.pickRegistry.resolve(e.pickId);if(!t)continue;let n=this.ctx.getBody(t);if(!n)continue;DT(n,r,this.ctx);let i=this.worldDistOf(n);if(this.isDotVisible(e.ndcX,e.ndcY,i))return{body:n,distance:i,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e.position[0]-t-i.x,e.position[1]-n-i.y,e.position[2]-r-i.z)}resolveMeshHit(e){for(let t of e){let e=t.object;for(;e;){let n=this.meshToBody.get(e)??e.userData.pickBody;if(n)return{body:n,distance:t.distance};e=e.parent}}}isDotVisible=(e,t,n)=>{if(this.modelPick(e,t))return!1;if(this.clickables.length===0&&rO.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);if(rO.size>0&&r.push(...this.raycaster.intersectObjects([...rO],!0)),r.length===0)return!0;let i=1/0;for(let e of r)e.distance<i&&(i=e.distance);return i>=n*.999}},IO=4,LO=16,RO=`
|
|
4551
|
+
#endif`)},PC(t,`shapeModel`),t}function mD(e,t){e.traverse(e=>{if(!(e instanceof As))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function hD(e,t,n,r){e.traverse(e=>{!(e instanceof As)||!(e.material instanceof mu)||(e.material.map=t,t?e.material.color.copy(aD(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function gD(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=Xr,e.map=t,e.color.copy(aD(t,n)),e.needsUpdate=!0}var _D=new Set([]);function vD(e){return e?.model_name?Hx()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!_D.has(e.id)?`dem-preferred`:null:`no-bundle`}function yD(e,t,n,r){e.body.orientation=t,n?.credits.registerOrientation({bodyId:e.body.data.id,systemId:r??e.body.data.id,source:t.source,reference:t.reference})}var bD=48,xD=96,SD=bD*xD,CD=1<<24,wD=Math.PI*2;function TD(e){let t=Math.floor((e+1)/2*bD);return Math.min(bD-1,Math.max(0,t))}function ED(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/wD*xD)%xD+xD)%xD}var DD=new J;function OD(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)DD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=DD.x,r[i*3+1]=DD.y,r[i*3+2]=DD.z,n[i]=TD(DD.y)*xD+ED(DD.x,DD.z);return{cells:n,dirs:r}}function kD(e,t){let n=e.geometry.attributes.position,r=new Y().multiplyMatrices(t,e.matrixWorld),i=new Float32Array(n.count*3);for(let e=0;e<n.count;e++)DD.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=DD.x,i[e*3+1]=DD.y,i[e*3+2]=DD.z;return i}var AD=new J,jD=new J,MD=new J,ND=new J,PD=new J,FD=new J;function ID(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function LD(e,t,n,r){return FD.crossVectors(e,n).dot(r)>=0&&FD.crossVectors(n,t).dot(r)>=0}function RD(e,t,n){ND.crossVectors(e,t);let r=ND.lengthSq();r<1e-18||(PD.set(0,1,0).addScaledVector(ND,-ND.y/r).normalize(),LD(e,t,PD,ND)&&(n.hi=Math.max(n.hi,TD(PD.y))),PD.negate(),LD(e,t,PD,ND)&&(n.lo=Math.min(n.lo,TD(PD.y))))}function zD(e,t,n,r){let i=(e.z*t.x-e.x*t.z)*r,a=(t.z*n.x-t.x*n.z)*r,o=(n.z*e.x-n.x*e.z)*r;return i>0&&a>0&&o>0||i<0&&a<0&&o<0}function BD(e,t){let n={lo:0,hi:0},r=[];for(let i=0;i<e.length;i++){let a=e[i],{cells:o,dirs:s}=t[i],c=new Int32Array(a.faces*4);r.push(c);for(let e=0;e<a.faces;e++){let t=a.idx?a.idx[e*3]:e*3,r=a.idx?a.idx[e*3+1]:e*3+1,i=a.idx?a.idx[e*3+2]:e*3+2,l=o[t],u=o[r],d=o[i],f=l/xD|0,p=u/xD|0,m=d/xD|0,h=l%xD,g=u%xD,_=d%xD,v=Math.min(f,p,m),y=Math.max(f,p,m),b=Math.min(h,g,_),x=Math.max(h,g,_),S=h+g+_-b-x,C=b+xD-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+xD):x-S>C&&(w=x,T=S+xD),(y-v>1||T-w>1)&&(ID(s,t,AD),ID(s,r,jD),ID(s,i,MD),zD(AD,jD,MD,1)?(y=bD-1,w=0,T=xD-1):zD(AD,jD,MD,-1)?(v=0,w=0,T=xD-1):(n.lo=v,n.hi=y,RD(AD,jD,n),RD(jD,MD,n),RD(MD,AD,n),v=n.lo,y=n.hi)),c[e*4]=v,c[e*4+1]=y,c[e*4+2]=w,c[e*4+3]=T}}return r}function VD(e,t){for(let n=0;n<e.length;n++){let r=e[n];for(let e=0;e*4<r.length;e++){let i=n*CD+e;for(let n=r[e*4];n<=r[e*4+1];n++)for(let a=r[e*4+2];a<=r[e*4+3];a++)t(n*xD+a%xD,i)}}}function HD(e){e.updateMatrixWorld(!0);let t=new Y().makeTranslation(-e.position.x,-e.position.y,-e.position.z),n=[];if(e.traverse(e=>{if(!(e instanceof As))return;let r=e.geometry.attributes.position;if(!r)return;let i=e.geometry.index,a=(i?i.count:r.count)/3;a<1||a>=CD||n.push({verts:kD(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=BD(n,n.map(OD)),i=new Int32Array(SD+1);VD(r,e=>i[e+1]++);for(let e=0;e<SD;e++)i[e+1]+=i[e];let a=new Int32Array(i[SD]),o=i.slice(0,SD);return VD(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var UD=new J,WD=new J,GD=new J,KD=new J,qD=new J,JD=new J,YD=new J;function XD(e,t,n){let r=e.idx?e.idx[t*3]:t*3,i=e.idx?e.idx[t*3+1]:t*3+1,a=e.idx?e.idx[t*3+2]:t*3+2;UD.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),WD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),GD.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),KD.subVectors(WD,UD),qD.subVectors(GD,UD),JD.crossVectors(n,qD);let o=KD.dot(JD);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-UD.dot(JD)*s;if(c<0||c>1)return 0;YD.crossVectors(UD,KD).negate();let l=n.dot(YD)*s;if(l<0||c+l>1)return 0;let u=qD.dot(YD)*s;return u>0?u:0}function ZD(e,t,n,r){let{start:i,slots:a,meshes:o}=e;for(let e=i[t];e<i[t+1];e++){let t=a[e],i=XD(o[t/CD|0],t%CD,n);i>r&&(r=i)}return r}function QD(e,t){let n=TD(t.y),r=ED(t.x,t.z),i=ZD(e,n*xD+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=bD))for(let n=-1;n<=1;n++)i=ZD(e,o*xD+(r+n+xD)%xD,t,i)}if(i===0&&(n===0||n===bD-1)){let r=n===0?0:bD-2;for(let n=r;n<r+2;n++)for(let r=0;r<xD;r++)i=ZD(e,n*xD+r,t,i)}return i>0?i:null}function $D(e){let t=e.data.objectType;return t===W.SPACECRAFT||t===W.DEBRIS||e.data.orbitalSource===U.SPICE_PROBE}var eO=new IT;eO.setMeshoptDecoder(IE);var tO=eO,nO=new Map;function rO(e){let t=nO.get(e);return t||(t=fetch(Yt(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),nO.set(e,t)),t}function iO(e){return e.credit??e.exports.high.credit}function aO(e){return e.modelUnitOverride??e.radiusScene}var oO=new Set;function sO(e,t){let n=new za;n.scale.setScalar(aO(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,oO.add(n)}function cO(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof As))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof mu)||n.has(t)||(n.add(t),e.eclipseShadow=HC(t,e.eclipseShadow??void 0))})}function lO(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=($D(e.body)?uO(e,t,n):dO(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function uO(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await hx(e.body.data.id,!1);e.body.pointing=i.global?.pointing;let a=i.global?.attitude;if(a&&(e.modelLoadEpoch??0)===r){let t=e.body.data.id.replace(/^probe-/,``);e.body.attitudeTrack=QE(t,a)}let o=i.global?.model_name;if(!o){e.noPhysical=`model`;return}if((e.modelLoadEpoch??0)!==r)return;e.mesh&&(e.mesh.visible=!1),pO(e,!0);let s=rO(o),c=await tO.loadAsync(Yt(`/v1/models/${o}/high.glb`,`models`)),l=null;try{l=await s}catch(e){console.warn(`Failed to load model metadata for ${o}:`,e)}if((e.modelLoadEpoch??0)!==r||!e.mesh){FO(c.scene);return}let u=l?.frame_map?xC(l.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=mO(c.scene,u),f=l?.model_anchor?new J(...l.model_anchor):null;if(hO(d,f&&u?f.applyQuaternion(u):f),PO(d),t.add(d),d.visible=!e.isCrashed,e.model=d,e.modelName=o,pO(e,!1),l){if(l.scale_meters){let t=l.scale_meters/2e3;e.body.data.radiusKm=t*(l.body_span_ratio??1),e.radiusScene=Q(gn(e.body.data)),e.modelUnitOverride=l.body_span_ratio?Q(t):void 0}n?.credits.registerModel({bodyId:e.body.data.id,source:l.exports.high.credit.url,organisation:l.exports.high.credit.name,license:l.exports.high.credit.license})}}finally{e.model||pO(e,!1)}}async function dO(e,t){if(!Mx().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await hx(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=vD(r.global);if(a){console.info(`Skipping ${r.global?.render_quality??`unrated`} shape mesh for ${e.body.data.id}: ${a}`);return}r.global?.orientation&&!e.body.orientation&&yD(e,r.global.orientation,t);let o=rO(i),s=await tO.loadAsync(Yt(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){FO(s.scene);return}let c;try{c=await o}catch(e){FO(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){FO(s.scene);return}let l=s.scene;hO(l),l.userData.radialIndex=HD(l),mD(l,pD(e.body.data.color??__(e.body.data)));let u=e.mesh?e.mesh.material.map:null;u&&hD(l,u,__(e.body.data),e.body.data.color),PO(l),cO(e,l),c.true_scale&&(e.radiusScene=Q(c.true_scale.max_extent_km/2),Number.isFinite(e.body.data.radiusKm)&&e.body.data.radiusKm>0||(e.body.data.radiusKm=c.true_scale.max_extent_km/2),e.noPhysical&&(e.noPhysical=void 0,tD(e,`missing`,null))),sO(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let d=iO(c),f=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:d.url,organisation:d.name,license:d.license,provenance:f?.provenance,technique:f?.technique,archive:f?.archive,archiveUrl:f?.archive_url,mission:f?.mission&&{name:f.mission.name,id:f.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function fO(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,pO(e,!1);let t=!$D(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=(oO.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),FO(n),e.model=null,e.modelName=void 0,e.body.pointing=void 0,e.body.attitudeTrack=void 0,e.body.modelBaseFrame=void 0,e.mesh&&t&&(e.mesh.visible=!0)}function pO(e,t){if(t){if(e.loadingEl)return;let t=document.createElement(`div`);t.className=`scene-label__loader`,t.style.display=`none`,document.body.appendChild(t),e.loadingEl=t,e.loadingShown=!1}else e.loadingEl&&(e.loadingEl.remove(),e.loadingEl=null,e.loadingShown=void 0)}function mO(e,t){if(!t)return e;let n=new za;return e.quaternion.copy(t),n.add(e),n}function hO(e,t=null){e.updateMatrixWorld(!0);let n=new co().setFromObject(e,!0),r=n.getSize(new J),i=n.getCenter(new J),a=Math.max(r.x,r.y,r.z);if(a<=0)return;let o=2/a;t&&i.addScaledVector(t,a/2),e.scale.multiplyScalar(o),e.userData.fitScale=e.scale.x,e.position.copy(i).multiplyScalar(-o),e.userData.centerOffset=i.clone().multiplyScalar(o),e.userData.feetOffset=new J(i.x,n.min.y,i.z).multiplyScalar(o),e.userData.halfExtents=r.clone().multiplyScalar(o*.5);let s=vO(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c}var gO=8,_O=4096;function vO(e,t,n,r){e.updateMatrixWorld(!0);let i=t.x>=t.y&&t.x>=t.z?0:t.y>=t.z?1:2,a=0;if(e.traverse(e=>{e instanceof As&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/_O)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof As))return;let n=t.geometry.attributes.position;if(n)for(let r=0;r<n.count;r+=o)c.fromBufferAttribute(n,r).applyMatrix4(t.matrixWorld).sub(e.position),s.push(c.clone())});let l=t.getComponent(i)*n/2+Math.abs(r.getComponent(i)),u=Array.from({length:gO},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(gO-1,Math.max(0,Math.floor(t*gO)))].push(e)}let d=1/0;for(let e of s)d=Math.min(d,e.length());let f=[];for(let e of u){if(e.length<3)continue;let t=new J;for(let n of e)t.add(n);t.divideScalar(e.length);let n=0;for(let r of e)n=Math.max(n,t.distanceToSquared(r));f.push({center:t,r:Math.sqrt(n)})}return{spheres:f,minRadius:Number.isFinite(d)?d:0}}var yO=4,bO=.05,xO=new J,SO=new J,CO=new J,wO=new J,TO=new Hi,EO=new J,DO=new Rd;function OO(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(wO).x;if(!(a>0))return null;let o=Math.cos(t);xO.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),SO.copy(xO).applyQuaternion(e.quaternion),CO.copy(e.position).addScaledVector(SO,yO),i.localToWorld(CO),DO.set(CO,SO.negate());let s=DO.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(TO.copy(e.quaternion).invert()),Math.max(yO-s.distance/a,bO)):null}function kO(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=QD(n,EO.set(t[0],t[1],t[2]));return r===null?null:cg(r*aO(e))}function AO(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function jO(e){if(!AO(e))return;let t=e.model.position,n=aO(e);return[t.x*n,t.y*n,t.z*n]}function MO(e){if(AO(e))return cg(e.model.userData.maxRadius*aO(e))}function NO(e){if(AO(e))return cg(e.model.userData.minRadius*aO(e))}function PO(e){e.traverse(e=>{e instanceof As&&(e.castShadow=!0,e.receiveShadow=!0)})}function FO(e){e.traverse(e=>{if(!(e instanceof As))return;e.geometry?.dispose();let t=e.material,n=Array.isArray(t)?t:[t];for(let e of n)if(e){for(let t of Object.values(e))t instanceof oa&&t.dispose();e.dispose()}})}function IO(e,t,n,r,i,a,o,s,c,l){let u=c===`touch`||c===`pen`?48:24,d=(e.x+1)*.5*i,f=(1-e.y)*.5*a,p=o,[m,h,g]=r,_=t.position,v,y=u,b=1/0,x=e=>{AT(e,s,n),p.set(e.position[0]-m,e.position[1]-h,e.position[2]-g);let r=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!aT(p.z))return;let o=(p.x+1)*.5*i,c=(1-p.y)*.5*a,u=Math.hypot(o-d,c-f);(u<y||u===y&&r<b)&&(l&&!l(p.x,p.y,r)||(y=u,b=r,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===W.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var LO=9,RO=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Rd;_tmpV3=new J;constructor(e,t,n,r,i,a,o,s,c,l,u,d){this.canvas=e,this.camera=t,this.ctx=n,this.clock=r,this.focus=i,this.clickables=a,this.meshToBody=o,this.onPick=s,this.modelPick=c,this.gpuPick=l,this.getClouds=u,this.pickRegistry=d}attach(){this.canvas.addEventListener(`pointerdown`,this.onDown),this.canvas.addEventListener(`pointerup`,this.onUp)}detach(){this.canvas.removeEventListener(`pointerdown`,this.onDown),this.canvas.removeEventListener(`pointerup`,this.onUp)}onDown=e=>{this.downPos.set(e.clientX,e.clientY)};onUp=e=>{let t=e.clientX-this.downPos.x,n=e.clientY-this.downPos.y;if(t*t+n*n>LO)return;let r=this.canvas.getBoundingClientRect();this.pointer.set((e.clientX-r.left)/r.width*2-1,-((e.clientY-r.top)/r.height)*2+1);let i=this.modelPick(this.pointer.x,this.pointer.y);if(i){this.onPick(i);return}this.raycaster.setFromCamera(this.pointer,this.camera);let a=this.resolveMeshHit(this.raycaster.intersectObjects([...this.clickables,...oO]))?.body,o=IO(this.pointer,this.camera,this.ctx,this.focus.focusTruePos,this.canvas.clientWidth,this.canvas.clientHeight,this._tmpV3,this.clock.jd,e.pointerType,this.isDotVisible),s=this.gpuPickCloud(e,r),c=this.nearer(o,s)?.body??a;c&&this.onPick(c)};nearer(e,t){return e?t&&(t.screenDist<e.screenDist||t.screenDist===e.screenDist&&t.distance<e.distance)?t:e:t}gpuPickCloud(e,t){let n=e.pointerType===`touch`||e.pointerType===`pen`?48:24,r=this.clock.jd,i=this.gpuPick.pick(this.getClouds(),this.camera,e.clientX,e.clientY,t,n);for(let e of i){let t=this.pickRegistry.resolve(e.pickId);if(!t)continue;let n=this.ctx.getBody(t);if(!n)continue;AT(n,r,this.ctx);let i=this.worldDistOf(n);if(this.isDotVisible(e.ndcX,e.ndcY,i))return{body:n,distance:i,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e.position[0]-t-i.x,e.position[1]-n-i.y,e.position[2]-r-i.z)}resolveMeshHit(e){for(let t of e){let e=t.object;for(;e;){let n=this.meshToBody.get(e)??e.userData.pickBody;if(n)return{body:n,distance:t.distance};e=e.parent}}}isDotVisible=(e,t,n)=>{if(this.modelPick(e,t))return!1;if(this.clickables.length===0&&oO.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);if(oO.size>0&&r.push(...this.raycaster.intersectObjects([...oO],!0)),r.length===0)return!0;let i=1/0;for(let e of r)e.distance<i&&(i=e.distance);return i>=n*.999}},zO=4,BO=16,VO=`
|
|
4541
4552
|
uniform mat4 modelViewMatrix;
|
|
4542
4553
|
uniform mat4 projectionMatrix;
|
|
4543
4554
|
uniform float uPointSize;
|
|
@@ -4549,13 +4560,13 @@ void main() {
|
|
|
4549
4560
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
4550
4561
|
gl_PointSize = uPointSize;
|
|
4551
4562
|
}
|
|
4552
|
-
`,
|
|
4563
|
+
`,HO=`
|
|
4553
4564
|
precision highp float;
|
|
4554
4565
|
varying vec4 vPick;
|
|
4555
4566
|
void main() {
|
|
4556
4567
|
gl_FragColor = vPick;
|
|
4557
4568
|
}
|
|
4558
|
-
`,BO=class{target;material;scene=new qa;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new la(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=Zr,this.target.texture.generateMipmaps=!1,this.material=new pu({vertexShader:RO,fragmentShader:zO,uniforms:{uPointSize:{value:IO}},blending:0,depthTest:!0,depthWrite:!0}),this.scene.matrixWorldAutoUpdate=!1,this.pickCamera=t.clone()}ensureSize(e){e!==this.size&&(this.size=e,this.target.setSize(e,e),this.buffer=new Uint8Array(e*e*4))}proxyAt(e,t){let n=this.proxies[e];return n?n.geometry=t.geometry:(n=new Ac(t.geometry,this.material),n.frustumCulled=!1,n.matrixAutoUpdate=!1,n.matrixWorldAutoUpdate=!1,this.proxies[e]=n),n.matrixWorld.copy(t.matrixWorld),n}pick(e,t,n,r,i,a){let o=Math.max(1,Math.round(a)),s=o*2+1;this.ensureSize(s);let c=n-i.left,l=r-i.top,u=c-o,d=l-o;this.scene.clear();let f=0;for(let t of e)t.visible&&t.geometry.getAttribute(`pickColor`)&&t.geometry.drawRange.count!==0&&this.scene.add(this.proxyAt(f++,t));if(f===0)return[];this.pickCamera.copy(t),this.pickCamera.setViewOffset(i.width,i.height,u,d,s,s),this.pickCamera.updateProjectionMatrix();let p=this.renderer.getRenderTarget(),m=this.renderer.autoClear;this.renderer.getClearColor(this.prevClear);let h=this.renderer.getClearAlpha();return this.renderer.setRenderTarget(this.target),this.renderer.autoClear=!1,this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!1),this.renderer.render(this.scene,this.pickCamera),this.renderer.readRenderTargetPixels(this.target,0,0,s,s,this.buffer),this.renderer.setRenderTarget(p),this.renderer.autoClear=m,this.renderer.setClearColor(this.prevClear,h),this.pickCamera.clearViewOffset(),this.decode(s,o,i,u,d)}decode(e,t,n,r,i){let a=this.buffer,o=new Map;for(let s=0;s<e;s++){let c=e-1-s;for(let l=0;l<e;l++){let u=(s*e+l)*4,d=(a[u]|a[u+1]<<8|a[u+2]<<16|a[u+3]<<24)>>>0;if(d===0)continue;let f=l-t,p=c-t,m=Math.hypot(f,p),h=o.get(d);if(h&&h.pixelDist<=m)continue;let g=r+l+.5,_=i+c+.5;o.set(d,{pickId:d,pixelDist:m,ndcX:g/n.width*2-1,ndcY:-(_/n.height*2-1)})}}return[...o.values()].sort((e,t)=>e.pixelDist-t.pixelDist).slice(0,LO)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function VO(e,t,n){return Math.min(Math.max(e,t),n)}function HO(e,t){let n=Math.max(e,0);return VO(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function UO(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return VO(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var WO={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},GO={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},KO={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},qO={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},JO=new J(0,1,0),YO=(()=>{let e=Math.PI/180,t=192.85948*e,n=27.12825*e,r=Math.cos(n),i=r*Math.cos(t),a=r*Math.sin(t),o=Math.sin(n),s=ag*e,c=Math.cos(s),l=Math.sin(s),u=i,d=a*c+o*l;return new J(u,-a*l+o*c,-d).normalize()})();function XO(e){return(e??new J).copy(YO)}function ZO(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&(i.set(e.position[0]-e.orbitCenter[0],e.position[1]-e.orbitCenter[1],e.position[2]-e.orbitCenter[2]),i.lengthSq()>1e-20)?i.normalize():(i.copy(JO),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=mC(e.orientation,t,e.nutPrec);return i.copy(JO).applyQuaternion(a).normalize()}var QO=class{refId=null;startVec=new J(0,1,0);targetVec=new J(0,1,0);currentVec=new J(0,1,0);animStartTime=-1/0;animDurationMs=GO.refMs;needsDurationCalc=!1;_quatA=new Hi;_quatB=new Hi;constructor(e,t,n,r){this.camera=e,this.controls=t,this.ctx=n,this.isLanded=r}setNorthReference(e){e!==this.refId&&(this.refId=e,this.startVec.copy(this.currentVec),this.animStartTime=performance.now(),this.needsDurationCalc=!0)}update(e){if(this.refId===`galactic`)XO(this.targetVec);else{let t=this.refId?this.ctx.getBody(this.refId):void 0;if(t){let n=!!t.featureAnchor||this.isLanded(t.data.id);ZO(t,e,this.targetVec,n)}else this.targetVec.copy(JO)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=HO(e,GO)}let t=performance.now()-this.animStartTime;if(t>=this.animDurationMs)this.currentVec.copy(this.targetVec);else{let e=Math.max(0,t/this.animDurationMs),n=e*e*(3-2*e);this._quatA.setFromUnitVectors(JO,this.startVec),this._quatB.setFromUnitVectors(JO,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy(JO).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,JO),n._quatInverse.copy(n._quat).invert()}},$O=class extends Ra{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new q(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}};new J,new Y,new Y,new J,new J;function ek(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}function tk(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function nk(e){switch(e){case W.STAR:return 0;case W.PLANET:return 1;case W.DWARF_PLANET:return 2;case W.MOON:return 3;default:return 4}}var rk=new J,ik=22;function ak(){return{cx0:0,cy0:0,f:0,gxx:0,gxy:0,gxz:0,gyx:0,gyy:0,gyz:0,gzx:0,gzy:0,gzz:0,cpx:0,cpy:0,cpz:0,K:0,id:``,dist:0,ccx:0,ccy:0,ccz:0}}var ok=new WeakMap;function sk(e){ok.delete(e)}function ck(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(ok.get(e)===t)return;ok.set(e,t),e.style.transform=`scale(${r})`,e.parentElement&&(e.parentElement.style.pointerEvents=n?``:`none`)}t&&(t.style.display=`none`,t.style.fontSize=``),i&&(i.style.display=`none`)}function lk(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(ok.get(e)===t)return;ok.set(e,t),n||(e.style.transform=``),e.style.border=e.dataset.origBorder??``,e.parentElement&&(e.parentElement.style.pointerEvents=``)}t&&(t.style.display=``,t.style.fontSize=r?`18px`:``),i&&(i.style.display=``)}function uk(e,t,n,r,i,a){let{label:o,labelHalo:s,radiusScene:c}=e;if(!o)return!1;let l=o.visible,u=!e.noPhysical&&c>0?c/r*i:0,d=e.body.data.id===a,f=u>=16;return!t&&n&&(d||u>=1)&&(t=u<320),f&&e.labelAnchorOffscreen&&(t=!1),e.trail&&f&&(e.trail.visible=!1),o.visible=t,s&&e.haloHidden!==f&&(s.style.visibility=f?`hidden`:``,e.haloHidden=f),e.loadingEl&&e.loadingShown!==f&&(e.loadingEl.style.display=f?``:`none`,e.loadingShown=f),o.center.x=f?1-4/32:.5,t&&!l}function dk(e,t,n,r,i){for(let a of i){if(a.id===r)continue;let i=e-a.cx0,o=a.cy0-t,s=-a.f,c=i*a.gxx+o*a.gxy+s*a.gxz,l=i*a.gyx+o*a.gyy+s*a.gyz,u=i*a.gzx+o*a.gzy+s*a.gzz,d=c*a.cpx+l*a.cpy+u*a.cpz;if(!(d<=0)&&!(d*d<=a.K*(c*c+l*l+u*u))&&i*a.ccx+o*a.ccy+s*a.ccz<=n*Math.hypot(i,o,s))return!0}return!1}function fk(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function pk(e,t,n,r,i,a){let o=e.label,[s,c,l]=e.body.position,u=o.position;rk.set(s-n[0]+u.x,c-n[1]+u.y,l-n[2]+u.z),rk.project(t),a.x=(rk.x*.5+.5)*r,a.y=(-rk.y*.5+.5)*i;let d=a.x-o.center.x*32;return a.left=d,a.right=d+40+(e.labelTextWidth||50),a.h=ik,aT(rk.z)}var mk=[],hk=0,gk=[],_k=0,vk=[],yk=0,bk={rects:gk,get count(){return _k}};function xk(){return{bodyId:``,bo:null,body:null,label:null,labelHalo:null,isCapped:!1,isMinor:!1,isFocused:!1,isSelected:!1,rect:{x:0,left:0,right:0,y:0,h:0},dist:0}}function Sk(){return{left:0,right:0,y:0,h:0}}var Ck={x:0,left:0,right:0,y:0,h:0};function wk(e,t){for(let n=0;n<t;n++)fk(tk(vk,n,Sk),e[n]);yk=t}function Tk(){for(let e=0;e<yk;e++)fk(tk(gk,e,Sk),vk[e]);return yk}function Ek(e,t,n,r,i,a,o,s,c=[0,0,0]){hk=0,_k=Tk();for(let s of e.values()){let{body:e,label:l,labelHalo:u}=s;if(!l?.visible)continue;if(!s.labelTextWidth&&u){let e=u.nextElementSibling;e&&e.offsetWidth>0&&(s.labelTextWidth=e.offsetWidth)}if(!pk(s,r,c,t,n,Ck))continue;let d=e.data.id===i,f=o.has(e.data.id),p=tk(mk,hk++,xk);fk(p.rect,Ck),p.rect.x=Ck.x,p.bodyId=e.data.id,p.bo=s,p.body=e,p.label=l,p.labelHalo=u,p.isCapped=e.data.objectType===W.MOON?a.visibility.getMoonVisibility(e)===$.CAPPED:!1,p.isMinor=s.isMinor,p.isFocused=d,p.isSelected=d||f||a.visibility.isPinned(e.data.id),p.dist=s.cachedDist}mk.length=hk,mk.sort((e,t)=>{if(e.isSelected!==t.isSelected)return e.isSelected?-1:1;let n=e.isMinor&&!e.isSelected;if(n!==(t.isMinor&&!t.isSelected))return n?1:-1;let r=nk(e.body.data.objectType),i=nk(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<hk;e++){let t=mk[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){ck(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&dk(t.rect.x,t.rect.y,t.dist,t.bodyId,s)){t.label.visible=!1,t.bo.labelMaximized=!1;continue}if(t.isMinor&&!t.isSelected){let e=!1;for(let n=0;n<_k;n++){let r=gk[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<ik){e=!0;break}}ck(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<_k;e++){let n=gk[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<ik){i=!0;break}}i?(ck(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(fk(tk(gk,_k++,Sk),t.rect),lk(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<hk;e++){let t=mk[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function Dk(e,t,n,r,i){_k=Tk();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&pk(a,r,i,t,n,Ck)&&fk(tk(gk,_k++,Sk),Ck)}var Ok=`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,kk=`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,Ak={flying:Ok,landed:kk,crashed:kk+`M15 9l-6 6M9 9l6 6`};function jk(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,Ak[t])}function Mk(e,t,n,r){let i=document.createElement(`span`);i.className=`scene-label__name scene-label__name--${n}${r?` scene-label__name--large`:``}`,i.dir=`auto`,i.textContent=t;let a=e.firstElementChild;return a?a.after(i):e.appendChild(i),i}function Nk(e,t,n,r){if(n===`none`||!t||!e.label)return;let i=e.label.element,a=i.querySelector(`.scene-label__name`);a?a.textContent=t:Mk(i,t,n,r),$E(e)}function Pk(e){let t=e.data.objectType;return vn(t)||t===W.STAR||_n(t)||t===W.COMET||t===W.BARYCENTER||t===W.LAGRANGE_POINT?`major`:t===W.SPACECRAFT?`spacecraft`:t===W.DEBRIS?`debris`:`none`}function Fk(e,t,n,r,i,a=!1,o,s=!1){if(n===`none`)return null;let c=document.createElement(`a`);c.className=`scene-label scene-label--${n}`,r&&(c.href=r),c.tabIndex=-1,c.draggable=!1,t&&c.setAttribute(`aria-label`,t);let l;if(n===`major`){let t=document.createElement(`div`);t.className=`scene-label__halo scene-label__halo--major`,t.style.border=`2px solid ${e}`,t.style.background=`${e}22`,l=t}else{let t=`http://www.w3.org/2000/svg`,r=document.createElementNS(t,`svg`);r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`fill`,`${e}22`),r.setAttribute(`stroke`,e),r.setAttribute(`stroke-width`,`2`),r.setAttribute(`stroke-linejoin`,`round`),r.classList.add(`scene-label__halo`,`scene-label__halo--${n}`);let i=document.createElementNS(t,`path`);i.setAttribute(`d`,n===`debris`?`M3 5 L21 5 L12 21 Z`:Ok),r.appendChild(i),l=r}c.appendChild(l);let u=0,d=0;c.addEventListener(`pointerdown`,e=>{u=e.clientX,d=e.clientY});let f=e=>{if(e.stopPropagation(),ek(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&Mk(c,t,n,a),s&&(l.style.transform=`scale(0.3)`),c.addEventListener(`click`,f),c.addEventListener(`mouseenter`,()=>{l.style.transform=`scale(1.15)`,document.body.style.cursor=`pointer`,o?.(!0)}),c.addEventListener(`mouseleave`,()=>{l.style.transform=s?`scale(0.3)`:``,sk(l),document.body.style.cursor=``,o?.(!1)});let p=new $O(c);return p.visible=!1,p}var Ik=3;function Lk(e,t){e.addEventListener(`wheel`,e=>{let n=e;t.dispatchEvent(new WheelEvent(`wheel`,{deltaY:n.deltaY,deltaMode:n.deltaMode,bubbles:!0,cancelable:!0})),n.preventDefault()},{passive:!1}),e.addEventListener(`pointerdown`,e=>{let n=e.clientX,r=e.clientY,i=e,a=e=>{let a=e.clientX-n,o=e.clientY-r;a*a+o*o>Ik*Ik&&(s(),t.dispatchEvent(new PointerEvent(`pointerdown`,i)),t.dispatchEvent(new PointerEvent(`pointermove`,e)))},o=()=>s(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)})}var Rk=[`low`,`medium`,`high`,`ultra`],zk={low:{primarySteps:6,lightSteps:2,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},medium:{primarySteps:12,lightSteps:3,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},high:{primarySteps:16,lightSteps:4,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0},ultra:{primarySteps:32,lightSteps:8,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0}};function Bk(){return Wx()?Hx()?`low`:`medium`:Hx()?`high`:`ultra`}function Vk(e){if(e!==`auto`)return e;let t=Mx();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??Bk()}function Hk(){let e=Mx();return{...zk[Vk(e.atmosphereQuality)],...e.atmoQualityOverrides}}function Uk(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var Wk=30,Gk=45,Kk=3e3,qk=2500,Jk=250,Yk=60,Xk=0,Zk=qk,Qk=``;function $k(e,t){let n=Mx();if(n.atmosphereQuality!==`auto`||e<=0||e>Jk)return;let r=Uk(Hk());if(r!==Qk&&(Qk=r,Zk=qk,Xk=0,Yk=60),Yk+=(1e3/e-Yk)*Math.min(1,e/500),Zk>0){Zk-=e;return}if(!t||Yk>Gk){Xk=Math.max(0,Xk-e);return}if(Yk>=Wk||(Xk+=e,Xk<Kk))return;Xk=0;let i=Rk[Rk.indexOf(Vk(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var eA=256,tA=96;async function nA(e,t,n){let r=await fetch(e);if(!r.ok)throw Error(`Failed to load ${e}: ${r.status} ${r.statusText}`);let i=await r.blob(),a=await createImageBitmap(i),o=Math.min(a.width,n);o<a.width&&console.info(`Ring strip ${e}: downscaling ${a.width}px → ${o}px to fit GL MAX_TEXTURE_SIZE.`);let s=rA(a,e,n),c={};for(let[n,r]of Object.entries(t)){let t=document.createElement(`canvas`);t.width=o,t.height=2;let i=t.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);let l=iA(s,a.width,r,o);i.putImageData(l,0,0),i.putImageData(l,0,1);let u=new Nc(t);n===`color`&&(u.colorSpace=Xr),u.minFilter=Fn,u.magFilter=Nn,u.generateMipmaps=!0,u.anisotropy=16,u.needsUpdate=!0,c[n]=u}return a.close(),c}function rA(e,t,n){let r=new Uint8ClampedArray(e.width*e.height*4),i=document.createElement(`canvas`);i.width=Math.min(e.width,n),i.height=e.height;let a=i.getContext(`2d`,{willReadFrequently:!0});if(!a)throw Error(`Failed to acquire 2D context for ring strip ${t}`);for(let t=0;t<e.width;t+=i.width){let n=Math.min(i.width,e.width-t);a.clearRect(0,0,n,e.height),a.drawImage(e,t,0,n,e.height,0,0,n,e.height);let o=a.getImageData(0,0,n,e.height).data;for(let i=0;i<e.height;i++)r.set(o.subarray(i*n*4,(i+1)*n*4),(i*e.width+t)*4)}return r}function iA(e,t,n,r){let i=new ImageData(r,1);for(let a=0;a<r;a++){let o=Math.floor(a*t/r),s=Math.max(o+1,Math.floor((a+1)*t/r)),c=0,l=0,u=0;for(let r=o;r<s;r++){let i=(n*t+r)*4;c+=e[i],l+=e[i+1],u+=e[i+2]}let d=s-o,f=a*4;i.data[f]=Math.round(c/d),i.data[f+1]=Math.round(l/d),i.data[f+2]=Math.round(u/d),i.data[f+3]=255}return i}var aA=`
|
|
4569
|
+
`,UO=class{target;material;scene=new qa;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new la(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=Zr,this.target.texture.generateMipmaps=!1,this.material=new pu({vertexShader:VO,fragmentShader:HO,uniforms:{uPointSize:{value:zO}},blending:0,depthTest:!0,depthWrite:!0}),this.scene.matrixWorldAutoUpdate=!1,this.pickCamera=t.clone()}ensureSize(e){e!==this.size&&(this.size=e,this.target.setSize(e,e),this.buffer=new Uint8Array(e*e*4))}proxyAt(e,t){let n=this.proxies[e];return n?n.geometry=t.geometry:(n=new Ac(t.geometry,this.material),n.frustumCulled=!1,n.matrixAutoUpdate=!1,n.matrixWorldAutoUpdate=!1,this.proxies[e]=n),n.matrixWorld.copy(t.matrixWorld),n}pick(e,t,n,r,i,a){let o=Math.max(1,Math.round(a)),s=o*2+1;this.ensureSize(s);let c=n-i.left,l=r-i.top,u=c-o,d=l-o;this.scene.clear();let f=0;for(let t of e)t.visible&&t.geometry.getAttribute(`pickColor`)&&t.geometry.drawRange.count!==0&&this.scene.add(this.proxyAt(f++,t));if(f===0)return[];this.pickCamera.copy(t),this.pickCamera.setViewOffset(i.width,i.height,u,d,s,s),this.pickCamera.updateProjectionMatrix();let p=this.renderer.getRenderTarget(),m=this.renderer.autoClear;this.renderer.getClearColor(this.prevClear);let h=this.renderer.getClearAlpha();return this.renderer.setRenderTarget(this.target),this.renderer.autoClear=!1,this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!1),this.renderer.render(this.scene,this.pickCamera),this.renderer.readRenderTargetPixels(this.target,0,0,s,s,this.buffer),this.renderer.setRenderTarget(p),this.renderer.autoClear=m,this.renderer.setClearColor(this.prevClear,h),this.pickCamera.clearViewOffset(),this.decode(s,o,i,u,d)}decode(e,t,n,r,i){let a=this.buffer,o=new Map;for(let s=0;s<e;s++){let c=e-1-s;for(let l=0;l<e;l++){let u=(s*e+l)*4,d=(a[u]|a[u+1]<<8|a[u+2]<<16|a[u+3]<<24)>>>0;if(d===0)continue;let f=l-t,p=c-t,m=Math.hypot(f,p),h=o.get(d);if(h&&h.pixelDist<=m)continue;let g=r+l+.5,_=i+c+.5;o.set(d,{pickId:d,pixelDist:m,ndcX:g/n.width*2-1,ndcY:-(_/n.height*2-1)})}}return[...o.values()].sort((e,t)=>e.pixelDist-t.pixelDist).slice(0,BO)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function WO(e,t,n){return Math.min(Math.max(e,t),n)}function GO(e,t){let n=Math.max(e,0);return WO(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function KO(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return WO(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var qO={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},JO={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},YO={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},XO={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},ZO=new J(0,1,0),QO=(()=>{let e=Math.PI/180,t=192.85948*e,n=27.12825*e,r=Math.cos(n),i=r*Math.cos(t),a=r*Math.sin(t),o=Math.sin(n),s=ag*e,c=Math.cos(s),l=Math.sin(s),u=i,d=a*c+o*l;return new J(u,-a*l+o*c,-d).normalize()})();function $O(e){return(e??new J).copy(QO)}function ek(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&(i.set(e.position[0]-e.orbitCenter[0],e.position[1]-e.orbitCenter[1],e.position[2]-e.orbitCenter[2]),i.lengthSq()>1e-20)?i.normalize():(i.copy(ZO),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=mC(e.orientation,t,e.nutPrec);return i.copy(ZO).applyQuaternion(a).normalize()}var tk=class{refId=null;startVec=new J(0,1,0);targetVec=new J(0,1,0);currentVec=new J(0,1,0);animStartTime=-1/0;animDurationMs=JO.refMs;needsDurationCalc=!1;_quatA=new Hi;_quatB=new Hi;constructor(e,t,n,r){this.camera=e,this.controls=t,this.ctx=n,this.isLanded=r}setNorthReference(e){e!==this.refId&&(this.refId=e,this.startVec.copy(this.currentVec),this.animStartTime=performance.now(),this.needsDurationCalc=!0)}update(e){if(this.refId===`galactic`)$O(this.targetVec);else{let t=this.refId?this.ctx.getBody(this.refId):void 0;if(t){let n=!!t.featureAnchor||this.isLanded(t.data.id);ek(t,e,this.targetVec,n)}else this.targetVec.copy(ZO)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=GO(e,JO)}let t=performance.now()-this.animStartTime;if(t>=this.animDurationMs)this.currentVec.copy(this.targetVec);else{let e=Math.max(0,t/this.animDurationMs),n=e*e*(3-2*e);this._quatA.setFromUnitVectors(ZO,this.startVec),this._quatB.setFromUnitVectors(ZO,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy(ZO).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,ZO),n._quatInverse.copy(n._quat).invert()}},nk=class extends Ra{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new q(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}};new J,new Y,new Y,new J,new J;function rk(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}function ik(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function ak(e){switch(e){case W.STAR:return 0;case W.PLANET:return 1;case W.DWARF_PLANET:return 2;case W.MOON:return 3;default:return 4}}var ok=new J,sk=22;function ck(){return{cx0:0,cy0:0,f:0,gxx:0,gxy:0,gxz:0,gyx:0,gyy:0,gyz:0,gzx:0,gzy:0,gzz:0,cpx:0,cpy:0,cpz:0,K:0,id:``,dist:0,ccx:0,ccy:0,ccz:0}}var lk=new WeakMap;function uk(e){lk.delete(e)}function dk(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(lk.get(e)===t)return;lk.set(e,t),e.style.transform=`scale(${r})`,e.parentElement&&(e.parentElement.style.pointerEvents=n?``:`none`)}t&&(t.style.display=`none`,t.style.fontSize=``),i&&(i.style.display=`none`)}function fk(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(lk.get(e)===t)return;lk.set(e,t),n||(e.style.transform=``),e.style.border=e.dataset.origBorder??``,e.parentElement&&(e.parentElement.style.pointerEvents=``)}t&&(t.style.display=``,t.style.fontSize=r?`18px`:``),i&&(i.style.display=``)}function pk(e,t,n,r,i,a){let{label:o,labelHalo:s,radiusScene:c}=e;if(!o)return!1;let l=o.visible,u=!e.noPhysical&&c>0?c/r*i:0,d=e.body.data.id===a,f=u>=16;return!t&&n&&(d||u>=1)&&(t=u<320),f&&e.labelAnchorOffscreen&&(t=!1),e.trail&&f&&(e.trail.visible=!1),o.visible=t,s&&e.haloHidden!==f&&(s.style.visibility=f?`hidden`:``,e.haloHidden=f),e.loadingEl&&e.loadingShown!==f&&(e.loadingEl.style.display=f?``:`none`,e.loadingShown=f),o.center.x=f?1-4/32:.5,t&&!l}function mk(e,t,n,r,i){for(let a of i){if(a.id===r)continue;let i=e-a.cx0,o=a.cy0-t,s=-a.f,c=i*a.gxx+o*a.gxy+s*a.gxz,l=i*a.gyx+o*a.gyy+s*a.gyz,u=i*a.gzx+o*a.gzy+s*a.gzz,d=c*a.cpx+l*a.cpy+u*a.cpz;if(!(d<=0)&&!(d*d<=a.K*(c*c+l*l+u*u))&&i*a.ccx+o*a.ccy+s*a.ccz<=n*Math.hypot(i,o,s))return!0}return!1}function hk(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function gk(e,t,n,r,i,a){let o=e.label,[s,c,l]=e.body.position,u=o.position;ok.set(s-n[0]+u.x,c-n[1]+u.y,l-n[2]+u.z),ok.project(t),a.x=(ok.x*.5+.5)*r,a.y=(-ok.y*.5+.5)*i;let d=a.x-o.center.x*32;return a.left=d,a.right=d+40+(e.labelTextWidth||50),a.h=sk,aT(ok.z)}var _k=[],vk=0,yk=[],bk=0,xk=[],Sk=0,Ck={rects:yk,get count(){return bk}};function wk(){return{bodyId:``,bo:null,body:null,label:null,labelHalo:null,isCapped:!1,isMinor:!1,isFocused:!1,isSelected:!1,rect:{x:0,left:0,right:0,y:0,h:0},dist:0}}function Tk(){return{left:0,right:0,y:0,h:0}}var Ek={x:0,left:0,right:0,y:0,h:0};function Dk(e,t){for(let n=0;n<t;n++)hk(ik(xk,n,Tk),e[n]);Sk=t}function Ok(){for(let e=0;e<Sk;e++)hk(ik(yk,e,Tk),xk[e]);return Sk}function kk(e,t,n,r,i,a,o,s,c=[0,0,0]){vk=0,bk=Ok();for(let s of e.values()){let{body:e,label:l,labelHalo:u}=s;if(!l?.visible)continue;if(!s.labelTextWidth&&u){let e=u.nextElementSibling;e&&e.offsetWidth>0&&(s.labelTextWidth=e.offsetWidth)}if(!gk(s,r,c,t,n,Ek))continue;let d=e.data.id===i,f=o.has(e.data.id),p=ik(_k,vk++,wk);hk(p.rect,Ek),p.rect.x=Ek.x,p.bodyId=e.data.id,p.bo=s,p.body=e,p.label=l,p.labelHalo=u,p.isCapped=e.data.objectType===W.MOON?a.visibility.getMoonVisibility(e)===$.CAPPED:!1,p.isMinor=s.isMinor,p.isFocused=d,p.isSelected=d||f||a.visibility.isPinned(e.data.id),p.dist=s.cachedDist}_k.length=vk,_k.sort((e,t)=>{if(e.isSelected!==t.isSelected)return e.isSelected?-1:1;let n=e.isMinor&&!e.isSelected;if(n!==(t.isMinor&&!t.isSelected))return n?1:-1;let r=ak(e.body.data.objectType),i=ak(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<vk;e++){let t=_k[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){dk(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&mk(t.rect.x,t.rect.y,t.dist,t.bodyId,s)){t.label.visible=!1,t.bo.labelMaximized=!1;continue}if(t.isMinor&&!t.isSelected){let e=!1;for(let n=0;n<bk;n++){let r=yk[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<sk){e=!0;break}}dk(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<bk;e++){let n=yk[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<sk){i=!0;break}}i?(dk(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(hk(ik(yk,bk++,Tk),t.rect),fk(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<vk;e++){let t=_k[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function Ak(e,t,n,r,i){bk=Ok();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&gk(a,r,i,t,n,Ek)&&hk(ik(yk,bk++,Tk),Ek)}var jk=`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,Mk={flying:jk,landed:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`};function Nk(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,Mk[t])}function Pk(e,t,n,r){let i=document.createElement(`span`);i.className=`scene-label__name scene-label__name--${n}${r?` scene-label__name--large`:``}`,i.dir=`auto`,i.textContent=t;let a=e.firstElementChild;return a?a.after(i):e.appendChild(i),i}function Fk(e,t,n,r){if(n===`none`||!t||!e.label)return;let i=e.label.element,a=i.querySelector(`.scene-label__name`);a?a.textContent=t:Pk(i,t,n,r),nD(e)}function Ik(e){let t=e.data.objectType;return vn(t)||t===W.STAR||_n(t)||t===W.COMET||t===W.BARYCENTER||t===W.LAGRANGE_POINT?`major`:t===W.SPACECRAFT?`spacecraft`:t===W.DEBRIS?`debris`:`none`}function Lk(e,t,n,r,i,a=!1,o,s=!1){if(n===`none`)return null;let c=document.createElement(`a`);c.className=`scene-label scene-label--${n}`,r&&(c.href=r),c.tabIndex=-1,c.draggable=!1,t&&c.setAttribute(`aria-label`,t);let l;if(n===`major`){let t=document.createElement(`div`);t.className=`scene-label__halo scene-label__halo--major`,t.style.border=`2px solid ${e}`,t.style.background=`${e}22`,l=t}else{let t=`http://www.w3.org/2000/svg`,r=document.createElementNS(t,`svg`);r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`fill`,`${e}22`),r.setAttribute(`stroke`,e),r.setAttribute(`stroke-width`,`2`),r.setAttribute(`stroke-linejoin`,`round`),r.classList.add(`scene-label__halo`,`scene-label__halo--${n}`);let i=document.createElementNS(t,`path`);i.setAttribute(`d`,n===`debris`?`M3 5 L21 5 L12 21 Z`:jk),r.appendChild(i),l=r}c.appendChild(l);let u=0,d=0;c.addEventListener(`pointerdown`,e=>{u=e.clientX,d=e.clientY});let f=e=>{if(e.stopPropagation(),rk(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&Pk(c,t,n,a),s&&(l.style.transform=`scale(0.3)`),c.addEventListener(`click`,f),c.addEventListener(`mouseenter`,()=>{l.style.transform=`scale(1.15)`,document.body.style.cursor=`pointer`,o?.(!0)}),c.addEventListener(`mouseleave`,()=>{l.style.transform=s?`scale(0.3)`:``,uk(l),document.body.style.cursor=``,o?.(!1)});let p=new nk(c);return p.visible=!1,p}var Rk=3;function zk(e,t){e.addEventListener(`wheel`,e=>{let n=e;t.dispatchEvent(new WheelEvent(`wheel`,{deltaY:n.deltaY,deltaMode:n.deltaMode,bubbles:!0,cancelable:!0})),n.preventDefault()},{passive:!1}),e.addEventListener(`pointerdown`,e=>{let n=e.clientX,r=e.clientY,i=e,a=e=>{let a=e.clientX-n,o=e.clientY-r;a*a+o*o>Rk*Rk&&(s(),t.dispatchEvent(new PointerEvent(`pointerdown`,i)),t.dispatchEvent(new PointerEvent(`pointermove`,e)))},o=()=>s(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)})}var Bk=[`low`,`medium`,`high`,`ultra`],Vk={low:{primarySteps:6,lightSteps:2,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},medium:{primarySteps:12,lightSteps:3,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!1,layeredDensity:!1,groundAlbedo:!0,seasonal:!0,refraction:!0},high:{primarySteps:16,lightSteps:4,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0},ultra:{primarySteps:32,lightSteps:8,eclipseShadows:!0,ringShadows:!0,insideView:!0,sunTint:!0,layeredDensity:!0,groundAlbedo:!0,seasonal:!0,refraction:!0}};function Hk(){return Wx()?Hx()?`low`:`medium`:Hx()?`high`:`ultra`}function Uk(e){if(e!==`auto`)return e;let t=Mx();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??Hk()}function Wk(){let e=Mx();return{...Vk[Uk(e.atmosphereQuality)],...e.atmoQualityOverrides}}function Gk(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var Kk=30,qk=45,Jk=3e3,Yk=2500,Xk=250,Zk=60,Qk=0,$k=Yk,eA=``;function tA(e,t){let n=Mx();if(n.atmosphereQuality!==`auto`||e<=0||e>Xk)return;let r=Gk(Wk());if(r!==eA&&(eA=r,$k=Yk,Qk=0,Zk=60),Zk+=(1e3/e-Zk)*Math.min(1,e/500),$k>0){$k-=e;return}if(!t||Zk>qk){Qk=Math.max(0,Qk-e);return}if(Zk>=Kk||(Qk+=e,Qk<Jk))return;Qk=0;let i=Bk[Bk.indexOf(Uk(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var nA=256,rA=96;async function iA(e,t,n){let r=await fetch(e);if(!r.ok)throw Error(`Failed to load ${e}: ${r.status} ${r.statusText}`);let i=await r.blob(),a=await createImageBitmap(i),o=Math.min(a.width,n);o<a.width&&console.info(`Ring strip ${e}: downscaling ${a.width}px → ${o}px to fit GL MAX_TEXTURE_SIZE.`);let s=aA(a,e,n),c={};for(let[n,r]of Object.entries(t)){let t=document.createElement(`canvas`);t.width=o,t.height=2;let i=t.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);let l=oA(s,a.width,r,o);i.putImageData(l,0,0),i.putImageData(l,0,1);let u=new Nc(t);n===`color`&&(u.colorSpace=Xr),u.minFilter=Fn,u.magFilter=Nn,u.generateMipmaps=!0,u.anisotropy=16,u.needsUpdate=!0,c[n]=u}return a.close(),c}function aA(e,t,n){let r=new Uint8ClampedArray(e.width*e.height*4),i=document.createElement(`canvas`);i.width=Math.min(e.width,n),i.height=e.height;let a=i.getContext(`2d`,{willReadFrequently:!0});if(!a)throw Error(`Failed to acquire 2D context for ring strip ${t}`);for(let t=0;t<e.width;t+=i.width){let n=Math.min(i.width,e.width-t);a.clearRect(0,0,n,e.height),a.drawImage(e,t,0,n,e.height,0,0,n,e.height);let o=a.getImageData(0,0,n,e.height).data;for(let i=0;i<e.height;i++)r.set(o.subarray(i*n*4,(i+1)*n*4),(i*e.width+t)*4)}return r}function oA(e,t,n,r){let i=new ImageData(r,1);for(let a=0;a<r;a++){let o=Math.floor(a*t/r),s=Math.max(o+1,Math.floor((a+1)*t/r)),c=0,l=0,u=0;for(let r=o;r<s;r++){let i=(n*t+r)*4;c+=e[i],l+=e[i+1],u+=e[i+2]}let d=s-o,f=a*4;i.data[f]=Math.round(c/d),i.data[f+1]=Math.round(l/d),i.data[f+2]=Math.round(u/d),i.data[f+3]=255}return i}var sA=`
|
|
4559
4570
|
#include <common>
|
|
4560
4571
|
#include <logdepthbuf_pars_vertex>
|
|
4561
4572
|
|
|
@@ -4590,7 +4601,7 @@ void main() {
|
|
|
4590
4601
|
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
|
4591
4602
|
#include <logdepthbuf_vertex>
|
|
4592
4603
|
}
|
|
4593
|
-
`,
|
|
4604
|
+
`,cA=`
|
|
4594
4605
|
#include <common>
|
|
4595
4606
|
#include <logdepthbuf_pars_fragment>
|
|
4596
4607
|
|
|
@@ -4706,7 +4717,7 @@ void main() {
|
|
|
4706
4717
|
gl_FragColor = vec4(finalAlbedo * uIntensityScale * shadow * uLightScale, alpha);
|
|
4707
4718
|
#include <logdepthbuf_fragment>
|
|
4708
4719
|
}
|
|
4709
|
-
`,
|
|
4720
|
+
`,lA=`
|
|
4710
4721
|
uniform sampler2D uRingShadowTransparency;
|
|
4711
4722
|
uniform float uRingShadowInnerScene;
|
|
4712
4723
|
uniform float uRingShadowOuterScene; // 0 = no rings
|
|
@@ -4759,14 +4770,14 @@ void main() {
|
|
|
4759
4770
|
// to avoid blow-up near grazing incidence.
|
|
4760
4771
|
return pow(max(trans, 1e-4), 1.0 / max(abs(denom), 0.02));
|
|
4761
4772
|
}
|
|
4762
|
-
`;function
|
|
4773
|
+
`;function uA(e,t,n,r,i){let a=e.userData,o=a.ringShadow;if(o)return o.uRingShadowTransparency.value=r,o.uRingShadowInnerScene.value=t,o.uRingShadowOuterScene.value=n,o.uRingShadowIntensity.value=i,o;let s=e.onBeforeCompile,c={uRingShadowTransparency:{value:r},uRingShadowInnerScene:{value:t},uRingShadowOuterScene:{value:n},uRingShadowIntensity:{value:i},uRingShadowSunAngularRadius:{value:0},uRingShadowSunDir:{value:new J(1,0,0)},uRingShadowPoleDir:{value:new J(0,1,0)},uRingShadowCenter:{value:new J(0,0,0)},disable:()=>{c.uRingShadowIntensity.value=0,c.uRingShadowTransparency.value=null}};return e.onBeforeCompile=(e,t)=>{s?.(e,t),Object.assign(e.uniforms,c),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
4763
4774
|
varying vec3 vRingShadowWorldPos;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
4764
4775
|
vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
4765
4776
|
varying vec3 vRingShadowWorldPos;
|
|
4766
|
-
${
|
|
4777
|
+
${lA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
|
|
4767
4778
|
float ringShadow = ringShadowAt(vRingShadowWorldPos);
|
|
4768
4779
|
reflectedLight.directDiffuse *= ringShadow;
|
|
4769
|
-
reflectedLight.directSpecular *= ringShadow;`)},PC(e,`ringShadow`),e.needsUpdate=!0,a.ringShadow=c,c}async function
|
|
4780
|
+
reflectedLight.directSpecular *= ringShadow;`)},PC(e,`ringShadow`),e.needsUpdate=!0,a.ringShadow=c,c}async function dA(e,t,n){let r=Q(t.inner_radius_km),i=Q(t.outer_radius_km),a=t.intensity_scale??1,o;try{o=await iA(Yt(`/v1/rings/${e}/${t.strip}`,`rings`),t.strip_rows,n)}catch(t){return console.warn(`Failed to load ring strip for ${e}:`,t),null}let s=t.thickness_scale_km&&o.thickness?Q(t.thickness_scale_km):0,c=s>0?48:1,l=new fu({uniforms:{uBackscattered:{value:o.backscattered},uForwardscattered:{value:o.forwardscattered},uUnlitside:{value:o.unlitside},uTransparency:{value:o.transparency},uColor:{value:o.color},uThickness:{value:o.thickness??o.transparency},uThicknessScene:{value:s},uLayerCount:{value:1},uLayerAlphaExp:{value:1},uInnerScene:{value:r},uOuterScene:{value:i},uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uPlanetCenter:{value:new J},uPlanetPoleDir:{value:new J(0,1,0)},uPlanetEquatorialScene:{value:0},uPlanetPolarScene:{value:0},uLightScale:{value:1},uIntensityScale:{value:a}},vertexShader:sA,fragmentShader:cA,transparent:!0,depthWrite:!1,blending:1,side:2}),u=new eu(r,i*(1/Math.cos(Math.PI/nA)),nA,c>1?rA:1);u.rotateX(-Math.PI/2);let d;if(c>1){u.setAttribute(`aLayerIndex`,new Js(Float32Array.from({length:c},(e,t)=>t),1));let e=new nc(u,l,c);e.count=1,d=e}else d=new As(u,l);d.frustumCulled=!1,d.renderOrder=3,d.userData.isRingMesh=!0;let f={uPlanetCenter:l.uniforms.uPlanetCenter,uPlanetPoleDir:l.uniforms.uPlanetPoleDir,uPlanetEquatorialScene:l.uniforms.uPlanetEquatorialScene,uPlanetPolarScene:l.uniforms.uPlanetPolarScene};return{mesh:d,material:l,layers:d instanceof nc?d:null,thicknessScene:s,transparency:o.transparency,intensityScale:a,innerScene:r,outerScene:i,planetShadow:null,planetShadowOnRing:f}}function fA(e){e.mesh.geometry.dispose();let t=e.material.uniforms;for(let e of[`uBackscattered`,`uForwardscattered`,`uUnlitside`,`uTransparency`,`uColor`,`uThickness`])(t[e]?.value)?.dispose();e.mesh.material.dispose()}var pA=null;function mA(){return pA||(pA=new Ws(new Uint8Array([255,255,255,255]),1,1),pA.needsUpdate=!0),pA}function hA(e){let t=new Float32Array(e.length*4);for(let n=0;n<e.length;n++)t[n*4]=e[n],t[n*4+3]=1;let n=new Ws(t,e.length,1,Zn,Hn);return n.needsUpdate=!0,n}function gA(e,t,n){if(t===n)return;let r=e.uniforms;r.uMieProfileTex.value!==pA&&r.uMieProfileTex.value.dispose(),r.uMieProfileTex.value=n?hA(n):mA(),r.uMieProfileOn.value=+!!n,r.uMieProfileN.value=n?.length??1}function _A(e){let t=new Float32Array(512);for(let n=0;n<128;n++)t[n*4]=e[n],t[n*4+1]=e[n+128],t[n*4+2]=e[n+256],t[n*4+3]=1;let n=new Ws(t,128,1,Zn,Hn);return n.needsUpdate=!0,n}var vA=new WeakMap;function yA(e){let t=vA.get(e);if(t)return t;let n=e.n,r=new Float32Array(n*3*4),i=[e.fluxDown,e.fluxUpRatio,e.extinctionPerKm];for(let e=0;e<3;e++)for(let t=0;t<n;t++){let a=(e*n+t)*4;for(let o=0;o<3;o++)r[a+o]=i[e][o*n+t];r[a+3]=1}return t=new Ws(r,n,3,Zn,Hn),t.needsUpdate=!0,vA.set(e,t),t}function bA(e,t,n){if(t===n)return;let r=e.uniforms;r.uDeepTex.value=n?yA(n):mA(),r.uDeepN.value=n?.n??1}function xA(e,t){return t+(e.referenceAltitudeKm??0)}var SA=`
|
|
4770
4781
|
#include <common>
|
|
4771
4782
|
#include <logdepthbuf_pars_vertex>
|
|
4772
4783
|
|
|
@@ -4783,7 +4794,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
4783
4794
|
gl_Position = projectionMatrix * viewMatrix * worldPos;
|
|
4784
4795
|
#include <logdepthbuf_vertex>
|
|
4785
4796
|
}
|
|
4786
|
-
`,
|
|
4797
|
+
`,CA=`
|
|
4787
4798
|
#include <common>
|
|
4788
4799
|
#include <logdepthbuf_pars_fragment>
|
|
4789
4800
|
|
|
@@ -4854,7 +4865,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
4854
4865
|
|
|
4855
4866
|
// Ring shadow on the air column: the same uniforms the planet surface
|
|
4856
4867
|
// marches, shared by value-ref once rings load.
|
|
4857
|
-
${
|
|
4868
|
+
${lA}
|
|
4858
4869
|
|
|
4859
4870
|
// PRIMARY_STEPS / LIGHT_STEPS and the ATMO_ECLIPSE / ATMO_RING_SHADOW /
|
|
4860
4871
|
// ATMO_INSIDE feature flags come from material.defines — quality tiers
|
|
@@ -5065,7 +5076,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5065
5076
|
if (hitGeom && fwd > 1e-4) {
|
|
5066
5077
|
float terrainW = uReversedDepth > 0.5
|
|
5067
5078
|
? uCameraNear * uCameraFar / (d * (uCameraFar - uCameraNear) + uCameraNear)
|
|
5068
|
-
:
|
|
5079
|
+
: ${cT(`d`,`uCameraFar`)};
|
|
5069
5080
|
float tTerrain = terrainW * dLen / (uPlanetRadiusScene * fwd);
|
|
5070
5081
|
if (tTerrain < tEnd) {
|
|
5071
5082
|
tEnd = tTerrain;
|
|
@@ -5264,7 +5275,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5264
5275
|
gl_FragColor = vec4(color, alpha);
|
|
5265
5276
|
#include <logdepthbuf_fragment>
|
|
5266
5277
|
}
|
|
5267
|
-
`;function
|
|
5278
|
+
`;function wA(e,t,n,r){let i=e=>e*r,a=t.rayleighScatterPerKm,o=t.mieScatterPerKm,s=t.mieAbsorptionPerKm,c=t.absorptionPerKm,l=e.uniforms;l.uPlanetRadiusScene.value=n,l.uAtmosphereRatio.value=1+t.topAltitudeKm/r,l.uSurfaceBlockR.value=1,l.uRayleighScatter.value.set(i(a[0]),i(a[1]),i(a[2])),l.uRayleighScaleHeight.value=t.rayleighScaleHeightKm/r,l.uMieScatter.value.set(i(o[0]),i(o[1]),i(o[2])),l.uMieExtinction.value.set(i(o[0]+s[0]),i(o[1]+s[1]),i(o[2]+s[2])),l.uMieScaleHeight.value=t.mieScaleHeightKm/r,l.uAbsorption.value.set(i(c[0]),i(c[1]),i(c[2])),l.uAbsorptionCenter.value=t.absorptionCenterKm/r,l.uAbsorptionWidth.value=t.absorptionWidthKm/r,l.uDeepBaseR.value=1-(t.referenceAltitudeKm??0)/r,l.uDeepSpanR.value=t.deepColumn?t.deepColumn.topKm/r:0,l.uDeepKmPerRadius.value=r}function TA(e,t,n){let r=xA(e,n),i=t*r/n,a=e.sunColor,o=RC(),s=Wk(),c=new fu({defines:jA(s),uniforms:{uSunAngularRadius:o.uSunAngularRadius,uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new sa)},uSunDir:{value:new J(1,0,0)},uSpinAxis:{value:new J(0,1,0)},uStretch:{value:1},uPlanetRadiusScene:{value:0},uAtmosphereRatio:{value:0},uSurfaceBlockR:{value:1},uRingShadowTransparency:{value:mA()},uRingShadowInnerScene:{value:0},uRingShadowOuterScene:{value:0},uRingShadowIntensity:{value:1},uRingShadowSunAngularRadius:{value:0},uRingShadowSunDir:{value:new J(1,0,0)},uRingShadowPoleDir:{value:new J(0,1,0)},uRingShadowCenter:{value:new J},uRayleighScatter:{value:new J},uRayleighScaleHeight:{value:0},uMieScatter:{value:new J},uMieExtinction:{value:new J},uMieScaleHeight:{value:0},uMiePhaseTex:{value:_A(e.miePhase)},uMieProfileTex:{value:e.mieProfile?hA(e.mieProfile):mA()},uMieProfileOn:{value:+!!e.mieProfile},uMieProfileN:{value:e.mieProfile?.length??1},uDeepTex:{value:e.deepColumn?yA(e.deepColumn):mA()},uDeepN:{value:e.deepColumn?.n??1},uDeepBaseR:{value:1},uDeepSpanR:{value:0},uDeepKmPerRadius:{value:1},uDeepOn:{value:0},uDeepBlend:{value:0},uDeepIrradiance:{value:0},uGroundAlbedo:{value:e.groundAlbedo??0},uAbsorption:{value:new J},uAbsorptionCenter:{value:0},uAbsorptionWidth:{value:0},uMultiScatter:{value:e.multiScatterGain},uBakedComp:{value:e.bakedCompensation},uSunIntensity:{value:e.sunIntensity},uSunColor:{value:new J(a[0],a[1],a[2])},uSceneDepth:{value:mA()},uUseDepth:{value:0},uReversedDepth:{value:0},uCamForward:{value:new J(0,0,-1)},uCameraNear:{value:.001},uCameraFar:{value:1},uResolution:{value:new q(1,1)}},vertexShader:SA,fragmentShader:CA,transparent:!0,depthWrite:!0,blending:5,blendSrc:201,blendDst:205,side:0});wA(c,e,i,r);let l=i*(1+e.topAltitudeKm/r),u=new As(new ru(l,64,64),c);return u.renderOrder=2,u.userData.isAtmosphereMesh=!0,{mesh:u,material:c,params:e,geometryRadiusScene:l,planetRadiusKm:r,surfaceRadiusKm:n,surfaceRadiusScene:t,qualityKey:Gk(s)}}function EA(e,t,n,r=+!!n){let i=e.material,a=i.uniforms,o=e.planetRadiusKm-e.surfaceRadiusKm;i.side=+!!t,e.mesh.renderOrder=t?10:2,i.depthWrite=!t,i.depthTest=!t;let s=t&&(n||o===0);a.uUseDepth.value=+!!s,a.uSurfaceBlockR.value=s?1-(o+6)/e.planetRadiusKm:1,a.uDeepOn.value=+!!n,a.uDeepBlend.value=r}var DA=2;function OA(e){return(e.deepColumn?.topKm??0)-(e.referenceAltitudeKm??0)}function kA(e,t){return!!e.deepColumn&&t<OA(e)}function AA(e,t){if(!e.deepColumn)return 0;let n=DA*e.mieScaleHeightKm,r=Math.min(1,Math.max(0,(t-OA(e))/n));return 1-r*r*(3-2*r)}function jA(e){let t={PRIMARY_STEPS:e.primarySteps,LIGHT_STEPS:e.lightSteps};return e.eclipseShadows&&(t.ATMO_ECLIPSE=``),e.ringShadows&&(t.ATMO_RING_SHADOW=``),e.insideView&&(t.ATMO_INSIDE=``),e.layeredDensity&&(t.ATMO_LAYERED=``),t}function MA(e,t){let n=Gk(t);n!==e.qualityKey&&(e.qualityKey=n,e.material.defines=jA(t),e.material.needsUpdate=!0)}function NA(e,t){gA(e.material,e.params.mieProfile,t.mieProfile),bA(e.material,e.params.deepColumn,t.deepColumn),e.params=t;let n=e.material.uniforms;n.uGroundAlbedo.value=t.groundAlbedo??0,e.planetRadiusKm=xA(t,e.surfaceRadiusKm);let r=e.surfaceRadiusScene*e.planetRadiusKm/e.surfaceRadiusKm;wA(e.material,t,r,e.planetRadiusKm),n.uMultiScatter.value=t.multiScatterGain,n.uBakedComp.value=t.bakedCompensation;let i=t.sunColor;n.uSunColor.value.set(i[0],i[1],i[2]);let a=r*(1+t.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function PA(e,t,n,r){e.surfaceRadiusKm=t,e.surfaceRadiusScene=r,e.planetRadiusKm=xA(e.params,t);let i=r*e.planetRadiusKm/t;wA(e.material,e.params,i,e.planetRadiusKm),e.material.uniforms.uStretch.value=e.planetRadiusKm/xA(e.params,n);let a=i*(1+e.params.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function FA(e,t,n,r,i){let a=e.material.uniforms;a.uRingShadowTransparency.value=n,a.uRingShadowInnerScene.value=r,a.uRingShadowOuterScene.value=i,a.uRingShadowSunDir=t.uRingShadowSunDir,a.uRingShadowPoleDir=t.uRingShadowPoleDir,a.uRingShadowCenter=t.uRingShadowCenter,a.uRingShadowIntensity=t.uRingShadowIntensity,a.uRingShadowSunAngularRadius=t.uRingShadowSunAngularRadius}function IA(e){e.mesh.geometry.dispose(),e.material.uniforms.uMiePhaseTex.value.dispose();let t=e.material.uniforms.uMieProfileTex.value;t!==pA&&t.dispose(),e.mesh.material.dispose()}var LA=6,RA=16,zA={uAtmoTEnable:{value:1}};function BA(e){zA.uAtmoTEnable.value=+!!e}var VA=`
|
|
5268
5279
|
uniform vec3 uAtmoTBetaR; // Rayleigh β, per planet radius, (R,G,B)
|
|
5269
5280
|
uniform vec3 uAtmoTBetaMExt; // Mie extinction β, per planet radius
|
|
5270
5281
|
uniform vec3 uAtmoTBetaA; // absorber band β, per planet radius
|
|
@@ -5314,11 +5325,11 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5314
5325
|
vec3 atmoTSquash(vec3 v) {
|
|
5315
5326
|
return v + (uAtmoTStretch - 1.0) * dot(v, uAtmoTSpinAxis) * uAtmoTSpinAxis;
|
|
5316
5327
|
}
|
|
5317
|
-
`,
|
|
5328
|
+
`,HA=`
|
|
5318
5329
|
// Eclipse's uSunDir/uEclipseSelfPos are declared after this chunk's
|
|
5319
5330
|
// insertion point — same value refs re-bound under own names.
|
|
5320
5331
|
uniform vec3 uAtmoTSunDir;
|
|
5321
|
-
${
|
|
5332
|
+
${VA}
|
|
5322
5333
|
|
|
5323
5334
|
// Column (∫density above h) of the linear-tent absorber, in radii of
|
|
5324
5335
|
// surface-density-equivalent path — mirrors tentColumnAboveKm.
|
|
@@ -5368,9 +5379,9 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5368
5379
|
float tFar = -b + sqrt(d);
|
|
5369
5380
|
if (tFar <= 0.0) return vec3(1.0);
|
|
5370
5381
|
// Fragment sits inside the shell → the segment starts at the fragment.
|
|
5371
|
-
float dt = tFar / ${
|
|
5382
|
+
float dt = tFar / ${LA.toFixed(1)};
|
|
5372
5383
|
vec3 od = vec3(0.0);
|
|
5373
|
-
for (int i = 0; i < ${
|
|
5384
|
+
for (int i = 0; i < ${LA}; i++) {
|
|
5374
5385
|
float h = max(length(p + sd * (dt * (float(i) + 0.5))) - 1.0, 0.0);
|
|
5375
5386
|
od += vec3(
|
|
5376
5387
|
exp(-h / uAtmoTRayleighH),
|
|
@@ -5410,8 +5421,8 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5410
5421
|
float w = 0.5 + 0.5 * dot(worldNormal, up);
|
|
5411
5422
|
return mix(down * atmoTDeepTap(1.0, zf), down, w) * uAtmoTDeepBlend;
|
|
5412
5423
|
}
|
|
5413
|
-
`,
|
|
5414
|
-
${
|
|
5424
|
+
`,UA=`
|
|
5425
|
+
${VA}
|
|
5415
5426
|
|
|
5416
5427
|
vec3 atmoViewTint(vec3 worldPos) {
|
|
5417
5428
|
if (uAtmoTEnable < 0.5) return vec3(1.0);
|
|
@@ -5429,9 +5440,9 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5429
5440
|
float t1 = -b + s;
|
|
5430
5441
|
if (t1 <= 0.0) return vec3(1.0);
|
|
5431
5442
|
float t0 = max(-b - s, 0.0);
|
|
5432
|
-
float dt = (t1 - t0) / ${
|
|
5443
|
+
float dt = (t1 - t0) / ${LA.toFixed(1)};
|
|
5433
5444
|
vec3 od = vec3(0.0);
|
|
5434
|
-
for (int i = 0; i < ${
|
|
5445
|
+
for (int i = 0; i < ${LA}; i++) {
|
|
5435
5446
|
float h = max(length(p + rd * (t0 + dt * (float(i) + 0.5))) - 1.0, 0.0);
|
|
5436
5447
|
od += vec3(
|
|
5437
5448
|
exp(-h / uAtmoTRayleighH),
|
|
@@ -5444,13 +5455,13 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5444
5455
|
float lum = dot(t, vec3(0.2126, 0.7152, 0.0722));
|
|
5445
5456
|
return t / max(lum, 1e-4);
|
|
5446
5457
|
}
|
|
5447
|
-
`;function
|
|
5458
|
+
`;function WA(e){return{uAtmoTBetaR:{value:new J},uAtmoTBetaMExt:{value:new J},uAtmoTBetaA:{value:new J},uAtmoTRayleighH:{value:0},uAtmoTMieH:{value:0},uAtmoTAbsCenter:{value:0},uAtmoTAbsWidth:{value:0},uAtmoTTopR:{value:0},uAtmoTBlockR:{value:0},uAtmoTBakedComp:{value:0},uAtmoTRadiusScene:{value:0},uAtmoTEnable:e,uAtmoTSpinAxis:{value:new J(0,1,0)},uAtmoTStretch:{value:1},uAtmoTMeshR:{value:1},uAtmoTDeepTex:{value:KA()},uAtmoTDeepN:{value:1},uAtmoTDeepBaseR:{value:1},uAtmoTDeepSpanR:{value:0},uAtmoTDeepKmPerRadius:{value:1},uAtmoTDeepIrradiance:{value:0},uAtmoTDeepBlend:{value:0}}}var GA=null;function KA(){return GA||(GA=new Ws(new Uint8Array([255,255,255,255]),1,1),GA.needsUpdate=!0),GA}function qA(e,t,n,r){let i=r;r=xA(t,i),n=n*r/i;let a=e=>e*r,o=t.rayleighScatterPerKm,s=t.mieScatterPerKm,c=t.mieAbsorptionPerKm,l=t.absorptionPerKm;e.uAtmoTBetaR.value.set(a(o[0]),a(o[1]),a(o[2])),e.uAtmoTBetaMExt.value.set(a(s[0]+c[0]),a(s[1]+c[1]),a(s[2]+c[2])),e.uAtmoTBetaA.value.set(a(l[0]),a(l[1]),a(l[2])),e.uAtmoTRayleighH.value=t.rayleighScaleHeightKm/r,e.uAtmoTMieH.value=t.mieScaleHeightKm/r,e.uAtmoTAbsCenter.value=t.absorptionCenterKm/r,e.uAtmoTAbsWidth.value=t.absorptionWidthKm/r,e.uAtmoTTopR.value=1+t.topAltitudeKm/r,e.uAtmoTBlockR.value=1-6/r-.015,e.uAtmoTBakedComp.value=t.bakedCompensation,e.uAtmoTRadiusScene.value=n;let u=t.deepColumn;e.uAtmoTDeepTex.value=u?yA(u):KA(),e.uAtmoTDeepN.value=u?.n??1,e.uAtmoTDeepBaseR.value=i/r,e.uAtmoTDeepSpanR.value=u?u.topKm/r:0,e.uAtmoTDeepKmPerRadius.value=r}function JA(){return{...WA({value:0}),uAtmoTCenter:{value:new J}}}function YA(e,t,n,r,i,a,o=1){qA(e,t,r,i),e.uAtmoTCenter.value.copy(n),a?e.uAtmoTSpinAxis.value.copy(a):e.uAtmoTSpinAxis.value.set(0,1,0),e.uAtmoTStretch.value=o,e.uAtmoTEnable.value=1}function XA(e,t,n,r,i,a,o=1){let s={...WA(zA.uAtmoTEnable),uAtmoTSunDir:RC().uSunDir,uAtmoTCenter:i.uEclipseSelfPos};return s.uAtmoTMeshR.value=o*r/xA(t,r),a&&(s.uAtmoTSpinAxis=a.material.uniforms.uSpinAxis,s.uAtmoTStretch=a.material.uniforms.uStretch),qA(s,t,n,r),FC(e,`sunTint`,e=>{Object.assign(e.uniforms,s),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${HA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
|
|
5448
5459
|
vec3 atmoTint = atmoSunTint(vEclipseWorldPos);
|
|
5449
5460
|
reflectedLight.directDiffuse *= atmoTint;
|
|
5450
5461
|
reflectedLight.directSpecular *= atmoTint;
|
|
5451
5462
|
reflectedLight.indirectDiffuse +=
|
|
5452
5463
|
atmoDeepSkyLight(vEclipseWorldPos, inverseTransformDirection(normal, viewMatrix)) *
|
|
5453
|
-
BRDF_Lambert(diffuseColor.rgb);`)}),s}var
|
|
5464
|
+
BRDF_Lambert(diffuseColor.rgb);`)}),s}var ZA=new J,QA=new J;function $A(e,t,n){return!t||n===1?e:e.addScaledVector(t,(n-1)*e.dot(t))}function ej(e,t,n,r,i,a,o,s=1){let c=i;i=xA(e,c),r=r*i/c;let l=$A(ZA.copy(t).divideScalar(r),o,s),u=$A(QA.copy(n),o,s),d=u.length();u.divideScalar(d);let f=1+e.topAltitudeKm/i,p=1-6/i-.015,m=l.dot(u),h=l.lengthSq(),g=m*m-(h-p*p);if(g>0&&-m-Math.sqrt(g)>0||(g=m*m-(h-f*f),g<=0))return!1;let _=Math.sqrt(g),v=-m+_;if(v<=0)return!1;let y=Math.max(-m-_,0),b=(v-y)/RA,x=b*i/d,S=0,C=0,w=0;for(let t=0;t<RA;t++){let n=y+b*(t+.5),r=Math.max((Math.hypot(l.x+u.x*n,l.y+u.y*n,l.z+u.z*n)-1)*i,0);S+=Math.exp(-r/e.rayleighScaleHeightKm)*x,C+=Math.exp(-r/e.mieScaleHeightKm)*x,w+=Math.max(0,1-Math.abs(r-e.absorptionCenterKm)/e.absorptionWidthKm)*x}let T=e.rayleighScatterPerKm,E=e.mieScatterPerKm,D=e.mieAbsorptionPerKm,O=e.absorptionPerKm;return a.set(Math.exp(-(T[0]*S+(E[0]+D[0])*C+O[0]*w)),Math.exp(-(T[1]*S+(E[1]+D[1])*C+O[1]*w)),Math.exp(-(T[2]*S+(E[2]+D[2])*C+O[2]*w))),!0}var tj=6*.8/.3;function nj(e,t=256){let n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=t/2,a=r.createRadialGradient(i,i,0,i,i,i);return a.addColorStop(0,ij(e,1)),a.addColorStop(.15,ij(e,1)),a.addColorStop(.4,ij(e,.3)),a.addColorStop(1,ij(e,0)),r.fillStyle=a,r.fillRect(0,0,t,t),new Nc(n)}function rj(e){return`rgb(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)})`}function ij(e,t){return e.replace(`)`,`, ${t})`).replace(`rgb(`,`rgba(`)}var aj=`#fff5eb`,oj=`#ffd9a8`;function sj(){let e=new X(aj),t=new X(oj);return new fu({uniforms:{uCentreColor:{value:new J(e.r,e.g,e.b)},uLimbColor:{value:new J(t.r,t.g,t.b)},uLimbAlpha:{value:new J(.5,.5,.5)},...JA()},vertexShader:`
|
|
5454
5465
|
#include <common>
|
|
5455
5466
|
#include <logdepthbuf_pars_vertex>
|
|
5456
5467
|
varying vec3 vNormalView;
|
|
@@ -5473,7 +5484,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5473
5484
|
varying vec3 vNormalView;
|
|
5474
5485
|
varying vec3 vViewDir;
|
|
5475
5486
|
varying vec3 vWorldPos;
|
|
5476
|
-
${
|
|
5487
|
+
${UA}
|
|
5477
5488
|
void main() {
|
|
5478
5489
|
#include <logdepthbuf_fragment>
|
|
5479
5490
|
float mu = max(dot(normalize(vNormalView), normalize(vViewDir)), 0.0);
|
|
@@ -5488,7 +5499,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5488
5499
|
vec3 hdr = tint * darkening * ${6 .toFixed(1)};
|
|
5489
5500
|
gl_FragColor = vec4(atmoViewTint(vWorldPos) * hdr, 1.0);
|
|
5490
5501
|
}
|
|
5491
|
-
`})}function
|
|
5502
|
+
`})}function cj(e,t){let n=new cs(new Jo({map:nj(t.startsWith(`#`)?rj(t):t),blending:2,transparent:!0,opacity:.6,depthWrite:!1,depthTest:!0})),r=e*6;return n.scale.set(r,r,1),n}function lj(e,t){let n=new Ho;n.setAttribute(`position`,new Ao(new Float32Array(3),3));let r=new X(e),i=new Ac(n,new fu({uniforms:{uColor:{value:new J(r.r,r.g,r.b)},uIntensity:{value:tj},uTint:{value:new J(1,1,1)},uMap:{value:t}},vertexShader:`
|
|
5492
5503
|
#include <common>
|
|
5493
5504
|
#include <logdepthbuf_pars_vertex>
|
|
5494
5505
|
void main() {
|
|
@@ -5509,7 +5520,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
|
|
|
5509
5520
|
if (texel.a < 0.01) discard;
|
|
5510
5521
|
gl_FragColor = vec4(uTint * uColor * uIntensity, texel.a);
|
|
5511
5522
|
}
|
|
5512
|
-
`,transparent:!0,depthTest:!0,depthWrite:!1}));return i.frustumCulled=!1,i}function
|
|
5523
|
+
`,transparent:!0,depthTest:!0,depthWrite:!1}));return i.frustumCulled=!1,i}function uj(e,t,n,r){let i=new dd(16777215,xT,0,0);e.add(i);let a=cj(t,n);e.add(a);let o=lj(n,r);return e.add(o),{light:i,corona:a,starPoint:o}}function dj(e,t,n){e&&e.material.color.setRGB(n.x,n.y,n.z),t&&t.material.uniforms.uTint.value.copy(n)}function fj(e){let t=e?.uniforms;return t?.uAtmoTEnable?t:null}function pj(e,t){let n=e?.uniforms;t&&n?.uLimbAlpha&&n.uLimbAlpha.value.set(t[0],t[1],t[2])}function mj(e){if(Array.isArray(e))for(let t of e)t.dispose();else e.dispose()}var hj=96,gj=24;function _j(e,t,n,r,i,o,s,c,l,u){for(let d of e){let e=d.data.id,f=u?.has(e)??!1,p=d.data.objectType,m=f||p===W.BARYCENTER||p===W.LAGRANGE_POINT||p===W.COMET||_n(p)||d.data.orbitalSource===U.SPICE_PROBE,h=h_(d.data),g=Q(gn(d.data)),_=p===W.STAR,v=$D(d),y=Number.isFinite(d.data.radiusKm)&&d.data.radiusKm>0,b=!v&&yn(p)&&!y?`radius`:void 0,x=new za;x.position.set(0,0,0);let S=null,C=null,w=null,T=null,E,D=[];if(!m&&!b){_&&(C=uj(t,g,h,o),D.push(C.light,C.corona,C.starPoint));let i=_?hj:gj,a=new ru(g,i,i),s=_?sj():new mu({color:__(d.data)});S=new As(a,s),v&&(S.visible=!1),_||(w=HC(s)),t.add(S),D.push(S),n.push(S),r.set(S,d);let c=_?void 0:_b(e);c&&(T=TA(c,g,gn(d.data)),t.add(T.mesh),D.push(T.mesh),w&&(E=[XA(s,c,g,gn(d.data),w,T)]))}let O=Ik(d),k=_||p===W.PLANET,A=f||m_.has(e)||d.data.isMinor===!0,j=Lk(h,d.data.name??``,O,a().bodyHref(e,d.data.name??``),()=>c(d),k,l?t=>l(e,t):void 0,A);j&&(zk(j.element,s),x.add(j)),t.add(x);let M=j?j.element.firstElementChild:null;M&&(M.dataset.origBorder=M.style.border),i.set(e,{body:d,group:x,mesh:S,label:j,labelHalo:M,labelStack:null,loadingEl:null,extraObjects:D,corona:C?.corona??null,starPoint:C?.starPoint??null,trail:null,radiusScene:g,cachedDist:0,currentSegments:m||b?void 0:_?hj:gj,isMinor:A,noPhysical:b,rings:[],clouds:null,atmosphere:T,sunTint:E,specularMap:null,emissiveMap:null,displacementMap:null,selfShadow:null,eclipseShadow:w,nomenclatureLabels:null,model:null})}}function vj(e){let t=e.data.objectType;return t===W.COMET||_n(t)||e.data.orbitalSource===U.SPICE_PROBE}function yj(e,t,n,r){if(e.mesh!==null)return;let{body:i,radiusScene:a}=e;e.focusUpgraded=!0;let o=$D(i);if(!o&&!(Number.isFinite(i.data.radiusKm)&&i.data.radiusKm>0)){e.noPhysical=`radius`;return}let s=__(i.data),c=gj,l=new ru(a,c,c),u=new mu({color:s}),d=new As(l,u);o&&(d.visible=!1),t.add(d),e.mesh=d,e.extraObjects.push(d),n.push(d),r.set(d,i),e.eclipseShadow=HC(u),e.currentSegments=c;let f=_b(i.data.id);f&&(e.atmosphere=TA(f,a,gn(i.data)),t.add(e.atmosphere.mesh),e.extraObjects.push(e.atmosphere.mesh),e.sunTint=[XA(u,f,a,gn(i.data),e.eclipseShadow,e.atmosphere)])}function bj(e,t,n,r){e.focusUpgraded=!1,fO(e);let i=e.mesh;if(i){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementTier=void 0,$C(e.selfShadow),e.selfShadow=null),e.terrainWindow=null,t.remove(i),i.geometry.dispose(),mj(i.material);let a=n.indexOf(i);a>=0&&n.splice(a,1),r.delete(i);let o=e.extraObjects.indexOf(i);o>=0&&e.extraObjects.splice(o,1),e.mesh=null,e.currentSegments=void 0,e.eclipseShadow=null,e.sunTint=void 0,e.radiiApplied=!1,e.semiAxesScene=void 0}if(e.atmosphere){let n=e.atmosphere.mesh;t.remove(n);let r=e.extraObjects.indexOf(n);r>=0&&e.extraObjects.splice(r,1),n.geometry.dispose(),mj(n.material),e.atmosphere=null}let a=e.body.data.orbitalSource===U.SPICE_PROBE;e.trail&&!a&&(t.remove(e.trail),e.trail.geometry.dispose(),mj(e.trail.material),e.trail=null)}var xj=class{#e;#t=new J;#n=new q;#r=new WeakMap;#i=[];constructor(e,t){this.#e=Sj(e,t)}setSize(e,t){this.#e.dispose(),this.#e.depthTexture?.dispose(),this.#e=Sj(e,t)}run(e,t,n,r,i){let a=this.#i;for(let e of r.values())e.atmosphere?.material.side===1&&(e.mesh&&this.#a(e.mesh,i),e.model&&e.model.parent===e.modelRoot&&e.model.traverse(e=>{e.isMesh&&this.#a(e,i)}));let o=e.getRenderTarget(),s=n.layers.mask,c=t.background;n.layers.set(i),t.background=null,e.setRenderTarget(this.#e),e.clear(),e.render(t,n),e.setRenderTarget(o),t.background=c,n.layers.mask=s;for(let{mesh:e,material:t}of a)e.material=t,e.layers.disable(i);a.length=0,n.getWorldDirection(this.#t),e.getDrawingBufferSize(this.#n);for(let e of r.values()){let t=e.atmosphere?.material.uniforms;t&&(t.uSceneDepth.value=this.#e.depthTexture,t.uCamForward.value.copy(this.#t),t.uReversedDepth.value=+!!iT(),t.uCameraNear.value=n.near,t.uCameraFar.value=n.far,t.uResolution.value.copy(this.#n))}}#a(e,t){if(!e.visible)return;let n=e.material;if(Array.isArray(n))return;let r=this.#r.get(n);r||(r=new _u,this.#r.set(n,r));let i=n;(r.displacementMap??null)!==(i.displacementMap??null)&&(r.displacementMap=i.displacementMap??null,r.needsUpdate=!0),r.displacementScale=i.displacementScale??1,r.displacementBias=i.displacementBias??0,r.side=i.side,this.#i.push({mesh:e,material:n}),e.material=r,e.layers.enable(t)}dispose(){this.#e.depthTexture?.dispose(),this.#e.dispose()}};function Sj(e,t){let n=new la(e,t);return n.depthTexture=new Pc(e,t,Hn),n}function Cj(e,t,n,r,i,a,o,s){if(!n.length||i.rings.length)return[];let c=n.reduce((e,t)=>t.intensity_scale>e.intensity_scale?t:e),l=[];for(let u of n){if(s)for(let n of u.sources)s.credits.registerImagery(`rings`,e,t,{...n,description:u.description});l.push(dA(e,u,o).then(e=>{if(!e)return;if(i.rings.some(e=>e.mesh.userData.ringBundle===u.bundle)){e.mesh.geometry.dispose(),e.mesh.material.dispose();return}e.mesh.userData.ringBundle=u.bundle;let t=i.mesh??i.model;t&&e.mesh.quaternion.copy(t.quaternion),i.rings.push(e),a.add(e.mesh),i.extraObjects.push(e.mesh),i.mesh&&u===c&&(e.planetShadow=uA(i.mesh.material,e.innerScene,e.outerScene,e.transparency,e.intensityScale),i.atmosphere&&FA(i.atmosphere,e.planetShadow,e.transparency,e.innerScene,e.outerScene)),r&&(e.planetShadowOnRing.uPlanetEquatorialScene.value=Q((r.a+r.b)/2),e.planetShadowOnRing.uPlanetPolarScene.value=Q(r.c))}))}return l}var wj=1.002;function Tj(e,t){let n=e?.referenceAltitudeKm??0;return n>0?1+n/t:wj}var Ej=1e3;function Dj(e,t,n){return Yt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function Oj(e,t,n){try{let r=await fetch(Dj(e,t,n));if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=new oa(await createImageBitmap(i,{imageOrientation:`flipY`}));return a.flipY=!1,a.colorSpace=Xr,a.needsUpdate=!0,a}catch(r){return console.warn(`Failed to load ${t} cloud texture for ${e} @ ${n}:`,r),null}}function kj(e){let t=parseInt(e.slice(0,4),10),n=parseInt(e.slice(4,6),10)-1,r=parseInt(e.slice(6,8),10),i=parseInt(e.slice(8,10),10);return Date.UTC(t,n,r,i)}var Aj=10800*1e3;function jj(e,t,n){return n?n.some(([t,n])=>e>=kj(t)&&e<kj(n)+Aj):e>=kj(t[0])&&e<=kj(t[t.length-1])}function Mj(e,t,n){if(t.length===0)return;let r=Pg(e).getTime(),i=kj(t[0]);if(jj(r,t,n)){let e=0,n=t.length;for(;e<n;){let i=e+n>>>1;kj(t[i])<=r?e=i+1:n=i}return t[Math.max(0,e-1)]}let a=Pg(e).getUTCHours(),o=Math.round(a/3)*3%24,s=String(o).padStart(2,`0`),c=t.filter(e=>e.slice(8,10)===s);return c.length===0?r<i?t[0]:t[t.length-1]:r<i?c[0]:c[c.length-1]}async function Nj(e,t,n,r,i=wj){let a=await Oj(n.id,`low`,r);if(!a)return null;let o=Pj(e,t,a,i);return o.id=n.id,o.availableTiers=n.tiers,o.availableFrames=n.frames,o.availableCoverage=n.coverage,o.textureTier=`low`,o.textureFrame=r,o}function Pj(e,t,n,r=wj){let i=new mu({map:n,transparent:!0,depthWrite:!1}),a=new As(new ru(t,64,64),i);return a.scale.setScalar(r),a.renderOrder=1,e.add(a),{mesh:a,material:i,id:``,availableTiers:[],availableFrames:[]}}async function Fj(e,t,n){if(e.textureLoading||e.textureTier===t&&e.textureFrame===n||!e.availableTiers.includes(t)||!e.availableFrames.includes(n))return;let r=performance.now();if(!(e.lastSwapMs!==void 0&&r-e.lastSwapMs<Ej)){e.lastSwapMs=r,e.textureLoading=!0;try{let r=await Oj(e.id,t,n);r&&(e.material.map?.dispose(),e.material.map=r,e.material.needsUpdate=!0,e.textureTier=t,e.textureFrame=n)}finally{e.textureLoading=!1}}}function Ij(e){e.mesh.geometry.dispose(),e.material.map?.dispose(),e.material.dispose(),e.mesh.parent?.remove(e.mesh)}var Lj=.2,Rj=-.125,zj=.1,Bj=Symbol(`night-lights-hook`);async function Vj(e,t,n,r){let i=Yt(`/v1/textures/${t.id}/${n}.webp`,`textures`),a;try{a=await new Promise((e,t)=>{r.load(i,e,void 0,t)})}catch(e){return console.warn(`Failed to load night-lights map ${i}:`,e),null}return a.colorSpace=Xr,Hj(e,a),a}function Hj(e,t){e.emissiveMap=t,e.emissive=new X(16777215);let n=e;if(!n[Bj]){n[Bj]=!0;let t=RC();FC(e,`nightLights`,e=>{e.uniforms.uSunDir=t.uSunDir,e.uniforms.uNightIntensity={value:Lj},e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
5513
5524
|
varying vec3 vNightOutwardWorld;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
5514
5525
|
vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
5515
5526
|
uniform float uNightIntensity;
|
|
@@ -5518,9 +5529,9 @@ vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragment
|
|
|
5518
5529
|
// Modulate by unlit-side factor: 1 night, 0 day.
|
|
5519
5530
|
vec3 nightOutward = normalize(vNightOutwardWorld);
|
|
5520
5531
|
float nightDot = dot(nightOutward, uSunDir);
|
|
5521
|
-
float nightFactor = 1.0 - smoothstep(${
|
|
5532
|
+
float nightFactor = 1.0 - smoothstep(${Rj.toFixed(2)}, ${zj.toFixed(2)}, nightDot);
|
|
5522
5533
|
totalEmissiveRadiance *= nightFactor * uNightIntensity;
|
|
5523
|
-
#endif`)})}e.needsUpdate=!0}function
|
|
5534
|
+
#endif`)})}e.needsUpdate=!0}function Uj(e){e.emissiveMap&&(e.emissiveMap.dispose(),e.emissiveMap=null,e.emissive.setRGB(0,0,0),e.needsUpdate=!0)}var Wj=.55,Gj=Symbol(`specular-hook`);async function Kj(e,t,n,r){let i=Yt(`/v1/textures/${t.id}/${n}.webp`,`textures`),a;try{a=await new Promise((e,t)=>{r.load(i,e,void 0,t)})}catch(e){return console.warn(`Failed to load specular map ${i}:`,e),null}e.roughnessMap=a;let o=e;return o[Gj]||(o[Gj]=!0,FC(e,`specular`,e=>{e.uniforms.uOceanRoughness={value:Wj},e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
5524
5535
|
uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`float roughnessFactor = roughness;
|
|
5525
5536
|
#ifdef USE_ROUGHNESSMAP
|
|
5526
5537
|
// Mask carries the fraction of the texel under water, so a
|
|
@@ -5529,14 +5540,14 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
|
|
|
5529
5540
|
// roughnessmap sample.
|
|
5530
5541
|
vec4 texelRoughness = texture2D(roughnessMap, vRoughnessMapUv);
|
|
5531
5542
|
roughnessFactor = mix(roughness, uOceanRoughness, texelRoughness.g);
|
|
5532
|
-
#endif`)})),e.needsUpdate=!0,a}function
|
|
5533
|
-
`)}function vM(e,t=c()){let n=`${e}:${t}`,r=hM.get(n);return r||(r=(async()=>{let[n,r]=await Promise.all([gM(e),_M(e,t)]);return n.map((e,t)=>({...e,name:r[t]??`Feature ${e.featureId}`}))})(),hM.set(n,r),r.catch(()=>{hM.get(n)===r&&hM.delete(n)})),r}var yM=3;function bM(e,t,n=yM){let r=0,i=0;e.addEventListener(`pointerdown`,e=>{r=e.clientX,i=e.clientY}),e.addEventListener(`click`,e=>{e.stopPropagation();let a=e.clientX-r,o=e.clientY-i;a*a+o*o<=n*n&&t(e)})}function xM(e,t){if(e)return un(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var SM=Math.PI/180,CM=.9,wM=24,TM=.2,EM=100,DM=16,OM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function kM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await hx(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await vM(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!OM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:EM;return(t.diameterM>0?t.diameterM:EM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await MM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=nO(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new za,i=s.userData.centerOffset;i&&r.position.copy(i).multiplyScalar(-n),r.quaternion.copy(s.quaternion),e.group.add(r),e.nomenclatureAnchor=r,l=r}else{let t=e.mesh.geometry.parameters?.radius;if(!t)return;let n=null;if(r.global.displacement&&(n=await ww(e,e.body.data.id,r.global.displacement,gn(e.body.data),a.map(e=>({latRad:e.lat*SM,lonRad:e.lon*SM}))),e.nomenclatureLabels||!e.mesh))return;for(let e=0;e<o;e++)c[e]=t+(n?Q(n[e]):0);l=e.mesh}let u=Array(o),d=new Float32Array(o),f=new Float32Array(o).fill(-1),p=new Float32Array(o).fill(NaN),m=new Float32Array(o).fill(NaN),h=0;for(let e=0;e<o;e++){let r=a[e],i=r.diameterM>0?r.diameterM:EM;r.diameterM<=0&&h++;let o=document.createElement(`div`);o.className=`scene-feature-label`,o.dir=`auto`,o.textContent=r.name,o.dataset.featureId=String(r.featureId),Lk(o,t),n&&bM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=lw(r.lat*SM,r.lon*SM),m=c[e],g=new $O(o);g.position.set(m*s,m*f,m*p),l.add(g),u[e]=g,d[e]=i}h>0&&console.log(`[nomenclature] ${e.body.data.id}: ${h}/${o} features have no diameter — using ${EM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var AM=8,jM=new J;async function MM(e,t){let n=t.length,r=new Float32Array(n),i=new Float32Array(n*3),a=e.userData.halfExtents;for(let o=0;o<n;o++){o>0&&o%AM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*SM,s=t[o].lon*SM,c=TO(e,n,s,jM);if(c!==null)r[o]=c;else{let[e,t,i]=lw(n,s),c=Math.max(a?.x??1,.001),l=Math.max(a?.y??1,.001),u=Math.max(a?.z??1,.001);r[o]=1/Math.sqrt((e/c)**2+(t/l)**2+(i/u)**2),jM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=jM.x,i[o*3+1]=jM.y,i[o*3+2]=jM.z}return{radii:r,normals:i}}function NM(e,t){let n=e.nomenclatureLabels;if(!n)return;let r=t===null?null:String(t),i=-1;for(let e=0;e<n.length;e++){let t=n[e].element,a=t.dataset.featureId===r;t.classList.toggle(`scene-feature-label--active`,a),a&&(i=e)}e.nomenclatureActiveIndex=i}function PM(e){if(e.nomenclatureLabels){for(let t of e.nomenclatureLabels)t.element.remove(),t.parent?.remove(t);e.nomenclatureAnchor&&=(e.nomenclatureAnchor.parent?.remove(e.nomenclatureAnchor),null),e.nomenclatureNormals=void 0,e.nomenclatureLabels=null,e.nomenclatureDiamsM=void 0,e.nomenclatureWidths=void 0,e.nomenclatureSX=void 0,e.nomenclatureSY=void 0,e.nomenclatureActiveIndex=void 0}}var FM=new J,IM=new J,LM=new J,RM=new J,zM=new J,BM=new Hi,VM=new J,HM=.12;function UM(e,t,n,r,i,a){let o=e.nomenclatureLabels;if(!o)return;if(!t||n<128){for(let e of o)e.visible=!1;return}let s=e.nomenclatureDiamsM,c=e.nomenclatureSX,l=e.nomenclatureSY,u=e.nomenclatureActiveIndex??-1,d=o.length,f=!!e.clouds?.mesh.visible,p=n/(gn(e.body.data)*1e3),m=TM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<wM)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(FM),r.getWorldPosition(IM);let h=IM.x-FM.x,g=IM.y-FM.y,_=IM.z-FM.z;RM.copy(FM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(CM*(n/Math.sqrt(Math.max(1-y/v,1e-6))))**2,x=.5*i,S=.5*a,C=e.nomenclatureNormals;C&&e.nomenclatureAnchor&&e.nomenclatureAnchor.getWorldQuaternion(BM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<wM||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(LM);let v=LM.x-FM.x,y=LM.y-FM.y,w=LM.z-FM.z;if(v*h+y*g+w*_<=v*v+y*y+w*w){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}if(C){VM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(BM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(VM.x*n+VM.y*r+VM.z*i<HM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}zM.copy(LM).project(r);let T=(zM.x-RM.x)*x,E=(zM.y-RM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(zM.x*.5+.5)*i,l[e]=(-zM.y*.5+.5)*a}}var WM=[];function GM(e){let t=WM[e];return t||(t={left:0,right:0,y:0,h:0},WM[e]=t),t}function KM(e,t,n,r){let i=e.nomenclatureLabels[t];if(!i.visible)return r;let a=e.nomenclatureSX[t],o=e.nomenclatureSY[t];if(Number.isNaN(a)||Number.isNaN(o))return r;let s=e.nomenclatureWidths,c=s[t];if(c<0){let e=i.element.offsetWidth;e>0?(s[t]=e,c=e):c=60}let l=c*.5,u=a-l,d=a+l;if(!n)for(let e=0;e<r;e++){let t=WM[e],n=(t.h+DM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=GM(r);return f.left=u,f.right=d,f.y=o,f.h=DM,r+1}function qM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=bk,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=GM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=KM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=KM(e,i,!1,r))}var JM=34028235e31,YM=3;function XM(e){return new X(e).multiplyScalar(.5)}function ZM(){let e=document.createElement(`canvas`);e.width=32,e.height=32;let t=e.getContext(`2d`);return t.beginPath(),t.arc(32/2,32/2,32/2-2,0,Math.PI*2),t.fillStyle=`#aaaaaa`,t.globalAlpha=.3,t.fill(),new Nc(e)}function QM(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function $M(e,t,n,r=[0,0,0],i=4,a=null){let o=e.filter(e=>{let[t,n,r]=e.position;return isFinite(t)&&Math.abs(t)<=JM&&isFinite(n)&&Math.abs(n)<=JM&&isFinite(r)&&Math.abs(r)<=JM?!0:(console.warn(`Skipping body with non-finite position: id=${e.data.id} name=${e.data.name}`,e.position),!1)}),s=new Float32Array(o.length*3),c=a?new Float32Array(o.length*3):null,l=c?new X:null;for(let e=0;e<o.length;e++){let t=o[e];s[e*3]=t.position[0]-r[0],s[e*3+1]=t.position[1]-r[1],s[e*3+2]=t.position[2]-r[2],c&&l&&a&&(l.set(a(t)),c[e*3]=l.r,c[e*3+1]=l.g,c[e*3+2]=l.b)}let u=new Ho;u.setAttribute(`position`,new Ao(s,3)),c&&u.setAttribute(`color`,new Ao(c,3));let d=new Ac(u,new Tc({map:t,color:c?new X(.5,.5,.5):XM(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=YM,d}function eN(e,t,n,r,i=4,a=null){let o=new Ho;o.setAttribute(`position`,new Do(e,3)),a&&o.setAttribute(`color`,new Do(a,3)),o.setDrawRange(0,t);let s=new Ac(o,new Tc({map:n,color:a?new X(.5,.5,.5):XM(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=YM,s}function tN(e,t=512,n=50){let r=e.q??e.a;if(!isFinite(r)||r<=0)return[];let i=Math.max(2*r/n-1,-.999),a=Math.acos(i),o=[];for(let n=0;n<=t;n++){let i=-a+2*a*n/t,s=2*r/(1+Math.cos(i)),c=s*Math.cos(i),l=s*Math.sin(i);o.push(Gv(c,l,e.w,e.i,e.om,e.equatorial))}return o}function nN(e,t=128){let{a:n,i:r,om:i,w:a}=e,o=Math.min(e.e,.9999999),s=1+3*o,c=Math.sqrt(1-o*o),l=[];for(let u=0;u<=t;u++){let d=2*u/t-1,f=Math.PI*Math.sign(d)*Math.abs(d)**+s,p=Math.cos(f),m=Math.sin(f),h=1-o*p,g=c*m/h,_=(p-o)/h,v=Math.atan2(g,_),y=n*h,b=y*Math.cos(v),x=y*Math.sin(v);!isFinite(b)||!isFinite(x)||l.push(Gv(b,x,a,r,i,e.equatorial))}return l}function rN(e,t=512,n=50){let r=Math.abs(e.a),i=r>0?(n/r+1)/e.e:100,a=Math.min(Math.acosh(Math.max(i,1)),6),o=[];for(let n=0;n<=t;n++){let r=-a+2*a*n/t,i=e.e*Math.cosh(r)-1;if(Math.abs(i)<1e-15)continue;let s=Math.sqrt(e.e*e.e-1)*Math.sinh(r)/i,c=(e.e-Math.cosh(r))/i,l=Math.atan2(s,c),u=e.a*(1-e.e*Math.cosh(r)),d=u*Math.cos(l),f=u*Math.sin(l);o.push(Gv(d,f,e.w,e.i,e.om,e.equatorial))}return o}function iN(e,t,n,r=128){if(!isFinite(n)||n<=0)return[];let i=1/n,a=[];for(let n=0;n<=r;n++){let o=bg(e,t-i+i*n/r);o&&a.push(o)}return a}function aN(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function oN(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:tN(e,t),isOpen:!0}:!n&&e.e>=1?{points:rN(e,t),isOpen:!0}:{points:nN(e,t),isOpen:!1}}var sN=3;function cN(e){let t=2*e,n=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(t);for(let t=0;t<e;t++)i[2*t]=-1,i[2*t+1]=1;let s=new Uint16Array(Math.max(0,6*(e-1)));for(let t=0;t<e-1;t++){let e=2*t,n=2*t+1,r=2*(t+1),i=2*(t+1)+1,a=t*6;s[a]=e,s[a+1]=n,s[a+2]=r,s[a+3]=r,s[a+4]=n,s[a+5]=i}let c=new Ho;return c.setAttribute(`position`,new Ao(n,3)),c.setAttribute(`nextPosition`,new Ao(r,3)),c.setAttribute(`side`,new Ao(i,1)),c.setAttribute(`trailAlpha`,new Ao(a,1)),c.setAttribute(`fullAlpha`,new Ao(o,1)),c.setIndex(new Oo(s,1)),c}function lN(e,t,n,r,i){let a=e.getAttribute(`position`),o=e.getAttribute(`nextPosition`),s=e.getAttribute(`trailAlpha`),c=e.getAttribute(`fullAlpha`),l=a.array,u=o.array,d=s.array,f=c.array,p=d.length/2,m=Math.min(i,p);for(let e=0;e<m;e++){let i=t[e*3],a=t[e*3+1],o=t[e*3+2],s=e<m-1?e+1:e,c=t[s*3],p=t[s*3+1],h=t[s*3+2],g=2*e*3;l[g]=i,l[g+1]=a,l[g+2]=o,l[g+3]=i,l[g+4]=a,l[g+5]=o,u[g]=c,u[g+1]=p,u[g+2]=h,u[g+3]=c,u[g+4]=p,u[g+5]=h;let _=n[e],v=r[e];d[2*e]=_,d[2*e+1]=_,f[2*e]=v,f[2*e+1]=v}a.needsUpdate=!0,o.needsUpdate=!0,s.needsUpdate=!0,c.needsUpdate=!0,e.setDrawRange(0,Math.max(0,6*(m-1)))}function uN(){let e=new Ho;e.setAttribute(`position`,new Ao(new Float32Array(6),3));let t=new yc(e,new fu({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=sN,t}function dN(e,t,n,r,i){let a=new Ho;a.setAttribute(`position`,new Ao(e,3)),a.setAttribute(`trailAlpha`,new Ao(t,1)),a.setAttribute(`fullAlpha`,new Ao(n,1)),a.setDrawRange(0,r);let o=new yc(a,pT(i));return o.matrixAutoUpdate=!1,o.renderOrder=sN,o}function fN(e,t,n){let r=e.getAttribute(`lineDistance`),i=r.array,a=Math.min(n,i.length/2);for(let e=0;e<a;e++)i[2*e]=i[2*e+1]=t[e];r.needsUpdate=!0}function pN(e,t,n,r,i,a,o,s,c){let l=cN(e);c&&l.setAttribute(`lineDistance`,new Ao(new Float32Array(2*e),1)),lN(l,t,n,r,i);let u=new As(l,mT(a,o,s,c));return u.matrixAutoUpdate=!1,u.renderOrder=sN,u}function mN(e){if(e.userData.isFatLine){let t=e.userData.thinPositions;return{posArr:t,trailArr:e.userData.thinTrailAlphas,fullArr:e.userData.thinFullAlphas,capacity:t.length/3}}let t=e.geometry.getAttribute(`position`);return{posArr:t.array,trailArr:e.geometry.getAttribute(`trailAlpha`).array,fullArr:e.geometry.getAttribute(`fullAlpha`).array,capacity:t.count}}function hN(e,t,n,r,i,a,o){if(i<2){e.geometry.setDrawRange(0,0),e.userData.isFatLine||(e.geometry.getAttribute(`position`).needsUpdate=!0);return}if(tb(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){lN(e.geometry,t,n,r,i);return}e.geometry.setDrawRange(0,i),e.geometry.getAttribute(`position`).needsUpdate=!0,e.geometry.getAttribute(`trailAlpha`).needsUpdate=!0,e.geometry.getAttribute(`fullAlpha`).needsUpdate=!0}function gN(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;n[0]=c[0]-o[0],n[1]=c[1]-o[1],n[2]=c[2]-o[2];let l=r-o[0],u=i-o[1],d=a-o[2];return 1+t.writeVertices(n.subarray(3),l,u,d,s)}function _N(e,t,n,r,i){let{orbitCenter:a,data:o}=e,s=a?.[0]??0,c=a?.[1]??0,l=a?.[2]??0,u=o.objectType===W.SPACECRAFT||o.objectType===W.DWARF_PLANET||o.objectType===W.MOON||o.objectType===W.COMET||_n(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=gN(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&tb(m.subarray(0,p),h.subarray(0,p),!0,u);let g=i>1,_=g?pN(d,f,h,m,p,n,i):dN(f,h,m,p,n);return _.frustumCulled=!1,_.visible=!1,_.userData.orbitCenter=new J(s,c,l),_.userData.trailBuffer=t,_.userData.useTrail=u,g&&(_.userData.isFatLine=!0,_.userData.thinPositions=f,_.userData.thinTrailAlphas=h,_.userData.thinFullAlphas=m),_}function vN(e,t,n=[0,0,0],r=Ng(new Date),i=1){if(e.trailBuffer)return _N(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l;if(s.satrec)c=iN(s.satrec,r,s.n/360,512),l=!0;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=aN(a)}let u=o?.[0]??0,d=o?.[1]??0,f=o?.[2]??0,p=l||s.objectType===W.DWARF_PLANET||s.objectType===W.MOON||s.objectType===W.SPACECRAFT||s.objectType===W.COMET||_n(s.objectType),m=c?eb(e,c,l,u,d,f):[];if(c&&m.length<2)return uN();let h=c?Math.max(m.length,c.length):513,g=new Float32Array(h),_=new Float32Array(h);tb(g.subarray(0,m.length),_.subarray(0,m.length),l,p);let v=u-n[0],y=d-n[1],b=f-n[2],x=new Float32Array(h*3);for(let e=0;e<m.length;e++)x[e*3]=m[e][0]+v,x[e*3+1]=m[e][1]+y,x[e*3+2]=m[e][2]+b;let S=i>1,C=S?pN(h,x,_,g,m.length,t,i):dN(x,_,g,m.length,t);return C.frustumCulled=!1,C.visible=!1,C.userData.orbitCenter=new J(u,d,f),C.userData.trailLocalPositions=c?m:void 0,C.userData.sourceCurve=c??void 0,C.userData.curvePending=c===null,C.userData.isOpenCurve=l,C.userData.useTrail=p,C.userData.curveJd=r,C.userData.elementsJd=a?.epoch??r,S&&(C.userData.isFatLine=!0,C.userData.thinPositions=x,C.userData.thinTrailAlphas=_,C.userData.thinFullAlphas=g),C}function yN(e,t){if(!t||t.size===0)return[...e];let n=[];for(let r of e)t.has(r.data.id)||n.push(r);return n}function bN(e){return e.data.objectType===W.PLANET?4:(e.data.objectType===W.MOON||e.data.objectType===W.DWARF_PLANET)&&n_[e.data.id]?3:1}function xN(e,t,n=[0,0,0],r){for(let[,i]of e){if(i.trail!==null)continue;let{body:e}=i;if(e.data.objectType===W.STAR)continue;if(e.data.orbitalSource===U.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&gj(e))continue;if(!e.orbitElements&&e.rederiveElements&&r!==void 0){let t=e.rederiveElements(r);t&&(e.orbitElements=t)}if(!e.orbitElements&&!e.trailBuffer)continue;let a=vN(e,h_(e.data),n,r,bN(e));t.add(a),i.trail=a}}function SN(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=QM();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=yN(c.values(),i);if(e.length===0)continue;let u=h_(e[0].data),{buckets:d}=b_(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=$M(i,n,u,r,l);a.userData.groupId=`asteroid:${s}#${e}`,a.userData.parentVec=[0,0,0],o.set(`${s}#${e}`,a),t.add(a)}}for(let[o,c]of e.bodies.spacecraftByParent.entries()){let l=wv(e.layers,o,yN(c.values(),i));if(l.length===0)continue;let{buckets:u}=b_(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=$M(i,n,`#ffffff`,r,void 0,e=>h_(e.data));a.userData.groupId=`spacecraft:${o}#${e}`,a.userData.parentBodyId=o,a.userData.parentVec=[0,0,0],s.set(`${o}#${e}`,a),t.add(a)}}let u=new Map;for(let t of e.bodies.majorBodies)if(t.data.objectType===W.MOON){let e=u.get(t.data.parentId)??[];e.push(t),u.set(t.data.parentId,e)}for(let[e,i]of u){let a=$M(i,n,h_(i[0].data),r),o=a.material;o.transparent=!1,o.alphaTest=.5,o.depthTest=!0,o.depthWrite=!0,a.visible=!1,c.set(e,a),t.add(a)}return{asteroidPoints:o,spacecraftPoints:s,moonPoints:c}}async function CN(e,t,n,r,i,a,o){let c;try{let t=await fetch(`${Kt()}/v1/systems/${e}.json`);if(!t.ok)return;c=await t.json()}catch{return}let l=[];for(let[u,d]of Object.entries(c)){let c=s([d.texture&&{...d.texture,id:u,tiers:d.tiers},...d.alternates??[]]);c&&o?.credits.registerImagery(`surface`,u,e,c);let f=t.get(u);if(f?.mesh){if(o?.bodies.orientationRead.add(u),d.orientation){if(gD(f,d.orientation,o,e),d.nut_prec){let e=u.match(/^naif-(-?\d+)$/),t=e?parseInt(e[1],10):null,n=t===null?void 0:Q_(Z_(t));n&&(f.body.nutPrec={...d.nut_prec,angles:n})}hC(f.mesh,d.orientation,i,f.body.nutPrec)}if(d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&rM(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,!f.textureTier)){let e=tM(i,f.availableFrames);l.push(sM(f,`low`,e,r))}l.push(...Jj(u,e,d,f,{textureLoader:r,currentJd:i,ctx:o})),d.rings?.length&&l.push(...xj(u,e,d.rings,d.radii,f,n,a,o))}}await Promise.allSettled(l)}function wN(e,t,n,r){for(let i of t.values())if(r.visibility.isBodyInSystem(i.body,e)){if(oM(i),Xj(i),i.terrainWindow&&i.mesh){i.terrainWindow=null;let e=Q(gn(i.body.data)),t=i.mesh.geometry;i.mesh.geometry=new ru(e,24,24),t.dispose(),i.currentSegments=24}for(let e of i.rings){e.planetShadow?.disable(),n.remove(e.mesh);let t=i.extraObjects.indexOf(e.mesh);t>=0&&i.extraObjects.splice(t,1),uA(e)}i.rings=[],PM(i)}}var TN=class{lastBaryId=null;pendingUnloads=new Set;prefetched=new Set;constructor(e,t,n,r,i,a,o){this.scene=e,this.ctx=t,this.renderer=n,this.textureLoader=r,this.bodyObjects=i,this.clock=a,this.onLoaded=o}syncToFocus(){let e=this.ctx.visibility.focusedSystemId,t=e?this.resolveBaryId(e):null;if(!t){this.lastBaryId&&=(this.pendingUnloads.add(this.lastBaryId),null);return}t!==this.lastBaryId&&(this.lastBaryId&&this.pendingUnloads.add(this.lastBaryId),this.pendingUnloads.delete(t),this.prefetched.delete(t),this.lastBaryId=t,this.load(t))}prefetch(e){let t=this.resolveBaryId(e);!t||t===this.lastBaryId||this.prefetched.has(t)||(this.prefetched.add(t),this.pendingUnloads.delete(t),this.load(t))}discardPrefetch(e){let t=this.resolveBaryId(e);!t||!this.prefetched.delete(t)||t!==this.lastBaryId&&this.pendingUnloads.add(t)}resolveBaryId(e){let t=this.ctx.getBody(e);if(t?.data.objectType===W.BARYCENTER)return e;let n=t?.data.parentId??e;return M_(n)?null:n}load(e){CN(e,this.bodyObjects,this.scene,this.textureLoader,this.clock.jd,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.onLoaded(),this.ctx.bodies.orientationVersion++})}drainPendingUnloads(){if(this.pendingUnloads.size!==0){for(let e of this.pendingUnloads)wN(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},EN=Math.PI/180,DN=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Hi;_adjustQ=new Hi;_tmpQ=new Hi;_axisX=new J(1,0,0);_axisY=new J(0,1,0);_axisZ=new J(0,0,1);constructor(e){this.scene=e}get(){return{...this.adjust}}set(e,t,n){this.adjust.rxDeg=e,this.adjust.ryDeg=t,this.adjust.rzDeg=n,this._adjustQ.setFromAxisAngle(this._axisX,e*EN).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*EN)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*EN)),this._q.copy(Qx).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},ON=Math.PI/180,kN=ag*ON,AN=Math.cos(kN),jN=Math.sin(kN),MN=5e3,NN=[{id:`galactic-center`,label:`Galactic Center`,raDeg:266.41683,decDeg:-29.00781,color:`#ff6b35`},{id:`galactic-anticenter`,label:`Galactic Anticenter`,raDeg:86.4,decDeg:28.93785,color:`#ff6b35`},{id:`galactic-np`,label:`Galactic NP`,raDeg:192.85948,decDeg:27.12825,color:`#ffb84d`},{id:`galactic-sp`,label:`Galactic SP`,raDeg:12.85948,decDeg:-27.12825,color:`#ffb84d`},{id:`ncp`,label:`NCP (Polaris ≈)`,raDeg:37.9542,decDeg:89.2641,color:`#4dd0ff`},{id:`scp`,label:`SCP`,raDeg:0,decDeg:-90,color:`#4dd0ff`},{id:`vernal`,label:`Vernal Equinox (γ)`,raDeg:0,decDeg:0,color:`#9d8cff`},{id:`autumnal`,label:`Autumnal Equinox`,raDeg:180,decDeg:0,color:`#9d8cff`},{id:`m31`,label:`M31 (Andromeda)`,raDeg:10.6847,decDeg:41.2692,color:`#ffffff`},{id:`lmc`,label:`LMC (Large Magellanic Cloud)`,raDeg:80.8942,decDeg:-69.7561,color:`#ffffff`},{id:`smc`,label:`SMC (Small Magellanic Cloud)`,raDeg:13.1583,decDeg:-72.8003,color:`#ffffff`},{id:`sirius`,label:`Sirius`,raDeg:101.2872,decDeg:-16.7161,color:`#ffffff`}],PN=192.85948,FN=27.12825,IN=266.40499,LN=-28.93617,RN=256,zN=[{name:`galactic-plane`,zero:BN(IN,LN,new J).normalize(),pole:BN(PN,FN,new J).normalize(),color:16739125},{name:`ecliptic-plane`,zero:new J(1,0,0),pole:new J(0,1,0),color:5099775},{name:`celestial-equator`,zero:BN(0,0,new J).normalize(),pole:BN(0,90,new J).normalize(),color:10325247}];function BN(e,t,n){let r=e*ON,i=t*ON,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*AN+c*jN,d=-s*jN+c*AN;return n.set(l,d,-u)}function VN(e){let t=document.createElement(`div`);t.className=`sky-debug-marker`,t.style.cssText=[`display:flex`,`align-items:center`,`gap:4px`,`font:11px/1 monospace`,`text-shadow:0 0 3px #000, 0 0 3px #000`,`pointer-events:none`,`white-space:nowrap`].join(`;`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`width`,`48`),n.setAttribute(`height`,`48`),n.setAttribute(`viewBox`,`-24 -24 48 48`),n.style.cssText=`flex:0 0 auto;filter:drop-shadow(0 0 2px #000);margin-inline-start:-24px`;let r=e.color;n.innerHTML=`
|
|
5543
|
+
#endif`)})),e.needsUpdate=!0,a}function qj(e){e.roughnessMap&&(e.roughnessMap.dispose(),e.roughnessMap=null,e.needsUpdate=!0)}var Jj={specular:{meta:e=>e.specular,loaded:e=>e.specularMap!==null,async load(e,t,n,r){let i=await Kj(n.material,t,`low`,r.textureLoader);if(i){if(e.specularMap){i.dispose();return}e.specularMap=i}},unload(e,t){t&&(qj(t.material),e.specularMap=null)}},night:{meta:e=>e.night,loaded:e=>e.emissiveMap!==null,async load(e,t,n,r){let i=await Vj(n.material,t,`low`,r.textureLoader);if(i){if(e.emissiveMap){i.dispose();return}e.emissiveMap=i}},unload(e,t){t&&(Uj(t.material),e.emissiveMap=null)}},topography:{meta:e=>e.displacement,loaded:e=>e.displacementMap!==null,enabled(e){return Hx()?(console.info(`Low-end device: skipping DEM relief for ${e}`),!1):Mx().showDisplacement},async load(e,t,n,r){let i=n.material,a=await ew(i,t,`low`,r.textureLoader,e.radiusScene);if(a){if(e.displacementMap){a.dispose();return}e.displacementMap=a,e.displacementMeta=t,e.displacementTier=`low`,e.selfShadow=Mx().showSelfShadow?QC(i,a,Q(t.scale_km)):null}},unload(e,t){t&&(sw(t.material),e.displacementMap=null,e.displacementTier=void 0,$C(e.selfShadow),e.selfShadow=null)}},clouds:{meta:e=>e.clouds,loaded:e=>e.clouds!==null,async load(e,t,n,r){let i=Mj(r.currentJd,t.frames,t.coverage);if(!i)return;let a=Tj(e.atmosphere?.params,e.atmosphere?.surfaceRadiusKm??1),o=a===1.002?1:a,s=await Nj(n,e.radiusScene,t,i,a);if(s){if(e.clouds){Ij(s);return}e.eclipseShadow&&(HC(s.material,e.eclipseShadow),e.atmosphere&&(e.sunTint??=[]).push(XA(s.material,e.atmosphere.params,e.radiusScene,e.atmosphere.surfaceRadiusKm,e.eclipseShadow,e.atmosphere,wj*o))),e.clouds=s}},unload(e){e.clouds&&=(Ij(e.clouds),null)}}},Yj=Object.keys(Jj);function Xj(e,t,n,r,i,a){let o=Jj[e],s=o.meta(r);return!s||!i.mesh||o.loaded(i)||o.enabled&&!o.enabled(t)?null:(a.ctx?.credits.registerImagery(e,t,n,s),o.load(i,s,i.mesh,a))}function Zj(e,t,n,r,i){let a=[];for(let o of Yj){let s=Xj(o,e,t,n,r,i);s&&a.push(s)}return a}function Qj(e,t){let n=Jj[e];n.loaded(t)&&n.unload(t,t.mesh)}function $j(e){for(let t of Yj)Qj(t,e)}var eM=[`low`,`medium`,`high`];function tM(e){return e===void 0?-1:eM.indexOf(e)}function nM(e,t){for(let n=e;n>=0;n--){let e=eM[n];if(t.includes(e))return e}}function rM(e,t,n){return Yt(n===void 0?`/v1/textures/${e}/${t}.webp`:`/v1/textures/${e}/${t}_${String(n).padStart(2,`0`)}.webp`,`textures`)}function iM(e,t){if(!(!t||t<2))return t===12?Pg(e).getUTCMonth()+1:1}async function aM(e,t,n,r){if(!e.mesh||e.appearance?.surfaceOwned)return;let i=e.textureBundleId??e.body.data.id,a=e.textureLoadGen??=0;e.textureLoading=!0;try{let o=await new Promise((e,a)=>{r.load(rM(i,t,n),e,void 0,a)});if(!e.mesh||e.textureLoadGen!==a){o.dispose();return}let s=e.mesh.material;gD(s,o,e.body.data.color),e.model&&hD(e.model,o,__(e.body.data),e.body.data.color),e.textureTier=t,e.textureFrame=n}catch(e){console.warn(`Failed to load ${t} texture for ${i}:`,e)}finally{e.textureLoading=!1}}function oM(e,t){if(!e.mesh)return;let{a:n,b:r,c:i}=t,a=Q(1)/e.radiusScene;if(e.mesh.scale.set(n*a,i*a,r*a),e.radiusScene=Q(Math.max(n,r,i)),e.semiAxesScene=[Q(n),Q(i),Q(r)],e.atmosphere){let t=Math.max(n,r);PA(e.atmosphere,t,i,Q(t));for(let n of e.sunTint??[])qA(n,e.atmosphere.params,Q(t),t)}e.radiiApplied=!0}async function sM(e,t,n,r,i,a){if(e.textureTier||e.textureLoading)return;let o=await hx(e.body.data.id,!1);if(a?.bodies.orientationRead.add(e.body.data.id),!o.global)return;o.global.orientation&&!e.body.orientation&&yD(e,o.global.orientation,a),o.global.radii&&e.radiusScene>0&&!e.radiiApplied&&!o.global.displacement?.absolute_radius&&oM(e,o.global.radii),o.global.rings?.length&&await Promise.allSettled(Cj(e.body.data.id,e.body.data.id,o.global.rings,o.global.radii,e,r,i,a));let c=o.global.sbdb?.color??o.global.color;if(c&&(e.body.data.color=c,e.mesh&&!e.textureTier&&e.mesh.material.color.set(c)),!o.global.map_texture_available)return;let l=e.body.data.id,u=s([o.global.texture&&{...o.global.texture,id:l,tiers:void 0},...o.global.alternates??[]]);a&&u&&a.credits.registerImagery(`surface`,l,l,u),await Xj(`topography`,l,l,o.global,e,{textureLoader:t,currentJd:n,ctx:a}),!(e.textureTier||e.textureLoading)&&Mx().showSurfaceTexture&&u&&(e.textureBundleId=u.id===l?void 0:u.id,e.availableTiers??=u.tiers??[...eM],e.availableFrames=u.frames,await aM(e,`low`,iM(n,e.availableFrames),t))}async function cM(e){if(!e.label)return;let t=e.body.data;if(t.name)return;let n=await hx(t.id,t.hasLocalized),r=n.localized?.name??n.global?.name;r&&(t.name??=r,Fk(e,r,Ik(e.body),t.objectType===W.STAR||t.objectType===W.PLANET))}function lM(e){if(!e.mesh)return;e.textureLoadGen=(e.textureLoadGen??0)+1;let t=e.mesh.material;Qj(`topography`,e),t.map&&(t.map.dispose(),t.map=null,t.color.set(__(e.body.data)),t.needsUpdate=!0,e.model&&hD(e.model,null,__(e.body.data)),e.textureTier=void 0)}async function uM(e,t,n,r){e.textureLoading||e.availableTiers?.includes(t)&&(e.textureTier===t&&e.textureFrame===n||await aM(e,t,n,r))}var dM=class{wanted=new Map;reverting=new Set;set(e,t){let n={...t};n.surface===void 0&&n.night===void 0&&n.clouds===void 0?this.wanted.delete(e):this.wanted.set(e,n),this.reverting.add(e)}get(e){let t=this.wanted.get(e);return t&&{...t}}ownsSurface(e){return this.wanted.get(e)?.surface!==void 0}apply(e,t){if(!(this.wanted.size===0&&this.reverting.size===0)){for(let t of this.reverting){let n=e.get(t);n&&fM(n,this.wanted.get(t))}this.reverting.clear();for(let[n,r]of this.wanted){let i=e.get(n);i?.mesh&&(r.surface!==void 0&&((i.appearance??={}).surfaceOwned=!0),pM(i,r,t,()=>this.wanted.get(n)))}}}};function fM(e,t){let n=e.appearance;if(!n||!e.mesh)return;let r=e.mesh.material;if(n.surfaceOwned&&t?.surface===void 0&&(n.surfaceMap?.dispose(),r.map=null,r.color.set(__(e.body.data)),r.needsUpdate=!0,e.model&&hD(e.model,null,__(e.body.data)),n.surfaceOwned=void 0,n.surfaceUrl=void 0,n.surfaceMap=void 0,e.textureTier=void 0),n.nightUrl!==void 0&&t?.night===void 0){let e=n.displacedNight;n.nightMap?.dispose(),e?Hj(r,e):Uj(r),n.nightUrl=void 0,n.nightMap=void 0,n.displacedNight=void 0}if(n.cloudsUrl!==void 0&&t?.clouds===void 0){n.cloudsMap?.dispose();let t=e.clouds;t&&n.ownCloudNode?(t.mesh.geometry.dispose(),t.material.dispose(),t.mesh.parent?.remove(t.mesh),e.clouds=null):t&&(t.material.map=n.displacedClouds??null,t.material.needsUpdate=!0,t.availableTiers=n.displacedCloudTiers??[],t.availableFrames=n.displacedCloudFrames??[]),n.cloudsUrl=void 0,n.cloudsMap=void 0,n.displacedClouds=void 0,n.ownCloudNode=void 0}}async function pM(e,t,n,r){let i=e.appearance??={};if(i.loading)return;let a=hM(e);if(!a)return;let o=t.surface!==void 0&&(t.surface!==i.surfaceUrl||a.map!==i.surfaceMap),s=t.night!==void 0&&(t.night!==i.nightUrl||a.emissiveMap!==i.nightMap),c=t.clouds!==void 0&&(t.clouds!==i.cloudsUrl||e.clouds?.material.map!==i.cloudsMap);if(!(!o&&!s&&!c)){i.loading=!0;try{if(o){let a=await gM(t.surface,n);if(r()!==t)return void a?.dispose();let o=hM(e);a&&o&&(gD(o,a),e.model&&hD(e.model,a,__(e.body.data)),i.surfaceUrl=t.surface,i.surfaceMap=a)}if(s){let a=await gM(t.night,n);if(r()!==t)return void a?.dispose();let o=hM(e);a&&o&&(i.displacedNight??=o.emissiveMap,Hj(o,a),i.nightUrl=t.night,i.nightMap=a)}if(c){let a=await gM(t.clouds,n);if(r()!==t)return void a?.dispose();a&&e.mesh&&mM(e,i,a,t.clouds)}}finally{i.loading=!1}}}function mM(e,t,n,r){let i=e.clouds;if(i)t.ownCloudNode||(t.displacedClouds??=i.material.map,t.displacedCloudTiers??=i.availableTiers,t.displacedCloudFrames??=i.availableFrames),i.material.map=n,i.material.needsUpdate=!0;else{if(!e.mesh)return;i=Pj(e.mesh,e.radiusScene,n),e.clouds=i,t.ownCloudNode=!0}i.availableTiers=[],i.availableFrames=[],t.cloudsUrl=r,t.cloudsMap=n}function hM(e){return e.mesh?e.mesh.material:null}async function gM(e,t){try{let n=await new Promise((n,r)=>{t.load(e,n,void 0,r)});return n.colorSpace=Xr,n}catch(t){return console.warn(`spacemap: could not load the picture at ${e}:`,t),null}}function _M(e){let t=new DataView(e),n=t.getUint32(0,!0);if(n!==1179536723)throw Error(`Invalid nomenclature file: bad magic 0x${n.toString(16)}`);let r=t.getUint16(4,!0);if(r!==1)throw Error(`Unsupported nomenclature file version: ${r}`);let i=t.getUint32(8,!0),a=Array(i);for(let e=0;e<i;e++){let n=16+e*20,r=t.getUint8(n+16),i=t.getUint8(n+17),o=i===0?String.fromCharCode(r):String.fromCharCode(r,i);a[e]={featureId:t.getUint32(n,!0),lat:t.getInt32(n+4,!0)/1e7,lon:t.getUint32(n+8,!0)/1e7,diameterM:t.getUint32(n+12,!0),typeCode:o,flags:t.getUint8(n+18)}}return a}var vM=new Map;async function yM(e){let t=Yt(`/v1/nomenclature/positions/${e}.bin.gz`,`nomenclature`),n=await fetch(t);if(!n.ok){if(n.status===404)return[];throw Error(`fetchPositions: ${t} returned ${n.status} ${n.statusText}`)}let r=new DecompressionStream(`gzip`);return _M(await new Response(n.body.pipeThrough(r)).arrayBuffer())}async function bM(e,t){let n=Yt(`/v1/nomenclature/labels/${t}/${e}.txt.gz`,`nomenclature`),r=await fetch(n);if(!r.ok){if(r.status===404)return[];throw Error(`fetchNomenclatureLabels: ${n} returned ${r.status} ${r.statusText}`)}let i=new DecompressionStream(`gzip`),a=await new Response(r.body.pipeThrough(i)).text();return a===``?[]:a.split(`
|
|
5544
|
+
`)}function xM(e,t=c()){let n=`${e}:${t}`,r=vM.get(n);return r||(r=(async()=>{let[n,r]=await Promise.all([yM(e),bM(e,t)]);return n.map((e,t)=>({...e,name:r[t]??`Feature ${e.featureId}`}))})(),vM.set(n,r),r.catch(()=>{vM.get(n)===r&&vM.delete(n)})),r}var SM=3;function CM(e,t,n=SM){let r=0,i=0;e.addEventListener(`pointerdown`,e=>{r=e.clientX,i=e.clientY}),e.addEventListener(`click`,e=>{e.stopPropagation();let a=e.clientX-r,o=e.clientY-i;a*a+o*o<=n*n&&t(e)})}function wM(e,t){if(e)return un(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var TM=Math.PI/180,EM=.9,DM=24,OM=.2,kM=100,AM=16,jM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function MM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await hx(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await xM(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!jM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:kM;return(t.diameterM>0?t.diameterM:kM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await FM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=aO(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new za,i=s.userData.centerOffset;i&&r.position.copy(i).multiplyScalar(-n),r.quaternion.copy(s.quaternion),e.group.add(r),e.nomenclatureAnchor=r,l=r}else{let t=e.mesh.geometry.parameters?.radius;if(!t)return;let n=null;if(r.global.displacement&&(n=await ww(e,e.body.data.id,r.global.displacement,gn(e.body.data),a.map(e=>({latRad:e.lat*TM,lonRad:e.lon*TM}))),e.nomenclatureLabels||!e.mesh))return;for(let e=0;e<o;e++)c[e]=t+(n?Q(n[e]):0);l=e.mesh}let u=Array(o),d=new Float32Array(o),f=new Float32Array(o).fill(-1),p=new Float32Array(o).fill(NaN),m=new Float32Array(o).fill(NaN),h=0;for(let e=0;e<o;e++){let r=a[e],i=r.diameterM>0?r.diameterM:kM;r.diameterM<=0&&h++;let o=document.createElement(`div`);o.className=`scene-feature-label`,o.dir=`auto`,o.textContent=r.name,o.dataset.featureId=String(r.featureId),zk(o,t),n&&CM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=lw(r.lat*TM,r.lon*TM),m=c[e],g=new nk(o);g.position.set(m*s,m*f,m*p),l.add(g),u[e]=g,d[e]=i}h>0&&console.log(`[nomenclature] ${e.body.data.id}: ${h}/${o} features have no diameter — using ${kM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var NM=8,PM=new J;async function FM(e,t){let n=t.length,r=new Float32Array(n),i=new Float32Array(n*3),a=e.userData.halfExtents;for(let o=0;o<n;o++){o>0&&o%NM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*TM,s=t[o].lon*TM,c=OO(e,n,s,PM);if(c!==null)r[o]=c;else{let[e,t,i]=lw(n,s),c=Math.max(a?.x??1,.001),l=Math.max(a?.y??1,.001),u=Math.max(a?.z??1,.001);r[o]=1/Math.sqrt((e/c)**2+(t/l)**2+(i/u)**2),PM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=PM.x,i[o*3+1]=PM.y,i[o*3+2]=PM.z}return{radii:r,normals:i}}function IM(e,t){let n=e.nomenclatureLabels;if(!n)return;let r=t===null?null:String(t),i=-1;for(let e=0;e<n.length;e++){let t=n[e].element,a=t.dataset.featureId===r;t.classList.toggle(`scene-feature-label--active`,a),a&&(i=e)}e.nomenclatureActiveIndex=i}function LM(e){if(e.nomenclatureLabels){for(let t of e.nomenclatureLabels)t.element.remove(),t.parent?.remove(t);e.nomenclatureAnchor&&=(e.nomenclatureAnchor.parent?.remove(e.nomenclatureAnchor),null),e.nomenclatureNormals=void 0,e.nomenclatureLabels=null,e.nomenclatureDiamsM=void 0,e.nomenclatureWidths=void 0,e.nomenclatureSX=void 0,e.nomenclatureSY=void 0,e.nomenclatureActiveIndex=void 0}}var RM=new J,zM=new J,BM=new J,VM=new J,HM=new J,UM=new Hi,WM=new J,GM=.12;function KM(e,t,n,r,i,a){let o=e.nomenclatureLabels;if(!o)return;if(!t||n<128){for(let e of o)e.visible=!1;return}let s=e.nomenclatureDiamsM,c=e.nomenclatureSX,l=e.nomenclatureSY,u=e.nomenclatureActiveIndex??-1,d=o.length,f=!!e.clouds?.mesh.visible,p=n/(gn(e.body.data)*1e3),m=OM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<DM)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(RM),r.getWorldPosition(zM);let h=zM.x-RM.x,g=zM.y-RM.y,_=zM.z-RM.z;VM.copy(RM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(EM*(n/Math.sqrt(Math.max(1-y/v,1e-6))))**2,x=.5*i,S=.5*a,C=e.nomenclatureNormals;C&&e.nomenclatureAnchor&&e.nomenclatureAnchor.getWorldQuaternion(UM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<DM||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(BM);let v=BM.x-RM.x,y=BM.y-RM.y,w=BM.z-RM.z;if(v*h+y*g+w*_<=v*v+y*y+w*w){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}if(C){WM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(UM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(WM.x*n+WM.y*r+WM.z*i<GM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}HM.copy(BM).project(r);let T=(HM.x-VM.x)*x,E=(HM.y-VM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(HM.x*.5+.5)*i,l[e]=(-HM.y*.5+.5)*a}}var qM=[];function JM(e){let t=qM[e];return t||(t={left:0,right:0,y:0,h:0},qM[e]=t),t}function YM(e,t,n,r){let i=e.nomenclatureLabels[t];if(!i.visible)return r;let a=e.nomenclatureSX[t],o=e.nomenclatureSY[t];if(Number.isNaN(a)||Number.isNaN(o))return r;let s=e.nomenclatureWidths,c=s[t];if(c<0){let e=i.element.offsetWidth;e>0?(s[t]=e,c=e):c=60}let l=c*.5,u=a-l,d=a+l;if(!n)for(let e=0;e<r;e++){let t=qM[e],n=(t.h+AM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=JM(r);return f.left=u,f.right=d,f.y=o,f.h=AM,r+1}function XM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=Ck,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=JM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=YM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=YM(e,i,!1,r))}var ZM=34028235e31,QM=3;function $M(e){return new X(e).multiplyScalar(.5)}function eN(){let e=document.createElement(`canvas`);e.width=32,e.height=32;let t=e.getContext(`2d`);return t.beginPath(),t.arc(32/2,32/2,32/2-2,0,Math.PI*2),t.fillStyle=`#aaaaaa`,t.globalAlpha=.3,t.fill(),new Nc(e)}function tN(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function nN(e,t,n,r=[0,0,0],i=4,a=null){let o=e.filter(e=>{let[t,n,r]=e.position;return isFinite(t)&&Math.abs(t)<=ZM&&isFinite(n)&&Math.abs(n)<=ZM&&isFinite(r)&&Math.abs(r)<=ZM?!0:(console.warn(`Skipping body with non-finite position: id=${e.data.id} name=${e.data.name}`,e.position),!1)}),s=new Float32Array(o.length*3),c=a?new Float32Array(o.length*3):null,l=c?new X:null;for(let e=0;e<o.length;e++){let t=o[e];s[e*3]=t.position[0]-r[0],s[e*3+1]=t.position[1]-r[1],s[e*3+2]=t.position[2]-r[2],c&&l&&a&&(l.set(a(t)),c[e*3]=l.r,c[e*3+1]=l.g,c[e*3+2]=l.b)}let u=new Ho;u.setAttribute(`position`,new Ao(s,3)),c&&u.setAttribute(`color`,new Ao(c,3));let d=new Ac(u,new Tc({map:t,color:c?new X(.5,.5,.5):$M(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=QM,d}function rN(e,t,n,r,i=4,a=null){let o=new Ho;o.setAttribute(`position`,new Do(e,3)),a&&o.setAttribute(`color`,new Do(a,3)),o.setDrawRange(0,t);let s=new Ac(o,new Tc({map:n,color:a?new X(.5,.5,.5):$M(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=QM,s}function iN(e,t=512,n=50){let r=e.q??e.a;if(!isFinite(r)||r<=0)return[];let i=Math.max(2*r/n-1,-.999),a=Math.acos(i),o=[];for(let n=0;n<=t;n++){let i=-a+2*a*n/t,s=2*r/(1+Math.cos(i)),c=s*Math.cos(i),l=s*Math.sin(i);o.push(Gv(c,l,e.w,e.i,e.om,e.equatorial))}return o}function aN(e,t=128){let{a:n,i:r,om:i,w:a}=e,o=Math.min(e.e,.9999999),s=1+3*o,c=Math.sqrt(1-o*o),l=[];for(let u=0;u<=t;u++){let d=2*u/t-1,f=Math.PI*Math.sign(d)*Math.abs(d)**+s,p=Math.cos(f),m=Math.sin(f),h=1-o*p,g=c*m/h,_=(p-o)/h,v=Math.atan2(g,_),y=n*h,b=y*Math.cos(v),x=y*Math.sin(v);!isFinite(b)||!isFinite(x)||l.push(Gv(b,x,a,r,i,e.equatorial))}return l}function oN(e,t=512,n=50){let r=Math.abs(e.a),i=r>0?(n/r+1)/e.e:100,a=Math.min(Math.acosh(Math.max(i,1)),6),o=[];for(let n=0;n<=t;n++){let r=-a+2*a*n/t,i=e.e*Math.cosh(r)-1;if(Math.abs(i)<1e-15)continue;let s=Math.sqrt(e.e*e.e-1)*Math.sinh(r)/i,c=(e.e-Math.cosh(r))/i,l=Math.atan2(s,c),u=e.a*(1-e.e*Math.cosh(r)),d=u*Math.cos(l),f=u*Math.sin(l);o.push(Gv(d,f,e.w,e.i,e.om,e.equatorial))}return o}function sN(e,t,n,r=128){if(!isFinite(n)||n<=0)return[];let i=1/n,a=[];for(let n=0;n<=r;n++){let o=bg(e,t-i+i*n/r);o&&a.push(o)}return a}function cN(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function lN(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:iN(e,t),isOpen:!0}:!n&&e.e>=1?{points:oN(e,t),isOpen:!0}:{points:aN(e,t),isOpen:!1}}var uN=3;function dN(e){let t=2*e,n=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),a=new Float32Array(t),o=new Float32Array(t);for(let t=0;t<e;t++)i[2*t]=-1,i[2*t+1]=1;let s=new Uint16Array(Math.max(0,6*(e-1)));for(let t=0;t<e-1;t++){let e=2*t,n=2*t+1,r=2*(t+1),i=2*(t+1)+1,a=t*6;s[a]=e,s[a+1]=n,s[a+2]=r,s[a+3]=r,s[a+4]=n,s[a+5]=i}let c=new Ho;return c.setAttribute(`position`,new Ao(n,3)),c.setAttribute(`nextPosition`,new Ao(r,3)),c.setAttribute(`side`,new Ao(i,1)),c.setAttribute(`trailAlpha`,new Ao(a,1)),c.setAttribute(`fullAlpha`,new Ao(o,1)),c.setIndex(new Oo(s,1)),c}function fN(e,t,n,r,i){let a=e.getAttribute(`position`),o=e.getAttribute(`nextPosition`),s=e.getAttribute(`trailAlpha`),c=e.getAttribute(`fullAlpha`),l=a.array,u=o.array,d=s.array,f=c.array,p=d.length/2,m=Math.min(i,p);for(let e=0;e<m;e++){let i=t[e*3],a=t[e*3+1],o=t[e*3+2],s=e<m-1?e+1:e,c=t[s*3],p=t[s*3+1],h=t[s*3+2],g=2*e*3;l[g]=i,l[g+1]=a,l[g+2]=o,l[g+3]=i,l[g+4]=a,l[g+5]=o,u[g]=c,u[g+1]=p,u[g+2]=h,u[g+3]=c,u[g+4]=p,u[g+5]=h;let _=n[e],v=r[e];d[2*e]=_,d[2*e+1]=_,f[2*e]=v,f[2*e+1]=v}a.needsUpdate=!0,o.needsUpdate=!0,s.needsUpdate=!0,c.needsUpdate=!0,e.setDrawRange(0,Math.max(0,6*(m-1)))}function pN(){let e=new Ho;e.setAttribute(`position`,new Ao(new Float32Array(6),3));let t=new yc(e,new fu({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=uN,t}function mN(e,t,n,r,i){let a=new Ho;a.setAttribute(`position`,new Ao(e,3)),a.setAttribute(`trailAlpha`,new Ao(t,1)),a.setAttribute(`fullAlpha`,new Ao(n,1)),a.setDrawRange(0,r);let o=new yc(a,gT(i));return o.matrixAutoUpdate=!1,o.renderOrder=uN,o}function hN(e,t,n){let r=e.getAttribute(`lineDistance`),i=r.array,a=Math.min(n,i.length/2);for(let e=0;e<a;e++)i[2*e]=i[2*e+1]=t[e];r.needsUpdate=!0}function gN(e,t,n,r,i,a,o,s,c){let l=dN(e);c&&l.setAttribute(`lineDistance`,new Ao(new Float32Array(2*e),1)),fN(l,t,n,r,i);let u=new As(l,_T(a,o,s,c));return u.matrixAutoUpdate=!1,u.renderOrder=uN,u}function _N(e){if(e.userData.isFatLine){let t=e.userData.thinPositions;return{posArr:t,trailArr:e.userData.thinTrailAlphas,fullArr:e.userData.thinFullAlphas,capacity:t.length/3}}let t=e.geometry.getAttribute(`position`);return{posArr:t.array,trailArr:e.geometry.getAttribute(`trailAlpha`).array,fullArr:e.geometry.getAttribute(`fullAlpha`).array,capacity:t.count}}function vN(e,t,n,r,i,a,o){if(i<2){e.geometry.setDrawRange(0,0),e.userData.isFatLine||(e.geometry.getAttribute(`position`).needsUpdate=!0);return}if(tb(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){fN(e.geometry,t,n,r,i);return}e.geometry.setDrawRange(0,i),e.geometry.getAttribute(`position`).needsUpdate=!0,e.geometry.getAttribute(`trailAlpha`).needsUpdate=!0,e.geometry.getAttribute(`fullAlpha`).needsUpdate=!0}function yN(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;n[0]=c[0]-o[0],n[1]=c[1]-o[1],n[2]=c[2]-o[2];let l=r-o[0],u=i-o[1],d=a-o[2];return 1+t.writeVertices(n.subarray(3),l,u,d,s)}function bN(e,t,n,r,i){let{orbitCenter:a,data:o}=e,s=a?.[0]??0,c=a?.[1]??0,l=a?.[2]??0,u=o.objectType===W.SPACECRAFT||o.objectType===W.DWARF_PLANET||o.objectType===W.MOON||o.objectType===W.COMET||_n(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=yN(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&tb(m.subarray(0,p),h.subarray(0,p),!0,u);let g=i>1,_=g?gN(d,f,h,m,p,n,i):mN(f,h,m,p,n);return _.frustumCulled=!1,_.visible=!1,_.userData.orbitCenter=new J(s,c,l),_.userData.trailBuffer=t,_.userData.useTrail=u,g&&(_.userData.isFatLine=!0,_.userData.thinPositions=f,_.userData.thinTrailAlphas=h,_.userData.thinFullAlphas=m),_}function xN(e,t,n=[0,0,0],r=Ng(new Date),i=1){if(e.trailBuffer)return bN(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l;if(s.satrec)c=sN(s.satrec,r,s.n/360,512),l=!0;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=cN(a)}let u=o?.[0]??0,d=o?.[1]??0,f=o?.[2]??0,p=l||s.objectType===W.DWARF_PLANET||s.objectType===W.MOON||s.objectType===W.SPACECRAFT||s.objectType===W.COMET||_n(s.objectType),m=c?eb(e,c,l,u,d,f):[];if(c&&m.length<2)return pN();let h=c?Math.max(m.length,c.length):513,g=new Float32Array(h),_=new Float32Array(h);tb(g.subarray(0,m.length),_.subarray(0,m.length),l,p);let v=u-n[0],y=d-n[1],b=f-n[2],x=new Float32Array(h*3);for(let e=0;e<m.length;e++)x[e*3]=m[e][0]+v,x[e*3+1]=m[e][1]+y,x[e*3+2]=m[e][2]+b;let S=i>1,C=S?gN(h,x,_,g,m.length,t,i):mN(x,_,g,m.length,t);return C.frustumCulled=!1,C.visible=!1,C.userData.orbitCenter=new J(u,d,f),C.userData.trailLocalPositions=c?m:void 0,C.userData.sourceCurve=c??void 0,C.userData.curvePending=c===null,C.userData.isOpenCurve=l,C.userData.useTrail=p,C.userData.curveJd=r,C.userData.elementsJd=a?.epoch??r,S&&(C.userData.isFatLine=!0,C.userData.thinPositions=x,C.userData.thinTrailAlphas=_,C.userData.thinFullAlphas=g),C}function SN(e,t){if(!t||t.size===0)return[...e];let n=[];for(let r of e)t.has(r.data.id)||n.push(r);return n}function CN(e){return e.data.objectType===W.PLANET?4:(e.data.objectType===W.MOON||e.data.objectType===W.DWARF_PLANET)&&n_[e.data.id]?3:1}function wN(e,t,n=[0,0,0],r){for(let[,i]of e){if(i.trail!==null)continue;let{body:e}=i;if(e.data.objectType===W.STAR)continue;if(e.data.orbitalSource===U.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&vj(e))continue;if(!e.orbitElements&&e.rederiveElements&&r!==void 0){let t=e.rederiveElements(r);t&&(e.orbitElements=t)}if(!e.orbitElements&&!e.trailBuffer)continue;let a=xN(e,h_(e.data),n,r,CN(e));t.add(a),i.trail=a}}function TN(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=tN();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=SN(c.values(),i);if(e.length===0)continue;let u=h_(e[0].data),{buckets:d}=b_(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=nN(i,n,u,r,l);a.userData.groupId=`asteroid:${s}#${e}`,a.userData.parentVec=[0,0,0],o.set(`${s}#${e}`,a),t.add(a)}}for(let[o,c]of e.bodies.spacecraftByParent.entries()){let l=wv(e.layers,o,SN(c.values(),i));if(l.length===0)continue;let{buckets:u}=b_(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=nN(i,n,`#ffffff`,r,void 0,e=>h_(e.data));a.userData.groupId=`spacecraft:${o}#${e}`,a.userData.parentBodyId=o,a.userData.parentVec=[0,0,0],s.set(`${o}#${e}`,a),t.add(a)}}let u=new Map;for(let t of e.bodies.majorBodies)if(t.data.objectType===W.MOON){let e=u.get(t.data.parentId)??[];e.push(t),u.set(t.data.parentId,e)}for(let[e,i]of u){let a=nN(i,n,h_(i[0].data),r),o=a.material;o.transparent=!1,o.alphaTest=.5,o.depthTest=!0,o.depthWrite=!0,a.visible=!1,c.set(e,a),t.add(a)}return{asteroidPoints:o,spacecraftPoints:s,moonPoints:c}}async function EN(e,t,n,r,i,a,o){let c;try{let t=await fetch(`${Kt()}/v1/systems/${e}.json`);if(!t.ok)return;c=await t.json()}catch{return}let l=[];for(let[u,d]of Object.entries(c)){let c=s([d.texture&&{...d.texture,id:u,tiers:d.tiers},...d.alternates??[]]);c&&o?.credits.registerImagery(`surface`,u,e,c);let f=t.get(u);if(f?.mesh){if(o?.bodies.orientationRead.add(u),d.orientation){if(yD(f,d.orientation,o,e),d.nut_prec){let e=u.match(/^naif-(-?\d+)$/),t=e?parseInt(e[1],10):null,n=t===null?void 0:Q_(Z_(t));n&&(f.body.nutPrec={...d.nut_prec,angles:n})}hC(f.mesh,d.orientation,i,f.body.nutPrec)}if(d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&oM(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,!f.textureTier)){let e=iM(i,f.availableFrames);l.push(uM(f,`low`,e,r))}l.push(...Zj(u,e,d,f,{textureLoader:r,currentJd:i,ctx:o})),d.rings?.length&&l.push(...Cj(u,e,d.rings,d.radii,f,n,a,o))}}await Promise.allSettled(l)}function DN(e,t,n,r){for(let i of t.values())if(r.visibility.isBodyInSystem(i.body,e)){if(lM(i),$j(i),i.terrainWindow&&i.mesh){i.terrainWindow=null;let e=Q(gn(i.body.data)),t=i.mesh.geometry;i.mesh.geometry=new ru(e,24,24),t.dispose(),i.currentSegments=24}for(let e of i.rings){e.planetShadow?.disable(),n.remove(e.mesh);let t=i.extraObjects.indexOf(e.mesh);t>=0&&i.extraObjects.splice(t,1),fA(e)}i.rings=[],LM(i)}}var ON=class{lastBaryId=null;pendingUnloads=new Set;prefetched=new Set;constructor(e,t,n,r,i,a,o){this.scene=e,this.ctx=t,this.renderer=n,this.textureLoader=r,this.bodyObjects=i,this.clock=a,this.onLoaded=o}syncToFocus(){let e=this.ctx.visibility.focusedSystemId,t=e?this.resolveBaryId(e):null;if(!t){this.lastBaryId&&=(this.pendingUnloads.add(this.lastBaryId),null);return}t!==this.lastBaryId&&(this.lastBaryId&&this.pendingUnloads.add(this.lastBaryId),this.pendingUnloads.delete(t),this.prefetched.delete(t),this.lastBaryId=t,this.load(t))}prefetch(e){let t=this.resolveBaryId(e);!t||t===this.lastBaryId||this.prefetched.has(t)||(this.prefetched.add(t),this.pendingUnloads.delete(t),this.load(t))}discardPrefetch(e){let t=this.resolveBaryId(e);!t||!this.prefetched.delete(t)||t!==this.lastBaryId&&this.pendingUnloads.add(t)}resolveBaryId(e){let t=this.ctx.getBody(e);if(t?.data.objectType===W.BARYCENTER)return e;let n=t?.data.parentId??e;return M_(n)?null:n}load(e){EN(e,this.bodyObjects,this.scene,this.textureLoader,this.clock.jd,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.onLoaded(),this.ctx.bodies.orientationVersion++})}drainPendingUnloads(){if(this.pendingUnloads.size!==0){for(let e of this.pendingUnloads)DN(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},kN=Math.PI/180,AN=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Hi;_adjustQ=new Hi;_tmpQ=new Hi;_axisX=new J(1,0,0);_axisY=new J(0,1,0);_axisZ=new J(0,0,1);constructor(e){this.scene=e}get(){return{...this.adjust}}set(e,t,n){this.adjust.rxDeg=e,this.adjust.ryDeg=t,this.adjust.rzDeg=n,this._adjustQ.setFromAxisAngle(this._axisX,e*kN).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*kN)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*kN)),this._q.copy(Qx).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},jN=Math.PI/180,MN=ag*jN,NN=Math.cos(MN),PN=Math.sin(MN),FN=5e3,IN=[{id:`galactic-center`,label:`Galactic Center`,raDeg:266.41683,decDeg:-29.00781,color:`#ff6b35`},{id:`galactic-anticenter`,label:`Galactic Anticenter`,raDeg:86.4,decDeg:28.93785,color:`#ff6b35`},{id:`galactic-np`,label:`Galactic NP`,raDeg:192.85948,decDeg:27.12825,color:`#ffb84d`},{id:`galactic-sp`,label:`Galactic SP`,raDeg:12.85948,decDeg:-27.12825,color:`#ffb84d`},{id:`ncp`,label:`NCP (Polaris ≈)`,raDeg:37.9542,decDeg:89.2641,color:`#4dd0ff`},{id:`scp`,label:`SCP`,raDeg:0,decDeg:-90,color:`#4dd0ff`},{id:`vernal`,label:`Vernal Equinox (γ)`,raDeg:0,decDeg:0,color:`#9d8cff`},{id:`autumnal`,label:`Autumnal Equinox`,raDeg:180,decDeg:0,color:`#9d8cff`},{id:`m31`,label:`M31 (Andromeda)`,raDeg:10.6847,decDeg:41.2692,color:`#ffffff`},{id:`lmc`,label:`LMC (Large Magellanic Cloud)`,raDeg:80.8942,decDeg:-69.7561,color:`#ffffff`},{id:`smc`,label:`SMC (Small Magellanic Cloud)`,raDeg:13.1583,decDeg:-72.8003,color:`#ffffff`},{id:`sirius`,label:`Sirius`,raDeg:101.2872,decDeg:-16.7161,color:`#ffffff`}],LN=192.85948,RN=27.12825,zN=266.40499,BN=-28.93617,VN=256,HN=[{name:`galactic-plane`,zero:UN(zN,BN,new J).normalize(),pole:UN(LN,RN,new J).normalize(),color:16739125},{name:`ecliptic-plane`,zero:new J(1,0,0),pole:new J(0,1,0),color:5099775},{name:`celestial-equator`,zero:UN(0,0,new J).normalize(),pole:UN(0,90,new J).normalize(),color:10325247}];function UN(e,t,n){let r=e*jN,i=t*jN,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*NN+c*PN,d=-s*PN+c*NN;return n.set(l,d,-u)}function WN(e){let t=document.createElement(`div`);t.className=`sky-debug-marker`,t.style.cssText=[`display:flex`,`align-items:center`,`gap:4px`,`font:11px/1 monospace`,`text-shadow:0 0 3px #000, 0 0 3px #000`,`pointer-events:none`,`white-space:nowrap`].join(`;`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`width`,`48`),n.setAttribute(`height`,`48`),n.setAttribute(`viewBox`,`-24 -24 48 48`),n.style.cssText=`flex:0 0 auto;filter:drop-shadow(0 0 2px #000);margin-inline-start:-24px`;let r=e.color;n.innerHTML=`
|
|
5534
5545
|
<circle cx="0" cy="0" r="14" fill="none" stroke="${r}" stroke-width="1.6"/>
|
|
5535
5546
|
<line x1="-23" y1="0" x2="-10" y2="0" stroke="${r}" stroke-width="1.6"/>
|
|
5536
5547
|
<line x1="10" y1="0" x2="23" y2="0" stroke="${r}" stroke-width="1.6"/>
|
|
5537
5548
|
<line x1="0" y1="-23" x2="0" y2="-10" stroke="${r}" stroke-width="1.6"/>
|
|
5538
5549
|
<line x1="0" y1="10" x2="0" y2="23" stroke="${r}" stroke-width="1.6"/>
|
|
5539
|
-
`;let i=document.createElement(`span`);return i.textContent=e.label,i.style.color=e.color,i.style.marginInlineStart=`2px`,t.appendChild(n),t.appendChild(i),t}function HN(e,t,n,r,i){let a=new J().crossVectors(t,e).normalize(),o=new Float32Array(i*3),s=new J;for(let t=0;t<i;t++){let r=t/i*Math.PI*2,c=Math.cos(r),l=Math.sin(r);s.copy(e).multiplyScalar(c).addScaledVector(a,l).multiplyScalar(n),o[t*3]=s.x,o[t*3+1]=s.y,o[t*3+2]=s.z}let c=new Ho;c.setAttribute(`position`,new Ao(o,3));let l=new wc(c,new dc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function UN(){let e=new za;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of NN){BN(n.raDeg,n.decDeg,t).multiplyScalar(MN);let r=new $O(VN(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of zN){let n=HN(t.zero,t.pole,MN*.999,t.color,RN);n.name=t.name,e.add(n)}return e}function WN(e){e.traverse(e=>{e instanceof $O&&e.element.remove(),e instanceof wc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var GN=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=UN(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(WN(this.group),null)}},KN=new J,qN=new J,JN=new J,YN=[KN,qN,JN];function XN(e,t,n){return KN.set(1,0,0).applyQuaternion(e).transformDirection(t),qN.set(0,1,0).applyQuaternion(e).transformDirection(t),JN.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:YN,a:n}}function ZN(e,t,n,r,i,a,o,s,c,l){let u=1/i;e.gxx=u,e.gxy=0,e.gxz=0,e.gyx=0,e.gyy=u,e.gyz=0,e.gzx=0,e.gzy=0,e.gzz=u,e.cpx=t*u,e.cpy=n*u,e.cpz=r*u,e.K=(t*t+n*n+r*r)*u*u-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function QN(e,t,n,r,i,a,o,s,c,l){let[u,d,f]=i.e,[p,m,h]=i.a;e.gxx=u.x/p,e.gxy=u.y/p,e.gxz=u.z/p,e.gyx=d.x/m,e.gyy=d.y/m,e.gyz=d.z/m,e.gzx=f.x/h,e.gzy=f.y/h,e.gzz=f.z/h;let g=(t*u.x+n*u.y+r*u.z)/p,_=(t*d.x+n*d.y+r*d.z)/m,v=(t*f.x+n*f.y+r*f.z)/h;e.cpx=g,e.cpy=_,e.cpz=v,e.K=g*g+_*_+v*v-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function $N(e,t,n,r,i,a){let[o,s,c]=r.e,[l,u,d]=r.a,f=1/(l*l),p=1/(u*u),m=1/(d*d),h=f*o.x*o.x+p*s.x*s.x+m*c.x*c.x,g=f*o.x*o.y+p*s.x*s.y+m*c.x*c.y,_=f*o.x*o.z+p*s.x*s.z+m*c.x*c.z,v=f*o.y*o.y+p*s.y*s.y+m*c.y*c.y,y=f*o.y*o.z+p*s.y*s.z+m*c.y*c.z,b=f*o.z*o.z+p*s.z*s.z+m*c.z*c.z,x=h*e+g*t+_*n,S=g*e+v*t+y*n,C=_*e+y*t+b*n,w=e*x+t*S+n*C-1,T=i,E=w*h-x*x,D=2*(w*g-x*S),O=w*v-S*S,k=-2*T*(w*_-x*C),A=-2*T*(w*y-S*C),j=4*E*O-D*D,M=(-2*O*k+D*A)/j,ee=(-2*E*A+D*k)/j,N=-n/T;a.ox=M*N-e,a.oy=ee*N-t}var eP=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Hi;items=[];one=[];labelRect={x:0,left:0,right:0,y:0,h:0};constructor(e){this.anchor=e}get active(){return this.canvas!==null}setVisible(e){if(e){if(this.canvas)return;let e=document.createElement(`canvas`);e.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:5`,this.anchor.parentElement?.appendChild(e),this.canvas=e,this.gfx=e.getContext(`2d`)}else this.canvas&&(this.canvas.remove(),this.canvas=null,this.gfx=null)}draw(e,t,n,r,i,a){let o=this.gfx,s=this.canvas;if(!o||!s)return;let c=window.devicePixelRatio||1,l=Math.round(i*c),u=Math.round(a*c);(s.width!==l||s.height!==u)&&(s.width=l,s.height=u),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,i,a),o.font=`10px monospace`,o.textBaseline=`middle`;let d=t.fov*Math.PI/180,f=a/(2*Math.tan(d/2)),p=t.matrixWorldInverse,[m,h,g]=n,_=i*.5,v=a*.5,y=0;for(let o of e.values()){let{label:e,group:s,radiusScene:c}=o;if(!e||c<=0)continue;let[l,u,d]=o.body.position;this.tmp.set(l-m,u-h,d-g).applyMatrix4(p);let b=this.tmp.x,x=this.tmp.y,S=this.tmp.z;if(S>=0||b*b+x*x+S*S<=c*c)continue;let C=tk(this.items,y++,tP),w=!!(o.semiAxesScene&&o.mesh);if(w){let e=XN(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);C.e0.copy(e.e[0]),C.e1.copy(e.e[1]),C.e2.copy(e.e[2]),C.sa[0]=e.a[0],C.sa[1]=e.a[1],C.sa[2]=e.a[2],QN(C.occ,b,x,S,e,f,_,v,o.body.data.id,o.cachedDist)}else C.e0.set(1,0,0),C.e1.set(0,1,0),C.e2.set(0,0,1),C.sa[0]=C.sa[1]=C.sa[2]=c,ZN(C.occ,b,x,S,c,f,_,v,o.body.data.id,o.cachedDist);let T=S*S-c*c,E=T<=0,D=E?0:c*f/Math.sqrt(T),O=E||D>=16;this.tmp.set(l-m,u-h,d-g).project(t),C.cx=(this.tmp.x*.5+.5)*i,C.cy=(-this.tmp.y*.5+.5)*a,pk(o,t,n,i,a,this.labelRect),C.hx=this.labelRect.x,C.hy=this.labelRect.y,C.id=o.body.data.id,C.camX=b,C.camY=x,C.camZ=S,C.worldR=c,C.dist=o.cachedDist,C.isEllipsoid=w,C.degenerate=E,C.isOccluder=O,C.meshHidden=!s.visible,C.labelVisible=e.visible,C.maximized=o.labelMaximized!==!1,C.focused=o.body.data.id===r,C.occludedBy=-1}for(let e=0;e<y;e++){let t=this.items[e];for(let e=0;e<y;e++){let n=this.items[e];if(!(!n.isOccluder||n.id===t.id)&&(this.one[0]=n.occ,this.one.length=1,dk(t.hx,t.hy,t.dist,t.id,this.one))){t.occludedBy=e;break}}}for(let e=0;e<y;e++){let n=this.items[e];if(n.meshHidden&&!n.isOccluder)continue;let r=n.focused?`#7dff7d`:n.isOccluder?`#ff8c1a`:n.labelVisible?n.maximized?`#1ae5ff`:`#ffe11a`:`#ff3b3b`;if(o.beginPath(),n.meshHidden&&o.setLineDash([5,4]),this.strokeLimb(o,n,t,i,a)&&(o.strokeStyle=r,o.lineWidth=n.isOccluder?2:1,o.stroke(),n.isOccluder&&(o.fillStyle=`rgba(255,140,26,0.08)`,o.fill())),o.setLineDash([]),!n.degenerate){let e=n.hx-n.cx,t=n.hy-n.cy;if(e*e+t*t>1&&(o.beginPath(),o.moveTo(n.cx,n.cy),o.lineTo(n.hx,n.hy),o.strokeStyle=`rgba(255,225,26,0.5)`,o.lineWidth=1,o.stroke(),iP(o,n.cx,n.cy,4,`#ff3ad1`)),n.occludedBy>=0){let e=this.items[n.occludedBy];o.beginPath(),o.setLineDash([4,3]),o.moveTo(n.hx,n.hy),o.lineTo(e.cx,e.cy),o.strokeStyle=`rgba(255,59,59,0.9)`,o.lineWidth=1,o.stroke(),o.setLineDash([])}o.beginPath(),o.arc(n.hx,n.hy,1.5,0,Math.PI*2),o.fillStyle=r,o.fill(),o.fillStyle=`rgba(255,255,255,0.85)`,o.fillText(n.id,n.hx+8,n.hy)}}rP(o,a)}strokeLimb(e,t,n,r,i){let{camX:a,camY:o,camZ:s,e0:c,e1:l,e2:u,sa:d}=t,f=(a*c.x+o*c.y+s*c.z)/d[0],p=(a*l.x+o*l.y+s*l.z)/d[1],m=(a*u.x+o*u.y+s*u.z)/d[2],h=f*f+p*p+m*m;if(h<=1)return!1;let g=Math.sqrt(h),_=(h-1)/h,v=Math.sqrt(h-1)/g,y=f*_,b=p*_,x=m*_,S=f/g,C=p/g,w=m/g,T=0,E=1;Math.abs(w)>.9&&(T=1,E=0);let D=C*E-w*0,O=w*T-S*E,k=S*0-C*T,A=Math.hypot(D,O,k)||1;D/=A,O/=A,k/=A;let j=C*k-w*O,M=w*D-S*k,ee=S*O-C*D,N=n.projectionMatrix.elements,te=!1;for(let t=0;t<=72;t++){let n=t/72*Math.PI*2,a=Math.cos(n),o=Math.sin(n),s=y+v*(a*D+o*j),f=b+v*(a*O+o*M),p=x+v*(a*k+o*ee),m=d[0]*s*c.x+d[1]*f*l.x+d[2]*p*u.x,h=d[0]*s*c.y+d[1]*f*l.y+d[2]*p*u.y,g=d[0]*s*c.z+d[1]*f*l.z+d[2]*p*u.z,_=N[3]*m+N[7]*h+N[11]*g+N[15];if(_<=1e-6){te=!1;continue}let S=(N[0]*m+N[4]*h+N[8]*g+N[12])/_,C=(N[1]*m+N[5]*h+N[9]*g+N[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;te?e.lineTo(w,T):(e.moveTo(w,T),te=!0)}return!0}dispose(){this.setVisible(!1)}};function tP(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:ak(),cx:0,cy:0,hx:0,hy:0,dist:0,isEllipsoid:!1,isOccluder:!1,degenerate:!1,meshHidden:!1,labelVisible:!1,maximized:!1,focused:!1,occludedBy:-1}}var nP=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function rP(e,t){let n=t-8-(nP.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of nP)e.fillStyle=t,e.fillRect(8,n-4,8,8),e.fillStyle=`rgba(255,255,255,0.9)`,e.fillText(r,20,n),n+=13}function iP(e,t,n,r,i){e.strokeStyle=i,e.lineWidth=1,e.beginPath(),e.moveTo(t-r,n),e.lineTo(t+r,n),e.moveTo(t,n-r),e.lineTo(t,n+r),e.stroke()}function aP(e){let{fps:t,orbitPool:n,renderer:r,bodyObjects:i,focusedBody:a,cameraDistanceScene:o}=e,s=r.info;return{fps:t,workers:n.workerCount,workerGroups:n.groupCount,drawCalls:s.render.calls,triangles:s.render.triangles,geometries:s.memory.geometries,textures:s.memory.textures,programs:s.programs?.length??0,promotedBodies:i.size,focusedId:a?.data.id,focusedName:a?.data.name??void 0,cameraDistanceAU:o/10,viewportW:r.domElement.clientWidth,viewportH:r.domElement.clientHeight,pixelRatio:r.getPixelRatio()}}var oP="function e(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}function t(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>700)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function n(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}const r=149597870.7,i=23.4392911;86400**2/r**3,1/r,Math.cos(Math.PI/180*i),Math.sin(Math.PI/180*i);const a=Math.PI,o=a*2,s=a/180;180/a;const c=6378.135,l=60/Math.sqrt(c*c*c/398600.8),u=c*l/60,d=1/l,f=.001082616,p=-253881e-11/f,m=2/3,ee=1440/(2*a);function te(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function h(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function g(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return h(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return h(e,t,n,r,i,a,o)}function ne(e,t){let{e3:n,ee2:r,peo:i,pgho:s,pho:c,pinco:l,plo:u,se2:d,se3:f,sgh2:p,sgh3:m,sgh4:ee,sh2:te,sh3:h,si2:g,si3:ne,sl2:_,sl3:v,sl4:y,t:b,xgh2:re,xgh3:ie,xgh4:x,xh2:ae,xh3:S,xi2:C,xi3:w,xl2:T,xl3:E,xl4:D,zmol:O,zmos:k}=e,{init:A,opsmode:j}=t,{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),X=fe+2*.01675*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*Y,ge=p*U+m*W+ee*Y,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),X=fe+2*.0549*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*Y,be=re*U+ie*W+x*Y,xe=ae*U+S*W;return G=pe+_e,J=me+ve,le=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,le-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,se+=K,N+=q,P+=le):(z=Math.sin(N),ce=Math.cos(N),F=R*z,I=R*ce,B=q*ce+J*L*z,V=-q*z+J*L*ce,F+=B,I+=V,N%=o,N<0&&j===`a`&&(N+=o),ue=P+se+L*N,H=le+K-J*N*R,ue+=H,de=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(de-N)>a&&(N<de?N+=o:N-=o),P+=le,se=ue-P-L*N)),{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}}function _(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:s,np:c}=e,l,u,d,f,p,m,ee,te,h,g,ne,_,v,y,b,re,ie,x,ae,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be=.01675,xe=.0549,Se=c,Ce=n,we=Math.sin(s),Te=Math.cos(s),Ee=Math.sin(r),Q=Math.cos(r),De=Math.sin(a),Oe=Math.cos(a),$=Ce*Ce,ke=1-$,Ae=Math.sqrt(ke),je=t+18261.5+i/1440,Me=(4.523602-.00092422029*je)%o,Ne=Math.sin(Me),Pe=Math.cos(Me),Fe=.91375164-.03568096*Pe,Ie=Math.sqrt(1-Fe*Fe),Le=.089683511*Ne/Ie,Re=Math.sqrt(1-Le*Le),ze=5.8351514+.001944368*je,Be=.39785416*Ne/Ie,Ve=Re*Pe+.91744867*Le*Ne;Be=Math.atan2(Be,Ve),Be+=ze-Me;let He=Math.cos(Be),Ue=Math.sin(Be);S=.1945905,C=-.98088458,E=.91744867,D=.39785416,w=Te,T=we,ne=29864797e-13;let We=1/Se,Ge=0;for(;Ge<2;)Ge+=1,l=S*w+C*E*T,d=-C*w+S*E*T,ee=-S*T+C*E*w,te=C*D,h=C*T+S*E*w,g=S*D,u=Oe*ee+De*te,f=Oe*h+De*g,p=-De*ee+Oe*te,m=-De*h+Oe*g,_=l*Q+u*Ee,v=d*Q+f*Ee,y=-l*Ee+u*Q,b=-d*Ee+f*Q,re=p*Ee,ie=m*Ee,x=p*Q,ae=m*Q,_e=12*_*_-3*y*y,ve=24*_*v-6*y*b,ye=12*v*v-3*b*b,ue=3*(l*l+u*u)+_e*$,de=6*(l*d+u*f)+ve*$,X=3*(d*d+f*f)+ye*$,fe=-6*l*p+$*(-24*_*x-6*y*re),pe=-6*(l*m+d*p)+$*(-24*(v*x+_*ae)+-6*(y*ie+b*re)),me=-6*d*m+$*(-24*v*ae-6*b*ie),he=6*u*p+$*(24*_*re-6*y*x),ge=6*(f*p+u*m)+$*(24*(v*re+_*ie)-6*(b*x+y*ae)),Z=6*f*m+$*(24*v*ie-6*b*ae),ue=ue+ue+ke*_e,de=de+de+ke*ve,X=X+X+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,le=v*y+_*b,Y=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=le,N=Y,se=ue,P=de,F=X,I=fe,L=pe,R=me,ce=he,z=ge,B=Z,V=_e,H=ve,U=ye,S=He,C=Ue,E=Fe,D=Ie,w=Re*Te+Le*we,T=we*Re-Te*Le,ne=4.7968065e-7);let Ke=(4.7199672+(.2299715*je-ze))%o,qe=(6.2565837+.017201977*je)%o,Je=2*O*M,Ye=2*O*N,Xe=2*k*L,Ze=2*k*(R-I),Qe=-2*A*P,$e=-2*A*(F-se),et=-2*A*(-21-9*$)*be,tt=2*j*H,nt=2*j*(U-V),rt=-18*j*be,it=-2*k*z,at=-2*k*(B-ce),ot=2*W*le,st=2*W*Y,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*de,dt=-2*K*(X-ue),ft=-2*K*(-21-9*$)*xe,pt=2*q*ve,mt=2*q*(ye-_e),ht=-18*q*xe,gt=-2*G*ge,_t=-2*G*(Z-he);return{snodm:we,cnodm:Te,sinim:De,cosim:Oe,sinomm:Ee,cosomm:Q,day:je,e3:st,ee2:ot,em:Ce,emsq:$,gam:ze,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Ae,se2:Je,se3:Ye,sgh2:tt,sgh3:nt,sgh4:rt,sh2:it,sh3:at,si2:Xe,si3:Ze,sl2:Qe,sl3:$e,sl4:et,s1:W,s2:G,s3:K,s4:q,s5:J,s6:le,s7:Y,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:se,sz2:P,sz3:F,sz11:I,sz12:L,sz13:R,sz21:ce,sz22:z,sz23:B,sz31:V,sz32:H,sz33:U,xgh2:pt,xgh3:mt,xgh4:ht,xh2:gt,xh3:_t,xi2:ct,xi3:lt,xl2:ut,xl3:dt,xl4:ft,nm:Se,z1:ue,z2:de,z3:X,z11:fe,z12:pe,z13:me,z21:he,z22:ge,z23:Z,z31:_e,z32:ve,z33:ye,zmol:Ke,zmos:qe}}function v(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:s,s4:c,s5:u,sinim:d,ss1:f,ss2:p,ss3:ee,ss4:te,ss5:h,sz1:g,sz3:ne,sz11:_,sz13:v,sz21:y,sz23:b,sz31:re,sz33:ie,t:x,tc:ae,gsto:S,mo:C,mdot:w,no:T,nodeo:E,nodedot:D,xpidot:O,z1:k,z3:A,z11:j,z13:oe,z21:M,z23:N,z31:se,z33:P,ecco:F,eccsq:I}=e,{emsq:L,em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}=e,we,Te,Ee,Q,De,Oe,$,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et=.0043752690880113,tt=.00015835218,nt=119459e-10;U=0,V<.0052359877&&V>.0034906585&&(U=1),V>=.00826&&V<=.00924&&R>=.5&&(U=2);let rt=f*nt*h,it=p*nt*(_+v),at=-nt*ee*(g+ne-14-6*L),ot=te*nt*(re+ie-6),st=-nt*p*(y+b);(z<.052359877||z>a-.052359877)&&(st=0),d!==0&&(st/=d);let ct=ot-t*st;pe=rt+r*tt*u,me=it+i*tt*(j+oe),he=at-tt*s*(k+A-14-6*L);let lt=c*tt*(se+P-6),ut=-tt*i*(M+N);(z<.052359877||z>a-.052359877)&&(ut=0),Z=ct+lt,ge=st,d!==0&&(Z-=t/d*ut,ge+=ut/d);let dt=(S+ae*et)%o;if(R+=pe*x,z+=me*x,ce+=Z*x,H+=ge*x,B+=he*x,U!==0){if(Ze=(V/l)**m,U===2){Qe=t*t;let e=R;R=F;let n=L;L=I,$e=R*L,Fe=-.306-(R-.64)*.44,R<=.65?(Ie=3.616-13.247*R+16.29*L,Re=-19.302+117.39*R-228.419*L+156.591*$e,ze=-18.9068+109.7927*R-214.6334*L+146.5816*$e,Be=-41.122+242.694*R-471.094*L+313.953*$e,Ve=-146.407+841.88*R-1629.014*L+1083.435*$e,He=-532.114+3017.977*R-5740.032*L+3708.276*$e):(Ie=-72.099+331.819*R-508.738*L+266.724*$e,Re=-346.844+1582.851*R-2415.925*L+1246.113*$e,ze=-342.585+1554.908*R-2366.899*L+1215.972*$e,Be=-1052.797+4758.686*R-7193.992*L+3651.957*$e,Ve=-3581.69+16178.11*R-24462.77*L+12422.52*$e,He=R>.715?-5149.66+29936.92*R-54087.36*L+31324.56*$e:1464.74-4664.75*R+3763.64*L),R<.7?(Ge=-919.2277+4988.61*R-9064.77*L+5542.21*$e,Ue=-822.71072+4568.6173*R-8491.4146*L+5337.524*$e,We=-853.666+4690.25*R-8624.77*L+5341.4*$e):(Ge=-37995.78+161616.52*R-229838.2*L+109377.94*$e,Ue=-51752.104+218913.95*R-309468.16*L+146349.42*$e,We=-40023.88+170470.89*R-242699.48*L+115605.82*$e),Ke=d*d,we=.75*(1+2*t+Qe),Te=1.5*Ke,Q=1.875*d*(1-2*t-3*Qe),De=-1.875*d*(1+2*t-3*Qe),$=35*Ke*we,ke=39.375*Ke*Ke,Ae=9.84375*d*(Ke*(1-2*t-5*Qe)+.33333333*(-2+4*t+6*Qe)),je=d*(4.92187512*Ke*(-2-4*t+10*Qe)+6.56250012*(1+2*t-3*Qe)),Me=29.53125*d*(2-8*t+Qe*(-12+8*t+10*Qe)),Ne=29.53125*d*(-2-8*t+Qe*(12+8*t-10*Qe)),Ye=V*V,Xe=Ze*Ze,Je=3*Ye*Xe,qe=Je*17891679e-13,G=qe*we*Fe,K=qe*Te*Ie,Je*=Ze,qe=Je*3.7393792e-7,q=qe*Q*Re,J=qe*De*ze,Je*=Ze,qe=2*Je*7.3636953e-9,le=qe*$*Be,Y=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,ue=qe*Ae*He,de=qe*je*We,qe=2*Je*2.1765803e-9,X=qe*Me*Ue,fe=qe*Ne*Ge,xe=(C+E+E-(dt+dt))%o,be=w+he+2*(D+ge-et)-T,R=e,L=n}U===1&&(Pe=1+L*(-2.5+.8125*L),Re=1+2*L,Le=1+L*(-6+6.60937*L),we=.75*(1+t)*(1+t),Ee=.9375*d*d*(1+3*t)-.75*(1+t),Oe=1+t,Oe*=1.875*Oe*Oe,_e=3*V*V*Ze*Ze,ve=2*_e*we*Pe*17891679e-13,ye=3*_e*Oe*Le*2.2123015e-7*Ze,_e=_e*Ee*Re*21460748e-13*Ze,xe=(C+E+n-dt)%o,be=w+O+he+Z+ge-(T+et)),Se=xe,Ce=T,W=0,V=T+0}return{em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dndt:0,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}}function y(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*s/240%o,n<0&&(n+=o),n}function b(e,t,n,r,i,a,o){return e instanceof Date?y(g(e)):y(t===void 0?e:g(e,t,n,r,i,a,o))}function re(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,s=t*t,c=1-s,u=Math.sqrt(c),d=Math.cos(r),p=d*d,ee=(l/a)**m,te=.75*f*(3*p-1)/(u*c),h=te/(ee*ee),g=ee*(1-h*h-h*(1/3+134*h*h/81));h=te/(g*g),a/=1+h;let ne=(l/a)**m,_=Math.sin(r),v=ne*c,y=1-5*p,re=-y-p-p,ie=1/ne,x=v*v,ae=ne*(1-t),S;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+o;S=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%o,S<0&&(S+=o)}else S=b(n+2433281.5);return{no:a,method:`n`,ainv:ie,ao:ne,con41:re,con42:y,cosio:d,cosio2:p,eccsq:s,omeosq:c,posq:x,rp:ae,rteosq:u,sinio:_,gsto:S}}function ie(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:s,d4422:c,d5220:l,d5232:u,d5421:d,d5433:f,dedt:p,del1:m,del2:ee,del3:te,didt:h,dmdt:g,dnodt:ne,domdt:_,argpo:v,argpdot:y,t:b,tc:re,gsto:ie,xfact:x,xlamo:ae,no:S}=e,{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,nm:j}=e,oe=.13130908,M=2.8843198,N=.37448087,se=5.7686396,P=.95240898,F=1.8014998,I=1.050833,L=4.4108898,R=259200,ce,z,B,V,H,U,W,G,K=0,q=0,J=(ie+re*.0043752690880113)%o;if(w+=p*b,E+=h*b,T+=_*b,A+=ne*b,O+=g*b,t!==0){(C===0||b*C<=0||Math.abs(b)<Math.abs(C))&&(C=0,k=S,D=ae),ce=b>0?720:-720;let e=381;for(;e===381;)t===2?(G=v+y*C,B=G+G,z=D+D,W=n*Math.sin(B+D-se)+r*Math.sin(D-se)+i*Math.sin(G+D-P)+a*Math.sin(-G+D-P)+s*Math.sin(B+z-F)+c*Math.sin(z-F)+l*Math.sin(G+D-I)+u*Math.sin(-G+D-I)+d*Math.sin(G+z-L)+f*Math.sin(-G+z-L),H=k+x,U=n*Math.cos(B+D-se)+r*Math.cos(D-se)+i*Math.cos(G+D-P)+a*Math.cos(-G+D-P)+l*Math.cos(G+D-I)+u*Math.cos(-G+D-I)+2*(s*Math.cos(B+z-F)+c*Math.cos(z-F)+d*Math.cos(G+z-L)+f*Math.cos(-G+z-L)),U*=H):(W=m*Math.sin(D-oe)+ee*Math.sin(2*(D-M))+te*Math.sin(3*(D-N)),H=k+x,U=m*Math.cos(D-oe)+2*ee*Math.cos(2*(D-M))+3*te*Math.cos(3*(D-N)),U*=H),Math.abs(b-C)>=720?e=381:(q=b-C,e=0),e===381&&(D+=H*ce+W*R,k+=W*ce+U*R,C+=ce);j=k+W*q+U*q*q*.5,V=D+H*q+W*q*q*.5,t===1?(O=V-A-T+J,K=j-S):(O=V-2*A+2*J,K=j-S),j=S+K}return{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,dndt:K,nm:j}}var x;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})(x||={});function ae(e,t){let n,r,i,s,d,ee,te,h,g,_,v,y,b,re,ae,S,C,w,T,E,D,O,k,A,j,oe,M;e.t=t,e.error=x.None;let N=e.mo+e.mdot*e.t,se=e.argpo+e.argpdot*e.t,P=e.nodeo+e.nodedot*e.t;g=se,D=N;let F=e.t*e.t;if(k=P+e.nodecf*F,C=1-e.cc1*e.t,w=e.bstar*e.cc4*e.t,T=e.t2cof*F,e.isimp!==1){te=e.omgcof*e.t;let t=1+e.eta*Math.cos(N);ee=e.xmcof*(t*t*t-e.delmo),S=te+ee,D=N+S,g=se-S,y=F*e.t,b=y*e.t,C=C-e.d2*F-e.d3*y-e.d4*b,w+=e.bstar*e.cc5*(Math.sin(D)-e.sinmao),T=T+e.t3cof*y+b*(e.t4cof+e.t*e.t5cof)}O=e.no;let I=e.ecco;if(E=e.inclo,e.method===`d`){re=e.t;let t=ie({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:re,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:I,argpm:g,inclm:E,xli:e.xli,mm:D,xni:e.xni,nodem:k,nm:O});({em:I,argpm:g,inclm:E,mm:D,nodem:k,nm:O}=t)}if(O<=0)return e.error=x.MeanMotionBelowZero,null;let L=(l/O)**m*C*C;if(O=l/L**1.5,I-=w,I>=1||I<-.001)return e.error=x.MeanEccentricityOutOfRange,null;I<1e-6&&(I=1e-6),D+=e.no*T,j=D+g+k,k%=o,g%=o,j%=o,D=(j-g-k)%o;let R={am:L,em:I,im:E,Om:k,om:g,mm:D,nm:O},ce=Math.sin(E),z=Math.cos(E),B=I;if(A=E,_=g,M=k,oe=D,s=ce,i=z,e.method===`d`){let t=ne(e,{inclo:e.inclo,init:`n`,ep:B,inclp:A,nodep:M,argpp:_,mp:oe,opsmode:e.operationmode});if({ep:B,nodep:M,argpp:_,mp:oe}=t,A=t.inclp,A<0&&(A=-A,M+=a,_-=a),B<0||B>1)return e.error=x.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(s=Math.sin(A),i=Math.cos(A),e.aycof=-.5*p*s,Math.abs(i+1)>15e-13?e.xlcof=-.25*p*s*(3+5*i)/(1+i):e.xlcof=-.25*p*s*(3+5*i)/15e-13);let V=B*Math.cos(_);S=1/(L*(1-B*B));let H=B*Math.sin(_)+S*e.aycof,U=(oe+_+M+S*e.xlcof*V-M)%o;h=U,ae=9999.9;let W=1;for(;Math.abs(ae)>=1e-12&&W<=10;)r=Math.sin(h),n=Math.cos(h),ae=1-n*V-r*H,ae=(U-H*n+V*r-h)/ae,Math.abs(ae)>=.95&&(ae=ae>0?.95:-.95),h+=ae,W+=1;let G=V*n+H*r,K=V*r-H*n,q=V*V+H*H,J=L*(1-q);if(J<0)return e.error=x.SemiLatusRectumBelowZero,null;let le=L*(1-G),Y=Math.sqrt(L)*K/le,ue=Math.sqrt(J)/le,de=Math.sqrt(1-q);S=K/(1+de);let X=L/le*(r-H-V*S),fe=L/le*(n-V+H*S);v=Math.atan2(X,fe);let pe=(fe+fe)*X,me=1-2*X*X;S=1/J;let he=.5*f*S,ge=he*S;e.method===`d`&&(d=i*i,e.con41=3*d-1,e.x1mth2=1-d,e.x7thm1=7*d-1);let Z=le*(1-1.5*ge*de*e.con41)+.5*he*e.x1mth2*me;if(Z<1)return e.error=x.Decayed,null;v-=.25*ge*e.x7thm1*pe;let _e=M+1.5*ge*i*pe,ve=A+1.5*ge*i*s*me,ye=Y-O*he*e.x1mth2*pe/l,be=ue+O*he*(e.x1mth2*me+1.5*e.con41)/l,xe=Math.sin(v),Se=Math.cos(v),Ce=Math.sin(_e),we=Math.cos(_e),Te=Math.sin(ve),Ee=Math.cos(ve),Q=-Ce*Ee,De=we*Ee,Oe=Q*xe+we*Se,$=De*xe+Ce*Se,ke=Te*xe,Ae=Q*Se-we*xe,je=De*Se-Ce*xe,Me=Te*Se;return{position:{x:Z*Oe*c,y:Z*$*c,z:Z*ke*c},velocity:{x:(ye*Oe+be*Ae)*u,y:(ye*$+be*je)*u,z:(ye*ke+be*Me)*u},meanElements:R}}function S(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:o,xecco:s,xargpo:l,xinclo:u,xmo:ee,xno:te,xnodeo:h}=t,g,y,b,ie,x,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,Q=e;Q.isimp=0,Q.method=`n`,Q.aycof=0,Q.con41=0,Q.cc1=0,Q.cc4=0,Q.cc5=0,Q.d2=0,Q.d3=0,Q.d4=0,Q.delmo=0,Q.eta=0,Q.argpdot=0,Q.omgcof=0,Q.sinmao=0,Q.t=0,Q.t2cof=0,Q.t3cof=0,Q.t4cof=0,Q.t5cof=0,Q.x1mth2=0,Q.x7thm1=0,Q.mdot=0,Q.nodedot=0,Q.xlcof=0,Q.xmcof=0,Q.nodecf=0,Q.irez=0,Q.d2201=0,Q.d2211=0,Q.d3210=0,Q.d3222=0,Q.d4410=0,Q.d4422=0,Q.d5220=0,Q.d5232=0,Q.d5421=0,Q.d5433=0,Q.dedt=0,Q.del1=0,Q.del2=0,Q.del3=0,Q.didt=0,Q.dmdt=0,Q.dnodt=0,Q.domdt=0,Q.e3=0,Q.ee2=0,Q.peo=0,Q.pgho=0,Q.pho=0,Q.pinco=0,Q.plo=0,Q.se2=0,Q.se3=0,Q.sgh2=0,Q.sgh3=0,Q.sgh4=0,Q.sh2=0,Q.sh3=0,Q.si2=0,Q.si3=0,Q.sl2=0,Q.sl3=0,Q.sl4=0,Q.gsto=0,Q.xfact=0,Q.xgh2=0,Q.xgh3=0,Q.xgh4=0,Q.xh2=0,Q.xh3=0,Q.xi2=0,Q.xi3=0,Q.xl2=0,Q.xl3=0,Q.xl4=0,Q.xlamo=0,Q.zmol=0,Q.zmos=0,Q.atime=0,Q.xli=0,Q.xni=0,Q.bstar=o,Q.ecco=s,Q.argpo=l,Q.inclo=u,Q.mo=ee,Q.no=te,Q.nodeo=h,Q.operationmode=n,78/c+1;let De=42/c;De*De*De*De,Q.init=`y`,Q.t=0;let Oe=re({satn:r,ecco:Q.ecco,epoch:i,inclo:Q.inclo,no:Q.no,method:Q.method,opsmode:Q.operationmode}),{ao:$,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=Oe;if(Q.no=Oe.no,Q.con41=Oe.con41,Q.gsto=Oe.gsto,Q.a=(Q.no*d)**(-2/3),Q.alta=Q.a*(1+Q.ecco)-1,Q.altp=Q.a*(1-Q.ecco)-1,Q.error=0,Ne>=0||Q.no>=0){if(Q.isimp=0,Fe<1.034492841559484&&(Q.isimp=1),B=1.0122292801892716,F=1.880279159015271e-9,N=(Fe-1)*c,N<156){B=N-78,N<98&&(B=20);let e=(120-B)/c;F=e*e*e*e,B=B/c+1}se=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,P=Math.abs(1-O),S=F*Z**4,C=S/P**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/P*Q.con41*(8+3*O*(8+O))),Q.cc1=Q.bstar*ie,x=0,Q.ecco>1e-4&&(x=-2*S*Z*p*Q.no*Le/Q.ecco),Q.x1mth2=1-je,Q.cc4=2*Q.no*C*$*Ne*(Q.eta*(2+.5*O)+Q.ecco*(.5+2*O)-f*Z/($*P)*(-3*Q.con41*(1-2*D+O*(1.5-.5*D))+.75*Q.x1mth2*(2*O-D*(1+O))*Math.cos(2*Q.argpo))),Q.cc5=2*C*$*Ne*(1+2.75*(O+D)+D*O),w=je*je,me=1.5*f*se*Q.no,he=.5*me*f*se,ge=-.46875*-165597e-11*se*se*Q.no,Q.mdot=Q.no+.5*me*Ie*Q.con41+.0625*he*Ie*(13-78*je+137*w),Q.argpdot=-.5*me*ke+.0625*he*(7-114*je+395*w)+ge*(3-36*je+49*w),ve=-me*Ae,Q.nodedot=ve+(.5*he*(4-19*je)+2*ge*(3-7*je))*Ae,_e=Q.argpdot+Q.nodedot,Q.omgcof=Q.bstar*x*Math.cos(Q.argpo),Q.xmcof=0,Q.ecco>1e-4&&(Q.xmcof=-m*S*Q.bstar/D),Q.nodecf=3.5*Ne*ve*Q.cc1,Q.t2cof=1.5*Q.cc1,Math.abs(Ae+1)>15e-13?Q.xlcof=-.25*p*Le*(3+5*Ae)/(1+Ae):Q.xlcof=-.25*p*Le*(3+5*Ae)/15e-13,Q.aycof=-.5*p*Le;let e=1+Q.eta*Math.cos(Q.mo);if(Q.delmo=e*e*e,Q.sinmao=Math.sin(Q.mo),Q.x7thm1=7*je-1,2*a/Q.no>=225){Q.method=`d`,Q.isimp=1,fe=0,j=Q.inclo;let e=_({epoch:i,ep:Q.ecco,argpp:Q.argpo,tc:fe,inclp:Q.inclo,nodep:Q.nodeo,np:Q.no,e3:Q.e3,ee2:Q.ee2,peo:Q.peo,pgho:Q.pgho,pho:Q.pho,pinco:Q.pinco,plo:Q.plo,se2:Q.se2,se3:Q.se3,sgh2:Q.sgh2,sgh3:Q.sgh3,sgh4:Q.sgh4,sh2:Q.sh2,sh3:Q.sh3,si2:Q.si2,si3:Q.si3,sl2:Q.sl2,sl3:Q.sl3,sl4:Q.sl4,xgh2:Q.xgh2,xgh3:Q.xgh3,xgh4:Q.xgh4,xh2:Q.xh2,xh3:Q.xh3,xi2:Q.xi2,xi3:Q.xi3,xl2:Q.xl2,xl3:Q.xl3,xl4:Q.xl4,zmol:Q.zmol,zmos:Q.zmos});Q.e3=e.e3,Q.ee2=e.ee2,Q.peo=e.peo,Q.pgho=e.pgho,Q.pho=e.pho,Q.pinco=e.pinco,Q.plo=e.plo,Q.se2=e.se2,Q.se3=e.se3,Q.sgh2=e.sgh2,Q.sgh3=e.sgh3,Q.sgh4=e.sgh4,Q.sh2=e.sh2,Q.sh3=e.sh3,Q.si2=e.si2,Q.si3=e.si3,Q.sl2=e.sl2,Q.sl3=e.sl3,Q.sl4=e.sl4,{sinim:y,cosim:g,em:T,emsq:E,s1:I,s2:L,s3:R,s4:ce,s5:z,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X}=e,Q.xgh2=e.xgh2,Q.xgh3=e.xgh3,Q.xgh4=e.xgh4,Q.xh2=e.xh2,Q.xh3=e.xh3,Q.xi2=e.xi2,Q.xi3=e.xi3,Q.xl2=e.xl2,Q.xl3=e.xl3,Q.xl4=e.xl4,Q.zmol=e.zmol,Q.zmos=e.zmos,{nm:M,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee}=e;let t=ne(Q,{inclo:j,init:Q.init,ep:Q.ecco,inclp:Q.inclo,nodep:Q.nodeo,argpp:Q.argpo,mp:Q.mo,opsmode:Q.operationmode});Q.ecco=t.ep,Q.inclo=t.inclp,Q.nodeo=t.nodep,Q.argpo=t.argpp,Q.mo=t.mp,k=0,A=0,oe=0;let n=v({cosim:g,emsq:E,argpo:Q.argpo,s1:I,s2:L,s3:R,s4:ce,s5:z,sinim:y,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X,t:Q.t,tc:fe,gsto:Q.gsto,mo:Q.mo,mdot:Q.mdot,no:Q.no,nodeo:Q.nodeo,nodedot:Q.nodedot,xpidot:_e,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee,ecco:Q.ecco,eccsq:Me,em:T,argpm:k,inclm:j,mm:oe,nm:M,nodem:A,irez:Q.irez,atime:Q.atime,d2201:Q.d2201,d2211:Q.d2211,d3210:Q.d3210,d3222:Q.d3222,d4410:Q.d4410,d4422:Q.d4422,d5220:Q.d5220,d5232:Q.d5232,d5421:Q.d5421,d5433:Q.d5433,dedt:Q.dedt,didt:Q.didt,dmdt:Q.dmdt,dnodt:Q.dnodt,domdt:Q.domdt,del1:Q.del1,del2:Q.del2,del3:Q.del3,xfact:Q.xfact,xlamo:Q.xlamo,xli:Q.xli,xni:Q.xni});Q.irez=n.irez,Q.atime=n.atime,Q.d2201=n.d2201,Q.d2211=n.d2211,Q.d3210=n.d3210,Q.d3222=n.d3222,Q.d4410=n.d4410,Q.d4422=n.d4422,Q.d5220=n.d5220,Q.d5232=n.d5232,Q.d5421=n.d5421,Q.d5433=n.d5433,Q.dedt=n.dedt,Q.didt=n.didt,Q.dmdt=n.dmdt,Q.dnodt=n.dnodt,Q.domdt=n.domdt,Q.del1=n.del1,Q.del2=n.del2,Q.del3=n.del3,Q.xfact=n.xfact,Q.xlamo=n.xlamo,Q.xli=n.xli,Q.xni=n.xni}Q.isimp!==1&&(b=Q.cc1*Q.cc1,Q.d2=4*$*Z*b,pe=Q.d2*Z*Q.cc1/3,Q.d3=(17*$+B)*pe,Q.d4=.5*pe*$*Z*(221*$+31*B)*Q.cc1,Q.t3cof=Q.d2+2*b,Q.t4cof=.25*(3*Q.d3+Q.cc1*(12*Q.d2+10*b)),Q.t5cof=.2*(3*Q.d4+12*Q.cc1*Q.d3+6*Q.d2*Q.d2+15*b*(2*Q.d2+b)))}ae(Q,0),Q.init=`n`}function C(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,c=Number(e.MEAN_MOTION_DOT),l=Number(e.MEAN_MOTION_DDOT);c/=ee*1440,l/=ee*1440*1440;let u=Number(e.BSTAR),d=Number(e.INCLINATION)*s,f=Number(e.RA_OF_ASC_NODE)*s,p=Number(e.ECCENTRICITY),m=Number(e.ARG_OF_PERICENTER)*s,h=Number(e.MEAN_ANOMALY)*s,ne=Number(e.MEAN_MOTION)/ee,{mon:_,day:v,hr:y,minute:b,sec:re}=te(i,o),ie=g(i,_,v,y,b,re),x={error:0,satnum:n,epochyr:a,epochdays:o,ndot:c,nddot:l,bstar:u,inclo:d,nodeo:f,ecco:p,argpo:m,mo:h,no:ne,jdsatepoch:ie};return S(x,{opsmode:t,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}3*Float64Array.BYTES_PER_ELEMENT;const w=Math.PI/180;Math.cos(i*w),Math.sin(i*w);function T(e){return new Date((e-2440587.5)*864e5).toISOString()}function E(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:T(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===x.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}const D=Math.PI/180,O=Math.cos(i*D),k=Math.sin(i*D),A=10/r;function j(e,t,n,r,i){return!isFinite(Math.fround(n))||!isFinite(Math.fround(r))||!isFinite(Math.fround(i))?!1:(e[t*3]=n,e[t*3+1]=r,e[t*3+2]=i,!0)}function oe(r,i,a,o,s,c,l,u,d,f=null,p=0){if(i<r.validityStart||i>r.validityEnd)return 0;let{count:m,kind:ee,equatorial:te,a:h,e:g,i:ne,om:_,w:v,ma:y,n:b,epoch:re,q:ie,tp:S,satrec:C,flags:w,visibleFromDays:T}=r,oe=p!==0&&r.applyFlagFilter,M=r.pickBase,N=d.length/3|0,se=i-2451545,P=0;for(let F=0;F<m&&!(P>=N);F++){let m=ee[F];if(m===0||T[F]>se||oe&&(w[F]&p)!==p)continue;if(m===3){let e=C[F];if(!e){if(e=E({noradCatId:r.satnum[F],epochJd:re[F],meanMotion:b[F]/360,eccentricity:g[F],inclination:ne[F],raOfAscNode:_[F],argOfPericenter:v[F],meanAnomaly:y[F],bstar:r.bstar[F],meanMotionDot:r.ndot[F],meanMotionDdot:r.nddot[F],elementSetNo:0,revAtEpoch:0}),!e){ee[F]=0;continue}C[F]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x,m=n.position.y,te=n.position.z,h=p*A,ie=m*A,S=te*A,w=ie*O+S*k,T=-ie*k+S*O,D=h,oe=T,N=-w;if(!j(d,P,a+D-c,o+oe-l,s+N-u))continue;if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++;continue}let N,I,L=g[F],R=ne[F],ce=_[F],z=v[F];if(m===2){let e=n(ie[F],S[F],i);if(!e)continue;N=e.r*Math.cos(e.nu),I=e.r*Math.sin(e.nu)}else{let n=h[F];if(!isFinite(n)||!isFinite(L)||!isFinite(y[F])||!isFinite(b[F]))continue;let r=i-re[F],a=(y[F]+b[F]*r)*D,o,s;if(L<1||n>0){let t=Math.min(L,.9999999),r=e(a,t),i=Math.sqrt(1-t*t)*Math.sin(r)/(1-t*Math.cos(r)),c=(Math.cos(r)-t)/(1-t*Math.cos(r));o=Math.atan2(i,c),s=n*(1-t*Math.cos(r))}else{let e=t(a,L);if(!isFinite(e))continue;let r=L*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(L*L-1)*Math.sinh(e)/r,c=(L-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-L*Math.cosh(e))}N=s*Math.cos(o),I=s*Math.sin(o)}if(!isFinite(N)||!isFinite(I))continue;let B=Math.cos(z*D),V=Math.sin(z*D),H=Math.cos(R*D),U=Math.sin(R*D),W=Math.cos(ce*D),G=Math.sin(ce*D),K=(W*B-G*V*H)*N+(-W*V-G*B*H)*I,q=(G*B+W*V*H)*N+(-G*V+W*B*H)*I,J=V*U*N+B*U*I;if(te[F]){let e=q*O+J*k,t=-q*k+J*O;q=e,J=t}let le=K*10,Y=J*10,ue=-q*10;if(j(d,P,a+le-c,o+Y-l,s+ue-u)){if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++}}return P}const M=new Map;self.onmessage=e=>{let t=e.data;if(t.type===`ping`){self.postMessage({type:`pong`});return}if(t.type===`rewireDelta`){if(t.remove)for(let e of t.remove)M.delete(e);for(let e of t.set)M.set(e.id,e.cols);return}if(t.type===`tick`){let e=[],n=[],[r,i,a]=t.basis;for(let o of t.groups){let s=M.get(o.id);if(!s){e.push({id:o.id,count:0,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer);continue}let c=oe(s,t.jd,o.parent[0],o.parent[1],o.parent[2],r,i,a,o.out,o.outIds,t.requiredFlags??0);e.push({id:o.id,count:c,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer)}self.postMessage({type:`tickResult`,groups:e},n);return}};\n//# sourceMappingURL=worker-CK5Z1yOu.js.map",sP=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,oP],{type:`text/javascript;charset=utf-8`});function cP(e){let t;try{if(t=sP&&(self.URL||self.webkitURL).createObjectURL(sP),!t)throw``;let n=new Worker(t,{type:`module`,name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(oP),{type:`module`,name:e?.name})}}var lP=class{workers=[];groups=new Map;onResult=null;size;pendingPing=null;generation=0;constructor(e=navigator.hardwareConcurrency??4){this.size=Math.max(2,Math.min(8,e)),this.spawn()}spawn(){for(let e=0;e<this.size;e++){let e=new cP;e.onmessage=e=>this.onMessage(e.data),this.workers.push(e)}}ping(e=800){if(this.workers.length===0)return Promise.resolve(!1);if(this.pendingPing)return this.pendingPing.promise;let t,n=new Promise(e=>t=e),r={need:this.workers.length,got:0,promise:n,resolve:e=>{this.pendingPing===r&&(this.pendingPing=null,t(e))}};this.pendingPing=r,setTimeout(()=>r.resolve(!1),e);for(let e of this.workers)e.postMessage({type:`ping`});return n}respawn(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers=[],this.groups.clear(),this.generation++,this.spawn()}get poolGeneration(){return this.generation}setResultHandler(e){this.onResult=e}get workerCount(){return this.workers.length}get groupCount(){return this.groups.size}async rewireOne(e,t,n,r,i=!1,a=0){if(t.length===0){this.unwireOne(e);return}let o=await Bg(t,n,i);o.pickBase=a,this.workers.length!==0&&this.wireCols(e,o,r,t.length)}rewireOneCols(e,t,n){if(this.workers.length!==0){if(t.count===0){this.unwireOne(e);return}this.wireCols(e,t,n,t.count)}}wireCols(e,t,n,r){let i=this.groups.get(e),a=i?.workerIdx??n%this.workers.length,o,s,c,l;if(i&&i.capacity===r)o=i.front,s=i.back,c=i.idFront,l=i.idBack;else if(o=new Float32Array(r*3),s=new Float32Array(r*3),c=new Uint8Array(r*4),l=new Uint8Array(r*4),i){let e=Math.min(i.front.length,o.length);o.set(i.front.subarray(0,e));let t=Math.min(i.idFront.length,c.length);c.set(i.idFront.subarray(0,t))}let u=!!i&&i.back===null;this.groups.set(e,{workerIdx:a,capacity:r,front:o,back:s,idFront:c,idBack:l,count:i?.count??r,pendingBasis:u?i.pendingBasis:null,pendingParent:u?i.pendingParent:null,pendingJd:u?i.pendingJd:null,frontBasis:i?.frontBasis??[0,0,0],frontParent:i?.frontParent??[0,0,0],frontJd:i?.frontJd??NaN}),this.workers[a].postMessage({type:`rewireDelta`,set:[{id:e,cols:t}]},Hg(t))}unwireOne(e){let t=this.groups.get(e);t&&(this.groups.delete(e),this.workers[t.workerIdx].postMessage({type:`rewireDelta`,set:[],remove:[e]}))}tick(e,t,n,r=0){let i=this.workers.map(()=>[]);for(let[r,a]of this.groups){if(!a.back||!a.idBack)continue;let o=n.get(r);o&&(i[a.workerIdx].push({id:r,parent:[o[0],o[1],o[2]],out:a.back,outIds:a.idBack}),a.back=null,a.idBack=null,a.pendingBasis=[t[0],t[1],t[2]],a.pendingParent=[o[0],o[1],o[2]],a.pendingJd=e)}for(let n=0;n<this.workers.length;n++){let a=i[n];if(a.length===0)continue;let o=a.flatMap(e=>[e.out.buffer,e.outIds.buffer]);this.workers[n].postMessage({type:`tick`,jd:e,basis:[t[0],t[1],t[2]],requiredFlags:r,groups:a},o)}}onMessage(e){if(e.type===`pong`){let e=this.pendingPing;e&&++e.got>=e.need&&e.resolve(!0);return}if(e.type===`tickResult`)for(let t of e.groups){let e=this.groups.get(t.id);if(!e)continue;let n=new Float32Array(t.buf),r=e.front;e.front=n,e.back=r;let i=new Uint8Array(t.idbuf),a=e.idFront;e.idFront=i,e.idBack=a,e.count=t.count;let o=e.pendingBasis??e.frontBasis,s=e.pendingParent??e.frontParent,c=e.pendingJd??e.frontJd;e.frontBasis=o,e.frontParent=s,e.frontJd=c,e.pendingBasis=null,e.pendingParent=null,e.pendingJd=null,this.onResult?.(t.id,n,t.count,o,s,c,i)}}destroy(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers.length=0,this.groups.clear()}},uP=class{#e=1;#t=new Map;allocate(e,t){let n=this.#e;return this.#e+=t.length,this.#t.set(e,{base:n,keys:t}),n}release(e){this.#t.delete(e)}resolve(e){if(e===0)return null;for(let{base:t,keys:n}of this.#t.values())if(e>=t&&e<t+n.length)return _h(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},dP=.01,fP=[`asteroid`,`spacecraft`],pP=.0002959122082855911,mP=.75,hP=Q(8*86400);function gP(e){let t=0,n=!1;for(let r=0;r<e.count;r++){if(e.kind[r]===0)continue;let i=e.a[r],a=e.e[r];if(e.kind[r]!==1||!(i>0)||!(a<1)||!isFinite(i)||!isFinite(a)){n=!0;continue}let o=Math.min(a,.9999999),s=Math.sqrt(pP/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function _P(e){return e<0?0:e>1?1:e}function vP(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function yP(e){return e===null?{tBright:0,tSize:0}:{tBright:_P((bP-e)/(bP-xP)),tSize:_P((SP-e)/(SP-CP))}}var bP=1e4,xP=500,SP=xP,CP=50,wP=4,TP=.5,EP=10,DP=1,OP=1,kP=3.5,AP=2.5,jP=2,MP=kP,NP=class{orbitPool=new lP;pickRegistry=new uP;disposed=!1;workerPoints={asteroid:new Map,spacecraft:new Map};moonPoints=new Map;pointBudget=1/0;drawFraction=1;pendingSceneAdds=[];basisPos=[0,0,0];parentAtUpdate=new Map;_parentsScratch=new Map;moonsByParentCache=null;lastPackedSize=new Map;groupKinematics=new Map;lastSolvedJd=new Map;earthSatEmphasis={size:wP,dim:TP,opacity:OP};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:OP};constructor(e,t,n,r,i,a,o){this.ctx=e,this.scene=t,this.bodyObjects=n,this.circleTexture=r,this.focus=i,this.mapLayer=a,this.onBasisRebuilt=o,this.orbitPool.setResultHandler(this.onPoolResult)}basis(){return this.basisPos}setPointBudget(e){this.pointBudget=e,this.applyPointBudget()}applyPointBudget(){let e=0;for(let t of fP)for(let n of this.workerPoints[t].values())n.visible&&(e+=n.userData.solvedCount??0);let t=e>this.pointBudget?this.pointBudget/e:1;if(t!==this.drawFraction){this.drawFraction=t;for(let e of fP)for(let n of this.workerPoints[e].values()){let e=n.userData.solvedCount;e!==void 0&&n.geometry.setDrawRange(0,Math.ceil(e*t))}}}setEarthSatEmphasis(e){this.earthSatEmphasis=this.computeEarthSatEmphasis(e);for(let[e,t]of this.workerPoints.spacecraft)S_(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=yP(e);return{size:wP+(EP-wP)*n,dim:TP+(DP-TP)*t,opacity:OP+(kP-OP)*t}}applyEarthSatEmphasis(e){let t=e.material,{size:n,dim:r,opacity:i}=this.earthSatEmphasis;t.size=n,t.color.setRGB(r,r,r),t.opacity=i}setEmphasizedSmallBodyZone(e,t){let n=this.emphasizedSmallBodyZone;if(this.emphasizedSmallBodyZone=e,this.smallBodyEmphasis=this.computeSmallBodyEmphasis(e===null?null:t),n!==null&&n!==e)for(let[e,t]of this.workerPoints.asteroid)vP(S_(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)vP(S_(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=yP(e);return{sizeMult:1+(AP-1)*n,brightMult:1+(jP-1)*t,opacity:OP+(MP-OP)*t}}applySmallBodyEmphasis(e){let t=e.material;e.userData.smallBodyBaseSize===void 0&&(e.userData.smallBodyBaseSize=t.size,e.userData.smallBodyBaseColor=t.color.clone());let n=e.userData.smallBodyBaseSize,r=e.userData.smallBodyBaseColor,{sizeMult:i,brightMult:a,opacity:o}=this.smallBodyEmphasis;t.size=n*i,t.color.copy(r).multiplyScalar(a),t.opacity=o}resetSmallBodyEmphasis(e){if(e.userData.smallBodyBaseSize===void 0)return;let t=e.material;t.size=e.userData.smallBodyBaseSize,t.color.copy(e.userData.smallBodyBaseColor),t.opacity=OP,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=SN(this.ctx,this.scene,this.circleTexture,this.basisPos,e,this.orbitPool.workerCount);this.workerPoints.asteroid=t.asteroidPoints,this.workerPoints.spacecraft=t.spacecraftPoints,this.moonPoints=t.moonPoints;for(let e of fP)for(let[t,n]of this.workerPoints[e]){let r=S_(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of fP)for(let t of this.workerPoints[e].values())t.layers.set(this.mapLayer);for(let e of this.moonPoints.values())e.layers.set(this.mapLayer)}cloudParentId(e,t){return e===`asteroid`?f_:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&vP(t,r)&&this.applySmallBodyEmphasis(n)}rebuildRunning=!1;rebuildQueued=!1;rebuildMinor(){if(this.rebuildRunning){this.rebuildQueued=!0;return}this.rebuildRunning=!0,(async()=>{try{do this.rebuildQueued=!1,await this.rebuildMinorPass();while(this.rebuildQueued)}finally{this.rebuildRunning=!1}})()}recovering=null;recoverWorkersIfDead(e){return this.recovering??=this.runRecovery(e).finally(()=>this.recovering=null),this.recovering}async runRecovery(e){if(await this.orbitPool.ping(e))return!1;this.orbitPool.respawn();for(let e of this.ctx.bodies.asteroidBodiesByZone.keys())this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);return this.lastPackedSize.clear(),this.rebuildMinor(),!0}async rebuildMinorPass(){if(this.disposed||this.ctx.bodies.dirtyAsteroidZones.size===0&&this.ctx.bodies.dirtySpacecraftGroups.size===0)return;let e=[this.basisPos[0],this.basisPos[1],this.basisPos[2]],t=this.orbitPool.workerCount,n=this.orbitPool.poolGeneration,r=[],i=[];for(let n of[...this.ctx.bodies.dirtyAsteroidZones]){let i=this.ctx.bodies.asteroidBodiesByZone.get(n);if(this.deferPackWhileStreaming(`asteroid:${n}`,i?.size??0))continue;this.ctx.bodies.dirtyAsteroidZones.delete(n),r.push(n);let a=yh(this.bodyObjects.keys()),{groups:o,baseWorker:s}=i?await i.buildWorkerGroups(n,t,a,!1):{groups:[],baseWorker:0};if(this.disposed)return;let c=i&&o.length>0?i.cloudColor():`#888888`;for(let r=0;r<t;r++){let i=`${n}#${r}`,a=`asteroid:${i}`,l=r<o.length?o[r]:null;if(!l||l.cols.count===0){this.unwireGroup(`asteroid`,i,a);continue}this.armGroupGate(a,gP(l.cols)),l.cols.pickBase=this.pickRegistry.allocate(a,l.keys),this.orbitPool.rewireOneCols(a,l.cols,(s+r)%t);let u=this.workerPoints.asteroid.get(i);if(u){this.resizeGeometryToCount(u.geometry,l.cols.count,null);continue}let d=eN(new Float32Array(l.cols.count*3),0,this.circleTexture,c,QM());this.adoptCloud(`asteroid`,i,a,d,e)}}for(let n of[...this.ctx.bodies.dirtySpacecraftGroups]){let r=this.ctx.bodies.spacecraftByParent.get(n);if(this.deferPackWhileStreaming(`spacecraft:${n}`,r?.size??0))continue;this.ctx.bodies.dirtySpacecraftGroups.delete(n),i.push(n);let{buckets:a,baseWorker:o}=await x_(n,wv(this.ctx.layers,n,r?Array.from(r.values()):[]),t);if(this.disposed)return;let s=new Set(this.bodyObjects.keys());for(let r=0;r<t;r++){let i=`${n}#${r}`,c=`spacecraft:${i}`,l=r<a.length?a[r]:[];if(l.length===0){this.unwireGroup(`spacecraft`,i,c);continue}let u=this.pickRegistry.allocate(c,Float64Array.from(l,e=>vh(e.data.id)??fh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:hP,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3),p=new Float32Array(l.length*3);this.seedGeometryArray(f,l,p);let m=eN(f,l.length,this.circleTexture,`#ffffff`,void 0,p);this.adoptCloud(`spacecraft`,i,c,m,e)}}if(this.orbitPool.poolGeneration!==n){for(let e of r)this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of i)this.ctx.bodies.dirtySpacecraftGroups.add(e);this.lastPackedSize.clear(),this.rebuildQueued=!0}}unwireGroup(e,t,n){this.orbitPool.unwireOne(n),this.forgetGroupGate(n),this.pickRegistry.release(n);let r=this.workerPoints[e].get(t);r&&(this.scene.remove(r),this.workerPoints[e].delete(t))}armGroupGate(e,t){this.groupKinematics.set(e,t),this.lastSolvedJd.delete(e)}adoptCloud(e,t,n,r,i){let a=S_(t);r.userData.frontBasis=i,r.userData.groupId=n,r.userData.parentBodyId=this.cloudParentId(e,a),r.userData.parentVec=[0,0,0],this.emphasiseNewCloud(e,a,r),this.workerPoints[e].set(t,r),this.pendingSceneAdds.push(r)}deferPackWhileStreaming(e,t){if(!this.ctx.bodies.minorStreaming)return this.lastPackedSize.set(e,t),!1;let n=this.lastPackedSize.get(e);return n!==void 0&&t>n&&t<n*2?!0:(this.lastPackedSize.set(e,t),!1)}seedGeometryArray(e,t,n=null){let[r,i,a]=this.basisPos,o=Math.min(t.length,e.length/3),s=n?new X:null;for(let c=0;c<o;c++){let o=t[c],l=o.position;e[c*3]=l[0]-r,e[c*3+1]=l[1]-i,e[c*3+2]=l[2]-a,n&&s&&(s.set(h_(o.data)),n[c*3]=s.r,n[c*3+1]=s.g,n[c*3+2]=s.b)}}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length===n){e.setDrawRange(0,t.length);return}let r=!!e.getAttribute(`color`),i=new Float32Array(n),a=r?new Float32Array(n):null;this.seedGeometryArray(i,t,a),e.setAttribute(`position`,new Do(i,3)),a&&e.setAttribute(`color`,new Do(a,3)),e.setDrawRange(0,t.length)}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Do(n,3)),i.length===r)return;let a=new Float32Array(r);a.set(i.subarray(0,Math.min(i.length,r))),e.setAttribute(`position`,new Do(a,3));let o=Math.min(e.drawRange.count,t);e.setDrawRange(0,Number.isFinite(o)?o:0)}onPoolResult=(e,t,n,r,i,a,o)=>{let[s,c]=e.split(`:`),l=this.workerPoints[s].get(c);if(!l)return;let u=l.geometry.getAttribute(`position`),d=u.array;if(d.length!==t.length)return;d.set(t),u.needsUpdate=!0,this.bindPickIds(l,o),l.userData.solvedCount=n,l.geometry.setDrawRange(0,Math.ceil(n*this.drawFraction)),this.lastSolvedJd.set(e,a),l.userData.frontBasis=[r[0],r[1],r[2]],this.parentAtUpdate.set(e,[i[0],i[1],i[2]]);let[f,p,m]=this.focus.focusTruePos,h=this.ctx.getBody(l.userData.parentBodyId)?.position,g=h?h[0]-i[0]:0,_=h?h[1]-i[1]:0,v=h?h[2]-i[2]:0;l.position.set(r[0]-f+g,r[1]-p+_,r[2]-m+v)};bindPickIds(e,t){let n=e.geometry.getAttribute(`pickColor`);n&&n.array.length===t.length?(n.array.set(t),n.needsUpdate=!0):e.geometry.setAttribute(`pickColor`,new Do(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of fP)for(let a of this.workerPoints[i].values()){let i=a.userData.frontBasis??r,[o,s,c]=this.parentShift(a.userData.groupId,a.userData.parentBodyId);a.position.set(i[0]-e+o,i[1]-t+s,i[2]-n+c)}let[i,a,o]=r,s=i-e,c=a-t,l=o-n;for(let e of this.moonPoints.values())e.position.set(s,c,l)}parentShift(e,t){let n=this.parentAtUpdate.get(e),r=this.ctx.getBody(t)?.position;return!n||!r?[0,0,0]:[r[0]-n[0],r[1]-n[1],r[2]-n[2]]}maybeRebase(){let[e,t,n]=this.focus.focusTruePos,[r,i,a]=this.basisPos,o=e-r,s=t-i,c=n-a,l=o*o+s*s+c*c,u=dP*10;l>u*u&&this.rebuildBasis()}rebuildBasis(){this.basisPos=[...this.focus.focusTruePos],this.rebuildMoons(),this.onBasisRebuilt(),this.reposition()}updateForJd(e,t){this.writeMoons();let n=this._parentsScratch;n.clear();let r=this.ctx.getBody(`naif-10`)?.position??[0,0,0];for(let[i,a]of this.workerPoints.asteroid){if(!this.ctx.visibility.isAsteroidGroupVisible(S_(i)))continue;let o=a.userData.groupId;if(!this.shouldSolveGroup(o,r,e,t))continue;let s=a.userData.parentVec;s[0]=r[0],s[1]=r[1],s[2]=r[2],n.set(o,s)}for(let[r,i]of this.workerPoints.spacecraft){if(!this.ctx.visibility.isSpacecraftGroupVisible(S_(r)))continue;let a=i.userData.groupId,o=this.ctx.getBody(i.userData.parentBodyId)?.position;if(o&&!this.shouldSolveGroup(a,o,e,t))continue;let s=i.userData.parentVec;o?(s[0]=o[0],s[1]=o[1],s[2]=o[2]):(s[0]=0,s[1]=0,s[2]=0),n.set(a,s)}this.orbitPool.tick(e,this.basisPos,n,this.ctx.visibility.getRequiredFlags())}shouldSolveGroup(e,t,n,r){let i=this.groupKinematics.get(e);if(!i||i.alwaysSolve)return!0;let a=this.lastSolvedJd.get(e);if(a===void 0||!isFinite(a))return!0;let[o,s,c]=this.focus.focusTruePos,l=r.camPos[0]-(t[0]-o),u=r.camPos[1]-(t[1]-s),d=r.camPos[2]-(t[2]-c),f=Math.max(1e-6,Math.sqrt(l*l+u*u+d*d)),p=Math.abs(n-a);return i.maxSpeedScene*p/f*r.pxPerRad>=mP}forgetGroupGate(e){this.groupKinematics.delete(e),this.lastSolvedJd.delete(e)}moonsByParent(){let e=this.ctx.bodies.majorBodies.length;if(this.moonsByParentCache?.len===e)return this.moonsByParentCache.map;let t=new Map;for(let e of this.ctx.bodies.majorBodies)if(e.data.objectType===W.MOON){let n=t.get(e.data.parentId)??[];n.push(e),t.set(e.data.parentId,n)}return this.moonsByParentCache={len:e,map:t},t}writeMoons(){let[e,t,n]=this.basisPos;for(let[r,i]of this.moonsByParent()){let a=this.moonPoints.get(r);if(!a||!this.ctx.visibility.isMoonGroupVisible(r))continue;let o=a.geometry.getAttribute(`position`),s=o.array,c=Math.min(i.length,s.length/3);for(let r=0;r<c;r++){let a=i[r];if(this.bodyObjects.get(a.data.id)?.outOfRange){s[r*3]=s[r*3+1]=s[r*3+2]=NaN;continue}s[r*3]=a.position[0]-e,s[r*3+1]=a.position[1]-t,s[r*3+2]=a.position[2]-n}o.needsUpdate=!0}}rebuildMoons(){let e=this.basisPos;for(let[t,n]of this.moonsByParent()){let r=this.moonPoints.get(t);if(!r)continue;let i=new Float32Array(n.length*3);for(let t=0;t<n.length;t++)i[t*3]=n[t].position[0]-e[0],i[t*3+1]=n[t].position[1]-e[1],i[t*3+2]=n[t].position[2]-e[2];r.geometry.setAttribute(`position`,new Ao(i,3))}}hasPendingSceneAdds(){return this.pendingSceneAdds.length>0}drainOnePendingSceneAdd(){if(this.pendingSceneAdds.length===0)return;let e=this.pendingSceneAdds.shift();e.layers.set(this.mapLayer),this.scene.add(e)}asteroids(){return this.workerPoints.asteroid}spacecraft(){return this.workerPoints.spacecraft}moons(){return this.moonPoints}dispose(){this.disposed=!0,this.orbitPool.destroy(),this.pickRegistry.clear();for(let e of fP)this.disposeClouds(this.workerPoints[e]);this.disposeClouds(this.moonPoints);for(let e of this.pendingSceneAdds)e.geometry.dispose(),e.material.dispose();this.pendingSceneAdds.length=0}disposeClouds(e){for(let t of e.values())this.scene.remove(t),t.geometry.dispose(),t.material.dispose();e.clear()}},PP=Math.PI/180,FP=2451545,IP=1.00000261,LP=.01671123,RP=100.46457166*PP,zP=35999.37244981/36525*PP,BP=102.93768193*PP,VP=.32327364/36525*PP;function HP(e){let t=e-FP,n=BP+VP*t,r=RP+zP*t-n,i=r+(2*LP-LP**3/4)*Math.sin(r)+1.25*LP*LP*Math.sin(2*r);return{lon:n+i,r:IP*(1-LP*LP)/(1+LP*Math.cos(i))}}function UP(e){let t=HP(e).lon;return(e,n)=>{let r=t-HP(e).lon,i=Math.cos(r),a=Math.sin(r),o=n[0],s=n[2];n[0]=o*i+s*a,n[2]=-o*a+s*i}}var WP=.01,GP=1/100,KP=1;function qP(e,t,n){if(!n)return 0;let r=1/0;for(let i=0;i<t;i++){let t=e[i*3]-n.camX,a=e[i*3+1]-n.camY,o=e[i*3+2]-n.camZ,s=t*t+a*a+o*o;s<r&&(r=s)}return Math.sqrt(r)*n.tolAngle}function JP(e,t,n,r,i,a,o,s,c){if(t!==e.lastVersion||e.lastOffX===void 0)return!1;let l=e.rewriteTol;if(c){let t=c.camX-e.lastCamX,n=c.camY-e.lastCamY,r=c.camZ-e.lastCamZ;l=Math.max(0,l-Math.sqrt(t*t+n*n+r*r)*c.tolAngle)}let u=(n-e.lastOffX)**2+(r-e.lastOffY)**2+(i-e.lastOffZ)**2,d=(a-e.lastHeadX)**2+(o-e.lastHeadY)**2+(s-e.lastHeadZ)**2;return u<=l*l&&d<=l*l}function YP(e,t,n,r,i,a,o,s,c,l,u){e.lastVersion=t,e.lastOffX=n,e.lastOffY=r,e.lastOffZ=i,e.lastHeadX=a,e.lastHeadY=o,e.lastHeadZ=s,e.lastCamX=u?.camX??0,e.lastCamY=u?.camY??0,e.lastCamZ=u?.camZ??0,e.rewriteTol=qP(c,l,u)}function XP(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position,u=c.x-r[0],d=c.y-r[1],f=c.z-r[2],p=l[0]-c.x,m=l[1]-c.y,h=l[2]-c.z,g=e.lagrangeTrail?NaN:n.newestJd+n.count*1e-9;if(JP(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=mN(t),b=e.lagrangeTrail?UP(i):null,x=gN(e,n,_,c.x,c.y,c.z,r,b??void 0);hN(t,_,v,y,x,!0,s),YP(o,g,u,d,f,p,m,h,_,x,a)}function ZP(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=mN(e),l=Math.min(t.length,c);for(let e=0;e<l;e++)a[e*3]=t[e][0]+n,a[e*3+1]=t[e][1]+r,a[e*3+2]=t[e][2]+i;if(e.userData.lastOffX=void 0,e.userData.isFatLine){lN(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function QP(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){XP(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=oN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.curvePending=!1}let s=t.userData.isOpenCurve,c=t.userData.useTrail,l=t.userData.orbitCenter,u=l.x,d=l.y,f=l.z;if(e.data.satrec){let n=e.data.n/360,i=n>0?1/n/512:0,a=t.userData.curveJd;(o.length===0||a===void 0||Math.abs(r-a)>=i)&&(o=iN(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=r)}else if(e.orbitElements){if(e.rederiveElements){let n=t.userData.elementsJd??r,i=e.orbitElements.n,a=i>0?360/i:1/0;if(Math.abs(r-n)>Math.min(a*GP,KP)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=oN(e.orbitElements,512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.elementsJd=r)}}let n=e.orbitElements.omDot??0,i=e.orbitElements.wDot??0,a=Math.max(Math.abs(n),Math.abs(i));if(a>0){let n=t.userData.curveJd??r;a*Math.abs(r-n)>WP&&(o=oN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let p=e.trailAnchor??e.position,m=t.userData,h=u-n[0],g=d-n[1],_=f-n[2],v=p[0]-u,y=p[1]-d,b=p[2]-f;if(JP(m,o,h,g,_,v,y,b,i))return;let x=eb(e,o,s,u,d,f);if(x.length<2)return;let{posArr:S,trailArr:C,fullArr:w,capacity:T}=mN(t),E=u-n[0],D=d-n[1],O=f-n[2],k=Math.min(x.length,T);for(let e=0;e<k;e++)S[e*3]=x[e][0]+E,S[e*3+1]=x[e][1]+D,S[e*3+2]=x[e][2]+O;hN(t,S,C,w,k,s,c),m.trailLocalPositions=x,YP(m,o,h,g,_,v,y,b,S,k,i)}function $P(e,t,n){let r=e===$.CAPPED;return{groupVisible:e===$.CLOSE||e===$.FULL||r&&t,orbitVisible:e===$.FULL||e===$.CLOSE&&n,showLabel:e===$.FULL||r&&t,isClose:e===$.CLOSE}}function eF(e,t,n){return{groupVisible:e===$.CLOSE||e===$.FULL,orbitVisible:e===$.FULL&&t||e===$.CLOSE&&n,showLabel:e===$.FULL&&t,isClose:t&&e===$.CLOSE}}var tF=4/2,nF=(.1*10)**2,rF=new J,iF=[],aF=iF;function oF(e){return tk(iF,e,ak)}var sF={x:0,y:0,left:0,right:0,h:0},cF=new Hi,lF={ox:0,oy:0},uF=new J,dF=new J;function fF(e,t,n,r,i,o,s,c,l,u,d,f,p,m,h){let g=n.layers,_=!g.isVisible(`orbits`),v=g.isVisible(`nomenclature`),y=t.fov*Math.PI/180,b=f.domElement.clientWidth,x=f.domElement.clientHeight,S=x/(2*Math.tan(y/2)),C=[r[0]+t.position.x,r[1]+t.position.y,r[2]+t.position.z],w=r,T=t.matrixWorldInverse;for(let n of e.values()){if(n.cachedDist=R_(C,n.body.position),n.isCrashed||n.noPhysical){let e=n.noPhysical===`model`,t=cg(n.cachedDist)<(n.isCrashed||e?.1:1),r=null;if(t){let t=a().messages;r=n.isCrashed?t.body_note_crash_site():e?t.body_note_no_model():t.body_note_no_radius()}QE(n,`missing`,r)}let e=n.label;if(!e)continue;n.labelAnchorOffscreen=!1;let r=n.noPhysical?0:n.radiusScene;if(!r){e.position.set(0,0,0);continue}let[i,o,s]=n.body.position;p.set(i-w[0],o-w[1],s-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z,d=u*u,f=r*r;if(d<=f){e.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let m=r/n.cachedDist*S;if(m<1){e.position.set(0,0,0);continue}if(m>=16){let a=n.cachedDist,d=1/a,f=c*d,m=l*d,h=u*d,g=r*d,_=Math.sqrt(Math.max(1-g*g,0)),v=1-f*f,y=-f*m,b=-f*h,x=Math.hypot(v,y,b);x<1e-4&&(v=-m*f,y=1-m*m,b=-m*h,x=Math.hypot(v,y,b));let S=g/x,C=f*_+v*S,T=m*_+y*S,E=h*_+b*S;p.set(C*a-c,T*a-l,E*a-u).applyQuaternion(t.quaternion),e.position.copy(p),dF.set(i-w[0]+p.x,o-w[1]+p.y,s-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(dF.x)>1||Math.abs(dF.y)>1;continue}if(n.semiAxesScene&&n.mesh)$N(c,l,u,XN(n.mesh.getWorldQuaternion(cF),T,n.semiAxesScene),S,lF),p.set(lF.ox,lF.oy,0).applyQuaternion(t.quaternion);else{let e=f/(d-f);p.set(e*c,e*l,0).applyQuaternion(t.quaternion)}e.position.copy(p)}let E=iF,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene;if(!e)continue;let n=t.cachedDist,[r,i,a]=t.body.position,o=t.model?.userData.occluderSpheres;if(t.model&&o?.length){let e=nO(t),s=t.model.position;for(let c of o){let o=c.r*e;if(uF.copy(c.center).applyQuaternion(t.model.quaternion).add(s).multiplyScalar(e),p.set(r-w[0]+uF.x,i-w[1]+uF.y,a-w[2]+uF.z).applyMatrix4(T),p.z>=o||p.lengthSq()<=o*o)continue;let l=p.z*p.z;(l<=o*o||o*S/Math.sqrt(l-o*o)>=16)&&ZN(oF(k++),p.x,p.y,p.z,o,S,D,O,t.body.data.id,n)}continue}p.set(r-w[0],i-w[1],a-w[2]).applyMatrix4(T);let s=p.x,c=p.y,l=p.z;if(l>=e)continue;let u=l*l;(u<=e*e||e*S/Math.sqrt(u-e*e)>=16)&&(t.semiAxesScene&&t.mesh?QN(oF(k++),s,c,l,XN(t.mesh.getWorldQuaternion(cF),T,t.semiAxesScene),S,D,O,t.body.data.id,n):ZN(oF(k++),s,c,l,e,S,D,O,t.body.data.id,n))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=i?xM(n.getBody(i),e):void 0;for(let r of e.values()){let{body:a,group:s,trail:c}=r,l=r.cachedDist,u,d,f=a.data.id===i,p=A!==null&&a.data.id===A;if(r.mesh===null&&!vn(a.data.objectType)){let t=a.data.objectType;if(t===W.BARYCENTER||t===W.LAGRANGE_POINT){let t=!0,r=f?void 0:P_(a.data.id);if(r){let i=e.get(r)?.body??n.getBody(r);i&&R_(a.position,i.position)/R_(C,i.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),u=t,d=!1}else{let e=n.visibility.getPlanetVisibility(a,l)!==$.HIDE&&n.visibility.hasFullRendering(a);s.visible=e,c&&(c.visible=e),u=e,d=!1}}else{let e=a.data.objectType===W.MOON,t=e?n.visibility.getMoonVisibility(a):n.visibility.getPlanetVisibility(a,l),r=e?$P(t,o,f):eF(t,n.visibility.hasFullRendering(a),f||p);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),u=r.showLabel,d=r.isClose}if(r.outOfRange&&(s.visible=!1,c&&(c.visible=!1),u=!1),r.starPoint){let e=r.radiusScene/l*S,t=e<tF;if(r.starPoint.visible=t,t){let t=r.starPoint.material,n=e/tF,i=Math.max($A*n*n,3);t.uniforms.uIntensity.value=i}s.visible=!0,d=!t,u=!d}if(r.isMinor&&!f&&c&&!n.visibility.isPinned(a.data.id)&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(rF.set(w[0],w[1],w[2]))>nF&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:m}=r;if(!s.visible&&m&&m.parent===s?(s.remove(m),m.element.remove()):s.visible&&m&&m.parent!==s&&s.add(m),r.mesh&&r.radiusScene>0){let e=!f&&!p&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}uk(r,u,d,l,S,i)&&(j=!0);let g=r.radiusScene>0?r.radiusScene/l*S:0;UM(r,v&&a.data.id===M,g,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(S_(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(S_(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0)for(let n of e.values())n.label?.visible&&pk(n,t,w,b,x,sF)&&dk(sF.x,sF.y,n.cachedDist,n.body.data.id,E)&&(n.label.visible=!1);if((m||j||++d>=3)&&(d=0,Ek(e,b,x,t,i,n,s,E,r)),Dk(e,b,x,t,r),M){let t=e.get(M);t&&qM(t)}for(let n of e.values()){let e=n.trail;if(!e?.visible)continue;let r=e.material;r.uniforms.uCenterOffset.value.set(-t.position.x,-t.position.y,-t.position.z);let a=n.body.data.id===i,o=s.has(n.body.data.id);r.uniforms.uAlphaMultiplier.value=o?2:a?1.75:1;let c=e.userData.isOpenCurve===!1;r.uniforms.uAlphaMin.value=a&&c?.15:0,r.uniforms.uShowFull.value=+!!a}return d}function pF(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function mF(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function hF(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function gF(e,t){let n=e.arcs[t].points.length,r=t=>e.endOrbits.find(e=>e.at===t);return{from:t===0?r(`departure`)?.trimFrom??0:0,to:t===e.arcs.length-1?r(`arrival`)?.trimTo??n:n}}function _F(e,t){let n=e.arcs[0],r=e.arcs[e.arcs.length-1];if(!n||!r)return null;let i=t=>e.endOrbits.find(e=>e.at===t)??null,a=i(`departure`),o=i(`arrival`),s=e=>e&&e.approach.length>1?e:null,c=s(a),l=s(o),u=e=>e&&e.pointJds&&e.points.length>1&&e.pointJds.length===e.points.length?{points:e.points,jds:e.pointJds}:null,d=u(a),f=o?.surfaceJd===void 0?u(o):null,p=Math.min(n.startJd,a?.surfaceJd??1/0),m=Math.max(r.endJd,o?.surfaceJd??l?.jds[l.jds.length-1]??-1/0),h=d?p-vF(d):p,g=f?m+vF(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:yF(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:bF(c.approach,c.jds,t),centerId:c.anchorId};if(o&&t>=(l?.jds[0]??r.endJd)){let e=o.surfaceJd??l?.jds[l.jds.length-1]??r.endJd;if(f&&(!l||t>e))return{r:yF(f,t),centerId:o.anchorId};if(l)return{r:bF(l.approach,l.jds,Math.min(t,e)),centerId:o.anchorId}}let _=e.arcs.findIndex(e=>t>=e.startJd&&t<=e.endJd),v=_>=0?_:e.arcs.length-1,{points:y,jds:b}=e.arcs[v];if(y.length===0)return null;if(y.length===1||b.length!==y.length)return{r:y[0],centerId:e.centerId};let{from:x,to:S}=gF(e,v);return{r:bF(y,b,t,x,S),centerId:e.centerId}}function vF(e){return e.jds[e.jds.length-1]-e.jds[0]}function yF(e,t){let n=vF(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return bF(e.points,e.jds,i)}function bF(e,t,n,r=0,i=e.length){if(i-r<2)return e[r];let a=r+1;for(;a<i-1&&t[a]<n;)a++;let o=t[a]-t[a-1],s=o>0?Math.min(1,Math.max(0,(n-t[a-1])/o)):0;return pF(e[a-1],hF(mF(e[a],e[a-1]),s))}var xF=Math.PI/180,SF=Math.cos(ag*xF),CF=Math.sin(ag*xF);function wF(e,t,n,r){let i=Math.cos(e*xF),a=Math.sin(e*xF),o=Math.cos(t*xF),s=Math.sin(t*xF),c=Math.cos(n*xF),l=Math.sin(n*xF);return{m11:c*i-l*a*o,m12:-c*a-l*i*o,m21:l*i+c*a*o,m22:-l*a+c*i*o,m31:a*s,m32:i*s,equatorial:r}}function TF(e,t,n){let r=n.m11*e+n.m12*t,i=n.m21*e+n.m22*t,a=n.m31*e+n.m32*t;if(n.equatorial){let e=i*SF+a*CF,t=-i*CF+a*SF;i=e,a=t}return[r,i,a]}function EF(e){let t=10/ig;return[e[0]*t,e[2]*t,-e[1]*t]}function DF(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,{om:u,w:d}=Kv(e,t),f=e.equatorial??!1;if(!isFinite(r)||r===0||!isFinite(o)||o<=0){if(c==null||l==null||!isFinite(c)||!isFinite(l)||c<=0)return null;let r=wg(c,l,t);if(!r)return null;let i=n&&n>0?n:ev,a=r.r*ig,o=2*c*ig;return OF(a,r.nu,o,1,i,d,e.i,u,f)}if(!isFinite(i)||!isFinite(a))return null;let p=r*ig,m=o*xF/tv,h=n&&n>0?n:m*m*Math.abs(p)*Math.abs(p)*Math.abs(p);if(!isFinite(h)||h<=0)return null;let g=(a+o*(t-s))*xF,_,v;if(i<1||r>0){let e=Math.min(i,.9999999),t=xg(g,e),n=1-e*Math.cos(t);_=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),v=p*n}else{let e=Cg(g,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;_=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),v=p*(1-i*Math.cosh(e))}if(!isFinite(v)||v<=0)return null;let y=p*(1-i*i);return!isFinite(y)||y<=0?null:OF(v,_,y,i,h,d,e.i,u,f)}function OF(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=wF(a,o,s,c),p=TF(e*l,e*u,f),m=TF(-d*u,d*(r+l),f);return!isFinite(p[0]+p[1]+p[2])||!isFinite(m[0]+m[1]+m[2])?null:{r:p,v:m,mu:i}}var kF={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};kF.cruise,kF.boost,kF.brake,kF.spiral,kF[`spiral-out`],kF[`spiral-in`];var AF={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},jF=3,MF=1,NF=2,PF=.6,FF=1.5,IF=.3,LF=1.5,RF=.85,zF=60,BF=.018,VF=.026,HF=`#ffffff`,UF=4,WF=1.5,GF=9,KF=1,qF={notice:UF-3,caution:UF-2,severe:UF-1},JF=[`notice`,`caution`,`severe`],YF=.03,XF=.2;function ZF(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.arc(64/2,64/2,64/2-10,0,Math.PI*2),n.fillStyle=e,n.fill(),n.lineWidth=6,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function QF(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.moveTo(64/2,8),n.lineTo(56,56),n.lineTo(8,56),n.closePath(),n.fillStyle=e,n.fill(),n.lineWidth=6,n.lineJoin=`round`,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function $F(e,t,n,r){let i=[];for(let a=r.from;a<r.to;a++)e.jds[a]>=t&&e.jds[a]<=n&&i.push(e.points[a]);return i}function eI(e,t){let n=new cs(new Jo({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=UF,n}function tI(e,t,n,r){let{canvas:i,color:a,onSelect:o,onHover:s}=r,c=document.createElement(o?`button`:`div`);c instanceof HTMLButtonElement&&(c.type=`button`),c.className=e===`step`?`scene-path-label scene-path-label--step`:`scene-path-label${o?``:` scene-path-label--static`}`,c.setAttribute(`aria-label`,`${t} \u2014 ${n}`);let l=document.createElement(`span`);l.className=`scene-path-label__halo`,a&&(l.style.border=`2px solid ${a}`,l.style.background=`${a}22`);let u=document.createElement(`span`);u.className=`scene-path-label__text`;let d=document.createElement(`span`);d.className=`scene-path-label__name`,d.dir=`auto`,d.textContent=t;let f=document.createElement(`span`);f.className=`scene-path-label__when`,f.dir=`auto`,f.textContent=n,u.append(d,f),c.append(l,u),o&&(Lk(c,i),bM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new $O(c);return p.center.set(0,.5),p}var nI=class{group=new za;arcs=[];rings=[];markers=[];labels=[];drawnSteps=[];craft=null;path=null;center=null;layer=null;offset=new J;projected=new J;rects=[];order=[];hovered=null;tint=new X;constructor(e,t){this.scene=e,this.canvas=t,this.group.frustumCulled=!1,this.scene.add(this.group)}get centerId(){return this.center}get isEmpty(){return this.center===null}get plan(){return this.path}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}set(e,t=[],n=[],r=[]){this.clear(),this.path=e?.path??null,this.center=e?.path.centerId??t[0]?.path.centerId??null;let i=e!==null;for(let e of t)this.addArcs(e.path,i?FF:NF,i?IF:PF,e.id),this.addEndLabels(e,i);e&&(this.addPlan(e,r),this.addHazards(e.path,n)),this.applyHover(),this.layer!==null&&this.setLayer(this.layer)}addHazards(e,t){let n=[...t].sort((e,t)=>JF.indexOf(e.severity)-JF.indexOf(t.severity));for(let t of n){let n=AF[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine($F(t,n.startJd,n.endJd,gF(e,r)),AF[n.severity],GF,KF,null,{renderOrder:qF[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=_F(e,t.startJd);if(!r)continue;let i=EF(r.r),a=r.centerId===e.centerId?null:r.centerId,o=eI(QF(n),YF);this.group.add(o),this.markers.push({sprite:o,local:i,anchorId:a});let s=document.createElement(`div`);s.className=`scene-hazard-label`,s.style.color=n,s.textContent=t.label;let c=new $O(s);c.center.set(0,.5),this.group.add(c),this.labels.push({object:c,local:i,anchorId:a,owner:null,width:0,height:0,dimmed:!1,faint:!0})}}mergeIntoStep(e,t){let n=e.kind===`aeroassist`?`aero-pass`:e.kind===`belt-crossing`?`assist`:null;if(!n)return!1;let r=null,i=1/0;for(let{step:t,label:a}of this.drawnSteps){if(t.kind!==n||e.bodyId&&t.bodyId!==e.bodyId)continue;let o=Math.abs(t.jd-e.peakJd);o<i&&(i=o,r=a)}if(!r)return!1;let a=r.object.element,o=document.createElement(`span`);return o.className=`scene-path-label__hazard`,o.style.color=t,o.dir=`auto`,o.textContent=e.label,a.querySelector(`.scene-path-label__text`)?.append(o),a.setAttribute(`aria-label`,`${a.getAttribute(`aria-label`)} — ${e.label}`),!0}addPlan(e,t){let n=e.path;this.addArcs(n,jF,MF,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.group.add(e.sprite);this.craft={sprite:eI(ZF(HF),VF),local:[0,0,0],anchorId:null},this.craft.sprite.visible=!1,this.group.add(this.craft.sprite)}addSteps(e,t){for(let n of t){let t=_F(e,n.jd);if(!t)continue;let r=EF(t.r),i=t.centerId===e.centerId?null:t.centerId,a=eI(ZF(HF),BF);this.markers.push({sprite:a,local:r,anchorId:i});let o=tI(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.group.add(o),this.labels.push({object:o,local:r,anchorId:i,owner:null,width:0,height:0,dimmed:!1,faint:!1,step:!0,sprite:a}),this.drawnSteps.push({step:n,label:this.labels[this.labels.length-1]})}}addEndLabels(e,t=!1){let{path:n,onSelect:r}=e,i=n.arcs[0],a=n.arcs[n.arcs.length-1],o=n.stops.find(e=>e.kind===`departure`),s=[{local:EF(n.meeting.r),end:e.arrival,color:kF[a?.kind??`cruise`]}];o&&s.push({local:EF(o.r),end:e.departure,color:kF[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=tI(`end`,i.name,i.when,{canvas:this.canvas,color:a,onSelect:r,onHover:e.onHover});t&&o.element.classList.add(`scene-path-label--faint`),this.group.add(o),this.labels.push({object:o,local:n,anchorId:null,owner:r?e.id:null,width:0,height:0,dimmed:!1,faint:t})}}setHovered(e){this.hovered!==e&&(this.hovered=e,this.applyHover())}applyHover(){for(let e of this.arcs){if(e.owner===null)continue;let t=e.owner===this.hovered,n=e.line.material;n.uniforms.uColor.value.set(e.color).multiplyScalar(t?MF:e.brightness),n.uniforms.uLineWidth.value=t?jF:e.width}for(let e of this.labels)e.owner!==null&&e.object.element.classList.toggle(`scene-path-label--lit`,e.owner===this.hovered)}addArcs(e,t,n,r=null,i=!1){let a=i&&e.frame===`planetary`,o=t=>a&&e.endOrbits.some(e=>e.at===t&&e.approach.length>1);e.arcs.forEach((a,s)=>{let{from:c,to:l}=i?gF(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),kF[a.kind],t,n,r,{fadeIn:s===0&&o(`departure`),fadeOut:s===e.arcs.length-1&&o(`arrival`)})})}addEndOrbits(e){for(let t of e.endOrbits){let n=this.anchorOf(e,t),r=(t.ground??[]).filter(e=>e.to>e.from);if(r.length>0){let e=0;for(let i of r)i.from>e&&this.addLine(t.approach.slice(Math.max(0,e-1),i.from+1),kF.cruise,jF,MF,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),kF.cruise,jF,MF,null,{anchorId:n,renderOrder:WF}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),kF.cruise,jF,MF,null,{anchorId:n})}else if(t.turn){let{from:e,to:r}=t.turn,i=t.approach.slice(0,e+1),a=t.approach.slice(r-1);for(let e of[i,a])e.length<2||this.addLine(e,kF.cruise,jF,MF,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),kF.cruise,LF,RF,null,{anchorId:n})}else this.addLine(t.approach,kF.cruise,jF,MF,null,{anchorId:n});let i=this.addLine(t.points,kF.cruise,LF,RF,null,{anchorId:n});if(!i)continue;let a=n===null?EF(t.center):[0,0,0];i.line.visible=!1,this.rings.push({arc:i,local:a,radius:Q(t.radiusKm),world:new J})}}anchorOf(e,t){return t.anchorId===e.centerId?null:t.anchorId}addLine(e,t,n,r,i,a={}){let o=e.length;if(o<2)return null;let s=new Float64Array(o*3);for(let t=0;t<o;t++){let[n,r,i]=EF(e[t]);s[t*3]=n,s[t*3+1]=r,s[t*3+2]=i}let c=new Float32Array(o*3),l=new Float32Array(o).fill(1),u=Math.max(1,Math.round(o*XF));for(let e=0;e<u;e++){let t=(e+1)/(u+1);a.fadeIn&&(l[e]=t),a.fadeOut&&(l[o-1-e]=t)}let d=pN(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??UF,this.group.add(d);let f={line:d,owner:i,anchorId:a.anchorId??null,color:t,brightness:r,width:n,local:s,positions:c,alphas:l,count:o};return this.arcs.push(f),f}setClock(e){let t=this.craft;if(!t||!this.path)return;let n=_F(this.path,e);t.sprite.visible=n!==null,n&&(t.local=EF(n.r),t.anchorId=n.centerId===this.path.centerId?null:n.centerId)}reposition(e,t,n){if(this.center===null)return;let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=new Map,s=e=>{if(e===null)return[r,i,a];let s=o.get(e);if(s)return s;let c=n(e),l=c?[c[0]-t[0],c[1]-t[1],c[2]-t[2]]:[r,i,a];return o.set(e,l),l};for(let e of this.arcs){let[t,n,r]=s(e.anchorId);for(let i=0;i<e.count;i++)e.positions[i*3]=e.local[i*3]+t,e.positions[i*3+1]=e.local[i*3+1]+n,e.positions[i*3+2]=e.local[i*3+2]+r;lN(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let[t,n,r]=s(e.anchorId);e.sprite.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}for(let e of this.labels){let[t,n,r]=s(e.anchorId);e.object.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}if(this.craft){let{sprite:e,local:t,anchorId:n}=this.craft,[r,i,a]=s(n);e.position.set(t[0]+r,t[1]+i,t[2]+a)}for(let e of this.rings){let[t,n,r]=s(e.arc.anchorId);e.world.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}}updateCameraOffset(e){if(this.arcs.length!==0){this.offset.set(-e.x,-e.y,-e.z);for(let e of this.arcs)e.line.material.uniforms.uCenterOffset.value.copy(this.offset);for(let t of this.rings){let n=t.world.distanceTo(e);t.arc.line.visible=n<t.radius*zF}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){wk(this.rects,0);return}this.order.length=0;for(let r of this.labels){if(r.faint)continue;let i=r.object.element;if(!r.width&&!r.dimmed&&(r.width=i.offsetWidth,r.height=i.offsetHeight),!r.width||(this.projected.copy(r.object.position).project(e),!aT(this.projected.z)))continue;let a=(this.projected.x*.5+.5)*t,o=(-this.projected.y*.5+.5)*n,s=r.object.position.distanceTo(e.position);if(r.step){let e=dk(a,o,s,``,aF);if(this.setStepVisible(r,!e),e)continue}this.order.push({label:r,left:a-16,y:o,distance:s})}this.order.sort((e,t)=>e.label.step===t.label.step?e.distance-t.distance:e.label.step?1:-1);let r=0;for(let{label:e,left:t,y:n}of this.order){let i=t+16+e.width,a=!1;for(let o=0;o<r;o++){let r=this.rects[o];if(t<r.right&&i>r.left&&Math.abs(n-r.y)<(e.height+r.h)/2){a=!0;break}}if(this.setLabelDimmed(e,a),a)continue;let o=this.rects[r];o||(o={left:0,right:0,y:0,h:0},this.rects[r]=o),o.left=t,o.right=i,o.y=n,o.h=e.height,r++}wk(this.rects,r)}setStepVisible(e,t){e.object.visible=t,e.sprite&&(e.sprite.visible=t)}setLabelDimmed(e,t){e.dimmed!==t&&(e.dimmed=t,e.object.element.classList.toggle(`scene-path-label--dim`,t))}clear(){for(let e of this.arcs)this.group.remove(e.line),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){this.group.remove(e.sprite);let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)this.group.remove(e.object),e.object.element.remove();this.arcs=[],this.rings=[],this.markers=[],this.labels=[],this.drawnSteps=[],this.craft=null,this.path=null,this.center=null}dispose(){this.clear(),this.scene.remove(this.group)}},rI=2,iI=1,aI=4,oI=200,sI=class{group=new za;slots=[];shown=0;layer=null;constructor(e){this.group.frustumCulled=!1,e.add(this.group)}get isEmpty(){return this.shown===0}set(e){let t=0;for(let n of e){if(n.pointsKm.length<2)continue;let e=this.slot(t++);e.bodyId=n.bodyId,e.count=Math.min(n.pointsKm.length,oI);for(let t=0;t<e.count;t++){let[r,i,a]=EF(n.pointsKm[t]);e.local[t*3]=r,e.local[t*3+1]=i,e.local[t*3+2]=a}}this.shown=t;for(let e=t;e<this.slots.length;e++)this.slots[e].line.visible=!1;this.group.visible=t>0}slot(e){for(;this.slots.length<=e;){let e=new Float32Array(oI*3),t=new Float32Array(oI).fill(1),n=pN(oI,e,t,t,0,kF.cruise,rI,iI);n.frustumCulled=!1,n.renderOrder=aI,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array(oI*3),positions:e,alphas:t,count:0})}return this.slots[e]}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}reposition(e,t){for(let n=0;n<this.shown;n++){let r=this.slots[n],i=e(r.bodyId);if(r.line.visible=i!==null,!i)continue;let a=i[0]-t[0],o=i[1]-t[1],s=i[2]-t[2];for(let e=0;e<r.count;e++)r.positions[e*3]=r.local[e*3]+a,r.positions[e*3+1]=r.local[e*3+1]+o,r.positions[e*3+2]=r.local[e*3+2]+s;lN(r.line.geometry,r.positions,r.alphas,r.alphas,r.count)}}updateCameraOffset(e){for(let t of this.slots)t.line.material.uniforms.uCenterOffset.value.set(-e.x,-e.y,-e.z)}},cI=30034e-10,lI=.45,uI=1.6,dI=.85,fI=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],pI=e=>Math.hypot(e[0],e[1],e[2]);function mI(e,t,n=cI){let r=pI(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=fI(e,t)/r,o=pI(e);if(Math.sqrt(Math.max(0,o*o-a*a))>dI*i)return null;let s=a/i;return s>=lI&&s<=uI?`EL1`:s<=-lI&&s>=-uI?`EL2`:null}function hI(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var gI=class{focused=!1;satSide=null;satJd=NaN;majSide=null;majJd=NaN;constructor(e){this.notices=e}update(e){let{jd:t,majorBodies:n,satellites:r}=e,i=null,a=NaN;n.count>0&&(Number.isFinite(n.latestEnd)&&t>n.latestEnd?(i=`after`,a=n.latestEnd):Number.isFinite(n.earliestStart)&&t<n.earliestStart?(i=`before`,a=n.earliestStart):i=`outside`);let o=r.kind===`covered`?null:r.kind,s=r.kind===`after`?Mg(r.lastMs):NaN,c=e.focusedOutOfRange;if(!(c===this.focused&&o===this.satSide&&Object.is(s,this.satJd)&&i===this.majSide&&Object.is(a,this.majJd))){if(Object.assign(this,{focused:c,satSide:o,satJd:s,majSide:i,majJd:a}),!c&&o===null&&i===null){this.notices.dismiss(`out-of-range`);return}this.notices.notify({topic:`out-of-range`,focusedOutOfRange:c,satellites:o===`after`?{side:`after`,jd:s}:o===`gap`?{side:`gap`}:null,majorBodies:i===`after`||i===`before`?{side:i,jd:a}:i===`outside`?{side:`outside`}:null})}}},_I=new Map,vI=new J;function yI(e,t,n,r,i,a,o){let s=Ey(n,r,wy(t));if(!s)return null;let c=`naif-${n.bodyNaifId}`,l=a.bodies.bodiesById.get(c);if(!l||!l.orientation)return null;let u=i.get(c);if(!u)return null;let d=l.data.radiusKm;if(!Number.isFinite(d)||d<=0)return null;let f=Math.PI/180,p=s.latDeg*f,m=s.lngDeg*f,h=Aw(o.get(c),c,d,p,m);h&&_I.set(e.id,h);let g=h??_I.get(e.id),_,v,y;if(g)[_,v,y]=g.pointKm;else{let e=Math.cos(p);_=d*e*Math.cos(m),v=d*Math.sin(p),y=-d*e*Math.sin(m)}let b=mC(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?vI.set(g.normal[0],g.normal[1],g.normal[2]).applyQuaternion(b):null;return e.parentId=c,{x:u[0]+Q(x.x),y:u[1]+Q(x.y),z:u[2]+Q(x.z),parentPos:u,up:S}}var bI=[0,0,0],xI=new Hi,SI=4,CI=0,wI=new Map;function TI(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function EI(e,t,n){let r=wI.get(e),i=r?.dir??null;if(r&&t!==r.jd){let e=Math.sign(t-r.jd),a=(n[0]-r.pos[0])*e,o=(n[1]-r.pos[1])*e,s=(n[2]-r.pos[2])*e,c=Math.hypot(a,o,s);c>1e-12&&(i=[a/c,o/c,s/c])}return wI.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}function DI(e){let{jd:t,ctx:n,bodyObjects:r,focus:i,focusedBody:o,positionMap:s,diagnostics:c,trailView:l,frame:u,outOfRange:d}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let f=n.visibility.activeSystemId,p=f?e=>n.bodies.isInSystem(`naif-${e}`,f):void 0,m={jd:t,satellites:{kind:`covered`},majorBodies:hI(),focusedOutOfRange:!1},h=o?.data.id,g=_x(n.probeStore?.ridesAt(t)??[],h,e=>n.getBody(e)?.data.name),_=[];if(o){let e=new Set([o.data.id]),t=n.getBody(o.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),_.push({id:t.data.id,oldPos:[t.position[0],t.position[1],t.position[2]],bo:r.get(t.data.id)}),t=n.getBody(t.data.parentId)}s.clear(),s.set(`naif-0`,[0,0,0]);for(let e of n.bodies.bodiesById.values())s.set(e.data.id,e.position);for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||s.set(e.body.data.id,e.body.position);let v=new Set,y=e=>{if(v.has(e))return;let t=n.bodies.bodiesById.get(e)??r.get(e)?.body;t&&S(t)},b=performance.now(),x=e=>{let t=n.bodies.hostRead.get(e);return t===void 0?!1:b-t<2e3?!0:(n.bodies.hostRead.delete(e),!1)},S=e=>{if(v.has(e.data.id))return;v.add(e.data.id);let i=e.data,o=r.get(i.id);if(o&&u!==void 0&&i.id!==h&&!x(i.id)&&!o.group.visible&&!o.trail?.visible&&(i.orbitalSource===U.SPICE_PROBE||!vn(i.objectType))&&(o.staggerSlot??=CI++%SI,u%SI!==o.staggerSlot))return;let l=(n=!1)=>{o&&(o.outOfRange=!0),e.positionUnknown=!0,e.placedJd=t,!n&&i.id===h&&(m.focusedOutOfRange=!0)};if(i.unplaceable){l(!0);return}let d=n.chebStore?.has(i.id)??!1,f=i.orbitalSource===U.SPICE_PROBE;if(f){if(g.hidden.has(i.id)){l(!0);return}if(o){let e=g.credits.get(i.id);QE(o,`carrier`,e?a().messages.carried_by_scene_label({carrier:e}):null)}}if(i.visibleFromDays!==void 0&&t-2451545<i.visibleFromDays){l();return}let _;if(f)_=s.get(i.parentId)??[0,0,0];else{let e=s.get(i.parentId);if(!e){l(),c.warnOnce(`missing-parent`,i.id,()=>`computePosition[${i.id}]: parent ${i.parentId} not in positionMap — hiding`);return}_=e,c.clear(`missing-parent`,i.id)}let b=i.q!=null;if(!d&&!f&&(t<i.validityStart||t>i.validityEnd)){l(!i.satrec);return}let S,C,w;if(d){let e=n.chebStore.positionScene(i.id,t);if(!e){l(!0);let e=n.chebStore.zoneCoverage(i.id);e&&(t<e.start||t>e.end)&&(m.majorBodies.count++,e.start<m.majorBodies.earliestStart&&(m.majorBodies.earliestStart=e.start),e.end>m.majorBodies.latestEnd&&(m.majorBodies.latestEnd=e.end),i.id===h&&(m.focusedOutOfRange=!0)),c.warnOnce(`cheb-null`,i.id,()=>{let n=e?t>=e.start&&t<=e.end:void 0,r=e?`[${e.start.toFixed(1)},${e.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${i.id}] returned null at jd=${t.toFixed(3)} (coverage=${r}, insideCoverage=${n}) — children of this body will read stale positionMap entry (pre-seeded) instead of falling to SSB`});return}S=_[0]+e[0],C=_[1]+e[1],w=_[2]+e[2]}else if(f){let a=n.probeStore?.probeWithCenter(i.id,t,p)??null;if(!a){l(),c.warnOnce(`probe-unavailable`,i.id,()=>{let e=n.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${i.id} (${i.name??`unnamed`}): hidden — ${e}`});return}let u=a.probe.landed;if(u&&Ty(a.probe,t)){let d=i.parentId;y(`naif-${u.bodyNaifId}`);let f=yI(i,a.probe,u,t,s,n,r);if(!f){l();return}if(c.clear(`probe-unavailable`,i.id),e.positionUnknown=!1,e.placedJd=t,d!==i.parentId&&e.trailBuffer?.clear(),o){o.outOfRange=!1;let e=u.isDestroyed;(!o.isLanded||o.isCrashed!==e)&&(jk(o.labelHalo,e?`crashed`:`landed`),o.isLanded=!0,o.isCrashed=e),o.model&&(o.model.visible=!e)}e.position[0]=f.x,e.position[1]=f.y,e.position[2]=f.z,e.orbitCenter&&(e.orbitCenter[0]=f.parentPos[0],e.orbitCenter[1]=f.parentPos[1],e.orbitCenter[2]=f.parentPos[2]),e.trailAnchor&&(e.trailAnchor[0]=f.parentPos[0],e.trailAnchor[1]=f.parentPos[1],e.trailAnchor[2]=f.parentPos[2]),s.set(i.id,e.position);let p=f.up;o?.mesh&&(p?yC(o.mesh,p):vC(o.mesh,e.position,f.parentPos)),o?.model&&(p?yC(o.model,p):vC(o.model,e.position,f.parentPos));return}let d=Vy(a.probe,t,a.fitCenterNaifId,n.chebStore??null,e=>s.has(e));if(!d){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`);return}let f=d.id,m=d.muKm3S2,g=Sy(a.probe,t,m);if(!g){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`);return}c.clear(`probe-unavailable`,i.id),o?.isLanded&&(jk(o.labelHalo,`flying`),o.isLanded=!1,o.isCrashed&&(o.isCrashed=!1,o.model&&(o.model.visible=!0),o.noPhysical||QE(o,`missing`,null)));let v=s.get(p_),b=s.get(f_),x=f===`naif-399`&&v!==void 0&&b!==void 0&&mI([Q(g[0]),Q(g[2]),-Q(g[1])],[b[0]-v[0],b[1]-v[1],b[2]-v[2]])!==null,T=x!==(e.lagrangeTrail??!1);e.lagrangeTrail=x;let E=i.parentId!==f;if((E||T)&&e.trailBuffer&&n.probeStore){let r=e.trailBuffer;r.clear(),r.needsPopulate=!1;let o=Gy(Ry(a.probe,t,m),i.validityEnd-i.validityStart,r.capacity,x);r.reconfigure(o.stepDays,o.epsilonScene,o.spanDays),Zy(r,n.probeStore,n.chebStore??null,i.id,f,t)}E&&(i.parentId=f),y(f);let D=s.get(f);if(!D){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — fit center ${f} has no position this frame`);return}_=D;let O=Q(g[0]),k=Q(g[2]),A=-Q(g[1]);S=_[0]+O,C=_[1]+k,w=_[2]+A;let j=e.trailBuffer;if(j?.needsPopulate&&o?.trail?.visible&&n.probeStore&&(j.needsPopulate=!1,j.clear(),Zy(j,n.probeStore,n.chebStore??null,i.id,f,t)),j){let e=j.newestJd,r=t-e,o=j.stepDays*j.capacity,s=isFinite(e)&&(r<0||r>o);if(s&&i.id===h&&n.probeStore){j.clear();let e=Gy(Ry(a.probe,t,m),i.validityEnd-i.validityStart,j.capacity,x);j.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),Zy(j,n.probeStore,n.chebStore??null,i.id,f,t)}else s?(j.clear(),j.append(t,O,k,A)):isFinite(e)?isFinite(j.epsilonScene)?r>=j.stepDays*.00390625&&n.probeStore&&j.readNewestPos(bI)&&$y(j,qy(n.probeStore,n.chebStore??null,i.id,f),e,[bI[0],bI[1],bI[2]],t):r>=j.stepDays&&j.append(t,O,k,A):j.append(t,O,k,A)}}else if(i.a===0&&!b&&!i.satrec)[S,C,w]=_;else{let e=i.satrec?bg(i.satrec,t):b?Xv(i,t):Jv(i,t);if(!e){l();return}S=_[0]+e[0],C=_[1]+e[1],w=_[2]+e[2]}if(o&&(o.outOfRange=!1),e.positionUnknown=!1,e.placedJd=t,e.position[0]=S,e.position[1]=C,e.position[2]=w,(!Number.isFinite(S)||!Number.isFinite(C)||!Number.isFinite(w))&&c.warnOnce(`non-finite`,i.id,()=>{let e=s.has(i.parentId);return`computePosition[${i.id}] non-finite: pos=[${S},${C},${w}] parentId=${i.parentId} parentInPositionMap=${e} parentPos=[${_[0]},${_[1]},${_[2]}] isChebTracked=${d} isProbe=${f} objectType=${i.objectType}`}),e.orbitCenter&&(e.orbitCenter[0]=_[0],e.orbitCenter[1]=_[1],e.orbitCenter[2]=_[2]),e.trailAnchor&&(e.trailAnchor[0]=_[0],e.trailAnchor[1]=_[1],e.trailAnchor[2]=_[2]),s.set(i.id,e.position),o){if(o.trail&&e.orbitCenter){let e=o.trail.userData.orbitCenter;e&&e.set(_[0],_[1],_[2])}if(e.orientation&&(o.mesh||o.model))o.mesh&&hC(o.mesh,e.orientation,t,e.nutPrec),o.model&&hC(o.model,e.orientation,t,e.nutPrec),o.nomenclatureAnchor&&hC(o.nomenclatureAnchor,e.orientation,t,e.nutPrec);else if(XD(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(t,xI))o.mesh&&o.mesh.quaternion.copy(xI),o.model&&o.model.quaternion.copy(xI);else{let n=e.pointingOverride??e.pointing;if(n){let r=TI(n)?EI(i.id,t,e.position):void 0,a={bodyPos:e.position,parentPos:_,sunPos:s.get(f_),velocity:r};o.mesh&&NC(o.mesh,n,a),o.model&&NC(o.model,n,a)}else o.mesh&&vC(o.mesh,e.position,_),o.model&&vC(o.model,e.position,_)}}if(e.orientation)for(let n of o.rings)hC(n.mesh,e.orientation,t,e.nutPrec)}},C=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values()){if(e.data.objectType===W.MOON&&!(C!==null&&e.data.parentId===C)&&e.data.id!==h){s.set(e.data.id,e.position);continue}S(e)}for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||S(e.body);if(m.satellites=n.refresher?.satelliteCoverage(t)??{kind:`covered`},d.update(m),o&&un(o)){let e=n.getBody(o.featureAnchor.hostId);e&&s.has(e.data.id)?Vw(o,e,r.get(e.data.id),t):m.focusedOutOfRange=!0}let w=null;if(o&&m.focusedOutOfRange){let e=_.find(e=>e.bo&&!e.bo.outOfRange);if(e){w=e.id;let t=s.get(e.id)??e.oldPos;if(performance.now()-i.focusStartTime<i.focusDurationMs){i.focusTargetWorld[0]=t[0],i.focusTargetWorld[1]=t[1],i.focusTargetWorld[2]=t[2];let e=i.camTargetOffset;e&&i.camTargetWorld&&(i.camTargetWorld[0]=t[0]+e[0],i.camTargetWorld[1]=t[1]+e[1],i.camTargetWorld[2]=t[2]+e[2])}else{let n=t[0]-e.oldPos[0],r=t[1]-e.oldPos[1],a=t[2]-e.oldPos[2];i.focusTruePos[0]+=n,i.focusTruePos[1]+=r,i.focusTruePos[2]+=a,i.focusTargetWorld[0]=i.focusTruePos[0],i.focusTargetWorld[1]=i.focusTruePos[1],i.focusTargetWorld[2]=i.focusTruePos[2]}}}else if(o){let e=o.position,t=performance.now()-i.focusStartTime<i.focusDurationMs;i.focusTargetWorld[0]=e[0],i.focusTargetWorld[1]=e[1],i.focusTargetWorld[2]=e[2];let n=i.camTargetOffset;n&&i.camTargetWorld&&(i.camTargetWorld[0]=e[0]+n[0],i.camTargetWorld[1]=e[1]+n[1],i.camTargetWorld[2]=e[2]+n[2]);let r=i.camOriginOffset;r&&i.camOriginWorld&&(i.camOriginWorld[0]=e[0]+r[0],i.camOriginWorld[1]=e[1]+r[1],i.camOriginWorld[2]=e[2]+r[2]),t||(i.focusTruePos[0]=e[0],i.focusTruePos[1]=e[1],i.focusTruePos[2]=e[2])}let T=i.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}QP(e.body,n,T,t,l),n.userData.refreshDeferred=!1}}return{focusedOutOfRange:m.focusedOutOfRange,reanchorId:w}}function OI(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(QP(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}var kI=class{seen=new Map;bucket(e){let t=this.seen.get(e);return t||this.seen.set(e,t=new Set),t}warnOnce(e,t,n){let r=this.bucket(e);r.has(t)||(r.add(t),console.warn(n()))}clear(e,t){this.seen.get(e)?.delete(t)}},AI=Q(695700),jI=2,MI=new J;function NI(e,t,n,r,i){MI.subVectors(e,t);let a=MI.dot(n),o=Math.sqrt(Math.max(MI.lengthSq()-a*a,0)),s=o-Math.min(Math.max(o,r),i),c=Math.sqrt(s*s+a*a);return{dist:c,sinToPole:c>0?Math.abs(s)/c:1}}function PI(e,t,n,r,i,a){let o=e.get(f_)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){if(!t.rings.length)continue;let[e,u,d]=t.body.position;for(let f of t.rings){let p=r||f.intensityScale>=.000980392156862745;f.mesh.visible=p;let m=r?1:p?f.intensityScale:0;f.material.uniforms.uIntensityScale.value=m;let h=f.material.uniforms.uSunDir.value;h.set(o[0]-e,o[1]-u,o[2]-d);let g=h.length(),_=AI/g;f.material.uniforms.uSunAngularRadius.value=_,f.material.uniforms.uLightScale.value=n?bT(g):1,h.normalize();let v=f.planetShadowOnRing;if(v.uPlanetCenter.value.set(e-s,u-c,d-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),f.layers){let{dist:e,sinToPole:t}=NI(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,f.innerScene,f.outerScene),n=f.thicknessScene*t/Math.max(e,1e-9)*a,r=Math.min(Math.max(Math.ceil(n*jI),1),48);f.layers.count!==r&&(f.layers.count=r,f.material.uniforms.uLayerCount.value=r,f.material.uniforms.uLayerAlphaExp.value=1/r)}let y=f.planetShadow;y&&(y.uRingShadowIntensity.value=m,y.uRingShadowSunAngularRadius.value=_,y.uRingShadowSunDir.value.copy(h),y.uRingShadowPoleDir.value.copy(v.uPlanetPoleDir.value),y.uRingShadowCenter.value.copy(v.uPlanetCenter.value))}}}var FI=Math.PI/180,II=2451545;function LI(e){let t=e-II,n=(19.3871+.52402073*t)*FI;return((270.3871+.524038496*t+((10.691+3e-7*t)*Math.sin(n)+.623*Math.sin(2*n)+.05*Math.sin(3*n)+.005*Math.sin(4*n)+5e-4*Math.sin(5*n)))%360+360)%360}function RI(e,t,n){let r=e.length,i=r-1;for(let t=0;t<r-1;t++)if(n<e[t+1]){i=t;break}let a=(i+1)%r,o=i===r-1?360-e[i]:e[a]-e[i],s=(n-e[i])/o;return t[i]+(t[a]-t[i])*s}function zI(e,t){let n=e.seasonal;if(!n)return e;let r=RI(n.lsDeg,n.dustTauFactor,t),i=RI(n.lsDeg,n.dustScaleHeightKm,t),a=RI(n.lsDeg,n.pressureFactor,t),o=r*e.mieScaleHeightKm/i,s=(e,t)=>[e[0]*t,e[1]*t,e[2]*t];return{...e,rayleighScatterPerKm:s(e.rayleighScatterPerKm,a),mieScatterPerKm:s(e.mieScatterPerKm,o),mieAbsorptionPerKm:s(e.mieAbsorptionPerKm,o),mieScaleHeightKm:i,seasonal:void 0}}var BI=new WeakMap,VI=.25;function HI(e,t){if(!e.seasonal)return e;let n=Math.round(LI(t)/VI),r=BI.get(e);if(r&&r.lsQ===n)return r.params;let i=zI(e,n*VI);return BI.set(e,{lsQ:n,params:i}),i}var UI=new J,WI=new J,GI=[.2126,.7152,.0722];function KI(e,t,n){return n<=0?0:e<=t-n?n:e>=t+n?0:e<=t?n-(e-(t-n))**2/(2*n):(t+n-e)**2/(2*n)}function qI(e,t){let n=Math.max(t,0),r=e.rayleighScaleHeightKm*Math.exp(-n/e.rayleighScaleHeightKm),i=e.mieScaleHeightKm*Math.exp(-n/e.mieScaleHeightKm),a=KI(n,e.absorptionCenterKm,e.absorptionWidthKm),o=0;for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*r+(e.mieScatterPerKm[t]+e.mieAbsorptionPerKm[t])*i+e.absorptionPerKm[t]*a;o+=GI[t]*Math.exp(-n)}return o}var JI=.4,YI=.05,XI=-.105,ZI=.3,QI=.05;function $I(e,t,n){let r=qI(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/QI),a=Math.min(1,Math.max(0,(n-XI)/ZI));return r*(1+(JI+(YI-JI)*a-1)*i)}function eL(e,t,n,r){let i=Math.sqrt(2*n/r),a=Math.sqrt(Math.PI*r/(2*n));return t>=0?e/(Math.tan(t)+1/a):e*a*Math.exp(t/i)}var tL=vT,nL=200,rL=new J,iL=new J,aL=new J,oL=new J;function sL(e,t,n,r){e.uOccluderCount.value=BC(e.uOccluders.value,t,r,n)}function cL(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:rL.set(1,1,1),sunRefraction:null};RA(n&&a.sunTint);let c=e.get(f_);dj(c?.mesh?.material,vb());let l=uj(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=nL,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere||(c.atmosphere.mesh.visible=n,!n))continue;AA(c.atmosphere,a);let e=_b(c.body.data.id);if(e?.seasonal){let t=a.seasonal?HI(e,o):e;if(c.atmosphere.params!==t){jA(c.atmosphere,t);for(let e of c.sunTint??[])GA(e,t,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[f,p,m]=c.body.position,h=c.atmosphere.material.uniforms;h.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let g=h.uSunDir.value.set(d[0]-f,d[1]-p,d[2]-m),_=c.atmosphere.params,v=r?bT(g.length()):_.realisticSunAlways?Math.sqrt(bT(g.length())):1;h.uSunIntensity.value=_.sunIntensity*v*i,g.normalize(),c.mesh&&(UI.set(0,1,0).applyQuaternion(c.mesh.quaternion),h.uSpinAxis.value.copy(UI));let y=c.atmosphere.mesh,b=c.atmosphere.geometryRadiusScene*y.scale.x,x=t.distanceTo(y.position);b>x*.1&&(s.shellProminent=!0),a.eclipseShadows&&sL(h,y.position,g,b);let S=a.insideView&&x<b,C=c.atmosphere.planetRadiusKm,w=x*((C+_.topAltitudeKm)/b)-C,T=S&&DA(_,w),E=S?OA(_,w):0;wA(c.atmosphere,S,T,E),h.uDeepIrradiance.value=tL*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=tL*i,e.uAtmoTDeepBlend.value=E;if(S){s.insideShell=!0;let e=WI.copy(t).sub(y.position).divideScalar(x).dot(g),n=$I(_,w,e);if(s.skyboxIntensity*=n*(1-E),a.refraction&&_.refractivity&&!T){let t=eL(_.refractivity[1]*Math.exp(-Math.max(w,0)/_.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),_.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:oL.copy(WI)})}}let D=x/b;if(a.sunTint&&D<nL){let e=b/(1+_.topAltitudeKm/C)*(c.atmosphere.surfaceRadiusKm/C);aL.copy(t).sub(y.position);let n=h.uSpinAxis.value,r=h.uStretch.value;if(QA(_,aL,g,e,c.atmosphere.surfaceRadiusKm,iL,n,r)){let e=GI[0]*iL.x+GI[1]*iL.y+GI[2]*iL.z;e>1e-4&&s.sunTint.multiply(iL.divideScalar(e))}l&&D<u&&(u=D,qA(l,_,y.position,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var lL=[];function uL(e,t){let n=RC(),r=e.get(f_);if(!r){n.uSunAngularRadius.value=0,n.uOccluderCount.value=0;return}let[i,a,o]=t,s=r.body.position,c=s[0]-i,l=s[1]-a,u=s[2]-o,d=Math.hypot(c,l,u);d>0?(n.uSunDir.value.set(c/d,l/d,u/d),n.uSunAngularRadius.value=Math.asin(Math.min(r.radiusScene/d,1))):n.uSunAngularRadius.value=0;let f=lL,p=0;for(let t of e.values()){if(t.body.data.objectType===W.STAR)continue;let e=t.body.data.radiusKm;!Number.isFinite(e)||e<=0||t.radiusScene<=0||(f[p++]=t)}f.length=p,p>32&&(f.sort((e,t)=>t.radiusScene-e.radiusScene),f.length=32,p=32);let m=n.uOccluders.value;for(let e=0;e<p;e++){let t=f[e],[n,r,s]=t.body.position;m[e].set(n-i,r-a,s-o,t.radiusScene)}n.uOccluderCount.value=p;for(let e=0;e<p;e++)f[e]=void 0;f.length=0;let h=n.uSunDir.value;for(let t of e.values()){let e=t.eclipseShadow;if(!e||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[n,r,s]=t.body.position,c=e.uEclipseSelfPos.value.set(n-i,r-a,s-o);e.uOccluderCount.value=BC(e.uOccluders.value,c,t.radiusScene,h)}}var dL=10;function fL(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&xT(i,s,c);return}let u=e.get(f_)?.body.position,[d,f,p]=t,m=(u?.[0]??0)-d,h=(u?.[1]??0)-f,g=(u?.[2]??0)-p,_=Math.hypot(m,h,g),v=o.set(m,h,g).normalize();r.position.copy(v).multiplyScalar(dL),r.target.position.set(0,0,0),r.intensity=vT*(s?bT(_):1)*c,i&&(i.intensity=0);let y=Math.max(a*2,.001),b=n.bodies.getSystemExtent(l)*10*1.2,x=r.shadow.camera;x.left=x.bottom=-y,x.right=x.top=y,x.near=dL-b,x.far=dL+b,x.updateProjectionMatrix()}var pL=128,mL=256,hL=.25,gL=.32,_L=.35,vL=300,yL=1.25,bL=.05,xL=4e5,SL=new Y,CL=new J;function wL(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/pL,a=[];for(let t=0;t<=pL;t++){let n=t===pL?e:t*i;(t===0||t===pL||!r(n))&&a.push(n)}for(let[r,i]of t){let t=Math.ceil(Math.max(r,0)/n-1e-9),o=Math.floor(Math.min(i,e)/n+1e-9);for(let e=t;e<=o;e++)a.push(e*n)}a.sort((e,t)=>e-t);let o=n*.25,s=[];for(let e of a)s.length&&e-s[s.length-1]<o||s.push(e);return s[0]=0,s[s.length-1]=e,Float64Array.from(s)}function TL(e,t,n){let r=t.length,i=n.length,a=new Float32Array(r*i*3),o=new Float32Array(r*i*3),s=new Float32Array(r*i*2);for(let c=0;c<r;c++){let r=t[c],l=Math.sin(r),u=Math.cos(r);for(let t=0;t<i;t++){let d=n[t],f=-Math.cos(d)*l,p=u,m=Math.sin(d)*l,h=(c*i+t)*3;a[h]=e*f,a[h+1]=e*p,a[h+2]=e*m,o[h]=f,o[h+1]=p,o[h+2]=m;let g=(c*i+t)*2;s[g]=d/(2*Math.PI),s[g+1]=1-r/Math.PI}}let c=new Uint32Array((r-1)*(i-1)*6),l=0;for(let e=0;e<r-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<i-1;t++){let a=e*i+t+1,o=e*i+t,s=(e+1)*i+t,u=(e+1)*i+t+1;n||(c[l++]=a,c[l++]=o,c[l++]=u),r||(c[l++]=o,c[l++]=s,c[l++]=u)}}let u=new Ho;return u.setAttribute(`position`,new Do(a,3)),u.setAttribute(`normal`,new Do(o,3)),u.setAttribute(`uv`,new Do(s,2)),u.setIndex(new Do(c.subarray(0,l),1)),u}function EL(e){e.terrainWindow&&(e.terrainWindow=null,e.currentSegments=void 0)}function DL(e,t,n){let r=e.mesh,i=e.displacementMap;if(!n||!r||!i)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!r} tex=${!!i}`),EL(e),!1;r.updateMatrixWorld(),SL.copy(r.matrixWorld).invert(),CL.copy(t.position).applyMatrix4(SL);let a=Q(gn(e.body.data)),o=CL.length(),s=Math.max(o/a-1,1e-6);if(s>(e.terrainWindow?gL:hL))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${s.toFixed(4)}`),EL(e),!1;let c=i.image?.width??2048,l=2*Math.PI/c,u=Math.acos(1/(1+s)),d=Math.max(l,2*u*yL/mL),f=Math.log2(d/l),p=Math.max(0,Math.ceil(f-1e-9)),m=e.terrainWindow;m&&m.texWidth===c&&f>m.stepLevel-.85&&f<m.stepLevel+.15&&(p=m.stepLevel);let h=l*2**p,g=h*mL/2,_=Math.acos(Math.min(1,Math.max(-1,CL.y/o))),v=Math.atan2(CL.z,-CL.x);if(v<0&&(v+=2*Math.PI),m&&m.texWidth===c){if(m.stepLevel===p){let e=Math.sin(_)*Math.sin(m.centerTheta)*Math.cos(v-m.centerPhi)+Math.cos(_)*Math.cos(m.centerTheta);if(Math.acos(Math.min(1,Math.max(-1,e)))<_L*m.angRadius)return!0}if(performance.now()-m.builtAt<vL)return!0}let y=Math.max(0,_-g),b=Math.min(Math.PI,_+g),x=wL(Math.PI,[[y,b]],h),S=Math.min(Math.PI,g/Math.max(Math.sin(_),bL)),C=Math.max(p,Math.ceil(Math.log2(2*S/mL/l)-1e-9)),w=l*2**Math.max(0,C),T=v-S,E=v+S,D=S>=Math.PI?[[0,2*Math.PI]]:T<0?[[0,E],[T+2*Math.PI,2*Math.PI]]:E>2*Math.PI?[[0,E-2*Math.PI],[T,2*Math.PI]]:[[T,E]],O=wL(2*Math.PI,D,w);if(x.length*O.length>xL)return console.warn(`terrain window for ${e.body.data.id} would need ${x.length}×${O.length} vertices — keeping the uniform sphere`),EL(e),!1;let k=r.geometry;return r.geometry=TL(a,x,O),k.dispose(),console.debug(`terrain window ${e.body.data.id}: ${x.length}×${O.length} grid, level ${p} (tex ${c})`),e.terrainWindow={thetas:x,phis:O,centerTheta:_,centerPhi:v,angRadius:g,stepLevel:p,texWidth:c,builtAt:performance.now()},e.currentSegments=pL,!0}var OL=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],kL=24;function AL(e,t,n,r){if(!n&&!t)return kL;let i=OL[OL.length-1].segs;for(let t of OL)if(e>=t.up){i=t.segs;break}if(i<r){let t=OL.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function jL(e,t,n,r,i){let a=t.fov*Math.PI/180,o=n.domElement.clientHeight/(2*Math.tan(a/2)),s=r.visibility.activeSystemId,c=i;for(let n of e.values()){if(!n.mesh||!n.radiusScene||!n.group.visible||n.cachedDist<=0)continue;let e=n.body.data.objectType===W.STAR,a=n.body.data.id;if((a===c||n.terrainWindow)&&DL(n,t,a===c))continue;let l=AL(n.radiusScene/n.cachedDist*o,e,s?a===s||r.visibility.isInActiveSystem(n.body.data.parentId):a===i,n.currentSegments??64);if(l===n.currentSegments)continue;let u=Q(gn(n.body.data)),d=n.mesh.geometry;n.mesh.geometry=new ru(u,l,l),d.dispose(),n.currentSegments=l}}function ML(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(Qj(n)>Qj(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return Qj(r)<Qj(t)?r:t}function NL(e,t,n,r,i,a,o,s){s.apply(e,i);let c=t.fov*Math.PI/180,l=n.domElement.clientHeight/(2*Math.tan(c/2)),u=r.visibility.activeSystemId,d=Mx(),f=d.showClouds,p=Qj(qx());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=f);for(let t of e.values()){if(!t.mesh||!t.radiusScene||!t.group.visible||!t.availableTiers?.length||t.cachedDist<=0)continue;let e=t.body.data.id;if(u){if(e!==u&&!r.visibility.isInActiveSystem(t.body.data.parentId))continue}else if(e!==a)continue;let s=t.radiusScene/t.cachedDist*l,c=t.cachedDist/t.radiusScene,f;f=s<256&&c>10?`low`:s<1024&&c>2?`medium`:`high`;let m=Qj(t.textureTier),h=Math.min(Qj(f),p),g=tM(o,t.availableFrames),_=g!==t.textureFrame,v=h>m;if(d.showSurfaceTexture&&!t.textureLoading&&(v||_)){let e=v?$j(h,t.availableTiers):t.textureTier;e&&sM(t,e,g,i)}let y=t.displacementMeta?.tiers;if(t.displacementMap&&y?.length&&!t.displacementLoading){let e=n.capabilities.maxTextureSize,r=e>=16383?2:+(e>=8192),i=t.displacementTier??`low`,a=$j(Math.min(Qj(ML(c,i)),r,p),y);a&&a!==i&&aw(t,a)}if(t.clouds&&t.textureTier){let e=$j(Qj(t.textureTier),t.clouds.availableTiers),n=kj(o,t.clouds.availableFrames,t.clouds.availableCoverage);e&&n&&Mj(t.clouds,e,n)}}}var PL=WO.refMs,FL=new Y,IL=new J,LL=new J,RL=new Hi,zL=new Hi,BL=new J,VL=new J;function HL(e,t,n){return IL.set(e[0],e[1],e[2]),LL.set(t[0],t[1],t[2]),FL.lookAt(IL,LL,n),RL.setFromRotationMatrix(FL).clone()}function UL(e,t,n,r,i){let a=performance.now()-e.focusStartTime,o=e.focusDurationMs>0?Math.min(a/e.focusDurationMs,1):1,s=o<1,c=!!(e.camOriginWorld&&e.camTargetWorld&&e.flyQ0);if(s&&c){let n=o*o*(3-2*o);if(e.focusTruePos=L_(e.focusOriginWorld,e.focusTargetWorld,n),r(),e.orbitFly){let r=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2],i;if(e.arcOrbit)i=z_(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=L_(e.camOriginWorld,e.camTargetWorld,t)}t.position.set(i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]),r&&!e.arcOrbit?(t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2]),zL.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,zL,n)):t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2])}else{let r;if(e.cameraStaysOnBody)r=e.camTargetWorld;else{let t=o*o*o;r=L_(e.camOriginWorld,e.camTargetWorld,t)}let i=HL(r,e.focusTargetWorld,t.up);t.quaternion.slerpQuaternions(e.flyQ0,i,n),t.position.set(r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2])}return!1}if((e.focusTruePos[0]!==e.focusTargetWorld[0]||e.focusTruePos[1]!==e.focusTargetWorld[1]||e.focusTruePos[2]!==e.focusTargetWorld[2])&&(e.focusTruePos=[...e.focusTargetWorld],r(),i()),n.target.set(0,0,0),e.camTargetWorld){let r=e.camTargetWorld[0]-e.focusTruePos[0],i=e.camTargetWorld[1]-e.focusTruePos[1],a=e.camTargetWorld[2]-e.focusTruePos[2];t.position.set(r,i,a),n.enableDamping=!1,n.update(),n.enableDamping=!0,t.position.set(r,i,a),e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1}return!n.update()}function WL(e,t,n,r,i,a=!1){if(e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...t],e.focusStartTime=performance.now(),e.arcOrbit=!1,e.camOriginOffset=null,i){e.camOriginWorld=r,e.camTargetWorld=[...i],e.camTargetOffset=[i[0]-t[0],i[1]-t[1],i[2]-t[2]],e.cameraStaysOnBody=!1,e.flyQ0=n.quaternion.clone();let a=HL([i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]],[t[0]-e.focusTruePos[0],t[1]-e.focusTruePos[1],t[2]-e.focusTruePos[2]],n.up),o=R_(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(UO(o,KO),HO(s,qO))}else e.camOriginWorld=r,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],e.cameraStaysOnBody=!0,e.flyQ0=n.quaternion.clone(),BL.set(0,0,-1).applyQuaternion(e.flyQ0),VL.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=HO(BL.angleTo(VL),WO);if(a){let t=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2];(i||t)&&(e.focusDurationMs=0)}}function GL(e,t,n,r,i=!1){e.camOriginWorld=n,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2]],e.camOriginOffset=[n[0]-e.focusTruePos[0],n[1]-e.focusTruePos[1],n[2]-e.focusTruePos[2]],e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...e.focusTruePos],e.focusStartTime=performance.now(),e.orbitFly=!0,e.arcOrbit=!0,e.cameraStaysOnBody=!1,e.flyQ0=t.quaternion.clone();let a=R_(n,r);BL.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),VL.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=BL.angleTo(VL);e.focusDurationMs=Math.max(UO(a,KO),HO(o,qO)),i&&(e.focusDurationMs=0)}var KL={[W.STAR]:1e3,[W.PLANET]:100,[W.DWARF_PLANET]:10,[W.ASTEROID]:.1,[W.ASTEROID_INNER]:.1,[W.ASTEROID_MAIN_BELT]:.1,[W.ASTEROID_CENTAUR]:1,[W.ASTEROID_TROJAN]:1,[W.ASTEROID_TNO]:1,[W.COMET]:1,[W.MOON]:1},qL=5e-4,JL=new J,YL=new J;function XL(e){return KL[e.data.objectType]??gn(e.data)*.25}function ZL(e,t){return Q((t??gn(e.data))+XL(e))}function QL(e,t,n,r){let i=t.data.radiusKm;if(!Number.isFinite(i)||i<=0)return;let a=t.position[0]-n[0],o=t.position[1]-n[1],s=t.position[2]-n[2],c=Math.hypot(a,o,s),l=r?.centerOffsetScene,u=a+(l?l[0]:0),d=o+(l?l[1]:0),f=s+(l?l[2]:0),p=e.position.x-u,m=e.position.y-d,h=e.position.z-f,g=Math.hypot(p,m,h);if(r?.seated){if(g<1e-9){e.position.set(u,d+c+Q(qL),f);return}let t=Math.tan(e.fov*Math.PI/360)*e.near,n=t*e.aspect,i=0;for(let[a,o,s]of[[0,0,0],[-n,-t,-e.near],[n,-t,-e.near],[-n,t,-e.near],[n,t,-e.near]]){YL.set(a,o,s).applyQuaternion(e.quaternion);let t=p+YL.x,n=m+YL.y,l=h+YL.z,u=Math.hypot(t,n,l);if(u<1e-12)continue;JL.set(t/u,n/u,l/u).applyQuaternion(r.invQuat);let d=r.radialKm([JL.x,JL.y,JL.z]),f=(d===null?c:Q(d))+Q(qL);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/g;e.position.set(e.position.x+p*a,e.position.y+m*a,e.position.z+h*a);return}let _=XL(t);if(g>=Q((r?.outerRadiusKm??i)+_))return;let v=i;r&&g>1e-9&&(JL.set(p/g,m/g,h/g).applyQuaternion(r.invQuat),v=r.radialKm([JL.x,JL.y,JL.z])??i);let y=Q(v+_),b=c>0?Math.min(y,c):y;if(!(g>=b)){if(g<1e-9)p=0,m=b,h=0;else{let e=b/g;p*=e,m*=e,h*=e}e.position.set(u+p,d+m,f+h)}}function $L(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=aC([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=lC(a,t.minLon,t.maxLon),l=Math.min(Math.max(o,t.minDistance??0),t.maxDistance??1/0);if(s===i&&c===a&&l===o)return;let[u,d,f]=oC([0,0,0],s,c,l,n);r.set(u,d,f)}var eR=50,tR=20;function nR(e){return e<=0?`none`:e<tR?`full`:e<eR?`half`:`none`}function rR(e,t){return e.data.validityStart<=t&&t<=e.data.validityEnd}var iR=class{pendingDefaults=new Set;defaults=new Set;userPromoted=new Set;autoPromoted=new Set;pinned=new Set;pinPromoted=new Set;groupTargets=null;groupMode=`none`;smallBodyZone=null;countStableLo=1/0;countStableHi=-1/0;constructor(e){this.deps=e,e.ctx.bodies.onBodiesAdded(()=>{this.onBodiesAdded(),this.buildPinned(),this.autoPromoteAsteroidMoons(),this.reevaluateEarthSatMode(),this.smallBodyZone!==null&&this.refreshSmallBodyEmphasis()}),e.ctx.onEarthSatRollover(()=>this.reevaluateEarthSatMode()),e.ctx.onGroupFilterChange(e=>this.applyGroupFilter(e)),this.applyGroupFilter(e.ctx.earthSatFilter),e.ctx.onSmallBodyFilterChange(e=>this.applySmallBodyFilter(e)),this.applySmallBodyFilter(e.ctx.smallBodyFilter),Vv().then(e=>{let t=[],n=e=>{if(!this.defaults.add(e)||this.deps.bodyObjects.has(e))return;let n=this.deps.ctx.getBody(e);if(!n){this.pendingDefaults.add(e);return}this.shouldAutoPromote(n,e)&&t.push(n)};for(let t of e.keys())n(t);for(let e of m_)n(e);this.buildBatch(t),this.autoPromoteAsteroidMoons();let r=!1;for(let e of this.userPromoted)this.defaults.has(e)&&(this.userPromoted.delete(e),r=!0);r&&this.emitUserPromotedCount()})}autoPromoteAsteroidMoons(){let e=this.deps.ctx.bodies.asteroidBodiesByZone.get(`small_body_moons`);if(!e||e.size===0)return;let t=[],n=new Set;for(let r of e.keys()){let i=e.getKey(r);if(!i||i.data.objectType!==W.MOON||!this.isDefault(i.data.parentId))continue;let a=this.deps.ctx.getBody(i.data.parentId);!a||!_n(a.data.objectType)||(!this.deps.bodyObjects.has(a.data.id)&&!n.has(a.data.id)&&(n.add(a.data.id),t.push(a)),this.deps.bodyObjects.has(i.data.id)||t.push(i))}this.buildBatch(t)}onBodiesAdded(){if(this.pendingDefaults.size===0)return;let e=[];for(let t of this.pendingDefaults){let n=this.deps.ctx.getBody(t);n&&(this.pendingDefaults.delete(t),this.shouldAutoPromote(n,t)&&e.push(n))}this.buildBatch(e)}shouldAutoPromote(e,t){return e.data.objectType!==W.BARYCENTER&&e.data.objectType!==W.LAGRANGE_POINT?!0:m_.has(t)}isDefault(e){return this.defaults.has(e)}ensureBodyObjects(e){this.buildBodyInstance(e)&&this.finalizeBuilds()}buildBodyInstance(e,t,n=!1){let{bodyObjects:r,ctx:i,clock:a,scene:o,clickables:s,meshToBody:c,circleTexture:l,renderer:u}=this.deps;if(r.has(e.data.id))return!1;if(DT(e,a.jd,i),!e.orbitElements&&!e.data.unplaceable&&e.data.orbitalSource!==U.SPICE_PROBE){e.orbitElements=e.data;let t=r.get(e.data.parentId);t&&(e.orbitCenter=[...t.body.position])}hj([e],o,s,c,r,l,u.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let d=r.get(e.data.id);if(d&&!e.data.name&&aM(d),e.data.objectType===W.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(_n(e.data.objectType)||e.data.objectType===W.COMET){let t=this.deps.ctx.bodies.findAsteroidZone(e.data.id);t&&i.bodies.dirtyAsteroidZones.add(t)}let f=e.data.id;return this.defaults.has(f)||(n?this.autoPromoted.add(f):(this.userPromoted.add(f),this.emitUserPromotedCount())),!0}finalizeBuilds(){xN(this.deps.bodyObjects,this.deps.scene,this.deps.pointClouds.basis(),this.deps.clock.jd),this.deps.assignMapLayerToTrails(),this.deps.repositionAll(),this.deps.pointClouds.rebuildMinor()}buildBatch(e,t,n=!1){let r=!1;for(let i of e)this.buildBodyInstance(i,t,n)&&(r=!0);r&&this.finalizeBuilds()}applyGroupFilter(e){this.groupTargets=e,this.reevaluateEarthSatMode()}applySmallBodyFilter(e){this.smallBodyZone=e?.kind===`class`?`small_bodies/${e.className}`:null,this.refreshSmallBodyEmphasis()}refreshSmallBodyEmphasis(){let e=this.smallBodyZone;if(e===null){this.deps.pointClouds.setEmphasizedSmallBodyZone(null,null);return}let t=this.deps.ctx.bodies.asteroidBodiesByZone.get(e)?.size??0;this.deps.pointClouds.setEmphasizedSmallBodyZone(e,t)}onSimTimeChanged(){let e=this.deps.clock.jd;e>this.countStableLo&&e<this.countStableHi||this.reevaluateEarthSatMode()}reevaluateEarthSatMode(){let e=this.deps.ctx.bodies.spacecraftByParent.get(p_),t=this.currentMemberCount(e),n=nR(t);this.deps.pointClouds.setEarthSatEmphasis(t);let r=n!==this.groupMode;if(this.teardownAutoPromoted(r),this.groupMode=n,n===`none`||!e)return;let i=this.deps.clock.jd,a=[];for(let t of e.values())this.groupTargets&&!this.groupTargets.has(t.data.id)||rR(t,i)&&(this.deps.bodyObjects.has(t.data.id)||a.push(t));if(a.length===0)return;let o=n===`half`?new Set(a.map(e=>e.data.id)):void 0;this.buildBatch(a,o,!0)}currentMemberCount(e){if(this.countStableLo=-1/0,this.countStableHi=1/0,!e)return 0;let t=this.deps.clock.jd,n=0;for(let r of e.values()){if(this.groupTargets&&!this.groupTargets.has(r.data.id))continue;let{validityStart:e,validityEnd:i}=r.data;e<=t?e>this.countStableLo&&(this.countStableLo=e):e<this.countStableHi&&(this.countStableHi=e),i<t?i>this.countStableLo&&(this.countStableLo=i):i<this.countStableHi&&(this.countStableHi=i),rR(r,t)&&n++}return n}teardownAutoPromoted(e){if(this.autoPromoted.size===0)return;let t=this.deps.getFocusedId(),n=this.deps.clock.jd,r=[];for(let i of this.autoPromoted){if(i===t)continue;if(e||this.groupTargets&&!this.groupTargets.has(i)){r.push(i);continue}let a=this.deps.bodyObjects.get(i)?.body;a&&!rR(a,n)&&r.push(i)}r.length!==0&&this.tearDownBodies(r,this.autoPromoted)}setPinned(e){this.pinned=new Set(e);let t=this.deps.getFocusedId(),n=[...this.pinPromoted].filter(e=>!this.pinned.has(e));t&&n.includes(t)&&(this.pinPromoted.delete(t),this.userPromoted.add(t),this.emitUserPromotedCount()),this.tearDownBodies(n.filter(e=>e!==t),this.pinPromoted),this.buildPinned()}buildPinned(){let e=!1;for(let t of this.pinned){let n=this.deps.ctx.getBody(t);!n||un(n)||n.data.objectType===W.MOON||this.buildBodyInstance(n)&&(e=!0,this.userPromoted.delete(t)&&this.pinPromoted.add(t))}e&&(this.emitUserPromotedCount(),this.finalizeBuilds())}clearUserPromoted(){let e=this.deps.getFocusedId(),t=[...this.userPromoted].filter(t=>t!==e);this.tearDownBodies(t,this.userPromoted),this.emitUserPromotedCount()}tearDownBodies(e,t){if(e.length===0)return;let{bodyObjects:n,ctx:r,scene:i,clickables:a,meshToBody:o,pointClouds:s}=this.deps,c=new Set,l=new Set;for(let r of e){let e=n.get(r);if(!e){t.delete(r);continue}e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),lO(e),oM(e),PM(e),i.remove(e.group);for(let t of e.extraObjects)i.remove(t);if(e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),fj(e.mesh.material);let t=a.indexOf(e.mesh);t>=0&&a.splice(t,1),o.delete(e.mesh)}e.atmosphere&&=(e.atmosphere.mesh.geometry.dispose(),fj(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),fj(e.trail.material));let s=e.body.data.objectType;if(s===W.SPACECRAFT)c.add(e.body.data.parentId);else if(_n(s)||s===W.COMET){let e=this.deps.ctx.bodies.findAsteroidZone(r);e&&l.add(e)}n.delete(r),t.delete(r)}for(let e of c)r.bodies.dirtySpacecraftGroups.add(e);for(let e of l)r.bodies.dirtyAsteroidZones.add(e);(c.size>0||l.size>0)&&s.rebuildMinor()}emitUserPromotedCount(){if(!this.deps.onUserPromotedChange)return;let e=this.deps.getFocusedId(),t=this.userPromoted.size;e&&this.userPromoted.has(e)&&t--,this.deps.onUserPromotedChange(t)}},aR=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r,i){this.deps=e,this.focusedBody=t,this.promotion=new iR({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer:i,circleTexture:r,clickables:e.clickables,meshToBody:e.meshToBody,hoveredBodyIds:n,pointClouds:e.pointClouds,onBodyClick:e=>this.handleFocus(e),assignMapLayerToTrails:e.assignMapLayerToTrails,repositionAll:e.repositionAll,getFocusedId:()=>this.focusedBody?.data.id,onUserPromotedChange:e.callbacks.onUserPromotedChange})}get current(){return this.focusedBody}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||XD(t))return;let n=this.deps.bodyObjects.get(t.data.id)?.mesh;if(!n)return;let r=n.quaternion;return[r.x,r.y,r.z,r.w]}cameraTruePos(){let{focus:e,camera:t}=this.deps;return[e.focusTruePos[0]+t.position.x,e.focusTruePos[1]+t.position.y,e.focusTruePos[2]+t.position.z]}syncUpgradeTargets(e){let{ctx:t,scene:n,clickables:r,meshToBody:i,bodyObjects:a,pointClouds:o,clock:s,loadTexture:c,assignMapLayerToTrails:l}=this.deps,u=oR(e,t),d=new Set(u.map(e=>e.data.id));for(let e of this.upgradeTargetIds){if(d.has(e))continue;let t=a.get(e);t&&(gj(t.body)?vj(t,n,r,i):lO(t))}let f=!1;for(let t of u){if(this.upgradeTargetIds.has(t.data.id))continue;this.promotion.ensureBodyObjects(t);let o=a.get(t.data.id);if(!o){d.delete(t.data.id);continue}gj(t)&&(_j(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(xN(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e){if(e.positionUnknown)return;let{focus:t,camera:n}=this.deps;WL(t,[...e.position],n,this.cameraTruePos(),void 0,Mx().resolvedReducedMotion)}focusOnPoint(e,t){let{focus:n,camera:r,callbacks:i}=this.deps,a=this.cameraTruePos(),o;if(t!==void 0){let n=this._tmpV3.set(e[0]-a[0],e[1]-a[1],e[2]-a[2]).normalize().negate();o=[e[0]+n.x*t,e[1]+n.y*t,e[2]+n.z*t]}this.focusedBody=void 0,WL(n,[...e],r,a,o,Mx().resolvedReducedMotion);let s=aC(o??a,e,void 0);i.onCameraPosition?.(s.latitude,s.longitude,s.distance)}handleFocus(e){if(this.readerFocusFilter&&!this.readerFocusFilter(e))return;if(this.focusedBody?.data.id===e.data.id){this.deps.callbacks.onFocusChange(e);return}if(this.setFocusTarget(e),e.positionUnknown)return;let{latitude:t,longitude:n,distance:r}=aC(this.cameraTruePos(),e.position,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(t,n,r)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;un(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=xM(u,r),f=xM(e,r),p=u&&(un(u)?u.featureAnchor.hostId:u.data.id),m=un(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&lO(e)}if(d&&d!==f){let e=r.get(d);e&&PM(e)}this.focusedBody=e,un(e)||(n.bodies.focusFeature=null),i.minDistance=ZL(e,AO(r.get(e.data.id)));let g=un(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),un(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus(),e.positionUnknown||WL(o,[...e.position],s,this.cameraTruePos(),t,Mx().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,clock:a,focus:o,camera:s,callbacks:c,pointClouds:l}=this.deps,u=i.getBody(e);if(!u)return 0;if(i.bodies.bodiesById.has(e)||DT(u,a.jd,i),u.positionUnknown)return this.setFocusTarget(u),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=oC(u.position,n,r,t,this.focusedBodyQuat(u));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u.position[0]-e[0],u.position[1]-e[1],u.position[2]-e[2]).normalize().negate();d=[u.position[0]+n.x*t,u.position[1]+n.y*t,u.position[2]+n.z*t]}let f=aC(d??this.cameraTruePos(),u.position,this.focusedBodyQuat(u));return c.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?this.focusedBody?.data.id===e&&R_(o.focusTruePos,u.position)<ZL(u)?(o.focusTruePos=[...u.position],this.deps.repositionAll(),l.rebuildBasis(),GL(o,s,this.cameraTruePos(),d,Mx().resolvedReducedMotion)):(this.setFocusTarget(u,d),n!==void 0&&r!==void 0&&(o.orbitFly=!0)):this.setFocusTarget(u),o.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e);!i||i.positionUnknown||(this.settleOnBodyInstant(i),this.snapToBodyFrame(t,n,r))}snapToBodyFacing(e,t,n,r){let{ctx:i,camera:a,controls:o,callbacks:s}=this.deps,c=i.getBody(e);if(!c||c.positionUnknown)return;this.settleOnBodyInstant(c);let l=i.getBody(t)?.position??[0,0,0],u=sC(c.position,l,n,r);a.position.set(u[0],u[1],u[2]),o.update();let d=aC(u,[0,0,0]);s.onCameraPosition?.(d.latitude,d.longitude,d.distance),this.pendingInitialView=null}settleOnBodyInstant(e){let{focus:t,pointClouds:n}=this.deps;this.setFocusTarget(e),t.focusTruePos=[...e.position],t.focusOriginWorld=[...e.position],t.focusTargetWorld=[...e.position],t.focusStartTime=-PL,t.camOriginWorld=null,t.camTargetWorld=null,t.flyQ0=null,t.orbitFly=!1,t.arcOrbit=!1,t.cameraStaysOnBody=!1,this.deps.repositionAll(),n.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!XD(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=oC([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=aC(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),s&&c[0]===0&&c[1]===0&&c[2]===0&&c[3]===1&&(this.pendingInitialView={latitude:e,longitude:t,zoom:n})}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===1){this.pendingInitialView=null;return}let n=oC([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function oR(e,t){if(!e)return[];if(un(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&gj(n)?[n]:[]}let n=[];if(gj(e)&&n.push(e),e.data.objectType===W.MOON||e.data.orbitalSource===U.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var sR=1e-6;function cR(e){return e.data.name??e.data.id}var lR=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}coverageFor(e){let t=this.coverage.get(e);if(t!==void 0)return t??void 0;this.pending.has(e)||(this.pending.add(e),hx(e,!1).then(t=>this.coverage.set(e,t.global?.coverage??null)).catch(()=>this.coverage.set(e,null)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.id??null,r=n===null?void 0:this.coverageFor(n);if(!e||!r){this.disarm();return}this.armedProbeId!==n&&(this.dismissNotice(),this.armedProbeId=n);let i=r.end_jd-sR,a=r.start_jd+sR;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:i,backwardJd:a,onHit:t=>this.onHit(e,t,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:cR(e),direction:t>=n?`forward`:`backward`,jd:t}),this.noticeShown=!0}disarm(){this.armedProbeId!==null&&(this.armedProbeId=null,this.dismissNotice(),this.clock.setBoundaryStops(null))}dismissNotice(){this.noticeShown&&=(this.notices.dismiss(`coverage-pause`),!1)}},uR=class{group=new za;extensions=new Set;constructor(){this.group.matrixAutoUpdate=!1,this.group.frustumCulled=!1}add(e){this.extensions.add(e),this.group.add(e.object)}remove(e){this.extensions.delete(e)&&(this.group.remove(e.object),e.dispose())}update(e){for(let t of this.extensions)t.update(e)}clear(e){for(let t of[...this.extensions])e?.(t)||(this.extensions.delete(t),this.group.remove(t.object),t.dispose())}dispose(){this.clear()}},dR=Math.PI/180;function fR(e){return`latitude`in e}function pR(e,t){let n=e*dR,r=t*dR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function mR(e,t,n,r,i,a){let o=2*(e.y*r-e.z*n),s=2*(e.z*t-e.x*r),c=2*(e.x*n-e.y*t);i[a]=t+e.w*o+(e.y*c-e.z*s),i[a+1]=n+e.w*s+(e.z*o-e.x*c),i[a+2]=r+e.w*c+(e.x*s-e.y*o)}function hR(e,t,n){return kT(e,n,t)?e.position:null}function gR(e,t,n){let r=t.getBody(e.body),i=r&&hR(r,t,n);if(!i)return null;let[a,o,s]=i;if(fR(e)){let t=Q(gn(r.data)+(e.altitudeKm??0)),[i,c,l]=pR(e.latitude,e.longitude),u=r.orientation?mC(r.orientation,n,r.nutPrec):null;if(!u)return[a+i*t,o+c*t,s+l*t];let d=[0,0,0];return mR(u,i,c,l,d,0),[a+d[0]*t,o+d[1]*t,s+d[2]*t]}let c=typeof e.offsetKm==`function`?e.offsetKm(n):e.offsetKm;if(c===null)return null;if(c===void 0)return[a,o,s];let[l,u,d]=EF(c);return[a+l,o+u,s+d]}function _R(e,t,n,r){let i=n.getBody(e.body),a=i&&hR(i,n,r);if(!a)return null;let o=t[0]-a[0],s=t[1]-a[1],c=t[2]-a[2],l=Math.hypot(o,s,c);return l===0?null:[o/l,s/l,c/l]}function vR(e){let t=ig/10;return[e[0]*t,-e[2]*t,e[1]*t]}function yR(e,t,n){let r=gR(e.position,t,n),i=gR(e.target,t,n);if(!r||!i)return null;let[a,o,s]=e.up??[0,0,1];return{position:r,target:i,up:[a,s,-o]}}var bR=.02,xR=1e-4;function SR(e){return e?.4:.05}function CR(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=XD(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){if(!n)continue;let r=Q(gn(n.data));if(!(r>0))continue;let i=Math.hypot(e.position.x-(n.position[0]-t[0]),e.position.y-(n.position[1]-t[1]),e.position.z-(n.position[2]-t[2]));s=Math.min(s,i-r)}let c=o?Q(gn(o.data)):0,l=Math.tan(Vi.degToRad(e.getEffectiveFOV())/2);return{rotate:wR(c>0?(a-c)*l/(Math.PI*c):1,xR),translate:wR(s/a,bR)}}function wR(e,t){return Math.min(1,Math.max(t,e))}var TR=Math.PI/180;function ER(e,t){let n=e*TR,r=t*TR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function DR(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new $O(i),[o,s,c]=ER(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function OR(e){e.parent?.remove(e),e.element.remove()}var kR=new J;function AR(e,t,n){if(!e)return;let r=t.get(p_);if(!r?.mesh)return;kR.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=kR.x,a=kR.y,o=kR.z,s=r.mesh.position,c=n.position.x-s.x,l=n.position.y-s.y,u=n.position.z-s.z,d=r.radiusScene,f=d*d;e.visible=c*c+l*l+u*u<=f||i*c+a*l+o*u>f}var jR=-1,MR=1.2,NR=Q(1e6),PR=.02,FR=2,IR=2.3,LR=.9,RR=new J,zR=.25,BR=10,VR=4,HR=4,UR=28,WR=.02,GR=class e{renderer;composer;atmoDepthPass;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=ZM();pointClouds;systemData;positionDiagnostics=new kI;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new uR;cameraHold=null;holdingCamera=!1;_tmpV3=new J;cameraBand=null;focusableBodies=null;limitsArmed=!1;bodySelectEnabled=!0;featureSelectEnabled=!0;modelScene;modelCamera;modelLight;overlayActive=!1;modelShadowPlane=null;_tmpUp=new J;_tmpSun=new J;_planeNormal=new J(0,0,1);_modelRaycaster=new Rd;_pickNdc=new q;showPointingAxes=!1;pointingAxes=null;cameraUp;skyboxAdjuster;skyDebugMarkers;haloDebug;travelPath;orbitPreview;previewFlyBodyId=null;travelFocus=null;focus={focusTruePos:[0,0,0],focusOriginWorld:[0,0,0],focusTargetWorld:[0,0,0],camOriginWorld:null,camTargetWorld:null,camTargetOffset:null,camOriginOffset:null,flyQ0:null,orbitFly:!1,arcOrbit:!1,cameraStaysOnBody:!1,focusStartTime:0,focusDurationMs:PL};lastUpdatedJd=NaN;get placedJd(){return this.lastUpdatedJd}lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;disposed=!1;lastHostReadVersion=0;focusWasOutOfRange=!1;_positionMapScratch=new Map;frameIndex=0;static WAKE_FRAMES=30;static IDLE_HEARTBEAT_FRAMES=10;static REALTIME_FRAME_MS=30;wakeUntilFrame=e.WAKE_FRAMES;lastRenderedFrame=0;lastRenderMs=0;lastRenderedJd=NaN;lastRenderedFocusKey=``;lastRenderedCamPos=new J(NaN,NaN,NaN);lastRenderedCamQuat=new Hi;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=Yx();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;textureLoader=new Ju;appearances=new cM;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(f_)?.extraObjects.find(e=>e instanceof dd)}tightFar=!1;sunProxyK=1;sunBaseMeshScale=1;sunBaseCoronaScale=0;userLocationMarker=null;labelContainer;static MAP_LAYER=1;static ATMO_DEPTH_LAYER=2;constructor(t,n,r,i,a,o){this.canvas=t,this.ctx=r,r.hasMeshBody=e=>this.bodyObjects.has(e),this.clock=i,this.callbacks=o,this.outOfRange=new gI(o.notices),this.labelContainer=n;let s=ET(t,n,r);this.viewportH=t.clientHeight||1,this.renderer=s.renderer,this.labelRenderer=s.labelRenderer,this.scene=s.scene,this.scene.add(this.extensions.group),this.camera=s.camera,this.composer=s.composer,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new yj(c.x,c.y),this.modelScene=new qa,this.modelScene.environment=ST(this.renderer),this.modelScene.environmentIntensity=yT,this.modelCamera=new sd(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new hd(16777215,_T);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new md(16777215,vT),this.modelLight.castShadow=!0,this.modelLight.shadow.mapSize.set(this.tier.shadowMapSize,this.tier.shadowMapSize),this.modelLight.shadow.camera.left=-4,this.modelLight.shadow.camera.right=4,this.modelLight.shadow.camera.top=4,this.modelLight.shadow.camera.bottom=-4,this.modelLight.shadow.camera.near=4,this.modelLight.shadow.camera.far=28,this.modelLight.shadow.bias=-1e-4,this.modelLight.shadow.normalBias=.02,this.modelScene.add(this.modelLight),this.modelScene.add(this.modelLight.target),this.modelShadowPlane=new As(new $l(40,40),new iu({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new DN(this.scene),this.skyDebugMarkers=new GN(this.scene),this.haloDebug=new eP(this.canvas),this.travelPath=new nI(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new sI(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),pS(this.scene,this.renderer,r,()=>this.disposed);let u=r.bodies.majorBodies.find(e=>e.data.id===f_),d=r.getBody(a.id),f=d&&!d.positionUnknown?d:void 0,p=r.bodies.majorBodies.find(e=>e.data.id===uC)||u,m=f??p,h=m?.position??[0,0,0];this.focus.focusTruePos=[...h],this.focus.focusOriginWorld=[...h],this.focus.focusTargetWorld=[...h],this.focus.focusStartTime=-PL,this.pointClouds=new NP(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(h),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new LS(this.camera,t),this.controls.enableDamping=!0,this.controls.dampingFactor=SR(Mx().resolvedReducedMotion),this.controls.minDistance=m?ZL(m):Q(.01),this.controls.maxDistance=31620.5*10,this.controls.target.set(0,0,0),this.controls.update(),this.controls.addEventListener(`end`,this.onControlsEnd),this.controls.addEventListener(`start`,this.invalidate),this.controls.addEventListener(`start`,this.armLimits),this.controls.addEventListener(`end`,this.invalidate);for(let n of e.INPUT_EVENTS)t.addEventListener(n,this.invalidate,{passive:!0});window.addEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded=r.bodies.onBodiesAdded(this.invalidate),this.cameraUp=new QO(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new TN(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new aR({ctx:r,clock:i,camera:this.camera,controls:this.controls,scene:this.scene,bodyObjects:this.bodyObjects,clickables:this.clickables,meshToBody:this.meshToBody,callbacks:o,focus:this.focus,pointClouds:this.pointClouds,systemData:this.systemData,loadTexture:e=>this.maybeLoadTexture(e),repositionAll:()=>this.repositionAll(),assignMapLayerToTrails:()=>this.assignMapLayerToTrails()},m,this.hoveredBodyIds,this.circleTexture,this.renderer),this.coverageWatch=new lR(i,o.notices);let g=f?a:{latitude:45,longitude:0,zoom:15},_=oC([0,0,0],g.latitude,g.longitude,g.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(..._),this.focusController.setPendingInitialView({latitude:g.latitude,longitude:g.longitude,zoom:g.zoom}),m&&r.visibility.setFocused(m),r.visibility.updateCamera(g.zoom,this.clock.jd),o.onFocusChange(m),this.buildScene(),m&&this.focusController.promotion.ensureBodyObjects(m),m&&this.focusController.syncUpgradeTargets(m),this.repositionAll(),m&&this.maybeLoadTexture(m),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new BO(this.renderer,this.camera),this.pointerInteraction=new FO(t,this.camera,r,i,this.focus,this.clickables,this.meshToBody,e=>this.focusController.handleFocus(e),(e,t)=>this.pickFocusedModel(e,t),this.gpuPick,()=>[...this.pointClouds.asteroids().values(),...this.pointClouds.spacecraft().values()],this.pointClouds.pickRegistry),this.pointerInteraction.attach(),this.tick()}buildScene(){hj(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,this.circleTexture,this.renderer.domElement,e=>this.focusController.handleFocus(e),(e,t)=>{t?this.hoveredBodyIds.add(e):this.hoveredBodyIds.delete(e),this.invalidate()}),this.pointClouds.buildInitial(new Set(this.bodyObjects.keys()));let e=this.pointClouds.basis();(globalThis.requestIdleCallback??(e=>setTimeout(e,0)))(()=>{xN(this.bodyObjects,this.scene,e,this.clock.jd),this.assignMapLayerToTrails()})}setTravelPath(e,t=[],n=[],r=[]){this.travelPath.set(e,t,n,r),this.refreshTravelPath()}setTravelHover(e){this.travelPath.setHovered(e)}setOrbitPreview(e,t=null){this.orbitPreview.set(e),this.refreshOrbitPreview(),t&&this.frameOrbitPreview(t)}frameOrbitPreview(e){let t=this.ctx.getBody(e.bodyId);if(!t)return;let n=Q(e.radiusKm);if(!(n>0)||performance.now()-this.focus.focusStartTime<this.focus.focusDurationMs&&this.previewFlyBodyId===e.bodyId)return;let r=this.focus.focusTruePos,i=t.position[0]-r[0]-this.camera.position.x,a=t.position[1]-r[1]-this.camera.position.y,o=t.position[2]-r[2]-this.camera.position.z,s=Math.hypot(i,a,o);s>n*1.35&&s<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.ctx.getBody(e)?.position??null,this.focus.focusTruePos),this.orbitPreview.updateCameraOffset(this.camera.position))}refreshTravelPath(){if(this.travelPath.isEmpty){this.reserveTravelLabelSpace();return}let e=this.travelPath.centerId,t=e?this.ctx.getBody(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.clock.jd),this.travelPath.reposition(t.position,this.focus.focusTruePos,e=>this.ctx.getBody(e)?.position??null),this.travelPath.updateCameraOffset(this.camera.position),this.reserveTravelLabelSpace()}reserveTravelLabelSpace(){this.travelPath.reserveLabelSpace(this.camera,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)}focusOnPathPoint(e,t){this.disarmLimits();let n=this.ctx.getBody(e);if(!n)return;let[r,i,a]=EF(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n.position);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=EF(t);this.travelFocus={centerId:e,local:[n,r,i]}}travelFocusWorld(e){let t=this.travelFocus;return t?[e[0]+t.local[0],e[1]+t.local[1],e[2]+t.local[2]]:null}refreshTravelFocus(){if(!this.travelFocus)return;if(this.focusController.current){this.travelFocus=null;return}let e=this.ctx.getBody(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e.position);if(!t)return;let n=this.focus;n.focusTargetWorld=t;let r=n.camTargetOffset;r&&n.camTargetWorld&&(n.camTargetWorld=[t[0]+r[0],t[1]+r[1],t[2]+r[2]]),performance.now()-n.focusStartTime>=n.focusDurationMs&&(n.focusTruePos=[...t])}updateTravelCraftSystem(){let e=this.travelFocus,t=this.travelPath.plan;if(!e||!t){this.ctx.visibility.clearTravelSystem();return}let n=this.ctx.getBody(e.centerId),r=n?this.travelFocusWorld(n.position):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId);if(!t)continue;let n=this.ctx.visibility.resolveSystemId(t);if(!n)continue;let a=this.ctx.visibility.systemReachAU(n);if(!(a>0))continue;let o=R_(r,t.position)/10;!i&&o<=a?i=n:o<=a*2?this.systemData.prefetch(n):this.systemData.discardPrefetch(n)}this.ctx.visibility.setTravelSystem(i)}assignMapLayerToTrails(){for(let t of this.bodyObjects.values())t.trail&&t.trail.layers.set(e.MAP_LAYER)}setImmersive(t){t?(this.camera.layers.disable(e.MAP_LAYER),this.labelContainer.style.display=`none`):(this.camera.layers.enable(e.MAP_LAYER),this.labelContainer.style.display=``)}rebuildMinorPointClouds(){this.pointClouds.rebuildMinor()}repositionAll(){this.repositionBodies(),this.rebuildTrailBasis()}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let[i,a,o]=r.body.position,s=i-e,c=a-t,l=o-n;r.group.position.set(s,c,l);for(let e of r.extraObjects)e.position.set(s,c,l)}this.pointClouds.reposition()}rebuildTrailBasis(){let e=this.focus.focusTruePos,[t,n,r]=e;for(let i of this.bodyObjects.values()){let a=i.trail;if(!a)continue;let o=a.userData.trailBuffer;if(o){XP(i.body,a,o,e,this.clock.jd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;ZP(a,s,c.x-t,c.y-n,c.z-r)}}tick=()=>{this.rafId=requestAnimationFrame(this.tick),this.frameIndex++;let t=performance.now(),n=this.lastTickMs?t-this.lastTickMs:0;if(this.lastTickMs=t,this.holdingCamera||this.cameraUp.update(this.clock.jd),this.firstFrame&&(this.firstFrame=!1,this.controls.target.set(0,0,0),this.controls.update()),this.coverageWatch?.sync(this.focusController.current,this.clock.jd),this.clock.tick(performance.now()),!this.shouldRender(t)){this.controls.update(),this.applyReaderLimits(t);return}this.fpsSamples.length<e.FPS_SAMPLE_FRAMES?this.fpsSamples.push(t):(this.fpsSamples[this.fpsSampleHead]=t,this.fpsSampleHead=(this.fpsSampleHead+1)%e.FPS_SAMPLE_FRAMES);let r=this.lastRenderedFrame===this.frameIndex-1?n:0;this.lastRenderedFrame=this.frameIndex,this.lastRenderMs=t,this.lastRenderedJd=this.clock.jd,this.lastRenderedFocusKey=this.focusKey(),this.lastRenderedCamPos.copy(this.camera.position),this.lastRenderedCamQuat.copy(this.camera.quaternion),this.applyJdUpdate(!0),this.refreshTravelFocus(),this.callbacks.onFrame?.(this.clock.jd,r);let i=this.holdingCamera?this.applyHeldCamera():UL(this.focus,this.camera,this.controls,()=>this.repositionAll(),()=>this.pointClouds.rebuildBasis());this.applyReaderLimits(t);let a=this.holdingCamera?void 0:this.focusController.current;if(a){let e=F_(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||un(a);t&&QL(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),DO(this.bodyObjects.get(a.data.id))&&QL(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(CR(this.camera,this.focus.focusTruePos,a,t,n))}else this.setMotionScale({rotate:1,translate:1});if(this.pendingUrlWrite&&i){this.pendingUrlWrite=!1;let{latitude:e,longitude:t,distance:n}=this.getCameraState();this.callbacks.onCameraPosition?.(e,t,n)}this.systemData.hasPendingUnloads()&&performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&this.systemData.drainPendingUnloads();let{distance:o}=this.getCameraState();this.updateTravelCraftSystem(),this.ctx.visibility.updateCamera(o,this.clock.jd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.clock.jd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=fF(this.bodyObjects,this.camera,this.ctx,this.focus.focusTruePos,this.focusController.current?.data.id,this.hideCappedMoonLabels,this.hoveredBodyIds,this.pointClouds.asteroids(),this.pointClouds.spacecraft(),this.pointClouds.moons(),this.cullFrameCounter,this.renderer,this._tmpV3,!i,this.tightFar),this.pointClouds.applyPointBudget(),OI(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),PI(this.bodyObjects,this.focus.focusTruePos,Mx().realisticLighting,Mx().overexposeRings,this.camera.position,this.pxPerRad()),uL(this.bodyObjects,this.focus.focusTruePos);let s=cL(this.bodyObjects,this.camera.position,Mx().showAtmospheres,Mx().realisticLighting,this.sunIntensityScale,Hk(),this.clock.jd);$k(r,s.shellProminent),this.scene.backgroundIntensity=s.skyboxIntensity,this.applyLayerChrome();let c=this.bodyObjects.get(f_);c&&lj(c.corona,c.starPoint,s.sunTint);let l=Mx().highAmbient?1:_T;if(!Mx().highAmbient&&Mx().realisticLighting){let e=this.bodyObjects.get(f_)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;l*=bT(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=l;AR(this.userLocationMarker,this.bodyObjects,this.camera);let u=xM(this.focusController.current,this.bodyObjects);NL(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,u,this.clock.jd,this.appearances),jL(this.bodyObjects,this.camera,this.renderer,this.ctx,u),fL(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,Mx().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(s.sunRefraction),s.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.composer.render(),this.renderModelOverlay(),this.labelRenderer.render(this.scene,this.camera),this.haloDebug.active&&this.haloDebug.draw(this.bodyObjects,this.camera,this.focus.focusTruePos,this.focusController.current?.data.id,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)};updateTightFar(e){if(iT())return;let t=this.focusController.current,n=t?xM(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e;if(t&&r&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[i,o,s]=r.body.position,c=this.camera.position;a=Math.hypot(e+c.x-i,t+c.y-o,n+c.z-s)}let o=this.tightFar?IR:FR;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*o}updateDepthFar(){if(iT())return;let e=CT,t=this.ctx.visibility.activeSystemId;if(t){let[n,r,i]=this.focus.focusTruePos,a=this.camera.position.lengthSq(),o=e=>{let t=e[0]-n,o=e[1]-r,s=e[2]-i,c=t*t+o*o+s*s;c>a&&(a=c)},s=this.bodyObjects.get(f_);if(this.tightFar){let e=this.bodyObjects.get(t)?.body;if(e){let o=Math.hypot(e.position[0]-n,e.position[1]-r,e.position[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s&&o(s.body.position);for(let e of this.bodyObjects.values())this.ctx.visibility.hasFullRendering(e.body)&&o(e.body.position);e=Math.min(CT,Math.max(NR,Math.sqrt(a)*MR))}Math.abs(e-this.camera.far)>this.camera.far*PR&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(f_);if(!t)return;let[n,r,i]=this.focus.focusTruePos,[a,o,s]=t.body.position,c=a-n,l=o-r,u=s-i;if(e){let t=this.camera.position,n=this._tmpV3.set(c-t.x,l-t.y,u-t.z),r=n.length();n.divideScalar(r);let i=RR.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),c=t.x+n.x*r,l=t.y+n.y*r,u=t.z+n.z*r)}let d=1;if(this.tightFar){let e=this.camera.far*LR,t=Math.hypot(c,l,u);t>e&&(d=e/t)}if(!(d===1&&this.sunProxyK===1&&!e)){this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.group.position.set(c*d,l*d,u*d);for(let e of t.extraObjects)e.position.set(c*d,l*d,u*d);t.mesh?.scale.setScalar(this.sunBaseMeshScale*d),t.corona?.scale.set(this.sunBaseCoronaScale*d,this.sunBaseCoronaScale*d,1),this.sunProxyK=d}}setMotionScale(e){this.motionScale=e,this.controls.rotateSpeed=e.rotate,this.controls.panSpeed=e.translate,this.controls.zoomSpeed=e.translate}isLanded(e){return!!this.bodyObjects.get(e)?.isLanded}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=lw(t*Math.PI/180,n*Math.PI/180);return jw(this.bodyObjects.get(e),e,gn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(DO(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:kO(n),centerOffsetScene:OO(n),radialKm:e=>EO(n,e)};if(!(!t||!e.orientation))return{invQuat:mC(e.orientation,this.clock.jd,e.nutPrec).invert(),seated:t,radialKm:t=>jw(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&XD(t.body)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model,r=t.modelRoot;if(!(!n||!r)){if(e)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==r){r.add(n);let e=n.userData;n.scale.setScalar(e.fitScale??1),n.position.set(0,0,0),e.centerOffset&&n.position.addScaledVector(e.centerOffset,-1)}}}if(e){this.shadowLight.castShadow=!1;return}this.updateFocusedMountedModel()}updateFocusedMountedModel(){let e=this.overlayModelBo(),t=e?.model&&e.model.parent===e.modelRoot?e.modelRoot:null;if(!e||!t){this.shadowLight.castShadow=!1;return}let n=nO(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(f_)?.body;if(!i)return;let[a,o,s]=i.position,[c,l,u]=e.body.position;this._tmpSun.set(a-c,o-l,s-u).normalize(),this.shadowLight.position.copy(e.group.position).addScaledVector(this._tmpSun,BR*n),this.shadowLight.target.position.copy(e.group.position);let d=this.shadowLight.shadow.camera;d.left=d.bottom=-VR*n,d.right=d.top=VR*n,d.near=HR*n,d.far=UR*n,d.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=WR*n}renderModelOverlay(){if(!this.overlayActive)return;let e=this.overlayModelBo();if(!e?.model)return;let t=e.model.userData;e.model.scale.setScalar(t.fitScale??1),e.model.position.set(0,0,0),e.isLanded&&t.feetOffset?e.model.position.copy(t.feetOffset).applyQuaternion(e.model.quaternion).multiplyScalar(-1):t.centerOffset&&e.model.position.copy(t.centerOffset).multiplyScalar(-1),this._tmpV3.copy(this.camera.position).sub(e.group.position);let n=this._tmpV3.length(),r=nO(e),i=n/r;this.modelCamera.position.copy(this._tmpV3).normalize().multiplyScalar(i),this.modelCamera.quaternion.copy(this.camera.quaternion),this.modelCamera.aspect=this.camera.aspect;let a=0;for(let t of this.bodyObjects.values()){let n=t.model;if(!n||t===e)continue;let i=nO(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.group.position,e.group.position).divideScalar(r);let s=n.userData;s.centerOffset&&n.position.addScaledVector(s.centerOffset,-i);let c=n.position.length()+i;c>a&&(a=c)}this.modelCamera.near=Math.max(.01,i-5-a),this.modelCamera.far=i+50+a,this.modelCamera.updateProjectionMatrix();let o=this.bodyObjects.get(f_)?.body,s=1;if(o){let[t,n,r]=o.position,[i,a,c]=e.body.position;this._tmpSun.set(t-i,n-a,r-c),Mx().realisticLighting&&(s=bT(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)}if(this.modelShadowPlane){this._tmpUp.set(0,1,0).applyQuaternion(e.model.quaternion);let t=this._tmpSun.dot(this._tmpUp)>.03;this.modelShadowPlane.visible=!!e.isLanded&&!e.isCrashed&&t,this.modelShadowPlane.visible&&this.modelShadowPlane.quaternion.setFromUnitVectors(this._planeNormal,this._tmpUp)}this._tmpV3.set(0,0,0);let c=VC(this._tmpV3,this._tmpV3)*s;this.modelLight.intensity=vT*c*this.sunIntensityScale,this.modelScene.environmentIntensity=yT*c,this.showPointingAxes?(this.pointingAxes||(this.pointingAxes=this.buildPointingAxes(),this.modelScene.add(this.pointingAxes)),this.pointingAxes.quaternion.copy(e.model.quaternion),this.pointingAxes.scale.setScalar(Math.min(.8,.45*i)),this.pointingAxes.visible=!0):this.pointingAxes&&(this.pointingAxes.visible=!1),this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.render(this.modelScene,this.modelCamera),this.renderer.autoClear=!0}pxPerRad(){return this.viewportH/2/Math.tan(this.camera.fov*Math.PI/360)}trailView(){let e=this._trailView,t=this.camera.position;return e.camX=t.x,e.camY=t.y,e.camZ=t.z,e.tolAngle=zR/this.pxPerRad(),e}cloudViewInfo(){let e=this.camera.position;return{camPos:[e.x,e.y,e.z],pxPerRad:this.pxPerRad()}}getCameraState(){let e=this.camera.position;return aC([e.x,e.y,e.z],[0,0,0],this.focusController.focusedBodyQuat())}setDragEnabled(e){this.controls.enableRotate=e,this.controls.enablePan=e}setZoomEnabled(e){this.controls.enableZoom=e}setBodySelectEnabled(e){this.bodySelectEnabled=e}setFeatureSelectEnabled(e){this.featureSelectEnabled=e}readerMayFocus=e=>this.bodySelectEnabled&&(this.focusableBodies?.has(e.data.id)??!0);setCooperativeTouch(e){this.controls.touches.ONE=e?jR:Tn.ROTATE,this.canvas.style.touchAction=e?`pan-x pan-y`:`none`}setCameraLimits(e,t){this.cameraBand=e,this.focusableBodies=t?new Set(t):null}armLimits=()=>{this.limitsArmed=!0};disarmLimits(){this.limitsArmed=!1}applyReaderLimits(e){!this.limitsArmed||!this.cameraBand||this.holdingCamera||e-this.focus.focusStartTime<this.focus.focusDurationMs||$L(this.camera,this.cameraBand,this.focusController.focusedBodyQuat())}static INPUT_EVENTS=[`pointerdown`,`pointermove`,`pointerup`,`wheel`];invalidate=()=>{this.wakeUntilFrame=this.frameIndex+e.WAKE_FRAMES};focusKey(){let e=this.ctx.visibility;return`${this.focusController.current?.data.id??``}|${e.focusedSystemId??``}|${e.activeSystemId??``}`}cameraOffsetFromFocus(){let e=this.focusController.current,t=this.focus.focusTruePos,n=this.camera.position;return e?[n.x+t[0]-e.position[0],n.y+t[1]-e.position[1],n.z+t[2]-e.position[2]]:[n.x,n.y,n.z]}holdCamera(){this.holdingCamera||(this.disarmLimits(),this.holdingCamera=!0,this.controls.enabled=!1,this.focus.camOriginWorld=null,this.focus.camTargetWorld=null,this.focus.camTargetOffset=null,this.focus.camOriginOffset=null,this.focus.flyQ0=null,this.focus.orbitFly=!1,this.focus.arcOrbit=!1,this.focus.cameraStaysOnBody=!1)}setHeldPose(e){this.cameraHold=e}releaseCamera(){this.holdingCamera&&(this.holdingCamera=!1,this.cameraHold=null,this.controls.enabled=!0,this.controls.target.set(0,0,0),this.controls.enableDamping=!1,this.controls.update(),this.controls.enableDamping=!0,this.invalidate())}applyHeldCamera(){let e=this.cameraHold,t=e&&yR(e,this.ctx,this.clock.jd);if(!t)return!0;let n=this.focus.focusTruePos;return this.camera.up.set(t.up[0],t.up[1],t.up[2]).normalize(),this.camera.position.set(t.position[0]-n[0],t.position[1]-n[1],t.position[2]-n[2]),this.camera.lookAt(t.target[0]-n[0],t.target[1]-n[1],t.target[2]-n[2]),!0}shouldRender(t){if(this.holdingCamera||t-this.focus.focusStartTime<this.focus.focusDurationMs||this.focusKey()!==this.lastRenderedFocusKey||this.ctx.bodies.minorStreaming||this.pointClouds.hasPendingSceneAdds()||this.systemData.hasPendingUnloads())return!0;if(this.covered)return!1;if(this.frameIndex-this.lastRenderedFrame>=e.IDLE_HEARTBEAT_FRAMES)return!0;let n=this.camera;return n.position.distanceToSquared(this.lastRenderedCamPos)>n.position.lengthSq()*1e-10||8*(1-Math.abs(n.quaternion.dot(this.lastRenderedCamQuat)))>1e-8||this.frameIndex<this.wakeUntilFrame||this.haloDebug.active?!0:this.clock.jd===this.lastRenderedJd?!1:Math.abs(this.clock.timeScale)>1||t-this.lastRenderMs>=e.REALTIME_FRAME_MS}onControlsEnd=()=>{this.pendingUrlWrite=!0,this.focusController.clearPendingInitialView()};nudgeCamera(e,t,n){this.armLimits();let{rotate:r,translate:i}=this.motionScale;e!==0&&this.controls.rotateLeft(e*r),t!==0&&this.controls.rotateUp(t*r),n!==1&&this.controls.dollyIn(1/n**+i),this.onControlsEnd()}maybeLoadTexture(e){let t=this.bodyObjects.get(e.data.id);t&&(iM(t,this.textureLoader,this.clock.jd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(hC(t.mesh,e.orientation,this.clock.jd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}),oO(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=ZL(t.body,AO(t))),!this.ctx.layers.skipped.has(`nomenclature`))return kM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&NM(t,this.selectedFeatureId)}))}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&(lO(t),oM(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=xM(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&NM(n,e)}syncLandedNomenclature(){let e=this.focusController.current,t=(e?this.bodyObjects.get(e.data.id):void 0)?.isLanded?e.data.parentId:null;if(t===this.landedNomBodyId||(this.landedNomBodyId=t,!t))return;let n=this.ctx.getBody(t);n&&this.maybeLoadTexture(n)}clearUserPromoted(){this.focusController.promotion.clearUserPromoted()}focusedSeatConfigKey(){let e=this.focusController.current;if(!e||e.data.objectType!==W.SPACECRAFT&&!un(e))return null;let t=F_(e.data.parentId),n=t?this.bodyObjects.get(t):void 0;if(!n)return null;let r=n.terrainWindow;return`${r?`w${r.stepLevel}x${r.texWidth}@${r.centerTheta.toFixed(6)},${r.centerPhi.toFixed(6)}`:`u${n.currentSegments??128}`}|${n.displacementMap?.uuid??`none`}|${vw()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==U.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),gx(e.data.id).then(e=>e&&t.registerCarried(e)));let n=`${e.data.id}@${this.clock.jd}`;if(n===this.lastProbeTargetCheck)return;this.lastProbeTargetCheck=n;let r=t.stampedFitCenterAt(e.data.id,this.clock.jd);if(!r)return;let i=this.ctx.getBody(r);if(!i){if(this.requestedProbeTargets.has(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Pg(this.clock.jd));return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}applyJdUpdate(e=!1){this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0,i=this.ctx.bodies.hostReadVersion;if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion&&i===this.lastHostReadVersion){this.clock.seeked=!1;return}let a=this.clock.seeked;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.lastHostReadVersion=i,this.ctx.refreshTick(Pg(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let o=DI({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,positionMap:this._positionMapScratch,diagnostics:this.positionDiagnostics,trailView:this.trailView(),frame:this.frameIndex,outOfRange:this.outOfRange});this.pointClouds.updateForJd(this.clock.jd,this.cloudViewInfo()),this.refreshTravelFocus(),performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&(this.repositionBodies(),this.pointClouds.maybeRebase()),this.syncLandedNomenclature();let s=o.focusedOutOfRange&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=o.focusedOutOfRange,e&&a&&s&&o.reanchorId){let e=this.ctx.getBody(o.reanchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.controls.dampingFactor=SR(e)}focusOnBody(e,t,n,r){return this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.focusOnBody(e,t,n,r)}focusOnFeature(e,t,n,r=`frame`,i){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1;let a=this.ctx.getBody(e.hostId);if(!a)return 0;this.focusController.clearPendingInitialView();let o=xM(this.focusController.current,this.bodyObjects)===e.hostId,s=Pw(e,t);this.ctx.bodies.focusFeature=s;let c=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,c&&NM(c,e.featureId),Vw(s,a,c,this.clock.jd);let l=s.position,u=this.focusController.focusedBodyQuat(s);if(r===`pan`){let e=aC(this.focusController.cameraTruePos(),l,u);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(s),this.focus.focusDurationMs}let d=l[0]-a.position[0],f=l[1]-a.position[1],p=l[2]-a.position[2],m=Math.hypot(d,f,p);m>1e-9?(d/=m,f/=m,p/=m):(d=0,f=1,p=0);let h=r===`snap`&&i?oC(l,i.latitude,i.longitude,i.zoom,u):[l[0]+d*n,l[1]+f*n,l[2]+p*n],g=aC(h,l,u);if(this.callbacks.onCameraPosition?.(g.latitude,g.longitude,g.distance),r===`snap`){this.focusController.setFocusTarget(s,h);let e=this.focus;return e.focusTruePos=[...l],e.focusOriginWorld=[...l],e.focusTargetWorld=[...l],e.focusStartTime=-PL,e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1,this.repositionAll(),this.pointClouds.rebuildBasis(),this.camera.position.set(h[0]-l[0],h[1]-l[1],h[2]-l[2]),this.controls.update(),0}if(o){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(s),this.focus.focusTruePos=[...l],this.camera.position.set(e[0]-l[0],e[1]-l[1],e[2]-l[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),GL(this.focus,this.camera,e,h,Mx().resolvedReducedMotion)}else this.focusController.setFocusTarget(s,h),this.focus.orbitFly=!0;return this.focus.focusDurationMs}pickFocusedModel(e,t){if(!this.overlayActive||!this.overlayModelBo()?.model)return null;this._pickNdc.set(e,t),this._modelRaycaster.setFromCamera(this._pickNdc,this.modelCamera);let n=null,r=1/0;for(let e of this.bodyObjects.values()){if(!e.model)continue;let t=this._modelRaycaster.intersectObject(e.model,!0);t.length>0&&t[0].distance<r&&(r=t[0].distance,n=e.body)}return n}overlayModelBo(){let e=this.focusController.current;if(!e){let e=this.travelFocus?.centerId,t=e?this.bodyObjects.get(e):void 0;return t?.model?t:null}let t=un(e)?e.featureAnchor.hostId:e.data.id,n=this.bodyObjects.get(t);if(n?.model)return n;if(e.data.orbitalSource===U.SPICE_PROBE&&!n?.isLanded){let t=this.bodyObjects.get(e.data.parentId);if(t?.model)return t}return null}snapToBodyFacing(e,t,n,r){this.disarmLimits(),this.focusController.snapToBodyFacing(e,t,n,r)}snapToBody(e,t,n,r){this.disarmLimits(),this.focusController.snapToBody(e,t,n,r)}setFocusTarget(e,t){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.setFocusTarget(e,t)}getFocusedBody(){return this.focusController.current}getDebugStats(){let t=this.fpsSamples,n=0;if(t.length>=2){let r=t.length<e.FPS_SAMPLE_FRAMES?0:this.fpsSampleHead,i=t[r],a=(t[(r-1+t.length)%t.length]-i)/1e3;a>0&&(n=(t.length-1)/a)}return aP({fps:n,orbitPool:this.pointClouds.orbitPool,renderer:this.renderer,bodyObjects:this.bodyObjects,focusedBody:this.focusController.current,cameraDistanceScene:this.getCameraState().distance})}setBodyAppearance(e,t){this.appearances.set(e,t)}setPinnedBodies(e){this.ctx.visibility.setPinned(e),this.focusController.promotion.setPinned(e)}setNorthReference(e){this.cameraUp.setNorthReference(e)}getFocusedPointing(){let e=this.focusController.current;if(!e)return null;let t=e.pointing??{primary:{axis:`-y`,target:`parent`}};return{supported:XD(e),base:t}}setFocusedPointing(e){let t=this.focusController.current;t&&(t.pointingOverride=e??void 0)}setPointingAxesVisible(e){this.showPointingAxes=e}buildPointingAxes(){let e=new za,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new Gd(n,t,1,r,.22,.12);o.line.material.depthTest=!1,o.cone.material.depthTest=!1,o.renderOrder=999,e.add(o);let s=this.makeAxisLabel(i,a);s.position.copy(n).multiplyScalar(1.12),e.add(s)};return n(new J(1,0,0),16729156,`+X`,`#ff9999`),n(new J(-1,0,0),8930372,`-X`,`#cc7777`),n(new J(0,1,0),4521796,`+Y`,`#99ff99`),n(new J(0,-1,0),4491332,`-Y`,`#77cc77`),n(new J(0,0,1),4491519,`+Z`,`#99bbff`),n(new J(0,0,-1),4478344,`-Z`,`#7799cc`),e}makeAxisLabel(e,t){let n=document.createElement(`canvas`);n.width=n.height=128;let r=n.getContext(`2d`);r.font=`bold 72px sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillStyle=t,r.fillText(e,128/2,128/2);let i=new cs(new Jo({map:new Nc(n),depthTest:!1,transparent:!0}));return i.scale.setScalar(.175),i.renderOrder=1e3,i}sunIntensityScale=1;getSunIntensityScale(){return this.sunIntensityScale}setSunIntensityScale(e){this.sunIntensityScale=e}getFocusedAtmosphere(){let e=this.focusController.current?.data.id;if(!e)return null;let t=this.bodyObjects.get(e)?.atmosphere,n=_b(e);return!t||!n?null:{id:e,current:t.params,shipped:n}}setFocusedAtmosphereParams(e){let t=this.focusController.current?.data.id,n=t?this.bodyObjects.get(t)?.atmosphere:void 0;n&&jA(n,e)}getSkyboxAdjust(){return this.skyboxAdjuster.get()}setSkyboxAdjust(e,t,n){this.skyboxAdjuster.set(e,t,n)}setSkyDebugMarkersVisible(e){this.skyDebugMarkers.setVisible(e)}applyLayerChrome(){this.ctx.layers.isVisible(`stars`)?this.stashedSky&&=(this.scene.background=this.stashedSky,null):this.scene.background&&(this.stashedSky=this.scene.background,this.scene.background=null);let e=this.ctx.layers.isVisible(`labels`);e!==this.namesShown&&(this.namesShown=e,this.labelContainer.classList.toggle(`scene-overlay--no-names`,!e))}setHaloDebugVisible(e){this.haloDebug.setVisible(e)}setUserLocation(e,t){let n=this.bodyObjects.get(p_);n?.mesh&&(this.userLocationMarker&&OR(this.userLocationMarker),this.userLocationMarker=DR(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(OR(this.userLocationMarker),null)}pause(){this.paused||(this.paused=!0,cancelAnimationFrame(this.rafId),this.rafId=0)}resume(){this.paused&&(this.paused=!1,this.invalidate(),this.tick())}setCovered(e){this.covered!==e&&(this.covered=e,e||this.invalidate())}isContextLost(){return this.renderer.getContext().isContextLost()}handleContextRestored(){this.renderer.setPixelRatio(Xx()),this.composer.setPixelRatio(Xx()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),pS(this.scene,this.renderer,this.ctx,()=>this.disposed),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=Yx();let e=Xx();e!==this.renderer.getPixelRatio()&&(this.renderer.setPixelRatio(e),this.composer.setPixelRatio(e),this.resize(this.canvas.clientWidth,this.canvas.clientHeight)),this.pointClouds.setPointBudget(this.tier.pointBudget)}resize(e,t){this.invalidate(),this.viewportH=t||1,this.renderer.setSize(e,t,!1),this.composer.setSize(e,t);let n=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass.setSize(n.x,n.y),this.bloomPass.setSize(e*this.tier.bloomScale,t*this.tier.bloomScale),this.labelRenderer.setSize(e,t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.ctx.visibility.updateViewport(t),fT(e,t)}dispose(){this.disposed=!0,cancelAnimationFrame(this.rafId),this.pointerInteraction.detach(),this.gpuPick.dispose(),this.controls.removeEventListener(`end`,this.onControlsEnd),this.controls.removeEventListener(`start`,this.invalidate),this.controls.removeEventListener(`start`,this.armLimits),this.controls.removeEventListener(`end`,this.invalidate);for(let t of e.INPUT_EVENTS)this.canvas.removeEventListener(t,this.invalidate);window.removeEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded?.(),this.controls.dispose(),this.haloDebug.dispose(),this.travelPath.dispose(),this.extensions.dispose();for(let e of this.bodyObjects.values())e.model&&lO(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),KR(this.scene.background),KR(this.scene.environment),KR(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.renderer.dispose()}disposeScene(e){let t=new Set;e.traverse(e=>{let n=e;n.geometry?.dispose();let r=n.material,i=Array.isArray(r)?r:r?[r]:[];for(let e of i)if(!t.has(e)){t.add(e);for(let t of Object.values(e))KR(t);e.dispose()}})}};function KR(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var qR=$e({progress:null,bootPending:!1}),JR=6371;function YR(e){let t=[];for(let n=0;n<128;n++){let r=Math.PI*(n/127)**2,i=Math.cos(r);t.push(1/(4*Math.PI)*(1-e*e)/(1+e*e-2*e*i)**1.5)}return[...t,...t,...t]}var XR={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:YR(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},ZR=1.6,QR=1.0005,$R=new J(.55,.25,.8).normalize(),ez=[`low`,`medium`,`high`,`ultra`],tz=4,nz=12,rz=10,iz=16,az=5;function oz(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function sz(e,t){let n=`low`;for(let r of e.tiers){let e=oz(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var cz=new Set([`WebKit WebGL`,`Mozilla`,``]);function lz(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!cz.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function uz(e,t){let n=e.getContext(),r=new qa,i=new sd(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new mu({color:7829367,roughness:1,metalness:0}),o=new As(new ru(1,64,64),a);o.renderOrder=1,r.add(o);let s=new md(16777215,2);s.position.copy($R),r.add(s);let c=XR,l=CA(c,1,JR),u=l.material.uniforms;u.uSunDir.value.copy($R),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,QR,0),i.lookAt(1,QR+.1,0)):(i.position.set(0,0,ZR),i.lookAt(0,0,0)),l.material.side=+!!t,l.material.depthWrite=!t,l.material.depthTest=!t},f=new Uint8Array(4),p=()=>new Promise((e,n)=>requestAnimationFrame(()=>t?.aborted?n(Error(`benchmark aborted`)):e())),m=t=>{let a=performance.now();for(let n=0;n<t;n++)e.render(r,i);return n.readPixels(0,0,1,1,n.RGBA,n.UNSIGNED_BYTE,f),(performance.now()-a)/t};return{measure:async(e,t,{decideMs:n,onFrame:r}={})=>{AA(l,zk[e]),d(t);let i=0;for(let e=0;e<tz;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(iz,Math.max(1,Math.ceil(rz/Math.max(i,.25)))),o=[],s=()=>{let e=[...o].sort((e,t)=>e-t);return{medianMs:e[Math.floor(e.length/2)],p75Ms:e[Math.floor(e.length*.75)]}};for(let e=0;e<nz;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=az){let{medianMs:e,p75Ms:t}=s();if(e>n*1.4||t<n*.7)break}return{...s(),repeats:a}},dispose:()=>{r.remove(o,s,l.mesh),o.geometry.dispose(),a.dispose(),s.dispose(),PA(l)}}}function dz(e,t,n,r){let i=e.getContext();return{tiers:t.map(e=>{let t=n.get(e)??null,i=r.get(e)??null;return{tier:e,limb:t,sky:i,skipped:!t&&!i}}),drawWidth:i.drawingBufferWidth,drawHeight:i.drawingBufferHeight}}async function fz(e,t){let n=t.tiers??ez,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=uz(e,i),c=tz+nz,l=0,u=0,d=(e,t,i)=>s.measure(n[e],t,{decideMs:r,onFrame:(r,o)=>{if(!a)return;l++;let s=c-((r===`measure`?tz:0)+o)+i*c;u=Math.max(u,l/(l+s)),a({tier:n[e],tierIndex:e,tierCount:n.length,scenario:t,phase:r,frame:o,frames:r===`measure`?nz:tz,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(zk[t].insideView){let n=await d(e,`sky`,1);if(p.set(t,n),n.medianMs>r)return!1}let i=await d(e,`limb`,0);return f.set(t,i),i.medianMs<=r};try{if(await m(o))for(let e=o+1;e<n.length&&await m(e);e++);else for(let e=o-1;e>=1&&!await m(e);e--);}finally{s.dispose()}return dz(e,n,f,p)}var pz=60,mz=100,hz=3e4,gz=25e4,_z=`v1`,vz=!1,yz=null,bz=Promise.resolve();function xz(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/gz);return`${lz(e)}|${n}|${_z}`}function Sz(){vz||typeof window>`u`||(vz=!0,qR.bootPending=!0,bz=new Promise(e=>{let t=()=>{qR.bootPending=!1,e()};setTimeout(t,hz),setTimeout(()=>void wz(!1).finally(t),mz)}))}function Cz(){return bz}function wz(e){return yz??=Tz(e).finally(()=>yz=null),yz}async function Tz(e){let t=Mx();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new dh({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(Gx()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=xz(n);if(!e&&t.atmosphereCalibration?.key===r)return;qR.progress=0;let i=await fz(n,{budgetMs:1e3/pz,startTier:Bk(),onProgress:e=>qR.progress=e.fraction}),a={};for(let e of i.tiers){let t=oz(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=sz(i,1e3/pz);t.setAtmosphereCalibration({key:r,tier:o,worstMs:a}),t.setAtmosphereAutoTier(null),console.info(`atmosphere calibration: ${o}`,a)}catch(e){console.warn(`atmosphere calibration failed, keeping heuristic tier`,e)}finally{qR.progress=null,n?.dispose(),n?.forceContextLoss()}}var Ez=class{object=new za;element;label;anchor;occlude;wanted=!0;removeSelf=null;constructor(e,t){this.anchor=e.anchor,this.occlude=e.occlude??!1,this.element=e.element,this.label=new $O(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,Lk(e.element,t)}bind(e){this.removeSelf=e}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{jd:t,basis:n,ctx:r}=e,i=this.wanted?gR(this.anchor,r,t):null;if(!i){this.label.visible=!1;return}let a=i[0]-n[0],o=i[1]-n[1],s=i[2]-n[2];this.label.position.set(a,o,s),this.label.visible=this.occlude?this.facesCamera(i,e):!0,this.object.updateMatrixWorld(!0)}facesCamera(e,{camera:t,ctx:n,jd:r}){let i=_R(this.anchor,e,n,r);if(!i)return!0;let{position:a}=this.label,o=t.position.x-a.x,s=t.position.y-a.y,c=t.position.z-a.z;return i[0]*o+i[1]*s+i[2]*c>0}dispose(){this.label.removeFromParent(),this.element.remove()}},Dz=3,Oz=new J,kz=new J,Az=new J;function jz(e){let[t,n=t]=(e??``).split(/[\s,]+/).filter(Boolean).map(Number);return t>0&&n>0?[t,n]:null}function Mz(e,t){return Oz.set(1,0,0).applyQuaternion(e.quaternion),kz.set(0,1,0).applyQuaternion(e.quaternion),Az.set(0,0,-1).applyQuaternion(e.quaternion),t/(2*Math.tan(e.getEffectiveFOV()*Math.PI/360))}function Nz(e,t,n,r){let i=e[t*3]-n.position.x,a=e[t*3+1]-n.position.y,o=e[t*3+2]-n.position.z;r[0]=i*Oz.x+a*Oz.y+o*Oz.z,r[1]=i*kz.x+a*kz.y+o*kz.z,r[2]=i*Az.x+a*Az.y+o*Az.z}function Pz(e,t,n){Az.set(0,0,-1).applyQuaternion(n.quaternion);let{x:r,y:i,z:a}=n.position;for(let o=0;o<t;o++)if((e[o*3]-r)*Az.x+(e[o*3+1]-i)*Az.y+(e[o*3+2]-a)*Az.z<n.near*2)return!0;return!1}function Fz(e,t,n,r,i){let a=Mz(n,r),o=[0,0,0],s=0,c=0,l=0,u=!1;for(let r=0;r<t;r++){if(Nz(e,r,n,o),o[2]>n.near){let e=o[0]/o[2]*a,t=o[1]/o[2]*a;u&&(s+=Math.hypot(e-c,t-l)),c=e,l=t,u=!0}i[r]=s}}var Iz=class{points=new Float32Array;alphas=new Float32Array;lengths=new Float32Array;count=0;a=[0,0,0];b=[0,0,0];see(e,t,n,r,i){this.alphas.length<n*4&&(this.points=new Float32Array(n*12),this.alphas=new Float32Array(n*4),this.lengths=new Float32Array(n*4)),this.count=0;let a=Mz(r,i),o=i*r.aspect*Dz/2,s=i*Dz/2,c=r.near*2,{a:l,b:u}=this,d=!1,f=0,p=0,m=0;n>0&&Nz(e,0,r,l);for(let i=0;i+1<n;i++,[l,u]=[u,l]){Nz(e,i+1,r,u);let n=0,h=1;for(let e=0;e<5&&n<=h;e++){let t=Lz(e,l,a,o,s,c),r=Lz(e,u,a,o,s,c);t<0&&r<0?h=-1:t<0?n=Math.max(n,t/(t-r)):r<0&&(h=Math.min(h,t/(t-r)))}if(n>h){d=!1;continue}let g=l[2]+(u[2]-l[2])*n,_=(l[0]+(u[0]-l[0])*n)/g*a,v=(l[1]+(u[1]-l[1])*n)/g*a;(!d||n>0)&&(this.count>0&&(this.copy(this.count-1,0),this.put(e,t,i,n,f,0)),this.put(e,t,i,n,f,1),p=_,m=v);let y=l[2]+(u[2]-l[2])*h,b=(l[0]+(u[0]-l[0])*h)/y*a,x=(l[1]+(u[1]-l[1])*h)/y*a;f+=Math.hypot(b-p,x-m),p=b,m=x,this.put(e,t,i,h,f,1),d=h===1}}put(e,t,n,r,i,a){let o=this.count++;for(let t=0;t<3;t++){let i=e[n*3+t];this.points[o*3+t]=i+(e[n*3+3+t]-i)*r}this.alphas[o]=(t[n]+(t[n+1]-t[n])*r)*a,this.lengths[o]=i}copy(e,t){let n=this.count++;this.points.copyWithin(n*3,e*3,e*3+3),this.alphas[n]=this.alphas[e]*t,this.lengths[n]=this.lengths[e]}};function Lz(e,t,n,r,i,a){return e===0?t[2]-a:e===1?r*t[2]-n*t[0]:e===2?r*t[2]+n*t[0]:e===3?i*t[2]-n*t[1]:i*t[2]+n*t[1]}var Rz=1e-9,zz=class{object=new za;anchor;color;widthPx;opacity;dash;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;seen=new Iz;capacity=0;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.dash=jz(e.dash),this.fade=e.fade??!1,this.closed=e.closed??!1,this.local=new Float64Array,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=e.length+(this.closed&&e.length>2?1:0);this.local.length<t*3&&(this.local=new Float64Array(t*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}t>e.length&&this.local.copyWithin(e.length*3,0,3),this.count=t,this.alphas.length<t&&(this.scratch=new Float32Array(t*3),this.alphas=new Float32Array(t)),t>this.capacity&&this.rebuild(t),this.fillAlphas(),this.dirty=!0}fillAlphas(){let e=this.count;for(let t=0;t<e;t++)this.alphas[t]=this.fade&&e>1?this.opacity*(1-t/(e-1)):this.opacity}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,viewportPx:r,ctx:i}){let a=this.wanted&&this.count>=2?gR(this.anchor,i,e):null;if(this.mesh&&(this.mesh.visible=a!==null),!this.mesh||!a)return;let o=[a[0]-t[0],a[1]-t[1],a[2]-t[2]],s=this.dirty||Math.abs(o[0]-this.lastOrigin[0])>Rz||Math.abs(o[1]-this.lastOrigin[1])>Rz||Math.abs(o[2]-this.lastOrigin[2])>Rz;if(s){for(let e=0;e<this.count*3;e++)this.scratch[e]=this.local[e]+o[e%3];this.lastOrigin=o}let c=this.dash!==null||Pz(this.scratch,this.count,n);if(c){let{seen:e}=this;e.see(this.scratch,this.alphas,this.count,n,r),e.count>this.capacity&&this.rebuild(e.count),lN(this.mesh.geometry,e.points,e.alphas,e.alphas,e.count),this.dash&&fN(this.mesh.geometry,e.lengths,e.count)}else s&&lN(this.mesh.geometry,this.scratch,this.alphas,this.alphas,this.count);this.dirty=c,this.mesh.material.uniforms.uCenterOffset.value.copy(n.position).negate()}rebuild(e){this.disposeMesh(),this.dirty=!0;let t=pN(e,this.scratch,this.alphas,this.alphas,0,this.color,this.widthPx,1,this.dash??void 0);t.frustumCulled=!1,this.object.add(t),this.mesh=t,this.capacity=e}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh()}};function Bz(e){let t=Math.hypot(e[0],e[1],e[2]),n=t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1],r=Vz(Math.abs(n[2])<.9?[0,0,1]:[1,0,0],n),i=Math.hypot(r[0],r[1],r[2]),a=[r[0]/i,r[1]/i,r[2]/i];return[a,Vz(n,a)]}function Vz(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Hz(e,t={}){let[n,r]=Bz(t.normal??[0,0,1]),i=Math.max(3,Math.round(t.steps??128)),a=[];for(let t=0;t<i;t++){let o=2*Math.PI*t/i,s=Math.cos(o)*e,c=Math.sin(o)*e;a.push([n[0]*s+r[0]*c,n[1]*s+r[1]*c,n[2]*s+r[2]*c])}return a}function Uz(e){if(e.length<3)return[];let[t,n]=Bz(Wz(e)),r=e.map(e=>new q(e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[0]*n[0]+e[1]*n[1]+e[2]*n[2]));return Xl.triangulateShape(r,[]).flat()}function Wz(e){let t=0,n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i],o=e[(i+1)%e.length];t+=(a[1]-o[1])*(a[2]+o[2]),n+=(a[2]-o[2])*(a[0]+o[0]),r+=(a[0]-o[0])*(a[1]+o[1])}return Math.hypot(t,n,r)>0?[t,n,r]:[0,0,1]}function Gz(e,t,n){let r=Math.min(1,Math.max(-1,e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),i=Math.acos(r);if(i<1e-9||Math.PI-i<1e-9)return Kz([e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]);let a=Math.sin(i),o=Math.sin((1-n)*i)/a,s=Math.sin(n*i)/a;return[e[0]*o+t[0]*s,e[1]*o+t[1]*s,e[2]*o+t[2]*s]}function Kz(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1]}function qz(e,t){let n=0,r=0,i=0;for(let a=0;a<t;a++)n+=e[a*3],r+=e[a*3+1],i+=e[a*3+2];return Math.hypot(n,r,i)<1e-9?[e[0],e[1],e[2]]:Kz([n,r,i])}function Jz(e,t){return new fu({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
|
|
5550
|
+
`;let i=document.createElement(`span`);return i.textContent=e.label,i.style.color=e.color,i.style.marginInlineStart=`2px`,t.appendChild(n),t.appendChild(i),t}function GN(e,t,n,r,i){let a=new J().crossVectors(t,e).normalize(),o=new Float32Array(i*3),s=new J;for(let t=0;t<i;t++){let r=t/i*Math.PI*2,c=Math.cos(r),l=Math.sin(r);s.copy(e).multiplyScalar(c).addScaledVector(a,l).multiplyScalar(n),o[t*3]=s.x,o[t*3+1]=s.y,o[t*3+2]=s.z}let c=new Ho;c.setAttribute(`position`,new Ao(o,3));let l=new wc(c,new dc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function KN(){let e=new za;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of IN){UN(n.raDeg,n.decDeg,t).multiplyScalar(FN);let r=new nk(WN(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of HN){let n=GN(t.zero,t.pole,FN*.999,t.color,VN);n.name=t.name,e.add(n)}return e}function qN(e){e.traverse(e=>{e instanceof nk&&e.element.remove(),e instanceof wc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var JN=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=KN(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(qN(this.group),null)}},YN=new J,XN=new J,ZN=new J,QN=[YN,XN,ZN];function $N(e,t,n){return YN.set(1,0,0).applyQuaternion(e).transformDirection(t),XN.set(0,1,0).applyQuaternion(e).transformDirection(t),ZN.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:QN,a:n}}function eP(e,t,n,r,i,a,o,s,c,l){let u=1/i;e.gxx=u,e.gxy=0,e.gxz=0,e.gyx=0,e.gyy=u,e.gyz=0,e.gzx=0,e.gzy=0,e.gzz=u,e.cpx=t*u,e.cpy=n*u,e.cpz=r*u,e.K=(t*t+n*n+r*r)*u*u-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function tP(e,t,n,r,i,a,o,s,c,l){let[u,d,f]=i.e,[p,m,h]=i.a;e.gxx=u.x/p,e.gxy=u.y/p,e.gxz=u.z/p,e.gyx=d.x/m,e.gyy=d.y/m,e.gyz=d.z/m,e.gzx=f.x/h,e.gzy=f.y/h,e.gzz=f.z/h;let g=(t*u.x+n*u.y+r*u.z)/p,_=(t*d.x+n*d.y+r*d.z)/m,v=(t*f.x+n*f.y+r*f.z)/h;e.cpx=g,e.cpy=_,e.cpz=v,e.K=g*g+_*_+v*v-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function nP(e,t,n,r,i,a){let[o,s,c]=r.e,[l,u,d]=r.a,f=1/(l*l),p=1/(u*u),m=1/(d*d),h=f*o.x*o.x+p*s.x*s.x+m*c.x*c.x,g=f*o.x*o.y+p*s.x*s.y+m*c.x*c.y,_=f*o.x*o.z+p*s.x*s.z+m*c.x*c.z,v=f*o.y*o.y+p*s.y*s.y+m*c.y*c.y,y=f*o.y*o.z+p*s.y*s.z+m*c.y*c.z,b=f*o.z*o.z+p*s.z*s.z+m*c.z*c.z,x=h*e+g*t+_*n,S=g*e+v*t+y*n,C=_*e+y*t+b*n,w=e*x+t*S+n*C-1,T=i,E=w*h-x*x,D=2*(w*g-x*S),O=w*v-S*S,k=-2*T*(w*_-x*C),A=-2*T*(w*y-S*C),j=4*E*O-D*D,M=(-2*O*k+D*A)/j,ee=(-2*E*A+D*k)/j,N=-n/T;a.ox=M*N-e,a.oy=ee*N-t}var rP=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Hi;items=[];one=[];labelRect={x:0,left:0,right:0,y:0,h:0};constructor(e){this.anchor=e}get active(){return this.canvas!==null}setVisible(e){if(e){if(this.canvas)return;let e=document.createElement(`canvas`);e.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:5`,this.anchor.parentElement?.appendChild(e),this.canvas=e,this.gfx=e.getContext(`2d`)}else this.canvas&&(this.canvas.remove(),this.canvas=null,this.gfx=null)}draw(e,t,n,r,i,a){let o=this.gfx,s=this.canvas;if(!o||!s)return;let c=window.devicePixelRatio||1,l=Math.round(i*c),u=Math.round(a*c);(s.width!==l||s.height!==u)&&(s.width=l,s.height=u),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,i,a),o.font=`10px monospace`,o.textBaseline=`middle`;let d=t.fov*Math.PI/180,f=a/(2*Math.tan(d/2)),p=t.matrixWorldInverse,[m,h,g]=n,_=i*.5,v=a*.5,y=0;for(let o of e.values()){let{label:e,group:s,radiusScene:c}=o;if(!e||c<=0)continue;let[l,u,d]=o.body.position;this.tmp.set(l-m,u-h,d-g).applyMatrix4(p);let b=this.tmp.x,x=this.tmp.y,S=this.tmp.z;if(S>=0||b*b+x*x+S*S<=c*c)continue;let C=ik(this.items,y++,iP),w=!!(o.semiAxesScene&&o.mesh);if(w){let e=$N(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);C.e0.copy(e.e[0]),C.e1.copy(e.e[1]),C.e2.copy(e.e[2]),C.sa[0]=e.a[0],C.sa[1]=e.a[1],C.sa[2]=e.a[2],tP(C.occ,b,x,S,e,f,_,v,o.body.data.id,o.cachedDist)}else C.e0.set(1,0,0),C.e1.set(0,1,0),C.e2.set(0,0,1),C.sa[0]=C.sa[1]=C.sa[2]=c,eP(C.occ,b,x,S,c,f,_,v,o.body.data.id,o.cachedDist);let T=S*S-c*c,E=T<=0,D=E?0:c*f/Math.sqrt(T),O=E||D>=16;this.tmp.set(l-m,u-h,d-g).project(t),C.cx=(this.tmp.x*.5+.5)*i,C.cy=(-this.tmp.y*.5+.5)*a,gk(o,t,n,i,a,this.labelRect),C.hx=this.labelRect.x,C.hy=this.labelRect.y,C.id=o.body.data.id,C.camX=b,C.camY=x,C.camZ=S,C.worldR=c,C.dist=o.cachedDist,C.isEllipsoid=w,C.degenerate=E,C.isOccluder=O,C.meshHidden=!s.visible,C.labelVisible=e.visible,C.maximized=o.labelMaximized!==!1,C.focused=o.body.data.id===r,C.occludedBy=-1}for(let e=0;e<y;e++){let t=this.items[e];for(let e=0;e<y;e++){let n=this.items[e];if(!(!n.isOccluder||n.id===t.id)&&(this.one[0]=n.occ,this.one.length=1,mk(t.hx,t.hy,t.dist,t.id,this.one))){t.occludedBy=e;break}}}for(let e=0;e<y;e++){let n=this.items[e];if(n.meshHidden&&!n.isOccluder)continue;let r=n.focused?`#7dff7d`:n.isOccluder?`#ff8c1a`:n.labelVisible?n.maximized?`#1ae5ff`:`#ffe11a`:`#ff3b3b`;if(o.beginPath(),n.meshHidden&&o.setLineDash([5,4]),this.strokeLimb(o,n,t,i,a)&&(o.strokeStyle=r,o.lineWidth=n.isOccluder?2:1,o.stroke(),n.isOccluder&&(o.fillStyle=`rgba(255,140,26,0.08)`,o.fill())),o.setLineDash([]),!n.degenerate){let e=n.hx-n.cx,t=n.hy-n.cy;if(e*e+t*t>1&&(o.beginPath(),o.moveTo(n.cx,n.cy),o.lineTo(n.hx,n.hy),o.strokeStyle=`rgba(255,225,26,0.5)`,o.lineWidth=1,o.stroke(),sP(o,n.cx,n.cy,4,`#ff3ad1`)),n.occludedBy>=0){let e=this.items[n.occludedBy];o.beginPath(),o.setLineDash([4,3]),o.moveTo(n.hx,n.hy),o.lineTo(e.cx,e.cy),o.strokeStyle=`rgba(255,59,59,0.9)`,o.lineWidth=1,o.stroke(),o.setLineDash([])}o.beginPath(),o.arc(n.hx,n.hy,1.5,0,Math.PI*2),o.fillStyle=r,o.fill(),o.fillStyle=`rgba(255,255,255,0.85)`,o.fillText(n.id,n.hx+8,n.hy)}}oP(o,a)}strokeLimb(e,t,n,r,i){let{camX:a,camY:o,camZ:s,e0:c,e1:l,e2:u,sa:d}=t,f=(a*c.x+o*c.y+s*c.z)/d[0],p=(a*l.x+o*l.y+s*l.z)/d[1],m=(a*u.x+o*u.y+s*u.z)/d[2],h=f*f+p*p+m*m;if(h<=1)return!1;let g=Math.sqrt(h),_=(h-1)/h,v=Math.sqrt(h-1)/g,y=f*_,b=p*_,x=m*_,S=f/g,C=p/g,w=m/g,T=0,E=1;Math.abs(w)>.9&&(T=1,E=0);let D=C*E-w*0,O=w*T-S*E,k=S*0-C*T,A=Math.hypot(D,O,k)||1;D/=A,O/=A,k/=A;let j=C*k-w*O,M=w*D-S*k,ee=S*O-C*D,N=n.projectionMatrix.elements,te=!1;for(let t=0;t<=72;t++){let n=t/72*Math.PI*2,a=Math.cos(n),o=Math.sin(n),s=y+v*(a*D+o*j),f=b+v*(a*O+o*M),p=x+v*(a*k+o*ee),m=d[0]*s*c.x+d[1]*f*l.x+d[2]*p*u.x,h=d[0]*s*c.y+d[1]*f*l.y+d[2]*p*u.y,g=d[0]*s*c.z+d[1]*f*l.z+d[2]*p*u.z,_=N[3]*m+N[7]*h+N[11]*g+N[15];if(_<=1e-6){te=!1;continue}let S=(N[0]*m+N[4]*h+N[8]*g+N[12])/_,C=(N[1]*m+N[5]*h+N[9]*g+N[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;te?e.lineTo(w,T):(e.moveTo(w,T),te=!0)}return!0}dispose(){this.setVisible(!1)}};function iP(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:ck(),cx:0,cy:0,hx:0,hy:0,dist:0,isEllipsoid:!1,isOccluder:!1,degenerate:!1,meshHidden:!1,labelVisible:!1,maximized:!1,focused:!1,occludedBy:-1}}var aP=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function oP(e,t){let n=t-8-(aP.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of aP)e.fillStyle=t,e.fillRect(8,n-4,8,8),e.fillStyle=`rgba(255,255,255,0.9)`,e.fillText(r,20,n),n+=13}function sP(e,t,n,r,i){e.strokeStyle=i,e.lineWidth=1,e.beginPath(),e.moveTo(t-r,n),e.lineTo(t+r,n),e.moveTo(t,n-r),e.lineTo(t,n+r),e.stroke()}function cP(e){let{fps:t,orbitPool:n,renderer:r,bodyObjects:i,focusedBody:a,cameraDistanceScene:o}=e,s=r.info;return{fps:t,workers:n.workerCount,workerGroups:n.groupCount,drawCalls:s.render.calls,triangles:s.render.triangles,geometries:s.memory.geometries,textures:s.memory.textures,programs:s.programs?.length??0,promotedBodies:i.size,focusedId:a?.data.id,focusedName:a?.data.name??void 0,cameraDistanceAU:o/10,viewportW:r.domElement.clientWidth,viewportH:r.domElement.clientHeight,pixelRatio:r.getPixelRatio()}}var lP="function e(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}function t(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>700)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function n(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}const r=149597870.7,i=23.4392911;86400**2/r**3,1/r,Math.cos(Math.PI/180*i),Math.sin(Math.PI/180*i);const a=Math.PI,o=a*2,s=a/180;180/a;const c=6378.135,l=60/Math.sqrt(c*c*c/398600.8),u=c*l/60,d=1/l,f=.001082616,p=-253881e-11/f,m=2/3,ee=1440/(2*a);function te(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function h(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function g(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return h(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return h(e,t,n,r,i,a,o)}function ne(e,t){let{e3:n,ee2:r,peo:i,pgho:s,pho:c,pinco:l,plo:u,se2:d,se3:f,sgh2:p,sgh3:m,sgh4:ee,sh2:te,sh3:h,si2:g,si3:ne,sl2:_,sl3:v,sl4:y,t:b,xgh2:re,xgh3:ie,xgh4:x,xh2:ae,xh3:S,xi2:C,xi3:w,xl2:T,xl3:E,xl4:D,zmol:O,zmos:k}=e,{init:A,opsmode:j}=t,{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),X=fe+2*.01675*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*Y,ge=p*U+m*W+ee*Y,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),X=fe+2*.0549*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*Y,be=re*U+ie*W+x*Y,xe=ae*U+S*W;return G=pe+_e,J=me+ve,le=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,le-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,se+=K,N+=q,P+=le):(z=Math.sin(N),ce=Math.cos(N),F=R*z,I=R*ce,B=q*ce+J*L*z,V=-q*z+J*L*ce,F+=B,I+=V,N%=o,N<0&&j===`a`&&(N+=o),ue=P+se+L*N,H=le+K-J*N*R,ue+=H,de=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(de-N)>a&&(N<de?N+=o:N-=o),P+=le,se=ue-P-L*N)),{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}}function _(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:s,np:c}=e,l,u,d,f,p,m,ee,te,h,g,ne,_,v,y,b,re,ie,x,ae,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be=.01675,xe=.0549,Se=c,Ce=n,we=Math.sin(s),Te=Math.cos(s),Ee=Math.sin(r),Q=Math.cos(r),De=Math.sin(a),Oe=Math.cos(a),$=Ce*Ce,ke=1-$,Ae=Math.sqrt(ke),je=t+18261.5+i/1440,Me=(4.523602-.00092422029*je)%o,Ne=Math.sin(Me),Pe=Math.cos(Me),Fe=.91375164-.03568096*Pe,Ie=Math.sqrt(1-Fe*Fe),Le=.089683511*Ne/Ie,Re=Math.sqrt(1-Le*Le),ze=5.8351514+.001944368*je,Be=.39785416*Ne/Ie,Ve=Re*Pe+.91744867*Le*Ne;Be=Math.atan2(Be,Ve),Be+=ze-Me;let He=Math.cos(Be),Ue=Math.sin(Be);S=.1945905,C=-.98088458,E=.91744867,D=.39785416,w=Te,T=we,ne=29864797e-13;let We=1/Se,Ge=0;for(;Ge<2;)Ge+=1,l=S*w+C*E*T,d=-C*w+S*E*T,ee=-S*T+C*E*w,te=C*D,h=C*T+S*E*w,g=S*D,u=Oe*ee+De*te,f=Oe*h+De*g,p=-De*ee+Oe*te,m=-De*h+Oe*g,_=l*Q+u*Ee,v=d*Q+f*Ee,y=-l*Ee+u*Q,b=-d*Ee+f*Q,re=p*Ee,ie=m*Ee,x=p*Q,ae=m*Q,_e=12*_*_-3*y*y,ve=24*_*v-6*y*b,ye=12*v*v-3*b*b,ue=3*(l*l+u*u)+_e*$,de=6*(l*d+u*f)+ve*$,X=3*(d*d+f*f)+ye*$,fe=-6*l*p+$*(-24*_*x-6*y*re),pe=-6*(l*m+d*p)+$*(-24*(v*x+_*ae)+-6*(y*ie+b*re)),me=-6*d*m+$*(-24*v*ae-6*b*ie),he=6*u*p+$*(24*_*re-6*y*x),ge=6*(f*p+u*m)+$*(24*(v*re+_*ie)-6*(b*x+y*ae)),Z=6*f*m+$*(24*v*ie-6*b*ae),ue=ue+ue+ke*_e,de=de+de+ke*ve,X=X+X+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,le=v*y+_*b,Y=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=le,N=Y,se=ue,P=de,F=X,I=fe,L=pe,R=me,ce=he,z=ge,B=Z,V=_e,H=ve,U=ye,S=He,C=Ue,E=Fe,D=Ie,w=Re*Te+Le*we,T=we*Re-Te*Le,ne=4.7968065e-7);let Ke=(4.7199672+(.2299715*je-ze))%o,qe=(6.2565837+.017201977*je)%o,Je=2*O*M,Ye=2*O*N,Xe=2*k*L,Ze=2*k*(R-I),Qe=-2*A*P,$e=-2*A*(F-se),et=-2*A*(-21-9*$)*be,tt=2*j*H,nt=2*j*(U-V),rt=-18*j*be,it=-2*k*z,at=-2*k*(B-ce),ot=2*W*le,st=2*W*Y,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*de,dt=-2*K*(X-ue),ft=-2*K*(-21-9*$)*xe,pt=2*q*ve,mt=2*q*(ye-_e),ht=-18*q*xe,gt=-2*G*ge,_t=-2*G*(Z-he);return{snodm:we,cnodm:Te,sinim:De,cosim:Oe,sinomm:Ee,cosomm:Q,day:je,e3:st,ee2:ot,em:Ce,emsq:$,gam:ze,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Ae,se2:Je,se3:Ye,sgh2:tt,sgh3:nt,sgh4:rt,sh2:it,sh3:at,si2:Xe,si3:Ze,sl2:Qe,sl3:$e,sl4:et,s1:W,s2:G,s3:K,s4:q,s5:J,s6:le,s7:Y,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:se,sz2:P,sz3:F,sz11:I,sz12:L,sz13:R,sz21:ce,sz22:z,sz23:B,sz31:V,sz32:H,sz33:U,xgh2:pt,xgh3:mt,xgh4:ht,xh2:gt,xh3:_t,xi2:ct,xi3:lt,xl2:ut,xl3:dt,xl4:ft,nm:Se,z1:ue,z2:de,z3:X,z11:fe,z12:pe,z13:me,z21:he,z22:ge,z23:Z,z31:_e,z32:ve,z33:ye,zmol:Ke,zmos:qe}}function v(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:s,s4:c,s5:u,sinim:d,ss1:f,ss2:p,ss3:ee,ss4:te,ss5:h,sz1:g,sz3:ne,sz11:_,sz13:v,sz21:y,sz23:b,sz31:re,sz33:ie,t:x,tc:ae,gsto:S,mo:C,mdot:w,no:T,nodeo:E,nodedot:D,xpidot:O,z1:k,z3:A,z11:j,z13:oe,z21:M,z23:N,z31:se,z33:P,ecco:F,eccsq:I}=e,{emsq:L,em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}=e,we,Te,Ee,Q,De,Oe,$,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et=.0043752690880113,tt=.00015835218,nt=119459e-10;U=0,V<.0052359877&&V>.0034906585&&(U=1),V>=.00826&&V<=.00924&&R>=.5&&(U=2);let rt=f*nt*h,it=p*nt*(_+v),at=-nt*ee*(g+ne-14-6*L),ot=te*nt*(re+ie-6),st=-nt*p*(y+b);(z<.052359877||z>a-.052359877)&&(st=0),d!==0&&(st/=d);let ct=ot-t*st;pe=rt+r*tt*u,me=it+i*tt*(j+oe),he=at-tt*s*(k+A-14-6*L);let lt=c*tt*(se+P-6),ut=-tt*i*(M+N);(z<.052359877||z>a-.052359877)&&(ut=0),Z=ct+lt,ge=st,d!==0&&(Z-=t/d*ut,ge+=ut/d);let dt=(S+ae*et)%o;if(R+=pe*x,z+=me*x,ce+=Z*x,H+=ge*x,B+=he*x,U!==0){if(Ze=(V/l)**m,U===2){Qe=t*t;let e=R;R=F;let n=L;L=I,$e=R*L,Fe=-.306-(R-.64)*.44,R<=.65?(Ie=3.616-13.247*R+16.29*L,Re=-19.302+117.39*R-228.419*L+156.591*$e,ze=-18.9068+109.7927*R-214.6334*L+146.5816*$e,Be=-41.122+242.694*R-471.094*L+313.953*$e,Ve=-146.407+841.88*R-1629.014*L+1083.435*$e,He=-532.114+3017.977*R-5740.032*L+3708.276*$e):(Ie=-72.099+331.819*R-508.738*L+266.724*$e,Re=-346.844+1582.851*R-2415.925*L+1246.113*$e,ze=-342.585+1554.908*R-2366.899*L+1215.972*$e,Be=-1052.797+4758.686*R-7193.992*L+3651.957*$e,Ve=-3581.69+16178.11*R-24462.77*L+12422.52*$e,He=R>.715?-5149.66+29936.92*R-54087.36*L+31324.56*$e:1464.74-4664.75*R+3763.64*L),R<.7?(Ge=-919.2277+4988.61*R-9064.77*L+5542.21*$e,Ue=-822.71072+4568.6173*R-8491.4146*L+5337.524*$e,We=-853.666+4690.25*R-8624.77*L+5341.4*$e):(Ge=-37995.78+161616.52*R-229838.2*L+109377.94*$e,Ue=-51752.104+218913.95*R-309468.16*L+146349.42*$e,We=-40023.88+170470.89*R-242699.48*L+115605.82*$e),Ke=d*d,we=.75*(1+2*t+Qe),Te=1.5*Ke,Q=1.875*d*(1-2*t-3*Qe),De=-1.875*d*(1+2*t-3*Qe),$=35*Ke*we,ke=39.375*Ke*Ke,Ae=9.84375*d*(Ke*(1-2*t-5*Qe)+.33333333*(-2+4*t+6*Qe)),je=d*(4.92187512*Ke*(-2-4*t+10*Qe)+6.56250012*(1+2*t-3*Qe)),Me=29.53125*d*(2-8*t+Qe*(-12+8*t+10*Qe)),Ne=29.53125*d*(-2-8*t+Qe*(12+8*t-10*Qe)),Ye=V*V,Xe=Ze*Ze,Je=3*Ye*Xe,qe=Je*17891679e-13,G=qe*we*Fe,K=qe*Te*Ie,Je*=Ze,qe=Je*3.7393792e-7,q=qe*Q*Re,J=qe*De*ze,Je*=Ze,qe=2*Je*7.3636953e-9,le=qe*$*Be,Y=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,ue=qe*Ae*He,de=qe*je*We,qe=2*Je*2.1765803e-9,X=qe*Me*Ue,fe=qe*Ne*Ge,xe=(C+E+E-(dt+dt))%o,be=w+he+2*(D+ge-et)-T,R=e,L=n}U===1&&(Pe=1+L*(-2.5+.8125*L),Re=1+2*L,Le=1+L*(-6+6.60937*L),we=.75*(1+t)*(1+t),Ee=.9375*d*d*(1+3*t)-.75*(1+t),Oe=1+t,Oe*=1.875*Oe*Oe,_e=3*V*V*Ze*Ze,ve=2*_e*we*Pe*17891679e-13,ye=3*_e*Oe*Le*2.2123015e-7*Ze,_e=_e*Ee*Re*21460748e-13*Ze,xe=(C+E+n-dt)%o,be=w+O+he+Z+ge-(T+et)),Se=xe,Ce=T,W=0,V=T+0}return{em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dndt:0,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}}function y(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*s/240%o,n<0&&(n+=o),n}function b(e,t,n,r,i,a,o){return e instanceof Date?y(g(e)):y(t===void 0?e:g(e,t,n,r,i,a,o))}function re(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,s=t*t,c=1-s,u=Math.sqrt(c),d=Math.cos(r),p=d*d,ee=(l/a)**m,te=.75*f*(3*p-1)/(u*c),h=te/(ee*ee),g=ee*(1-h*h-h*(1/3+134*h*h/81));h=te/(g*g),a/=1+h;let ne=(l/a)**m,_=Math.sin(r),v=ne*c,y=1-5*p,re=-y-p-p,ie=1/ne,x=v*v,ae=ne*(1-t),S;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+o;S=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%o,S<0&&(S+=o)}else S=b(n+2433281.5);return{no:a,method:`n`,ainv:ie,ao:ne,con41:re,con42:y,cosio:d,cosio2:p,eccsq:s,omeosq:c,posq:x,rp:ae,rteosq:u,sinio:_,gsto:S}}function ie(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:s,d4422:c,d5220:l,d5232:u,d5421:d,d5433:f,dedt:p,del1:m,del2:ee,del3:te,didt:h,dmdt:g,dnodt:ne,domdt:_,argpo:v,argpdot:y,t:b,tc:re,gsto:ie,xfact:x,xlamo:ae,no:S}=e,{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,nm:j}=e,oe=.13130908,M=2.8843198,N=.37448087,se=5.7686396,P=.95240898,F=1.8014998,I=1.050833,L=4.4108898,R=259200,ce,z,B,V,H,U,W,G,K=0,q=0,J=(ie+re*.0043752690880113)%o;if(w+=p*b,E+=h*b,T+=_*b,A+=ne*b,O+=g*b,t!==0){(C===0||b*C<=0||Math.abs(b)<Math.abs(C))&&(C=0,k=S,D=ae),ce=b>0?720:-720;let e=381;for(;e===381;)t===2?(G=v+y*C,B=G+G,z=D+D,W=n*Math.sin(B+D-se)+r*Math.sin(D-se)+i*Math.sin(G+D-P)+a*Math.sin(-G+D-P)+s*Math.sin(B+z-F)+c*Math.sin(z-F)+l*Math.sin(G+D-I)+u*Math.sin(-G+D-I)+d*Math.sin(G+z-L)+f*Math.sin(-G+z-L),H=k+x,U=n*Math.cos(B+D-se)+r*Math.cos(D-se)+i*Math.cos(G+D-P)+a*Math.cos(-G+D-P)+l*Math.cos(G+D-I)+u*Math.cos(-G+D-I)+2*(s*Math.cos(B+z-F)+c*Math.cos(z-F)+d*Math.cos(G+z-L)+f*Math.cos(-G+z-L)),U*=H):(W=m*Math.sin(D-oe)+ee*Math.sin(2*(D-M))+te*Math.sin(3*(D-N)),H=k+x,U=m*Math.cos(D-oe)+2*ee*Math.cos(2*(D-M))+3*te*Math.cos(3*(D-N)),U*=H),Math.abs(b-C)>=720?e=381:(q=b-C,e=0),e===381&&(D+=H*ce+W*R,k+=W*ce+U*R,C+=ce);j=k+W*q+U*q*q*.5,V=D+H*q+W*q*q*.5,t===1?(O=V-A-T+J,K=j-S):(O=V-2*A+2*J,K=j-S),j=S+K}return{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,dndt:K,nm:j}}var x;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})(x||={});function ae(e,t){let n,r,i,s,d,ee,te,h,g,_,v,y,b,re,ae,S,C,w,T,E,D,O,k,A,j,oe,M;e.t=t,e.error=x.None;let N=e.mo+e.mdot*e.t,se=e.argpo+e.argpdot*e.t,P=e.nodeo+e.nodedot*e.t;g=se,D=N;let F=e.t*e.t;if(k=P+e.nodecf*F,C=1-e.cc1*e.t,w=e.bstar*e.cc4*e.t,T=e.t2cof*F,e.isimp!==1){te=e.omgcof*e.t;let t=1+e.eta*Math.cos(N);ee=e.xmcof*(t*t*t-e.delmo),S=te+ee,D=N+S,g=se-S,y=F*e.t,b=y*e.t,C=C-e.d2*F-e.d3*y-e.d4*b,w+=e.bstar*e.cc5*(Math.sin(D)-e.sinmao),T=T+e.t3cof*y+b*(e.t4cof+e.t*e.t5cof)}O=e.no;let I=e.ecco;if(E=e.inclo,e.method===`d`){re=e.t;let t=ie({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:re,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:I,argpm:g,inclm:E,xli:e.xli,mm:D,xni:e.xni,nodem:k,nm:O});({em:I,argpm:g,inclm:E,mm:D,nodem:k,nm:O}=t)}if(O<=0)return e.error=x.MeanMotionBelowZero,null;let L=(l/O)**m*C*C;if(O=l/L**1.5,I-=w,I>=1||I<-.001)return e.error=x.MeanEccentricityOutOfRange,null;I<1e-6&&(I=1e-6),D+=e.no*T,j=D+g+k,k%=o,g%=o,j%=o,D=(j-g-k)%o;let R={am:L,em:I,im:E,Om:k,om:g,mm:D,nm:O},ce=Math.sin(E),z=Math.cos(E),B=I;if(A=E,_=g,M=k,oe=D,s=ce,i=z,e.method===`d`){let t=ne(e,{inclo:e.inclo,init:`n`,ep:B,inclp:A,nodep:M,argpp:_,mp:oe,opsmode:e.operationmode});if({ep:B,nodep:M,argpp:_,mp:oe}=t,A=t.inclp,A<0&&(A=-A,M+=a,_-=a),B<0||B>1)return e.error=x.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(s=Math.sin(A),i=Math.cos(A),e.aycof=-.5*p*s,Math.abs(i+1)>15e-13?e.xlcof=-.25*p*s*(3+5*i)/(1+i):e.xlcof=-.25*p*s*(3+5*i)/15e-13);let V=B*Math.cos(_);S=1/(L*(1-B*B));let H=B*Math.sin(_)+S*e.aycof,U=(oe+_+M+S*e.xlcof*V-M)%o;h=U,ae=9999.9;let W=1;for(;Math.abs(ae)>=1e-12&&W<=10;)r=Math.sin(h),n=Math.cos(h),ae=1-n*V-r*H,ae=(U-H*n+V*r-h)/ae,Math.abs(ae)>=.95&&(ae=ae>0?.95:-.95),h+=ae,W+=1;let G=V*n+H*r,K=V*r-H*n,q=V*V+H*H,J=L*(1-q);if(J<0)return e.error=x.SemiLatusRectumBelowZero,null;let le=L*(1-G),Y=Math.sqrt(L)*K/le,ue=Math.sqrt(J)/le,de=Math.sqrt(1-q);S=K/(1+de);let X=L/le*(r-H-V*S),fe=L/le*(n-V+H*S);v=Math.atan2(X,fe);let pe=(fe+fe)*X,me=1-2*X*X;S=1/J;let he=.5*f*S,ge=he*S;e.method===`d`&&(d=i*i,e.con41=3*d-1,e.x1mth2=1-d,e.x7thm1=7*d-1);let Z=le*(1-1.5*ge*de*e.con41)+.5*he*e.x1mth2*me;if(Z<1)return e.error=x.Decayed,null;v-=.25*ge*e.x7thm1*pe;let _e=M+1.5*ge*i*pe,ve=A+1.5*ge*i*s*me,ye=Y-O*he*e.x1mth2*pe/l,be=ue+O*he*(e.x1mth2*me+1.5*e.con41)/l,xe=Math.sin(v),Se=Math.cos(v),Ce=Math.sin(_e),we=Math.cos(_e),Te=Math.sin(ve),Ee=Math.cos(ve),Q=-Ce*Ee,De=we*Ee,Oe=Q*xe+we*Se,$=De*xe+Ce*Se,ke=Te*xe,Ae=Q*Se-we*xe,je=De*Se-Ce*xe,Me=Te*Se;return{position:{x:Z*Oe*c,y:Z*$*c,z:Z*ke*c},velocity:{x:(ye*Oe+be*Ae)*u,y:(ye*$+be*je)*u,z:(ye*ke+be*Me)*u},meanElements:R}}function S(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:o,xecco:s,xargpo:l,xinclo:u,xmo:ee,xno:te,xnodeo:h}=t,g,y,b,ie,x,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,Q=e;Q.isimp=0,Q.method=`n`,Q.aycof=0,Q.con41=0,Q.cc1=0,Q.cc4=0,Q.cc5=0,Q.d2=0,Q.d3=0,Q.d4=0,Q.delmo=0,Q.eta=0,Q.argpdot=0,Q.omgcof=0,Q.sinmao=0,Q.t=0,Q.t2cof=0,Q.t3cof=0,Q.t4cof=0,Q.t5cof=0,Q.x1mth2=0,Q.x7thm1=0,Q.mdot=0,Q.nodedot=0,Q.xlcof=0,Q.xmcof=0,Q.nodecf=0,Q.irez=0,Q.d2201=0,Q.d2211=0,Q.d3210=0,Q.d3222=0,Q.d4410=0,Q.d4422=0,Q.d5220=0,Q.d5232=0,Q.d5421=0,Q.d5433=0,Q.dedt=0,Q.del1=0,Q.del2=0,Q.del3=0,Q.didt=0,Q.dmdt=0,Q.dnodt=0,Q.domdt=0,Q.e3=0,Q.ee2=0,Q.peo=0,Q.pgho=0,Q.pho=0,Q.pinco=0,Q.plo=0,Q.se2=0,Q.se3=0,Q.sgh2=0,Q.sgh3=0,Q.sgh4=0,Q.sh2=0,Q.sh3=0,Q.si2=0,Q.si3=0,Q.sl2=0,Q.sl3=0,Q.sl4=0,Q.gsto=0,Q.xfact=0,Q.xgh2=0,Q.xgh3=0,Q.xgh4=0,Q.xh2=0,Q.xh3=0,Q.xi2=0,Q.xi3=0,Q.xl2=0,Q.xl3=0,Q.xl4=0,Q.xlamo=0,Q.zmol=0,Q.zmos=0,Q.atime=0,Q.xli=0,Q.xni=0,Q.bstar=o,Q.ecco=s,Q.argpo=l,Q.inclo=u,Q.mo=ee,Q.no=te,Q.nodeo=h,Q.operationmode=n,78/c+1;let De=42/c;De*De*De*De,Q.init=`y`,Q.t=0;let Oe=re({satn:r,ecco:Q.ecco,epoch:i,inclo:Q.inclo,no:Q.no,method:Q.method,opsmode:Q.operationmode}),{ao:$,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=Oe;if(Q.no=Oe.no,Q.con41=Oe.con41,Q.gsto=Oe.gsto,Q.a=(Q.no*d)**(-2/3),Q.alta=Q.a*(1+Q.ecco)-1,Q.altp=Q.a*(1-Q.ecco)-1,Q.error=0,Ne>=0||Q.no>=0){if(Q.isimp=0,Fe<1.034492841559484&&(Q.isimp=1),B=1.0122292801892716,F=1.880279159015271e-9,N=(Fe-1)*c,N<156){B=N-78,N<98&&(B=20);let e=(120-B)/c;F=e*e*e*e,B=B/c+1}se=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,P=Math.abs(1-O),S=F*Z**4,C=S/P**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/P*Q.con41*(8+3*O*(8+O))),Q.cc1=Q.bstar*ie,x=0,Q.ecco>1e-4&&(x=-2*S*Z*p*Q.no*Le/Q.ecco),Q.x1mth2=1-je,Q.cc4=2*Q.no*C*$*Ne*(Q.eta*(2+.5*O)+Q.ecco*(.5+2*O)-f*Z/($*P)*(-3*Q.con41*(1-2*D+O*(1.5-.5*D))+.75*Q.x1mth2*(2*O-D*(1+O))*Math.cos(2*Q.argpo))),Q.cc5=2*C*$*Ne*(1+2.75*(O+D)+D*O),w=je*je,me=1.5*f*se*Q.no,he=.5*me*f*se,ge=-.46875*-165597e-11*se*se*Q.no,Q.mdot=Q.no+.5*me*Ie*Q.con41+.0625*he*Ie*(13-78*je+137*w),Q.argpdot=-.5*me*ke+.0625*he*(7-114*je+395*w)+ge*(3-36*je+49*w),ve=-me*Ae,Q.nodedot=ve+(.5*he*(4-19*je)+2*ge*(3-7*je))*Ae,_e=Q.argpdot+Q.nodedot,Q.omgcof=Q.bstar*x*Math.cos(Q.argpo),Q.xmcof=0,Q.ecco>1e-4&&(Q.xmcof=-m*S*Q.bstar/D),Q.nodecf=3.5*Ne*ve*Q.cc1,Q.t2cof=1.5*Q.cc1,Math.abs(Ae+1)>15e-13?Q.xlcof=-.25*p*Le*(3+5*Ae)/(1+Ae):Q.xlcof=-.25*p*Le*(3+5*Ae)/15e-13,Q.aycof=-.5*p*Le;let e=1+Q.eta*Math.cos(Q.mo);if(Q.delmo=e*e*e,Q.sinmao=Math.sin(Q.mo),Q.x7thm1=7*je-1,2*a/Q.no>=225){Q.method=`d`,Q.isimp=1,fe=0,j=Q.inclo;let e=_({epoch:i,ep:Q.ecco,argpp:Q.argpo,tc:fe,inclp:Q.inclo,nodep:Q.nodeo,np:Q.no,e3:Q.e3,ee2:Q.ee2,peo:Q.peo,pgho:Q.pgho,pho:Q.pho,pinco:Q.pinco,plo:Q.plo,se2:Q.se2,se3:Q.se3,sgh2:Q.sgh2,sgh3:Q.sgh3,sgh4:Q.sgh4,sh2:Q.sh2,sh3:Q.sh3,si2:Q.si2,si3:Q.si3,sl2:Q.sl2,sl3:Q.sl3,sl4:Q.sl4,xgh2:Q.xgh2,xgh3:Q.xgh3,xgh4:Q.xgh4,xh2:Q.xh2,xh3:Q.xh3,xi2:Q.xi2,xi3:Q.xi3,xl2:Q.xl2,xl3:Q.xl3,xl4:Q.xl4,zmol:Q.zmol,zmos:Q.zmos});Q.e3=e.e3,Q.ee2=e.ee2,Q.peo=e.peo,Q.pgho=e.pgho,Q.pho=e.pho,Q.pinco=e.pinco,Q.plo=e.plo,Q.se2=e.se2,Q.se3=e.se3,Q.sgh2=e.sgh2,Q.sgh3=e.sgh3,Q.sgh4=e.sgh4,Q.sh2=e.sh2,Q.sh3=e.sh3,Q.si2=e.si2,Q.si3=e.si3,Q.sl2=e.sl2,Q.sl3=e.sl3,Q.sl4=e.sl4,{sinim:y,cosim:g,em:T,emsq:E,s1:I,s2:L,s3:R,s4:ce,s5:z,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X}=e,Q.xgh2=e.xgh2,Q.xgh3=e.xgh3,Q.xgh4=e.xgh4,Q.xh2=e.xh2,Q.xh3=e.xh3,Q.xi2=e.xi2,Q.xi3=e.xi3,Q.xl2=e.xl2,Q.xl3=e.xl3,Q.xl4=e.xl4,Q.zmol=e.zmol,Q.zmos=e.zmos,{nm:M,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee}=e;let t=ne(Q,{inclo:j,init:Q.init,ep:Q.ecco,inclp:Q.inclo,nodep:Q.nodeo,argpp:Q.argpo,mp:Q.mo,opsmode:Q.operationmode});Q.ecco=t.ep,Q.inclo=t.inclp,Q.nodeo=t.nodep,Q.argpo=t.argpp,Q.mo=t.mp,k=0,A=0,oe=0;let n=v({cosim:g,emsq:E,argpo:Q.argpo,s1:I,s2:L,s3:R,s4:ce,s5:z,sinim:y,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X,t:Q.t,tc:fe,gsto:Q.gsto,mo:Q.mo,mdot:Q.mdot,no:Q.no,nodeo:Q.nodeo,nodedot:Q.nodedot,xpidot:_e,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee,ecco:Q.ecco,eccsq:Me,em:T,argpm:k,inclm:j,mm:oe,nm:M,nodem:A,irez:Q.irez,atime:Q.atime,d2201:Q.d2201,d2211:Q.d2211,d3210:Q.d3210,d3222:Q.d3222,d4410:Q.d4410,d4422:Q.d4422,d5220:Q.d5220,d5232:Q.d5232,d5421:Q.d5421,d5433:Q.d5433,dedt:Q.dedt,didt:Q.didt,dmdt:Q.dmdt,dnodt:Q.dnodt,domdt:Q.domdt,del1:Q.del1,del2:Q.del2,del3:Q.del3,xfact:Q.xfact,xlamo:Q.xlamo,xli:Q.xli,xni:Q.xni});Q.irez=n.irez,Q.atime=n.atime,Q.d2201=n.d2201,Q.d2211=n.d2211,Q.d3210=n.d3210,Q.d3222=n.d3222,Q.d4410=n.d4410,Q.d4422=n.d4422,Q.d5220=n.d5220,Q.d5232=n.d5232,Q.d5421=n.d5421,Q.d5433=n.d5433,Q.dedt=n.dedt,Q.didt=n.didt,Q.dmdt=n.dmdt,Q.dnodt=n.dnodt,Q.domdt=n.domdt,Q.del1=n.del1,Q.del2=n.del2,Q.del3=n.del3,Q.xfact=n.xfact,Q.xlamo=n.xlamo,Q.xli=n.xli,Q.xni=n.xni}Q.isimp!==1&&(b=Q.cc1*Q.cc1,Q.d2=4*$*Z*b,pe=Q.d2*Z*Q.cc1/3,Q.d3=(17*$+B)*pe,Q.d4=.5*pe*$*Z*(221*$+31*B)*Q.cc1,Q.t3cof=Q.d2+2*b,Q.t4cof=.25*(3*Q.d3+Q.cc1*(12*Q.d2+10*b)),Q.t5cof=.2*(3*Q.d4+12*Q.cc1*Q.d3+6*Q.d2*Q.d2+15*b*(2*Q.d2+b)))}ae(Q,0),Q.init=`n`}function C(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,c=Number(e.MEAN_MOTION_DOT),l=Number(e.MEAN_MOTION_DDOT);c/=ee*1440,l/=ee*1440*1440;let u=Number(e.BSTAR),d=Number(e.INCLINATION)*s,f=Number(e.RA_OF_ASC_NODE)*s,p=Number(e.ECCENTRICITY),m=Number(e.ARG_OF_PERICENTER)*s,h=Number(e.MEAN_ANOMALY)*s,ne=Number(e.MEAN_MOTION)/ee,{mon:_,day:v,hr:y,minute:b,sec:re}=te(i,o),ie=g(i,_,v,y,b,re),x={error:0,satnum:n,epochyr:a,epochdays:o,ndot:c,nddot:l,bstar:u,inclo:d,nodeo:f,ecco:p,argpo:m,mo:h,no:ne,jdsatepoch:ie};return S(x,{opsmode:t,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}3*Float64Array.BYTES_PER_ELEMENT;const w=Math.PI/180;Math.cos(i*w),Math.sin(i*w);function T(e){return new Date((e-2440587.5)*864e5).toISOString()}function E(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:T(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===x.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}const D=Math.PI/180,O=Math.cos(i*D),k=Math.sin(i*D),A=10/r;function j(e,t,n,r,i){return!isFinite(Math.fround(n))||!isFinite(Math.fround(r))||!isFinite(Math.fround(i))?!1:(e[t*3]=n,e[t*3+1]=r,e[t*3+2]=i,!0)}function oe(r,i,a,o,s,c,l,u,d,f=null,p=0){if(i<r.validityStart||i>r.validityEnd)return 0;let{count:m,kind:ee,equatorial:te,a:h,e:g,i:ne,om:_,w:v,ma:y,n:b,epoch:re,q:ie,tp:S,satrec:C,flags:w,visibleFromDays:T}=r,oe=p!==0&&r.applyFlagFilter,M=r.pickBase,N=d.length/3|0,se=i-2451545,P=0;for(let F=0;F<m&&!(P>=N);F++){let m=ee[F];if(m===0||T[F]>se||oe&&(w[F]&p)!==p)continue;if(m===3){let e=C[F];if(!e){if(e=E({noradCatId:r.satnum[F],epochJd:re[F],meanMotion:b[F]/360,eccentricity:g[F],inclination:ne[F],raOfAscNode:_[F],argOfPericenter:v[F],meanAnomaly:y[F],bstar:r.bstar[F],meanMotionDot:r.ndot[F],meanMotionDdot:r.nddot[F],elementSetNo:0,revAtEpoch:0}),!e){ee[F]=0;continue}C[F]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x,m=n.position.y,te=n.position.z,h=p*A,ie=m*A,S=te*A,w=ie*O+S*k,T=-ie*k+S*O,D=h,oe=T,N=-w;if(!j(d,P,a+D-c,o+oe-l,s+N-u))continue;if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++;continue}let N,I,L=g[F],R=ne[F],ce=_[F],z=v[F];if(m===2){let e=n(ie[F],S[F],i);if(!e)continue;N=e.r*Math.cos(e.nu),I=e.r*Math.sin(e.nu)}else{let n=h[F];if(!isFinite(n)||!isFinite(L)||!isFinite(y[F])||!isFinite(b[F]))continue;let r=i-re[F],a=(y[F]+b[F]*r)*D,o,s;if(L<1||n>0){let t=Math.min(L,.9999999),r=e(a,t),i=Math.sqrt(1-t*t)*Math.sin(r)/(1-t*Math.cos(r)),c=(Math.cos(r)-t)/(1-t*Math.cos(r));o=Math.atan2(i,c),s=n*(1-t*Math.cos(r))}else{let e=t(a,L);if(!isFinite(e))continue;let r=L*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(L*L-1)*Math.sinh(e)/r,c=(L-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-L*Math.cosh(e))}N=s*Math.cos(o),I=s*Math.sin(o)}if(!isFinite(N)||!isFinite(I))continue;let B=Math.cos(z*D),V=Math.sin(z*D),H=Math.cos(R*D),U=Math.sin(R*D),W=Math.cos(ce*D),G=Math.sin(ce*D),K=(W*B-G*V*H)*N+(-W*V-G*B*H)*I,q=(G*B+W*V*H)*N+(-G*V+W*B*H)*I,J=V*U*N+B*U*I;if(te[F]){let e=q*O+J*k,t=-q*k+J*O;q=e,J=t}let le=K*10,Y=J*10,ue=-q*10;if(j(d,P,a+le-c,o+Y-l,s+ue-u)){if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++}}return P}const M=new Map;self.onmessage=e=>{let t=e.data;if(t.type===`ping`){self.postMessage({type:`pong`});return}if(t.type===`rewireDelta`){if(t.remove)for(let e of t.remove)M.delete(e);for(let e of t.set)M.set(e.id,e.cols);return}if(t.type===`tick`){let e=[],n=[],[r,i,a]=t.basis;for(let o of t.groups){let s=M.get(o.id);if(!s){e.push({id:o.id,count:0,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer);continue}let c=oe(s,t.jd,o.parent[0],o.parent[1],o.parent[2],r,i,a,o.out,o.outIds,t.requiredFlags??0);e.push({id:o.id,count:c,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer)}self.postMessage({type:`tickResult`,groups:e},n);return}};\n//# sourceMappingURL=worker-CK5Z1yOu.js.map",uP=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,lP],{type:`text/javascript;charset=utf-8`});function dP(e){let t;try{if(t=uP&&(self.URL||self.webkitURL).createObjectURL(uP),!t)throw``;let n=new Worker(t,{type:`module`,name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(lP),{type:`module`,name:e?.name})}}var fP=class{workers=[];groups=new Map;onResult=null;size;pendingPing=null;generation=0;constructor(e=navigator.hardwareConcurrency??4){this.size=Math.max(2,Math.min(8,e)),this.spawn()}spawn(){for(let e=0;e<this.size;e++){let e=new dP;e.onmessage=e=>this.onMessage(e.data),this.workers.push(e)}}ping(e=800){if(this.workers.length===0)return Promise.resolve(!1);if(this.pendingPing)return this.pendingPing.promise;let t,n=new Promise(e=>t=e),r={need:this.workers.length,got:0,promise:n,resolve:e=>{this.pendingPing===r&&(this.pendingPing=null,t(e))}};this.pendingPing=r,setTimeout(()=>r.resolve(!1),e);for(let e of this.workers)e.postMessage({type:`ping`});return n}respawn(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers=[],this.groups.clear(),this.generation++,this.spawn()}get poolGeneration(){return this.generation}setResultHandler(e){this.onResult=e}get workerCount(){return this.workers.length}get groupCount(){return this.groups.size}async rewireOne(e,t,n,r,i=!1,a=0){if(t.length===0){this.unwireOne(e);return}let o=await Bg(t,n,i);o.pickBase=a,this.workers.length!==0&&this.wireCols(e,o,r,t.length)}rewireOneCols(e,t,n){if(this.workers.length!==0){if(t.count===0){this.unwireOne(e);return}this.wireCols(e,t,n,t.count)}}wireCols(e,t,n,r){let i=this.groups.get(e),a=i?.workerIdx??n%this.workers.length,o,s,c,l;if(i&&i.capacity===r)o=i.front,s=i.back,c=i.idFront,l=i.idBack;else if(o=new Float32Array(r*3),s=new Float32Array(r*3),c=new Uint8Array(r*4),l=new Uint8Array(r*4),i){let e=Math.min(i.front.length,o.length);o.set(i.front.subarray(0,e));let t=Math.min(i.idFront.length,c.length);c.set(i.idFront.subarray(0,t))}let u=!!i&&i.back===null;this.groups.set(e,{workerIdx:a,capacity:r,front:o,back:s,idFront:c,idBack:l,count:i?.count??r,pendingBasis:u?i.pendingBasis:null,pendingParent:u?i.pendingParent:null,pendingJd:u?i.pendingJd:null,frontBasis:i?.frontBasis??[0,0,0],frontParent:i?.frontParent??[0,0,0],frontJd:i?.frontJd??NaN}),this.workers[a].postMessage({type:`rewireDelta`,set:[{id:e,cols:t}]},Hg(t))}unwireOne(e){let t=this.groups.get(e);t&&(this.groups.delete(e),this.workers[t.workerIdx].postMessage({type:`rewireDelta`,set:[],remove:[e]}))}tick(e,t,n,r=0){let i=this.workers.map(()=>[]);for(let[r,a]of this.groups){if(!a.back||!a.idBack)continue;let o=n.get(r);o&&(i[a.workerIdx].push({id:r,parent:[o[0],o[1],o[2]],out:a.back,outIds:a.idBack}),a.back=null,a.idBack=null,a.pendingBasis=[t[0],t[1],t[2]],a.pendingParent=[o[0],o[1],o[2]],a.pendingJd=e)}for(let n=0;n<this.workers.length;n++){let a=i[n];if(a.length===0)continue;let o=a.flatMap(e=>[e.out.buffer,e.outIds.buffer]);this.workers[n].postMessage({type:`tick`,jd:e,basis:[t[0],t[1],t[2]],requiredFlags:r,groups:a},o)}}onMessage(e){if(e.type===`pong`){let e=this.pendingPing;e&&++e.got>=e.need&&e.resolve(!0);return}if(e.type===`tickResult`)for(let t of e.groups){let e=this.groups.get(t.id);if(!e)continue;let n=new Float32Array(t.buf),r=e.front;e.front=n,e.back=r;let i=new Uint8Array(t.idbuf),a=e.idFront;e.idFront=i,e.idBack=a,e.count=t.count;let o=e.pendingBasis??e.frontBasis,s=e.pendingParent??e.frontParent,c=e.pendingJd??e.frontJd;e.frontBasis=o,e.frontParent=s,e.frontJd=c,e.pendingBasis=null,e.pendingParent=null,e.pendingJd=null,this.onResult?.(t.id,n,t.count,o,s,c,i)}}destroy(){this.pendingPing?.resolve(!1);for(let e of this.workers)e.terminate();this.workers.length=0,this.groups.clear()}},pP=class{#e=1;#t=new Map;allocate(e,t){let n=this.#e;return this.#e+=t.length,this.#t.set(e,{base:n,keys:t}),n}release(e){this.#t.delete(e)}resolve(e){if(e===0)return null;for(let{base:t,keys:n}of this.#t.values())if(e>=t&&e<t+n.length)return _h(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},mP=.01,hP=[`asteroid`,`spacecraft`],gP=.0002959122082855911,_P=.75,vP=Q(8*86400);function yP(e){let t=0,n=!1;for(let r=0;r<e.count;r++){if(e.kind[r]===0)continue;let i=e.a[r],a=e.e[r];if(e.kind[r]!==1||!(i>0)||!(a<1)||!isFinite(i)||!isFinite(a)){n=!0;continue}let o=Math.min(a,.9999999),s=Math.sqrt(gP/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function bP(e){return e<0?0:e>1?1:e}function xP(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function SP(e){return e===null?{tBright:0,tSize:0}:{tBright:bP((CP-e)/(CP-wP)),tSize:bP((TP-e)/(TP-EP))}}var CP=1e4,wP=500,TP=wP,EP=50,DP=4,OP=.5,kP=10,AP=1,jP=1,MP=3.5,NP=2.5,PP=2,FP=MP,IP=class{orbitPool=new fP;pickRegistry=new pP;disposed=!1;workerPoints={asteroid:new Map,spacecraft:new Map};moonPoints=new Map;pointBudget=1/0;drawFraction=1;pendingSceneAdds=[];basisPos=[0,0,0];parentAtUpdate=new Map;_parentsScratch=new Map;moonsByParentCache=null;lastPackedSize=new Map;groupKinematics=new Map;lastSolvedJd=new Map;earthSatEmphasis={size:DP,dim:OP,opacity:jP};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:jP};constructor(e,t,n,r,i,a,o){this.ctx=e,this.scene=t,this.bodyObjects=n,this.circleTexture=r,this.focus=i,this.mapLayer=a,this.onBasisRebuilt=o,this.orbitPool.setResultHandler(this.onPoolResult)}basis(){return this.basisPos}setPointBudget(e){this.pointBudget=e,this.applyPointBudget()}applyPointBudget(){let e=0;for(let t of hP)for(let n of this.workerPoints[t].values())n.visible&&(e+=n.userData.solvedCount??0);let t=e>this.pointBudget?this.pointBudget/e:1;if(t!==this.drawFraction){this.drawFraction=t;for(let e of hP)for(let n of this.workerPoints[e].values()){let e=n.userData.solvedCount;e!==void 0&&n.geometry.setDrawRange(0,Math.ceil(e*t))}}}setEarthSatEmphasis(e){this.earthSatEmphasis=this.computeEarthSatEmphasis(e);for(let[e,t]of this.workerPoints.spacecraft)S_(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=SP(e);return{size:DP+(kP-DP)*n,dim:OP+(AP-OP)*t,opacity:jP+(MP-jP)*t}}applyEarthSatEmphasis(e){let t=e.material,{size:n,dim:r,opacity:i}=this.earthSatEmphasis;t.size=n,t.color.setRGB(r,r,r),t.opacity=i}setEmphasizedSmallBodyZone(e,t){let n=this.emphasizedSmallBodyZone;if(this.emphasizedSmallBodyZone=e,this.smallBodyEmphasis=this.computeSmallBodyEmphasis(e===null?null:t),n!==null&&n!==e)for(let[e,t]of this.workerPoints.asteroid)xP(S_(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)xP(S_(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=SP(e);return{sizeMult:1+(NP-1)*n,brightMult:1+(PP-1)*t,opacity:jP+(FP-jP)*t}}applySmallBodyEmphasis(e){let t=e.material;e.userData.smallBodyBaseSize===void 0&&(e.userData.smallBodyBaseSize=t.size,e.userData.smallBodyBaseColor=t.color.clone());let n=e.userData.smallBodyBaseSize,r=e.userData.smallBodyBaseColor,{sizeMult:i,brightMult:a,opacity:o}=this.smallBodyEmphasis;t.size=n*i,t.color.copy(r).multiplyScalar(a),t.opacity=o}resetSmallBodyEmphasis(e){if(e.userData.smallBodyBaseSize===void 0)return;let t=e.material;t.size=e.userData.smallBodyBaseSize,t.color.copy(e.userData.smallBodyBaseColor),t.opacity=jP,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=TN(this.ctx,this.scene,this.circleTexture,this.basisPos,e,this.orbitPool.workerCount);this.workerPoints.asteroid=t.asteroidPoints,this.workerPoints.spacecraft=t.spacecraftPoints,this.moonPoints=t.moonPoints;for(let e of hP)for(let[t,n]of this.workerPoints[e]){let r=S_(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of hP)for(let t of this.workerPoints[e].values())t.layers.set(this.mapLayer);for(let e of this.moonPoints.values())e.layers.set(this.mapLayer)}cloudParentId(e,t){return e===`asteroid`?f_:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&xP(t,r)&&this.applySmallBodyEmphasis(n)}rebuildRunning=!1;rebuildQueued=!1;rebuildMinor(){if(this.rebuildRunning){this.rebuildQueued=!0;return}this.rebuildRunning=!0,(async()=>{try{do this.rebuildQueued=!1,await this.rebuildMinorPass();while(this.rebuildQueued)}finally{this.rebuildRunning=!1}})()}recovering=null;recoverWorkersIfDead(e){return this.recovering??=this.runRecovery(e).finally(()=>this.recovering=null),this.recovering}async runRecovery(e){if(await this.orbitPool.ping(e))return!1;this.orbitPool.respawn();for(let e of this.ctx.bodies.asteroidBodiesByZone.keys())this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);return this.lastPackedSize.clear(),this.rebuildMinor(),!0}async rebuildMinorPass(){if(this.disposed||this.ctx.bodies.dirtyAsteroidZones.size===0&&this.ctx.bodies.dirtySpacecraftGroups.size===0)return;let e=[this.basisPos[0],this.basisPos[1],this.basisPos[2]],t=this.orbitPool.workerCount,n=this.orbitPool.poolGeneration,r=[],i=[];for(let n of[...this.ctx.bodies.dirtyAsteroidZones]){let i=this.ctx.bodies.asteroidBodiesByZone.get(n);if(this.deferPackWhileStreaming(`asteroid:${n}`,i?.size??0))continue;this.ctx.bodies.dirtyAsteroidZones.delete(n),r.push(n);let a=yh(this.bodyObjects.keys()),{groups:o,baseWorker:s}=i?await i.buildWorkerGroups(n,t,a,!1):{groups:[],baseWorker:0};if(this.disposed)return;let c=i&&o.length>0?i.cloudColor():`#888888`;for(let r=0;r<t;r++){let i=`${n}#${r}`,a=`asteroid:${i}`,l=r<o.length?o[r]:null;if(!l||l.cols.count===0){this.unwireGroup(`asteroid`,i,a);continue}this.armGroupGate(a,yP(l.cols)),l.cols.pickBase=this.pickRegistry.allocate(a,l.keys),this.orbitPool.rewireOneCols(a,l.cols,(s+r)%t);let u=this.workerPoints.asteroid.get(i);if(u){this.resizeGeometryToCount(u.geometry,l.cols.count,null);continue}let d=rN(new Float32Array(l.cols.count*3),0,this.circleTexture,c,tN());this.adoptCloud(`asteroid`,i,a,d,e)}}for(let n of[...this.ctx.bodies.dirtySpacecraftGroups]){let r=this.ctx.bodies.spacecraftByParent.get(n);if(this.deferPackWhileStreaming(`spacecraft:${n}`,r?.size??0))continue;this.ctx.bodies.dirtySpacecraftGroups.delete(n),i.push(n);let{buckets:a,baseWorker:o}=await x_(n,wv(this.ctx.layers,n,r?Array.from(r.values()):[]),t);if(this.disposed)return;let s=new Set(this.bodyObjects.keys());for(let r=0;r<t;r++){let i=`${n}#${r}`,c=`spacecraft:${i}`,l=r<a.length?a[r]:[];if(l.length===0){this.unwireGroup(`spacecraft`,i,c);continue}let u=this.pickRegistry.allocate(c,Float64Array.from(l,e=>vh(e.data.id)??fh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:vP,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3),p=new Float32Array(l.length*3);this.seedGeometryArray(f,l,p);let m=rN(f,l.length,this.circleTexture,`#ffffff`,void 0,p);this.adoptCloud(`spacecraft`,i,c,m,e)}}if(this.orbitPool.poolGeneration!==n){for(let e of r)this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of i)this.ctx.bodies.dirtySpacecraftGroups.add(e);this.lastPackedSize.clear(),this.rebuildQueued=!0}}unwireGroup(e,t,n){this.orbitPool.unwireOne(n),this.forgetGroupGate(n),this.pickRegistry.release(n);let r=this.workerPoints[e].get(t);r&&(this.scene.remove(r),this.workerPoints[e].delete(t))}armGroupGate(e,t){this.groupKinematics.set(e,t),this.lastSolvedJd.delete(e)}adoptCloud(e,t,n,r,i){let a=S_(t);r.userData.frontBasis=i,r.userData.groupId=n,r.userData.parentBodyId=this.cloudParentId(e,a),r.userData.parentVec=[0,0,0],this.emphasiseNewCloud(e,a,r),this.workerPoints[e].set(t,r),this.pendingSceneAdds.push(r)}deferPackWhileStreaming(e,t){if(!this.ctx.bodies.minorStreaming)return this.lastPackedSize.set(e,t),!1;let n=this.lastPackedSize.get(e);return n!==void 0&&t>n&&t<n*2?!0:(this.lastPackedSize.set(e,t),!1)}seedGeometryArray(e,t,n=null){let[r,i,a]=this.basisPos,o=Math.min(t.length,e.length/3),s=n?new X:null;for(let c=0;c<o;c++){let o=t[c],l=o.position;e[c*3]=l[0]-r,e[c*3+1]=l[1]-i,e[c*3+2]=l[2]-a,n&&s&&(s.set(h_(o.data)),n[c*3]=s.r,n[c*3+1]=s.g,n[c*3+2]=s.b)}}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length===n){e.setDrawRange(0,t.length);return}let r=!!e.getAttribute(`color`),i=new Float32Array(n),a=r?new Float32Array(n):null;this.seedGeometryArray(i,t,a),e.setAttribute(`position`,new Do(i,3)),a&&e.setAttribute(`color`,new Do(a,3)),e.setDrawRange(0,t.length)}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Do(n,3)),i.length===r)return;let a=new Float32Array(r);a.set(i.subarray(0,Math.min(i.length,r))),e.setAttribute(`position`,new Do(a,3));let o=Math.min(e.drawRange.count,t);e.setDrawRange(0,Number.isFinite(o)?o:0)}onPoolResult=(e,t,n,r,i,a,o)=>{let[s,c]=e.split(`:`),l=this.workerPoints[s].get(c);if(!l)return;let u=l.geometry.getAttribute(`position`),d=u.array;if(d.length!==t.length)return;d.set(t),u.needsUpdate=!0,this.bindPickIds(l,o),l.userData.solvedCount=n,l.geometry.setDrawRange(0,Math.ceil(n*this.drawFraction)),this.lastSolvedJd.set(e,a),l.userData.frontBasis=[r[0],r[1],r[2]],this.parentAtUpdate.set(e,[i[0],i[1],i[2]]);let[f,p,m]=this.focus.focusTruePos,h=this.ctx.getBody(l.userData.parentBodyId)?.position,g=h?h[0]-i[0]:0,_=h?h[1]-i[1]:0,v=h?h[2]-i[2]:0;l.position.set(r[0]-f+g,r[1]-p+_,r[2]-m+v)};bindPickIds(e,t){let n=e.geometry.getAttribute(`pickColor`);n&&n.array.length===t.length?(n.array.set(t),n.needsUpdate=!0):e.geometry.setAttribute(`pickColor`,new Do(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of hP)for(let a of this.workerPoints[i].values()){let i=a.userData.frontBasis??r,[o,s,c]=this.parentShift(a.userData.groupId,a.userData.parentBodyId);a.position.set(i[0]-e+o,i[1]-t+s,i[2]-n+c)}let[i,a,o]=r,s=i-e,c=a-t,l=o-n;for(let e of this.moonPoints.values())e.position.set(s,c,l)}parentShift(e,t){let n=this.parentAtUpdate.get(e),r=this.ctx.getBody(t)?.position;return!n||!r?[0,0,0]:[r[0]-n[0],r[1]-n[1],r[2]-n[2]]}maybeRebase(){let[e,t,n]=this.focus.focusTruePos,[r,i,a]=this.basisPos,o=e-r,s=t-i,c=n-a,l=o*o+s*s+c*c,u=mP*10;l>u*u&&this.rebuildBasis()}rebuildBasis(){this.basisPos=[...this.focus.focusTruePos],this.rebuildMoons(),this.onBasisRebuilt(),this.reposition()}updateForJd(e,t){this.writeMoons();let n=this._parentsScratch;n.clear();let r=this.ctx.getBody(`naif-10`)?.position??[0,0,0];for(let[i,a]of this.workerPoints.asteroid){if(!this.ctx.visibility.isAsteroidGroupVisible(S_(i)))continue;let o=a.userData.groupId;if(!this.shouldSolveGroup(o,r,e,t))continue;let s=a.userData.parentVec;s[0]=r[0],s[1]=r[1],s[2]=r[2],n.set(o,s)}for(let[r,i]of this.workerPoints.spacecraft){if(!this.ctx.visibility.isSpacecraftGroupVisible(S_(r)))continue;let a=i.userData.groupId,o=this.ctx.getBody(i.userData.parentBodyId)?.position;if(o&&!this.shouldSolveGroup(a,o,e,t))continue;let s=i.userData.parentVec;o?(s[0]=o[0],s[1]=o[1],s[2]=o[2]):(s[0]=0,s[1]=0,s[2]=0),n.set(a,s)}this.orbitPool.tick(e,this.basisPos,n,this.ctx.visibility.getRequiredFlags())}shouldSolveGroup(e,t,n,r){let i=this.groupKinematics.get(e);if(!i||i.alwaysSolve)return!0;let a=this.lastSolvedJd.get(e);if(a===void 0||!isFinite(a))return!0;let[o,s,c]=this.focus.focusTruePos,l=r.camPos[0]-(t[0]-o),u=r.camPos[1]-(t[1]-s),d=r.camPos[2]-(t[2]-c),f=Math.max(1e-6,Math.sqrt(l*l+u*u+d*d)),p=Math.abs(n-a);return i.maxSpeedScene*p/f*r.pxPerRad>=_P}forgetGroupGate(e){this.groupKinematics.delete(e),this.lastSolvedJd.delete(e)}moonsByParent(){let e=this.ctx.bodies.majorBodies.length;if(this.moonsByParentCache?.len===e)return this.moonsByParentCache.map;let t=new Map;for(let e of this.ctx.bodies.majorBodies)if(e.data.objectType===W.MOON){let n=t.get(e.data.parentId)??[];n.push(e),t.set(e.data.parentId,n)}return this.moonsByParentCache={len:e,map:t},t}writeMoons(){let[e,t,n]=this.basisPos;for(let[r,i]of this.moonsByParent()){let a=this.moonPoints.get(r);if(!a||!this.ctx.visibility.isMoonGroupVisible(r))continue;let o=a.geometry.getAttribute(`position`),s=o.array,c=Math.min(i.length,s.length/3);for(let r=0;r<c;r++){let a=i[r];if(this.bodyObjects.get(a.data.id)?.outOfRange){s[r*3]=s[r*3+1]=s[r*3+2]=NaN;continue}s[r*3]=a.position[0]-e,s[r*3+1]=a.position[1]-t,s[r*3+2]=a.position[2]-n}o.needsUpdate=!0}}rebuildMoons(){let e=this.basisPos;for(let[t,n]of this.moonsByParent()){let r=this.moonPoints.get(t);if(!r)continue;let i=new Float32Array(n.length*3);for(let t=0;t<n.length;t++)i[t*3]=n[t].position[0]-e[0],i[t*3+1]=n[t].position[1]-e[1],i[t*3+2]=n[t].position[2]-e[2];r.geometry.setAttribute(`position`,new Ao(i,3))}}hasPendingSceneAdds(){return this.pendingSceneAdds.length>0}drainOnePendingSceneAdd(){if(this.pendingSceneAdds.length===0)return;let e=this.pendingSceneAdds.shift();e.layers.set(this.mapLayer),this.scene.add(e)}asteroids(){return this.workerPoints.asteroid}spacecraft(){return this.workerPoints.spacecraft}moons(){return this.moonPoints}dispose(){this.disposed=!0,this.orbitPool.destroy(),this.pickRegistry.clear();for(let e of hP)this.disposeClouds(this.workerPoints[e]);this.disposeClouds(this.moonPoints);for(let e of this.pendingSceneAdds)e.geometry.dispose(),e.material.dispose();this.pendingSceneAdds.length=0}disposeClouds(e){for(let t of e.values())this.scene.remove(t),t.geometry.dispose(),t.material.dispose();e.clear()}},LP=Math.PI/180,RP=2451545,zP=1.00000261,BP=.01671123,VP=100.46457166*LP,HP=35999.37244981/36525*LP,UP=102.93768193*LP,WP=.32327364/36525*LP;function GP(e){let t=e-RP,n=UP+WP*t,r=VP+HP*t-n,i=r+(2*BP-BP**3/4)*Math.sin(r)+1.25*BP*BP*Math.sin(2*r);return{lon:n+i,r:zP*(1-BP*BP)/(1+BP*Math.cos(i))}}function KP(e){let t=GP(e).lon;return(e,n)=>{let r=t-GP(e).lon,i=Math.cos(r),a=Math.sin(r),o=n[0],s=n[2];n[0]=o*i+s*a,n[2]=-o*a+s*i}}var qP=.01,JP=1/100,YP=1;function XP(e,t,n){if(!n)return 0;let r=1/0;for(let i=0;i<t;i++){let t=e[i*3]-n.camX,a=e[i*3+1]-n.camY,o=e[i*3+2]-n.camZ,s=t*t+a*a+o*o;s<r&&(r=s)}return Math.sqrt(r)*n.tolAngle}function ZP(e,t,n,r,i,a,o,s,c){if(t!==e.lastVersion||e.lastOffX===void 0)return!1;let l=e.rewriteTol;if(c){let t=c.camX-e.lastCamX,n=c.camY-e.lastCamY,r=c.camZ-e.lastCamZ;l=Math.max(0,l-Math.sqrt(t*t+n*n+r*r)*c.tolAngle)}let u=(n-e.lastOffX)**2+(r-e.lastOffY)**2+(i-e.lastOffZ)**2,d=(a-e.lastHeadX)**2+(o-e.lastHeadY)**2+(s-e.lastHeadZ)**2;return u<=l*l&&d<=l*l}function QP(e,t,n,r,i,a,o,s,c,l,u){e.lastVersion=t,e.lastOffX=n,e.lastOffY=r,e.lastOffZ=i,e.lastHeadX=a,e.lastHeadY=o,e.lastHeadZ=s,e.lastCamX=u?.camX??0,e.lastCamY=u?.camY??0,e.lastCamZ=u?.camZ??0,e.rewriteTol=XP(c,l,u)}function $P(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position,u=c.x-r[0],d=c.y-r[1],f=c.z-r[2],p=l[0]-c.x,m=l[1]-c.y,h=l[2]-c.z,g=e.lagrangeTrail?NaN:n.newestJd+n.count*1e-9;if(ZP(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=_N(t),b=e.lagrangeTrail?KP(i):null,x=yN(e,n,_,c.x,c.y,c.z,r,b??void 0);vN(t,_,v,y,x,!0,s),QP(o,g,u,d,f,p,m,h,_,x,a)}function eF(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=_N(e),l=Math.min(t.length,c);for(let e=0;e<l;e++)a[e*3]=t[e][0]+n,a[e*3+1]=t[e][1]+r,a[e*3+2]=t[e][2]+i;if(e.userData.lastOffX=void 0,e.userData.isFatLine){fN(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function tF(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){$P(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=lN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.curvePending=!1}let s=t.userData.isOpenCurve,c=t.userData.useTrail,l=t.userData.orbitCenter,u=l.x,d=l.y,f=l.z;if(e.data.satrec){let n=e.data.n/360,i=n>0?1/n/512:0,a=t.userData.curveJd;(o.length===0||a===void 0||Math.abs(r-a)>=i)&&(o=sN(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=r)}else if(e.orbitElements){if(e.rederiveElements){let n=t.userData.elementsJd??r,i=e.orbitElements.n,a=i>0?360/i:1/0;if(Math.abs(r-n)>Math.min(a*JP,YP)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=lN(e.orbitElements,512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.elementsJd=r)}}let n=e.orbitElements.omDot??0,i=e.orbitElements.wDot??0,a=Math.max(Math.abs(n),Math.abs(i));if(a>0){let n=t.userData.curveJd??r;a*Math.abs(r-n)>qP&&(o=lN(Kv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let p=e.trailAnchor??e.position,m=t.userData,h=u-n[0],g=d-n[1],_=f-n[2],v=p[0]-u,y=p[1]-d,b=p[2]-f;if(ZP(m,o,h,g,_,v,y,b,i))return;let x=eb(e,o,s,u,d,f);if(x.length<2)return;let{posArr:S,trailArr:C,fullArr:w,capacity:T}=_N(t),E=u-n[0],D=d-n[1],O=f-n[2],k=Math.min(x.length,T);for(let e=0;e<k;e++)S[e*3]=x[e][0]+E,S[e*3+1]=x[e][1]+D,S[e*3+2]=x[e][2]+O;vN(t,S,C,w,k,s,c),m.trailLocalPositions=x,QP(m,o,h,g,_,v,y,b,S,k,i)}function nF(e,t,n){let r=e===$.CAPPED;return{groupVisible:e===$.CLOSE||e===$.FULL||r&&t,orbitVisible:e===$.FULL||e===$.CLOSE&&n,showLabel:e===$.FULL||r&&t,isClose:e===$.CLOSE}}function rF(e,t,n){return{groupVisible:e===$.CLOSE||e===$.FULL,orbitVisible:e===$.FULL&&t||e===$.CLOSE&&n,showLabel:e===$.FULL&&t,isClose:t&&e===$.CLOSE}}var iF=4/2,aF=(.1*10)**2,oF=new J,sF=[],cF=sF;function lF(e){return ik(sF,e,ck)}var uF={x:0,y:0,left:0,right:0,h:0},dF=new Hi,fF={ox:0,oy:0},pF=new J,mF=new J;function hF(e,t,n,r,i,o,s,c,l,u,d,f,p,m,h){let g=n.layers,_=!g.isVisible(`orbits`),v=g.isVisible(`nomenclature`),y=t.fov*Math.PI/180,b=f.domElement.clientWidth,x=f.domElement.clientHeight,S=x/(2*Math.tan(y/2)),C=[r[0]+t.position.x,r[1]+t.position.y,r[2]+t.position.z],w=r,T=t.matrixWorldInverse;for(let n of e.values()){if(n.cachedDist=R_(C,n.body.position),n.isCrashed||n.noPhysical){let e=n.noPhysical===`model`,t=cg(n.cachedDist)<(n.isCrashed||e?.1:1),r=null;if(t){let t=a().messages;r=n.isCrashed?t.body_note_crash_site():e?t.body_note_no_model():t.body_note_no_radius()}tD(n,`missing`,r)}let e=n.label;if(!e)continue;n.labelAnchorOffscreen=!1;let r=n.noPhysical?0:n.radiusScene;if(!r){e.position.set(0,0,0);continue}let[i,o,s]=n.body.position;p.set(i-w[0],o-w[1],s-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z,d=u*u,f=r*r;if(d<=f){e.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let m=r/n.cachedDist*S;if(m<1){e.position.set(0,0,0);continue}if(m>=16){let a=n.cachedDist,d=1/a,f=c*d,m=l*d,h=u*d,g=r*d,_=Math.sqrt(Math.max(1-g*g,0)),v=1-f*f,y=-f*m,b=-f*h,x=Math.hypot(v,y,b);x<1e-4&&(v=-m*f,y=1-m*m,b=-m*h,x=Math.hypot(v,y,b));let S=g/x,C=f*_+v*S,T=m*_+y*S,E=h*_+b*S;p.set(C*a-c,T*a-l,E*a-u).applyQuaternion(t.quaternion),e.position.copy(p),mF.set(i-w[0]+p.x,o-w[1]+p.y,s-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(mF.x)>1||Math.abs(mF.y)>1;continue}if(n.semiAxesScene&&n.mesh)nP(c,l,u,$N(n.mesh.getWorldQuaternion(dF),T,n.semiAxesScene),S,fF),p.set(fF.ox,fF.oy,0).applyQuaternion(t.quaternion);else{let e=f/(d-f);p.set(e*c,e*l,0).applyQuaternion(t.quaternion)}e.position.copy(p)}let E=sF,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene;if(!e)continue;let n=t.cachedDist,[r,i,a]=t.body.position,o=t.model?.userData.occluderSpheres;if(t.model&&o?.length){let e=aO(t),s=t.model.position;for(let c of o){let o=c.r*e;if(pF.copy(c.center).applyQuaternion(t.model.quaternion).add(s).multiplyScalar(e),p.set(r-w[0]+pF.x,i-w[1]+pF.y,a-w[2]+pF.z).applyMatrix4(T),p.z>=o||p.lengthSq()<=o*o)continue;let l=p.z*p.z;(l<=o*o||o*S/Math.sqrt(l-o*o)>=16)&&eP(lF(k++),p.x,p.y,p.z,o,S,D,O,t.body.data.id,n)}continue}p.set(r-w[0],i-w[1],a-w[2]).applyMatrix4(T);let s=p.x,c=p.y,l=p.z;if(l>=e)continue;let u=l*l;(u<=e*e||e*S/Math.sqrt(u-e*e)>=16)&&(t.semiAxesScene&&t.mesh?tP(lF(k++),s,c,l,$N(t.mesh.getWorldQuaternion(dF),T,t.semiAxesScene),S,D,O,t.body.data.id,n):eP(lF(k++),s,c,l,e,S,D,O,t.body.data.id,n))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=i?wM(n.getBody(i),e):void 0;for(let r of e.values()){let{body:a,group:s,trail:c}=r,l=r.cachedDist,u,d,f=a.data.id===i,p=A!==null&&a.data.id===A;if(r.mesh===null&&!vn(a.data.objectType)){let t=a.data.objectType;if(t===W.BARYCENTER||t===W.LAGRANGE_POINT){let t=!0,r=f?void 0:P_(a.data.id);if(r){let i=e.get(r)?.body??n.getBody(r);i&&R_(a.position,i.position)/R_(C,i.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),u=t,d=!1}else{let e=n.visibility.getPlanetVisibility(a,l)!==$.HIDE&&n.visibility.hasFullRendering(a);s.visible=e,c&&(c.visible=e),u=e,d=!1}}else{let e=a.data.objectType===W.MOON,t=e?n.visibility.getMoonVisibility(a):n.visibility.getPlanetVisibility(a,l),r=e?nF(t,o,f):rF(t,n.visibility.hasFullRendering(a),f||p);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),u=r.showLabel,d=r.isClose}if(r.outOfRange&&(s.visible=!1,c&&(c.visible=!1),u=!1),r.starPoint){let e=r.radiusScene/l*S,t=e<iF;if(r.starPoint.visible=t,t){let t=r.starPoint.material,n=e/iF,i=Math.max(tj*n*n,3);t.uniforms.uIntensity.value=i}s.visible=!0,d=!t,u=!d}if(r.isMinor&&!f&&c&&!n.visibility.isPinned(a.data.id)&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(oF.set(w[0],w[1],w[2]))>aF&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:m}=r;if(!s.visible&&m&&m.parent===s?(s.remove(m),m.element.remove()):s.visible&&m&&m.parent!==s&&s.add(m),r.mesh&&r.radiusScene>0){let e=!f&&!p&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}pk(r,u,d,l,S,i)&&(j=!0);let g=r.radiusScene>0?r.radiusScene/l*S:0;KM(r,v&&a.data.id===M,g,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(S_(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(S_(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0)for(let n of e.values())n.label?.visible&&gk(n,t,w,b,x,uF)&&mk(uF.x,uF.y,n.cachedDist,n.body.data.id,E)&&(n.label.visible=!1);if((m||j||++d>=3)&&(d=0,kk(e,b,x,t,i,n,s,E,r)),Ak(e,b,x,t,r),M){let t=e.get(M);t&&XM(t)}for(let n of e.values()){let e=n.trail;if(!e?.visible)continue;let r=e.material;r.uniforms.uCenterOffset.value.set(-t.position.x,-t.position.y,-t.position.z);let a=n.body.data.id===i,o=s.has(n.body.data.id);r.uniforms.uAlphaMultiplier.value=o?2:a?1.75:1;let c=e.userData.isOpenCurve===!1;r.uniforms.uAlphaMin.value=a&&c?.15:0,r.uniforms.uShowFull.value=+!!a}return d}function gF(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function _F(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function vF(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function yF(e,t){let n=e.arcs[t].points.length,r=t=>e.endOrbits.find(e=>e.at===t);return{from:t===0?r(`departure`)?.trimFrom??0:0,to:t===e.arcs.length-1?r(`arrival`)?.trimTo??n:n}}function bF(e,t){let n=e.arcs[0],r=e.arcs[e.arcs.length-1];if(!n||!r)return null;let i=t=>e.endOrbits.find(e=>e.at===t)??null,a=i(`departure`),o=i(`arrival`),s=e=>e&&e.approach.length>1?e:null,c=s(a),l=s(o),u=e=>e&&e.pointJds&&e.points.length>1&&e.pointJds.length===e.points.length?{points:e.points,jds:e.pointJds}:null,d=u(a),f=o?.surfaceJd===void 0?u(o):null,p=Math.min(n.startJd,a?.surfaceJd??1/0),m=Math.max(r.endJd,o?.surfaceJd??l?.jds[l.jds.length-1]??-1/0),h=d?p-xF(d):p,g=f?m+xF(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:SF(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:CF(c.approach,c.jds,t),centerId:c.anchorId};if(o&&t>=(l?.jds[0]??r.endJd)){let e=o.surfaceJd??l?.jds[l.jds.length-1]??r.endJd;if(f&&(!l||t>e))return{r:SF(f,t),centerId:o.anchorId};if(l)return{r:CF(l.approach,l.jds,Math.min(t,e)),centerId:o.anchorId}}let _=e.arcs.findIndex(e=>t>=e.startJd&&t<=e.endJd),v=_>=0?_:e.arcs.length-1,{points:y,jds:b}=e.arcs[v];if(y.length===0)return null;if(y.length===1||b.length!==y.length)return{r:y[0],centerId:e.centerId};let{from:x,to:S}=yF(e,v);return{r:CF(y,b,t,x,S),centerId:e.centerId}}function xF(e){return e.jds[e.jds.length-1]-e.jds[0]}function SF(e,t){let n=xF(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return CF(e.points,e.jds,i)}function CF(e,t,n,r=0,i=e.length){if(i-r<2)return e[r];let a=r+1;for(;a<i-1&&t[a]<n;)a++;let o=t[a]-t[a-1],s=o>0?Math.min(1,Math.max(0,(n-t[a-1])/o)):0;return gF(e[a-1],vF(_F(e[a],e[a-1]),s))}var wF=Math.PI/180,TF=Math.cos(ag*wF),EF=Math.sin(ag*wF);function DF(e,t,n,r){let i=Math.cos(e*wF),a=Math.sin(e*wF),o=Math.cos(t*wF),s=Math.sin(t*wF),c=Math.cos(n*wF),l=Math.sin(n*wF);return{m11:c*i-l*a*o,m12:-c*a-l*i*o,m21:l*i+c*a*o,m22:-l*a+c*i*o,m31:a*s,m32:i*s,equatorial:r}}function OF(e,t,n){let r=n.m11*e+n.m12*t,i=n.m21*e+n.m22*t,a=n.m31*e+n.m32*t;if(n.equatorial){let e=i*TF+a*EF,t=-i*EF+a*TF;i=e,a=t}return[r,i,a]}function kF(e){let t=10/ig;return[e[0]*t,e[2]*t,-e[1]*t]}function AF(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,{om:u,w:d}=Kv(e,t),f=e.equatorial??!1;if(!isFinite(r)||r===0||!isFinite(o)||o<=0){if(c==null||l==null||!isFinite(c)||!isFinite(l)||c<=0)return null;let r=wg(c,l,t);if(!r)return null;let i=n&&n>0?n:ev,a=r.r*ig,o=2*c*ig;return jF(a,r.nu,o,1,i,d,e.i,u,f)}if(!isFinite(i)||!isFinite(a))return null;let p=r*ig,m=o*wF/tv,h=n&&n>0?n:m*m*Math.abs(p)*Math.abs(p)*Math.abs(p);if(!isFinite(h)||h<=0)return null;let g=(a+o*(t-s))*wF,_,v;if(i<1||r>0){let e=Math.min(i,.9999999),t=xg(g,e),n=1-e*Math.cos(t);_=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),v=p*n}else{let e=Cg(g,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;_=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),v=p*(1-i*Math.cosh(e))}if(!isFinite(v)||v<=0)return null;let y=p*(1-i*i);return!isFinite(y)||y<=0?null:jF(v,_,y,i,h,d,e.i,u,f)}function jF(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=DF(a,o,s,c),p=OF(e*l,e*u,f),m=OF(-d*u,d*(r+l),f);return!isFinite(p[0]+p[1]+p[2])||!isFinite(m[0]+m[1]+m[2])?null:{r:p,v:m,mu:i}}var MF={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};MF.cruise,MF.boost,MF.brake,MF.spiral,MF[`spiral-out`],MF[`spiral-in`];var NF={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},PF=3,FF=1,IF=2,LF=.6,RF=1.5,zF=.3,BF=1.5,VF=.85,HF=60,UF=.018,WF=.026,GF=`#ffffff`,KF=4,qF=1.5,JF=9,YF=1,XF={notice:KF-3,caution:KF-2,severe:KF-1},ZF=[`notice`,`caution`,`severe`],QF=.03,$F=.2;function eI(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.arc(64/2,64/2,64/2-10,0,Math.PI*2),n.fillStyle=e,n.fill(),n.lineWidth=6,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function tI(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.moveTo(64/2,8),n.lineTo(56,56),n.lineTo(8,56),n.closePath(),n.fillStyle=e,n.fill(),n.lineWidth=6,n.lineJoin=`round`,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Nc(t)}function nI(e,t,n,r){let i=[];for(let a=r.from;a<r.to;a++)e.jds[a]>=t&&e.jds[a]<=n&&i.push(e.points[a]);return i}function rI(e,t){let n=new cs(new Jo({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=KF,n}function iI(e,t,n,r){let{canvas:i,color:a,onSelect:o,onHover:s}=r,c=document.createElement(o?`button`:`div`);c instanceof HTMLButtonElement&&(c.type=`button`),c.className=e===`step`?`scene-path-label scene-path-label--step`:`scene-path-label${o?``:` scene-path-label--static`}`,c.setAttribute(`aria-label`,`${t} \u2014 ${n}`);let l=document.createElement(`span`);l.className=`scene-path-label__halo`,a&&(l.style.border=`2px solid ${a}`,l.style.background=`${a}22`);let u=document.createElement(`span`);u.className=`scene-path-label__text`;let d=document.createElement(`span`);d.className=`scene-path-label__name`,d.dir=`auto`,d.textContent=t;let f=document.createElement(`span`);f.className=`scene-path-label__when`,f.dir=`auto`,f.textContent=n,u.append(d,f),c.append(l,u),o&&(zk(c,i),CM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new nk(c);return p.center.set(0,.5),p}var aI=class{group=new za;arcs=[];rings=[];markers=[];labels=[];drawnSteps=[];craft=null;path=null;center=null;layer=null;offset=new J;projected=new J;rects=[];order=[];hovered=null;tint=new X;constructor(e,t){this.scene=e,this.canvas=t,this.group.frustumCulled=!1,this.scene.add(this.group)}get centerId(){return this.center}get isEmpty(){return this.center===null}get plan(){return this.path}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}set(e,t=[],n=[],r=[]){this.clear(),this.path=e?.path??null,this.center=e?.path.centerId??t[0]?.path.centerId??null;let i=e!==null;for(let e of t)this.addArcs(e.path,i?RF:IF,i?zF:LF,e.id),this.addEndLabels(e,i);e&&(this.addPlan(e,r),this.addHazards(e.path,n)),this.applyHover(),this.layer!==null&&this.setLayer(this.layer)}addHazards(e,t){let n=[...t].sort((e,t)=>ZF.indexOf(e.severity)-ZF.indexOf(t.severity));for(let t of n){let n=NF[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine(nI(t,n.startJd,n.endJd,yF(e,r)),NF[n.severity],JF,YF,null,{renderOrder:XF[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=bF(e,t.startJd);if(!r)continue;let i=kF(r.r),a=r.centerId===e.centerId?null:r.centerId,o=rI(tI(n),QF);this.group.add(o),this.markers.push({sprite:o,local:i,anchorId:a});let s=document.createElement(`div`);s.className=`scene-hazard-label`,s.style.color=n,s.textContent=t.label;let c=new nk(s);c.center.set(0,.5),this.group.add(c),this.labels.push({object:c,local:i,anchorId:a,owner:null,width:0,height:0,dimmed:!1,faint:!0})}}mergeIntoStep(e,t){let n=e.kind===`aeroassist`?`aero-pass`:e.kind===`belt-crossing`?`assist`:null;if(!n)return!1;let r=null,i=1/0;for(let{step:t,label:a}of this.drawnSteps){if(t.kind!==n||e.bodyId&&t.bodyId!==e.bodyId)continue;let o=Math.abs(t.jd-e.peakJd);o<i&&(i=o,r=a)}if(!r)return!1;let a=r.object.element,o=document.createElement(`span`);return o.className=`scene-path-label__hazard`,o.style.color=t,o.dir=`auto`,o.textContent=e.label,a.querySelector(`.scene-path-label__text`)?.append(o),a.setAttribute(`aria-label`,`${a.getAttribute(`aria-label`)} — ${e.label}`),!0}addPlan(e,t){let n=e.path;this.addArcs(n,PF,FF,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.group.add(e.sprite);this.craft={sprite:rI(eI(GF),WF),local:[0,0,0],anchorId:null},this.craft.sprite.visible=!1,this.group.add(this.craft.sprite)}addSteps(e,t){for(let n of t){let t=bF(e,n.jd);if(!t)continue;let r=kF(t.r),i=t.centerId===e.centerId?null:t.centerId,a=rI(eI(GF),UF);this.markers.push({sprite:a,local:r,anchorId:i});let o=iI(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.group.add(o),this.labels.push({object:o,local:r,anchorId:i,owner:null,width:0,height:0,dimmed:!1,faint:!1,step:!0,sprite:a}),this.drawnSteps.push({step:n,label:this.labels[this.labels.length-1]})}}addEndLabels(e,t=!1){let{path:n,onSelect:r}=e,i=n.arcs[0],a=n.arcs[n.arcs.length-1],o=n.stops.find(e=>e.kind===`departure`),s=[{local:kF(n.meeting.r),end:e.arrival,color:MF[a?.kind??`cruise`]}];o&&s.push({local:kF(o.r),end:e.departure,color:MF[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=iI(`end`,i.name,i.when,{canvas:this.canvas,color:a,onSelect:r,onHover:e.onHover});t&&o.element.classList.add(`scene-path-label--faint`),this.group.add(o),this.labels.push({object:o,local:n,anchorId:null,owner:r?e.id:null,width:0,height:0,dimmed:!1,faint:t})}}setHovered(e){this.hovered!==e&&(this.hovered=e,this.applyHover())}applyHover(){for(let e of this.arcs){if(e.owner===null)continue;let t=e.owner===this.hovered,n=e.line.material;n.uniforms.uColor.value.set(e.color).multiplyScalar(t?FF:e.brightness),n.uniforms.uLineWidth.value=t?PF:e.width}for(let e of this.labels)e.owner!==null&&e.object.element.classList.toggle(`scene-path-label--lit`,e.owner===this.hovered)}addArcs(e,t,n,r=null,i=!1){let a=i&&e.frame===`planetary`,o=t=>a&&e.endOrbits.some(e=>e.at===t&&e.approach.length>1);e.arcs.forEach((a,s)=>{let{from:c,to:l}=i?yF(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),MF[a.kind],t,n,r,{fadeIn:s===0&&o(`departure`),fadeOut:s===e.arcs.length-1&&o(`arrival`)})})}addEndOrbits(e){for(let t of e.endOrbits){let n=this.anchorOf(e,t),r=(t.ground??[]).filter(e=>e.to>e.from);if(r.length>0){let e=0;for(let i of r)i.from>e&&this.addLine(t.approach.slice(Math.max(0,e-1),i.from+1),MF.cruise,PF,FF,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),MF.cruise,PF,FF,null,{anchorId:n,renderOrder:qF}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),MF.cruise,PF,FF,null,{anchorId:n})}else if(t.turn){let{from:e,to:r}=t.turn,i=t.approach.slice(0,e+1),a=t.approach.slice(r-1);for(let e of[i,a])e.length<2||this.addLine(e,MF.cruise,PF,FF,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),MF.cruise,BF,VF,null,{anchorId:n})}else this.addLine(t.approach,MF.cruise,PF,FF,null,{anchorId:n});let i=this.addLine(t.points,MF.cruise,BF,VF,null,{anchorId:n});if(!i)continue;let a=n===null?kF(t.center):[0,0,0];i.line.visible=!1,this.rings.push({arc:i,local:a,radius:Q(t.radiusKm),world:new J})}}anchorOf(e,t){return t.anchorId===e.centerId?null:t.anchorId}addLine(e,t,n,r,i,a={}){let o=e.length;if(o<2)return null;let s=new Float64Array(o*3);for(let t=0;t<o;t++){let[n,r,i]=kF(e[t]);s[t*3]=n,s[t*3+1]=r,s[t*3+2]=i}let c=new Float32Array(o*3),l=new Float32Array(o).fill(1),u=Math.max(1,Math.round(o*$F));for(let e=0;e<u;e++){let t=(e+1)/(u+1);a.fadeIn&&(l[e]=t),a.fadeOut&&(l[o-1-e]=t)}let d=gN(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??KF,this.group.add(d);let f={line:d,owner:i,anchorId:a.anchorId??null,color:t,brightness:r,width:n,local:s,positions:c,alphas:l,count:o};return this.arcs.push(f),f}setClock(e){let t=this.craft;if(!t||!this.path)return;let n=bF(this.path,e);t.sprite.visible=n!==null,n&&(t.local=kF(n.r),t.anchorId=n.centerId===this.path.centerId?null:n.centerId)}reposition(e,t,n){if(this.center===null)return;let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=new Map,s=e=>{if(e===null)return[r,i,a];let s=o.get(e);if(s)return s;let c=n(e),l=c?[c[0]-t[0],c[1]-t[1],c[2]-t[2]]:[r,i,a];return o.set(e,l),l};for(let e of this.arcs){let[t,n,r]=s(e.anchorId);for(let i=0;i<e.count;i++)e.positions[i*3]=e.local[i*3]+t,e.positions[i*3+1]=e.local[i*3+1]+n,e.positions[i*3+2]=e.local[i*3+2]+r;fN(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let[t,n,r]=s(e.anchorId);e.sprite.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}for(let e of this.labels){let[t,n,r]=s(e.anchorId);e.object.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}if(this.craft){let{sprite:e,local:t,anchorId:n}=this.craft,[r,i,a]=s(n);e.position.set(t[0]+r,t[1]+i,t[2]+a)}for(let e of this.rings){let[t,n,r]=s(e.arc.anchorId);e.world.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}}updateCameraOffset(e){if(this.arcs.length!==0){this.offset.set(-e.x,-e.y,-e.z);for(let e of this.arcs)e.line.material.uniforms.uCenterOffset.value.copy(this.offset);for(let t of this.rings){let n=t.world.distanceTo(e);t.arc.line.visible=n<t.radius*HF}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){Dk(this.rects,0);return}this.order.length=0;for(let r of this.labels){if(r.faint)continue;let i=r.object.element;if(!r.width&&!r.dimmed&&(r.width=i.offsetWidth,r.height=i.offsetHeight),!r.width||(this.projected.copy(r.object.position).project(e),!aT(this.projected.z)))continue;let a=(this.projected.x*.5+.5)*t,o=(-this.projected.y*.5+.5)*n,s=r.object.position.distanceTo(e.position);if(r.step){let e=mk(a,o,s,``,cF);if(this.setStepVisible(r,!e),e)continue}this.order.push({label:r,left:a-16,y:o,distance:s})}this.order.sort((e,t)=>e.label.step===t.label.step?e.distance-t.distance:e.label.step?1:-1);let r=0;for(let{label:e,left:t,y:n}of this.order){let i=t+16+e.width,a=!1;for(let o=0;o<r;o++){let r=this.rects[o];if(t<r.right&&i>r.left&&Math.abs(n-r.y)<(e.height+r.h)/2){a=!0;break}}if(this.setLabelDimmed(e,a),a)continue;let o=this.rects[r];o||(o={left:0,right:0,y:0,h:0},this.rects[r]=o),o.left=t,o.right=i,o.y=n,o.h=e.height,r++}Dk(this.rects,r)}setStepVisible(e,t){e.object.visible=t,e.sprite&&(e.sprite.visible=t)}setLabelDimmed(e,t){e.dimmed!==t&&(e.dimmed=t,e.object.element.classList.toggle(`scene-path-label--dim`,t))}clear(){for(let e of this.arcs)this.group.remove(e.line),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){this.group.remove(e.sprite);let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)this.group.remove(e.object),e.object.element.remove();this.arcs=[],this.rings=[],this.markers=[],this.labels=[],this.drawnSteps=[],this.craft=null,this.path=null,this.center=null}dispose(){this.clear(),this.scene.remove(this.group)}},oI=2,sI=1,cI=4,lI=200,uI=class{group=new za;slots=[];shown=0;layer=null;constructor(e){this.group.frustumCulled=!1,e.add(this.group)}get isEmpty(){return this.shown===0}set(e){let t=0;for(let n of e){if(n.pointsKm.length<2)continue;let e=this.slot(t++);e.bodyId=n.bodyId,e.count=Math.min(n.pointsKm.length,lI);for(let t=0;t<e.count;t++){let[r,i,a]=kF(n.pointsKm[t]);e.local[t*3]=r,e.local[t*3+1]=i,e.local[t*3+2]=a}}this.shown=t;for(let e=t;e<this.slots.length;e++)this.slots[e].line.visible=!1;this.group.visible=t>0}slot(e){for(;this.slots.length<=e;){let e=new Float32Array(lI*3),t=new Float32Array(lI).fill(1),n=gN(lI,e,t,t,0,MF.cruise,oI,sI);n.frustumCulled=!1,n.renderOrder=cI,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array(lI*3),positions:e,alphas:t,count:0})}return this.slots[e]}setLayer(e){this.layer=e,this.group.traverse(t=>t.layers.set(e))}reposition(e,t){for(let n=0;n<this.shown;n++){let r=this.slots[n],i=e(r.bodyId);if(r.line.visible=i!==null,!i)continue;let a=i[0]-t[0],o=i[1]-t[1],s=i[2]-t[2];for(let e=0;e<r.count;e++)r.positions[e*3]=r.local[e*3]+a,r.positions[e*3+1]=r.local[e*3+1]+o,r.positions[e*3+2]=r.local[e*3+2]+s;fN(r.line.geometry,r.positions,r.alphas,r.alphas,r.count)}}updateCameraOffset(e){for(let t of this.slots)t.line.material.uniforms.uCenterOffset.value.set(-e.x,-e.y,-e.z)}},dI=30034e-10,fI=.45,pI=1.6,mI=.85,hI=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],gI=e=>Math.hypot(e[0],e[1],e[2]);function _I(e,t,n=dI){let r=gI(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=hI(e,t)/r,o=gI(e);if(Math.sqrt(Math.max(0,o*o-a*a))>mI*i)return null;let s=a/i;return s>=fI&&s<=pI?`EL1`:s<=-fI&&s>=-pI?`EL2`:null}function vI(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var yI=class{focused=!1;satSide=null;satJd=NaN;majSide=null;majJd=NaN;constructor(e){this.notices=e}update(e){let{jd:t,majorBodies:n,satellites:r}=e,i=null,a=NaN;n.count>0&&(Number.isFinite(n.latestEnd)&&t>n.latestEnd?(i=`after`,a=n.latestEnd):Number.isFinite(n.earliestStart)&&t<n.earliestStart?(i=`before`,a=n.earliestStart):i=`outside`);let o=r.kind===`covered`?null:r.kind,s=r.kind===`after`?Mg(r.lastMs):NaN,c=e.focusedOutOfRange;if(!(c===this.focused&&o===this.satSide&&Object.is(s,this.satJd)&&i===this.majSide&&Object.is(a,this.majJd))){if(Object.assign(this,{focused:c,satSide:o,satJd:s,majSide:i,majJd:a}),!c&&o===null&&i===null){this.notices.dismiss(`out-of-range`);return}this.notices.notify({topic:`out-of-range`,focusedOutOfRange:c,satellites:o===`after`?{side:`after`,jd:s}:o===`gap`?{side:`gap`}:null,majorBodies:i===`after`||i===`before`?{side:i,jd:a}:i===`outside`?{side:`outside`}:null})}}},bI=new Map,xI=new J;function SI(e,t,n,r,i,a,o){let s=Ey(n,r,wy(t));if(!s)return null;let c=`naif-${n.bodyNaifId}`,l=a.bodies.bodiesById.get(c);if(!l||!l.orientation)return null;let u=i.get(c);if(!u)return null;let d=l.data.radiusKm;if(!Number.isFinite(d)||d<=0)return null;let f=Math.PI/180,p=s.latDeg*f,m=s.lngDeg*f,h=Aw(o.get(c),c,d,p,m);h&&bI.set(e.id,h);let g=h??bI.get(e.id),_,v,y;if(g)[_,v,y]=g.pointKm;else{let e=Math.cos(p);_=d*e*Math.cos(m),v=d*Math.sin(p),y=-d*e*Math.sin(m)}let b=mC(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?xI.set(g.normal[0],g.normal[1],g.normal[2]).applyQuaternion(b):null;return e.parentId=c,{x:u[0]+Q(x.x),y:u[1]+Q(x.y),z:u[2]+Q(x.z),parentPos:u,up:S}}var CI=[0,0,0],wI=new Hi,TI=4,EI=0,DI=new Map;function OI(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function kI(e,t,n){let r=DI.get(e),i=r?.dir??null;if(r&&t!==r.jd){let e=Math.sign(t-r.jd),a=(n[0]-r.pos[0])*e,o=(n[1]-r.pos[1])*e,s=(n[2]-r.pos[2])*e,c=Math.hypot(a,o,s);c>1e-12&&(i=[a/c,o/c,s/c])}return DI.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}function AI(e){let{jd:t,ctx:n,bodyObjects:r,focus:i,focusedBody:o,positionMap:s,diagnostics:c,trailView:l,frame:u,outOfRange:d}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let f=n.visibility.activeSystemId,p=f?e=>n.bodies.isInSystem(`naif-${e}`,f):void 0,m={jd:t,satellites:{kind:`covered`},majorBodies:vI(),focusedOutOfRange:!1},h=o?.data.id,g=_x(n.probeStore?.ridesAt(t)??[],h,e=>n.getBody(e)?.data.name),_=[];if(o){let e=new Set([o.data.id]),t=n.getBody(o.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),_.push({id:t.data.id,oldPos:[t.position[0],t.position[1],t.position[2]],bo:r.get(t.data.id)}),t=n.getBody(t.data.parentId)}s.clear(),s.set(`naif-0`,[0,0,0]);for(let e of n.bodies.bodiesById.values())s.set(e.data.id,e.position);for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||s.set(e.body.data.id,e.body.position);let v=new Set,y=e=>{if(v.has(e))return;let t=n.bodies.bodiesById.get(e)??r.get(e)?.body;t&&C(t)},b=performance.now(),x=e=>{let t=n.bodies.hostRead.get(e);return t===void 0?!1:b-t<2e3?!0:(n.bodies.hostRead.delete(e),!1)},S=(e,r)=>{let i=n.bodies.elementRow(e),a=i&&s.get(i.parentId);if(!a)return null;let o=i.q==null?Jv(i,t):Xv(i,t);return o?[a[0]-r[0]+o[0],a[1]-r[1]+o[1],a[2]-r[2]+o[2]]:null},C=e=>{if(v.has(e.data.id))return;v.add(e.data.id);let i=e.data,o=r.get(i.id);if(o&&u!==void 0&&i.id!==h&&!x(i.id)&&!o.group.visible&&!o.trail?.visible&&(i.orbitalSource===U.SPICE_PROBE||!vn(i.objectType))&&(o.staggerSlot??=EI++%TI,u%TI!==o.staggerSlot))return;let l=(n=!1)=>{o&&(o.outOfRange=!0),e.positionUnknown=!0,e.placedJd=t,!n&&i.id===h&&(m.focusedOutOfRange=!0)};if(i.unplaceable){l(!0);return}let d=n.chebStore?.has(i.id)??!1,f=i.orbitalSource===U.SPICE_PROBE;if(f){if(g.hidden.has(i.id)){l(!0);return}if(o){let e=g.credits.get(i.id);tD(o,`carrier`,e?a().messages.carried_by_scene_label({carrier:e}):null)}}if(i.visibleFromDays!==void 0&&t-2451545<i.visibleFromDays){l();return}let _;if(f)_=s.get(i.parentId)??[0,0,0];else{let e=s.get(i.parentId);if(!e){l(),c.warnOnce(`missing-parent`,i.id,()=>`computePosition[${i.id}]: parent ${i.parentId} not in positionMap — hiding`);return}_=e,c.clear(`missing-parent`,i.id)}let b=i.q!=null;if(!d&&!f&&(t<i.validityStart||t>i.validityEnd)){l(!i.satrec);return}let C,w,T;if(d){let r=n.chebStore.positionScene(i.id,t)??S(e,_);if(!r){l(!0);let e=n.chebStore.zoneCoverage(i.id);e&&(t<e.start||t>e.end)&&(m.majorBodies.count++,e.start<m.majorBodies.earliestStart&&(m.majorBodies.earliestStart=e.start),e.end>m.majorBodies.latestEnd&&(m.majorBodies.latestEnd=e.end),i.id===h&&(m.focusedOutOfRange=!0)),c.warnOnce(`cheb-null`,i.id,()=>{let n=e?t>=e.start&&t<=e.end:void 0,r=e?`[${e.start.toFixed(1)},${e.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${i.id}] returned null at jd=${t.toFixed(3)} (coverage=${r}, insideCoverage=${n}) — children of this body will read stale positionMap entry (pre-seeded) instead of falling to SSB`});return}C=_[0]+r[0],w=_[1]+r[1],T=_[2]+r[2]}else if(f){let a=n.probeStore?.probeWithCenter(i.id,t,p)??null;if(!a){l(),c.warnOnce(`probe-unavailable`,i.id,()=>{let e=n.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${i.id} (${i.name??`unnamed`}): hidden — ${e}`});return}let u=a.probe.landed;if(u&&Ty(a.probe,t)){let d=i.parentId;y(`naif-${u.bodyNaifId}`);let f=SI(i,a.probe,u,t,s,n,r);if(!f){l();return}if(c.clear(`probe-unavailable`,i.id),e.positionUnknown=!1,e.placedJd=t,d!==i.parentId&&e.trailBuffer?.clear(),o){o.outOfRange=!1;let e=u.isDestroyed;o.isLanded||=(Nk(o.labelHalo,`landed`),!0),o.isCrashed=e,o.model&&(o.model.visible=!e)}e.position[0]=f.x,e.position[1]=f.y,e.position[2]=f.z,e.orbitCenter&&(e.orbitCenter[0]=f.parentPos[0],e.orbitCenter[1]=f.parentPos[1],e.orbitCenter[2]=f.parentPos[2]),e.trailAnchor&&(e.trailAnchor[0]=f.parentPos[0],e.trailAnchor[1]=f.parentPos[1],e.trailAnchor[2]=f.parentPos[2]),s.set(i.id,e.position);let p=f.up;o?.mesh&&(p?yC(o.mesh,p):vC(o.mesh,e.position,f.parentPos)),o?.model&&(p?yC(o.model,p):vC(o.model,e.position,f.parentPos));return}let d=Vy(a.probe,t,a.fitCenterNaifId,n.chebStore??null,e=>s.has(e));if(!d){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`);return}let f=d.id,m=d.muKm3S2,g=Sy(a.probe,t,m);if(!g){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`);return}c.clear(`probe-unavailable`,i.id),o?.isLanded&&(Nk(o.labelHalo,`flying`),o.isLanded=!1,o.isCrashed&&(o.isCrashed=!1,o.model&&(o.model.visible=!0),o.noPhysical||tD(o,`missing`,null)));let v=s.get(p_),b=s.get(f_),x=f===`naif-399`&&v!==void 0&&b!==void 0&&_I([Q(g[0]),Q(g[2]),-Q(g[1])],[b[0]-v[0],b[1]-v[1],b[2]-v[2]])!==null,S=x!==(e.lagrangeTrail??!1);e.lagrangeTrail=x;let E=i.parentId!==f;if((E||S)&&e.trailBuffer&&n.probeStore){let r=e.trailBuffer;r.clear(),r.needsPopulate=!1;let o=Gy(Ry(a.probe,t,m),i.validityEnd-i.validityStart,r.capacity,x);r.reconfigure(o.stepDays,o.epsilonScene,o.spanDays),Zy(r,n.probeStore,n.chebStore??null,i.id,f,t)}E&&(i.parentId=f),y(f);let D=s.get(f);if(!D){l(),c.warnOnce(`probe-unavailable`,i.id,()=>`probe ${i.id} (${i.name??`unnamed`}): hidden — fit center ${f} has no position this frame`);return}_=D;let O=Q(g[0]),k=Q(g[2]),A=-Q(g[1]);C=_[0]+O,w=_[1]+k,T=_[2]+A;let j=e.trailBuffer;if(j?.needsPopulate&&o?.trail?.visible&&n.probeStore&&(j.needsPopulate=!1,j.clear(),Zy(j,n.probeStore,n.chebStore??null,i.id,f,t)),j){let e=j.newestJd,r=t-e,o=j.stepDays*j.capacity,s=isFinite(e)&&(r<0||r>o);if(s&&i.id===h&&n.probeStore){j.clear();let e=Gy(Ry(a.probe,t,m),i.validityEnd-i.validityStart,j.capacity,x);j.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),Zy(j,n.probeStore,n.chebStore??null,i.id,f,t)}else s?(j.clear(),j.append(t,O,k,A)):isFinite(e)?isFinite(j.epsilonScene)?r>=j.stepDays*.00390625&&n.probeStore&&j.readNewestPos(CI)&&$y(j,qy(n.probeStore,n.chebStore??null,i.id,f),e,[CI[0],CI[1],CI[2]],t):r>=j.stepDays&&j.append(t,O,k,A):j.append(t,O,k,A)}}else if(i.a===0&&!b&&!i.satrec)[C,w,T]=_;else{let e=i.satrec?bg(i.satrec,t):b?Xv(i,t):Jv(i,t);if(!e){l();return}C=_[0]+e[0],w=_[1]+e[1],T=_[2]+e[2]}if(o&&(o.outOfRange=!1),e.positionUnknown=!1,e.placedJd=t,e.position[0]=C,e.position[1]=w,e.position[2]=T,(!Number.isFinite(C)||!Number.isFinite(w)||!Number.isFinite(T))&&c.warnOnce(`non-finite`,i.id,()=>{let e=s.has(i.parentId);return`computePosition[${i.id}] non-finite: pos=[${C},${w},${T}] parentId=${i.parentId} parentInPositionMap=${e} parentPos=[${_[0]},${_[1]},${_[2]}] isChebTracked=${d} isProbe=${f} objectType=${i.objectType}`}),e.orbitCenter&&(e.orbitCenter[0]=_[0],e.orbitCenter[1]=_[1],e.orbitCenter[2]=_[2]),e.trailAnchor&&(e.trailAnchor[0]=_[0],e.trailAnchor[1]=_[1],e.trailAnchor[2]=_[2]),s.set(i.id,e.position),o){if(o.trail&&e.orbitCenter){let e=o.trail.userData.orbitCenter;e&&e.set(_[0],_[1],_[2])}if(e.orientation&&(o.mesh||o.model))o.mesh&&hC(o.mesh,e.orientation,t,e.nutPrec),o.model&&hC(o.model,e.orientation,t,e.nutPrec),o.nomenclatureAnchor&&hC(o.nomenclatureAnchor,e.orientation,t,e.nutPrec);else if($D(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(t,wI))o.mesh&&o.mesh.quaternion.copy(wI),o.model&&o.model.quaternion.copy(wI);else{let n=e.pointingOverride??e.pointing;if(n){let r=OI(n)?kI(i.id,t,e.position):void 0,a={bodyPos:e.position,parentPos:_,sunPos:s.get(f_),velocity:r};o.mesh&&NC(o.mesh,n,a),o.model&&NC(o.model,n,a)}else o.mesh&&vC(o.mesh,e.position,_),o.model&&vC(o.model,e.position,_)}}if(e.orientation)for(let n of o.rings)hC(n.mesh,e.orientation,t,e.nutPrec)}},w=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values()){if(e.data.objectType===W.MOON&&!(w!==null&&e.data.parentId===w)&&e.data.id!==h){s.set(e.data.id,e.position);continue}C(e)}for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||C(e.body);if(m.satellites=n.refresher?.satelliteCoverage(t)??{kind:`covered`},d.update(m),o&&un(o)){let e=n.getBody(o.featureAnchor.hostId);e&&s.has(e.data.id)?Vw(o,e,r.get(e.data.id),t):m.focusedOutOfRange=!0}let T=null;if(o&&m.focusedOutOfRange){let e=_.find(e=>e.bo&&!e.bo.outOfRange);if(e){T=e.id;let t=s.get(e.id)??e.oldPos;if(performance.now()-i.focusStartTime<i.focusDurationMs){i.focusTargetWorld[0]=t[0],i.focusTargetWorld[1]=t[1],i.focusTargetWorld[2]=t[2];let e=i.camTargetOffset;e&&i.camTargetWorld&&(i.camTargetWorld[0]=t[0]+e[0],i.camTargetWorld[1]=t[1]+e[1],i.camTargetWorld[2]=t[2]+e[2])}else{let n=t[0]-e.oldPos[0],r=t[1]-e.oldPos[1],a=t[2]-e.oldPos[2];i.focusTruePos[0]+=n,i.focusTruePos[1]+=r,i.focusTruePos[2]+=a,i.focusTargetWorld[0]=i.focusTruePos[0],i.focusTargetWorld[1]=i.focusTruePos[1],i.focusTargetWorld[2]=i.focusTruePos[2]}}}else if(o){let e=o.position,t=performance.now()-i.focusStartTime<i.focusDurationMs;i.focusTargetWorld[0]=e[0],i.focusTargetWorld[1]=e[1],i.focusTargetWorld[2]=e[2];let n=i.camTargetOffset;n&&i.camTargetWorld&&(i.camTargetWorld[0]=e[0]+n[0],i.camTargetWorld[1]=e[1]+n[1],i.camTargetWorld[2]=e[2]+n[2]);let r=i.camOriginOffset;r&&i.camOriginWorld&&(i.camOriginWorld[0]=e[0]+r[0],i.camOriginWorld[1]=e[1]+r[1],i.camOriginWorld[2]=e[2]+r[2]),t||(i.focusTruePos[0]=e[0],i.focusTruePos[1]=e[1],i.focusTruePos[2]=e[2])}let E=i.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}tF(e.body,n,E,t,l),n.userData.refreshDeferred=!1}}return{focusedOutOfRange:m.focusedOutOfRange,reanchorId:T}}function jI(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(tF(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}var MI=class{seen=new Map;bucket(e){let t=this.seen.get(e);return t||this.seen.set(e,t=new Set),t}warnOnce(e,t,n){let r=this.bucket(e);r.has(t)||(r.add(t),console.warn(n()))}clear(e,t){this.seen.get(e)?.delete(t)}},NI=Q(695700),PI=2,FI=new J;function II(e,t,n,r,i){FI.subVectors(e,t);let a=FI.dot(n),o=Math.sqrt(Math.max(FI.lengthSq()-a*a,0)),s=o-Math.min(Math.max(o,r),i),c=Math.sqrt(s*s+a*a);return{dist:c,sinToPole:c>0?Math.abs(s)/c:1}}function LI(e,t,n,r,i,a){let o=e.get(f_)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){if(!t.rings.length)continue;let[e,u,d]=t.body.position;for(let f of t.rings){let p=r||f.intensityScale>=.000980392156862745;f.mesh.visible=p;let m=r?1:p?f.intensityScale:0;f.material.uniforms.uIntensityScale.value=m;let h=f.material.uniforms.uSunDir.value;h.set(o[0]-e,o[1]-u,o[2]-d);let g=h.length(),_=NI/g;f.material.uniforms.uSunAngularRadius.value=_,f.material.uniforms.uLightScale.value=n?CT(g):1,h.normalize();let v=f.planetShadowOnRing;if(v.uPlanetCenter.value.set(e-s,u-c,d-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),f.layers){let{dist:e,sinToPole:t}=II(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,f.innerScene,f.outerScene),n=f.thicknessScene*t/Math.max(e,1e-9)*a,r=Math.min(Math.max(Math.ceil(n*PI),1),48);f.layers.count!==r&&(f.layers.count=r,f.material.uniforms.uLayerCount.value=r,f.material.uniforms.uLayerAlphaExp.value=1/r)}let y=f.planetShadow;y&&(y.uRingShadowIntensity.value=m,y.uRingShadowSunAngularRadius.value=_,y.uRingShadowSunDir.value.copy(h),y.uRingShadowPoleDir.value.copy(v.uPlanetPoleDir.value),y.uRingShadowCenter.value.copy(v.uPlanetCenter.value))}}}var RI=Math.PI/180,zI=2451545;function BI(e){let t=e-zI,n=(19.3871+.52402073*t)*RI;return((270.3871+.524038496*t+((10.691+3e-7*t)*Math.sin(n)+.623*Math.sin(2*n)+.05*Math.sin(3*n)+.005*Math.sin(4*n)+5e-4*Math.sin(5*n)))%360+360)%360}function VI(e,t,n){let r=e.length,i=r-1;for(let t=0;t<r-1;t++)if(n<e[t+1]){i=t;break}let a=(i+1)%r,o=i===r-1?360-e[i]:e[a]-e[i],s=(n-e[i])/o;return t[i]+(t[a]-t[i])*s}function HI(e,t){let n=e.seasonal;if(!n)return e;let r=VI(n.lsDeg,n.dustTauFactor,t),i=VI(n.lsDeg,n.dustScaleHeightKm,t),a=VI(n.lsDeg,n.pressureFactor,t),o=r*e.mieScaleHeightKm/i,s=(e,t)=>[e[0]*t,e[1]*t,e[2]*t];return{...e,rayleighScatterPerKm:s(e.rayleighScatterPerKm,a),mieScatterPerKm:s(e.mieScatterPerKm,o),mieAbsorptionPerKm:s(e.mieAbsorptionPerKm,o),mieScaleHeightKm:i,seasonal:void 0}}var UI=new WeakMap,WI=.25;function GI(e,t){if(!e.seasonal)return e;let n=Math.round(BI(t)/WI),r=UI.get(e);if(r&&r.lsQ===n)return r.params;let i=HI(e,n*WI);return UI.set(e,{lsQ:n,params:i}),i}var KI=new J,qI=new J,JI=[.2126,.7152,.0722];function YI(e,t,n){return n<=0?0:e<=t-n?n:e>=t+n?0:e<=t?n-(e-(t-n))**2/(2*n):(t+n-e)**2/(2*n)}function XI(e,t){let n=Math.max(t,0),r=e.rayleighScaleHeightKm*Math.exp(-n/e.rayleighScaleHeightKm),i=e.mieScaleHeightKm*Math.exp(-n/e.mieScaleHeightKm),a=YI(n,e.absorptionCenterKm,e.absorptionWidthKm),o=0;for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*r+(e.mieScatterPerKm[t]+e.mieAbsorptionPerKm[t])*i+e.absorptionPerKm[t]*a;o+=JI[t]*Math.exp(-n)}return o}var ZI=.4,QI=.05,$I=-.105,eL=.3,tL=.05;function nL(e,t,n){let r=XI(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/tL),a=Math.min(1,Math.max(0,(n-$I)/eL));return r*(1+(ZI+(QI-ZI)*a-1)*i)}function rL(e,t,n,r){let i=Math.sqrt(2*n/r),a=Math.sqrt(Math.PI*r/(2*n));return t>=0?e/(Math.tan(t)+1/a):e*a*Math.exp(t/i)}var iL=xT,aL=200,oL=new J,sL=new J,cL=new J,lL=new J;function uL(e,t,n,r){e.uOccluderCount.value=BC(e.uOccluders.value,t,r,n)}function dL(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:oL.set(1,1,1),sunRefraction:null};BA(n&&a.sunTint);let c=e.get(f_);pj(c?.mesh?.material,vb());let l=fj(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=aL,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere||(c.atmosphere.mesh.visible=n,!n))continue;MA(c.atmosphere,a);let e=_b(c.body.data.id);if(e?.seasonal){let t=a.seasonal?GI(e,o):e;if(c.atmosphere.params!==t){NA(c.atmosphere,t);for(let e of c.sunTint??[])qA(e,t,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[f,p,m]=c.body.position,h=c.atmosphere.material.uniforms;h.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let g=h.uSunDir.value.set(d[0]-f,d[1]-p,d[2]-m),_=c.atmosphere.params,v=r?CT(g.length()):_.realisticSunAlways?Math.sqrt(CT(g.length())):1;h.uSunIntensity.value=_.sunIntensity*v*i,g.normalize(),c.mesh&&(KI.set(0,1,0).applyQuaternion(c.mesh.quaternion),h.uSpinAxis.value.copy(KI));let y=c.atmosphere.mesh,b=c.atmosphere.geometryRadiusScene*y.scale.x,x=t.distanceTo(y.position);b>x*.1&&(s.shellProminent=!0),a.eclipseShadows&&uL(h,y.position,g,b);let S=a.insideView&&x<b,C=c.atmosphere.planetRadiusKm,w=x*((C+_.topAltitudeKm)/b)-C,T=S&&kA(_,w),E=S?AA(_,w):0;EA(c.atmosphere,S,T,E),h.uDeepIrradiance.value=iL*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=iL*i,e.uAtmoTDeepBlend.value=E;if(S){s.insideShell=!0;let e=qI.copy(t).sub(y.position).divideScalar(x).dot(g),n=nL(_,w,e);if(s.skyboxIntensity*=n*(1-E),a.refraction&&_.refractivity&&!T){let t=rL(_.refractivity[1]*Math.exp(-Math.max(w,0)/_.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),_.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:lL.copy(qI)})}}let D=x/b;if(a.sunTint&&D<aL){let e=b/(1+_.topAltitudeKm/C)*(c.atmosphere.surfaceRadiusKm/C);cL.copy(t).sub(y.position);let n=h.uSpinAxis.value,r=h.uStretch.value;if(ej(_,cL,g,e,c.atmosphere.surfaceRadiusKm,sL,n,r)){let e=JI[0]*sL.x+JI[1]*sL.y+JI[2]*sL.z;e>1e-4&&s.sunTint.multiply(sL.divideScalar(e))}l&&D<u&&(u=D,YA(l,_,y.position,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var fL=[];function pL(e,t){let n=RC(),r=e.get(f_);if(!r){n.uSunAngularRadius.value=0,n.uOccluderCount.value=0;return}let[i,a,o]=t,s=r.body.position,c=s[0]-i,l=s[1]-a,u=s[2]-o,d=Math.hypot(c,l,u);d>0?(n.uSunDir.value.set(c/d,l/d,u/d),n.uSunAngularRadius.value=Math.asin(Math.min(r.radiusScene/d,1))):n.uSunAngularRadius.value=0;let f=fL,p=0;for(let t of e.values()){if(t.body.data.objectType===W.STAR)continue;let e=t.body.data.radiusKm;!Number.isFinite(e)||e<=0||t.radiusScene<=0||(f[p++]=t)}f.length=p,p>32&&(f.sort((e,t)=>t.radiusScene-e.radiusScene),f.length=32,p=32);let m=n.uOccluders.value;for(let e=0;e<p;e++){let t=f[e],[n,r,s]=t.body.position;m[e].set(n-i,r-a,s-o,t.radiusScene)}n.uOccluderCount.value=p;for(let e=0;e<p;e++)f[e]=void 0;f.length=0;let h=n.uSunDir.value;for(let t of e.values()){let e=t.eclipseShadow;if(!e||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[n,r,s]=t.body.position,c=e.uEclipseSelfPos.value.set(n-i,r-a,s-o);e.uOccluderCount.value=BC(e.uOccluders.value,c,t.radiusScene,h)}}var mL=10;function hL(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&wT(i,s,c);return}let u=e.get(f_)?.body.position,[d,f,p]=t,m=(u?.[0]??0)-d,h=(u?.[1]??0)-f,g=(u?.[2]??0)-p,_=Math.hypot(m,h,g),v=o.set(m,h,g).normalize();r.position.copy(v).multiplyScalar(mL),r.target.position.set(0,0,0),r.intensity=xT*(s?CT(_):1)*c,i&&(i.intensity=0);let y=Math.max(a*2,.001),b=n.bodies.getSystemExtent(l)*10*1.2,x=r.shadow.camera;x.left=x.bottom=-y,x.right=x.top=y,x.near=mL-b,x.far=mL+b,x.updateProjectionMatrix()}var gL=128,_L=256,vL=.25,yL=.32,bL=.35,xL=300,SL=1.25,CL=.05,wL=4e5,TL=new Y,EL=new J;function DL(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/gL,a=[];for(let t=0;t<=gL;t++){let n=t===gL?e:t*i;(t===0||t===gL||!r(n))&&a.push(n)}for(let[r,i]of t){let t=Math.ceil(Math.max(r,0)/n-1e-9),o=Math.floor(Math.min(i,e)/n+1e-9);for(let e=t;e<=o;e++)a.push(e*n)}a.sort((e,t)=>e-t);let o=n*.25,s=[];for(let e of a)s.length&&e-s[s.length-1]<o||s.push(e);return s[0]=0,s[s.length-1]=e,Float64Array.from(s)}function OL(e,t,n){let r=t.length,i=n.length,a=new Float32Array(r*i*3),o=new Float32Array(r*i*3),s=new Float32Array(r*i*2);for(let c=0;c<r;c++){let r=t[c],l=Math.sin(r),u=Math.cos(r);for(let t=0;t<i;t++){let d=n[t],f=-Math.cos(d)*l,p=u,m=Math.sin(d)*l,h=(c*i+t)*3;a[h]=e*f,a[h+1]=e*p,a[h+2]=e*m,o[h]=f,o[h+1]=p,o[h+2]=m;let g=(c*i+t)*2;s[g]=d/(2*Math.PI),s[g+1]=1-r/Math.PI}}let c=new Uint32Array((r-1)*(i-1)*6),l=0;for(let e=0;e<r-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<i-1;t++){let a=e*i+t+1,o=e*i+t,s=(e+1)*i+t,u=(e+1)*i+t+1;n||(c[l++]=a,c[l++]=o,c[l++]=u),r||(c[l++]=o,c[l++]=s,c[l++]=u)}}let u=new Ho;return u.setAttribute(`position`,new Do(a,3)),u.setAttribute(`normal`,new Do(o,3)),u.setAttribute(`uv`,new Do(s,2)),u.setIndex(new Do(c.subarray(0,l),1)),u}function kL(e){e.terrainWindow&&(e.terrainWindow=null,e.currentSegments=void 0)}function AL(e,t,n){let r=e.mesh,i=e.displacementMap;if(!n||!r||!i)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!r} tex=${!!i}`),kL(e),!1;r.updateMatrixWorld(),TL.copy(r.matrixWorld).invert(),EL.copy(t.position).applyMatrix4(TL);let a=Q(gn(e.body.data)),o=EL.length(),s=Math.max(o/a-1,1e-6);if(s>(e.terrainWindow?yL:vL))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${s.toFixed(4)}`),kL(e),!1;let c=i.image?.width??2048,l=2*Math.PI/c,u=Math.acos(1/(1+s)),d=Math.max(l,2*u*SL/_L),f=Math.log2(d/l),p=Math.max(0,Math.ceil(f-1e-9)),m=e.terrainWindow;m&&m.texWidth===c&&f>m.stepLevel-.85&&f<m.stepLevel+.15&&(p=m.stepLevel);let h=l*2**p,g=h*_L/2,_=Math.acos(Math.min(1,Math.max(-1,EL.y/o))),v=Math.atan2(EL.z,-EL.x);if(v<0&&(v+=2*Math.PI),m&&m.texWidth===c){if(m.stepLevel===p){let e=Math.sin(_)*Math.sin(m.centerTheta)*Math.cos(v-m.centerPhi)+Math.cos(_)*Math.cos(m.centerTheta);if(Math.acos(Math.min(1,Math.max(-1,e)))<bL*m.angRadius)return!0}if(performance.now()-m.builtAt<xL)return!0}let y=Math.max(0,_-g),b=Math.min(Math.PI,_+g),x=DL(Math.PI,[[y,b]],h),S=Math.min(Math.PI,g/Math.max(Math.sin(_),CL)),C=Math.max(p,Math.ceil(Math.log2(2*S/_L/l)-1e-9)),w=l*2**Math.max(0,C),T=v-S,E=v+S,D=S>=Math.PI?[[0,2*Math.PI]]:T<0?[[0,E],[T+2*Math.PI,2*Math.PI]]:E>2*Math.PI?[[0,E-2*Math.PI],[T,2*Math.PI]]:[[T,E]],O=DL(2*Math.PI,D,w);if(x.length*O.length>wL)return console.warn(`terrain window for ${e.body.data.id} would need ${x.length}×${O.length} vertices — keeping the uniform sphere`),kL(e),!1;let k=r.geometry;return r.geometry=OL(a,x,O),k.dispose(),console.debug(`terrain window ${e.body.data.id}: ${x.length}×${O.length} grid, level ${p} (tex ${c})`),e.terrainWindow={thetas:x,phis:O,centerTheta:_,centerPhi:v,angRadius:g,stepLevel:p,texWidth:c,builtAt:performance.now()},e.currentSegments=gL,!0}var jL=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],ML=24;function NL(e,t,n,r){if(!n&&!t)return ML;let i=jL[jL.length-1].segs;for(let t of jL)if(e>=t.up){i=t.segs;break}if(i<r){let t=jL.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function PL(e,t,n,r,i){let a=t.fov*Math.PI/180,o=n.domElement.clientHeight/(2*Math.tan(a/2)),s=r.visibility.activeSystemId,c=i;for(let n of e.values()){if(!n.mesh||!n.radiusScene||!n.group.visible||n.cachedDist<=0)continue;let e=n.body.data.objectType===W.STAR,a=n.body.data.id;if((a===c||n.terrainWindow)&&AL(n,t,a===c))continue;let l=NL(n.radiusScene/n.cachedDist*o,e,s?a===s||r.visibility.isInActiveSystem(n.body.data.parentId):a===i,n.currentSegments??64);if(l===n.currentSegments)continue;let u=Q(gn(n.body.data)),d=n.mesh.geometry;n.mesh.geometry=new ru(u,l,l),d.dispose(),n.currentSegments=l}}function FL(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(tM(n)>tM(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return tM(r)<tM(t)?r:t}function IL(e,t,n,r,i,a,o,s){s.apply(e,i);let c=t.fov*Math.PI/180,l=n.domElement.clientHeight/(2*Math.tan(c/2)),u=r.visibility.activeSystemId,d=Mx(),f=d.showClouds,p=tM(qx());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=f);for(let t of e.values()){if(!t.mesh||!t.radiusScene||!t.group.visible||!t.availableTiers?.length||t.cachedDist<=0)continue;let e=t.body.data.id;if(u){if(e!==u&&!r.visibility.isInActiveSystem(t.body.data.parentId))continue}else if(e!==a)continue;let s=t.radiusScene/t.cachedDist*l,c=t.cachedDist/t.radiusScene,f;f=s<256&&c>10?`low`:s<1024&&c>2?`medium`:`high`;let m=tM(t.textureTier),h=Math.min(tM(f),p),g=iM(o,t.availableFrames),_=g!==t.textureFrame,v=h>m;if(d.showSurfaceTexture&&!t.textureLoading&&(v||_)){let e=v?nM(h,t.availableTiers):t.textureTier;e&&uM(t,e,g,i)}let y=t.displacementMeta?.tiers;if(t.displacementMap&&y?.length&&!t.displacementLoading){let e=n.capabilities.maxTextureSize,r=e>=16383?2:+(e>=8192),i=t.displacementTier??`low`,a=nM(Math.min(tM(FL(c,i)),r,p),y);a&&a!==i&&aw(t,a)}if(t.clouds&&t.textureTier){let e=nM(tM(t.textureTier),t.clouds.availableTiers),n=Mj(o,t.clouds.availableFrames,t.clouds.availableCoverage);e&&n&&Fj(t.clouds,e,n)}}}var LL=qO.refMs,RL=new Y,zL=new J,BL=new J,VL=new Hi,HL=new Hi,UL=new J,WL=new J;function GL(e,t,n){return zL.set(e[0],e[1],e[2]),BL.set(t[0],t[1],t[2]),RL.lookAt(zL,BL,n),VL.setFromRotationMatrix(RL).clone()}function KL(e,t,n,r,i){let a=performance.now()-e.focusStartTime,o=e.focusDurationMs>0?Math.min(a/e.focusDurationMs,1):1,s=o<1,c=!!(e.camOriginWorld&&e.camTargetWorld&&e.flyQ0);if(s&&c){let n=o*o*(3-2*o);if(e.focusTruePos=L_(e.focusOriginWorld,e.focusTargetWorld,n),r(),e.orbitFly){let r=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2],i;if(e.arcOrbit)i=z_(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=L_(e.camOriginWorld,e.camTargetWorld,t)}t.position.set(i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]),r&&!e.arcOrbit?(t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2]),HL.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,HL,n)):t.lookAt(e.focusTargetWorld[0]-e.focusTruePos[0],e.focusTargetWorld[1]-e.focusTruePos[1],e.focusTargetWorld[2]-e.focusTruePos[2])}else{let r;if(e.cameraStaysOnBody)r=e.camTargetWorld;else{let t=o*o*o;r=L_(e.camOriginWorld,e.camTargetWorld,t)}let i=GL(r,e.focusTargetWorld,t.up);t.quaternion.slerpQuaternions(e.flyQ0,i,n),t.position.set(r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2])}return!1}if((e.focusTruePos[0]!==e.focusTargetWorld[0]||e.focusTruePos[1]!==e.focusTargetWorld[1]||e.focusTruePos[2]!==e.focusTargetWorld[2])&&(e.focusTruePos=[...e.focusTargetWorld],r(),i()),n.target.set(0,0,0),e.camTargetWorld){let r=e.camTargetWorld[0]-e.focusTruePos[0],i=e.camTargetWorld[1]-e.focusTruePos[1],a=e.camTargetWorld[2]-e.focusTruePos[2];t.position.set(r,i,a),n.enableDamping=!1,n.update(),n.enableDamping=!0,t.position.set(r,i,a),e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1}return!n.update()}function qL(e,t,n,r,i,a=!1){if(e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...t],e.focusStartTime=performance.now(),e.arcOrbit=!1,e.camOriginOffset=null,i){e.camOriginWorld=r,e.camTargetWorld=[...i],e.camTargetOffset=[i[0]-t[0],i[1]-t[1],i[2]-t[2]],e.cameraStaysOnBody=!1,e.flyQ0=n.quaternion.clone();let a=GL([i[0]-e.focusTruePos[0],i[1]-e.focusTruePos[1],i[2]-e.focusTruePos[2]],[t[0]-e.focusTruePos[0],t[1]-e.focusTruePos[1],t[2]-e.focusTruePos[2]],n.up),o=R_(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(KO(o,YO),GO(s,XO))}else e.camOriginWorld=r,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],e.cameraStaysOnBody=!0,e.flyQ0=n.quaternion.clone(),UL.set(0,0,-1).applyQuaternion(e.flyQ0),WL.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=GO(UL.angleTo(WL),qO);if(a){let t=e.focusOriginWorld[0]!==e.focusTargetWorld[0]||e.focusOriginWorld[1]!==e.focusTargetWorld[1]||e.focusOriginWorld[2]!==e.focusTargetWorld[2];(i||t)&&(e.focusDurationMs=0)}}function JL(e,t,n,r,i=!1){e.camOriginWorld=n,e.camTargetWorld=[...r],e.camTargetOffset=[r[0]-e.focusTruePos[0],r[1]-e.focusTruePos[1],r[2]-e.focusTruePos[2]],e.camOriginOffset=[n[0]-e.focusTruePos[0],n[1]-e.focusTruePos[1],n[2]-e.focusTruePos[2]],e.focusOriginWorld=[...e.focusTruePos],e.focusTargetWorld=[...e.focusTruePos],e.focusStartTime=performance.now(),e.orbitFly=!0,e.arcOrbit=!0,e.cameraStaysOnBody=!1,e.flyQ0=t.quaternion.clone();let a=R_(n,r);UL.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),WL.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=UL.angleTo(WL);e.focusDurationMs=Math.max(KO(a,YO),GO(o,XO)),i&&(e.focusDurationMs=0)}var YL={[W.STAR]:1e3,[W.PLANET]:100,[W.DWARF_PLANET]:10,[W.ASTEROID]:.1,[W.ASTEROID_INNER]:.1,[W.ASTEROID_MAIN_BELT]:.1,[W.ASTEROID_CENTAUR]:1,[W.ASTEROID_TROJAN]:1,[W.ASTEROID_TNO]:1,[W.COMET]:1,[W.MOON]:1},XL=5e-4,ZL=new J,QL=new J;function $L(e){return YL[e.data.objectType]??gn(e.data)*.25}function eR(e,t){return Q((t??gn(e.data))+$L(e))}function tR(e,t,n,r){let i=t.data.radiusKm;if(!Number.isFinite(i)||i<=0)return;let a=t.position[0]-n[0],o=t.position[1]-n[1],s=t.position[2]-n[2],c=Math.hypot(a,o,s),l=r?.centerOffsetScene,u=a+(l?l[0]:0),d=o+(l?l[1]:0),f=s+(l?l[2]:0),p=e.position.x-u,m=e.position.y-d,h=e.position.z-f,g=Math.hypot(p,m,h);if(r?.seated){if(g<1e-9){e.position.set(u,d+c+Q(XL),f);return}let t=Math.tan(e.fov*Math.PI/360)*e.near,n=t*e.aspect,i=0;for(let[a,o,s]of[[0,0,0],[-n,-t,-e.near],[n,-t,-e.near],[-n,t,-e.near],[n,t,-e.near]]){QL.set(a,o,s).applyQuaternion(e.quaternion);let t=p+QL.x,n=m+QL.y,l=h+QL.z,u=Math.hypot(t,n,l);if(u<1e-12)continue;ZL.set(t/u,n/u,l/u).applyQuaternion(r.invQuat);let d=r.radialKm([ZL.x,ZL.y,ZL.z]),f=(d===null?c:Q(d))+Q(XL);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/g;e.position.set(e.position.x+p*a,e.position.y+m*a,e.position.z+h*a);return}let _=$L(t);if(g>=Q((r?.outerRadiusKm??i)+_))return;let v=i;r&&g>1e-9&&(ZL.set(p/g,m/g,h/g).applyQuaternion(r.invQuat),v=r.radialKm([ZL.x,ZL.y,ZL.z])??i);let y=Q(v+_),b=c>0?Math.min(y,c):y;if(!(g>=b)){if(g<1e-9)p=0,m=b,h=0;else{let e=b/g;p*=e,m*=e,h*=e}e.position.set(u+p,d+m,f+h)}}function nR(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=aC([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=lC(a,t.minLon,t.maxLon),l=Math.min(Math.max(o,t.minDistance??0),t.maxDistance??1/0);if(s===i&&c===a&&l===o)return;let[u,d,f]=oC([0,0,0],s,c,l,n);r.set(u,d,f)}var rR=50,iR=20;function aR(e){return e<=0?`none`:e<iR?`full`:e<rR?`half`:`none`}function oR(e,t){return e.data.validityStart<=t&&t<=e.data.validityEnd}var sR=class{pendingDefaults=new Set;defaults=new Set;userPromoted=new Set;autoPromoted=new Set;pinned=new Set;pinPromoted=new Set;groupTargets=null;groupMode=`none`;smallBodyZone=null;countStableLo=1/0;countStableHi=-1/0;constructor(e){this.deps=e,e.ctx.bodies.onBodiesAdded(()=>{this.onBodiesAdded(),this.buildPinned(),this.autoPromoteAsteroidMoons(),this.reevaluateEarthSatMode(),this.smallBodyZone!==null&&this.refreshSmallBodyEmphasis()}),e.ctx.onEarthSatRollover(()=>this.reevaluateEarthSatMode()),e.ctx.onGroupFilterChange(e=>this.applyGroupFilter(e)),this.applyGroupFilter(e.ctx.earthSatFilter),e.ctx.onSmallBodyFilterChange(e=>this.applySmallBodyFilter(e)),this.applySmallBodyFilter(e.ctx.smallBodyFilter),Vv().then(e=>{let t=[],n=e=>{if(!this.defaults.add(e)||this.deps.bodyObjects.has(e))return;let n=this.deps.ctx.getBody(e);if(!n){this.pendingDefaults.add(e);return}this.shouldAutoPromote(n,e)&&t.push(n)};for(let t of e.keys())n(t);for(let e of m_)n(e);this.buildBatch(t),this.autoPromoteAsteroidMoons();let r=!1;for(let e of this.userPromoted)this.defaults.has(e)&&(this.userPromoted.delete(e),r=!0);r&&this.emitUserPromotedCount()})}autoPromoteAsteroidMoons(){let e=this.deps.ctx.bodies.asteroidBodiesByZone.get(`small_body_moons`);if(!e||e.size===0)return;let t=[],n=new Set;for(let r of e.keys()){let i=e.getKey(r);if(!i||i.data.objectType!==W.MOON||!this.isDefault(i.data.parentId))continue;let a=this.deps.ctx.getBody(i.data.parentId);!a||!_n(a.data.objectType)||(!this.deps.bodyObjects.has(a.data.id)&&!n.has(a.data.id)&&(n.add(a.data.id),t.push(a)),this.deps.bodyObjects.has(i.data.id)||t.push(i))}this.buildBatch(t)}onBodiesAdded(){if(this.pendingDefaults.size===0)return;let e=[];for(let t of this.pendingDefaults){let n=this.deps.ctx.getBody(t);n&&(this.pendingDefaults.delete(t),this.shouldAutoPromote(n,t)&&e.push(n))}this.buildBatch(e)}shouldAutoPromote(e,t){return e.data.objectType!==W.BARYCENTER&&e.data.objectType!==W.LAGRANGE_POINT?!0:m_.has(t)}isDefault(e){return this.defaults.has(e)}ensureBodyObjects(e){this.buildBodyInstance(e)&&this.finalizeBuilds()}buildBodyInstance(e,t,n=!1){let{bodyObjects:r,ctx:i,clock:a,scene:o,clickables:s,meshToBody:c,circleTexture:l,renderer:u}=this.deps;if(r.has(e.data.id))return!1;if(AT(e,a.jd,i),!e.orbitElements&&!e.data.unplaceable&&e.data.orbitalSource!==U.SPICE_PROBE){e.orbitElements=e.data;let t=r.get(e.data.parentId);t&&(e.orbitCenter=[...t.body.position])}_j([e],o,s,c,r,l,u.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let d=r.get(e.data.id);if(d&&!e.data.name&&cM(d),e.data.objectType===W.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(_n(e.data.objectType)||e.data.objectType===W.COMET){let t=this.deps.ctx.bodies.findAsteroidZone(e.data.id);t&&i.bodies.dirtyAsteroidZones.add(t)}let f=e.data.id;return this.defaults.has(f)||(n?this.autoPromoted.add(f):(this.userPromoted.add(f),this.emitUserPromotedCount())),!0}finalizeBuilds(){wN(this.deps.bodyObjects,this.deps.scene,this.deps.pointClouds.basis(),this.deps.clock.jd),this.deps.assignMapLayerToTrails(),this.deps.repositionAll(),this.deps.pointClouds.rebuildMinor()}buildBatch(e,t,n=!1){let r=!1;for(let i of e)this.buildBodyInstance(i,t,n)&&(r=!0);r&&this.finalizeBuilds()}applyGroupFilter(e){this.groupTargets=e,this.reevaluateEarthSatMode()}applySmallBodyFilter(e){this.smallBodyZone=e?.kind===`class`?`small_bodies/${e.className}`:null,this.refreshSmallBodyEmphasis()}refreshSmallBodyEmphasis(){let e=this.smallBodyZone;if(e===null){this.deps.pointClouds.setEmphasizedSmallBodyZone(null,null);return}let t=this.deps.ctx.bodies.asteroidBodiesByZone.get(e)?.size??0;this.deps.pointClouds.setEmphasizedSmallBodyZone(e,t)}onSimTimeChanged(){let e=this.deps.clock.jd;e>this.countStableLo&&e<this.countStableHi||this.reevaluateEarthSatMode()}reevaluateEarthSatMode(){let e=this.deps.ctx.bodies.spacecraftByParent.get(p_),t=this.currentMemberCount(e),n=aR(t);this.deps.pointClouds.setEarthSatEmphasis(t);let r=n!==this.groupMode;if(this.teardownAutoPromoted(r),this.groupMode=n,n===`none`||!e)return;let i=this.deps.clock.jd,a=[];for(let t of e.values())this.groupTargets&&!this.groupTargets.has(t.data.id)||oR(t,i)&&(this.deps.bodyObjects.has(t.data.id)||a.push(t));if(a.length===0)return;let o=n===`half`?new Set(a.map(e=>e.data.id)):void 0;this.buildBatch(a,o,!0)}currentMemberCount(e){if(this.countStableLo=-1/0,this.countStableHi=1/0,!e)return 0;let t=this.deps.clock.jd,n=0;for(let r of e.values()){if(this.groupTargets&&!this.groupTargets.has(r.data.id))continue;let{validityStart:e,validityEnd:i}=r.data;e<=t?e>this.countStableLo&&(this.countStableLo=e):e<this.countStableHi&&(this.countStableHi=e),i<t?i>this.countStableLo&&(this.countStableLo=i):i<this.countStableHi&&(this.countStableHi=i),oR(r,t)&&n++}return n}teardownAutoPromoted(e){if(this.autoPromoted.size===0)return;let t=this.deps.getFocusedId(),n=this.deps.clock.jd,r=[];for(let i of this.autoPromoted){if(i===t)continue;if(e||this.groupTargets&&!this.groupTargets.has(i)){r.push(i);continue}let a=this.deps.bodyObjects.get(i)?.body;a&&!oR(a,n)&&r.push(i)}r.length!==0&&this.tearDownBodies(r,this.autoPromoted)}setPinned(e){this.pinned=new Set(e);let t=this.deps.getFocusedId(),n=[...this.pinPromoted].filter(e=>!this.pinned.has(e));t&&n.includes(t)&&(this.pinPromoted.delete(t),this.userPromoted.add(t),this.emitUserPromotedCount()),this.tearDownBodies(n.filter(e=>e!==t),this.pinPromoted),this.buildPinned()}buildPinned(){let e=!1;for(let t of this.pinned){let n=this.deps.ctx.getBody(t);!n||un(n)||n.data.objectType===W.MOON||this.buildBodyInstance(n)&&(e=!0,this.userPromoted.delete(t)&&this.pinPromoted.add(t))}e&&(this.emitUserPromotedCount(),this.finalizeBuilds())}clearUserPromoted(){let e=this.deps.getFocusedId(),t=[...this.userPromoted].filter(t=>t!==e);this.tearDownBodies(t,this.userPromoted),this.emitUserPromotedCount()}tearDownBodies(e,t){if(e.length===0)return;let{bodyObjects:n,ctx:r,scene:i,clickables:a,meshToBody:o,pointClouds:s}=this.deps,c=new Set,l=new Set;for(let r of e){let e=n.get(r);if(!e){t.delete(r);continue}e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),fO(e),lM(e),LM(e),i.remove(e.group);for(let t of e.extraObjects)i.remove(t);if(e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),mj(e.mesh.material);let t=a.indexOf(e.mesh);t>=0&&a.splice(t,1),o.delete(e.mesh)}e.atmosphere&&=(e.atmosphere.mesh.geometry.dispose(),mj(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),mj(e.trail.material));let s=e.body.data.objectType;if(s===W.SPACECRAFT)c.add(e.body.data.parentId);else if(_n(s)||s===W.COMET){let e=this.deps.ctx.bodies.findAsteroidZone(r);e&&l.add(e)}n.delete(r),t.delete(r)}for(let e of c)r.bodies.dirtySpacecraftGroups.add(e);for(let e of l)r.bodies.dirtyAsteroidZones.add(e);(c.size>0||l.size>0)&&s.rebuildMinor()}emitUserPromotedCount(){if(!this.deps.onUserPromotedChange)return;let e=this.deps.getFocusedId(),t=this.userPromoted.size;e&&this.userPromoted.has(e)&&t--,this.deps.onUserPromotedChange(t)}},cR=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r,i){this.deps=e,this.focusedBody=t,this.promotion=new sR({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer:i,circleTexture:r,clickables:e.clickables,meshToBody:e.meshToBody,hoveredBodyIds:n,pointClouds:e.pointClouds,onBodyClick:e=>this.handleFocus(e),assignMapLayerToTrails:e.assignMapLayerToTrails,repositionAll:e.repositionAll,getFocusedId:()=>this.focusedBody?.data.id,onUserPromotedChange:e.callbacks.onUserPromotedChange})}get current(){return this.focusedBody}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||$D(t))return;let n=this.deps.bodyObjects.get(t.data.id)?.mesh;if(!n)return;let r=n.quaternion;return[r.x,r.y,r.z,r.w]}cameraTruePos(){let{focus:e,camera:t}=this.deps;return[e.focusTruePos[0]+t.position.x,e.focusTruePos[1]+t.position.y,e.focusTruePos[2]+t.position.z]}syncUpgradeTargets(e){let{ctx:t,scene:n,clickables:r,meshToBody:i,bodyObjects:a,pointClouds:o,clock:s,loadTexture:c,assignMapLayerToTrails:l}=this.deps,u=lR(e,t),d=new Set(u.map(e=>e.data.id));for(let e of this.upgradeTargetIds){if(d.has(e))continue;let t=a.get(e);t&&(vj(t.body)?bj(t,n,r,i):fO(t))}let f=!1;for(let t of u){if(this.upgradeTargetIds.has(t.data.id))continue;this.promotion.ensureBodyObjects(t);let o=a.get(t.data.id);if(!o){d.delete(t.data.id);continue}vj(t)&&(yj(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(wN(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e){if(e.positionUnknown)return;let{focus:t,camera:n}=this.deps;qL(t,[...e.position],n,this.cameraTruePos(),void 0,Mx().resolvedReducedMotion)}focusOnPoint(e,t){let{focus:n,camera:r,callbacks:i}=this.deps,a=this.cameraTruePos(),o;if(t!==void 0){let n=this._tmpV3.set(e[0]-a[0],e[1]-a[1],e[2]-a[2]).normalize().negate();o=[e[0]+n.x*t,e[1]+n.y*t,e[2]+n.z*t]}this.focusedBody=void 0,qL(n,[...e],r,a,o,Mx().resolvedReducedMotion);let s=aC(o??a,e,void 0);i.onCameraPosition?.(s.latitude,s.longitude,s.distance)}handleFocus(e){if(this.readerFocusFilter&&!this.readerFocusFilter(e))return;if(this.focusedBody?.data.id===e.data.id){this.deps.callbacks.onFocusChange(e);return}if(this.setFocusTarget(e),e.positionUnknown)return;let{latitude:t,longitude:n,distance:r}=aC(this.cameraTruePos(),e.position,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(t,n,r)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;un(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=wM(u,r),f=wM(e,r),p=u&&(un(u)?u.featureAnchor.hostId:u.data.id),m=un(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&fO(e)}if(d&&d!==f){let e=r.get(d);e&&LM(e)}this.focusedBody=e,un(e)||(n.bodies.focusFeature=null),i.minDistance=eR(e,NO(r.get(e.data.id)));let g=un(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),un(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus(),e.positionUnknown||qL(o,[...e.position],s,this.cameraTruePos(),t,Mx().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,clock:a,focus:o,camera:s,callbacks:c,pointClouds:l}=this.deps,u=i.getBody(e);if(!u)return 0;if(i.bodies.bodiesById.has(e)||AT(u,a.jd,i),u.positionUnknown)return this.setFocusTarget(u),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=oC(u.position,n,r,t,this.focusedBodyQuat(u));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u.position[0]-e[0],u.position[1]-e[1],u.position[2]-e[2]).normalize().negate();d=[u.position[0]+n.x*t,u.position[1]+n.y*t,u.position[2]+n.z*t]}let f=aC(d??this.cameraTruePos(),u.position,this.focusedBodyQuat(u));return c.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?this.focusedBody?.data.id===e&&R_(o.focusTruePos,u.position)<eR(u)?(o.focusTruePos=[...u.position],this.deps.repositionAll(),l.rebuildBasis(),JL(o,s,this.cameraTruePos(),d,Mx().resolvedReducedMotion)):(this.setFocusTarget(u,d),n!==void 0&&r!==void 0&&(o.orbitFly=!0)):this.setFocusTarget(u),o.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e);!i||i.positionUnknown||(this.settleOnBodyInstant(i),this.snapToBodyFrame(t,n,r))}snapToBodyFacing(e,t,n,r){let{ctx:i,camera:a,controls:o,callbacks:s}=this.deps,c=i.getBody(e);if(!c||c.positionUnknown)return;this.settleOnBodyInstant(c);let l=i.getBody(t)?.position??[0,0,0],u=sC(c.position,l,n,r);a.position.set(u[0],u[1],u[2]),o.update();let d=aC(u,[0,0,0]);s.onCameraPosition?.(d.latitude,d.longitude,d.distance),this.pendingInitialView=null}settleOnBodyInstant(e){let{focus:t,pointClouds:n}=this.deps;this.setFocusTarget(e),t.focusTruePos=[...e.position],t.focusOriginWorld=[...e.position],t.focusTargetWorld=[...e.position],t.focusStartTime=-LL,t.camOriginWorld=null,t.camTargetWorld=null,t.flyQ0=null,t.orbitFly=!1,t.arcOrbit=!1,t.cameraStaysOnBody=!1,this.deps.repositionAll(),n.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!$D(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=oC([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=aC(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),s&&c[0]===0&&c[1]===0&&c[2]===0&&c[3]===1&&(this.pendingInitialView={latitude:e,longitude:t,zoom:n})}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===1){this.pendingInitialView=null;return}let n=oC([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function lR(e,t){if(!e)return[];if(un(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&vj(n)?[n]:[]}let n=[];if(vj(e)&&n.push(e),e.data.objectType===W.MOON||e.data.orbitalSource===U.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var uR=1e-6;function dR(e){return e.data.name??e.data.id}var fR=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}coverageFor(e){let t=this.coverage.get(e);if(t!==void 0)return t??void 0;this.pending.has(e)||(this.pending.add(e),hx(e,!1).then(t=>this.coverage.set(e,t.global?.coverage??null)).catch(()=>this.coverage.set(e,null)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.id??null,r=n===null?void 0:this.coverageFor(n);if(!e||!r){this.disarm();return}this.armedProbeId!==n&&(this.dismissNotice(),this.armedProbeId=n);let i=r.end_jd-uR,a=r.start_jd+uR;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:i,backwardJd:a,onHit:t=>this.onHit(e,t,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:dR(e),direction:t>=n?`forward`:`backward`,jd:t}),this.noticeShown=!0}disarm(){this.armedProbeId!==null&&(this.armedProbeId=null,this.dismissNotice(),this.clock.setBoundaryStops(null))}dismissNotice(){this.noticeShown&&=(this.notices.dismiss(`coverage-pause`),!1)}},pR=class{group=new za;extensions=new Set;constructor(){this.group.matrixAutoUpdate=!1,this.group.frustumCulled=!1}add(e){this.extensions.add(e),this.group.add(e.object)}remove(e){this.extensions.delete(e)&&(this.group.remove(e.object),e.dispose())}update(e){for(let t of this.extensions)t.update(e)}clear(e){for(let t of[...this.extensions])e?.(t)||(this.extensions.delete(t),this.group.remove(t.object),t.dispose())}dispose(){this.clear()}},mR=Math.PI/180;function hR(e){return`latitude`in e}function gR(e,t){let n=e*mR,r=t*mR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function _R(e,t,n,r,i,a){let o=2*(e.y*r-e.z*n),s=2*(e.z*t-e.x*r),c=2*(e.x*n-e.y*t);i[a]=t+e.w*o+(e.y*c-e.z*s),i[a+1]=n+e.w*s+(e.z*o-e.x*c),i[a+2]=r+e.w*c+(e.x*s-e.y*o)}function vR(e,t,n){return MT(e,n,t)?e.position:null}function yR(e,t,n,r){let[i,a,o]=n;if(hR(e)){let n=Q(gn(t.data)+(e.altitudeKm??0)),[s,c,l]=gR(e.latitude,e.longitude),u=t.orientation?mC(t.orientation,r,t.nutPrec):null;if(!u)return[i+s*n,a+c*n,o+l*n];let d=[0,0,0];return _R(u,s,c,l,d,0),[i+d[0]*n,a+d[1]*n,o+d[2]*n]}let s=typeof e.offsetKm==`function`?e.offsetKm(r):e.offsetKm;if(s===null)return null;if(s===void 0)return[i,a,o];let[c,l,u]=kF(s);return[i+c,a+l,o+u]}function bR(e,t,n){let r=t.getBody(e.body),i=r&&vR(r,t,n);return i?yR(e,r,i,n):null}function xR(e,t,n,r){let i=n.getBody(e.body),a=i&&vR(i,n,r);if(!a)return null;let o=t[0]-a[0],s=t[1]-a[1],c=t[2]-a[2],l=Math.hypot(o,s,c);return l===0?null:[o/l,s/l,c/l]}function SR(e){let t=ig/10;return[e[0]*t,-e[2]*t,e[1]*t]}function CR(e,t,n){let r=bR(e.position,t,n),i=bR(e.target,t,n);if(!r||!i)return null;let[a,o,s]=e.up??[0,0,1];return{position:r,target:i,up:[a,s,-o]}}var wR=.02,TR=1e-4;function ER(e){return e?.4:.05}function DR(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=$D(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){if(!n)continue;let r=Q(gn(n.data));if(!(r>0))continue;let i=Math.hypot(e.position.x-(n.position[0]-t[0]),e.position.y-(n.position[1]-t[1]),e.position.z-(n.position[2]-t[2]));s=Math.min(s,i-r)}let c=o?Q(gn(o.data)):0,l=Math.tan(Vi.degToRad(e.getEffectiveFOV())/2);return{rotate:OR(c>0?(a-c)*l/(Math.PI*c):1,TR),translate:OR(s/a,wR)}}function OR(e,t){return Math.min(1,Math.max(t,e))}var kR=Math.PI/180;function AR(e,t){let n=e*kR,r=t*kR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function jR(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new nk(i),[o,s,c]=AR(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function MR(e){e.parent?.remove(e),e.element.remove()}var NR=new J;function PR(e,t,n){if(!e)return;let r=t.get(p_);if(!r?.mesh)return;NR.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=NR.x,a=NR.y,o=NR.z,s=r.mesh.position,c=n.position.x-s.x,l=n.position.y-s.y,u=n.position.z-s.z,d=r.radiusScene,f=d*d;e.visible=c*c+l*l+u*u<=f||i*c+a*l+o*u>f}var FR=-1,IR=1.2,LR=Q(1e6),RR=.02,zR=2,BR=2.3,VR=.9,HR=new J,UR=.25,WR=10,GR=4,KR=4,qR=28,JR=.02,YR=class e{renderer;composer;atmoDepthPass;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=eN();pointClouds;systemData;positionDiagnostics=new MI;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new pR;cameraHold=null;holdingCamera=!1;_tmpV3=new J;cameraBand=null;focusableBodies=null;limitsArmed=!1;bodySelectEnabled=!0;featureSelectEnabled=!0;modelScene;modelCamera;modelLight;overlayActive=!1;modelShadowPlane=null;_tmpUp=new J;_tmpSun=new J;_planeNormal=new J(0,0,1);_modelRaycaster=new Rd;_pickNdc=new q;showPointingAxes=!1;pointingAxes=null;cameraUp;skyboxAdjuster;skyDebugMarkers;haloDebug;travelPath;orbitPreview;previewFlyBodyId=null;travelFocus=null;focus={focusTruePos:[0,0,0],focusOriginWorld:[0,0,0],focusTargetWorld:[0,0,0],camOriginWorld:null,camTargetWorld:null,camTargetOffset:null,camOriginOffset:null,flyQ0:null,orbitFly:!1,arcOrbit:!1,cameraStaysOnBody:!1,focusStartTime:0,focusDurationMs:LL};lastUpdatedJd=NaN;get placedJd(){return this.lastUpdatedJd}lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;disposed=!1;lastHostReadVersion=0;focusWasOutOfRange=!1;_positionMapScratch=new Map;frameIndex=0;static WAKE_FRAMES=30;static IDLE_HEARTBEAT_FRAMES=10;static REALTIME_FRAME_MS=30;wakeUntilFrame=e.WAKE_FRAMES;lastRenderedFrame=0;lastRenderMs=0;lastRenderedJd=NaN;lastRenderedFocusKey=``;lastRenderedCamPos=new J(NaN,NaN,NaN);lastRenderedCamQuat=new Hi;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=Yx();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;halosShown=!0;textureLoader=new Ju;appearances=new dM;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(f_)?.extraObjects.find(e=>e instanceof dd)}tightFar=!1;sunProxyK=1;sunBaseMeshScale=1;sunBaseCoronaScale=0;userLocationMarker=null;labelContainer;static MAP_LAYER=1;static ATMO_DEPTH_LAYER=2;constructor(t,n,r,i,a,o){this.canvas=t,this.ctx=r,r.hasMeshBody=e=>this.bodyObjects.has(e),this.clock=i,this.callbacks=o,this.outOfRange=new yI(o.notices),this.labelContainer=n;let s=kT(t,n,r);this.viewportH=t.clientHeight||1,this.renderer=s.renderer,this.labelRenderer=s.labelRenderer,this.scene=s.scene,this.scene.add(this.extensions.group),this.camera=s.camera,this.composer=s.composer,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new xj(c.x,c.y),this.modelScene=new qa,this.modelScene.environment=TT(this.renderer),this.modelScene.environmentIntensity=ST,this.modelCamera=new sd(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new hd(16777215,bT);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new md(16777215,xT),this.modelLight.castShadow=!0,this.modelLight.shadow.mapSize.set(this.tier.shadowMapSize,this.tier.shadowMapSize),this.modelLight.shadow.camera.left=-4,this.modelLight.shadow.camera.right=4,this.modelLight.shadow.camera.top=4,this.modelLight.shadow.camera.bottom=-4,this.modelLight.shadow.camera.near=4,this.modelLight.shadow.camera.far=28,this.modelLight.shadow.bias=-1e-4,this.modelLight.shadow.normalBias=.02,this.modelScene.add(this.modelLight),this.modelScene.add(this.modelLight.target),this.modelShadowPlane=new As(new $l(40,40),new iu({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new AN(this.scene),this.skyDebugMarkers=new JN(this.scene),this.haloDebug=new rP(this.canvas),this.travelPath=new aI(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new uI(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),pS(this.scene,this.renderer,r,()=>this.disposed);let u=r.bodies.majorBodies.find(e=>e.data.id===f_),d=r.getBody(a.id),f=d&&!d.positionUnknown?d:void 0,p=r.bodies.majorBodies.find(e=>e.data.id===uC)||u,m=f??p,h=m?.position??[0,0,0];this.focus.focusTruePos=[...h],this.focus.focusOriginWorld=[...h],this.focus.focusTargetWorld=[...h],this.focus.focusStartTime=-LL,this.pointClouds=new IP(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(h),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new LS(this.camera,t),this.controls.enableDamping=!0,this.controls.dampingFactor=ER(Mx().resolvedReducedMotion),this.controls.minDistance=m?eR(m):Q(.01),this.controls.maxDistance=31620.5*10,this.controls.target.set(0,0,0),this.controls.update(),this.controls.addEventListener(`end`,this.onControlsEnd),this.controls.addEventListener(`start`,this.invalidate),this.controls.addEventListener(`start`,this.armLimits),this.controls.addEventListener(`end`,this.invalidate);for(let n of e.INPUT_EVENTS)t.addEventListener(n,this.invalidate,{passive:!0});window.addEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded=r.bodies.onBodiesAdded(this.invalidate),this.cameraUp=new tk(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new ON(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new cR({ctx:r,clock:i,camera:this.camera,controls:this.controls,scene:this.scene,bodyObjects:this.bodyObjects,clickables:this.clickables,meshToBody:this.meshToBody,callbacks:o,focus:this.focus,pointClouds:this.pointClouds,systemData:this.systemData,loadTexture:e=>this.maybeLoadTexture(e),repositionAll:()=>this.repositionAll(),assignMapLayerToTrails:()=>this.assignMapLayerToTrails()},m,this.hoveredBodyIds,this.circleTexture,this.renderer),this.coverageWatch=new fR(i,o.notices);let g=f?a:{latitude:45,longitude:0,zoom:15},_=oC([0,0,0],g.latitude,g.longitude,g.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(..._),this.focusController.setPendingInitialView({latitude:g.latitude,longitude:g.longitude,zoom:g.zoom}),m&&r.visibility.setFocused(m),r.visibility.updateCamera(g.zoom,this.clock.jd),o.onFocusChange(m),this.buildScene(),m&&this.focusController.promotion.ensureBodyObjects(m),m&&this.focusController.syncUpgradeTargets(m),this.repositionAll(),m&&this.maybeLoadTexture(m),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new UO(this.renderer,this.camera),this.pointerInteraction=new RO(t,this.camera,r,i,this.focus,this.clickables,this.meshToBody,e=>this.focusController.handleFocus(e),(e,t)=>this.pickFocusedModel(e,t),this.gpuPick,()=>[...this.pointClouds.asteroids().values(),...this.pointClouds.spacecraft().values()],this.pointClouds.pickRegistry),this.pointerInteraction.attach(),this.tick()}buildScene(){_j(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,this.circleTexture,this.renderer.domElement,e=>this.focusController.handleFocus(e),(e,t)=>{t?this.hoveredBodyIds.add(e):this.hoveredBodyIds.delete(e),this.invalidate()}),this.pointClouds.buildInitial(new Set(this.bodyObjects.keys()));let e=this.pointClouds.basis();(globalThis.requestIdleCallback??(e=>setTimeout(e,0)))(()=>{wN(this.bodyObjects,this.scene,e,this.clock.jd),this.assignMapLayerToTrails()})}setTravelPath(e,t=[],n=[],r=[]){this.travelPath.set(e,t,n,r),this.refreshTravelPath()}setTravelHover(e){this.travelPath.setHovered(e)}setOrbitPreview(e,t=null){this.orbitPreview.set(e),this.refreshOrbitPreview(),t&&this.frameOrbitPreview(t)}frameOrbitPreview(e){let t=this.ctx.getBody(e.bodyId);if(!t)return;let n=Q(e.radiusKm);if(!(n>0)||performance.now()-this.focus.focusStartTime<this.focus.focusDurationMs&&this.previewFlyBodyId===e.bodyId)return;let r=this.focus.focusTruePos,i=t.position[0]-r[0]-this.camera.position.x,a=t.position[1]-r[1]-this.camera.position.y,o=t.position[2]-r[2]-this.camera.position.z,s=Math.hypot(i,a,o);s>n*1.35&&s<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.ctx.getBody(e)?.position??null,this.focus.focusTruePos),this.orbitPreview.updateCameraOffset(this.camera.position))}refreshTravelPath(){if(this.travelPath.isEmpty){this.reserveTravelLabelSpace();return}let e=this.travelPath.centerId,t=e?this.ctx.getBody(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.clock.jd),this.travelPath.reposition(t.position,this.focus.focusTruePos,e=>this.ctx.getBody(e)?.position??null),this.travelPath.updateCameraOffset(this.camera.position),this.reserveTravelLabelSpace()}reserveTravelLabelSpace(){this.travelPath.reserveLabelSpace(this.camera,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)}focusOnPathPoint(e,t){this.disarmLimits();let n=this.ctx.getBody(e);if(!n)return;let[r,i,a]=kF(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n.position);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=kF(t);this.travelFocus={centerId:e,local:[n,r,i]}}travelFocusWorld(e){let t=this.travelFocus;return t?[e[0]+t.local[0],e[1]+t.local[1],e[2]+t.local[2]]:null}refreshTravelFocus(){if(!this.travelFocus)return;if(this.focusController.current){this.travelFocus=null;return}let e=this.ctx.getBody(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e.position);if(!t)return;let n=this.focus;n.focusTargetWorld=t;let r=n.camTargetOffset;r&&n.camTargetWorld&&(n.camTargetWorld=[t[0]+r[0],t[1]+r[1],t[2]+r[2]]),performance.now()-n.focusStartTime>=n.focusDurationMs&&(n.focusTruePos=[...t])}updateTravelCraftSystem(){let e=this.travelFocus,t=this.travelPath.plan;if(!e||!t){this.ctx.visibility.clearTravelSystem();return}let n=this.ctx.getBody(e.centerId),r=n?this.travelFocusWorld(n.position):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId);if(!t)continue;let n=this.ctx.visibility.resolveSystemId(t);if(!n)continue;let a=this.ctx.visibility.systemReachAU(n);if(!(a>0))continue;let o=R_(r,t.position)/10;!i&&o<=a?i=n:o<=a*2?this.systemData.prefetch(n):this.systemData.discardPrefetch(n)}this.ctx.visibility.setTravelSystem(i)}assignMapLayerToTrails(){for(let t of this.bodyObjects.values())t.trail&&t.trail.layers.set(e.MAP_LAYER)}setImmersive(t){t?(this.camera.layers.disable(e.MAP_LAYER),this.labelContainer.style.display=`none`):(this.camera.layers.enable(e.MAP_LAYER),this.labelContainer.style.display=``)}rebuildMinorPointClouds(){this.pointClouds.rebuildMinor()}repositionAll(){this.repositionBodies(),this.rebuildTrailBasis()}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let[i,a,o]=r.body.position,s=i-e,c=a-t,l=o-n;r.group.position.set(s,c,l);for(let e of r.extraObjects)e.position.set(s,c,l)}this.pointClouds.reposition()}rebuildTrailBasis(){let e=this.focus.focusTruePos,[t,n,r]=e;for(let i of this.bodyObjects.values()){let a=i.trail;if(!a)continue;let o=a.userData.trailBuffer;if(o){$P(i.body,a,o,e,this.clock.jd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;eF(a,s,c.x-t,c.y-n,c.z-r)}}tick=()=>{this.rafId=requestAnimationFrame(this.tick),this.frameIndex++;let t=performance.now(),n=this.lastTickMs?t-this.lastTickMs:0;if(this.lastTickMs=t,this.holdingCamera||this.cameraUp.update(this.clock.jd),this.firstFrame&&(this.firstFrame=!1,this.controls.target.set(0,0,0),this.controls.update()),this.coverageWatch?.sync(this.focusController.current,this.clock.jd),this.clock.tick(performance.now()),!this.shouldRender(t)){this.controls.update(),this.applyReaderLimits(t);return}this.fpsSamples.length<e.FPS_SAMPLE_FRAMES?this.fpsSamples.push(t):(this.fpsSamples[this.fpsSampleHead]=t,this.fpsSampleHead=(this.fpsSampleHead+1)%e.FPS_SAMPLE_FRAMES);let r=this.lastRenderedFrame===this.frameIndex-1?n:0;this.lastRenderedFrame=this.frameIndex,this.lastRenderMs=t,this.lastRenderedJd=this.clock.jd,this.lastRenderedFocusKey=this.focusKey(),this.lastRenderedCamPos.copy(this.camera.position),this.lastRenderedCamQuat.copy(this.camera.quaternion),this.applyJdUpdate(!0),this.refreshTravelFocus(),this.callbacks.onFrame?.(this.clock.jd,r);let i=this.holdingCamera?this.applyHeldCamera():KL(this.focus,this.camera,this.controls,()=>this.repositionAll(),()=>this.pointClouds.rebuildBasis());this.applyReaderLimits(t);let a=this.holdingCamera?void 0:this.focusController.current;if(a){let e=F_(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||un(a);t&&tR(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),AO(this.bodyObjects.get(a.data.id))&&tR(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(DR(this.camera,this.focus.focusTruePos,a,t,n))}else this.setMotionScale({rotate:1,translate:1});if(this.pendingUrlWrite&&i){this.pendingUrlWrite=!1;let{latitude:e,longitude:t,distance:n}=this.getCameraState();this.callbacks.onCameraPosition?.(e,t,n)}this.systemData.hasPendingUnloads()&&performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&this.systemData.drainPendingUnloads();let{distance:o}=this.getCameraState();this.updateTravelCraftSystem(),this.ctx.visibility.updateCamera(o,this.clock.jd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.clock.jd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=hF(this.bodyObjects,this.camera,this.ctx,this.focus.focusTruePos,this.focusController.current?.data.id,this.hideCappedMoonLabels,this.hoveredBodyIds,this.pointClouds.asteroids(),this.pointClouds.spacecraft(),this.pointClouds.moons(),this.cullFrameCounter,this.renderer,this._tmpV3,!i,this.tightFar),this.pointClouds.applyPointBudget(),jI(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),LI(this.bodyObjects,this.focus.focusTruePos,Mx().realisticLighting,Mx().overexposeRings,this.camera.position,this.pxPerRad()),pL(this.bodyObjects,this.focus.focusTruePos);let s=dL(this.bodyObjects,this.camera.position,Mx().showAtmospheres,Mx().realisticLighting,this.sunIntensityScale,Wk(),this.clock.jd);tA(r,s.shellProminent),this.scene.backgroundIntensity=s.skyboxIntensity,this.applyLayerChrome();let c=this.bodyObjects.get(f_);c&&dj(c.corona,c.starPoint,s.sunTint);let l=Mx().highAmbient?1:bT;if(!Mx().highAmbient&&Mx().realisticLighting){let e=this.bodyObjects.get(f_)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;l*=CT(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=l;PR(this.userLocationMarker,this.bodyObjects,this.camera);let u=wM(this.focusController.current,this.bodyObjects);IL(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,u,this.clock.jd,this.appearances),PL(this.bodyObjects,this.camera,this.renderer,this.ctx,u),hL(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,Mx().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(s.sunRefraction),s.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.composer.render(),this.renderModelOverlay(),this.labelRenderer.render(this.scene,this.camera),this.haloDebug.active&&this.haloDebug.draw(this.bodyObjects,this.camera,this.focus.focusTruePos,this.focusController.current?.data.id,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)};updateTightFar(e){if(iT())return;let t=this.focusController.current,n=t?wM(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e;if(t&&r&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[i,o,s]=r.body.position,c=this.camera.position;a=Math.hypot(e+c.x-i,t+c.y-o,n+c.z-s)}let o=this.tightFar?BR:zR;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*o}updateDepthFar(){if(iT())return;let e=ET,t=this.ctx.visibility.activeSystemId;if(t){let[n,r,i]=this.focus.focusTruePos,a=this.camera.position.lengthSq(),o=e=>{let t=e[0]-n,o=e[1]-r,s=e[2]-i,c=t*t+o*o+s*s;c>a&&(a=c)},s=this.bodyObjects.get(f_);if(this.tightFar){let e=this.bodyObjects.get(t)?.body;if(e){let o=Math.hypot(e.position[0]-n,e.position[1]-r,e.position[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s&&o(s.body.position);for(let e of this.bodyObjects.values())this.ctx.visibility.hasFullRendering(e.body)&&o(e.body.position);e=Math.min(ET,Math.max(LR,Math.sqrt(a)*IR))}Math.abs(e-this.camera.far)>this.camera.far*RR&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(f_);if(!t)return;let[n,r,i]=this.focus.focusTruePos,[a,o,s]=t.body.position,c=a-n,l=o-r,u=s-i;if(e){let t=this.camera.position,n=this._tmpV3.set(c-t.x,l-t.y,u-t.z),r=n.length();n.divideScalar(r);let i=HR.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),c=t.x+n.x*r,l=t.y+n.y*r,u=t.z+n.z*r)}let d=1;if(this.tightFar){let e=this.camera.far*VR,t=Math.hypot(c,l,u);t>e&&(d=e/t)}if(!(d===1&&this.sunProxyK===1&&!e)){this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.group.position.set(c*d,l*d,u*d);for(let e of t.extraObjects)e.position.set(c*d,l*d,u*d);t.mesh?.scale.setScalar(this.sunBaseMeshScale*d),t.corona?.scale.set(this.sunBaseCoronaScale*d,this.sunBaseCoronaScale*d,1),this.sunProxyK=d}}setMotionScale(e){this.motionScale=e,this.controls.rotateSpeed=e.rotate,this.controls.panSpeed=e.translate,this.controls.zoomSpeed=e.translate}isLanded(e){return!!this.bodyObjects.get(e)?.isLanded}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=lw(t*Math.PI/180,n*Math.PI/180);return jw(this.bodyObjects.get(e),e,gn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(AO(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:MO(n),centerOffsetScene:jO(n),radialKm:e=>kO(n,e)};if(!(!t||!e.orientation))return{invQuat:mC(e.orientation,this.clock.jd,e.nutPrec).invert(),seated:t,radialKm:t=>jw(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&$D(t.body)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model,r=t.modelRoot;if(!(!n||!r)){if(e)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==r){r.add(n);let e=n.userData;n.scale.setScalar(e.fitScale??1),n.position.set(0,0,0),e.centerOffset&&n.position.addScaledVector(e.centerOffset,-1)}}}if(e){this.shadowLight.castShadow=!1;return}this.updateFocusedMountedModel()}updateFocusedMountedModel(){let e=this.overlayModelBo(),t=e?.model&&e.model.parent===e.modelRoot?e.modelRoot:null;if(!e||!t){this.shadowLight.castShadow=!1;return}let n=aO(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(f_)?.body;if(!i)return;let[a,o,s]=i.position,[c,l,u]=e.body.position;this._tmpSun.set(a-c,o-l,s-u).normalize(),this.shadowLight.position.copy(e.group.position).addScaledVector(this._tmpSun,WR*n),this.shadowLight.target.position.copy(e.group.position);let d=this.shadowLight.shadow.camera;d.left=d.bottom=-GR*n,d.right=d.top=GR*n,d.near=KR*n,d.far=qR*n,d.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=JR*n}renderModelOverlay(){if(!this.overlayActive)return;let e=this.overlayModelBo();if(!e?.model)return;let t=e.model.userData;e.model.scale.setScalar(t.fitScale??1),e.model.position.set(0,0,0),e.isLanded&&t.feetOffset?e.model.position.copy(t.feetOffset).applyQuaternion(e.model.quaternion).multiplyScalar(-1):t.centerOffset&&e.model.position.copy(t.centerOffset).multiplyScalar(-1),this._tmpV3.copy(this.camera.position).sub(e.group.position);let n=this._tmpV3.length(),r=aO(e),i=n/r;this.modelCamera.position.copy(this._tmpV3).normalize().multiplyScalar(i),this.modelCamera.quaternion.copy(this.camera.quaternion),this.modelCamera.aspect=this.camera.aspect;let a=0;for(let t of this.bodyObjects.values()){let n=t.model;if(!n||t===e)continue;let i=aO(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.group.position,e.group.position).divideScalar(r);let s=n.userData;s.centerOffset&&n.position.addScaledVector(s.centerOffset,-i);let c=n.position.length()+i;c>a&&(a=c)}this.modelCamera.near=Math.max(.01,i-5-a),this.modelCamera.far=i+50+a,this.modelCamera.updateProjectionMatrix();let o=this.bodyObjects.get(f_)?.body,s=1;if(o){let[t,n,r]=o.position,[i,a,c]=e.body.position;this._tmpSun.set(t-i,n-a,r-c),Mx().realisticLighting&&(s=CT(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)}if(this.modelShadowPlane){this._tmpUp.set(0,1,0).applyQuaternion(e.model.quaternion);let t=this._tmpSun.dot(this._tmpUp)>.03;this.modelShadowPlane.visible=!!e.isLanded&&!e.isCrashed&&t,this.modelShadowPlane.visible&&this.modelShadowPlane.quaternion.setFromUnitVectors(this._planeNormal,this._tmpUp)}this._tmpV3.set(0,0,0);let c=VC(this._tmpV3,this._tmpV3)*s;this.modelLight.intensity=xT*c*this.sunIntensityScale,this.modelScene.environmentIntensity=ST*c,this.showPointingAxes?(this.pointingAxes||(this.pointingAxes=this.buildPointingAxes(),this.modelScene.add(this.pointingAxes)),this.pointingAxes.quaternion.copy(e.model.quaternion),this.pointingAxes.scale.setScalar(Math.min(.8,.45*i)),this.pointingAxes.visible=!0):this.pointingAxes&&(this.pointingAxes.visible=!1),this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.render(this.modelScene,this.modelCamera),this.renderer.autoClear=!0}pxPerRad(){return this.viewportH/2/Math.tan(this.camera.fov*Math.PI/360)}trailView(){let e=this._trailView,t=this.camera.position;return e.camX=t.x,e.camY=t.y,e.camZ=t.z,e.tolAngle=UR/this.pxPerRad(),e}cloudViewInfo(){let e=this.camera.position;return{camPos:[e.x,e.y,e.z],pxPerRad:this.pxPerRad()}}getCameraState(){let e=this.camera.position;return aC([e.x,e.y,e.z],[0,0,0],this.focusController.focusedBodyQuat())}setDragEnabled(e){this.controls.enableRotate=e,this.controls.enablePan=e}setZoomEnabled(e){this.controls.enableZoom=e}setBodySelectEnabled(e){this.bodySelectEnabled=e}setFeatureSelectEnabled(e){this.featureSelectEnabled=e}readerMayFocus=e=>this.bodySelectEnabled&&(this.focusableBodies?.has(e.data.id)??!0);setCooperativeTouch(e){this.controls.touches.ONE=e?FR:Tn.ROTATE,this.canvas.style.touchAction=e?`pan-x pan-y`:`none`}setCameraLimits(e,t){this.cameraBand=e,this.focusableBodies=t?new Set(t):null}armLimits=()=>{this.limitsArmed=!0};disarmLimits(){this.limitsArmed=!1}applyReaderLimits(e){!this.limitsArmed||!this.cameraBand||this.holdingCamera||e-this.focus.focusStartTime<this.focus.focusDurationMs||nR(this.camera,this.cameraBand,this.focusController.focusedBodyQuat())}static INPUT_EVENTS=[`pointerdown`,`pointermove`,`pointerup`,`wheel`];invalidate=()=>{this.wakeUntilFrame=this.frameIndex+e.WAKE_FRAMES};focusKey(){let e=this.ctx.visibility;return`${this.focusController.current?.data.id??``}|${e.focusedSystemId??``}|${e.activeSystemId??``}`}cameraOffsetFromFocus(){let e=this.focusController.current,t=this.focus.focusTruePos,n=this.camera.position;return e?[n.x+t[0]-e.position[0],n.y+t[1]-e.position[1],n.z+t[2]-e.position[2]]:[n.x,n.y,n.z]}holdCamera(){this.holdingCamera||(this.disarmLimits(),this.holdingCamera=!0,this.controls.enabled=!1,this.focus.camOriginWorld=null,this.focus.camTargetWorld=null,this.focus.camTargetOffset=null,this.focus.camOriginOffset=null,this.focus.flyQ0=null,this.focus.orbitFly=!1,this.focus.arcOrbit=!1,this.focus.cameraStaysOnBody=!1)}setHeldPose(e){this.cameraHold=e}releaseCamera(){this.holdingCamera&&(this.holdingCamera=!1,this.cameraHold=null,this.controls.enabled=!0,this.controls.target.set(0,0,0),this.controls.enableDamping=!1,this.controls.update(),this.controls.enableDamping=!0,this.invalidate())}applyHeldCamera(){let e=this.cameraHold,t=e&&CR(e,this.ctx,this.clock.jd);if(!t)return!0;let n=this.focus.focusTruePos;return this.camera.up.set(t.up[0],t.up[1],t.up[2]).normalize(),this.camera.position.set(t.position[0]-n[0],t.position[1]-n[1],t.position[2]-n[2]),this.camera.lookAt(t.target[0]-n[0],t.target[1]-n[1],t.target[2]-n[2]),!0}shouldRender(t){if(this.holdingCamera||t-this.focus.focusStartTime<this.focus.focusDurationMs||this.focusKey()!==this.lastRenderedFocusKey||this.ctx.bodies.minorStreaming||this.pointClouds.hasPendingSceneAdds()||this.systemData.hasPendingUnloads())return!0;if(this.covered)return!1;if(this.frameIndex-this.lastRenderedFrame>=e.IDLE_HEARTBEAT_FRAMES)return!0;let n=this.camera;return n.position.distanceToSquared(this.lastRenderedCamPos)>n.position.lengthSq()*1e-10||8*(1-Math.abs(n.quaternion.dot(this.lastRenderedCamQuat)))>1e-8||this.frameIndex<this.wakeUntilFrame||this.haloDebug.active?!0:this.clock.jd===this.lastRenderedJd?!1:Math.abs(this.clock.timeScale)>1||t-this.lastRenderMs>=e.REALTIME_FRAME_MS}onControlsEnd=()=>{this.pendingUrlWrite=!0,this.focusController.clearPendingInitialView()};nudgeCamera(e,t,n){this.armLimits();let{rotate:r,translate:i}=this.motionScale;e!==0&&this.controls.rotateLeft(e*r),t!==0&&this.controls.rotateUp(t*r),n!==1&&this.controls.dollyIn(1/n**+i),this.onControlsEnd()}maybeLoadTexture(e){let t=this.bodyObjects.get(e.data.id);t&&(sM(t,this.textureLoader,this.clock.jd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(hC(t.mesh,e.orientation,this.clock.jd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}),lO(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=eR(t.body,NO(t))),!this.ctx.layers.skipped.has(`nomenclature`))return MM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&IM(t,this.selectedFeatureId)}))}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&(fO(t),lM(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=wM(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&IM(n,e)}syncLandedNomenclature(){let e=this.focusController.current,t=(e?this.bodyObjects.get(e.data.id):void 0)?.isLanded?e.data.parentId:null;if(t===this.landedNomBodyId||(this.landedNomBodyId=t,!t))return;let n=this.ctx.getBody(t);n&&this.maybeLoadTexture(n)}clearUserPromoted(){this.focusController.promotion.clearUserPromoted()}focusedSeatConfigKey(){let e=this.focusController.current;if(!e||e.data.objectType!==W.SPACECRAFT&&!un(e))return null;let t=F_(e.data.parentId),n=t?this.bodyObjects.get(t):void 0;if(!n)return null;let r=n.terrainWindow;return`${r?`w${r.stepLevel}x${r.texWidth}@${r.centerTheta.toFixed(6)},${r.centerPhi.toFixed(6)}`:`u${n.currentSegments??128}`}|${n.displacementMap?.uuid??`none`}|${vw()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==U.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),gx(e.data.id).then(e=>e&&t.registerCarried(e)));let n=`${e.data.id}@${this.clock.jd}`;if(n===this.lastProbeTargetCheck)return;this.lastProbeTargetCheck=n;let r=t.stampedFitCenterAt(e.data.id,this.clock.jd);if(!r)return;let i=this.ctx.getBody(r);if(!i){if(this.requestedProbeTargets.has(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Pg(this.clock.jd));return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}applyJdUpdate(e=!1){this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0,i=this.ctx.bodies.hostReadVersion;if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion&&i===this.lastHostReadVersion){this.clock.seeked=!1;return}let a=this.clock.seeked;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.lastHostReadVersion=i,this.ctx.refreshTick(Pg(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let o=AI({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,positionMap:this._positionMapScratch,diagnostics:this.positionDiagnostics,trailView:this.trailView(),frame:this.frameIndex,outOfRange:this.outOfRange});this.pointClouds.updateForJd(this.clock.jd,this.cloudViewInfo()),this.refreshTravelFocus(),performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&(this.repositionBodies(),this.pointClouds.maybeRebase()),this.syncLandedNomenclature();let s=o.focusedOutOfRange&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=o.focusedOutOfRange,e&&a&&s&&o.reanchorId){let e=this.ctx.getBody(o.reanchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.controls.dampingFactor=ER(e)}focusOnBody(e,t,n,r){return this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.focusOnBody(e,t,n,r)}focusOnFeature(e,t,n,r=`frame`,i){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1;let a=this.ctx.getBody(e.hostId);if(!a)return 0;this.focusController.clearPendingInitialView();let o=wM(this.focusController.current,this.bodyObjects)===e.hostId,s=Pw(e,t);this.ctx.bodies.focusFeature=s;let c=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,c&&IM(c,e.featureId),Vw(s,a,c,this.clock.jd);let l=s.position,u=this.focusController.focusedBodyQuat(s);if(r===`pan`){let e=aC(this.focusController.cameraTruePos(),l,u);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(s),this.focus.focusDurationMs}let d=l[0]-a.position[0],f=l[1]-a.position[1],p=l[2]-a.position[2],m=Math.hypot(d,f,p);m>1e-9?(d/=m,f/=m,p/=m):(d=0,f=1,p=0);let h=r===`snap`&&i?oC(l,i.latitude,i.longitude,i.zoom,u):[l[0]+d*n,l[1]+f*n,l[2]+p*n],g=aC(h,l,u);if(this.callbacks.onCameraPosition?.(g.latitude,g.longitude,g.distance),r===`snap`){this.focusController.setFocusTarget(s,h);let e=this.focus;return e.focusTruePos=[...l],e.focusOriginWorld=[...l],e.focusTargetWorld=[...l],e.focusStartTime=-LL,e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1,this.repositionAll(),this.pointClouds.rebuildBasis(),this.camera.position.set(h[0]-l[0],h[1]-l[1],h[2]-l[2]),this.controls.update(),0}if(o){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(s),this.focus.focusTruePos=[...l],this.camera.position.set(e[0]-l[0],e[1]-l[1],e[2]-l[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),JL(this.focus,this.camera,e,h,Mx().resolvedReducedMotion)}else this.focusController.setFocusTarget(s,h),this.focus.orbitFly=!0;return this.focus.focusDurationMs}pickFocusedModel(e,t){if(!this.overlayActive||!this.overlayModelBo()?.model)return null;this._pickNdc.set(e,t),this._modelRaycaster.setFromCamera(this._pickNdc,this.modelCamera);let n=null,r=1/0;for(let e of this.bodyObjects.values()){if(!e.model)continue;let t=this._modelRaycaster.intersectObject(e.model,!0);t.length>0&&t[0].distance<r&&(r=t[0].distance,n=e.body)}return n}overlayModelBo(){let e=this.focusController.current;if(!e){let e=this.travelFocus?.centerId,t=e?this.bodyObjects.get(e):void 0;return t?.model?t:null}let t=un(e)?e.featureAnchor.hostId:e.data.id,n=this.bodyObjects.get(t);if(n?.model)return n;if(e.data.orbitalSource===U.SPICE_PROBE&&!n?.isLanded){let t=this.bodyObjects.get(e.data.parentId);if(t?.model)return t}return null}snapToBodyFacing(e,t,n,r){this.disarmLimits(),this.focusController.snapToBodyFacing(e,t,n,r)}snapToBody(e,t,n,r){this.disarmLimits(),this.focusController.snapToBody(e,t,n,r)}setFocusTarget(e,t){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.setFocusTarget(e,t)}getFocusedBody(){return this.focusController.current}getDebugStats(){let t=this.fpsSamples,n=0;if(t.length>=2){let r=t.length<e.FPS_SAMPLE_FRAMES?0:this.fpsSampleHead,i=t[r],a=(t[(r-1+t.length)%t.length]-i)/1e3;a>0&&(n=(t.length-1)/a)}return cP({fps:n,orbitPool:this.pointClouds.orbitPool,renderer:this.renderer,bodyObjects:this.bodyObjects,focusedBody:this.focusController.current,cameraDistanceScene:this.getCameraState().distance})}setBodyAppearance(e,t){this.appearances.set(e,t)}setPinnedBodies(e){this.ctx.visibility.setPinned(e),this.focusController.promotion.setPinned(e)}setNorthReference(e){this.cameraUp.setNorthReference(e)}getFocusedPointing(){let e=this.focusController.current;if(!e)return null;let t=e.pointing??{primary:{axis:`-y`,target:`parent`}};return{supported:$D(e),base:t}}setFocusedPointing(e){let t=this.focusController.current;t&&(t.pointingOverride=e??void 0)}setPointingAxesVisible(e){this.showPointingAxes=e}buildPointingAxes(){let e=new za,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new Gd(n,t,1,r,.22,.12);o.line.material.depthTest=!1,o.cone.material.depthTest=!1,o.renderOrder=999,e.add(o);let s=this.makeAxisLabel(i,a);s.position.copy(n).multiplyScalar(1.12),e.add(s)};return n(new J(1,0,0),16729156,`+X`,`#ff9999`),n(new J(-1,0,0),8930372,`-X`,`#cc7777`),n(new J(0,1,0),4521796,`+Y`,`#99ff99`),n(new J(0,-1,0),4491332,`-Y`,`#77cc77`),n(new J(0,0,1),4491519,`+Z`,`#99bbff`),n(new J(0,0,-1),4478344,`-Z`,`#7799cc`),e}makeAxisLabel(e,t){let n=document.createElement(`canvas`);n.width=n.height=128;let r=n.getContext(`2d`);r.font=`bold 72px sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillStyle=t,r.fillText(e,128/2,128/2);let i=new cs(new Jo({map:new Nc(n),depthTest:!1,transparent:!0}));return i.scale.setScalar(.175),i.renderOrder=1e3,i}sunIntensityScale=1;getSunIntensityScale(){return this.sunIntensityScale}setSunIntensityScale(e){this.sunIntensityScale=e}getFocusedAtmosphere(){let e=this.focusController.current?.data.id;if(!e)return null;let t=this.bodyObjects.get(e)?.atmosphere,n=_b(e);return!t||!n?null:{id:e,current:t.params,shipped:n}}setFocusedAtmosphereParams(e){let t=this.focusController.current?.data.id,n=t?this.bodyObjects.get(t)?.atmosphere:void 0;n&&NA(n,e)}getSkyboxAdjust(){return this.skyboxAdjuster.get()}setSkyboxAdjust(e,t,n){this.skyboxAdjuster.set(e,t,n)}setSkyDebugMarkersVisible(e){this.skyDebugMarkers.setVisible(e)}applyLayerChrome(){this.ctx.layers.isVisible(`stars`)?this.stashedSky&&=(this.scene.background=this.stashedSky,null):this.scene.background&&(this.stashedSky=this.scene.background,this.scene.background=null);let e=this.ctx.layers.isVisible(`labels`);e!==this.namesShown&&(this.namesShown=e,this.labelContainer.classList.toggle(`scene-overlay--no-names`,!e));let t=this.ctx.layers.isVisible(`halos`);t!==this.halosShown&&(this.halosShown=t,this.labelContainer.classList.toggle(`scene-overlay--no-halos`,!t))}setHaloDebugVisible(e){this.haloDebug.setVisible(e)}setUserLocation(e,t){let n=this.bodyObjects.get(p_);n?.mesh&&(this.userLocationMarker&&MR(this.userLocationMarker),this.userLocationMarker=jR(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(MR(this.userLocationMarker),null)}pause(){this.paused||(this.paused=!0,cancelAnimationFrame(this.rafId),this.rafId=0)}resume(){this.paused&&(this.paused=!1,this.invalidate(),this.tick())}setCovered(e){this.covered!==e&&(this.covered=e,e||this.invalidate())}isContextLost(){return this.renderer.getContext().isContextLost()}handleContextRestored(){this.renderer.setPixelRatio(Xx()),this.composer.setPixelRatio(Xx()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),pS(this.scene,this.renderer,this.ctx,()=>this.disposed),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=Yx();let e=Xx();e!==this.renderer.getPixelRatio()&&(this.renderer.setPixelRatio(e),this.composer.setPixelRatio(e),this.resize(this.canvas.clientWidth,this.canvas.clientHeight)),this.pointClouds.setPointBudget(this.tier.pointBudget)}resize(e,t){this.invalidate(),this.viewportH=t||1,this.renderer.setSize(e,t,!1),this.composer.setSize(e,t);let n=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass.setSize(n.x,n.y),this.bloomPass.setSize(e*this.tier.bloomScale,t*this.tier.bloomScale),this.labelRenderer.setSize(e,t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.ctx.visibility.updateViewport(t),hT(e,t)}dispose(){this.disposed=!0,cancelAnimationFrame(this.rafId),this.pointerInteraction.detach(),this.gpuPick.dispose(),this.controls.removeEventListener(`end`,this.onControlsEnd),this.controls.removeEventListener(`start`,this.invalidate),this.controls.removeEventListener(`start`,this.armLimits),this.controls.removeEventListener(`end`,this.invalidate);for(let t of e.INPUT_EVENTS)this.canvas.removeEventListener(t,this.invalidate);window.removeEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded?.(),this.controls.dispose(),this.haloDebug.dispose(),this.travelPath.dispose(),this.extensions.dispose();for(let e of this.bodyObjects.values())e.model&&fO(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),XR(this.scene.background),XR(this.scene.environment),XR(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.renderer.dispose()}disposeScene(e){let t=new Set;e.traverse(e=>{let n=e;n.geometry?.dispose();let r=n.material,i=Array.isArray(r)?r:r?[r]:[];for(let e of i)if(!t.has(e)){t.add(e);for(let t of Object.values(e))XR(t);e.dispose()}})}};function XR(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var ZR=$e({progress:null,bootPending:!1}),QR=6371;function $R(e){let t=[];for(let n=0;n<128;n++){let r=Math.PI*(n/127)**2,i=Math.cos(r);t.push(1/(4*Math.PI)*(1-e*e)/(1+e*e-2*e*i)**1.5)}return[...t,...t,...t]}var ez={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:$R(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},tz=1.6,nz=1.0005,rz=new J(.55,.25,.8).normalize(),iz=[`low`,`medium`,`high`,`ultra`],az=4,oz=12,sz=10,cz=16,lz=5;function uz(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function dz(e,t){let n=`low`;for(let r of e.tiers){let e=uz(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var fz=new Set([`WebKit WebGL`,`Mozilla`,``]);function pz(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!fz.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function mz(e,t){let n=e.getContext(),r=new qa,i=new sd(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new mu({color:7829367,roughness:1,metalness:0}),o=new As(new ru(1,64,64),a);o.renderOrder=1,r.add(o);let s=new md(16777215,2);s.position.copy(rz),r.add(s);let c=ez,l=TA(c,1,QR),u=l.material.uniforms;u.uSunDir.value.copy(rz),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,nz,0),i.lookAt(1,nz+.1,0)):(i.position.set(0,0,tz),i.lookAt(0,0,0)),l.material.side=+!!t,l.material.depthWrite=!t,l.material.depthTest=!t},f=new Uint8Array(4),p=()=>new Promise((e,n)=>requestAnimationFrame(()=>t?.aborted?n(Error(`benchmark aborted`)):e())),m=t=>{let a=performance.now();for(let n=0;n<t;n++)e.render(r,i);return n.readPixels(0,0,1,1,n.RGBA,n.UNSIGNED_BYTE,f),(performance.now()-a)/t};return{measure:async(e,t,{decideMs:n,onFrame:r}={})=>{MA(l,Vk[e]),d(t);let i=0;for(let e=0;e<az;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(cz,Math.max(1,Math.ceil(sz/Math.max(i,.25)))),o=[],s=()=>{let e=[...o].sort((e,t)=>e-t);return{medianMs:e[Math.floor(e.length/2)],p75Ms:e[Math.floor(e.length*.75)]}};for(let e=0;e<oz;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=lz){let{medianMs:e,p75Ms:t}=s();if(e>n*1.4||t<n*.7)break}return{...s(),repeats:a}},dispose:()=>{r.remove(o,s,l.mesh),o.geometry.dispose(),a.dispose(),s.dispose(),IA(l)}}}function hz(e,t,n,r){let i=e.getContext();return{tiers:t.map(e=>{let t=n.get(e)??null,i=r.get(e)??null;return{tier:e,limb:t,sky:i,skipped:!t&&!i}}),drawWidth:i.drawingBufferWidth,drawHeight:i.drawingBufferHeight}}async function gz(e,t){let n=t.tiers??iz,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=mz(e,i),c=az+oz,l=0,u=0,d=(e,t,i)=>s.measure(n[e],t,{decideMs:r,onFrame:(r,o)=>{if(!a)return;l++;let s=c-((r===`measure`?az:0)+o)+i*c;u=Math.max(u,l/(l+s)),a({tier:n[e],tierIndex:e,tierCount:n.length,scenario:t,phase:r,frame:o,frames:r===`measure`?oz:az,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(Vk[t].insideView){let n=await d(e,`sky`,1);if(p.set(t,n),n.medianMs>r)return!1}let i=await d(e,`limb`,0);return f.set(t,i),i.medianMs<=r};try{if(await m(o))for(let e=o+1;e<n.length&&await m(e);e++);else for(let e=o-1;e>=1&&!await m(e);e--);}finally{s.dispose()}return hz(e,n,f,p)}var _z=60,vz=100,yz=3e4,bz=25e4,xz=`v1`,Sz=!1,Cz=null,wz=Promise.resolve();function Tz(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/bz);return`${pz(e)}|${n}|${xz}`}function Ez(){Sz||typeof window>`u`||(Sz=!0,ZR.bootPending=!0,wz=new Promise(e=>{let t=()=>{ZR.bootPending=!1,e()};setTimeout(t,yz),setTimeout(()=>void Oz(!1).finally(t),vz)}))}function Dz(){return wz}function Oz(e){return Cz??=kz(e).finally(()=>Cz=null),Cz}async function kz(e){let t=Mx();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new dh({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(Gx()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=Tz(n);if(!e&&t.atmosphereCalibration?.key===r)return;ZR.progress=0;let i=await gz(n,{budgetMs:1e3/_z,startTier:Hk(),onProgress:e=>ZR.progress=e.fraction}),a={};for(let e of i.tiers){let t=uz(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=dz(i,1e3/_z);t.setAtmosphereCalibration({key:r,tier:o,worstMs:a}),t.setAtmosphereAutoTier(null),console.info(`atmosphere calibration: ${o}`,a)}catch(e){console.warn(`atmosphere calibration failed, keeping heuristic tier`,e)}finally{ZR.progress=null,n?.dispose(),n?.forceContextLoss()}}var Az=class{object=new za;element;label;anchor;occlude;wanted=!0;removeSelf=null;constructor(e,t){this.anchor=e.anchor,this.occlude=e.occlude??!1,this.element=e.element,this.label=new nk(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,zk(e.element,t)}bind(e){this.removeSelf=e}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{jd:t,basis:n,ctx:r}=e,i=this.wanted?bR(this.anchor,r,t):null;if(!i){this.label.visible=!1;return}let a=i[0]-n[0],o=i[1]-n[1],s=i[2]-n[2];this.label.position.set(a,o,s),this.label.visible=this.occlude?this.facesCamera(i,e):!0,this.object.updateMatrixWorld(!0)}facesCamera(e,{camera:t,ctx:n,jd:r}){let i=xR(this.anchor,e,n,r);if(!i)return!0;let{position:a}=this.label,o=t.position.x-a.x,s=t.position.y-a.y,c=t.position.z-a.z;return i[0]*o+i[1]*s+i[2]*c>0}dispose(){this.label.removeFromParent(),this.element.remove()}},jz=3,Mz=new J,Nz=new J,Pz=new J;function Fz(e){let[t,n=t]=(e??``).split(/[\s,]+/).filter(Boolean).map(Number);return t>0&&n>0?[t,n]:null}function Iz(e,t){return Mz.set(1,0,0).applyQuaternion(e.quaternion),Nz.set(0,1,0).applyQuaternion(e.quaternion),Pz.set(0,0,-1).applyQuaternion(e.quaternion),t/(2*Math.tan(e.getEffectiveFOV()*Math.PI/360))}function Lz(e,t,n,r){let i=e[t*3]-n.position.x,a=e[t*3+1]-n.position.y,o=e[t*3+2]-n.position.z;r[0]=i*Mz.x+a*Mz.y+o*Mz.z,r[1]=i*Nz.x+a*Nz.y+o*Nz.z,r[2]=i*Pz.x+a*Pz.y+o*Pz.z}function Rz(e,t,n){Pz.set(0,0,-1).applyQuaternion(n.quaternion);let{x:r,y:i,z:a}=n.position;for(let o=0;o<t;o++)if((e[o*3]-r)*Pz.x+(e[o*3+1]-i)*Pz.y+(e[o*3+2]-a)*Pz.z<n.near*2)return!0;return!1}function zz(e,t,n,r,i){let a=Iz(n,r),o=[0,0,0],s=0,c=0,l=0,u=!1;for(let r=0;r<t;r++){if(Lz(e,r,n,o),o[2]>n.near){let e=o[0]/o[2]*a,t=o[1]/o[2]*a;u&&(s+=Math.hypot(e-c,t-l)),c=e,l=t,u=!0}i[r]=s}}var Bz=class{points=new Float32Array;alphas=new Float32Array;lengths=new Float32Array;count=0;a=[0,0,0];b=[0,0,0];see(e,t,n,r,i){this.alphas.length<n*4&&(this.points=new Float32Array(n*12),this.alphas=new Float32Array(n*4),this.lengths=new Float32Array(n*4)),this.count=0;let a=Iz(r,i),o=i*r.aspect*jz/2,s=i*jz/2,c=r.near*2,{a:l,b:u}=this,d=!1,f=0,p=0,m=0;n>0&&Lz(e,0,r,l);for(let i=0;i+1<n;i++,[l,u]=[u,l]){Lz(e,i+1,r,u);let n=0,h=1;for(let e=0;e<5&&n<=h;e++){let t=Vz(e,l,a,o,s,c),r=Vz(e,u,a,o,s,c);t<0&&r<0?h=-1:t<0?n=Math.max(n,t/(t-r)):r<0&&(h=Math.min(h,t/(t-r)))}if(n>h){d=!1;continue}let g=l[2]+(u[2]-l[2])*n,_=(l[0]+(u[0]-l[0])*n)/g*a,v=(l[1]+(u[1]-l[1])*n)/g*a;(!d||n>0)&&(this.count>0&&(this.copy(this.count-1,0),this.put(e,t,i,n,f,0)),this.put(e,t,i,n,f,1),p=_,m=v);let y=l[2]+(u[2]-l[2])*h,b=(l[0]+(u[0]-l[0])*h)/y*a,x=(l[1]+(u[1]-l[1])*h)/y*a;f+=Math.hypot(b-p,x-m),p=b,m=x,this.put(e,t,i,h,f,1),d=h===1}}put(e,t,n,r,i,a){let o=this.count++;for(let t=0;t<3;t++){let i=e[n*3+t];this.points[o*3+t]=i+(e[n*3+3+t]-i)*r}this.alphas[o]=(t[n]+(t[n+1]-t[n])*r)*a,this.lengths[o]=i}copy(e,t){let n=this.count++;this.points.copyWithin(n*3,e*3,e*3+3),this.alphas[n]=this.alphas[e]*t,this.lengths[n]=this.lengths[e]}};function Vz(e,t,n,r,i,a){return e===0?t[2]-a:e===1?r*t[2]-n*t[0]:e===2?r*t[2]+n*t[0]:e===3?i*t[2]-n*t[1]:i*t[2]+n*t[1]}var Hz=1e-9,Uz=class{object=new za;anchor;color;widthPx;opacity;dash;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;seen=new Bz;capacity=0;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.dash=Fz(e.dash),this.fade=e.fade??!1,this.closed=e.closed??!1,this.local=new Float64Array,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=e.length+(this.closed&&e.length>2?1:0);this.local.length<t*3&&(this.local=new Float64Array(t*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}t>e.length&&this.local.copyWithin(e.length*3,0,3),this.count=t,this.alphas.length<t&&(this.scratch=new Float32Array(t*3),this.alphas=new Float32Array(t)),t>this.capacity&&this.rebuild(t),this.fillAlphas(),this.dirty=!0}fillAlphas(){let e=this.count;for(let t=0;t<e;t++)this.alphas[t]=this.fade&&e>1?this.opacity*(1-t/(e-1)):this.opacity}setAnchor(e){this.anchor=e}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,viewportPx:r,ctx:i}){let a=this.wanted&&this.count>=2?bR(this.anchor,i,e):null;if(this.mesh&&(this.mesh.visible=a!==null),!this.mesh||!a)return;let o=[a[0]-t[0],a[1]-t[1],a[2]-t[2]],s=this.dirty||Math.abs(o[0]-this.lastOrigin[0])>Hz||Math.abs(o[1]-this.lastOrigin[1])>Hz||Math.abs(o[2]-this.lastOrigin[2])>Hz;if(s){for(let e=0;e<this.count*3;e++)this.scratch[e]=this.local[e]+o[e%3];this.lastOrigin=o}let c=this.dash!==null||Rz(this.scratch,this.count,n);if(c){let{seen:e}=this;e.see(this.scratch,this.alphas,this.count,n,r),e.count>this.capacity&&this.rebuild(e.count),fN(this.mesh.geometry,e.points,e.alphas,e.alphas,e.count),this.dash&&hN(this.mesh.geometry,e.lengths,e.count)}else s&&fN(this.mesh.geometry,this.scratch,this.alphas,this.alphas,this.count);this.dirty=c,this.mesh.material.uniforms.uCenterOffset.value.copy(n.position).negate()}rebuild(e){this.disposeMesh(),this.dirty=!0;let t=gN(e,this.scratch,this.alphas,this.alphas,0,this.color,this.widthPx,1,this.dash??void 0);t.frustumCulled=!1,this.object.add(t),this.mesh=t,this.capacity=e}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh()}};function Wz(e){let t=Math.hypot(e[0],e[1],e[2]),n=t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1],r=Gz(Math.abs(n[2])<.9?[0,0,1]:[1,0,0],n),i=Math.hypot(r[0],r[1],r[2]),a=[r[0]/i,r[1]/i,r[2]/i];return[a,Gz(n,a)]}function Gz(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Kz(e,t={}){let[n,r]=Wz(t.normal??[0,0,1]),i=Math.max(3,Math.round(t.steps??128)),a=[];for(let t=0;t<i;t++){let o=2*Math.PI*t/i,s=Math.cos(o)*e,c=Math.sin(o)*e;a.push([n[0]*s+r[0]*c,n[1]*s+r[1]*c,n[2]*s+r[2]*c])}return a}function qz(e){if(e.length<3)return[];let[t,n]=Wz(Jz(e)),r=e.map(e=>new q(e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[0]*n[0]+e[1]*n[1]+e[2]*n[2]));return Xl.triangulateShape(r,[]).flat()}function Jz(e){let t=0,n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i],o=e[(i+1)%e.length];t+=(a[1]-o[1])*(a[2]+o[2]),n+=(a[2]-o[2])*(a[0]+o[0]),r+=(a[0]-o[0])*(a[1]+o[1])}return Math.hypot(t,n,r)>0?[t,n,r]:[0,0,1]}function Yz(e,t,n){let r=Math.min(1,Math.max(-1,e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),i=Math.acos(r);if(i<1e-9||Math.PI-i<1e-9)return Xz([e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]);let a=Math.sin(i),o=Math.sin((1-n)*i)/a,s=Math.sin(n*i)/a;return[e[0]*o+t[0]*s,e[1]*o+t[1]*s,e[2]*o+t[2]*s]}function Xz(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1]}function Zz(e,t){let n=0,r=0,i=0;for(let a=0;a<t;a++)n+=e[a*3],r+=e[a*3+1],i+=e[a*3+2];return Math.hypot(n,r,i)<1e-9?[e[0],e[1],e[2]]:Xz([n,r,i])}function Qz(e,t){return new fu({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
|
|
5540
5551
|
#include <common>
|
|
5541
5552
|
#include <logdepthbuf_pars_vertex>
|
|
5542
5553
|
uniform vec3 uCenterOffset;
|
|
@@ -5553,6 +5564,6 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
|
|
|
5553
5564
|
gl_FragColor = vec4(uColor, uOpacity);
|
|
5554
5565
|
#include <logdepthbuf_fragment>
|
|
5555
5566
|
}
|
|
5556
|
-
`})}var Yz=.25,Xz=1e-9,Zz=3,Qz=class{object=new za;anchor;outline;fillColor;fillOpacity;local=new Float64Array;count=0;mesh=null;scratch=new Float32Array;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor;let t=e.widthPx??2;this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??Yz,this.outline=t>0?new zz({anchor:e.anchor,points:e.points,color:e.color,widthPx:t,opacity:e.opacity,closed:!0}):null,this.outline&&this.object.add(this.outline.object),this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){this.outline?.setPoints(e),this.local.length<e.length*3&&(this.local=new Float64Array(e.length*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}this.count=e.length,this.rebuild(e)}setAnchor(e){this.anchor=e,this.outline?.setAnchor(e)}setVisible(e){this.wanted=e,this.outline?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){this.outline?.update(e);let t=this.mesh;if(!t)return;let{jd:n,basis:r,camera:i,ctx:a}=e,o=this.wanted?gR(this.anchor,a,n):null;if(t.visible=o!==null,!o)return;let s=[o[0]-r[0],o[1]-r[1],o[2]-r[2]];if(this.dirty||Math.abs(s[0]-this.lastOrigin[0])>Xz||Math.abs(s[1]-this.lastOrigin[1])>Xz||Math.abs(s[2]-this.lastOrigin[2])>Xz){let e=t.geometry.getAttribute(`position`);for(let e=0;e<this.count*3;e+=3)this.scratch[e]=this.local[e]+s[0],this.scratch[e+1]=this.local[e+1]+s[1],this.scratch[e+2]=this.local[e+2]+s[2];e.needsUpdate=!0,this.lastOrigin=s,this.dirty=!1}t.material.uniforms.uCenterOffset.value.copy(i.position).negate()}rebuild(e){this.disposeMesh(),this.dirty=!0;let t=this.fillColor;if(!t)return;let n=Uz(e);if(!n.length)return;let r=new Ho;r.setAttribute(`position`,new Ao(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new As(r,Jz(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=Zz,i.frustumCulled=!1,this.object.add(i),this.mesh=i}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh(),this.outline?.dispose()}},$z=class extends Qz{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:Hz(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(Hz(e,{normal:this.normal,steps:this.steps}))}},eB=class extends Ez{constructor(e,t){let n=document.createElement(`div`);n.className=`sm-drawing-label`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.textContent=e.text,e.color&&(n.style.color=e.color),e.fontSizePx!==void 0&&(n.style.fontSize=`${e.fontSizePx}px`),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setText(e){this.element.textContent=e}},tB=class extends Ez{constructor(e,t){let n=document.createElement(`img`);n.className=`sm-drawing-icon`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.src=e.url,n.alt=e.alt??``,e.widthPx!==void 0&&(n.style.width=`${e.widthPx}px`),e.heightPx!==void 0&&(n.style.height=`${e.heightPx}px`),e.opacity!==void 0&&(n.style.opacity=String(e.opacity)),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setUrl(e){this.element.src=e}},nB=Math.PI/180,rB=180/Math.PI;function iB(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function aB(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[iB(n*i.lonPerX+t),i.lat]}}function oB(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function sB(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=179.999999999;for(let o=0;o<=720;o++){let s=-90+180*o/720;for(let o=0;o<=720;o++){let c=e(-a+2*a*o/720,s);c&&(c[0]<t&&(t=c[0]),c[0]>r&&(r=c[0]),c[1]<n&&(n=c[1]),c[1]>i&&(i=c[1]))}}return{minX:t,minY:n,maxX:r,maxY:i}}function cB(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*rB,lonPerX:rB,maxAbsX:Math.PI};return{id:`equirectangular`,centerLon:t,cyclic:!0,rectangular:!0,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>[iB(e-t)*nB,n*nB],rowInverse:n,inverse:aB(n,t)}}var lB=1.340264,uB=-.081106,dB=893e-6,fB=.003796,pB=Math.sqrt(3),mB=e=>fB*e**9+dB*e**7+uB*e**3+lB*e,hB=e=>9*fB*e**8+7*dB*e**6+3*uB*e**2+lB;function gB(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(MB(pB/2*Math.sin(n*nB))),i=iB(e-t)*nB;return[2*pB*i*Math.cos(r)/(3*hB(r)),mB(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(mB(t)-e)/hB(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/pB*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*hB(t)/(2*pB*Math.cos(t))*rB;return{lat:Math.asin(n)*rB,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:sB(n),forward:n,rowInverse:i,inverse:aB(i,t)}}var _B=Math.SQRT2;function vB(e){let t=e.centerLon??0,n=e=>{let t=e/_B;if(Math.abs(t)>1)return null;let n=Math.asin(t),r=(2*n+Math.sin(2*n))/Math.PI;if(Math.abs(r)>1)return null;let i=Math.cos(n);if(i<1e-12)return{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0};let a=Math.PI/(2*_B*i)*rB;return{lat:Math.asin(r)*rB,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*_B,minY:-_B,maxX:2*_B,maxY:_B},forward:(e,n)=>{let r=n*nB,i=r;if(Math.abs(Math.abs(r)-Math.PI/2)<1e-9)i=Math.PI/2*Math.sign(r);else{let e=Math.PI*Math.sin(r);for(let t=0;t<20;t++){let t=(2*i+Math.sin(2*i)-e)/(2+2*Math.cos(2*i));if(i-=t,Math.abs(t)<1e-12)break}}let a=iB(e-t)*nB;return[2*_B/Math.PI*a*Math.cos(i),_B*Math.sin(i)]},rowInverse:n,inverse:aB(n,t)}}function yB(e){let t=e.centerLon??0,n=e=>{if(Math.abs(e)>Math.PI/2)return null;let t=Math.cos(e);return t<1e-12?{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0}:{lat:e*rB,lonPerX:rB/t,maxAbsX:Math.PI*t}};return{id:`sinusoidal`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>{let r=n*nB;return[iB(e-t)*nB*Math.cos(r),r]},rowInverse:n,inverse:aB(n,t)}}var bB=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],xB=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],SB=.8487,CB=1.3523,wB=5;function TB(e,t){let n=e[Math.max(t-1,0)],r=e[t],i=e[t+1],a=e[Math.min(t+2,e.length-1)];return[r,.5*(i-n),.5*(2*n-5*r+4*i-a),.5*(-n+3*r-3*i+a)]}var EB=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),DB=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function OB(e){let t=Math.min(Math.max(Math.floor(e),0),bB.length-2);return[t,e-t]}function kB(e){let[t,n]=OB(e);return SB*EB(TB(bB,t),n)*Math.PI}function AB(e){let t=0,n=xB.length-1;for(;n-t>1;){let r=t+n>>1;xB[r]<=e?t=r:n=r}let r=Math.min(t,xB.length-2),i=TB(xB,r),a=(e-xB[r])/(xB[r+1]-xB[r]);for(let t=0;t<8;t++){let t=DB(i,a);if(t===0)break;let n=(EB(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function jB(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/CB;if(t>1)return null;let n=AB(t),r=kB(n);return{lat:Math.sign(e)*n*wB,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-SB*Math.PI,minY:-CB,maxX:SB*Math.PI,maxY:CB},forward:(e,n)=>{let[r,i]=OB(Math.abs(n)/wB),a=EB(TB(bB,r),i),o=EB(TB(xB,r),i);return[SB*a*iB(e-t)*nB,CB*o*Math.sign(n)]},rowInverse:n,inverse:aB(n,t)}}function MB(e){return e<-1?-1:e>1?1:e}function NB(e,t,n,r,i,a,o){let s=Math.asin(MB(n*a+t*r*o));return[iB(i+Math.atan2(e*r,n*o-t*r*a)*rB),s*rB]}function PB(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function FB(e,t,n,r){let i=iB(e-n)*nB,a=t*nB;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function IB(e){let t=e.centerLon??0,n=(e.centerLat??0)*nB,r=Math.min(e.clipAngle??90,90)*nB,i=Math.cos(r),a=Math.sin(r),o=Math.sin(n),s=Math.cos(n);return{id:`orthographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:PB(a),forward:(e,r)=>{let a=iB(e-t)*nB,o=r*nB;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:FB(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:NB(e,n,Math.sqrt(1-r),1,t,o,s)}}}var LB=120;function RB(e){let t=e.centerLon??0,n=(e.centerLat??90)*nB,r=Math.min(e.clipAngle??LB,170)*nB,i=Math.cos(r),a=2*Math.tan(r/2),o=Math.sin(n),s=Math.cos(n);return{id:`stereographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:PB(a),forward:(e,r)=>{let a=iB(e-t)*nB,o=r*nB,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a);if(s<i)return null;let c=2/(1+s),[l,u]=FB(e,r,t,n);return[c*l,c*u]},inverse:(e,n)=>{let r=e*e+n*n;if(r>a*a)return null;let i=4/(4+r);return NB(e,n,(4-r)*i*.25,i,t,o,s)}}}var zB={equirectangular:cB,equalEarth:gB,mollweide:vB,sinusoidal:yB,robinson:jB,orthographic:IB,stereographic:RB},BB=Object.keys(zB);function VB(e,t={}){let n=zB[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var HB=Math.PI/180,UB=2*Math.PI,WB=2*HB,GB=180/Math.PI,KB=512,qB=2;function JB(e,t){let n=e.lat*HB,r=t.lat*HB,i=r-n,a=iB(t.lon-e.lon)*HB,o=Math.sin(i/2)**2+Math.cos(n)*Math.cos(r)*Math.sin(a/2)**2;return 2*Math.asin(Math.min(1,Math.sqrt(o)))*GB}function YB(e,t,n){let r=JB(e,t)*HB;if(r<1e-12)return e;let i=Math.sin(r),a=Math.sin((1-n)*r)/i,o=Math.sin(n*r)/i,s=e.lat*HB,c=e.lon*HB,l=t.lat*HB,u=(e.lon+iB(t.lon-e.lon))*HB,d=a*Math.cos(s)*Math.cos(c)+o*Math.cos(l)*Math.cos(u),f=a*Math.cos(s)*Math.sin(c)+o*Math.cos(l)*Math.sin(u),p=a*Math.sin(s)+o*Math.sin(l);return{lon:Math.atan2(f,d)*GB,lat:Math.atan2(p,Math.hypot(d,f))*GB}}function XB(e,t,n){return{lon:e.lon+iB(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function ZB(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??qB,i=n===`geodesic`?YB:XB,a=t.closed&&e.length>2?[...e,e[0]]:e;if(a.length<2)return[...a];let o=[a[0]];for(let e=1;e<a.length;e++){let t=a[e-1],n=a[e],s=Math.min(KB,Math.max(1,Math.ceil(JB(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function QB(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=XB(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return XB(e,t,r)}function $B(e,t){let n=t.projection.cyclic?t.worldWidthPx/2:1/0,{projection:r}=t,i=[],a=[],o=null,s=0;for(let c=0;c<e.length;c++){let l=e[c],u=t.project(l.lon,l.lat);if(!u){if(a.length&&c>0){let n=QB(e[c-1],l,r);a.push(t.project(n.lon,n.lat))}a.length>1&&i.push(a),a=[],o=null,s++;continue}if(o&&Math.abs(u[0]-o[0])>n&&(a.length>1&&i.push(a),a=[]),!a.length&&c>0&&!t.project(e[c-1].lon,e[c-1].lat)){let n=QB(l,e[c-1],r);a.push(t.project(n.lon,n.lat))}a.push(u),o=u}return a.length>1&&i.push(a),{runs:i,whole:i.length===1&&s===0}}function eV(e,t){let n=[...e];for(let r of t.repeatShifts)if(r!==0)for(let i of e){let e=1/0,a=-1/0;for(let[t]of i)t<e&&(e=t),t>a&&(a=t);e+r>t.width||a+r<0||n.push(i.map(([e,t])=>[e+r,t]))}return n}function tV(e,t){let n=`M${e[0][0].toFixed(2)} ${e[0][1].toFixed(2)}`;for(let t=1;t<e.length;t++)n+=`L${e[t][0].toFixed(2)} ${e[t][1].toFixed(2)}`;return t?`${n}Z`:n}var nV=179.999999;function rV(e,t){let n=e=>e>nV?nV:e<-nV?-nV:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=iB(e[0].lon-t);a.push({lon:n(o),lat:e[0].lat});for(let t=0;t<r;t++){let s=e[t],c=e[(t+1)%r],l=iB(c.lon-s.lon),u=o+l,d=u>180?1:u<-180?-1:0;if(d!==0){let e=s.lat+(c.lat-s.lat)*((d*180-o)/l);a.push({lon:d*nV,lat:e}),i.push(a),a=[{lon:-d*nV,lat:e}],o=u-d*360}else o=u;t<r-1&&a.push({lon:n(o),lat:c.lat})}return i.length===0?[a.map(e=>({lon:e.lon+t,lat:e.lat}))]:(i[0]=a.concat(i[0]),i.map(e=>e.map(e=>({lon:e.lon+t,lat:e.lat}))))}function iV(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?rV(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=$B(ZB(e,n),t),a=!!n.closed&&i;return eV(r,t).map(e=>tV(e,a)).join(``)}).join(``)}function aV(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return iV(e,t,{...n,closed:!0});if(e.length<2)return``;let i=ZB(e,{...n,closed:!0}),a=e.length>2?i.slice(0,-1):i,o=a.map(e=>r.forward(e.lon,e.lat)),s=([e,n])=>t.toScreen(e,n),c=o.filter(Boolean).length;if(c===0)return``;if(c===a.length)return tV(o.map(e=>s(e)),!0);let l=a.length,u=0;for(;!o[u]||o[(u+l-1)%l];)u++;let d=[],f=null;for(let e=0;e<l;e++){let t=(u+e)%l,n=(t+l-1)%l,i=o[t];if(i){if(!f){let e=QB(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=QB(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=oV(a),m=([e,t])=>Math.atan2(t,e),h=Math.hypot(...d[0][0]),g=[],_=new Set;for(let e=0;e<d.length;e++){if(_.has(e))continue;let t=[],n=e;do{_.add(n),t.push(...d[n]);let r=m(d[n][d[n].length-1]),i=e,a=1/0;for(let e=0;e<d.length;e++){let t=m(d[e][0]),n=((p?t-r:r-t)%UB+UB)%UB;n<a&&(a=n,i=e)}let o=Math.ceil(a/WB);for(let e=1;e<o;e++){let n=r+(p?1:-1)*a*e/o;t.push([h*Math.cos(n),h*Math.sin(n)])}n=i}while(n!==e&&!_.has(n));g.push(t)}return g.map(e=>tV(e.map(s),!0)).join(``)}function oV(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=iB(i.lon-r.lon)*HB*(2+Math.sin(r.lat*HB)+Math.sin(i.lat*HB))}let n=-t/2;return n>0?n<UB:n<-UB}function sV(e,t=2){let{projection:n}=e,r=179.999999,i=[],a=(r,a,o)=>{let s=a<o?t:-t;for(let t=a;s>0?t<=o:t>=o;t+=s){let a=n.forward(r,t);a&&i.push(e.toScreen(a[0],a[1]))}};return a(n.centerLon-r,-90,90),a(n.centerLon+r,90,-90),i.length<3?``:eV([i],e).map(e=>tV(e,!0)).join(``)}function cV(e,t,n,r){let i=n+r,a=[],o=(e,t,n)=>{let r=Math.max(1,Math.ceil(Math.abs(n-t)/5));for(let i=0;i<=r;i++)a.push({lon:t+(n-t)*i/r,lat:e})};return o(e,n,i),o(t,i,n),a}function lV(e,t,n=128){let r=e.lat*HB,i=e.lon*HB,a=[Math.cos(r)*Math.cos(i),Math.cos(r)*Math.sin(i),Math.sin(r)],o=[-a[1],a[0],0],s=Math.hypot(o[0],o[1]);o=s<1e-9?[1,0,0]:[o[0]/s,o[1]/s,0];let c=[a[1]*o[2]-a[2]*o[1],a[2]*o[0]-a[0]*o[2],a[0]*o[1]-a[1]*o[0]],l=t*HB,u=Math.sin(l),d=Math.cos(l),f=[];for(let e=0;e<n;e++){let t=2*Math.PI*e/n,r=Math.sin(t)*u,i=Math.cos(t)*u,s=a[0]*d+o[0]*r+c[0]*i,l=a[1]*d+o[1]*r+c[1]*i,p=a[2]*d+o[2]*r+c[2]*i;f.push({lon:iB(Math.atan2(l,s)*GB),lat:Math.atan2(p,Math.hypot(s,l))*GB})}return f}var uV=24;function dV(e=30){let t=[];for(let n=-180;n<180;n+=e)t.push([{lon:n,lat:-90},{lon:n,lat:90}]);let n=179.999999;for(let r=-90+e;r<90;r+=e){let e=[];for(let t=0;t<=uV;t++)e.push({lon:-n+2*n*t/uV,lat:r});t.push(e)}return t}var fV=.005,pV=1.5,mV=5,hV=24,gV=class{object=new za;body;altitudeKm;closed;interpolate;stepDeg;color;widthPx;opacity;dash;fillColor;fillOpacity;dirs=new Float64Array;count=0;line=null;scratch=new Float32Array;alphas=new Float32Array;lengths=new Float32Array;fanDirs=new Float64Array;fill=null;fillScratch=new Float32Array;turned=[0,0,0];wanted=!0;removeSelf=null;constructor(e){this.body=e.body,this.altitudeKm=e.altitudeKm??null,this.closed=e.closed??!1,this.interpolate=e.interpolate??`linear`,this.stepDeg=e.stepDeg,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.dash=jz(e.dash),this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??.25,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=ZB(e,{interpolate:this.interpolate,stepDeg:this.stepDeg,closed:this.closed});this.dirs=new Float64Array(t.length*3);for(let e=0;e<t.length;e++){let[n,r,i]=pR(t[e].lat,t[e].lon);this.dirs[e*3]=n,this.dirs[e*3+1]=r,this.dirs[e*3+2]=i}this.count=t.length,this.buildLine(),this.buildFill()}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,viewportPx:r,ctx:i}){let a=this.wanted&&this.count>=2?i.getBody(this.body):void 0,o=a&&hR(a,i,e);if(this.line&&(this.line.visible=!!o),this.fill&&(this.fill.visible=!!o),!a||!o)return;let s=gn(a.data),c=Q(s+(this.altitudeKm??s*fV)),l=a.orientation?mC(a.orientation,e,a.nutPrec):null,u=[o[0]-t[0],o[1]-t[1],o[2]-t[2]];if(this.line&&(this.place(this.dirs,this.count,l,c,u,this.scratch),lN(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.dash&&(Fz(this.scratch,this.count,n,r,this.lengths),fN(this.line.geometry,this.lengths,this.count)),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()),this.fill){let e=this.fill.geometry.getAttribute(`position`);this.place(this.fanDirs,this.fillScratch.length/3,l,c,u,this.fillScratch),e.needsUpdate=!0,this.fill.material.uniforms.uCenterOffset.value.copy(n.position).negate()}}place(e,t,n,r,i,a){for(let o=0;o<t;o++){let t=o*3;n?mR(n,e[t],e[t+1],e[t+2],this.turned,0):(this.turned[0]=e[t],this.turned[1]=e[t+1],this.turned[2]=e[t+2]),a[t]=this.turned[0]*r+i[0],a[t+1]=this.turned[1]*r+i[1],a[t+2]=this.turned[2]*r+i[2]}}buildLine(){if(this.disposeLine(),this.count<2||this.widthPx<=0)return;this.scratch=new Float32Array(this.count*3),this.alphas=new Float32Array(this.count).fill(this.opacity),this.lengths=new Float32Array(this.count);let e=pN(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1,this.dash??void 0);e.frustumCulled=!1,e.renderOrder=pV,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=qz(this.dirs,this.count),t=0;for(let n=0;n<this.count;n++){let r=e[0]*this.dirs[n*3]+e[1]*this.dirs[n*3+1]+e[2]*this.dirs[n*3+2];t=Math.max(t,Math.acos(Math.min(1,Math.max(-1,r))))}let n=Math.min(hV,Math.max(1,Math.ceil(t*180/Math.PI/mV))),r=1+n*this.count;this.fanDirs=new Float64Array(r*3),this.fanDirs[0]=e[0],this.fanDirs[1]=e[1],this.fanDirs[2]=e[2];for(let t=1;t<=n;t++)for(let r=0;r<this.count;r++){let[i,a,o]=Gz(e,[this.dirs[r*3],this.dirs[r*3+1],this.dirs[r*3+2]],t/n),s=(1+(t-1)*this.count+r)*3;this.fanDirs[s]=i,this.fanDirs[s+1]=a,this.fanDirs[s+2]=o}let i=[],a=(e,t)=>1+(e-1)*this.count+t;for(let e=0;e<this.count-1;e++)i.push(0,a(1,e),a(1,e+1));for(let e=1;e<n;e++)for(let t=0;t<this.count-1;t++){let n=a(e,t),r=a(e,t+1),o=a(e+1,t),s=a(e+1,t+1);i.push(n,o,r,r,o,s)}let o=new Ho;o.setAttribute(`position`,new Ao(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new As(o,Jz(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=pV,this.object.add(s),this.fill=s}disposeLine(){this.line&&=(this.object.remove(this.line),this.line.geometry.dispose(),this.line.material.dispose(),null)}disposeFill(){this.fill&&=(this.object.remove(this.fill),this.fill.geometry.dispose(),this.fill.material.dispose(),null)}dispose(){this.disposeLine(),this.disposeFill()}},_V=class{object=new za;id;name;anchor;model;trueScale;spanScene;minPx;label;wanted=!0;removeSelf=null;constructor(e,t,n){this.id=t,this.name=e.name??null,this.anchor=e.position,this.object.matrixAutoUpdate=!1,this.object.frustumCulled=!1;let r=e.model;this.model=r?.object3d??null,this.minPx=r?.minPx??0;let i=r?vV(r.object3d):0;this.trueScale=r?.scaleM!==void 0&&i>0?Q(r.scaleM/1e3)/i:1,this.spanScene=i*this.trueScale,this.model&&this.object.add(this.model),this.label=e.label&&this.name?new eB({anchor:e.position,text:this.name,align:[.5,1.4],occlude:e.occludeLabel},n):null,this.label&&this.object.add(this.label.object)}bind(e){this.removeSelf=e}get position(){return this.anchor}positionKm(e){let t=this.anchor;if(`latitude`in t)return null;let n=typeof t.offsetKm==`function`?t.offsetKm(e):t.offsetKm;return n===void 0?[0,0,0]:n}setPosition(e){this.anchor=e,this.label?.setAnchor(e)}setVisible(e){this.wanted=e,this.label?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{basis:t,camera:n,jd:r,ctx:i}=e,a=this.model,o=this.wanted?gR(this.anchor,i,r):null;if(this.label?.update(e),!a||(a.visible=o!==null,!o))return;a.position.set(o[0]-t[0],o[1]-t[1],o[2]-t[2]);let s=this.drawnScale(a.position,n,e.viewportPx);a.scale.setScalar(s),a.updateMatrixWorld(!0)}drawnScale(e,t,n){if(this.minPx<=0||this.spanScene<=0)return this.trueScale;let r=t.position.distanceTo(e);if(r<=0)return this.trueScale;let i=n/(2*Math.tan(t.fov*Math.PI/180/2)*r),a=this.spanScene*i;return a>=this.minPx?this.trueScale:this.trueScale*(this.minPx/a)}dispose(){this.label?.dispose(),this.model&&this.object.remove(this.model)}};function vV(e){let t=new co().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var yV=class{byId=new Map;nextId=1;constructor(e,t){this.registry=e,this.canvas=t}add(e){let t=e.id??`object-${this.nextId++}`;this.byId.get(t)?.remove();let n=new _V(e,t,this.canvas()),r=this.registry();return n.bind(()=>{this.byId.delete(t),r.remove(n)}),this.byId.set(t,n),r.add(n),n}get(e){return this.byId.get(e)}all(){return[...this.byId.values()]}clear(){for(let e of[...this.byId.values()])e.remove()}};function bV(e,t,n,r){let i=gR(e,n,r),a=gR(t,n,r);return!i||!a?null:vR([a[0]-i[0],a[1]-i[1],a[2]-i[2]])}function xV(e,t,n,r){let i=bV(e,t,n,r);return i&&Math.hypot(...i)}function SV(e,t,n){let r=t.getBody(e),i=t.getBody(f_);if(!r||!i||r===i||!r.orientation&&!t.bodies.orientationRead.has(e))return null;let a=hR(r,t,n);if(!a)return null;let o=r.orientation?mC(r.orientation,n,r.nutPrec).toArray():[0,0,0,1],{latitude:s,longitude:c,distance:l}=aC([i.position[0],i.position[1],i.position[2]],[a[0],a[1],a[2]],o);return l>0?{lon:c,lat:s}:null}var CV=class{enabled;apply;constructor(e,t){this.enabled=e,this.apply=t}enable(){this.set(!0)}disable(){this.set(!1)}isEnabled(){return this.enabled}set(e){this.enabled!==e&&(this.enabled=e,this.apply?.(e))}};function wV(e,t){return e??t??!0}var TV=1400,EV=class{enabled;element=document.createElement(`div`);timer;constructor(e,t){this.enabled=t,this.element.className=`sm-cooperative-hint`,this.element.setAttribute(`aria-hidden`,`true`),e.append(this.element)}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,e||this.hide()}allowsWheel(e){if(!this.enabled||e.ctrlKey||e.metaKey)return!0;let{cooperative_wheel:t,cooperative_wheel_mac:n}=a().messages;return this.show(DV()?n():t()),!1}allowsTouchDrag(e){return!this.enabled||e>1?!0:(this.show(a().messages.cooperative_touch()),!1)}dispose(){clearTimeout(this.timer),this.element.remove()}show(e){this.element.textContent=e,this.element.classList.add(`sm-cooperative-hint--shown`),clearTimeout(this.timer),this.timer=setTimeout(()=>this.hide(),TV)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function DV(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var OV={[W.BARYCENTER]:`barycenter`,[W.LAGRANGE_POINT]:`lagrange-point`,[W.STAR]:`star`,[W.PLANET]:`planet`,[W.DWARF_PLANET]:`dwarf-planet`,[W.MOON]:`moon`,[W.ASTEROID]:`asteroid`,[W.ASTEROID_INNER]:`asteroid`,[W.ASTEROID_MAIN_BELT]:`asteroid`,[W.ASTEROID_TROJAN]:`asteroid`,[W.ASTEROID_CENTAUR]:`asteroid`,[W.ASTEROID_TNO]:`asteroid`,[W.COMET]:`comet`,[W.SPACECRAFT]:`spacecraft`,[W.DEBRIS]:`debris`,[W.UNDOCUMENTED]:`unknown`,[W.SURFACE_FEATURE]:`surface-feature`},kV={[W.ASTEROID_INNER]:`inner`,[W.ASTEROID_MAIN_BELT]:`main-belt`,[W.ASTEROID_TROJAN]:`trojan`,[W.ASTEROID_CENTAUR]:`centaur`,[W.ASTEROID_TNO]:`tno`};function AV(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a,unplaceable:o}=e.data,s={id:t,name:n,type:OV[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:o!==!0&&e.positionUnknown!==!0},c=kV[r];return c&&(s.orbitClass=c),s}var jV=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],MV=class{corners=new Map;added=new Map;constructor(e,t){this.map=e,this.root=t}add(e,t){if(this.added.has(e))return;let n=e.onAdd(this.map);this.added.set(e,n),this.corner(t??e.getDefaultPosition?.()??`top-right`).append(n)}remove(e){let t=this.added.get(e);t&&(this.added.delete(e),e.onRemove?.(this.map),t.remove())}clear(){for(let e of[...this.added.keys()])this.remove(e);for(let e of this.corners.values())e.remove();this.corners.clear()}corner(e){let t=this.corners.get(e);return t||(t=document.createElement(`div`),t.className=`sm-ctrl sm-ctrl--${e}`,this.corners.set(e,t),this.root.append(...jV.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},NV=[(e,t)=>e.setReducedMotion(t.resolvedReducedMotion),(e,t)=>e.setImmersive(t.viewMode===`immersive`),(e,t)=>e.setHaloDebugVisible(t.showHaloDebug),(e,t)=>{t.atmosphereCalibration,e.applyRenderTier()}],PV=.05,FV=1.15,IV=2e3,LV=4e3,RV=new WeakMap,zV=new WeakMap,BV=class{ctx=new wS;clock;initialView;#e=qe(null);get renderer(){return Ut(this.#e)}set renderer(e){Je(this.#e,e)}#t=qe(!1);get webglError(){return Ut(this.#t)}set webglError(e){Je(this.#t,e,!0)}#n=qe(!1);get contextLost(){return Ut(this.#n)}set contextLost(e){Je(this.#n,e,!0)}#r=qe();get focusedBody(){return Ut(this.#r)}set focusedBody(e){Je(this.#r,e)}attribution=null;objects=new yV(()=>this.requireRenderer().extensions,()=>this.requireCanvas());dragRotate;scrollZoom;keyboard;bodySelect;featureSelect;cooperativeGestures;container=null;canvas=null;labelLayer=null;stopWatching=null;controls=null;lostPanelTimer;cooperative=null;limits={};initialFocusPending=!0;pendingFocusId=null;retireCameraHold=null;listeners={focuschange:new Set,camera:new Set,featureselect:new Set,userpromoted:new Set,contextlost:new Set,contextrestored:new Set,clock:new Set,loading:new Set,progress:new Set,error:new Set,datastale:new Set,notice:new Set,noticedismiss:new Set,layerschange:new Set,frame:new Set};constructor(e={}){e.settings&&Nx(e.settings),this.clock=new ES(Ng(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??uC,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new CV(wV(e.interactions?.[t],e.interactive),()=>this.applyGestures());this.dragRotate=n(`dragRotate`),this.scrollZoom=n(`scrollZoom`),this.keyboard=n(`keyboard`),this.bodySelect=n(`bodySelect`),this.featureSelect=n(`featureSelect`),this.cooperativeGestures=new CV(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new Cv(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),Sz()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};zV.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners[e];n.delete(t);for(let e of n)zV.get(e)===t&&n.delete(e)}emit(e,...t){for(let n of this.listeners[e])n(...t)}getBody(e){let t=this.ctx.getBody(e);return t&&AV(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=un(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&AV(t)}getChildren(e){return[...this.ctx.bodies.getChildren(e)??[]]}get placedJd(){let e=this.renderer?.placedJd;return e===void 0||Number.isNaN(e)?this.clock.jd:e}distanceKm(e,t){return xV(e,t,this.ctx,this.placedJd)}offsetKm(e,t){return bV(e,t,this.ctx,this.placedJd)}getSubsolarPoint(e){return SV(e,this.ctx,this.placedJd)}load(e=this.initialView.id){return this.ctx.load(Pg(this.clock.jd),e)}async open(e=this.initialView.id){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&this.ctx.getBody(e)?t():document.hidden?setTimeout(r,100):requestAnimationFrame(r))};r()});try{await Promise.race([t,r])}finally{n=!1}}applyInitialView(){let{id:e,latitude:t,longitude:n,zoom:r}=this.initialView;this.focusedBody||!this.ctx.getBody(e)||this.renderer?.snapToBody(e,t,n,r)}mount(e){if(this.container)throw Error(`SpaceMap is already mounted`);this.container=e,e.classList.add(`sm-map`),RV.set(e,(RV.get(e)??0)+1),this.controls=new MV(this,e);let t=document.createElement(`canvas`);t.className=`sm-map__canvas`,t.tabIndex=0,t.setAttribute(`role`,`application`),t.setAttribute(`aria-label`,a().messages.scene_canvas_label());let n=document.createElement(`div`);n.className=`scene-overlay`,e.append(t,n),this.canvas=t,this.labelLayer=n,this.cooperative=new EV(e,this.cooperativeGestures.isEnabled()),t.addEventListener(`keydown`,this.onKeyDown),t.addEventListener(`touchmove`,this.onTouchMove,{passive:!0}),e.addEventListener(`wheel`,this.onWheelCapture,{capture:!0,passive:!0}),t.addEventListener(`webglcontextlost`,this.onContextLost,!1),t.addEventListener(`webglcontextrestored`,this.onContextRestored,!1),document.addEventListener(`visibilitychange`,this.onVisibility);let r;try{r=new GR(t,n,this.ctx,this.clock,this.initialView,this.callbacks())}catch(e){console.error(`[scene] renderer init failed:`,e),this.webglError=!0;return}this.renderer=r,this.applyGestures(),this.applyLimits(),this.pendingFocusId!==null&&(r.focusOnBody(this.pendingFocusId),this.pendingFocusId=null);let i=new ResizeObserver(()=>r.resize(t.clientWidth,t.clientHeight));i.observe(t);let o=lt(()=>this.watch(r));this.stopWatching=()=>{i.disconnect(),o()}}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){let{container:e,canvas:t}=this;if(!e||!t)return;this.controls?.clear(),this.controls=null,this.stopWatching?.(),this.stopWatching=null,clearTimeout(this.lostPanelTimer),t.removeEventListener(`keydown`,this.onKeyDown),t.removeEventListener(`touchmove`,this.onTouchMove),e.removeEventListener(`wheel`,this.onWheelCapture,{capture:!0}),this.cooperative?.dispose(),this.cooperative=null,t.removeEventListener(`webglcontextlost`,this.onContextLost),t.removeEventListener(`webglcontextrestored`,this.onContextRestored),document.removeEventListener(`visibilitychange`,this.onVisibility),this.retireCameraHold?.(),this.retireCameraHold=null,this.renderer?.dispose(),this.renderer=null,t.remove(),this.labelLayer?.remove();let n=(RV.get(e)??1)-1;RV.set(e,n),n===0&&e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null}watch(e){st(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=Mx();for(let n of NV)st(()=>n(e,t));let n=this.clock;st(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Pg(e),playing:t,timeScale:r,direction:i,live:a})}),st(()=>{let e=this.ctx.loading,t=qR.bootPending;this.emit(`loading`,e||t)}),st(()=>this.emit(`progress`,U_.value)),st(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),st(()=>{qR.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=Mx();for(let n of NV)n(e,t)}callbacks(){return{notices:{notify:e=>this.emit(`notice`,e),dismiss:e=>this.emit(`noticedismiss`,e)},onFocusChange:e=>{let t=this.initialFocusPending;this.initialFocusPending=!1,this.focusedBody=e;let n=e!==void 0&&un(e);this.emit(`focuschange`,{body:this.getFocusedBody(),initial:t,feature:n})},onFrame:(e,t)=>{this.listeners.frame.size>0&&this.emit(`frame`,{jd:e,dtMs:t})},onCameraPosition:(e,t,n)=>{let r=this.focusedBody?.data.id;r!==void 0&&this.emit(`camera`,{body:r,lat:e,lon:t,distanceKm:cg(n)})},onUserPromotedChange:e=>this.emit(`userpromoted`,e),onFeatureSelect:(e,t,n,r,i)=>this.emit(`featureselect`,{bodyId:e,featureId:t,lat:n,lon:r,diameterM:i})}}onKeyDown=e=>{if(!this.keyboard.isEnabled()||e.ctrlKey||e.metaKey||e.altKey)return;let t=(e.shiftKey?4:1)*PV,n=0,r=0,i=1;switch(e.key){case`ArrowLeft`:n=t;break;case`ArrowRight`:n=-t;break;case`ArrowUp`:r=t;break;case`ArrowDown`:r=-t;break;case`+`:case`=`:i=FV;break;case`-`:case`_`:i=1/FV;break;default:return}e.preventDefault(),this.renderer?.nudgeCamera(n,r,i)};onContextLost=e=>{e.preventDefault(),console.warn(`[scene] WebGL context lost`),this.renderer?.pause(),clearTimeout(this.lostPanelTimer),this.lostPanelTimer=setTimeout(()=>{this.contextLost=!0,this.emit(`contextlost`)},IV)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(LV),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};flyTo(e){let t=this.targetBody(e);return e.feature?this.toFeature(t,e.feature,`frame`):this.settled(this.focusOnBody(t,this.framing(e,t),e.lat,e.lon))}panTo(e){return this.toFeature(this.targetBody(e),e.feature,`pan`)}jumpTo(e){let t=this.targetBody(e);if(e.facing!==void 0)return this.snapToBodyFacing(t,e.facing,e.elevationDeg??0,this.framing(e,t)),this;if(e.feature){let{featureId:n,lat:r,lon:i,diameterM:a}=e.feature;return this.focusOnFeature(t,n,r,i,a,null,`snap`),this}let n=this.getCamera();return this.snapToBody(t,e.lat??n?.lat??45,e.lon??n?.lon??0,this.framing(e,t)),this}getCamera(){let e=this.renderer,t=this.focusedBody?.data.id;if(!e||t===void 0)return null;let{latitude:n,longitude:r,distance:i}=e.getCameraState();return{body:t,lat:n,lon:r,distanceKm:cg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...gv]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,gv.filter(e=>this.ctx.layers.isVisible(e)))}setLimits(e){return this.limits={...e},this.applyLimits(),this}getLimits(){return{...this.limits}}applyLimits(){let e=this.limits,t={};e.minDistanceKm!==void 0&&(t.minDistance=Q(e.minDistanceKm)),e.maxDistanceKm!==void 0&&(t.maxDistance=Q(e.maxDistanceKm)),e.minLat!==void 0&&(t.minLat=e.minLat),e.maxLat!==void 0&&(t.maxLat=e.maxLat),e.minLon!==void 0&&(t.minLon=e.minLon),e.maxLon!==void 0&&(t.maxLon=e.maxLon);let n=Object.keys(t).length>0;this.renderer?.setCameraLimits(n?t:null,e.bodies??null)}applyGestures(){let e=this.cooperativeGestures.isEnabled();this.cooperative?.setEnabled(e);let t=this.renderer;t&&(t.setDragEnabled(this.dragRotate.isEnabled()),t.setZoomEnabled(this.scrollZoom.isEnabled()),t.setBodySelectEnabled(this.bodySelect.isEnabled()),t.setFeatureSelectEnabled(this.featureSelect.isEnabled()),t.setCooperativeTouch(e))}onWheelCapture=e=>{this.scrollZoom.isEnabled()&&this.cooperative&&!this.cooperative.allowsWheel(e)&&e.stopPropagation()};onTouchMove=e=>{this.cooperative?.allowsTouchDrag(e.touches.length)};toFeature(e,t,n){let{featureId:r,lat:i,lon:a,diameterM:o}=t;return this.settled(this.focusOnFeature(e,r,i,a,o,null,n))}settled(e){return new Promise(t=>{setTimeout(()=>requestAnimationFrame(()=>t()),e)})}targetBody(e){let t=e.body??this.focusedBody?.data.id;if(t===void 0)throw Error(`spacemap: no body to move to, and none focused`);return t}framing(e,t){if(e.distanceKm!==void 0)return Q(e.distanceKm);let n=this.ctx.getBody(t);return n&&n.data.radiusKm>0?ZL(n)*5:this.renderer?.getCameraState().distance??15}focusOnBody(e,t,n,r){return this.renderer?this.renderer.focusOnBody(e,t,n,r):(this.pendingFocusId=e,0)}snapToBody(e,t,n,r){this.renderer?.snapToBody(e,t,n,r)}snapToBodyFacing(e,t,n,r){this.renderer?.snapToBodyFacing(e,t,n,r)}focusOnFeature(e,t,n,r,i,a,o=`frame`,s=null){let c=this.ctx.getBody(e);if(!c)return 0;let l=Q(i*4/1e3),u=Q(.02),d=Q(gn(c.data)*5),f=Math.min(Math.max(l,u),d),p={hostId:e,featureId:t,lat:n,lon:r,diameterM:i};return this.renderer?.focusOnFeature(p,a,f,o,s)??0}setFocusTarget(e,t){this.renderer?.setFocusTarget(e,t)}getPose(){let e=this.renderer,t=this.focusedBody;if(!e||!t)return null;let n=t.data.id;return{position:{body:n,offsetKm:vR(e.cameraOffsetFromFocus())},target:{body:n}}}holdCamera(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);this.retireCameraHold?.(),e.holdCamera();let t=!0,n=()=>{t=!1};return this.retireCameraHold=n,{get held(){return t},set:n=>{t&&e.setHeldPose(n)},release:()=>{t&&(n(),this.retireCameraHold=null,e.releaseCamera())}}}addMarker(e){return this.track(new Ez(e,this.requireCanvas()))}addPolyline(e){return this.track(new zz(e))}addPolygon(e){return this.track(new Qz({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new $z(e))}addLabel(e){return this.track(new eB(e,this.requireCanvas()))}addIcon(e){return this.track(new tB(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new gV(e))}addSurfacePolygon(e){return this.track(new gV({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:lV(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof _V)}setBodyAppearance(e,t){return this.requireRenderer().setBodyAppearance(e,t),this}setPinnedBodies(e){return this.requireRenderer().setPinnedBodies(e),this}capRadiusDeg(e){if(e.radiusDeg!==void 0)return e.radiusDeg;let t=this.getBody(e.body)?.radiusKm;return e.radiusKm!==void 0&&t?e.radiusKm/t*(180/Math.PI):1}track(e){let t=this.requireRenderer();return e.bind(()=>t.extensions.remove(e)),t.extensions.add(e),e}requireCanvas(){let e=this.canvas;if(!e)throw Error(`SpaceMap is not mounted`);return e}requireRenderer(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);return e}setNorthReference(e){this.renderer?.setNorthReference(e)}setUserLocation(e,t){this.renderer?.setUserLocation(e,t)}clearUserPromoted(){this.renderer?.clearUserPromoted()}setSelectedFeature(e){this.renderer?.setSelectedFeature(e)}setTravelPath(e,t=[],n=[],r=[]){this.renderer?.setTravelPath(e,t,n,r)}setOrbitPreview(e,t){this.renderer?.setOrbitPreview(e,t)}setTravelHover(e){this.renderer?.setTravelHover(e)}focusOnPathPoint(e,t){this.renderer?.focusOnPathPoint(e,t)}trackPathPoint(e,t){this.renderer?.trackPathPoint(e,t)}setCovered(e){this.renderer?.setCovered(e)}},VV=`http://www.w3.org/2000/svg`;function HV(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function UV(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function WV(e,t){let n=document.createElementNS(VV,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function GV(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of dV(t)){let t=iV(r,e,{stepDeg:2});t&&n.append(WV(t,`sm-flat__graticule`))}if(e.projection.azimuthal){let t=e.toScreen(0,0),r=e.toScreen(e.projection.extent.maxX,0),i=document.createElementNS(VV,`circle`);i.setAttribute(`cx`,String(t[0])),i.setAttribute(`cy`,String(t[1])),i.setAttribute(`r`,String(Math.abs(r[0]-t[0]))),i.setAttribute(`class`,`sm-flat__frame`),n.append(i)}else{let t=sV(e);t&&n.append(WV(t,`sm-flat__frame`))}}}}var KV=120;function qV(e,t){let n=[];return{kind:`vector`,id:`nomenclature`,label:t,visible:!1,credit:{organisation:`IAU`,source:`https://planetarynames.wr.usgs.gov/`},async prepare(){n.length||(n=[...await vM(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,KV))},render(e,t){let r=e.repeatShifts;for(let i of n){let n=e.project(i.lon,i.lat);if(!(!n||n[1]<0||n[1]>e.height))for(let a of r){let r=n[0]+a;if(r<0||r>e.width)continue;let o=document.createElementNS(VV,`circle`);o.setAttribute(`cx`,r.toFixed(1)),o.setAttribute(`cy`,n[1].toFixed(1)),o.setAttribute(`r`,`1.6`),o.setAttribute(`class`,`sm-flat__feature-dot`);let s=document.createElementNS(VV,`text`);s.setAttribute(`x`,(r+4).toFixed(1)),s.setAttribute(`y`,(n[1]+3).toFixed(1)),s.setAttribute(`class`,`sm-flat__feature-label`),s.textContent=i.name,t.append(o,s)}}}}}function JV(e,t){e.setAttribute(`fill`,t.fill??`none`),t.fill&&t.fillOpacity!==void 0&&e.setAttribute(`fill-opacity`,String(t.fillOpacity)),e.setAttribute(`stroke`,t.color??`#ffffff`),e.setAttribute(`stroke-width`,String(t.widthPx??2)),e.setAttribute(`stroke-linejoin`,`round`),e.setAttribute(`stroke-linecap`,`round`),t.opacity!==void 0&&e.setAttribute(`opacity`,String(t.opacity)),t.dash&&e.setAttribute(`stroke-dasharray`,t.dash),t.className&&e.setAttribute(`class`,t.className),e.style.pointerEvents=t.interactive?`auto`:`none`,t.ariaLabel&&(e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.ariaLabel))}function YV(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var XV=class{node;area;edge;points;visible=!0;constructor(e,t,n,r,i,a){this.closed=n,this.interpolate=r,this.onRemove=i,this.onChange=a,this.points=e,this.node=document.createElementNS(VV,`g`),JV(this.node,t),YV(this.node,t),this.area=n?document.createElementNS(VV,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(VV,`path`),this.edge.setAttribute(`fill`,`none`),this.area&&this.node.append(this.area),this.node.append(this.edge)}redraw(e){if(!this.visible)return;let t={closed:this.closed,interpolate:this.interpolate};this.edge.setAttribute(`d`,iV(this.points,e,t)),this.area?.setAttribute(`d`,aV(this.points,e,t))}setPoints(e){this.points=e,this.onChange()}setVisible(e){this.visible=e,this.node.style.display=e?``:`none`,this.onChange()}detach(){this.node.remove()}remove(){this.onRemove(this)}},ZV=class{element;at;visible=!0;align;constructor(e,t,n){this.onRemove=t,this.onChange=n,this.at=e.at,this.align=e.align??[.5,.5],this.element=e.element??document.createElement(`div`),e.element||(this.element.className=`sm-flat__marker-dot`),e.className&&this.element.classList.add(e.className),this.element.style.position=`absolute`,this.element.style.left=`0`,this.element.style.top=`0`,this.element.style.pointerEvents=e.interactive?`auto`:`none`}redraw(e){let t=this.visible?e.project(this.at.lon,this.at.lat):null;if(this.element.style.display=t?``:`none`,!t)return;let n=e.repeatShifts.find(n=>t[0]+n>=0&&t[0]+n<=e.width)??0;this.element.style.transform=`translate(${t[0]+n}px, ${t[1]}px) translate(${-this.align[0]*100}%, ${-this.align[1]*100}%)`}setPosition(e){this.at=e,this.onChange()}setVisible(e){this.visible=e,this.onChange()}detach(){this.element.remove()}remove(){this.onRemove(this)}},QV=class{drawings=new Set;constructor(e,t,n=()=>{},r=null){this.shapes=e,this.markers=t,this.onChange=n,this.radiusKm=r}setBodyRadiusKm(e){this.radiusKm=e}track(e,t){return this.drawings.add(e),t instanceof HTMLElement?this.markers.append(t):this.shapes.append(t),e}drop=e=>{this.drawings.delete(e)&&e.detach()};addPolyline(e){let t=new XV(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new XV(e.points,{fill:`rgb(255 255 255 / 25%)`,...e},!0,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addBox(e){let t=new XV(cV(e.latMin,e.latMax,e.lonMin,e.lonSpan),{fill:`rgb(255 255 255 / 15%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(t,t.node)}addCircle(e){let t=this.circleRadiusDeg(e),n=new XV(lV(e.center,t),{fill:`rgb(255 255 255 / 20%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(n,n.node)}circleRadiusDeg(e){return e.radiusDeg===void 0?e.radiusKm!==void 0&&this.radiusKm?e.radiusKm/this.radiusKm*(180/Math.PI):1:e.radiusDeg}addMarker(e){let t=new ZV(e,this.drop,this.onChange);return this.track(t,t.element)}redraw(e){for(let t of this.drawings)t.redraw(e)}clear(){for(let e of this.drawings)e.detach();this.drawings.clear()}};function $V(e){let t=`width`in e?e.width:e.codedWidth,n=`height`in e?e.height:e.codedHeight;return typeof t!=`number`||typeof n!=`number`||!t||!n?null:[t,n]}function eH(e,t){let[n,r]=$V(e)??[t,t/2],i=Math.max(2,Math.min(n,Math.round(t))),a=Math.max(1,Math.round(i*r/n)),o=document.createElement(`canvas`);o.width=i,o.height=a;let s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)return null;s.imageSmoothingEnabled=!0,s.imageSmoothingQuality=`high`,s.drawImage(e,0,0,i,a);try{let{data:e}=s.getImageData(0,0,i,a);return{width:i,height:a,data:e}}catch{return null}}var tH=class{width;height;u;v;inside;constructor(e,t,n){this.width=t,this.height=n;let r=t*n;this.u=new Float32Array(r),this.v=new Float32Array(r),this.inside=new Uint8Array(r);let{projection:i}=e,a=1/e.scale,o=e.view.centerX-e.width/2*a,s=e.view.centerY+e.height/2*a;for(let r=0;r<n;r++){let n=s-(r+.5)*a,c=r*t;i.rowInverse?this.fillRow(i,c,n,o,a,e):this.walkRow(i,c,n,o,a)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s}=this,c=(90-o.lat)/180,{minX:l,maxX:u}=e.extent,d=u-l,f=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(f)a=((a-l)%d+d)%d+l;else if(a<l||a>u)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360,p=t+n;this.u[p]=s-Math.floor(s),this.v[p]=c,this.inside[p]=1}}walkRow(e,t,n,r,i){let{width:a}=this,o=0,s=a-1;if(e.azimuthal){let t=e.extent.maxX;if(Math.abs(n)>t)return;let c=Math.sqrt(t*t-n*n);o=Math.max(0,Math.ceil((-c-r)/i-.5)),s=Math.min(a-1,Math.floor((c-r)/i-.5))}for(let a=o;a<=s;a++){let o=r+(a+.5)*i,s=e.inverse(o,n);if(!s)continue;let c=t+a;this.u[c]=(s[0]+180)/360,this.v[c]=(90-s[1])/180,this.inside[c]=1}}};function nH(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c}=e,l=i*a;for(let e of t){let{image:t,opacity:n,blend:i}=e;if(n<=0)continue;let a=t.data,u=t.width,d=t.height,f=i===`add`;for(let e=0;e<l;e++){if(!c[e])continue;let t=Math.floor(o[e]*u),i=Math.floor(s[e]*d);t=t<0?t+u:t>=u?t-u:t,i=i<0?0:i>=d?d-1:i;let l=(i*u+t)*4,p=a[l+3]/255*n;if(p<=0)continue;let m=e*4;if(f){r[m]=Math.min(255,r[m]+a[l]*p),r[m+1]=Math.min(255,r[m+1]+a[l+1]*p),r[m+2]=Math.min(255,r[m+2]+a[l+2]*p);continue}let h=r[m+3]/255,g=p+h*(1-p);if(!(g<=0)){if(p>=1)r[m]=a[l],r[m+1]=a[l+1],r[m+2]=a[l+2];else{let e=h*(1-p);r[m]=(a[l]*p+r[m]*e)/g,r[m+1]=(a[l+1]*p+r[m+1]*e)/g,r[m+2]=(a[l+2]*p+r[m+2]*e)/g}r[m+3]=g*255}}}}function rH(e,t,n){let{minX:r,maxX:i,minY:a,maxY:o}=t.projection.extent,s=t.projection.centerLon*Math.PI/180,[c,l]=t.toScreen(r-s,o),[u,d]=t.toScreen(i-s,a),f=t.repeatsHorizontally?0:t.toScreen(r,o)[0],p=t.repeatsHorizontally?e.canvas.width:t.toScreen(i,o)[0];e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`;for(let t of n){if(t.opacity<=0)continue;let n=$V(t.image),r=n&&e.createPattern(t.image,`repeat-x`);r&&(r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l))}e.restore()}var iH=[`low`,`medium`,`high`];function aH(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function oH(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function sH(e){let t=await Promise.all(iH.map(t=>fetch(Yt(`/v1/textures/${e}/${t}.webp`,`textures`),{method:`HEAD`}).then(e=>e.ok).catch(()=>!1)));return iH.filter((e,n)=>t[n])}async function cH(e,t,n=sH){if(!t?.map_texture_available||!t.texture)return{};let r=s([{...t.texture,id:e,tiers:void 0},...t.alternates??[]]);if(!r)return{};let i=r.tiers??await n(r.id);if(i.length===0)return{};let{frames:a,...o}=r,c=t.radii;return{surface:{...o,tiers:i,monthlyFrames:a},radiusKm:c?(c.a+c.b+c.c)/3:void 0}}async function lH(e){return cH(e,(await hx(e,!1).catch(()=>null))?.global)}async function uH(e){let t=aH(e);if(!t)return lH(e);let n=(await oH(`${Kt()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return lH(e);let r=s([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return lH(e);let{frames:i,...a}=r,o=n.radii;return{surface:{...a,monthlyFrames:i},clouds:n.clouds,night:n.night,radiusKm:o?(o.a+o.b+o.c)/3:void 0}}var dH={low:2048,medium:8192,high:16383};function fH(e){return iH.find(t=>dH[t]>=e)??iH[iH.length-1]}function pH(e,t){return iH.indexOf(e)<=iH.indexOf(t)?e:t}function mH(e,t){let n=iH.indexOf(t);for(let t=n<0?iH.length-1:n;t>=0;t--)if(e.includes(iH[t]))return iH[t];return e[0]??`low`}function hH(e,t,n){let r=e.id;if(e.frames?.length){let i=kj(n,e.frames,e.coverage);if(i)return Yt(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=tM(n,e.monthlyFrames);return Yt(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function gH(e,t){return e*t*4}function _H(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var vH=class{entries=new Map;clock=0;constructor(e){this.free=e}claim(e){let t=this.entries.get(e);return t?(t.claims++,t.used=++this.clock,t.value):null}put(e,t,n){let r=this.entries.get(e);return r?(r.value!==t&&this.free(t),r.claims++,r.used=++this.clock,r.value):(this.entries.set(e,{value:t,bytes:n,claims:1,used:++this.clock}),this.evict(),t)}release(e){let t=this.entries.get(e);t&&(t.claims=Math.max(0,t.claims-1),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=_H();if(e<=t)return;let n=[...this.entries].filter(([,e])=>!e.claims).sort((e,t)=>e[1].used-t[1].used);for(let[r,i]of n){if(e<=t)return;this.entries.delete(r),this.free(i.value),e-=i.bytes}}clear(){for(let e of this.entries.values())this.free(e.value);this.entries.clear()}},yH=new vH(e=>e.close()),bH=new vH(()=>{}),xH=new Map;function SH(e,t){return t?`${e}@${t}`:e}async function CH(e,t){let n=SH(e,t),r=yH.claim(n);if(r)return{key:n,bitmap:r};let i=xH.get(n);i||(i=wH(e,t),xH.set(n,i),i.finally(()=>xH.delete(n)));let a=await i;return a?{key:n,bitmap:yH.put(n,a,gH(a.width,a.height))}:null}async function wH(e,t){let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob();if(!t)return createImageBitmap(r);try{return await createImageBitmap(r,{resizeWidth:t,resizeQuality:`high`})}catch{return createImageBitmap(r)}}function TH(e){yH.release(e)}function EH(e,t,n){let r=SH(e,t),i=bH.claim(r);if(i)return{key:r,raster:i};let a=eH(n,t);return a?{key:r,raster:bH.put(r,a,gH(a.width,a.height))}:null}function DH(e){bH.release(e)}function OH(e,t,n){return[lC(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var kH=class{projection;width;height;view;scale;constructor(e,t,n,r){this.projection=e,this.width=t,this.height=n,this.view=r;let{minX:i,maxX:a,minY:o,maxY:s}=e.extent,c=Math.min(t/(a-i),n/(s-o));this.scale=c*r.zoom}toScreen(e,t){return[this.width/2+(e-this.view.centerX)*this.scale,this.height/2-(t-this.view.centerY)*this.scale]}fromScreen(e,t){return[this.view.centerX+(e-this.width/2)/this.scale,this.view.centerY-(t-this.height/2)/this.scale]}project(e,t){let n=this.projection.forward(e,t);return n?this.toScreen(n[0],n[1]):null}unproject(e,t){let[n,r]=this.fromScreen(e,t);return this.projection.inverse(n,r)}get worldWidthPx(){let{minX:e,maxX:t}=this.projection.extent;return(t-e)*this.scale}get repeatsHorizontally(){return AH(this.projection,this.worldWidthPx,this.width)}get repeatShifts(){if(!this.repeatsHorizontally)return[0];let e=this.worldWidthPx,t=this.toScreen(this.projection.extent.minX,0)[0];return[0,-e,e].filter(n=>t+n<this.width&&t+n+e>0)}};function AH(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function jH(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=MH(e,t,i),s=t.extent,c=s.maxX-s.minX,l=s.maxY-s.minY,u=Math.min(n/c,r/l)*a,d=n/2/u,f=r/2/u,p=(s.minX+s.maxX)/2,m=(s.minY+s.maxY)/2,h=(e,t,n,r)=>n>=r/2?t:Math.min(t+r/2-n,Math.max(t-r/2+n,e));return{zoom:a,centerX:AH(t,c*u,n)?((o.centerX-s.minX)%c+c)%c+s.minX:h(o.centerX,p,d,c),centerY:h(o.centerY,m,f,l)}}function MH(e,t,n){if(!(n.minLon!==void 0||n.maxLon!==void 0||n.minLat!==void 0||n.maxLat!==void 0)||t.azimuthal)return e;let r=t.inverse(e.centerX,e.centerY);if(!r)return e;let[i,a]=OH(r[0],r[1],n);if(i===r[0]&&a===r[1])return e;let o=t.forward(i,a);return o?{centerX:o[0],centerY:o[1]}:e}var NH=[[6,`high`],[2.5,`medium`]],PH=22e5,FH=4096,IH=11,LH=.4,RH=.8,zH=140,BH=`naif-399`,VH=[{kind:`surface`,label:e=>e.layer_surface(),visible:!0,opacity:1,blend:`normal`},{kind:`clouds`,label:e=>e.layer_clouds(),visible:!0,opacity:1,blend:`normal`},{kind:`night`,label:e=>e.layer_night(),visible:!1,opacity:.85,blend:`add`}];function HH(e){return e.kind===`raster`}var UH=new WeakMap,WH=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(VV,`svg`);layerGroup=document.createElementNS(VV,`g`);shapeGroup=document.createElementNS(VV,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;generation=0;controls=null;attribution=null;dragPan;scrollZoom;cooperativeGestures;lookup=null;lookupKey=``;buffer=null;frame=0;resizeObserver=null;listeners=new Map;announcedReady=!1;disposed=!1;moving=!1;sharpWidth=0;msPerPixel=0;settleTimer=0;chosenVisibility=new Map;customLayers=[];constructor(e={}){this.bodyId=e.body??BH,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=VB(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??Ng(new Date),this.dragPan=new CV(wV(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new CV(wV(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new CV(e.cooperativeGestures??!1,e=>this.applyCooperative(e)),this.root.className=`sm-flat`,this.canvas.className=`sm-flat__raster`,this.svg.setAttribute(`class`,`sm-flat__vector`),this.markerLayer.className=`sm-flat__markers`,this.svg.append(this.layerGroup,this.shapeGroup),this.root.append(this.canvas,this.svg,this.markerLayer),this.ctx=this.canvas.getContext(`2d`),this.overlay=new QV(this.shapeGroup,this.markerLayer,()=>this.render()),this.root.classList.toggle(`sm-flat--interactive`,this.dragPan.isEnabled()),this.applyCooperative(this.cooperativeGestures.isEnabled());for(let[t,n]of Object.entries(e.layers??{}))this.chosenVisibility.set(t,n)}mount(e){this.container=e,e.append(this.root),this.controls=new MV(this,this.root),this.cooperative=new EV(this.root,this.cooperativeGestures.isEnabled()),this.resizeObserver=new ResizeObserver(()=>this.renderMoving()),this.resizeObserver.observe(this.root),this.attachInteraction()}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){this.disposed=!0,this.controls?.clear(),this.controls=null,this.cooperative?.dispose(),this.cooperative=null,this.resizeObserver?.disconnect(),this.resizeObserver=null,cancelAnimationFrame(this.frame),clearTimeout(this.settleTimer);for(let e of this.layerList)HH(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await uH(e);if(!this.disposed){if(!t.surface){let t=Error(`spacemap: no map texture for ${e}`);throw this.emit(`error`,t),t}e!==this.bodyId&&this.release(),this.bodyId=e,this.sources=t,this.bodyRadiusKm=t.radiusKm??null,this.overlay.setBodyRadiusKm(this.bodyRadiusKm),this.buildLayers(),await this.loadVisible(),!this.disposed&&this.render()}}release(){this.generation++,this.dropTextures(),this.missing.clear();for(let e of this.layerList)!HH(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=a(),t=[];for(let n of VH){let r=this.sources[n.kind];r&&t.push({kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:UV(r),tiers:r.tiers,url:(e,t)=>hH(r,t,e)})}t.push(GV(e.layer_graticule())),t.push(qV(this.bodyId,e.layer_nomenclature())),t.push(...this.customLayers);for(let e of t){let t=this.chosenVisibility.get(e.id);t!==void 0&&(e.visible=t)}this.layerList=t,this.emit(`layerschange`,this.layers)}get layers(){return this.layerList.map(HV)}getLayers(){return this.layerList.map(e=>e.id)}isLayerVisible(e){return this.layerList.find(t=>t.id===e)?.visible??!1}get credits(){let e=new Set,t=[];for(let n of this.layerList)!n.visible||!n.credit||e.has(n.credit.organisation)||(e.add(n.credit.organisation),t.push(n.credit));return t}setLayerVisible(e,t){this.chosenVisibility.set(e,t);let n=this.layerList.find(t=>t.id===e);!n||n.visible===t||(n.visible=t,this.emit(`layerschange`,this.layers),this.loadVisible(),this.render())}setLayerOpacity(e,t){let n=this.layerList.find(t=>t.id===e);!n||!HH(n)||(n.opacity=Math.min(1,Math.max(0,t)),this.render())}addRasterLayer(e){let t={kind:`raster`,id:e.id,label:e.label??e.id,visible:e.visible??!0,opacity:e.opacity??1,blend:e.blend??`normal`,credit:e.credit,tiers:[`low`],url:()=>e.url};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}addVectorLayer(e){let t={kind:`vector`,id:e.id,label:e.label??e.id,visible:e.visible??!0,credit:e.credit,render:e.render,prepare:e.prepare};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}get projectionName(){return this.projectionId}static get projections(){return BB}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=VB(e,this.projectionOptions),this.view={...this.view,centerX:0,centerY:0},this.render(),this.emit(`viewchange`,this.viewState)}get viewState(){let e=this.viewport(),t=e.unproject(e.width/2,e.height/2);return{projection:this.projectionId,zoom:this.view.zoom,centerLon:t?.[0]??this.projectionOptions.centerLon??0,centerLat:t?.[1]??this.projectionOptions.centerLat??0}}setView(e){if(e.projection&&e.projection!==this.projectionId&&this.setProjection(e.projection),this.limitsArmed=!1,e.zoom!==void 0&&(this.view={...this.view,zoom:e.zoom}),e.centerLon!==void 0||e.centerLat!==void 0){let t=this.viewState,n=e.centerLon??t.centerLon,r=e.centerLat??t.centerLat;if(this.projection.azimuthal)this.projectionOptions={...this.projectionOptions,centerLon:n,centerLat:r},this.projection=VB(this.projectionId,this.projectionOptions);else{let e=this.projection.forward(n,r);e&&(this.view={...this.view,centerX:e[0],centerY:e[1]})}}this.loadVisible(),this.render(),this.emit(`viewchange`,this.viewState)}setLimits(e){return this.limits={maxZoom:16,...e},this.render(),this}getLimits(){return{...this.limits}}setTime(e){this.jd=e,this.loadVisible(),this.render()}async setBody(e){e!==this.bodyId&&(this.limitsArmed=!1,await this.adopt(e))}project(e,t){return this.viewport().project(e,t)}unproject(e,t){let n=this.viewport().unproject(e,t);return n?{lon:n[0],lat:n[1]}:null}addPolyline(e){let t=this.overlay.addPolyline(e);return this.render(),t}addPolygon(e){let t=this.overlay.addPolygon(e);return this.render(),t}addBox(e){let t=this.overlay.addBox(e);return this.render(),t}addCircle(e){let t=this.overlay.addCircle(e);return this.render(),t}addMarker(e){let t=this.overlay.addMarker(e);return this.render(),t}clearDrawings(){this.overlay.clear(),this.render()}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});UH.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners.get(e);if(n){n.delete(t);for(let e of n)UH.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}tier(e){return mH(e,pH(NH.find(([e])=>this.view.zoom>=e)?.[1]??`low`,fH(this.usableSourceWidth())))}usableSourceWidth(){return this.projectionId===`equirectangular`?this.deviceWidth()*this.view.zoom:this.workingWidth()}deviceWidth(){return this.sharpWidth||Math.max(1,this.root.clientWidth)}workingWidth(){let e=this.deviceWidth()*2*this.view.zoom;return Math.min(FH,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),dH[e]??FH)}picturesInUse(){return this.layerList.filter(e=>HH(e)&&e.visible).map(e=>{let t=this.tier(e.tiers);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!HH(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==SH(e,this.decodeWidth(t))).filter(({url:e})=>!this.pending.has(e)&&!this.missing.has(e)).map(async({url:e,tier:t})=>{this.pending.add(e);let n=this.generation;try{let r=await CH(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){TH(r.key);return}this.hold(this.bitmaps,e,r,TH),this.render()}catch(t){if(n!==this.generation)return;this.missing.add(e),this.emit(`error`,Error(`spacemap: could not load ${e}`,{cause:t}))}finally{this.pending.delete(e)}});await Promise.all([...t,...n]),this.dropUnused(new Set(this.picturesInUse().map(({url:e})=>e)))}dropUnused(e){for(let[t,n]of this.bitmaps)e.has(t)||(TH(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(DH(n.key),this.rasters.delete(t))}hold(e,t,n,r){let i=e.get(t);i?.key!==n.key&&(i&&r(i.key),e.set(t,n))}rasterFor(e,t){let n=this.rasters.get(e);if(n?.key===SH(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=EH(e,t,r);return i?(this.hold(this.rasters,e,i,DH),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())TH(e.key);for(let e of this.rasters.values())DH(e.key);this.bitmaps.clear(),this.rasters.clear()}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1;return this.view=jH(this.view,this.projection,n,r,this.limitsArmed?this.limits:{}),new kH(this.projection,Math.max(1,n),Math.max(1,r),this.view)}render(){this.disposed||(cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.draw()))}renderMoving(){this.moving=!0,clearTimeout(this.settleTimer),this.settleTimer=window.setTimeout(()=>{this.moving=!1,this.render()},zH),this.render()}draw(){let e=this.root.clientWidth,t=this.root.clientHeight;if(!this.ctx||e===0||t===0)return;let n=Math.min(window.devicePixelRatio||1,2),r=Math.sqrt(PH/(e*t*n*n)),i=n*Math.min(1,r),a=Math.max(1,Math.round(e*i));a!==this.sharpWidth&&(this.sharpWidth=a,this.loadVisible());let o=e*i*t*i,s=i*(this.moving?this.interactionScale(o):1),c=Math.max(1,Math.round(e*s)),l=Math.max(1,Math.round(t*s));(this.canvas.width!==c||this.canvas.height!==l)&&(this.canvas.width=c,this.canvas.height=l,this.buffer=null,this.lookup=null);let u=this.viewport(e,t),d=new kH(this.projection,c,l,this.view);this.clipToDisc(u),this.drawRaster(d,c,l),this.drawVector(u),!this.announcedReady&&this.bitmaps.size>0&&(this.announcedReady=!0,this.emit(`ready`))}record(e,t){if(t<=0)return;let n=e/t;this.msPerPixel=this.msPerPixel===0?n:this.msPerPixel*.7+n*.3}interactionScale(e){if(this.msPerPixel<=0||e<=0)return 1;let t=Math.sqrt(IH/this.msPerPixel/e);return t>RH?1:Math.max(LH,t)}clipToDisc(e){let{projection:t}=e;if(!t.azimuthal){this.canvas.style.clipPath=``;return}let[n,r]=e.toScreen(0,0),i=t.extent.maxX*e.scale;this.canvas.style.clipPath=`circle(${i}px at ${n}px ${r}px)`}drawRaster(e,t,n){let r=this.ctx;r.clearRect(0,0,t,n);let i=this.layerList.filter(e=>HH(e)&&e.visible);if(i.length===0)return;if(this.projectionId===`equirectangular`){let t=i.map(e=>({image:this.bitmaps.get(e.url(this.jd,this.tier(e.tiers)))?.bitmap,opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);t.length&&rH(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e.tiers)),a),opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);if(o.length===0)return;(!this.buffer||this.buffer.width!==t||this.buffer.height!==n)&&(this.buffer=r.createImageData(t,n));let s=`${this.projectionId}|${JSON.stringify(this.projectionOptions)}|${this.view.zoom}|${this.view.centerX}|${this.view.centerY}|${t}x${n}`,c=!this.lookup||this.lookupKey!==s,l=performance.now();c&&(this.lookup=new tH(e,t,n),this.lookupKey=s),nH(this.lookup,o,this.buffer),r.putImageData(this.buffer,0,0),c&&this.record(performance.now()-l,t*n)}drawVector(e){this.svg.setAttribute(`viewBox`,`0 0 ${e.width} ${e.height}`),this.layerGroup.replaceChildren();for(let t of this.layerList){if(HH(t)||!t.visible)continue;let n=document.createElementNS(VV,`g`);n.setAttribute(`data-layer`,t.id),t.render(e,n),this.layerGroup.append(n)}this.overlay.redraw(e)}applyCooperative(e){this.root.classList.toggle(`sm-flat--cooperative`,e),this.cooperative?.setEnabled(e)}attachInteraction(){let e=!1,t=0,n=0,r=!1,i=!1,a=new Map,o=-1,s=0,c=null,l=()=>{let[e,t]=[...a.values()];if(!t)return null;let n=this.root.getBoundingClientRect();return{gap:Math.hypot(e.x-t.x,e.y-t.y),x:(e.x+t.x)/2-n.left,y:(e.y+t.y)/2-n.top}},u=e=>{let t=this.root.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]};this.root.addEventListener(`pointerdown`,u=>{u.pointerType===`touch`&&a.set(u.pointerId,{x:u.clientX,y:u.clientY}),c=l(),s=c?.gap??0,u.button===0&&(o=u.pointerId,e=!0,r=!1,i=u.pointerType===`touch`&&this.cooperative.isEnabled()&&a.size<2,this.root.setPointerCapture(u.pointerId),t=u.clientX,n=u.clientY,!i&&this.dragPan.isEnabled()&&this.root.classList.add(`sm-flat--dragging`))}),this.root.addEventListener(`pointermove`,d=>{let[f,p]=u(d);a.has(d.pointerId)&&a.set(d.pointerId,{x:d.clientX,y:d.clientY});let m=l();if(m){r=!0,c&&this.dragPan.isEnabled()&&this.drag(m.x-c.x,m.y-c.y),s>0&&this.scrollZoom.isEnabled()&&this.zoomBy(m.gap/s,m.x,m.y),s=m.gap,c=m;return}if(!e){this.emit(`pointermove`,this.unproject(f,p),d);return}if(d.pointerId!==o)return;let h=d.clientX-t,g=d.clientY-n;if(t=d.clientX,n=d.clientY,(Math.abs(h)>1||Math.abs(g)>1)&&(r=!0),i){r&&this.cooperative.allowsTouchDrag(a.size);return}this.dragPan.isEnabled()&&this.drag(h,g)});let d=l=>{a.delete(l.pointerId),s=0,c=null;let[d]=[...a.entries()];if(d&&e){o=d[0],t=d[1].x,n=d[1].y,i=this.cooperative.isEnabled()&&a.size<2;return}if(!(!e||l.pointerId!==o)&&(e=!1,this.root.releasePointerCapture?.(l.pointerId),this.root.classList.remove(`sm-flat--dragging`),!r)){let[e,t]=u(l);this.emit(`click`,this.unproject(e,t),l)}};this.root.addEventListener(`pointerup`,d),this.root.addEventListener(`pointercancel`,d),this.root.addEventListener(`wheel`,e=>{if(!this.scrollZoom.isEnabled()||!this.cooperative.allowsWheel(e))return;e.preventDefault();let[t,n]=u(e);this.zoomBy(Math.exp(-e.deltaY/400),t,n)},{passive:!1})}drag(e,t){this.limitsArmed=!0;let n=this.viewport();if(this.projection.azimuthal){let r=n.scale,i=e=>e/r*(180/Math.PI),[a,o]=OH((this.projectionOptions.centerLon??0)-i(e),Math.max(-90,Math.min(90,(this.projectionOptions.centerLat??0)+i(t))),this.limits);this.projectionOptions={...this.projectionOptions,centerLon:a,centerLat:o},this.projection=VB(this.projectionId,this.projectionOptions)}else this.view={...this.view,centerX:this.view.centerX-e/n.scale,centerY:this.view.centerY+t/n.scale};this.renderMoving(),this.emit(`viewchange`,this.viewState)}zoomBy(e,t,n){this.limitsArmed=!0;let r=this.viewport().fromScreen(t,n),i=Math.min(this.limits.maxZoom??1/0,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(i===this.view.zoom)return;this.view={...this.view,zoom:i};let a=this.viewport();if(!this.projection.azimuthal){let e=a.fromScreen(t,n);this.view={...this.view,centerX:this.view.centerX+r[0]-e[0],centerY:this.view.centerY+r[1]-e[1]}}this.loadVisible(),this.renderMoving(),this.emit(`viewchange`,this.viewState)}};function GH(e){let t=e?.radii;if(t)return(t.a+t.b+t.c)/3;let n=e?.wikidata?.radius;if(n)return n.unit===`kilometre`?n.value:n.unit===`metre`?n.value/1e3:null;let r=e?.sbdb?.diameter;return r?r/2:null}function KH(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function qH(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var JH=Math.PI/180,YH=256,XH=128,ZH=.05,QH=.25;function $H(e){try{let t=document.createElement(`canvas`);t.width=YH,t.height=XH;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,YH,XH);let{data:r}=n.getImageData(0,0,YH,XH),i=new Uint8Array(YH*XH);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:YH,height:XH,covered:i}}catch{return null}}function eU(e,t,n){let{width:r,height:i,covered:a}=e,o=new Float64Array(r);for(let e=0;e<r;e++)o[e]=(e+.5)*360/r;let s=new Float64Array(i);for(let e=0;e<i;e++)s[e]=90-(e+.5)*180/i;let c=0,l=0,u=0;for(let e=0;e<i;e++){let t=Math.cos(s[e]*JH);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*JH),l+=t*Math.cos(o[n]*JH),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<ZH?t.heading:tU(Math.atan2(c,l)/JH-n.northOffsetDeg),f=tU(d+n.northOffsetDeg),p=Math.min(180,n.hfovDeg/2),m=new Float64Array(i),h=0;for(let e=0;e<r;e++)if(!(Math.abs((o[e]-f+540)%360-180)>p))for(let t=0;t<i;t++)a[t*r+e]&&(h=Math.max(h,++m[t]));let g=-1/0,_=1/0;for(let e=0;e<i;e++)m[e]<h*QH||(g=Math.max(g,s[e]),_=Math.min(_,s[e]));if(g<_)return{heading:d,pitch:t.pitch};let v=Math.min(n.vfovDeg/3,(g-_)/2);return{heading:d,pitch:Math.max(_+v,Math.min(g-v,t.pitch))}}function tU(e){return(e%360+360)%360}Math.PI/180;function nU(e){return e.orientation!==`unknown`&&e.north_offset_deg!==void 0}function rU(e){return e.id}function iU(e){return`${e.time},${e.lat},${e.lon}`}function aU(e,t){return t?e.find(e=>rU(e)===t||iU(e)===t)??null:null}function oU(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=e=>e&&e.mission===t.mission,a=e=>i(e)?{entry:e,distanceM:cU(t,e,n),bearingDeg:lU(t,e)}:null;return{previous:a(e[r-1]),next:a(e[r+1])}}var sU=Math.PI/180;function cU(e,t,n){return JB(e,t)*sU*n*1e3}function lU(e,t){let n=e.lat*sU,r=t.lat*sU,i=(t.lon-e.lon)*sU,a=Math.sin(i)*Math.cos(r),o=Math.cos(n)*Math.sin(r)-Math.sin(n)*Math.cos(r)*Math.cos(i);return(Math.atan2(a,o)/sU%360+360)%360}var uU=Math.PI/180,dU=30,fU=110,pU=85,mU=75,hU=-22,gU=9,_U=6,vU=10,yU=1,bU=1,xU=new Hi(-Math.SQRT1_2,0,0,Math.SQRT1_2),SU=new J(0,0,1);function CU(e){return(e%360+360)%360}function wU(e,[t,n]){let r=CU(n-t),i=CU(e-t);return i<=r?CU(e):i-r<360-i?CU(n):CU(t)}function TU(e,t,n){return Math.max(t,Math.min(n,e))}function EU(e,t,n=new J){let r=e*uU,i=t*uU;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function DU(){let e=new hl;return e.moveTo(0,1),e.lineTo(.85,.05),e.lineTo(.38,.05),e.lineTo(.38,-.9),e.lineTo(-.38,-.9),e.lineTo(-.38,.05),e.lineTo(-.85,.05),e.closePath(),e}var OU=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new qa;camera=new sd(mU,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new za;arrowGeometry=new tu(DU());raycaster=new Rd;loader=new Ju;texture=null;loadToken=0;frame=0;disposed=!1;entries=[];radiusKm=0;current=null;neighbours=null;view;pointers=new Map;pinchDistance=0;dragStart=null;hovered=null;gyroEnabled=!1;gyroOrigin=null;gyroEuler=new xa;gyroQuaternion=new Hi;gyroScreen=new Hi;gyroDirection=new J;lookAt=new J;ndc=new J;gridPoint=new J;viewDirection=new J;listeners={ready:new Set,load:new Set,error:new Set,viewchange:new Set,step:new Set,arrows:new Set};constructor(e){this.bodyId=e.body,this.openAt=e.at,this.interactive=e.interactive??!0,this.arrows.visible=e.arrows??!0,this.followArrows=e.followArrows??!0,this.openingView=e.heading!==void 0||e.pitch!==void 0?{heading:e.heading,pitch:e.pitch}:null,this.view={heading:e.heading??0,pitch:e.pitch??0,fov:e.fov??mU},e.limits&&this.setLimits(e.limits),this.root.className=`sm-panorama`,this.root.style.cssText=`position:relative;width:100%;height:100%;overflow:hidden`,this.scene.background=new X(`#0b0d12`),this.sphere=new As(new ru(500,96,48).scale(-1,1,1),new vs({transparent:!0,visible:!1,depthWrite:!1})),this.sphere.renderOrder=-2,this.scene.add(this.sphere,this.arrows)}mount(e){this.container=e,e.append(this.root),this.renderer=new dh({antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2));let t=this.renderer.domElement;t.style.cssText=`display:block;width:100%;height:100%;touch-action:none`,t.tabIndex=0,this.root.append(t),this.angleCanvas.style.cssText=`position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none`,this.angleCanvas.setAttribute(`aria-hidden`,`true`),this.angleCanvas.hidden=!0,this.root.append(this.angleCanvas),this.controls=new MV(this,this.root),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(this.root),this.resize(),this.interactive?(t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp),t.addEventListener(`pointercancel`,this.onPointerCancel),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.addEventListener(`keydown`,this.onKeyDown)):(t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp))}async load(){let e=await hx(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(mx),this.radiusKm=GH(e.global)??0,this.emit(`ready`);let t=this.openAt?this.byKey(this.openAt):this.entries[0]??null;if(!t){let e=Error(this.openAt?`spacemap: no panorama ${this.openAt} on ${this.bodyId}`:`spacemap: no panoramas on ${this.bodyId}`);throw this.emit(`error`,e),e}await this.open(t)}addControl(e,t){return this.controls?.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.disposed=!0,this.setGyroEnabled(!1),this.loadToken++,cancelAnimationFrame(this.frame),this.frame=0,this.controls?.clear(),this.resizeObserver?.disconnect();let e=this.renderer?.domElement;e&&(e.removeEventListener(`pointerdown`,this.onPointerDown),e.removeEventListener(`pointermove`,this.onPointerMove),e.removeEventListener(`pointerup`,this.onPointerUp),e.removeEventListener(`pointercancel`,this.onPointerCancel),e.removeEventListener(`wheel`,this.onWheel),e.removeEventListener(`keydown`,this.onKeyDown)),this.setArrowTargets([]),this.texture?.dispose(),this.sphere.geometry.dispose(),this.sphere.material.dispose(),this.arrowGeometry.dispose(),this.renderer?.dispose(),this.renderer=null,this.root.remove(),this.container=null}getPanoramas(){return this.entries}getCurrent(){return this.current}getNeighbours(){return this.neighbours}async open(e){let t=typeof e==`string`?this.byKey(e):e;if(!t){let t=Error(`spacemap: no panorama ${String(e)} on ${this.bodyId}`);throw this.emit(`error`,t),t}this.current=t,this.neighbours=this.radiusKm?oU(this.entries,t,this.radiusKm):null;let n=this.openingView;this.openingView=null,n&&this.setView({heading:n.heading,pitch:n.pitch??0}),this.setArrowTargets(this.neighbours&&nU(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n&&e.n.distanceM>=bU).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture(Yt(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg??0,!n),this.current===t&&this.emit(`load`,t)}async step(e){let t=this.neighbours?.[e];t&&await this.open(t.entry)}byKey(e){return this.entries.find(t=>t.id===e)??aU(this.entries,e)}getView(){return{...this.view}}setView(e){let t=e.heading??this.view.heading,n=e.pitch??this.view.pitch,r=e.fov??this.view.fov,{limits:i}=this;this.view={heading:i.heading?wU(t,i.heading):CU(t),pitch:TU(n,i.pitch?.[0]??-pU,i.pitch?.[1]??pU),fov:TU(r,i.fov?.[0]??dU,i.fov?.[1]??fU)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[TU(e[0],t,n),TU(e[1],t,n)];this.limits={heading:e.heading&&[CU(e.heading[0]),CU(e.heading[1])],pitch:t(e.pitch,-pU,pU),fov:t(e.fov,dU,fU)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?KH()!==`available`||!await qH()||this.disposed?!1:(this.gyroOrigin=null,this.gyroEnabled=!0,window.addEventListener(`deviceorientation`,this.onDeviceOrientation),!0):(window.removeEventListener(`deviceorientation`,this.onDeviceOrientation),this.gyroEnabled=!1,!1)}isGyroEnabled(){return this.gyroEnabled}onDeviceOrientation=e=>{if(e.alpha===null||e.beta===null||e.gamma===null)return;this.gyroEuler.set(e.beta*uU,e.alpha*uU,-e.gamma*uU,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(xU).multiply(this.gyroScreen.setFromAxisAngle(SU,-(screen.orientation?.angle??0)*uU)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/uU,n=Math.asin(TU(this.gyroDirection.y,-1,1))/uU;this.gyroOrigin===null&&(this.gyroOrigin=CU(t-this.view.heading)),this.setView({heading:t-this.gyroOrigin,pitch:n})};on(e,t){return this.listeners[e].add(t),()=>this.off(e,t)}once(e,t){let n=this.on(e,((...e)=>{n(),t(...e)}));return n}off(e,t){this.listeners[e].delete(t)}emit(e,...t){for(let n of this.listeners[e])n(...t)}faceCoverage(e,t){let n=$H(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*uU)*this.camera.aspect)/uU;this.setView(eU(n,this.view,{northOffsetDeg:t,hfovDeg:i,vfovDeg:r}))}loadTexture(e,t,n){let r=++this.loadToken;return new Promise((i,a)=>{this.loader.load(e,e=>{if(r!==this.loadToken){e.dispose(),i();return}e.colorSpace=Xr,this.renderer&&(e.anisotropy=this.renderer.capabilities.getMaxAnisotropy()),this.texture?.dispose(),this.texture=e,this.sphere.material.map=e,this.sphere.material.visible=!0,this.sphere.material.needsUpdate=!0,this.sphere.rotation.y=Math.PI/2+t*uU,n&&this.faceCoverage(e.image,t),this.invalidate(),i()},void 0,()=>{if(r!==this.loadToken)return i();let t=Error(`spacemap: panorama failed to load: ${e}`);this.emit(`error`,t),a(t)})})}setArrowTargets(e){for(let e of[...this.arrows.children])this.arrows.remove(e),e.traverse(e=>{e instanceof As&&e.material.dispose()});for(let t of e){let e=new za;e.name=t.key;let n=new As(this.arrowGeometry,new vs({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new As(this.arrowGeometry,new vs({color:`#ffffff`,transparent:!0,opacity:.85,side:2,depthWrite:!1}));r.position.y=.02;for(let e of[n,r])e.rotation.x=-Math.PI/2;e.add(n,r),e.position.copy(EU(t.bearingDeg,hU)).multiplyScalar(gU),e.rotation.y=-t.bearingDeg*uU,this.arrows.add(e)}this.invalidate()}invalidate(){this.disposed||this.frame||!this.renderer||(this.frame=requestAnimationFrame(()=>{this.frame=0,this.render()}))}setAngleGridVisible(e){e!==this.angleGridVisible&&(this.angleGridVisible=e,this.angleCanvas.hidden=!e,this.invalidate())}setArrowsVisible(e){e!==this.arrows.visible&&(this.arrows.visible=e,e||(this.hovered=null,this.renderer&&(this.renderer.domElement.style.cursor=``)),this.invalidate())}resize(){let{clientWidth:e,clientHeight:t}=this.root;if(!e||!t||!this.renderer)return;this.renderer.setSize(e,t,!1);let n=Math.min(window.devicePixelRatio,2);this.angleCanvas.width=Math.round(e*n),this.angleCanvas.height=Math.round(t*n),this.angleContext.setTransform(n,0,0,n,0,0),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.invalidate()}render(){if(!this.renderer)return;this.camera.fov=this.view.fov,this.camera.updateProjectionMatrix(),this.camera.lookAt(EU(this.view.heading,this.view.pitch,this.lookAt)),this.renderer.render(this.scene,this.camera);let{clientWidth:e,clientHeight:t}=this.root;if(this.drawAngleGrid(e,t),this.listeners.arrows.size===0)return;let n={};for(let r of this.arrows.visible?this.arrows.children:[])this.ndc.copy(r.position).project(this.camera),n[r.name]={x:(this.ndc.x+1)/2*e,y:(1-this.ndc.y)/2*t,visible:this.ndc.z<1&&Math.abs(this.ndc.x)<.98&&Math.abs(this.ndc.y)<.98};this.emit(`arrows`,n)}drawAngleGrid(e,t){let n=this.angleContext;if(n.clearRect(0,0,e,t),this.angleGridVisible){this.camera.getWorldDirection(this.viewDirection),n.strokeStyle=`rgba(255, 255, 255, 0.24)`,n.lineWidth=1,n.beginPath();for(let r=0;r<360;r+=vU)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=vU)this.traceAngleLine(n,e,t,r,!1);n.stroke(),n.font=`12px system-ui, sans-serif`,n.lineWidth=3,n.strokeStyle=`rgba(0, 0, 0, 0.7)`,n.fillStyle=`rgba(255, 255, 255, 0.85)`,n.textAlign=`center`,n.textBaseline=`bottom`;for(let r=0;r<360;r+=vU){if(!this.projectAngle(r,0,e,t,!0))continue;let i=`${r}°`;n.strokeText(i,this.gridPoint.x,this.gridPoint.y-3),n.fillText(i,this.gridPoint.x,this.gridPoint.y-3)}n.textAlign=`left`,n.textBaseline=`middle`;for(let r of[0,90,180,270])for(let i=-80;i<=80;i+=vU){if(i===0||!this.projectAngle(r,i,e,t,!0))continue;let a=`${i>0?`+`:``}${i}°`;n.strokeText(a,this.gridPoint.x+4,this.gridPoint.y),n.fillText(a,this.gridPoint.x+4,this.gridPoint.y)}}}traceAngleLine(e,t,n,r,i){let a=!1,o=0,s=0,c=Math.max(t,n)*2,l=i?-90:0,u=i?90:360;for(let d=l;d<=u;d+=yU){let l=i?r:d,u=i?d:r;if(!this.projectAngle(l,u,t,n)){a=!1;continue}let{x:f,y:p}=this.gridPoint;!a||Math.hypot(f-o,p-s)>c?e.moveTo(f,p):e.lineTo(f,p),a=!0,o=f,s=p}}projectAngle(e,t,n,r,i=!1){return EU(e,t,this.gridPoint),this.gridPoint.dot(this.viewDirection)<=.001||(this.gridPoint.project(this.camera),!Number.isFinite(this.gridPoint.x)||!Number.isFinite(this.gridPoint.y))||i&&(Math.abs(this.gridPoint.x)>=.98||Math.abs(this.gridPoint.y)>=.98)||Math.abs(this.gridPoint.x)>4||Math.abs(this.gridPoint.y)>4?!1:(this.gridPoint.x=(this.gridPoint.x+1)/2*n,this.gridPoint.y=(1-this.gridPoint.y)/2*r,!0)}degreesPerPixel(){return this.view.fov/Math.max(1,this.root.clientHeight)}arrowAt(e,t){if(!this.renderer||!this.arrows.visible||this.arrows.children.length===0)return null;let n=this.renderer.domElement.getBoundingClientRect(),r=new q((e-n.left)/n.width*2-1,-((t-n.top)/n.height)*2+1);this.raycaster.setFromCamera(r,this.camera);let i=this.raycaster.intersectObjects(this.arrows.children,!0)[0];return i?i.object.parent.name:null}pressArrow(e){let t=this.neighbours?.[e];t&&(this.emit(`step`,{key:e,entry:t.entry}),this.followArrows&&this.open(t.entry).catch(()=>{}))}onPointerDown=e=>{try{this.renderer?.domElement.setPointerCapture(e.pointerId)}catch{}this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.dragStart=this.pointers.size===1?{x:e.clientX,y:e.clientY}:null,this.pointers.size===2&&(this.pinchDistance=this.pinchSpan())};onPointerMove=e=>{let t=this.pointers.get(e.pointerId);if(!t){let t=this.arrowAt(e.clientX,e.clientY);t!==this.hovered&&this.renderer&&(this.hovered=t,this.renderer.domElement.style.cursor=t?`pointer`:``);return}let n=e.clientX-t.x,r=e.clientY-t.y;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===1){if(this.gyroEnabled)return;let e=this.degreesPerPixel();this.setView({heading:this.view.heading-n*e,pitch:this.view.pitch+r*e})}else if(this.pointers.size===2){let e=this.pinchSpan();this.pinchDistance>0&&this.zoom(this.pinchDistance/e),this.pinchDistance=e}};onPointerUp=e=>{this.pointers.delete(e.pointerId);let t=this.dragStart;if(this.dragStart=null,this.pointers.size>0||!(!this.interactive||t!==null&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<_U))return;let n=this.arrowAt(e.clientX,e.clientY);n&&this.pressArrow(n)};onPointerCancel=e=>{this.pointers.delete(e.pointerId),this.dragStart=null};pinchSpan(){let[e,t]=[...this.pointers.values()];return Math.hypot(e.x-t.x,e.y-t.y)}zoom(e){this.setView({fov:this.view.fov*e})}onWheel=e=>{e.preventDefault(),this.zoom(Math.exp(e.deltaY*.0015))};onKeyDown=e=>{let t=this.view.fov/10,{heading:n,pitch:r}=this.view,i={ArrowLeft:()=>this.setView({heading:n-t}),ArrowRight:()=>this.setView({heading:n+t}),ArrowUp:()=>this.setView({pitch:r+t}),ArrowDown:()=>this.setView({pitch:r-t}),"+":()=>this.zoom(.8),"-":()=>this.zoom(1.25)}[e.key];i&&(e.preventDefault(),i())}},kU=ax(()=>`${Kt()}/v1/groups/__planetary_systems_map__.json.gz`,{error:e=>`Failed to fetch planetary systems map: ${e.status}`}),AU=ax(()=>`${Kt()}/v1/groups/__solar_system_map__.json.gz`,{error:e=>`Failed to fetch solar system map: ${e.status}`});function jU({onScrub:e,onEnd:t}){let n=null,r=0,i=!1;function a(){i&&t(),n=null,i=!1}return{onpointerdown(e){e.pointerType!==`mouse`&&(n=e.clientX,r=e.clientY,i=!1)},onpointermove(t){t.pointerType===`mouse`||n===null||!i&&Math.hypot(t.clientX-n,t.clientY-r)<8||(i=!0,e(t.clientX,t.clientY))},onpointerup:a,onpointercancel:a,onpointerleave:a}}var MU=2.2,NU=84,PU=40,FU=4,IU=3,LU=1e4,RU=34,zU=7,BU=.42,VU=30;function HU(e,t,n){let r=1/0;for(let i of n)r=Math.min(r,Math.hypot(i.cx-e,i.cy-t));return r}function UU(e){return e>90?180-e:e}function WU(e){let t=Math.log10(e.domain[0]),n=Math.log10(e.domain[1])-t,r=r=>44+(Math.log10(Math.max(r/e.unitKm,1e-9))-t)/n*656,i=[];for(let t of[...e.bodies].sort((e,t)=>e.aKm-t.aKm)){let n=r(t.aKm),a=Math.max(MU,t.radiusKm*e.pxPerKm),o=120;if(t.tiltDeg>0){let r=Math.min(UU(t.tiltDeg)*e.pxPerDeg,NU),a=120-r,s=120+r;o=HU(n,a,i)>=HU(n,s,i)?a:s}i.push({...t,cx:n,cy:o,r:a})}let a=[];for(let t of i){if(!t.satellites?.length)continue;let n=t.rings?t.r*t.rings.outer*BU:0,r=t.cy-Math.max(t.r,n)-FU,i=[];for(let n of[...t.satellites].sort((e,t)=>t.radiusKm-e.radiusKm)){let a=Math.max(MU,n.radiusKm*e.pxPerKm);r-=a,i.push({...n,cx:t.cx,cy:r,r:a,hitY:0,hitHeight:0}),r-=a+IU}let o=Math.min(...i.map(e=>e.cy-e.r))-zU,s=Math.max(...i.map(e=>e.cy+e.r))+zU;i.forEach((e,t)=>{let n=t===0?s:(i[t-1].cy+e.cy)/2,r=t===i.length-1?o:(i[t+1].cy+e.cy)/2;e.hitY=r,e.hitHeight=n-r}),a.push({parent:t,moons:i,x:t.cx-RU/2,y:o,width:RU,height:s-o,perMoon:!t.grouped&&!t.satellitesLink&&i.some(e=>e.link)})}let o=e.bands.map(e=>{let t=r(e.innerKm),n=r(e.outerKm)-t,i=Math.max(n,VU);return{...e,x:t,width:n,hitX:t+(n-i)/2,hitWidth:i}}).sort((e,t)=>t.width-e.width),s=``;e.cloud?.points.forEach((t,n)=>{let i=t.aKm/e.unitKm;if(i<e.domain[0]||i>e.domain[1])return;let a=Math.min(Math.max(UU(t.tiltDeg),0)*e.pxPerDeg,NU),o=120+(n%2==0?-a:a);s+=`M${r(t.aKm).toFixed(1)} ${o.toFixed(1)}h0.01`});let c=e.primary.radiusKm*e.pxPerKm;return{bodies:i,moonZones:a,bands:o,cloudPath:s,primaryR:c,primaryCx:PU-c,xOf:r}}function GU(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function KU(e,t,n,r){for(let i of[!0,!1]){let a=null,o=r;for(let r of e.bodies){if(!!r.link!==i)continue;let e=Math.hypot(t-r.cx,n-r.cy),s=e<=r.r?e-LU:e-r.r;s>o||(a=r,o=s)}if(a)return a}return null}function qU(e,t,n){let r=KU(e,t,n,0);if(r)return{kind:`body`,id:r.id};for(let r of e.moonZones){if(!GU(r,t,n))continue;if(r.parent.grouped)return{kind:`body`,id:r.parent.id};if(!r.perMoon)return{kind:`stack`,id:r.parent.id};let e=r.moons.find(e=>n>=e.hitY&&n<=e.hitY+e.hitHeight);if(e)return{kind:`moon`,parent:r.parent.id,id:e.id}}let i=KU(e,t,n,16);if(i)return{kind:`body`,id:i.id};for(let r=e.bands.length-1;r>=0;r--){let i=e.bands[r];if(t>=i.hitX&&t<=i.hitX+i.hitWidth&&n>=26&&n<=206)return{kind:`band`,key:i.key}}return Math.hypot(t-e.primaryCx,n-120)<=e.primaryR?{kind:`primary`}:null}function JU(e,t,n){if(!n)return null;let{text:r}=e;switch(n.kind){case`primary`:return{cx:Math.max(44,t.primaryCx),cy:120-Math.min(t.primaryR,80),title:e.primary.name,sub:r.primary};case`body`:{let e=t.bodies.find(e=>e.id===n.id);if(!e)return null;let i=[r.distance(e.aKm)];return e.tiltDeg>90&&i.push(r.retrograde),e.grouped&&e.satellites?.length&&i.push(r.moons(e.satelliteCount??e.satellites.length)),{cx:e.cx,cy:e.cy-e.r-4,title:e.name,sub:i.join(` · `)}}case`stack`:{let e=t.moonZones.find(e=>e.parent.id===n.id);if(!e)return null;let i=e.x+e.width/2;return e.parent.satellitesTab?{cx:i,cy:e.y,title:e.parent.name,sub:r.moons(e.parent.satelliteCount??e.moons.length)}:{cx:i,cy:e.y,title:e.moons[0].name,sub:e.parent.name}}case`moon`:{let e=t.moonZones.find(e=>e.parent.id===n.parent),r=e?.moons.find(e=>e.id===n.id);return!e||!r?null:{cx:r.cx,cy:r.cy-r.r-4,title:r.name,sub:e.parent.name}}case`band`:{let e=t.bands.find(e=>e.key===n.key);return e?{cx:e.x+e.width/2,cy:44,title:e.name??e.label,sub:e.sub??`${r.distance(e.innerKm)}–${r.distance(e.outerKm)}`}:null}}}var YU=`http://www.w3.org/2000/svg`,XU=10,ZU=-18,QU=1.2,$U=28,eW=6,tW=4,nW=18,rW=12,iW=190;function aW(e,t={},...n){let r=document.createElementNS(YU,e);for(let[e,n]of Object.entries(t))n!==void 0&&r.setAttribute(e,String(n));for(let e of n)e&&r.append(e);return r}function oW(e,t){return JSON.stringify(e)===JSON.stringify(t)}function sW(e,t){let n=new Map,r=(e,t)=>{(t?.href||t?.onclick)&&n.set(JSON.stringify(e),t)};for(let e of t.bands)r({kind:`band`,key:e.key},e);r({kind:`primary`},e.primary.link);for(let e of t.bodies)r({kind:`body`,id:e.id},e.link);for(let e of t.moonZones)if(!e.parent.grouped)if(!e.perMoon)r({kind:`stack`,id:e.parent.id},e.parent.satellitesLink);else for(let t of e.moons)r({kind:`moon`,parent:e.parent.id,id:t.id},t.link);return n}var cW=0,lW=class{root=document.createElement(`div`);svg=aW(`svg`);tip=document.createElement(`div`);tipTitle=document.createElement(`span`);tipSub=document.createElement(`span`);uid=`sm-system-map-${cW++}`;resize=new ResizeObserver(()=>{this.fitLabels(),this.placeTip()});model=null;placed=null;background=!1;hover=null;highlights=new Map;targets=new Map;links=new Map;shape=``;labels=[];constructor(){this.tip.className=`sm-system-map__tip`,this.tipTitle.className=`sm-system-map__tip-title`,this.tipSub.className=`sm-system-map__tip-sub`,this.tip.append(this.tipTitle,this.tipSub),this.tip.hidden=!0,this.root.append(this.svg,this.tip),this.resize.observe(this.root);let e=jU({onScrub:(e,t)=>this.setHover(this.hitAt(e,t)),onEnd:()=>this.setHover(null)});this.svg.addEventListener(`pointerdown`,e.onpointerdown),this.svg.addEventListener(`pointermove`,e.onpointermove),this.svg.addEventListener(`pointerup`,e.onpointerup),this.svg.addEventListener(`pointercancel`,e.onpointercancel),this.svg.addEventListener(`pointerleave`,e.onpointerleave);let t=[0,0],n=e=>{t=[e.clientX,e.clientY]};this.svg.addEventListener(`pointerdown`,n),this.svg.addEventListener(`pointerup`,n),this.svg.addEventListener(`pointermove`,e=>{n(e),e.pointerType===`mouse`&&this.setHover(this.hitAt(e.clientX,e.clientY))}),this.svg.addEventListener(`pointerleave`,e=>{e.pointerType===`mouse`&&this.setHover(null)}),this.svg.addEventListener(`click`,e=>{if(e.detail===0)return;let n=Math.abs(t[0]-e.clientX)<1&&Math.abs(t[1]-e.clientY)<1?this.hitAt(...t):this.hitAt(e.clientX,e.clientY);if(!n)return;let r=this.targets.get(JSON.stringify(n));r?.contains(e.target)||(e.stopPropagation(),e.preventDefault(),r?.dispatchEvent(new MouseEvent(`click`,{bubbles:!0,cancelable:!0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,button:e.button})))},!0)}destroy(){this.resize.disconnect(),this.root.remove()}update(e,t){this.model=e,this.placed=WU(e);let n=sW(e,this.placed),r=JSON.stringify([JSON.stringify(e,(e,t)=>e===`href`?void 0:t),t,[...n].map(([e,t])=>[e,!!t.href,!!t.onclick])]);if(this.links=n,r===this.shape){for(let[e,t]of this.targets){let r=n.get(e)?.href;r&&t.setAttribute(`href`,r)}return}this.shape=r,this.background=t.variant===`background`,this.hover=null,this.root.className=this.background?`sm-system-map sm-system-map--background`:`sm-system-map`,this.draw(e,this.placed,t.ariaLabel),this.fitLabels(),this.placeTip()}draw(e,t,n){let r=this.background;this.highlights=new Map,this.targets=new Map,this.labels=[];let i=this.svg;i.replaceChildren(),i.setAttribute(`viewBox`,r&&e.backgroundView||`0 0 720 240`),i.setAttribute(`preserveAspectRatio`,r?e.backgroundFit===`fit`?`xMidYMid meet`:e.backgroundView?`xMinYMid slice`:`xMidYMid slice`:`xMidYMid meet`),i.setAttribute(`class`,`sm-system-map__svg`),i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,n),i.setAttribute(`data-vaul-no-drag`,``);let a=(t,n)=>aW(`stop`,{offset:t,"stop-color":e.primary.color,"stop-opacity":n});i.append(aW(`defs`,{},aW(`radialGradient`,{id:`${this.uid}-primary`,gradientUnits:`userSpaceOnUse`,cx:t.primaryCx,cy:120,r:t.primaryR},a(`0%`,1),a(Math.max(0,1-XU/t.primaryR),.85),a(`100%`,.35)),aW(`pattern`,{id:`${this.uid}-band`,width:9,height:9,patternUnits:`userSpaceOnUse`},aW(`circle`,{cx:2,cy:2,r:.9,fill:`currentColor`,opacity:.55}),aW(`circle`,{cx:6.5,cy:6,r:.9,fill:`currentColor`,opacity:.55})))),r||this.drawAxis(e,t),t.cloudPath&&i.append(aW(`path`,{d:t.cloudPath,stroke:e.cloud?.color,"stroke-width":QU*2,"stroke-linecap":`round`,fill:`none`,opacity:.45,"pointer-events":`none`}));for(let e of t.bands){let t=aW(`rect`,{x:e.x,y:26,width:e.width,height:180,fill:`url(#${this.uid}-band)`,class:`sm-system-map__band sm-system-map__band--${e.tone}`});if(r){i.append(t);continue}let n=aW(`text`,{x:e.x+e.width/2,y:232,"text-anchor":`middle`,"font-size":nW,class:`sm-system-map__band-label sm-system-map__band-label--${e.tone}`});n.textContent=e.label,this.labels.push(n),i.append(this.target(e,e.name??e.label,{kind:`band`,key:e.key},t,aW(`rect`,{x:e.hitX,y:26,width:e.hitWidth,height:180,fill:`transparent`}),n))}let o=aW(`circle`,{cx:t.primaryCx,cy:120,r:t.primaryR,fill:`url(#${this.uid}-primary)`});i.append(r?o:this.target(e.primary.link,e.primary.name,{kind:`primary`},o));for(let e of t.bodies){if(!e.rings)continue;let t=e.r*(e.rings.inner+e.rings.outer)/2;i.append(aW(`ellipse`,{cx:e.cx,cy:e.cy,rx:t,ry:t*BU,transform:`rotate(${ZU} ${e.cx} ${e.cy})`,fill:`none`,stroke:`#d9c89f`,"stroke-width":e.r*(e.rings.outer-e.rings.inner),opacity:.45}))}let s=new Map(t.moonZones.map(e=>[e.parent.id,e]));for(let e of t.bodies)i.append(this.body(e,s.get(e.id)));for(let e of t.moonZones)e.parent.grouped||this.stack(e)}drawAxis(e,t){for(let n of e.ticks){let r=t.xOf(n*e.unitKm),i=aW(`text`,{x:r,y:16,"text-anchor":`middle`,"font-size":16,fill:`currentColor`,opacity:.85});i.textContent=String(n),this.svg.append(aW(`line`,{x1:r,x2:r,y1:20,y2:212,stroke:`currentColor`,"stroke-width":.5,opacity:.12}),i)}let n=aW(`text`,{x:700,y:16,"text-anchor":`end`,"font-size":14,fill:`currentColor`,opacity:.65});n.textContent=e.axisLabel,this.svg.append(n)}body(e,t){let n=e.reference?aW(`circle`,{cx:e.cx,cy:e.cy,r:e.r+1,fill:`none`,stroke:e.color,"stroke-width":1.2,class:`sm-system-map__reference`}):aW(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color});if(this.background)return!t||!e.grouped?n:aW(`g`,{},n,...this.moonDots(t));let r={kind:`body`,id:e.id},i=this.highlight(r,aW(`circle`,{cx:e.cx,cy:e.cy,r:e.r+3.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),a=aW(`circle`,{cx:e.cx,cy:e.cy,r:e.r+16,fill:`transparent`});return!t||!e.grouped?this.target(e.link,e.name,r,i,n,a):this.target(e.link,e.name,r,this.highlight(r,this.zoneWash(t)),i,n,a,...this.moonDots(t),this.zoneHit(t))}stack(e){if(this.background){this.svg.append(...this.moonDots(e));return}let t=e.parent;if(e.perMoon){this.svg.append(...this.moonDots(e));for(let n of e.moons){let r={kind:`moon`,parent:t.id,id:n.id};this.svg.append(this.target(n.link,n.name,r,this.highlight(r,aW(`circle`,{cx:n.cx,cy:n.cy,r:n.r+2.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),aW(`rect`,{x:e.x,y:n.hitY,width:e.width,height:n.hitHeight,fill:`transparent`})))}return}let n={kind:`stack`,id:t.id},r=e.moons[0];this.svg.append(this.highlight(n,this.zoneWash(e)),...this.moonDots(e),this.target(t.satellitesLink,t.satellitesTab?`${t.name} · ${this.model.text.moons(t.satelliteCount??e.moons.length)}`:r.name,n,this.zoneHit(e)))}moonDots(e){return e.moons.map(e=>aW(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color}))}zoneWash(e){return aW(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:4,fill:`currentColor`,opacity:.1,"pointer-events":`none`})}zoneHit(e){return aW(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:`transparent`})}highlight(e,t){let n=JSON.stringify(e),r=this.highlights.get(n);return r?r.push(t):this.highlights.set(n,[t]),t.style.display=`none`,t}target(e,t,n,...r){let i=!!(e?.href||e?.onclick),a=e?.href?aW(`a`,{href:e.href,"aria-label":t}):i?aW(`g`,{role:`button`,tabindex:0,"aria-label":t,class:`sm-system-map__button`}):aW(`g`);if(a.append(...r),!i)return a;let o=JSON.stringify(n);return this.targets.set(o,a),a.addEventListener(`focus`,()=>this.setHover(n)),a.addEventListener(`blur`,()=>{oW(this.hover,n)&&this.setHover(null)}),a.addEventListener(`click`,e=>this.links.get(o)?.onclick?.(e)),e?.href||a.addEventListener(`keydown`,e=>{let t=e.key;t!==`Enter`&&t!==` `||(e.preventDefault(),a.dispatchEvent(new MouseEvent(`click`,{bubbles:!0})))}),a}setHover(e){if(oW(this.hover,e))return;for(let e of this.highlights.get(JSON.stringify(this.hover))??[])e.style.display=`none`;this.targets.get(JSON.stringify(this.hover))?.removeAttribute(`data-near`),this.hover=e;for(let t of this.highlights.get(JSON.stringify(e))??[])t.style.display=``;let t=this.targets.get(JSON.stringify(e));t?.setAttribute(`data-near`,``),this.svg.classList.toggle(`sm-system-map__svg--near`,!!t),this.placeTip()}hitAt(e,t){if(!this.placed||this.background)return null;let n=this.svg.getBoundingClientRect();if(!n.width||!n.height)return null;let r=(e-n.left)/n.width*720,i=(t-n.top)/n.height*240;return qU(this.placed,r,i)}fitLabels(){for(let e of this.labels){let t=0;e.setAttribute(`font-size`,String(nW));try{t=e.getComputedTextLength()}catch{}if(!t)continue;if(t>iW){let n=Math.max(rW,nW*iW/t);e.setAttribute(`font-size`,String(n)),t*=n/nW}let n=Number(e.dataset.centre??e.getAttribute(`x`));e.dataset.centre=String(n);let r=t/2,i=Math.min(Math.max(n,r+tW),Math.max(r,720-r-tW));e.setAttribute(`x`,String(i))}}placeTip(){let e=this.model&&this.placed&&!this.background?JU(this.model,this.placed,this.hover):null;if(this.tip.hidden=!e,!e)return;this.tipTitle.textContent=e.title,this.tipSub.textContent=e.sub?` · ${e.sub}`:``;let t=this.root.clientWidth,n=t/720;this.tip.style.maxWidth=`${Math.max(0,t-2*eW)}px`;let r=this.tip.offsetWidth/2,i=Math.min(Math.max(e.cx*n,r+eW),Math.max(r,t-r-eW));this.tip.style.left=`${i}px`,this.tip.style.top=`${Math.max(4,e.cy*n-$U)}px`}};function uW(e,t){return{planetId:e.primary.id,planetName:t,planetRadiusKm:e.primary.radius_km,planetColor:n_[e.primary.id]??`#cccccc`,moons:e.moons.map(e=>({id:e.id,name:e.id,aRp:e.a_rp,tiltDeg:e.tilt_deg,radiusKm:e.radius_km,color:n_[e.id]??e.color??`#cccccc`})),rings:e.rings?{innerRp:e.rings.inner_rp,outerRp:e.rings.outer_rp}:null,moonCount:e.moon_count}}var dW=14,fW=1.001,pW=.62,mW=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,5e3],hW=`0 96 320 144`,gW=`0 96 720 144`,_W=[1,100];function vW(e,t){let n=Math.min(...e.moons.map(e=>e.aRp)),r=Math.max(...e.moons.map(e=>e.aRp));for(let i of t)n=Math.min(n,i.innerKm/e.planetRadiusKm),r=Math.max(r,i.outerKm/e.planetRadiusKm);return!Number.isFinite(n)||!Number.isFinite(r)?_W:(r<=n&&(n/=2,r*=2),n=n<=fW?1:n,[n>1?10**(Math.log10(n)-.12):1,10**(Math.log10(r)+.12)])}function yW(e,t){let n=e.planetRadiusKm,r=vW(e,t.bands);return{primary:{id:e.planetId,name:e.planetName,radiusKm:n,color:e.planetColor,link:t.primaryLink},bodies:e.moons.map(e=>({id:e.id,name:e.name,aKm:e.aRp*n,tiltDeg:e.tiltDeg,radiusKm:e.radiusKm,color:e.color,link:t.moonLink?.(e)})),bands:t.bands,cloud:t.cloud,unitKm:n,domain:r,ticks:mW.filter(e=>e>=r[0]&&e<=r[1]),axisLabel:t.axisLabel,pxPerKm:dW/Math.max(...e.moons.map(e=>e.radiusKm).filter(e=>e>0),1),pxPerDeg:pW,text:t.text,backgroundView:t.wide?gW:hW,backgroundFit:t.wide?`fit`:`slice`}}var bW=224e-6,xW=1.8,SW=[.3,50],CW=[.3,1,3,10,30],wW=`#ffdd44`;function TW(e){let t=e.replace(/^\d+\s+/,``);return t===t.toUpperCase()&&/[A-Z]/.test(t)?t.charAt(0)+t.slice(1).toLowerCase():t}function EW(e){return e.color||n_[e.id]||`#cccccc`}function DW(e,t){let n=new Map,r=new Map(e.objects.map(e=>[e.id,e]));for(let i of e.objects){if(i.kind!==`moon`||!i.parent)continue;let e=n.get(i.parent)??{satellites:[],count:r.get(i.parent)?.moon_count,tab:!1};e.satellites.push({id:i.id,name:t(i),radiusKm:i.diameter_km/2,color:EW(i)}),e.tab||=!!i.link_parent,n.set(i.parent,e)}return n}function OW(e,t){let n=e.objects.find(e=>e.kind===`star`);if(!n)return null;let r=DW(e,t.name),i=t.stack??(e=>r.get(e.id)),a=e.objects.filter(e=>e.kind!==`moon`&&e.kind!==`star`&&(t.keep?.(e)??!0)).map(e=>{let n=i(e);return{id:e.id,name:t.name(e),aKm:e.a*ig,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:EW(e),rings:e.rings,satellites:n?.satellites,satelliteCount:n?.count,satellitesTab:n?.tab??!1,...t.links(e,n)}});return{primary:{id:n.id,name:t.name(n),radiusKm:n.diameter_km/2,color:wW,link:t.primaryLink},bodies:a,bands:e.belts.map(e=>({key:e.slug,innerKm:e.inner_au*ig,outerKm:e.outer_au*ig,tone:e.kind===`kuiper_belt`?`sky`:`muted`,...t.band(e)})),unitKm:ig,domain:SW,ticks:CW,axisLabel:t.text.axisAu,pxPerKm:bW,pxPerDeg:xW,text:t.text}}function kW(e){return{id:e.id,name:e.name??e.id,moon:e.moon??!1,aAu:e.aAu??0,tiltDeg:e.tiltDeg??0,radiusKm:e.radiusKm??0,color:e.color??n_[e.id]??`#cccccc`,parent:e.parent}}var AW=4,jW=10,MW={inner:[.6,5.5],outer:[4.5,55]},NW=[.1,.2,.3,.5,1,2,3,5,10,20,30,50,100,200,500,1e3],PW=.9,FW=.76;function IW(e,t){return Math.log(e/t[0])/Math.log(t[1]/t[0])}var LW=`naif-599`;function RW(e,t,n,r=[]){if(!n)return[];let i=new Set([...e.objects.map(e=>e.id),...r]);for(let e of Object.values(t)){i.add(e.primary.id);for(let t of e.moons)i.add(t.id)}return[...n].filter(e=>!i.has(e))}function zW(e){let t=e.type===`moon`,n=e.orbit?.parent_id,r=n===void 0||n===`naif-10`||n===`naif-0`?e.orbit?.a??e.orbit?.q:void 0;if(r===void 0&&!t)return null;let i=e.radii;return{id:e.id,name:TW(e.name??e.id),moon:t,aAu:r??0,tiltDeg:e.orbit?.i??0,radiusKm:i?(i.a+i.b+i.c)/3:(e.sbdb?.diameter??0)/2,color:n_[e.id]??e.sbdb?.color??e.color??`#cccccc`,parent:e.orbit?.parent_id}}var BW=.92;function VW(e,t){return e<t*BW?`inner`:`outer`}function HW(e,t){return Object.values(e).find(e=>e.primary.id===t)}function UW(e){return e.kind===`zone`?`zone:${e.zone}`:`${e.kind}:${e.id}`}var WW=class{targets=new Map;constructor(e,t,n){this.data=e,this.options=t,this.pick=n}has(e){return!this.options.bodies||this.options.bodies.has(e)}name(e,t){return this.options.names[e]??(t?TW(t):e)}named(e,t){return this.options.names[e]??t}link(e){return this.targets.set(UW(e),e),{onclick:()=>this.pick(e)}}body(e,t){return this.has(e)?this.link({kind:`body`,id:e,name:t}):void 0}stack(e,t){if(t&&!this.options.bodies)return t;let n=(HW(this.data.systems,e)?.moons??[]).filter(e=>this.has(e.id)).map(e=>({id:e.id,name:this.name(e.id),radiusKm:e.radius_km,color:n_[e.id]??e.color??`#cccccc`}));if(n.length)return n.sort((e,t)=>t.radiusKm-e.radiusKm),{satellites:n.slice(0,AW),count:n.length,tab:!0}}links(e,t,n){if(!n)return{link:this.body(e,t)};let r=()=>this.link({kind:`system`,id:e,name:t});if(this.options.grouping===`systems`)return{link:r(),grouped:!0};let i=n.satellites[0];return{link:this.body(e,t),satellitesLink:n.tab?r():this.body(i.id,i.name)}}built(e,t){return{model:e,targets:[...this.targets.values()],label:t}}};function GW(e,t,n,r){let i=new WW(e,t,r),a=e=>i.name(e.id,e.name),o=DW(e.solar,a),s=new Map(e.solar.objects.map(e=>[e.id,i.stack(e.id,o.get(e.id))])),c=e.solar.objects.find(e=>e.kind===`star`),l=e=>{let t=e===`inner`?n.zoneInner:n.zoneOuter;return{label:t,sub:``,...i.link({kind:`zone`,zone:e,name:t})}},u=OW(e.solar,{text:n,name:a,primaryLink:c&&i.body(c.id,a(c)),keep:e=>i.has(e.id)||!!s.get(e.id),stack:e=>s.get(e.id),links:(e,t)=>i.links(e.id,a(e),t),band:e=>t.zones===`belts`?{label:e.label}:l(e.kind===`kuiper_belt`?`outer`:`inner`)});if(!u)throw Error(`spacemap: the Solar System map names no Sun`);return i.built(u,n.solarSystem)}function KW(e,t,n,r,i,a){let o=HW(e.systems,t);if(!o)throw Error(`spacemap: no planetary system around ${t}`);let s=new WW(e,r,a),c=uW(o,s.name(t,n[t]));c.moons=c.moons.filter(e=>s.has(e.id)).map(e=>({...e,name:s.name(e.id,n[e.id])}));let l=c.planetRadiusKm,u=c.rings?[{key:`rings`,label:i.rings,innerKm:c.rings.innerRp*l,outerKm:c.rings.outerRp*l,tone:`amber`}]:[],d=yW(c,{text:i,axisLabel:i.axisRadii,bands:u,primaryLink:s.body(t,c.planetName),moonLink:e=>s.body(e.id,e.name)});return d.ticks=d.ticks.filter(e=>IW(e,d.domain)<FW),s.built(d,c.planetName)}function qW(e,t,n,r,i){let a=new WW(e,n,i),{solar:o,extras:s}=e,c=o.objects.find(e=>e.kind===`star`),l=o.objects.find(e=>e.id===LW)?.a;if(!c||l===void 0)throw Error(`spacemap: the Solar System map names no Sun or no Jupiter`);let u=o.objects.filter(e=>e.kind===`dwarf`||e.kind===`asteroid`).map(e=>({id:e.id,name:a.name(e.id,e.name),aAu:e.a,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:EW(e)}));for(let e of s)e.moon||u.some(t=>t.id===e.id)||e.aAu>0&&u.push({...e,name:a.named(e.id,e.name)});let d=[];for(let e of u){if(VW(e.aAu,l)!==t)continue;let n={...e,aKm:e.aAu*ig},r=a.stack(e.id);if(r){d.push({...n,satellites:r.satellites,satelliteCount:r.count,satellitesTab:!0,...a.links(e.id,e.name,r)});continue}let i=s.filter(t=>t.moon&&t.parent===e.id&&a.has(t.id)).map(e=>{let t=a.named(e.id,e.name);return{...e,name:t,link:a.body(e.id,t)}});!a.has(e.id)&&!i.length||d.push({...n,link:a.body(e.id,e.name),satellites:i.length?i:void 0})}let[f,p]=MW[t],m=[Math.min(f,...d.map(e=>e.aKm/ig*.85)),Math.max(p,...d.map(e=>e.aKm/ig*1.15))],h=e=>e>=m[0]&&e<=m[1],g=jW/Math.max(...d.map(e=>e.radiusKm),1);for(let e of o.objects)e.kind!==`planet`||!h(e.a)||d.push({id:e.id,name:a.name(e.id,e.name),aKm:e.a*ig,tiltDeg:0,radiusKm:0,color:EW(e),reference:!0});let _=t===`inner`?r.zoneInner:r.zoneOuter;return a.built({primary:{id:c.id,name:a.name(c.id,c.name),radiusKm:c.diameter_km/2*bW/g,color:wW},bodies:d,bands:o.belts.filter(e=>h(e.inner_au)&&h(e.outer_au)).map(e=>({key:e.slug,label:e.label,innerKm:e.inner_au*ig,outerKm:e.outer_au*ig,tone:e.kind===`kuiper_belt`?`sky`:`muted`})),unitKm:ig,domain:m,ticks:NW.filter(e=>h(e)&&IW(e,m)<PW),axisLabel:r.axisAu,pxPerKm:g,pxPerDeg:xW,text:r},_)}var JW=new WeakMap,YW=.01;function XW(){let{messages:e,locale:t}=a(),n=new Intl.NumberFormat(t(),{maximumSignificantDigits:3}),r=new Intl.NumberFormat(t(),{style:`unit`,unit:`kilometer`,maximumSignificantDigits:3}),i=e.unit_symbol_astronomical_unit();return{primary:e.planetary_system_primary(),retrograde:e.planetary_system_retrograde(),moons:t=>e.system_map_moons({count:t}),distance:e=>{let t=e/ig;return t>0&&t<YW?r.format(e):`${n.format(t)} ${i}`},axisAu:e.system_map_axis_au(),solarSystem:e.system_map_solar_system(),rings:e.tab_rings(),axisRadii:e.planetary_system_axis_unit(),zoneInner:e.system_map_zone_inner(),zoneOuter:e.system_map_zone_outer()}}var ZW=class{chart=new lW;listeners=new Map;view;bodies;names;grouping;zones;places;targets=[];extras=new Map;queue=Promise.resolve();disposed=!1;constructor(e={}){this.view=e.view??{kind:`solar-system`},this.bodies=e.bodies?new Set(e.bodies):null,this.names=e.names??{},this.grouping=e.grouping??`bodies`,this.zones=e.zones??`belts`,this.places=(e.places??[]).map(kW)}mount(e){e.append(this.chart.root)}remove(){this.disposed=!0,this.chart.destroy()}load(){return this.draw()}async setView(e){await this.draw(e)}getView(){return this.view}setBodies(e){let t=e?new Set(e):null;return this.draw(void 0,t).catch(()=>{})}getTargets(){return[...this.targets]}draw(e,t){let n=this.queue.then(()=>(t!==void 0&&(this.bodies=t),this.drawNow(e??this.view)));return this.queue=n.catch(()=>{}),n}async drawNow(e){let t;try{t=await this.build(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw this.disposed||this.emit(`error`,t),t}if(this.disposed)return;let n=JSON.stringify(e)!==JSON.stringify(this.view);this.view=e,this.targets=t.targets,this.chart.update(t.model,{ariaLabel:t.label}),n&&this.emit(`viewchange`,e)}async build(e){let[t,n]=await Promise.all([AU(),kU()]),r={bodies:this.bodies,names:this.names,grouping:this.grouping,zones:this.zones},i=XW(),a=e=>this.emit(`select`,e),o={solar:t,systems:n,extras:[]};switch(e.kind){case`solar-system`:return GW(o,r,i,a);case`system`:return KW(o,e.id,await this.exportedNames(e.id,n),r,i,a);case`zone`:{let s=RW(t,n,this.bodies,this.places.map(e=>e.id)),c=(await Promise.all(s.map(e=>this.extra(e)))).filter(e=>e!==null),l=[...this.places,...c],u=RW(t,n,new Set(l.flatMap(e=>e.moon&&e.parent?[e.parent]:[])),l.map(e=>e.id)),d=await Promise.all(u.map(e=>this.extra(e))),f=[...l,...d.filter(e=>e!==null)];return qW({...o,extras:f},e.zone,r,i,a)}}}extra(e){let t=this.extras.get(e);return t||(t=hx(e,!1).then(t=>{if(!t.global)throw Error(`spacemap: no such body as ${e}`);return zW(t.global)}).catch(t=>(this.extras.delete(e),this.emit(`error`,t instanceof Error?t:Error(String(t))),null)),this.extras.set(e,t)),t}async exportedNames(e,t){if(![e,...(HW(t,e)?.moons??[]).map(e=>e.id)].some(t=>!(t in this.names)&&(t===e||!this.bodies||this.bodies.has(t))))return{};try{let{global:t,localized:n}=await hx(e,!0,a().locale()),r={};for(let e of t?.notable_moons??[])e.id&&(r[e.id]=e.name);Object.assign(r,n?.notable_moon_names);let i=n?.name??t?.name;return i&&(r[e]=i),r}catch{return{}}}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});JW.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners.get(e);if(n){n.delete(t);for(let e of n)JW.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}},QW=Object.fromEntries(xn.map(e=>[e,bn[e].label]));function $W(e,t){let n=e.credits.orbitSourceParents.get(t);if(!n)return!0;let r=e.visibility.focusedSystemId;for(let t of n)if(e.bodies.isInSystem(t,r))return!0;return!1}function eG(e){return xn.filter(t=>e.credits.orbitSources.has(t)).filter(t=>!bn[t].scoped||$W(e,t)).map(e=>({source:e,info:bn[e]}))}function tG(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function nG(e,t=QW){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(eG(e).map(({source:e})=>t[e]))],i=new Set;for(let t of tG(e,n.imagery.values()))i.add(t.organisation);let a=e.visibility.focusedBodyId,o=a?n.model.get(a):void 0;return o&&i.add(o.organisation),{orbits:r,imagery:[...i].sort()}}var rG=`https://spacemap.co`,iG=`https://spacemap.co/credits`;function aG(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function oG(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function sG(e,t,n){let r=document.createElement(`a`);return r.href=e,r.target=`_blank`,r.rel=`noopener noreferrer`,r.textContent=t,n&&(r.className=n),r}var cG=class{stop=null;onAdd(e){let t=aG(),n=oG(),r=oG();return t.append(sG(rG,`spacemap`,`sm-attribution__home`),n,r,sG(iG,a().messages.credits_see_all())),this.stop=lt(()=>{st(()=>{let t=nG(e.ctx);lG(n,a().messages.attribution_orbits(),t.orbits),lG(r,a().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function lG(e,t,n){if(e.hidden=n.length===0,e.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${t}:`,e.replaceChildren(r,` ${n.join(` · `)}`)}var uG=class{off=null;onAdd(e){let t=aG(),n=oG();t.append(sG(rG,`spacemap`,`sm-attribution__home`),n,sG(iG,a().messages.credits_see_all()));let r=()=>{let t=[...new Set(e.credits.map(e=>e.organisation))].filter(Boolean);if(n.hidden=t.length===0,n.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`,n.replaceChildren(r,` ${t.join(` · `)}`)};return r(),this.off=e.on(`layerschange`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}};function dG(e){if(e)try{let t=typeof window<`u`?window.location.href:`https://spacemap.co`,{protocol:n}=new URL(e,t);return n===`http:`||n===`https:`?e:void 0}catch{return}}var fG=class{off=null;onAdd(e){let t=aG(),n=oG();t.append(sG(rG,`spacemap`,`sm-attribution__home`),n,sG(iG,a().messages.credits_see_all()));let r=()=>{let t=e.getCurrent();if(n.hidden=!t?.credit,!t?.credit)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`;let i=dG(t.credit_url),o=i?sG(i,t.credit):t.credit;n.replaceChildren(r,` `,o)};return r(),this.off=e.on(`load`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}},pG=Math.PI/180,mG=Math.cos(ag*pG),hG=Math.sin(ag*pG);function gG(e){return e}function _G(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>xG(t,e)}}function vG(e){return{body:e.body??`naif-10`,offsetKm:t=>DF(e.elements,t)?.r??null}}function yG(e,t){let n=ng(e,t);return n.error!==$h.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:p_,offsetKm:e=>{if(n.error!==$h.None)return null;let t=vg(n,e);return t&&bG(t[0],t[1],t[2])}}}function bG(e,t,n){return[e,t*mG+n*hG,-t*hG+n*mG]}function xG(e,t){let n=e.length;if(n<2||t<e[0].jd||t>e[n-1].jd)return null;let r=0,i=n-1;for(;r<i;){let n=r+i>>1;e[n].jd<t?r=n+1:i=n}let a=Math.max(r,1),o=e[a-1],s=e[a],c=s.jd-o.jd;if(c<=0)return s.km;let l=(t-o.jd)/c,u=l*l,d=u*l,f=2*d-3*u+1,p=d-2*u+l,m=-2*d+3*u,h=d-u,g=[0,0,0];for(let t=0;t<3;t++){let n=o.km[t],r=s.km[t],i=SG(e,a-1,t),l=SG(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function SG(e,t,n){let r=e[t-1]??e[t],i=e[t+1]??e[t],a=i.jd-r.jd;return a<=0?0:(i.km[n]-r.km[n])/a}function CG(e){return e/ig}var wG=null;function TG(e=K_){return wG||(wG=(async()=>{let t=await e(`${Kt()}/v1/panoramas.json`);if(!t.ok)throw Error(`Failed to load panoramas.json: ${t.status}`);return(await t.json()).bodies??[]})(),wG.catch(()=>wG=null),wG)}async function EG(e){return(await hx(e,!1)).global?.panoramas??[]}async function DG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=jG(t);MG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new BV(l);if(d.mount(u),d.webglError)throw d.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new cG,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.open(),d.applyInitialView(),await Cz(),d}async function OG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=jG(t);MG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new WH(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new uG,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function kG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=jG(t);MG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new OU(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new fG,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function AG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,events:s,...c}=e,l=jG(t);MG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let u=new ZW(c);u.mount(l);for(let[e,t]of Object.entries(s??{}))u.on(e,t);try{await u.load()}catch(e){throw u.remove(),e}return u}function jG(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`spacemap: no element matches ${e}`);return t}function MG(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.locale!==void 0&&(t.locale=()=>e.locale),e.messages!==void 0&&(t.messages=e.messages),e.includeNonCommercial&&(t.textures=`non-commercial`),i(t)}return e.AttributionControl=cG,e.FlatAttributionControl=uG,e.FlatMap=WH,e.GestureHandler=CV,e.MAP_LAYERS=gv,e.PROJECTION_IDS=BB,e.PanoramaAttributionControl=fG,e.PanoramaView=OU,e.SpaceMap=BV,e.SystemMap=ZW,e.Viewport=kH,e.bearingDeg=lU,e.boxRing=cV,e.circlePoints=Hz,e.configureHost=i,e.createFlatMap=OG,e.createMap=DG,e.createPanorama=kG,e.createProjection=VB,e.createSystemMap=AG,e.dateToJD=Ng,e.defaultSceneSettings=Ax,e.elements=vG,e.fetchPanoramaIndex=TG,e.fetchPanoramas=EG,e.findPanorama=aU,e.fixed=gG,e.graticule=dV,e.groundDistanceM=cU,e.isViewable=mx,e.jdToDate=Pg,e.kmToAu=CG,e.neighboursOf=oU,e.panoramaAt=rU,e.pathFor=iV,e.planeBasis=Bz,e.projectionAspect=oB,e.samples=_G,e.smallCircle=lV,e.tle=yG,e})({});
|
|
5567
|
+
`})}var $z=.25,eB=1e-9,tB=3,nB=class{object=new za;anchor;outline;fillColor;fillOpacity;local=new Float64Array;count=0;mesh=null;scratch=new Float32Array;lastOrigin=[0,0,0];dirty=!0;wanted=!0;removeSelf=null;constructor(e){this.anchor=e.anchor;let t=e.widthPx??2;this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??$z,this.outline=t>0?new Uz({anchor:e.anchor,points:e.points,color:e.color,widthPx:t,opacity:e.opacity,closed:!0}):null,this.outline&&this.object.add(this.outline.object),this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){this.outline?.setPoints(e),this.local.length<e.length*3&&(this.local=new Float64Array(e.length*3));for(let t=0;t<e.length;t++){let[n,r,i]=e[t];this.local[t*3]=Q(n),this.local[t*3+1]=Q(i),this.local[t*3+2]=Q(-r)}this.count=e.length,this.rebuild(e)}setAnchor(e){this.anchor=e,this.outline?.setAnchor(e)}setVisible(e){this.wanted=e,this.outline?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){this.outline?.update(e);let t=this.mesh;if(!t)return;let{jd:n,basis:r,camera:i,ctx:a}=e,o=this.wanted?bR(this.anchor,a,n):null;if(t.visible=o!==null,!o)return;let s=[o[0]-r[0],o[1]-r[1],o[2]-r[2]];if(this.dirty||Math.abs(s[0]-this.lastOrigin[0])>eB||Math.abs(s[1]-this.lastOrigin[1])>eB||Math.abs(s[2]-this.lastOrigin[2])>eB){let e=t.geometry.getAttribute(`position`);for(let e=0;e<this.count*3;e+=3)this.scratch[e]=this.local[e]+s[0],this.scratch[e+1]=this.local[e+1]+s[1],this.scratch[e+2]=this.local[e+2]+s[2];e.needsUpdate=!0,this.lastOrigin=s,this.dirty=!1}t.material.uniforms.uCenterOffset.value.copy(i.position).negate()}rebuild(e){this.disposeMesh(),this.dirty=!0;let t=this.fillColor;if(!t)return;let n=qz(e);if(!n.length)return;let r=new Ho;r.setAttribute(`position`,new Ao(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new As(r,Qz(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=tB,i.frustumCulled=!1,this.object.add(i),this.mesh=i}disposeMesh(){let e=this.mesh;e&&(this.object.remove(e),e.geometry.dispose(),e.material.dispose(),this.mesh=null)}dispose(){this.disposeMesh(),this.outline?.dispose()}},rB=class extends nB{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:Kz(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(Kz(e,{normal:this.normal,steps:this.steps}))}},iB=class extends Az{constructor(e,t){let n=document.createElement(`div`);n.className=`sm-drawing-label`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.textContent=e.text,e.color&&(n.style.color=e.color),e.fontSizePx!==void 0&&(n.style.fontSize=`${e.fontSizePx}px`),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setText(e){this.element.textContent=e}},aB=class extends Az{constructor(e,t){let n=document.createElement(`img`);n.className=`sm-drawing-icon`,e.interactive&&n.classList.add(`sm-drawing--interactive`),e.className&&n.classList.add(e.className),n.src=e.url,n.alt=e.alt??``,e.widthPx!==void 0&&(n.style.width=`${e.widthPx}px`),e.heightPx!==void 0&&(n.style.height=`${e.heightPx}px`),e.opacity!==void 0&&(n.style.opacity=String(e.opacity)),super({anchor:e.anchor,element:n,align:e.align,occlude:e.occlude},t)}setUrl(e){this.element.src=e}},oB=Math.PI/180,sB=180/Math.PI;function cB(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function lB(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[cB(n*i.lonPerX+t),i.lat]}}function uB(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function dB(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=179.999999999;for(let o=0;o<=720;o++){let s=-90+180*o/720;for(let o=0;o<=720;o++){let c=e(-a+2*a*o/720,s);c&&(c[0]<t&&(t=c[0]),c[0]>r&&(r=c[0]),c[1]<n&&(n=c[1]),c[1]>i&&(i=c[1]))}}return{minX:t,minY:n,maxX:r,maxY:i}}function fB(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*sB,lonPerX:sB,maxAbsX:Math.PI};return{id:`equirectangular`,centerLon:t,cyclic:!0,rectangular:!0,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>[cB(e-t)*oB,n*oB],rowInverse:n,inverse:lB(n,t)}}var pB=1.340264,mB=-.081106,hB=893e-6,gB=.003796,_B=Math.sqrt(3),vB=e=>gB*e**9+hB*e**7+mB*e**3+pB*e,yB=e=>9*gB*e**8+7*hB*e**6+3*mB*e**2+pB;function bB(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(IB(_B/2*Math.sin(n*oB))),i=cB(e-t)*oB;return[2*_B*i*Math.cos(r)/(3*yB(r)),vB(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(vB(t)-e)/yB(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/_B*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*yB(t)/(2*_B*Math.cos(t))*sB;return{lat:Math.asin(n)*sB,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:dB(n),forward:n,rowInverse:i,inverse:lB(i,t)}}var xB=Math.SQRT2;function SB(e){let t=e.centerLon??0,n=e=>{let t=e/xB;if(Math.abs(t)>1)return null;let n=Math.asin(t),r=(2*n+Math.sin(2*n))/Math.PI;if(Math.abs(r)>1)return null;let i=Math.cos(n);if(i<1e-12)return{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0};let a=Math.PI/(2*xB*i)*sB;return{lat:Math.asin(r)*sB,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*xB,minY:-xB,maxX:2*xB,maxY:xB},forward:(e,n)=>{let r=n*oB,i=r;if(Math.abs(Math.abs(r)-Math.PI/2)<1e-9)i=Math.PI/2*Math.sign(r);else{let e=Math.PI*Math.sin(r);for(let t=0;t<20;t++){let t=(2*i+Math.sin(2*i)-e)/(2+2*Math.cos(2*i));if(i-=t,Math.abs(t)<1e-12)break}}let a=cB(e-t)*oB;return[2*xB/Math.PI*a*Math.cos(i),xB*Math.sin(i)]},rowInverse:n,inverse:lB(n,t)}}function CB(e){let t=e.centerLon??0,n=e=>{if(Math.abs(e)>Math.PI/2)return null;let t=Math.cos(e);return t<1e-12?{lat:Math.sign(e)*90,lonPerX:0,maxAbsX:0}:{lat:e*sB,lonPerX:sB/t,maxAbsX:Math.PI*t}};return{id:`sinusoidal`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-Math.PI,minY:-Math.PI/2,maxX:Math.PI,maxY:Math.PI/2},forward:(e,n)=>{let r=n*oB;return[cB(e-t)*oB*Math.cos(r),r]},rowInverse:n,inverse:lB(n,t)}}var wB=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],TB=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],EB=.8487,DB=1.3523,OB=5;function kB(e,t){let n=e[Math.max(t-1,0)],r=e[t],i=e[t+1],a=e[Math.min(t+2,e.length-1)];return[r,.5*(i-n),.5*(2*n-5*r+4*i-a),.5*(-n+3*r-3*i+a)]}var AB=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),jB=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function MB(e){let t=Math.min(Math.max(Math.floor(e),0),wB.length-2);return[t,e-t]}function NB(e){let[t,n]=MB(e);return EB*AB(kB(wB,t),n)*Math.PI}function PB(e){let t=0,n=TB.length-1;for(;n-t>1;){let r=t+n>>1;TB[r]<=e?t=r:n=r}let r=Math.min(t,TB.length-2),i=kB(TB,r),a=(e-TB[r])/(TB[r+1]-TB[r]);for(let t=0;t<8;t++){let t=jB(i,a);if(t===0)break;let n=(AB(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function FB(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/DB;if(t>1)return null;let n=PB(t),r=NB(n);return{lat:Math.sign(e)*n*OB,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-EB*Math.PI,minY:-DB,maxX:EB*Math.PI,maxY:DB},forward:(e,n)=>{let[r,i]=MB(Math.abs(n)/OB),a=AB(kB(wB,r),i),o=AB(kB(TB,r),i);return[EB*a*cB(e-t)*oB,DB*o*Math.sign(n)]},rowInverse:n,inverse:lB(n,t)}}function IB(e){return e<-1?-1:e>1?1:e}function LB(e,t,n,r,i,a,o){let s=Math.asin(IB(n*a+t*r*o));return[cB(i+Math.atan2(e*r,n*o-t*r*a)*sB),s*sB]}function RB(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function zB(e,t,n,r){let i=cB(e-n)*oB,a=t*oB;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function BB(e){let t=e.centerLon??0,n=(e.centerLat??0)*oB,r=Math.min(e.clipAngle??90,90)*oB,i=Math.cos(r),a=Math.sin(r),o=Math.sin(n),s=Math.cos(n);return{id:`orthographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:RB(a),forward:(e,r)=>{let a=cB(e-t)*oB,o=r*oB;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:zB(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:LB(e,n,Math.sqrt(1-r),1,t,o,s)}}}var VB=120;function HB(e){let t=e.centerLon??0,n=(e.centerLat??90)*oB,r=Math.min(e.clipAngle??VB,170)*oB,i=Math.cos(r),a=2*Math.tan(r/2),o=Math.sin(n),s=Math.cos(n);return{id:`stereographic`,centerLon:t,cyclic:!1,rectangular:!1,azimuthal:!0,extent:RB(a),forward:(e,r)=>{let a=cB(e-t)*oB,o=r*oB,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a);if(s<i)return null;let c=2/(1+s),[l,u]=zB(e,r,t,n);return[c*l,c*u]},inverse:(e,n)=>{let r=e*e+n*n;if(r>a*a)return null;let i=4/(4+r);return LB(e,n,(4-r)*i*.25,i,t,o,s)}}}var UB={equirectangular:fB,equalEarth:bB,mollweide:SB,sinusoidal:CB,robinson:FB,orthographic:BB,stereographic:HB},WB=Object.keys(UB);function GB(e,t={}){let n=UB[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var KB=Math.PI/180,qB=2*Math.PI,JB=2*KB,YB=180/Math.PI,XB=512,ZB=2;function QB(e,t){let n=e.lat*KB,r=t.lat*KB,i=r-n,a=cB(t.lon-e.lon)*KB,o=Math.sin(i/2)**2+Math.cos(n)*Math.cos(r)*Math.sin(a/2)**2;return 2*Math.asin(Math.min(1,Math.sqrt(o)))*YB}function $B(e,t,n){let r=QB(e,t)*KB;if(r<1e-12)return e;let i=Math.sin(r),a=Math.sin((1-n)*r)/i,o=Math.sin(n*r)/i,s=e.lat*KB,c=e.lon*KB,l=t.lat*KB,u=(e.lon+cB(t.lon-e.lon))*KB,d=a*Math.cos(s)*Math.cos(c)+o*Math.cos(l)*Math.cos(u),f=a*Math.cos(s)*Math.sin(c)+o*Math.cos(l)*Math.sin(u),p=a*Math.sin(s)+o*Math.sin(l);return{lon:Math.atan2(f,d)*YB,lat:Math.atan2(p,Math.hypot(d,f))*YB}}function eV(e,t,n){return{lon:e.lon+cB(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function tV(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??ZB,i=n===`geodesic`?$B:eV,a=t.closed&&e.length>2?[...e,e[0]]:e;if(a.length<2)return[...a];let o=[a[0]];for(let e=1;e<a.length;e++){let t=a[e-1],n=a[e],s=Math.min(XB,Math.max(1,Math.ceil(QB(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function nV(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=eV(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return eV(e,t,r)}function rV(e,t){let n=t.projection.cyclic?t.worldWidthPx/2:1/0,{projection:r}=t,i=[],a=[],o=null,s=0;for(let c=0;c<e.length;c++){let l=e[c],u=t.project(l.lon,l.lat);if(!u){if(a.length&&c>0){let n=nV(e[c-1],l,r);a.push(t.project(n.lon,n.lat))}a.length>1&&i.push(a),a=[],o=null,s++;continue}if(o&&Math.abs(u[0]-o[0])>n&&(a.length>1&&i.push(a),a=[]),!a.length&&c>0&&!t.project(e[c-1].lon,e[c-1].lat)){let n=nV(l,e[c-1],r);a.push(t.project(n.lon,n.lat))}a.push(u),o=u}return a.length>1&&i.push(a),{runs:i,whole:i.length===1&&s===0}}function iV(e,t){let n=[...e];for(let r of t.repeatShifts)if(r!==0)for(let i of e){let e=1/0,a=-1/0;for(let[t]of i)t<e&&(e=t),t>a&&(a=t);e+r>t.width||a+r<0||n.push(i.map(([e,t])=>[e+r,t]))}return n}function aV(e,t){let n=`M${e[0][0].toFixed(2)} ${e[0][1].toFixed(2)}`;for(let t=1;t<e.length;t++)n+=`L${e[t][0].toFixed(2)} ${e[t][1].toFixed(2)}`;return t?`${n}Z`:n}var oV=179.999999;function sV(e,t){let n=e=>e>oV?oV:e<-oV?-oV:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=cB(e[0].lon-t);a.push({lon:n(o),lat:e[0].lat});for(let t=0;t<r;t++){let s=e[t],c=e[(t+1)%r],l=cB(c.lon-s.lon),u=o+l,d=u>180?1:u<-180?-1:0;if(d!==0){let e=s.lat+(c.lat-s.lat)*((d*180-o)/l);a.push({lon:d*oV,lat:e}),i.push(a),a=[{lon:-d*oV,lat:e}],o=u-d*360}else o=u;t<r-1&&a.push({lon:n(o),lat:c.lat})}return i.length===0?[a.map(e=>({lon:e.lon+t,lat:e.lat}))]:(i[0]=a.concat(i[0]),i.map(e=>e.map(e=>({lon:e.lon+t,lat:e.lat}))))}function cV(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?sV(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=rV(tV(e,n),t),a=!!n.closed&&i;return iV(r,t).map(e=>aV(e,a)).join(``)}).join(``)}function lV(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return cV(e,t,{...n,closed:!0});if(e.length<2)return``;let i=tV(e,{...n,closed:!0}),a=e.length>2?i.slice(0,-1):i,o=a.map(e=>r.forward(e.lon,e.lat)),s=([e,n])=>t.toScreen(e,n),c=o.filter(Boolean).length;if(c===0)return``;if(c===a.length)return aV(o.map(e=>s(e)),!0);let l=a.length,u=0;for(;!o[u]||o[(u+l-1)%l];)u++;let d=[],f=null;for(let e=0;e<l;e++){let t=(u+e)%l,n=(t+l-1)%l,i=o[t];if(i){if(!f){let e=nV(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=nV(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=uV(a),m=([e,t])=>Math.atan2(t,e),h=Math.hypot(...d[0][0]),g=[],_=new Set;for(let e=0;e<d.length;e++){if(_.has(e))continue;let t=[],n=e;do{_.add(n),t.push(...d[n]);let r=m(d[n][d[n].length-1]),i=e,a=1/0;for(let e=0;e<d.length;e++){let t=m(d[e][0]),n=((p?t-r:r-t)%qB+qB)%qB;n<a&&(a=n,i=e)}let o=Math.ceil(a/JB);for(let e=1;e<o;e++){let n=r+(p?1:-1)*a*e/o;t.push([h*Math.cos(n),h*Math.sin(n)])}n=i}while(n!==e&&!_.has(n));g.push(t)}return g.map(e=>aV(e.map(s),!0)).join(``)}function uV(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=cB(i.lon-r.lon)*KB*(2+Math.sin(r.lat*KB)+Math.sin(i.lat*KB))}let n=-t/2;return n>0?n<qB:n<-qB}function dV(e,t=2){let{projection:n}=e,r=179.999999,i=[],a=(r,a,o)=>{let s=a<o?t:-t;for(let t=a;s>0?t<=o:t>=o;t+=s){let a=n.forward(r,t);a&&i.push(e.toScreen(a[0],a[1]))}};return a(n.centerLon-r,-90,90),a(n.centerLon+r,90,-90),i.length<3?``:iV([i],e).map(e=>aV(e,!0)).join(``)}function fV(e,t,n,r){let i=n+r,a=[],o=(e,t,n)=>{let r=Math.max(1,Math.ceil(Math.abs(n-t)/5));for(let i=0;i<=r;i++)a.push({lon:t+(n-t)*i/r,lat:e})};return o(e,n,i),o(t,i,n),a}function pV(e,t,n=128){let r=e.lat*KB,i=e.lon*KB,a=[Math.cos(r)*Math.cos(i),Math.cos(r)*Math.sin(i),Math.sin(r)],o=[-a[1],a[0],0],s=Math.hypot(o[0],o[1]);o=s<1e-9?[1,0,0]:[o[0]/s,o[1]/s,0];let c=[a[1]*o[2]-a[2]*o[1],a[2]*o[0]-a[0]*o[2],a[0]*o[1]-a[1]*o[0]],l=t*KB,u=Math.sin(l),d=Math.cos(l),f=[];for(let e=0;e<n;e++){let t=2*Math.PI*e/n,r=Math.sin(t)*u,i=Math.cos(t)*u,s=a[0]*d+o[0]*r+c[0]*i,l=a[1]*d+o[1]*r+c[1]*i,p=a[2]*d+o[2]*r+c[2]*i;f.push({lon:cB(Math.atan2(l,s)*YB),lat:Math.atan2(p,Math.hypot(s,l))*YB})}return f}var mV=24;function hV(e=30){let t=[];for(let n=-180;n<180;n+=e)t.push([{lon:n,lat:-90},{lon:n,lat:90}]);let n=179.999999;for(let r=-90+e;r<90;r+=e){let e=[];for(let t=0;t<=mV;t++)e.push({lon:-n+2*n*t/mV,lat:r});t.push(e)}return t}var gV=.005,_V=1.5,vV=5,yV=24,bV=class{object=new za;body;altitudeKm;closed;interpolate;stepDeg;color;widthPx;opacity;dash;fillColor;fillOpacity;dirs=new Float64Array;count=0;line=null;scratch=new Float32Array;alphas=new Float32Array;lengths=new Float32Array;fanDirs=new Float64Array;fill=null;fillScratch=new Float32Array;turned=[0,0,0];wanted=!0;removeSelf=null;constructor(e){this.body=e.body,this.altitudeKm=e.altitudeKm??null,this.closed=e.closed??!1,this.interpolate=e.interpolate??`linear`,this.stepDeg=e.stepDeg,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.dash=Fz(e.dash),this.fillColor=e.fill??null,this.fillOpacity=e.fillOpacity??.25,this.object.matrixAutoUpdate=!1,this.setPoints(e.points)}bind(e){this.removeSelf=e}setPoints(e){let t=tV(e,{interpolate:this.interpolate,stepDeg:this.stepDeg,closed:this.closed});this.dirs=new Float64Array(t.length*3);for(let e=0;e<t.length;e++){let[n,r,i]=gR(t[e].lat,t[e].lon);this.dirs[e*3]=n,this.dirs[e*3+1]=r,this.dirs[e*3+2]=i}this.count=t.length,this.buildLine(),this.buildFill()}setVisible(e){this.wanted=e}remove(){this.removeSelf?.(),this.removeSelf=null}update({jd:e,basis:t,camera:n,viewportPx:r,ctx:i}){let a=this.wanted&&this.count>=2?i.getBody(this.body):void 0,o=a&&vR(a,i,e);if(this.line&&(this.line.visible=!!o),this.fill&&(this.fill.visible=!!o),!a||!o)return;let s=gn(a.data),c=Q(s+(this.altitudeKm??s*gV)),l=a.orientation?mC(a.orientation,e,a.nutPrec):null,u=[o[0]-t[0],o[1]-t[1],o[2]-t[2]];if(this.line&&(this.place(this.dirs,this.count,l,c,u,this.scratch),fN(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.dash&&(zz(this.scratch,this.count,n,r,this.lengths),hN(this.line.geometry,this.lengths,this.count)),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()),this.fill){let e=this.fill.geometry.getAttribute(`position`);this.place(this.fanDirs,this.fillScratch.length/3,l,c,u,this.fillScratch),e.needsUpdate=!0,this.fill.material.uniforms.uCenterOffset.value.copy(n.position).negate()}}place(e,t,n,r,i,a){for(let o=0;o<t;o++){let t=o*3;n?_R(n,e[t],e[t+1],e[t+2],this.turned,0):(this.turned[0]=e[t],this.turned[1]=e[t+1],this.turned[2]=e[t+2]),a[t]=this.turned[0]*r+i[0],a[t+1]=this.turned[1]*r+i[1],a[t+2]=this.turned[2]*r+i[2]}}buildLine(){if(this.disposeLine(),this.count<2||this.widthPx<=0)return;this.scratch=new Float32Array(this.count*3),this.alphas=new Float32Array(this.count).fill(this.opacity),this.lengths=new Float32Array(this.count);let e=gN(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1,this.dash??void 0);e.frustumCulled=!1,e.renderOrder=_V,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=Zz(this.dirs,this.count),t=0;for(let n=0;n<this.count;n++){let r=e[0]*this.dirs[n*3]+e[1]*this.dirs[n*3+1]+e[2]*this.dirs[n*3+2];t=Math.max(t,Math.acos(Math.min(1,Math.max(-1,r))))}let n=Math.min(yV,Math.max(1,Math.ceil(t*180/Math.PI/vV))),r=1+n*this.count;this.fanDirs=new Float64Array(r*3),this.fanDirs[0]=e[0],this.fanDirs[1]=e[1],this.fanDirs[2]=e[2];for(let t=1;t<=n;t++)for(let r=0;r<this.count;r++){let[i,a,o]=Yz(e,[this.dirs[r*3],this.dirs[r*3+1],this.dirs[r*3+2]],t/n),s=(1+(t-1)*this.count+r)*3;this.fanDirs[s]=i,this.fanDirs[s+1]=a,this.fanDirs[s+2]=o}let i=[],a=(e,t)=>1+(e-1)*this.count+t;for(let e=0;e<this.count-1;e++)i.push(0,a(1,e),a(1,e+1));for(let e=1;e<n;e++)for(let t=0;t<this.count-1;t++){let n=a(e,t),r=a(e,t+1),o=a(e+1,t),s=a(e+1,t+1);i.push(n,o,r,r,o,s)}let o=new Ho;o.setAttribute(`position`,new Ao(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new As(o,Qz(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=_V,this.object.add(s),this.fill=s}disposeLine(){this.line&&=(this.object.remove(this.line),this.line.geometry.dispose(),this.line.material.dispose(),null)}disposeFill(){this.fill&&=(this.object.remove(this.fill),this.fill.geometry.dispose(),this.fill.material.dispose(),null)}dispose(){this.disposeLine(),this.disposeFill()}},xV=class{object=new za;id;name;anchor;model;trueScale;spanScene;minPx;label;wanted=!0;removeSelf=null;constructor(e,t,n){this.id=t,this.name=e.name??null,this.anchor=e.position,this.object.matrixAutoUpdate=!1,this.object.frustumCulled=!1;let r=e.model;this.model=r?.object3d??null,this.minPx=r?.minPx??0;let i=r?SV(r.object3d):0;this.trueScale=r?.scaleM!==void 0&&i>0?Q(r.scaleM/1e3)/i:1,this.spanScene=i*this.trueScale,this.model&&this.object.add(this.model),this.label=e.label&&this.name?new iB({anchor:e.position,text:this.name,align:[.5,1.4],occlude:e.occludeLabel},n):null,this.label&&this.object.add(this.label.object)}bind(e){this.removeSelf=e}get position(){return this.anchor}positionKm(e){let t=this.anchor;if(`latitude`in t)return null;let n=typeof t.offsetKm==`function`?t.offsetKm(e):t.offsetKm;return n===void 0?[0,0,0]:n}setPosition(e){this.anchor=e,this.label?.setAnchor(e)}setVisible(e){this.wanted=e,this.label?.setVisible(e)}remove(){this.removeSelf?.(),this.removeSelf=null}update(e){let{basis:t,camera:n,jd:r,ctx:i}=e,a=this.model,o=this.wanted?bR(this.anchor,i,r):null;if(this.label?.update(e),!a||(a.visible=o!==null,!o))return;a.position.set(o[0]-t[0],o[1]-t[1],o[2]-t[2]);let s=this.drawnScale(a.position,n,e.viewportPx);a.scale.setScalar(s),a.updateMatrixWorld(!0)}drawnScale(e,t,n){if(this.minPx<=0||this.spanScene<=0)return this.trueScale;let r=t.position.distanceTo(e);if(r<=0)return this.trueScale;let i=n/(2*Math.tan(t.fov*Math.PI/180/2)*r),a=this.spanScene*i;return a>=this.minPx?this.trueScale:this.trueScale*(this.minPx/a)}dispose(){this.label?.dispose(),this.model&&this.object.remove(this.model)}};function SV(e){let t=new co().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var CV=class{byId=new Map;nextId=1;constructor(e,t){this.registry=e,this.canvas=t}add(e){let t=e.id??`object-${this.nextId++}`;this.byId.get(t)?.remove();let n=new xV(e,t,this.canvas()),r=this.registry();return n.bind(()=>{this.byId.delete(t),r.remove(n)}),this.byId.set(t,n),r.add(n),n}get(e){return this.byId.get(e)}all(){return[...this.byId.values()]}clear(){for(let e of[...this.byId.values()])e.remove()}};function wV(e,t,n,r){let i=bR(e,n,r),a=bR(t,n,r);return!i||!a?null:SR([a[0]-i[0],a[1]-i[1],a[2]-i[2]])}function TV(e,t,n,r){let i=wV(e,t,n,r);return i&&Math.hypot(...i)}function EV(e,t,n,r){let i=e.orientation?mC(e.orientation,r,e.nutPrec).toArray():[0,0,0,1],{latitude:a,longitude:o,distance:s}=aC([n[0],n[1],n[2]],[t[0],t[1],t[2]],i);return s>0?{lon:o,lat:a}:null}function DV(e,t,n){let r=t.getBody(e),i=t.getBody(f_);if(!r||!i||r===i||!r.orientation&&!t.bodies.orientationRead.has(e))return null;let a=vR(r,t,n);return a&&EV(r,a,i.position,n)}var OV=class{enabled;apply;constructor(e,t){this.enabled=e,this.apply=t}enable(){this.set(!0)}disable(){this.set(!1)}isEnabled(){return this.enabled}set(e){this.enabled!==e&&(this.enabled=e,this.apply?.(e))}};function kV(e,t){return e??t??!0}var AV=1400,jV=class{enabled;element=document.createElement(`div`);timer;constructor(e,t){this.enabled=t,this.element.className=`sm-cooperative-hint`,this.element.setAttribute(`aria-hidden`,`true`),e.append(this.element)}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,e||this.hide()}allowsWheel(e){if(!this.enabled||e.ctrlKey||e.metaKey)return!0;let{cooperative_wheel:t,cooperative_wheel_mac:n}=a().messages;return this.show(MV()?n():t()),!1}allowsTouchDrag(e){return!this.enabled||e>1?!0:(this.show(a().messages.cooperative_touch()),!1)}dispose(){clearTimeout(this.timer),this.element.remove()}show(e){this.element.textContent=e,this.element.classList.add(`sm-cooperative-hint--shown`),clearTimeout(this.timer),this.timer=setTimeout(()=>this.hide(),AV)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function MV(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var NV={[W.BARYCENTER]:`barycenter`,[W.LAGRANGE_POINT]:`lagrange-point`,[W.STAR]:`star`,[W.PLANET]:`planet`,[W.DWARF_PLANET]:`dwarf-planet`,[W.MOON]:`moon`,[W.ASTEROID]:`asteroid`,[W.ASTEROID_INNER]:`asteroid`,[W.ASTEROID_MAIN_BELT]:`asteroid`,[W.ASTEROID_TROJAN]:`asteroid`,[W.ASTEROID_CENTAUR]:`asteroid`,[W.ASTEROID_TNO]:`asteroid`,[W.COMET]:`comet`,[W.SPACECRAFT]:`spacecraft`,[W.DEBRIS]:`debris`,[W.UNDOCUMENTED]:`unknown`,[W.SURFACE_FEATURE]:`surface-feature`},PV={[W.ASTEROID_INNER]:`inner`,[W.ASTEROID_MAIN_BELT]:`main-belt`,[W.ASTEROID_TROJAN]:`trojan`,[W.ASTEROID_CENTAUR]:`centaur`,[W.ASTEROID_TNO]:`tno`};function FV(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a,unplaceable:o}=e.data,s={id:t,name:n,type:NV[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:o!==!0&&e.positionUnknown!==!0},c=PV[r];return c&&(s.orbitClass=c),s}var IV=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],LV=class{corners=new Map;added=new Map;constructor(e,t){this.map=e,this.root=t}add(e,t){if(this.added.has(e))return;let n=e.onAdd(this.map);this.added.set(e,n),this.corner(t??e.getDefaultPosition?.()??`top-right`).append(n)}remove(e){let t=this.added.get(e);t&&(this.added.delete(e),e.onRemove?.(this.map),t.remove())}clear(){for(let e of[...this.added.keys()])this.remove(e);for(let e of this.corners.values())e.remove();this.corners.clear()}corner(e){let t=this.corners.get(e);return t||(t=document.createElement(`div`),t.className=`sm-ctrl sm-ctrl--${e}`,this.corners.set(e,t),this.root.append(...IV.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},RV=[(e,t)=>e.setReducedMotion(t.resolvedReducedMotion),(e,t)=>e.setImmersive(t.viewMode===`immersive`),(e,t)=>e.setHaloDebugVisible(t.showHaloDebug),(e,t)=>{t.atmosphereCalibration,e.applyRenderTier()}],zV=.05,BV=1.15,VV=2e3,HV=4e3,UV=new WeakMap,WV=new WeakMap,GV=class{ctx=new wS;clock;initialView;#e=qe(null);get renderer(){return Ut(this.#e)}set renderer(e){Je(this.#e,e)}#t=qe(!1);get webglError(){return Ut(this.#t)}set webglError(e){Je(this.#t,e,!0)}#n=qe(!1);get contextLost(){return Ut(this.#n)}set contextLost(e){Je(this.#n,e,!0)}#r=qe();get focusedBody(){return Ut(this.#r)}set focusedBody(e){Je(this.#r,e)}attribution=null;objects=new CV(()=>this.requireRenderer().extensions,()=>this.requireCanvas());dragRotate;scrollZoom;keyboard;bodySelect;featureSelect;cooperativeGestures;container=null;canvas=null;labelLayer=null;stopWatching=null;controls=null;lostPanelTimer;cooperative=null;limits={};initialFocusPending=!0;pendingFocusId=null;retireCameraHold=null;listeners={focuschange:new Set,camera:new Set,featureselect:new Set,userpromoted:new Set,contextlost:new Set,contextrestored:new Set,clock:new Set,loading:new Set,progress:new Set,error:new Set,datastale:new Set,notice:new Set,noticedismiss:new Set,layerschange:new Set,frame:new Set};constructor(e={}){e.settings&&Nx(e.settings),this.clock=new ES(Ng(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??uC,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new OV(kV(e.interactions?.[t],e.interactive),()=>this.applyGestures());this.dragRotate=n(`dragRotate`),this.scrollZoom=n(`scrollZoom`),this.keyboard=n(`keyboard`),this.bodySelect=n(`bodySelect`),this.featureSelect=n(`featureSelect`),this.cooperativeGestures=new OV(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new Cv(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),Ez()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};WV.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners[e];n.delete(t);for(let e of n)WV.get(e)===t&&n.delete(e)}emit(e,...t){for(let n of this.listeners[e])n(...t)}getBody(e){let t=this.ctx.getBody(e);return t&&FV(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=un(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&FV(t)}getChildren(e){return[...this.ctx.bodies.getChildren(e)??[]]}get placedJd(){let e=this.renderer?.placedJd;return e===void 0||Number.isNaN(e)?this.clock.jd:e}distanceKm(e,t){return TV(e,t,this.ctx,this.placedJd)}offsetKm(e,t){return wV(e,t,this.ctx,this.placedJd)}getSubsolarPoint(e){return DV(e,this.ctx,this.placedJd)}load(e=this.initialView.id){return this.ctx.load(Pg(this.clock.jd),e)}async open(e=this.initialView.id){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&this.ctx.getBody(e)?t():document.hidden?setTimeout(r,100):requestAnimationFrame(r))};r()});try{await Promise.race([t,r])}finally{n=!1}}applyInitialView(){let{id:e,latitude:t,longitude:n,zoom:r}=this.initialView;this.focusedBody||!this.ctx.getBody(e)||this.renderer?.snapToBody(e,t,n,r)}mount(e){if(this.container)throw Error(`SpaceMap is already mounted`);this.container=e,e.classList.add(`sm-map`),UV.set(e,(UV.get(e)??0)+1),this.controls=new LV(this,e);let t=document.createElement(`canvas`);t.className=`sm-map__canvas`,t.tabIndex=0,t.setAttribute(`role`,`application`),t.setAttribute(`aria-label`,a().messages.scene_canvas_label());let n=document.createElement(`div`);n.className=`scene-overlay`,e.append(t,n),this.canvas=t,this.labelLayer=n,this.cooperative=new jV(e,this.cooperativeGestures.isEnabled()),t.addEventListener(`keydown`,this.onKeyDown),t.addEventListener(`touchmove`,this.onTouchMove,{passive:!0}),e.addEventListener(`wheel`,this.onWheelCapture,{capture:!0,passive:!0}),t.addEventListener(`webglcontextlost`,this.onContextLost,!1),t.addEventListener(`webglcontextrestored`,this.onContextRestored,!1),document.addEventListener(`visibilitychange`,this.onVisibility);let r;try{r=new YR(t,n,this.ctx,this.clock,this.initialView,this.callbacks())}catch(e){console.error(`[scene] renderer init failed:`,e),this.webglError=!0;return}this.renderer=r,this.applyGestures(),this.applyLimits(),this.pendingFocusId!==null&&(r.focusOnBody(this.pendingFocusId),this.pendingFocusId=null);let i=new ResizeObserver(()=>r.resize(t.clientWidth,t.clientHeight));i.observe(t);let o=lt(()=>this.watch(r));this.stopWatching=()=>{i.disconnect(),o()}}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){let{container:e,canvas:t}=this;if(!e||!t)return;this.controls?.clear(),this.controls=null,this.stopWatching?.(),this.stopWatching=null,clearTimeout(this.lostPanelTimer),t.removeEventListener(`keydown`,this.onKeyDown),t.removeEventListener(`touchmove`,this.onTouchMove),e.removeEventListener(`wheel`,this.onWheelCapture,{capture:!0}),this.cooperative?.dispose(),this.cooperative=null,t.removeEventListener(`webglcontextlost`,this.onContextLost),t.removeEventListener(`webglcontextrestored`,this.onContextRestored),document.removeEventListener(`visibilitychange`,this.onVisibility),this.retireCameraHold?.(),this.retireCameraHold=null,this.renderer?.dispose(),this.renderer=null,t.remove(),this.labelLayer?.remove();let n=(UV.get(e)??1)-1;UV.set(e,n),n===0&&e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null}watch(e){st(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=Mx();for(let n of RV)st(()=>n(e,t));let n=this.clock;st(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Pg(e),playing:t,timeScale:r,direction:i,live:a})}),st(()=>{let e=this.ctx.loading,t=ZR.bootPending;this.emit(`loading`,e||t)}),st(()=>this.emit(`progress`,U_.value)),st(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),st(()=>{ZR.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=Mx();for(let n of RV)n(e,t)}callbacks(){return{notices:{notify:e=>this.emit(`notice`,e),dismiss:e=>this.emit(`noticedismiss`,e)},onFocusChange:e=>{let t=this.initialFocusPending;this.initialFocusPending=!1,this.focusedBody=e;let n=e!==void 0&&un(e);this.emit(`focuschange`,{body:this.getFocusedBody(),initial:t,feature:n})},onFrame:(e,t)=>{this.listeners.frame.size>0&&this.emit(`frame`,{jd:e,dtMs:t})},onCameraPosition:(e,t,n)=>{let r=this.focusedBody?.data.id;r!==void 0&&this.emit(`camera`,{body:r,lat:e,lon:t,distanceKm:cg(n)})},onUserPromotedChange:e=>this.emit(`userpromoted`,e),onFeatureSelect:(e,t,n,r,i)=>this.emit(`featureselect`,{bodyId:e,featureId:t,lat:n,lon:r,diameterM:i})}}onKeyDown=e=>{if(!this.keyboard.isEnabled()||e.ctrlKey||e.metaKey||e.altKey)return;let t=(e.shiftKey?4:1)*zV,n=0,r=0,i=1;switch(e.key){case`ArrowLeft`:n=t;break;case`ArrowRight`:n=-t;break;case`ArrowUp`:r=t;break;case`ArrowDown`:r=-t;break;case`+`:case`=`:i=BV;break;case`-`:case`_`:i=1/BV;break;default:return}e.preventDefault(),this.renderer?.nudgeCamera(n,r,i)};onContextLost=e=>{e.preventDefault(),console.warn(`[scene] WebGL context lost`),this.renderer?.pause(),clearTimeout(this.lostPanelTimer),this.lostPanelTimer=setTimeout(()=>{this.contextLost=!0,this.emit(`contextlost`)},VV)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(HV),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};flyTo(e){let t=this.targetBody(e);return e.feature?this.toFeature(t,e.feature,`frame`):this.settled(this.focusOnBody(t,this.framing(e,t),e.lat,e.lon))}panTo(e){return this.toFeature(this.targetBody(e),e.feature,`pan`)}jumpTo(e){let t=this.targetBody(e);if(e.facing!==void 0)return this.snapToBodyFacing(t,e.facing,e.elevationDeg??0,this.framing(e,t)),this;if(e.feature){let{featureId:n,lat:r,lon:i,diameterM:a}=e.feature;return this.focusOnFeature(t,n,r,i,a,null,`snap`),this}let n=this.getCamera();return this.snapToBody(t,e.lat??n?.lat??45,e.lon??n?.lon??0,this.framing(e,t)),this}getCamera(){let e=this.renderer,t=this.focusedBody?.data.id;if(!e||t===void 0)return null;let{latitude:n,longitude:r,distance:i}=e.getCameraState();return{body:t,lat:n,lon:r,distanceKm:cg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...gv]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,gv.filter(e=>this.ctx.layers.isVisible(e)))}setLimits(e){return this.limits={...e},this.applyLimits(),this}getLimits(){return{...this.limits}}applyLimits(){let e=this.limits,t={};e.minDistanceKm!==void 0&&(t.minDistance=Q(e.minDistanceKm)),e.maxDistanceKm!==void 0&&(t.maxDistance=Q(e.maxDistanceKm)),e.minLat!==void 0&&(t.minLat=e.minLat),e.maxLat!==void 0&&(t.maxLat=e.maxLat),e.minLon!==void 0&&(t.minLon=e.minLon),e.maxLon!==void 0&&(t.maxLon=e.maxLon);let n=Object.keys(t).length>0;this.renderer?.setCameraLimits(n?t:null,e.bodies??null)}applyGestures(){let e=this.cooperativeGestures.isEnabled();this.cooperative?.setEnabled(e);let t=this.renderer;t&&(t.setDragEnabled(this.dragRotate.isEnabled()),t.setZoomEnabled(this.scrollZoom.isEnabled()),t.setBodySelectEnabled(this.bodySelect.isEnabled()),t.setFeatureSelectEnabled(this.featureSelect.isEnabled()),t.setCooperativeTouch(e))}onWheelCapture=e=>{this.scrollZoom.isEnabled()&&this.cooperative&&!this.cooperative.allowsWheel(e)&&e.stopPropagation()};onTouchMove=e=>{this.cooperative?.allowsTouchDrag(e.touches.length)};toFeature(e,t,n){let{featureId:r,lat:i,lon:a,diameterM:o}=t;return this.settled(this.focusOnFeature(e,r,i,a,o,null,n))}settled(e){return new Promise(t=>{setTimeout(()=>requestAnimationFrame(()=>t()),e)})}targetBody(e){let t=e.body??this.focusedBody?.data.id;if(t===void 0)throw Error(`spacemap: no body to move to, and none focused`);return t}framing(e,t){if(e.distanceKm!==void 0)return Q(e.distanceKm);let n=this.ctx.getBody(t);return n&&n.data.radiusKm>0?eR(n)*5:this.renderer?.getCameraState().distance??15}focusOnBody(e,t,n,r){return this.renderer?this.renderer.focusOnBody(e,t,n,r):(this.pendingFocusId=e,0)}snapToBody(e,t,n,r){this.renderer?.snapToBody(e,t,n,r)}snapToBodyFacing(e,t,n,r){this.renderer?.snapToBodyFacing(e,t,n,r)}focusOnFeature(e,t,n,r,i,a,o=`frame`,s=null){let c=this.ctx.getBody(e);if(!c)return 0;let l=Q(i*4/1e3),u=Q(.02),d=Q(gn(c.data)*5),f=Math.min(Math.max(l,u),d),p={hostId:e,featureId:t,lat:n,lon:r,diameterM:i};return this.renderer?.focusOnFeature(p,a,f,o,s)??0}setFocusTarget(e,t){this.renderer?.setFocusTarget(e,t)}getPose(){let e=this.renderer,t=this.focusedBody;if(!e||!t)return null;let n=t.data.id;return{position:{body:n,offsetKm:SR(e.cameraOffsetFromFocus())},target:{body:n}}}holdCamera(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);this.retireCameraHold?.(),e.holdCamera();let t=!0,n=()=>{t=!1};return this.retireCameraHold=n,{get held(){return t},set:n=>{t&&e.setHeldPose(n)},release:()=>{t&&(n(),this.retireCameraHold=null,e.releaseCamera())}}}addMarker(e){return this.track(new Az(e,this.requireCanvas()))}addPolyline(e){return this.track(new Uz(e))}addPolygon(e){return this.track(new nB({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new rB(e))}addLabel(e){return this.track(new iB(e,this.requireCanvas()))}addIcon(e){return this.track(new aB(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new bV(e))}addSurfacePolygon(e){return this.track(new bV({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:pV(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof xV)}setBodyAppearance(e,t){return this.requireRenderer().setBodyAppearance(e,t),this}setPinnedBodies(e){return this.requireRenderer().setPinnedBodies(e),this}capRadiusDeg(e){if(e.radiusDeg!==void 0)return e.radiusDeg;let t=this.getBody(e.body)?.radiusKm;return e.radiusKm!==void 0&&t?e.radiusKm/t*(180/Math.PI):1}track(e){let t=this.requireRenderer();return e.bind(()=>t.extensions.remove(e)),t.extensions.add(e),e}requireCanvas(){let e=this.canvas;if(!e)throw Error(`SpaceMap is not mounted`);return e}requireRenderer(){let e=this.renderer;if(!e)throw Error(`SpaceMap is not mounted`);return e}setNorthReference(e){this.renderer?.setNorthReference(e)}setUserLocation(e,t){this.renderer?.setUserLocation(e,t)}clearUserPromoted(){this.renderer?.clearUserPromoted()}setSelectedFeature(e){this.renderer?.setSelectedFeature(e)}setTravelPath(e,t=[],n=[],r=[]){this.renderer?.setTravelPath(e,t,n,r)}setOrbitPreview(e,t){this.renderer?.setOrbitPreview(e,t)}setTravelHover(e){this.renderer?.setTravelHover(e)}focusOnPathPoint(e,t){this.renderer?.focusOnPathPoint(e,t)}trackPathPoint(e,t){this.renderer?.trackPathPoint(e,t)}setCovered(e){this.renderer?.setCovered(e)}},KV=`http://www.w3.org/2000/svg`;function qV(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function JV(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function YV(e,t){let n=document.createElementNS(KV,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function XV(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of hV(t)){let t=cV(r,e,{stepDeg:2});t&&n.append(YV(t,`sm-flat__graticule`))}if(e.projection.azimuthal){let t=e.toScreen(0,0),r=e.toScreen(e.projection.extent.maxX,0),i=document.createElementNS(KV,`circle`);i.setAttribute(`cx`,String(t[0])),i.setAttribute(`cy`,String(t[1])),i.setAttribute(`r`,String(Math.abs(r[0]-t[0]))),i.setAttribute(`class`,`sm-flat__frame`),n.append(i)}else{let t=dV(e);t&&n.append(YV(t,`sm-flat__frame`))}}}}var ZV=120;function QV(e,t){let n=[];return{kind:`vector`,id:`nomenclature`,label:t,visible:!1,credit:{organisation:`IAU`,source:`https://planetarynames.wr.usgs.gov/`},async prepare(){n.length||(n=[...await xM(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,ZV))},render(e,t){let r=e.repeatShifts;for(let i of n){let n=e.project(i.lon,i.lat);if(!(!n||n[1]<0||n[1]>e.height))for(let a of r){let r=n[0]+a;if(r<0||r>e.width)continue;let o=document.createElementNS(KV,`circle`);o.setAttribute(`cx`,r.toFixed(1)),o.setAttribute(`cy`,n[1].toFixed(1)),o.setAttribute(`r`,`1.6`),o.setAttribute(`class`,`sm-flat__feature-dot`);let s=document.createElementNS(KV,`text`);s.setAttribute(`x`,(r+4).toFixed(1)),s.setAttribute(`y`,(n[1]+3).toFixed(1)),s.setAttribute(`class`,`sm-flat__feature-label`),s.textContent=i.name,t.append(o,s)}}}}}function $V(e,t){e.setAttribute(`fill`,t.fill??`none`),t.fill&&t.fillOpacity!==void 0&&e.setAttribute(`fill-opacity`,String(t.fillOpacity)),e.setAttribute(`stroke`,t.color??`#ffffff`),e.setAttribute(`stroke-width`,String(t.widthPx??2)),e.setAttribute(`stroke-linejoin`,`round`),e.setAttribute(`stroke-linecap`,`round`),t.opacity!==void 0&&e.setAttribute(`opacity`,String(t.opacity)),t.dash&&e.setAttribute(`stroke-dasharray`,t.dash),t.className&&e.setAttribute(`class`,t.className),e.style.pointerEvents=t.interactive?`auto`:`none`,t.ariaLabel&&(e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.ariaLabel))}function eH(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var tH=class{node;area;edge;points;visible=!0;constructor(e,t,n,r,i,a){this.closed=n,this.interpolate=r,this.onRemove=i,this.onChange=a,this.points=e,this.node=document.createElementNS(KV,`g`),$V(this.node,t),eH(this.node,t),this.area=n?document.createElementNS(KV,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(KV,`path`),this.edge.setAttribute(`fill`,`none`),this.area&&this.node.append(this.area),this.node.append(this.edge)}redraw(e){if(!this.visible)return;let t={closed:this.closed,interpolate:this.interpolate};this.edge.setAttribute(`d`,cV(this.points,e,t)),this.area?.setAttribute(`d`,lV(this.points,e,t))}setPoints(e){this.points=e,this.onChange()}setVisible(e){this.visible=e,this.node.style.display=e?``:`none`,this.onChange()}detach(){this.node.remove()}remove(){this.onRemove(this)}},nH=class{element;at;visible=!0;align;constructor(e,t,n){this.onRemove=t,this.onChange=n,this.at=e.at,this.align=e.align??[.5,.5],this.element=e.element??document.createElement(`div`),e.element||(this.element.className=`sm-flat__marker-dot`),e.className&&this.element.classList.add(e.className),this.element.style.position=`absolute`,this.element.style.left=`0`,this.element.style.top=`0`,this.element.style.pointerEvents=e.interactive?`auto`:`none`}redraw(e){let t=this.visible?e.project(this.at.lon,this.at.lat):null;if(this.element.style.display=t?``:`none`,!t)return;let n=e.repeatShifts.find(n=>t[0]+n>=0&&t[0]+n<=e.width)??0;this.element.style.transform=`translate(${t[0]+n}px, ${t[1]}px) translate(${-this.align[0]*100}%, ${-this.align[1]*100}%)`}setPosition(e){this.at=e,this.onChange()}setVisible(e){this.visible=e,this.onChange()}detach(){this.element.remove()}remove(){this.onRemove(this)}},rH=class{drawings=new Set;constructor(e,t,n=()=>{},r=null){this.shapes=e,this.markers=t,this.onChange=n,this.radiusKm=r}setBodyRadiusKm(e){this.radiusKm=e}track(e,t){return this.drawings.add(e),t instanceof HTMLElement?this.markers.append(t):this.shapes.append(t),e}drop=e=>{this.drawings.delete(e)&&e.detach()};addPolyline(e){let t=new tH(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new tH(e.points,{fill:`rgb(255 255 255 / 25%)`,...e},!0,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addBox(e){let t=new tH(fV(e.latMin,e.latMax,e.lonMin,e.lonSpan),{fill:`rgb(255 255 255 / 15%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(t,t.node)}addCircle(e){let t=this.circleRadiusDeg(e),n=new tH(pV(e.center,t),{fill:`rgb(255 255 255 / 20%)`,...e},!0,`linear`,this.drop,this.onChange);return this.track(n,n.node)}circleRadiusDeg(e){return e.radiusDeg===void 0?e.radiusKm!==void 0&&this.radiusKm?e.radiusKm/this.radiusKm*(180/Math.PI):1:e.radiusDeg}addMarker(e){let t=new nH(e,this.drop,this.onChange);return this.track(t,t.element)}redraw(e){for(let t of this.drawings)t.redraw(e)}clear(){for(let e of this.drawings)e.detach();this.drawings.clear()}};function iH(e){let t=`width`in e?e.width:e.codedWidth,n=`height`in e?e.height:e.codedHeight;return typeof t!=`number`||typeof n!=`number`||!t||!n?null:[t,n]}function aH(e,t){let[n,r]=iH(e)??[t,t/2],i=Math.max(2,Math.min(n,Math.round(t))),a=Math.max(1,Math.round(i*r/n)),o=document.createElement(`canvas`);o.width=i,o.height=a;let s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)return null;s.imageSmoothingEnabled=!0,s.imageSmoothingQuality=`high`,s.drawImage(e,0,0,i,a);try{let{data:e}=s.getImageData(0,0,i,a);return{width:i,height:a,data:e}}catch{return null}}var oH=class{width;height;u;v;inside;constructor(e,t,n){this.width=t,this.height=n;let r=t*n;this.u=new Float32Array(r),this.v=new Float32Array(r),this.inside=new Uint8Array(r);let{projection:i}=e,a=1/e.scale,o=e.view.centerX-e.width/2*a,s=e.view.centerY+e.height/2*a;for(let r=0;r<n;r++){let n=s-(r+.5)*a,c=r*t;i.rowInverse?this.fillRow(i,c,n,o,a,e):this.walkRow(i,c,n,o,a)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s}=this,c=(90-o.lat)/180,{minX:l,maxX:u}=e.extent,d=u-l,f=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(f)a=((a-l)%d+d)%d+l;else if(a<l||a>u)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360,p=t+n;this.u[p]=s-Math.floor(s),this.v[p]=c,this.inside[p]=1}}walkRow(e,t,n,r,i){let{width:a}=this,o=0,s=a-1;if(e.azimuthal){let t=e.extent.maxX;if(Math.abs(n)>t)return;let c=Math.sqrt(t*t-n*n);o=Math.max(0,Math.ceil((-c-r)/i-.5)),s=Math.min(a-1,Math.floor((c-r)/i-.5))}for(let a=o;a<=s;a++){let o=r+(a+.5)*i,s=e.inverse(o,n);if(!s)continue;let c=t+a;this.u[c]=(s[0]+180)/360,this.v[c]=(90-s[1])/180,this.inside[c]=1}}};function sH(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c}=e,l=i*a;for(let e of t){let{image:t,opacity:n,blend:i}=e;if(n<=0)continue;let a=t.data,u=t.width,d=t.height,f=i===`add`;for(let e=0;e<l;e++){if(!c[e])continue;let t=Math.floor(o[e]*u),i=Math.floor(s[e]*d);t=t<0?t+u:t>=u?t-u:t,i=i<0?0:i>=d?d-1:i;let l=(i*u+t)*4,p=a[l+3]/255*n;if(p<=0)continue;let m=e*4;if(f){r[m]=Math.min(255,r[m]+a[l]*p),r[m+1]=Math.min(255,r[m+1]+a[l+1]*p),r[m+2]=Math.min(255,r[m+2]+a[l+2]*p);continue}let h=r[m+3]/255,g=p+h*(1-p);if(!(g<=0)){if(p>=1)r[m]=a[l],r[m+1]=a[l+1],r[m+2]=a[l+2];else{let e=h*(1-p);r[m]=(a[l]*p+r[m]*e)/g,r[m+1]=(a[l+1]*p+r[m+1]*e)/g,r[m+2]=(a[l+2]*p+r[m+2]*e)/g}r[m+3]=g*255}}}}function cH(e,t,n){let{minX:r,maxX:i,minY:a,maxY:o}=t.projection.extent,s=t.projection.centerLon*Math.PI/180,[c,l]=t.toScreen(r-s,o),[u,d]=t.toScreen(i-s,a),f=t.repeatsHorizontally?0:t.toScreen(r,o)[0],p=t.repeatsHorizontally?e.canvas.width:t.toScreen(i,o)[0];e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`;for(let t of n){if(t.opacity<=0)continue;let n=iH(t.image),r=n&&e.createPattern(t.image,`repeat-x`);r&&(r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l))}e.restore()}var lH=[`low`,`medium`,`high`];function uH(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function dH(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function fH(e){let t=await Promise.all(lH.map(t=>fetch(Yt(`/v1/textures/${e}/${t}.webp`,`textures`),{method:`HEAD`}).then(e=>e.ok).catch(()=>!1)));return lH.filter((e,n)=>t[n])}async function pH(e,t,n=fH){if(!t?.map_texture_available||!t.texture)return{};let r=s([{...t.texture,id:e,tiers:void 0},...t.alternates??[]]);if(!r)return{};let i=r.tiers??await n(r.id);if(i.length===0)return{};let{frames:a,...o}=r,c=t.radii;return{surface:{...o,tiers:i,monthlyFrames:a},radiusKm:c?(c.a+c.b+c.c)/3:void 0}}async function mH(e){return pH(e,(await hx(e,!1).catch(()=>null))?.global)}async function hH(e){let t=uH(e);if(!t)return mH(e);let n=(await dH(`${Kt()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return mH(e);let r=s([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return mH(e);let{frames:i,...a}=r,o=n.radii;return{surface:{...a,monthlyFrames:i},clouds:n.clouds,night:n.night,radiusKm:o?(o.a+o.b+o.c)/3:void 0}}var gH={low:2048,medium:8192,high:16383};function _H(e){return lH.find(t=>gH[t]>=e)??lH[lH.length-1]}function vH(e,t){return lH.indexOf(e)<=lH.indexOf(t)?e:t}function yH(e,t){let n=lH.indexOf(t);for(let t=n<0?lH.length-1:n;t>=0;t--)if(e.includes(lH[t]))return lH[t];return e[0]??`low`}function bH(e,t,n){let r=e.id;if(e.frames?.length){let i=Mj(n,e.frames,e.coverage);if(i)return Yt(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=iM(n,e.monthlyFrames);return Yt(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function xH(e,t){return e*t*4}function SH(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var CH=class{entries=new Map;clock=0;constructor(e){this.free=e}claim(e){let t=this.entries.get(e);return t?(t.claims++,t.used=++this.clock,t.value):null}put(e,t,n){let r=this.entries.get(e);return r?(r.value!==t&&this.free(t),r.claims++,r.used=++this.clock,r.value):(this.entries.set(e,{value:t,bytes:n,claims:1,used:++this.clock}),this.evict(),t)}release(e){let t=this.entries.get(e);t&&(t.claims=Math.max(0,t.claims-1),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=SH();if(e<=t)return;let n=[...this.entries].filter(([,e])=>!e.claims).sort((e,t)=>e[1].used-t[1].used);for(let[r,i]of n){if(e<=t)return;this.entries.delete(r),this.free(i.value),e-=i.bytes}}clear(){for(let e of this.entries.values())this.free(e.value);this.entries.clear()}},wH=new CH(e=>e.close()),TH=new CH(()=>{}),EH=new Map;function DH(e,t){return t?`${e}@${t}`:e}async function OH(e,t){let n=DH(e,t),r=wH.claim(n);if(r)return{key:n,bitmap:r};let i=EH.get(n);i||(i=kH(e,t),EH.set(n,i),i.finally(()=>EH.delete(n)));let a=await i;return a?{key:n,bitmap:wH.put(n,a,xH(a.width,a.height))}:null}async function kH(e,t){let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob();if(!t)return createImageBitmap(r);try{return await createImageBitmap(r,{resizeWidth:t,resizeQuality:`high`})}catch{return createImageBitmap(r)}}function AH(e){wH.release(e)}function jH(e,t,n){let r=DH(e,t),i=TH.claim(r);if(i)return{key:r,raster:i};let a=aH(n,t);return a?{key:r,raster:TH.put(r,a,xH(a.width,a.height))}:null}function MH(e){TH.release(e)}function NH(e,t,n){return[lC(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var PH=class{projection;width;height;view;scale;constructor(e,t,n,r){this.projection=e,this.width=t,this.height=n,this.view=r;let{minX:i,maxX:a,minY:o,maxY:s}=e.extent,c=Math.min(t/(a-i),n/(s-o));this.scale=c*r.zoom}toScreen(e,t){return[this.width/2+(e-this.view.centerX)*this.scale,this.height/2-(t-this.view.centerY)*this.scale]}fromScreen(e,t){return[this.view.centerX+(e-this.width/2)/this.scale,this.view.centerY-(t-this.height/2)/this.scale]}project(e,t){let n=this.projection.forward(e,t);return n?this.toScreen(n[0],n[1]):null}unproject(e,t){let[n,r]=this.fromScreen(e,t);return this.projection.inverse(n,r)}get worldWidthPx(){let{minX:e,maxX:t}=this.projection.extent;return(t-e)*this.scale}get repeatsHorizontally(){return FH(this.projection,this.worldWidthPx,this.width)}get repeatShifts(){if(!this.repeatsHorizontally)return[0];let e=this.worldWidthPx,t=this.toScreen(this.projection.extent.minX,0)[0];return[0,-e,e].filter(n=>t+n<this.width&&t+n+e>0)}};function FH(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function IH(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=LH(e,t,i),s=t.extent,c=s.maxX-s.minX,l=s.maxY-s.minY,u=Math.min(n/c,r/l)*a,d=n/2/u,f=r/2/u,p=(s.minX+s.maxX)/2,m=(s.minY+s.maxY)/2,h=(e,t,n,r)=>n>=r/2?t:Math.min(t+r/2-n,Math.max(t-r/2+n,e));return{zoom:a,centerX:FH(t,c*u,n)?((o.centerX-s.minX)%c+c)%c+s.minX:h(o.centerX,p,d,c),centerY:h(o.centerY,m,f,l)}}function LH(e,t,n){if(!(n.minLon!==void 0||n.maxLon!==void 0||n.minLat!==void 0||n.maxLat!==void 0)||t.azimuthal)return e;let r=t.inverse(e.centerX,e.centerY);if(!r)return e;let[i,a]=NH(r[0],r[1],n);if(i===r[0]&&a===r[1])return e;let o=t.forward(i,a);return o?{centerX:o[0],centerY:o[1]}:e}var RH=[[6,`high`],[2.5,`medium`]],zH=22e5,BH=4096,VH=11,HH=.4,UH=.8,WH=140,GH=`naif-399`,KH=[{kind:`surface`,label:e=>e.layer_surface(),visible:!0,opacity:1,blend:`normal`},{kind:`clouds`,label:e=>e.layer_clouds(),visible:!0,opacity:1,blend:`normal`},{kind:`night`,label:e=>e.layer_night(),visible:!1,opacity:.85,blend:`add`}];function qH(e){return e.kind===`raster`}var JH=new WeakMap,YH=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(KV,`svg`);layerGroup=document.createElementNS(KV,`g`);shapeGroup=document.createElementNS(KV,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;generation=0;controls=null;attribution=null;dragPan;scrollZoom;cooperativeGestures;lookup=null;lookupKey=``;buffer=null;frame=0;resizeObserver=null;listeners=new Map;announcedReady=!1;disposed=!1;moving=!1;sharpWidth=0;msPerPixel=0;settleTimer=0;chosenVisibility=new Map;customLayers=[];constructor(e={}){this.bodyId=e.body??GH,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=GB(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??Ng(new Date),this.dragPan=new OV(kV(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new OV(kV(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new OV(e.cooperativeGestures??!1,e=>this.applyCooperative(e)),this.root.className=`sm-flat`,this.canvas.className=`sm-flat__raster`,this.svg.setAttribute(`class`,`sm-flat__vector`),this.markerLayer.className=`sm-flat__markers`,this.svg.append(this.layerGroup,this.shapeGroup),this.root.append(this.canvas,this.svg,this.markerLayer),this.ctx=this.canvas.getContext(`2d`),this.overlay=new rH(this.shapeGroup,this.markerLayer,()=>this.render()),this.root.classList.toggle(`sm-flat--interactive`,this.dragPan.isEnabled()),this.applyCooperative(this.cooperativeGestures.isEnabled());for(let[t,n]of Object.entries(e.layers??{}))this.chosenVisibility.set(t,n)}mount(e){this.container=e,e.append(this.root),this.controls=new LV(this,this.root),this.cooperative=new jV(this.root,this.cooperativeGestures.isEnabled()),this.resizeObserver=new ResizeObserver(()=>this.renderMoving()),this.resizeObserver.observe(this.root),this.attachInteraction()}addControl(e,t){if(!this.controls)throw Error(`spacemap: the map is not mounted`);return this.controls.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.unmount()}unmount(){this.disposed=!0,this.controls?.clear(),this.controls=null,this.cooperative?.dispose(),this.cooperative=null,this.resizeObserver?.disconnect(),this.resizeObserver=null,cancelAnimationFrame(this.frame),clearTimeout(this.settleTimer);for(let e of this.layerList)qH(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await hH(e);if(!this.disposed){if(!t.surface){let t=Error(`spacemap: no map texture for ${e}`);throw this.emit(`error`,t),t}e!==this.bodyId&&this.release(),this.bodyId=e,this.sources=t,this.bodyRadiusKm=t.radiusKm??null,this.overlay.setBodyRadiusKm(this.bodyRadiusKm),this.buildLayers(),await this.loadVisible(),!this.disposed&&this.render()}}release(){this.generation++,this.dropTextures(),this.missing.clear();for(let e of this.layerList)!qH(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=a(),t=[];for(let n of KH){let r=this.sources[n.kind];r&&t.push({kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:JV(r),tiers:r.tiers,url:(e,t)=>bH(r,t,e)})}t.push(XV(e.layer_graticule())),t.push(QV(this.bodyId,e.layer_nomenclature())),t.push(...this.customLayers);for(let e of t){let t=this.chosenVisibility.get(e.id);t!==void 0&&(e.visible=t)}this.layerList=t,this.emit(`layerschange`,this.layers)}get layers(){return this.layerList.map(qV)}getLayers(){return this.layerList.map(e=>e.id)}isLayerVisible(e){return this.layerList.find(t=>t.id===e)?.visible??!1}get credits(){let e=new Set,t=[];for(let n of this.layerList)!n.visible||!n.credit||e.has(n.credit.organisation)||(e.add(n.credit.organisation),t.push(n.credit));return t}setLayerVisible(e,t){this.chosenVisibility.set(e,t);let n=this.layerList.find(t=>t.id===e);!n||n.visible===t||(n.visible=t,this.emit(`layerschange`,this.layers),this.loadVisible(),this.render())}setLayerOpacity(e,t){let n=this.layerList.find(t=>t.id===e);!n||!qH(n)||(n.opacity=Math.min(1,Math.max(0,t)),this.render())}addRasterLayer(e){let t={kind:`raster`,id:e.id,label:e.label??e.id,visible:e.visible??!0,opacity:e.opacity??1,blend:e.blend??`normal`,credit:e.credit,tiers:[`low`],url:()=>e.url};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}addVectorLayer(e){let t={kind:`vector`,id:e.id,label:e.label??e.id,visible:e.visible??!0,credit:e.credit,render:e.render,prepare:e.prepare};this.customLayers.push(t),this.layerList.push(t),this.emit(`layerschange`,this.layers),this.loadVisible()}get projectionName(){return this.projectionId}static get projections(){return WB}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=GB(e,this.projectionOptions),this.view={...this.view,centerX:0,centerY:0},this.render(),this.emit(`viewchange`,this.viewState)}get viewState(){let e=this.viewport(),t=e.unproject(e.width/2,e.height/2);return{projection:this.projectionId,zoom:this.view.zoom,centerLon:t?.[0]??this.projectionOptions.centerLon??0,centerLat:t?.[1]??this.projectionOptions.centerLat??0}}setView(e){if(e.projection&&e.projection!==this.projectionId&&this.setProjection(e.projection),this.limitsArmed=!1,e.zoom!==void 0&&(this.view={...this.view,zoom:e.zoom}),e.centerLon!==void 0||e.centerLat!==void 0){let t=this.viewState,n=e.centerLon??t.centerLon,r=e.centerLat??t.centerLat;if(this.projection.azimuthal)this.projectionOptions={...this.projectionOptions,centerLon:n,centerLat:r},this.projection=GB(this.projectionId,this.projectionOptions);else{let e=this.projection.forward(n,r);e&&(this.view={...this.view,centerX:e[0],centerY:e[1]})}}this.loadVisible(),this.render(),this.emit(`viewchange`,this.viewState)}setLimits(e){return this.limits={maxZoom:16,...e},this.render(),this}getLimits(){return{...this.limits}}setTime(e){this.jd=e,this.loadVisible(),this.render()}async setBody(e){e!==this.bodyId&&(this.limitsArmed=!1,await this.adopt(e))}project(e,t){return this.viewport().project(e,t)}unproject(e,t){let n=this.viewport().unproject(e,t);return n?{lon:n[0],lat:n[1]}:null}addPolyline(e){let t=this.overlay.addPolyline(e);return this.render(),t}addPolygon(e){let t=this.overlay.addPolygon(e);return this.render(),t}addBox(e){let t=this.overlay.addBox(e);return this.render(),t}addCircle(e){let t=this.overlay.addCircle(e);return this.render(),t}addMarker(e){let t=this.overlay.addMarker(e);return this.render(),t}clearDrawings(){this.overlay.clear(),this.render()}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});JH.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners.get(e);if(n){n.delete(t);for(let e of n)JH.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}tier(e){return yH(e,vH(RH.find(([e])=>this.view.zoom>=e)?.[1]??`low`,_H(this.usableSourceWidth())))}usableSourceWidth(){return this.projectionId===`equirectangular`?this.deviceWidth()*this.view.zoom:this.workingWidth()}deviceWidth(){return this.sharpWidth||Math.max(1,this.root.clientWidth)}workingWidth(){let e=this.deviceWidth()*2*this.view.zoom;return Math.min(BH,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),gH[e]??BH)}picturesInUse(){return this.layerList.filter(e=>qH(e)&&e.visible).map(e=>{let t=this.tier(e.tiers);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!qH(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==DH(e,this.decodeWidth(t))).filter(({url:e})=>!this.pending.has(e)&&!this.missing.has(e)).map(async({url:e,tier:t})=>{this.pending.add(e);let n=this.generation;try{let r=await OH(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){AH(r.key);return}this.hold(this.bitmaps,e,r,AH),this.render()}catch(t){if(n!==this.generation)return;this.missing.add(e),this.emit(`error`,Error(`spacemap: could not load ${e}`,{cause:t}))}finally{this.pending.delete(e)}});await Promise.all([...t,...n]),this.dropUnused(new Set(this.picturesInUse().map(({url:e})=>e)))}dropUnused(e){for(let[t,n]of this.bitmaps)e.has(t)||(AH(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(MH(n.key),this.rasters.delete(t))}hold(e,t,n,r){let i=e.get(t);i?.key!==n.key&&(i&&r(i.key),e.set(t,n))}rasterFor(e,t){let n=this.rasters.get(e);if(n?.key===DH(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=jH(e,t,r);return i?(this.hold(this.rasters,e,i,MH),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())AH(e.key);for(let e of this.rasters.values())MH(e.key);this.bitmaps.clear(),this.rasters.clear()}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1;return this.view=IH(this.view,this.projection,n,r,this.limitsArmed?this.limits:{}),new PH(this.projection,Math.max(1,n),Math.max(1,r),this.view)}render(){this.disposed||(cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.draw()))}renderMoving(){this.moving=!0,clearTimeout(this.settleTimer),this.settleTimer=window.setTimeout(()=>{this.moving=!1,this.render()},WH),this.render()}draw(){let e=this.root.clientWidth,t=this.root.clientHeight;if(!this.ctx||e===0||t===0)return;let n=Math.min(window.devicePixelRatio||1,2),r=Math.sqrt(zH/(e*t*n*n)),i=n*Math.min(1,r),a=Math.max(1,Math.round(e*i));a!==this.sharpWidth&&(this.sharpWidth=a,this.loadVisible());let o=e*i*t*i,s=i*(this.moving?this.interactionScale(o):1),c=Math.max(1,Math.round(e*s)),l=Math.max(1,Math.round(t*s));(this.canvas.width!==c||this.canvas.height!==l)&&(this.canvas.width=c,this.canvas.height=l,this.buffer=null,this.lookup=null);let u=this.viewport(e,t),d=new PH(this.projection,c,l,this.view);this.clipToDisc(u),this.drawRaster(d,c,l),this.drawVector(u),!this.announcedReady&&this.bitmaps.size>0&&(this.announcedReady=!0,this.emit(`ready`))}record(e,t){if(t<=0)return;let n=e/t;this.msPerPixel=this.msPerPixel===0?n:this.msPerPixel*.7+n*.3}interactionScale(e){if(this.msPerPixel<=0||e<=0)return 1;let t=Math.sqrt(VH/this.msPerPixel/e);return t>UH?1:Math.max(HH,t)}clipToDisc(e){let{projection:t}=e;if(!t.azimuthal){this.canvas.style.clipPath=``;return}let[n,r]=e.toScreen(0,0),i=t.extent.maxX*e.scale;this.canvas.style.clipPath=`circle(${i}px at ${n}px ${r}px)`}drawRaster(e,t,n){let r=this.ctx;r.clearRect(0,0,t,n);let i=this.layerList.filter(e=>qH(e)&&e.visible);if(i.length===0)return;if(this.projectionId===`equirectangular`){let t=i.map(e=>({image:this.bitmaps.get(e.url(this.jd,this.tier(e.tiers)))?.bitmap,opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);t.length&&cH(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e.tiers)),a),opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);if(o.length===0)return;(!this.buffer||this.buffer.width!==t||this.buffer.height!==n)&&(this.buffer=r.createImageData(t,n));let s=`${this.projectionId}|${JSON.stringify(this.projectionOptions)}|${this.view.zoom}|${this.view.centerX}|${this.view.centerY}|${t}x${n}`,c=!this.lookup||this.lookupKey!==s,l=performance.now();c&&(this.lookup=new oH(e,t,n),this.lookupKey=s),sH(this.lookup,o,this.buffer),r.putImageData(this.buffer,0,0),c&&this.record(performance.now()-l,t*n)}drawVector(e){this.svg.setAttribute(`viewBox`,`0 0 ${e.width} ${e.height}`),this.layerGroup.replaceChildren();for(let t of this.layerList){if(qH(t)||!t.visible)continue;let n=document.createElementNS(KV,`g`);n.setAttribute(`data-layer`,t.id),t.render(e,n),this.layerGroup.append(n)}this.overlay.redraw(e)}applyCooperative(e){this.root.classList.toggle(`sm-flat--cooperative`,e),this.cooperative?.setEnabled(e)}attachInteraction(){let e=!1,t=0,n=0,r=!1,i=!1,a=new Map,o=-1,s=0,c=null,l=()=>{let[e,t]=[...a.values()];if(!t)return null;let n=this.root.getBoundingClientRect();return{gap:Math.hypot(e.x-t.x,e.y-t.y),x:(e.x+t.x)/2-n.left,y:(e.y+t.y)/2-n.top}},u=e=>{let t=this.root.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]};this.root.addEventListener(`pointerdown`,u=>{u.pointerType===`touch`&&a.set(u.pointerId,{x:u.clientX,y:u.clientY}),c=l(),s=c?.gap??0,u.button===0&&(o=u.pointerId,e=!0,r=!1,i=u.pointerType===`touch`&&this.cooperative.isEnabled()&&a.size<2,this.root.setPointerCapture(u.pointerId),t=u.clientX,n=u.clientY,!i&&this.dragPan.isEnabled()&&this.root.classList.add(`sm-flat--dragging`))}),this.root.addEventListener(`pointermove`,d=>{let[f,p]=u(d);a.has(d.pointerId)&&a.set(d.pointerId,{x:d.clientX,y:d.clientY});let m=l();if(m){r=!0,c&&this.dragPan.isEnabled()&&this.drag(m.x-c.x,m.y-c.y),s>0&&this.scrollZoom.isEnabled()&&this.zoomBy(m.gap/s,m.x,m.y),s=m.gap,c=m;return}if(!e){this.emit(`pointermove`,this.unproject(f,p),d);return}if(d.pointerId!==o)return;let h=d.clientX-t,g=d.clientY-n;if(t=d.clientX,n=d.clientY,(Math.abs(h)>1||Math.abs(g)>1)&&(r=!0),i){r&&this.cooperative.allowsTouchDrag(a.size);return}this.dragPan.isEnabled()&&this.drag(h,g)});let d=l=>{a.delete(l.pointerId),s=0,c=null;let[d]=[...a.entries()];if(d&&e){o=d[0],t=d[1].x,n=d[1].y,i=this.cooperative.isEnabled()&&a.size<2;return}if(!(!e||l.pointerId!==o)&&(e=!1,this.root.releasePointerCapture?.(l.pointerId),this.root.classList.remove(`sm-flat--dragging`),!r)){let[e,t]=u(l);this.emit(`click`,this.unproject(e,t),l)}};this.root.addEventListener(`pointerup`,d),this.root.addEventListener(`pointercancel`,d),this.root.addEventListener(`wheel`,e=>{if(!this.scrollZoom.isEnabled()||!this.cooperative.allowsWheel(e))return;e.preventDefault();let[t,n]=u(e);this.zoomBy(Math.exp(-e.deltaY/400),t,n)},{passive:!1})}drag(e,t){this.limitsArmed=!0;let n=this.viewport();if(this.projection.azimuthal){let r=n.scale,i=e=>e/r*(180/Math.PI),[a,o]=NH((this.projectionOptions.centerLon??0)-i(e),Math.max(-90,Math.min(90,(this.projectionOptions.centerLat??0)+i(t))),this.limits);this.projectionOptions={...this.projectionOptions,centerLon:a,centerLat:o},this.projection=GB(this.projectionId,this.projectionOptions)}else this.view={...this.view,centerX:this.view.centerX-e/n.scale,centerY:this.view.centerY+t/n.scale};this.renderMoving(),this.emit(`viewchange`,this.viewState)}zoomBy(e,t,n){this.limitsArmed=!0;let r=this.viewport().fromScreen(t,n),i=Math.min(this.limits.maxZoom??1/0,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(i===this.view.zoom)return;this.view={...this.view,zoom:i};let a=this.viewport();if(!this.projection.azimuthal){let e=a.fromScreen(t,n);this.view={...this.view,centerX:this.view.centerX+r[0]-e[0],centerY:this.view.centerY+r[1]-e[1]}}this.loadVisible(),this.renderMoving(),this.emit(`viewchange`,this.viewState)}};function XH(e){let t=e?.radii;if(t)return(t.a+t.b+t.c)/3;let n=e?.wikidata?.radius;if(n)return n.unit===`kilometre`?n.value:n.unit===`metre`?n.value/1e3:null;let r=e?.sbdb?.diameter;return r?r/2:null}function ZH(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function QH(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var $H=Math.PI/180,eU=256,tU=128,nU=.05,rU=.25;function iU(e){try{let t=document.createElement(`canvas`);t.width=eU,t.height=tU;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,eU,tU);let{data:r}=n.getImageData(0,0,eU,tU),i=new Uint8Array(eU*tU);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:eU,height:tU,covered:i}}catch{return null}}function aU(e,t,n){let{width:r,height:i,covered:a}=e,o=new Float64Array(r);for(let e=0;e<r;e++)o[e]=(e+.5)*360/r;let s=new Float64Array(i);for(let e=0;e<i;e++)s[e]=90-(e+.5)*180/i;let c=0,l=0,u=0;for(let e=0;e<i;e++){let t=Math.cos(s[e]*$H);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*$H),l+=t*Math.cos(o[n]*$H),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<nU?t.heading:oU(Math.atan2(c,l)/$H-n.northOffsetDeg),f=oU(d+n.northOffsetDeg),p=Math.min(180,n.hfovDeg/2),m=new Float64Array(i),h=0;for(let e=0;e<r;e++)if(!(Math.abs((o[e]-f+540)%360-180)>p))for(let t=0;t<i;t++)a[t*r+e]&&(h=Math.max(h,++m[t]));let g=-1/0,_=1/0;for(let e=0;e<i;e++)m[e]<h*rU||(g=Math.max(g,s[e]),_=Math.min(_,s[e]));if(g<_)return{heading:d,pitch:t.pitch};let v=Math.min(n.vfovDeg/3,(g-_)/2);return{heading:d,pitch:Math.max(_+v,Math.min(g-v,t.pitch))}}function oU(e){return(e%360+360)%360}Math.PI/180;function sU(e){return e.orientation!==`unknown`&&e.north_offset_deg!==void 0}function cU(e){return e.id}function lU(e){return`${e.time},${e.lat},${e.lon}`}function uU(e,t){return t?e.find(e=>cU(e)===t||lU(e)===t)??null:null}function dU(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=e=>e&&e.mission===t.mission,a=e=>i(e)?{entry:e,distanceM:pU(t,e,n),bearingDeg:mU(t,e)}:null;return{previous:a(e[r-1]),next:a(e[r+1])}}var fU=Math.PI/180;function pU(e,t,n){return QB(e,t)*fU*n*1e3}function mU(e,t){let n=e.lat*fU,r=t.lat*fU,i=(t.lon-e.lon)*fU,a=Math.sin(i)*Math.cos(r),o=Math.cos(n)*Math.sin(r)-Math.sin(n)*Math.cos(r)*Math.cos(i);return(Math.atan2(a,o)/fU%360+360)%360}var hU=Math.PI/180,gU=30,_U=110,vU=85,yU=75,bU=-22,xU=9,SU=6,CU=10,wU=1,TU=1,EU=new Hi(-Math.SQRT1_2,0,0,Math.SQRT1_2),DU=new J(0,0,1);function OU(e){return(e%360+360)%360}function kU(e,[t,n]){let r=OU(n-t),i=OU(e-t);return i<=r?OU(e):i-r<360-i?OU(n):OU(t)}function AU(e,t,n){return Math.max(t,Math.min(n,e))}function jU(e,t,n=new J){let r=e*hU,i=t*hU;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function MU(){let e=new hl;return e.moveTo(0,1),e.lineTo(.85,.05),e.lineTo(.38,.05),e.lineTo(.38,-.9),e.lineTo(-.38,-.9),e.lineTo(-.38,.05),e.lineTo(-.85,.05),e.closePath(),e}var NU=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new qa;camera=new sd(yU,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new za;arrowGeometry=new tu(MU());raycaster=new Rd;loader=new Ju;texture=null;loadToken=0;frame=0;disposed=!1;entries=[];radiusKm=0;current=null;neighbours=null;view;pointers=new Map;pinchDistance=0;dragStart=null;hovered=null;gyroEnabled=!1;gyroOrigin=null;gyroEuler=new xa;gyroQuaternion=new Hi;gyroScreen=new Hi;gyroDirection=new J;lookAt=new J;ndc=new J;gridPoint=new J;viewDirection=new J;listeners={ready:new Set,load:new Set,error:new Set,viewchange:new Set,step:new Set,arrows:new Set};constructor(e){this.bodyId=e.body,this.openAt=e.at,this.interactive=e.interactive??!0,this.arrows.visible=e.arrows??!0,this.followArrows=e.followArrows??!0,this.openingView=e.heading!==void 0||e.pitch!==void 0?{heading:e.heading,pitch:e.pitch}:null,this.view={heading:e.heading??0,pitch:e.pitch??0,fov:e.fov??yU},e.limits&&this.setLimits(e.limits),this.root.className=`sm-panorama`,this.root.style.cssText=`position:relative;width:100%;height:100%;overflow:hidden`,this.scene.background=new X(`#0b0d12`),this.sphere=new As(new ru(500,96,48).scale(-1,1,1),new vs({transparent:!0,visible:!1,depthWrite:!1})),this.sphere.renderOrder=-2,this.scene.add(this.sphere,this.arrows)}mount(e){this.container=e,e.append(this.root),this.renderer=new dh({antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2));let t=this.renderer.domElement;t.style.cssText=`display:block;width:100%;height:100%;touch-action:none`,t.tabIndex=0,this.root.append(t),this.angleCanvas.style.cssText=`position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none`,this.angleCanvas.setAttribute(`aria-hidden`,`true`),this.angleCanvas.hidden=!0,this.root.append(this.angleCanvas),this.controls=new LV(this,this.root),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(this.root),this.resize(),this.interactive?(t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp),t.addEventListener(`pointercancel`,this.onPointerCancel),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.addEventListener(`keydown`,this.onKeyDown)):(t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp))}async load(){let e=await hx(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(mx),this.radiusKm=XH(e.global)??0,this.emit(`ready`);let t=this.openAt?this.byKey(this.openAt):this.entries[0]??null;if(!t){let e=Error(this.openAt?`spacemap: no panorama ${this.openAt} on ${this.bodyId}`:`spacemap: no panoramas on ${this.bodyId}`);throw this.emit(`error`,e),e}await this.open(t)}addControl(e,t){return this.controls?.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.disposed=!0,this.setGyroEnabled(!1),this.loadToken++,cancelAnimationFrame(this.frame),this.frame=0,this.controls?.clear(),this.resizeObserver?.disconnect();let e=this.renderer?.domElement;e&&(e.removeEventListener(`pointerdown`,this.onPointerDown),e.removeEventListener(`pointermove`,this.onPointerMove),e.removeEventListener(`pointerup`,this.onPointerUp),e.removeEventListener(`pointercancel`,this.onPointerCancel),e.removeEventListener(`wheel`,this.onWheel),e.removeEventListener(`keydown`,this.onKeyDown)),this.setArrowTargets([]),this.texture?.dispose(),this.sphere.geometry.dispose(),this.sphere.material.dispose(),this.arrowGeometry.dispose(),this.renderer?.dispose(),this.renderer=null,this.root.remove(),this.container=null}getPanoramas(){return this.entries}getCurrent(){return this.current}getNeighbours(){return this.neighbours}async open(e){let t=typeof e==`string`?this.byKey(e):e;if(!t){let t=Error(`spacemap: no panorama ${String(e)} on ${this.bodyId}`);throw this.emit(`error`,t),t}this.current=t,this.neighbours=this.radiusKm?dU(this.entries,t,this.radiusKm):null;let n=this.openingView;this.openingView=null,n&&this.setView({heading:n.heading,pitch:n.pitch??0}),this.setArrowTargets(this.neighbours&&sU(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n&&e.n.distanceM>=TU).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture(Yt(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg??0,!n),this.current===t&&this.emit(`load`,t)}async step(e){let t=this.neighbours?.[e];t&&await this.open(t.entry)}byKey(e){return this.entries.find(t=>t.id===e)??uU(this.entries,e)}getView(){return{...this.view}}setView(e){let t=e.heading??this.view.heading,n=e.pitch??this.view.pitch,r=e.fov??this.view.fov,{limits:i}=this;this.view={heading:i.heading?kU(t,i.heading):OU(t),pitch:AU(n,i.pitch?.[0]??-vU,i.pitch?.[1]??vU),fov:AU(r,i.fov?.[0]??gU,i.fov?.[1]??_U)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[AU(e[0],t,n),AU(e[1],t,n)];this.limits={heading:e.heading&&[OU(e.heading[0]),OU(e.heading[1])],pitch:t(e.pitch,-vU,vU),fov:t(e.fov,gU,_U)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?ZH()!==`available`||!await QH()||this.disposed?!1:(this.gyroOrigin=null,this.gyroEnabled=!0,window.addEventListener(`deviceorientation`,this.onDeviceOrientation),!0):(window.removeEventListener(`deviceorientation`,this.onDeviceOrientation),this.gyroEnabled=!1,!1)}isGyroEnabled(){return this.gyroEnabled}onDeviceOrientation=e=>{if(e.alpha===null||e.beta===null||e.gamma===null)return;this.gyroEuler.set(e.beta*hU,e.alpha*hU,-e.gamma*hU,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(EU).multiply(this.gyroScreen.setFromAxisAngle(DU,-(screen.orientation?.angle??0)*hU)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/hU,n=Math.asin(AU(this.gyroDirection.y,-1,1))/hU;this.gyroOrigin===null&&(this.gyroOrigin=OU(t-this.view.heading)),this.setView({heading:t-this.gyroOrigin,pitch:n})};on(e,t){return this.listeners[e].add(t),()=>this.off(e,t)}once(e,t){let n=this.on(e,((...e)=>{n(),t(...e)}));return n}off(e,t){this.listeners[e].delete(t)}emit(e,...t){for(let n of this.listeners[e])n(...t)}faceCoverage(e,t){let n=iU(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*hU)*this.camera.aspect)/hU;this.setView(aU(n,this.view,{northOffsetDeg:t,hfovDeg:i,vfovDeg:r}))}loadTexture(e,t,n){let r=++this.loadToken;return new Promise((i,a)=>{this.loader.load(e,e=>{if(r!==this.loadToken){e.dispose(),i();return}e.colorSpace=Xr,this.renderer&&(e.anisotropy=this.renderer.capabilities.getMaxAnisotropy()),this.texture?.dispose(),this.texture=e,this.sphere.material.map=e,this.sphere.material.visible=!0,this.sphere.material.needsUpdate=!0,this.sphere.rotation.y=Math.PI/2+t*hU,n&&this.faceCoverage(e.image,t),this.invalidate(),i()},void 0,()=>{if(r!==this.loadToken)return i();let t=Error(`spacemap: panorama failed to load: ${e}`);this.emit(`error`,t),a(t)})})}setArrowTargets(e){for(let e of[...this.arrows.children])this.arrows.remove(e),e.traverse(e=>{e instanceof As&&e.material.dispose()});for(let t of e){let e=new za;e.name=t.key;let n=new As(this.arrowGeometry,new vs({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new As(this.arrowGeometry,new vs({color:`#ffffff`,transparent:!0,opacity:.85,side:2,depthWrite:!1}));r.position.y=.02;for(let e of[n,r])e.rotation.x=-Math.PI/2;e.add(n,r),e.position.copy(jU(t.bearingDeg,bU)).multiplyScalar(xU),e.rotation.y=-t.bearingDeg*hU,this.arrows.add(e)}this.invalidate()}invalidate(){this.disposed||this.frame||!this.renderer||(this.frame=requestAnimationFrame(()=>{this.frame=0,this.render()}))}setAngleGridVisible(e){e!==this.angleGridVisible&&(this.angleGridVisible=e,this.angleCanvas.hidden=!e,this.invalidate())}setArrowsVisible(e){e!==this.arrows.visible&&(this.arrows.visible=e,e||(this.hovered=null,this.renderer&&(this.renderer.domElement.style.cursor=``)),this.invalidate())}resize(){let{clientWidth:e,clientHeight:t}=this.root;if(!e||!t||!this.renderer)return;this.renderer.setSize(e,t,!1);let n=Math.min(window.devicePixelRatio,2);this.angleCanvas.width=Math.round(e*n),this.angleCanvas.height=Math.round(t*n),this.angleContext.setTransform(n,0,0,n,0,0),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.invalidate()}render(){if(!this.renderer)return;this.camera.fov=this.view.fov,this.camera.updateProjectionMatrix(),this.camera.lookAt(jU(this.view.heading,this.view.pitch,this.lookAt)),this.renderer.render(this.scene,this.camera);let{clientWidth:e,clientHeight:t}=this.root;if(this.drawAngleGrid(e,t),this.listeners.arrows.size===0)return;let n={};for(let r of this.arrows.visible?this.arrows.children:[])this.ndc.copy(r.position).project(this.camera),n[r.name]={x:(this.ndc.x+1)/2*e,y:(1-this.ndc.y)/2*t,visible:this.ndc.z<1&&Math.abs(this.ndc.x)<.98&&Math.abs(this.ndc.y)<.98};this.emit(`arrows`,n)}drawAngleGrid(e,t){let n=this.angleContext;if(n.clearRect(0,0,e,t),this.angleGridVisible){this.camera.getWorldDirection(this.viewDirection),n.strokeStyle=`rgba(255, 255, 255, 0.24)`,n.lineWidth=1,n.beginPath();for(let r=0;r<360;r+=CU)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=CU)this.traceAngleLine(n,e,t,r,!1);n.stroke(),n.font=`12px system-ui, sans-serif`,n.lineWidth=3,n.strokeStyle=`rgba(0, 0, 0, 0.7)`,n.fillStyle=`rgba(255, 255, 255, 0.85)`,n.textAlign=`center`,n.textBaseline=`bottom`;for(let r=0;r<360;r+=CU){if(!this.projectAngle(r,0,e,t,!0))continue;let i=`${r}°`;n.strokeText(i,this.gridPoint.x,this.gridPoint.y-3),n.fillText(i,this.gridPoint.x,this.gridPoint.y-3)}n.textAlign=`left`,n.textBaseline=`middle`;for(let r of[0,90,180,270])for(let i=-80;i<=80;i+=CU){if(i===0||!this.projectAngle(r,i,e,t,!0))continue;let a=`${i>0?`+`:``}${i}°`;n.strokeText(a,this.gridPoint.x+4,this.gridPoint.y),n.fillText(a,this.gridPoint.x+4,this.gridPoint.y)}}}traceAngleLine(e,t,n,r,i){let a=!1,o=0,s=0,c=Math.max(t,n)*2,l=i?-90:0,u=i?90:360;for(let d=l;d<=u;d+=wU){let l=i?r:d,u=i?d:r;if(!this.projectAngle(l,u,t,n)){a=!1;continue}let{x:f,y:p}=this.gridPoint;!a||Math.hypot(f-o,p-s)>c?e.moveTo(f,p):e.lineTo(f,p),a=!0,o=f,s=p}}projectAngle(e,t,n,r,i=!1){return jU(e,t,this.gridPoint),this.gridPoint.dot(this.viewDirection)<=.001||(this.gridPoint.project(this.camera),!Number.isFinite(this.gridPoint.x)||!Number.isFinite(this.gridPoint.y))||i&&(Math.abs(this.gridPoint.x)>=.98||Math.abs(this.gridPoint.y)>=.98)||Math.abs(this.gridPoint.x)>4||Math.abs(this.gridPoint.y)>4?!1:(this.gridPoint.x=(this.gridPoint.x+1)/2*n,this.gridPoint.y=(1-this.gridPoint.y)/2*r,!0)}degreesPerPixel(){return this.view.fov/Math.max(1,this.root.clientHeight)}arrowAt(e,t){if(!this.renderer||!this.arrows.visible||this.arrows.children.length===0)return null;let n=this.renderer.domElement.getBoundingClientRect(),r=new q((e-n.left)/n.width*2-1,-((t-n.top)/n.height)*2+1);this.raycaster.setFromCamera(r,this.camera);let i=this.raycaster.intersectObjects(this.arrows.children,!0)[0];return i?i.object.parent.name:null}pressArrow(e){let t=this.neighbours?.[e];t&&(this.emit(`step`,{key:e,entry:t.entry}),this.followArrows&&this.open(t.entry).catch(()=>{}))}onPointerDown=e=>{try{this.renderer?.domElement.setPointerCapture(e.pointerId)}catch{}this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.dragStart=this.pointers.size===1?{x:e.clientX,y:e.clientY}:null,this.pointers.size===2&&(this.pinchDistance=this.pinchSpan())};onPointerMove=e=>{let t=this.pointers.get(e.pointerId);if(!t){let t=this.arrowAt(e.clientX,e.clientY);t!==this.hovered&&this.renderer&&(this.hovered=t,this.renderer.domElement.style.cursor=t?`pointer`:``);return}let n=e.clientX-t.x,r=e.clientY-t.y;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===1){if(this.gyroEnabled)return;let e=this.degreesPerPixel();this.setView({heading:this.view.heading-n*e,pitch:this.view.pitch+r*e})}else if(this.pointers.size===2){let e=this.pinchSpan();this.pinchDistance>0&&this.zoom(this.pinchDistance/e),this.pinchDistance=e}};onPointerUp=e=>{this.pointers.delete(e.pointerId);let t=this.dragStart;if(this.dragStart=null,this.pointers.size>0||!(!this.interactive||t!==null&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<SU))return;let n=this.arrowAt(e.clientX,e.clientY);n&&this.pressArrow(n)};onPointerCancel=e=>{this.pointers.delete(e.pointerId),this.dragStart=null};pinchSpan(){let[e,t]=[...this.pointers.values()];return Math.hypot(e.x-t.x,e.y-t.y)}zoom(e){this.setView({fov:this.view.fov*e})}onWheel=e=>{e.preventDefault(),this.zoom(Math.exp(e.deltaY*.0015))};onKeyDown=e=>{let t=this.view.fov/10,{heading:n,pitch:r}=this.view,i={ArrowLeft:()=>this.setView({heading:n-t}),ArrowRight:()=>this.setView({heading:n+t}),ArrowUp:()=>this.setView({pitch:r+t}),ArrowDown:()=>this.setView({pitch:r-t}),"+":()=>this.zoom(.8),"-":()=>this.zoom(1.25)}[e.key];i&&(e.preventDefault(),i())}},PU=ax(()=>`${Kt()}/v1/groups/__planetary_systems_map__.json.gz`,{error:e=>`Failed to fetch planetary systems map: ${e.status}`}),FU=ax(()=>`${Kt()}/v1/groups/__solar_system_map__.json.gz`,{error:e=>`Failed to fetch solar system map: ${e.status}`});function IU({onScrub:e,onEnd:t}){let n=null,r=0,i=!1;function a(){i&&t(),n=null,i=!1}return{onpointerdown(e){e.pointerType!==`mouse`&&(n=e.clientX,r=e.clientY,i=!1)},onpointermove(t){t.pointerType===`mouse`||n===null||!i&&Math.hypot(t.clientX-n,t.clientY-r)<8||(i=!0,e(t.clientX,t.clientY))},onpointerup:a,onpointercancel:a,onpointerleave:a}}var LU=2.2,RU=84,zU=40,BU=4,VU=3,HU=1e4,UU=34,WU=7,GU=.42,KU=30;function qU(e,t,n){let r=1/0;for(let i of n)r=Math.min(r,Math.hypot(i.cx-e,i.cy-t));return r}function JU(e){return e>90?180-e:e}function YU(e){let t=Math.log10(e.domain[0]),n=Math.log10(e.domain[1])-t,r=r=>44+(Math.log10(Math.max(r/e.unitKm,1e-9))-t)/n*656,i=[];for(let t of[...e.bodies].sort((e,t)=>e.aKm-t.aKm)){let n=r(t.aKm),a=Math.max(LU,t.radiusKm*e.pxPerKm),o=120;if(t.tiltDeg>0){let r=Math.min(JU(t.tiltDeg)*e.pxPerDeg,RU),a=120-r,s=120+r;o=qU(n,a,i)>=qU(n,s,i)?a:s}i.push({...t,cx:n,cy:o,r:a})}let a=[];for(let t of i){if(!t.satellites?.length)continue;let n=t.rings?t.r*t.rings.outer*GU:0,r=t.cy-Math.max(t.r,n)-BU,i=[];for(let n of[...t.satellites].sort((e,t)=>t.radiusKm-e.radiusKm)){let a=Math.max(LU,n.radiusKm*e.pxPerKm);r-=a,i.push({...n,cx:t.cx,cy:r,r:a,hitY:0,hitHeight:0}),r-=a+VU}let o=Math.min(...i.map(e=>e.cy-e.r))-WU,s=Math.max(...i.map(e=>e.cy+e.r))+WU;i.forEach((e,t)=>{let n=t===0?s:(i[t-1].cy+e.cy)/2,r=t===i.length-1?o:(i[t+1].cy+e.cy)/2;e.hitY=r,e.hitHeight=n-r}),a.push({parent:t,moons:i,x:t.cx-UU/2,y:o,width:UU,height:s-o,perMoon:!t.grouped&&!t.satellitesLink&&i.some(e=>e.link)})}let o=e.bands.map(e=>{let t=r(e.innerKm),n=r(e.outerKm)-t,i=Math.max(n,KU);return{...e,x:t,width:n,hitX:t+(n-i)/2,hitWidth:i}}).sort((e,t)=>t.width-e.width),s=``;e.cloud?.points.forEach((t,n)=>{let i=t.aKm/e.unitKm;if(i<e.domain[0]||i>e.domain[1])return;let a=Math.min(Math.max(JU(t.tiltDeg),0)*e.pxPerDeg,RU),o=120+(n%2==0?-a:a);s+=`M${r(t.aKm).toFixed(1)} ${o.toFixed(1)}h0.01`});let c=e.primary.radiusKm*e.pxPerKm;return{bodies:i,moonZones:a,bands:o,cloudPath:s,primaryR:c,primaryCx:zU-c,xOf:r}}function XU(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function ZU(e,t,n,r){for(let i of[!0,!1]){let a=null,o=r;for(let r of e.bodies){if(!!r.link!==i)continue;let e=Math.hypot(t-r.cx,n-r.cy),s=e<=r.r?e-HU:e-r.r;s>o||(a=r,o=s)}if(a)return a}return null}function QU(e,t,n){let r=ZU(e,t,n,0);if(r)return{kind:`body`,id:r.id};for(let r of e.moonZones){if(!XU(r,t,n))continue;if(r.parent.grouped)return{kind:`body`,id:r.parent.id};if(!r.perMoon)return{kind:`stack`,id:r.parent.id};let e=r.moons.find(e=>n>=e.hitY&&n<=e.hitY+e.hitHeight);if(e)return{kind:`moon`,parent:r.parent.id,id:e.id}}let i=ZU(e,t,n,16);if(i)return{kind:`body`,id:i.id};for(let r=e.bands.length-1;r>=0;r--){let i=e.bands[r];if(t>=i.hitX&&t<=i.hitX+i.hitWidth&&n>=26&&n<=206)return{kind:`band`,key:i.key}}return Math.hypot(t-e.primaryCx,n-120)<=e.primaryR?{kind:`primary`}:null}function $U(e,t,n){if(!n)return null;let{text:r}=e;switch(n.kind){case`primary`:return{cx:Math.max(44,t.primaryCx),cy:120-Math.min(t.primaryR,80),title:e.primary.name,sub:r.primary};case`body`:{let e=t.bodies.find(e=>e.id===n.id);if(!e)return null;let i=[r.distance(e.aKm)];return e.tiltDeg>90&&i.push(r.retrograde),e.grouped&&e.satellites?.length&&i.push(r.moons(e.satelliteCount??e.satellites.length)),{cx:e.cx,cy:e.cy-e.r-4,title:e.name,sub:i.join(` · `)}}case`stack`:{let e=t.moonZones.find(e=>e.parent.id===n.id);if(!e)return null;let i=e.x+e.width/2;return e.parent.satellitesTab?{cx:i,cy:e.y,title:e.parent.name,sub:r.moons(e.parent.satelliteCount??e.moons.length)}:{cx:i,cy:e.y,title:e.moons[0].name,sub:e.parent.name}}case`moon`:{let e=t.moonZones.find(e=>e.parent.id===n.parent),r=e?.moons.find(e=>e.id===n.id);return!e||!r?null:{cx:r.cx,cy:r.cy-r.r-4,title:r.name,sub:e.parent.name}}case`band`:{let e=t.bands.find(e=>e.key===n.key);return e?{cx:e.x+e.width/2,cy:44,title:e.name??e.label,sub:e.sub??`${r.distance(e.innerKm)}–${r.distance(e.outerKm)}`}:null}}}var eW=`http://www.w3.org/2000/svg`,tW=10,nW=-18,rW=1.2,iW=28,aW=6,oW=4,sW=18,cW=12,lW=190;function uW(e,t={},...n){let r=document.createElementNS(eW,e);for(let[e,n]of Object.entries(t))n!==void 0&&r.setAttribute(e,String(n));for(let e of n)e&&r.append(e);return r}function dW(e,t){return JSON.stringify(e)===JSON.stringify(t)}function fW(e,t){let n=new Map,r=(e,t)=>{(t?.href||t?.onclick)&&n.set(JSON.stringify(e),t)};for(let e of t.bands)r({kind:`band`,key:e.key},e);r({kind:`primary`},e.primary.link);for(let e of t.bodies)r({kind:`body`,id:e.id},e.link);for(let e of t.moonZones)if(!e.parent.grouped)if(!e.perMoon)r({kind:`stack`,id:e.parent.id},e.parent.satellitesLink);else for(let t of e.moons)r({kind:`moon`,parent:e.parent.id,id:t.id},t.link);return n}var pW=0,mW=class{root=document.createElement(`div`);svg=uW(`svg`);tip=document.createElement(`div`);tipTitle=document.createElement(`span`);tipSub=document.createElement(`span`);uid=`sm-system-map-${pW++}`;resize=new ResizeObserver(()=>{this.fitLabels(),this.placeTip()});model=null;placed=null;background=!1;hover=null;highlights=new Map;targets=new Map;links=new Map;shape=``;labels=[];constructor(){this.tip.className=`sm-system-map__tip`,this.tipTitle.className=`sm-system-map__tip-title`,this.tipSub.className=`sm-system-map__tip-sub`,this.tip.append(this.tipTitle,this.tipSub),this.tip.hidden=!0,this.root.append(this.svg,this.tip),this.resize.observe(this.root);let e=IU({onScrub:(e,t)=>this.setHover(this.hitAt(e,t)),onEnd:()=>this.setHover(null)});this.svg.addEventListener(`pointerdown`,e.onpointerdown),this.svg.addEventListener(`pointermove`,e.onpointermove),this.svg.addEventListener(`pointerup`,e.onpointerup),this.svg.addEventListener(`pointercancel`,e.onpointercancel),this.svg.addEventListener(`pointerleave`,e.onpointerleave);let t=[0,0],n=e=>{t=[e.clientX,e.clientY]};this.svg.addEventListener(`pointerdown`,n),this.svg.addEventListener(`pointerup`,n),this.svg.addEventListener(`pointermove`,e=>{n(e),e.pointerType===`mouse`&&this.setHover(this.hitAt(e.clientX,e.clientY))}),this.svg.addEventListener(`pointerleave`,e=>{e.pointerType===`mouse`&&this.setHover(null)}),this.svg.addEventListener(`click`,e=>{if(e.detail===0)return;let n=Math.abs(t[0]-e.clientX)<1&&Math.abs(t[1]-e.clientY)<1?this.hitAt(...t):this.hitAt(e.clientX,e.clientY);if(!n)return;let r=this.targets.get(JSON.stringify(n));r?.contains(e.target)||(e.stopPropagation(),e.preventDefault(),r?.dispatchEvent(new MouseEvent(`click`,{bubbles:!0,cancelable:!0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,button:e.button})))},!0)}destroy(){this.resize.disconnect(),this.root.remove()}update(e,t){this.model=e,this.placed=YU(e);let n=fW(e,this.placed),r=JSON.stringify([JSON.stringify(e,(e,t)=>e===`href`?void 0:t),t,[...n].map(([e,t])=>[e,!!t.href,!!t.onclick])]);if(this.links=n,r===this.shape){for(let[e,t]of this.targets){let r=n.get(e)?.href;r&&t.setAttribute(`href`,r)}return}this.shape=r,this.background=t.variant===`background`,this.hover=null,this.root.className=this.background?`sm-system-map sm-system-map--background`:`sm-system-map`,this.draw(e,this.placed,t.ariaLabel),this.fitLabels(),this.placeTip()}draw(e,t,n){let r=this.background;this.highlights=new Map,this.targets=new Map,this.labels=[];let i=this.svg;i.replaceChildren(),i.setAttribute(`viewBox`,r&&e.backgroundView||`0 0 720 240`),i.setAttribute(`preserveAspectRatio`,r?e.backgroundFit===`fit`?`xMidYMid meet`:e.backgroundView?`xMinYMid slice`:`xMidYMid slice`:`xMidYMid meet`),i.setAttribute(`class`,`sm-system-map__svg`),i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,n),i.setAttribute(`data-vaul-no-drag`,``);let a=(t,n)=>uW(`stop`,{offset:t,"stop-color":e.primary.color,"stop-opacity":n});i.append(uW(`defs`,{},uW(`radialGradient`,{id:`${this.uid}-primary`,gradientUnits:`userSpaceOnUse`,cx:t.primaryCx,cy:120,r:t.primaryR},a(`0%`,1),a(Math.max(0,1-tW/t.primaryR),.85),a(`100%`,.35)),uW(`pattern`,{id:`${this.uid}-band`,width:9,height:9,patternUnits:`userSpaceOnUse`},uW(`circle`,{cx:2,cy:2,r:.9,fill:`currentColor`,opacity:.55}),uW(`circle`,{cx:6.5,cy:6,r:.9,fill:`currentColor`,opacity:.55})))),r||this.drawAxis(e,t),t.cloudPath&&i.append(uW(`path`,{d:t.cloudPath,stroke:e.cloud?.color,"stroke-width":rW*2,"stroke-linecap":`round`,fill:`none`,opacity:.45,"pointer-events":`none`}));for(let e of t.bands){let t=uW(`rect`,{x:e.x,y:26,width:e.width,height:180,fill:`url(#${this.uid}-band)`,class:`sm-system-map__band sm-system-map__band--${e.tone}`});if(r){i.append(t);continue}let n=uW(`text`,{x:e.x+e.width/2,y:232,"text-anchor":`middle`,"font-size":sW,class:`sm-system-map__band-label sm-system-map__band-label--${e.tone}`});n.textContent=e.label,this.labels.push(n),i.append(this.target(e,e.name??e.label,{kind:`band`,key:e.key},t,uW(`rect`,{x:e.hitX,y:26,width:e.hitWidth,height:180,fill:`transparent`}),n))}let o=uW(`circle`,{cx:t.primaryCx,cy:120,r:t.primaryR,fill:`url(#${this.uid}-primary)`});i.append(r?o:this.target(e.primary.link,e.primary.name,{kind:`primary`},o));for(let e of t.bodies){if(!e.rings)continue;let t=e.r*(e.rings.inner+e.rings.outer)/2;i.append(uW(`ellipse`,{cx:e.cx,cy:e.cy,rx:t,ry:t*GU,transform:`rotate(${nW} ${e.cx} ${e.cy})`,fill:`none`,stroke:`#d9c89f`,"stroke-width":e.r*(e.rings.outer-e.rings.inner),opacity:.45}))}let s=new Map(t.moonZones.map(e=>[e.parent.id,e]));for(let e of t.bodies)i.append(this.body(e,s.get(e.id)));for(let e of t.moonZones)e.parent.grouped||this.stack(e)}drawAxis(e,t){for(let n of e.ticks){let r=t.xOf(n*e.unitKm),i=uW(`text`,{x:r,y:16,"text-anchor":`middle`,"font-size":16,fill:`currentColor`,opacity:.85});i.textContent=String(n),this.svg.append(uW(`line`,{x1:r,x2:r,y1:20,y2:212,stroke:`currentColor`,"stroke-width":.5,opacity:.12}),i)}let n=uW(`text`,{x:700,y:16,"text-anchor":`end`,"font-size":14,fill:`currentColor`,opacity:.65});n.textContent=e.axisLabel,this.svg.append(n)}body(e,t){let n=e.reference?uW(`circle`,{cx:e.cx,cy:e.cy,r:e.r+1,fill:`none`,stroke:e.color,"stroke-width":1.2,class:`sm-system-map__reference`}):uW(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color});if(this.background)return!t||!e.grouped?n:uW(`g`,{},n,...this.moonDots(t));let r={kind:`body`,id:e.id},i=this.highlight(r,uW(`circle`,{cx:e.cx,cy:e.cy,r:e.r+3.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),a=uW(`circle`,{cx:e.cx,cy:e.cy,r:e.r+16,fill:`transparent`});return!t||!e.grouped?this.target(e.link,e.name,r,i,n,a):this.target(e.link,e.name,r,this.highlight(r,this.zoneWash(t)),i,n,a,...this.moonDots(t),this.zoneHit(t))}stack(e){if(this.background){this.svg.append(...this.moonDots(e));return}let t=e.parent;if(e.perMoon){this.svg.append(...this.moonDots(e));for(let n of e.moons){let r={kind:`moon`,parent:t.id,id:n.id};this.svg.append(this.target(n.link,n.name,r,this.highlight(r,uW(`circle`,{cx:n.cx,cy:n.cy,r:n.r+2.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),uW(`rect`,{x:e.x,y:n.hitY,width:e.width,height:n.hitHeight,fill:`transparent`})))}return}let n={kind:`stack`,id:t.id},r=e.moons[0];this.svg.append(this.highlight(n,this.zoneWash(e)),...this.moonDots(e),this.target(t.satellitesLink,t.satellitesTab?`${t.name} · ${this.model.text.moons(t.satelliteCount??e.moons.length)}`:r.name,n,this.zoneHit(e)))}moonDots(e){return e.moons.map(e=>uW(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color}))}zoneWash(e){return uW(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:4,fill:`currentColor`,opacity:.1,"pointer-events":`none`})}zoneHit(e){return uW(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:`transparent`})}highlight(e,t){let n=JSON.stringify(e),r=this.highlights.get(n);return r?r.push(t):this.highlights.set(n,[t]),t.style.display=`none`,t}target(e,t,n,...r){let i=!!(e?.href||e?.onclick),a=e?.href?uW(`a`,{href:e.href,"aria-label":t}):i?uW(`g`,{role:`button`,tabindex:0,"aria-label":t,class:`sm-system-map__button`}):uW(`g`);if(a.append(...r),!i)return a;let o=JSON.stringify(n);return this.targets.set(o,a),a.addEventListener(`focus`,()=>this.setHover(n)),a.addEventListener(`blur`,()=>{dW(this.hover,n)&&this.setHover(null)}),a.addEventListener(`click`,e=>this.links.get(o)?.onclick?.(e)),e?.href||a.addEventListener(`keydown`,e=>{let t=e.key;t!==`Enter`&&t!==` `||(e.preventDefault(),a.dispatchEvent(new MouseEvent(`click`,{bubbles:!0})))}),a}setHover(e){if(dW(this.hover,e))return;for(let e of this.highlights.get(JSON.stringify(this.hover))??[])e.style.display=`none`;this.targets.get(JSON.stringify(this.hover))?.removeAttribute(`data-near`),this.hover=e;for(let t of this.highlights.get(JSON.stringify(e))??[])t.style.display=``;let t=this.targets.get(JSON.stringify(e));t?.setAttribute(`data-near`,``),this.svg.classList.toggle(`sm-system-map__svg--near`,!!t),this.placeTip()}hitAt(e,t){if(!this.placed||this.background)return null;let n=this.svg.getBoundingClientRect();if(!n.width||!n.height)return null;let r=(e-n.left)/n.width*720,i=(t-n.top)/n.height*240;return QU(this.placed,r,i)}fitLabels(){for(let e of this.labels){let t=0;e.setAttribute(`font-size`,String(sW));try{t=e.getComputedTextLength()}catch{}if(!t)continue;if(t>lW){let n=Math.max(cW,sW*lW/t);e.setAttribute(`font-size`,String(n)),t*=n/sW}let n=Number(e.dataset.centre??e.getAttribute(`x`));e.dataset.centre=String(n);let r=t/2,i=Math.min(Math.max(n,r+oW),Math.max(r,720-r-oW));e.setAttribute(`x`,String(i))}}placeTip(){let e=this.model&&this.placed&&!this.background?$U(this.model,this.placed,this.hover):null;if(this.tip.hidden=!e,!e)return;this.tipTitle.textContent=e.title,this.tipSub.textContent=e.sub?` · ${e.sub}`:``;let t=this.root.clientWidth,n=t/720;this.tip.style.maxWidth=`${Math.max(0,t-2*aW)}px`;let r=this.tip.offsetWidth/2,i=Math.min(Math.max(e.cx*n,r+aW),Math.max(r,t-r-aW));this.tip.style.left=`${i}px`,this.tip.style.top=`${Math.max(4,e.cy*n-iW)}px`}};function hW(e,t){return{planetId:e.primary.id,planetName:t,planetRadiusKm:e.primary.radius_km,planetColor:n_[e.primary.id]??`#cccccc`,moons:e.moons.map(e=>({id:e.id,name:e.id,aRp:e.a_rp,tiltDeg:e.tilt_deg,radiusKm:e.radius_km,color:n_[e.id]??e.color??`#cccccc`})),rings:e.rings?{innerRp:e.rings.inner_rp,outerRp:e.rings.outer_rp}:null,moonCount:e.moon_count}}var gW=14,_W=1.001,vW=.62,yW=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,5e3],bW=`0 96 320 144`,xW=`0 96 720 144`,SW=[1,100];function CW(e,t){let n=Math.min(...e.moons.map(e=>e.aRp)),r=Math.max(...e.moons.map(e=>e.aRp));for(let i of t)n=Math.min(n,i.innerKm/e.planetRadiusKm),r=Math.max(r,i.outerKm/e.planetRadiusKm);return!Number.isFinite(n)||!Number.isFinite(r)?SW:(r<=n&&(n/=2,r*=2),n=n<=_W?1:n,[n>1?10**(Math.log10(n)-.12):1,10**(Math.log10(r)+.12)])}function wW(e,t){let n=e.planetRadiusKm,r=CW(e,t.bands);return{primary:{id:e.planetId,name:e.planetName,radiusKm:n,color:e.planetColor,link:t.primaryLink},bodies:e.moons.map(e=>({id:e.id,name:e.name,aKm:e.aRp*n,tiltDeg:e.tiltDeg,radiusKm:e.radiusKm,color:e.color,link:t.moonLink?.(e)})),bands:t.bands,cloud:t.cloud,unitKm:n,domain:r,ticks:yW.filter(e=>e>=r[0]&&e<=r[1]),axisLabel:t.axisLabel,pxPerKm:gW/Math.max(...e.moons.map(e=>e.radiusKm).filter(e=>e>0),1),pxPerDeg:vW,text:t.text,backgroundView:t.wide?xW:bW,backgroundFit:t.wide?`fit`:`slice`}}var TW=224e-6,EW=1.8,DW=[.3,50],OW=[.3,1,3,10,30],kW=`#ffdd44`;function AW(e){let t=e.replace(/^\d+\s+/,``);return t===t.toUpperCase()&&/[A-Z]/.test(t)?t.charAt(0)+t.slice(1).toLowerCase():t}function jW(e){return e.color||n_[e.id]||`#cccccc`}function MW(e,t){let n=new Map,r=new Map(e.objects.map(e=>[e.id,e]));for(let i of e.objects){if(i.kind!==`moon`||!i.parent)continue;let e=n.get(i.parent)??{satellites:[],count:r.get(i.parent)?.moon_count,tab:!1};e.satellites.push({id:i.id,name:t(i),radiusKm:i.diameter_km/2,color:jW(i)}),e.tab||=!!i.link_parent,n.set(i.parent,e)}return n}function NW(e,t){let n=e.objects.find(e=>e.kind===`star`);if(!n)return null;let r=MW(e,t.name),i=t.stack??(e=>r.get(e.id)),a=e.objects.filter(e=>e.kind!==`moon`&&e.kind!==`star`&&(t.keep?.(e)??!0)).map(e=>{let n=i(e);return{id:e.id,name:t.name(e),aKm:e.a*ig,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:jW(e),rings:e.rings,satellites:n?.satellites,satelliteCount:n?.count,satellitesTab:n?.tab??!1,...t.links(e,n)}});return{primary:{id:n.id,name:t.name(n),radiusKm:n.diameter_km/2,color:kW,link:t.primaryLink},bodies:a,bands:e.belts.map(e=>({key:e.slug,innerKm:e.inner_au*ig,outerKm:e.outer_au*ig,tone:e.kind===`kuiper_belt`?`sky`:`muted`,...t.band(e)})),unitKm:ig,domain:DW,ticks:OW,axisLabel:t.text.axisAu,pxPerKm:TW,pxPerDeg:EW,text:t.text}}function PW(e){return{id:e.id,name:e.name??e.id,moon:e.moon??!1,aAu:e.aAu??0,tiltDeg:e.tiltDeg??0,radiusKm:e.radiusKm??0,color:e.color??n_[e.id]??`#cccccc`,parent:e.parent}}var FW=4,IW=10,LW={inner:[.6,5.5],outer:[4.5,55]},RW=[.1,.2,.3,.5,1,2,3,5,10,20,30,50,100,200,500,1e3],zW=.9,BW=.76;function VW(e,t){return Math.log(e/t[0])/Math.log(t[1]/t[0])}var HW=`naif-599`;function UW(e,t,n,r=[]){if(!n)return[];let i=new Set([...e.objects.map(e=>e.id),...r]);for(let e of Object.values(t)){i.add(e.primary.id);for(let t of e.moons)i.add(t.id)}return[...n].filter(e=>!i.has(e))}function WW(e){let t=e.type===`moon`,n=e.orbit?.parent_id,r=n===void 0||n===`naif-10`||n===`naif-0`?e.orbit?.a??e.orbit?.q:void 0;if(r===void 0&&!t)return null;let i=e.radii;return{id:e.id,name:AW(e.name??e.id),moon:t,aAu:r??0,tiltDeg:e.orbit?.i??0,radiusKm:i?(i.a+i.b+i.c)/3:(e.sbdb?.diameter??0)/2,color:n_[e.id]??e.sbdb?.color??e.color??`#cccccc`,parent:e.orbit?.parent_id}}var GW=.92;function KW(e,t){return e<t*GW?`inner`:`outer`}function qW(e,t){return Object.values(e).find(e=>e.primary.id===t)}function JW(e){return e.kind===`zone`?`zone:${e.zone}`:`${e.kind}:${e.id}`}var YW=class{targets=new Map;constructor(e,t,n){this.data=e,this.options=t,this.pick=n}has(e){return!this.options.bodies||this.options.bodies.has(e)}name(e,t){return this.options.names[e]??(t?AW(t):e)}named(e,t){return this.options.names[e]??t}link(e){return this.targets.set(JW(e),e),{onclick:()=>this.pick(e)}}body(e,t){return this.has(e)?this.link({kind:`body`,id:e,name:t}):void 0}stack(e,t){if(t&&!this.options.bodies)return t;let n=(qW(this.data.systems,e)?.moons??[]).filter(e=>this.has(e.id)).map(e=>({id:e.id,name:this.name(e.id),radiusKm:e.radius_km,color:n_[e.id]??e.color??`#cccccc`}));if(n.length)return n.sort((e,t)=>t.radiusKm-e.radiusKm),{satellites:n.slice(0,FW),count:n.length,tab:!0}}links(e,t,n){if(!n)return{link:this.body(e,t)};let r=()=>this.link({kind:`system`,id:e,name:t});if(this.options.grouping===`systems`)return{link:r(),grouped:!0};let i=n.satellites[0];return{link:this.body(e,t),satellitesLink:n.tab?r():this.body(i.id,i.name)}}built(e,t){return{model:e,targets:[...this.targets.values()],label:t}}};function XW(e,t,n,r){let i=new YW(e,t,r),a=e=>i.name(e.id,e.name),o=MW(e.solar,a),s=new Map(e.solar.objects.map(e=>[e.id,i.stack(e.id,o.get(e.id))])),c=e.solar.objects.find(e=>e.kind===`star`),l=e=>{let t=e===`inner`?n.zoneInner:n.zoneOuter;return{label:t,sub:``,...i.link({kind:`zone`,zone:e,name:t})}},u=NW(e.solar,{text:n,name:a,primaryLink:c&&i.body(c.id,a(c)),keep:e=>i.has(e.id)||!!s.get(e.id),stack:e=>s.get(e.id),links:(e,t)=>i.links(e.id,a(e),t),band:e=>t.zones===`belts`?{label:e.label}:l(e.kind===`kuiper_belt`?`outer`:`inner`)});if(!u)throw Error(`spacemap: the Solar System map names no Sun`);return i.built(u,n.solarSystem)}function ZW(e,t,n,r,i,a){let o=qW(e.systems,t);if(!o)throw Error(`spacemap: no planetary system around ${t}`);let s=new YW(e,r,a),c=hW(o,s.name(t,n[t]));c.moons=c.moons.filter(e=>s.has(e.id)).map(e=>({...e,name:s.name(e.id,n[e.id])}));let l=c.planetRadiusKm,u=c.rings?[{key:`rings`,label:i.rings,innerKm:c.rings.innerRp*l,outerKm:c.rings.outerRp*l,tone:`amber`}]:[],d=wW(c,{text:i,axisLabel:i.axisRadii,bands:u,primaryLink:s.body(t,c.planetName),moonLink:e=>s.body(e.id,e.name)});return d.ticks=d.ticks.filter(e=>VW(e,d.domain)<BW),s.built(d,c.planetName)}function QW(e,t,n,r,i){let a=new YW(e,n,i),{solar:o,extras:s}=e,c=o.objects.find(e=>e.kind===`star`),l=o.objects.find(e=>e.id===HW)?.a;if(!c||l===void 0)throw Error(`spacemap: the Solar System map names no Sun or no Jupiter`);let u=o.objects.filter(e=>e.kind===`dwarf`||e.kind===`asteroid`).map(e=>({id:e.id,name:a.name(e.id,e.name),aAu:e.a,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:jW(e)}));for(let e of s)e.moon||u.some(t=>t.id===e.id)||e.aAu>0&&u.push({...e,name:a.named(e.id,e.name)});let d=[];for(let e of u){if(KW(e.aAu,l)!==t)continue;let n={...e,aKm:e.aAu*ig},r=a.stack(e.id);if(r){d.push({...n,satellites:r.satellites,satelliteCount:r.count,satellitesTab:!0,...a.links(e.id,e.name,r)});continue}let i=s.filter(t=>t.moon&&t.parent===e.id&&a.has(t.id)).map(e=>{let t=a.named(e.id,e.name);return{...e,name:t,link:a.body(e.id,t)}});!a.has(e.id)&&!i.length||d.push({...n,link:a.body(e.id,e.name),satellites:i.length?i:void 0})}let[f,p]=LW[t],m=[Math.min(f,...d.map(e=>e.aKm/ig*.85)),Math.max(p,...d.map(e=>e.aKm/ig*1.15))],h=e=>e>=m[0]&&e<=m[1],g=IW/Math.max(...d.map(e=>e.radiusKm),1);for(let e of o.objects)e.kind!==`planet`||!h(e.a)||d.push({id:e.id,name:a.name(e.id,e.name),aKm:e.a*ig,tiltDeg:0,radiusKm:0,color:jW(e),reference:!0});let _=t===`inner`?r.zoneInner:r.zoneOuter;return a.built({primary:{id:c.id,name:a.name(c.id,c.name),radiusKm:c.diameter_km/2*TW/g,color:kW},bodies:d,bands:o.belts.filter(e=>h(e.inner_au)&&h(e.outer_au)).map(e=>({key:e.slug,label:e.label,innerKm:e.inner_au*ig,outerKm:e.outer_au*ig,tone:e.kind===`kuiper_belt`?`sky`:`muted`})),unitKm:ig,domain:m,ticks:RW.filter(e=>h(e)&&VW(e,m)<zW),axisLabel:r.axisAu,pxPerKm:g,pxPerDeg:EW,text:r},_)}var $W=new WeakMap,eG=.01;function tG(){let{messages:e,locale:t}=a(),n=new Intl.NumberFormat(t(),{maximumSignificantDigits:3}),r=new Intl.NumberFormat(t(),{style:`unit`,unit:`kilometer`,maximumSignificantDigits:3}),i=e.unit_symbol_astronomical_unit();return{primary:e.planetary_system_primary(),retrograde:e.planetary_system_retrograde(),moons:t=>e.system_map_moons({count:t}),distance:e=>{let t=e/ig;return t>0&&t<eG?r.format(e):`${n.format(t)} ${i}`},axisAu:e.system_map_axis_au(),solarSystem:e.system_map_solar_system(),rings:e.tab_rings(),axisRadii:e.planetary_system_axis_unit(),zoneInner:e.system_map_zone_inner(),zoneOuter:e.system_map_zone_outer()}}var nG=class{chart=new mW;listeners=new Map;view;bodies;names;grouping;zones;places;targets=[];extras=new Map;queue=Promise.resolve();disposed=!1;constructor(e={}){this.view=e.view??{kind:`solar-system`},this.bodies=e.bodies?new Set(e.bodies):null,this.names=e.names??{},this.grouping=e.grouping??`bodies`,this.zones=e.zones??`belts`,this.places=(e.places??[]).map(PW)}mount(e){e.append(this.chart.root)}remove(){this.disposed=!0,this.chart.destroy()}load(){return this.draw()}async setView(e){await this.draw(e)}getView(){return this.view}setBodies(e){let t=e?new Set(e):null;return this.draw(void 0,t).catch(()=>{})}getTargets(){return[...this.targets]}draw(e,t){let n=this.queue.then(()=>(t!==void 0&&(this.bodies=t),this.drawNow(e??this.view)));return this.queue=n.catch(()=>{}),n}async drawNow(e){let t;try{t=await this.build(e)}catch(e){let t=e instanceof Error?e:Error(String(e));throw this.disposed||this.emit(`error`,t),t}if(this.disposed)return;let n=JSON.stringify(e)!==JSON.stringify(this.view);this.view=e,this.targets=t.targets,this.chart.update(t.model,{ariaLabel:t.label}),n&&this.emit(`viewchange`,e)}async build(e){let[t,n]=await Promise.all([FU(),PU()]),r={bodies:this.bodies,names:this.names,grouping:this.grouping,zones:this.zones},i=tG(),a=e=>this.emit(`select`,e),o={solar:t,systems:n,extras:[]};switch(e.kind){case`solar-system`:return XW(o,r,i,a);case`system`:return ZW(o,e.id,await this.exportedNames(e.id,n),r,i,a);case`zone`:{let s=UW(t,n,this.bodies,this.places.map(e=>e.id)),c=(await Promise.all(s.map(e=>this.extra(e)))).filter(e=>e!==null),l=[...this.places,...c],u=UW(t,n,new Set(l.flatMap(e=>e.moon&&e.parent?[e.parent]:[])),l.map(e=>e.id)),d=await Promise.all(u.map(e=>this.extra(e))),f=[...l,...d.filter(e=>e!==null)];return QW({...o,extras:f},e.zone,r,i,a)}}}extra(e){let t=this.extras.get(e);return t||(t=hx(e,!1).then(t=>{if(!t.global)throw Error(`spacemap: no such body as ${e}`);return WW(t.global)}).catch(t=>(this.extras.delete(e),this.emit(`error`,t instanceof Error?t:Error(String(t))),null)),this.extras.set(e,t)),t}async exportedNames(e,t){if(![e,...(qW(t,e)?.moons??[]).map(e=>e.id)].some(t=>!(t in this.names)&&(t===e||!this.bodies||this.bodies.has(t))))return{};try{let{global:t,localized:n}=await hx(e,!0,a().locale()),r={};for(let e of t?.notable_moons??[])e.id&&(r[e.id]=e.name);Object.assign(r,n?.notable_moon_names);let i=n?.name??t?.name;return i&&(r[e]=i),r}catch{return{}}}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});$W.set(n,t);let r=this.on(e,n);return r}off(e,t){let n=this.listeners.get(e);if(n){n.delete(t);for(let e of n)$W.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}},rG=Object.fromEntries(xn.map(e=>[e,bn[e].label]));function iG(e,t){let n=e.credits.orbitSourceParents.get(t);if(!n)return!0;let r=e.visibility.focusedSystemId;for(let t of n)if(e.bodies.isInSystem(t,r))return!0;return!1}function aG(e){return xn.filter(t=>e.credits.orbitSources.has(t)).filter(t=>!bn[t].scoped||iG(e,t)).map(e=>({source:e,info:bn[e]}))}function oG(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function sG(e,t=rG){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(aG(e).map(({source:e})=>t[e]))],i=new Set;for(let t of oG(e,n.imagery.values()))i.add(t.organisation);let a=e.visibility.focusedBodyId,o=a?n.model.get(a):void 0;return o&&i.add(o.organisation),{orbits:r,imagery:[...i].sort()}}var cG=`https://spacemap.co`,lG=`https://spacemap.co/credits`;function uG(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function dG(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function fG(e,t,n){let r=document.createElement(`a`);return r.href=e,r.target=`_blank`,r.rel=`noopener noreferrer`,r.textContent=t,n&&(r.className=n),r}var pG=class{stop=null;onAdd(e){let t=uG(),n=dG(),r=dG();return t.append(fG(cG,`spacemap`,`sm-attribution__home`),n,r,fG(lG,a().messages.credits_see_all())),this.stop=lt(()=>{st(()=>{let t=sG(e.ctx);mG(n,a().messages.attribution_orbits(),t.orbits),mG(r,a().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function mG(e,t,n){if(e.hidden=n.length===0,e.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${t}:`,e.replaceChildren(r,` ${n.join(` · `)}`)}var hG=class{off=null;onAdd(e){let t=uG(),n=dG();t.append(fG(cG,`spacemap`,`sm-attribution__home`),n,fG(lG,a().messages.credits_see_all()));let r=()=>{let t=[...new Set(e.credits.map(e=>e.organisation))].filter(Boolean);if(n.hidden=t.length===0,n.hidden)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`,n.replaceChildren(r,` ${t.join(` · `)}`)};return r(),this.off=e.on(`layerschange`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}};function gG(e){if(e)try{let t=typeof window<`u`?window.location.href:`https://spacemap.co`,{protocol:n}=new URL(e,t);return n===`http:`||n===`https:`?e:void 0}catch{return}}var _G=class{off=null;onAdd(e){let t=uG(),n=dG();t.append(fG(cG,`spacemap`,`sm-attribution__home`),n,fG(lG,a().messages.credits_see_all()));let r=()=>{let t=e.getCurrent();if(n.hidden=!t?.credit,!t?.credit)return;let r=document.createElement(`span`);r.className=`sm-attribution__label`,r.textContent=`${a().messages.attribution_imagery()}:`;let i=gG(t.credit_url),o=i?fG(i,t.credit):t.credit;n.replaceChildren(r,` `,o)};return r(),this.off=e.on(`load`,r),t}onRemove(){this.off?.(),this.off=null}getDefaultPosition(){return`bottom-right`}},vG=Math.PI/180,yG=Math.cos(ag*vG),bG=Math.sin(ag*vG);function xG(e){return e}function SG(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>EG(t,e)}}function CG(e){return{body:e.body??`naif-10`,offsetKm:t=>AF(e.elements,t)?.r??null}}function wG(e,t){let n=ng(e,t);return n.error!==$h.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:p_,offsetKm:e=>{if(n.error!==$h.None)return null;let t=vg(n,e);return t&&TG(t[0],t[1],t[2])}}}function TG(e,t,n){return[e,t*yG+n*bG,-t*bG+n*yG]}function EG(e,t){let n=e.length;if(n<2||t<e[0].jd||t>e[n-1].jd)return null;let r=0,i=n-1;for(;r<i;){let n=r+i>>1;e[n].jd<t?r=n+1:i=n}let a=Math.max(r,1),o=e[a-1],s=e[a],c=s.jd-o.jd;if(c<=0)return s.km;let l=(t-o.jd)/c,u=l*l,d=u*l,f=2*d-3*u+1,p=d-2*u+l,m=-2*d+3*u,h=d-u,g=[0,0,0];for(let t=0;t<3;t++){let n=o.km[t],r=s.km[t],i=DG(e,a-1,t),l=DG(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function DG(e,t,n){let r=e[t-1]??e[t],i=e[t+1]??e[t],a=i.jd-r.jd;return a<=0?0:(i.km[n]-r.km[n])/a}function OG(e){return e/ig}var kG=null,AG=Promise.resolve();function jG(e){let t=AG.then(e,e);return AG=t.catch(()=>{}),t}async function MG(e){let t=Ng(e),n=await Rb();if(!kG){let e=zb(n);e.size>0&&(kG=new Jb(e))}try{await kG?.ensure(t).done}catch(e){throw kG=null,e}return{jd:t,metadata:n,chebyshev:kG}}function NG(e,t){return!(e!==void 0&&t-2451545<e)}async function PG(e,{jd:t,metadata:n}){let r=n.position.zones.moons,i=r&&Ab(r);if(!i)return null;let a=await lb(`moons`,null,0,wb(i)?String(Eb(i,t)):null);for(let t=0;t<a.rowCount;t++)if(Sh(a,t)===e)return e_(a,t,new Map,`naif`);return null}function FG(e,t){return!NG(e.visibleFromDays,t)||t<e.validityStart||t>e.validityEnd?null:e.satrec?bg(e.satrec,t):e.q==null?e.a===0?[0,0,0]:Jv(e,t):Xv(e,t)}async function IG(e,t){let{jd:n}=t;if(t.chebyshev?.has(e)){let r=t.chebyshev.body(e,n);if(r&&!NG(r.visibleFromDays,n))return null;let i=r&&py(r,n);if(i){let{radiusKm:e,objectType:t}=r;return{data:{radiusKm:e,objectType:t,orbitalSource:U.SPICE},parentId:`naif-${r.parentId}`,offset:i}}if(e.startsWith(`naif-`))return null}let r=(e.startsWith(`naif-`)?await PG(e,t):null)??Sx(e,await hx(e,!1)),i=r&&FG(r,n);return i?{data:r,parentId:r.parentId,offset:i}:null}async function LG(e,t,n=new Set){if(n.has(e))return null;let r=await IG(e,t);if(!r)return null;if(r.parentId===`naif-0`)return{data:r.data,centre:r.offset};let i=await LG(r.parentId,t,new Set(n).add(e));if(!i)return null;let[a,o,s]=i.centre;return{data:r.data,centre:[a+r.offset[0],o+r.offset[1],s+r.offset[2]]}}async function RG(e){let[t]=await Promise.all([hx(e,!1),X_()]),n=t.global?.orientation,r=t.global?.nut_prec,i=/^naif-(-?\d+)$/.exec(e),a=i?Q_(Z_(parseInt(i[1],10))):void 0;return{orientation:n,nutPrec:r&&a?{...r,angles:a}:void 0}}async function zG(e,t){let n=await LG(e.body,t);if(!n)return null;let r=`latitude`in e?await RG(e.body):{};return yR(e,{data:n.data,...r},n.centre,t.jd)}function BG(e,t,n){return jG(async()=>{let r=await MG(n),i=await zG(e,r),a=i&&await zG(t,r);return i&&a?SR([a[0]-i[0],a[1]-i[1],a[2]-i[2]]):null})}async function VG(e,t,n){let r=await BG(e,t,n);return r&&Math.hypot(...r)}function HG(e,t){return jG(async()=>{if(e===`naif-10`)return null;let n=await MG(t),r=await LG(e,n),i=r&&await LG(`naif-10`,n);return!r||!i?null:EV({data:r.data,...await RG(e)},r.centre,i.centre,n.jd)})}var UG=null;function WG(e=K_){return UG||(UG=(async()=>{let t=await e(`${Kt()}/v1/panoramas.json`);if(!t.ok)throw Error(`Failed to load panoramas.json: ${t.status}`);return(await t.json()).bodies??[]})(),UG.catch(()=>UG=null),UG)}async function GG(e){return(await hx(e,!1)).global?.panoramas??[]}async function KG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=XG(t);ZG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new GV(l);if(d.mount(u),d.webglError)throw d.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new pG,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.open(),d.applyInitialView(),await Dz(),d}async function qG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=XG(t);ZG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new YH(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new hG,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function JG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=XG(t);ZG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new NU(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new _G,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function YG(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,events:s,...c}=e,l=XG(t);ZG({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let u=new nG(c);u.mount(l);for(let[e,t]of Object.entries(s??{}))u.on(e,t);try{await u.load()}catch(e){throw u.remove(),e}return u}function XG(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`spacemap: no element matches ${e}`);return t}function ZG(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.locale!==void 0&&(t.locale=()=>e.locale),e.messages!==void 0&&(t.messages=e.messages),e.includeNonCommercial&&(t.textures=`non-commercial`),i(t)}return e.AttributionControl=pG,e.FlatAttributionControl=hG,e.FlatMap=YH,e.GestureHandler=OV,e.MAP_LAYERS=gv,e.PROJECTION_IDS=WB,e.PanoramaAttributionControl=_G,e.PanoramaView=NU,e.SpaceMap=GV,e.SystemMap=nG,e.Viewport=PH,e.bearingDeg=mU,e.boxRing=fV,e.circlePoints=Kz,e.configureHost=i,e.createFlatMap=qG,e.createMap=KG,e.createPanorama=JG,e.createProjection=GB,e.createSystemMap=YG,e.dateToJD=Ng,e.defaultSceneSettings=Ax,e.distanceKm=VG,e.elements=CG,e.fetchPanoramaIndex=WG,e.fetchPanoramas=GG,e.findPanorama=uU,e.fixed=xG,e.graticule=hV,e.groundDistanceM=pU,e.isViewable=mx,e.jdToDate=Pg,e.kmToAu=OG,e.neighboursOf=dU,e.offsetKm=BG,e.panoramaAt=cU,e.pathFor=cV,e.planeBasis=Wz,e.projectionAspect=uB,e.samples=SG,e.smallCircle=pV,e.subsolarPoint=HG,e.tle=wG,e})({});
|
|
5557
5568
|
//# sourceMappingURL=spacemap.iife.js.map
|
|
5558
|
-
(function(){if(typeof document==='undefined')return;var s=document.createElement('style');s.textContent=".scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none}:where(.sm-map){width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-system-map{border-radius:var(--sm-system-map-radius,6px);background:var(--sm-system-map-background,#ffffff0d);width:100%;color:var(--sm-system-map-ink,#ffffff9e);position:relative;overflow:hidden}.sm-system-map--background{pointer-events:none;background:0 0;border-radius:0;height:100%}.sm-system-map__svg{touch-action:pan-y;width:100%;height:auto;display:block}.sm-system-map--background .sm-system-map__svg{height:100%}.sm-system-map__svg--near :is(a,.sm-system-map__button):not([data-near]){pointer-events:none}.sm-system-map__button{cursor:pointer}.sm-system-map__button:focus{outline:none}.sm-system-map__reference{opacity:.6}.sm-system-map__band--muted{color:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band--sky{color:var(--sm-system-map-sky,oklch(74.6% .16 232.661/.7))}.sm-system-map__band--amber{color:var(--sm-system-map-amber,oklch(92.4% .12 95.746/.8))}.sm-system-map__band-label{font-weight:600}.sm-system-map__band-label--muted{fill:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band-label--sky{fill:var(--sm-system-map-sky-label,oklch(74.6% .16 232.661))}.sm-system-map__band-label--amber{fill:var(--sm-system-map-amber-label,oklch(92.4% .12 95.746/.9))}.sm-system-map__tip{z-index:10;background:var(--sm-system-map-tip-background,#0a0c14e6);width:max-content;color:var(--sm-system-map-tip-ink,#fffffff2);white-space:nowrap;pointer-events:none;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:.25rem;padding:.25rem .5rem;font-size:.75rem;line-height:1.33333;position:absolute;transform:translate(-50%);box-shadow:0 1px 3px #0000001a,0 1px 2px -1px #0000001a}.sm-system-map__tip[hidden]{display:none}.sm-system-map__tip-title{font-weight:500}.sm-system-map__tip-sub{color:var(--sm-system-map-ink,#ffffff9e)}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/.scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none}:where(.sm-map){width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-system-map{border-radius:var(--sm-system-map-radius,6px);background:var(--sm-system-map-background,#ffffff0d);width:100%;color:var(--sm-system-map-ink,#ffffff9e);position:relative;overflow:hidden}.sm-system-map--background{pointer-events:none;background:0 0;border-radius:0;height:100%}.sm-system-map__svg{touch-action:pan-y;width:100%;height:auto;display:block}.sm-system-map--background .sm-system-map__svg{height:100%}.sm-system-map__svg--near :is(a,.sm-system-map__button):not([data-near]){pointer-events:none}.sm-system-map__button{cursor:pointer}.sm-system-map__button:focus{outline:none}.sm-system-map__reference{opacity:.6}.sm-system-map__band--muted{color:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band--sky{color:var(--sm-system-map-sky,oklch(74.6% .16 232.661/.7))}.sm-system-map__band--amber{color:var(--sm-system-map-amber,oklch(92.4% .12 95.746/.8))}.sm-system-map__band-label{font-weight:600}.sm-system-map__band-label--muted{fill:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band-label--sky{fill:var(--sm-system-map-sky-label,oklch(74.6% .16 232.661))}.sm-system-map__band-label--amber{fill:var(--sm-system-map-amber-label,oklch(92.4% .12 95.746/.9))}.sm-system-map__tip{z-index:10;background:var(--sm-system-map-tip-background,#0a0c14e6);width:max-content;color:var(--sm-system-map-tip-ink,#fffffff2);white-space:nowrap;pointer-events:none;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:.25rem;padding:.25rem .5rem;font-size:.75rem;line-height:1.33333;position:absolute;transform:translate(-50%);box-shadow:0 1px 3px #0000001a,0 1px 2px -1px #0000001a}.sm-system-map__tip[hidden]{display:none}.sm-system-map__tip-title{font-weight:500}.sm-system-map__tip-sub{color:var(--sm-system-map-ink,#ffffff9e)}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/";document.head.appendChild(s);})();
|
|
5569
|
+
(function(){if(typeof document==='undefined')return;var s=document.createElement('style');s.textContent=".scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-overlay--no-halos .scene-label__halo{visibility:hidden}.scene-overlay--no-halos .scene-label{pointer-events:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none}:where(.sm-map){width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-system-map{border-radius:var(--sm-system-map-radius,6px);background:var(--sm-system-map-background,#ffffff0d);width:100%;color:var(--sm-system-map-ink,#ffffff9e);position:relative;overflow:hidden}.sm-system-map--background{pointer-events:none;background:0 0;border-radius:0;height:100%}.sm-system-map__svg{touch-action:pan-y;width:100%;height:auto;display:block}.sm-system-map--background .sm-system-map__svg{height:100%}.sm-system-map__svg--near :is(a,.sm-system-map__button):not([data-near]){pointer-events:none}.sm-system-map__button{cursor:pointer}.sm-system-map__button:focus{outline:none}.sm-system-map__reference{opacity:.6}.sm-system-map__band--muted{color:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band--sky{color:var(--sm-system-map-sky,oklch(74.6% .16 232.661/.7))}.sm-system-map__band--amber{color:var(--sm-system-map-amber,oklch(92.4% .12 95.746/.8))}.sm-system-map__band-label{font-weight:600}.sm-system-map__band-label--muted{fill:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band-label--sky{fill:var(--sm-system-map-sky-label,oklch(74.6% .16 232.661))}.sm-system-map__band-label--amber{fill:var(--sm-system-map-amber-label,oklch(92.4% .12 95.746/.9))}.sm-system-map__tip{z-index:10;background:var(--sm-system-map-tip-background,#0a0c14e6);width:max-content;color:var(--sm-system-map-tip-ink,#fffffff2);white-space:nowrap;pointer-events:none;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:.25rem;padding:.25rem .5rem;font-size:.75rem;line-height:1.33333;position:absolute;transform:translate(-50%);box-shadow:0 1px 3px #0000001a,0 1px 2px -1px #0000001a}.sm-system-map__tip[hidden]{display:none}.sm-system-map__tip-title{font-weight:500}.sm-system-map__tip-sub{color:var(--sm-system-map-ink,#ffffff9e)}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/.scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-overlay--no-halos .scene-label__halo{visibility:hidden}.scene-overlay--no-halos .scene-label{pointer-events:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none}:where(.sm-map){width:100%;height:100%;position:relative}.sm-map__canvas{pointer-events:auto;touch-action:none;width:100%;height:100%;display:block}.sm-map__canvas:focus-visible{outline:2px solid var(--ring,Highlight)}.sm-map .scene-overlay{pointer-events:none;z-index:0;position:absolute;inset:0}.sm-flat{touch-action:none;background:#05070e;width:100%;height:100%;position:relative;overflow:hidden}.sm-flat__raster,.sm-flat__vector,.sm-flat__markers{width:100%;height:100%;position:absolute;inset:0}.sm-flat__raster{display:block}.sm-flat__vector,.sm-flat__markers{pointer-events:none}.sm-flat--interactive{cursor:grab}.sm-flat--cooperative{touch-action:pan-x pan-y}.sm-flat--dragging{cursor:grabbing}.sm-flat__graticule{fill:none;stroke:#ffffff47;stroke-width:1px}.sm-flat__frame{fill:none;stroke:#ffffff73;stroke-width:1px}.sm-flat__feature-dot{fill:#fffc}.sm-flat__feature-label{fill:#ffffffd9;paint-order:stroke;stroke:#000000a6;stroke-width:2.5px;font:10px/1 system-ui,sans-serif}.sm-flat__marker-dot{background:#4ea3ff;border:2px solid #fff;border-radius:50%;width:10px;height:10px;box-shadow:0 0 0 1px #00000073}.sm-system-map{border-radius:var(--sm-system-map-radius,6px);background:var(--sm-system-map-background,#ffffff0d);width:100%;color:var(--sm-system-map-ink,#ffffff9e);position:relative;overflow:hidden}.sm-system-map--background{pointer-events:none;background:0 0;border-radius:0;height:100%}.sm-system-map__svg{touch-action:pan-y;width:100%;height:auto;display:block}.sm-system-map--background .sm-system-map__svg{height:100%}.sm-system-map__svg--near :is(a,.sm-system-map__button):not([data-near]){pointer-events:none}.sm-system-map__button{cursor:pointer}.sm-system-map__button:focus{outline:none}.sm-system-map__reference{opacity:.6}.sm-system-map__band--muted{color:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band--sky{color:var(--sm-system-map-sky,oklch(74.6% .16 232.661/.7))}.sm-system-map__band--amber{color:var(--sm-system-map-amber,oklch(92.4% .12 95.746/.8))}.sm-system-map__band-label{font-weight:600}.sm-system-map__band-label--muted{fill:var(--sm-system-map-ink,#ffffff9e)}.sm-system-map__band-label--sky{fill:var(--sm-system-map-sky-label,oklch(74.6% .16 232.661))}.sm-system-map__band-label--amber{fill:var(--sm-system-map-amber-label,oklch(92.4% .12 95.746/.9))}.sm-system-map__tip{z-index:10;background:var(--sm-system-map-tip-background,#0a0c14e6);width:max-content;color:var(--sm-system-map-tip-ink,#fffffff2);white-space:nowrap;pointer-events:none;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:.25rem;padding:.25rem .5rem;font-size:.75rem;line-height:1.33333;position:absolute;transform:translate(-50%);box-shadow:0 1px 3px #0000001a,0 1px 2px -1px #0000001a}.sm-system-map__tip[hidden]{display:none}.sm-system-map__tip-title{font-weight:500}.sm-system-map__tip-sub{color:var(--sm-system-map-ink,#ffffff9e)}.sm-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/";document.head.appendChild(s);})();
|