spacemap 0.1.16 → 0.1.18

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.
@@ -4048,12 +4048,12 @@ void main() {
4048
4048
  }
4049
4049
 
4050
4050
  }`,gh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Xc(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 Eu({vertexShader:mh,fragmentShader:hh,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ws(new pu(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},_h=class extends Ci{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 gh,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new q,C=null,w=new xd;w.viewport=new ga;let T=new xd;T.viewport=new ga;let E=[w,T],D=new Id,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 Xa,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Xa,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Xa,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,ie.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&&K(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&K(`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?sr:or,a=_.stencil?er:Yn);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 va(d.textureWidth,d.textureHeight,{format:ar,type:Wn,depthTexture:new Jc(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 va(f.framebufferWidth,f.framebufferHeight,{format:ar,type:Wn,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),ie.setContext(r),ie.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 N=new J,P=new J;function ee(e,t,n){N.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(n.matrixWorld);let r=N.distanceTo(P),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 te(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;te(D,i);for(let e=0;e<a.length;e++)te(a[e],i);a.length===2?ee(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),ne(e,D,i)};function ne(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=Di*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 F=null;function re(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 xd,o.layers.enable(n),o.viewport=new ga,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 Xc,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)}F&&F(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ie=new uf;ie.setAnimationLoop(re),this.setAnimationLoop=function(e){F=e},this.dispose=function(){}}},vh=new Aa,yh=new Y;function bh(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,Su(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,vh.copy(o),vh.x*=-1,vh.y*=-1,vh.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(vh.y*=-1,vh.z*=-1),e.envMapRotation.value.setFromMatrix4(yh.makeRotationFromEuler(vh)),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 xh(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 yi(`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?K(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):K(`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 Sh=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]),Ch=null;function wh(){return Ch===null&&(Ch=new ic(Sh,16,16,ur,Zn),Ch.name=`DFG_LUT`,Ch.minFilter=Vn,Ch.magFilter=Vn,Ch.wrapS=In,Ch.wrapT=In,Ch.generateMipmaps=!1,Ch.needsUpdate=!0),Ch}var Th=class{constructor(e={}){let{canvas:t=mi(),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=Wn}=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([fr,dr,lr]),g=new Set([Wn,Yn,qn,er,Qn,$n]),_=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=ii;let E=0,D=0,O=null,k=-1,A=null,j=new ga,M=new ga,N=null,P=new X(0),ee=0,te=t.width,ne=t.height,F=1,re=null,ie=null,I=new ga(0,0,te,ne),L=new ga(0,0,te,ne),ae=!1,oe=new wc,se=!1,ce=!1,le=new Y,ue=new J,de=new ga,fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},pe=!1;function me(){return O===null?F:1}let R=n;function he(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`,Ie,!1),t.addEventListener(`webglcontextrestored`,Le,!1),t.addEventListener(`webglcontextcreationerror`,Re,!1),R===null){let t=`webgl2`;if(R=he(t,e),R===null)throw he(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw yi(`WebGLRenderer: `+e.message),e}let z,ge,B,_e,V,H,ve,ye,be,xe,Se,Ce,we,U,Te,Ee,De,Oe,ke,Ae,je,Me,Ne;function Pe(){z=new Wf(R),z.init(),je=new ph(R,z),ge=new bf(R,z,e,je),B=new dh(R,z),ge.reversedDepthBuffer&&d&&B.buffers.depth.setReversed(!0),_e=new qf(R),V=new Gm,H=new fh(R,z,B,V,ge,je,_e),ve=new Uf(w),ye=new df(R),Me=new vf(R,ye),be=new Gf(R,ye,_e,Me),xe=new Yf(R,be,ye,Me,_e),Oe=new Jf(R,ge,H),Te=new xf(V),Se=new Wm(w,ve,z,ge,Me,Te),Ce=new bh(w,V),we=new Ym,U=new nh(z),De=new _f(w,ve,B,xe,p,s),Ee=new uh(w,xe,ge),Ne=new xh(R,_e,ge,B),ke=new yf(R,z,_e),Ae=new Kf(R,z,_e),_e.programs=Se.programs,w.capabilities=ge,w.extensions=z,w.properties=V,w.renderLists=we,w.shadowMap=Ee,w.state=B,w.info=_e}Pe(),m!==1009&&(C=new Zf(m,t.width,t.height,r,i));let Fe=new _h(w,R);this.xr=Fe,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){let e=z.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=z.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(e){e!==void 0&&(F=e,this.setSize(te,ne,!1))},this.getSize=function(e){return e.set(te,ne)},this.setSize=function(e,n,r=!0){if(Fe.isPresenting){K(`WebGLRenderer: Can't change size while VR device is presenting.`);return}te=e,ne=n,t.width=Math.floor(e*F),t.height=Math.floor(n*F),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(te*F,ne*F).floor()},this.setDrawingBufferSize=function(e,n,r){te=e,ne=n,F=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(I)},this.setViewport=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),B.viewport(j.copy(I).multiplyScalar(F).round())},this.getScissor=function(e){return e.copy(L)},this.setScissor=function(e,t,n,r){e.isVector4?L.set(e.x,e.y,e.z,e.w):L.set(e,t,n,r),B.scissor(M.copy(L).multiplyScalar(F).round())},this.getScissorTest=function(){return ae},this.setScissorTest=function(e){B.setScissorTest(ae=e)},this.setOpaqueSort=function(e){re=e},this.setTransparentSort=function(e){ie=e},this.getClearColor=function(e){return e.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.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=De.getClearColor(),r=De.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,R.clearBufferuiv(R.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,R.clearBufferiv(R.COLOR,0,v))}else r|=R.COLOR_BUFFER_BIT}t&&(r|=R.DEPTH_BUFFER_BIT),n&&(r|=R.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&R.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`,Ie,!1),t.removeEventListener(`webglcontextrestored`,Le,!1),t.removeEventListener(`webglcontextcreationerror`,Re,!1),De.dispose(),we.dispose(),U.dispose(),V.dispose(),ve.dispose(),xe.dispose(),Me.dispose(),Ne.dispose(),Se.dispose(),Fe.dispose(),Fe.removeEventListener(`sessionstart`,Ge),Fe.removeEventListener(`sessionend`,Ke),qe.stop()};function Ie(e){e.preventDefault(),_i(`WebGLRenderer: Context Lost.`),T=!0}function Le(){_i(`WebGLRenderer: Context Restored.`),T=!1;let e=_e.autoReset,t=Ee.enabled,n=Ee.autoUpdate,r=Ee.needsUpdate,i=Ee.type;Pe(),_e.autoReset=e,Ee.enabled=t,Ee.autoUpdate=n,Ee.needsUpdate=r,Ee.type=i}function Re(e){yi(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function ze(e){let t=e.target;t.removeEventListener(`dispose`,ze),Be(t)}function Be(e){Ve(e),V.remove(e)}function Ve(e){let t=V.get(e).programs;t!==void 0&&(t.forEach(function(e){Se.releaseProgram(e)}),e.isShaderMaterial&&Se.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=fe);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=nt(e,t,n,r,i);B.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=be.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;Me.setup(i,r,s,n,c);let h,g=ke;if(c!==null&&(h=ye.get(c),g=Ae,g.setIndex(h)),i.isMesh)r.wireframe===!0?(B.setLineWidth(r.wireframeLinewidth*me()),g.setMode(R.LINES)):g.setMode(R.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),B.setLineWidth(e*me()),i.isLineSegments?g.setMode(R.LINES):i.isLineLoop?g.setMode(R.LINE_LOOP):g.setMode(R.LINE_STRIP)}else i.isPoints?g.setMode(R.POINTS):i.isSprite&&g.setMode(R.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)bi(`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(z.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?ye.get(c).bytesPerElement:1,o=V.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(R,`_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 He(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,$e(e,t,n),e.side=0,e.needsUpdate=!0,$e(e,t,n),e.side=2):$e(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),b=U.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];He(a,n,e),r.add(a)}else He(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){V.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}z.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Ue=null;function We(e){Ue&&Ue(e)}function Ge(){qe.stop()}function Ke(){qe.start()}let qe=new uf;qe.setAnimationLoop(We),typeof self<`u`&&qe.setContext(self),this.setAnimationLoop=function(e){Ue=e,Fe.setAnimationLoop(e),e===null?qe.stop():qe.start()},Fe.addEventListener(`sessionstart`,Ge),Fe.addEventListener(`sessionend`,Ke),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){yi(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(T===!0)return;let n=Fe.enabled===!0&&Fe.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(),Fe.enabled===!0&&Fe.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Fe.cameraAutoUpdate===!0&&Fe.updateCamera(t),t=Fe.getCamera()),e.isScene===!0&&e.onBeforeRender(w,e,t,O),b=U.get(e,S.length),b.init(t),S.push(b),le.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),oe.setFromProjectionMatrix(le,ui,t.reversedDepth),ce=this.localClippingEnabled,se=Te.init(this.clippingPlanes,ce),y=we.get(e,x.length),y.init(),x.push(y),Fe.enabled===!0&&Fe.isPresenting===!0){let e=w.xr.getDepthSensingMesh();e!==null&&Je(e,t,-1/0,w.sortObjects)}Je(e,t,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(re,ie),pe=Fe.enabled===!1||Fe.isPresenting===!1||Fe.hasDepthSensing()===!1,pe&&De.addToRenderList(y,e),this.info.render.frame++,se===!0&&Te.beginShadows();let i=b.state.shadowsArray;if(Ee.render(i,e,t),se===!0&&Te.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];Xe(n,r,e,a)}pe&&De.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];Ye(y,e,n,n.viewport)}}else r.length>0&&Xe(n,r,e,t),pe&&De.render(e),Ye(y,e,t)}O!==null&&D===0&&(H.updateMultisampleRenderTarget(O),H.updateRenderTargetMipmap(O)),r&&C.end(w),e.isScene===!0&&e.onAfterRender(w,e,t),Me.resetDefaultState(),k=-1,A=null,S.pop(),S.length>0?(b=S[S.length-1],se===!0&&Te.setGlobalState(w.clippingPlanes,b.state.camera)):b=null,x.pop(),y=x.length>0?x[x.length-1]:null};function Je(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||oe.intersectsSprite(e)){r&&de.setFromMatrixPosition(e.matrixWorld).applyMatrix4(le);let t=xe.update(e),i=e.material;i.visible&&y.push(e,t,i,n,de.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||oe.intersectsObject(e))){let t=xe.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),de.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),de.copy(e.boundingSphere.center)),de.applyMatrix4(e.matrixWorld).applyMatrix4(le)),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,de.z,o)}}else i.visible&&y.push(e,t,i,n,de.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Je(i[e],t,n,r)}function Ye(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;b.setupLightsView(n),se===!0&&Te.setGlobalState(w.clippingPlanes,n),r&&B.viewport(j.copy(r)),i.length>0&&Ze(i,t,n),a.length>0&&Ze(a,t,n),o.length>0&&Ze(o,t,n),B.buffers.depth.setTest(!0),B.buffers.depth.setMask(!0),B.buffers.color.setMask(!0),B.setPolygonOffset(!1)}function Xe(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[r.id]===void 0){let e=z.has(`EXT_color_buffer_half_float`)||z.has(`EXT_color_buffer_float`);b.state.transmissionRenderTarget[r.id]=new va(1,1,{generateMipmaps:!0,type:e?Zn:Wn,minFilter:Un,samples:Math.max(4,ge.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:aa.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(P),ee=w.getClearAlpha(),ee<1&&w.setClearColor(16777215,.5),w.clear(),pe&&De.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),se===!0&&Te.setGlobalState(w.clippingPlanes,r),Ze(e,n,r),H.updateMultisampleRenderTarget(a),H.updateRenderTargetMipmap(a),z.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,Qe(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(H.updateMultisampleRenderTarget(a),H.updateRenderTargetMipmap(a))}w.setRenderTarget(s,c,l),w.setClearColor(P,ee),d!==void 0&&(r.viewport=d),w.toneMapping=u}function Ze(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)&&Qe(o,t,n,s,l,c)}}function Qe(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 $e(e,t,n){t.isScene!==!0&&(t=fe);let r=V.get(e),i=b.state.lights,a=b.state.shadowsArray,o=i.state.version,s=Se.getParameters(e,i.state,a,t,n),c=Se.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=ve.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,ze),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return tt(e,s),d}else s.uniforms=Se.getUniforms(e),e.onBeforeCompile(s,w),d=Se.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=Te.uniform),tt(e,s),r.needsLights=it(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 et(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=im.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function tt(e,t){let n=V.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 nt(e,t,n,r,i){t.isScene!==!0&&(t=fe),H.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:ai,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=ve.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=V.get(r),y=b.state.lights;if(se===!0&&(ce===!0||e!==A)){let t=e===A&&r.id===k;Te.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!==Te.numPlanes||v.numIntersection!==Te.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=$e(r,t,i));let C=!1,T=!1,E=!1,D=S.getUniforms(),j=v.uniforms;if(B.useProgram(S.program)&&(C=!0,T=!0,E=!0),r.id!==k&&(k=r.id,T=!0),C||A!==e){B.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),D.setValue(R,`projectionMatrix`,e.projectionMatrix),D.setValue(R,`viewMatrix`,e.matrixWorldInverse);let t=D.map.cameraPosition;t!==void 0&&t.setValue(R,ue.setFromMatrixPosition(e.matrixWorld)),ge.logarithmicDepthBuffer&&D.setValue(R,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&D.setValue(R,`isOrthographic`,e.isOrthographicCamera===!0),A!==e&&(A=e,T=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&D.setValue(R,`directionalShadowMap`,y.state.directionalShadowMap,H),y.state.spotShadowMap.length>0&&D.setValue(R,`spotShadowMap`,y.state.spotShadowMap,H),y.state.pointShadowMap.length>0&&D.setValue(R,`pointShadowMap`,y.state.pointShadowMap,H)),i.isSkinnedMesh){D.setOptional(R,i,`bindMatrix`),D.setOptional(R,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),D.setValue(R,`boneTexture`,e.boneTexture,H))}i.isBatchedMesh&&(D.setOptional(R,i,`batchingTexture`),D.setValue(R,`batchingTexture`,i._matricesTexture,H),D.setOptional(R,i,`batchingIdTexture`),D.setValue(R,`batchingIdTexture`,i._indirectTexture,H),D.setOptional(R,i,`batchingColorTexture`),i._colorsTexture!==null&&D.setValue(R,`batchingColorTexture`,i._colorsTexture,H));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&Oe.update(i,n,S),(T||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,D.setValue(R,`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=wh()),T&&(D.setValue(R,`toneMappingExposure`,w.toneMappingExposure),v.needsLights&&rt(j,E),a&&r.fog===!0&&Ce.refreshFogUniforms(j,a),Ce.refreshMaterialUniforms(j,r,F,ne,b.state.transmissionRenderTarget[e.id]),im.upload(R,et(v),j,H)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(im.upload(R,et(v),j,H),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&D.setValue(R,`center`,i.center),D.setValue(R,`modelViewMatrix`,i.modelViewMatrix),D.setValue(R,`normalMatrix`,i.normalMatrix),D.setValue(R,`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];Ne.update(n,S),Ne.bind(n,S)}}return S}function rt(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 it(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=V.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),V.get(e.texture).__webglTexture=t,V.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=V.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let at=R.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=V.get(e);if(o.__useDefaultFramebuffer!==void 0){B.bindFramebuffer(R.FRAMEBUFFER,o.__webglFramebuffer),j.copy(e.viewport),M.copy(e.scissor),N=e.scissorTest,B.viewport(j),B.scissor(M),B.setScissorTest(N),k=-1;return}else if(o.__webglFramebuffer===void 0)H.setupRenderTarget(e);else if(o.__hasExternalTextures)H.rebindTextures(e,V.get(e.texture).__webglTexture,V.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&V.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);H.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=V.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&H.useMultisampledRTT(e)===!1?V.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,j.copy(e.viewport),M.copy(e.scissor),N=e.scissorTest}else j.copy(I).multiplyScalar(F).floor(),M.copy(L).multiplyScalar(F).floor(),N=ae;if(n!==0&&(r=at),B.bindFramebuffer(R.FRAMEBUFFER,r)&&B.drawBuffers(e,r),B.viewport(j),B.scissor(M),B.setScissorTest(N),i){let r=V.get(e.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.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=V.get(e.textures[t]);R.framebufferTextureLayer(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=V.get(e.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_2D,t.__webglTexture,n)}k=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){yi(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=V.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){B.bindFramebuffer(R.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&R.readBuffer(R.COLOR_ATTACHMENT0+s),!ge.textureFormatReadable(c)){yi(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!ge.textureTypeReadable(l)){yi(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&R.readPixels(t,n,r,i,je.convert(c),je.convert(l),a)}finally{let e=O===null?null:V.get(O).__webglFramebuffer;B.bindFramebuffer(R.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=V.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){B.bindFramebuffer(R.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&R.readBuffer(R.COLOR_ATTACHMENT0+s),!ge.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!ge.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=R.createBuffer();R.bindBuffer(R.PIXEL_PACK_BUFFER,d),R.bufferData(R.PIXEL_PACK_BUFFER,a.byteLength,R.STREAM_READ),R.readPixels(t,n,r,i,je.convert(l),je.convert(u),0);let f=O===null?null:V.get(O).__webglFramebuffer;B.bindFramebuffer(R.FRAMEBUFFER,f);let p=R.fenceSync(R.SYNC_GPU_COMMANDS_COMPLETE,0);return R.flush(),await xi(R,p,4),R.bindBuffer(R.PIXEL_PACK_BUFFER,d),R.getBufferSubData(R.PIXEL_PACK_BUFFER,0,a),R.deleteBuffer(d),R.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;H.setTexture2D(e,0),R.copyTexSubImage2D(R.TEXTURE_2D,n,0,0,o,s,i,a),B.unbindTexture()};let ot=R.createFramebuffer(),st=R.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=je.convert(t.format),_=je.convert(t.type),v;t.isData3DTexture?(H.setTexture3D(t,0),v=R.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(H.setTexture2DArray(t,0),v=R.TEXTURE_2D_ARRAY):(H.setTexture2D(t,0),v=R.TEXTURE_2D),R.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,t.flipY),R.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),R.pixelStorei(R.UNPACK_ALIGNMENT,t.unpackAlignment);let y=R.getParameter(R.UNPACK_ROW_LENGTH),b=R.getParameter(R.UNPACK_IMAGE_HEIGHT),x=R.getParameter(R.UNPACK_SKIP_PIXELS),S=R.getParameter(R.UNPACK_SKIP_ROWS),C=R.getParameter(R.UNPACK_SKIP_IMAGES);R.pixelStorei(R.UNPACK_ROW_LENGTH,h.width),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,h.height),R.pixelStorei(R.UNPACK_SKIP_PIXELS,l),R.pixelStorei(R.UNPACK_SKIP_ROWS,u),R.pixelStorei(R.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=V.get(e),r=V.get(t),h=V.get(n.__renderTarget),g=V.get(r.__renderTarget);B.bindFramebuffer(R.READ_FRAMEBUFFER,h.__webglFramebuffer),B.bindFramebuffer(R.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(R.framebufferTextureLayer(R.READ_FRAMEBUFFER,R.COLOR_ATTACHMENT0,V.get(e).__webglTexture,i,d+n),R.framebufferTextureLayer(R.DRAW_FRAMEBUFFER,R.COLOR_ATTACHMENT0,V.get(t).__webglTexture,a,m+n)),R.blitFramebuffer(l,u,o,s,f,p,o,s,R.DEPTH_BUFFER_BIT,R.NEAREST);B.bindFramebuffer(R.READ_FRAMEBUFFER,null),B.bindFramebuffer(R.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||V.has(e)){let n=V.get(e),r=V.get(t);B.bindFramebuffer(R.READ_FRAMEBUFFER,ot),B.bindFramebuffer(R.DRAW_FRAMEBUFFER,st);for(let e=0;e<c;e++)w?R.framebufferTextureLayer(R.READ_FRAMEBUFFER,R.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):R.framebufferTexture2D(R.READ_FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_2D,n.__webglTexture,i),T?R.framebufferTextureLayer(R.DRAW_FRAMEBUFFER,R.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):R.framebufferTexture2D(R.DRAW_FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_2D,r.__webglTexture,a),i===0?T?R.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):R.copyTexSubImage2D(v,a,f,p,l,u,o,s):R.blitFramebuffer(l,u,o,s,f,p,o,s,R.COLOR_BUFFER_BIT,R.NEAREST);B.bindFramebuffer(R.READ_FRAMEBUFFER,null),B.bindFramebuffer(R.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?R.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?R.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):R.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?R.texSubImage2D(R.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?R.compressedTexSubImage2D(R.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):R.texSubImage2D(R.TEXTURE_2D,a,f,p,o,s,g,_,h);R.pixelStorei(R.UNPACK_ROW_LENGTH,y),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,b),R.pixelStorei(R.UNPACK_SKIP_PIXELS,x),R.pixelStorei(R.UNPACK_SKIP_ROWS,S),R.pixelStorei(R.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&R.generateMipmap(v),B.unbindTexture()},this.initRenderTarget=function(e){V.get(e).__webglFramebuffer===void 0&&H.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?H.setTextureCube(e,0):e.isData3DTexture?H.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?H.setTexture2DArray(e,0):H.setTexture2D(e,0),B.unbindTexture()},this.resetState=function(){E=0,D=0,O=null,B.reset(),Me.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return ui}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=aa._getDrawingBufferColorSpace(e),t.unpackColorSpace=aa._getUnpackColorSpace()}},Eh=-(2**40),Dh=8;function Oh(e,t){return e<0||e>=Dh?Eh:t*Dh+e}function kh(e){return(e%Dh+Dh)%Dh}function Ah(e){return(e-kh(e))/Dh}function jh(e){return e===Eh?null:mn(kh(e),Ah(e))}function Mh(e){let t=e.indexOf(`-`);if(t<=0)return null;let n=pn(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=Oh(n,r);return i===Eh?null:i}function Nh(e){let t=new Set;for(let n of e){let e=Mh(n);e!==null&&t.add(e)}return t}function Ph(e){return e+7&-8}function Fh(e){return{subFormat:e.getUint16(24,!0),source:e.getUint8(26),idType:e.getUint8(27),rowCount:e.getUint32(28,!0)}}function Ih(e,t){return mn(e.idType,e.id[t])}function Lh(e,t){return Oh(e.idType,e.id[t])}function Rh(e,t){let n=tn,r=new Int32Array(e,n,t);n+=Ph(t*4);let i=new Uint8Array(e,n,t);n+=Ph(t);let a=new Int32Array(e,n,t);n+=Ph(t*4);let o=new Uint8Array(e,n,t);return n+=Ph(t),{id:r,objectType:i,parentId:a,scale:o,offset:n}}function zh(e,t,n){let r=n,i=new Float64Array(e,r,t);r+=t*8;let a=new Float32Array(e,r,t);r+=Ph(t*4);let o=new Float32Array(e,r,t);r+=Ph(t*4);let s=new Float32Array(e,r,t);r+=Ph(t*4);let c=new Float32Array(e,r,t);r+=Ph(t*4);let l=new Float32Array(e,r,t);r+=Ph(t*4);let u=new Float32Array(e,r,t);r+=Ph(t*4);let d=new Float32Array(e,r,t);r+=Ph(t*4);let f=new Float32Array(e,r,t);return r+=Ph(t*4),{epochJd:i,a,e:o,i:s,om:c,w:l,ma:u,n:d,radiusKm:f,offset:r}}function Bh(e,t,n){let{subFormat:r,rowCount:i,source:a,idType:o}=Fh(new DataView(e));if(o===un.UNKNOWN&&i>0&&console.warn(`elements payload has unknown id-type — ${i} row(s) will lack reconstructed IDs`),r===1)return Hh(e,i,t,n,a,o);if(r===2)return Vh(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}=Rh(e,i),f=zh(e,i,d),p=f.offset,m=new Float32Array(e,p,i);p+=Ph(i*4);let h=new Float32Array(e,p,i);p+=Ph(i*4);let g=new Uint8Array(e,p,i);p+=Ph(i);let _=new Uint8Array(e,p,i);p+=Ph(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 Vh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=Rh(e,t),d=zh(e,t,u),f=d.offset,p={validityStart:n,validityEnd:r,source:i,idType:a},m=new Float32Array(e,f,t);f+=Ph(t*4);let h=new Float32Array(e,f,t);f+=Ph(t*4);let g=new Float32Array(e,f,t);f+=Ph(t*4);let _=new Int32Array(e,f,t);f+=Ph(t*4);let v=new Int32Array(e,f,t);f+=Ph(t*4);let y=new Uint8Array(e,f,t);f+=Ph(t);let b=new Uint8Array(e,f,t);f+=Ph(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 Hh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=Rh(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+=Ph(t*4);let h=new Float32Array(e,d,t);d+=Ph(t*4);let g=new Float32Array(e,d,t);d+=Ph(t*4);let _=new Float32Array(e,d,t);d+=Ph(t*4);let v=new Float32Array(e,d,t);d+=Ph(t*4);let y=new Float64Array(e,d,t);d+=t*8;let b=new Float32Array(e,d,t);d+=Ph(t*4);let x=new Uint8Array(e,d,t);d+=Ph(t);let S=new Uint8Array(e,d,t);return d+=Ph(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 Uh=Math.PI,Wh=Uh*2,Gh=Uh/180;180/Uh;var Kh=398600.8,qh=6378.135,Jh=60/Math.sqrt(qh*qh*qh/Kh),Yh=qh*Jh/60,Xh=1/Jh,Zh=.001082616,Qh=-253881e-11,$h=-165597e-11,eg=Qh/Zh,tg=2/3,ng=1440/(2*Uh);function rg(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 ig(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 ag(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return ig(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return ig(e,t,n,r,i,a,o)}function og(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:N}=e,{init:P,opsmode:ee}=t,{ep:te,inclp:ne,nodep:F,argpp:re,mp:ie}=t,I,L,ae,oe,se,ce,le,ue,de,fe,pe,me,R,he,z,ge,B,_e,V,H,ve;ve=N+119459e-10*x,P===`y`&&(ve=N),H=ve+2*.01675*Math.sin(ve),B=Math.sin(H),fe=.5*B*B-.25,pe=-.5*B*Math.cos(H);let ye=l*fe+u*pe,be=g*fe+_*pe,xe=v*fe+y*pe+b*B,Se=d*fe+f*pe+p*B,Ce=m*fe+h*pe;ve=M+.00015835218*x,P===`y`&&(ve=M),H=ve+2*.0549*Math.sin(ve),B=Math.sin(H),fe=.5*B*B-.25,pe=-.5*B*Math.cos(H);let we=r*fe+n*pe,U=D*fe+O*pe,Te=k*fe+A*pe+j*B,Ee=S*fe+C*pe+w*B,De=T*fe+E*pe;return me=ye+we,z=be+U,ge=xe+Te,R=Se+Ee,he=Ce+De,P===`n`&&(me-=i,z-=s,ge-=c,R-=a,he-=o,ne+=z,te+=me,oe=Math.sin(ne),ae=Math.cos(ne),ne>=.2?(he/=oe,R-=ae*he,re+=R,F+=he,ie+=ge):(ce=Math.sin(F),se=Math.cos(F),I=oe*ce,L=oe*se,le=he*se+z*ae*ce,ue=-he*ce+z*ae*se,I+=le,L+=ue,F%=Wh,F<0&&ee===`a`&&(F+=Wh),_e=ie+re+ae*F,de=ge+R-z*F*oe,_e+=de,V=F,F=Math.atan2(I,L),F<0&&ee===`a`&&(F+=Wh),Math.abs(V-F)>Uh&&(F<V?F+=Wh:F-=Wh),ie+=ge,re=_e-ie-ae*F)),{ep:te,inclp:ne,nodep:F,argpp:re,mp:ie}}function sg(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,N,P,ee,te,ne,F,re,ie,I,L,ae,oe,se,ce,le,ue,de,fe,pe,me,R,he,z,ge,B,_e,V,H,ve,ye,be,xe,Se,Ce,we,U,Te,Ee,De=.01675,Oe=.0549,ke=s,Ae=n,je=Math.sin(o),Me=Math.cos(o),Ne=Math.sin(r),Pe=Math.cos(r),Fe=Math.sin(a),Ie=Math.cos(a),Le=Ae*Ae,Re=1-Le,ze=Math.sqrt(Re),Be=t+18261.5+i/1440,Ve=(4.523602-.00092422029*Be)%Wh,He=Math.sin(Ve),Ue=Math.cos(Ve),We=.91375164-.03568096*Ue,Ge=Math.sqrt(1-We*We),Ke=.089683511*He/Ge,qe=Math.sqrt(1-Ke*Ke),Je=5.8351514+.001944368*Be,Ye=.39785416*He/Ge,Xe=qe*Ue+.91744867*Ke*He;Ye=Math.atan2(Ye,Xe),Ye+=Je-Ve;let Ze=Math.cos(Ye),Qe=Math.sin(Ye);D=.1945905,O=-.98088458,j=.91744867,M=.39785416,k=Me,A=je,v=29864797e-13;let $e=1/ke,et=0;for(;et<2;)et+=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=Ie*m+Fe*h,d=Ie*g+Fe*_,f=-Fe*m+Ie*h,p=-Fe*g+Ie*_,y=c*Pe+l*Ne,b=u*Pe+d*Ne,x=-c*Ne+l*Pe,S=-u*Ne+d*Pe,C=f*Ne,w=p*Ne,T=f*Pe,E=p*Pe,U=12*y*y-3*x*x,Te=24*y*b-6*x*S,Ee=12*b*b-3*S*S,V=3*(c*c+l*l)+U*Le,H=6*(c*u+l*d)+Te*Le,ve=3*(u*u+d*d)+Ee*Le,ye=-6*c*f+Le*(-24*y*T-6*x*C),be=-6*(c*p+u*f)+Le*(-24*(b*T+y*E)+-6*(x*w+S*C)),xe=-6*u*p+Le*(-24*b*E-6*S*w),Se=6*l*f+Le*(24*y*C-6*x*T),Ce=6*(d*f+l*p)+Le*(24*(b*C+y*w)-6*(S*T+x*E)),we=6*d*p+Le*(24*b*w-6*S*E),V=V+V+Re*U,H=H+H+Re*Te,ve=ve+ve+Re*Ee,he=v*$e,R=-.5*he/ze,z=he*ze,me=-15*Ae*z,ge=y*x+b*S,B=b*x+y*S,_e=b*S-y*x,et===1&&(N=me,P=R,ee=he,te=z,ne=ge,F=B,re=_e,ie=V,I=H,L=ve,ae=ye,oe=be,se=xe,ce=Se,le=Ce,ue=we,de=U,fe=Te,pe=Ee,D=Ze,O=Qe,j=We,M=Ge,k=qe*Me+Ke*je,A=je*qe-Me*Ke,v=4.7968065e-7);let tt=(4.7199672+(.2299715*Be-Je))%Wh,nt=(6.2565837+.017201977*Be)%Wh,rt=2*N*F,it=2*N*re,at=2*P*oe,ot=2*P*(se-ae),st=-2*ee*I,ct=-2*ee*(L-ie),lt=-2*ee*(-21-9*Le)*De,ut=2*te*fe,dt=2*te*(pe-de),ft=-18*te*De,pt=-2*P*le,mt=-2*P*(ue-ce),ht=2*me*B,gt=2*me*_e,_t=2*R*be,vt=2*R*(xe-ye),yt=-2*he*H,bt=-2*he*(ve-V),xt=-2*he*(-21-9*Le)*Oe,St=2*z*Te,Ct=2*z*(Ee-U),wt=-18*z*Oe,Tt=-2*R*Ce,Et=-2*R*(we-Se);return{snodm:je,cnodm:Me,sinim:Fe,cosim:Ie,sinomm:Ne,cosomm:Pe,day:Be,e3:gt,ee2:ht,em:Ae,emsq:Le,gam:Je,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:ze,se2:rt,se3:it,sgh2:ut,sgh3:dt,sgh4:ft,sh2:pt,sh3:mt,si2:at,si3:ot,sl2:st,sl3:ct,sl4:lt,s1:me,s2:R,s3:he,s4:z,s5:ge,s6:B,s7:_e,ss1:N,ss2:P,ss3:ee,ss4:te,ss5:ne,ss6:F,ss7:re,sz1:ie,sz2:I,sz3:L,sz11:ae,sz12:oe,sz13:se,sz21:ce,sz22:le,sz23:ue,sz31:de,sz32:fe,sz33:pe,xgh2:St,xgh3:Ct,xgh4:wt,xh2:Tt,xh3:Et,xi2:_t,xi3:vt,xl2:yt,xl3:bt,xl4:xt,nm:ke,z1:V,z2:H,z3:ve,z11:ye,z12:be,z13:xe,z21:Se,z22:Ce,z23:we,z31:U,z32:Te,z33:Ee,zmol:tt,zmos:nt}}function cg(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:N,z13:P,z21:ee,z23:te,z31:ne,z33:F,ecco:re,eccsq:ie}=e,{emsq:I,em:L,argpm:ae,inclm:oe,mm:se,nm:ce,nodem:le,irez:ue,atime:de,d2201:fe,d2211:pe,d3210:me,d3222:R,d4410:he,d4422:z,d5220:ge,d5232:B,d5421:_e,d5433:V,dedt:H,didt:ve,dmdt:ye,dnodt:be,domdt:xe,del1:Se,del2:Ce,del3:we,xfact:U,xlamo:Te,xli:Ee,xni:De}=e,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,tt,nt,rt,it,at,ot=.0043752690880113,st=.00015835218,ct=119459e-10;ue=0,ce<.0052359877&&ce>.0034906585&&(ue=1),ce>=.00826&&ce<=.00924&&L>=.5&&(ue=2);let lt=l*ct*p,ut=u*ct*(g+_),dt=-ct*d*(m+h-14-6*I),ft=f*ct*(b+x-6),pt=-ct*u*(v+y);(oe<.052359877||oe>Uh-.052359877)&&(pt=0),c!==0&&(pt/=c);let mt=ft-t*pt;H=lt+r*st*s,ve=ut+i*st*(N+P),ye=dt-st*a*(j+M-14-6*I);let ht=o*st*(ne+F-6),gt=-st*i*(ee+te);(oe<.052359877||oe>Uh-.052359877)&&(gt=0),xe=mt+ht,be=pt,c!==0&&(xe-=t/c*gt,be+=gt/c);let _t=(w+C*ot)%Wh;if(L+=H*S,oe+=ve*S,ae+=xe*S,le+=be*S,se+=ye*S,ue!==0){if(rt=(ce/Jh)**tg,ue===2){it=t*t;let e=L;L=re;let n=I;I=ie,at=L*I,Ve=-.306-(L-.64)*.44,L<=.65?(He=3.616-13.247*L+16.29*I,We=-19.302+117.39*L-228.419*I+156.591*at,Ge=-18.9068+109.7927*L-214.6334*I+146.5816*at,Ke=-41.122+242.694*L-471.094*I+313.953*at,qe=-146.407+841.88*L-1629.014*I+1083.435*at,Je=-532.114+3017.977*L-5740.032*I+3708.276*at):(He=-72.099+331.819*L-508.738*I+266.724*at,We=-346.844+1582.851*L-2415.925*I+1246.113*at,Ge=-342.585+1554.908*L-2366.899*I+1215.972*at,Ke=-1052.797+4758.686*L-7193.992*I+3651.957*at,qe=-3581.69+16178.11*L-24462.77*I+12422.52*at,Je=L>.715?-5149.66+29936.92*L-54087.36*I+31324.56*at:1464.74-4664.75*L+3763.64*I),L<.7?(Ze=-919.2277+4988.61*L-9064.77*I+5542.21*at,Ye=-822.71072+4568.6173*L-8491.4146*I+5337.524*at,Xe=-853.666+4690.25*L-8624.77*I+5341.4*at):(Ze=-37995.78+161616.52*L-229838.2*I+109377.94*at,Ye=-51752.104+218913.95*L-309468.16*I+146349.42*at,Xe=-40023.88+170470.89*L-242699.48*I+115605.82*at),Qe=c*c,Oe=.75*(1+2*t+it),ke=1.5*Qe,je=1.875*c*(1-2*t-3*it),Me=-1.875*c*(1+2*t-3*it),Pe=35*Qe*Oe,Fe=39.375*Qe*Qe,Ie=9.84375*c*(Qe*(1-2*t-5*it)+.33333333*(-2+4*t+6*it)),Le=c*(4.92187512*Qe*(-2-4*t+10*it)+6.56250012*(1+2*t-3*it)),Re=29.53125*c*(2-8*t+it*(-12+8*t+10*it)),ze=29.53125*c*(-2-8*t+it*(12+8*t-10*it)),tt=ce*ce,nt=rt*rt,et=3*tt*nt,$e=et*17891679e-13,fe=$e*Oe*Ve,pe=$e*ke*He,et*=rt,$e=et*3.7393792e-7,me=$e*je*We,R=$e*Me*Ge,et*=rt,$e=2*et*7.3636953e-9,he=$e*Pe*Ke,z=$e*Fe*qe,et*=rt,$e=et*1.1428639e-7,ge=$e*Ie*Je,B=$e*Le*Xe,$e=2*et*2.1765803e-9,_e=$e*Re*Ye,V=$e*ze*Ze,Te=(T+O+O-(_t+_t))%Wh,U=E+ye+2*(k+be-ot)-D,L=e,I=n}ue===1&&(Be=1+I*(-2.5+.8125*I),We=1+2*I,Ue=1+I*(-6+6.60937*I),Oe=.75*(1+t)*(1+t),Ae=.9375*c*c*(1+3*t)-.75*(1+t),Ne=1+t,Ne*=1.875*Ne*Ne,Se=3*ce*ce*rt*rt,Ce=2*Se*Oe*Be*17891679e-13,we=3*Se*Ne*Ue*2.2123015e-7*rt,Se=Se*Ae*We*21460748e-13*rt,Te=(T+O+n-_t)%Wh,U=E+A+ye+xe+be-(D+ot)),Ee=Te,De=D,de=0,ce=D+0}return{em:L,argpm:ae,inclm:oe,mm:se,nm:ce,nodem:le,irez:ue,atime:de,d2201:fe,d2211:pe,d3210:me,d3222:R,d4410:he,d4422:z,d5220:ge,d5232:B,d5421:_e,d5433:V,dedt:H,didt:ve,dmdt:ye,dndt:0,dnodt:be,domdt:xe,del1:Se,del2:Ce,del3:we,xfact:U,xlamo:Te,xli:Ee,xni:De}}function lg(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*Gh/240%Wh,n<0&&(n+=Wh),n}function ug(e,t,n,r,i,a,o){return e instanceof Date?lg(ag(e)):lg(t===void 0?e:ag(e,t,n,r,i,a,o))}function dg(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=(Jh/a)**tg,f=.75*Zh*(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=(Jh/a)**tg,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+Wh;C=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%Wh,C<0&&(C+=Wh)}else C=ug(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 fg(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:N,xni:P,nodem:ee,nm:te}=e,ne=.13130908,F=2.8843198,re=.37448087,ie=5.7686396,I=.95240898,L=1.8014998,ae=1.050833,oe=4.4108898,se=259200,ce,le,ue,de,fe,pe,me,R,he=0,z=0,ge=(w+C*.0043752690880113)%Wh;if(k+=f*S,j+=g*S,A+=y*S,ee+=v*S,N+=_*S,t!==0){(O===0||S*O<=0||Math.abs(S)<Math.abs(O))&&(O=0,P=D,M=E),ce=S>0?720:-720;let e=381;for(;e===381;)t===2?(R=b+x*O,ue=R+R,le=M+M,me=n*Math.sin(ue+M-ie)+r*Math.sin(M-ie)+i*Math.sin(R+M-I)+a*Math.sin(-R+M-I)+o*Math.sin(ue+le-L)+s*Math.sin(le-L)+c*Math.sin(R+M-ae)+l*Math.sin(-R+M-ae)+u*Math.sin(R+le-oe)+d*Math.sin(-R+le-oe),fe=P+T,pe=n*Math.cos(ue+M-ie)+r*Math.cos(M-ie)+i*Math.cos(R+M-I)+a*Math.cos(-R+M-I)+c*Math.cos(R+M-ae)+l*Math.cos(-R+M-ae)+2*(o*Math.cos(ue+le-L)+s*Math.cos(le-L)+u*Math.cos(R+le-oe)+d*Math.cos(-R+le-oe)),pe*=fe):(me=p*Math.sin(M-ne)+m*Math.sin(2*(M-F))+h*Math.sin(3*(M-re)),fe=P+T,pe=p*Math.cos(M-ne)+2*m*Math.cos(2*(M-F))+3*h*Math.cos(3*(M-re)),pe*=fe),Math.abs(S-O)>=720?e=381:(z=S-O,e=0),e===381&&(M+=fe*ce+me*se,P+=me*ce+pe*se,O+=ce);te=P+me*z+pe*z*z*.5,de=M+fe*z+me*z*z*.5,t===1?(N=de-ee-A+ge,he=te-D):(N=de-2*ee+2*ge,he=te-D),te=D+he}return{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:N,xni:P,nodem:ee,dndt:he,nm:te}}var pg;(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`})(pg||={});function mg(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=pg.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 N=e.ecco;if(x=e.inclo,e.method===`d`){h=e.t;let t=fg({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:N,argpm:u,inclm:x,xli:e.xli,mm:S,xni:e.xni,nodem:w,nm:C});({em:N,argpm:u,inclm:x,mm:S,nodem:w,nm:C}=t)}if(C<=0)return e.error=pg.MeanMotionBelowZero,null;let P=(Jh/C)**tg*v*v;if(C=Jh/P**1.5,N-=y,N>=1||N<-.001)return e.error=pg.MeanEccentricityOutOfRange,null;N<1e-6&&(N=1e-6),S+=e.no*b,E=S+u+w,w%=Wh,u%=Wh,E%=Wh,S=(E-u-w)%Wh;let ee={am:P,em:N,im:x,Om:w,om:u,mm:S,nm:C},te=Math.sin(x),ne=Math.cos(x),F=N;if(T=x,d=u,O=w,D=S,a=te,i=ne,e.method===`d`){let t=og(e,{inclo:e.inclo,init:`n`,ep:F,inclp:T,nodep:O,argpp:d,mp:D,opsmode:e.operationmode});if({ep:F,nodep:O,argpp:d,mp:D}=t,T=t.inclp,T<0&&(T=-T,O+=Uh,d-=Uh),F<0||F>1)return e.error=pg.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(a=Math.sin(T),i=Math.cos(T),e.aycof=-.5*eg*a,Math.abs(i+1)>15e-13?e.xlcof=-.25*eg*a*(3+5*i)/(1+i):e.xlcof=-.25*eg*a*(3+5*i)/15e-13);let re=F*Math.cos(d);_=1/(P*(1-F*F));let ie=F*Math.sin(d)+_*e.aycof,I=(D+d+O+_*e.xlcof*re-O)%Wh;l=I,g=9999.9;let L=1;for(;Math.abs(g)>=1e-12&&L<=10;)r=Math.sin(l),n=Math.cos(l),g=1-n*re-r*ie,g=(I-ie*n+re*r-l)/g,Math.abs(g)>=.95&&(g=g>0?.95:-.95),l+=g,L+=1;let ae=re*n+ie*r,oe=re*r-ie*n,se=re*re+ie*ie,ce=P*(1-se);if(ce<0)return e.error=pg.SemiLatusRectumBelowZero,null;let le=P*(1-ae),ue=Math.sqrt(P)*oe/le,de=Math.sqrt(ce)/le,fe=Math.sqrt(1-se);_=oe/(1+fe);let pe=P/le*(r-ie-re*_),me=P/le*(n-re+ie*_);f=Math.atan2(pe,me);let R=(me+me)*pe,he=1-2*pe*pe;_=1/ce;let z=.5*Zh*_,ge=z*_;e.method===`d`&&(o=i*i,e.con41=3*o-1,e.x1mth2=1-o,e.x7thm1=7*o-1);let B=le*(1-1.5*ge*fe*e.con41)+.5*z*e.x1mth2*he;if(B<1)return e.error=pg.Decayed,null;f-=.25*ge*e.x7thm1*R;let _e=O+1.5*ge*i*R,V=T+1.5*ge*i*a*he,H=ue-C*z*e.x1mth2*R/Jh,ve=de+C*z*(e.x1mth2*he+1.5*e.con41)/Jh,ye=Math.sin(f),be=Math.cos(f),xe=Math.sin(_e),Se=Math.cos(_e),Ce=Math.sin(V),we=Math.cos(V),U=-xe*we,Te=Se*we,Ee=U*ye+Se*be,De=Te*ye+xe*be,Oe=Ce*ye,ke=U*be-Se*ye,Ae=Te*be-xe*ye,je=Ce*be;return{position:{x:B*Ee*qh,y:B*De*qh,z:B*Oe*qh},velocity:{x:(H*Ee+ve*ke)*Yh,y:(H*De+ve*Ae)*Yh,z:(H*Oe+ve*je)*Yh},meanElements:ee}}function hg(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,N,P,ee,te,ne,F,re,ie,I,L,ae,oe,se,ce,le,ue,de,fe,pe,me,R,he,z,ge,B,_e,V,H,ve,ye,be,xe,Se,Ce,we,U=e;U.isimp=0,U.method=`n`,U.aycof=0,U.con41=0,U.cc1=0,U.cc4=0,U.cc5=0,U.d2=0,U.d3=0,U.d4=0,U.delmo=0,U.eta=0,U.argpdot=0,U.omgcof=0,U.sinmao=0,U.t=0,U.t2cof=0,U.t3cof=0,U.t4cof=0,U.t5cof=0,U.x1mth2=0,U.x7thm1=0,U.mdot=0,U.nodedot=0,U.xlcof=0,U.xmcof=0,U.nodecf=0,U.irez=0,U.d2201=0,U.d2211=0,U.d3210=0,U.d3222=0,U.d4410=0,U.d4422=0,U.d5220=0,U.d5232=0,U.d5421=0,U.d5433=0,U.dedt=0,U.del1=0,U.del2=0,U.del3=0,U.didt=0,U.dmdt=0,U.dnodt=0,U.domdt=0,U.e3=0,U.ee2=0,U.peo=0,U.pgho=0,U.pho=0,U.pinco=0,U.plo=0,U.se2=0,U.se3=0,U.sgh2=0,U.sgh3=0,U.sgh4=0,U.sh2=0,U.sh3=0,U.si2=0,U.si3=0,U.sl2=0,U.sl3=0,U.sl4=0,U.gsto=0,U.xfact=0,U.xgh2=0,U.xgh3=0,U.xgh4=0,U.xh2=0,U.xh3=0,U.xi2=0,U.xi3=0,U.xl2=0,U.xl3=0,U.xl4=0,U.xlamo=0,U.zmol=0,U.zmos=0,U.atime=0,U.xli=0,U.xni=0,U.bstar=a,U.ecco=o,U.argpo=s,U.inclo=c,U.mo=l,U.no=u,U.nodeo=d,U.operationmode=n;let Te=78/qh+1,Ee=42/qh,De=Ee*Ee*Ee*Ee;U.init=`y`,U.t=0;let Oe=dg({satn:r,ecco:U.ecco,epoch:i,inclo:U.inclo,no:U.no,method:U.method,opsmode:U.operationmode}),{ao:ke,con42:Ae,cosio:je,cosio2:Me,eccsq:Ne,omeosq:Pe,posq:Fe,rp:Ie,rteosq:Le,sinio:Re}=Oe;if(U.no=Oe.no,U.con41=Oe.con41,U.gsto=Oe.gsto,U.a=(U.no*Xh)**(-2/3),U.alta=U.a*(1+U.ecco)-1,U.altp=U.a*(1-U.ecco)-1,U.error=0,Pe>=0||U.no>=0){if(U.isimp=0,Ie<1.034492841559484&&(U.isimp=1),F=Te,M=De,k=(Ie-1)*qh,k<156){F=k-78,k<98&&(F=20);let e=(120-F)/qh;M=e*e*e*e,F=F/qh+1}A=1/Fe,B=1/(ke-F),U.eta=ke*U.ecco*B,C=U.eta*U.eta,S=U.ecco*U.eta,j=Math.abs(1-C),_=M*B**4,v=_/j**3.5,h=v*U.no*(ke*(1+1.5*C+S*(4+C))+.375*Zh*B/j*U.con41*(8+3*C*(8+C))),U.cc1=U.bstar*h,g=0,U.ecco>1e-4&&(g=-2*_*B*eg*U.no*Re/U.ecco),U.x1mth2=1-Me,U.cc4=2*U.no*v*ke*Pe*(U.eta*(2+.5*C)+U.ecco*(.5+2*C)-Zh*B/(ke*j)*(-3*U.con41*(1-2*S+C*(1.5-.5*S))+.75*U.x1mth2*(2*C-S*(1+C))*Math.cos(2*U.argpo))),U.cc5=2*v*ke*Pe*(1+2.75*(C+S)+S*C),y=Me*Me,he=1.5*Zh*A*U.no,z=.5*he*Zh*A,ge=-.46875*$h*A*A*U.no,U.mdot=U.no+.5*he*Le*U.con41+.0625*z*Le*(13-78*Me+137*y),U.argpdot=-.5*he*Ae+.0625*z*(7-114*Me+395*y)+ge*(3-36*Me+49*y),V=-he*je,U.nodedot=V+(.5*z*(4-19*Me)+2*ge*(3-7*Me))*je,_e=U.argpdot+U.nodedot,U.omgcof=U.bstar*g*Math.cos(U.argpo),U.xmcof=0,U.ecco>1e-4&&(U.xmcof=-tg*_*U.bstar/S),U.nodecf=3.5*Pe*V*U.cc1,U.t2cof=1.5*U.cc1,Math.abs(je+1)>15e-13?U.xlcof=-.25*eg*Re*(3+5*je)/(1+je):U.xlcof=-.25*eg*Re*(3+5*je)/15e-13,U.aycof=-.5*eg*Re;let e=1+U.eta*Math.cos(U.mo);if(U.delmo=e*e*e,U.sinmao=Math.sin(U.mo),U.x7thm1=7*Me-1,2*Uh/U.no>=225){U.method=`d`,U.isimp=1,me=0,E=U.inclo;let e=sg({epoch:i,ep:U.ecco,argpp:U.argpo,tc:me,inclp:U.inclo,nodep:U.nodeo,np:U.no,e3:U.e3,ee2:U.ee2,peo:U.peo,pgho:U.pgho,pho:U.pho,pinco:U.pinco,plo:U.plo,se2:U.se2,se3:U.se3,sgh2:U.sgh2,sgh3:U.sgh3,sgh4:U.sgh4,sh2:U.sh2,sh3:U.sh3,si2:U.si2,si3:U.si3,sl2:U.sl2,sl3:U.sl3,sl4:U.sl4,xgh2:U.xgh2,xgh3:U.xgh3,xgh4:U.xgh4,xh2:U.xh2,xh3:U.xh3,xi2:U.xi2,xi3:U.xi3,xl2:U.xl2,xl3:U.xl3,xl4:U.xl4,zmol:U.zmol,zmos:U.zmos});U.e3=e.e3,U.ee2=e.ee2,U.peo=e.peo,U.pgho=e.pgho,U.pho=e.pho,U.pinco=e.pinco,U.plo=e.plo,U.se2=e.se2,U.se3=e.se3,U.sgh2=e.sgh2,U.sgh3=e.sgh3,U.sgh4=e.sgh4,U.sh2=e.sh2,U.sh3=e.sh3,U.si2=e.si2,U.si3=e.si3,U.sl2=e.sl2,U.sl3=e.sl3,U.sl4=e.sl4,{sinim:p,cosim:f,em:b,emsq:x,s1:N,s2:P,s3:ee,s4:te,s5:ne,ss1:re,ss2:ie,ss3:I,ss4:L,ss5:ae,sz1:oe,sz3:se,sz11:ce,sz13:le,sz21:ue,sz23:de,sz31:fe,sz33:pe}=e,U.xgh2=e.xgh2,U.xgh3=e.xgh3,U.xgh4=e.xgh4,U.xh2=e.xh2,U.xh3=e.xh3,U.xi2=e.xi2,U.xi3=e.xi3,U.xl2=e.xl2,U.xl3=e.xl3,U.xl4=e.xl4,U.zmol=e.zmol,U.zmos=e.zmos,{nm:O,z1:H,z3:ve,z11:ye,z13:be,z21:xe,z23:Se,z31:Ce,z33:we}=e;let t=og(U,{inclo:E,init:U.init,ep:U.ecco,inclp:U.inclo,nodep:U.nodeo,argpp:U.argpo,mp:U.mo,opsmode:U.operationmode});U.ecco=t.ep,U.inclo=t.inclp,U.nodeo=t.nodep,U.argpo=t.argpp,U.mo=t.mp,w=0,T=0,D=0;let n=cg({cosim:f,emsq:x,argpo:U.argpo,s1:N,s2:P,s3:ee,s4:te,s5:ne,sinim:p,ss1:re,ss2:ie,ss3:I,ss4:L,ss5:ae,sz1:oe,sz3:se,sz11:ce,sz13:le,sz21:ue,sz23:de,sz31:fe,sz33:pe,t:U.t,tc:me,gsto:U.gsto,mo:U.mo,mdot:U.mdot,no:U.no,nodeo:U.nodeo,nodedot:U.nodedot,xpidot:_e,z1:H,z3:ve,z11:ye,z13:be,z21:xe,z23:Se,z31:Ce,z33:we,ecco:U.ecco,eccsq:Ne,em:b,argpm:w,inclm:E,mm:D,nm:O,nodem:T,irez:U.irez,atime:U.atime,d2201:U.d2201,d2211:U.d2211,d3210:U.d3210,d3222:U.d3222,d4410:U.d4410,d4422:U.d4422,d5220:U.d5220,d5232:U.d5232,d5421:U.d5421,d5433:U.d5433,dedt:U.dedt,didt:U.didt,dmdt:U.dmdt,dnodt:U.dnodt,domdt:U.domdt,del1:U.del1,del2:U.del2,del3:U.del3,xfact:U.xfact,xlamo:U.xlamo,xli:U.xli,xni:U.xni});U.irez=n.irez,U.atime=n.atime,U.d2201=n.d2201,U.d2211=n.d2211,U.d3210=n.d3210,U.d3222=n.d3222,U.d4410=n.d4410,U.d4422=n.d4422,U.d5220=n.d5220,U.d5232=n.d5232,U.d5421=n.d5421,U.d5433=n.d5433,U.dedt=n.dedt,U.didt=n.didt,U.dmdt=n.dmdt,U.dnodt=n.dnodt,U.domdt=n.domdt,U.del1=n.del1,U.del2=n.del2,U.del3=n.del3,U.xfact=n.xfact,U.xlamo=n.xlamo,U.xli=n.xli,U.xni=n.xni}U.isimp!==1&&(m=U.cc1*U.cc1,U.d2=4*ke*B*m,R=U.d2*B*U.cc1/3,U.d3=(17*ke+F)*R,U.d4=.5*R*ke*B*(221*ke+31*F)*U.cc1,U.t3cof=U.d2+2*m,U.t4cof=.25*(3*U.d3+U.cc1*(12*U.d2+10*m)),U.t5cof=.2*(3*U.d4+12*U.cc1*U.d3+6*U.d2*U.d2+15*m*(2*U.d2+m)))}mg(U,0),U.init=`n`}function gg(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))*Gh,l=parseFloat(t.substring(17,25))*Gh,u=parseFloat(`.${t.substring(26,33).replace(/\s/g,`0`)}`),d=parseFloat(t.substring(34,42))*Gh,f=parseFloat(t.substring(43,51))*Gh,p=parseFloat(t.substring(52,63))/ng;a/=ng*1440,o/=ng*1440*1440;let m=r<57?r+2e3:r+1900,{mon:h,day:g,hr:_,minute:v,sec:y}=rg(m,i),b=ag(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 hg(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 _g(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/=ng*1440,c/=ng*1440*1440;let l=Number(e.BSTAR),u=Number(e.INCLINATION)*Gh,d=Number(e.RA_OF_ASC_NODE)*Gh,f=Number(e.ECCENTRICITY),p=Number(e.ARG_OF_PERICENTER)*Gh,m=Number(e.MEAN_ANOMALY)*Gh,h=Number(e.MEAN_MOTION)/ng,{mon:g,day:_,hr:v,minute:y,sec:b}=rg(i,o),x=ag(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 hg(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 vg=149597870.7,yg=23.4392911,bg=86400**2/vg**3,xg=1/vg;function Q(e){return e/vg*10}function Sg(e){return e/10*vg}var Cg=Math.cos(Math.PI/180*yg),wg=Math.sin(Math.PI/180*yg);function Tg(e,t,n,r){let i=r??{x:0,y:0,z:0};return i.x=e,i.y=-t*wg+n*Cg,i.z=-(t*Cg+n*wg),i}var Eg=2451545,Dg=86400,Og=2440587.5,kg=864e5;function Ag(e){return e/kg+Og}function jg(e){return Ag(e.getTime())}function Mg(e){return new Date((e-Og)*kg)}var Ng=32.184,Pg=[[2441317.5,10],[2441499.5,11],[2441683.5,12],[2442048.5,13],[2442413.5,14],[2442778.5,15],[2443144.5,16],[2443509.5,17],[2443874.5,18],[2444239.5,19],[2444786.5,20],[2445151.5,21],[2445516.5,22],[2446247.5,23],[2447161.5,24],[2447892.5,25],[2448257.5,26],[2448804.5,27],[2449169.5,28],[2449534.5,29],[2450083.5,30],[2450630.5,31],[2451179.5,32],[2453736.5,33],[2454832.5,34],[2456109.5,35],[2457204.5,36],[2457754.5,37]];function Fg(e){for(let t=Pg.length-1;t>=0;t--)if(e>=Pg[t][0])return Pg[t][1];return Pg[0][1]-1}function Ig(e){let t=6.239996+1.99096871e-7*(e-Eg)*Dg;return .001657*Math.sin(t+.01671*Math.sin(t))}function Lg(e){if(!Number.isFinite(e))return e;let t=e+(Fg(e)+Ng)/Dg;return t+Ig(t)/Dg}function Rg(e){if(!Number.isFinite(e))return e;let t=e-Ig(e)/Dg;return t-(Fg(t-(Fg(t)+Ng)/Dg)+Ng)/Dg}function zg(e){return(Lg(e)-Eg)*Dg}function Bg(e){return Eg+e/Dg}function Vg(e){return(e-Eg)*Dg}var Hg=Math.PI/180,Ug=Hg/3600,Wg=1e-4*Ug,Gg=.01,Kg=[[0,0,0,0,1,-171996,-174.2,92025,8.9],[0,0,2,-2,2,-13187,-1.6,5736,-3.1],[0,0,2,0,2,-2274,-.2,977,-.5],[0,0,0,0,2,2062,.2,-895,.5],[0,1,0,0,0,1426,-3.4,54,-.1],[1,0,0,0,0,712,.1,-7,0],[0,1,2,-2,2,-517,1.2,224,-.6],[0,0,2,0,1,-386,-.4,200,0],[1,0,2,0,2,-301,0,129,-.1],[0,-1,2,-2,2,217,-.5,-95,.3],[1,0,0,-2,0,-158,0,-1,0],[0,0,2,-2,1,129,.1,-70,0],[-1,0,2,0,2,123,0,-53,0],[1,0,0,0,1,63,.1,-33,0],[0,0,0,2,0,63,0,-2,0],[-1,0,2,2,2,-59,0,26,0],[-1,0,0,0,1,-58,-.1,32,0],[1,0,2,0,1,-51,0,27,0]];function qg(e,t){let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[3*r+i]=e[3*r]*t[i]+e[3*r+1]*t[3+i]+e[3*r+2]*t[6+i];return n}function Jg(e){let t=Math.cos(e),n=Math.sin(e);return[1,0,0,0,t,n,0,-n,t]}function Yg(e){let t=Math.cos(e),n=Math.sin(e);return[t,0,-n,0,1,0,n,0,t]}function Xg(e){let t=Math.cos(e),n=Math.sin(e);return[t,n,0,-n,t,0,0,0,1]}function Zg(e){let t=(e-Eg)/36525,n=(2306.2181*t+.30188*t*t+.017998*t**3)*Ug,r=(2004.3109*t-.42665*t*t-.041833*t**3)*Ug,i=(2306.2181*t+1.09468*t*t+.018203*t**3)*Ug,a=134.96298139+477198.8673981*t+.0086972*t*t,o=357.52772333+35999.05034*t-1603e-7*t*t,s=93.27191028+483202.0175381*t-.0036825*t*t,c=297.85036306+445267.11148*t-.0019142*t*t,l=125.04452222-1934.1362608*t+.0020708*t*t,u=0,d=0;for(let[e,n,r,i,f,p,m,h,g]of Kg){let _=(e*a+n*o+r*s+i*c+f*l)*Hg;u+=(p+m*t)*Math.sin(_),d+=(h+g*t)*Math.cos(_)}u*=Wg,d*=Wg;let f=(84381.448-46.815*t-59e-5*t*t+.001813*t**3)*Ug,p=u*Math.cos(f),m=qg(qg(qg(qg(Xg(n),Yg(-r)),Xg(i)),qg(qg(Jg(-f),Xg(u)),Jg(f+d))),Xg(-p));return qg(Jg(yg*Hg),m)}var Qg=NaN,$g=[1,0,0,0,1,0,0,0,1];function e_(e){return Math.abs(e-Qg)<=Gg||($g=Zg(e),Qg=e),$g}function t_(e,t,n,r){let i=e_(r);return[i[0]*e+i[1]*t+i[2]*n,i[3]*e+i[4]*t+i[5]*n,i[6]*e+i[7]*t+i[8]*n]}var n_=2440587.5;function r_(e){return new Date((e-n_)*864e5).toISOString()}function i_(e,t){let n=_g({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:r_(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===pg.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}function a_(e,t){let n=mg(e,(t-e.jdsatepoch)*1440);if(!n||e.error!==pg.None)return null;let{x:r,y:i,z:a}=n.position;return[r,i,a]}function o_(e,t,n,r){let i=10/vg,[a,o,s]=t_(e,t,n,r);return[a*i,s*i,-o*i]}function s_(e,t){let n=a_(e,t);return n?o_(n[0],n[1],n[2],t):null}function c_(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 l_=700;function u_(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>l_)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 d_(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 f_=null,p_=null;function m_(){if(!p_){f_=[];let e=new MessageChannel;e.port1.onmessage=()=>f_.shift()?.(),p_=e.port2}return new Promise(e=>{f_.push(e),p_.postMessage(null)})}var h_=Math.PI/180,g_=Math.cos(yg*h_),__=Math.sin(yg*h_);function v_(e,t,n,r,i,a=!1){let o=Math.cos(n*h_),s=Math.sin(n*h_),c=Math.cos(r*h_),l=Math.sin(r*h_),u=Math.cos(i*h_),d=Math.sin(i*h_),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*g_+m*__,t=-p*__+m*g_;p=e,m=t}return[f*10,m*10,-p*10]}function y_(e,t){return e.equatorial?t:Lg(t)}function b_(e,t){return e.equatorial?t:Rg(t)}function x_(e,t){return S_(e,y_(e,t))}function S_(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 C_(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=y_(e,t),l=(a+o*(c-s))*h_,{om:u,w:d}=S_(e,c),f,p;if(r<1||n>0){let e=Math.min(r,.9999999),t=c_(l,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));f=Math.atan2(i,a),p=n*(1-e*Math.cos(t))}else{let e=u_(l,r);if(!isFinite(e))return console.warn(`solveKeplerHyperbolic overflow: M=${l} 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;f=Math.atan2(i,a),p=n*(1-r*Math.cosh(e))}let m=p*Math.cos(f),h=p*Math.sin(f);return!isFinite(m)||!isFinite(h)?(console.warn(`Non-finite orbital position: r=${p} nu=${f} xOrb=${m} yOrb=${h} a=${n} e=${r}`),null):v_(m,h,d,i,u,e.equatorial)}function w_(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=d_(n,r,y_(e,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:v_(c,l,o,i,a,e.equatorial)}var T_=Math.PI/180;Math.cos(yg*T_),Math.sin(yg*T_),10/vg;function E_(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 D_(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 E_(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 O_(e,t,n=!1){let r=e.length,i=j_(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 m_(),s=performance.now()),!D_(i,n,e[n],t))continue;let r=e[n].data,c=b_(r,r.validityStart),l=b_(r,r.validityEnd);c<a&&(a=c),l>o&&(o=l)}return i.validityStart=a===1/0?-1/0:a,i.validityEnd=o===-1/0?1/0:o,i}var k_=[{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 A_(e){let t=[];for(let n of k_)n.transferable!==!1&&t.push(e[n.name].buffer);return t}function j_(e){let t={count:e,applyFlagFilter:!1,validityStart:-1/0,validityEnd:1/0,pickBase:0};for(let n of k_)t[n.name]=n.make(e);return t}function M_(e,t){return e.get(t)?.name||null}function N_(e,t){return e.get(t)?.isMinor??!1}function P_(e,t){let n=e.get(t);return{name:n?.name||null,isMinor:n?.isMinor??!1}}function F_(e,t,n,r){let i=e.scale[t]===cn.PLANET,a=e.omDot[t],o=e.wDot[t],s=Ih(e,t);if(s===null)return null;let{name:c,isMinor:l}=P_(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]/vg: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 I_(e,t,n,r){let i=Ih(e,t);if(i===null)return null;let{name:a,isMinor:o}=P_(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 L_=new WeakMap,R_=new WeakMap;function z_(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 B_={get omm(){let e=R_.get(this);return e&&z_(e[0],e[1])},get satrec(){let e=this,t=L_.get(e);return t===void 0&&(t=i_(e.omm,e.name??void 0),L_.set(e,t)),t??void 0}};function V_(e,t,n,r){let i=Ih(e,t);if(i===null)return null;let{name:a,isMinor:o}=P_(n,i),s=Object.assign(Object.create(B_),{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]/vg,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 R_.set(s,[e,t]),s}function H_(e,t,n,r){return e.kind===`parabolic`?I_(e,t,n,r):e.kind===`sgp4`?V_(e,t,n,r):F_(e,t,n,r)}function U_(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,E_(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],E_(n,r,e.a[t]/vg,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]===cn.PLANET,s=o?e.a[t]/vg:e.a[t];return s!==0&&isFinite(s)?(n.kind[r]=1,E_(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 W_={"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`},G_=`#cccccc`,K_=`#fcb493`,q_=`#c7ccda`,J_=`#ffe89e`,Y_=`#ccb49a`,X_=`#d8ffe8`,Z_=`#e8a85c`,Q_=`#bed4ec`,$_=`#d5cfe7`,ev=`naif-10`,tv=`naif-399`;function nv(e){if(!e.startsWith(`naif-`))return null;let t=Number.parseInt(e.slice(5),10);return Number.isFinite(t)?t:null}function rv(e){let t=/^naif-([1-9])$/.exec(e);return t?`naif-${t[1]}99`:null}var iv=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 av(e){if(W_[e.id])return W_[e.id];let{objectType:t,parentId:n}=e;if(t===G.BARYCENTER){if(e.id===`naif-0`)return W_[`naif-10`];if(e.id===`naif-9`)return W_[`naif-999`];let t=`naif-${e.id.replace(`naif-`,``)}99`;if(W_[t])return W_[t]}if(t===G.STAR)return J_;if(t===G.PLANET||t===G.DWARF_PLANET)return K_;if(t===G.MOON)return q_;if(Sn(t))return Y_;if(t===G.COMET)return X_;if(t===G.DEBRIS)return Z_;if(t===G.SPACECRAFT){if(n===`naif-399`)return Q_;if(n===`naif-0`||n===`naif-10`)return $_}return G_}function ov(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t>>>0}function sv(e,t){let n=Array.from({length:t},()=>[]);for(let r of e)n[ov(r.data.id)%t].push(r);return n}function cv(e,t,n){return{buckets:sv(t,t.length>=n*600?n:1),baseWorker:ov(e)%n}}async function lv(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 m_(),a=performance.now());let n=t[e];i[ov(n.data.id)%r].push(n)}return{buckets:i,baseWorker:ov(e)%n}}function uv(e){let t=e.indexOf(`#`);return t<0?e:e.substring(0,t)}var dv=4096,fv=.75;function pv(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 mv=class{table=new Uint32Array(dv);mask=dv-1;count=0;constructor(e){this.keyOfRef=e}get size(){return this.count}slot(e){let t=pv(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*fv&&(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=pv(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)}},hv=2**20,gv=4096,_v=6;function vv(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 yv=class{chunks=[];rowOf=new mv(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>=hv)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%gv===gv-1&&performance.now()-o>_v&&(await m_(),o=performance.now());let s=Lh(e,t);if(!(s===Eh||n&&!n.has(s))&&(this.rowOf.set(s,r*hv+t,e=>Math.floor(e/hv)<=r)&&i++,a)){let n=Ih(e,t),r=n===null?void 0:this.placeholders.get(n);if(r){let n=H_(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/hv);return Lh(this.chunks[t],e-t*hv)}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=Mh(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=jh(e);return t!==null&&this.placeholders.has(t)}*ids(){for(let e of this.rowOf.keys()){let t=jh(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=Mh(e);t!==null&&!this.rowOf.has(t)&&(yield t)}}get(e){let t=this.cache.get(e);if(t)return t;let n=Mh(e),r=n===null?void 0:this.rowOf.get(n);if(r===void 0)return;let i=Math.floor(r/hv),a=H_(this.chunks[i],r-i*hv,this.labels,this.parentIdType);if(!a)return;let o={data:a,position:null};return this.cache.set(e,o),o}getKey(e){let t=jh(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=H_(e,0,this.labels,this.parentIdType);return t?av(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 m_(),u=performance.now());let t=Math.floor(e/hv),n=a===1?0:vv(this.chunks[t].id[e-t*hv])%a;o[l]=e,s[l]=n,c[n]++,l++}let d=[];for(let e=0;e<a;e++){let t=j_(c[e]);t.applyFlagFilter=!1,d.push({cols:t,colors:r?new Float32Array(c[e]*3):null,keys:new Float64Array(c[e]).fill(Eh)})}let f=this.chunks.map(e=>Rg(e.validityStart)),p=this.chunks.map(e=>Rg(e.validityEnd)),m=Array(a).fill(1/0),h=Array(a).fill(-1/0),g=Array(a).fill(0),_=r?new X:null;u=performance.now();for(let e=0;e<l;e++){(e&16383)==16383&&performance.now()-u>6&&(await m_(),u=performance.now());let t=o[e],r=Math.floor(t/hv),i=t-r*hv,a=this.chunks[r],c=s[e],l=d[c],v=g[c]++,y=Lh(a,i);if(l.keys[v]=y,U_(a,i,l.cols,v,y,n)){let e=l.cols.equatorial[v]===1,t=e?a.validityStart:f[r],n=e?a.validityEnd:p[r];t<m[c]&&(m[c]=t),n>h[c]&&(h[c]=n)}if(l.colors&&_){let e=H_(a,i,this.labels,this.parentIdType);_.set(e?av(e):`#ffffff`),l.colors[v*3]=_.r,l.colors[v*3+1]=_.g,l.colors[v*3+2]=_.b}}for(let e=0;e<a;e++)d[e].cols.validityStart=m[e]===1/0?-1/0:m[e],d[e].cols.validityEnd=h[e]===-1/0?1/0:h[e];return{groups:d,baseWorker:ov(e)%t}}};function bv(e){return e===`naif-0`||e===`naif-10`}function xv(e){return e===`naif-0`?ev:rv(e)}function Sv(e){if(!bv(e))return rv(e)??e}function Cv(e,t){e.data=t.data,t.orbitElements!==void 0&&(e.orbitElements=t.orbitElements),e.orbitCenterId=t.orbitCenterId??e.orbitCenterId,e.trailAnchorId=t.trailAnchorId}var wv=class{bodiesById=new Map;majorBodies=[];asteroidBodiesByZone=new Map;spacecraftByParent=new Map;focusFeature=null;dirtyAsteroidZones=new Set;dirtySpacecraftGroups=new Set;minorStreaming=!1;dataVersion=0;#e=Ke(0);get minorBodyVersion(){return Ht(this.#e)}set minorBodyVersion(e){qe(this.#e,e,!0)}#t=Ke(0);get orientationVersion(){return Ht(this.#t)}set orientationVersion(e){qe(this.#t,e,!0)}orientationRead=new Set;childrenByParent=new Map;moonMaxAByParent=new Map;addListeners=new Set;onBodiesAdded(e){return this.addListeners.add(e),()=>this.addListeners.delete(e)}notifyBodiesAdded(){this.dataVersion++;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){let e=this.bodiesById.get(n.data.id);e?Cv(e,n):(t=!0,this.bodiesById.set(n.data.id,n));let r=this.childrenByParent.get(n.data.parentId)??new Set;if(r.add(n.data.id),this.childrenByParent.set(n.data.parentId,r),n.data.objectType===G.MOON){let e=this.moonMaxAByParent.get(n.data.parentId)??0;n.data.a>e&&this.moonMaxAByParent.set(n.data.parentId,n.data.a)}}this.dataVersion++,t&&this.notifyBodiesAdded()}putSpacecraft(e){let t=e.data.id,n=this.spacecraftBucket(e.data.parentId),r=n.get(t)??this.bodiesById.get(t);if(!r){for(let e of this.spacecraftByParent.values())if(r=e.get(t),r){e.delete(t);break}}return this.dataVersion++,r?(Cv(r,e),this.bodiesById.delete(t),n.set(t,r),!1):(n.set(t,e),!0)}asteroidBucket(e,t){let n=this.asteroidBodiesByZone.get(e);return n||this.asteroidBodiesByZone.set(e,n=new yv(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++,this.dataVersion++,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!==W.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 bv(e.data.parentId)?!1:this.bodiesById.get(e.data.parentId)?.data.objectType!==G.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===G.PLANET||i===G.DWARF_PLANET?e++:i===G.MOON?t++:i===G.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())(Sn(e.data.objectType)||e.data.objectType===G.COMET)&&i++;return{planets:e,moons:t,probes:n,earthSatellites:r,smallBodies:i}}};function Tv(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 Ev(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 Dv(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 Tv(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 Tv(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 Ov={metadata:.12,ephemeris:.55,majors:.8,labels:.92,done:1},kv=[`metadata`,`ephemeris`,`majors`,`labels`,`done`],Av=.9,jv=new class{#e=0;#t=Ov.metadata;#n=0;#r=0;#i=!1;#a=Ke(0);get value(){return Ht(this.#a)}set value(e){qe(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*Av;n>this.value&&(this.value=n)}reset(){this.#e=0,this.#t=Ov.metadata,this.#n=0,this.#r=0,this.#i=!0,this.value=0}reach(e){if(!this.#i)return;let t=Ov[e];if(t<=this.#e)return;this.#e=t,this.value<t&&(this.value=t);let n=kv[kv.indexOf(e)+1];this.#t=n?Ov[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())}},Mv=3e4;function Nv(e,t){if(t||!jv.active)return null;let n=Number(e.headers.get(`content-length`));return!Number.isFinite(n)||n<=0?null:(jv.announce(n),e=>jv.addBytes(e))}async function Pv(e,t={},n=Mv){let r=new AbortController,i,a=!1,o=()=>{clearTimeout(i),i=setTimeout(()=>{a=!0,r.abort()},n)},s=()=>r.abort();t.signal?.addEventListener(`abort`,s,{once:!0});let c=()=>{clearTimeout(i),t.signal?.removeEventListener(`abort`,s)},l=t=>a?Error(`Request stalled for ${n} ms: ${e}`,{cause:t}):t;o();let u;try{u=await fetch(e,{...t,signal:r.signal})}catch(e){throw c(),l(e)}if(!u.body)return c(),u;let d=Nv(u,t.priority===`low`),f=u.body.getReader(),p=new ReadableStream({async pull(e){o();try{let{done:t,value:n}=await f.read();if(clearTimeout(i),t){c(),e.close();return}d?.(n.byteLength),e.enqueue(n)}catch(t){c(),e.error(l(t))}},cancel(e){return c(),f.cancel(e)}});return new Response(p,{status:u.status,statusText:u.statusText,headers:u.headers})}var Fv=new Map,Iv=new Map,Lv=null;function Rv(){if(Lv)return Lv;let e=(async()=>{let e=await Pv(`${Kt()}/v1/systems/global.json`);if(!e.ok)throw Error(`systems/global.json: ${e.status}`);let t=await e.json();if(t.gm)for(let[e,n]of Object.entries(t.gm))Iv.set(parseInt(e,10),n);if(t.nut_prec_angles)for(let[e,n]of Object.entries(t.nut_prec_angles)){let r=t.nut_prec_phase_degree?.[e]??1;Fv.set(parseInt(e,10),{angles:n,phaseDegree:r})}})();return e.catch(()=>{Lv===e&&(Lv=null)}),Lv=e,e}function zv(e,t){let n=nv(e);if(n===null||!t)return;let r=Fv.get(n>=100?Math.trunc(n/100):n);return r&&{...t,...r}}function Bv(e){return Iv.get(e)}var Vv=132712440018,Hv=86400;function Uv(e){if(!bv(e.parentId))return;let t=Number(e.id.replace(/^naif-/,``));if(!Number.isFinite(t))return;let n=Bv(t>=1&&t<=9?t*100+99:t),r=e.a*vg;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*Vv))/vg}var Wv=`class-`,Gv=`flag-`,Kv=`cat-`;`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`;var qv=`${Kv}asteroids`,Jv=`${Kv}comets`,Yv=`${Kv}satellites`,Xv=`${Kv}debris`;`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`,`${Kv}`;var Zv={neo:1,pha:2},Qv=new Set([`ETc`,`JFc`,`JFC`,`CTc`,`HTC`,`PAR`,`HYP`,`COM`]);function $v(e){return Qv.has(e)?`comet`:`asteroid`}function ey(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 ty=null;function ny(){if(ty)return ty;let e=Pv(`${Kt()}/v1/groups/__index__.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch group index: ${e.status}`);return e.json()});return ty=e,e.catch(()=>{ty===e&&(ty=null)}),ty}var ry=[`planets`,`dwarfPlanets`,`moons`,`asteroids`,`comets`,`spacecraft`,`satellites`,`debris`,`orbits`,`labels`,`halos`,`nomenclature`,`stars`],iy=new Set(ry),ay={[G.PLANET]:`planets`,[G.DWARF_PLANET]:`dwarfPlanets`,[G.MOON]:`moons`,[G.ASTEROID]:`asteroids`,[G.ASTEROID_INNER]:`asteroids`,[G.ASTEROID_MAIN_BELT]:`asteroids`,[G.ASTEROID_TROJAN]:`asteroids`,[G.ASTEROID_CENTAUR]:`asteroids`,[G.ASTEROID_TNO]:`asteroids`,[G.COMET]:`comets`,[G.DEBRIS]:`debris`},oy=`small_bodies/`,sy=new Set([`COM`,`PAR`,`HYP`,`HYA`,`JFC`,`JFc`,`HTC`,`CTc`]);function cy(e){return e===`moons`||e.startsWith(`moons/`)||e===`small_body_moons`?`moons`:e.startsWith(`probes/`)?`spacecraft`:e.startsWith(oy)?sy.has(e.slice(13))?`comets`:`asteroids`:null}function ly(e,t){return e===G.SPACECRAFT?t===`naif-399`?`satellites`:`spacecraft`:ay[e]??null}var uy=class{skipped;hiddenIds;onChange=null;constructor(e={}){let t=new Set;for(let n of ry)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 iy.has(e)}skipsZone(e){if(e===`earth`)return this.skipped.has(`satellites`)&&this.skipped.has(`debris`);let t=cy(e);return t!==null&&this.skipped.has(t)}hidesZone(e){let t=cy(e);return t!==null&&!this.isVisible(t)}hidesBody(e,t){let n=ly(e,t);return n!==null&&!this.isVisible(n)}hidesSpacecraftGroup(e){return e===`naif-399`?!this.isVisible(`satellites`)&&!this.isVisible(`debris`):!this.isVisible(`spacecraft`)}};function dy(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 fy=`small_bodies/`;function py(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!==G.DWARF_PLANET)return null;let i=r.data.a,a=r.data.e;if(!bv(r.data.parentId)){let t=e.bodiesById.get(r.data.parentId);t?.data.a&&(i=t.data.a,a=t.data.e)}return _n(i,a)}function my(e,t,n){if(n.kind===`class`||n.kind===`category`){let r=py(e,t);return r===null?!1:n.kind===`class`?r===n.className:$v(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}({}),hy=1503,gy={[$.CLOSE]:.3,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},_y={[$.CLOSE]:.01,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},vy=1/3;function yy(e,t,n,r){return e<=t[$.CLOSE]?$.CLOSE:e<=t[$.FULL]*(r?n:1)?$.FULL:e<=t[$.FAR]?$.FAR:$.HIDE}var by=new uy,xy=3,Sy=4e6/vg;function Cy(e){return Sn(e)||e===G.COMET||e===G.DWARF_PLANET}var wy=class{#e=Ke(Qe(ev));get focusedBodyId(){return Ht(this.#e)}set focusedBodyId(e){qe(this.#e,e,!0)}#t=Ke(null);get focusedSystemId(){return Ht(this.#t)}set focusedSystemId(e){qe(this.#t,e,!0)}activeSystemId=null;isZoomedIn=!1;focusedBodyIdPlain=ev;focusedSystemIdPlain=null;travelSystemActive=!1;cameraDistThreeJS=0;lastRecomputeDist=-1;currentJd=0;hideThresholdAU=0;scaledPlanetary=gy;scaledSystem=_y;fullMoonIds=new Set;moonVisibilityCache=new Map;pinned=new Set;constructor(e,t=()=>null,n=()=>null,r=()=>null,i=()=>by){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/hy)**1.5,n=e=>({...e,[$.FULL]:e[$.FULL]*t,[$.FAR]:e[$.FAR]*t});this.scaledPlanetary=n(gy),this.scaledSystem=n(_y)}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!==W.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===G.BARYCENTER&&bv(e.data.parentId)&&!bv(e.data.id),n=e.data.objectType===G.STAR||!t&&bv(e.data.parentId);if(t)return e.data.id;if(n)return Cy(e.data.objectType)?e.data.id:null;let r=this.bodies.bodiesById.get(e.data.parentId);return r&&!bv(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&&Sn(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=yy(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===W.SPICE_PROBE)return this.getProbeVisibility(e,t);let r=this.getEarthSatGroupFilter();if(r&&e.data.parentId===`naif-399`&&!r.has(e.data.id))return $.HIDE;let i=e.data.objectType;if((Sn(i)||i===G.COMET||i===G.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 yy(t/10/n,this.scaledPlanetary,5,r)}let a=e.data.a;if(!bv(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=yy(t/10/a,this.scaledSystem,50,o);return s===$.CLOSE?$.FULL:s}getProbeVisibility(e,t){let n=this.getProbeStore();if((n?n.containingSystemAt(e.data.id,this.currentJd):null)===xy&&this.getEarthSatGroupFilter())return $.HIDE;let r=e.data.id===this.focusedBodyIdPlain;if(!(n&&!n.hasHeliocentricFit(e.data.id,this.currentJd))){let t=this.bodies.bodiesById.get(ev),n=t?.position&&e.position?Ev(e.position,t.position)/10:0;if(n===0)return $.FULL;let i=yy(this.cameraDistThreeJS/10/n,this.scaledSystem,50,r);return i===$.CLOSE?$.FULL:i}if(!this.isProbeInFocusedSystem(e))return $.HIDE;let i=this.bodies.bodiesById.get(e.data.parentId);if(!i?.position||!e.position)return $.FULL;let a=Ev(e.position,i.position)/10;return a===0||t/10/a<=this.scaledPlanetary[$.FULL]*(r?5:1)?$.FULL:$.HIDE}isProbeInFocusedSystem(e){let t=e.data.parentId;if(!bv(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(bv(e.data.parentId)?e.data.id:e.data.parentId))return!0;if(e.data.orbitalSource!==W.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.bodies.bodiesById.get(e);if(e!==`naif-0`&&!t?.position)return!1;let n=this.activeSystemId;return bv(e)||t?.data.objectType===G.STAR?!n:n?e===n?!0:this.bodies.getChildren(n)?.has(e)??!1:!1}isAsteroidGroupVisible(e){if(this.getLayers().hidesZone(e)||this.activeSystemId||!this.bodies.bodiesById.get(`naif-10`)?.position)return!1;let t=this.getSmallBodyFilter();if(t&&e.startsWith(`small_bodies/`)){let n=e.slice(fy.length);if(t.kind===`class`&&n!==t.className||t.kind===`category`&&$v(n)!==t.category)return!1}let n=gn[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===G.MOON,i=this.getProbeStore(),a=r?this.getMoonVisibility(t):this.getPlanetVisibility(t,this.cameraDistThreeJS);return{id:e,name:t.data.name,objectType:G[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:my(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===G.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(Cy(n.data.objectType))return Sy;let r=Uv(n.data);return r?r*vy:0}},Ty=``;function Ey(e){let t=new Map;if(!e)return t;for(let n of e.split(`
4051
- `)){let e=n.indexOf(Ty);if(e===-1)continue;let r=n.slice(0,e),i=n.slice(e+1),a=i.indexOf(Ty),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 Dy=new Map;async function Oy(e=c()){let t=Dy.get(e);return t||(t=(async()=>{let t=nn(e),n=await Pv(t,{priority:`high`});if(!n.ok)throw Error(`Failed to fetch ${t}: ${n.status}`);let r=new DecompressionStream(`gzip`);return Ey(await new Response(n.body.pipeThrough(r)).text())})(),Dy.set(e,t),t.catch(()=>{Dy.get(e)===t&&Dy.delete(e)})),t}var ky=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 Ay(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=tn;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 _=mn(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 jy(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 My(e,t,n,r){let i=jy(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 Ny=1e-7,Py=.001,Fy=1,Iy=2,Ly=16,Ry=32;function zy(e,t,n){let r=new DataView(e,t,Ry),i=r.getInt32(0,!0),a=r.getUint8(4),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=r.getInt32(16,!0)*Ny,l=r.getInt32(20,!0)*Ny,u=r.getInt32(24,!0)*Py,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+Ry,d*Ly);for(let e=0;e<d;e++){let t=e*Ly;f[e]=n+r.getUint32(t,!0),p[e]=r.getInt32(t+4,!0)*Ny,m[e]=r.getInt32(t+8,!0)*Ny,h[e]=r.getInt32(t+12,!0)*Py}}return{bodyNaifId:i,isStatic:(a&Fy)!==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 By(e,t,n,r){let i=n/(36*(r?8:4));return{method:3,coeffsPerAxis:12,nSeg:i,coeffs:jy(e,t,i*3*12,r)}}function Vy(e,t,n,r){let i=new DataView(e),a=i.getUint32(24,!0),o=i.getFloat32(28,!0),s=o*Dg,c=Vg(t),l=[],u=tn;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),v=ln[i.getUint8(u+18)];u+=20;let y=mn(a,n)??``;y||console.warn(`probes payload: probe[${t}] (value=${n}) has unknown id-type ${a}; skipping`);let b=null;if(h!==-1&&g!==255){let e=mn(g,h);e?b={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 x=Array(p),S=Array(p),C=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(x[n]=d,S[n]=d+s,a===0)C[n]={method:0};else if(a===1||a===2)C[n]=My(e,l,a,r);else if(a===3)C[n]=By(e,l,o,r);else throw Error(`Unknown probe sub-chunk method ${a} at probe ${t} sub ${n}`);u=l+o}let w;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;w=zy(e,a,c),u=a+r}let T=Array(_);for(let e=0;e<_;e++)T[e]={startEt:i.getFloat64(u,!0),endEt:i.getFloat64(u+8,!0),systemNaifId:i.getUint8(u+16)},u+=17;l.push({id:y,probeId:n,hasLocalized:d,objectType:o,archive:v,fitCenter:b,subStartEt:x,subEndEt:S,subChunks:C,landed:w,systemIntervals:T})}return{startJd:t,endJd:n,subchunkDays:o,probes:l}}function Hy(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:Bh(e,o,s)};if(a===1)return{kind:`chebyshev`,chunk:Ay(e,o,s)};if(a===2)return{kind:`probes`,chunk:Vy(e,o,s,t.probesFloat64??!1)};throw Error(`Unknown position-file format: ${a}`)}function Uy(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 Wy(e,t){let n=Lg(t),r=Uy(e.startJds,e.endJds,n);if(r<0)return null;let i=e.startJds[r],a=e.endJds[r],o=2*(n-i)/(a-i)-1,s=e.coeffsPerAxis,c=e.coeffs,l=r*3*s,u=[0,0,0],d=2*o;for(let e=0;e<3;e++){let t=l+e*s;if(s===1){u[e]=c[t];continue}let n=0,r=0;for(let e=s-1;e>=1;e--){let i=c[t+e]+d*n-r;r=n,n=i}u[e]=c[t]+o*n-r}return u}function Gy(e,t){let n=Wy(e,t);return n===null?null:[Q(n[0]),Q(n[2]),-Q(n[1])]}function Ky(e,t){let n=Lg(t),r=Uy(e.startJds,e.endJds,n);if(r<0)return null;let i=e.startJds[r],a=e.endJds[r],o=2*(n-i)/(a-i)-1,s=2/(a-i),c=e.coeffsPerAxis,l=e.coeffs,u=r*3*c,d=[0,0,0],f=[0,0,0],p=2*o;for(let e=0;e<3;e++){let t=u+e*c;if(c===1){d[e]=l[t],f[e]=0;continue}let n=0,r=0;for(let e=c-1;e>=1;e--){let i=l[t+e]+p*n-r;r=n,n=i}d[e]=l[t]+o*n-r;let i=0,a=0;for(let e=c-2;e>=0;e--){let n=l[t+e+1]*(e+1)+p*i-a;a=i,i=n}f[e]=i*s}return{position:d,velocity:f}}Math.PI/180;var qy=180/Math.PI;vg/86400;var Jy=1e-9,Yy=1e-9;function Xy(e,t,n){return e<t?t:e>n?n:e}function Zy(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(Xy(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;_<Yy||E===0?D=0:(D=Math.acos(Xy(w/E,-1,1)),T<0&&(D=2*Math.PI-D));let O;if(x<Jy)O=0;else if(_<Yy||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(Xy(e,-1,1)),b<0&&(O=2*Math.PI-O)}let k,A=i*s+a*c+o*l;if(x<Jy&&(_<Yy||E===0))k=Math.atan2(a,i),m<0&&(k=-k),k<0&&(k+=2*Math.PI);else if(x<Jy){let e=(w*i+T*a)/(E*u);k=Math.acos(Xy(e,-1,1)),o<0&&(k=2*Math.PI-k)}else{let e=(v*i+y*a+b*o)/(x*u);k=Math.acos(Xy(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),N=Math.sqrt(n/(M*M*M))*qy;return{a:C,e:x,i:g*qy,om:D*qy,w:O*qy,ma:j*qy,n:N,epoch:r,equatorial:!1}}function Qy(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 $y(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 eb(e,t,n,r,i,a){if(t>=1)return null;let o=c_(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:$y(f,p,r,n,i)}function tb(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 eb(e.aKm,e.e,e.iRad,e.om0,e.w0,o)}function nb(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 eb(e.aKm,e.e,e.iRad,i,a,o)}function rb(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 ib(e,t,n,r,i){switch(e.method){case 0:return null;case 1:return tb(e,t,r,i);case 2:return nb(e,t,r);case 3:return rb(e,t,n,r)}}function ab(e,t,n){let r=zg(t),i=Qy(e,r);return i<0?null:ib(e.subChunks[i],e.subStartEt[i],e.subEndEt[i],r,n)}function ob(e,t,n){let r=ab(e,t,n);return r===null?null:[Q(r[0]),Q(r[2]),-Q(r[1])]}function sb(e){if(!e.landed)return!1;let t=e.subEndEt.length;return t===0||e.subEndEt[t-1]<=e.landed.endEt}function cb(e,t){if(!e.landed)return!1;let n=zg(t);return n>=e.landed.startEt&&(n<e.landed.endEt||sb(e))}function lb(e,t,n=!1){let r=zg(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 ub=30/Dg;function db(e,t,n){let r=ab(e,t,n);if(r===null)return null;let i=ub,a=ab(e,t+i,n),o=ab(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]}}var fb=180/Math.PI;function pb(e,t,n){if(n<=0)return null;let r=Math.sqrt(n/(e.aKm*e.aKm*e.aKm)),i=Bg(t+e.tAnchorOffsetS);return{a:e.aKm/vg,e:e.e,i:e.iRad*fb,om:e.om0*fb,w:e.w0*fb,ma:e.m0*fb,n:r*fb*Dg,epoch:i,equatorial:!1}}function mb(e,t){let n=Bg(t+e.tAnchorOffsetS);return{a:e.aKm/vg,e:e.e,i:e.iRad*fb,om:e.om0*fb,w:e.w0*fb,ma:e.m0*fb,n:e.nMeanRadS*fb*Dg,omDot:e.omDot*fb*Dg,wDot:e.wDot*fb*Dg,epoch:n,equatorial:!1}}function hb(e,t,n){if(n<=0)return null;let r=db(e,t,n);if(!r)return null;let i=n*bg;return Zy([r.position[0]/vg,r.position[1]/vg,r.position[2]/vg],[r.velocity[0]*xg,r.velocity[1]*xg,r.velocity[2]*xg],i,Lg(t))}function gb(e,t,n){let r=Qy(e,zg(t));if(r<0)return null;let i=e.subChunks[r];switch(i.method){case 0:return null;case 1:return pb(i,e.subStartEt[r],n);case 2:return mb(i,e.subStartEt[r]);case 3:return hb(e,t,n)}}function _b(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=Ky(a,t),c=Ky(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 vb(e){let t=e-18e6;if(t>=2e6&&t<=2999999){let e=Bv(t);if(e!==void 0)return{naifId:t,muKm3S2:e}}return{naifId:e,muKm3S2:Bv(e)??0}}function yb(e,t,n,r,i){let a=`naif-${n}`,o=e.fitCenter;if(o&&o.id!==a){let n=_b(e,t,a,r);return n?{id:n.id,naifId:n.naifId,muKm3S2:Bv(n.naifId)??0}:i?.(o.id)?o.idType===un.SPKID?{id:o.id,...vb(o.idValue)}:{id:o.id,naifId:o.idValue,muKm3S2:Bv(o.idValue)??0}:null}return{id:a,naifId:n,muKm3S2:Bv(n)??0}}var bb=1/256,xb=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}},Sb=200;function Cb(e,t,n,r=!1){if(r)return{stepDays:Sb/n,epsilonScene:1/0,spanDays:Sb};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 wb(e){let t=Number(e.slice(5));return e=>e===t}function Tb(e,t,n,r){let i=wb(r);return a=>{let o=e.probeWithCenter(n,a,i);if(!o)return null;let s=yb(o.probe,a,o.fitCenterNaifId,t,e=>e===r);return!s||s.id!==r?null:ob(o.probe,a,s.muKm3S2)}}function Eb(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 Db=.005;function Ob(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,Db*i)},c=t+o*a,l=e(c);if(l!==null&&s(Eb(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(Eb(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 kb(e,t,n,r,i,a){Ab(e,Tb(t,n,r,i),a)}function Ab(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*bb,o=n-e.spanDays;for(;i.length<e.capacity;){let n=i[i.length-1];if(n.jd<=o)break;let s=Ob(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 jb(e,t,n,r,i){if(!isFinite(e.epsilonScene))return;let a=e.stepDays*16,o=e.stepDays*bb,s=n,c=r;for(let n=0;n<e.capacity&&!(i-s<=o);n++){let n=Math.min(a,i-s),r=Ob(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 Mb(e,t){let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=(e[i][0]-t[0])**2+(e[i][1]-t[1])**2+(e[i][2]-t[2])**2;a<r&&(r=a,n=i)}let i=Math.max(n-1,0),a=Math.min(n+1,e.length-1);return(e[i][0]-t[0])**2+(e[i][1]-t[1])**2+(e[i][2]-t[2])**2<(e[a][0]-t[0])**2+(e[a][1]-t[1])**2+(e[a][2]-t[2])**2?i:n}function Nb(e,t,n,r,i,a,o){if(t.length===0)return[];let s=e.trailAnchor??e.position;if(!s)return[];let c=[s[0]-r,s[1]-i,s[2]-a],l=o??Mb(t,c),u=[c];if(n)for(let e=0;e<511;e++){let n=Math.max(l-e,0);if(u.push(t[n]),n===0)break}else{for(let e=0;e<511;e++)u.push(t[((l-e)%512+512)%512]);u.push(c)}return u.filter(e=>e.every(Number.isFinite))}function Pb(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 Fb=0,Ib=10;function Lb(e,t,n,r){let i=Bv(t);if(!i)return null;let a=Ky(e,n);if(!a)return null;let o=r?Ky(r,n):null;if(r&&!o)return null;let s=i*bg;return Zy([(a.position[0]-(o?.position[0]??0))/vg,(a.position[1]-(o?.position[1]??0))/vg,(a.position[2]-(o?.position[2]??0))/vg],[(a.velocity[0]-(o?.velocity[0]??0))*xg,(a.velocity[1]-(o?.velocity[1]??0))*xg,(a.velocity[2]-(o?.velocity[2]??0))*xg],s,Lg(n))}function Rb(e,t,n){return!n||e.parentId!==Fb||e.naifId===Ib?null:Lb(e,Ib,t,n)}function zb(e,t,n,r){return r?on(e,t,r,n):an(e,t,n)}var Bb=new ky(8);async function Vb(e,t,n,r,i){let a=`${e}:${t??``}:${n}:${r??``}`;return Bb.getOrCompute(a,async()=>{let a=await Pv(zb(e,t,n,r),{priority:i});if(!a.ok)throw Error(`Failed to fetch elements: ${a.status}`);let o=new DecompressionStream(`gzip`),s=Hy(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 Hb=class{static prefetch(e,t,n,r=null){fetch(zb(e,t,n,r)).catch(()=>{})}barycenters=new Map;probeBuffers=new Map;constructor(e){this.cheb=e}processChebyshev(e,t){if(!this.cheb)return[];let n=jg(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===G.BARYCENTER?0:e.objectType===G.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=Gy(e,n);if(!o)continue;a.set(e.naifId,e);let d=`naif-${e.parentId}`,f=e.objectType,p=f===G.MOON&&e.parentId>=1&&e.parentId<=9?`naif-${e.parentId*100+99}`:null,m=(e,t)=>{if(!p)return Lb(e,e.parentId,t);let n=s.body(p,t);return n?Lb(e,e.parentId,t,n):null},h=m(e,n),g=e.id,_=e=>{let t=s.body(g,e);return t?m(t,e):null},v=Math.hypot(o[0],o[1],o[2])/10,y={id:e.id,name:M_(t,e.id),isMinor:N_(t,e.id),hasLocalized:e.hasLocalized,objectType:f,parentId:`naif-${e.parentId}`,radiusKm:e.radiusKm,a:h?Math.abs(h.a):v,e:h?.e??0,i:h?.i??0,om:h?.om??0,w:h?.w??0,ma:h?.ma??0,n:h?.n??0,epoch:h?.epoch??0,equatorial:!1,helioElements:Rb(e,n,c)??void 0,validityStart:l,validityEnd:u,orbitalSource:W.SPICE,visibleFromDays:e.visibleFromDays};if(f===G.BARYCENTER||f===G.LAGRANGE_POINT){r&&h&&h.a>0&&h.e<1&&this.barycenters.set(e.id,h),i.push({data:y,position:null,orbitElements:h??void 0,orbitCenterId:d,rederiveElements:_});continue}if(Cn(f)){let t=f===G.MOON,n=this.barycenters.get(d),r=t?h:n??h,o=!t&&n!==void 0,c=a.get(e.parentId)?.id,l=o&&c?e=>{let t=s.body(c,e);return t?Lb(t,t.parentId,e):null}:_;i.push({data:y,position:null,orbitElements:r??void 0,orbitCenterId:o?void 0:p??d,trailAnchorId:o?d:void 0,rederiveElements:l})}else i.push({data:y,position:null,orbitElements:h??void 0,orbitCenterId:d,rederiveElements:_})}return i}processProbes(e,t,n){let r=jg(t),i=[],a=new Map,o=new Set;for(let{id:t,probe:s,zoneCenterNaifId:c,startJd:l,endJd:u}of e.probesAt(r)){if(!t)continue;c===void 0&&o.add(t);let d=`naif-${c}`,f=c===void 0?null:yb(s,r,c,this.cheb,()=>!0),p=f?f.id:d,m=f?.muKm3S2??0;if(m===0){let e=a.get(p);e||a.set(p,e=new Set),e.add(t)}let h={id:t,name:M_(n,t),isMinor:N_(n,t),hasLocalized:s.hasLocalized,objectType:s.objectType,parentId:p,loadParentId:p,radiusKm:NaN,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,equatorial:!1,validityStart:l,validityEnd:u,orbitalSource:W.SPICE_PROBE,orbitArchive:s.archive},g=gb(s,r,m),_=t,v=this.cheb,y=t=>{let n=e.probeWithCenter(_,t);if(!n)return null;let r=yb(n.probe,t,n.fitCenterNaifId,v,()=>!0);return r?gb(n.probe,t,r.muKm3S2):null},b;{let{stepDays:e,epsilonScene:n,spanDays:r}=Cb(g,u-l,512),i=this.probeBuffers.get(t);i&&i.parentKey===p?(b=i.buffer,!isFinite(b.epsilonScene)&&isFinite(n)&&b.reconfigure(e,n,r)):(b=new xb(512,e,n,r),b.needsPopulate=!0,this.probeBuffers.set(t,{buffer:b,parentKey:p}))}i.push({data:h,position:null,orbitElements:g??void 0,orbitCenterId:p,rederiveElements:y,trailBuffer:b})}o.size>0&&console.error(`processProbes: ${o.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(o).slice(0,10).join(`, `)}`+(o.size>10?` (+${o.size-10} more)`:``));for(let[e,t]of a)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 i}async fetchMinorColumns(e,t,n,r=null,i){return Vb(e,t,n,r,i)}async process(e,t,n,r=null,i=`naif`,a){let o=this.barycenters.size===0,s=[],c=0,[l,u]=await Promise.all([Vb(e,t,n,r,a),Oy()]),d=l.kind===`parabolic`,f=l.kind===`sgp4`,p=performance.now();for(let e=0;e<l.rowCount;e++){(e&255)==255&&performance.now()-p>6&&(await m_(),p=performance.now());let t=l.objectType[e];if(!d&&l.a[e]===0&&t!==G.BARYCENTER&&t!==G.LAGRANGE_POINT&&!Cn(t)){c++;continue}let n=`${i}-${l.parentId[e]}`,r=d?I_(l,e,u,i):f?V_(l,e,u,i):F_(l,e,u,i);if(r){if(t===G.BARYCENTER||t===G.LAGRANGE_POINT){o&&r.a>0&&r.e<1&&this.barycenters.set(r.id,r),s.push({data:r,position:null,orbitElements:r.a>0?r:void 0,orbitCenterId:n});continue}if(Cn(t)){let e=t===G.MOON,i=this.barycenters.has(n);s.push({data:r,position:null,orbitElements:e?r:this.barycenters.get(n)??r,orbitCenterId:e||!i?n:void 0})}else s.push({data:r,position:null})}}return c>0&&console.debug(`process(${e}/${t}/${n}): skipped ${c} row(s) with a = 0`),s}},Ub=new Map,Wb=null,Gb=null;function Kb(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 qb(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 Jb(){if(Gb)return Gb;let e=(async()=>{let e=await Pv(`${Kt()}/v1/atmospheres.json`);if(!e.ok){console.warn(`atmospheres: fetch failed (${e.status}) — rendering without shells`);return}let t=await e.json();Wb=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),Ub.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:Kb(n.seasonal),referenceAltitudeKm:n.reference_altitude_km,deepColumn:qb(e,n.deep_column,t.deep_n)})}})();return e.catch(()=>{Gb===e&&(Gb=null)}),Gb=e,e}function Yb(e){return Ub.get(e)}function Xb(){return Wb}var Zb=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 Qb(e,t){return e>>>t|e<<32-t}function $b(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=Qb(i[e-15],7)^Qb(i[e-15],18)^i[e-15]>>>3,n=Qb(i[e-2],17)^Qb(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=Qb(c,6)^Qb(c,11)^Qb(c,25),a=c&l^~c&u,f=d+t+a+Zb[e]+i[e]|0,p=(Qb(n,2)^Qb(n,13)^Qb(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 ex(e){return e.shape===`parted`}function tx(e){return e.shape===`chunked-parted`&&e.label===`date`}function nx(e){return e.shape===`chunked-parted`&&e.label===`index`}function rx(e){return e.shape===`chunked`}function ix(e,t){let n=Math.floor((Lg(t)-e.start_jd)/e.chunk_days);return Math.max(0,Math.min(e.chunks-1,n))}function ax(e){return`shape`in e&&e.shape===`probes`}function ox(e){return`zooms`in e}function sx(e){return ax(e)?[]:ox(e)?Object.entries(e.zooms).map(([e,t])=>({zoom:Number(e),data:t})):[{zoom:null,data:e}]}function cx(e){return!ox(e)&&!ax(e)?e:void 0}var lx=new WeakMap;function ux(e){let t=lx.get(e);return t||(t=Object.keys(e.parts_by_date).map(e=>Date.parse(`${e}T00:00:00Z`)).sort((e,t)=>e-t),lx.set(e,t)),t}function dx(e,t){let n=ux(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 fx=14;function px(e){let t=ux(e);return t[t.length-1]+fx*864e5}function mx(e,t){let n=ux(e),r=t.getTime(),i=fx*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 hx(e,t,n=0){let r=e.parts_by_date[t]??e.parts;return n>0?Math.min(r,n):r}var gx=null;function _x(){if(gx)return gx;let e=Pv(`${Kt()}/v1/metadata.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch metadata: ${e.status}`);return e.json()}).then(e=>(Zt(e.versions),e));return gx=e,e.catch(()=>{gx===e&&(gx=null)}),gx}function vx(e){let t=new Map;for(let[n,r]of Object.entries(e.position.zones)){if(ax(r))continue;let e=ox(r)?0:null,i=e===0?r.zooms[0]:r;!i||!rx(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 yx(e){let t=new Map,n=Object.entries(e.position.zones).filter(([,e])=>ax(e)).sort(([e],[t])=>(e===`probes/interplanetary`)-+(t===`probes/interplanetary`)||e.localeCompare(t));for(let[e,r]of n)ax(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 bx(e,t){let n=new TextEncoder().encode(e),r=crypto.subtle?await crypto.subtle.digest(`SHA-256`,n):$b(n).buffer;return new DataView(r).getUint32(0,!1)%t}async function xx(e,t){let n=await Pv(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 Sx(e,t,n,r){let i=Hy(await xx(sn(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 Cx=2e3,wx=6e4,Tx=.25,Ex=class{failures=new Map;constructor(e=()=>{},t=Math.random){this.onDue=e,this.random=t}waiting(e){return this.failures.get(e)?.timer!==void 0}fail(e){let t=this.failures.get(e);clearTimeout(t?.timer);let n={count:(t?.count??0)+1,timer:void 0},r=Math.min(Cx*2**(n.count-1),wx),i=1+Tx*(2*this.random()-1);n.timer=setTimeout(()=>{n.timer=void 0,this.onDue(e)},r*i),this.failures.set(e,n)}clear(e){clearTimeout(this.failures.get(e)?.timer),this.failures.delete(e)}},Dx=1,Ox=Promise.resolve();function kx(e,t){return`${e}:${t}`}var Ax=class{chunks=new Map;inflight=new Map;retries=new Ex(()=>{this.retryDue=!0,this._version++});retryDue=!1;lastEnsuredJd=NaN;_version=0;constructor(e){this.zoneParams=e}get version(){return this._version}zones(){return Array.from(this.zoneParams.keys())}ensure(e){e===this.lastEnsuredJd&&!this.retryDue||this.pass(e,!1)}load(e){return this.pass(e,!0)}pass(e,t){this.lastEnsuredJd=e,this.retryDue=!1;let n=[],r=[];for(let[i,a]of this.zoneParams){let o=ix(a,e);if(this.isLoadable(a,o)){let e=this.loadChunk(i,a,o,`high`,t);e&&n.push(e)}for(let e=-Dx;e<=Dx;e++){let t=o+e;e===0||t<0||t>=a.chunks||this.isLoadable(a,t)&&r.push([i,a,t])}this.evictOutsideWindow(i,o)}let i=n.length>0?Promise.all(n).then(()=>void 0):Ox;return i.catch(()=>{}).then(()=>{for(let[e,t,n]of r)this.loadChunk(e,t,n,`low`)?.catch(()=>{})}),i}request(e){for(let[t,n]of this.zoneParams){let r=ix(n,e);this.isLoadable(n,r)&&this.loadChunk(t,n,r,`high`,!0)?.catch(()=>{})}}loadingAt(e,t){if(this.inflight.size===0)return!1;for(let[n,r]of this.zoneParams)if(!(t!==void 0&&n!==t)&&this.inflight.has(kx(n,ix(r,e))))return!0;return!1}awaitedAt(e,t){for(let[n,r]of this.zoneParams){if(t!==void 0&&n!==t)continue;let i=kx(n,ix(r,e));if(this.inflight.has(i)||this.retries.waiting(i))return!0}return!1}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-Dx||e>t+Dx)&&n.delete(e)}loadChunk(e,t,n,r,i=!1){if(this.isResident(e,n))return null;let a=kx(e,n);return this.inflight.get(a)||(!i&&this.retries.waiting(a)?null:this.track(a,this.fetchAndStore(e,t,n,r)))}track(e,t){this.inflight.set(e,t);let n=n=>{this.inflight.get(e)===t&&this.inflight.delete(e),n?this.retries.clear(e):this.retries.fail(e)};return t.then(()=>n(!0),t=>{console.warn(`[position] chunk ${e} did not load:`,t),n(!1)}),t}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._version++,this.afterStore(e,i)}},jx=class extends Ax{idToZone=new Map;isLoadable(){return!0}fetchChunk(e,t,n,r){return Sx(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:Rg(n.start_jd),end:Rg(n.end_jd)}:null}isAwaited(e,t){let n=this.idToZone.get(e);return n!==void 0&&this.awaitedAt(t,n)}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=ix(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=ix(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?Gy(n.body,t):null}};async function Mx(e,t,n,r){let i=sn(e,null,t),a=await Pv(i,{priority:r});if(!a.ok)throw Error(`Failed to fetch ${i}: ${a.status}`);let o=new DecompressionStream(`gzip`),s=Hy(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 Nx=24;function Px(e,t){for(let[n,r]of e){if(t<n)return!1;if(t<=r)return!0}return!1}var Fx=7,Ix=class extends Ax{fitCenterUsable=null;warmed=new Map;carried=new Map;zoneCenter(e){return this.zoneParams.get(e)?.fit_center_naif_id}isLoadable(e,t){return Px(e.present,t)}fetchChunk(e,t,n,r){return Mx(e,n,t.float64_coeffs,r)}afterStore(){}async warmAt(e){let t=[];for(let[n,r]of this.zoneParams){let i=ix(r,e);if(i<0||i>=r.chunks||!Px(r.present,i)||this.isResident(n,i))continue;let a=kx(n,i);this.warmed.has(a)||t.push(this.inflight.get(a)??this.track(a,this.fetchAndWarm(a,n,i,r)))}await Promise.all(t)}async fetchAndWarm(e,t,n,r){let i=await Mx(t,n,r.float64_coeffs,`low`);for(this.warmed.set(e,i);this.warmed.size>Nx;){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=ix(a,e),s=this.chunks.get(i)?.get(o)??this.warmed.get(kx(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+Fx?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+Fx)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=zg(t),i=null;for(let[a,o]of this.zoneParams){let s=ix(o,t),c=this.chunks.get(a)?.get(s)??this.warmed.get(kx(a,s));if(c)for(let t of Bx(c,e)){let e=c.probes[t];if(!this.fitCenterCovered(e))break;let s=Qy(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=zg(t);for(let[r,i]of this.zoneParams){let a=ix(i,t),o=this.chunks.get(r)?.get(a)??this.warmed.get(kx(r,a));if(o)for(let t of Bx(o,e)){let e=o.probes[t];if(Qy(e,n)<0)break;return e.fitCenter?.id??null}}return null}landingBodyAt(e,t){let n=this.probe(e,t);return n?.landed&&cb(n,t)?`naif-${n.landed.bodyNaifId}`: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?ab(i.probe,t,n):null}positionScene(e,t,n,r){let i=this.resolve(e,t,r);return i?ob(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=zg(t),r=this.zoneParams.get(Lx);if(r){let i=ix(r,t),a=this.chunks.get(Lx)?.get(i);if(a)for(let t of Bx(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===Lx||r.fit_center_naif_id===10)continue;let i=ix(r,t),a=this.chunks.get(n)?.get(i);if(a)for(let t of Bx(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(Lx);if(!n)return!1;let r=ix(n,t),i=this.chunks.get(Lx)?.get(r);if(!i)return!1;let a=zg(t);for(let t of Bx(i,e))if(Qy(i.probes[t],a)>=0)return!0;return!1}},Lx=`probes/interplanetary`,Rx=[],zx=new WeakMap;function Bx(e,t){let n=zx.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])}zx.set(e,n)}return n.get(t)??Rx}var Vx=15e3;async function Hx(){try{let e=await fetch(`${Kt()}/v1/metadata.json`,{cache:`no-store`,signal:AbortSignal.timeout(Vx)});if(!e.ok)return!1;let t=await e.json(),n=Qt();if(Object.keys(n).length===0)return!1;let r=t.versions??{},i=new Set([...Object.keys(n),...Object.keys(r)]);for(let e of i)if(n[e]!==r[e])return!0;return!1}catch{return!1}}function Ux(e){return new Response(e.body.pipeThrough(new DecompressionStream(`gzip`)))}async function Wx(e){return await Ux(e).json()}function Gx(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 Wx(a)})();return a=t,t.catch(()=>{a===t&&(a=null)}),t}}var Kx=24,qx=new Map;function Jx(e,t){let n=qx.get(e);if(n&&(qx.delete(e),qx.set(e,n)),!n){n=(async()=>{let n=await Pv(e,t);if(!n.ok){if(n.status===404)return{};throw Error(`fetchGzipBundle: ${e} returned ${n.status} ${n.statusText}`)}return Wx(n)})(),qx.set(e,n),n.catch(()=>{qx.get(e)===n&&qx.delete(e)});for(let e of qx.keys()){if(qx.size<=Kx)break;qx.delete(e)}}return n}var Yx={counts:`object_bundles`,globalPath:e=>`/v1/objects/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/objects/${e}/${t}.json.gz`,versionClass:`objects`},Xx={counts:`group_bundles`,globalPath:e=>`/v1/groups/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/groups/${e}/${t}.json.gz`},Zx=(e,t)=>Jx(t?$t(e,t):`${Kt()}${e}`),Qx=(e,t)=>Jx(t?$t(e,t):`${Kt()}${e}`,{priority:`low`});async function $x(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?bx(t,s):-1,c?bx(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 eS(e,t,n,r=!0,i=!1){return $x(e,t,{meta:await _x(),lang:n,localized:r,fetchBundle:i?Qx:Zx})}function tS(e){return o(e.distribution)}function nS(e,t=!0,n=c(),r=!1){return eS(Yx,e,n,t,r)}async function rS(e){if(e?.startsWith(`probe-`))try{let t=(await nS(e,!1)).global,n=t?.coverage?.position_from;return n?{id:e,carriedFrom:n,carrierName:t?.carried_by?.name}:void 0}catch{return}}function iS(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}}var aS=1/1440;function oS(e){return(e?.coverage?.windows.length??0)>0}async function sS(){let e=(await _x()).position.zones.earth,t=e&&sx(e).find(e=>tx(e.data))?.data;return t&&tx(t)?Ag(px(t)):1/0}async function cS(e){let t=await nS(e,!1),n=t.global?.coverage?.windows??[],r=t.global?.orbit?.scale===`planet`,i=r?await sS():1/0;return n.map(([e,t])=>[e??-1/0,t==null?i:r?t:Rg(t)]).filter(([e,t])=>t>e)}function lS(e,t){let n=null;for(let[r,i]of e){if(t>r&&t<i)return t;let e=Math.min(aS,(i-r)/2),a=t<=r?r+e:i-e;(n===null||Math.abs(a-t)<Math.abs(n-t))&&(n=a)}return n}function uS(e){return G[e.toUpperCase()]??G.UNDOCUMENTED}var dS={horizons:W.HORIZONS,sbdb:W.SBDB,celestrak:W.CELESTRAK,spacetrack:W.SPACETRACK,spice:W.SPICE,sbdb_moons:W.SBDB_MOON,astersat:W.ASTERSAT};function fS(e){return e?dS[e]??W.UNKNOWN:W.UNKNOWN}var pS=14;function mS(e,t){let n=t.global,r=n?.orbit;if(!n||!r||!oS(n))return null;let i=r.q!=null&&r.tp!=null;if(!i&&(r.epoch_jd==null||r.a==null||r.ma==null||r.n==null))return null;let a=r.scale===`planet`,o=n.cross_refs?.norad_cat_id,s=a&&r.bstar!=null&&r.mean_motion_dot!=null&&r.mean_motion_ddot!=null&&r.n!=null&&o!=null?{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}:void 0,c=s?i_(s,n.name??void 0)??void 0:void 0,l=n.coverage?.windows[0]?.[0];return{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:uS(n.type),parentId:r.parent_id,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,a:a?(r.a??0)/vg:r.a??0,e:r.e,i:r.i,om:r.om,w:r.w,ma:r.ma??0,n:a?(r.n??0)*360:r.n??0,epoch:r.epoch_jd,equatorial:a,validityStart:s?r.epoch_jd-pS:-1/0,validityEnd:s?r.epoch_jd+pS:1/0,orbitalSource:fS(r.source),...l==null?{}:{visibleFromDays:l-Eg},...i?{q:r.q,tp:r.tp}:{},...s?{omm:s}:{},...c?{satrec:c}:{}}}function hS(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:uS(n.type),parentId:n.host_id??``,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,pageOnly:!0,a:NaN,e:NaN,i:NaN,om:NaN,w:NaN,ma:NaN,n:NaN,epoch:NaN,validityStart:-1/0,validityEnd:1/0,orbitalSource:W.UNKNOWN}:null}async function gS(e,t,n=new Set){if(n.has(e))return console.warn(`createPlaceholderBody: cycle detected at ${e} — hiding`),[];n.add(e);let r=await nS(e),i=r.global;if(!i)return console.warn(`createPlaceholderBody: no catalogue record for ${e} — hiding`),[];let a=i.sbdb?.class??null,o=mS(e,r)??hS(e,r);if(!o)return[];let s=o.parentId,c=s===``||s===`naif-0`||t.getBody(s)?[]:await gS(s,t,n),l=o.pageOnly?{data:o,position:null}:{data:o,position:null,orbitElements:o,orbitCenterId:s};return[...c,{body:l,zone:a}]}function _S(e,t,n){let r=0;for(let i=0;i<t.length;i++){let{body:a,zone:o}=t[i];if(e.getBody(a.data.id))continue;let s=a.data.objectType,c=s===G.SPACECRAFT||s===G.DEBRIS,l=i>0?t[i-1]:null,u=s===G.MOON&&l&&Sn(l.body.data.objectType)?`small_body_moons`:o;c&&a.data.parentId!==``?(e.bodies.putSpacecraft(a)&&r++,e.bodies.dirtySpacecraftGroups.add(a.data.parentId)):u&&!a.data.pageOnly?(e.bodies.asteroidBucket(u,n).addPlaceholder(a),e.bodies.dirtyAsteroidZones.add(u),r++):e.bodies.addBodies([a]),e.credits.recordOrbitSources([a])}return r}async function vS(e,t){if(e.getBody(t))return;let n=await gS(t,e);if(n.length===0)return;let r=_S(e,n,await Oy());e.bodies.flushMinor(r>0)}var yS=Math.PI/180,bS=36525;function xS(e,t,n){let r=Lg(t)-Eg,i=r/bS,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=n.phaseDegree+1,u=Math.min(Math.floor(c.length/l),Math.max(e.length,t.length,r.length));for(let n=0;n<u;n++){let u=0;for(let e=l-1;e>=0;e--)u=u*i+c[l*n+e];let d=u*yS,f=Math.sin(d);n<e.length&&(a+=e[n]*f),n<t.length&&(o+=t[n]*Math.cos(d)),n<r.length&&(s+=r[n]*f)}}return{ra:a,dec:o,w:s}}function SS(e,t,n){let{ra:r,dec:i,w:a}=xS(e,t,n),o=r*yS,s=i*yS,c=Math.cos(s),l=Tg(c*Math.cos(o),c*Math.sin(o),Math.sin(s),new J).normalize(),u=Tg(-Math.sin(o),Math.cos(o),0,new J).normalize(),d=new J().crossVectors(u,l).normalize(),f=new Zi().setFromRotationMatrix(new Y().makeBasis(u,l,d));return new Zi().setFromAxisAngle(l,a*yS).multiply(f)}function CS(e,t,n,r){e.quaternion.copy(SS(t,n,r))}var wS=new J(0,1,0),TS=new J;function ES(e,t,n){TS.set(t[0]-n[0],t[1]-n[1],t[2]-n[2]),!(TS.lengthSq()<1e-20)&&(TS.normalize(),e.quaternion.setFromUnitVectors(wS,TS))}function DS(e,t){e.quaternion.setFromUnitVectors(wS,t)}var OS={"+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 kS(e){let t=[];for(let[n,r]of Object.entries(e)){let e=OS[n],i=OS[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 Zi().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 Zi().setFromRotationMatrix(c.multiply(l))}var AS=new J,jS=new J,MS=new J,NS=new J,PS=new J,FS=new J,IS=new J,LS=new J,RS=new Y,zS=new Y;function BS(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 VS(e,t,n){if(!BS(t.primary.target,n,AS))return;let r=OS[t.primary.axis],i=t.secondary;if(!i||!BS(i.target,n,jS)){e.quaternion.setFromUnitVectors(r,AS);return}if(PS.crossVectors(r,OS[i.axis]),LS.crossVectors(AS,jS),PS.lengthSq()<1e-20||LS.lengthSq()<1e-20){e.quaternion.setFromUnitVectors(r,AS);return}PS.normalize(),LS.normalize(),MS.copy(r),FS.copy(AS),NS.crossVectors(PS,MS),IS.crossVectors(LS,FS),RS.makeBasis(FS,IS,LS),zS.makeBasis(MS,NS,PS).transpose(),RS.multiply(zS),e.quaternion.setFromRotationMatrix(RS)}function HS(e,t){let n=e,r=n.userData.shaderMods??=[];r.includes(t)||(r.push(t),e.customProgramCacheKey=()=>r.map(e=>typeof e==`string`?e:e()).join(`|`))}function US(e,t,n){let r=e.onBeforeCompile;e.onBeforeCompile=(e,t)=>{r?.(e,t),n(e,t)},HS(e,t),e.needsUpdate=!0}var WS=class extends no{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Zc;e.deleteAttribute(`uv`);let t=new Ou({side:1}),n=new Ou,r=new Td(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new Ws(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new gc(e,n,6),o=new qa;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 Ws(e,GS(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new Ws(e,GS(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new Ws(e,GS(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new Ws(e,GS(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new Ws(e,GS(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new Ws(e,GS(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 GS(e){return new Au({color:0,emissive:16777215,emissiveIntensity:e})}var KS=.01,qS=3.5,JS=.04;function YS(e){let t=Math.max(e/10,.01);return 1/(t*t)}function XS(e,t,n=1){e.decay=t?2:0,e.intensity=(t?qS*10*10:qS)*n}function ZS(e){let t=new Nf(e),n=t.fromScene(new WS).texture;return t.dispose(),n}var QS=[1,.97075,.952],$S=[1.02,.99,.97],eC=Math.sin(8*Math.PI/180);function tC(e){return e<.001?e*(1-.5*e):1-Math.exp(-e)}function nC(e,t,n){let r=Math.max(e,1e-4),i=Math.max(t,1e-4),a=Math.max(n,1e-6);return e/(r+i)*tC(a*(1/r+1/i))/(.5*tC(2*a/eC))}var rC=3,iC=12;rC*(iC/2+1);var aC=1e-4,oC=256,sC=new Float64Array(oC),cC=6,lC=24,uC=48;function dC(e,t,n){return .2126*e+.7152*t+.0722*n}var fC=Float64Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4});function pC(e,t,n,r,i,a){let o=new Float64Array(oC),s=new Float64Array(oC),c=new Float64Array(oC),l=new Float64Array(oC),u=dC(...QS),[d,f,p]=$S,m=[0,0,0],h=(e,n)=>(e*t+n)*4;for(let g=0;g<oC;g++){let _=Math.floor(g*t/oC),v=Math.max(_+1,Math.floor((g+1)*t/oC)),y=r+(g+.5)/oC*(i-r);for(let t=_;t<v;t++){let r=h(n.color,t),i=fC[e[r]],_=fC[e[r+1]],v=fC[e[r+2]],b=Math.min(1,(1-e[h(n.transparency,t)]/255)*a),x=e[h(n.backscattered,t)]/255*a;o[g]+=x*dC(i,_,v),s[g]+=e[h(n.forwardscattered,t)]/255*b*a*dC(i*d,_*f,v*p),c[g]+=e[h(n.unlitside,t)]/255*b*a*u,l[g]+=1-b,m[0]+=x*i*y,m[1]+=x*_*y,m[2]+=x*v*y}let b=v-_;o[g]/=b,s[g]/=b,c[g]/=b,l[g]/=b}let g=dC(m[0],m[1],m[2]);return{inner:r,outer:i,back:o,forward:s,unlit:c,transmission:l,litTint:g>0?new X(m[0],m[1],m[2]).multiplyScalar(1/g):new X(1,1,1),bands:mC(o,c,r,i)}}function mC(e,t,n,r){let i=new Float64Array(oC+1);for(let a=0;a<oC;a++){let o=n+(a+.5)/oC*(r-n);i[a+1]=i[a]+(e[a]+t[a])/o}let a=i[oC],o=new Int32Array(rC+1);o[rC]=oC;for(let e=1;e<rC;e++){let t=o[e-1]+1;for(;t<oC-(rC-e)&&i[t]<a*e/rC;)t++;o[e]=t}return o}function hC(e){let t=Math.min(Math.max((e+1)/2,0),1);return 1-t*t*(3-2*t)}var gC=3.09;function _C(e){return(1-Math.acos(Math.min(Math.max(e,-1),1))/Math.PI)**gC}function vC(e,t,n,r,i){let a=e/i.equatorial,o=t/i.equatorial,s=n/i.equatorial,c=r/i.polar,l=a*s;return l>=0?!1:a*a+o*o-l*l/(s*s+c*c)<1}function yC(e,t,n,r){let i=Math.sqrt(Math.max(0,1-n*n)),a=Math.abs(n),o=n>=0,{inner:s,outer:c,back:l,forward:u,unlit:d,transmission:f,bands:p}=t;for(let e=0;e<oC;e++)sC[e]=nC(a,a,-Math.log(Math.max(f[e],1e-6)));let m=(c-s)/oC,h=2*Math.PI/iC,g=h/cC,_=0;for(let t=0;t<rC;t++)for(let a=0;a<=iC/2;a++,_++){let c=0,f=0,v=0,y=0,b=0;for(let e=0;e<cC;e++){let _=(a-.5)*h+(e+.5)*g,x=Math.cos(_),S=Math.sin(_),C=hC(-i*x),w=_C(-i*x);for(let e=p[t];e<p[t+1];e++){let t=s+(e+.5)*m;if(vC(t*x,t*S,i,n,r))continue;let a=t*m*g,p=(l[e]*w+(u[e]-l[e]*w)*C)*sC[e]*a,h=d[e]*a;c+=o?p:h,f+=o?h:p;let _=p+h;v+=_,y+=_*t*x,b+=_*t*Math.abs(S)}}let x=a===0||a===iC/2?.5:1;if(v>0)e[4*_]=y/v,e[4*_+1]=b/v;else{let n=s+(p[t]+p[t+1])/2*m;e[4*_]=n*Math.cos(a*h),e[4*_+1]=n*Math.abs(Math.sin(a*h))}e[4*_+2]=c*x,e[4*_+3]=f*x}}function bC(e,t,n,r,i,a,o,s){let c=i>=0,l=Math.abs(i),u=n*n+r*r+i*i,d=a*n+o*r+s*i,f=0;for(let i=0;i<21;i++){let s=e[4*i],p=e[4*i+1],m=c?e[4*i+2]:e[4*i+3],h=u+s*s+p*p-2*s*n,g=2*p*r,_=s*a-d,v=p*o;for(let e of[1,-1]){let n=h-e*g,r=Math.sqrt(n),i=Math.max(_+e*v,0);f+=m*i/(n*r*(t*r+l))}}return 2*t*l*f}function xC(e,t,n,r,i,a){if(Math.abs(a)<1e-6)return 1;let o=-r/a;if(o<0)return 1;let s=(Math.hypot(t+o*i,n)-e.inner)/(e.outer-e.inner);if(s<0||s>1)return 1;let c=Math.min(Math.floor(s*oC),oC-1);return Math.max(e.transmission[c],1e-4)**(1/Math.max(Math.abs(a),.02))}var SC={x:new Float64Array(lC*uC),y:new Float64Array(lC*uC),z:new Float64Array(lC*uC),nx:new Float64Array(lC*uC),ny:new Float64Array(lC*uC),nz:new Float64Array(lC*uC),light:new Float64Array(lC*uC)};function CC(e,t,n,r,i,a,o){let s=Math.sqrt(Math.max(0,1-r*r)),c=Math.abs(r),{equatorial:l,polar:u}=i,d=SC,f=Math.PI/lC,p=2*Math.PI/uC;for(let e=0;e<lC;e++){let t=-Math.PI/2+(e+.5)*f,n=Math.cos(t),i=Math.sin(t),m=l*n*Math.sqrt(u*u*n*n+l*l*i*i)*f*p;for(let t=0;t<uC;t++){let f=(t+.5)*p,h=Math.cos(f),g=Math.sin(f),_=e*uC+t,v=l*n*h,y=l*n*g,b=u*i,x=n*h/l,S=n*g/l,C=i/u,w=Math.hypot(x,S,C);x/=w,S/=w,C/=w;let T=x*s+C*r,E=T>0?T*xC(a,v,y,b,s,r):0,D=c<aC?0:bC(o,c,v,y,b,x,S,C)/qS;d.x[_]=v,d.y[_]=y,d.z[_]=b,d.nx[_]=x,d.ny[_]=S,d.nz[_]=C,d.light[_]=(E+D)/Math.PI*m}}for(let r=0;r<8;r++){let i=t+r/7*(n-t);for(let t=0;t<19;t++){let n=1-2*t/18,a=i*n,o=i*Math.sqrt(1-n*n),s=0,c=0,l=0,u=0;for(let e=0;e<lC*uC;e++){let t=a-d.x[e],n=o-d.y[e],r=-d.z[e],i=t*t+n*n+r*r,f=d.nx[e]*t+d.ny[e]*n+d.nz[e]*r;if(f<=0)continue;let p=Math.sqrt(i),m=d.light[e]*f/(i*p),h=Math.abs(r)/p;d.z[e]>0?(s+=m,l+=m*h):(c+=m,u+=m*h)}let f=4*(r*19+t);e[f]=s,e[f+1]=c,e[f+2]=s>0?l/s:0,e[f+3]=c>0?u/c:0}}}var wC=new Float32Array(608);function TC(e){let t=new ic(new Uint16Array(608),19,8,ar,Zn);return t.minFilter=Vn,t.magFilter=Vn,t.wrapS=In,t.wrapT=In,t.needsUpdate=!0,{profile:e,planet:{equatorial:0,polar:0},planetLight:t,planetLightSinB:NaN,patches:new Float64Array(84),patchesSinB:NaN}}function EC(e,t,n){CC(wC,e.profile.inner,e.profile.outer,t,e.planet,n.profile,n.patches);let r=e.planetLight.image.data;for(let e=0;e<wC.length;e++)r[e]=Lo.toHalfFloat(wC[e]);e.planetLight.needsUpdate=!0,e.planetLightSinB=t}function DC(e,t){let n=new Float64Array(84);yC(n,e,1,t);let r=0;for(let e=2;e<90;e+=2){let i=e*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=a/t.equatorial,c=o/t.polar,l=Math.hypot(s,c),u=bC(n,1,t.equatorial*a,0,t.polar*o,s/l,0,c/l);r=Math.max(r,u/qS)}return r}var OC=`
4051
+ `)){let e=n.indexOf(Ty);if(e===-1)continue;let r=n.slice(0,e),i=n.slice(e+1),a=i.indexOf(Ty),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 Dy=new Map;async function Oy(e=c()){let t=Dy.get(e);return t||(t=(async()=>{let t=nn(e),n=await Pv(t,{priority:`high`});if(!n.ok)throw Error(`Failed to fetch ${t}: ${n.status}`);let r=new DecompressionStream(`gzip`);return Ey(await new Response(n.body.pipeThrough(r)).text())})(),Dy.set(e,t),t.catch(()=>{Dy.get(e)===t&&Dy.delete(e)})),t}var ky=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 Ay(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=tn;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 _=mn(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 jy(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 My(e,t,n,r){let i=jy(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 Ny=1e-7,Py=.001,Fy=1,Iy=2,Ly=16,Ry=32;function zy(e,t,n){let r=new DataView(e,t,Ry),i=r.getInt32(0,!0),a=r.getUint8(4),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=r.getInt32(16,!0)*Ny,l=r.getInt32(20,!0)*Ny,u=r.getInt32(24,!0)*Py,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+Ry,d*Ly);for(let e=0;e<d;e++){let t=e*Ly;f[e]=n+r.getUint32(t,!0),p[e]=r.getInt32(t+4,!0)*Ny,m[e]=r.getInt32(t+8,!0)*Ny,h[e]=r.getInt32(t+12,!0)*Py}}return{bodyNaifId:i,isStatic:(a&Fy)!==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 By(e,t,n,r){let i=n/(36*(r?8:4));return{method:3,coeffsPerAxis:12,nSeg:i,coeffs:jy(e,t,i*3*12,r)}}function Vy(e,t,n,r){let i=new DataView(e),a=i.getUint32(24,!0),o=i.getFloat32(28,!0),s=o*Dg,c=Vg(t),l=[],u=tn;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),v=ln[i.getUint8(u+18)];u+=20;let y=mn(a,n)??``;y||console.warn(`probes payload: probe[${t}] (value=${n}) has unknown id-type ${a}; skipping`);let b=null;if(h!==-1&&g!==255){let e=mn(g,h);e?b={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 x=Array(p),S=Array(p),C=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(x[n]=d,S[n]=d+s,a===0)C[n]={method:0};else if(a===1||a===2)C[n]=My(e,l,a,r);else if(a===3)C[n]=By(e,l,o,r);else throw Error(`Unknown probe sub-chunk method ${a} at probe ${t} sub ${n}`);u=l+o}let w;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;w=zy(e,a,c),u=a+r}let T=Array(_);for(let e=0;e<_;e++)T[e]={startEt:i.getFloat64(u,!0),endEt:i.getFloat64(u+8,!0),systemNaifId:i.getUint8(u+16)},u+=17;l.push({id:y,probeId:n,hasLocalized:d,objectType:o,archive:v,fitCenter:b,subStartEt:x,subEndEt:S,subChunks:C,landed:w,systemIntervals:T})}return{startJd:t,endJd:n,subchunkDays:o,probes:l}}function Hy(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:Bh(e,o,s)};if(a===1)return{kind:`chebyshev`,chunk:Ay(e,o,s)};if(a===2)return{kind:`probes`,chunk:Vy(e,o,s,t.probesFloat64??!1)};throw Error(`Unknown position-file format: ${a}`)}function Uy(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 Wy(e,t){let n=Lg(t),r=Uy(e.startJds,e.endJds,n);if(r<0)return null;let i=e.startJds[r],a=e.endJds[r],o=2*(n-i)/(a-i)-1,s=e.coeffsPerAxis,c=e.coeffs,l=r*3*s,u=[0,0,0],d=2*o;for(let e=0;e<3;e++){let t=l+e*s;if(s===1){u[e]=c[t];continue}let n=0,r=0;for(let e=s-1;e>=1;e--){let i=c[t+e]+d*n-r;r=n,n=i}u[e]=c[t]+o*n-r}return u}function Gy(e,t){let n=Wy(e,t);return n===null?null:[Q(n[0]),Q(n[2]),-Q(n[1])]}function Ky(e,t){let n=Lg(t),r=Uy(e.startJds,e.endJds,n);if(r<0)return null;let i=e.startJds[r],a=e.endJds[r],o=2*(n-i)/(a-i)-1,s=2/(a-i),c=e.coeffsPerAxis,l=e.coeffs,u=r*3*c,d=[0,0,0],f=[0,0,0],p=2*o;for(let e=0;e<3;e++){let t=u+e*c;if(c===1){d[e]=l[t],f[e]=0;continue}let n=0,r=0;for(let e=c-1;e>=1;e--){let i=l[t+e]+p*n-r;r=n,n=i}d[e]=l[t]+o*n-r;let i=0,a=0;for(let e=c-2;e>=0;e--){let n=l[t+e+1]*(e+1)+p*i-a;a=i,i=n}f[e]=i*s}return{position:d,velocity:f}}Math.PI/180;var qy=180/Math.PI;vg/86400;var Jy=1e-9,Yy=1e-9;function Xy(e,t,n){return e<t?t:e>n?n:e}function Zy(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(Xy(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;_<Yy||E===0?D=0:(D=Math.acos(Xy(w/E,-1,1)),T<0&&(D=2*Math.PI-D));let O;if(x<Jy)O=0;else if(_<Yy||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(Xy(e,-1,1)),b<0&&(O=2*Math.PI-O)}let k,A=i*s+a*c+o*l;if(x<Jy&&(_<Yy||E===0))k=Math.atan2(a,i),m<0&&(k=-k),k<0&&(k+=2*Math.PI);else if(x<Jy){let e=(w*i+T*a)/(E*u);k=Math.acos(Xy(e,-1,1)),o<0&&(k=2*Math.PI-k)}else{let e=(v*i+y*a+b*o)/(x*u);k=Math.acos(Xy(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),N=Math.sqrt(n/(M*M*M))*qy;return{a:C,e:x,i:g*qy,om:D*qy,w:O*qy,ma:j*qy,n:N,epoch:r,equatorial:!1}}function Qy(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 $y(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 eb(e,t,n,r,i,a){if(t>=1)return null;let o=c_(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:$y(f,p,r,n,i)}function tb(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 eb(e.aKm,e.e,e.iRad,e.om0,e.w0,o)}function nb(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 eb(e.aKm,e.e,e.iRad,i,a,o)}function rb(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 ib(e,t,n,r,i){switch(e.method){case 0:return null;case 1:return tb(e,t,r,i);case 2:return nb(e,t,r);case 3:return rb(e,t,n,r)}}function ab(e,t,n){let r=zg(t),i=Qy(e,r);return i<0?null:ib(e.subChunks[i],e.subStartEt[i],e.subEndEt[i],r,n)}function ob(e,t,n){let r=ab(e,t,n);return r===null?null:[Q(r[0]),Q(r[2]),-Q(r[1])]}function sb(e){if(!e.landed)return!1;let t=e.subEndEt.length;return t===0||e.subEndEt[t-1]<=e.landed.endEt}function cb(e,t){if(!e.landed)return!1;let n=zg(t);return n>=e.landed.startEt&&(n<e.landed.endEt||sb(e))}function lb(e,t,n=!1){let r=zg(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 ub=30/Dg;function db(e,t,n){let r=ab(e,t,n);if(r===null)return null;let i=ub,a=ab(e,t+i,n),o=ab(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]}}var fb=180/Math.PI;function pb(e,t,n){if(n<=0)return null;let r=Math.sqrt(n/(e.aKm*e.aKm*e.aKm)),i=Bg(t+e.tAnchorOffsetS);return{a:e.aKm/vg,e:e.e,i:e.iRad*fb,om:e.om0*fb,w:e.w0*fb,ma:e.m0*fb,n:r*fb*Dg,epoch:i,equatorial:!1}}function mb(e,t){let n=Bg(t+e.tAnchorOffsetS);return{a:e.aKm/vg,e:e.e,i:e.iRad*fb,om:e.om0*fb,w:e.w0*fb,ma:e.m0*fb,n:e.nMeanRadS*fb*Dg,omDot:e.omDot*fb*Dg,wDot:e.wDot*fb*Dg,epoch:n,equatorial:!1}}function hb(e,t,n){if(n<=0)return null;let r=db(e,t,n);if(!r)return null;let i=n*bg;return Zy([r.position[0]/vg,r.position[1]/vg,r.position[2]/vg],[r.velocity[0]*xg,r.velocity[1]*xg,r.velocity[2]*xg],i,Lg(t))}function gb(e,t,n){let r=Qy(e,zg(t));if(r<0)return null;let i=e.subChunks[r];switch(i.method){case 0:return null;case 1:return pb(i,e.subStartEt[r],n);case 2:return mb(i,e.subStartEt[r]);case 3:return hb(e,t,n)}}function _b(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=Ky(a,t),c=Ky(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 vb(e){let t=e-18e6;if(t>=2e6&&t<=2999999){let e=Bv(t);if(e!==void 0)return{naifId:t,muKm3S2:e}}return{naifId:e,muKm3S2:Bv(e)??0}}function yb(e,t,n,r,i){let a=`naif-${n}`,o=e.fitCenter;if(o&&o.id!==a){let n=_b(e,t,a,r);return n?{id:n.id,naifId:n.naifId,muKm3S2:Bv(n.naifId)??0}:i?.(o.id)?o.idType===un.SPKID?{id:o.id,...vb(o.idValue)}:{id:o.id,naifId:o.idValue,muKm3S2:Bv(o.idValue)??0}:null}return{id:a,naifId:n,muKm3S2:Bv(n)??0}}var bb=1/256,xb=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}},Sb=200;function Cb(e,t,n,r=!1){if(r)return{stepDays:Sb/n,epsilonScene:1/0,spanDays:Sb};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 wb(e){let t=Number(e.slice(5));return e=>e===t}function Tb(e,t,n,r){let i=wb(r);return a=>{let o=e.probeWithCenter(n,a,i);if(!o)return null;let s=yb(o.probe,a,o.fitCenterNaifId,t,e=>e===r);return!s||s.id!==r?null:ob(o.probe,a,s.muKm3S2)}}function Eb(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 Db=.005;function Ob(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,Db*i)},c=t+o*a,l=e(c);if(l!==null&&s(Eb(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(Eb(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 kb(e,t,n,r,i,a){Ab(e,Tb(t,n,r,i),a)}function Ab(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*bb,o=n-e.spanDays;for(;i.length<e.capacity;){let n=i[i.length-1];if(n.jd<=o)break;let s=Ob(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 jb(e,t,n,r,i){if(!isFinite(e.epsilonScene))return;let a=e.stepDays*16,o=e.stepDays*bb,s=n,c=r;for(let n=0;n<e.capacity&&!(i-s<=o);n++){let n=Math.min(a,i-s),r=Ob(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 Mb(e,t){let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=(e[i][0]-t[0])**2+(e[i][1]-t[1])**2+(e[i][2]-t[2])**2;a<r&&(r=a,n=i)}let i=Math.max(n-1,0),a=Math.min(n+1,e.length-1);return(e[i][0]-t[0])**2+(e[i][1]-t[1])**2+(e[i][2]-t[2])**2<(e[a][0]-t[0])**2+(e[a][1]-t[1])**2+(e[a][2]-t[2])**2?i:n}function Nb(e,t,n,r,i,a,o){if(t.length===0)return[];let s=e.trailAnchor??e.position;if(!s)return[];let c=[s[0]-r,s[1]-i,s[2]-a],l=o??Mb(t,c),u=[c];if(n)for(let e=0;e<511;e++){let n=Math.max(l-e,0);if(u.push(t[n]),n===0)break}else{for(let e=0;e<511;e++)u.push(t[((l-e)%512+512)%512]);u.push(c)}return u.filter(e=>e.every(Number.isFinite))}function Pb(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 Fb=0,Ib=10;function Lb(e,t,n,r){let i=Bv(t);if(!i)return null;let a=Ky(e,n);if(!a)return null;let o=r?Ky(r,n):null;if(r&&!o)return null;let s=i*bg;return Zy([(a.position[0]-(o?.position[0]??0))/vg,(a.position[1]-(o?.position[1]??0))/vg,(a.position[2]-(o?.position[2]??0))/vg],[(a.velocity[0]-(o?.velocity[0]??0))*xg,(a.velocity[1]-(o?.velocity[1]??0))*xg,(a.velocity[2]-(o?.velocity[2]??0))*xg],s,Lg(n))}function Rb(e,t,n){return!n||e.parentId!==Fb||e.naifId===Ib?null:Lb(e,Ib,t,n)}function zb(e,t,n,r){return r?on(e,t,r,n):an(e,t,n)}var Bb=new ky(8);async function Vb(e,t,n,r,i){let a=`${e}:${t??``}:${n}:${r??``}`;return Bb.getOrCompute(a,async()=>{let a=await Pv(zb(e,t,n,r),{priority:i});if(!a.ok)throw Error(`Failed to fetch elements: ${a.status}`);let o=new DecompressionStream(`gzip`),s=Hy(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 Hb=class{static prefetch(e,t,n,r=null){fetch(zb(e,t,n,r)).catch(()=>{})}barycenters=new Map;probeBuffers=new Map;constructor(e){this.cheb=e}processChebyshev(e,t){if(!this.cheb)return[];let n=jg(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===G.BARYCENTER?0:e.objectType===G.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=Gy(e,n);if(!o)continue;a.set(e.naifId,e);let d=`naif-${e.parentId}`,f=e.objectType,p=f===G.MOON&&e.parentId>=1&&e.parentId<=9?`naif-${e.parentId*100+99}`:null,m=(e,t)=>{if(!p)return Lb(e,e.parentId,t);let n=s.body(p,t);return n?Lb(e,e.parentId,t,n):null},h=m(e,n),g=e.id,_=e=>{let t=s.body(g,e);return t?m(t,e):null},v=Math.hypot(o[0],o[1],o[2])/10,y={id:e.id,name:M_(t,e.id),isMinor:N_(t,e.id),hasLocalized:e.hasLocalized,objectType:f,parentId:`naif-${e.parentId}`,radiusKm:e.radiusKm,a:h?Math.abs(h.a):v,e:h?.e??0,i:h?.i??0,om:h?.om??0,w:h?.w??0,ma:h?.ma??0,n:h?.n??0,epoch:h?.epoch??0,equatorial:!1,helioElements:Rb(e,n,c)??void 0,validityStart:l,validityEnd:u,orbitalSource:W.SPICE,visibleFromDays:e.visibleFromDays};if(f===G.BARYCENTER||f===G.LAGRANGE_POINT){r&&h&&h.a>0&&h.e<1&&this.barycenters.set(e.id,h),i.push({data:y,position:null,orbitElements:h??void 0,orbitCenterId:d,rederiveElements:_});continue}if(Cn(f)){let t=f===G.MOON,n=this.barycenters.get(d),r=t?h:n??h,o=!t&&n!==void 0,c=a.get(e.parentId)?.id,l=o&&c?e=>{let t=s.body(c,e);return t?Lb(t,t.parentId,e):null}:_;i.push({data:y,position:null,orbitElements:r??void 0,orbitCenterId:o?void 0:p??d,trailAnchorId:o?d:void 0,rederiveElements:l})}else i.push({data:y,position:null,orbitElements:h??void 0,orbitCenterId:d,rederiveElements:_})}return i}processProbes(e,t,n){let r=jg(t),i=[],a=new Map,o=new Set;for(let{id:t,probe:s,zoneCenterNaifId:c,startJd:l,endJd:u}of e.probesAt(r)){if(!t)continue;c===void 0&&o.add(t);let d=`naif-${c}`,f=c===void 0?null:yb(s,r,c,this.cheb,()=>!0),p=f?f.id:d,m=f?.muKm3S2??0;if(m===0){let e=a.get(p);e||a.set(p,e=new Set),e.add(t)}let h={id:t,name:M_(n,t),isMinor:N_(n,t),hasLocalized:s.hasLocalized,objectType:s.objectType,parentId:p,loadParentId:p,radiusKm:NaN,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,equatorial:!1,validityStart:l,validityEnd:u,orbitalSource:W.SPICE_PROBE,orbitArchive:s.archive},g=gb(s,r,m),_=t,v=this.cheb,y=t=>{let n=e.probeWithCenter(_,t);if(!n)return null;let r=yb(n.probe,t,n.fitCenterNaifId,v,()=>!0);return r?gb(n.probe,t,r.muKm3S2):null},b;{let{stepDays:e,epsilonScene:n,spanDays:r}=Cb(g,u-l,512),i=this.probeBuffers.get(t);i&&i.parentKey===p?(b=i.buffer,!isFinite(b.epsilonScene)&&isFinite(n)&&b.reconfigure(e,n,r)):(b=new xb(512,e,n,r),b.needsPopulate=!0,this.probeBuffers.set(t,{buffer:b,parentKey:p}))}i.push({data:h,position:null,orbitElements:g??void 0,orbitCenterId:p,rederiveElements:y,trailBuffer:b})}o.size>0&&console.error(`processProbes: ${o.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(o).slice(0,10).join(`, `)}`+(o.size>10?` (+${o.size-10} more)`:``));for(let[e,t]of a)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 i}async fetchMinorColumns(e,t,n,r=null,i){return Vb(e,t,n,r,i)}async process(e,t,n,r=null,i=`naif`,a){let o=this.barycenters.size===0,s=[],c=0,[l,u]=await Promise.all([Vb(e,t,n,r,a),Oy()]),d=l.kind===`parabolic`,f=l.kind===`sgp4`,p=performance.now();for(let e=0;e<l.rowCount;e++){(e&255)==255&&performance.now()-p>6&&(await m_(),p=performance.now());let t=l.objectType[e];if(!d&&l.a[e]===0&&t!==G.BARYCENTER&&t!==G.LAGRANGE_POINT&&!Cn(t)){c++;continue}let n=`${i}-${l.parentId[e]}`,r=d?I_(l,e,u,i):f?V_(l,e,u,i):F_(l,e,u,i);if(r){if(t===G.BARYCENTER||t===G.LAGRANGE_POINT){o&&r.a>0&&r.e<1&&this.barycenters.set(r.id,r),s.push({data:r,position:null,orbitElements:r.a>0?r:void 0,orbitCenterId:n});continue}if(Cn(t)){let e=t===G.MOON,i=this.barycenters.has(n);s.push({data:r,position:null,orbitElements:e?r:this.barycenters.get(n)??r,orbitCenterId:e||!i?n:void 0})}else s.push({data:r,position:null})}}return c>0&&console.debug(`process(${e}/${t}/${n}): skipped ${c} row(s) with a = 0`),s}},Ub=new Map,Wb=null,Gb=null;function Kb(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 qb(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 Jb(){if(Gb)return Gb;let e=(async()=>{let e=await Pv(`${Kt()}/v1/atmospheres.json`);if(!e.ok){console.warn(`atmospheres: fetch failed (${e.status}) — rendering without shells`);return}let t=await e.json();Wb=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),Ub.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:Kb(n.seasonal),referenceAltitudeKm:n.reference_altitude_km,deepColumn:qb(e,n.deep_column,t.deep_n)})}})();return e.catch(()=>{Gb===e&&(Gb=null)}),Gb=e,e}function Yb(e){return Ub.get(e)}function Xb(){return Wb}var Zb=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 Qb(e,t){return e>>>t|e<<32-t}function $b(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=Qb(i[e-15],7)^Qb(i[e-15],18)^i[e-15]>>>3,n=Qb(i[e-2],17)^Qb(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=Qb(c,6)^Qb(c,11)^Qb(c,25),a=c&l^~c&u,f=d+t+a+Zb[e]+i[e]|0,p=(Qb(n,2)^Qb(n,13)^Qb(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 ex(e){return e.shape===`parted`}function tx(e){return e.shape===`chunked-parted`&&e.label===`date`}function nx(e){return e.shape===`chunked-parted`&&e.label===`index`}function rx(e){return e.shape===`chunked`}function ix(e,t){let n=Math.floor((Lg(t)-e.start_jd)/e.chunk_days);return Math.max(0,Math.min(e.chunks-1,n))}function ax(e){return`shape`in e&&e.shape===`probes`}function ox(e){return`zooms`in e}function sx(e){return ax(e)?[]:ox(e)?Object.entries(e.zooms).map(([e,t])=>({zoom:Number(e),data:t})):[{zoom:null,data:e}]}function cx(e){return!ox(e)&&!ax(e)?e:void 0}var lx=new WeakMap;function ux(e){let t=lx.get(e);return t||(t=Object.keys(e.parts_by_date).map(e=>Date.parse(`${e}T00:00:00Z`)).sort((e,t)=>e-t),lx.set(e,t)),t}function dx(e,t){let n=ux(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 fx=14;function px(e){let t=ux(e);return t[t.length-1]+fx*864e5}function mx(e,t){let n=ux(e),r=t.getTime(),i=fx*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 hx(e,t,n=0){let r=e.parts_by_date[t]??e.parts;return n>0?Math.min(r,n):r}var gx=null;function _x(){if(gx)return gx;let e=Pv(`${Kt()}/v1/metadata.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch metadata: ${e.status}`);return e.json()}).then(e=>(Zt(e.versions),e));return gx=e,e.catch(()=>{gx===e&&(gx=null)}),gx}function vx(e){let t=new Map;for(let[n,r]of Object.entries(e.position.zones)){if(ax(r))continue;let e=ox(r)?0:null,i=e===0?r.zooms[0]:r;!i||!rx(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 yx(e){let t=new Map,n=Object.entries(e.position.zones).filter(([,e])=>ax(e)).sort(([e],[t])=>(e===`probes/interplanetary`)-+(t===`probes/interplanetary`)||e.localeCompare(t));for(let[e,r]of n)ax(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 bx(e,t){let n=new TextEncoder().encode(e),r=crypto.subtle?await crypto.subtle.digest(`SHA-256`,n):$b(n).buffer;return new DataView(r).getUint32(0,!1)%t}async function xx(e,t){let n=await Pv(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 Sx(e,t,n,r){let i=Hy(await xx(sn(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 Cx=2e3,wx=6e4,Tx=.25,Ex=class{failures=new Map;constructor(e=()=>{},t=Math.random){this.onDue=e,this.random=t}waiting(e){return this.failures.get(e)?.timer!==void 0}fail(e){let t=this.failures.get(e);clearTimeout(t?.timer);let n={count:(t?.count??0)+1,timer:void 0},r=Math.min(Cx*2**(n.count-1),wx),i=1+Tx*(2*this.random()-1);n.timer=setTimeout(()=>{n.timer=void 0,this.onDue(e)},r*i),this.failures.set(e,n)}clear(e){clearTimeout(this.failures.get(e)?.timer),this.failures.delete(e)}},Dx=1,Ox=Promise.resolve();function kx(e,t){return`${e}:${t}`}var Ax=class{chunks=new Map;inflight=new Map;retries=new Ex(()=>{this.retryDue=!0,this._version++});retryDue=!1;lastEnsuredJd=NaN;_version=0;constructor(e){this.zoneParams=e}get version(){return this._version}zones(){return Array.from(this.zoneParams.keys())}ensure(e){e===this.lastEnsuredJd&&!this.retryDue||this.pass(e,!1)}load(e){return this.pass(e,!0)}pass(e,t){this.lastEnsuredJd=e,this.retryDue=!1;let n=[],r=[];for(let[i,a]of this.zoneParams){let o=ix(a,e);if(this.isLoadable(a,o)){let e=this.loadChunk(i,a,o,`high`,t);e&&n.push(e)}for(let e=-Dx;e<=Dx;e++){let t=o+e;e===0||t<0||t>=a.chunks||this.isLoadable(a,t)&&r.push([i,a,t])}this.evictOutsideWindow(i,o)}let i=n.length>0?Promise.all(n).then(()=>void 0):Ox;return i.catch(()=>{}).then(()=>{for(let[e,t,n]of r)this.loadChunk(e,t,n,`low`)?.catch(()=>{})}),i}request(e){for(let[t,n]of this.zoneParams){let r=ix(n,e);this.isLoadable(n,r)&&this.loadChunk(t,n,r,`high`,!0)?.catch(()=>{})}}loadingAt(e,t){if(this.inflight.size===0)return!1;for(let[n,r]of this.zoneParams)if(!(t!==void 0&&n!==t)&&this.inflight.has(kx(n,ix(r,e))))return!0;return!1}awaitedAt(e,t){for(let[n,r]of this.zoneParams){if(t!==void 0&&n!==t)continue;let i=kx(n,ix(r,e));if(this.inflight.has(i)||this.retries.waiting(i))return!0}return!1}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-Dx||e>t+Dx)&&n.delete(e)}loadChunk(e,t,n,r,i=!1){if(this.isResident(e,n))return null;let a=kx(e,n);return this.inflight.get(a)||(!i&&this.retries.waiting(a)?null:this.track(a,this.fetchAndStore(e,t,n,r)))}track(e,t){this.inflight.set(e,t);let n=n=>{this.inflight.get(e)===t&&this.inflight.delete(e),n?this.retries.clear(e):this.retries.fail(e)};return t.then(()=>n(!0),t=>{console.warn(`[position] chunk ${e} did not load:`,t),n(!1)}),t}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._version++,this.afterStore(e,i)}},jx=class extends Ax{idToZone=new Map;isLoadable(){return!0}fetchChunk(e,t,n,r){return Sx(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:Rg(n.start_jd),end:Rg(n.end_jd)}:null}isAwaited(e,t){let n=this.idToZone.get(e);return n!==void 0&&this.awaitedAt(t,n)}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=ix(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=ix(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?Gy(n.body,t):null}};async function Mx(e,t,n,r){let i=sn(e,null,t),a=await Pv(i,{priority:r});if(!a.ok)throw Error(`Failed to fetch ${i}: ${a.status}`);let o=new DecompressionStream(`gzip`),s=Hy(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 Nx=24;function Px(e,t){for(let[n,r]of e){if(t<n)return!1;if(t<=r)return!0}return!1}var Fx=7,Ix=class extends Ax{fitCenterUsable=null;warmed=new Map;carried=new Map;zoneCenter(e){return this.zoneParams.get(e)?.fit_center_naif_id}isLoadable(e,t){return Px(e.present,t)}fetchChunk(e,t,n,r){return Mx(e,n,t.float64_coeffs,r)}afterStore(){}async warmAt(e){let t=[];for(let[n,r]of this.zoneParams){let i=ix(r,e);if(i<0||i>=r.chunks||!Px(r.present,i)||this.isResident(n,i))continue;let a=kx(n,i);this.warmed.has(a)||t.push(this.inflight.get(a)??this.track(a,this.fetchAndWarm(a,n,i,r)))}await Promise.all(t)}async fetchAndWarm(e,t,n,r){let i=await Mx(t,n,r.float64_coeffs,`low`);for(this.warmed.set(e,i);this.warmed.size>Nx;){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=ix(a,e),s=this.chunks.get(i)?.get(o)??this.warmed.get(kx(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+Fx?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+Fx)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=zg(t),i=null;for(let[a,o]of this.zoneParams){let s=ix(o,t),c=this.chunks.get(a)?.get(s)??this.warmed.get(kx(a,s));if(c)for(let t of Bx(c,e)){let e=c.probes[t];if(!this.fitCenterCovered(e))break;let s=Qy(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=zg(t);for(let[r,i]of this.zoneParams){let a=ix(i,t),o=this.chunks.get(r)?.get(a)??this.warmed.get(kx(r,a));if(o)for(let t of Bx(o,e)){let e=o.probes[t];if(Qy(e,n)<0)break;return e.fitCenter?.id??null}}return null}landingBodyAt(e,t){let n=this.probe(e,t);return n?.landed&&cb(n,t)?`naif-${n.landed.bodyNaifId}`: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?ab(i.probe,t,n):null}positionScene(e,t,n,r){let i=this.resolve(e,t,r);return i?ob(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=zg(t),r=this.zoneParams.get(Lx);if(r){let i=ix(r,t),a=this.chunks.get(Lx)?.get(i);if(a)for(let t of Bx(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===Lx||r.fit_center_naif_id===10)continue;let i=ix(r,t),a=this.chunks.get(n)?.get(i);if(a)for(let t of Bx(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(Lx);if(!n)return!1;let r=ix(n,t),i=this.chunks.get(Lx)?.get(r);if(!i)return!1;let a=zg(t);for(let t of Bx(i,e))if(Qy(i.probes[t],a)>=0)return!0;return!1}},Lx=`probes/interplanetary`,Rx=[],zx=new WeakMap;function Bx(e,t){let n=zx.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])}zx.set(e,n)}return n.get(t)??Rx}var Vx=15e3;async function Hx(){try{let e=await fetch(`${Kt()}/v1/metadata.json`,{cache:`no-store`,signal:AbortSignal.timeout(Vx)});if(!e.ok)return!1;let t=await e.json(),n=Qt();if(Object.keys(n).length===0)return!1;let r=t.versions??{},i=new Set([...Object.keys(n),...Object.keys(r)]);for(let e of i)if(n[e]!==r[e])return!0;return!1}catch{return!1}}function Ux(e){return new Response(e.body.pipeThrough(new DecompressionStream(`gzip`)))}async function Wx(e){return await Ux(e).json()}function Gx(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 Wx(a)})();return a=t,t.catch(()=>{a===t&&(a=null)}),t}}var Kx=24,qx=new Map;function Jx(e,t){let n=qx.get(e);if(n&&(qx.delete(e),qx.set(e,n)),!n){n=(async()=>{let n=await Pv(e,t);if(!n.ok){if(n.status===404)return{};throw Error(`fetchGzipBundle: ${e} returned ${n.status} ${n.statusText}`)}return Wx(n)})(),qx.set(e,n),n.catch(()=>{qx.get(e)===n&&qx.delete(e)});for(let e of qx.keys()){if(qx.size<=Kx)break;qx.delete(e)}}return n}var Yx={counts:`object_bundles`,globalPath:e=>`/v1/objects/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/objects/${e}/${t}.json.gz`,versionClass:`objects`},Xx={counts:`group_bundles`,globalPath:e=>`/v1/groups/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/groups/${e}/${t}.json.gz`},Zx=(e,t)=>Jx(t?$t(e,t):`${Kt()}${e}`),Qx=(e,t)=>Jx(t?$t(e,t):`${Kt()}${e}`,{priority:`low`});async function $x(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?bx(t,s):-1,c?bx(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 eS(e,t,n,r=!0,i=!1){return $x(e,t,{meta:await _x(),lang:n,localized:r,fetchBundle:i?Qx:Zx})}function tS(e){return o(e.distribution)}function nS(e,t=!0,n=c(),r=!1){return eS(Yx,e,n,t,r)}async function rS(e){if(e?.startsWith(`probe-`))try{let t=(await nS(e,!1)).global,n=t?.coverage?.position_from;return n?{id:e,carriedFrom:n,carrierName:t?.carried_by?.name}:void 0}catch{return}}function iS(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}}var aS=1/1440;function oS(e){return(e?.coverage?.windows.length??0)>0}async function sS(){let e=(await _x()).position.zones.earth,t=e&&sx(e).find(e=>tx(e.data))?.data;return t&&tx(t)?Ag(px(t)):1/0}async function cS(e){let t=await nS(e,!1),n=t.global?.coverage?.windows??[],r=t.global?.orbit?.scale===`planet`,i=r?await sS():1/0;return n.map(([e,t])=>[e??-1/0,t==null?i:r?t:Rg(t)]).filter(([e,t])=>t>e)}function lS(e,t){let n=null;for(let[r,i]of e){if(t>r&&t<i)return t;let e=Math.min(aS,(i-r)/2),a=t<=r?r+e:i-e;(n===null||Math.abs(a-t)<Math.abs(n-t))&&(n=a)}return n}function uS(e){return G[e.toUpperCase()]??G.UNDOCUMENTED}var dS={horizons:W.HORIZONS,sbdb:W.SBDB,celestrak:W.CELESTRAK,spacetrack:W.SPACETRACK,spice:W.SPICE,sbdb_moons:W.SBDB_MOON,astersat:W.ASTERSAT};function fS(e){return e?dS[e]??W.UNKNOWN:W.UNKNOWN}var pS=14;function mS(e,t){let n=t.global,r=n?.orbit;if(!n||!r||!oS(n))return null;let i=r.q!=null&&r.tp!=null;if(!i&&(r.epoch_jd==null||r.a==null||r.ma==null||r.n==null))return null;let a=r.scale===`planet`,o=n.cross_refs?.norad_cat_id,s=a&&r.bstar!=null&&r.mean_motion_dot!=null&&r.mean_motion_ddot!=null&&r.n!=null&&o!=null?{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}:void 0,c=s?i_(s,n.name??void 0)??void 0:void 0,l=n.coverage?.windows[0]?.[0];return{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:uS(n.type),parentId:r.parent_id,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,a:a?(r.a??0)/vg:r.a??0,e:r.e,i:r.i,om:r.om,w:r.w,ma:r.ma??0,n:a?(r.n??0)*360:r.n??0,epoch:r.epoch_jd,equatorial:a,validityStart:s?r.epoch_jd-pS:-1/0,validityEnd:s?r.epoch_jd+pS:1/0,orbitalSource:fS(r.source),...l==null?{}:{visibleFromDays:l-Eg},...i?{q:r.q,tp:r.tp}:{},...s?{omm:s}:{},...c?{satrec:c}:{}}}function hS(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:uS(n.type),parentId:n.host_id??``,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,pageOnly:!0,a:NaN,e:NaN,i:NaN,om:NaN,w:NaN,ma:NaN,n:NaN,epoch:NaN,validityStart:-1/0,validityEnd:1/0,orbitalSource:W.UNKNOWN}:null}async function gS(e,t,n=new Set){if(n.has(e))return console.warn(`createPlaceholderBody: cycle detected at ${e} — hiding`),[];n.add(e);let r=await nS(e),i=r.global;if(!i)return console.warn(`createPlaceholderBody: no catalogue record for ${e} — hiding`),[];let a=i.sbdb?.class??null,o=mS(e,r)??hS(e,r);if(!o)return[];let s=o.parentId,c=s===``||s===`naif-0`||t.getBody(s)?[]:await gS(s,t,n),l=o.pageOnly?{data:o,position:null}:{data:o,position:null,orbitElements:o,orbitCenterId:s};return[...c,{body:l,zone:a}]}function _S(e,t,n){let r=0;for(let i=0;i<t.length;i++){let{body:a,zone:o}=t[i];if(e.getBody(a.data.id))continue;let s=a.data.objectType,c=s===G.SPACECRAFT||s===G.DEBRIS,l=i>0?t[i-1]:null,u=s===G.MOON&&l&&Sn(l.body.data.objectType)?`small_body_moons`:o;c&&a.data.parentId!==``?(e.bodies.putSpacecraft(a)&&r++,e.bodies.dirtySpacecraftGroups.add(a.data.parentId)):u&&!a.data.pageOnly?(e.bodies.asteroidBucket(u,n).addPlaceholder(a),e.bodies.dirtyAsteroidZones.add(u),r++):e.bodies.addBodies([a]),e.credits.recordOrbitSources([a])}return r}async function vS(e,t){if(e.getBody(t))return;let n=await gS(t,e);if(n.length===0)return;let r=_S(e,n,await Oy());e.bodies.flushMinor(r>0)}var yS=Math.PI/180,bS=36525;function xS(e,t,n){let r=Lg(t)-Eg,i=r/bS,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=n.phaseDegree+1,u=Math.min(Math.floor(c.length/l),Math.max(e.length,t.length,r.length));for(let n=0;n<u;n++){let u=0;for(let e=l-1;e>=0;e--)u=u*i+c[l*n+e];let d=u*yS,f=Math.sin(d);n<e.length&&(a+=e[n]*f),n<t.length&&(o+=t[n]*Math.cos(d)),n<r.length&&(s+=r[n]*f)}}return{ra:a,dec:o,w:s}}function SS(e,t,n){let{ra:r,dec:i,w:a}=xS(e,t,n),o=r*yS,s=i*yS,c=Math.cos(s),l=Tg(c*Math.cos(o),c*Math.sin(o),Math.sin(s),new J).normalize(),u=Tg(-Math.sin(o),Math.cos(o),0,new J).normalize(),d=new J().crossVectors(u,l).normalize(),f=new Zi().setFromRotationMatrix(new Y().makeBasis(u,l,d));return new Zi().setFromAxisAngle(l,a*yS).multiply(f)}function CS(e,t,n,r){e.quaternion.copy(SS(t,n,r))}var wS=new J(0,1,0),TS=new J;function ES(e,t,n){TS.set(t[0]-n[0],t[1]-n[1],t[2]-n[2]),!(TS.lengthSq()<1e-20)&&(TS.normalize(),e.quaternion.setFromUnitVectors(wS,TS))}function DS(e,t){e.quaternion.setFromUnitVectors(wS,t)}function OS(e,t){let n;for(let r of e??[])r.jd<=t&&(n=r.deg);return n}var kS=new J(0,0,1),AS=new J,jS=new J,MS=new J,NS=new J,PS=new J,FS=new J,IS=new Zi;function LS(e,t,n){AS.copy(wS).applyQuaternion(e.quaternion),MS.copy(t).addScaledVector(AS,-t.dot(AS)).normalize(),NS.crossVectors(MS,AS);let r=n*yS;PS.copy(MS).multiplyScalar(Math.cos(r)).addScaledVector(NS,Math.sin(r)),jS.copy(kS).applyQuaternion(e.quaternion),jS.addScaledVector(AS,-jS.dot(AS)).normalize();let i=Math.atan2(FS.crossVectors(jS,PS).dot(AS),jS.dot(PS));e.quaternion.premultiply(IS.setFromAxisAngle(AS,i))}var RS={"+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 zS(e){let t=[];for(let[n,r]of Object.entries(e)){let e=RS[n],i=RS[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 Zi().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 Zi().setFromRotationMatrix(c.multiply(l))}var BS=new J,VS=new J,HS=new J,US=new J,WS=new J,GS=new J,KS=new J,qS=new J,JS=new Y,YS=new Y;function XS(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 ZS(e,t,n){if(!XS(t.primary.target,n,BS))return;let r=RS[t.primary.axis],i=t.secondary;if(!i||!XS(i.target,n,VS)){e.quaternion.setFromUnitVectors(r,BS);return}if(WS.crossVectors(r,RS[i.axis]),qS.crossVectors(BS,VS),WS.lengthSq()<1e-20||qS.lengthSq()<1e-20){e.quaternion.setFromUnitVectors(r,BS);return}WS.normalize(),qS.normalize(),HS.copy(r),GS.copy(BS),US.crossVectors(WS,HS),KS.crossVectors(qS,GS),JS.makeBasis(GS,KS,qS),YS.makeBasis(HS,US,WS).transpose(),JS.multiply(YS),e.quaternion.setFromRotationMatrix(JS)}function QS(e,t){let n=e,r=n.userData.shaderMods??=[];r.includes(t)||(r.push(t),e.customProgramCacheKey=()=>r.map(e=>typeof e==`string`?e:e()).join(`|`))}function $S(e,t,n){let r=e.onBeforeCompile;e.onBeforeCompile=(e,t)=>{r?.(e,t),n(e,t)},QS(e,t),e.needsUpdate=!0}var eC=class extends no{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Zc;e.deleteAttribute(`uv`);let t=new Ou({side:1}),n=new Ou,r=new Td(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new Ws(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new gc(e,n,6),o=new qa;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 Ws(e,tC(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new Ws(e,tC(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new Ws(e,tC(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new Ws(e,tC(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new Ws(e,tC(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new Ws(e,tC(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 tC(e){return new Au({color:0,emissive:16777215,emissiveIntensity:e})}var nC=.01,rC=3.5,iC=.04;function aC(e){let t=Math.max(e/10,.01);return 1/(t*t)}function oC(e,t,n=1){e.decay=t?2:0,e.intensity=(t?rC*10*10:rC)*n}function sC(e){let t=new Nf(e),n=t.fromScene(new eC).texture;return t.dispose(),n}var cC=[1,.97075,.952],lC=[1.02,.99,.97],uC=Math.sin(8*Math.PI/180);function dC(e){return e<.001?e*(1-.5*e):1-Math.exp(-e)}function fC(e,t,n){let r=Math.max(e,1e-4),i=Math.max(t,1e-4),a=Math.max(n,1e-6);return e/(r+i)*dC(a*(1/r+1/i))/(.5*dC(2*a/uC))}var pC=3,mC=12;pC*(mC/2+1);var hC=1e-4,gC=256,_C=new Float64Array(gC),vC=6,yC=24,bC=48;function xC(e,t,n){return .2126*e+.7152*t+.0722*n}var SC=Float64Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4});function CC(e,t,n,r,i,a){let o=new Float64Array(gC),s=new Float64Array(gC),c=new Float64Array(gC),l=new Float64Array(gC),u=xC(...cC),[d,f,p]=lC,m=[0,0,0],h=(e,n)=>(e*t+n)*4;for(let g=0;g<gC;g++){let _=Math.floor(g*t/gC),v=Math.max(_+1,Math.floor((g+1)*t/gC)),y=r+(g+.5)/gC*(i-r);for(let t=_;t<v;t++){let r=h(n.color,t),i=SC[e[r]],_=SC[e[r+1]],v=SC[e[r+2]],b=Math.min(1,(1-e[h(n.transparency,t)]/255)*a),x=e[h(n.backscattered,t)]/255*a;o[g]+=x*xC(i,_,v),s[g]+=e[h(n.forwardscattered,t)]/255*b*a*xC(i*d,_*f,v*p),c[g]+=e[h(n.unlitside,t)]/255*b*a*u,l[g]+=1-b,m[0]+=x*i*y,m[1]+=x*_*y,m[2]+=x*v*y}let b=v-_;o[g]/=b,s[g]/=b,c[g]/=b,l[g]/=b}let g=xC(m[0],m[1],m[2]);return{inner:r,outer:i,back:o,forward:s,unlit:c,transmission:l,litTint:g>0?new X(m[0],m[1],m[2]).multiplyScalar(1/g):new X(1,1,1),bands:wC(o,c,r,i)}}function wC(e,t,n,r){let i=new Float64Array(gC+1);for(let a=0;a<gC;a++){let o=n+(a+.5)/gC*(r-n);i[a+1]=i[a]+(e[a]+t[a])/o}let a=i[gC],o=new Int32Array(pC+1);o[pC]=gC;for(let e=1;e<pC;e++){let t=o[e-1]+1;for(;t<gC-(pC-e)&&i[t]<a*e/pC;)t++;o[e]=t}return o}function TC(e){let t=Math.min(Math.max((e+1)/2,0),1);return 1-t*t*(3-2*t)}var EC=3.09;function DC(e){return(1-Math.acos(Math.min(Math.max(e,-1),1))/Math.PI)**EC}function OC(e,t,n,r,i){let a=e/i.equatorial,o=t/i.equatorial,s=n/i.equatorial,c=r/i.polar,l=a*s;return l>=0?!1:a*a+o*o-l*l/(s*s+c*c)<1}function kC(e,t,n,r){let i=Math.sqrt(Math.max(0,1-n*n)),a=Math.abs(n),o=n>=0,{inner:s,outer:c,back:l,forward:u,unlit:d,transmission:f,bands:p}=t;for(let e=0;e<gC;e++)_C[e]=fC(a,a,-Math.log(Math.max(f[e],1e-6)));let m=(c-s)/gC,h=2*Math.PI/mC,g=h/vC,_=0;for(let t=0;t<pC;t++)for(let a=0;a<=mC/2;a++,_++){let c=0,f=0,v=0,y=0,b=0;for(let e=0;e<vC;e++){let _=(a-.5)*h+(e+.5)*g,x=Math.cos(_),S=Math.sin(_),C=TC(-i*x),w=DC(-i*x);for(let e=p[t];e<p[t+1];e++){let t=s+(e+.5)*m;if(OC(t*x,t*S,i,n,r))continue;let a=t*m*g,p=(l[e]*w+(u[e]-l[e]*w)*C)*_C[e]*a,h=d[e]*a;c+=o?p:h,f+=o?h:p;let _=p+h;v+=_,y+=_*t*x,b+=_*t*Math.abs(S)}}let x=a===0||a===mC/2?.5:1;if(v>0)e[4*_]=y/v,e[4*_+1]=b/v;else{let n=s+(p[t]+p[t+1])/2*m;e[4*_]=n*Math.cos(a*h),e[4*_+1]=n*Math.abs(Math.sin(a*h))}e[4*_+2]=c*x,e[4*_+3]=f*x}}function AC(e,t,n,r,i,a,o,s){let c=i>=0,l=Math.abs(i),u=n*n+r*r+i*i,d=a*n+o*r+s*i,f=0;for(let i=0;i<21;i++){let s=e[4*i],p=e[4*i+1],m=c?e[4*i+2]:e[4*i+3],h=u+s*s+p*p-2*s*n,g=2*p*r,_=s*a-d,v=p*o;for(let e of[1,-1]){let n=h-e*g,r=Math.sqrt(n),i=Math.max(_+e*v,0);f+=m*i/(n*r*(t*r+l))}}return 2*t*l*f}function jC(e,t,n,r,i,a){if(Math.abs(a)<1e-6)return 1;let o=-r/a;if(o<0)return 1;let s=(Math.hypot(t+o*i,n)-e.inner)/(e.outer-e.inner);if(s<0||s>1)return 1;let c=Math.min(Math.floor(s*gC),gC-1);return Math.max(e.transmission[c],1e-4)**(1/Math.max(Math.abs(a),.02))}var MC={x:new Float64Array(yC*bC),y:new Float64Array(yC*bC),z:new Float64Array(yC*bC),nx:new Float64Array(yC*bC),ny:new Float64Array(yC*bC),nz:new Float64Array(yC*bC),light:new Float64Array(yC*bC)};function NC(e,t,n,r,i,a,o){let s=Math.sqrt(Math.max(0,1-r*r)),c=Math.abs(r),{equatorial:l,polar:u}=i,d=MC,f=Math.PI/yC,p=2*Math.PI/bC;for(let e=0;e<yC;e++){let t=-Math.PI/2+(e+.5)*f,n=Math.cos(t),i=Math.sin(t),m=l*n*Math.sqrt(u*u*n*n+l*l*i*i)*f*p;for(let t=0;t<bC;t++){let f=(t+.5)*p,h=Math.cos(f),g=Math.sin(f),_=e*bC+t,v=l*n*h,y=l*n*g,b=u*i,x=n*h/l,S=n*g/l,C=i/u,w=Math.hypot(x,S,C);x/=w,S/=w,C/=w;let T=x*s+C*r,E=T>0?T*jC(a,v,y,b,s,r):0,D=c<hC?0:AC(o,c,v,y,b,x,S,C)/rC;d.x[_]=v,d.y[_]=y,d.z[_]=b,d.nx[_]=x,d.ny[_]=S,d.nz[_]=C,d.light[_]=(E+D)/Math.PI*m}}for(let r=0;r<8;r++){let i=t+r/7*(n-t);for(let t=0;t<19;t++){let n=1-2*t/18,a=i*n,o=i*Math.sqrt(1-n*n),s=0,c=0,l=0,u=0;for(let e=0;e<yC*bC;e++){let t=a-d.x[e],n=o-d.y[e],r=-d.z[e],i=t*t+n*n+r*r,f=d.nx[e]*t+d.ny[e]*n+d.nz[e]*r;if(f<=0)continue;let p=Math.sqrt(i),m=d.light[e]*f/(i*p),h=Math.abs(r)/p;d.z[e]>0?(s+=m,l+=m*h):(c+=m,u+=m*h)}let f=4*(r*19+t);e[f]=s,e[f+1]=c,e[f+2]=s>0?l/s:0,e[f+3]=c>0?u/c:0}}}var PC=new Float32Array(608);function FC(e){let t=new ic(new Uint16Array(608),19,8,ar,Zn);return t.minFilter=Vn,t.magFilter=Vn,t.wrapS=In,t.wrapT=In,t.needsUpdate=!0,{profile:e,planet:{equatorial:0,polar:0},planetLight:t,planetLightSinB:NaN,patches:new Float64Array(84),patchesSinB:NaN}}function IC(e,t,n){NC(PC,e.profile.inner,e.profile.outer,t,e.planet,n.profile,n.patches);let r=e.planetLight.image.data;for(let e=0;e<PC.length;e++)r[e]=Lo.toHalfFloat(PC[e]);e.planetLight.needsUpdate=!0,e.planetLightSinB=t}function LC(e,t){let n=new Float64Array(84);kC(n,e,1,t);let r=0;for(let e=2;e<90;e+=2){let i=e*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=a/t.equatorial,c=o/t.polar,l=Math.hypot(s,c),u=AC(n,1,t.equatorial*a,0,t.polar*o,s/l,0,c/l);r=Math.max(r,u/rC)}return r}var RC=`
4052
4052
  #define RINGSHINE_PATCHES 21
4053
4053
  uniform vec4 uRingshinePatch[RINGSHINE_PATCHES];
4054
4054
  uniform vec3 uRingshineAxis;
4055
4055
  uniform vec3 uRingshineTint[2];
4056
- `,kC=`
4056
+ `,zC=`
4057
4057
  if (uRingshineTint[0].g + uRingshineTint[1].g > 0.0) {
4058
4058
  vec3 q = vRingShadowWorldPos - uRingShadowCenter;
4059
4059
  vec3 axisY = cross(uRingShadowPoleDir, uRingshineAxis);
@@ -4086,7 +4086,7 @@ void main() {
4086
4086
  reflectedLight.indirectDiffuse +=
4087
4087
  tint * (2.0 * mu0 * absHeight * sum) * BRDF_Lambert(material.diffuseContribution);
4088
4088
  }
4089
- `;function AC(e){let t=e.userData;if(t.ringshine)return t.ringshine;let n={uRingshinePatch:{value:Array.from({length:21},()=>new ga)},uRingshineAxis:{value:new J(1,0,0)},uRingshineTint:{value:[new J,new J]},disable:()=>{for(let e of n.uRingshineTint.value)e.set(0,0,0)}};return US(e,`ringshine`,e=>{e.uniforms.uRingshinePatch=n.uRingshinePatch,e.uniforms.uRingshineAxis=n.uRingshineAxis,e.uniforms.uRingshineTint=n.uRingshineTint,e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${OC}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>\n${kC}`)}),t.ringshine=n,n}function jC(e,t,n,r,i){let a=e.uRingshinePatch.value;for(let e=0;e<21;e++)a[e].fromArray(t.patches,4*e);e.uRingshineAxis.value.copy(n);let[o,s]=e.uRingshineTint.value;if(Math.abs(r)<aC){o.set(0,0,0),s.set(0,0,0);return}let c=t.profile.litTint,l=dC(...QS),[u,d]=r>=0?[o,s]:[s,o];u.set(c.r,c.g,c.b).multiplyScalar(i),d.set(...QS).multiplyScalar(i/l)}var MC=256,NC=96;async function PC(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=a.width,s=Math.min(o,n);s<o&&console.info(`Ring strip ${e}: downscaling ${o}px → ${s}px to fit GL MAX_TEXTURE_SIZE.`);let c=FC(a,e,n);a.close();let l=e=>IC(c,o,e,s),u=(t,n=!1)=>{let r=document.createElement(`canvas`);r.width=s,r.height=2;let i=r.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);i.putImageData(t,0,0),i.putImageData(t,0,1);let a=new qc(r);return n&&(a.colorSpace=ii),a.minFilter=Un,a.magFilter=Vn,a.generateMipmaps=!0,a.anisotropy=16,a.needsUpdate=!0,a},d=l(t.backscattered),f=l(t.forwardscattered),p=l(t.unlitside);for(let e=0;e<d.data.length;e+=4)d.data[e+1]=f.data[e],d.data[e+2]=p.data[e];let m={color:u(l(t.color),!0),scatter:u(d),transparency:u(l(t.transparency))};return t.thickness!==void 0&&(m.thickness=u(l(t.thickness))),{textures:m,pixels:c,width:o}}function FC(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 IC(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 LC=`
4089
+ `;function BC(e){let t=e.userData;if(t.ringshine)return t.ringshine;let n={uRingshinePatch:{value:Array.from({length:21},()=>new ga)},uRingshineAxis:{value:new J(1,0,0)},uRingshineTint:{value:[new J,new J]},disable:()=>{for(let e of n.uRingshineTint.value)e.set(0,0,0)}};return $S(e,`ringshine`,e=>{e.uniforms.uRingshinePatch=n.uRingshinePatch,e.uniforms.uRingshineAxis=n.uRingshineAxis,e.uniforms.uRingshineTint=n.uRingshineTint,e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${RC}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>\n${zC}`)}),t.ringshine=n,n}function VC(e,t,n,r,i){let a=e.uRingshinePatch.value;for(let e=0;e<21;e++)a[e].fromArray(t.patches,4*e);e.uRingshineAxis.value.copy(n);let[o,s]=e.uRingshineTint.value;if(Math.abs(r)<hC){o.set(0,0,0),s.set(0,0,0);return}let c=t.profile.litTint,l=xC(...cC),[u,d]=r>=0?[o,s]:[s,o];u.set(c.r,c.g,c.b).multiplyScalar(i),d.set(...cC).multiplyScalar(i/l)}var HC=256,UC=96;async function WC(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=a.width,s=Math.min(o,n);s<o&&console.info(`Ring strip ${e}: downscaling ${o}px → ${s}px to fit GL MAX_TEXTURE_SIZE.`);let c=GC(a,e,n);a.close();let l=e=>KC(c,o,e,s),u=(t,n=!1)=>{let r=document.createElement(`canvas`);r.width=s,r.height=2;let i=r.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);i.putImageData(t,0,0),i.putImageData(t,0,1);let a=new qc(r);return n&&(a.colorSpace=ii),a.minFilter=Un,a.magFilter=Vn,a.generateMipmaps=!0,a.anisotropy=16,a.needsUpdate=!0,a},d=l(t.backscattered),f=l(t.forwardscattered),p=l(t.unlitside);for(let e=0;e<d.data.length;e+=4)d.data[e+1]=f.data[e],d.data[e+2]=p.data[e];let m={color:u(l(t.color),!0),scatter:u(d),transparency:u(l(t.transparency))};return t.thickness!==void 0&&(m.thickness=u(l(t.thickness))),{textures:m,pixels:c,width:o}}function GC(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 KC(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 qC=`
4090
4090
  #include <common>
4091
4091
  #include <logdepthbuf_pars_vertex>
4092
4092
 
@@ -4121,7 +4121,7 @@ void main() {
4121
4121
  gl_Position = projectionMatrix * viewMatrix * worldPosition;
4122
4122
  #include <logdepthbuf_vertex>
4123
4123
  }
4124
- `,RC=`
4124
+ `,JC=`
4125
4125
  #include <common>
4126
4126
  #include <logdepthbuf_pars_fragment>
4127
4127
 
@@ -4160,9 +4160,9 @@ void main() {
4160
4160
  varying vec3 vWorldPos;
4161
4161
  varying vec3 vWorldNormal;
4162
4162
 
4163
- const vec3 UNLIT_TINT = vec3(${QS.join(`, `)});
4164
- const vec3 FORWARD_TINT_BIAS = vec3(${$S.join(`, `)});
4165
- const float PROFILE_MU = ${eC};
4163
+ const vec3 UNLIT_TINT = vec3(${cC.join(`, `)});
4164
+ const vec3 FORWARD_TINT_BIAS = vec3(${lC.join(`, `)});
4165
+ const float PROFILE_MU = ${uC};
4166
4166
 
4167
4167
  float oneMinusExp(float x) {
4168
4168
  return x < 1e-3 ? x * (1.0 - 0.5 * x) : 1.0 - exp(-x);
@@ -4185,7 +4185,7 @@ void main() {
4185
4185
  }
4186
4186
 
4187
4187
  float particlePhase(float cosPhase) {
4188
- return pow(1.0 - acos(clamp(cosPhase, -1.0, 1.0)) / PI, ${gC});
4188
+ return pow(1.0 - acos(clamp(cosPhase, -1.0, 1.0)) / PI, ${EC});
4189
4189
  }
4190
4190
 
4191
4191
  // The lit face at a phase and a gain: the backscatter profile under the
@@ -4282,7 +4282,7 @@ void main() {
4282
4282
  );
4283
4283
  #include <logdepthbuf_fragment>
4284
4284
  }
4285
- `,zC=`
4285
+ `,YC=`
4286
4286
  uniform sampler2D uRingShadowTransparency;
4287
4287
  uniform float uRingShadowInnerScene;
4288
4288
  uniform float uRingShadowOuterScene; // 0 = no rings
@@ -4335,16 +4335,16 @@ void main() {
4335
4335
  // to avoid blow-up near grazing incidence.
4336
4336
  return pow(max(trans, 1e-4), 1.0 / max(abs(denom), 0.02));
4337
4337
  }
4338
- `;function BC(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>
4338
+ `;function XC(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>
4339
4339
  varying vec3 vRingShadowWorldPos;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
4340
4340
  vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
4341
4341
  varying vec3 vRingShadowWorldPos;
4342
4342
  // The sky light of sun-transmittance.ts reads ringShadow.
4343
4343
  #define PLANET_RING_SHADOW
4344
- ${zC}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
4344
+ ${YC}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
4345
4345
  float ringShadow = ringShadowAt(vRingShadowWorldPos);
4346
4346
  reflectedLight.directDiffuse *= ringShadow;
4347
- reflectedLight.directSpecular *= ringShadow;`)},HS(e,`ringShadow`),e.needsUpdate=!0,a.ringShadow=c,c}async function VC(e,t,n){let r=Q(t.inner_radius_km),i=Q(t.outer_radius_km),a=t.intensity_scale??1,o,s;try{let c=await PC($t(`/v1/rings/${e}/${t.strip}`,`rings`),t.strip_rows,n);o=c.textures,s=TC(pC(c.pixels,c.width,t.strip_rows,r,i,a))}catch(t){return console.warn(`Failed to load ring strip for ${e}:`,t),null}let c=t.thickness_scale_km&&o.thickness?Q(t.thickness_scale_km):0,l=c>0?48:1,u=new Eu({uniforms:{uScatter:{value:o.scatter},uTransparency:{value:o.transparency},uColor:{value:o.color},uThickness:{value:o.thickness??o.transparency},uThicknessScene:{value:c},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},uPlanetLight:{value:s.planetLight},uPlanetAlbedo:{value:new X(0,0,0)},uSunAzimuth:{value:new q(1,0)}},vertexShader:LC,fragmentShader:RC,transparent:!0,depthWrite:!1,blending:1,premultipliedAlpha:!0,side:2}),d=new mu(r,i*(1/Math.cos(Math.PI/MC)),MC,l>1?NC:1);d.rotateX(-Math.PI/2);let f;if(l>1){d.setAttribute(`aLayerIndex`,new cc(Float32Array.from({length:l},(e,t)=>t),1));let e=new gc(d,u,l);e.count=1,f=e}else f=new Ws(d,u);f.frustumCulled=!1,f.renderOrder=3,f.userData.isRingMesh=!0;let p={uPlanetCenter:u.uniforms.uPlanetCenter,uPlanetPoleDir:u.uniforms.uPlanetPoleDir,uPlanetEquatorialScene:u.uniforms.uPlanetEquatorialScene,uPlanetPolarScene:u.uniforms.uPlanetPolarScene};return{mesh:f,material:u,layers:f instanceof gc?f:null,thicknessScene:c,transparency:o.transparency,intensityScale:a,innerScene:r,outerScene:i,planetShadow:null,planetShadowOnRing:p,light:s,ringshine:null}}function HC(e){e.mesh.geometry.dispose();let t=e.material.uniforms;for(let e of[`uScatter`,`uTransparency`,`uColor`,`uThickness`,`uPlanetLight`])(t[e]?.value)?.dispose();e.mesh.material.dispose()}var UC=4;function WC(){return typeof navigator>`u`?!1:navigator.connection?.saveData===!0}function GC(){if(typeof navigator>`u`)return!1;if(WC())return!0;let e=navigator.deviceMemory;return typeof e==`number`&&e>0&&e<=UC}var KC;function qC(){return KC===void 0&&(KC=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches),KC}function JC(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,2)}var YC=`spacemap.atmosphere-calibration`;function XC(){try{let e=localStorage.getItem(YC);return e?JSON.parse(e):null}catch{return null}}function ZC(e){try{e?localStorage.setItem(YC,JSON.stringify(e)):localStorage.removeItem(YC)}catch{}}function QC(){return Qe({resolvedReducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,viewMode:`map`,showClouds:!0,showAtmospheres:!0,atmosphereQuality:`auto`,atmosphereAutoTier:null,atmosphereCalibration:XC(),atmoQualityOverrides:{},highAmbient:!1,realisticLighting:!1,overexposeRings:!1,showShapeMesh:!0,showSurfaceTexture:!0,showDisplacement:!0,showSelfShadow:!0,showHaloDebug:!1,maxPartsPerZone:0,setAtmosphereCalibration(e){this.atmosphereCalibration=e,ZC(e)},setAtmosphereAutoTier(e){this.atmosphereAutoTier=e}})}var $C=null;function ew(){return $C??=QC()}function tw(e){$C=e}var nw=[`low`,`medium`,`high`,`ultra`],rw={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 iw(){return qC()?GC()?`low`:`medium`:GC()?`high`:`ultra`}function aw(e){if(e!==`auto`)return e;let t=ew();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??iw()}function ow(){let e=ew();return{...rw[aw(e.atmosphereQuality)],...e.atmoQualityOverrides}}function sw(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var cw=30,lw=45,uw=3e3,dw=2500,fw=250,pw=60,mw=0,hw=dw,gw=``;function _w(e,t){let n=ew();if(n.atmosphereQuality!==`auto`||e<=0||e>fw)return;let r=sw(ow());if(r!==gw&&(gw=r,hw=dw,mw=0,pw=60),pw+=(1e3/e-pw)*Math.min(1,e/500),hw>0){hw-=e;return}if(!t||pw>lw){mw=Math.max(0,mw-e);return}if(pw>=cw||(mw+=e,mw<uw))return;mw=0;let i=nw[nw.indexOf(aw(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var vw=!1;function yw(e){vw=e}function bw(){return vw}function xw(e){return vw?e>=0&&e<=1:e>=-1&&e<=1}var Sw=-44;function Cw(){ff.logdepthbuf_vertex=`
4347
+ reflectedLight.directSpecular *= ringShadow;`)},QS(e,`ringShadow`),e.needsUpdate=!0,a.ringShadow=c,c}async function ZC(e,t,n){let r=Q(t.inner_radius_km),i=Q(t.outer_radius_km),a=t.intensity_scale??1,o,s;try{let c=await WC($t(`/v1/rings/${e}/${t.strip}`,`rings`),t.strip_rows,n);o=c.textures,s=FC(CC(c.pixels,c.width,t.strip_rows,r,i,a))}catch(t){return console.warn(`Failed to load ring strip for ${e}:`,t),null}let c=t.thickness_scale_km&&o.thickness?Q(t.thickness_scale_km):0,l=c>0?48:1,u=new Eu({uniforms:{uScatter:{value:o.scatter},uTransparency:{value:o.transparency},uColor:{value:o.color},uThickness:{value:o.thickness??o.transparency},uThicknessScene:{value:c},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},uPlanetLight:{value:s.planetLight},uPlanetAlbedo:{value:new X(0,0,0)},uSunAzimuth:{value:new q(1,0)}},vertexShader:qC,fragmentShader:JC,transparent:!0,depthWrite:!1,blending:1,premultipliedAlpha:!0,side:2}),d=new mu(r,i*(1/Math.cos(Math.PI/HC)),HC,l>1?UC:1);d.rotateX(-Math.PI/2);let f;if(l>1){d.setAttribute(`aLayerIndex`,new cc(Float32Array.from({length:l},(e,t)=>t),1));let e=new gc(d,u,l);e.count=1,f=e}else f=new Ws(d,u);f.frustumCulled=!1,f.renderOrder=3,f.userData.isRingMesh=!0;let p={uPlanetCenter:u.uniforms.uPlanetCenter,uPlanetPoleDir:u.uniforms.uPlanetPoleDir,uPlanetEquatorialScene:u.uniforms.uPlanetEquatorialScene,uPlanetPolarScene:u.uniforms.uPlanetPolarScene};return{mesh:f,material:u,layers:f instanceof gc?f:null,thicknessScene:c,transparency:o.transparency,intensityScale:a,innerScene:r,outerScene:i,planetShadow:null,planetShadowOnRing:p,light:s,ringshine:null}}function QC(e){e.mesh.geometry.dispose();let t=e.material.uniforms;for(let e of[`uScatter`,`uTransparency`,`uColor`,`uThickness`,`uPlanetLight`])(t[e]?.value)?.dispose();e.mesh.material.dispose()}var $C=4;function ew(){return typeof navigator>`u`?!1:navigator.connection?.saveData===!0}function tw(){if(typeof navigator>`u`)return!1;if(ew())return!0;let e=navigator.deviceMemory;return typeof e==`number`&&e>0&&e<=$C}var nw;function rw(){return nw===void 0&&(nw=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches),nw}function iw(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,2)}var aw=`spacemap.atmosphere-calibration`;function ow(){try{let e=localStorage.getItem(aw);return e?JSON.parse(e):null}catch{return null}}function sw(e){try{e?localStorage.setItem(aw,JSON.stringify(e)):localStorage.removeItem(aw)}catch{}}function cw(){return Qe({resolvedReducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,viewMode:`map`,showClouds:!0,showAtmospheres:!0,atmosphereQuality:`auto`,atmosphereAutoTier:null,atmosphereCalibration:ow(),atmoQualityOverrides:{},highAmbient:!1,realisticLighting:!1,overexposeRings:!1,showShapeMesh:!0,showSurfaceTexture:!0,showDisplacement:!0,showSelfShadow:!0,showHaloDebug:!1,maxPartsPerZone:0,setAtmosphereCalibration(e){this.atmosphereCalibration=e,sw(e)},setAtmosphereAutoTier(e){this.atmosphereAutoTier=e}})}var lw=null;function uw(){return lw??=cw()}function dw(e){lw=e}var fw=[`low`,`medium`,`high`,`ultra`],pw={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 mw(){return rw()?tw()?`low`:`medium`:tw()?`high`:`ultra`}function hw(e){if(e!==`auto`)return e;let t=uw();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??mw()}function gw(){let e=uw();return{...pw[hw(e.atmosphereQuality)],...e.atmoQualityOverrides}}function _w(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var vw=30,yw=45,bw=3e3,xw=2500,Sw=250,Cw=60,ww=0,Tw=xw,Ew=``;function Dw(e,t){let n=uw();if(n.atmosphereQuality!==`auto`||e<=0||e>Sw)return;let r=_w(gw());if(r!==Ew&&(Ew=r,Tw=xw,ww=0,Cw=60),Cw+=(1e3/e-Cw)*Math.min(1,e/500),Tw>0){Tw-=e;return}if(!t||Cw>yw){ww=Math.max(0,ww-e);return}if(Cw>=vw||(ww+=e,ww<bw))return;ww=0;let i=fw[fw.indexOf(hw(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var Ow=!1;function kw(e){Ow=e}function Aw(){return Ow}function jw(e){return Ow?e>=0&&e<=1:e>=-1&&e<=1}var Mw=-44;function Nw(){ff.logdepthbuf_vertex=`
4348
4348
  #ifdef USE_LOGARITHMIC_DEPTH_BUFFER
4349
4349
  vFragDepth = gl_Position.w;
4350
4350
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
@@ -4353,9 +4353,9 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
4353
4353
  #if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
4354
4354
  gl_FragDepth = vIsPerspective == 0.0
4355
4355
  ? gl_FragCoord.z
4356
- : max( log2( vFragDepth ) - ${Sw.toFixed(1)}, 0.0 ) / ( 2.0 / logDepthBufFC - ${Sw.toFixed(1)} );
4356
+ : max( log2( vFragDepth ) - ${Mw.toFixed(1)}, 0.0 ) / ( 2.0 / logDepthBufFC - ${Mw.toFixed(1)} );
4357
4357
  #endif
4358
- `}function ww(e,t){let n=Sw.toFixed(1);return`exp2(${e} * (log2(${t} + 1.0) - ${n}) + ${n})`}function Tw(e,t){let n=Sw.toFixed(1);return`max(log2(${e}) - ${n}, 0.0) / (log2(${t} + 1.0) - ${n})`}var Ew=.5,Dw=8,Ow={uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new ga)},uOccluderLeak:{value:Array.from({length:32},()=>new ga)}},kw={occluders:[],leaks:[],count:0};function Aw(){return kw}var jw=`
4358
+ `}function Pw(e,t){let n=Mw.toFixed(1);return`exp2(${e} * (log2(${t} + 1.0) - ${n}) + ${n})`}function Fw(e,t){let n=Mw.toFixed(1);return`max(log2(${e}) - ${n}, 0.0) / (log2(${t} + 1.0) - ${n})`}var Iw=.5,Lw=8,Rw={uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new ga)},uOccluderLeak:{value:Array.from({length:32},()=>new ga)}},zw={occluders:[],leaks:[],count:0};function Bw(){return zw}var Vw=`
4359
4359
  #define ECLIPSE_MAX_OCCLUDERS 32
4360
4360
  uniform float uSunAngularRadius;
4361
4361
  uniform int uOccluderCount;
@@ -4404,7 +4404,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
4404
4404
  }
4405
4405
  return result;
4406
4406
  }
4407
- `,Mw=`
4407
+ `,Hw=`
4408
4408
  uniform vec4 uOccluderLeak[ECLIPSE_MAX_OCCLUDERS];
4409
4409
 
4410
4410
  vec3 eclipseLeakAt(vec3 fragPos, vec3 selfPos, vec3 sunDir) {
@@ -4423,23 +4423,23 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
4423
4423
  float sep = acos(clamp(dot(sunDir, toOc) / dOc, -1.0, 1.0));
4424
4424
  float inView = sunInView(aSun, aOc, sep);
4425
4425
  float behind = sunInView(aSun, max(aOc - air.w, 0.0), sep) - inView;
4426
- if (behind > 0.0) leak += behind * pow(1.0 - inView, ${Dw.toFixed(1)}) * exp(-air.xyz * clamp(aOc - sep, 0.0, air.w));
4426
+ if (behind > 0.0) leak += behind * pow(1.0 - inView, ${Lw.toFixed(1)}) * exp(-air.xyz * clamp(aOc - sep, 0.0, air.w));
4427
4427
  }
4428
- return ${Ew.toFixed(3)} * leak;
4428
+ return ${Iw.toFixed(3)} * leak;
4429
4429
  }
4430
- `;function Nw(){return Ow}function Pw(){return{uEclipseSelfPos:{value:new J},uOccluders:{value:Array.from({length:32},()=>new ga)},uOccluderLeak:{value:Array.from({length:32},()=>new ga)},uOccluderCount:{value:0}}}var Fw=new Int32Array,Iw=new Float64Array,Lw=(e,t)=>Iw[t]-Iw[e];function Rw(e,t,n,r,i){let a=Ow.uSunAngularRadius.value,o=kw.occluders;Fw.length<kw.count&&(Fw=new Int32Array(kw.count),Iw=new Float64Array(kw.count));let s=0;for(let e=0;e<kw.count;e++){let i=o[e],c=i.x-t.x,l=i.y-t.y,u=i.z-t.z,d=c*c+l*l+u*u;if(d<i.w*i.w*.25)continue;let f=c*r.x+l*r.y+u*r.z;if(f<-(n+i.w))continue;let p=n+i.w+a*(f+n)*1.5;d-f*f>p*p||(Iw[e]=i.w*i.w/d,Fw[s++]=e)}s>32&&(Fw.subarray(0,s).sort(Lw),s=32);for(let t=0;t<s;t++){let n=Fw[t];i?.[t].copy(kw.leaks[n]),e[t].copy(o[n])}return s}function zw(e,t,n){if(t>10*e){let r=(t-n)/e;return r>=1?0:r<=-1?1:1-(Math.acos(-r)+r*Math.sqrt(Math.max(1-r*r,0)))/Math.PI}if(n>=e+t)return 1;if(n+e<=t)return 0;if(n+t<=e)return 1-t*t/(e*e);let r=e,i=t,a=n,o=(a*a+r*r-i*i)/(2*a),s=Math.sqrt(Math.max(r*r-o*o,0));return 1-(r*r*Math.acos(Math.max(-1,Math.min(1,o/r)))+i*i*Math.acos(Math.max(-1,Math.min(1,(a-o)/i)))-a*s)/(Math.PI*r*r)}function Bw(e,t){let n=Ow.uSunAngularRadius.value;if(n<=0)return 1;let r=Ow.uSunDir.value,i=Ow.uOccluderCount.value,a=Ow.uOccluders.value,o=1;for(let s=0;s<i;s++){let i=a[s],c=i.w;if(c<=0)continue;let l=i.x-t.x,u=i.y-t.y,d=i.z-t.z;if(Math.hypot(l,u,d)<c*.5)continue;let f=i.x-e.x,p=i.y-e.y,m=i.z-e.z,h=Math.hypot(f,p,m);if(h<1e-5)continue;let g=Math.asin(Math.min(c/h,1)),_=Math.max(-1,Math.min(1,(r.x*f+r.y*p+r.z*m)/h));if(o*=zw(n,g,Math.acos(_)),o===0)return 0}return o}function Vw(e,t,n){let r=e.refractivity?.[1];if(!r)return n.set(0,0,0,0);let i=e.rayleighScaleHeightKm,a=e.mieScaleHeightKm,o=Math.min(e.mieScatterPerKm[0]+e.mieAbsorptionPerKm[0],e.mieScatterPerKm[1]+e.mieAbsorptionPerKm[1],e.mieScatterPerKm[2]+e.mieAbsorptionPerKm[2])*Math.sqrt(2*Math.PI*t*a),s=Math.min(1,o**(-a/i)),c=r*Math.sqrt(2*Math.PI*t/i),l=i/r,[u,d,f]=e.rayleighScatterPerKm;return n.set(u*l,d*l,f*l,c*s)}function Hw(e,t,n,r,i){let a=zw(e,t,n),o=zw(e,Math.max(t-r.w,0),n)-a;if(o<=0)return i.set(0,0,0);let s=o*(1-a)**Dw,c=Math.min(Math.max(t-n,0),r.w);return i.set(s*Math.exp(-r.x*c),s*Math.exp(-r.y*c),s*Math.exp(-r.z*c))}var Uw=new J;function Ww(e,t,n){n.set(0,0,0);let r=Ow.uSunAngularRadius.value;if(r<=0)return n;let i=Ow.uSunDir.value,a=Ow.uOccluderCount.value,o=Ow.uOccluders.value,s=Ow.uOccluderLeak.value;for(let c=0;c<a;c++){let a=s[c];if(a.w<=0)continue;let l=o[c];if(Math.hypot(l.x-t.x,l.y-t.y,l.z-t.z)<l.w*.5)continue;let u=l.x-e.x,d=l.y-e.y,f=l.z-e.z,p=Math.hypot(u,d,f),m=Math.asin(Math.min(l.w/p,1)),h=Math.max(-1,Math.min(1,(i.x*u+i.y*d+i.z*f)/p));n.add(Hw(r,m,Math.acos(h),a,Uw))}return n.multiplyScalar(Ew)}function Gw(e,t){let n=t??Pw();return US(e,`eclipse`,e=>{Object.assign(e.uniforms,Ow,n),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4430
+ `;function Uw(){return Rw}function Ww(){return{uEclipseSelfPos:{value:new J},uOccluders:{value:Array.from({length:32},()=>new ga)},uOccluderLeak:{value:Array.from({length:32},()=>new ga)},uOccluderCount:{value:0}}}var Gw=new Int32Array,Kw=new Float64Array,qw=(e,t)=>Kw[t]-Kw[e];function Jw(e,t,n,r,i){let a=Rw.uSunAngularRadius.value,o=zw.occluders;Gw.length<zw.count&&(Gw=new Int32Array(zw.count),Kw=new Float64Array(zw.count));let s=0;for(let e=0;e<zw.count;e++){let i=o[e],c=i.x-t.x,l=i.y-t.y,u=i.z-t.z,d=c*c+l*l+u*u;if(d<i.w*i.w*.25)continue;let f=c*r.x+l*r.y+u*r.z;if(f<-(n+i.w))continue;let p=n+i.w+a*(f+n)*1.5;d-f*f>p*p||(Kw[e]=i.w*i.w/d,Gw[s++]=e)}s>32&&(Gw.subarray(0,s).sort(qw),s=32);for(let t=0;t<s;t++){let n=Gw[t];i?.[t].copy(zw.leaks[n]),e[t].copy(o[n])}return s}function Yw(e,t,n){if(t>10*e){let r=(t-n)/e;return r>=1?0:r<=-1?1:1-(Math.acos(-r)+r*Math.sqrt(Math.max(1-r*r,0)))/Math.PI}if(n>=e+t)return 1;if(n+e<=t)return 0;if(n+t<=e)return 1-t*t/(e*e);let r=e,i=t,a=n,o=(a*a+r*r-i*i)/(2*a),s=Math.sqrt(Math.max(r*r-o*o,0));return 1-(r*r*Math.acos(Math.max(-1,Math.min(1,o/r)))+i*i*Math.acos(Math.max(-1,Math.min(1,(a-o)/i)))-a*s)/(Math.PI*r*r)}function Xw(e,t){let n=Rw.uSunAngularRadius.value;if(n<=0)return 1;let r=Rw.uSunDir.value,i=Rw.uOccluderCount.value,a=Rw.uOccluders.value,o=1;for(let s=0;s<i;s++){let i=a[s],c=i.w;if(c<=0)continue;let l=i.x-t.x,u=i.y-t.y,d=i.z-t.z;if(Math.hypot(l,u,d)<c*.5)continue;let f=i.x-e.x,p=i.y-e.y,m=i.z-e.z,h=Math.hypot(f,p,m);if(h<1e-5)continue;let g=Math.asin(Math.min(c/h,1)),_=Math.max(-1,Math.min(1,(r.x*f+r.y*p+r.z*m)/h));if(o*=Yw(n,g,Math.acos(_)),o===0)return 0}return o}function Zw(e,t,n){let r=e.refractivity?.[1];if(!r)return n.set(0,0,0,0);let i=e.rayleighScaleHeightKm,a=e.mieScaleHeightKm,o=Math.min(e.mieScatterPerKm[0]+e.mieAbsorptionPerKm[0],e.mieScatterPerKm[1]+e.mieAbsorptionPerKm[1],e.mieScatterPerKm[2]+e.mieAbsorptionPerKm[2])*Math.sqrt(2*Math.PI*t*a),s=Math.min(1,o**(-a/i)),c=r*Math.sqrt(2*Math.PI*t/i),l=i/r,[u,d,f]=e.rayleighScatterPerKm;return n.set(u*l,d*l,f*l,c*s)}function Qw(e,t,n,r,i){let a=Yw(e,t,n),o=Yw(e,Math.max(t-r.w,0),n)-a;if(o<=0)return i.set(0,0,0);let s=o*(1-a)**Lw,c=Math.min(Math.max(t-n,0),r.w);return i.set(s*Math.exp(-r.x*c),s*Math.exp(-r.y*c),s*Math.exp(-r.z*c))}var $w=new J;function eT(e,t,n){n.set(0,0,0);let r=Rw.uSunAngularRadius.value;if(r<=0)return n;let i=Rw.uSunDir.value,a=Rw.uOccluderCount.value,o=Rw.uOccluders.value,s=Rw.uOccluderLeak.value;for(let c=0;c<a;c++){let a=s[c];if(a.w<=0)continue;let l=o[c];if(Math.hypot(l.x-t.x,l.y-t.y,l.z-t.z)<l.w*.5)continue;let u=l.x-e.x,d=l.y-e.y,f=l.z-e.z,p=Math.hypot(u,d,f),m=Math.asin(Math.min(l.w/p,1)),h=Math.max(-1,Math.min(1,(i.x*u+i.y*d+i.z*f)/p));n.add(Qw(r,m,Math.acos(h),a,$w))}return n.multiplyScalar(Iw)}function tT(e,t){let n=t??Ww();return $S(e,`eclipse`,e=>{Object.assign(e.uniforms,Rw,n),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4431
4431
  varying vec3 vEclipseWorldPos;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
4432
4432
  vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
4433
4433
  uniform vec3 uSunDir;
4434
4434
  uniform vec3 uEclipseSelfPos;
4435
4435
  varying vec3 vEclipseWorldPos;
4436
- ${jw}
4437
- ${Mw}
4436
+ ${Vw}
4437
+ ${Hw}
4438
4438
  `).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
4439
4439
  vec3 eclipseLight = eclipseFactorAt(vEclipseWorldPos, uEclipseSelfPos, uSunDir)
4440
4440
  + eclipseLeakAt(vEclipseWorldPos, uEclipseSelfPos, uSunDir);
4441
4441
  reflectedLight.directDiffuse *= eclipseLight;
4442
- reflectedLight.directSpecular *= eclipseLight;`)}),n}var Kw=null;function qw(){return Kw||(Kw=new ic(new Uint8Array([255,255,255,255]),1,1),Kw.needsUpdate=!0),Kw}function Jw(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 ic(t,e.length,1,ar,Xn);return n.needsUpdate=!0,n}function Yw(e,t,n){if(t===n)return;let r=e.uniforms;r.uMieProfileTex.value!==Kw&&r.uMieProfileTex.value.dispose(),r.uMieProfileTex.value=n?Jw(n):qw(),r.uMieProfileOn.value=+!!n,r.uMieProfileN.value=n?.length??1}function Xw(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 ic(t,128,1,ar,Xn);return n.needsUpdate=!0,n}var Zw=new WeakMap;function Qw(e){let t=Zw.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 ic(r,n,3,ar,Xn),t.needsUpdate=!0,Zw.set(e,t),t}function $w(e,t,n){if(t===n)return;let r=e.uniforms;r.uDeepTex.value=n?Qw(n):qw(),r.uDeepN.value=n?.n??1}function eT(e,t){return t+(e.referenceAltitudeKm??0)}var tT=`
4442
+ reflectedLight.directSpecular *= eclipseLight;`)}),n}var nT=null;function rT(){return nT||(nT=new ic(new Uint8Array([255,255,255,255]),1,1),nT.needsUpdate=!0),nT}function iT(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 ic(t,e.length,1,ar,Xn);return n.needsUpdate=!0,n}function aT(e,t,n){if(t===n)return;let r=e.uniforms;r.uMieProfileTex.value!==nT&&r.uMieProfileTex.value.dispose(),r.uMieProfileTex.value=n?iT(n):rT(),r.uMieProfileOn.value=+!!n,r.uMieProfileN.value=n?.length??1}function oT(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 ic(t,128,1,ar,Xn);return n.needsUpdate=!0,n}var sT=new WeakMap;function cT(e){let t=sT.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 ic(r,n,3,ar,Xn),t.needsUpdate=!0,sT.set(e,t),t}function lT(e,t,n){if(t===n)return;let r=e.uniforms;r.uDeepTex.value=n?cT(n):rT(),r.uDeepN.value=n?.n??1}function uT(e,t){return t+(e.referenceAltitudeKm??0)}var dT=`
4443
4443
  #include <common>
4444
4444
  #include <logdepthbuf_pars_vertex>
4445
4445
 
@@ -4456,7 +4456,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4456
4456
  gl_Position = projectionMatrix * viewMatrix * worldPos;
4457
4457
  #include <logdepthbuf_vertex>
4458
4458
  }
4459
- `,nT=`
4459
+ `,fT=`
4460
4460
  #include <common>
4461
4461
  #include <logdepthbuf_pars_fragment>
4462
4462
 
@@ -4523,11 +4523,11 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4523
4523
  varying vec3 vWorldPos;
4524
4524
  varying vec3 vPlanetCenter;
4525
4525
 
4526
- ${jw}
4526
+ ${Vw}
4527
4527
 
4528
4528
  // Ring shadow on the air column: the same uniforms the planet surface
4529
4529
  // marches, shared by value-ref once rings load.
4530
- ${zC}
4530
+ ${YC}
4531
4531
 
4532
4532
  // PRIMARY_STEPS / LIGHT_STEPS and the ATMO_ECLIPSE / ATMO_RING_SHADOW /
4533
4533
  // ATMO_INSIDE feature flags come from material.defines — quality tiers
@@ -4738,7 +4738,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4738
4738
  if (hitGeom && fwd > 1e-4) {
4739
4739
  float terrainW = uReversedDepth > 0.5
4740
4740
  ? uCameraNear * uCameraFar / (d * (uCameraFar - uCameraNear) + uCameraNear)
4741
- : ${ww(`d`,`uCameraFar`)};
4741
+ : ${Pw(`d`,`uCameraFar`)};
4742
4742
  float tTerrain = terrainW * dLen / (uPlanetRadiusScene * fwd);
4743
4743
  if (tTerrain < tEnd) {
4744
4744
  tEnd = tTerrain;
@@ -4937,7 +4937,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4937
4937
  gl_FragColor = vec4(color, alpha);
4938
4938
  #include <logdepthbuf_fragment>
4939
4939
  }
4940
- `;function rT(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 iT(e,t,n){let r=eT(e,n),i=t*r/n,a=e.sunColor,o=Nw(),s=ow(),c=new Eu({defines:uT(s),uniforms:{uSunAngularRadius:o.uSunAngularRadius,uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new ga)},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:qw()},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:Xw(e.miePhase)},uMieProfileTex:{value:e.mieProfile?Jw(e.mieProfile):qw()},uMieProfileOn:{value:+!!e.mieProfile},uMieProfileN:{value:e.mieProfile?.length??1},uDeepTex:{value:e.deepColumn?Qw(e.deepColumn):qw()},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:qw()},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:tT,fragmentShader:nT,transparent:!0,depthWrite:!0,blending:5,blendSrc:201,blendDst:205,side:0});rT(c,e,i,r);let l=i*(1+e.topAltitudeKm/r),u=new Ws(new _u(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:sw(s)}}function aT(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 oT=2;function sT(e){return(e.deepColumn?.topKm??0)-(e.referenceAltitudeKm??0)}function cT(e,t){return!!e.deepColumn&&t<sT(e)}function lT(e,t){if(!e.deepColumn)return 0;let n=oT*e.mieScaleHeightKm,r=Math.min(1,Math.max(0,(t-sT(e))/n));return 1-r*r*(3-2*r)}function uT(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 dT(e,t){let n=sw(t);n!==e.qualityKey&&(e.qualityKey=n,e.material.defines=uT(t),e.material.needsUpdate=!0)}function fT(e,t){Yw(e.material,e.params.mieProfile,t.mieProfile),$w(e.material,e.params.deepColumn,t.deepColumn),e.params=t;let n=e.material.uniforms;n.uGroundAlbedo.value=t.groundAlbedo??0,e.planetRadiusKm=eT(t,e.surfaceRadiusKm);let r=e.surfaceRadiusScene*e.planetRadiusKm/e.surfaceRadiusKm;rT(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 pT(e,t,n,r){e.surfaceRadiusKm=t,e.surfaceRadiusScene=r,e.planetRadiusKm=eT(e.params,t);let i=r*e.planetRadiusKm/t;rT(e.material,e.params,i,e.planetRadiusKm),e.material.uniforms.uStretch.value=e.planetRadiusKm/eT(e.params,n);let a=i*(1+e.params.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function mT(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 hT(e){e.mesh.geometry.dispose(),e.material.uniforms.uMiePhaseTex.value.dispose();let t=e.material.uniforms.uMieProfileTex.value;t!==Kw&&t.dispose(),e.mesh.material.dispose()}function gT(e){return(Math.sin(e)+(Math.PI-e)*Math.cos(e))/Math.PI}function _T(e,t,n){let r=e/t;return 2/3*gT(n)*r*r}var vT=`
4940
+ `;function pT(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 mT(e,t,n){let r=uT(e,n),i=t*r/n,a=e.sunColor,o=Uw(),s=gw(),c=new Eu({defines:bT(s),uniforms:{uSunAngularRadius:o.uSunAngularRadius,uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new ga)},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:rT()},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:oT(e.miePhase)},uMieProfileTex:{value:e.mieProfile?iT(e.mieProfile):rT()},uMieProfileOn:{value:+!!e.mieProfile},uMieProfileN:{value:e.mieProfile?.length??1},uDeepTex:{value:e.deepColumn?cT(e.deepColumn):rT()},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:rT()},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:dT,fragmentShader:fT,transparent:!0,depthWrite:!0,blending:5,blendSrc:201,blendDst:205,side:0});pT(c,e,i,r);let l=i*(1+e.topAltitudeKm/r),u=new Ws(new _u(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:_w(s)}}function hT(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 gT=2;function _T(e){return(e.deepColumn?.topKm??0)-(e.referenceAltitudeKm??0)}function vT(e,t){return!!e.deepColumn&&t<_T(e)}function yT(e,t){if(!e.deepColumn)return 0;let n=gT*e.mieScaleHeightKm,r=Math.min(1,Math.max(0,(t-_T(e))/n));return 1-r*r*(3-2*r)}function bT(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 xT(e,t){let n=_w(t);n!==e.qualityKey&&(e.qualityKey=n,e.material.defines=bT(t),e.material.needsUpdate=!0)}function ST(e,t){aT(e.material,e.params.mieProfile,t.mieProfile),lT(e.material,e.params.deepColumn,t.deepColumn),e.params=t;let n=e.material.uniforms;n.uGroundAlbedo.value=t.groundAlbedo??0,e.planetRadiusKm=uT(t,e.surfaceRadiusKm);let r=e.surfaceRadiusScene*e.planetRadiusKm/e.surfaceRadiusKm;pT(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 CT(e,t,n,r){e.surfaceRadiusKm=t,e.surfaceRadiusScene=r,e.planetRadiusKm=uT(e.params,t);let i=r*e.planetRadiusKm/t;pT(e.material,e.params,i,e.planetRadiusKm),e.material.uniforms.uStretch.value=e.planetRadiusKm/uT(e.params,n);let a=i*(1+e.params.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function wT(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 TT(e){e.mesh.geometry.dispose(),e.material.uniforms.uMiePhaseTex.value.dispose();let t=e.material.uniforms.uMieProfileTex.value;t!==nT&&t.dispose(),e.mesh.material.dispose()}function ET(e){return(Math.sin(e)+(Math.PI-e)*Math.cos(e))/Math.PI}function DT(e,t,n){let r=e/t;return 2/3*ET(n)*r*r}var OT=`
4941
4941
  #define PLANETSHINE_SHINERS 2
4942
4942
  uniform vec4 uShineDir[PLANETSHINE_SHINERS];
4943
4943
  uniform vec3 uShineLight[PLANETSHINE_SHINERS];
@@ -4946,7 +4946,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4946
4946
  float t = max(cosTheta + sinAlpha, 0.0);
4947
4947
  return cosTheta >= sinAlpha ? cosTheta : t * t / (4.0 * sinAlpha);
4948
4948
  }
4949
- `,yT=`
4949
+ `,kT=`
4950
4950
  for (int i = 0; i < PLANETSHINE_SHINERS; i++) {
4951
4951
  vec4 shiner = uShineDir[i];
4952
4952
  // The slots fill in order, so the first empty slot ends the list.
@@ -4954,8 +4954,8 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4954
4954
  float cosine = sphereLightCosine(dot(geometryNormal, mat3(viewMatrix) * shiner.xyz), shiner.w);
4955
4955
  reflectedLight.indirectDiffuse += uShineLight[i] * cosine * BRDF_Lambert(material.diffuseContribution);
4956
4956
  }
4957
- `;function bT(){return{uShineDir:{value:Array.from({length:2},()=>new ga(0,0,0,0))},uShineLight:{value:Array.from({length:2},()=>new J)}}}function xT(e,t){let n=t??bT();return US(e,`planetshine`,e=>{Object.assign(e.uniforms,n),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${vT}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>\n${yT}`)}),n}var ST=new Float64Array(2),CT=new ga,wT=new J;function TT(e,t,n,r,i,a){let o=e.uShineDir.value,s=e.uShineLight.value,c=0;for(let e=0;e<a;e++){let a=i[e],l=a.x-t,u=a.y-n,d=a.z-r,f=l*l+u*u+d*d;if(2/3*a.radius*a.radius<1e-4*f)continue;let p=Math.sqrt(f);if(p<=a.radius)continue;let m=a.radius/p,h=-(l*a.sunX+u*a.sunY+d*a.sunZ)/p,g=_T(a.radius,p,Math.acos(Math.max(-1,Math.min(1,h)))),_=g*(.2126*a.albedo.r+.7152*a.albedo.g+.0722*a.albedo.b);if(_<1e-4)continue;let v=c;if(c<2)c++;else if(_>ST[1])v=1;else continue;for(ST[v]=_,o[v].set(l/p,u/p,d/p,m),s[v].set(a.albedo.r,a.albedo.g,a.albedo.b).multiplyScalar(a.sunlight*g);v>0&&ST[v-1]<_;v--)ST[v]=ST[v-1],ST[v-1]=_,CT.copy(o[v-1]),o[v-1].copy(o[v]),o[v].copy(CT),wT.copy(s[v-1]),s[v-1].copy(s[v]),s[v].copy(wT)}for(let e=c;e<2;e++)o[e].set(0,0,0,0),s[e].set(0,0,0);return c}function ET(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 a of n){if(s)for(let n of a.sources)s.credits.registerImagery(`rings`,e,t,{...n,description:a.description});l.push(VC(e,a,o).then(e=>{if(!e)return;if(i.rings.some(e=>e.mesh.userData.ringBundle===a.bundle)){e.mesh.geometry.dispose(),e.mesh.material.dispose();return}e.mesh.userData.ringBundle=a.bundle,e.light.planet=DT(r,i.radiusScene);let t=i.mesh??i.model;if(t&&e.mesh.quaternion.copy(t.quaternion),i.rings.push(e),i.root.add(e.mesh),i.mesh&&a===c){let t=i.mesh.material;e.planetShadow=BC(t,e.innerScene,e.outerScene,e.transparency,e.intensityScale),DC(e.light.profile,e.light.planet)>=1e-4&&(e.ringshine=AC(t)),i.atmosphere&&mT(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}function DT(e,t){return e?{equatorial:Q((e.a+e.b)/2),polar:Q(e.c)}:{equatorial:t,polar:t}}var OT=class extends qa{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 kT(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 AT=new Map;async function jT(e){let t=$t(`/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}`)}return kT(await Ux(n).arrayBuffer())}async function MT(e,t){let n=$t(`/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}`)}return Ux(r).text()}function NT(e,t){let n=t===``?[]:t.split(`
4958
- `);return e.map((e,t)=>({...e,name:n[t]??`Feature ${e.featureId}`}))}function PT(e,t=c()){let n=`${e}:${t}`,r=AT.get(n);return r||(r=(async()=>{await _x();let[n,r]=await Promise.all([jT(e),MT(e,t)]);return NT(n,r)})(),AT.set(n,r),r.catch(()=>{AT.get(n)===r&&AT.delete(n)})),r}var FT=3;function IT(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>FT*FT&&(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 LT="function e(e,t,n,r){return`${e&&`${e}/`}${t}/${n}/${r}.webp`}function t(e,t,n,r,i=1){let a=t.length,o=n.length,s=new Float32Array(a*o*3),c=new Float32Array(a*o*3),l=new Float32Array(a*o*2),u=Float64Array.from(n,Math.sin),d=Float64Array.from(n,Math.cos);for(let f=0;f<a;f++){let a=t[f],p=Math.sin(a),m=Math.cos(a);for(let t=0;t<o;t++){let h=f*o+t,g=-d[t]*p,_=m,v=u[t]*p,y=e+(r?r[h]*i:0),b=h*3;s[b]=y*g,s[b+1]=y*_,s[b+2]=y*v,c[b]=g,c[b+1]=_,c[b+2]=v;let x=h*2;l[x]=n[t]/(2*Math.PI),l[x+1]=1-a/Math.PI}}let f=new Uint32Array((a-1)*(o-1)*6),p=0;for(let e=0;e<a-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<o-1;t++){let i=e*o+t+1,a=e*o+t,s=(e+1)*o+t,c=(e+1)*o+t+1;n||(f[p++]=i,f[p++]=a,f[p++]=c),r||(f[p++]=a,f[p++]=s,f[p++]=c)}}return{positions:s,normals:c,uvs:l,indices:f.subarray(0,p)}}const n=[``,`north`,`south`],r=Math.SQRT2-1;function i(e,t){return e===0?2<<t:1<<t-1}function a(e,t){return e===0?1<<t:1<<t-1}function o(e,t,n,i){if(e===0){let e=Math.atan2(i,-t)/(2*Math.PI);return{x:e<0?e+1:e,y:Math.acos(Math.min(Math.max(n,-1),1))/Math.PI}}let a=e===1?1:-1,o=.5/(r*(1+a*n));return{x:.5+t*o,y:.5+a*i*o}}function s(e,t,n,r){let i=e.max_level-t;return i>=0&&n>=e.x[0]>>i&&n<=e.x[1]>>i&&r>=e.y[0]>>i&&r<=e.y[1]>>i}function c(e,t,n,r){return e?.find(e=>s(e,t,n,r))}const l=Math.sin(60*Math.PI/180),u=2**18,d=2**17;function f(e,t,n,r){return((e*32+t)*u+n)*d+r}function p(e){let t=e%d,n=Math.floor(e/d)%u,r=Math.floor(e/(d*u));return{chart:Math.floor(r/32),level:r%32,x:n,y:t}}const m={chart:0,level:0,x0:0,x1:0,y0:0,y1:0,fx:0,fy:0};function h(e,t,n,r,s){let c=e<1||Math.abs(n)<=l?0:n>0?1:2,u=i(c,e)*s,d=a(c,e)*s,f=o(c,t,n,r),p=f.x*u-.5,h=f.y*d-.5,g=Math.floor(p),_=Math.floor(h),v=e=>Math.min(Math.max(e,0),u-1),y=e=>Math.min(Math.max(e,0),d-1);return m.chart=c,m.level=e,m.fx=p-g,m.fy=h-_,m.x0=c===0?(g+u)%u:v(g),m.x1=c===0?(g+1)%u:v(g+1),m.y0=y(_),m.y1=y(_+1),m}function g(e,t,n){let r=Float64Array.from(t.at,Math.sin),i=Float64Array.from(t.at,Math.cos),a=t.at.length;for(let o=0;o<e.at.length;o++){let s=Math.sin(e.at[o]),c=Math.cos(e.at[o]);for(let l=0;l<a;l++){let u=Math.min(e.level[o],t.level[l]);n(o*a+l,u,-i[l]*s,c,r[l]*s)}}}function _(e,t,n,r=1/0,i=()=>!0){let a=new Set([f(0,0,0,0),f(0,0,1,0)]);return g(e,t,(e,t,o,s,c)=>{for(let e=t;;e--){let t=h(e,o,s,c,n),l=Math.floor(t.x0/n),u=Math.floor(t.x1/n),d=Math.floor(t.y0/n),p=Math.floor(t.y1/n);if(!(e>r&&!(i(t.chart,e,l,d)&&i(t.chart,e,u,d)&&i(t.chart,e,l,p)&&i(t.chart,e,u,p)))){a.add(f(t.chart,e,l,d)),u!==l&&a.add(f(t.chart,e,u,d)),p!==d&&(a.add(f(t.chart,e,l,p)),u!==l&&a.add(f(t.chart,e,u,p)));return}}}),a}function v(e,t,n,r,i,a){for(let o=t;o>=0;o--){let t=h(o,n,r,i,a),s=(n,r)=>{let i=e(f(t.chart,o,Math.floor(n/a),Math.floor(r/a)));return i&&i[r%a*a+n%a]},c=s(t.x0,t.y0),l=s(t.x1,t.y0),u=s(t.x0,t.y1),d=s(t.x1,t.y1);if(c===void 0||l===void 0||u===void 0||d===void 0)continue;let p=c+(l-c)*t.fx;return p+(u+(d-u)*t.fx-p)*t.fy}}function y(e,t,n,r,i,a){let o=new Float32Array(e.at.length*t.at.length),s=!1;return g(e,t,(e,t,c,l,u)=>{let d=v(n,t,c,l,u,r);d===void 0?s=!0:o[e]=a+i*d/65535}),s?null:o}function b(e,t){let n=new Uint8Array(t*t*2);for(let r=0;r<t;r++){let i=(t-1-r)*t*4,a=r*t*2;for(let r=0;r<t;r++,i+=4,a+=2)n[a]=e[i],n[a+1]=e[i+1]}return n}function x(e,t){let n=new Float32Array(t*t);for(let r=0;r<t;r++){let i=(t-1-r)*t*4,a=(r+1)*t;for(let o=r*t;o<a;o++,i+=4)n[o]=(e[i]<<8|e[i+1])+e[i+2]/256}return n}function S(e,t,n){let r=n?new Float32Array(t*t):new Uint16Array(t*t);for(let t=0,i=0;t<r.length;t++,i+=4){let a=e[i]<<8|e[i+1];r[t]=n?a+e[i+2]/256:a}return r}const C=self,w=new Map;let T;async function E(e,t){let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`tile ${n.status}`);let r=await createImageBitmap(await n.blob(),{premultiplyAlpha:`none`,colorSpaceConversion:`none`}),i=r.width;T?.width!==i&&(T=new OffscreenCanvas(i,i));let a=T.getContext(`2d`,{willReadFrequently:!0});if(!a)throw Error(`no 2d canvas in this worker`);return a.globalCompositeOperation=`copy`,a.drawImage(r,0,0),r.close(),{rgba:a.getImageData(0,0,i,i).data,size:i}}async function D(e,t){let{rgba:n,size:r}=await E(e.url,t),i=e.fine?x(n,r):b(n,r);C.postMessage({type:`tile`,id:e.id,size:r,heights:i},[i.buffer])}const O=new Map;let k=``;async function A(r,i){let{rows:a,columns:o,tileSize:s,maxLevel:l,patches:u}=r,d=[r.version,...u.map(e=>e.version)],f=`${r.root}?${d.join()}`;f!==k&&O.clear(),k=f;let m=(e,t,n,r)=>e===0?c(u,t,n,r):void 0,h=_(a,o,s,l,(e,t,n,r)=>m(e,t,n,r)!==void 0),g=[...h].filter(e=>!O.has(e));await Promise.all(Array.from({length:6},async()=>{for(let t=g.pop();t!==void 0;t=g.pop()){let{chart:a,level:o,x:s,y:c}=p(t),u=o>l,d=u?m(a,o,s,c)?.version:r.version,f=`${r.root}${e(n[a],o,s,c)}?v=${d}`;try{let{rgba:e,size:n}=await E(f,i);O.set(t,S(e,n,u))}catch{if(i.aborted)return}}})),i.throwIfAborted();let v=y(a,o,e=>O.get(e),s,r.scaleKm,r.biasKm);for(let e of[...O.keys()])h.has(e)||O.delete(e);if(!v)throw Error(`no height tiles for the grid`);let b=t(r.radius,a.at,o.at,v,r.unitsPerKm),x=b.indices.slice();C.postMessage({type:`grid`,id:r.id,...b,indices:x,riseKm:v},[b.positions.buffer,b.normals.buffer,b.uvs.buffer,x.buffer,v.buffer])}async function j(e){let t=new AbortController;w.set(e.id,t);try{e.type===`tile`?await D(e,t.signal):await A(e,t.signal)}catch{C.postMessage({type:`failed`,id:e.id})}finally{w.delete(e.id)}}self.onmessage=e=>{let t=e.data;t.type===`abort`?w.get(t.id)?.abort():j(t)};\n//# sourceMappingURL=worker-BiAlrV6p.js.map",RT=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,LT],{type:`text/javascript;charset=utf-8`});function zT(e){let t;try{if(t=RT&&(self.URL||self.webkitURL).createObjectURL(RT),!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(LT),{type:`module`,name:e?.name})}}var BT=null,VT=1,HT=new Map;function UT(e){BT?.terminate(),BT=null;let t=[...HT.values()];HT.clear();for(let{reject:n}of t)n(Error(e))}function WT(){return BT||(BT=new zT,BT.onmessage=e=>{let t=e.data,n=HT.get(t.id);HT.delete(t.id),n&&(t.type===`failed`?n.reject(Error(`relief worker could not answer`)):n.resolve(t))},BT.onerror=e=>UT(`relief worker error: ${e.message||`unknown`}`),BT.onmessageerror=()=>UT(`relief worker sent a message that could not be read`),BT)}function GT(e,t){return new Promise((n,r)=>{if(typeof Worker>`u`){r(Error(`no workers here`));return}let i=VT++;HT.set(i,{resolve:n,reject:r}),t.addEventListener(`abort`,()=>{HT.delete(i)&&(WT().postMessage({type:`abort`,id:i}),r(new DOMException(`aborted`,`AbortError`)))},{once:!0}),WT().postMessage(e(i))})}function KT(e){return new URL(e,location.href).href}function qT(e,t,n){return GT(n=>({type:`tile`,id:n,url:KT(e),fine:t}),n)}function JT(e,t){return GT(t=>({...e,type:`grid`,id:t,root:KT(e.root)}),t)}var YT=[``,`north`,`south`],XT=.75,ZT=2048,QT=Math.SQRT2-1,$T=62,eE=58,tE=45;function nE(e,t){return e===0?2<<t:1<<t-1}function rE(e,t){return e===0?1<<t:1<<t-1}function iE(e,t,n,r){let i=Math.max(t-e,e*1e-6),a=2*Math.PI*e*n/i;return Math.min(Math.ceil(Math.log2(a/ZT)),r)}function aE(e,t,n,r){if(e===0){let e=Math.atan2(r,-t)/(2*Math.PI);return{x:e<0?e+1:e,y:Math.acos(Math.min(Math.max(n,-1),1))/Math.PI}}let i=e===1?1:-1,a=.5/(QT*(1+i*n));return{x:.5+t*a,y:.5+i*r*a}}function oE(e,t){let n=e>=0?1:2;return Math.asin(Math.min(Math.abs(e),1))*180/Math.PI>(t===n?eE:$T)?n:0}function sE(e,t,n,r,i,a=!1){let o=[],s=e-i;if(a&&t>1&&s>=t){let r=t===2?i+Math.ceil(s/2):e;for(let e=0;e<t;e++)o.push({chart:n,level:Math.round(r-e*(r-i)/(t-1))});return o}let c=Math.max(1,Math.floor(t/3)),l=e;for(;l>=3&&o.length<t;)o.push({chart:n,level:l}),l=l>i&&o.length>=t-c?Math.min(l-1,i):l-1;let u=o.length>0&&o[o.length-1].level===3,d=Math.abs(r)>Math.sin(tE*Math.PI/180);if(u&&d&&o.length<t){let e=r>=0?1:2;o.push({chart:n===0?e:0,level:3})}return o}function cE(e,t,n,r){let i=Math.max(t-4,0);if(r!==void 0){let a=e-(r+4/2);if(n&&(a-=t*Math.round(a/t)),!n&&(r===0&&a<0||r===i&&a>0)||Math.abs(a)<=XT)return r}let a=Math.round(e-4/2);return n?(a%t+t)%t:Math.min(Math.max(a,0),i)}function lE(e,t,n,r,i){let a=nE(e,t),o=rE(e,t),s=i?.chart===e&&i.level===t?i:void 0,c=cE(n*a,a,e===0,s?.tx0),l=cE(r*o,o,!1,s?.ty0);return s&&s.tx0===c&&s.ty0===l?s:{chart:e,level:t,tx0:c,ty0:l}}function uE(e,t,n,r){let i=e.max_level-t;return i>=0&&n>=e.x[0]>>i&&n<=e.x[1]>>i&&r>=e.y[0]>>i&&r<=e.y[1]>>i}function dE(e,t,n,r){return e?.find(e=>uE(e,t,n,r))}function fE(e,t,n,r){let i=e.patches?.filter(i=>t>e.max_level-(i.map_levels??0)&&uE(i,t,n,r));return i?.length?i.map(e=>e.version).join(`.`):e.version}var pE=4/2-.5;function mE(e,t,n,r){let i=e;if(!t)return i;for(let e of t)for(let t=e.max_level;t>i;t--){let a=e.max_level-t,o=nE(0,t),s=e.x[0]>>a,c=e.y[0]>>a,l=((e.x[1]>>a)+1-s)/2,u=((e.y[1]>>a)+1-c)/2,d=n*o-(s+l);d-=o*Math.round(d/o);let f=r*rE(0,t)-(c+u);if(Math.abs(d)-l<=pE&&Math.abs(f)-u<=pE){i=t;break}}return i}function hE(e,t,n){let r=nE(e.chart,e.level),i=t*r-e.tx0;return i-=r*Math.round(i/r),{x:i,y:n*rE(e.chart,e.level)-e.ty0}}function gE(e,t,n){let r=nE(e.chart,e.level),i=((t-e.tx0)%4+4)%4,a=((n-e.ty0)%4+4)%4;return{x:(e.tx0+i)%r,y:e.ty0+a}}var _E={low:{maxPixelRatio:1.25,shadowMapSize:1024,softShadows:!1,bloomScale:.5,sceneSamples:0,pointBudget:4e5,maxTextureTier:`medium`,tileWindows:3,reliefWindows:2,reliefShadowSteps:12,terrainBandCells:16,maxSkyboxFace:2048},medium:{maxPixelRatio:1.5,shadowMapSize:2048,softShadows:!0,bloomScale:.75,sceneSamples:4,pointBudget:9e5,maxTextureTier:`medium`,tileWindows:4,reliefWindows:3,reliefShadowSteps:16,terrainBandCells:24,maxSkyboxFace:2048},high:{maxPixelRatio:2,shadowMapSize:4096,softShadows:!0,bloomScale:1,sceneSamples:4,pointBudget:1/0,maxTextureTier:`high`,tileWindows:6,reliefWindows:4,reliefShadowSteps:32,terrainBandCells:32,maxSkyboxFace:1/0}};function vE(){return GC()?`low`:CE().maxTextureTier}function yE(){return GC()?0:CE().tileWindows}function bE(){return GC()?0:CE().reliefWindows}function xE(){return CE().reliefShadowSteps}function SE(){let e=ew().atmosphereCalibration?.tier;return e===`low`||e===`medium`?e:e===`high`||e===`ultra`?`high`:qC()?GC()?`low`:`medium`:GC()?`medium`:`high`}function CE(){return _E[SE()]}function wE(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,CE().maxPixelRatio)}var TE=6,EE=4,DE=30,OE=5,kE=.5,AE=16,jE=`
4957
+ `;function AT(){return{uShineDir:{value:Array.from({length:2},()=>new ga(0,0,0,0))},uShineLight:{value:Array.from({length:2},()=>new J)}}}function jT(e,t){let n=t??AT();return $S(e,`planetshine`,e=>{Object.assign(e.uniforms,n),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${OT}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>\n${kT}`)}),n}var MT=new Float64Array(2),NT=new ga,PT=new J;function FT(e,t,n,r,i,a){let o=e.uShineDir.value,s=e.uShineLight.value,c=0;for(let e=0;e<a;e++){let a=i[e],l=a.x-t,u=a.y-n,d=a.z-r,f=l*l+u*u+d*d;if(2/3*a.radius*a.radius<1e-4*f)continue;let p=Math.sqrt(f);if(p<=a.radius)continue;let m=a.radius/p,h=-(l*a.sunX+u*a.sunY+d*a.sunZ)/p,g=DT(a.radius,p,Math.acos(Math.max(-1,Math.min(1,h)))),_=g*(.2126*a.albedo.r+.7152*a.albedo.g+.0722*a.albedo.b);if(_<1e-4)continue;let v=c;if(c<2)c++;else if(_>MT[1])v=1;else continue;for(MT[v]=_,o[v].set(l/p,u/p,d/p,m),s[v].set(a.albedo.r,a.albedo.g,a.albedo.b).multiplyScalar(a.sunlight*g);v>0&&MT[v-1]<_;v--)MT[v]=MT[v-1],MT[v-1]=_,NT.copy(o[v-1]),o[v-1].copy(o[v]),o[v].copy(NT),PT.copy(s[v-1]),s[v-1].copy(s[v]),s[v].copy(PT)}for(let e=c;e<2;e++)o[e].set(0,0,0,0),s[e].set(0,0,0);return c}function IT(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 a of n){if(s)for(let n of a.sources)s.credits.registerImagery(`rings`,e,t,{...n,description:a.description});l.push(ZC(e,a,o).then(e=>{if(!e)return;if(i.rings.some(e=>e.mesh.userData.ringBundle===a.bundle)){e.mesh.geometry.dispose(),e.mesh.material.dispose();return}e.mesh.userData.ringBundle=a.bundle,e.light.planet=LT(r,i.radiusScene);let t=i.mesh??i.model;if(t&&e.mesh.quaternion.copy(t.quaternion),i.rings.push(e),i.root.add(e.mesh),i.mesh&&a===c){let t=i.mesh.material;e.planetShadow=XC(t,e.innerScene,e.outerScene,e.transparency,e.intensityScale),LC(e.light.profile,e.light.planet)>=1e-4&&(e.ringshine=BC(t)),i.atmosphere&&wT(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}function LT(e,t){return e?{equatorial:Q((e.a+e.b)/2),polar:Q(e.c)}:{equatorial:t,polar:t}}var RT=class extends qa{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 zT(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 BT=new Map;async function VT(e){let t=$t(`/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}`)}return zT(await Ux(n).arrayBuffer())}async function HT(e,t){let n=$t(`/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}`)}return Ux(r).text()}function UT(e,t){let n=t===``?[]:t.split(`
4958
+ `);return e.map((e,t)=>({...e,name:n[t]??`Feature ${e.featureId}`}))}function WT(e,t=c()){let n=`${e}:${t}`,r=BT.get(n);return r||(r=(async()=>{await _x();let[n,r]=await Promise.all([VT(e),HT(e,t)]);return UT(n,r)})(),BT.set(n,r),r.catch(()=>{BT.get(n)===r&&BT.delete(n)})),r}var GT=3;function KT(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>GT*GT&&(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 qT="function e(e,t,n,r){return`${e&&`${e}/`}${t}/${n}/${r}.webp`}function t(e,t,n,r,i=1){let a=t.length,o=n.length,s=new Float32Array(a*o*3),c=new Float32Array(a*o*3),l=new Float32Array(a*o*2),u=Float64Array.from(n,Math.sin),d=Float64Array.from(n,Math.cos);for(let f=0;f<a;f++){let a=t[f],p=Math.sin(a),m=Math.cos(a);for(let t=0;t<o;t++){let h=f*o+t,g=-d[t]*p,_=m,v=u[t]*p,y=e+(r?r[h]*i:0),b=h*3;s[b]=y*g,s[b+1]=y*_,s[b+2]=y*v,c[b]=g,c[b+1]=_,c[b+2]=v;let x=h*2;l[x]=n[t]/(2*Math.PI),l[x+1]=1-a/Math.PI}}let f=new Uint32Array((a-1)*(o-1)*6),p=0;for(let e=0;e<a-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<o-1;t++){let i=e*o+t+1,a=e*o+t,s=(e+1)*o+t,c=(e+1)*o+t+1;n||(f[p++]=i,f[p++]=a,f[p++]=c),r||(f[p++]=a,f[p++]=s,f[p++]=c)}}return{positions:s,normals:c,uvs:l,indices:f.subarray(0,p)}}const n=[``,`north`,`south`],r=Math.SQRT2-1;function i(e,t){return e===0?2<<t:1<<t-1}function a(e,t){return e===0?1<<t:1<<t-1}function o(e,t,n,i){if(e===0){let e=Math.atan2(i,-t)/(2*Math.PI);return{x:e<0?e+1:e,y:Math.acos(Math.min(Math.max(n,-1),1))/Math.PI}}let a=e===1?1:-1,o=.5/(r*(1+a*n));return{x:.5+t*o,y:.5+a*i*o}}function s(e,t,n,r){let i=e.max_level-t;return i>=0&&n>=e.x[0]>>i&&n<=e.x[1]>>i&&r>=e.y[0]>>i&&r<=e.y[1]>>i}function c(e,t,n,r){return e?.find(e=>s(e,t,n,r))}const l=Math.sin(60*Math.PI/180),u=2**18,d=2**17;function f(e,t,n,r){return((e*32+t)*u+n)*d+r}function p(e){let t=e%d,n=Math.floor(e/d)%u,r=Math.floor(e/(d*u));return{chart:Math.floor(r/32),level:r%32,x:n,y:t}}const m={chart:0,level:0,x0:0,x1:0,y0:0,y1:0,fx:0,fy:0};function h(e,t,n,r,s){let c=e<1||Math.abs(n)<=l?0:n>0?1:2,u=i(c,e)*s,d=a(c,e)*s,f=o(c,t,n,r),p=f.x*u-.5,h=f.y*d-.5,g=Math.floor(p),_=Math.floor(h),v=e=>Math.min(Math.max(e,0),u-1),y=e=>Math.min(Math.max(e,0),d-1);return m.chart=c,m.level=e,m.fx=p-g,m.fy=h-_,m.x0=c===0?(g+u)%u:v(g),m.x1=c===0?(g+1)%u:v(g+1),m.y0=y(_),m.y1=y(_+1),m}function g(e,t,n){let r=Float64Array.from(t.at,Math.sin),i=Float64Array.from(t.at,Math.cos),a=t.at.length;for(let o=0;o<e.at.length;o++){let s=Math.sin(e.at[o]),c=Math.cos(e.at[o]);for(let l=0;l<a;l++){let u=Math.min(e.level[o],t.level[l]);n(o*a+l,u,-i[l]*s,c,r[l]*s)}}}function _(e,t,n,r=1/0,i=()=>!0){let a=new Set([f(0,0,0,0),f(0,0,1,0)]);return g(e,t,(e,t,o,s,c)=>{for(let e=t;;e--){let t=h(e,o,s,c,n),l=Math.floor(t.x0/n),u=Math.floor(t.x1/n),d=Math.floor(t.y0/n),p=Math.floor(t.y1/n);if(!(e>r&&!(i(t.chart,e,l,d)&&i(t.chart,e,u,d)&&i(t.chart,e,l,p)&&i(t.chart,e,u,p)))){a.add(f(t.chart,e,l,d)),u!==l&&a.add(f(t.chart,e,u,d)),p!==d&&(a.add(f(t.chart,e,l,p)),u!==l&&a.add(f(t.chart,e,u,p)));return}}}),a}function v(e,t,n,r,i,a){for(let o=t;o>=0;o--){let t=h(o,n,r,i,a),s=(n,r)=>{let i=e(f(t.chart,o,Math.floor(n/a),Math.floor(r/a)));return i&&i[r%a*a+n%a]},c=s(t.x0,t.y0),l=s(t.x1,t.y0),u=s(t.x0,t.y1),d=s(t.x1,t.y1);if(c===void 0||l===void 0||u===void 0||d===void 0)continue;let p=c+(l-c)*t.fx;return p+(u+(d-u)*t.fx-p)*t.fy}}function y(e,t,n,r,i,a){let o=new Float32Array(e.at.length*t.at.length),s=!1;return g(e,t,(e,t,c,l,u)=>{let d=v(n,t,c,l,u,r);d===void 0?s=!0:o[e]=a+i*d/65535}),s?null:o}function b(e,t){let n=new Uint8Array(t*t*2);for(let r=0;r<t;r++){let i=(t-1-r)*t*4,a=r*t*2;for(let r=0;r<t;r++,i+=4,a+=2)n[a]=e[i],n[a+1]=e[i+1]}return n}function x(e,t){let n=new Float32Array(t*t);for(let r=0;r<t;r++){let i=(t-1-r)*t*4,a=(r+1)*t;for(let o=r*t;o<a;o++,i+=4)n[o]=(e[i]<<8|e[i+1])+e[i+2]/256}return n}function S(e,t,n){let r=n?new Float32Array(t*t):new Uint16Array(t*t);for(let t=0,i=0;t<r.length;t++,i+=4){let a=e[i]<<8|e[i+1];r[t]=n?a+e[i+2]/256:a}return r}const C=self,w=new Map;let T;async function E(e,t){let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`tile ${n.status}`);let r=await createImageBitmap(await n.blob(),{premultiplyAlpha:`none`,colorSpaceConversion:`none`}),i=r.width;T?.width!==i&&(T=new OffscreenCanvas(i,i));let a=T.getContext(`2d`,{willReadFrequently:!0});if(!a)throw Error(`no 2d canvas in this worker`);return a.globalCompositeOperation=`copy`,a.drawImage(r,0,0),r.close(),{rgba:a.getImageData(0,0,i,i).data,size:i}}async function D(e,t){let{rgba:n,size:r}=await E(e.url,t),i=e.fine?x(n,r):b(n,r);C.postMessage({type:`tile`,id:e.id,size:r,heights:i},[i.buffer])}const O=new Map;let k=``;async function A(r,i){let{rows:a,columns:o,tileSize:s,maxLevel:l,patches:u}=r,d=[r.version,...u.map(e=>e.version)],f=`${r.root}?${d.join()}`;f!==k&&O.clear(),k=f;let m=(e,t,n,r)=>e===0?c(u,t,n,r):void 0,h=_(a,o,s,l,(e,t,n,r)=>m(e,t,n,r)!==void 0),g=[...h].filter(e=>!O.has(e));await Promise.all(Array.from({length:6},async()=>{for(let t=g.pop();t!==void 0;t=g.pop()){let{chart:a,level:o,x:s,y:c}=p(t),u=o>l,d=u?m(a,o,s,c)?.version:r.version,f=`${r.root}${e(n[a],o,s,c)}?v=${d}`;try{let{rgba:e,size:n}=await E(f,i);O.set(t,S(e,n,u))}catch{if(i.aborted)return}}})),i.throwIfAborted();let v=y(a,o,e=>O.get(e),s,r.scaleKm,r.biasKm);for(let e of[...O.keys()])h.has(e)||O.delete(e);if(!v)throw Error(`no height tiles for the grid`);let b=t(r.radius,a.at,o.at,v,r.unitsPerKm),x=b.indices.slice();C.postMessage({type:`grid`,id:r.id,...b,indices:x,riseKm:v},[b.positions.buffer,b.normals.buffer,b.uvs.buffer,x.buffer,v.buffer])}async function j(e){let t=new AbortController;w.set(e.id,t);try{e.type===`tile`?await D(e,t.signal):await A(e,t.signal)}catch{C.postMessage({type:`failed`,id:e.id})}finally{w.delete(e.id)}}self.onmessage=e=>{let t=e.data;t.type===`abort`?w.get(t.id)?.abort():j(t)};\n//# sourceMappingURL=worker-BiAlrV6p.js.map",JT=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,qT],{type:`text/javascript;charset=utf-8`});function YT(e){let t;try{if(t=JT&&(self.URL||self.webkitURL).createObjectURL(JT),!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(qT),{type:`module`,name:e?.name})}}var XT=null,ZT=1,QT=new Map;function $T(e){XT?.terminate(),XT=null;let t=[...QT.values()];QT.clear();for(let{reject:n}of t)n(Error(e))}function eE(){return XT||(XT=new YT,XT.onmessage=e=>{let t=e.data,n=QT.get(t.id);QT.delete(t.id),n&&(t.type===`failed`?n.reject(Error(`relief worker could not answer`)):n.resolve(t))},XT.onerror=e=>$T(`relief worker error: ${e.message||`unknown`}`),XT.onmessageerror=()=>$T(`relief worker sent a message that could not be read`),XT)}function tE(e,t){return new Promise((n,r)=>{if(typeof Worker>`u`){r(Error(`no workers here`));return}let i=ZT++;QT.set(i,{resolve:n,reject:r}),t.addEventListener(`abort`,()=>{QT.delete(i)&&(eE().postMessage({type:`abort`,id:i}),r(new DOMException(`aborted`,`AbortError`)))},{once:!0}),eE().postMessage(e(i))})}function nE(e){return new URL(e,location.href).href}function rE(e,t,n){return tE(n=>({type:`tile`,id:n,url:nE(e),fine:t}),n)}function iE(e,t){return tE(t=>({...e,type:`grid`,id:t,root:nE(e.root)}),t)}var aE=[``,`north`,`south`],oE=.75,sE=2048,cE=Math.SQRT2-1,lE=62,uE=58,dE=45;function fE(e,t){return e===0?2<<t:1<<t-1}function pE(e,t){return e===0?1<<t:1<<t-1}function mE(e,t,n,r){let i=Math.max(t-e,e*1e-6),a=2*Math.PI*e*n/i;return Math.min(Math.ceil(Math.log2(a/sE)),r)}function hE(e,t,n,r){if(e===0){let e=Math.atan2(r,-t)/(2*Math.PI);return{x:e<0?e+1:e,y:Math.acos(Math.min(Math.max(n,-1),1))/Math.PI}}let i=e===1?1:-1,a=.5/(cE*(1+i*n));return{x:.5+t*a,y:.5+i*r*a}}function gE(e,t){let n=e>=0?1:2;return Math.asin(Math.min(Math.abs(e),1))*180/Math.PI>(t===n?uE:lE)?n:0}function _E(e,t,n,r,i,a=!1){let o=[],s=e-i;if(a&&t>1&&s>=t){let r=t===2?i+Math.ceil(s/2):e;for(let e=0;e<t;e++)o.push({chart:n,level:Math.round(r-e*(r-i)/(t-1))});return o}let c=Math.max(1,Math.floor(t/3)),l=e;for(;l>=3&&o.length<t;)o.push({chart:n,level:l}),l=l>i&&o.length>=t-c?Math.min(l-1,i):l-1;let u=o.length>0&&o[o.length-1].level===3,d=Math.abs(r)>Math.sin(dE*Math.PI/180);if(u&&d&&o.length<t){let e=r>=0?1:2;o.push({chart:n===0?e:0,level:3})}return o}function vE(e,t,n,r){let i=Math.max(t-4,0);if(r!==void 0){let a=e-(r+4/2);if(n&&(a-=t*Math.round(a/t)),!n&&(r===0&&a<0||r===i&&a>0)||Math.abs(a)<=oE)return r}let a=Math.round(e-4/2);return n?(a%t+t)%t:Math.min(Math.max(a,0),i)}function yE(e,t,n,r,i){let a=fE(e,t),o=pE(e,t),s=i?.chart===e&&i.level===t?i:void 0,c=vE(n*a,a,e===0,s?.tx0),l=vE(r*o,o,!1,s?.ty0);return s&&s.tx0===c&&s.ty0===l?s:{chart:e,level:t,tx0:c,ty0:l}}function bE(e,t,n,r){let i=e.max_level-t;return i>=0&&n>=e.x[0]>>i&&n<=e.x[1]>>i&&r>=e.y[0]>>i&&r<=e.y[1]>>i}function xE(e,t,n,r){return e?.find(e=>bE(e,t,n,r))}function SE(e,t,n,r){let i=e.patches?.filter(i=>t>e.max_level-(i.map_levels??0)&&bE(i,t,n,r));return i?.length?i.map(e=>e.version).join(`.`):e.version}var CE=4/2-.5;function wE(e,t,n,r){let i=e;if(!t)return i;for(let e of t)for(let t=e.max_level;t>i;t--){let a=e.max_level-t,o=fE(0,t),s=e.x[0]>>a,c=e.y[0]>>a,l=((e.x[1]>>a)+1-s)/2,u=((e.y[1]>>a)+1-c)/2,d=n*o-(s+l);d-=o*Math.round(d/o);let f=r*pE(0,t)-(c+u);if(Math.abs(d)-l<=CE&&Math.abs(f)-u<=CE){i=t;break}}return i}function TE(e,t,n){let r=fE(e.chart,e.level),i=t*r-e.tx0;return i-=r*Math.round(i/r),{x:i,y:n*pE(e.chart,e.level)-e.ty0}}function EE(e,t,n){let r=fE(e.chart,e.level),i=((t-e.tx0)%4+4)%4,a=((n-e.ty0)%4+4)%4;return{x:(e.tx0+i)%r,y:e.ty0+a}}var DE={low:{maxPixelRatio:1.25,shadowMapSize:1024,softShadows:!1,bloomScale:.5,sceneSamples:0,pointBudget:4e5,maxTextureTier:`medium`,tileWindows:3,reliefWindows:2,reliefShadowSteps:12,terrainBandCells:16,maxSkyboxFace:2048},medium:{maxPixelRatio:1.5,shadowMapSize:2048,softShadows:!0,bloomScale:.75,sceneSamples:4,pointBudget:9e5,maxTextureTier:`medium`,tileWindows:4,reliefWindows:3,reliefShadowSteps:16,terrainBandCells:24,maxSkyboxFace:2048},high:{maxPixelRatio:2,shadowMapSize:4096,softShadows:!0,bloomScale:1,sceneSamples:4,pointBudget:1/0,maxTextureTier:`high`,tileWindows:6,reliefWindows:4,reliefShadowSteps:32,terrainBandCells:32,maxSkyboxFace:1/0}};function OE(){return tw()?`low`:NE().maxTextureTier}function kE(){return tw()?0:NE().tileWindows}function AE(){return tw()?0:NE().reliefWindows}function jE(){return NE().reliefShadowSteps}function ME(){let e=uw().atmosphereCalibration?.tier;return e===`low`||e===`medium`?e:e===`high`||e===`ultra`?`high`:rw()?tw()?`low`:`medium`:tw()?`medium`:`high`}function NE(){return DE[ME()]}function PE(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,NE().maxPixelRatio)}var FE=6,IE=4,LE=30,RE=5,zE=.5,BE=16,VE=`
4959
4959
  #ifndef TILE_CHAIN
4960
4960
  #define TILE_CHAIN
4961
4961
 
@@ -4969,7 +4969,7 @@ void tileCap( vec3 dir, vec3 ddx, vec3 ddy, out float side, out mat3x2 cap ) {
4969
4969
  side = dir.y < 0.0 ? - 1.0 : 1.0;
4970
4970
  float fold = 1.0 + side * dir.y;
4971
4971
  vec2 plane = vec2( dir.x, side * dir.z );
4972
- float capScale = 0.5 / ( ${QT.toFixed(8)} * fold );
4972
+ float capScale = 0.5 / ( ${cE.toFixed(8)} * fold );
4973
4973
  cap = mat3x2(
4974
4974
  0.5 + plane * capScale,
4975
4975
  ( vec2( ddx.x, side * ddx.z ) - plane * ( side * ddx.y / fold ) ) * capScale,
@@ -5065,11 +5065,11 @@ float tileWindowWeight( mat3x2 map, mat3x2 cap, float side, vec4 window, vec4 gr
5065
5065
  // The texture repeats every window: a tile sits in the slot its own
5066
5066
  // column and row pick, north up.
5067
5067
  spot = rel + mod( grid.zw, rows );
5068
- return weight * smoothstep( 0.0, ${kE.toFixed(2)}, min( near.x, near.y ) );
5068
+ return weight * smoothstep( 0.0, ${zE.toFixed(2)}, min( near.x, near.y ) );
5069
5069
  }
5070
5070
 
5071
5071
  #endif
5072
- `;function ME(e,t=!1){return{kind:e,spread:t,uniforms:{map:{value:null},mask:{value:null},grid:{value:Array.from({length:7},()=>new ga)},window:{value:Array.from({length:7},()=>new ga)},home:{value:Array.from({length:7},()=>new q)},anchor:{value:new J(1,0,0)},loaded:{value:new Int32Array(7)},filter:{value:new q(1,1)}},inflight:0,failures:0,failed:new Set,dead:!1,lastUsed:0}}function NE(e,t,n,r){let i=t*4,a=new ya(null,i,i,n);a.source.dataReady=!1,a.format=e.format,a.type=e.type,a.colorSpace=e.colorSpace,a.wrapS=a.wrapT=Fn,a.magFilter=Vn,a.minFilter=Un,a.generateMipmaps=!1,a.anisotropy=Math.min(16,r.capabilities.getMaxAnisotropy()),a.needsUpdate=!0;let o=new ya(new Uint8Array(AE*n),4,4,n);return o.format=cr,o.type=Wn,o.minFilter=o.magFilter=Vn,o.wrapS=o.wrapT=Fn,o.unpackAlignment=1,o.needsUpdate=!0,{kind:e,texture:a,mask:o,windows:[],free:Array.from({length:n},(e,t)=>t),tileSize:t}}function PE(e,t,n,r){e.mask.image.data[t*AE+n]=r?255:0,e.mask.needsUpdate=!0}function FE(e,t,n){return e.mask.image.data[t*AE+n]!==0}function IE(e,t,n,r){if(!(t.placement===n&&t.frame===r)){t.placement=n,t.frame=r;for(let i=0;i<AE;i++){let{x:a,y:o}=gE(n,i%4,Math.floor(i/4)),s=`${r??0}/${t.chart}/${t.level}/${a}/${o}`;if(t.wanted[i]===s)continue;t.wanted[i]=s,PE(e,t.layer,i,!1);let c=t.pending.get(i);c&&(c.abort.abort(),t.pending.delete(i))}}}function LE(e,t){for(let{abort:e}of t.pending.values())e.abort();t.pending.clear();for(let n=0;n<AE;n++)PE(e,t.layer,n,!1);e.free.push(t.layer)}function RE(e,t,n){if(!(t.chart!==0||t.level<=e.max_level))return dE(e.patches,t.level,n.x,n.y)}function zE(e,t,n){return t.level<=e.max_level?!0:t.placement?RE(e,t,gE(t.placement,n%4,Math.floor(n/4)))!==void 0:!1}function BE(e,t,n,r){for(let i=0;i<AE;i++){let a=r.wanted[i];if(!a||!(FE(t,r.layer,i)||e.failed.has(a))&&zE(n,r,i))return!1}return!0}var VE=new J,HE=[];function UE(e,t,n,r,i,a,o,s){let c=r.placement;if(!c)return;let l=nE(r.chart,r.level),u=i*l,d=a*rE(r.chart,r.level);HE.length=0;for(let i=0;i<AE;i++){let a=r.wanted[i];if(!a||r.pending.has(i)||e.failed.has(a)||FE(t,r.layer,i)||!zE(n,r,i))continue;let o=gE(c,i%4,Math.floor(i/4)),s=o.x+.5-u;r.chart===0&&(s-=l*Math.round(s/l)),HE.push({slot:i,far:Math.hypot(s,o.y+.5-d)})}HE.sort((e,t)=>e.far-t.far);for(let{slot:i}of HE){if(e.inflight>=TE)return;let a=r.wanted[i],l=i%4,u=Math.floor(i/4),d=gE(c,l,u),f=new AbortController,p=!1,m=setTimeout(()=>{p=!0,f.abort()},DE*1e3);r.pending.set(i,{key:a,abort:f}),e.inflight++;let h=YT[r.chart],g=RE(n,r,d)?.version??(r.chart===0?fE(n,r.level,d.x,d.y):n.version),_={id:n.id,version:g};e.kind.load(Yt(_,h,r.level,d.x,d.y,r.frame),f.signal).then(n=>{r.wanted[i]===a&&!f.signal.aborted&&(VE.set(l*t.tileSize,(3-u)*t.tileSize,r.layer),o.copyTextureToTexture(n.texture,t.texture,null,VE),PE(t,r.layer,i,!0),e.failures=0,s()),n.release()}).catch(()=>{f.signal.aborted&&!p||(e.failed.add(a),++e.failures>=EE&&(e.dead=!0))}).finally(()=>{clearTimeout(m),e.inflight--,r.pending.get(i)?.key===a&&r.pending.delete(i)})}}function WE(e){for(let t of e.uniforms.window.value)t.w=0}function GE(e){WE(e);let t=e.store;if(t){for(let e of t.windows)for(let{abort:t}of e.pending.values())t.abort();t.texture.dispose(),t.mask.dispose(),e.store=void 0,e.uniforms.map.value=null,e.uniforms.mask.value=null}}function KE(e,t){WE(e),t-e.lastUsed>OE*1e3&&GE(e)}var qE=new Y,JE=new J,YE=new J;function XE(e,t){return JE.copy(t.position).applyMatrix4(qE.copy(e.matrixWorld).invert()).normalize()}function ZE(e,t,n){if(oE(n.y,e?.chart)!==0)return t.max_level;let r=aE(0,n.x,n.y,n.z);return mE(t.max_level,t.patches,r.x,r.y)}function QE(e,t){let n=e.max_level;if(e.patches)for(let t of e.patches)n=Math.max(n,t.max_level);let r=n-3+1;return Math.min(t,6,r+1)}function $E(e,t,n,r,i,a,o,s,c){e.lastUsed=performance.now();let l=e.store;l&&(l.texture.image.depth!==n+1||l.kind!==e.kind)&&GE(e);let u=e.store??=NE(e.kind,t.tile_size,n+1,s);e.uniforms.map.value=u.texture,e.uniforms.mask.value=u.mask,e.uniforms.filter.value.set(u.texture.anisotropy,t.tile_size);let d=i.y>=0?1:2;e.chart=oE(i.y,e.chart);let f=sE(r,n,e.chart,i.y,t.max_level,e.spread);YE.set(Math.fround(i.x*a),Math.fround(i.y*a),Math.fround(i.z*a)),e.uniforms.anchor.value.copy(YE);let p=YE.length(),m=aE(0,YE.x/p,YE.y/p,YE.z/p),h=e=>u.windows.find(t=>t.chart===e.chart&&t.level===e.level);u.windows=u.windows.filter(n=>{if(n.rank=f.findIndex(e=>e.chart===n.chart&&e.level===n.level),n.rank>=0)return!0;n.rank=f.length;let r=f.find(e=>e.level===n.level),i=r&&h(r),a=n.chart===0||n.chart===d;return r&&a&&!(i&&BE(e,u,t,i))?!0:(LE(u,n),!1)});for(let n=f.length-1;n>=0;n--){let r=f[n],a=h(r);if(!a){let e=u.free.pop();if(e===void 0)continue;a={layer:e,...r,rank:n,wanted:Array(AE),pending:new Map},u.windows.push(a)}let l=aE(r.chart,i.x,i.y,i.z);IE(u,a,lE(r.chart,r.level,l.x,l.y,a.placement),o),UE(e,u,t,a,l.x,l.y,s,c)}u.windows.sort((e,t)=>t.level-e.level||e.rank-t.rank);for(let t=0;t<7;t++){let n=u.windows[t],r=e.uniforms.window.value[t];if(!n?.placement){r.w=0;continue}if(e.uniforms.grid.value[t].set(nE(n.chart,n.level),rE(n.chart,n.level),n.placement.tx0,n.placement.ty0),n.chart===0){let r=hE(n.placement,m.x,m.y);e.uniforms.home.value[t].set(r.x,r.y)}r.set(n.chart,n.layer,n.level,1);let i=0;for(let e=0;e<AE;e++)FE(u,n.layer,e)&&(i|=1<<e);e.uniforms.loaded.value[t]=i}}var eD=8,tD=1.5,nD=3,rD=1,iD=.006,aD=`
5072
+ `;function HE(e,t=!1){return{kind:e,spread:t,uniforms:{map:{value:null},mask:{value:null},grid:{value:Array.from({length:7},()=>new ga)},window:{value:Array.from({length:7},()=>new ga)},home:{value:Array.from({length:7},()=>new q)},anchor:{value:new J(1,0,0)},loaded:{value:new Int32Array(7)},filter:{value:new q(1,1)}},inflight:0,failures:0,failed:new Set,dead:!1,lastUsed:0}}function UE(e,t,n,r){let i=t*4,a=new ya(null,i,i,n);a.source.dataReady=!1,a.format=e.format,a.type=e.type,a.colorSpace=e.colorSpace,a.wrapS=a.wrapT=Fn,a.magFilter=Vn,a.minFilter=Un,a.generateMipmaps=!1,a.anisotropy=Math.min(16,r.capabilities.getMaxAnisotropy()),a.needsUpdate=!0;let o=new ya(new Uint8Array(BE*n),4,4,n);return o.format=cr,o.type=Wn,o.minFilter=o.magFilter=Vn,o.wrapS=o.wrapT=Fn,o.unpackAlignment=1,o.needsUpdate=!0,{kind:e,texture:a,mask:o,windows:[],free:Array.from({length:n},(e,t)=>t),tileSize:t}}function WE(e,t,n,r){e.mask.image.data[t*BE+n]=r?255:0,e.mask.needsUpdate=!0}function GE(e,t,n){return e.mask.image.data[t*BE+n]!==0}function KE(e,t,n,r){if(!(t.placement===n&&t.frame===r)){t.placement=n,t.frame=r;for(let i=0;i<BE;i++){let{x:a,y:o}=EE(n,i%4,Math.floor(i/4)),s=`${r??0}/${t.chart}/${t.level}/${a}/${o}`;if(t.wanted[i]===s)continue;t.wanted[i]=s,WE(e,t.layer,i,!1);let c=t.pending.get(i);c&&(c.abort.abort(),t.pending.delete(i))}}}function qE(e,t){for(let{abort:e}of t.pending.values())e.abort();t.pending.clear();for(let n=0;n<BE;n++)WE(e,t.layer,n,!1);e.free.push(t.layer)}function JE(e,t,n){if(!(t.chart!==0||t.level<=e.max_level))return xE(e.patches,t.level,n.x,n.y)}function YE(e,t,n){return t.level<=e.max_level?!0:t.placement?JE(e,t,EE(t.placement,n%4,Math.floor(n/4)))!==void 0:!1}function XE(e,t,n,r){for(let i=0;i<BE;i++){let a=r.wanted[i];if(!a||!(GE(t,r.layer,i)||e.failed.has(a))&&YE(n,r,i))return!1}return!0}var ZE=new J,QE=[];function $E(e,t,n,r,i,a,o,s){let c=r.placement;if(!c)return;let l=fE(r.chart,r.level),u=i*l,d=a*pE(r.chart,r.level);QE.length=0;for(let i=0;i<BE;i++){let a=r.wanted[i];if(!a||r.pending.has(i)||e.failed.has(a)||GE(t,r.layer,i)||!YE(n,r,i))continue;let o=EE(c,i%4,Math.floor(i/4)),s=o.x+.5-u;r.chart===0&&(s-=l*Math.round(s/l)),QE.push({slot:i,far:Math.hypot(s,o.y+.5-d)})}QE.sort((e,t)=>e.far-t.far);for(let{slot:i}of QE){if(e.inflight>=FE)return;let a=r.wanted[i],l=i%4,u=Math.floor(i/4),d=EE(c,l,u),f=new AbortController,p=!1,m=setTimeout(()=>{p=!0,f.abort()},LE*1e3);r.pending.set(i,{key:a,abort:f}),e.inflight++;let h=aE[r.chart],g=JE(n,r,d)?.version??(r.chart===0?SE(n,r.level,d.x,d.y):n.version),_={id:n.id,version:g};e.kind.load(Yt(_,h,r.level,d.x,d.y,r.frame),f.signal).then(n=>{r.wanted[i]===a&&!f.signal.aborted&&(ZE.set(l*t.tileSize,(3-u)*t.tileSize,r.layer),o.copyTextureToTexture(n.texture,t.texture,null,ZE),WE(t,r.layer,i,!0),e.failures=0,s()),n.release()}).catch(()=>{f.signal.aborted&&!p||(e.failed.add(a),++e.failures>=IE&&(e.dead=!0))}).finally(()=>{clearTimeout(m),e.inflight--,r.pending.get(i)?.key===a&&r.pending.delete(i)})}}function eD(e){for(let t of e.uniforms.window.value)t.w=0}function tD(e){eD(e);let t=e.store;if(t){for(let e of t.windows)for(let{abort:t}of e.pending.values())t.abort();t.texture.dispose(),t.mask.dispose(),e.store=void 0,e.uniforms.map.value=null,e.uniforms.mask.value=null}}function nD(e,t){let n=e.store;return!n||e.dead||e.uniforms.window.value[0].w===0?!0:n.windows.every(r=>XE(e,n,t,r))}function rD(e,t){eD(e),t-e.lastUsed>RE*1e3&&tD(e)}var iD=new Y,aD=new J,oD=new J;function sD(e,t){return aD.copy(t.position).applyMatrix4(iD.copy(e.matrixWorld).invert()).normalize()}function cD(e,t,n){if(gE(n.y,e?.chart)!==0)return t.max_level;let r=hE(0,n.x,n.y,n.z);return wE(t.max_level,t.patches,r.x,r.y)}function lD(e,t){let n=e.max_level;if(e.patches)for(let t of e.patches)n=Math.max(n,t.max_level);let r=n-3+1;return Math.min(t,6,r+1)}function uD(e,t,n,r,i,a,o,s,c){e.lastUsed=performance.now();let l=e.store;l&&(l.texture.image.depth!==n+1||l.kind!==e.kind)&&tD(e);let u=e.store??=UE(e.kind,t.tile_size,n+1,s);e.uniforms.map.value=u.texture,e.uniforms.mask.value=u.mask,e.uniforms.filter.value.set(u.texture.anisotropy,t.tile_size);let d=i.y>=0?1:2;e.chart=gE(i.y,e.chart);let f=_E(r,n,e.chart,i.y,t.max_level,e.spread);oD.set(Math.fround(i.x*a),Math.fround(i.y*a),Math.fround(i.z*a)),e.uniforms.anchor.value.copy(oD);let p=oD.length(),m=hE(0,oD.x/p,oD.y/p,oD.z/p),h=e=>u.windows.find(t=>t.chart===e.chart&&t.level===e.level);u.windows=u.windows.filter(n=>{if(n.rank=f.findIndex(e=>e.chart===n.chart&&e.level===n.level),n.rank>=0)return!0;n.rank=f.length;let r=f.find(e=>e.level===n.level),i=r&&h(r),a=n.chart===0||n.chart===d;return r&&a&&!(i&&XE(e,u,t,i))?!0:(qE(u,n),!1)});for(let n=f.length-1;n>=0;n--){let r=f[n],a=h(r);if(!a){let e=u.free.pop();if(e===void 0)continue;a={layer:e,...r,rank:n,wanted:Array(BE),pending:new Map},u.windows.push(a)}let l=hE(r.chart,i.x,i.y,i.z);KE(u,a,yE(r.chart,r.level,l.x,l.y,a.placement),o),$E(e,u,t,a,l.x,l.y,s,c)}u.windows.sort((e,t)=>t.level-e.level||e.rank-t.rank);for(let t=0;t<7;t++){let n=u.windows[t],r=e.uniforms.window.value[t];if(!n?.placement){r.w=0;continue}if(e.uniforms.grid.value[t].set(fE(n.chart,n.level),pE(n.chart,n.level),n.placement.tx0,n.placement.ty0),n.chart===0){let r=TE(n.placement,m.x,m.y);e.uniforms.home.value[t].set(r.x,r.y)}r.set(n.chart,n.layer,n.level,1);let i=0;for(let e=0;e<BE;e++)GE(u,n.layer,e)&&(i|=1<<e);e.uniforms.loaded.value[t]=i}}var dD=8,fD=1.5,pD=3,mD=1,hD=.006,gD=`
5073
5073
  uniform sampler2DArray uReliefMap;
5074
5074
  uniform sampler2DArray uReliefMask;
5075
5075
  uniform vec4 uReliefGrid[ 7 ];
@@ -5081,7 +5081,7 @@ uniform vec2 uReliefFilter;
5081
5081
  uniform vec4 uReliefRead;
5082
5082
  uniform float uReliefScale;
5083
5083
  varying vec3 vReliefOff;
5084
- ${jE}
5084
+ ${VE}
5085
5085
  // The height of a pixel of the windows, as a part of the pyramid's range.
5086
5086
  // They hold it as two bytes or as one number, and uReliefRead weighs either.
5087
5087
  float reliefValue( vec4 texel ) {
@@ -5098,7 +5098,7 @@ void reliefRates( vec3 dir, float side, out mat2x3 map, out mat2x3 cap ) {
5098
5098
  ( dir * dir.y - vec3( 0.0, 1.0, 0.0 ) ) / ( PI * sqrt( flat2 ) )
5099
5099
  );
5100
5100
  float fold = 1.0 + side * dir.y;
5101
- float capScale = 0.5 / ( ${QT.toFixed(8)} * fold );
5101
+ float capScale = 0.5 / ( ${cE.toFixed(8)} * fold );
5102
5102
  vec2 plane = vec2( dir.x, side * dir.z ) * side / fold;
5103
5103
  vec3 capX = vec3( 1.0, - plane.x, 0.0 ) * capScale;
5104
5104
  vec3 capY = vec3( 0.0, - plane.y, side ) * capScale;
@@ -5152,7 +5152,7 @@ vec3 reliefTileSlope( vec3 dir, mat3x2 map, mat3x2 cap, float side, out float co
5152
5152
  }
5153
5153
  return slope * uReliefScale;
5154
5154
  }
5155
- `;function oD(e){return`
5155
+ `;function _D(e){return`
5156
5156
  // One window as a shadow ray reads it. The ray is a line on the window's
5157
5157
  // chart, so where it is inside the window is worked out once, not at each
5158
5158
  // sample. 'sight' holds what a sample reads, as a mat2x4 and not a struct
@@ -5192,7 +5192,7 @@ void reliefSight( int i, mat3x2 map, mat3x2 cap, float side, vec2 mapStep, vec2
5192
5192
  slot.x / rows, - slot.y / rows, rate.x / rows, - rate.y / rows,
5193
5193
  max( near.x, near.y ), leaves, window.y, float( uReliefLoaded[ i ] )
5194
5194
  );
5195
- widest = ${tD.toFixed(2)} * PI / ( uReliefFilter.y * exp2( window.z ) );
5195
+ widest = ${fD.toFixed(2)} * PI / ( uReliefFilter.y * exp2( window.z ) );
5196
5196
  // Near a patch the next window can be some levels coarser. The ray then
5197
5197
  // stays here until its step is half of what that window holds: too wide
5198
5198
  // for these pixels, but they are the same ground as the fragment's. The
@@ -5202,7 +5202,7 @@ void reliefSight( int i, mat3x2 map, mat3x2 cap, float side, vec2 mapStep, vec2
5202
5202
  beyond = 0.0;
5203
5203
  if ( i + 1 < 7 ) {
5204
5204
  float next = PI / ( uReliefFilter.y * exp2( uReliefWindow[ i + 1 ].z ) );
5205
- hands = max( hands, 0.5 * ${tD.toFixed(2)} * next );
5205
+ hands = max( hands, 0.5 * ${fD.toFixed(2)} * next );
5206
5206
  // Within half a pixel of a window, its height is that of the fragment's
5207
5207
  // own pixel, and the fragment stands above or below that by all the
5208
5208
  // relief that the pixel averages away.
@@ -5270,13 +5270,13 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5270
5270
  // curve under it. Past where it clears the pyramid's range, nothing
5271
5271
  // can stand in it.
5272
5272
  float clear = sqrt( tanElev * tanElev + 2.0 * uReliefScale * ( 1.0 - own ) ) - tanElev;
5273
- float reach = min( clear, ${eD.toFixed(1)} * uReliefScale );
5273
+ float reach = min( clear, ${dD.toFixed(1)} * uReliefScale );
5274
5274
  if ( reach < 1e-7 ) return 1.0;
5275
5275
 
5276
5276
  // The ratio that takes steps from one pixel to the reach: 'rate' is its
5277
5277
  // logarithm times the count, and solves rate / ( exp( rate ) - 1 ) = part.
5278
5278
  float count = ${e.toFixed(1)};
5279
- float pixel = widest / ${tD.toFixed(2)};
5279
+ float pixel = widest / ${fD.toFixed(2)};
5280
5280
  float part = count * pixel / reach;
5281
5281
  float rate = 0.0;
5282
5282
  if ( part < 1.0 ) {
@@ -5290,7 +5290,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5290
5290
 
5291
5291
  // How far the ground stands into the ray is counted in discs of the Sun.
5292
5292
  // The disc is an angle, and the ray's rise is a slope.
5293
- float perDisc = 1.0 / ( max( sunSize, ${iD.toFixed(4)} ) * ( 1.0 + tanElev * tanElev ) );
5293
+ float perDisc = 1.0 / ( max( sunSize, ${hD.toFixed(4)} ) * ( 1.0 + tanElev * tanElev ) );
5294
5294
  float t = 0.0;
5295
5295
  float hidden = - 1e9;
5296
5296
  // The sample that hides the most, the step around it and its window.
@@ -5328,11 +5328,11 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5328
5328
  // those are far apart. Look for it around the best one, each time at half
5329
5329
  // the distance and in a finer window. Not where the best one is so clear
5330
5330
  // of the ray that no crest beside it can reach the Sun's disc.
5331
- float crest = ${(rD*.5).toFixed(2)} * around / max( worst, 1e-9 ) * perDisc;
5331
+ float crest = ${(mD*.5).toFixed(2)} * around / max( worst, 1e-9 ) * perDisc;
5332
5332
  if ( hidden < 1.0 && hidden + crest > - 1.0 ) {
5333
5333
  w = worstWindow;
5334
5334
  reliefSight( w, map, cap, side, mapStep, capStep, sight, widest, hands, beyond );
5335
- for ( int k = 0; k < ${nD}; k ++ ) {
5335
+ for ( int k = 0; k < ${pD}; k ++ ) {
5336
5336
  around *= 0.5;
5337
5337
  if ( w > start && around < widest ) {
5338
5338
  w --;
@@ -5343,7 +5343,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5343
5343
  float at = centre + ( e == 0 ? - around : around );
5344
5344
  // Nearer than a pixel, the window holds no crest: only the slope
5345
5345
  // of the fragment's own ground, which is the normal's to light.
5346
- if ( at < widest * ${(1/tD).toFixed(4)} ) continue;
5346
+ if ( at < widest * ${(1/fD).toFixed(4)} ) continue;
5347
5347
  float value = reliefSightValue( sight, at );
5348
5348
  if ( value < 0.0 ) continue;
5349
5349
  float stands = ( ( value - own ) * uReliefScale / at - tanElev - 0.5 * at ) * perDisc;
@@ -5356,7 +5356,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5356
5356
  }
5357
5357
  return 1.0 - smoothstep( - 1.0, 1.0, hidden );
5358
5358
  }
5359
- `}function sD(e){return e>0?aD+oD(e):aD}function cD(e){let t=e?cr:ur,n=e?Xn:Wn;return{format:t,type:n,colorSpace:``,async load(r,i){let a=await qT(r,e,i),o=new ic(a.heights,a.size,a.size,t,n);return{texture:o,release:()=>o.dispose()}}}}var lD=cD(!1),uD=new ga(65280/65535,255/65535,0,0),dD=cD(!0),fD=new ga(1/65535,0,0,0);function pD(e){return!!e&&e.scale_km!==void 0&&e.max_level>=3&&qt()!==``&&bE()>0&&o(e.distribution)}function mD(e,t,n){if(!pD(t))return;let r=e.userData.reliefTiles;if(r)return r;let i=ME(lD,!0),a={tiles:t,chain:i,shadowSteps:xE(),uniforms:{uReliefMap:i.uniforms.map,uReliefMask:i.uniforms.mask,uReliefGrid:i.uniforms.grid,uReliefWindow:i.uniforms.window,uReliefHome:i.uniforms.home,uReliefAnchor:i.uniforms.anchor,uReliefLoaded:i.uniforms.loaded,uReliefFilter:i.uniforms.filter,uReliefRead:{value:uD},uReliefScale:{value:(t.scale_km??0)/n}}};return e.userData.reliefTiles=a,a}function hD(e){return!!e.reliefTiles&&!e.reliefTiles.chain.dead}function gD(e){e.reliefTiles&&GE(e.reliefTiles.chain)}function _D(e,t,n,r,i){let a=e.reliefTiles;if(!a)return;let o=e.mesh;o&&a.shadowSteps!==xE()&&(a.shadowSteps=xE(),o.material.needsUpdate=!0);let{chain:s,tiles:c}=a,l=o&&e.selfShadow&&!s.dead?XE(o,t):void 0,u=n.extensions.has(`OES_texture_float_linear`),d=l?iE(e.radiusScene,e.cachedDist,r,u?ZE(s,c,l):c.max_level):-1;if(!l||d<3){KE(s,performance.now()),s.store||(s.kind=lD);return}d>c.max_level&&(s.kind=dD);let f=c.max_level;if(u)for(let e of c.patches??[])f=Math.max(f,e.max_level);$E(s,c,Math.min(bE(),f-3+1),d,l,e.radiusScene,void 0,n,i),a.uniforms.uReliefRead.value=s.kind===dD?fD:uD}var vD=32,yD=1,bD=2,xD=1.5,SD=4,CD=.04,wD=.02,TD=-.08,ED=.18,DD=`
5359
+ `}function vD(e){return e>0?gD+_D(e):gD}function yD(e){let t=e?cr:ur,n=e?Xn:Wn;return{format:t,type:n,colorSpace:``,async load(r,i){let a=await rE(r,e,i),o=new ic(a.heights,a.size,a.size,t,n);return{texture:o,release:()=>o.dispose()}}}}var bD=yD(!1),xD=new ga(65280/65535,255/65535,0,0),SD=yD(!0),CD=new ga(1/65535,0,0,0);function wD(e){return!!e&&e.scale_km!==void 0&&e.max_level>=3&&qt()!==``&&AE()>0&&o(e.distribution)}function TD(e,t,n){if(!wD(t))return;let r=e.userData.reliefTiles;if(r)return r;let i=HE(bD,!0),a={tiles:t,chain:i,shadowSteps:jE(),uniforms:{uReliefMap:i.uniforms.map,uReliefMask:i.uniforms.mask,uReliefGrid:i.uniforms.grid,uReliefWindow:i.uniforms.window,uReliefHome:i.uniforms.home,uReliefAnchor:i.uniforms.anchor,uReliefLoaded:i.uniforms.loaded,uReliefFilter:i.uniforms.filter,uReliefRead:{value:xD},uReliefScale:{value:(t.scale_km??0)/n}}};return e.userData.reliefTiles=a,a}function ED(e){return!!e.reliefTiles&&!e.reliefTiles.chain.dead}function DD(e){e.reliefTiles&&tD(e.reliefTiles.chain)}function OD(e,t,n,r,i){let a=e.reliefTiles;if(!a)return;let o=e.mesh;o&&a.shadowSteps!==jE()&&(a.shadowSteps=jE(),o.material.needsUpdate=!0);let{chain:s,tiles:c}=a,l=o&&e.selfShadow&&!s.dead?sD(o,t):void 0,u=n.extensions.has(`OES_texture_float_linear`),d=l?mE(e.radiusScene,e.cachedDist,r,u?cD(s,c,l):c.max_level):-1;if(!l||d<3){rD(s,performance.now()),s.store||(s.kind=bD);return}d>c.max_level&&(s.kind=SD);let f=c.max_level;if(u)for(let e of c.patches??[])f=Math.max(f,e.max_level);uD(s,c,Math.min(AE(),f-3+1),d,l,e.radiusScene,void 0,n,i),a.uniforms.uReliefRead.value=s.kind===SD?CD:xD}var kD=32,AD=1,jD=2,MD=1.5,ND=4,PD=.04,FD=.02,ID=-.08,LD=.18,RD=`
5360
5360
  if (byTiles > 0.005 && dot(normal, mat3(viewMatrix) * L) > 0.0) {
5361
5361
  vec3 sunward = normalize(L * mat3(modelMatrix));
5362
5362
  float up = dot(sunward, selfDir);
@@ -5364,7 +5364,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5364
5364
  float run = length(along);
5365
5365
  if (run > 1e-4) tileLight = reliefTileShadow(selfDir, selfMap, selfCap, selfSide, along / run, up / run, uSelfSunSize, selfFirst);
5366
5366
  if (tileLight < 0.0) byTiles = 0.0;
5367
- }`;function OD(e,t,n,r,i){let a=t.image,o=new q(1/(a?.width??4096),1/(a?.height??2048)),s=e.userData.selfShadow;if(s)return s.uSelfHeightMap.value=t,s.uSelfScale.value=n,s.uSelfTexel.value.copy(o),s;let c={uSelfHeightMap:{value:t},uSelfScale:{value:n},uSelfTexel:{value:o}};e.userData.selfShadow=c;let l=r??Nw().uSunDir;return US(e,i?()=>`selfShadowTiles${xE()}`:`selfShadow`,e=>{let t=i?xE():0;Object.assign(e.uniforms,c,{uSelfSunDir:l},i?.uniforms),i&&(e.uniforms.uSelfSunSize=Nw().uSunAngularRadius),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5367
+ }`;function zD(e,t,n,r,i){let a=t.image,o=new q(1/(a?.width??4096),1/(a?.height??2048)),s=e.userData.selfShadow;if(s)return s.uSelfHeightMap.value=t,s.uSelfScale.value=n,s.uSelfTexel.value.copy(o),s;let c={uSelfHeightMap:{value:t},uSelfScale:{value:n},uSelfTexel:{value:o}};e.userData.selfShadow=c;let l=r??Uw().uSunDir;return $S(e,i?()=>`selfShadowTiles${jE()}`:`selfShadow`,e=>{let t=i?jE():0;Object.assign(e.uniforms,c,{uSelfSunDir:l},i?.uniforms),i&&(e.uniforms.uSelfSunSize=Uw().uSunAngularRadius),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5368
5368
  varying vec3 vSelfWorldNormal;
5369
5369
  varying vec2 vSelfUv;
5370
5370
  varying vec3 vSelfDir;
@@ -5388,7 +5388,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5388
5388
  vSelfNorthW = normalize(mat3(modelMatrix) * cross(nObj, eastObj));
5389
5389
  vSelfRadiusW = length(mat3(modelMatrix) * position);
5390
5390
  vSelfCosLat = cl;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5391
- #define SELF_STEPS ${vD}
5391
+ #define SELF_STEPS ${kD}
5392
5392
  uniform sampler2D uSelfHeightMap;
5393
5393
  uniform float uSelfScale;
5394
5394
  uniform vec2 uSelfTexel;
@@ -5403,7 +5403,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5403
5403
  varying vec3 vSelfNorthW;
5404
5404
  varying float vSelfRadiusW;
5405
5405
  varying float vSelfCosLat;
5406
- ${i?sD(t):``}
5406
+ ${i?vD(t):``}
5407
5407
 
5408
5408
  float selfHeight(vec2 uv) {
5409
5409
  return texture2D(uSelfHeightMap, uv).r * uSelfScale;
@@ -5420,7 +5420,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5420
5420
  // Wider-than-one-texel stencil averages out 8-bit terracing, floored
5421
5421
  // at the low tier's texel so a higher-res map keeps the same
5422
5422
  // physical smoothing width instead of flattening the relief.
5423
- vec2 d = max(uSelfTexel, vec2(1.0 / 2048.0, 1.0 / 1024.0)) * ${bD.toFixed(3)};
5423
+ vec2 d = max(uSelfTexel, vec2(1.0 / 2048.0, 1.0 / 1024.0)) * ${jD.toFixed(3)};
5424
5424
  float hu = selfHeight(vSelfUv + vec2(d.x, 0.0))
5425
5425
  - selfHeight(vSelfUv - vec2(d.x, 0.0));
5426
5426
  float hv = selfHeight(vSelfUv + vec2(0.0, d.y))
@@ -5430,9 +5430,9 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5430
5430
  float sv = hv / (2.0 * d.y * 3.14159265 * vSelfRadiusW);
5431
5431
  // Fade at the poles, where the columns of the map close in and
5432
5432
  // blow the east-west slope up into a starburst.
5433
- float gain = ${yD.toFixed(3)} * smoothstep(0.0, 0.12, cosLat);
5434
- su = clamp(su * gain, -${xD.toFixed(3)}, ${xD.toFixed(3)});
5435
- sv = clamp(sv * gain, -${xD.toFixed(3)}, ${xD.toFixed(3)});
5433
+ float gain = ${AD.toFixed(3)} * smoothstep(0.0, 0.12, cosLat);
5434
+ su = clamp(su * gain, -${MD.toFixed(3)}, ${MD.toFixed(3)});
5435
+ sv = clamp(sv * gain, -${MD.toFixed(3)}, ${MD.toFixed(3)});
5436
5436
  return east * su + north * sv;
5437
5437
  }
5438
5438
 
@@ -5456,7 +5456,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5456
5456
  float lv = dot(L, Tv / lenTv);
5457
5457
  float lh = sqrt(lu * lu + lv * lv);
5458
5458
  if (lh <= 1e-4) return 1.0;
5459
- float ds = ${SD.toFixed(3)} * uSelfScale / float(SELF_STEPS);
5459
+ float ds = ${ND.toFixed(3)} * uSelfScale / float(SELF_STEPS);
5460
5460
  // World step → uv step via the per-axis metric (|Tu|, |Tv|).
5461
5461
  vec2 stepUv = ds * vec2((lu / lh) / lenTu, (lv / lh) / lenTv);
5462
5462
  float h0 = selfHeight(vSelfUv);
@@ -5469,8 +5469,8 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5469
5469
  }
5470
5470
  // Fade the march out at grazing angles: a near-horizontal ray
5471
5471
  // occludes every away-facing slope, banding the terminator.
5472
- float marchFade = smoothstep(0.0, ${ED.toFixed(3)}, gN);
5473
- return 1.0 - marchFade * clamp(block / (${CD.toFixed(3)} * uSelfScale), 0.0, 1.0);
5472
+ float marchFade = smoothstep(0.0, ${LD.toFixed(3)}, gN);
5473
+ return 1.0 - marchFade * clamp(block / (${PD.toFixed(3)} * uSelfScale), 0.0, 1.0);
5474
5474
  }`).replace(`#include <normal_fragment_maps>`,`#include <normal_fragment_maps>
5475
5475
  vec3 selfDir = normalize(vSelfDir);
5476
5476
  // The part of the fragment that the tiles answer for.
@@ -5485,7 +5485,7 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5485
5485
  ${i?`slope = reliefTileSlope(selfDir, selfMap, selfCap, selfSide, selfCovered, selfFirst);`:``}
5486
5486
  if (selfCovered < 0.995 && uSelfScale > 0.0) slope += (1.0 - selfCovered) * selfMapSlope(selfDir);
5487
5487
  float steep = length(slope);
5488
- if (steep > ${xD.toFixed(3)}) slope *= ${xD.toFixed(3)} / steep;
5488
+ if (steep > ${MD.toFixed(3)}) slope *= ${MD.toFixed(3)} / steep;
5489
5489
  normal = normalize(normalMatrix * (selfDir - slope));
5490
5490
  }`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
5491
5491
  {
@@ -5495,21 +5495,21 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5495
5495
  // Gate on the GEOMETRIC normal: the relief normal can tilt sunward
5496
5496
  // past the terminator and light the night side. Fading direct light
5497
5497
  // by geometric N·L keeps the night dark regardless.
5498
- float shadow = smoothstep(${TD.toFixed(3)}, ${wD.toFixed(3)}, gN);
5498
+ float shadow = smoothstep(${ID.toFixed(3)}, ${FD.toFixed(3)}, gN);
5499
5499
  // Local crater self-shadow, lit hemisphere only — the macro gate owns
5500
5500
  // the night side; the short march can't see that curvature.
5501
5501
  if (shadow > 0.0 && gN > 0.0) {
5502
5502
  // The part of the fragment whose shadow the tiles cast.
5503
5503
  float byTiles = ${t>0?`selfCovered`:`0.0`};
5504
5504
  float tileLight = 1.0;
5505
- ${t>0?DD:``}
5505
+ ${t>0?RD:``}
5506
5506
  float mapLight = 1.0;
5507
5507
  if (byTiles < 0.995 && uSelfScale > 0.0) mapLight = selfMapLight(L, gN);
5508
5508
  shadow *= mix(mapLight, tileLight, byTiles);
5509
5509
  }
5510
5510
  reflectedLight.directDiffuse *= shadow;
5511
5511
  reflectedLight.directSpecular *= shadow;
5512
- }`)}),c}function kD(e){e&&(e.uSelfHeightMap.value=null,e.uSelfScale.value=0)}async function AD(e,t,n,r,i,a=Q(1)){let o=MD(t,n),s;try{s=await new Promise((e,t)=>{r.load(o,e,void 0,t)})}catch(e){return console.warn(`Failed to load displacement map ${o}:`,e),null}return s.colorSpace=``,e.displacementMap=s,jD(e,t,i,a),e.needsUpdate=!0,s}function jD(e,t,n,r=Q(1)){e.displacementScale=t.scale_km*r,e.displacementBias=t.bias_km*r-(t.absolute_radius?n:0)}function MD(e,t){return $t(`/v1/textures/${e.id}/${t}.webp`,`textures`)}async function ND(e){try{let t=await fetch(e);if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return await createImageBitmap(await t.blob())}catch(t){return console.warn(`Failed to decode displacement map ${e}:`,t),null}}var PD=4e6;async function FD(e,t,n){let r=e.width,i=Math.max(1,Math.floor(PD/r)),a=document.createElement(`canvas`);a.width=r,a.height=Math.min(i,n-t+1);let o=a.getContext(`2d`,{willReadFrequently:!0});if(!o)return null;let s=new Uint8Array(r*(n-t+1));for(let a=t;a<=n;a+=i){let c=Math.min(i,n-a+1);o.drawImage(e,0,a,r,c,0,0,r,c);let l=o.getImageData(0,0,r,c).data,u=(a-t)*r;for(let e=0;e<r*c;e++)s[u+e]=l[e*4];!document.hidden&&a+i<=n&&await new Promise(e=>setTimeout(e))}return s}var ID=`pyramid`,LD=new WeakSet;function RD(e,t){let n=e.displacementMeta?.tiles;return!!n&&n.scale_km!==void 0&&qt()!==``&&o(n.distribution)&&t.extensions.has(`OES_texture_float_linear`)&&!LD.has(e)}async function zD(e,t){let n=e.displacementMeta;if(!(!n||!e.mesh||e.displacementLoading||e.displacementTier===t)){e.displacementLoading=!0;try{let r=t===`pyramid`?await VD(e,n):await BD(n,t);if(!r)return;if(!e.mesh||!e.displacementMap){r.dispose();return}let i=e.mesh.material,a=i.displacementMap;i.displacementMap=r,e.displacementMap=r,e.displacementTier=t,e.selfShadow&&OD(i,r,Q(n.scale_km)),a&&a!==r&&a.dispose()}finally{e.displacementLoading=!1}}}async function BD(e,t){let n=await ND(MD(e,t));if(!n)return null;let r=n.width,i=n.height,a=await FD(n,0,i-1);if(n.close(),!a)return null;let o=new Uint8Array(r);for(let e=0;e<i>>1;e++){let t=a.subarray(e*r,(e+1)*r),n=a.subarray((i-1-e)*r,(i-e)*r);o.set(t),t.set(n),n.set(o)}let s=new ic(a,r,i,cr,Wn);return s.colorSpace=``,s.magFilter=Vn,s.minFilter=Vn,s.generateMipmaps=!1,s.unpackAlignment=1,s.needsUpdate=!0,s}async function VD(e,t){if(!t.tiles)return null;try{return await HD(t,t.tiles)}catch(n){return console.warn(`Failed to load the height pyramid of ${t.id}:`,n),LD.add(e),null}}async function HD(e,t){let n=new AbortController().signal,r=await Promise.all([0,1].map(e=>qT(Yt(t,``,0,e,0),!0,n))),i=r[0].size,a=2*i,o=new Float32Array(a*i),s=(t.scale_km??0)/65535/e.scale_km,c=((t.bias_km??0)-e.bias_km)/e.scale_km;r.forEach(({heights:e},t)=>{for(let n=0;n<i;n++){let r=n*i,l=n*a+t*i;for(let t=0;t<i;t++)o[l+t]=e[r+t]*s+c}});let l=new ic(o,a,i,cr,Xn);return l.colorSpace=``,l.magFilter=Vn,l.minFilter=Un,l.generateMipmaps=!1,l.mipmaps=UD(o,a,i),l.needsUpdate=!0,l}function UD(e,t,n){let r=[{data:e,width:t,height:n}];for(;t>1||n>1;){let i=Math.max(1,t>>1),a=Math.max(1,n>>1),o=t/i,s=n/a,c=new Float32Array(i*a);for(let n=0;n<a;n++)for(let r=0;r<i;r++){let a=0;for(let i=0;i<s;i++){let c=(n*s+i)*t+r*o;for(let t=0;t<o;t++)a+=e[c+t]}c[n*i+r]=a/(o*s)}r.push({data:c,width:i,height:a}),e=c,t=i,n=a}return r}function WD(e,t,n,r,i){let a=Math.floor(r),o=Math.floor(i),s=r-a,c=i-o,l=e=>(e%t+t)%t,u=e=>e<0?0:e>n-1?n-1:e,d=l(a),f=l(a+1),p=u(o)*t,m=u(o+1)*t,h=e[p+d]*(1-s)+e[p+f]*s,g=e[m+d]*(1-s)+e[m+f]*s,_=h*(1-c)+g*c;return e instanceof Float32Array?_:_/255}function GD(e){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.needsUpdate=!0)}function KD(e,t){let n=0,r=e.length-2;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n}function qD(e,t){let n=Math.cos(e);return[n*Math.cos(t),Math.sin(e),-n*Math.sin(t)]}function JD(e,t,n,r,i,a,o){let s=(r+n)/r,[c,l,u]=qD(e,t);return[s*i*c,s*o*l,s*a*u]}function YD(e,t,n){if(e.kind===`uniform`){let r=e.segs,i=(Math.PI/2-t)*r/Math.PI,a=Math.min(Math.max(Math.floor(i),0),r-1),o=Math.min(Math.max(i-a,0),1),s=(n-Math.PI)*r/(2*Math.PI),c=Math.floor(s),l=s-c;return{corners:[[a,c],[a,c+1],[a+1,c],[a+1,c+1]].map(([e,t])=>({latRad:Math.PI/2-Math.min(e,r)*Math.PI/r,lonRad:Math.PI+t*2*Math.PI/r})),tx:l,ty:o}}let{thetas:r,phis:i,riseKm:a}=e,o=Math.PI/2-t,s=(n-Math.PI)%(2*Math.PI);s<0&&(s+=2*Math.PI);let c=KD(r,o),l=KD(i,s),u=Math.min(Math.max((o-r[c])/(r[c+1]-r[c]),0),1),d=Math.min(Math.max((s-i[l])/(i[l+1]-i[l]),0),1);return{corners:[[c,l],[c,l+1],[c+1,l],[c+1,l+1]].map(([e,t])=>({latRad:Math.PI/2-r[e],lonRad:i[t]+Math.PI,riseKm:a?.[e*i.length+t]})),tx:d,ty:u}}function XD(e,t,n){let[r,i,a,o]=e,s=[0,0,0];for(let e=0;e<3;e++)s[e]=t>=n?r[e]+(i[e]-r[e])*t+(o[e]-i[e])*n:r[e]+(o[e]-a[e])*t+(a[e]-r[e])*n;return s}function ZD(e,t,n){let[r,i,a]=t>=n?[e[0],e[1],e[3]]:[e[0],e[2],e[3]],o=[i[0]-r[0],i[1]-r[1],i[2]-r[2]],s=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];return{p0:r,n:[o[1]*s[2]-o[2]*s[1],o[2]*s[0]-o[0]*s[2],o[0]*s[1]-o[1]*s[0]]}}function QD(e,t,n){let{p0:r,n:i}=ZD(e,t,n),a=Math.hypot(i[0],i[1],i[2]);if(a<1e-12){let e=Math.hypot(r[0],r[1],r[2]);return[r[0]/e,r[1]/e,r[2]/e]}let o=i[0]*r[0]+i[1]*r[1]+i[2]*r[2]<0?-1/a:1/a;return[i[0]*o,i[1]*o,i[2]*o]}var $D=new Map,eO=new Map,tO=0;function nO(){return tO}var rO=6;function iO(){let e=0;for(let t of $D.values())t!==`failed`&&e++;for(let[t,n]of $D){if(e<=rO)break;n!==`failed`&&($D.delete(t),e--)}}function aO(e,t){let n=eO.get(e);return n||(n=(async()=>{let n=await ND(MD(t,`low`)),r=n&&await FD(n,0,n.height-1);if(!n||!r)return n?.close(),$D.set(e,`failed`),null;let i={data:r,width:n.width,height:n.height,bottomUp:!1};return n.close(),$D.set(e,i),iO(),tO++,i})(),n.finally(()=>eO.delete(e)),eO.set(e,n),n)}function oO(e,t){let n=e.displacementMap?.image;if(!n)return null;let r=n.data;if((r instanceof Uint8Array||r instanceof Float32Array)&&n.width&&n.height)return{data:r,width:n.width,height:n.height,bottomUp:!0};let i=$D.get(t);if(i&&i!==`failed`)return $D.delete(t),$D.set(t,i),i;let a=e.displacementMeta;return!i&&a&&aO(t,a),null}function sO(e,t,n){let r=.5+n/(2*Math.PI),i=.5+t/Math.PI,a=(r-Math.floor(r))*e.width-.5,o=(e.bottomUp?i:1-i)*e.height-.5;return WD(e.data,e.width,e.height,a,o)}async function cO(e,t,n,r,i){let a=(e&&oO(e,t))??await aO(t,n);if(!a)return null;let o=n.bias_km-(n.absolute_radius?r:0),s=new Float64Array(i.length);for(let e=0;e<i.length;e++)s[e]=sO(a,i[e].latRad,i[e].lonRad)*n.scale_km+o;return s}var lO=new Map,uO=new Set;function dO(e,t){return lO.get(e)||(uO.has(e)||(uO.add(e),(async()=>{try{let n=(await nS(e,!1)).global;lO.set(e,n?.radii??{a:t,b:t,c:t})}catch(n){console.warn(`Failed to load radii for ${e}:`,n),lO.set(e,{a:t,b:t,c:t})}finally{uO.delete(e),tO++}})()),null)}function fO(e){let t=e?.terrainWindow;return t?{kind:`window`,thetas:t.thetas,phis:t.phis,riseKm:t.riseKm}:{kind:`uniform`,segs:e?.currentSegments??128}}function pO(e,t,n,r,i){let a=dO(t,n);if(!a)return null;let o=fO(e),s=null,c=0,l=0,u=e?.displacementMeta,d=o.kind===`window`&&!!o.riseKm;if(u&&e?.displacementMap&&!d){if(s=oO(e,t),!s)return null;c=u.scale_km,l=u.bias_km-(u.absolute_radius?n:0)}let{corners:f,tx:p,ty:m}=YD(o,r,i);return{pts:f.map(e=>{let t=e.riseKm??(s?sO(s,e.latRad,e.lonRad)*c+l:0);return JD(e.latRad,e.lonRad,t,n,a.a,a.b,a.c)}),tx:p,ty:m}}function mO(e,t,n,r,i){let a=pO(e,t,n,r,i);return a?{pointKm:XD(a.pts,a.tx,a.ty),normal:QD(a.pts,a.tx,a.ty)}:null}function hO(e,t,n,r){let i=dO(t,n);if(!i)return null;let a=pO(e,t,n,Math.atan2(r[1]/i.c,Math.hypot(r[0]/i.a,r[2]/i.b)),Math.atan2(-r[2]/i.b,r[0]/i.a));if(!a)return null;let{p0:o,n:s}=ZD(a.pts,a.tx,a.ty),c=r[0]*s[0]+r[1]*s[1]+r[2]*s[2];if(Math.abs(c)<1e-12)return null;let l=(o[0]*s[0]+o[1]*s[1]+o[2]*s[2])/c;return l>0?l:null}function gO(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function _O(e){switch(e){case G.STAR:return 0;case G.PLANET:return 1;case G.DWARF_PLANET:return 2;case G.MOON:return 3;default:return 4}}function vO(e){return e.body.position!==null&&!e.carried}var yO=new J,bO=22;function xO(){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 SO=new WeakMap;function CO(e){SO.delete(e)}function wO(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(SO.get(e)===t)return;SO.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 TO(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(SO.get(e)===t)return;SO.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 EO(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 DO(e,t,n,r,i,a=null){for(let o of i){if(o.id===r||o.id===a)continue;let i=e-o.cx0,s=o.cy0-t,c=-o.f,l=i*o.gxx+s*o.gxy+c*o.gxz,u=i*o.gyx+s*o.gyy+c*o.gyz,d=i*o.gzx+s*o.gzy+c*o.gzz,f=l*o.cpx+u*o.cpy+d*o.cpz;if(!(f<=0)&&!(f*f<=o.K*(l*l+u*u+d*d))&&i*o.ccx+s*o.ccy+c*o.ccz<=n*Math.hypot(i,s,c))return!0}return!1}function OO(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function kO(e,t,n,r,i,a){let o=e.label,s=e.body.position;if(!s)return!1;let[c,l,u]=s,d=o.position;yO.set(c-n[0]+d.x,l-n[1]+d.y,u-n[2]+d.z),yO.project(t),a.x=(yO.x*.5+.5)*r,a.y=(-yO.y*.5+.5)*i;let f=a.x-o.center.x*32;return a.left=f,a.right=f+40+(e.labelTextWidth||50),a.h=bO,xw(yO.z)}var AO=[],jO=0,MO=[],NO=0,PO=[],FO=0,IO={rects:MO,get count(){return NO}};function LO(){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 RO(){return{left:0,right:0,y:0,h:0}}var zO={x:0,left:0,right:0,y:0,h:0};function BO(e,t){for(let n=0;n<t;n++)OO(gO(PO,n,RO),e[n]);FO=t}function VO(){for(let e=0;e<FO;e++)OO(gO(MO,e,RO),PO[e]);return FO}function HO(e,t,n,r,i,a,o,s,c=[0,0,0]){jO=0,NO=VO();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(!kO(s,r,c,t,n,zO))continue;let d=e.data.id===i,f=o.has(e.data.id),p=gO(AO,jO++,LO);OO(p.rect,zO),p.rect.x=zO.x,p.bodyId=e.data.id,p.bo=s,p.body=e,p.label=l,p.labelHalo=u,p.isCapped=e.data.objectType===G.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}AO.length=jO,AO.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=_O(e.body.data.objectType),i=_O(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<jO;e++){let t=AO[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){wO(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&DO(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<NO;n++){let r=MO[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<bO){e=!0;break}}wO(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<NO;e++){let n=MO[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<bO){i=!0;break}}i?(wO(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(OO(gO(MO,NO++,RO),t.rect),TO(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<jO;e++){let t=AO[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function UO(e,t,n,r,i){NO=VO();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&kO(a,r,i,t,n,zO)&&OO(gO(MO,NO++,RO),zO)}function WO(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 GO(e){let t=new Map,n=new Map,r=e.clone();return KO(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 KO(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)KO(e.children[r],t.children[r],n)}var qO=class extends nd{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new ek(e)}),this.register(function(e){return new tk(e)}),this.register(function(e){return new uk(e)}),this.register(function(e){return new dk(e)}),this.register(function(e){return new fk(e)}),this.register(function(e){return new rk(e)}),this.register(function(e){return new ik(e)}),this.register(function(e){return new ak(e)}),this.register(function(e){return new ok(e)}),this.register(function(e){return new $O(e)}),this.register(function(e){return new sk(e)}),this.register(function(e){return new nk(e)}),this.register(function(e){return new lk(e)}),this.register(function(e){return new ck(e)}),this.register(function(e){return new ZO(e)}),this.register(function(e){return new pk(e,XO.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new pk(e,XO.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new mk(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=Ad.extractUrlBase(e);a=Ad.resolveURL(t,this.path)}else a=Ad.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 ad(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))===hk){try{a[XO.KHR_BINARY_GLTF]=new vk(e)}catch(e){r&&r(e);return}i=JSON.parse(a[XO.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 Wk(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 XO.KHR_MATERIALS_UNLIT:a[t]=new QO;break;case XO.KHR_DRACO_MESH_COMPRESSION:a[t]=new yk(i,this.dracoLoader);break;case XO.KHR_TEXTURE_TRANSFORM:a[t]=new bk;break;case XO.KHR_MESH_QUANTIZATION:a[t]=new xk;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 JO(){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 YO(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var XO={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`},ZO=class{constructor(e){this.parser=e,this.name=XO.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],ai);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new Od(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new Td(s),o.distance=c;break;case`spot`:o=new Cd(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),Ik(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)})}},QO=class{constructor(){this.name=XO.KHR_MATERIALS_UNLIT}getMaterialType(){return Ms}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],ai),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,ii))}return Promise.all(r)}},$O=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=YO(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},ek=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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)}},tk=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_DISPERSION}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},nk=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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)}},rk=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_SHEEN}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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],ai)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,ii)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},ik=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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)}},ak=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_VOLUME}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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],ai),Promise.all(r)}},ok=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_IOR}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},sk=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_SPECULAR}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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],ai),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,ii)),Promise.all(r)}},ck=class{constructor(e){this.parser=e,this.name=XO.EXT_MATERIALS_BUMP}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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)}},lk=class{constructor(e){this.parser=e,this.name=XO.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return YO(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=YO(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)}},uk=class{constructor(e){this.parser=e,this.name=XO.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)}},dk=class{constructor(e){this.parser=e,this.name=XO.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)}},fk=class{constructor(e){this.parser=e,this.name=XO.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)}},pk=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}},mk=class{constructor(e){this.name=XO.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!==Tk.TRIANGLES&&e.mode!==Tk.TRIANGLE_STRIP&&e.mode!==Tk.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 Zi,s=new J(1,1,1),c=new gc(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 cc(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);qa.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},hk=`glTF`,gk=12,_k={JSON:1313821514,BIN:5130562},vk=class{constructor(e){this.name=XO.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,gk),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!==hk)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-gk,i=new DataView(e,gk),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===_k.JSON){let r=new Uint8Array(e,gk+a,t);this.content=n.decode(r)}else if(r===_k.BIN){let n=gk+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},yk=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=XO.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=Ak[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=Ak[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=Ek[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,ai,n)})})}},bk=class{constructor(){this.name=XO.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)}},xk=class{constructor(){this.name=XO.KHR_MESH_QUANTIZATION}},Sk=class extends Lu{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}},Ck=new Zi,wk=class extends Sk{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return Ck.fromArray(i).normalize().toArray(i),i}},Tk={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},Ek={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Dk={9728:Rn,9729:Vn,9984:zn,9985:Hn,9986:Bn,9987:Un},Ok={33071:In,33648:Ln,10497:Fn},kk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ak={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`},jk={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},Mk={CUBICSPLINE:void 0,LINEAR:Xr,STEP:Yr},Nk={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function Pk(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new Ou({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Fk(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 Ik(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 Lk(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 Rk(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 zk(e){let t,n=e.extensions&&e.extensions[XO.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+Bk(n.attributes):e.indices+`:`+Bk(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+Bk(e.targets[n]);return t}function Bk(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 Vk(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 Hk(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 Uk=new Y,Wk=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new JO,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 cd(this.options.manager):this.textureLoader=new Md(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ad(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 Fk(i,a,r),Ik(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[XO.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(Ad.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=kk[r.type],t=Ek[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Vo(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=kk[r.type],o=Ek[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 rs(f,u/s),t.cache.add(n,c)),p=new as(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Vo(f,a,d);if(r.sparse!==void 0){let t=kk.SCALAR,n=Ek[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 Vo(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=Dk[n.magFilter]||1006,t.minFilter=Dk[n.minFilter]||1008,t.wrapS=Ok[n.wrapS]||1e3,t.wrapT=Ok[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 ha(e);t.needsUpdate=!0,n(t)}),t.load(Ad.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),Ik(e,a),e.userData.mimeType=a.mimeType||Hk(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[XO.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[XO.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[XO.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 zc,ss.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 Tc,ss.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 Ou}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[XO.KHR_MATERIALS_UNLIT]){let e=r[XO.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],ai),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,ii)),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||Nk.OPAQUE;if(l===Nk.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===Nk.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==Ms&&(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!==Ms&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==Ms){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],ai)}return i.emissiveTexture!==void 0&&a!==Ms&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,ii)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),Ik(n,i),t.associations.set(n,{materials:e}),i.extensions&&Fk(r,n,i),n})}createUniqueName(e){let t=Xd.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[XO.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return Kk(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=zk(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[XO.KHR_DRACO_MESH_COMPRESSION]?i(o):Kk(new ns,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?Pk(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===Tk.TRIANGLES||u.mode===Tk.TRIANGLE_STRIP||u.mode===Tk.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new nc(l,f):new Ws(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===Tk.TRIANGLE_STRIP?d.geometry=WO(d.geometry,1):u.mode===Tk.TRIANGLE_FAN&&(d.geometry=WO(d.geometry,2));else if(u.mode===Tk.LINES)d=new Lc(l,f);else if(u.mode===Tk.LINE_STRIP)d=new Nc(l,f);else if(u.mode===Tk.LINE_LOOP)d=new Rc(l,f);else if(u.mode===Tk.POINTS)d=new Wc(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&Rk(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),Ik(d,i),u.extensions&&Fk(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&&Fk(r,c[0],i),c[0];let l=new Ja;i.extensions&&Fk(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 xd(Xi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new Ed(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Ik(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 sc(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 Xu(i,void 0,l);return Ik(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,Uk)});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 rc:t.length>1?new Ja:t.length===1?t[0]:new qa,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),Ik(o,i),i.extensions&&Fk(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 Ja;n.name&&(i.name=r.createUniqueName(n.name)),Ik(i,n),n.extensions&&Fk(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(GO(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof ss||e instanceof ha)&&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=[];jk[i.path]===jk.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(jk[i.path]){case jk.weights:c=Gu;break;case jk.rotation:c=qu;break;case jk.translation:case jk.scale:c=Yu;break;default:switch(n.itemSize){case 1:c=Gu;break;default:c=Yu;break}break}let l=r.interpolation===void 0?Xr:Mk[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+jk[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=Vk(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 qu?wk:Sk)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function Gk(e,t,n){let r=t.attributes,i=new vo;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=Vk(Ek[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=Vk(Ek[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 Jo;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function Kk(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=Ak[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 aa.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${aa.workingColorSpace}" not supported.`),Ik(e,t),Gk(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:Lk(e,t.targets,n)})}var qk=(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})}}})(),Jk=1230263361,Yk=2,Xk=16,Zk=11,Qk=32767,$k=86400;function eA(e){let t=new DataView(e);if(t.getUint32(0,!0)!==Jk)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==Yk)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-Xk)/Zk),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=Xk+e*Zk;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/$k;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/Qk,l=t.getInt16(n+7,!0)/Qk,u=t.getInt16(n+9,!0)/Qk,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 tA=86400,nA=new Zi().setFromRotationMatrix(new Y().makeBasis(Tg(1,0,0,new J),Tg(0,1,0,new J),Tg(0,0,1,new J))),rA=new Zi,iA=new Zi,aA=new Zi,oA=new J;function sA(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var cA=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;retries=new Ex;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 this.coversTdb(Lg(e))}coversTdb(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){let n=Lg(e);if(!this.coversTdb(n))return!1;let r=this.fileIndexFor(n),i=this.ensure(r);if(!i)return!1;this.ensure(r-1),this.ensure(r+1),this.sampleChunk(n,r,i);let a=this.baselines?.[this.files[r].baseline_index??0];if(a){let{axis:e,rate_rad_s:t,anchor:r,anchor_jd:i}=a,o=(n-i)*tA;oA.set(e[0],e[1],e[2]),aA.setFromAxisAngle(oA,t*o),iA.set(r[1],r[2],r[3],r[0]),aA.multiply(iA),rA.copy(aA.multiply(rA))}return rA.conjugate(),t.copy(nA).multiply(rA),!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]){sA(i,0,rA);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);sA(i,a-1,rA),sA(n.quats,0,iA),rA.slerpQuaternions(rA,iA,o)}else sA(i,a-1,rA);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;sA(i,o,rA),sA(i,s,iA),rA.slerpQuaternions(rA,iA,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.retries.waiting(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,eA(i)),this.retries.clear(e)}catch(n){this.retries.fail(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function lA(e,t){return new cA(e,t)}var uA=[`carrier`,`missing`],dA=`scene-label__annotation--visible`;function fA(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,hA(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(dA))return}else if(r.textContent===n&&r.classList.contains(dA))return;else r.textContent=n;r.classList.toggle(dA,n!==null),pA(e)}function pA(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 uA){let r=e.labelAnnotations?.[t];r?.classList.contains(dA)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function mA(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 hA(e,t,n){for(let r of uA.slice(uA.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}mA(e).appendChild(t)}function gA(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=CA(e,t);return n.tintBase=i,n.tintKey=r,i}function _A(e){let t=e.userData;return t.meanColorImage!==e.image&&(t.meanColor=vA(e),t.meanColorImage=e.image),t.meanColor??null}function vA(e){let t=TA(e);if(!t)return null;let n=new X(0,0,0),r=new X,i=0;for(let a=0;a<bA;a++){let o=Math.sin(Math.PI*(a+.5)/bA);for(let i=a*yA*4;i<(a+1)*yA*4;i+=4)r.setRGB(t[i]/255,t[i+1]/255,t[i+2]/255,e.colorSpace),n.r+=o*r.r,n.g+=o*r.g,n.b+=o*r.b;i+=o*yA}return n.multiplyScalar(1/i)}var yA=32,bA=16,xA=.01,SA=.001;function CA(e,t){let n=new X(16777215);if(!t)return n;let r=wA(e);if(r===null||r>xA)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<SA?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function wA(e){let t=TA(e);if(!t)return null;let n=0,r=t.length/4;for(let e=0;e<t.length;e+=4){let r=t[e]/255,i=t[e+1]/255,a=t[e+2]/255;n+=Math.max(r,i,a)-Math.min(r,i,a)}return n/r}function TA(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=yA,n.height=bA;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,yA,bA);try{return r.getImageData(0,0,yA,bA).data}catch{return null}}var EA=`
5512
+ }`)}),c}function BD(e){e&&(e.uSelfHeightMap.value=null,e.uSelfScale.value=0)}async function VD(e,t,n,r,i,a=Q(1)){let o=UD(t,n),s;try{s=await new Promise((e,t)=>{r.load(o,e,void 0,t)})}catch(e){return console.warn(`Failed to load displacement map ${o}:`,e),null}return s.colorSpace=``,e.displacementMap=s,HD(e,t,i,a),e.needsUpdate=!0,s}function HD(e,t,n,r=Q(1)){e.displacementScale=t.scale_km*r,e.displacementBias=t.bias_km*r-(t.absolute_radius?n:0)}function UD(e,t){return $t(`/v1/textures/${e.id}/${t}.webp`,`textures`)}async function WD(e){try{let t=await fetch(e);if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return await createImageBitmap(await t.blob())}catch(t){return console.warn(`Failed to decode displacement map ${e}:`,t),null}}var GD=4e6;async function KD(e,t,n){let r=e.width,i=Math.max(1,Math.floor(GD/r)),a=document.createElement(`canvas`);a.width=r,a.height=Math.min(i,n-t+1);let o=a.getContext(`2d`,{willReadFrequently:!0});if(!o)return null;let s=new Uint8Array(r*(n-t+1));for(let a=t;a<=n;a+=i){let c=Math.min(i,n-a+1);o.drawImage(e,0,a,r,c,0,0,r,c);let l=o.getImageData(0,0,r,c).data,u=(a-t)*r;for(let e=0;e<r*c;e++)s[u+e]=l[e*4];!document.hidden&&a+i<=n&&await new Promise(e=>setTimeout(e))}return s}var qD=`pyramid`,JD=new WeakSet;function YD(e,t){let n=e.displacementMeta?.tiles;return!!n&&n.scale_km!==void 0&&qt()!==``&&o(n.distribution)&&t.extensions.has(`OES_texture_float_linear`)&&!JD.has(e)}async function XD(e,t){let n=e.displacementMeta;if(!(!n||!e.mesh||e.displacementLoading||e.displacementTier===t)){e.displacementLoading=!0;try{let r=t===`pyramid`?await QD(e,n):await ZD(n,t);if(!r)return;if(!e.mesh||!e.displacementMap){r.dispose();return}let i=e.mesh.material,a=i.displacementMap;i.displacementMap=r,e.displacementMap=r,e.displacementTier=t,e.selfShadow&&zD(i,r,Q(n.scale_km)),a&&a!==r&&a.dispose()}finally{e.displacementLoading=!1}}}async function ZD(e,t){let n=await WD(UD(e,t));if(!n)return null;let r=n.width,i=n.height,a=await KD(n,0,i-1);if(n.close(),!a)return null;let o=new Uint8Array(r);for(let e=0;e<i>>1;e++){let t=a.subarray(e*r,(e+1)*r),n=a.subarray((i-1-e)*r,(i-e)*r);o.set(t),t.set(n),n.set(o)}let s=new ic(a,r,i,cr,Wn);return s.colorSpace=``,s.magFilter=Vn,s.minFilter=Vn,s.generateMipmaps=!1,s.unpackAlignment=1,s.needsUpdate=!0,s}async function QD(e,t){if(!t.tiles)return null;try{return await $D(t,t.tiles)}catch(n){return console.warn(`Failed to load the height pyramid of ${t.id}:`,n),JD.add(e),null}}async function $D(e,t){let n=new AbortController().signal,r=await Promise.all([0,1].map(e=>rE(Yt(t,``,0,e,0),!0,n))),i=r[0].size,a=2*i,o=new Float32Array(a*i),s=(t.scale_km??0)/65535/e.scale_km,c=((t.bias_km??0)-e.bias_km)/e.scale_km;r.forEach(({heights:e},t)=>{for(let n=0;n<i;n++){let r=n*i,l=n*a+t*i;for(let t=0;t<i;t++)o[l+t]=e[r+t]*s+c}});let l=new ic(o,a,i,cr,Xn);return l.colorSpace=``,l.magFilter=Vn,l.minFilter=Un,l.generateMipmaps=!1,l.mipmaps=eO(o,a,i),l.needsUpdate=!0,l}function eO(e,t,n){let r=[{data:e,width:t,height:n}];for(;t>1||n>1;){let i=Math.max(1,t>>1),a=Math.max(1,n>>1),o=t/i,s=n/a,c=new Float32Array(i*a);for(let n=0;n<a;n++)for(let r=0;r<i;r++){let a=0;for(let i=0;i<s;i++){let c=(n*s+i)*t+r*o;for(let t=0;t<o;t++)a+=e[c+t]}c[n*i+r]=a/(o*s)}r.push({data:c,width:i,height:a}),e=c,t=i,n=a}return r}function tO(e,t,n,r,i){let a=Math.floor(r),o=Math.floor(i),s=r-a,c=i-o,l=e=>(e%t+t)%t,u=e=>e<0?0:e>n-1?n-1:e,d=l(a),f=l(a+1),p=u(o)*t,m=u(o+1)*t,h=e[p+d]*(1-s)+e[p+f]*s,g=e[m+d]*(1-s)+e[m+f]*s,_=h*(1-c)+g*c;return e instanceof Float32Array?_:_/255}function nO(e){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.needsUpdate=!0)}function rO(e,t){let n=0,r=e.length-2;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n}function iO(e,t){let n=Math.cos(e);return[n*Math.cos(t),Math.sin(e),-n*Math.sin(t)]}function aO(e,t,n,r,i,a,o){let s=(r+n)/r,[c,l,u]=iO(e,t);return[s*i*c,s*o*l,s*a*u]}function oO(e,t,n){if(e.kind===`uniform`){let r=e.segs,i=(Math.PI/2-t)*r/Math.PI,a=Math.min(Math.max(Math.floor(i),0),r-1),o=Math.min(Math.max(i-a,0),1),s=(n-Math.PI)*r/(2*Math.PI),c=Math.floor(s),l=s-c;return{corners:[[a,c],[a,c+1],[a+1,c],[a+1,c+1]].map(([e,t])=>({latRad:Math.PI/2-Math.min(e,r)*Math.PI/r,lonRad:Math.PI+t*2*Math.PI/r})),tx:l,ty:o}}let{thetas:r,phis:i,riseKm:a}=e,o=Math.PI/2-t,s=(n-Math.PI)%(2*Math.PI);s<0&&(s+=2*Math.PI);let c=rO(r,o),l=rO(i,s),u=Math.min(Math.max((o-r[c])/(r[c+1]-r[c]),0),1),d=Math.min(Math.max((s-i[l])/(i[l+1]-i[l]),0),1);return{corners:[[c,l],[c,l+1],[c+1,l],[c+1,l+1]].map(([e,t])=>({latRad:Math.PI/2-r[e],lonRad:i[t]+Math.PI,riseKm:a?.[e*i.length+t]})),tx:d,ty:u}}function sO(e,t,n){let[r,i,a,o]=e,s=[0,0,0];for(let e=0;e<3;e++)s[e]=t>=n?r[e]+(i[e]-r[e])*t+(o[e]-i[e])*n:r[e]+(o[e]-a[e])*t+(a[e]-r[e])*n;return s}function cO(e,t,n){let[r,i,a]=t>=n?[e[0],e[1],e[3]]:[e[0],e[2],e[3]],o=[i[0]-r[0],i[1]-r[1],i[2]-r[2]],s=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];return{p0:r,n:[o[1]*s[2]-o[2]*s[1],o[2]*s[0]-o[0]*s[2],o[0]*s[1]-o[1]*s[0]]}}function lO(e,t,n){let{p0:r,n:i}=cO(e,t,n),a=Math.hypot(i[0],i[1],i[2]);if(a<1e-12){let e=Math.hypot(r[0],r[1],r[2]);return[r[0]/e,r[1]/e,r[2]/e]}let o=i[0]*r[0]+i[1]*r[1]+i[2]*r[2]<0?-1/a:1/a;return[i[0]*o,i[1]*o,i[2]*o]}var uO=new Map,dO=new Map,fO=0;function pO(){return fO}var mO=6;function hO(){let e=0;for(let t of uO.values())t!==`failed`&&e++;for(let[t,n]of uO){if(e<=mO)break;n!==`failed`&&(uO.delete(t),e--)}}function gO(e,t){let n=dO.get(e);return n||(n=(async()=>{let n=await WD(UD(t,`low`)),r=n&&await KD(n,0,n.height-1);if(!n||!r)return n?.close(),uO.set(e,`failed`),null;let i={data:r,width:n.width,height:n.height,bottomUp:!1};return n.close(),uO.set(e,i),hO(),fO++,i})(),n.finally(()=>dO.delete(e)),dO.set(e,n),n)}function _O(e,t){let n=e.displacementMap?.image;if(!n)return null;let r=n.data;if((r instanceof Uint8Array||r instanceof Float32Array)&&n.width&&n.height)return{data:r,width:n.width,height:n.height,bottomUp:!0};let i=uO.get(t);if(i&&i!==`failed`)return uO.delete(t),uO.set(t,i),i;let a=e.displacementMeta;return!i&&a&&gO(t,a),null}function vO(e,t,n){let r=.5+n/(2*Math.PI),i=.5+t/Math.PI,a=(r-Math.floor(r))*e.width-.5,o=(e.bottomUp?i:1-i)*e.height-.5;return tO(e.data,e.width,e.height,a,o)}async function yO(e,t,n,r,i){let a=(e&&_O(e,t))??await gO(t,n);if(!a)return null;let o=n.bias_km-(n.absolute_radius?r:0),s=new Float64Array(i.length);for(let e=0;e<i.length;e++)s[e]=vO(a,i[e].latRad,i[e].lonRad)*n.scale_km+o;return s}var bO=new Map,xO=new Set;function SO(e,t){return bO.get(e)||(xO.has(e)||(xO.add(e),(async()=>{try{let n=(await nS(e,!1)).global;bO.set(e,n?.radii??{a:t,b:t,c:t})}catch(n){console.warn(`Failed to load radii for ${e}:`,n),bO.set(e,{a:t,b:t,c:t})}finally{xO.delete(e),fO++}})()),null)}function CO(e){let t=e?.terrainWindow;return t?{kind:`window`,thetas:t.thetas,phis:t.phis,riseKm:t.riseKm}:{kind:`uniform`,segs:e?.currentSegments??128}}function wO(e,t,n,r,i){let a=SO(t,n);if(!a)return null;let o=CO(e),s=null,c=0,l=0,u=e?.displacementMeta,d=o.kind===`window`&&!!o.riseKm;if(u&&e?.displacementMap&&!d){if(s=_O(e,t),!s)return null;c=u.scale_km,l=u.bias_km-(u.absolute_radius?n:0)}let{corners:f,tx:p,ty:m}=oO(o,r,i);return{pts:f.map(e=>{let t=e.riseKm??(s?vO(s,e.latRad,e.lonRad)*c+l:0);return aO(e.latRad,e.lonRad,t,n,a.a,a.b,a.c)}),tx:p,ty:m}}function TO(e,t,n,r,i){let a=wO(e,t,n,r,i);return a?{pointKm:sO(a.pts,a.tx,a.ty),normal:lO(a.pts,a.tx,a.ty)}:null}function EO(e,t,n,r){let i=SO(t,n);if(!i)return null;let a=wO(e,t,n,Math.atan2(r[1]/i.c,Math.hypot(r[0]/i.a,r[2]/i.b)),Math.atan2(-r[2]/i.b,r[0]/i.a));if(!a)return null;let{p0:o,n:s}=cO(a.pts,a.tx,a.ty),c=r[0]*s[0]+r[1]*s[1]+r[2]*s[2];if(Math.abs(c)<1e-12)return null;let l=(o[0]*s[0]+o[1]*s[1]+o[2]*s[2])/c;return l>0?l:null}function DO(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function OO(e){switch(e){case G.STAR:return 0;case G.PLANET:return 1;case G.DWARF_PLANET:return 2;case G.MOON:return 3;default:return 4}}function kO(e){return e.body.position!==null&&!e.carried}var AO=new J,jO=22;function MO(){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 NO=new WeakMap;function PO(e){NO.delete(e)}function FO(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(NO.get(e)===t)return;NO.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 IO(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(NO.get(e)===t)return;NO.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 LO(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 RO(e,t,n,r,i,a=null){for(let o of i){if(o.id===r||o.id===a)continue;let i=e-o.cx0,s=o.cy0-t,c=-o.f,l=i*o.gxx+s*o.gxy+c*o.gxz,u=i*o.gyx+s*o.gyy+c*o.gyz,d=i*o.gzx+s*o.gzy+c*o.gzz,f=l*o.cpx+u*o.cpy+d*o.cpz;if(!(f<=0)&&!(f*f<=o.K*(l*l+u*u+d*d))&&i*o.ccx+s*o.ccy+c*o.ccz<=n*Math.hypot(i,s,c))return!0}return!1}function zO(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function BO(e,t,n,r,i,a){let o=e.label,s=e.body.position;if(!s)return!1;let[c,l,u]=s,d=o.position;AO.set(c-n[0]+d.x,l-n[1]+d.y,u-n[2]+d.z),AO.project(t),a.x=(AO.x*.5+.5)*r,a.y=(-AO.y*.5+.5)*i;let f=a.x-o.center.x*32;return a.left=f,a.right=f+40+(e.labelTextWidth||50),a.h=jO,jw(AO.z)}var VO=[],HO=0,UO=[],WO=0,GO=[],KO=0,qO={rects:UO,get count(){return WO}};function JO(){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 YO(){return{left:0,right:0,y:0,h:0}}var XO={x:0,left:0,right:0,y:0,h:0};function ZO(e,t){for(let n=0;n<t;n++)zO(DO(GO,n,YO),e[n]);KO=t}function QO(){for(let e=0;e<KO;e++)zO(DO(UO,e,YO),GO[e]);return KO}function $O(e,t,n,r,i,a,o,s,c=[0,0,0]){HO=0,WO=QO();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(!BO(s,r,c,t,n,XO))continue;let d=e.data.id===i,f=o.has(e.data.id),p=DO(VO,HO++,JO);zO(p.rect,XO),p.rect.x=XO.x,p.bodyId=e.data.id,p.bo=s,p.body=e,p.label=l,p.labelHalo=u,p.isCapped=e.data.objectType===G.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}VO.length=HO,VO.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=OO(e.body.data.objectType),i=OO(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<HO;e++){let t=VO[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){FO(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&RO(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<WO;n++){let r=UO[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<jO){e=!0;break}}FO(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<WO;e++){let n=UO[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<jO){i=!0;break}}i?(FO(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(zO(DO(UO,WO++,YO),t.rect),IO(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<HO;e++){let t=VO[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function ek(e,t,n,r,i){WO=QO();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&BO(a,r,i,t,n,XO)&&zO(DO(UO,WO++,YO),XO)}function tk(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 nk(e){let t=new Map,n=new Map,r=e.clone();return rk(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 rk(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)rk(e.children[r],t.children[r],n)}var ik=class extends nd{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new dk(e)}),this.register(function(e){return new fk(e)}),this.register(function(e){return new xk(e)}),this.register(function(e){return new Sk(e)}),this.register(function(e){return new Ck(e)}),this.register(function(e){return new mk(e)}),this.register(function(e){return new hk(e)}),this.register(function(e){return new gk(e)}),this.register(function(e){return new _k(e)}),this.register(function(e){return new uk(e)}),this.register(function(e){return new vk(e)}),this.register(function(e){return new pk(e)}),this.register(function(e){return new bk(e)}),this.register(function(e){return new yk(e)}),this.register(function(e){return new ck(e)}),this.register(function(e){return new wk(e,sk.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new wk(e,sk.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Tk(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=Ad.extractUrlBase(e);a=Ad.resolveURL(t,this.path)}else a=Ad.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 ad(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))===Ek){try{a[sk.KHR_BINARY_GLTF]=new kk(e)}catch(e){r&&r(e);return}i=JSON.parse(a[sk.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 tA(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 sk.KHR_MATERIALS_UNLIT:a[t]=new lk;break;case sk.KHR_DRACO_MESH_COMPRESSION:a[t]=new Ak(i,this.dracoLoader);break;case sk.KHR_TEXTURE_TRANSFORM:a[t]=new jk;break;case sk.KHR_MESH_QUANTIZATION:a[t]=new Mk;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 ak(){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 ok(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var sk={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`},ck=class{constructor(e){this.parser=e,this.name=sk.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],ai);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new Od(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new Td(s),o.distance=c;break;case`spot`:o=new Cd(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),qk(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)})}},lk=class{constructor(){this.name=sk.KHR_MATERIALS_UNLIT}getMaterialType(){return Ms}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],ai),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,ii))}return Promise.all(r)}},uk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=ok(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},dk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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)}},fk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_DISPERSION}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},pk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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)}},mk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_SHEEN}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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],ai)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,ii)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},hk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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)}},gk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_VOLUME}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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],ai),Promise.all(r)}},_k=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_IOR}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},vk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_SPECULAR}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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],ai),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,ii)),Promise.all(r)}},yk=class{constructor(e){this.parser=e,this.name=sk.EXT_MATERIALS_BUMP}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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)}},bk=class{constructor(e){this.parser=e,this.name=sk.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return ok(this.parser,e,this.name)===null?null:ku}extendMaterialParams(e,t){let n=ok(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)}},xk=class{constructor(e){this.parser=e,this.name=sk.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)}},Sk=class{constructor(e){this.parser=e,this.name=sk.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)}},Ck=class{constructor(e){this.parser=e,this.name=sk.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)}},wk=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}},Tk=class{constructor(e){this.name=sk.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!==Ik.TRIANGLES&&e.mode!==Ik.TRIANGLE_STRIP&&e.mode!==Ik.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 Zi,s=new J(1,1,1),c=new gc(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 cc(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);qa.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},Ek=`glTF`,Dk=12,Ok={JSON:1313821514,BIN:5130562},kk=class{constructor(e){this.name=sk.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Dk),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!==Ek)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-Dk,i=new DataView(e,Dk),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===Ok.JSON){let r=new Uint8Array(e,Dk+a,t);this.content=n.decode(r)}else if(r===Ok.BIN){let n=Dk+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},Ak=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=sk.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=Vk[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=Vk[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=Lk[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,ai,n)})})}},jk=class{constructor(){this.name=sk.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)}},Mk=class{constructor(){this.name=sk.KHR_MESH_QUANTIZATION}},Nk=class extends Lu{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}},Pk=new Zi,Fk=class extends Nk{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return Pk.fromArray(i).normalize().toArray(i),i}},Ik={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},Lk={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Rk={9728:Rn,9729:Vn,9984:zn,9985:Hn,9986:Bn,9987:Un},zk={33071:In,33648:Ln,10497:Fn},Bk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vk={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`},Hk={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},Uk={CUBICSPLINE:void 0,LINEAR:Xr,STEP:Yr},Wk={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function Gk(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new Ou({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Kk(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 qk(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 Jk(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 Yk(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 Xk(e){let t,n=e.extensions&&e.extensions[sk.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+Zk(n.attributes):e.indices+`:`+Zk(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+Zk(e.targets[n]);return t}function Zk(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 Qk(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 $k(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 eA=new Y,tA=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ak,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 cd(this.options.manager):this.textureLoader=new Md(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ad(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 Kk(i,a,r),qk(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[sk.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(Ad.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=Bk[r.type],t=Lk[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Vo(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=Bk[r.type],o=Lk[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 rs(f,u/s),t.cache.add(n,c)),p=new as(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Vo(f,a,d);if(r.sparse!==void 0){let t=Bk.SCALAR,n=Lk[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 Vo(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=Rk[n.magFilter]||1006,t.minFilter=Rk[n.minFilter]||1008,t.wrapS=zk[n.wrapS]||1e3,t.wrapT=zk[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 ha(e);t.needsUpdate=!0,n(t)}),t.load(Ad.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),qk(e,a),e.userData.mimeType=a.mimeType||$k(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[sk.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[sk.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[sk.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 zc,ss.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 Tc,ss.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 Ou}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[sk.KHR_MATERIALS_UNLIT]){let e=r[sk.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],ai),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,ii)),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||Wk.OPAQUE;if(l===Wk.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===Wk.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==Ms&&(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!==Ms&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==Ms){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],ai)}return i.emissiveTexture!==void 0&&a!==Ms&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,ii)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),qk(n,i),t.associations.set(n,{materials:e}),i.extensions&&Kk(r,n,i),n})}createUniqueName(e){let t=Xd.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[sk.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return rA(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=Xk(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[sk.KHR_DRACO_MESH_COMPRESSION]?i(o):rA(new ns,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?Gk(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===Ik.TRIANGLES||u.mode===Ik.TRIANGLE_STRIP||u.mode===Ik.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new nc(l,f):new Ws(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===Ik.TRIANGLE_STRIP?d.geometry=tk(d.geometry,1):u.mode===Ik.TRIANGLE_FAN&&(d.geometry=tk(d.geometry,2));else if(u.mode===Ik.LINES)d=new Lc(l,f);else if(u.mode===Ik.LINE_STRIP)d=new Nc(l,f);else if(u.mode===Ik.LINE_LOOP)d=new Rc(l,f);else if(u.mode===Ik.POINTS)d=new Wc(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&Yk(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),qk(d,i),u.extensions&&Kk(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&&Kk(r,c[0],i),c[0];let l=new Ja;i.extensions&&Kk(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 xd(Xi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new Ed(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),qk(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 sc(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 Xu(i,void 0,l);return qk(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,eA)});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 rc:t.length>1?new Ja:t.length===1?t[0]:new qa,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),qk(o,i),i.extensions&&Kk(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 Ja;n.name&&(i.name=r.createUniqueName(n.name)),qk(i,n),n.extensions&&Kk(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(nk(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof ss||e instanceof ha)&&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=[];Hk[i.path]===Hk.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(Hk[i.path]){case Hk.weights:c=Gu;break;case Hk.rotation:c=qu;break;case Hk.translation:case Hk.scale:c=Yu;break;default:switch(n.itemSize){case 1:c=Gu;break;default:c=Yu;break}break}let l=r.interpolation===void 0?Xr:Uk[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+Hk[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=Qk(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 qu?Fk:Nk)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function nA(e,t,n){let r=t.attributes,i=new vo;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=Qk(Lk[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=Qk(Lk[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 Jo;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function rA(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=Vk[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 aa.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${aa.workingColorSpace}" not supported.`),qk(e,t),nA(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:Jk(e,t.targets,n)})}var iA=(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})}}})(),aA=1230263361,oA=2,sA=16,cA=11,lA=32767,uA=86400;function dA(e){let t=new DataView(e);if(t.getUint32(0,!0)!==aA)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==oA)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-sA)/cA),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=sA+e*cA;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/uA;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/lA,l=t.getInt16(n+7,!0)/lA,u=t.getInt16(n+9,!0)/lA,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 fA=86400,pA=new Zi().setFromRotationMatrix(new Y().makeBasis(Tg(1,0,0,new J),Tg(0,1,0,new J),Tg(0,0,1,new J))),mA=new Zi,hA=new Zi,gA=new Zi,_A=new J;function vA(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var yA=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;retries=new Ex;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 this.coversTdb(Lg(e))}coversTdb(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){let n=Lg(e);if(!this.coversTdb(n))return!1;let r=this.fileIndexFor(n),i=this.ensure(r);if(!i)return!1;this.ensure(r-1),this.ensure(r+1),this.sampleChunk(n,r,i);let a=this.baselines?.[this.files[r].baseline_index??0];if(a){let{axis:e,rate_rad_s:t,anchor:r,anchor_jd:i}=a,o=(n-i)*fA;_A.set(e[0],e[1],e[2]),gA.setFromAxisAngle(_A,t*o),hA.set(r[1],r[2],r[3],r[0]),gA.multiply(hA),mA.copy(gA.multiply(mA))}return mA.conjugate(),t.copy(pA).multiply(mA),!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]){vA(i,0,mA);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);vA(i,a-1,mA),vA(n.quats,0,hA),mA.slerpQuaternions(mA,hA,o)}else vA(i,a-1,mA);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;vA(i,o,mA),vA(i,s,hA),mA.slerpQuaternions(mA,hA,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.retries.waiting(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,dA(i)),this.retries.clear(e)}catch(n){this.retries.fail(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function bA(e,t){return new yA(e,t)}var xA=[`carrier`,`missing`],SA=`scene-label__annotation--visible`;function CA(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,EA(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(SA))return}else if(r.textContent===n&&r.classList.contains(SA))return;else r.textContent=n;r.classList.toggle(SA,n!==null),wA(e)}function wA(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 xA){let r=e.labelAnnotations?.[t];r?.classList.contains(SA)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function TA(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 EA(e,t,n){for(let r of xA.slice(xA.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}TA(e).appendChild(t)}function DA(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=PA(e,t);return n.tintBase=i,n.tintKey=r,i}function OA(e){let t=e.userData;return t.meanColorImage!==e.image&&(t.meanColor=kA(e),t.meanColorImage=e.image),t.meanColor??null}function kA(e){let t=IA(e);if(!t)return null;let n=new X(0,0,0),r=new X,i=0;for(let a=0;a<jA;a++){let o=Math.sin(Math.PI*(a+.5)/jA);for(let i=a*AA*4;i<(a+1)*AA*4;i+=4)r.setRGB(t[i]/255,t[i+1]/255,t[i+2]/255,e.colorSpace),n.r+=o*r.r,n.g+=o*r.g,n.b+=o*r.b;i+=o*AA}return n.multiplyScalar(1/i)}var AA=32,jA=16,MA=.01,NA=.001;function PA(e,t){let n=new X(16777215);if(!t)return n;let r=FA(e);if(r===null||r>MA)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<NA?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function FA(e){let t=IA(e);if(!t)return null;let n=0,r=t.length/4;for(let e=0;e<t.length;e+=4){let r=t[e]/255,i=t[e+1]/255,a=t[e+2]/255;n+=Math.max(r,i,a)-Math.min(r,i,a)}return n/r}function IA(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=AA,n.height=jA;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,AA,jA);try{return r.getImageData(0,0,AA,jA).data}catch{return null}}var LA=`
5513
5513
  #ifdef USE_MAP
5514
5514
  vec3 bodyDir = normalize( vBodyDir );
5515
5515
  float lon = atan( -bodyDir.z, bodyDir.x );
@@ -5521,16 +5521,16 @@ float reliefTileShadow( vec3 dir, mat3x2 map, mat3x2 cap, float side, vec3 toSun
5521
5521
  vec4 sampledDiffuseColor = textureGrad( map, euv, seam ? dxB : dxA, seam ? dyB : dyA );
5522
5522
  diffuseColor *= sampledDiffuseColor;
5523
5523
  #endif
5524
- `;function DA(e){let t=new Ou({color:e,roughness:1,metalness:0});return t.onBeforeCompile=e=>{e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5524
+ `;function RA(e){let t=new Ou({color:e,roughness:1,metalness:0});return t.onBeforeCompile=e=>{e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5525
5525
  varying vec3 vBodyDir;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
5526
5526
  vBodyDir = position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5527
- varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,EA).replace(`#include <envmap_physical_pars_fragment>`,`
5527
+ varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,LA).replace(`#include <envmap_physical_pars_fragment>`,`
5528
5528
  #ifdef USE_ENVMAP
5529
5529
  vec3 getIBLIrradiance( const in vec3 normal ) { return vec3( 0.0 ); }
5530
5530
  vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { return vec3( 0.0 ); }
5531
- #endif`)},HS(t,`shapeModel`),t}function OA(e,t){e.traverse(e=>{if(!(e instanceof Ws))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function kA(e,t,n,r){e.traverse(e=>{!(e instanceof Ws)||!(e.material instanceof Ou)||(e.material.map=t,t?e.material.color.copy(gA(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function AA(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=ii,t.anisotropy=16,e.map=t,e.color.copy(gA(t,n)),e.needsUpdate=!0}var jA=[-.019,242e-6,-146e-8],MA=`
5531
+ #endif`)},QS(t,`shapeModel`),t}function zA(e,t){e.traverse(e=>{if(!(e instanceof Ws))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function BA(e,t,n,r){e.traverse(e=>{!(e instanceof Ws)||!(e.material instanceof Ou)||(e.material.map=t,t?e.material.color.copy(DA(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function VA(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=ii,t.anisotropy=16,e.map=t,e.color.copy(DA(t,n)),e.needsUpdate=!0}var HA=[-.019,242e-6,-146e-8],UA=`
5532
5532
  float lunarLambertWeight(float phaseDeg, float scale) {
5533
- return min(scale * clamp(1.0 + phaseDeg * (${jA[0].toFixed(8)} + phaseDeg * (${jA[1].toFixed(8)} + phaseDeg * ${jA[2].toFixed(8)})), 0.0, 1.0), 1.0);
5533
+ return min(scale * clamp(1.0 + phaseDeg * (${HA[0].toFixed(8)} + phaseDeg * (${HA[1].toFixed(8)} + phaseDeg * ${HA[2].toFixed(8)})), 0.0, 1.0), 1.0);
5534
5534
  }
5535
5535
 
5536
5536
  float lunarLambertGain(float phaseDeg, float mu0, float mu, float scale) {
@@ -5538,13 +5538,13 @@ varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,EA).replace(`#include
5538
5538
  float sun = max(mu0, 0.0);
5539
5539
  return 2.0 * weight / max(sun + max(mu, sun), ${.05.toFixed(3)}) + 1.0 - weight;
5540
5540
  }
5541
- `;function NA(e){return{uLunarWeightScale:{value:e??1}}}function PA(e,t){let[n,r,i]=jA,a=Math.min(1,Math.max(0,1+e*(n+e*(r+e*i))));return Math.min(1,t*a)}var FA=`
5541
+ `;function WA(e){return{uLunarWeightScale:{value:e??1}}}function GA(e,t){let[n,r,i]=HA,a=Math.min(1,Math.max(0,1+e*(n+e*(r+e*i))));return Math.min(1,t*a)}var KA=`
5542
5542
  #ifdef USE_ROUGHNESSMAP
5543
5543
  reflectedLight.directSpecular *= texelRoughness.g;
5544
5544
  #else
5545
5545
  reflectedLight.directSpecular = vec3(0.0);
5546
5546
  #endif
5547
- `,IA=`
5547
+ `,qA=`
5548
5548
  {
5549
5549
  vec3 sunView = mat3(viewMatrix) * uPhotometrySunDir;
5550
5550
  #if NUM_POINT_LIGHTS > 0
@@ -5559,7 +5559,7 @@ varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,EA).replace(`#include
5559
5559
  uLunarWeightScale
5560
5560
  );
5561
5561
  }
5562
- `;function LA(e,t,n,r){let i=!Yb(t);US(e,i?`photometryAirless`:`photometry`,e=>{let t=``,a=FA;i&&(e.uniforms.uPhotometrySunDir=r??Nw().uSunDir,Object.assign(e.uniforms,n),t=`uniform vec3 uPhotometrySunDir;\nuniform float uLunarWeightScale;\n${MA}`,a+=IA),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${t}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>\n${a}`)})}var RA=`#6b6b6b`;function zA(e){return .2126*e.r+.7152*e.g+.0722*e.b}function BA(e,t){return e?(2+PA(0,t??1))/3:2/3}var VA=new X;function HA(e){return e.color?(e.geometricAlbedo??zA(VA.set(e.color)))/BA(!Yb(e.id),e.lunarWeightScale):null}function UA(e,t=new X){let n=HA(e);return n===null?t.set(RA):(t.set(e.color),t.multiplyScalar(n/zA(t)))}function WA(e,t,n){if(e.color)n.set(e.color);else if(e.geometricAlbedo===void 0)return null;else{let e=t&&_A(t);e?n.copy(e):n.setRGB(1,1,1)}let r=e.geometricAlbedo??zA(n);return n.multiplyScalar(1.5*r/zA(n))}var GA=new Set([]);function KA(e){return e?.model_name?GC()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!GA.has(e.id)?`dem-preferred`:null:`no-bundle`}function qA(e,t,n,r,i){e.orientation=t,e.nutPrec=zv(e.data.id,n),r&&r.bodies.dataVersion++,r?.credits.registerOrientation({bodyId:e.data.id,systemId:i??e.data.id,source:t.source,reference:t.reference})}var JA=48,YA=96,XA=JA*YA,ZA=1<<24,QA=Math.PI*2;function $A(e){let t=Math.floor((e+1)/2*JA);return Math.min(JA-1,Math.max(0,t))}function ej(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/QA*YA)%YA+YA)%YA}var tj=new J;function nj(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)tj.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=tj.x,r[i*3+1]=tj.y,r[i*3+2]=tj.z,n[i]=$A(tj.y)*YA+ej(tj.x,tj.z);return{cells:n,dirs:r}}function rj(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++)tj.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=tj.x,i[e*3+1]=tj.y,i[e*3+2]=tj.z;return i}var ij=new J,aj=new J,oj=new J,sj=new J,cj=new J,lj=new J;function uj(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function dj(e,t,n,r){return lj.crossVectors(e,n).dot(r)>=0&&lj.crossVectors(n,t).dot(r)>=0}function fj(e,t,n){sj.crossVectors(e,t);let r=sj.lengthSq();r<1e-18||(cj.set(0,1,0).addScaledVector(sj,-sj.y/r).normalize(),dj(e,t,cj,sj)&&(n.hi=Math.max(n.hi,$A(cj.y))),cj.negate(),dj(e,t,cj,sj)&&(n.lo=Math.min(n.lo,$A(cj.y))))}function pj(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 mj(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/YA|0,p=u/YA|0,m=d/YA|0,h=l%YA,g=u%YA,_=d%YA,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+YA-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+YA):x-S>C&&(w=x,T=S+YA),(y-v>1||T-w>1)&&(uj(s,t,ij),uj(s,r,aj),uj(s,i,oj),pj(ij,aj,oj,1)?(y=JA-1,w=0,T=YA-1):pj(ij,aj,oj,-1)?(v=0,w=0,T=YA-1):(n.lo=v,n.hi=y,fj(ij,aj,n),fj(aj,oj,n),fj(oj,ij,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 hj(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*ZA+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*YA+a%YA,i)}}}function gj(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 Ws))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>=ZA||n.push({verts:rj(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=mj(n,n.map(nj)),i=new Int32Array(XA+1);hj(r,e=>i[e+1]++);for(let e=0;e<XA;e++)i[e+1]+=i[e];let a=new Int32Array(i[XA]),o=i.slice(0,XA);return hj(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var _j=new J,vj=new J,yj=new J,bj=new J,xj=new J,Sj=new J,Cj=new J;function wj(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;_j.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),vj.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),yj.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),bj.subVectors(vj,_j),xj.subVectors(yj,_j),Sj.crossVectors(n,xj);let o=bj.dot(Sj);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-_j.dot(Sj)*s;if(c<0||c>1)return 0;Cj.crossVectors(_j,bj).negate();let l=n.dot(Cj)*s;if(l<0||c+l>1)return 0;let u=xj.dot(Cj)*s;return u>0?u:0}function Tj(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=wj(o[t/ZA|0],t%ZA,n);i>r&&(r=i)}return r}function Ej(e,t){let n=$A(t.y),r=ej(t.x,t.z),i=Tj(e,n*YA+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=JA))for(let n=-1;n<=1;n++)i=Tj(e,o*YA+(r+n+YA)%YA,t,i)}if(i===0&&(n===0||n===JA-1)){let r=n===0?0:JA-2;for(let n=r;n<r+2;n++)for(let r=0;r<YA;r++)i=Tj(e,n*YA+r,t,i)}return i>0?i:null}function Dj(e){let t=e.data.objectType;return t===G.SPACECRAFT||t===G.DEBRIS||e.data.orbitalSource===W.SPICE_PROBE}var Oj=new qO;Oj.setMeshoptDecoder(qk);var kj=Oj,Aj=new Map;function jj(e){let t=Aj.get(e);return t||(t=fetch($t(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),Aj.set(e,t),t.catch(()=>Aj.delete(e))),t}function Mj(e){if(o(e.exports.high.distribution))return`high`;if(e.exports.low&&o(e.exports.low.distribution))return`low`}function Nj(e){return e.credit??e.exports.high.credit}function Pj(e,t){return e.exports[t]?.credit??e.exports.high.credit}function Fj(e){return e.modelUnitOverride??e.radiusScene}var Ij=new Set;function Lj(e,t){let n=new Ja;n.scale.setScalar(Fj(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,Ij.add(n)}function Rj(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof Ws))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof Ou)||n.has(t)||(n.add(t),e.eclipseShadow=Gw(t,e.eclipseShadow??void 0))})}function zj(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=(Dj(e.body)?Bj(e,t,n):Vj(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function Bj(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await nS(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=lA(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),Uj(e,!0);let s=await jj(o),c=Mj(s);if(!c){e.noPhysical=`model`;return}let l=await kj.loadAsync($t(`/v1/models/${o}/${c}.glb`,`models`));if((e.modelLoadEpoch??0)!==r||!e.mesh){dM(l.scene);return}let u=s.frame_map?kS(s.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=Wj(l.scene,u),f=s.model_anchor?new J(...s.model_anchor):null;if(!Gj(d,f&&u?f.applyQuaternion(u):f)){dM(l.scene),e.noPhysical=`model`;return}if(uM(d),t.add(d),d.visible=!e.isCrashed,e.model=d,e.modelName=o,Uj(e,!1),s.scale_meters){let t=s.scale_meters/2e3;e.body.data.radiusKm=t*(s.body_span_ratio??1),e.radiusScene=Q(xn(e.body.data)),e.modelUnitOverride=s.body_span_ratio?Q(t):void 0}let p=Pj(s,c);n?.credits.registerModel({bodyId:e.body.data.id,source:p.url,organisation:p.name,license:p.license})}finally{e.model||Uj(e,!1)}}async function Vj(e,t){if(!ew().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await nS(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=KA(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&&qA(e.body,r.global.orientation,r.global.nut_prec,t);let o=jj(i),s=await kj.loadAsync($t(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){dM(s.scene);return}let c;try{c=await o}catch(e){dM(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){dM(s.scene);return}let l=s.scene;if(!Gj(l)){dM(s.scene);return}l.userData.radialIndex=gj(l);let u=DA(UA(e.body.data));e.photometry??=NA(e.body.data.lunarWeightScale),LA(u,e.body.data.id,e.photometry),e.planetshine=xT(u,e.planetshine??void 0),OA(l,u);let d=e.mesh?e.mesh.material.map:null;d&&kA(l,d,UA(e.body.data),e.body.data.color),uM(l),Rj(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,fA(e,`missing`,null))),Lj(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let f=Nj(c),p=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:f.url,organisation:f.name,license:f.license,provenance:p?.provenance,technique:p?.technique,archive:p?.archive,archiveUrl:p?.archive_url,mission:p?.mission&&{name:p.mission.name,id:p.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function Hj(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,Uj(e,!1);let t=!Dj(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=(Ij.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),dM(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 Uj(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 Wj(e,t){if(!t)return e;let n=new Ja;return e.quaternion.copy(t),n.add(e),n}function Gj(e,t=null){e.updateMatrixWorld(!0);let n=new vo().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!1;let o=2/a;e.userData.boxCenter=i.clone().multiplyScalar(o),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=Jj(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();return e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c,!0}var Kj=8,qj=4096;function Jj(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 Ws&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/qj)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof Ws))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:Kj},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(Kj-1,Math.max(0,Math.floor(t*Kj)))].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 Yj=4,Xj=.05,Zj=new J,Qj=new J,$j=new J,eM=new J,tM=new Zi,nM=new J,rM=new Qd;function iM(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(eM).x;if(!(a>0))return null;let o=Math.cos(t);Zj.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),Qj.copy(Zj).applyQuaternion(e.quaternion),$j.copy(e.position).addScaledVector(Qj,Yj),i.localToWorld($j),rM.set($j,Qj.negate());let s=rM.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(tM.copy(e.quaternion).invert()),Math.max(Yj-s.distance/a,Xj)):null}function aM(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=Ej(n,nM.set(t[0],t[1],t[2]));return r===null?null:Sg(r*Fj(e))}function oM(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function sM(e){if(!oM(e))return;let t=e.model.position,n=Fj(e);return[t.x*n,t.y*n,t.z*n]}function cM(e){if(oM(e))return Sg(e.model.userData.maxRadius*Fj(e))}function lM(e){if(oM(e))return Sg(e.model.userData.minRadius*Fj(e))}function uM(e){e.traverse(e=>{e instanceof Ws&&(e.castShadow=!0,e.receiveShadow=!0)})}function dM(e){e.traverse(e=>{if(!(e instanceof Ws))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 ha&&t.dispose();e.dispose()}})}var fM=3;function pM(e,t,n=fM){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 mM(e,t){if(e)return hn(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var hM=Math.PI/180,gM=.9,_M=24,vM=.2,yM=100,bM=16,xM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function SM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await nS(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await PT(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!xM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:yM;return(t.diameterM>0?t.diameterM:yM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await TM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=Fj(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new Ja,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 cO(e,e.body.data.id,r.global.displacement,xn(e.body.data),a.map(e=>({latRad:e.lat*hM,lonRad:e.lon*hM}))),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:yM;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),IT(o,t),n&&pM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=qD(r.lat*hM,r.lon*hM),m=c[e],g=new OT(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 ${yM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var CM=8,wM=new J;async function TM(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%CM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*hM,s=t[o].lon*hM,c=iM(e,n,s,wM);if(c!==null)r[o]=c;else{let[e,t,i]=qD(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),wM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=wM.x,i[o*3+1]=wM.y,i[o*3+2]=wM.z}return{radii:r,normals:i}}function EM(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 DM(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 OM=new J,kM=new J,AM=new J,jM=new J,MM=new J,NM=new Zi,PM=new J,FM=.12;function IM(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/(xn(e.body.data)*1e3),m=vM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<_M)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(OM),r.getWorldPosition(kM);let h=kM.x-OM.x,g=kM.y-OM.y,_=kM.z-OM.z;jM.copy(OM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(gM*(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(NM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<_M||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(AM);let v=AM.x-OM.x,y=AM.y-OM.y,w=AM.z-OM.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){PM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(NM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(PM.x*n+PM.y*r+PM.z*i<FM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}MM.copy(AM).project(r);let T=(MM.x-jM.x)*x,E=(MM.y-jM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(MM.x*.5+.5)*i,l[e]=(-MM.y*.5+.5)*a}}var LM=[];function RM(e){let t=LM[e];return t||(t={left:0,right:0,y:0,h:0},LM[e]=t),t}function zM(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=LM[e],n=(t.h+bM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=RM(r);return f.left=u,f.right=d,f.y=o,f.h=bM,r+1}function BM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=IO,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=RM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=zM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=zM(e,i,!1,r))}var VM=1.002;function HM(e,t){let n=e?.referenceAltitudeKm??0;return n>0?1+n/t:VM}var UM=1e3;function WM(e,t,n){return $t(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function GM(e,t,n){try{let r=await fetch(WM(e,t,n));if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=new ha(await createImageBitmap(i,{imageOrientation:`flipY`}));return a.flipY=!1,a.colorSpace=ii,a.anisotropy=16,a.needsUpdate=!0,a}catch(r){return console.warn(`Failed to load ${t} cloud texture for ${e} @ ${n}:`,r),null}}function KM(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 qM=10800*1e3;function JM(e,t,n){return n?n.some(([t,n])=>e>=KM(t)&&e<KM(n)+qM):e>=KM(t[0])&&e<=KM(t[t.length-1])}function YM(e,t,n){if(t.length===0)return;let r=Mg(e).getTime(),i=KM(t[0]);if(JM(r,t,n)){let e=0,n=t.length;for(;e<n;){let i=e+n>>>1;KM(t[i])<=r?e=i+1:n=i}return t[Math.max(0,e-1)]}let a=Mg(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 XM(e,t,n,r,i=VM){let a=await GM(n.id,`low`,r);if(!a)return null;let o=ZM(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 ZM(e,t,n,r=VM){let i=new Ou({map:n,transparent:!0,depthWrite:!1}),a=new Ws(new _u(t,64,64),i);return a.scale.setScalar(r),a.renderOrder=1,e.add(a),{mesh:a,material:i,id:``,availableTiers:[],availableFrames:[]}}async function QM(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<UM)){e.lastSwapMs=r,e.textureLoading=!0;try{let r=await GM(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 $M(e){e.mesh.geometry.dispose(),e.material.map?.dispose(),e.material.dispose(),e.mesh.parent?.remove(e.mesh)}var eN=.2,tN=-.125,nN=.1,rN=Symbol(`night-lights-hook`);async function iN(e,t,n,r){let i=$t(`/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=ii,aN(e,a),a}function aN(e,t){t.anisotropy=16,e.emissiveMap=t,e.emissive=new X(16777215);let n=e;if(!n[rN]){n[rN]=!0;let t=Nw();US(e,`nightLights`,e=>{e.uniforms.uSunDir=t.uSunDir,e.uniforms.uNightIntensity={value:eN},e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5562
+ `;function JA(e,t,n,r){let i=!Yb(t);$S(e,i?`photometryAirless`:`photometry`,e=>{let t=``,a=KA;i&&(e.uniforms.uPhotometrySunDir=r??Uw().uSunDir,Object.assign(e.uniforms,n),t=`uniform vec3 uPhotometrySunDir;\nuniform float uLunarWeightScale;\n${UA}`,a+=qA),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${t}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>\n${a}`)})}var YA=`#6b6b6b`;function XA(e){return .2126*e.r+.7152*e.g+.0722*e.b}function ZA(e,t){return e?(2+GA(0,t??1))/3:2/3}var QA=new X;function $A(e){return e.color?(e.geometricAlbedo??XA(QA.set(e.color)))/ZA(!Yb(e.id),e.lunarWeightScale):null}function ej(e,t=new X){let n=$A(e);return n===null?t.set(YA):(t.set(e.color),t.multiplyScalar(n/XA(t)))}function tj(e,t,n){if(e.color)n.set(e.color);else if(e.geometricAlbedo===void 0)return null;else{let e=t&&OA(t);e?n.copy(e):n.setRGB(1,1,1)}let r=e.geometricAlbedo??XA(n);return n.multiplyScalar(1.5*r/XA(n))}var nj=new Set([]);function rj(e){return e?.model_name?tw()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!nj.has(e.id)?`dem-preferred`:null:`no-bundle`}function ij(e,t,n,r,i){e.orientation=t,e.nutPrec=zv(e.data.id,n),r&&r.bodies.dataVersion++,r?.credits.registerOrientation({bodyId:e.data.id,systemId:i??e.data.id,source:t.source,reference:t.reference})}var aj=48,oj=96,sj=aj*oj,cj=1<<24,lj=Math.PI*2;function uj(e){let t=Math.floor((e+1)/2*aj);return Math.min(aj-1,Math.max(0,t))}function dj(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/lj*oj)%oj+oj)%oj}var fj=new J;function pj(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)fj.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=fj.x,r[i*3+1]=fj.y,r[i*3+2]=fj.z,n[i]=uj(fj.y)*oj+dj(fj.x,fj.z);return{cells:n,dirs:r}}function mj(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++)fj.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=fj.x,i[e*3+1]=fj.y,i[e*3+2]=fj.z;return i}var hj=new J,gj=new J,_j=new J,vj=new J,yj=new J,bj=new J;function xj(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function Sj(e,t,n,r){return bj.crossVectors(e,n).dot(r)>=0&&bj.crossVectors(n,t).dot(r)>=0}function Cj(e,t,n){vj.crossVectors(e,t);let r=vj.lengthSq();r<1e-18||(yj.set(0,1,0).addScaledVector(vj,-vj.y/r).normalize(),Sj(e,t,yj,vj)&&(n.hi=Math.max(n.hi,uj(yj.y))),yj.negate(),Sj(e,t,yj,vj)&&(n.lo=Math.min(n.lo,uj(yj.y))))}function wj(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 Tj(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/oj|0,p=u/oj|0,m=d/oj|0,h=l%oj,g=u%oj,_=d%oj,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+oj-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+oj):x-S>C&&(w=x,T=S+oj),(y-v>1||T-w>1)&&(xj(s,t,hj),xj(s,r,gj),xj(s,i,_j),wj(hj,gj,_j,1)?(y=aj-1,w=0,T=oj-1):wj(hj,gj,_j,-1)?(v=0,w=0,T=oj-1):(n.lo=v,n.hi=y,Cj(hj,gj,n),Cj(gj,_j,n),Cj(_j,hj,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 Ej(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*cj+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*oj+a%oj,i)}}}function Dj(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 Ws))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>=cj||n.push({verts:mj(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=Tj(n,n.map(pj)),i=new Int32Array(sj+1);Ej(r,e=>i[e+1]++);for(let e=0;e<sj;e++)i[e+1]+=i[e];let a=new Int32Array(i[sj]),o=i.slice(0,sj);return Ej(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var Oj=new J,kj=new J,Aj=new J,jj=new J,Mj=new J,Nj=new J,Pj=new J;function Fj(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;Oj.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),kj.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),Aj.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),jj.subVectors(kj,Oj),Mj.subVectors(Aj,Oj),Nj.crossVectors(n,Mj);let o=jj.dot(Nj);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-Oj.dot(Nj)*s;if(c<0||c>1)return 0;Pj.crossVectors(Oj,jj).negate();let l=n.dot(Pj)*s;if(l<0||c+l>1)return 0;let u=Mj.dot(Pj)*s;return u>0?u:0}function Ij(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=Fj(o[t/cj|0],t%cj,n);i>r&&(r=i)}return r}function Lj(e,t){let n=uj(t.y),r=dj(t.x,t.z),i=Ij(e,n*oj+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=aj))for(let n=-1;n<=1;n++)i=Ij(e,o*oj+(r+n+oj)%oj,t,i)}if(i===0&&(n===0||n===aj-1)){let r=n===0?0:aj-2;for(let n=r;n<r+2;n++)for(let r=0;r<oj;r++)i=Ij(e,n*oj+r,t,i)}return i>0?i:null}function Rj(e){let t=e.data.objectType;return t===G.SPACECRAFT||t===G.DEBRIS||e.data.orbitalSource===W.SPICE_PROBE}var zj=new ik;zj.setMeshoptDecoder(iA);var Bj=zj,Vj=new Map;function Hj(e){let t=Vj.get(e);return t||(t=fetch($t(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),Vj.set(e,t),t.catch(()=>Vj.delete(e))),t}function Uj(e){if(o(e.exports.high.distribution))return`high`;if(e.exports.low&&o(e.exports.low.distribution))return`low`}function Wj(e){return e.credit??e.exports.high.credit}function Gj(e,t){return e.exports[t]?.credit??e.exports.high.credit}function Kj(e){return e.modelUnitOverride??e.radiusScene}var qj=new Set;function Jj(e,t){let n=new Ja;n.scale.setScalar(Kj(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,qj.add(n)}function Yj(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof Ws))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof Ou)||n.has(t)||(n.add(t),e.eclipseShadow=tT(t,e.eclipseShadow??void 0))})}function Xj(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=(Rj(e.body)?Zj(e,t,n):Qj(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function Zj(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await nS(e.body.data.id,!1);e.body.pointing=i.global?.pointing,e.body.landedHeadings=tM(i.global?.events?.items);let a=i.global?.attitude;if(a&&(e.modelLoadEpoch??0)===r){let t=e.body.data.id.replace(/^probe-/,``);e.body.attitudeTrack=bA(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),eM(e,!0);let s=await Hj(o),c=Uj(s);if(!c){e.noPhysical=`model`;return}let l=await Bj.loadAsync($t(`/v1/models/${o}/${c}.glb`,`models`));if((e.modelLoadEpoch??0)!==r||!e.mesh){CM(l.scene);return}let u=s.frame_map?zS(s.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=nM(l.scene,u),f=s.model_anchor?new J(...s.model_anchor):null;if(!rM(d,f&&u?f.applyQuaternion(u):f)){CM(l.scene),e.noPhysical=`model`;return}SM(d),t.add(d),d.visible=!e.isCrashed,e.model=d,e.modelName=o,eM(e,!1);let p=s.exports[c]?.scale_meters;if(p){let t=p/2e3;e.body.data.radiusKm=t*(s.body_span_ratio??1),e.radiusScene=Q(xn(e.body.data)),e.modelUnitOverride=s.body_span_ratio?Q(t):void 0}let m=Gj(s,c);n?.credits.registerModel({bodyId:e.body.data.id,source:m.url,organisation:m.name,license:m.license})}finally{e.model||eM(e,!1)}}async function Qj(e,t){if(!uw().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await nS(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=rj(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&&ij(e.body,r.global.orientation,r.global.nut_prec,t);let o=Hj(i),s=await Bj.loadAsync($t(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){CM(s.scene);return}let c;try{c=await o}catch(e){CM(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){CM(s.scene);return}let l=s.scene;if(!rM(l)){CM(s.scene);return}l.userData.radialIndex=Dj(l);let u=RA(ej(e.body.data));e.photometry??=WA(e.body.data.lunarWeightScale),JA(u,e.body.data.id,e.photometry),e.planetshine=jT(u,e.planetshine??void 0),zA(l,u);let d=e.mesh?e.mesh.material.map:null;d&&BA(l,d,ej(e.body.data),e.body.data.color),SM(l),Yj(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,CA(e,`missing`,null))),Jj(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let f=Wj(c),p=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:f.url,organisation:f.name,license:f.license,provenance:p?.provenance,technique:p?.technique,archive:p?.archive,archiveUrl:p?.archive_url,mission:p?.mission&&{name:p.mission.name,id:p.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function $j(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,eM(e,!1);let t=!Rj(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=(qj.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),CM(n),e.model=null,e.modelName=void 0,e.body.pointing=void 0,e.body.landedHeadings=void 0,e.body.attitudeTrack=void 0,e.body.modelBaseFrame=void 0,e.mesh&&t&&(e.mesh.visible=!0)}function eM(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 tM(e){let t=[];for(let n of e??[]){let e=n.type===`landing`?n.site?.heading_deg:void 0;e!==void 0&&t.push({jd:n.jd,deg:e})}return t.length?t:void 0}function nM(e,t){if(!t)return e;let n=new Ja;return e.quaternion.copy(t),n.add(e),n}function rM(e,t=null){e.updateMatrixWorld(!0);let n=new vo().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!1;let o=2/a;e.userData.boxCenter=i.clone().multiplyScalar(o),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=oM(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();return e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c,!0}var iM=8,aM=4096;function oM(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 Ws&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/aM)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof Ws))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:iM},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(iM-1,Math.max(0,Math.floor(t*iM)))].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 sM=4,cM=.05,lM=new J,uM=new J,dM=new J,fM=new J,pM=new Zi,mM=new J,hM=new Qd;function gM(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(fM).x;if(!(a>0))return null;let o=Math.cos(t);lM.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),uM.copy(lM).applyQuaternion(e.quaternion),dM.copy(e.position).addScaledVector(uM,sM),i.localToWorld(dM),hM.set(dM,uM.negate());let s=hM.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(pM.copy(e.quaternion).invert()),Math.max(sM-s.distance/a,cM)):null}function _M(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=Lj(n,mM.set(t[0],t[1],t[2]));return r===null?null:Sg(r*Kj(e))}function vM(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function yM(e){if(!vM(e))return;let t=e.model.position,n=Kj(e);return[t.x*n,t.y*n,t.z*n]}function bM(e){if(vM(e))return Sg(e.model.userData.maxRadius*Kj(e))}function xM(e){if(vM(e))return Sg(e.model.userData.minRadius*Kj(e))}function SM(e){e.traverse(e=>{e instanceof Ws&&(e.castShadow=!0,e.receiveShadow=!0)})}function CM(e){e.traverse(e=>{if(!(e instanceof Ws))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 ha&&t.dispose();e.dispose()}})}var wM=3;function TM(e,t,n=wM){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 EM(e,t){if(e)return hn(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var DM=Math.PI/180,OM=.9,kM=24,AM=.2,jM=100,MM=16,NM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function PM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await nS(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await WT(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!NM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:jM;return(t.diameterM>0?t.diameterM:jM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await LM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=Kj(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new Ja,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 yO(e,e.body.data.id,r.global.displacement,xn(e.body.data),a.map(e=>({latRad:e.lat*DM,lonRad:e.lon*DM}))),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:jM;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),KT(o,t),n&&TM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=iO(r.lat*DM,r.lon*DM),m=c[e],g=new RT(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 ${jM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var FM=8,IM=new J;async function LM(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%FM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*DM,s=t[o].lon*DM,c=gM(e,n,s,IM);if(c!==null)r[o]=c;else{let[e,t,i]=iO(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),IM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=IM.x,i[o*3+1]=IM.y,i[o*3+2]=IM.z}return{radii:r,normals:i}}function RM(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 zM(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 BM=new J,VM=new J,HM=new J,UM=new J,WM=new J,GM=new Zi,KM=new J,qM=.12;function JM(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/(xn(e.body.data)*1e3),m=AM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<kM)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(BM),r.getWorldPosition(VM);let h=VM.x-BM.x,g=VM.y-BM.y,_=VM.z-BM.z;UM.copy(BM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(OM*(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(GM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<kM||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(HM);let v=HM.x-BM.x,y=HM.y-BM.y,w=HM.z-BM.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){KM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(GM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(KM.x*n+KM.y*r+KM.z*i<qM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}WM.copy(HM).project(r);let T=(WM.x-UM.x)*x,E=(WM.y-UM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(WM.x*.5+.5)*i,l[e]=(-WM.y*.5+.5)*a}}var YM=[];function XM(e){let t=YM[e];return t||(t={left:0,right:0,y:0,h:0},YM[e]=t),t}function ZM(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=YM[e],n=(t.h+MM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=XM(r);return f.left=u,f.right=d,f.y=o,f.h=MM,r+1}function QM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=qO,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=XM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=ZM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=ZM(e,i,!1,r))}var $M=1.002;function eN(e,t){let n=e?.referenceAltitudeKm??0;return n>0?1+n/t:$M}var tN=1e3;function nN(e,t,n){return $t(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function rN(e,t,n){try{let r=await fetch(nN(e,t,n));if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=new ha(await createImageBitmap(i,{imageOrientation:`flipY`}));return a.flipY=!1,a.colorSpace=ii,a.anisotropy=16,a.needsUpdate=!0,a}catch(r){return console.warn(`Failed to load ${t} cloud texture for ${e} @ ${n}:`,r),null}}function iN(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 aN=10800*1e3;function oN(e,t,n){return n?n.some(([t,n])=>e>=iN(t)&&e<iN(n)+aN):e>=iN(t[0])&&e<=iN(t[t.length-1])}function sN(e,t,n){if(t.length===0)return;let r=Mg(e).getTime(),i=iN(t[0]);if(oN(r,t,n)){let e=0,n=t.length;for(;e<n;){let i=e+n>>>1;iN(t[i])<=r?e=i+1:n=i}return t[Math.max(0,e-1)]}let a=Mg(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 cN(e,t,n,r,i=$M){let a=await rN(n.id,`low`,r);if(!a)return null;let o=lN(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 lN(e,t,n,r=$M){let i=new Ou({map:n,transparent:!0,depthWrite:!1}),a=new Ws(new _u(t,64,64),i);return a.scale.setScalar(r),a.renderOrder=1,e.add(a),{mesh:a,material:i,id:``,availableTiers:[],availableFrames:[]}}async function uN(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<tN)){e.lastSwapMs=r,e.textureLoading=!0;try{let r=await rN(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 dN(e){e.mesh.geometry.dispose(),e.material.map?.dispose(),e.material.dispose(),e.mesh.parent?.remove(e.mesh)}var fN=.2,pN=-.125,mN=.1,hN=Symbol(`night-lights-hook`);async function gN(e,t,n,r){let i=$t(`/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=ii,_N(e,a),a}function _N(e,t){t.anisotropy=16,e.emissiveMap=t,e.emissive=new X(16777215);let n=e;if(!n[hN]){n[hN]=!0;let t=Uw();$S(e,`nightLights`,e=>{e.uniforms.uSunDir=t.uSunDir,e.uniforms.uNightIntensity={value:fN},e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5563
5563
  varying vec3 vNightOutwardWorld;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
5564
5564
  vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5565
5565
  uniform float uNightIntensity;
@@ -5568,9 +5568,9 @@ vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragment
5568
5568
  // Modulate by unlit-side factor: 1 night, 0 day.
5569
5569
  vec3 nightOutward = normalize(vNightOutwardWorld);
5570
5570
  float nightDot = dot(nightOutward, uSunDir);
5571
- float nightFactor = 1.0 - smoothstep(${tN.toFixed(2)}, ${nN.toFixed(2)}, nightDot);
5571
+ float nightFactor = 1.0 - smoothstep(${pN.toFixed(2)}, ${mN.toFixed(2)}, nightDot);
5572
5572
  totalEmissiveRadiance *= nightFactor * uNightIntensity;
5573
- #endif`)})}e.needsUpdate=!0}function oN(e){e.emissiveMap&&(e.emissiveMap.dispose(),e.emissiveMap=null,e.emissive.setRGB(0,0,0),e.needsUpdate=!0)}var sN=.55,cN=Symbol(`specular-hook`);async function lN(e,t,n,r){let i=$t(`/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}a.anisotropy=16,e.roughnessMap=a;let o=e;return o[cN]||(o[cN]=!0,US(e,`specular`,e=>{e.uniforms.uOceanRoughness={value:sN},e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5573
+ #endif`)})}e.needsUpdate=!0}function vN(e){e.emissiveMap&&(e.emissiveMap.dispose(),e.emissiveMap=null,e.emissive.setRGB(0,0,0),e.needsUpdate=!0)}var yN=.55,bN=Symbol(`specular-hook`);async function xN(e,t,n,r){let i=$t(`/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}a.anisotropy=16,e.roughnessMap=a;let o=e;return o[bN]||(o[bN]=!0,$S(e,`specular`,e=>{e.uniforms.uOceanRoughness={value:yN},e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5574
5574
  uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`float roughnessFactor = roughness;
5575
5575
  #ifdef USE_ROUGHNESSMAP
5576
5576
  // Mask carries the fraction of the texel under water, so a
@@ -5579,7 +5579,7 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5579
5579
  // roughnessmap sample.
5580
5580
  vec4 texelRoughness = texture2D(roughnessMap, vRoughnessMapUv);
5581
5581
  roughnessFactor = mix(roughness, uOceanRoughness, texelRoughness.g);
5582
- #endif`)})),e.needsUpdate=!0,a}function uN(e){e.roughnessMap&&(e.roughnessMap.dispose(),e.roughnessMap=null,e.needsUpdate=!0)}var dN=6,fN=16,pN=1/Math.sqrt(Math.PI),mN={uAtmoTEnable:{value:1}};function hN(e){mN.uAtmoTEnable.value=+!!e}var gN=`
5582
+ #endif`)})),e.needsUpdate=!0,a}function SN(e){e.roughnessMap&&(e.roughnessMap.dispose(),e.roughnessMap=null,e.needsUpdate=!0)}var CN=6,wN=16,TN=1/Math.sqrt(Math.PI),EN={uAtmoTEnable:{value:1}};function DN(e){EN.uAtmoTEnable.value=+!!e}var ON=`
5583
5583
  uniform vec3 uAtmoTBetaR; // Rayleigh β, per planet radius, (R,G,B)
5584
5584
  uniform vec3 uAtmoTBetaMExt; // Mie extinction β, per planet radius
5585
5585
  uniform vec3 uAtmoTBetaA; // absorber band β, per planet radius
@@ -5629,11 +5629,11 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5629
5629
  vec3 atmoTSquash(vec3 v) {
5630
5630
  return v + (uAtmoTStretch - 1.0) * dot(v, uAtmoTSpinAxis) * uAtmoTSpinAxis;
5631
5631
  }
5632
- `,_N=`
5632
+ `,kN=`
5633
5633
  // Eclipse's uSunDir/uEclipseSelfPos are declared after this chunk's
5634
5634
  // insertion point — same value refs re-bound under own names.
5635
5635
  uniform vec3 uAtmoTSunDir;
5636
- ${gN}
5636
+ ${ON}
5637
5637
 
5638
5638
  // Column (∫density above h) of the linear-tent absorber, in radii of
5639
5639
  // surface-density-equivalent path — mirrors tentColumnAboveKm.
@@ -5683,9 +5683,9 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5683
5683
  float tFar = -b + sqrt(d);
5684
5684
  if (tFar <= 0.0) return vec3(1.0);
5685
5685
  // Fragment sits inside the shell → the segment starts at the fragment.
5686
- float dt = tFar / ${dN.toFixed(1)};
5686
+ float dt = tFar / ${CN.toFixed(1)};
5687
5687
  vec3 od = vec3(0.0);
5688
- for (int i = 0; i < ${dN}; i++) {
5688
+ for (int i = 0; i < ${CN}; i++) {
5689
5689
  float h = max(length(p + sd * (dt * (float(i) + 0.5))) - 1.0, 0.0);
5690
5690
  od += vec3(
5691
5691
  exp(-h / uAtmoTRayleighH),
@@ -5735,7 +5735,7 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5735
5735
  // Sun height and airmass over a column of scale height h, in radii.
5736
5736
  vec2 atmoTSkySun(float s, float h) {
5737
5737
  float delta = sqrt(2.0 * h);
5738
- float muH = ${pN.toFixed(7)} * delta;
5738
+ float muH = ${TN.toFixed(7)} * delta;
5739
5739
  float day = sqrt(s * s + muH * muH);
5740
5740
  float night = muH * exp(-(s * s) / (delta * delta));
5741
5741
  return s > 0.0 ? vec2(day, 1.0 / day) : vec2(night, 1.0 / muH);
@@ -5768,8 +5768,8 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5768
5768
  vec3 atmoSkyDirect() {
5769
5769
  return uAtmoTEnable < 0.5 ? vec3(1.0) : uAtmoTSkyDirect;
5770
5770
  }
5771
- `,vN=`
5772
- ${gN}
5771
+ `,AN=`
5772
+ ${ON}
5773
5773
 
5774
5774
  vec3 atmoViewTint(vec3 worldPos) {
5775
5775
  if (uAtmoTEnable < 0.5) return vec3(1.0);
@@ -5787,9 +5787,9 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5787
5787
  float t1 = -b + s;
5788
5788
  if (t1 <= 0.0) return vec3(1.0);
5789
5789
  float t0 = max(-b - s, 0.0);
5790
- float dt = (t1 - t0) / ${dN.toFixed(1)};
5790
+ float dt = (t1 - t0) / ${CN.toFixed(1)};
5791
5791
  vec3 od = vec3(0.0);
5792
- for (int i = 0; i < ${dN}; i++) {
5792
+ for (int i = 0; i < ${CN}; i++) {
5793
5793
  float h = max(length(p + rd * (t0 + dt * (float(i) + 0.5))) - 1.0, 0.0);
5794
5794
  od += vec3(
5795
5795
  exp(-h / uAtmoTRayleighH),
@@ -5802,7 +5802,7 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5802
5802
  float lum = dot(t, vec3(0.2126, 0.7152, 0.0722));
5803
5803
  return t / max(lum, 1e-4);
5804
5804
  }
5805
- `;function yN(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:xN()},uAtmoTDeepN:{value:1},uAtmoTDeepBaseR:{value:1},uAtmoTDeepSpanR:{value:0},uAtmoTDeepKmPerRadius:{value:1},uAtmoTDeepIrradiance:{value:0},uAtmoTDeepBlend:{value:0},uAtmoTBetaMScat:{value:new J},uAtmoTMieG:{value:new J},uAtmoTSkyDirect:{value:new J(1,1,1)},uAtmoTSkyGain:{value:new J}}}var bN=null;function xN(){return bN||(bN=new ic(new Uint8Array([255,255,255,255]),1,1),bN.needsUpdate=!0),bN}function SN(e,t,n,r){let i=r;r=eT(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?Qw(u):xN(),e.uAtmoTDeepN.value=u?.n??1,e.uAtmoTDeepBaseR.value=i/r,e.uAtmoTDeepSpanR.value=u?u.topKm/r:0,e.uAtmoTDeepKmPerRadius.value=r,e.uAtmoTBetaMScat.value.set(a(s[0]),a(s[1]),a(s[2])),e.uAtmoTMieG.value.fromArray(TN(t.miePhase)),ON(t,Math.max(e.uAtmoTMeshR.value-1,0)*r,r,e.uAtmoTSkyDirect.value,e.uAtmoTSkyGain.value)}function CN(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)}var wN=new WeakMap;function TN(e){let t=wN.get(e);if(t)return t;let n=e.length/3,r=[0,0,0];for(let t=0;t<3;t++){let i=0,a=0;for(let r=0;r<n-1;r++){let o=Math.PI*(r/(n-1))**2,s=Math.PI*((r+1)/(n-1))**2,c=e[t*n+r]*Math.sin(o),l=e[t*n+r+1]*Math.sin(s);i+=.5*(c+l)*(s-o),a+=.5*(c*Math.cos(o)+l*Math.cos(s))*(s-o)}r[t]=a/i}return wN.set(e,r),r}function EN(e,t){let n=Math.sqrt(2*t),r=pN*n;if(e>0){let t=Math.hypot(e,r);return[t,1/t]}return[r*Math.exp(-(e*e)/(n*n)),1/r]}function DN(e,t,n,r){let i=e.rayleighScaleHeightKm,a=e.mieScaleHeightKm,[o,s]=EN(r,i/n),[c,l]=EN(r,a/n),u=i*Math.exp(-t/i),d=a*Math.exp(-t/a),f=CN(t,e.absorptionCenterKm,e.absorptionWidthKm),p=TN(e.miePhase),m=[0,0,0];for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*u,r=Math.exp(-(e.mieAbsorptionPerKm[t]*d*l+e.absorptionPerKm[t]*f*s)),i=Math.log(1-p[t]),a=i*(1.459+i*(.1595+i*.4129)),h=i*(.0783+i*(-.3824-i*.5874)),g=1-.5*Math.exp((a+h*c)*c);m[t]=(.5*o*(1-Math.exp(-.95*s*n))+c*g*Math.exp(-1.5*s*n)*(1-Math.exp(-l*d*e.mieScatterPerKm[t])))*r}return m}function ON(e,t,n,r,i){if(e.deepColumn||!e.groundAlbedo){r.set(1,1,1),i.set(0,0,0);return}let a=DN(e,t,n,1),o=e.rayleighScaleHeightKm*Math.exp(-t/e.rayleighScaleHeightKm),s=e.mieScaleHeightKm*Math.exp(-t/e.mieScaleHeightKm),c=CN(t,e.absorptionCenterKm,e.absorptionWidthKm);for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*o+(e.mieScatterPerKm[t]+e.mieAbsorptionPerKm[t])*s+e.absorptionPerKm[t]*c,l=Math.exp(-n),u=Math.exp(-(1-e.bakedCompensation)*n);r.setComponent(t,l/(l+a[t])),i.setComponent(t,u/(l+a[t]))}}function kN(){return{...yN({value:0}),uAtmoTCenter:{value:new J}}}function AN(e,t,n,r,i,a,o=1){SN(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 jN(e,t,n,r,i,a,o=1){let s={...yN(mN.uAtmoTEnable),uAtmoTSunDir:Nw().uSunDir,uAtmoTCenter:i.uEclipseSelfPos};return s.uAtmoTMeshR.value=o*r/eT(t,r),a&&(s.uAtmoTSpinAxis=a.material.uniforms.uSpinAxis,s.uAtmoTStretch=a.material.uniforms.uStretch),SN(s,t,n,r),US(e,`sunTint`,e=>{Object.assign(e.uniforms,s),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${_N}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
5805
+ `;function jN(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:NN()},uAtmoTDeepN:{value:1},uAtmoTDeepBaseR:{value:1},uAtmoTDeepSpanR:{value:0},uAtmoTDeepKmPerRadius:{value:1},uAtmoTDeepIrradiance:{value:0},uAtmoTDeepBlend:{value:0},uAtmoTBetaMScat:{value:new J},uAtmoTMieG:{value:new J},uAtmoTSkyDirect:{value:new J(1,1,1)},uAtmoTSkyGain:{value:new J}}}var MN=null;function NN(){return MN||(MN=new ic(new Uint8Array([255,255,255,255]),1,1),MN.needsUpdate=!0),MN}function PN(e,t,n,r){let i=r;r=uT(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?cT(u):NN(),e.uAtmoTDeepN.value=u?.n??1,e.uAtmoTDeepBaseR.value=i/r,e.uAtmoTDeepSpanR.value=u?u.topKm/r:0,e.uAtmoTDeepKmPerRadius.value=r,e.uAtmoTBetaMScat.value.set(a(s[0]),a(s[1]),a(s[2])),e.uAtmoTMieG.value.fromArray(LN(t.miePhase)),BN(t,Math.max(e.uAtmoTMeshR.value-1,0)*r,r,e.uAtmoTSkyDirect.value,e.uAtmoTSkyGain.value)}function FN(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)}var IN=new WeakMap;function LN(e){let t=IN.get(e);if(t)return t;let n=e.length/3,r=[0,0,0];for(let t=0;t<3;t++){let i=0,a=0;for(let r=0;r<n-1;r++){let o=Math.PI*(r/(n-1))**2,s=Math.PI*((r+1)/(n-1))**2,c=e[t*n+r]*Math.sin(o),l=e[t*n+r+1]*Math.sin(s);i+=.5*(c+l)*(s-o),a+=.5*(c*Math.cos(o)+l*Math.cos(s))*(s-o)}r[t]=a/i}return IN.set(e,r),r}function RN(e,t){let n=Math.sqrt(2*t),r=TN*n;if(e>0){let t=Math.hypot(e,r);return[t,1/t]}return[r*Math.exp(-(e*e)/(n*n)),1/r]}function zN(e,t,n,r){let i=e.rayleighScaleHeightKm,a=e.mieScaleHeightKm,[o,s]=RN(r,i/n),[c,l]=RN(r,a/n),u=i*Math.exp(-t/i),d=a*Math.exp(-t/a),f=FN(t,e.absorptionCenterKm,e.absorptionWidthKm),p=LN(e.miePhase),m=[0,0,0];for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*u,r=Math.exp(-(e.mieAbsorptionPerKm[t]*d*l+e.absorptionPerKm[t]*f*s)),i=Math.log(1-p[t]),a=i*(1.459+i*(.1595+i*.4129)),h=i*(.0783+i*(-.3824-i*.5874)),g=1-.5*Math.exp((a+h*c)*c);m[t]=(.5*o*(1-Math.exp(-.95*s*n))+c*g*Math.exp(-1.5*s*n)*(1-Math.exp(-l*d*e.mieScatterPerKm[t])))*r}return m}function BN(e,t,n,r,i){if(e.deepColumn||!e.groundAlbedo){r.set(1,1,1),i.set(0,0,0);return}let a=zN(e,t,n,1),o=e.rayleighScaleHeightKm*Math.exp(-t/e.rayleighScaleHeightKm),s=e.mieScaleHeightKm*Math.exp(-t/e.mieScaleHeightKm),c=FN(t,e.absorptionCenterKm,e.absorptionWidthKm);for(let t=0;t<3;t++){let n=e.rayleighScatterPerKm[t]*o+(e.mieScatterPerKm[t]+e.mieAbsorptionPerKm[t])*s+e.absorptionPerKm[t]*c,l=Math.exp(-n),u=Math.exp(-(1-e.bakedCompensation)*n);r.setComponent(t,l/(l+a[t])),i.setComponent(t,u/(l+a[t]))}}function VN(){return{...jN({value:0}),uAtmoTCenter:{value:new J}}}function HN(e,t,n,r,i,a,o=1){PN(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 UN(e,t,n,r,i,a,o=1){let s={...jN(EN.uAtmoTEnable),uAtmoTSunDir:Uw().uSunDir,uAtmoTCenter:i.uEclipseSelfPos};return s.uAtmoTMeshR.value=o*r/uT(t,r),a&&(s.uAtmoTSpinAxis=a.material.uniforms.uSpinAxis,s.uAtmoTStretch=a.material.uniforms.uStretch),PN(s,t,n,r),$S(e,`sunTint`,e=>{Object.assign(e.uniforms,s),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${kN}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
5806
5806
  vec3 atmoSunDir = uAtmoTSunDir;
5807
5807
  vec3 atmoSunLight = vec3(0.0);
5808
5808
  #if NUM_DIR_LIGHTS > 0
@@ -5829,7 +5829,7 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5829
5829
  #endif
5830
5830
  if (atmoSky.g > 0.0) atmoSky *= eclipseFactorAt(vEclipseWorldPos, uEclipseSelfPos, uSunDir);
5831
5831
  reflectedLight.indirectDiffuse += atmoSky * BRDF_Lambert(diffuseColor.rgb);
5832
- #include <aomap_fragment>`)}),s}var MN=new J,NN=new J;function PN(e,t,n){return!t||n===1?e:e.addScaledVector(t,(n-1)*e.dot(t))}function FN(e,t,n,r,i,a,o,s=1){let c=i;i=eT(e,c),r=r*i/c;let l=PN(MN.copy(t).divideScalar(r),o,s),u=PN(NN.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)/fN,x=b*i/d,S=0,C=0,w=0;for(let t=0;t<fN;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 IN={specular:{meta:e=>e.specular,loaded:e=>e.specularMap!==null,async load(e,t,n,r){let i=await lN(n.material,t,`low`,r.textureLoader);if(i){if(e.specularMap){i.dispose();return}e.specularMap=i}},unload(e,t){t&&(uN(t.material),e.specularMap=null)}},night:{meta:e=>e.night,loaded:e=>e.emissiveMap!==null,async load(e,t,n,r){let i=await iN(n.material,t,`low`,r.textureLoader);if(i){if(e.emissiveMap){i.dispose();return}e.emissiveMap=i}},unload(e,t){t&&(oN(t.material),e.emissiveMap=null)}},topography:{meta:e=>e.displacement,loaded:e=>e.displacementMap!==null,enabled(e){return GC()?(console.info(`Low-end device: skipping DEM relief for ${e}`),!1):ew().showDisplacement},async load(e,t,n,r){let i=n.material,a=await AD(i,t,`low`,r.textureLoader,e.radiusScene);if(a){if(e.displacementMap){a.dispose();return}if(e.displacementMap=a,e.displacementMeta=t,e.displacementTier=`low`,!ew().showSelfShadow){e.selfShadow=null;return}e.reliefTiles=mD(i,t.tiles,xn(e.body.data)),e.selfShadow=OD(i,a,Q(t.scale_km),void 0,e.reliefTiles)}},unload(e,t){t&&(GD(t.material),e.displacementMap=null,e.displacementTier=void 0,kD(e.selfShadow),e.selfShadow=null,gD(e),e.reliefTiles=void 0)}},clouds:{meta:e=>e.clouds,loaded:e=>e.clouds!==null,async load(e,t,n,r){let i=YM(r.currentJd,t.frames,t.coverage);if(!i)return;let a=HM(e.atmosphere?.params,e.atmosphere?.surfaceRadiusKm??1),o=a===1.002?1:a,s=await XM(n,e.radiusScene,t,i,a);if(s){if(e.clouds){$M(s);return}e.eclipseShadow&&(Gw(s.material,e.eclipseShadow),e.atmosphere&&(e.sunTint??=[]).push(jN(s.material,e.atmosphere.params,e.radiusScene,e.atmosphere.surfaceRadiusKm,e.eclipseShadow,e.atmosphere,VM*o))),e.clouds=s}},unload(e){e.clouds&&=($M(e.clouds),null)}}},LN=Object.keys(IN);function RN(e,t,n,r,i,a){let o=IN[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 zN(e,t,n,r,i){let a=[];for(let o of LN){let s=RN(o,e,t,n,r,i);s&&a.push(s)}return a}function BN(e,t){let n=IN[e];n.loaded(t)&&n.unload(t,t.mesh)}function VN(e){for(let t of LN)BN(t,e)}function HN(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}var UN=`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`,WN={flying:UN,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 GN(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,WN[t])}function KN(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 qN(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:KN(i,t,n,r),pA(e)}function JN(e){let t=e.data.objectType;return Cn(t)||t===G.STAR||Sn(t)||t===G.COMET||t===G.BARYCENTER||t===G.LAGRANGE_POINT?`major`:t===G.SPACECRAFT?`spacecraft`:t===G.DEBRIS?`debris`:`none`}function YN(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`:UN),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(),HN(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&KN(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)`:``,CO(l),document.body.style.cursor=``,o?.(!1)});let p=new OT(c);return p.visible=!1,p}var XN=`
5832
+ #include <aomap_fragment>`)}),s}var WN=new J,GN=new J;function KN(e,t,n){return!t||n===1?e:e.addScaledVector(t,(n-1)*e.dot(t))}function qN(e,t,n,r,i,a,o,s=1){let c=i;i=uT(e,c),r=r*i/c;let l=KN(WN.copy(t).divideScalar(r),o,s),u=KN(GN.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)/wN,x=b*i/d,S=0,C=0,w=0;for(let t=0;t<wN;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 JN={specular:{meta:e=>e.specular,loaded:e=>e.specularMap!==null,async load(e,t,n,r){let i=await xN(n.material,t,`low`,r.textureLoader);if(i){if(e.specularMap){i.dispose();return}e.specularMap=i}},unload(e,t){t&&(SN(t.material),e.specularMap=null)}},night:{meta:e=>e.night,loaded:e=>e.emissiveMap!==null,async load(e,t,n,r){let i=await gN(n.material,t,`low`,r.textureLoader);if(i){if(e.emissiveMap){i.dispose();return}e.emissiveMap=i}},unload(e,t){t&&(vN(t.material),e.emissiveMap=null)}},topography:{meta:e=>e.displacement,loaded:e=>e.displacementMap!==null,enabled(e){return tw()?(console.info(`Low-end device: skipping DEM relief for ${e}`),!1):uw().showDisplacement},async load(e,t,n,r){let i=n.material,a=await VD(i,t,`low`,r.textureLoader,e.radiusScene);if(a){if(e.displacementMap){a.dispose();return}if(e.displacementMap=a,e.displacementMeta=t,e.displacementTier=`low`,!uw().showSelfShadow){e.selfShadow=null;return}e.reliefTiles=TD(i,t.tiles,xn(e.body.data)),e.selfShadow=zD(i,a,Q(t.scale_km),void 0,e.reliefTiles)}},unload(e,t){t&&(nO(t.material),e.displacementMap=null,e.displacementTier=void 0,BD(e.selfShadow),e.selfShadow=null,DD(e),e.reliefTiles=void 0)}},clouds:{meta:e=>e.clouds,loaded:e=>e.clouds!==null,async load(e,t,n,r){let i=sN(r.currentJd,t.frames,t.coverage);if(!i)return;let a=eN(e.atmosphere?.params,e.atmosphere?.surfaceRadiusKm??1),o=a===1.002?1:a,s=await cN(n,e.radiusScene,t,i,a);if(s){if(e.clouds){dN(s);return}e.eclipseShadow&&(tT(s.material,e.eclipseShadow),e.atmosphere&&(e.sunTint??=[]).push(UN(s.material,e.atmosphere.params,e.radiusScene,e.atmosphere.surfaceRadiusKm,e.eclipseShadow,e.atmosphere,$M*o))),e.clouds=s}},unload(e){e.clouds&&=(dN(e.clouds),null)}}},YN=Object.keys(JN);function XN(e,t,n,r,i,a){let o=JN[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 ZN(e,t,n,r,i){let a=[];for(let o of YN){let s=XN(o,e,t,n,r,i);s&&a.push(s)}return a}function QN(e,t){let n=JN[e];n.loaded(t)&&n.unload(t,t.mesh)}function $N(e){for(let t of YN)QN(t,e)}function eP(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}var tP=`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`,nP={flying:tP,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 rP(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,nP[t])}function iP(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 aP(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:iP(i,t,n,r),wA(e)}function oP(e){let t=e.data.objectType;return Cn(t)||t===G.STAR||Sn(t)||t===G.COMET||t===G.BARYCENTER||t===G.LAGRANGE_POINT?`major`:t===G.SPACECRAFT?`spacecraft`:t===G.DEBRIS?`debris`:`none`}function sP(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`:tP),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(),eP(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&iP(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)`:``,PO(l),document.body.style.cursor=``,o?.(!1)});let p=new RT(c);return p.visible=!1,p}var cP=`
5833
5833
  varying vec3 vTileOff;
5834
5834
  uniform sampler2DArray uTileMap;
5835
5835
  uniform sampler2DArray uTileMask;
@@ -5838,7 +5838,7 @@ uniform vec4 uTileWindow[ 7 ];
5838
5838
  uniform vec2 uTileHome[ 7 ];
5839
5839
  uniform vec3 uTileAnchor;
5840
5840
  uniform vec2 uTileFilter;
5841
- ${jE}
5841
+ ${VE}
5842
5842
  vec3 tileColour( vec3 below ) {
5843
5843
  if ( uTileWindow[ 0 ].w < 0.5 ) return below;
5844
5844
  mat3x2 map;
@@ -5869,17 +5869,17 @@ vec3 tileColour( vec3 below ) {
5869
5869
  }
5870
5870
  return colour + ( 1.0 - covered ) * below;
5871
5871
  }
5872
- `,ZN=`
5872
+ `,lP=`
5873
5873
  #ifdef USE_MAP
5874
5874
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
5875
5875
  sampledDiffuseColor.rgb = tileColour( sampledDiffuseColor.rgb );
5876
5876
  diffuseColor *= sampledDiffuseColor;
5877
5877
  #endif
5878
- `;async function QN(e,t){let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`tile ${n.status}`);let r=await createImageBitmap(await n.blob(),{imageOrientation:`flipY`,premultiplyAlpha:`none`,colorSpaceConversion:`none`}),i=new ha(r);return i.colorSpace=ii,i.flipY=!1,i.generateMipmaps=!1,{texture:i,release(){i.dispose(),r.close()}}}var $N={format:ar,type:Wn,colorSpace:ii,load:QN};function eP(e){let t=ME($N);return US(e,`surfaceTiles`,e=>{Object.assign(e.uniforms,{uTileMap:t.uniforms.map,uTileMask:t.uniforms.mask,uTileGrid:t.uniforms.grid,uTileWindow:t.uniforms.window,uTileHome:t.uniforms.home,uTileAnchor:t.uniforms.anchor,uTileFilter:t.uniforms.filter}),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5878
+ `;async function uP(e,t){let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`tile ${n.status}`);let r=await createImageBitmap(await n.blob(),{imageOrientation:`flipY`,premultiplyAlpha:`none`,colorSpaceConversion:`none`}),i=new ha(r);return i.colorSpace=ii,i.flipY=!1,i.generateMipmaps=!1,{texture:i,release(){i.dispose(),r.close()}}}var dP={format:ar,type:Wn,colorSpace:ii,load:uP};function fP(e){let t=HE(dP);return $S(e,`surfaceTiles`,e=>{Object.assign(e.uniforms,{uTileMap:t.uniforms.map,uTileMask:t.uniforms.mask,uTileGrid:t.uniforms.grid,uTileWindow:t.uniforms.window,uTileHome:t.uniforms.home,uTileAnchor:t.uniforms.anchor,uTileFilter:t.uniforms.filter}),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5879
5879
  varying vec3 vTileOff;
5880
5880
  uniform vec3 uTileAnchor;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
5881
- vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`#include <map_pars_fragment>`,`#include <map_pars_fragment>\n${XN}`).replace(`#include <map_fragment>`,ZN)}),{material:e,chain:t}}function tP(e){e.tileOverlay&&GE(e.tileOverlay.chain)}function nP(){return qt()!==``&&yE()>0}function rP(e){return!!e&&e.max_level>=3&&nP()&&o(e.distribution)}function iP(e){return rP(e.surfaceTiles)&&!e.model&&!e.tileOverlay?.chain.dead}function aP(e,t,n,r,i,a){let o=e.surfaceTiles,s=e.mesh,c=s?.material,l,u=-1;if(o&&s&&c?.map&&i&&iP(e)){l=XE(s,t);let n=ZE(e.tileOverlay?.chain,o,l);u=iE(e.radiusScene,e.cachedDist,r,n)}if(!o||!l||!c||u<3){e.tileOverlay&&KE(e.tileOverlay.chain,performance.now());return}e.tileOverlay&&e.tileOverlay.material!==c&&(tP(e),e.tileOverlay=void 0),$E((e.tileOverlay??=eP(c)).chain,o,QE(o,yE()),u,l,e.radiusScene,o.frames?e.textureFrame:void 0,n,a)}var oP=[`low`,`medium`,`high`];function sP(e){return e===void 0?-1:oP.indexOf(e)}function cP(e,t){for(let n=e;n>=0;n--){let e=oP[n];if(t.includes(e))return e}}function lP(e,t,n){return $t(n===void 0?`/v1/textures/${e}/${t}.webp`:`/v1/textures/${e}/${t}_${String(n).padStart(2,`0`)}.webp`,`textures`)}function uP(e,t){if(!(!t||t<2))return t===12?Mg(e).getUTCMonth()+1:1}async function dP(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(lP(i,t,n),e,void 0,a)});if(!e.mesh||e.textureLoadGen!==a){o.dispose();return}let s=e.mesh.material,c=e.body.data;AA(s,o,c.color),e.model&&kA(e.model,o,UA(c),c.color),e.textureTier=t,e.textureFrame=n}catch(e){console.warn(`Failed to load ${t} texture for ${i}:`,e)}finally{e.textureLoading=!1}}function fP(e){if(!e.mesh||!e.photometry||Dj(e.body)||e.appearance?.surfaceOwned)return;let t=e.mesh.material;t.map||(UA(e.body.data,t.color),e.model&&kA(e.model,null,t.color))}function pP(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.body.drawnRadii={a:n,b:r,c:i},e.atmosphere){let t=Math.max(n,r);pT(e.atmosphere,t,i,Q(t));for(let n of e.sunTint??[])SN(n,e.atmosphere.params,Q(t),t)}e.radiiApplied=!0}async function mP(e,t,n,r,i,a){if(e.textureTier||e.textureLoading)return;let o=await nS(e.body.data.id,!1);if(a?.bodies.orientationRead.add(e.body.data.id),!o.global)return;o.global.orientation&&!e.body.orientation&&qA(e.body,o.global.orientation,o.global.nut_prec,a),o.global.radii&&e.radiusScene>0&&!e.radiiApplied&&!o.global.displacement?.absolute_radius&&pP(e,o.global.radii),o.global.rings?.length&&await Promise.allSettled(ET(e.body.data.id,e.body.data.id,o.global.rings,o.global.radii,e,r,i,a));let c=e.body.data;if(c.color=o.global.sbdb?.color??o.global.color,c.geometricAlbedo=o.global.sbdb?.geometric_albedo??o.global.geometric_albedo,c.lunarWeightScale=o.global.lunar_weight_scale,e.photometry&&(e.photometry.uLunarWeightScale.value=c.lunarWeightScale??1),fP(e),!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 RN(`topography`,l,l,o.global,e,{textureLoader:t,currentJd:n,ctx:a}),!(e.textureTier||e.textureLoading)&&ew().showSurfaceTexture&&u&&(e.textureBundleId=u.id===l?void 0:u.id,e.surfaceTiles=u.tiles,e.availableTiers??=u.tiers??[...oP],e.availableFrames=u.frames,await dP(e,`low`,uP(n,e.availableFrames),t))}async function hP(e){if(!e.label)return;let t=e.body.data;if(t.name)return;let n=await nS(t.id,t.hasLocalized),r=n.localized?.name??n.global?.name;r&&(t.name??=r,qN(e,r,JN(e.body),t.objectType===G.STAR||t.objectType===G.PLANET))}function gP(e){if(!e.mesh)return;e.textureLoadGen=(e.textureLoadGen??0)+1;let t=e.mesh.material;BN(`topography`,e),tP(e),t.map&&(t.map.dispose(),t.map=null,UA(e.body.data,t.color),t.needsUpdate=!0,e.model&&kA(e.model,null,t.color),e.textureTier=void 0)}async function _P(e,t,n,r){e.textureLoading||e.availableTiers?.includes(t)&&(e.textureTier===t&&e.textureFrame===n||await dP(e,t,n,r))}var vP=new Map;function yP(e){let t=vP.get(e);return t||(t=bP(e).finally(()=>vP.delete(e)),vP.set(e,t)),t}async function bP(e){let t=await Pv(`${Kt()}/v1/systems/${e}.json`);if(t.status===404)return null;if(!t.ok)throw Error(`systems/${e}.json: ${t.status}`);return t.json()}async function xP(e,t){let n=e.data.id,r=()=>!!e.orientation||t.bodies.orientationRead.has(n);if(r())return;let i=t.visibility.resolveSystemId(e),a=i?t.getBody(i):void 0,o=a?.data.objectType===G.BARYCENTER?a.data.id:null,s=o?(await yP(o))?.[n]:void 0,c=s?.orientation?null:await nS(n,!1);r()||(s?.orientation?qA(e,s.orientation,s.nut_prec,t,o):c?.global?.orientation&&qA(e,c.global.orientation,c.global.nut_prec,t),t.bodies.orientationRead.add(n),e.orientation&&t.bodies.orientationVersion++)}async function SP(e,t,n){let r=n.probeStore?.landingBodyAt(e,t),i=r?n.getBody(r):void 0;i&&await xP(i,n)}async function CP(e,t,n,r,i,a,o){let c=await yP(e).catch(()=>null);if(!c)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)continue;o?.bodies.orientationRead.add(u);let p=f.body.data;if(p.color??=d.color,p.geometricAlbedo??=d.geometric_albedo,p.lunarWeightScale??=d.lunar_weight_scale,f.photometry&&(f.photometry.uLunarWeightScale.value=p.lunarWeightScale??1),fP(f),d.orientation&&(qA(f.body,d.orientation,d.nut_prec,o,e),CS(f.mesh,d.orientation,i,f.body.nutPrec)),d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&pP(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,f.surfaceTiles=c.tiles,!f.textureTier)){let e=uP(i,f.availableFrames);l.push(_P(f,`low`,e,r))}l.push(...zN(u,e,d,f,{textureLoader:r,currentJd:i,ctx:o})),d.rings?.length&&l.push(...ET(u,e,d.rings,d.radii,f,n,a,o))}await Promise.allSettled(l)}function wP(e,t,n,r){for(let n of t.values())if(r.visibility.isBodyInSystem(n.body,e)){if(gP(n),VN(n),n.terrainWindow&&n.mesh){n.terrainWindow=null;let e=Q(xn(n.body.data)),t=n.mesh.geometry;n.mesh.geometry=new _u(e,24,24),t.dispose(),n.currentSegments=24}for(let e of n.rings)e.planetShadow?.disable(),e.ringshine?.disable(),e.mesh.removeFromParent(),HC(e);n.rings=[],DM(n)}}var TP=2e3,EP=3;function DP(e,t){return`${e.zone}:${e.zoom??``}:${t}`}var OP=class{zones=[];latestDate;failureStreak=0;staleNotified=!1;staleCheckRunning=!1;retries=new Ex(()=>this.wakes++);wakes=0;wakeTimer;constructor(e,t,n,r){this.ctx=e,this.loader=n,this.latestDate=r;let i=jg(r),a=ew().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 sx(o)){if(s.shape===`chunked`||s.shape===`parted`)continue;let o=a>0?Math.min(s.parts,a):s.parts;if(tx(s)){let i={kind:`time`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentTime:``,inFlight:null,lastLoadStartMs:-1/0,cap:a};this.zones.push(i),this.prefetchTimeNeighbors(i,r)}else if(nx(s)){let r={kind:`chunk`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentIdx:ix(s,i),inFlight:null,preloads:new Map};this.zones.push(r),this.preloadChunkNeighbors(r)}}}}recordSuccess(e){this.retries.clear(e),this.failureStreak=0}recordFailure(e){this.retries.fail(e),this.failureStreak++,!(this.failureStreak<EP||this.staleNotified||this.staleCheckRunning)&&(this.staleCheckRunning=!0,Hx().then(e=>{if(this.staleCheckRunning=!1,!e){this.failureStreak=0;return}this.staleNotified=!0,this.ctx.onDataStale?.()}))}wakeIn(e){this.wakeTimer??=setTimeout(()=>{this.wakeTimer=void 0,this.wakes++},e)}start(e,t){return e.inFlight=t.catch(()=>{}).finally(()=>{e.inFlight=null}),t}invalidateZone(e){for(let t of this.zones)t.zone!==e||t.kind!==`time`||(t.currentTime=``,t.lastLoadStartMs=-1/0,this.retries.clear(DP(t,dx(t.zoomData,this.latestDate))));this.tick(this.latestDate)}satelliteCoverage(e){let t=this.zones.find(e=>e.kind===`time`&&e.zone===`earth`);return t?mx(t.zoomData,Mg(e)):{kind:`covered`}}tick(e){this.latestDate=e;let t=jg(e);for(let n of this.zones)if(n.kind===`time`){if(n.inFlight)continue;let t=dx(n.zoomData,e);if(t===n.currentTime||this.retries.waiting(DP(n,t)))continue;let r=performance.now(),i=n.lastLoadStartMs+TP-r;if(i>0){this.wakeIn(i);continue}n.lastLoadStartMs=r,this.start(n,this.loadTime(n,t,e))}else{for(;;){let e=ix(n.zoomData,t);if(e===n.currentIdx)break;let r=n.preloads.get(e);if(r?.kind!==`ready`)break;let i=n.currentIdx;n.currentIdx=e,this.applyChunkSwap(n,i,e,r.bodies),this.preloadChunkNeighbors(n)}if(n.inFlight)continue;let e=ix(n.zoomData,t);if(e===n.currentIdx||this.retries.waiting(DP(n,e)))continue;this.start(n,this.loadChunk(n,e))}}async ready(e=this.latestDate){this.latestDate=e;let t=jg(e),n=this.zones.map(n=>this.zoneReady(n,e,t));this.ctx.chebStore&&n.push(this.ctx.chebStore.load(t)),this.ctx.probeStore&&n.push(this.ctx.probeStore.load(t));let r=(await Promise.allSettled(n)).find(e=>e.status===`rejected`);if(r)throw r.reason}async zoneReady(e,t,n){for(;e.inFlight;)await e.inFlight;if(e.kind===`time`){let n=dx(e.zoomData,t);if(n===e.currentTime)return;e.lastLoadStartMs=performance.now(),await this.start(e,this.loadTime(e,n,t))}else{let t=ix(e.zoomData,n);if(t===e.currentIdx)return;await this.start(e,this.loadChunk(e,t))}}wanted=new Set;want(e){this.wanted.add(e)}async ensureBody(e,t){let n=e.startsWith(`probe-`)?await this.ensureProbe(e,t):null;if(await this.ensureListed(e,t),n)throw n.error}async ensureListed(e,t){this.ctx.getBody(e)||e.startsWith(`norad_satcat-`)&&!this.wanted.has(e)&&(this.want(e),(this.ctx.earthSatFilter||this.ctx.earthTypeFilter)&&(this.invalidateZone(`earth`),await this.ready(t).catch(()=>{}),this.ctx.getBody(e)))||await vS(this.ctx,e)}async ensureProbe(e,t){let n=this.ctx.probeStore;if(!n)return null;let r=jg(t),i=rS(e);await n.load(r).catch(()=>{});let a=await i;a&&n.registerCarried(a);let o=n.stampedFitCenterAt(e,r),s=e=>e.then(()=>null,e=>({error:e})),c=o?await s(vS(this.ctx,o)):null,l=await s(SP(e,r,this.ctx)),u=c??l;if(this.ctx.getBody(e))return u;let d=await Oy(),f=this.loader.processProbes(n,t,d).find(t=>t.data.id===e);return f&&(this.ctx.bodies.addBodies([f]),this.ctx.credits.recordOrbitSources([f])),u}async loadTime(e,t,n){let r=e.currentTime;try{let i=hx(e.zoomData,t,e.cap),a=await Promise.all(Array.from({length:i},(n,r)=>this.loader.process(e.zone,e.zoom,r,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!==G.SPACECRAFT&&t!==G.DEBRIS){console.warn(`zone-refresher: unexpected non-spacecraft body in ${e.zone}: ${n.data.id} (type=${t})`);continue}if(!this.wanted.has(n.data.id)){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)||this.wanted.has(e)||(n.delete(e),p++);for(let e of t.values())this.ctx.bodies.putSpacecraft(e)?d++:f++;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(DP(e,t))}catch(n){throw console.warn(`zone-refresher: failed to refresh ${e.zone}@${t}:`,n),this.recordFailure(DP(e,t)),n}}async loadChunk(e,t){let n=e.currentIdx;e.currentIdx=t;try{let r=e.preloads.get(t),i;i=r?.kind===`pending`?await r.promise:await Promise.all(Array.from({length:e.parts},(n,r)=>this.loader.process(e.zone,e.zoom,r,String(t),e.parentIdType))),this.applyChunkSwap(e,n,t,i),this.preloadChunkNeighbors(e),this.recordSuccess(DP(e,t))}catch(r){throw console.warn(`zone-refresher: ${e.zone} chunk reload failed (${n} → ${t}):`,r),e.currentIdx=n,this.recordFailure(DP(e,t)),r}}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.has(t.data.id);this.ctx.bodies.addBodies([t]),e?(this.ctx.bodies.majorBodies.push(t),a++):i++}}this.ctx.bodies.minorBodyVersion++,console.log(`zone-refresher: ${e.zone} chunk ${t} → ${n} (+${a} ~${i})`)}preloadChunkNeighbors(e){let t=Math.max(0,e.currentIdx-1),n=Math.min(e.zoomData.chunks-1,e.currentIdx+1);for(let r=t;r<=n;r++){if(e.preloads.has(r))continue;let t=String(r),n=Promise.all(Array.from({length:e.parts},(n,r)=>this.loader.process(e.zone,e.zoom,r,t,e.parentIdType)));e.preloads.set(r,{kind:`pending`,promise:n}),n.then(t=>{e.preloads.get(r)?.kind===`pending`&&e.preloads.set(r,{kind:`ready`,bodies:t})},t=>{console.warn(`zone-refresher: ${e.zone} chunk ${r} preload failed:`,t),e.preloads.get(r)?.kind===`pending`&&e.preloads.delete(r)})}for(let r of e.preloads.keys())(r<t||r>n)&&e.preloads.delete(r)}prefetchTimeNeighbors(e,t){let n=864e5,r=dx(e.zoomData,new Date(t.getTime()-n)),i=dx(e.zoomData,new Date(t.getTime()+n));for(let t of new Set([r,i])){if(t===e.currentTime)continue;let n=hx(e.zoomData,t,e.cap);for(let r=0;r<n;r++)Hb.prefetch(e.zone,e.zoom,r,t)}}},kP,AP=new Promise(e=>{kP=e});function jP(){kP()}var MP=Math.PI/180*yg,NP=new Zi().setFromAxisAngle(new J(0,0,1),-Math.PI/2).premultiply(new Zi().setFromAxisAngle(new J(0,1,0),Math.PI/2-MP)).premultiply(new Zi().setFromAxisAngle(new J(1,0,0),-Math.PI/2)),PP=[`px`,`nx`,`py`,`ny`,`pz`,`nz`];function FP(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 IP(e,t,n){return $t(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function LP(e,t,n){return Promise.all(PP.map(async r=>{let i=await fetch(IP(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 RP=new Map,zP=new Map;function BP(e,t){return`${e}:${t}`}function VP(e,t,n,r=!0){let i=BP(e,t),a=RP.get(i);if(!a){let r=LP(e,t,n);a=r,RP.set(i,a),r.catch(()=>{RP.get(i)===r&&(RP.delete(i),zP.delete(i))})}return r&&zP.set(i,(zP.get(i)??0)+1),a}function HP(e,t,n){let r=BP(e,t),i=(zP.get(r)??1)-1;if(i>0){zP.set(r,i);return}zP.delete(r),RP.delete(r);for(let e of n)e.close()}function UP(e){let t=new Kc(e);return t.colorSpace=ii,t.needsUpdate=!0,t}function WP(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 GP(e){let t=WP(e);t&&VP(e.id,t,void 0,!1).catch(()=>{})}var KP=12e3;async function qP(e,t,n,r){let i=FP(n,Math.min(t.capabilities.maxTextureSize,CE().maxSkyboxFace));if(!i){console.warn(`Skybox ${n.id}: no tiers declared`);return}let a=WP(n),o={cube:null,bitmaps:null},s=!1;a&&a!==i&&VP(n.id,a).then(t=>{if(s||r()){HP(n.id,a,t);return}o.cube=UP(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),HP(n.id,a,o.bitmaps),o.bitmaps=null)};i!==a&&await Promise.race([AP,new Promise(e=>setTimeout(e,KP))]);let u;try{u=await VP(n.id,i,i===a?void 0:`low`)}catch(e){throw c=!0,r()?a&&o.bitmaps&&(o.cube?.dispose(),HP(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(),HP(n.id,i,u),a&&a!==i&&o.bitmaps&&HP(n.id,a,o.bitmaps);return}let d=UP(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 Kc&&f.dispose(),HP(n.id,i,u),a&&a!==i&&o.bitmaps&&HP(n.id,a,o.bitmaps)}async function JP(e,t,n,r=()=>!1){if(!n?.layers.skipped.has(`stars`))try{let i=await _x();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 qP(e,t,i.skybox,r)}catch(e){console.warn(`Failed to load skybox:`,e)}}var YP=13;function XP(e,t,n){let r=ew().maxPartsPerZone,i=[],a=[];for(let[o,s]of Object.entries(e.position.zones)){if(o===`major`||o===`moons`||o===`spacecraft`||ax(s)||n.skipsZone(o))continue;let e=s.parent_id_type??`naif`;for(let{zoom:n,data:c}of sx(s)){if(c.shape===`chunked`)continue;let s=tx(c)?dx(c,t):null,l=tx(c)&&s!==null?hx(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>=YP?a.push(r):i.push(r)}}}return{eager:i,deferred:a}}async function ZP(e,t,n){let r=yx(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(`
5882
- `));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 Ix(r);return await a.load(t),a}async function QP(e,t,n,r,i,a){let o=[],s=null;e.chebStore&&(s=await Oy(),o.push(...t.processChebyshev(r,s))),e.probeStore&&(s??=await Oy(),a&&e.probeStore.registerCarried(a),o.push(...t.processProbes(e.probeStore,r,s)));let c=n.position.zones.major;if(c&&ox(c))for(let e of[1,2]){let n=c.zooms[String(e)];if(n&&ex(n))for(let r=0;r<n.parts;r++)o.push(...await t.process(`major`,e,r))}let l=e.layers.skipsZone(`moons`)?void 0:n.position.zones.moons,u=l?cx(l):void 0,d=u&&nx(u)?String(ix(u,i)):null;return u&&o.push(...await t.process(`moons`,null,0,d)),$P(o)}function $P(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 eF(e,t,n){performance.mark(`sm-load-start`),jv.reset();let r=Rv().catch(e=>console.warn(`scene-load: systems-global (GMs/nutation) failed to load:`,e)),i=Jb().catch(e=>console.warn(`scene-load: atmospheres failed to load — rendering without shells:`,e)),a=jg(t),o=_x();Oy().catch(()=>{}),o.then(t=>{let n=t.position.zones.moons;if(!n||e.layers.skipsZone(`moons`))return;let r=cx(n);r&&ex(r)&&Hb.prefetch(`moons`,null,0,null)}),o.then(t=>{t.skybox&&!e.layers.skipped.has(`stars`)&&GP(t.skybox)});let s=o.then(n=>XP(n,t,e.layers)),c=o.then(async t=>{let n=vx(t);for(let t of n.keys())e.layers.skipsZone(t)&&n.delete(t);if(n.size===0)return null;let r=new jx(n);return await r.load(a),r}),l=o.then(t=>ZP(t,a,e.layers)),u=rS(n),d=await o;jv.reach(`metadata`),e.chebStore=await c,e.probeStore=await l,jv.reach(`ephemeris`);let f=new Hb(e.chebStore);e.probeStore&&(e.probeStore.fitCenterUsable=t=>(e.chebStore?.has(t)??!1)||e.getBody(t)!==void 0),await r;let p=await QP(e,f,d,t,a,await u);jv.reach(`majors`),await i,e.bodies.addBodies(p),e.credits.recordOrbitSources(p);let m=n?SP(n,a,e).catch(()=>{}):void 0,h=await Oy();jv.reach(`labels`);let g=!1,_=()=>{g=!0},v=()=>{let t=g;g=!1,e.bodies.flushMinor(t)};if(n&&!e.getBody(n)){let t=await gS(n,e);_S(e,t,h)>0&&_(),t.length>0&&v()}e.bodies.majorBodies=p.filter(e=>e.data.objectType!==G.BARYCENTER&&e.data.objectType!==G.LAGRANGE_POINT&&e.data.orbitalSource!==W.SPICE_PROBE);try{e.refresher=new OP(e,d,f,t),n&&e.refresher.want(n)}catch(e){console.error(`scene-load: ZoneRefresher init failed; time-segmented zones stay empty:`,e)}await m,jv.reach(`done`),e.loading=!1,performance.mark(`sm-majors-done`);let{eager:y,deferred:b}=await s,x=y.filter(e=>e.zone===`small_body_moons`),S=y.filter(e=>e.zone!==`small_body_moons`);e.bodies.minorStreaming=!0;let C=setInterval(v,500),w=async(t,n,r)=>{e.credits.recordOrbitSource(n.source),n.rowCount!==0&&(await e.bodies.asteroidBucket(t,h).addChunk(n,r)>0&&_(),e.bodies.dirtyAsteroidZones.add(t))},T=(t,n)=>{e.credits.recordOrbitSources(n);let r=e.bodies.asteroidBucket(t,h);for(let e of n)r.addPlaceholder(e),_();e.bodies.dirtyAsteroidZones.add(t)},E=S.filter(e=>e.zone.startsWith(`small_bodies/`)),D=(e,t)=>n=>{console.warn(`scene-load: ${e} part ${t} failed (skipped):`,n)};try{await Promise.all([...E.map(({zone:e,zoom:t,part:n,time:r,parentIdType:i})=>f.fetchMinorColumns(e,t,n,r).then(t=>w(e,t,i)).catch(D(e,n))),e.refresher?.ready().then(_,e=>{console.warn(`scene-load: the data of the opening date is not all in:`,e)})]),await Promise.all(x.map(({zone:e,zoom:t,part:n,time:r,parentIdType:i})=>f.process(e,t,n,r,i).then(t=>T(e,t)).catch(D(e,n))))}finally{clearInterval(C),e.bodies.minorStreaming=!1,v(),performance.mark(`sm-minors-done`),jP()}if(b.length>0&&GC())console.info(`Low-end device: skipping ${b.length} deferred minor-belt parts to conserve memory`);else if(b.length>0){e.bodies.minorStreaming=!0;let t=setInterval(v,1e3);try{await Promise.all(b.map(({zone:e,zoom:t,part:n,time:r,parentIdType:i})=>f.fetchMinorColumns(e,t,n,r,`low`).then(t=>w(e,t,i)).catch(D(e,n))))}finally{clearInterval(t),e.bodies.minorStreaming=!1,v(),performance.mark(`sm-deferred-done`)}}}var tF=Gx(async()=>(await _x(),$t(`/v1/membership/earth.json.gz`,`membership`)),{fetcher:Pv,onMissing:()=>({}),error:e=>`fetchEarthMembership: ${e.status} ${e.statusText}`});async function nF(e){let t=await tF();return new Set(t[e]??[])}function rF(e,t=c()){return eS(Xx,e,t)}var iF={[Yv]:new Set([G.SPACECRAFT]),[Xv]:new Set([G.DEBRIS])},aF=class{bodies=new wv;credits=new jn;layers=new uy;visibility=new wy(this.bodies,()=>this.probeStore,()=>this.earthSatFilter,()=>this.smallBodyFilter,()=>this.layers);#e=Ke(!0);get loading(){return Ht(this.#e)}set loading(e){qe(this.#e,e,!0)}#t=Ke(null);get error(){return Ht(this.#t)}set error(e){qe(this.#t,e,!0)}onDataStale=null;constructor(){}chebStore=null;probeStore=null;refresher=null;placer=null;hasMeshBody=null;earthSatFilter=null;earthSatFilterSlug=null;earthTypeFilter=null;smallBodyFilter=null;missionMemberIds=null;currentGroupSlug=null;groupFilterJob=Promise.resolve();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)}place(e,t){return this.placer?.place(e,t)??null}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:my(this.bodies,e,n)}async load(e,t){try{await eF(this,e,t)}catch(e){throw this.fail(e),e}}fail(e){this.loading=!1,this.error=e instanceof Error?e.message:String(e),console.error(`[scene-load]`,e)}refreshTick(e){this.refresher?.tick(e)}async ready(e){await this.refresher?.ready(e)}async ensureBody(e,t){await this.refresher?.ensureBody(e,t)}applyGroupFilter(e){if(e===this.currentGroupSlug)return this.groupFilterJob;this.currentGroupSlug=e;let t=this.installGroupFilter(e);return this.groupFilterJob=t,t.catch(()=>{this.groupFilterJob===t&&(this.currentGroupSlug=void 0)}),t}async installGroupFilter(e){if(e?.startsWith(`mission-`)){let t=await rF(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 ny())[e]??null: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=iF[e??``]??null;if(!ey(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 nF(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(tv),this.bodies.dirtySpacecraftGroups.add(tv),this.bodies.minorBodyVersion++,this.refresher?.invalidateZone(`earth`))}}resolveSmallBodyFilter(e,t,n){if(e===qv)return{kind:`category`,category:`asteroid`};if(e===Jv)return{kind:`category`,category:`comet`};if(e===null||t!==`small_body`)return null;if(e.startsWith(`class-`))return{kind:`class`,className:e.slice(Wv.length)};if(e.startsWith(`flag-`)){let t=e.slice(Gv.length),r=Zv[t];return r===void 0?null:{kind:`flag`,flag:t,mask:r,n:n??0}}return null}},oF=400,sF=class{#e=Ke(0);get jd(){return Ht(this.#e)}set jd(e){qe(this.#e,e,!0)}#t=Ke(1);get timeScale(){return Ht(this.#t)}set timeScale(e){qe(this.#t,e,!0)}#n=Ke(1);get direction(){return Ht(this.#n)}set direction(e){qe(this.#n,e,!0)}seeked=!1;#r=Ke(0);get jumps(){return Ht(this.#r)}set jumps(e){qe(this.#r,e,!0)}#i=Ke(0);get settledJd(){return Ht(this.#i)}set settledJd(e){qe(this.#i,e,!0)}#a=Ke(!1);get live(){return Ht(this.#a)}set live(e){qe(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/kg*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(),oF))}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(jg(new Date)),this.live=this.timeScale===1}get playing(){return this.timeScale!==0}get date(){return Mg(this.jd)}setDate(e){this.jumpTo(jg(e))}},cF={type:`change`},lF={type:`start`},uF={type:`end`},dF=new js,fF=new bc,pF=Math.cos(70*Xi.DEG2RAD),mF=new J,hF=2*Math.PI,gF={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},_F=1e-6,vF=class extends sf{constructor(e,t=null){super(e,t),this.state=gF.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:Mn.ROTATE,MIDDLE:Mn.DOLLY,RIGHT:Mn.PAN},this.touches={ONE:Nn.ROTATE,TWO:Nn.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 Zi,this._lastTargetPosition=new J,this._quat=new Zi().setFromUnitVectors(e.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new tf,this._sphericalDelta=new tf,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=bF.bind(this),this._onPointerDown=yF.bind(this),this._onPointerUp=xF.bind(this),this._onContextMenu=OF.bind(this),this._onMouseWheel=wF.bind(this),this._onKeyDown=TF.bind(this),this._onTouchStart=EF.bind(this),this._onTouchMove=DF.bind(this),this._onMouseDown=SF.bind(this),this._onMouseMove=CF.bind(this),this._interceptControlDown=kF.bind(this),this._interceptControlUp=AF.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(cF),this.update(),this.state=gF.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;mF.copy(t).sub(this.target),mF.applyQuaternion(this._quat),this._spherical.setFromVector3(mF),this.autoRotate&&this.state===gF.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+=hF:n>Math.PI&&(n-=hF),r<-Math.PI?r+=hF:r>Math.PI&&(r-=hF),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(mF.setFromSpherical(this._spherical),mF.applyQuaternion(this._quatInverse),t.copy(this.target).add(mF),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=mF.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=mF.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):(dF.origin.copy(this.object.position),dF.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(dF.direction))<pF?this.object.lookAt(this.target):(fF.setFromNormalAndCoplanarPoint(this.object.up,this.target),dF.intersectPlane(fF,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)>_F||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_F||this._lastTargetPosition.distanceToSquared(this.target)>_F?(this.dispatchEvent(cF),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?hF/60/60*this.autoRotateSpeed:hF/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){mF.setFromMatrixColumn(t,0),mF.multiplyScalar(-e),this._panOffset.add(mF)}_panUp(e,t){this.screenSpacePanning===!0?mF.setFromMatrixColumn(t,1):(mF.setFromMatrixColumn(t,0),mF.crossVectors(this.object.up,mF)),mF.multiplyScalar(e),this._panOffset.add(mF)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;mF.copy(r).sub(this.target);let i=mF.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(hF*this._rotateDelta.x/t.clientHeight),this._rotateUp(hF*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(hF*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(-hF*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(hF*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(-hF*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(hF*this._rotateDelta.x/t.clientHeight),this._rotateUp(hF*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 yF(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 bF(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function xF(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(uF),this.state=gF.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 SF(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 Mn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=gF.DOLLY;break;case Mn.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=gF.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=gF.ROTATE}break;case Mn.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=gF.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=gF.PAN}break;default:this.state=gF.NONE}this.state!==gF.NONE&&this.dispatchEvent(lF)}function CF(e){switch(this.state){case gF.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case gF.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case gF.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function wF(e){this.enabled===!1||this.enableZoom===!1||this.state!==gF.NONE||(e.preventDefault(),this.dispatchEvent(lF),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(uF))}function TF(e){this.enabled!==!1&&this._handleKeyDown(e)}function EF(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Nn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=gF.TOUCH_ROTATE;break;case Nn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=gF.TOUCH_PAN;break;default:this.state=gF.NONE}break;case 2:switch(this.touches.TWO){case Nn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=gF.TOUCH_DOLLY_PAN;break;case Nn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=gF.TOUCH_DOLLY_ROTATE;break;default:this.state=gF.NONE}break;default:this.state=gF.NONE}this.state!==gF.NONE&&this.dispatchEvent(lF)}function DF(e){switch(this._trackPointer(e),this.state){case gF.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case gF.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case gF.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case gF.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=gF.NONE}}function OF(e){this.enabled!==!1&&e.preventDefault()}function kF(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function AF(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var{PI:jF,sin:MF,cos:NF,asin:PF,atan2:FF,sqrt:IF}=Math,LF=180/jF,RF=jF/180;function zF(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 BF(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=IF(r*r+i*i+a*a);return n&&([r,i,a]=zF([r,i,a],n,!0)),{latitude:PF(i/o)*LF,longitude:n?FF(-a,r)*LF:FF(r,a)*LF,distance:o}}function VF(e,t,n,r,i){let a=t*RF,o=n*RF,s,c,l;if(i){let e=[r*NF(a)*NF(o),r*MF(a),-r*NF(a)*MF(o)];[s,c,l]=zF(e,i,!1)}else s=r*NF(a)*MF(o),c=r*MF(a),l=r*NF(a)*NF(o);return[e[0]+s,e[1]+c,e[2]+l]}function HF(e,t,n,r){let i=e[0]-t[0],a=e[2]-t[2],o=IF(i*i+a*a);o>0?(i/=o,a/=o):(i=0,a=1);let s=n*RF,c=NF(s);return[r*c*i,r*MF(s),r*c*a]}function UF(e){let t=(e+180)%360-180;return t<=-180?t+360:t}function WF(e,t,n){if(t===void 0&&n===void 0)return e;let r=t===void 0?-180:UF(t),i=r===180?-180:r,a=n===void 0?180:UF(n);if(i<=a?e>=i&&e<=a:e>=i||e<=a)return e;let o=(e,t)=>Math.abs(UF(e-t));return o(e,i)<=o(e,a)?i:a}var GF=tv;function KF(e,t){return`feature:${e}:${t}`}function qF(e,t){return{data:{id:KF(e.hostId,e.featureId),name:t,objectType:G.SURFACE_FEATURE,parentId:e.hostId,radiusKm:NaN,hasLocalized:!1,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,validityStart:-1/0,validityEnd:1/0,orbitalSource:W.UNKNOWN},position:null,orbitCenterId:e.hostId,featureAnchor:e}}var JF={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
5881
+ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`#include <map_pars_fragment>`,`#include <map_pars_fragment>\n${cP}`).replace(`#include <map_fragment>`,lP)}),{material:e,chain:t}}function pP(e){e.tileOverlay&&tD(e.tileOverlay.chain)}function mP(){return qt()!==``&&kE()>0}function hP(e){return!!e&&e.max_level>=3&&mP()&&o(e.distribution)}function gP(e){return hP(e.surfaceTiles)&&!e.model&&!e.tileOverlay?.chain.dead}function _P(e,t,n,r,i,a){let o=e.surfaceTiles,s=e.mesh,c=s?.material,l,u=-1;if(o&&s&&c?.map&&i&&gP(e)){l=sD(s,t);let n=cD(e.tileOverlay?.chain,o,l);u=mE(e.radiusScene,e.cachedDist,r,n)}if(!o||!l||!c||u<3){e.tileOverlay&&rD(e.tileOverlay.chain,performance.now());return}e.tileOverlay&&e.tileOverlay.material!==c&&(pP(e),e.tileOverlay=void 0),uD((e.tileOverlay??=fP(c)).chain,o,lD(o,kE()),u,l,e.radiusScene,o.frames?e.textureFrame:void 0,n,a)}var vP=[`low`,`medium`,`high`];function yP(e){return e===void 0?-1:vP.indexOf(e)}function bP(e,t){for(let n=e;n>=0;n--){let e=vP[n];if(t.includes(e))return e}}function xP(e,t,n){return $t(n===void 0?`/v1/textures/${e}/${t}.webp`:`/v1/textures/${e}/${t}_${String(n).padStart(2,`0`)}.webp`,`textures`)}function SP(e,t){if(!(!t||t<2))return t===12?Mg(e).getUTCMonth()+1:1}async function CP(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(xP(i,t,n),e,void 0,a)});if(!e.mesh||e.textureLoadGen!==a){o.dispose();return}let s=e.mesh.material,c=e.body.data;VA(s,o,c.color),e.model&&BA(e.model,o,ej(c),c.color),e.textureTier=t,e.textureFrame=n}catch(e){console.warn(`Failed to load ${t} texture for ${i}:`,e)}finally{e.textureLoading=!1}}function wP(e){if(!e.mesh||!e.photometry||Rj(e.body)||e.appearance?.surfaceOwned)return;let t=e.mesh.material;t.map||(ej(e.body.data,t.color),e.model&&BA(e.model,null,t.color))}function TP(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.body.drawnRadii={a:n,b:r,c:i},e.atmosphere){let t=Math.max(n,r);CT(e.atmosphere,t,i,Q(t));for(let n of e.sunTint??[])PN(n,e.atmosphere.params,Q(t),t)}e.radiiApplied=!0}async function EP(e,t,n,r,i,a){if(e.textureTier||e.textureLoading)return;let o=await nS(e.body.data.id,!1);if(a?.bodies.orientationRead.add(e.body.data.id),!o.global)return;o.global.orientation&&!e.body.orientation&&ij(e.body,o.global.orientation,o.global.nut_prec,a),o.global.radii&&e.radiusScene>0&&!e.radiiApplied&&!o.global.displacement?.absolute_radius&&TP(e,o.global.radii),o.global.rings?.length&&await Promise.allSettled(IT(e.body.data.id,e.body.data.id,o.global.rings,o.global.radii,e,r,i,a));let c=e.body.data;if(c.color=o.global.sbdb?.color??o.global.color,c.geometricAlbedo=o.global.sbdb?.geometric_albedo??o.global.geometric_albedo,c.lunarWeightScale=o.global.lunar_weight_scale,e.photometry&&(e.photometry.uLunarWeightScale.value=c.lunarWeightScale??1),wP(e),!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 XN(`topography`,l,l,o.global,e,{textureLoader:t,currentJd:n,ctx:a}),!(e.textureTier||e.textureLoading)&&uw().showSurfaceTexture&&u&&(e.textureBundleId=u.id===l?void 0:u.id,e.surfaceTiles=u.tiles,e.availableTiers??=u.tiers??[...vP],e.availableFrames=u.frames,await CP(e,`low`,SP(n,e.availableFrames),t))}async function DP(e){if(!e.label)return;let t=e.body.data;if(t.name)return;let n=await nS(t.id,t.hasLocalized),r=n.localized?.name??n.global?.name;r&&(t.name??=r,aP(e,r,oP(e.body),t.objectType===G.STAR||t.objectType===G.PLANET))}function OP(e){if(!e.mesh)return;e.textureLoadGen=(e.textureLoadGen??0)+1;let t=e.mesh.material;QN(`topography`,e),pP(e),t.map&&(t.map.dispose(),t.map=null,ej(e.body.data,t.color),t.needsUpdate=!0,e.model&&BA(e.model,null,t.color),e.textureTier=void 0)}async function kP(e,t,n,r){e.textureLoading||e.availableTiers?.includes(t)&&(e.textureTier===t&&e.textureFrame===n||await CP(e,t,n,r))}var AP=new Map;function jP(e){let t=AP.get(e);return t||(t=MP(e).finally(()=>AP.delete(e)),AP.set(e,t)),t}async function MP(e){let t=await Pv(`${Kt()}/v1/systems/${e}.json`);if(t.status===404)return null;if(!t.ok)throw Error(`systems/${e}.json: ${t.status}`);return t.json()}async function NP(e,t){let n=e.data.id,r=()=>!!e.orientation||t.bodies.orientationRead.has(n);if(r())return;let i=t.visibility.resolveSystemId(e),a=i?t.getBody(i):void 0,o=a?.data.objectType===G.BARYCENTER?a.data.id:null,s=o?(await jP(o))?.[n]:void 0,c=s?.orientation?null:await nS(n,!1);r()||(s?.orientation?ij(e,s.orientation,s.nut_prec,t,o):c?.global?.orientation&&ij(e,c.global.orientation,c.global.nut_prec,t),t.bodies.orientationRead.add(n),e.orientation&&t.bodies.orientationVersion++)}async function PP(e,t,n){let r=n.probeStore?.landingBodyAt(e,t),i=r?n.getBody(r):void 0;i&&await NP(i,n)}async function FP(e,t,n,r,i,a,o){let c=await jP(e).catch(()=>null);if(!c)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)continue;o?.bodies.orientationRead.add(u);let p=f.body.data;if(p.color??=d.color,p.geometricAlbedo??=d.geometric_albedo,p.lunarWeightScale??=d.lunar_weight_scale,f.photometry&&(f.photometry.uLunarWeightScale.value=p.lunarWeightScale??1),wP(f),d.orientation&&(ij(f.body,d.orientation,d.nut_prec,o,e),CS(f.mesh,d.orientation,i,f.body.nutPrec)),d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&TP(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,f.surfaceTiles=c.tiles,!f.textureTier)){let e=SP(i,f.availableFrames);l.push(kP(f,`low`,e,r))}l.push(...ZN(u,e,d,f,{textureLoader:r,currentJd:i,ctx:o})),d.rings?.length&&l.push(...IT(u,e,d.rings,d.radii,f,n,a,o))}await Promise.allSettled(l)}function IP(e,t,n,r){for(let n of t.values())if(r.visibility.isBodyInSystem(n.body,e)){if(OP(n),$N(n),n.terrainWindow&&n.mesh){n.terrainWindow=null;let e=Q(xn(n.body.data)),t=n.mesh.geometry;n.mesh.geometry=new _u(e,24,24),t.dispose(),n.currentSegments=24}for(let e of n.rings)e.planetShadow?.disable(),e.ringshine?.disable(),e.mesh.removeFromParent(),QC(e);n.rings=[],zM(n)}}var LP=2e3,RP=3;function zP(e,t){return`${e.zone}:${e.zoom??``}:${t}`}var BP=class{zones=[];latestDate;failureStreak=0;staleNotified=!1;staleCheckRunning=!1;retries=new Ex(()=>this.wakes++);wakes=0;wakeTimer;constructor(e,t,n,r){this.ctx=e,this.loader=n,this.latestDate=r;let i=jg(r),a=uw().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 sx(o)){if(s.shape===`chunked`||s.shape===`parted`)continue;let o=a>0?Math.min(s.parts,a):s.parts;if(tx(s)){let i={kind:`time`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentTime:``,inFlight:null,lastLoadStartMs:-1/0,cap:a};this.zones.push(i),this.prefetchTimeNeighbors(i,r)}else if(nx(s)){let r={kind:`chunk`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentIdx:ix(s,i),inFlight:null,preloads:new Map};this.zones.push(r),this.preloadChunkNeighbors(r)}}}}recordSuccess(e){this.retries.clear(e),this.failureStreak=0}recordFailure(e){this.retries.fail(e),this.failureStreak++,!(this.failureStreak<RP||this.staleNotified||this.staleCheckRunning)&&(this.staleCheckRunning=!0,Hx().then(e=>{if(this.staleCheckRunning=!1,!e){this.failureStreak=0;return}this.staleNotified=!0,this.ctx.onDataStale?.()}))}wakeIn(e){this.wakeTimer??=setTimeout(()=>{this.wakeTimer=void 0,this.wakes++},e)}start(e,t){return e.inFlight=t.catch(()=>{}).finally(()=>{e.inFlight=null}),t}invalidateZone(e){for(let t of this.zones)t.zone!==e||t.kind!==`time`||(t.currentTime=``,t.lastLoadStartMs=-1/0,this.retries.clear(zP(t,dx(t.zoomData,this.latestDate))));this.tick(this.latestDate)}satelliteCoverage(e){let t=this.zones.find(e=>e.kind===`time`&&e.zone===`earth`);return t?mx(t.zoomData,Mg(e)):{kind:`covered`}}tick(e){this.latestDate=e;let t=jg(e);for(let n of this.zones)if(n.kind===`time`){if(n.inFlight)continue;let t=dx(n.zoomData,e);if(t===n.currentTime||this.retries.waiting(zP(n,t)))continue;let r=performance.now(),i=n.lastLoadStartMs+LP-r;if(i>0){this.wakeIn(i);continue}n.lastLoadStartMs=r,this.start(n,this.loadTime(n,t,e))}else{for(;;){let e=ix(n.zoomData,t);if(e===n.currentIdx)break;let r=n.preloads.get(e);if(r?.kind!==`ready`)break;let i=n.currentIdx;n.currentIdx=e,this.applyChunkSwap(n,i,e,r.bodies),this.preloadChunkNeighbors(n)}if(n.inFlight)continue;let e=ix(n.zoomData,t);if(e===n.currentIdx||this.retries.waiting(zP(n,e)))continue;this.start(n,this.loadChunk(n,e))}}async ready(e=this.latestDate){this.latestDate=e;let t=jg(e),n=this.zones.map(n=>this.zoneReady(n,e,t));this.ctx.chebStore&&n.push(this.ctx.chebStore.load(t)),this.ctx.probeStore&&n.push(this.ctx.probeStore.load(t));let r=(await Promise.allSettled(n)).find(e=>e.status===`rejected`);if(r)throw r.reason}async zoneReady(e,t,n){for(;e.inFlight;)await e.inFlight;if(e.kind===`time`){let n=dx(e.zoomData,t);if(n===e.currentTime)return;e.lastLoadStartMs=performance.now(),await this.start(e,this.loadTime(e,n,t))}else{let t=ix(e.zoomData,n);if(t===e.currentIdx)return;await this.start(e,this.loadChunk(e,t))}}wanted=new Set;want(e){this.wanted.add(e)}async ensureBody(e,t){let n=e.startsWith(`probe-`)?await this.ensureProbe(e,t):null;if(await this.ensureListed(e,t),n)throw n.error}async ensureListed(e,t){this.ctx.getBody(e)||e.startsWith(`norad_satcat-`)&&!this.wanted.has(e)&&(this.want(e),(this.ctx.earthSatFilter||this.ctx.earthTypeFilter)&&(this.invalidateZone(`earth`),await this.ready(t).catch(()=>{}),this.ctx.getBody(e)))||await vS(this.ctx,e)}async ensureProbe(e,t){let n=this.ctx.probeStore;if(!n)return null;let r=jg(t),i=rS(e);await n.load(r).catch(()=>{});let a=await i;a&&n.registerCarried(a);let o=n.stampedFitCenterAt(e,r),s=e=>e.then(()=>null,e=>({error:e})),c=o?await s(vS(this.ctx,o)):null,l=await s(PP(e,r,this.ctx)),u=c??l;if(this.ctx.getBody(e))return u;let d=await Oy(),f=this.loader.processProbes(n,t,d).find(t=>t.data.id===e);return f&&(this.ctx.bodies.addBodies([f]),this.ctx.credits.recordOrbitSources([f])),u}async loadTime(e,t,n){let r=e.currentTime;try{let i=hx(e.zoomData,t,e.cap),a=await Promise.all(Array.from({length:i},(n,r)=>this.loader.process(e.zone,e.zoom,r,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!==G.SPACECRAFT&&t!==G.DEBRIS){console.warn(`zone-refresher: unexpected non-spacecraft body in ${e.zone}: ${n.data.id} (type=${t})`);continue}if(!this.wanted.has(n.data.id)){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)||this.wanted.has(e)||(n.delete(e),p++);for(let e of t.values())this.ctx.bodies.putSpacecraft(e)?d++:f++;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(zP(e,t))}catch(n){throw console.warn(`zone-refresher: failed to refresh ${e.zone}@${t}:`,n),this.recordFailure(zP(e,t)),n}}async loadChunk(e,t){let n=e.currentIdx;e.currentIdx=t;try{let r=e.preloads.get(t),i;i=r?.kind===`pending`?await r.promise:await Promise.all(Array.from({length:e.parts},(n,r)=>this.loader.process(e.zone,e.zoom,r,String(t),e.parentIdType))),this.applyChunkSwap(e,n,t,i),this.preloadChunkNeighbors(e),this.recordSuccess(zP(e,t))}catch(r){throw console.warn(`zone-refresher: ${e.zone} chunk reload failed (${n} → ${t}):`,r),e.currentIdx=n,this.recordFailure(zP(e,t)),r}}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.has(t.data.id);this.ctx.bodies.addBodies([t]),e?(this.ctx.bodies.majorBodies.push(t),a++):i++}}this.ctx.bodies.minorBodyVersion++,console.log(`zone-refresher: ${e.zone} chunk ${t} → ${n} (+${a} ~${i})`)}preloadChunkNeighbors(e){let t=Math.max(0,e.currentIdx-1),n=Math.min(e.zoomData.chunks-1,e.currentIdx+1);for(let r=t;r<=n;r++){if(e.preloads.has(r))continue;let t=String(r),n=Promise.all(Array.from({length:e.parts},(n,r)=>this.loader.process(e.zone,e.zoom,r,t,e.parentIdType)));e.preloads.set(r,{kind:`pending`,promise:n}),n.then(t=>{e.preloads.get(r)?.kind===`pending`&&e.preloads.set(r,{kind:`ready`,bodies:t})},t=>{console.warn(`zone-refresher: ${e.zone} chunk ${r} preload failed:`,t),e.preloads.get(r)?.kind===`pending`&&e.preloads.delete(r)})}for(let r of e.preloads.keys())(r<t||r>n)&&e.preloads.delete(r)}prefetchTimeNeighbors(e,t){let n=864e5,r=dx(e.zoomData,new Date(t.getTime()-n)),i=dx(e.zoomData,new Date(t.getTime()+n));for(let t of new Set([r,i])){if(t===e.currentTime)continue;let n=hx(e.zoomData,t,e.cap);for(let r=0;r<n;r++)Hb.prefetch(e.zone,e.zoom,r,t)}}},VP,HP=new Promise(e=>{VP=e});function UP(){VP()}var WP=Math.PI/180*yg,GP=new Zi().setFromAxisAngle(new J(0,0,1),-Math.PI/2).premultiply(new Zi().setFromAxisAngle(new J(0,1,0),Math.PI/2-WP)).premultiply(new Zi().setFromAxisAngle(new J(1,0,0),-Math.PI/2)),KP=[`px`,`nx`,`py`,`ny`,`pz`,`nz`];function qP(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 JP(e,t,n){return $t(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function YP(e,t,n){return Promise.all(KP.map(async r=>{let i=await fetch(JP(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 XP=new Map,ZP=new Map;function QP(e,t){return`${e}:${t}`}function $P(e,t,n,r=!0){let i=QP(e,t),a=XP.get(i);if(!a){let r=YP(e,t,n);a=r,XP.set(i,a),r.catch(()=>{XP.get(i)===r&&(XP.delete(i),ZP.delete(i))})}return r&&ZP.set(i,(ZP.get(i)??0)+1),a}function eF(e,t,n){let r=QP(e,t),i=(ZP.get(r)??1)-1;if(i>0){ZP.set(r,i);return}ZP.delete(r),XP.delete(r);for(let e of n)e.close()}function tF(e){let t=new Kc(e);return t.colorSpace=ii,t.needsUpdate=!0,t}function nF(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 rF(e){let t=nF(e);t&&$P(e.id,t,void 0,!1).catch(()=>{})}var iF=12e3;async function aF(e,t,n,r){let i=qP(n,Math.min(t.capabilities.maxTextureSize,NE().maxSkyboxFace));if(!i){console.warn(`Skybox ${n.id}: no tiers declared`);return}let a=nF(n),o={cube:null,bitmaps:null},s=!1;a&&a!==i&&$P(n.id,a).then(t=>{if(s||r()){eF(n.id,a,t);return}o.cube=tF(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),eF(n.id,a,o.bitmaps),o.bitmaps=null)};i!==a&&await Promise.race([HP,new Promise(e=>setTimeout(e,iF))]);let u;try{u=await $P(n.id,i,i===a?void 0:`low`)}catch(e){throw c=!0,r()?a&&o.bitmaps&&(o.cube?.dispose(),eF(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(),eF(n.id,i,u),a&&a!==i&&o.bitmaps&&eF(n.id,a,o.bitmaps);return}let d=tF(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 Kc&&f.dispose(),eF(n.id,i,u),a&&a!==i&&o.bitmaps&&eF(n.id,a,o.bitmaps)}async function oF(e,t,n,r=()=>!1){if(!n?.layers.skipped.has(`stars`))try{let i=await _x();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 aF(e,t,i.skybox,r)}catch(e){console.warn(`Failed to load skybox:`,e)}}var sF=13;function cF(e,t,n){let r=uw().maxPartsPerZone,i=[],a=[];for(let[o,s]of Object.entries(e.position.zones)){if(o===`major`||o===`moons`||o===`spacecraft`||ax(s)||n.skipsZone(o))continue;let e=s.parent_id_type??`naif`;for(let{zoom:n,data:c}of sx(s)){if(c.shape===`chunked`)continue;let s=tx(c)?dx(c,t):null,l=tx(c)&&s!==null?hx(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>=sF?a.push(r):i.push(r)}}}return{eager:i,deferred:a}}async function lF(e,t,n){let r=yx(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(`
5882
+ `));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 Ix(r);return await a.load(t),a}async function uF(e,t,n,r,i,a){let o=[],s=null;e.chebStore&&(s=await Oy(),o.push(...t.processChebyshev(r,s))),e.probeStore&&(s??=await Oy(),a&&e.probeStore.registerCarried(a),o.push(...t.processProbes(e.probeStore,r,s)));let c=n.position.zones.major;if(c&&ox(c))for(let e of[1,2]){let n=c.zooms[String(e)];if(n&&ex(n))for(let r=0;r<n.parts;r++)o.push(...await t.process(`major`,e,r))}let l=e.layers.skipsZone(`moons`)?void 0:n.position.zones.moons,u=l?cx(l):void 0,d=u&&nx(u)?String(ix(u,i)):null;return u&&o.push(...await t.process(`moons`,null,0,d)),dF(o)}function dF(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 fF(e,t,n){performance.mark(`sm-load-start`),jv.reset();let r=Rv().catch(e=>console.warn(`scene-load: systems-global (GMs/nutation) failed to load:`,e)),i=Jb().catch(e=>console.warn(`scene-load: atmospheres failed to load — rendering without shells:`,e)),a=jg(t),o=_x();Oy().catch(()=>{}),o.then(t=>{let n=t.position.zones.moons;if(!n||e.layers.skipsZone(`moons`))return;let r=cx(n);r&&ex(r)&&Hb.prefetch(`moons`,null,0,null)}),o.then(t=>{t.skybox&&!e.layers.skipped.has(`stars`)&&rF(t.skybox)});let s=o.then(n=>cF(n,t,e.layers)),c=o.then(async t=>{let n=vx(t);for(let t of n.keys())e.layers.skipsZone(t)&&n.delete(t);if(n.size===0)return null;let r=new jx(n);return await r.load(a),r}),l=o.then(t=>lF(t,a,e.layers)),u=rS(n),d=await o;jv.reach(`metadata`),e.chebStore=await c,e.probeStore=await l,jv.reach(`ephemeris`);let f=new Hb(e.chebStore);e.probeStore&&(e.probeStore.fitCenterUsable=t=>(e.chebStore?.has(t)??!1)||e.getBody(t)!==void 0),await r;let p=await uF(e,f,d,t,a,await u);jv.reach(`majors`),await i,e.bodies.addBodies(p),e.credits.recordOrbitSources(p);let m=n?PP(n,a,e).catch(()=>{}):void 0,h=await Oy();jv.reach(`labels`);let g=!1,_=()=>{g=!0},v=()=>{let t=g;g=!1,e.bodies.flushMinor(t)};if(n&&!e.getBody(n)){let t=await gS(n,e);_S(e,t,h)>0&&_(),t.length>0&&v()}e.bodies.majorBodies=p.filter(e=>e.data.objectType!==G.BARYCENTER&&e.data.objectType!==G.LAGRANGE_POINT&&e.data.orbitalSource!==W.SPICE_PROBE);try{e.refresher=new BP(e,d,f,t),n&&e.refresher.want(n)}catch(e){console.error(`scene-load: ZoneRefresher init failed; time-segmented zones stay empty:`,e)}await m,jv.reach(`done`),e.loading=!1,performance.mark(`sm-majors-done`);let{eager:y,deferred:b}=await s,x=y.filter(e=>e.zone===`small_body_moons`),S=y.filter(e=>e.zone!==`small_body_moons`);e.bodies.minorStreaming=!0;let C=setInterval(v,500),w=async(t,n,r)=>{e.credits.recordOrbitSource(n.source),n.rowCount!==0&&(await e.bodies.asteroidBucket(t,h).addChunk(n,r)>0&&_(),e.bodies.dirtyAsteroidZones.add(t))},T=(t,n)=>{e.credits.recordOrbitSources(n);let r=e.bodies.asteroidBucket(t,h);for(let e of n)r.addPlaceholder(e),_();e.bodies.dirtyAsteroidZones.add(t)},E=S.filter(e=>e.zone.startsWith(`small_bodies/`)),D=(e,t)=>n=>{console.warn(`scene-load: ${e} part ${t} failed (skipped):`,n)};try{await Promise.all([...E.map(({zone:e,zoom:t,part:n,time:r,parentIdType:i})=>f.fetchMinorColumns(e,t,n,r).then(t=>w(e,t,i)).catch(D(e,n))),e.refresher?.ready().then(_,e=>{console.warn(`scene-load: the data of the opening date is not all in:`,e)})]),await Promise.all(x.map(({zone:e,zoom:t,part:n,time:r,parentIdType:i})=>f.process(e,t,n,r,i).then(t=>T(e,t)).catch(D(e,n))))}finally{clearInterval(C),e.bodies.minorStreaming=!1,v(),performance.mark(`sm-minors-done`),UP()}if(b.length>0&&tw())console.info(`Low-end device: skipping ${b.length} deferred minor-belt parts to conserve memory`);else if(b.length>0){e.bodies.minorStreaming=!0;let t=setInterval(v,1e3);try{await Promise.all(b.map(({zone:e,zoom:t,part:n,time:r,parentIdType:i})=>f.fetchMinorColumns(e,t,n,r,`low`).then(t=>w(e,t,i)).catch(D(e,n))))}finally{clearInterval(t),e.bodies.minorStreaming=!1,v(),performance.mark(`sm-deferred-done`)}}}var pF=Gx(async()=>(await _x(),$t(`/v1/membership/earth.json.gz`,`membership`)),{fetcher:Pv,onMissing:()=>({}),error:e=>`fetchEarthMembership: ${e.status} ${e.statusText}`});async function mF(e){let t=await pF();return new Set(t[e]??[])}function hF(e,t=c()){return eS(Xx,e,t)}var gF={[Yv]:new Set([G.SPACECRAFT]),[Xv]:new Set([G.DEBRIS])},_F=class{bodies=new wv;credits=new jn;layers=new uy;visibility=new wy(this.bodies,()=>this.probeStore,()=>this.earthSatFilter,()=>this.smallBodyFilter,()=>this.layers);#e=Ke(!0);get loading(){return Ht(this.#e)}set loading(e){qe(this.#e,e,!0)}#t=Ke(null);get error(){return Ht(this.#t)}set error(e){qe(this.#t,e,!0)}onDataStale=null;constructor(){}chebStore=null;probeStore=null;refresher=null;placer=null;hasMeshBody=null;earthSatFilter=null;earthSatFilterSlug=null;earthTypeFilter=null;smallBodyFilter=null;missionMemberIds=null;currentGroupSlug=null;groupFilterJob=Promise.resolve();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)}place(e,t){return this.placer?.place(e,t)??null}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:my(this.bodies,e,n)}async load(e,t){try{await fF(this,e,t)}catch(e){throw this.fail(e),e}}fail(e){this.loading=!1,this.error=e instanceof Error?e.message:String(e),console.error(`[scene-load]`,e)}refreshTick(e){this.refresher?.tick(e)}async ready(e){await this.refresher?.ready(e)}async ensureBody(e,t){await this.refresher?.ensureBody(e,t)}applyGroupFilter(e){if(e===this.currentGroupSlug)return this.groupFilterJob;this.currentGroupSlug=e;let t=this.installGroupFilter(e);return this.groupFilterJob=t,t.catch(()=>{this.groupFilterJob===t&&(this.currentGroupSlug=void 0)}),t}async installGroupFilter(e){if(e?.startsWith(`mission-`)){let t=await hF(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 ny())[e]??null: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=gF[e??``]??null;if(!ey(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 mF(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(tv),this.bodies.dirtySpacecraftGroups.add(tv),this.bodies.minorBodyVersion++,this.refresher?.invalidateZone(`earth`))}}resolveSmallBodyFilter(e,t,n){if(e===qv)return{kind:`category`,category:`asteroid`};if(e===Jv)return{kind:`category`,category:`comet`};if(e===null||t!==`small_body`)return null;if(e.startsWith(`class-`))return{kind:`class`,className:e.slice(Wv.length)};if(e.startsWith(`flag-`)){let t=e.slice(Gv.length),r=Zv[t];return r===void 0?null:{kind:`flag`,flag:t,mask:r,n:n??0}}return null}},vF=400,yF=class{#e=Ke(0);get jd(){return Ht(this.#e)}set jd(e){qe(this.#e,e,!0)}#t=Ke(1);get timeScale(){return Ht(this.#t)}set timeScale(e){qe(this.#t,e,!0)}#n=Ke(1);get direction(){return Ht(this.#n)}set direction(e){qe(this.#n,e,!0)}seeked=!1;#r=Ke(0);get jumps(){return Ht(this.#r)}set jumps(e){qe(this.#r,e,!0)}#i=Ke(0);get settledJd(){return Ht(this.#i)}set settledJd(e){qe(this.#i,e,!0)}#a=Ke(!1);get live(){return Ht(this.#a)}set live(e){qe(this.#a,e,!0)}lastRealMs=0;prevScale=1;stops=null;settleTimer=null;arrivals=[];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/kg*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();let t=this.jumps;return new Promise(e=>this.arrivals.push({jumps:t,resolve:e}))}placed(e){this.arrivals.length!==0&&(this.arrivals=this.arrivals.filter(t=>t.jumps>e?!0:(t.resolve(),!1)))}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(),vF))}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(jg(new Date)),this.live=this.timeScale===1}get playing(){return this.timeScale!==0}get date(){return Mg(this.jd)}setDate(e){return this.jumpTo(jg(e))}},bF={type:`change`},xF={type:`start`},SF={type:`end`},CF=new js,wF=new bc,TF=Math.cos(70*Xi.DEG2RAD),EF=new J,DF=2*Math.PI,OF={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},kF=1e-6,AF=class extends sf{constructor(e,t=null){super(e,t),this.state=OF.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:Mn.ROTATE,MIDDLE:Mn.DOLLY,RIGHT:Mn.PAN},this.touches={ONE:Nn.ROTATE,TWO:Nn.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 Zi,this._lastTargetPosition=new J,this._quat=new Zi().setFromUnitVectors(e.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new tf,this._sphericalDelta=new tf,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=MF.bind(this),this._onPointerDown=jF.bind(this),this._onPointerUp=NF.bind(this),this._onContextMenu=BF.bind(this),this._onMouseWheel=IF.bind(this),this._onKeyDown=LF.bind(this),this._onTouchStart=RF.bind(this),this._onTouchMove=zF.bind(this),this._onMouseDown=PF.bind(this),this._onMouseMove=FF.bind(this),this._interceptControlDown=VF.bind(this),this._interceptControlUp=HF.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(bF),this.update(),this.state=OF.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;EF.copy(t).sub(this.target),EF.applyQuaternion(this._quat),this._spherical.setFromVector3(EF),this.autoRotate&&this.state===OF.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+=DF:n>Math.PI&&(n-=DF),r<-Math.PI?r+=DF:r>Math.PI&&(r-=DF),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(EF.setFromSpherical(this._spherical),EF.applyQuaternion(this._quatInverse),t.copy(this.target).add(EF),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=EF.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=EF.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):(CF.origin.copy(this.object.position),CF.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(CF.direction))<TF?this.object.lookAt(this.target):(wF.setFromNormalAndCoplanarPoint(this.object.up,this.target),CF.intersectPlane(wF,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)>kF||8*(1-this._lastQuaternion.dot(this.object.quaternion))>kF||this._lastTargetPosition.distanceToSquared(this.target)>kF?(this.dispatchEvent(bF),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?DF/60/60*this.autoRotateSpeed:DF/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){EF.setFromMatrixColumn(t,0),EF.multiplyScalar(-e),this._panOffset.add(EF)}_panUp(e,t){this.screenSpacePanning===!0?EF.setFromMatrixColumn(t,1):(EF.setFromMatrixColumn(t,0),EF.crossVectors(this.object.up,EF)),EF.multiplyScalar(e),this._panOffset.add(EF)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;EF.copy(r).sub(this.target);let i=EF.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(DF*this._rotateDelta.x/t.clientHeight),this._rotateUp(DF*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(DF*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(-DF*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(DF*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(-DF*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(DF*this._rotateDelta.x/t.clientHeight),this._rotateUp(DF*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 jF(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 MF(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function NF(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(SF),this.state=OF.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 PF(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 Mn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=OF.DOLLY;break;case Mn.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=OF.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=OF.ROTATE}break;case Mn.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=OF.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=OF.PAN}break;default:this.state=OF.NONE}this.state!==OF.NONE&&this.dispatchEvent(xF)}function FF(e){switch(this.state){case OF.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case OF.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case OF.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function IF(e){this.enabled===!1||this.enableZoom===!1||this.state!==OF.NONE||(e.preventDefault(),this.dispatchEvent(xF),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(SF))}function LF(e){this.enabled!==!1&&this._handleKeyDown(e)}function RF(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Nn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=OF.TOUCH_ROTATE;break;case Nn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=OF.TOUCH_PAN;break;default:this.state=OF.NONE}break;case 2:switch(this.touches.TWO){case Nn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=OF.TOUCH_DOLLY_PAN;break;case Nn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=OF.TOUCH_DOLLY_ROTATE;break;default:this.state=OF.NONE}break;default:this.state=OF.NONE}this.state!==OF.NONE&&this.dispatchEvent(xF)}function zF(e){switch(this._trackPointer(e),this.state){case OF.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case OF.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case OF.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case OF.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=OF.NONE}}function BF(e){this.enabled!==!1&&e.preventDefault()}function VF(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function HF(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var{PI:UF,sin:WF,cos:GF,asin:KF,atan2:qF,sqrt:JF}=Math,YF=180/UF,XF=UF/180;function ZF(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 QF(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=JF(r*r+i*i+a*a);return n&&([r,i,a]=ZF([r,i,a],n,!0)),{latitude:KF(i/o)*YF,longitude:n?qF(-a,r)*YF:qF(r,a)*YF,distance:o}}function $F(e,t,n,r,i){let a=t*XF,o=n*XF,s,c,l;if(i){let e=[r*GF(a)*GF(o),r*WF(a),-r*GF(a)*WF(o)];[s,c,l]=ZF(e,i,!1)}else s=r*GF(a)*WF(o),c=r*WF(a),l=r*GF(a)*GF(o);return[e[0]+s,e[1]+c,e[2]+l]}function eI(e,t,n,r){let i=e[0]-t[0],a=e[2]-t[2],o=JF(i*i+a*a);o>0?(i/=o,a/=o):(i=0,a=1);let s=n*XF,c=GF(s);return[r*c*i,r*WF(s),r*c*a]}function tI(e){let t=(e+180)%360-180;return t<=-180?t+360:t}function nI(e,t,n){if(t===void 0&&n===void 0)return e;let r=t===void 0?-180:tI(t),i=r===180?-180:r,a=n===void 0?180:tI(n);if(i<=a?e>=i&&e<=a:e>=i||e<=a)return e;let o=(e,t)=>Math.abs(tI(e-t));return o(e,i)<=o(e,a)?i:a}var rI=tv;function iI(e,t){return`feature:${e}:${t}`}function aI(e,t){return{data:{id:iI(e.hostId,e.featureId),name:t,objectType:G.SURFACE_FEATURE,parentId:e.hostId,radiusKm:NaN,hasLocalized:!1,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,validityStart:-1/0,validityEnd:1/0,orbitalSource:W.UNKNOWN},position:null,orbitCenterId:e.hostId,featureAnchor:e}}var oI={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
5883
5883
 
5884
5884
  varying vec2 vUv;
5885
5885
 
@@ -5902,7 +5902,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
5902
5902
  gl_FragColor = opacity * texel;
5903
5903
 
5904
5904
 
5905
- }`},YF=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},XF=new Ed(-1,1,1,-1,0,1),ZF=new class extends ns{constructor(){super(),this.setAttribute(`position`,new Wo([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Wo([0,2,0,0,2,0],2))}},QF=class{constructor(e){this._mesh=new Ws(ZF,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,XF)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},$F=class extends YF{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Eu?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Cu.clone(e.uniforms),this.material=new Eu({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new QF(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(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()}},eI=class extends YF{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},tI=class extends YF{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},nI=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new q);this._width=n.width,this._height=n.height,t=new va(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Zn}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new $F(JF),this.copyPass.material.blending=0,this.timer=new Ld}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let t=0,r=this.passes.length;t<r;t++){let r=this.passes[t];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}eI!==void 0&&(r instanceof eI?n=!0:r instanceof tI&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new q);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},rI=class extends YF{constructor(e,t,n=null,r=null,i=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=i,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new X}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let i,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==1&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(i),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}},iI={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new X(0)},defaultOpacity:{value:0}},vertexShader:`
5905
+ }`},sI=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},cI=new Ed(-1,1,1,-1,0,1),lI=new class extends ns{constructor(){super(),this.setAttribute(`position`,new Wo([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Wo([0,2,0,0,2,0],2))}},uI=class{constructor(e){this._mesh=new Ws(lI,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,cI)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},dI=class extends sI{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Eu?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Cu.clone(e.uniforms),this.material=new Eu({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new uI(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(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()}},fI=class extends sI{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},pI=class extends sI{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},mI=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new q);this._width=n.width,this._height=n.height,t=new va(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Zn}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new dI(oI),this.copyPass.material.blending=0,this.timer=new Ld}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let t=0,r=this.passes.length;t<r;t++){let r=this.passes[t];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}fI!==void 0&&(r instanceof fI?n=!0:r instanceof pI&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new q);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},hI=class extends sI{constructor(e,t,n=null,r=null,i=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=i,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new X}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let i,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(i=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==1&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(i),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}},gI={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new X(0)},defaultOpacity:{value:0}},vertexShader:`
5906
5906
 
5907
5907
  varying vec2 vUv;
5908
5908
 
@@ -5934,7 +5934,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
5934
5934
 
5935
5935
  gl_FragColor = mix( outputColor, texel, alpha );
5936
5936
 
5937
- }`},aI=class e extends YF{constructor(e,t=1,n,r){super(),this.strength=t,this.radius=n,this.threshold=r,this.resolution=e===void 0?new q(256,256):new q(e.x,e.y),this.clearColor=new X(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new va(i,a,{type:Zn}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new va(i,a,{type:Zn});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let n=new va(i,a,{type:Zn});n.texture.name=`UnrealBloomPass.v`+e,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),i=Math.round(i/2),a=Math.round(a/2)}let o=iI;this.highPassUniforms=Cu.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new Eu({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];let s=[6,10,14,18,22];i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(s[e])),this.separableBlurMaterials[e].uniforms.invSize.value=new q(1/i,1/a),i=Math.round(i/2),a=Math.round(a/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;let c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=Cu.clone(JF.uniforms),this.blendMaterial=new Eu({uniforms:this.copyUniforms,vertexShader:JF.vertexShader,fragmentShader:JF.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new X,this._oldClearAlpha=1,this._basic=new Ms,this._fsQuad=new QF(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(n,r),this.renderTargetsVertical[e].setSize(n,r),this.separableBlurMaterials[e].uniforms.invSize.value=new q(1/n,1/r),n=Math.round(n/2),r=Math.round(r/2)}render(t,n,r,i,a){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();let o=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),a&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=r.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let s=this.renderTargetBright;for(let n=0;n<this.nMips;n++)this._fsQuad.material=this.separableBlurMaterials[n],this.separableBlurMaterials[n].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[n]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[n].uniforms.colorTexture.value=this.renderTargetsHorizontal[n].texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[n]),t.clear(),this._fsQuad.render(t),s=this.renderTargetsVertical[n];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(r),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=o}_getSeparableBlurMaterial(e){let t=[],n=e/3;for(let r=0;r<e;r++)t.push(.39894*Math.exp(-.5*r*r/(n*n))/n);return new Eu({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new q(.5,.5)},direction:{value:new q(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
5937
+ }`},_I=class e extends sI{constructor(e,t=1,n,r){super(),this.strength=t,this.radius=n,this.threshold=r,this.resolution=e===void 0?new q(256,256):new q(e.x,e.y),this.clearColor=new X(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new va(i,a,{type:Zn}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new va(i,a,{type:Zn});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let n=new va(i,a,{type:Zn});n.texture.name=`UnrealBloomPass.v`+e,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),i=Math.round(i/2),a=Math.round(a/2)}let o=gI;this.highPassUniforms=Cu.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new Eu({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];let s=[6,10,14,18,22];i=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(s[e])),this.separableBlurMaterials[e].uniforms.invSize.value=new q(1/i,1/a),i=Math.round(i/2),a=Math.round(a/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;let c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=Cu.clone(oI.uniforms),this.blendMaterial=new Eu({uniforms:this.copyUniforms,vertexShader:oI.vertexShader,fragmentShader:oI.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new X,this._oldClearAlpha=1,this._basic=new Ms,this._fsQuad=new uI(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(n,r),this.renderTargetsVertical[e].setSize(n,r),this.separableBlurMaterials[e].uniforms.invSize.value=new q(1/n,1/r),n=Math.round(n/2),r=Math.round(r/2)}render(t,n,r,i,a){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();let o=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),a&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=r.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let s=this.renderTargetBright;for(let n=0;n<this.nMips;n++)this._fsQuad.material=this.separableBlurMaterials[n],this.separableBlurMaterials[n].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[n]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[n].uniforms.colorTexture.value=this.renderTargetsHorizontal[n].texture,this.separableBlurMaterials[n].uniforms.direction.value=e.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[n]),t.clear(),this._fsQuad.render(t),s=this.renderTargetsVertical[n];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(r),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=o}_getSeparableBlurMaterial(e){let t=[],n=e/3;for(let r=0;r<e;r++)t.push(.39894*Math.exp(-.5*r*r/(n*n))/n);return new Eu({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new q(.5,.5)},direction:{value:new q(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
5938
5938
 
5939
5939
  varying vec2 vUv;
5940
5940
 
@@ -6016,7 +6016,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
6016
6016
  float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
6017
6017
  gl_FragColor = vec4( bloom, bloomAlpha );
6018
6018
 
6019
- }`})}};aI.BlurDirectionX=new q(1,0),aI.BlurDirectionY=new q(0,1);var oI={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
6019
+ }`})}};_I.BlurDirectionX=new q(1,0),_I.BlurDirectionY=new q(0,1);var vI={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
6020
6020
  precision highp float;
6021
6021
 
6022
6022
  uniform mat4 modelViewMatrix;
@@ -6087,7 +6087,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
6087
6087
 
6088
6088
  #endif
6089
6089
 
6090
- }`},sI=class extends YF{constructor(){super(),this.isOutputPass=!0,this.uniforms=Cu.clone(oI.uniforms),this.material=new Du({name:oI.name,uniforms:this.uniforms,vertexShader:oI.vertexShader,fragmentShader:oI.fragmentShader}),this._fsQuad=new QF(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={},aa.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()}};function cI(e){return e.isCSS2DObject===!0}var lI=NaN,uI=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),cI(e)){let n=e.element;this._vector.setFromMatrixPosition(e.matrixWorld),this._vector.applyMatrix4(this._viewProjectionMatrix);let r=this._vector.z,i=xw(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:lI,ty:lI,cx:lI,cy:lI,display:`__init__`,zIndex:lI,dist2:0},this._cache.set(e,t)),t}hideObject(e){if(cI(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)}}},dI=.5;function fI(e,t){return new X(e).multiplyScalar(t)}var pI=new q(1,1);function mI(e,t){pI.set(e,t)}function hI(e,t=dI){return new Eu({transparent:!0,depthWrite:!1,uniforms:{uColor:{value:fI(e,t)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0}},vertexShader:`
6090
+ }`},yI=class extends sI{constructor(){super(),this.isOutputPass=!0,this.uniforms=Cu.clone(vI.uniforms),this.material=new Du({name:vI.name,uniforms:this.uniforms,vertexShader:vI.vertexShader,fragmentShader:vI.fragmentShader}),this._fsQuad=new uI(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={},aa.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()}};function bI(e){return e.isCSS2DObject===!0}var xI=NaN,SI=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),bI(e)){let n=e.element;this._vector.setFromMatrixPosition(e.matrixWorld),this._vector.applyMatrix4(this._viewProjectionMatrix);let r=this._vector.z,i=jw(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:xI,ty:xI,cx:xI,cy:xI,display:`__init__`,zIndex:xI,dist2:0},this._cache.set(e,t)),t}hideObject(e){if(bI(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)}}},CI=.5;function wI(e,t){return new X(e).multiplyScalar(t)}var TI=new q(1,1);function EI(e,t){TI.set(e,t)}function DI(e,t=CI){return new Eu({transparent:!0,depthWrite:!1,uniforms:{uColor:{value:wI(e,t)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0}},vertexShader:`
6091
6091
  #include <common>
6092
6092
  #include <logdepthbuf_pars_vertex>
6093
6093
  uniform vec3 uCenterOffset;
@@ -6111,7 +6111,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
6111
6111
  gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
6112
6112
  #include <logdepthbuf_fragment>
6113
6113
  }
6114
- `})}function gI(e,t,n=dI,r){return new Eu({defines:r?{DASHED:``}:{},transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:fI(e,n)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0},uLineWidth:{value:t},uResolution:{value:pI},uDash:{value:new q(r?.[0]??0,r?.[1]??0)}},vertexShader:`
6114
+ `})}function OI(e,t,n=CI,r){return new Eu({defines:r?{DASHED:``}:{},transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:wI(e,n)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0},uLineWidth:{value:t},uResolution:{value:TI},uDash:{value:new q(r?.[0]??0,r?.[1]??0)}},vertexShader:`
6115
6115
  #include <common>
6116
6116
  #include <logdepthbuf_pars_vertex>
6117
6117
  uniform vec3 uCenterOffset;
@@ -6171,7 +6171,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
6171
6171
  gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
6172
6172
  #include <logdepthbuf_fragment>
6173
6173
  }
6174
- `})}var _I=16;function vI(e){e.materialHighPassFilter.dispose(),e.materialHighPassFilter=new Eu({uniforms:e.highPassUniforms,vertexShader:`
6174
+ `})}var kI=16;function AI(e){e.materialHighPassFilter.dispose(),e.materialHighPassFilter=new Eu({uniforms:e.highPassUniforms,vertexShader:`
6175
6175
  varying vec2 vUv;
6176
6176
  void main() {
6177
6177
  vUv = uv;
@@ -6190,7 +6190,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
6190
6190
  // A sliver of a pixel is rounding, not light.
6191
6191
  ivec2 first = max(ivec2(floor(lo + 0.001)), ivec2(0));
6192
6192
  ivec2 last = min(ivec2(ceil(hi - 0.001)) - 1, ivec2(size) - 1);
6193
- last = min(last, first + ${_I-1});
6193
+ last = min(last, first + ${kI-1});
6194
6194
  vec3 sum = vec3(0.0);
6195
6195
  for (int y = first.y; y <= last.y; y++) {
6196
6196
  float wy = min(float(y) + 1.0, hi.y) - max(float(y), lo.y);
@@ -6204,7 +6204,7 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
6204
6204
  }
6205
6205
  gl_FragColor = vec4(sum / (span.x * span.y), 1.0);
6206
6206
  }
6207
- `})}var yI=`
6207
+ `})}var jI=`
6208
6208
  vec3 outputDither(vec3 color) {
6209
6209
  // ES 1.00 gives gl_FragCoord at medium precision. Copy it before the arithmetic.
6210
6210
  vec3 p3 = gl_FragCoord.xyx;
@@ -6217,8 +6217,8 @@ vTileOff = position - uTileAnchor;`),e.fragmentShader=e.fragmentShader.replace(`
6217
6217
  vec3 amplitude = clamp(min(color, 1.0 - color) * 255.0, 0.0, 1.0);
6218
6218
  return color + noise * amplitude / 255.0;
6219
6219
  }
6220
- `;function bI(e){e.material.fragmentShader=e.material.fragmentShader.replace(`#include <colorspace_pars_fragment>`,`#include <colorspace_pars_fragment>\n${yI}`).replace(/}\s*$/,`gl_FragColor.rgb = outputDither(gl_FragColor.rgb);
6221
- }`)}var xI=1e5;function SI(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var CI=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function wI(e,t,n){let r,i=SI();i||Cw();try{r=new Th(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new CI(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),yw(r.capabilities.reversedDepthBuffer);let a=CE();r.setPixelRatio(wE()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,mI(e.clientWidth,e.clientHeight);let o=new uI({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new no,c=new kd(16777215,KS);s.add(c);let l=new Od(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 xd(60,e.clientWidth/e.clientHeight,Q(.001),xI),d=new va(e.clientWidth,e.clientHeight,{type:Zn,resolveDepthBuffer:!1,depthTexture:new Jc(e.clientWidth,e.clientHeight,Xn)}),f=r.getContext(),p=f.getInternalformatParameter(f.RENDERBUFFER,f.RGBA16F,f.SAMPLES),m=new nI(r,d);m.setPixelRatio(wE()),m.setSize(e.clientWidth,e.clientHeight),m.addPass(new rI(s,u));let h=new aI(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);vI(h),m.addPass(h);let g=new sI;return bI(g),g.needsSwap=!1,m.addPass(g),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:m,maxSceneSamples:p?.[0]??0,bloomPass:h,ambientLight:c,shadowLight:l}}function TI(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=>{let r=n.place(e,s);if(!r)return;p.set(r[0]-m,r[1]-h,r[2]-g);let o=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!xw(p.z))return;let c=(p.x+1)*.5*i,u=(1-p.y)*.5*a,x=Math.hypot(c-d,u-f);(x<y||x===y&&o<b)&&(l&&!l(p.x,p.y,o)||(y=x,b=o,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===G.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var EI=9;function DI(e){let t=e;for(;t.parent?.parent;)t=t.parent;return!t.visible}var OI=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Qd;_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>EI)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,...Ij]))?.body,o=TI(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;let i=this.ctx.place(n,r);if(!i)continue;let a=this.worldDistOf(i);if(this.isDotVisible(e.ndcX,e.ndcY,a))return{body:n,distance:a,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e[0]-t-i.x,e[1]-n-i.y,e[2]-r-i.z)}resolveMeshHit(e){for(let t of e){if(DI(t.object))continue;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&&Ij.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);Ij.size>0&&r.push(...this.raycaster.intersectObjects([...Ij],!0));let i=1/0;for(let e of r)e.distance<i&&!DI(e.object)&&(i=e.distance);return i>=n*.999}},kI=4,AI=16,jI=`
6220
+ `;function MI(e){e.material.fragmentShader=e.material.fragmentShader.replace(`#include <colorspace_pars_fragment>`,`#include <colorspace_pars_fragment>\n${jI}`).replace(/}\s*$/,`gl_FragColor.rgb = outputDither(gl_FragColor.rgb);
6221
+ }`)}var NI=1e5;function PI(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var FI=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function II(e,t,n){let r,i=PI();i||Nw();try{r=new Th(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new FI(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),kw(r.capabilities.reversedDepthBuffer);let a=NE();r.setPixelRatio(PE()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,EI(e.clientWidth,e.clientHeight);let o=new SI({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new no,c=new kd(16777215,nC);s.add(c);let l=new Od(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 xd(60,e.clientWidth/e.clientHeight,Q(.001),NI),d=new va(e.clientWidth,e.clientHeight,{type:Zn,resolveDepthBuffer:!1,depthTexture:new Jc(e.clientWidth,e.clientHeight,Xn)}),f=r.getContext(),p=f.getInternalformatParameter(f.RENDERBUFFER,f.RGBA16F,f.SAMPLES),m=new mI(r,d);m.setPixelRatio(PE()),m.setSize(e.clientWidth,e.clientHeight),m.addPass(new hI(s,u));let h=new _I(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);AI(h),m.addPass(h);let g=new yI;return MI(g),g.needsSwap=!1,m.addPass(g),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:m,maxSceneSamples:p?.[0]??0,bloomPass:h,ambientLight:c,shadowLight:l}}function LI(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=>{let r=n.place(e,s);if(!r)return;p.set(r[0]-m,r[1]-h,r[2]-g);let o=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!jw(p.z))return;let c=(p.x+1)*.5*i,u=(1-p.y)*.5*a,x=Math.hypot(c-d,u-f);(x<y||x===y&&o<b)&&(l&&!l(p.x,p.y,o)||(y=x,b=o,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===G.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var RI=9;function zI(e){let t=e;for(;t.parent?.parent;)t=t.parent;return!t.visible}var BI=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Qd;_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>RI)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,...qj]))?.body,o=LI(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;let i=this.ctx.place(n,r);if(!i)continue;let a=this.worldDistOf(i);if(this.isDotVisible(e.ndcX,e.ndcY,a))return{body:n,distance:a,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e[0]-t-i.x,e[1]-n-i.y,e[2]-r-i.z)}resolveMeshHit(e){for(let t of e){if(zI(t.object))continue;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&&qj.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);qj.size>0&&r.push(...this.raycaster.intersectObjects([...qj],!0));let i=1/0;for(let e of r)e.distance<i&&!zI(e.object)&&(i=e.distance);return i>=n*.999}},VI=4,HI=16,UI=`
6222
6222
  uniform mat4 modelViewMatrix;
6223
6223
  uniform mat4 projectionMatrix;
6224
6224
  uniform float uPointSize;
@@ -6230,13 +6230,13 @@ void main() {
6230
6230
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
6231
6231
  gl_PointSize = uPointSize;
6232
6232
  }
6233
- `,MI=`
6233
+ `,WI=`
6234
6234
  precision highp float;
6235
6235
  varying vec4 vPick;
6236
6236
  void main() {
6237
6237
  gl_FragColor = vPick;
6238
6238
  }
6239
- `,NI=class{target;material;scene=new no;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new va(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=ai,this.target.texture.generateMipmaps=!1,this.material=new Du({vertexShader:jI,fragmentShader:MI,uniforms:{uPointSize:{value:kI}},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 Wc(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,AI)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function PI(e,t,n){return Math.min(Math.max(e,t),n)}function FI(e,t){let n=Math.max(e,0);return PI(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function II(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return PI(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var LI={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},RI={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},zI={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},BI={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},VI=new J(0,1,0),HI=(()=>{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=yg*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 UI(e){return(e??new J).copy(HI)}function WI(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&e.position&&(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(VI),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=SS(e.orientation,t,e.nutPrec);return i.copy(VI).applyQuaternion(a).normalize()}var GI=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=RI.refMs;needsDurationCalc=!1;_quatA=new Zi;_quatB=new Zi;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`)UI(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);WI(t,e,this.targetVec,n)}else this.targetVec.copy(VI)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=FI(e,RI)}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(VI,this.startVec),this._quatB.setFromUnitVectors(VI,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy(VI).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,VI),n._quatInverse.copy(n._quat).invert()}},KI=6*.8*Math.PI*(4/2)**2,qI=.9,JI=.125,YI=.6,XI=1.5;function ZI(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,$I(e,1)),a.addColorStop(.15,$I(e,1)),a.addColorStop(.4,$I(e,.3)),a.addColorStop(1,$I(e,0)),r.fillStyle=a,r.fillRect(0,0,t,t),new qc(n)}function QI(e){return`rgb(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)})`}function $I(e,t){return e.replace(`)`,`, ${t})`).replace(`rgb(`,`rgba(`)}var eL=`#fff5eb`,tL=`#ffd9a8`;function nL(){let e=new X(eL),t=new X(tL);return new Eu({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)},...kN()},vertexShader:`
6239
+ `,GI=class{target;material;scene=new no;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new va(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=ai,this.target.texture.generateMipmaps=!1,this.material=new Du({vertexShader:UI,fragmentShader:WI,uniforms:{uPointSize:{value:VI}},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 Wc(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,HI)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function KI(e,t,n){return Math.min(Math.max(e,t),n)}function qI(e,t){let n=Math.max(e,0);return KI(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function JI(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return KI(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var YI={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},XI={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},ZI={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},QI={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},$I=new J(0,1,0),eL=(()=>{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=yg*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 tL(e){return(e??new J).copy(eL)}function nL(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&e.position&&(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($I),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=SS(e.orientation,t,e.nutPrec);return i.copy($I).applyQuaternion(a).normalize()}var rL=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=XI.refMs;needsDurationCalc=!1;_quatA=new Zi;_quatB=new Zi;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`)tL(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);nL(t,e,this.targetVec,n)}else this.targetVec.copy($I)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=qI(e,XI)}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($I,this.startVec),this._quatB.setFromUnitVectors($I,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy($I).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,$I),n._quatInverse.copy(n._quat).invert()}},iL=6*.8*Math.PI*(4/2)**2,aL=.9,oL=.125,sL=.6,cL=1.5;function lL(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,dL(e,1)),a.addColorStop(.15,dL(e,1)),a.addColorStop(.4,dL(e,.3)),a.addColorStop(1,dL(e,0)),r.fillStyle=a,r.fillRect(0,0,t,t),new qc(n)}function uL(e){return`rgb(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)})`}function dL(e,t){return e.replace(`)`,`, ${t})`).replace(`rgb(`,`rgba(`)}var fL=`#fff5eb`,pL=`#ffd9a8`;function mL(){let e=new X(fL),t=new X(pL);return new Eu({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)},...VN()},vertexShader:`
6240
6240
  #include <common>
6241
6241
  #include <logdepthbuf_pars_vertex>
6242
6242
  varying vec3 vNormalView;
@@ -6259,7 +6259,7 @@ void main() {
6259
6259
  varying vec3 vNormalView;
6260
6260
  varying vec3 vViewDir;
6261
6261
  varying vec3 vWorldPos;
6262
- ${vN}
6262
+ ${AN}
6263
6263
  void main() {
6264
6264
  #include <logdepthbuf_fragment>
6265
6265
  float mu = max(dot(normalize(vNormalView), normalize(vViewDir)), 0.0);
@@ -6274,7 +6274,7 @@ void main() {
6274
6274
  vec3 hdr = tint * darkening * ${6 .toFixed(1)};
6275
6275
  gl_FragColor = vec4(atmoViewTint(vWorldPos) * hdr, 1.0);
6276
6276
  }
6277
- `})}function rL(e,t){let n=new Ss(new cs({map:ZI(t.startsWith(`#`)?QI(t):t),blending:2,transparent:!0,opacity:YI,depthWrite:!1,depthTest:!0})),r=e*6;return n.scale.set(r,r,1),n}function iL(e){let t=Math.ceil(e/2),n=0;for(let r=-t;r<t;r++)for(let i=-t;i<t;i++)(i+.5)**2+(r+.5)**2<=e*e/4&&n++;return n}function aL(e){let t=new ns;t.setAttribute(`position`,new Wo(new Float32Array(3),3));let n=new X(e),r=new X(eL),i=new ga(0,0,1,1),a=4 .toFixed(1),o={uColor:{value:new J(n.r,n.g,n.b)},uDiscColor:{value:new J(r.r,r.g,r.b)},uFlux:{value:1},uPixelRatio:{value:1},uPixels:{value:iL(4)},uViewport:{value:i},uTint:{value:new J(1,1,1)}},s=new Wc(t,new Eu({uniforms:o,vertexShader:`
6277
+ `})}function hL(e,t){let n=new Ss(new cs({map:lL(t.startsWith(`#`)?uL(t):t),blending:2,transparent:!0,opacity:sL,depthWrite:!1,depthTest:!0})),r=e*6;return n.scale.set(r,r,1),n}function gL(e){let t=Math.ceil(e/2),n=0;for(let r=-t;r<t;r++)for(let i=-t;i<t;i++)(i+.5)**2+(r+.5)**2<=e*e/4&&n++;return n}function _L(e){let t=new ns;t.setAttribute(`position`,new Wo(new Float32Array(3),3));let n=new X(e),r=new X(fL),i=new ga(0,0,1,1),a=4 .toFixed(1),o={uColor:{value:new J(n.r,n.g,n.b)},uDiscColor:{value:new J(r.r,r.g,r.b)},uFlux:{value:1},uPixelRatio:{value:1},uPixels:{value:gL(4)},uViewport:{value:i},uTint:{value:new J(1,1,1)}},s=new Wc(t,new Eu({uniforms:o,vertexShader:`
6278
6278
  #include <common>
6279
6279
  #include <logdepthbuf_pars_vertex>
6280
6280
  uniform float uPixelRatio;
@@ -6283,7 +6283,7 @@ void main() {
6283
6283
  void main() {
6284
6284
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
6285
6285
  vec2 halfView = 0.5 * uViewport.zw;
6286
- vec2 seat = floor((gl_Position.xy / gl_Position.w + 1.0) * halfView + ${(.5+JI).toFixed(3)});
6286
+ vec2 seat = floor((gl_Position.xy / gl_Position.w + 1.0) * halfView + ${(.5+oL).toFixed(3)});
6287
6287
  gl_Position.xy = (seat / halfView - 1.0) * gl_Position.w;
6288
6288
  vSeat = uViewport.xy + seat;
6289
6289
  // A margin: the square of the point must not cut the dot.
@@ -6314,9 +6314,9 @@ void main() {
6314
6314
  // The disc's light at the handoff, on all the pixels. With too little
6315
6315
  // for all, the four at the centre have it: the glow goes on for a
6316
6316
  // fainter star.
6317
- float all = ${KI.toFixed(3)} * uFlux * uPixelRatio * uPixelRatio / uPixels;
6317
+ float all = ${iL.toFixed(3)} * uFlux * uPixelRatio * uPixelRatio / uPixels;
6318
6318
  float four = all * uPixels / 4.0;
6319
- float value = clamp(all, ${qI.toFixed(1)}, under);
6319
+ float value = clamp(all, ${aL.toFixed(1)}, under);
6320
6320
  if (all >= over) {
6321
6321
  value = all;
6322
6322
  } else if (four >= over && max(abs(p.x), abs(p.y)) < 1.0) {
@@ -6324,17 +6324,17 @@ void main() {
6324
6324
  }
6325
6325
  gl_FragColor = vec4(colour * value, 1.0);
6326
6326
  }
6327
- `,transparent:!0,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.onBeforeRender=e=>{e.getCurrentViewport(i).floor();let t=e.getPixelRatio();t!==o.uPixelRatio.value&&(o.uPixelRatio.value=t,o.uPixels.value=iL(4*t))},s}function oL(e,t,n){let r=new Td(16777215,qS,0,0);e.add(r);let i=rL(t,n);e.add(i);let a=aL(n);return e.add(a),{light:r,corona:i,starPoint:a}}function sL(e,t,n){e&&e.material.color.setRGB(n.x,n.y,n.z),t&&t.material.uniforms.uTint.value.copy(n)}function cL(e,t){if(!e)return;let n=Math.min(Math.max((t-1)/(XI-1),0),1);e.visible=n>0,e.material.opacity=YI*n}function lL(e){let t=e?.uniforms;return t?.uAtmoTEnable?t:null}function uL(e,t){let n=e?.uniforms;t&&n?.uLimbAlpha&&n.uLimbAlpha.value.set(t[0],t[1],t[2])}var dL=`
6327
+ `,transparent:!0,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.onBeforeRender=e=>{e.getCurrentViewport(i).floor();let t=e.getPixelRatio();t!==o.uPixelRatio.value&&(o.uPixelRatio.value=t,o.uPixels.value=gL(4*t))},s}function vL(e,t,n){let r=new Td(16777215,rC,0,0);e.add(r);let i=hL(t,n);e.add(i);let a=_L(n);return e.add(a),{light:r,corona:i,starPoint:a}}function yL(e,t,n){e&&e.material.color.setRGB(n.x,n.y,n.z),t&&t.material.uniforms.uTint.value.copy(n)}function bL(e,t){if(!e)return;let n=Math.min(Math.max((t-1)/(cL-1),0),1);e.visible=n>0,e.material.opacity=sL*n}function xL(e){let t=e?.uniforms;return t?.uAtmoTEnable?t:null}function SL(e,t){let n=e?.uniforms;t&&n?.uLimbAlpha&&n.uLimbAlpha.value.set(t[0],t[1],t[2])}var CL=`
6328
6328
  uniform vec3 uEyeAnchor;
6329
6329
  uniform vec3 uEyeAnchorView;
6330
- `,fL=`
6330
+ `,wL=`
6331
6331
  vec4 mvPosition = vec4( mat3( modelViewMatrix ) * ( transformed - uEyeAnchor ) + uEyeAnchorView, 1.0 );
6332
6332
  gl_Position = projectionMatrix * mvPosition;
6333
- `,pL=new WeakMap,mL=new Y,hL=new Y,gL=new J;function _L(e,t){US(e,`cameraRelative`,e=>{e.uniforms.uEyeAnchor=t.local,e.uniforms.uEyeAnchorView=t.view,e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>\n${dL}`).replace(`#include <project_vertex>`,fL)})}function vL(e,t){let n={local:{value:new J},view:{value:new J}};pL.set(t,n),_L(t,n),e.onBeforeRender=(t,r,i)=>{mL.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),gL.setFromMatrixPosition(hL.copy(mL).invert()),n.local.value.set(Math.fround(gL.x),Math.fround(gL.y),Math.fround(gL.z)),n.view.value.copy(n.local.value).applyMatrix4(mL)}}function yL(e,t){let n=pL.get(e);n&&_L(t,n)}function bL(e){if(Array.isArray(e))for(let t of e)t.dispose();else e.dispose()}var xL=96,SL=24;function CL(e,t,n,r,i,o,s,c,l){for(let u of e){let e=u.data.id,d=l?.has(e)??!1,f=u.data.objectType,p=d||f===G.BARYCENTER||f===G.LAGRANGE_POINT||f===G.COMET||Sn(f)||u.data.orbitalSource===W.SPICE_PROBE,m=av(u.data),h=Q(xn(u.data)),g=f===G.STAR,_=Dj(u),v=Number.isFinite(u.data.radiusKm)&&u.data.radiusKm>0,y=!_&&wn(f)&&!v?`radius`:void 0,b=new Ja;b.visible=!1;let x=new Ja;b.add(x);let S=null,C=null,w=null,T=null,E=null,D=null,O;if(!p&&!y){g&&(C=oL(b,h,m));let t=g?xL:SL,i=new _u(h,t,t),a=g?nL():new Ou({color:UA(u.data)});S=new Ws(i,a),_&&(S.visible=!1),g||(w=Gw(a),vL(S,a),E=NA(u.data.lunarWeightScale),LA(a,e,E),_||(T=xT(a))),b.add(S),n.push(S),r.set(S,u);let o=g?void 0:Yb(e);o&&(D=iT(o,h,xn(u.data)),b.add(D.mesh),w&&(O=[jN(a,o,h,xn(u.data),w,D)]))}let k=JN(u),A=g||f===G.PLANET,j=d||iv.has(e)||u.data.isMinor===!0,M=YN(m,u.data.name??``,k,a().bodyHref(e,u.data.name??``),()=>s(u),A,c?t=>c(e,t):void 0,j);M&&(IT(M.element,o),x.add(M)),t.add(b);let N=M?M.element.firstElementChild:null;N&&(N.dataset.origBorder=N.style.border),i.set(e,{body:u,root:b,group:x,mesh:S,label:M,labelHalo:N,labelStack:null,loadingEl:null,corona:C?.corona??null,starPoint:C?.starPoint??null,trail:null,radiusScene:h,cachedDist:0,currentSegments:p||y?void 0:g?xL:SL,isMinor:j,noPhysical:y,rings:[],clouds:null,atmosphere:D,sunTint:O,specularMap:null,emissiveMap:null,displacementMap:null,selfShadow:null,eclipseShadow:w,planetshine:T,photometry:E,nomenclatureLabels:null,model:null})}}function wL(e){let t=e.data.objectType;return t===G.COMET||Sn(t)||e.data.orbitalSource===W.SPICE_PROBE}function TL(e,t,n,r){if(e.mesh!==null)return;let{body:i,radiusScene:a}=e;e.focusUpgraded=!0;let o=Dj(i);if(!o&&!(Number.isFinite(i.data.radiusKm)&&i.data.radiusKm>0)){e.noPhysical=`radius`;return}let s=SL,c=new _u(a,s,s),l=new Ou({color:UA(i.data)}),u=new Ws(c,l);o&&(u.visible=!1),e.root.add(u),e.mesh=u,n.push(u),r.set(u,i),e.eclipseShadow=Gw(l),vL(u,l),e.photometry=NA(i.data.lunarWeightScale),LA(l,i.data.id,e.photometry),o||(e.planetshine=xT(l)),e.currentSegments=s;let d=Yb(i.data.id);d&&(e.atmosphere=iT(d,a,xn(i.data)),e.root.add(e.atmosphere.mesh),e.sunTint=[jN(l,d,a,xn(i.data),e.eclipseShadow,e.atmosphere)])}function EL(e,t,n,r){e.focusUpgraded=!1,Hj(e);let i=e.mesh;if(i){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementTier=void 0,kD(e.selfShadow),e.selfShadow=null),tP(e),e.tileOverlay=void 0,gD(e),e.reliefTiles=void 0,e.terrainWindow=null,i.removeFromParent(),i.geometry.dispose(),bL(i.material);let t=n.indexOf(i);t>=0&&n.splice(t,1),r.delete(i),e.mesh=null,e.currentSegments=void 0,e.eclipseShadow=null,e.planetshine=null,e.photometry=null,e.sunTint=void 0,e.radiiApplied=!1,e.semiAxesScene=void 0}if(e.atmosphere){let t=e.atmosphere.mesh;t.removeFromParent(),t.geometry.dispose(),bL(t.material),e.atmosphere=null}let a=e.body.data.orbitalSource===W.SPICE_PROBE;e.trail&&!a&&(t.remove(e.trail),e.trail.geometry.dispose(),bL(e.trail.material),e.trail=null)}var DL=class{#e;#t=new J;#n=new q;#r=new WeakMap;#i=[];constructor(e,t){this.#e=OL(e,t)}setSize(e,t){this.#e.dispose(),this.#e.depthTexture?.dispose(),this.#e=OL(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=+!!bw(),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 ju,yL(n,r),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 OL(e,t){let n=new va(e,t);return n.depthTexture=new Jc(e,t,Xn),n}var kL=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&&AL(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),jL(i,r,t,()=>this.wanted.get(n)))}}}};function AL(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,UA(e.body.data,r.color),r.needsUpdate=!0,e.model&&kA(e.model,null,r.color),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?aN(r,e):oN(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 jL(e,t,n,r){let i=e.appearance??={};if(i.loading)return;let a=NL(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 PL(t.surface,n);if(r()!==t)return void a?.dispose();let o=NL(e);a&&o&&(AA(o,a),e.model&&kA(e.model,a,UA(e.body.data)),i.surfaceUrl=t.surface,i.surfaceMap=a)}if(s){let a=await PL(t.night,n);if(r()!==t)return void a?.dispose();let o=NL(e);a&&o&&(i.displacedNight??=o.emissiveMap,aN(o,a),i.nightUrl=t.night,i.nightMap=a)}if(c){let a=await PL(t.clouds,n);if(r()!==t)return void a?.dispose();a&&e.mesh&&ML(e,i,a,t.clouds)}}finally{i.loading=!1}}}function ML(e,t,n,r){n.anisotropy=16;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=ZM(e.mesh,e.radiusScene,n),e.clouds=i,t.ownCloudNode=!0}i.availableTiers=[],i.availableFrames=[],t.cloudsUrl=r,t.cloudsMap=n}function NL(e){return e.mesh?e.mesh.material:null}async function PL(e,t){try{let n=await new Promise((n,r)=>{t.load(e,n,void 0,r)});return n.colorSpace=ii,n}catch(t){return console.warn(`spacemap: could not load the picture at ${e}:`,t),null}}var FL=`
6333
+ `,TL=new WeakMap,EL=new Y,DL=new Y,OL=new J;function kL(e,t){$S(e,`cameraRelative`,e=>{e.uniforms.uEyeAnchor=t.local,e.uniforms.uEyeAnchorView=t.view,e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>\n${CL}`).replace(`#include <project_vertex>`,wL)})}function AL(e,t){let n={local:{value:new J},view:{value:new J}};TL.set(t,n),kL(t,n),e.onBeforeRender=(t,r,i)=>{EL.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),OL.setFromMatrixPosition(DL.copy(EL).invert()),n.local.value.set(Math.fround(OL.x),Math.fround(OL.y),Math.fround(OL.z)),n.view.value.copy(n.local.value).applyMatrix4(EL)}}function jL(e,t){let n=TL.get(e);n&&kL(t,n)}function ML(e){if(Array.isArray(e))for(let t of e)t.dispose();else e.dispose()}var NL=96,PL=24;function FL(e,t,n,r,i,o,s,c,l){for(let u of e){let e=u.data.id,d=l?.has(e)??!1,f=u.data.objectType,p=d||f===G.BARYCENTER||f===G.LAGRANGE_POINT||f===G.COMET||Sn(f)||u.data.orbitalSource===W.SPICE_PROBE,m=av(u.data),h=Q(xn(u.data)),g=f===G.STAR,_=Rj(u),v=Number.isFinite(u.data.radiusKm)&&u.data.radiusKm>0,y=!_&&wn(f)&&!v?`radius`:void 0,b=new Ja;b.visible=!1;let x=new Ja;b.add(x);let S=null,C=null,w=null,T=null,E=null,D=null,O;if(!p&&!y){g&&(C=vL(b,h,m));let t=g?NL:PL,i=new _u(h,t,t),a=g?mL():new Ou({color:ej(u.data)});S=new Ws(i,a),_&&(S.visible=!1),g||(w=tT(a),AL(S,a),E=WA(u.data.lunarWeightScale),JA(a,e,E),_||(T=jT(a))),b.add(S),n.push(S),r.set(S,u);let o=g?void 0:Yb(e);o&&(D=mT(o,h,xn(u.data)),b.add(D.mesh),w&&(O=[UN(a,o,h,xn(u.data),w,D)]))}let k=oP(u),A=g||f===G.PLANET,j=d||iv.has(e)||u.data.isMinor===!0,M=sP(m,u.data.name??``,k,a().bodyHref(e,u.data.name??``),()=>s(u),A,c?t=>c(e,t):void 0,j);M&&(KT(M.element,o),x.add(M)),t.add(b);let N=M?M.element.firstElementChild:null;N&&(N.dataset.origBorder=N.style.border),i.set(e,{body:u,root:b,group:x,mesh:S,label:M,labelHalo:N,labelStack:null,loadingEl:null,corona:C?.corona??null,starPoint:C?.starPoint??null,trail:null,radiusScene:h,cachedDist:0,currentSegments:p||y?void 0:g?NL:PL,isMinor:j,noPhysical:y,rings:[],clouds:null,atmosphere:D,sunTint:O,specularMap:null,emissiveMap:null,displacementMap:null,selfShadow:null,eclipseShadow:w,planetshine:T,photometry:E,nomenclatureLabels:null,model:null})}}function IL(e){let t=e.data.objectType;return t===G.COMET||Sn(t)||e.data.orbitalSource===W.SPICE_PROBE}function LL(e,t,n,r){if(e.mesh!==null)return;let{body:i,radiusScene:a}=e;e.focusUpgraded=!0;let o=Rj(i);if(!o&&!(Number.isFinite(i.data.radiusKm)&&i.data.radiusKm>0)){e.noPhysical=`radius`;return}let s=PL,c=new _u(a,s,s),l=new Ou({color:ej(i.data)}),u=new Ws(c,l);o&&(u.visible=!1),e.root.add(u),e.mesh=u,n.push(u),r.set(u,i),e.eclipseShadow=tT(l),AL(u,l),e.photometry=WA(i.data.lunarWeightScale),JA(l,i.data.id,e.photometry),o||(e.planetshine=jT(l)),e.currentSegments=s;let d=Yb(i.data.id);d&&(e.atmosphere=mT(d,a,xn(i.data)),e.root.add(e.atmosphere.mesh),e.sunTint=[UN(l,d,a,xn(i.data),e.eclipseShadow,e.atmosphere)])}function RL(e,t,n,r){e.focusUpgraded=!1,$j(e);let i=e.mesh;if(i){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementTier=void 0,BD(e.selfShadow),e.selfShadow=null),pP(e),e.tileOverlay=void 0,DD(e),e.reliefTiles=void 0,e.terrainWindow=null,i.removeFromParent(),i.geometry.dispose(),ML(i.material);let t=n.indexOf(i);t>=0&&n.splice(t,1),r.delete(i),e.mesh=null,e.currentSegments=void 0,e.eclipseShadow=null,e.planetshine=null,e.photometry=null,e.sunTint=void 0,e.radiiApplied=!1,e.semiAxesScene=void 0}if(e.atmosphere){let t=e.atmosphere.mesh;t.removeFromParent(),t.geometry.dispose(),ML(t.material),e.atmosphere=null}let a=e.body.data.orbitalSource===W.SPICE_PROBE;e.trail&&!a&&(t.remove(e.trail),e.trail.geometry.dispose(),ML(e.trail.material),e.trail=null)}var zL=class{#e;#t=new J;#n=new q;#r=new WeakMap;#i=[];constructor(e,t){this.#e=BL(e,t)}setSize(e,t){this.#e.dispose(),this.#e.depthTexture?.dispose(),this.#e=BL(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=+!!Aw(),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 ju,jL(n,r),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 BL(e,t){let n=new va(e,t);return n.depthTexture=new Jc(e,t,Xn),n}var VL=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&&HL(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),UL(i,r,t,()=>this.wanted.get(n)))}}}};function HL(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,ej(e.body.data,r.color),r.needsUpdate=!0,e.model&&BA(e.model,null,r.color),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?_N(r,e):vN(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 UL(e,t,n,r){let i=e.appearance??={};if(i.loading)return;let a=GL(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 KL(t.surface,n);if(r()!==t)return void a?.dispose();let o=GL(e);a&&o&&(VA(o,a),e.model&&BA(e.model,a,ej(e.body.data)),i.surfaceUrl=t.surface,i.surfaceMap=a)}if(s){let a=await KL(t.night,n);if(r()!==t)return void a?.dispose();let o=GL(e);a&&o&&(i.displacedNight??=o.emissiveMap,_N(o,a),i.nightUrl=t.night,i.nightMap=a)}if(c){let a=await KL(t.clouds,n);if(r()!==t)return void a?.dispose();a&&e.mesh&&WL(e,i,a,t.clouds)}}finally{i.loading=!1}}}function WL(e,t,n,r){n.anisotropy=16;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=lN(e.mesh,e.radiusScene,n),e.clouds=i,t.ownCloudNode=!0}i.availableTiers=[],i.availableFrames=[],t.cloudsUrl=r,t.cloudsMap=n}function GL(e){return e.mesh?e.mesh.material:null}async function KL(e,t){try{let n=await new Promise((n,r)=>{t.load(e,n,void 0,r)});return n.colorSpace=ii,n}catch(t){return console.warn(`spacemap: could not load the picture at ${e}:`,t),null}}var qL=`
6334
6334
  void main() {
6335
6335
  gl_Position = vec4(position.xy, 0.0, 1.0);
6336
6336
  }
6337
- `,IL=`
6337
+ `,JL=`
6338
6338
  uniform sampler2D uSceneDepth;
6339
6339
  uniform vec2 uResolution;
6340
6340
  uniform float uReversed;
@@ -6351,19 +6351,19 @@ void main() {
6351
6351
  if (uReversed > 0.5 ? d <= 0.0 : d >= 1.0) discard;
6352
6352
  float w = (uReversed > 0.5
6353
6353
  ? uSceneNear * uSceneFar / (d * (uSceneFar - uSceneNear) + uSceneNear)
6354
- : ${ww(`d`,`uSceneFar`)}) / uUnit;
6354
+ : ${Pw(`d`,`uSceneFar`)}) / uUnit;
6355
6355
  if (w >= uFront) discard;
6356
6356
  gl_FragDepth = uReversed > 0.5
6357
6357
  ? uNear * (uFar - w) / (w * (uFar - uNear))
6358
- : ${Tw(`w`,`uFar`)};
6358
+ : ${Fw(`w`,`uFar`)};
6359
6359
  }
6360
- `,LL=class{#e=new Eu({uniforms:{uSceneDepth:{value:null},uResolution:{value:new q(1,1)},uReversed:{value:0},uSceneNear:{value:1},uSceneFar:{value:2},uNear:{value:1},uFar:{value:2},uUnit:{value:1},uFront:{value:0}},vertexShader:FL,fragmentShader:IL,colorWrite:!1});#t=new QF(this.#e);run(e,t,n,r,i,a){let o=this.#e.uniforms;o.uSceneDepth.value=t,e.getDrawingBufferSize(o.uResolution.value),o.uReversed.value=+!!bw(),o.uSceneNear.value=n.near,o.uSceneFar.value=n.far,o.uNear.value=r.near,o.uFar.value=r.far,o.uUnit.value=i,o.uFront.value=a,this.#t.render(e)}dispose(){this.#t.dispose(),this.#e.dispose()}},RL=34028235e31,zL=3;function BL(e){return new X(e).multiplyScalar(.5)}function VL(){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 qc(e)}function HL(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function UL(e,t,n,r=[0,0,0],i=4,a=null){let o=[];for(let t of e){let e=t.position;e&&Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]))<=RL&&o.push({body:t,at:e})}let 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{body:t,at:n}=o[e];s[e*3]=n[0]-r[0],s[e*3+1]=n[1]-r[1],s[e*3+2]=n[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 ns;u.setAttribute(`position`,new Wo(s,3)),c&&u.setAttribute(`color`,new Wo(c,3));let d=new Wc(u,new zc({map:t,color:c?new X(.5,.5,.5):BL(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=zL,d}function WL(e,t,n,r,i=4,a=null){let o=new ns;o.setAttribute(`position`,new Vo(e,3)),a&&o.setAttribute(`color`,new Vo(a,3)),o.setDrawRange(0,t);let s=new Wc(o,new zc({map:n,color:a?new X(.5,.5,.5):BL(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=zL,s}function GL(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(v_(c,l,e.w,e.i,e.om,e.equatorial))}return o}function KL(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(v_(b,x,a,r,i,e.equatorial))}return l}function qL(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(v_(d,f,e.w,e.i,e.om,e.equatorial))}return o}function JL(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=s_(e,t-i+i*n/r);o&&a.push(o)}return a}function YL(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function XL(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:GL(e,t),isOpen:!0}:!n&&e.e>=1?{points:qL(e,t),isOpen:!0}:{points:KL(e,t),isOpen:!1}}var ZL=3;function QL(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 ns;return c.setAttribute(`position`,new Wo(n,3)),c.setAttribute(`nextPosition`,new Wo(r,3)),c.setAttribute(`side`,new Wo(i,1)),c.setAttribute(`trailAlpha`,new Wo(a,1)),c.setAttribute(`fullAlpha`,new Wo(o,1)),c.setIndex(new Ho(s,1)),c}function $L(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 eR(){let e=new ns;e.setAttribute(`position`,new Wo(new Float32Array(6),3));let t=new Nc(e,new Eu({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=ZL,t}function tR(e,t,n,r,i){let a=new ns;a.setAttribute(`position`,new Wo(e,3)),a.setAttribute(`trailAlpha`,new Wo(t,1)),a.setAttribute(`fullAlpha`,new Wo(n,1)),a.setDrawRange(0,r);let o=new Nc(a,hI(i));return o.matrixAutoUpdate=!1,o.renderOrder=ZL,o}function nR(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 rR(e,t,n,r,i,a,o,s,c){let l=QL(e);c&&l.setAttribute(`lineDistance`,new Wo(new Float32Array(2*e),1)),$L(l,t,n,r,i);let u=new Ws(l,gI(a,o,s,c));return u.matrixAutoUpdate=!1,u.renderOrder=ZL,u}function iR(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 aR(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(Pb(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){$L(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}var oR=1.5;function sR(e){return e>1||wE()>=oR}function cR(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;if(!c)return 0;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 lR(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===G.SPACECRAFT||o.objectType===G.DWARF_PLANET||o.objectType===G.MOON||o.objectType===G.COMET||Sn(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=cR(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&Pb(m.subarray(0,p),h.subarray(0,p),!0,u);let g=sR(i),_=g?rR(d,f,h,m,p,n,i):tR(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 uR(e,t,n=[0,0,0],r=jg(new Date),i=1){if(e.trailBuffer)return lR(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l,u;if(s.satrec)c=JL(s.satrec,r,s.n/360,512),l=!0,u=c.length-1;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=YL(a)}let d=o?.[0]??0,f=o?.[1]??0,p=o?.[2]??0,m=l||s.objectType===G.DWARF_PLANET||s.objectType===G.MOON||s.objectType===G.SPACECRAFT||s.objectType===G.COMET||Sn(s.objectType),h=c?Nb(e,c,l,d,f,p,u):[];if(c&&h.length<2)return eR();let g=c?Math.max(h.length,c.length):513,_=new Float32Array(g),v=new Float32Array(g);Pb(_.subarray(0,h.length),v.subarray(0,h.length),l,m);let y=d-n[0],b=f-n[1],x=p-n[2],S=new Float32Array(g*3);for(let e=0;e<h.length;e++)S[e*3]=h[e][0]+y,S[e*3+1]=h[e][1]+b,S[e*3+2]=h[e][2]+x;let C=sR(i),w=C?rR(g,S,v,_,h.length,t,i):tR(S,v,_,h.length,t);return w.frustumCulled=!1,w.visible=!1,w.userData.orbitCenter=new J(d,f,p),w.userData.trailLocalPositions=c?h:void 0,w.userData.sourceCurve=c??void 0,w.userData.curvePending=c===null,w.userData.isOpenCurve=l,w.userData.useTrail=m,w.userData.curveJd=r,w.userData.elementsJd=a?.epoch??r,C&&(w.userData.isFatLine=!0,w.userData.thinPositions=S,w.userData.thinTrailAlphas=v,w.userData.thinFullAlphas=_),w}function dR(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 fR(e){return e.data.objectType===G.PLANET?4:(e.data.objectType===G.MOON||e.data.objectType===G.DWARF_PLANET)&&W_[e.data.id]?3:1}function pR(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===G.STAR)continue;if(e.data.orbitalSource===W.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&wL(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=uR(e,av(e.data),n,r,fR(e));t.add(a),i.trail=a}}function mR(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=HL();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=dR(c.values(),i);if(e.length===0)continue;let u=av(e[0].data),{buckets:d}=cv(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=UL(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=dy(e.layers,o,dR(c.values(),i));if(l.length===0)continue;let{buckets:u}=cv(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=UL(i,n,`#ffffff`,r,void 0,e=>av(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===G.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=UL(i,n,av(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}}var hR=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===G.BARYCENTER)return e;let n=t?.data.parentId??e;return bv(n)?null:n}load(e){CP(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)wP(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},gR=Math.PI/180,_R=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Zi;_adjustQ=new Zi;_tmpQ=new Zi;_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*gR).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*gR)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*gR)),this._q.copy(NP).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},vR=Math.PI/180,yR=yg*vR,bR=Math.cos(yR),xR=Math.sin(yR),SR=5e3,CR=[{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`}],wR=192.85948,TR=27.12825,ER=266.40499,DR=-28.93617,OR=256,kR=[{name:`galactic-plane`,zero:AR(ER,DR,new J).normalize(),pole:AR(wR,TR,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:AR(0,0,new J).normalize(),pole:AR(0,90,new J).normalize(),color:10325247}];function AR(e,t,n){let r=e*vR,i=t*vR,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*bR+c*xR,d=-s*xR+c*bR;return n.set(l,d,-u)}function jR(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=`
6360
+ `,YL=class{#e=new Eu({uniforms:{uSceneDepth:{value:null},uResolution:{value:new q(1,1)},uReversed:{value:0},uSceneNear:{value:1},uSceneFar:{value:2},uNear:{value:1},uFar:{value:2},uUnit:{value:1},uFront:{value:0}},vertexShader:qL,fragmentShader:JL,colorWrite:!1});#t=new uI(this.#e);run(e,t,n,r,i,a){let o=this.#e.uniforms;o.uSceneDepth.value=t,e.getDrawingBufferSize(o.uResolution.value),o.uReversed.value=+!!Aw(),o.uSceneNear.value=n.near,o.uSceneFar.value=n.far,o.uNear.value=r.near,o.uFar.value=r.far,o.uUnit.value=i,o.uFront.value=a,this.#t.render(e)}dispose(){this.#t.dispose(),this.#e.dispose()}},XL=34028235e31,ZL=3;function QL(e){return new X(e).multiplyScalar(.5)}function $L(){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 qc(e)}function eR(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function tR(e,t,n,r=[0,0,0],i=4,a=null){let o=[];for(let t of e){let e=t.position;e&&Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]))<=XL&&o.push({body:t,at:e})}let 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{body:t,at:n}=o[e];s[e*3]=n[0]-r[0],s[e*3+1]=n[1]-r[1],s[e*3+2]=n[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 ns;u.setAttribute(`position`,new Wo(s,3)),c&&u.setAttribute(`color`,new Wo(c,3));let d=new Wc(u,new zc({map:t,color:c?new X(.5,.5,.5):QL(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=ZL,d}function nR(e,t,n,r,i=4,a=null){let o=new ns;o.setAttribute(`position`,new Vo(e,3)),a&&o.setAttribute(`color`,new Vo(a,3)),o.setDrawRange(0,t);let s=new Wc(o,new zc({map:n,color:a?new X(.5,.5,.5):QL(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=ZL,s}function rR(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(v_(c,l,e.w,e.i,e.om,e.equatorial))}return o}function iR(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(v_(b,x,a,r,i,e.equatorial))}return l}function aR(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(v_(d,f,e.w,e.i,e.om,e.equatorial))}return o}function oR(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=s_(e,t-i+i*n/r);o&&a.push(o)}return a}function sR(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function cR(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:rR(e,t),isOpen:!0}:!n&&e.e>=1?{points:aR(e,t),isOpen:!0}:{points:iR(e,t),isOpen:!1}}var lR=3;function uR(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 ns;return c.setAttribute(`position`,new Wo(n,3)),c.setAttribute(`nextPosition`,new Wo(r,3)),c.setAttribute(`side`,new Wo(i,1)),c.setAttribute(`trailAlpha`,new Wo(a,1)),c.setAttribute(`fullAlpha`,new Wo(o,1)),c.setIndex(new Ho(s,1)),c}function dR(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 fR(){let e=new ns;e.setAttribute(`position`,new Wo(new Float32Array(6),3));let t=new Nc(e,new Eu({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=lR,t}function pR(e,t,n,r,i){let a=new ns;a.setAttribute(`position`,new Wo(e,3)),a.setAttribute(`trailAlpha`,new Wo(t,1)),a.setAttribute(`fullAlpha`,new Wo(n,1)),a.setDrawRange(0,r);let o=new Nc(a,DI(i));return o.matrixAutoUpdate=!1,o.renderOrder=lR,o}function mR(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 hR(e,t,n,r,i,a,o,s,c){let l=uR(e);c&&l.setAttribute(`lineDistance`,new Wo(new Float32Array(2*e),1)),dR(l,t,n,r,i);let u=new Ws(l,OI(a,o,s,c));return u.matrixAutoUpdate=!1,u.renderOrder=lR,u}function gR(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 _R(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(Pb(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){dR(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}var vR=1.5;function yR(e){return e>1||PE()>=vR}function bR(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;if(!c)return 0;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 xR(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===G.SPACECRAFT||o.objectType===G.DWARF_PLANET||o.objectType===G.MOON||o.objectType===G.COMET||Sn(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=bR(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&Pb(m.subarray(0,p),h.subarray(0,p),!0,u);let g=yR(i),_=g?hR(d,f,h,m,p,n,i):pR(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 SR(e,t,n=[0,0,0],r=jg(new Date),i=1){if(e.trailBuffer)return xR(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l,u;if(s.satrec)c=oR(s.satrec,r,s.n/360,512),l=!0,u=c.length-1;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=sR(a)}let d=o?.[0]??0,f=o?.[1]??0,p=o?.[2]??0,m=l||s.objectType===G.DWARF_PLANET||s.objectType===G.MOON||s.objectType===G.SPACECRAFT||s.objectType===G.COMET||Sn(s.objectType),h=c?Nb(e,c,l,d,f,p,u):[];if(c&&h.length<2)return fR();let g=c?Math.max(h.length,c.length):513,_=new Float32Array(g),v=new Float32Array(g);Pb(_.subarray(0,h.length),v.subarray(0,h.length),l,m);let y=d-n[0],b=f-n[1],x=p-n[2],S=new Float32Array(g*3);for(let e=0;e<h.length;e++)S[e*3]=h[e][0]+y,S[e*3+1]=h[e][1]+b,S[e*3+2]=h[e][2]+x;let C=yR(i),w=C?hR(g,S,v,_,h.length,t,i):pR(S,v,_,h.length,t);return w.frustumCulled=!1,w.visible=!1,w.userData.orbitCenter=new J(d,f,p),w.userData.trailLocalPositions=c?h:void 0,w.userData.sourceCurve=c??void 0,w.userData.curvePending=c===null,w.userData.isOpenCurve=l,w.userData.useTrail=m,w.userData.curveJd=r,w.userData.elementsJd=a?.epoch??r,C&&(w.userData.isFatLine=!0,w.userData.thinPositions=S,w.userData.thinTrailAlphas=v,w.userData.thinFullAlphas=_),w}function CR(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 wR(e){return e.data.objectType===G.PLANET?4:(e.data.objectType===G.MOON||e.data.objectType===G.DWARF_PLANET)&&W_[e.data.id]?3:1}function TR(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===G.STAR)continue;if(e.data.orbitalSource===W.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&IL(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=SR(e,av(e.data),n,r,wR(e));t.add(a),i.trail=a}}function ER(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=eR();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=CR(c.values(),i);if(e.length===0)continue;let u=av(e[0].data),{buckets:d}=cv(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=tR(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=dy(e.layers,o,CR(c.values(),i));if(l.length===0)continue;let{buckets:u}=cv(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=tR(i,n,`#ffffff`,r,void 0,e=>av(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===G.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=tR(i,n,av(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}}var DR=class{lastBaryId=null;pendingUnloads=new Set;prefetched=new Set;loads=0;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===G.BARYCENTER)return e;let n=t?.data.parentId??e;return bv(n)?null:n}load(e){this.loads++,FP(e,this.bodyObjects,this.scene,this.textureLoader,this.clock.jd,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.onLoaded(),this.ctx.bodies.orientationVersion++}).finally(()=>this.loads--)}isLoading(){return this.loads>0}drainPendingUnloads(){if(this.pendingUnloads.size!==0){for(let e of this.pendingUnloads)IP(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},OR=Math.PI/180,kR=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Zi;_adjustQ=new Zi;_tmpQ=new Zi;_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*OR).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*OR)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*OR)),this._q.copy(GP).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},AR=Math.PI/180,jR=yg*AR,MR=Math.cos(jR),NR=Math.sin(jR),PR=5e3,FR=[{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`}],IR=192.85948,LR=27.12825,RR=266.40499,zR=-28.93617,BR=256,VR=[{name:`galactic-plane`,zero:HR(RR,zR,new J).normalize(),pole:HR(IR,LR,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:HR(0,0,new J).normalize(),pole:HR(0,90,new J).normalize(),color:10325247}];function HR(e,t,n){let r=e*AR,i=t*AR,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*MR+c*NR,d=-s*NR+c*MR;return n.set(l,d,-u)}function UR(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=`
6361
6361
  <circle cx="0" cy="0" r="14" fill="none" stroke="${r}" stroke-width="1.6"/>
6362
6362
  <line x1="-23" y1="0" x2="-10" y2="0" stroke="${r}" stroke-width="1.6"/>
6363
6363
  <line x1="10" y1="0" x2="23" y2="0" stroke="${r}" stroke-width="1.6"/>
6364
6364
  <line x1="0" y1="-23" x2="0" y2="-10" stroke="${r}" stroke-width="1.6"/>
6365
6365
  <line x1="0" y1="10" x2="0" y2="23" stroke="${r}" stroke-width="1.6"/>
6366
- `;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 MR(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 ns;c.setAttribute(`position`,new Wo(o,3));let l=new Rc(c,new Tc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function NR(){let e=new Ja;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of CR){AR(n.raDeg,n.decDeg,t).multiplyScalar(SR);let r=new OT(jR(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of kR){let n=MR(t.zero,t.pole,SR*.999,t.color,OR);n.name=t.name,e.add(n)}return e}function PR(e){e.traverse(e=>{e instanceof OT&&e.element.remove(),e instanceof Rc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var FR=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=NR(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(PR(this.group),null)}},IR=new J,LR=new J,RR=new J,zR=[IR,LR,RR];function BR(e,t,n){return IR.set(1,0,0).applyQuaternion(e).transformDirection(t),LR.set(0,1,0).applyQuaternion(e).transformDirection(t),RR.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:zR,a:n}}function VR(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 HR(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 UR(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,N=(-2*E*A+D*k)/j,P=-n/T;a.ox=M*P-e,a.oy=N*P-t}var WR=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Zi;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,l=o.body.position;if(!e||c<=0||!l)continue;let[u,d,b]=l;this.tmp.set(u-m,d-h,b-g).applyMatrix4(p);let x=this.tmp.x,S=this.tmp.y,C=this.tmp.z;if(C>=0||x*x+S*S+C*C<=c*c)continue;let w=gO(this.items,y++,GR),T=!!(o.semiAxesScene&&o.mesh);if(T){let e=BR(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);w.e0.copy(e.e[0]),w.e1.copy(e.e[1]),w.e2.copy(e.e[2]),w.sa[0]=e.a[0],w.sa[1]=e.a[1],w.sa[2]=e.a[2],HR(w.occ,x,S,C,e,f,_,v,o.body.data.id,o.cachedDist)}else w.e0.set(1,0,0),w.e1.set(0,1,0),w.e2.set(0,0,1),w.sa[0]=w.sa[1]=w.sa[2]=c,VR(w.occ,x,S,C,c,f,_,v,o.body.data.id,o.cachedDist);let E=C*C-c*c,D=E<=0,O=D?0:c*f/Math.sqrt(E),k=D||O>=16;this.tmp.set(u-m,d-h,b-g).project(t),w.cx=(this.tmp.x*.5+.5)*i,w.cy=(-this.tmp.y*.5+.5)*a,kO(o,t,n,i,a,this.labelRect),w.hx=this.labelRect.x,w.hy=this.labelRect.y,w.id=o.body.data.id,w.camX=x,w.camY=S,w.camZ=C,w.worldR=c,w.dist=o.cachedDist,w.isEllipsoid=T,w.degenerate=D,w.isOccluder=k,w.meshHidden=!s.visible,w.labelVisible=e.visible,w.maximized=o.labelMaximized!==!1,w.focused=o.body.data.id===r,w.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,DO(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(),JR(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)}}qR(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,N=S*O-C*D,P=n.projectionMatrix.elements,ee=!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*N),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,_=P[3]*m+P[7]*h+P[11]*g+P[15];if(_<=1e-6){ee=!1;continue}let S=(P[0]*m+P[4]*h+P[8]*g+P[12])/_,C=(P[1]*m+P[5]*h+P[9]*g+P[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;ee?e.lineTo(w,T):(e.moveTo(w,T),ee=!0)}return!0}dispose(){this.setVisible(!1)}};function GR(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:xO(),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 KR=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function qR(e,t){let n=t-8-(KR.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of KR)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 JR(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 YR(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 XR="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:P,mp:se}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,Y,X,le,ue,de,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),de=fe+2*.01675*Math.sin(fe),X=Math.sin(de),U=.5*X*X-.25,W=-.5*X*Math.cos(de);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*X,ge=p*U+m*W+ee*X,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),de=fe+2*.0549*Math.sin(fe),X=Math.sin(de),U=.5*X*X-.25,W=-.5*X*Math.cos(de);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*X,be=re*U+ie*W+x*X,xe=ae*U+S*W;return G=pe+_e,J=me+ve,Y=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,Y-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,P+=K,N+=q,se+=Y):(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),le=se+P+L*N,H=Y+K-J*N*R,le+=H,ue=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(ue-N)>a&&(N<ue?N+=o:N-=o),se+=Y,P=le-se-L*N)),{ep:oe,inclp:M,nodep:N,argpp:P,mp:se}}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,P,se,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,Y,X,le,ue,de,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,le=3*(l*l+u*u)+_e*$,ue=6*(l*d+u*f)+ve*$,de=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),le=le+le+ke*_e,ue=ue+ue+ke*ve,de=de+de+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,Y=v*y+_*b,X=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=Y,N=X,P=le,se=ue,F=de,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*se,$e=-2*A*(F-P),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*Y,st=2*W*X,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*ue,dt=-2*K*(de-le),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:Y,s7:X,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:P,sz2:se,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:le,z2:ue,z3:de,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:P,z33:se,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:Y,d4422:X,d5220:le,d5232:ue,d5421:de,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*(P+se-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,Y=qe*$*Be,X=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,le=qe*Ae*He,ue=qe*je*We,qe=2*Je*2.1765803e-9,de=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:Y,d4422:X,d5220:le,d5232:ue,d5421:de,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,P=5.7686396,se=.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-P)+r*Math.sin(D-P)+i*Math.sin(G+D-se)+a*Math.sin(-G+D-se)+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-P)+r*Math.cos(D-P)+i*Math.cos(G+D-se)+a*Math.cos(-G+D-se)+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,P=e.argpo+e.argpdot*e.t,se=e.nodeo+e.nodedot*e.t;g=P,D=N;let F=e.t*e.t;if(k=se+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=P-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 Y=L*(1-G),X=Math.sqrt(L)*K/Y,le=Math.sqrt(J)/Y,ue=Math.sqrt(1-q);S=K/(1+ue);let de=L/Y*(r-H-V*S),fe=L/Y*(n-V+H*S);v=Math.atan2(de,fe);let pe=(fe+fe)*de,me=1-2*de*de;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=Y*(1-1.5*ge*ue*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=X-O*he*e.x1mth2*pe/l,be=le+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,P,se,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,Y,X,le,ue,de,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}P=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,se=Math.abs(1-O),S=F*Z**4,C=S/se**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/se*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/($*se)*(-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*P*Q.no,he=.5*me*f*P,ge=-.46875*-165597e-11*P*P*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:Y,sz21:X,sz23:le,sz31:ue,sz33:de}=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:Y,sz21:X,sz23:le,sz31:ue,sz33:de,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=2451545,T=86400,E=[[2441317.5,10],[2441499.5,11],[2441683.5,12],[2442048.5,13],[2442413.5,14],[2442778.5,15],[2443144.5,16],[2443509.5,17],[2443874.5,18],[2444239.5,19],[2444786.5,20],[2445151.5,21],[2445516.5,22],[2446247.5,23],[2447161.5,24],[2447892.5,25],[2448257.5,26],[2448804.5,27],[2449169.5,28],[2449534.5,29],[2450083.5,30],[2450630.5,31],[2451179.5,32],[2453736.5,33],[2454832.5,34],[2456109.5,35],[2457204.5,36],[2457754.5,37]];function D(e){for(let t=E.length-1;t>=0;t--)if(e>=E[t][0])return E[t][1];return E[0][1]-1}function O(e){let t=6.239996+1.99096871e-7*(e-w)*T;return .001657*Math.sin(t+.01671*Math.sin(t))}function k(e){if(!Number.isFinite(e))return e;let t=e+(D(e)+32.184)/T;return t+O(t)/T}const A=Math.PI/180,j=A/3600,oe=1e-4*j,M=[[0,0,0,0,1,-171996,-174.2,92025,8.9],[0,0,2,-2,2,-13187,-1.6,5736,-3.1],[0,0,2,0,2,-2274,-.2,977,-.5],[0,0,0,0,2,2062,.2,-895,.5],[0,1,0,0,0,1426,-3.4,54,-.1],[1,0,0,0,0,712,.1,-7,0],[0,1,2,-2,2,-517,1.2,224,-.6],[0,0,2,0,1,-386,-.4,200,0],[1,0,2,0,2,-301,0,129,-.1],[0,-1,2,-2,2,217,-.5,-95,.3],[1,0,0,-2,0,-158,0,-1,0],[0,0,2,-2,1,129,.1,-70,0],[-1,0,2,0,2,123,0,-53,0],[1,0,0,0,1,63,.1,-33,0],[0,0,0,2,0,63,0,-2,0],[-1,0,2,2,2,-59,0,26,0],[-1,0,0,0,1,-58,-.1,32,0],[1,0,2,0,1,-51,0,27,0]];function N(e,t){let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[3*r+i]=e[3*r]*t[i]+e[3*r+1]*t[3+i]+e[3*r+2]*t[6+i];return n}function P(e){let t=Math.cos(e),n=Math.sin(e);return[1,0,0,0,t,n,0,-n,t]}function se(e){let t=Math.cos(e),n=Math.sin(e);return[t,0,-n,0,1,0,n,0,t]}function F(e){let t=Math.cos(e),n=Math.sin(e);return[t,n,0,-n,t,0,0,0,1]}function I(e){let t=(e-w)/36525,n=(2306.2181*t+.30188*t*t+.017998*t**3)*j,r=(2004.3109*t-.42665*t*t-.041833*t**3)*j,a=(2306.2181*t+1.09468*t*t+.018203*t**3)*j,o=134.96298139+477198.8673981*t+.0086972*t*t,s=357.52772333+35999.05034*t-1603e-7*t*t,c=93.27191028+483202.0175381*t-.0036825*t*t,l=297.85036306+445267.11148*t-.0019142*t*t,u=125.04452222-1934.1362608*t+.0020708*t*t,d=0,f=0;for(let[e,n,r,i,a,p,m,ee,te]of M){let h=(e*o+n*s+r*c+i*l+a*u)*A;d+=(p+m*t)*Math.sin(h),f+=(ee+te*t)*Math.cos(h)}d*=oe,f*=oe;let p=(84381.448-46.815*t-59e-5*t*t+.001813*t**3)*j,m=d*Math.cos(p),ee=N(N(N(N(F(n),se(-r)),F(a)),N(N(P(-p),F(d)),P(p+f))),F(-m));return N(P(i*A),ee)}let L=NaN,R=[1,0,0,0,1,0,0,0,1];function ce(e){return Math.abs(e-L)<=.01||(R=I(e),L=e),R}function z(e){return new Date((e-2440587.5)*864e5).toISOString()}function B(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:z(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 V=Math.PI/180;Math.cos(i*V),Math.sin(i*V);const H=Math.PI/180,U=Math.cos(i*H),W=Math.sin(i*H),G=10/r;function K(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 q(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:T,visibleFromDays:E}=r,D=p!==0&&r.applyFlagFilter,O=r.pickBase,A=d.length/3|0,j=i-w,oe=k(i),M=ce(i),N=0;for(let w=0;w<m&&!(N>=A);w++){let m=ee[w];if(m===0||E[w]>j||D&&(T[w]&p)!==p)continue;if(m===3){let e=C[w];if(!e){if(e=B({noradCatId:r.satnum[w],epochJd:re[w],meanMotion:b[w]/360,eccentricity:g[w],inclination:ne[w],raOfAscNode:_[w],argOfPericenter:v[w],meanAnomaly:y[w],bstar:r.bstar[w],meanMotionDot:r.ndot[w],meanMotionDdot:r.nddot[w],elementSetNo:0,revAtEpoch:0}),!e){ee[w]=0;continue}C[w]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x*G,m=n.position.y*G,te=n.position.z*G,h=M[0]*p+M[1]*m+M[2]*te,ie=M[3]*p+M[4]*m+M[5]*te,S=M[6]*p+M[7]*m+M[8]*te,T=-ie;if(!K(d,N,a+h-c,o+S-l,s+T-u))continue;if(f){let e=O+w,t=N*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}N++;continue}let k,A,P=g[w],se=ne[w],F=_[w],I=v[w];if(m===2){let e=n(ie[w],S[w],te[w]?i:oe);if(!e)continue;k=e.r*Math.cos(e.nu),A=e.r*Math.sin(e.nu)}else{let n=h[w];if(!isFinite(n)||!isFinite(P)||!isFinite(y[w])||!isFinite(b[w]))continue;let r=(te[w]?i:oe)-re[w],a=(y[w]+b[w]*r)*H,o,s;if(P<1||n>0){let t=Math.min(P,.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,P);if(!isFinite(e))continue;let r=P*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(P*P-1)*Math.sinh(e)/r,c=(P-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-P*Math.cosh(e))}k=s*Math.cos(o),A=s*Math.sin(o)}if(!isFinite(k)||!isFinite(A))continue;let L=Math.cos(I*H),R=Math.sin(I*H),ce=Math.cos(se*H),z=Math.sin(se*H),V=Math.cos(F*H),q=Math.sin(F*H),J=(V*L-q*R*ce)*k+(-V*R-q*L*ce)*A,Y=(q*L+V*R*ce)*k+(-q*R+V*L*ce)*A,X=R*z*k+L*z*A;if(te[w]){let e=Y*U+X*W,t=-Y*W+X*U;Y=e,X=t}let le=J*10,ue=X*10,de=-Y*10;if(K(d,N,a+le-c,o+ue-l,s+de-u)){if(f){let e=O+w,t=N*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}N++}}return N}const J=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)J.delete(e);for(let e of t.set)J.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=J.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=q(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-D2PB8gf5.js.map",ZR=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,XR],{type:`text/javascript;charset=utf-8`});function QR(e){let t;try{if(t=ZR&&(self.URL||self.webkitURL).createObjectURL(ZR),!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(XR),{type:`module`,name:e?.name})}}var $R=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 QR;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 O_(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}]},A_(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()}},ez=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 jh(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},tz=.01,nz=[`asteroid`,`spacecraft`],rz=.0002959122082855911,iz=.75,az=Q(8*86400);function oz(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(rz/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function sz(e){return e<0?0:e>1?1:e}function cz(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function lz(e){return e===null?{tBright:0,tSize:0}:{tBright:sz((uz-e)/(uz-dz)),tSize:sz((fz-e)/(fz-pz))}}var uz=1e4,dz=500,fz=dz,pz=50,mz=4,hz=.5,gz=10,_z=1,vz=1,yz=3.5,bz=2.5,xz=2,Sz=yz,Cz=class{orbitPool=new $R;pickRegistry=new ez;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:mz,dim:hz,opacity:vz};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:vz};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 nz)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 nz)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)uv(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=lz(e);return{size:mz+(gz-mz)*n,dim:hz+(_z-hz)*t,opacity:vz+(yz-vz)*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)cz(uv(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)cz(uv(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=lz(e);return{sizeMult:1+(bz-1)*n,brightMult:1+(xz-1)*t,opacity:vz+(Sz-vz)*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=vz,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=mR(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 nz)for(let[t,n]of this.workerPoints[e]){let r=uv(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of nz)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`?ev:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&cz(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=Nh(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,oz(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=WL(new Float32Array(l.cols.count*3),0,this.circleTexture,c,HL());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 lv(n,dy(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=>Mh(e.data.id)??Eh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:az,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3);this.seedColors(f,l);let p=WL(new Float32Array(l.length*3),0,this.circleTexture,`#ffffff`,void 0,f);this.adoptCloud(`spacecraft`,i,c,p,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=uv(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)}seedColors(e,t){let n=new X,r=Math.min(t.length,e.length/3);for(let i=0;i<r;i++)n.set(av(t[i].data)),e[i*3]=n.r,e[i*3+1]=n.g,e[i*3+2]=n.b}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length!==n){if(e.setAttribute(`position`,new Vo(new Float32Array(n),3)),e.getAttribute(`color`)){let r=new Float32Array(n);this.seedColors(r,t),e.setAttribute(`color`,new Vo(r,3))}e.setDrawRange(0,0)}}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Vo(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 Vo(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 Vo(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of nz)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=tz*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(ev)?.position;for(let[i,a]of this.workerPoints.asteroid){if(!r)break;if(!this.ctx.visibility.isAsteroidGroupVisible(uv(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(uv(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;s[0]=o[0],s[1]=o[1],s[2]=o[2],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>=iz}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===G.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].position;s[r*3]=a?a[0]-e:NaN,s[r*3+1]=a?a[1]-t:NaN,s[r*3+2]=a?a[2]-n:NaN}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++){let r=n[t].position;i[t*3]=r?r[0]-e[0]:NaN,i[t*3+1]=r?r[1]-e[1]:NaN,i[t*3+2]=r?r[2]-e[2]:NaN}r.geometry.setAttribute(`position`,new Wo(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 nz)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()}},wz=Math.PI/180,Tz=2451545,Ez=1.00000261,Dz=.01671123,Oz=100.46457166*wz,kz=35999.37244981/36525*wz,Az=102.93768193*wz,jz=.32327364/36525*wz;function Mz(e){let t=e-Tz,n=Az+jz*t,r=Oz+kz*t-n,i=r+(2*Dz-Dz**3/4)*Math.sin(r)+1.25*Dz*Dz*Math.sin(2*r);return{lon:n+i,r:Ez*(1-Dz*Dz)/(1+Dz*Math.cos(i))}}function Nz(e){let t=Mz(e).lon;return(e,n)=>{let r=t-Mz(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 Pz=.01,Fz=1/100,Iz=1;function Lz(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 Rz(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 zz(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=Lz(c,l,u)}function Bz(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position;if(!l)return;let 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(Rz(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=iR(t),b=e.lagrangeTrail?Nz(i):null,x=cR(e,n,_,c.x,c.y,c.z,r,b??void 0);aR(t,_,v,y,x,!0,s),zz(o,g,u,d,f,p,m,h,_,x,a)}function Vz(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=iR(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){$L(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function Hz(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){Bz(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=XL(x_(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,p;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=JL(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=a=r),p=o.length-(r<a?2:1)}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*Fz,Iz)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=XL(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)>Pz&&(o=XL(x_(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let m=e.trailAnchor??e.position;if(!m)return;let h=t.userData,g=u-n[0],_=d-n[1],v=f-n[2],y=m[0]-u,b=m[1]-d,x=m[2]-f;if(Rz(h,o,g,_,v,y,b,x,i))return;let S=Nb(e,o,s,u,d,f,p);if(S.length<2)return;let{posArr:C,trailArr:w,fullArr:T,capacity:E}=iR(t),D=u-n[0],O=d-n[1],k=f-n[2],A=Math.min(S.length,E);for(let e=0;e<A;e++)C[e*3]=S[e][0]+D,C[e*3+1]=S[e][1]+O,C[e*3+2]=S[e][2]+k;aR(t,C,w,T,A,s,c),h.trailLocalPositions=S,zz(h,o,g,_,v,y,b,x,C,A,i)}function Uz(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 Wz(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 Gz=4/2,Kz=(.1*10)**2,qz=new J,Jz=[],Yz=Jz;function Xz(e){return gO(Jz,e,xO)}var Zz={x:0,y:0,left:0,right:0,h:0},Qz=new Zi,$z={ox:0,oy:0},eB=new J,tB=new J;function nB(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()){let e=n.body.position;if(!e||n.carried){n.cachedDist=1/0;continue}if(n.cachedDist=Ev(C,e),n.isCrashed||n.noPhysical){let e=n.noPhysical===`model`,t=Sg(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()}fA(n,`missing`,r)}let r=n.label;if(!r)continue;n.labelAnchorOffscreen=!1;let i=n.noPhysical?0:n.radiusScene;if(!i){r.position.set(0,0,0);continue}let[o,s,c]=e;p.set(o-w[0],s-w[1],c-w[2]).applyMatrix4(T);let l=p.x,u=p.y,d=p.z,f=d*d,m=i*i;if(f<=m){r.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let h=i/n.cachedDist*S;if(h<1){r.position.set(0,0,0);continue}if(h>=16){let e=n.cachedDist,a=1/e,f=l*a,m=u*a,h=d*a,g=i*a,_=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*e-l,T*e-u,E*e-d).applyQuaternion(t.quaternion),r.position.copy(p),tB.set(o-w[0]+p.x,s-w[1]+p.y,c-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(tB.x)>1||Math.abs(tB.y)>1;continue}if(n.semiAxesScene&&n.mesh)UR(l,u,d,BR(n.mesh.getWorldQuaternion(Qz),T,n.semiAxesScene),S,$z),p.set($z.ox,$z.oy,0).applyQuaternion(t.quaternion);else{let e=m/(f-m);p.set(e*l,e*u,0).applyQuaternion(t.quaternion)}r.position.copy(p)}let E=Jz,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene,n=t.body.position;if(!e||!n||t.carried)continue;let r=t.cachedDist,[i,a,o]=n,s=t.model?.userData.occluderSpheres;if(t.model&&s?.length){let e=Fj(t),n=t.model.position;for(let c of s){let s=c.r*e;if(eB.copy(c.center).applyQuaternion(t.model.quaternion).add(n).multiplyScalar(e),p.set(i-w[0]+eB.x,a-w[1]+eB.y,o-w[2]+eB.z).applyMatrix4(T),p.z>=s||p.lengthSq()<=s*s)continue;let l=p.z*p.z;(l<=s*s||s*S/Math.sqrt(l-s*s)>=16)&&VR(Xz(k++),p.x,p.y,p.z,s,S,D,O,t.body.data.id,r)}continue}p.set(i-w[0],a-w[1],o-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z;if(u>=e)continue;let d=u*u;(d<=e*e||e*S/Math.sqrt(d-e*e)>=16)&&(t.semiAxesScene&&t.mesh?HR(Xz(k++),c,l,u,BR(t.mesh.getWorldQuaternion(Qz),T,t.semiAxesScene),S,D,O,t.body.data.id,r):VR(Xz(k++),c,l,u,e,S,D,O,t.body.data.id,r))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=i?mM(n.getBody(i),e):void 0;for(let r of e.values()){let{body:a,group:s,trail:c}=r,l=r.cachedDist,u=vO(r);r.root.visible=u;let d,f,p=a.data.id===i,m=A!==null&&a.data.id===A;if(r.mesh===null&&!Cn(a.data.objectType)){let t=a.data.objectType;if(t===G.BARYCENTER||t===G.LAGRANGE_POINT){let t=!0,r=p?void 0:xv(a.data.id);if(r){let i=e.get(r)?.body??n.getBody(r);i?.position&&a.position&&Ev(a.position,i.position)/Ev(C,i.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),d=t,f=!1}else{let e=n.visibility.getPlanetVisibility(a,l)!==$.HIDE&&n.visibility.hasFullRendering(a);s.visible=e,c&&(c.visible=e),d=e,f=!1}}else{let e=a.data.objectType===G.MOON,t=e?n.visibility.getMoonVisibility(a):n.visibility.getPlanetVisibility(a,l),r=e?Uz(t,o,p):Wz(t,n.visibility.hasFullRendering(a),p||m);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),d=r.showLabel,f=r.isClose}u||(s.visible=!1,d=!1,f=!1),c&&(!u||a.orbitCenter===null)&&(c.visible=!1);let g=!1;if(r.starPoint&&u){let e=r.radiusScene/l*S/Gz;g=e<1,r.starPoint.visible=g,g&&(r.starPoint.material.uniforms.uFlux.value=e*e),cL(r.corona,e),s.visible=!0,f=!g,d=!f}if(r.isMinor&&!p&&c&&!n.visibility.isPinned(a.data.id)&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(qz.set(w[0],w[1],w[2]))>Kz&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:y}=r;if(!s.visible&&y&&y.parent===s?(s.remove(y),y.element.remove()):s.visible&&y&&y.parent!==s&&s.add(y),r.mesh&&r.radiusScene>0){let e=g||!p&&!m&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}EO(r,d,f,l,S,i)&&(j=!0);let T=r.radiusScene>0?r.radiusScene/l*S:0;IM(r,v&&a.data.id===M,T,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(uv(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(uv(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0){let n=i?xv(i):null;for(let r of e.values()){if(!r.label?.visible||!kO(r,t,w,b,x,Zz))continue;let e=r.body.data.id;DO(Zz.x,Zz.y,r.cachedDist,e,E,e===i?n:null)&&(r.label.visible=!1)}}if((m||j||++d>=3)&&(d=0,HO(e,b,x,t,i,n,s,E,r)),UO(e,b,x,t,r),M){let t=e.get(M);t&&BM(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 rB(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function iB(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function aB(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function oB(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 sB(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-cB(d):p,g=f?m+cB(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:lB(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:uB(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:lB(f,t),centerId:o.anchorId};if(l)return{r:uB(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}=oB(e,v);return{r:uB(y,b,t,x,S),centerId:e.centerId}}function cB(e){return e.jds[e.jds.length-1]-e.jds[0]}function lB(e,t){let n=cB(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return uB(e.points,e.jds,i)}function uB(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 rB(e[a-1],aB(iB(e[a],e[a-1]),s))}var dB=Math.PI/180,fB=Math.cos(yg*dB),pB=Math.sin(yg*dB);function mB(e,t,n,r){let i=Math.cos(e*dB),a=Math.sin(e*dB),o=Math.cos(t*dB),s=Math.sin(t*dB),c=Math.cos(n*dB),l=Math.sin(n*dB);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 hB(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*fB+a*pB,t=-i*pB+a*fB;i=e,a=t}return[r,i,a]}function gB(e){let t=10/vg;return[e[0]*t,e[2]*t,-e[1]*t]}function _B(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,u=y_(e,t),{om:d,w:f}=x_(e,t),p=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 t=d_(c,l,u);if(!t)return null;let r=n&&n>0?n:Vv,i=t.r*vg,a=2*c*vg;return vB(i,t.nu,a,1,r,f,e.i,d,p)}if(!isFinite(i)||!isFinite(a))return null;let m=r*vg,h=o*dB/Hv,g=n&&n>0?n:h*h*Math.abs(m)*Math.abs(m)*Math.abs(m);if(!isFinite(g)||g<=0)return null;let _=(a+o*(u-s))*dB,v,y;if(i<1||r>0){let e=Math.min(i,.9999999),t=c_(_,e),n=1-e*Math.cos(t);v=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),y=m*n}else{let e=u_(_,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;v=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),y=m*(1-i*Math.cosh(e))}if(!isFinite(y)||y<=0)return null;let b=m*(1-i*i);return!isFinite(b)||b<=0?null:vB(y,v,b,i,g,f,e.i,d,p)}function vB(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=mB(a,o,s,c),p=hB(e*l,e*u,f),m=hB(-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 yB={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};yB.cruise,yB.boost,yB.brake,yB.spiral,yB[`spiral-out`],yB[`spiral-in`];var bB={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},xB=3,SB=1,CB=2,wB=.6,TB=1.5,EB=.3,DB=1.5,OB=.85,kB=60,AB=.018,jB=.026,MB=`#ffffff`,NB=4,PB=1.5,FB=9,IB=1,LB={notice:NB-3,caution:NB-2,severe:NB-1},RB=[`notice`,`caution`,`severe`],zB=.03,BB=.2;function VB(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 qc(t)}function HB(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 qc(t)}function UB(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 WB(e,t){let n=new Ss(new cs({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=NB,n}function GB(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&&(IT(c,i),pM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new OT(c);return p.center.set(0,.5),p}function KB(e,t){return e&&[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}var qB=class{group=new Ja;anchored=new Map;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?TB:CB,i?EB:wB,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)=>RB.indexOf(e.severity)-RB.indexOf(t.severity));for(let t of n){let n=bB[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine(UB(t,n.startJd,n.endJd,oB(e,r)),bB[n.severity],FB,IB,null,{renderOrder:LB[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=sB(e,t.startJd);if(!r)continue;let i=gB(r.r),a=r.centerId===e.centerId?null:r.centerId,o=WB(HB(n),zB);this.parentOf(a).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 OT(s);c.center.set(0,.5),this.parentOf(a).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,xB,SB,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.parentOf(e.anchorId).add(e.sprite);this.craft={sprite:WB(VB(MB),jB),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=sB(e,n.jd);if(!t)continue;let r=gB(t.r),i=t.centerId===e.centerId?null:t.centerId,a=WB(VB(MB),AB);this.markers.push({sprite:a,local:r,anchorId:i});let o=GB(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.parentOf(i).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:gB(n.meeting.r),end:e.arrival,color:yB[a?.kind??`cruise`]}];o&&s.push({local:gB(o.r),end:e.departure,color:yB[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=GB(`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?SB:e.brightness),n.uniforms.uLineWidth.value=t?xB: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?oB(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),yB[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),yB.cruise,xB,SB,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),yB.cruise,xB,SB,null,{anchorId:n,renderOrder:PB}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),yB.cruise,xB,SB,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,yB.cruise,xB,SB,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),yB.cruise,DB,OB,null,{anchorId:n})}else this.addLine(t.approach,yB.cruise,xB,SB,null,{anchorId:n});let i=this.addLine(t.points,yB.cruise,DB,OB,null,{anchorId:n});if(!i)continue;let a=n===null?gB(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]=gB(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*BB));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=rR(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??NB,this.parentOf(a.anchorId??null).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=sB(this.path,e);t.sprite.visible=n!==null,n&&(t.local=gB(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],e[1]-t[1],e[2]-t[2]],i=new Map;for(let[e,r]of this.anchored){let a=n(e);i.set(e,KB(a,t)),r.visible=a!==null}let a=e=>e===null?r:i.get(e)??null;for(let e of this.arcs){let t=a(e.anchorId);if(!t)continue;let[n,r,i]=t;for(let t=0;t<e.count;t++)e.positions[t*3]=e.local[t*3]+n,e.positions[t*3+1]=e.local[t*3+1]+r,e.positions[t*3+2]=e.local[t*3+2]+i;$L(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let t=a(e.anchorId);if(!t)continue;let[n,r,i]=t;e.sprite.position.set(e.local[0]+n,e.local[1]+r,e.local[2]+i)}for(let e of this.labels){let t=a(e.anchorId);if(!t)continue;let[n,r,i]=t;e.object.position.set(e.local[0]+n,e.local[1]+r,e.local[2]+i)}if(this.craft){let{sprite:e,local:r,anchorId:i}=this.craft,o=i===null||this.anchored.has(i)?a(i):KB(n(i),t);o?e.position.set(r[0]+o[0],r[1]+o[1],r[2]+o[2]):e.visible=!1}for(let e of this.rings){let t=a(e.arc.anchorId);if(!t)continue;let[n,r,i]=t;e.world.set(e.local[0]+n,e.local[1]+r,e.local[2]+i)}}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*kB}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){BO(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),!xw(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=DO(a,o,s,``,Yz);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++}BO(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))}parentOf(e){if(e===null)return this.group;let t=this.anchored.get(e);return t||(t=new Ja,this.anchored.set(e,t),this.group.add(t)),t}clear(){for(let e of this.arcs)e.line.removeFromParent(),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){e.sprite.removeFromParent();let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)e.object.removeFromParent(),e.object.element.remove();for(let e of this.anchored.values())this.group.remove(e);this.anchored.clear(),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)}},JB=2,YB=1,XB=4,ZB=200,QB=class{group=new Ja;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,ZB);for(let t=0;t<e.count;t++){let[r,i,a]=gB(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(ZB*3),t=new Float32Array(ZB).fill(1),n=rR(ZB,e,t,t,0,yB.cruise,JB,YB);n.frustumCulled=!1,n.renderOrder=XB,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array(ZB*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;$L(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)}},$B=new Set([`not-yet`,`no-data`,`parent`,`failed`]);function eV(e){let{jd:t,ctx:n,bodyObjects:r,focus:i,focusedBody:a,placer:o,trailView:s,frame:c,outOfRange:l}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let u=[];if(a){let e=new Set([a.data.id]),t=n.getBody(a.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),u.push({body:t,oldPos:t.position?[...t.position]:null}),t=n.getBody(t.data.parentId)}o.begin(t,a?.data.id,c);let d=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values())e.data.objectType===G.MOON&&e.data.parentId!==d&&e!==a||o.placeInPass(e);for(let e of r.values())o.placeInPass(e.body);let f=a?o.place(a,t):null,p=a?.unplaced;l.update({jd:t,satellites:n.refresher?.satelliteCoverage(t)??{kind:`covered`},majorBodies:o.noData,focusedOutOfRange:p!==void 0&&$B.has(p)});let m=null,h=performance.now()-i.focusStartTime<i.focusDurationMs;if(a&&!f)for(let e of u){let n=o.place(e.body,t);if(n){if(m=e.body.data.id,h){nV(i.focusTargetWorld,n);let e=i.camTargetOffset;e&&i.camTargetWorld&&rV(i.camTargetWorld,n,e)}else if(e.oldPos)for(let t=0;t<3;t++){let r=n[t]-e.oldPos[t];i.focusTruePos[t]+=r,i.focusTargetWorld[t]+=r}break}}else if(f){nV(i.focusTargetWorld,f);let e=i.camTargetOffset;e&&i.camTargetWorld&&rV(i.camTargetWorld,f,e);let t=i.camOriginOffset;t&&i.camOriginWorld&&rV(i.camOriginWorld,f,t),h||nV(i.focusTruePos,f)}let g=i.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}Hz(e.body,n,g,t,s),n.userData.refreshDeferred=!1}}let _=!f&&p===`loading`;return{focusUnplaced:a!==void 0&&!f&&!_,focusLoading:_,anchorId:m}}function tV(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(Hz(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}function nV(e,t){e[0]=t[0],e[1]=t[1],e[2]=t[2]}function rV(e,t,n){e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2]}var iV=Object.freeze([0,0,0]);function aV(e,t,n,r){if(!Number.isFinite(t+n+r))return oV(e,`failed`);let i=e,a=i.position??=[0,0,0];return a[0]=t,a[1]=n,a[2]=r,i.unplaced=void 0,a}function oV(e,t){let n=e;return n.position=null,n.orbitCenter=n.orbitCenterId===void 0?void 0:null,n.unplaced=t,null}function sV(e,t){let n=e;if(!t){n.orbitCenter=null;return}let r=n.orbitCenter??=[0,0,0];r[0]=t[0],r[1]=t[1],r[2]=t[2]}function cV(e,t){let n=e.trailAnchor??=[0,0,0];n[0]=t[0],n[1]=t[1],n[2]=t[2]}var lV=Math.PI/180,uV=120,dV=Q(.001)**2,fV=new WeakMap,pV=new J,mV=new J;function hV(e,t,n){e.distanceToSquared(t)<=dV?e.copy(t):e.lerp(t,n)}function gV(e,t,n,r,i){let a=e.featureAnchor;sV(e,n),mV.set(0,0,0);let o=r?.nomenclatureActiveIndex??-1,s=o>=0?r?.nomenclatureLabels?.[o]??null:null;if(s&&s.element.dataset.featureId===String(a.featureId)){let e=r?.nomenclatureAnchor;e?(pV.copy(s.position),mV.copy(e.position)):(pV.copy(s.position),r?.mesh&&pV.multiply(r.mesh.scale))}else{let e=t.data.radiusKm,n=a.lat*lV,i=a.lon*lV,o=t.orientation&&Number.isFinite(e)&&e>0?mO(r,t.data.id,e,n,i):null;if(o)pV.set(o.pointKm[0],o.pointKm[1],o.pointKm[2]);else{let t=Number.isFinite(e)&&e>0?e:0,[r,a,o]=qD(n,i);pV.set(t*r,t*a,t*o)}pV.multiplyScalar(Q(1))}let c=performance.now(),l=fV.get(e);if(!l)l={fixed:pV.clone(),addend:mV.clone(),t:c},fV.set(e,l);else{let e=1-Math.exp(-(c-l.t)/uV);l.t=c,hV(l.fixed,pV,e),hV(l.addend,mV,e)}return pV.copy(l.fixed),t.orientation&&pV.applyQuaternion(SS(t.orientation,i,t.nutPrec)),aV(e,n[0]+pV.x+l.addend.x,n[1]+pV.y+l.addend.y,n[2]+pV.z+l.addend.z)}var _V=30034e-10,vV=.45,yV=1.6,bV=.85,xV=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],SV=e=>Math.hypot(e[0],e[1],e[2]);function CV(e,t,n=_V){let r=SV(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=xV(e,t)/r,o=SV(e);if(Math.sqrt(Math.max(0,o*o-a*a))>bV*i)return null;let s=a/i;return s>=vV&&s<=yV?`EL1`:s<=-vV&&s>=-yV?`EL2`:null}function wV(e,t){return!(e.visibleFromDays!==void 0&&t-2451545<e.visibleFromDays)}function TV(e,t){let n=y_(e,t);return n>=e.validityStart&&n<=e.validityEnd}function EV(e){return e.a===0&&(e.objectType===G.BARYCENTER||e.objectType===G.LAGRANGE_POINT||Cn(e.objectType))}function DV(e,t){if(e.pageOnly)return`never`;if(!wV(e,t))return`not-yet`;if(!TV(e,t))return`no-data`;let n,r=e.satrec;return n=r?s_(r,t):e.omm?null:e.q==null?e.a===0?EV(e)?[0,0,0]:null:C_(e,t):w_(e,t),!n||!Number.isFinite(n[0]+n[1]+n[2])?`failed`:n}function OV(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var kV=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`?Ag(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})}}},AV=new Map,jV=new J;function MV(e,t,n,r,i,a,o){let s=lb(n,r,sb(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(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=mO(o.get(c),c,d,p,m);h&&AV.set(e.id,h);let g=h??AV.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=SS(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?jV.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 NV=[0,0,0],PV=new Zi,FV=4,IV=0,LV=new Map;function RV(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function zV(e,t,n){let r=LV.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 LV.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}var BV=class{focusedId;noData=OV();passJd=NaN;frame;settled=new Set;settling=new Set;ride=iS([],void 0,()=>void 0);rideJd=NaN;rideFocus;constructor(e,t,n,r=()=>!1){this.ctx=e,this.bodyObjects=t,this.diagnostics=n,this.held=r}begin(e,t,n){this.passJd=e,this.focusedId=t,this.frame=n,this.settled.clear(),this.noData=OV()}at(e,t){if(e===`naif-0`)return iV;let n=this.ctx.getBody(e)??this.bodyObjects.get(e)?.body;return n?this.place(n,t):null}placeInPass(e){let t=e.data,n=this.bodyObjects.get(t.id);n&&this.frame!==void 0&&t.id!==this.focusedId&&!n.root.visible&&!n.trail?.visible&&(t.orbitalSource===W.SPICE_PROBE||!Cn(t.objectType))&&(n.staggerSlot??=IV++%FV,this.frame%FV!==n.staggerSlot)||this.place(e,this.passJd)}place(e,t){t!==this.passJd&&this.held()&&(t=this.passJd);let n=e.data.id;if(t===this.passJd&&this.settled.has(n))return e.position;if(this.settling.has(n))return this.diagnostics.warnOnce(`parent-cycle`,n,()=>`place[${n}]: parent chain loops`),null;this.settling.add(n);let r=hn(e)?this.seatFeature(e,t):this.settle(e,t);return this.settling.delete(n),t===this.passJd&&this.settled.add(n),r}under(e){return(this.ctx.getBody(e)??this.bodyObjects.get(e)?.body)?.unplaced===`loading`?`loading`:`parent`}seatFeature(e,t){let n=e.featureAnchor.hostId,r=this.ctx.getBody(n),i=r&&this.place(r,t);return!r||!i?oV(e,this.under(n)):gV(e,r,i,this.bodyObjects.get(n),t)}rideAt(e){return(e!==this.rideJd||this.focusedId!==this.rideFocus)&&(this.rideJd=e,this.rideFocus=this.focusedId,this.ride=iS(this.ctx.probeStore?.ridesAt(e)??[],this.focusedId,e=>this.ctx.getBody(e)?.data.name)),this.ride}rowOffset(e,t,n){let r=this.ctx.bodies.elementRow(e),i=r&&this.at(r.parentId,n);if(!i)return null;let a=DV(r,n);return typeof a==`string`?null:[i[0]-t[0]+a[0],i[1]-t[1]+a[1],i[2]-t[2]+a[2]]}settle(e,t){let{ctx:n,diagnostics:r}=this,i=e.data,a=this.bodyObjects.get(i.id);if(i.pageOnly)return oV(e,`never`);if(i.orbitalSource===W.SPICE_PROBE)return this.settleProbe(e,a,t);let o=this.at(i.parentId,t);if(!o){let t=this.under(i.parentId);return t===`parent`&&r.warnOnce(`missing-parent`,i.id,()=>`place[${i.id}]: parent ${i.parentId} has no place`),oV(e,t)}r.clear(`missing-parent`,i.id);let s;return s=n.chebStore?.has(i.id)?wV(i,t)?n.chebStore.positionScene(i.id,t)??this.rowOffset(e,o,t)??this.chebMiss(i.id,t):`not-yet`:DV(i,t),typeof s==`string`?oV(e,s):this.finish(e,a,o[0]+s[0],o[1]+s[1],o[2]+s[2],o,t)}chebMiss(e,t){let n=this.ctx.chebStore;if(n.isAwaited(e,t))return`loading`;let r=n.zoneCoverage(e);return r!==null&&(t<r.start||t>r.end)&&t===this.passJd&&(this.noData.count++,r.start<this.noData.earliestStart&&(this.noData.earliestStart=r.start),r.end>this.noData.latestEnd&&(this.noData.latestEnd=r.end)),this.diagnostics.warnOnce(`cheb-null`,e,()=>{let n=r?`[${r.start.toFixed(1)},${r.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${e}] returned null at jd=${t.toFixed(3)} (coverage=${n})`}),`no-data`}finish(e,t,n,r,i,a,o){let s=e.data,c=aV(e,n,r,i);if(!c)return this.diagnostics.warnOnce(`non-finite`,s.id,()=>`place[${s.id}] non-finite: pos=[${n},${r},${i}] parentId=${s.parentId}`),null;let l=e.orbitCenterId;if(l!==void 0&&sV(e,l===s.parentId?a:this.at(l,o)),e.trailAnchorId!==void 0){let t=this.at(e.trailAnchorId,o);t&&cV(e,t)}if(!t)return c;if(t.trail&&e.orbitCenter){let n=t.trail.userData.orbitCenter;n&&n.set(e.orbitCenter[0],e.orbitCenter[1],e.orbitCenter[2])}if(e.orientation&&(t.mesh||t.model))t.mesh&&CS(t.mesh,e.orientation,o,e.nutPrec),t.model&&CS(t.model,e.orientation,o,e.nutPrec),t.nomenclatureAnchor&&CS(t.nomenclatureAnchor,e.orientation,o,e.nutPrec);else if(Dj(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(o,PV))t.mesh&&t.mesh.quaternion.copy(PV),t.model&&t.model.quaternion.copy(PV);else{let n=e.pointingOverride??e.pointing;if(n){let e=RV(n)?zV(s.id,o,c):void 0,r={bodyPos:c,parentPos:a,sunPos:this.at(`naif-10`,o)??void 0,velocity:e};t.mesh&&VS(t.mesh,n,r),t.model&&VS(t.model,n,r)}else t.mesh&&ES(t.mesh,c,a),t.model&&ES(t.model,c,a)}}if(e.orientation)for(let n of t.rings)CS(n.mesh,e.orientation,o,e.nutPrec);return c}settleProbe(e,t,n){let{ctx:r,bodyObjects:i,diagnostics:o}=this,s=e.data,c=this.rideAt(n);if(t){t.carried=c.hidden.has(s.id);let e=c.credits.get(s.id);fA(t,`carrier`,e?a().messages.carried_by_scene_label({carrier:e}):null)}let l=r.visibility.activeSystemId,u=l?e=>r.bodies.isInSystem(`naif-${e}`,l):void 0,d=r.probeStore?.probeWithCenter(s.id,n,u)??null;if(!d)return r.probeStore?.awaitedAt(n)?oV(e,`loading`):(oV(e,`no-data`),o.warnOnce(`probe-unavailable`,s.id,()=>{let e=r.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${s.id} (${s.name??`unnamed`}): hidden — ${e}`}),null);let f=d.probe.landed;if(f&&cb(d.probe,n)){let a=s.parentId,c=MV(s,d.probe,f,n,e=>this.at(e,n),r,i);if(!c)return oV(e,this.under(`naif-${f.bodyNaifId}`));if(o.clear(`probe-unavailable`,s.id),a!==s.parentId&&e.trailBuffer?.clear(),t){let e=f.isDestroyed;t.isLanded||=(GN(t.labelHalo,`landed`),!0),t.isCrashed=e,t.model&&(t.model.visible=!e)}let l=aV(e,c.x,c.y,c.z);if(!l)return null;e.orbitCenterId=s.parentId,sV(e,c.parentPos);let u=c.up;return t?.mesh&&(u?DS(t.mesh,u):ES(t.mesh,l,c.parentPos)),t?.model&&(u?DS(t.model,u):ES(t.model,l,c.parentPos)),l}let p=yb(d.probe,n,d.fitCenterNaifId,r.chebStore??null,e=>this.at(e,n)!==null);if(!p){let t=d.probe.fitCenter?.id;return oV(e,t?this.under(t):`parent`),o.warnOnce(`probe-unavailable`,s.id,()=>`probe ${s.id} (${s.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`),null}let m=p.id,h=p.muKm3S2,g=ab(d.probe,n,h);if(!g)return oV(e,`no-data`),o.warnOnce(`probe-unavailable`,s.id,()=>`probe ${s.id} (${s.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`),null;o.clear(`probe-unavailable`,s.id),t?.isLanded&&(GN(t.labelHalo,`flying`),t.isLanded=!1,t.isCrashed&&(t.isCrashed=!1,t.model&&(t.model.visible=!0),t.noPhysical||fA(t,`missing`,null)));let _=this.at(tv,n),v=this.at(ev,n),y=m===`naif-399`&&_!==null&&v!==null&&CV([Q(g[0]),Q(g[2]),-Q(g[1])],[v[0]-_[0],v[1]-_[1],v[2]-_[2]])!==null,b=y!==(e.lagrangeTrail??!1);e.lagrangeTrail=y;let x=s.parentId!==m;if((x||b)&&e.trailBuffer&&r.probeStore){let t=e.trailBuffer;t.clear(),t.needsPopulate=!1;let i=Cb(gb(d.probe,n,h),s.validityEnd-s.validityStart,t.capacity,y);t.reconfigure(i.stepDays,i.epsilonScene,i.spanDays),kb(t,r.probeStore,r.chebStore??null,s.id,m,n)}x&&(s.parentId=m);let S=this.at(m,n);if(!S)return oV(e,this.under(m)),o.warnOnce(`probe-unavailable`,s.id,()=>`probe ${s.id} (${s.name??`unnamed`}): hidden — fit center ${m} has no position this frame`),null;let C=S,w=Q(g[0]),T=Q(g[2]),E=-Q(g[1]),D=C[0]+w,O=C[1]+T,k=C[2]+E,A=e.trailBuffer;if(A?.needsPopulate&&t?.trail?.visible&&r.probeStore&&(A.needsPopulate=!1,A.clear(),kb(A,r.probeStore,r.chebStore??null,s.id,m,n)),A){let e=A.newestJd,t=n-e,i=A.stepDays*A.capacity,a=isFinite(e)&&(t<0||t>i);if(a&&s.id===this.focusedId&&r.probeStore){A.clear();let e=Cb(gb(d.probe,n,h),s.validityEnd-s.validityStart,A.capacity,y);A.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),kb(A,r.probeStore,r.chebStore??null,s.id,m,n)}else a?(A.clear(),A.append(n,w,T,E)):isFinite(e)?isFinite(A.epsilonScene)?t>=A.stepDays*.00390625&&r.probeStore&&A.readNewestPos(NV)&&jb(A,Tb(r.probeStore,r.chebStore??null,s.id,m),e,[NV[0],NV[1],NV[2]],n):t>=A.stepDays&&A.append(n,w,T,E):A.append(n,w,T,E)}return e.orbitCenterId=s.parentId,this.finish(e,t,D,O,k,C,n)}},VV=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)}},HV=[],UV=new WeakMap;function WV(e,t){let{color:n,geometricAlbedo:r}=e.body.data,i=UV.get(e);return(!i||i.color!==n||i.geometricAlbedo!==r||i.map!==t)&&(i={color:n,geometricAlbedo:r,map:t,albedo:WA(e.body.data,t,new X)},UV.set(e,i)),i.albedo}function GV(e,t,n){let r=WV(e,t.map);if(r)return n.copy(r);n.copy(t.color);let i=t.map&&_A(t.map);return i?n.multiply(i):n}function KV(e,t,n,r){let i=e.get(ev)?.body.position,a=0;if(i)for(let e of t){if(!e.mesh)continue;let t=e.mesh.material,[o,s,c]=e.body.position,l=i[0]-o,u=i[1]-s,d=i[2]-c,f=Math.hypot(l,u,d),p=HV[a++]??={x:0,y:0,z:0,radius:0,sunX:0,sunY:0,sunZ:0,sunlight:0,albedo:new X};p.x=o,p.y=s,p.z=c,p.radius=e.radiusScene,p.sunX=l/f,p.sunY=u/f,p.sunZ=d/f,p.sunlight=qS*r*(n?YS(f):1),GV(e,t,p.albedo)}for(let t of e.values()){let e=t.planetshine,n=t.body.position;!e||!n||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4||TT(e,n[0],n[1],n[2],HV,a)}}var qV=Q(695700),JV=2,YV=1e-4,XV=2,ZV=new J,QV=new J,$V=new J,eH=new Zi;function tH(e,t,n,r,i){ZV.subVectors(e,t);let a=ZV.dot(n),o=Math.sqrt(Math.max(ZV.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 nH(e,t,n,r,i,a){let o=e.get(ev)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){let e=t.body.position;if(!t.rings.length||!e)continue;let[u,d,f]=e;for(let e of t.rings){let p=r||e.intensityScale>=.000980392156862745;e.mesh.visible=p;let m=r?1:p?e.intensityScale:0;e.material.uniforms.uIntensityScale.value=m;let h=e.material.uniforms.uSunDir.value;h.set(o[0]-u,o[1]-d,o[2]-f);let g=h.length(),_=qV/g;e.material.uniforms.uSunAngularRadius.value=_,e.material.uniforms.uLightScale.value=n?YS(g):1,h.normalize();let v=e.planetShadowOnRing;if(v.uPlanetCenter.value.set(u-s,d-c,f-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),e.layers){let{dist:t,sinToPole:n}=tH(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,e.innerScene,e.outerScene),r=e.thicknessScene*n/Math.max(t,1e-9)*a,o=Math.min(Math.max(Math.ceil(r*JV),1),48);e.layers.count!==o&&(e.layers.count=o,e.material.uniforms.uLayerCount.value=o,e.material.uniforms.uLayerAlphaExp.value=1/o)}let y=e.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))}rH(t,i,a)}}function rH(e,t,n){let r=e.rings.reduce((e,t)=>t.intensityScale>e.intensityScale?t:e),i=r.material.uniforms,a=i.uSunDir.value,o=r.planetShadowOnRing.uPlanetPoleDir.value,s=r.planetShadowOnRing.uPlanetCenter.value,c=Math.min(Math.max(a.dot(o),-1),1),l=r.light,u=r.outerScene/Math.max(t.distanceTo(s),1e-12)*n>=XV;u&&!(Math.abs(c-l.patchesSinB)<YV)&&(yC(l.patches,l.profile,c,l.planet),l.patchesSinB=c),QV.copy(a).addScaledVector(o,-c),QV.lengthSq()<1e-12&&QV.set(+(Math.abs(o.x)<.9),Math.abs(o.x)<.9?0:1,0).cross(o),QV.normalize(),r.ringshine&&jC(r.ringshine,l,QV,c,i.uLightScale.value),$V.copy(QV).applyQuaternion(eH.copy(r.mesh.quaternion).invert());for(let t of e.rings){if(!t.mesh.visible)continue;u&&t.light.planetLightSinB!==l.patchesSinB&&EC(t.light,l.patchesSinB,l);let n=t.material.uniforms;n.uSunAzimuth.value.set($V.x,$V.z).normalize();let r=n.uPlanetAlbedo.value;e.mesh?GV(e,e.mesh.material,r):r.setRGB(0,0,0)}}var iH=Math.PI/180,aH=2451545;function oH(e){let t=e-aH,n=(19.3871+.52402073*t)*iH;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 sH(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 cH(e,t){let n=e.seasonal;if(!n)return e;let r=sH(n.lsDeg,n.dustTauFactor,t),i=sH(n.lsDeg,n.dustScaleHeightKm,t),a=sH(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 lH=new WeakMap,uH=.25;function dH(e,t){if(!e.seasonal)return e;let n=Math.round(oH(t)/uH),r=lH.get(e);if(r&&r.lsQ===n)return r.params;let i=cH(e,n*uH);return lH.set(e,{lsQ:n,params:i}),i}var fH=new J,pH=new J,mH=[.2126,.7152,.0722];function hH(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=CN(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+=mH[t]*Math.exp(-n)}return o}var gH=.4,_H=.05,vH=-.105,yH=.3,bH=.05;function xH(e,t,n){let r=hH(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/bH),a=Math.min(1,Math.max(0,(n-vH)/yH));return r*(1+(gH+(_H-gH)*a-1)*i)}function SH(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 CH=qS,wH=200,TH=new J,EH=new J,DH=new J,OH=new J;function kH(e,t,n,r){e.uOccluderCount.value=Rw(e.uOccluders.value,t,r,n)}function AH(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:TH.set(1,1,1),sunRefraction:null};hN(n&&a.sunTint);let c=e.get(ev);uL(c?.mesh?.material,Xb());let l=lL(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=wH,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere)continue;c.atmosphere.mesh.visible=n;let e=c.body.position;if(!n||!e)continue;dT(c.atmosphere,a);let f=Yb(c.body.data.id);if(f?.seasonal){let e=a.seasonal?dH(f,o):f;if(c.atmosphere.params!==e){fT(c.atmosphere,e);for(let t of c.sunTint??[])SN(t,e,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[p,m,h]=e,g=c.atmosphere.material.uniforms;g.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let _=g.uSunDir.value.set(d[0]-p,d[1]-m,d[2]-h),v=c.atmosphere.params,y=r?YS(_.length()):v.realisticSunAlways?Math.sqrt(YS(_.length())):1;g.uSunIntensity.value=v.sunIntensity*y*i,_.normalize(),c.mesh&&(fH.set(0,1,0).applyQuaternion(c.mesh.quaternion),g.uSpinAxis.value.copy(fH));let b=c.root.position,x=c.atmosphere.geometryRadiusScene*c.atmosphere.mesh.scale.x,S=t.distanceTo(b);x>S*.1&&(s.shellProminent=!0),a.eclipseShadows&&kH(g,b,_,x);let C=a.insideView&&S<x,w=c.atmosphere.planetRadiusKm,T=S*((w+v.topAltitudeKm)/x)-w,E=C&&cT(v,T),D=C?lT(v,T):0;aT(c.atmosphere,C,E,D),g.uDeepIrradiance.value=CH*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=CH*i,e.uAtmoTDeepBlend.value=D;if(C){s.insideShell=!0;let e=pH.copy(t).sub(b).divideScalar(S).dot(_),n=xH(v,T,e);if(s.skyboxIntensity*=n*(1-D),a.refraction&&v.refractivity&&!E){let t=SH(v.refractivity[1]*Math.exp(-Math.max(T,0)/v.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),v.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:OH.copy(pH)})}}let O=S/x;if(a.sunTint&&O<wH){let e=x/(1+v.topAltitudeKm/w)*(c.atmosphere.surfaceRadiusKm/w);DH.copy(t).sub(b);let n=g.uSpinAxis.value,r=g.uStretch.value;if(FN(v,DH,_,e,c.atmosphere.surfaceRadiusKm,EH,n,r)){let e=mH[0]*EH.x+mH[1]*EH.y+mH[2]*EH.z;e>1e-4&&s.sunTint.multiply(EH.divideScalar(e))}l&&O<u&&(u=O,AN(l,v,b,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var jH=new J;function MH(e,t){let n=0;for(let r of e.values()){if(r.body.data.objectType===G.STAR)continue;let e=r.body.data.radiusKm;!Number.isFinite(e)||e<=0||r.radiusScene<=0||!vO(r)||(t[n++]=r)}return t.length=n,t}function NH(e,t,n,r,i){let a=Nw(),o=Aw(),s=e.get(ev),c=s?.body.position;if(!s||!c){a.uSunAngularRadius.value=0,a.uOccluderCount.value=0,o.count=0;return}let[l,u,d]=n,f=c[0]-l,p=c[1]-u,m=c[2]-d,h=Math.hypot(f,p,m);h>0?(a.uSunDir.value.set(f/h,p/h,m/h),a.uSunAngularRadius.value=Math.asin(Math.min(s.radiusScene/h,1))):a.uSunAngularRadius.value=0;let g=t.length;for(;o.occluders.length<g;)o.occluders.push(new ga),o.leaks.push(new ga);for(let e=0;e<g;e++){let n=t[e],[r,a,s]=n.body.position;o.occluders[e].set(r-l,a-u,s-d,n.radiusScene),i&&n.atmosphere?Vw(n.atmosphere.params,n.atmosphere.planetRadiusKm,o.leaks[e]):o.leaks[e].set(0,0,0,0)}o.count=g;let _=a.uSunDir.value;a.uOccluderCount.value=Rw(a.uOccluders.value,jH,r,_,a.uOccluderLeak.value);for(let t of e.values()){let e=t.eclipseShadow,n=t.body.position;if(!e||!n||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[r,i,a]=n,o=e.uEclipseSelfPos.value.set(r-l,i-u,a-d);e.uOccluderCount.value=Rw(e.uOccluders.value,o,t.radiusScene,_,e.uOccluderLeak.value)}}var PH=10;function FH(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&XS(i,s,c);return}let u=e.get(ev)?.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(PH),r.target.position.set(0,0,0),r.intensity=qS*(s?YS(_):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=PH-b,x.far=PH+b,x.updateProjectionMatrix()}var IH=1.25,LH=.05,RH=2048;function zH(e,t,n){let r=(e,t)=>!!e&&e.intervals.some(([e,n])=>t>e+1e-9&&t<n-1e-9),i=[],a=Math.round(e/n);for(let o=0;o<=a;o++){let s=o===a?e:o*n;(o===0||o===a||!r(t[t.length-1],s))&&i.push({p:s,level:0})}t.forEach((n,a)=>{for(let[o,s]of n.intervals){let c=Math.ceil(Math.max(o,0)/n.step-1e-9),l=Math.floor(Math.min(s,e)/n.step+1e-9);for(let e=c;e<=l;e++){let o=e*n.step;r(t[a-1],o)||i.push({p:o,level:n.level})}}}),i.sort((e,t)=>e.p-t.p||t.level-e.level);let o=(t[0]?.step??n)*.25,s=[];for(let e of i){let t=s[s.length-1];t&&e.p-t.p<o?t.level=Math.max(t.level,e.level):s.push(e)}return s[0].p=0,s[s.length-1].p=e,{at:Float64Array.from(s,e=>e.p),level:Int8Array.from(s,e=>e.level)}}function BH(e,t){let n=2*Math.PI;if(t>=Math.PI)return[[0,n]];let r=e-t,i=e+t;return r<0?[[0,i],[r+n,n]]:i>n?[[0,i-n],[r,n]]:[[r,i]]}function VH(e){return 2*Math.PI/(RH*2**e)}function HH(e,t,n,r){let i=VH(t),a=Math.log2(Math.max(e/n,i)/i);return r!==void 0&&a>r-.85&&a<r+.15?r:Math.max(0,Math.ceil(a-1e-9))}function UH(e,t,n,r,i,a,o){let s=VH(i),c=Math.PI/128,l=2*Math.PI/128,u=e=>Math.acos(1/(1+Math.max(e,0))),d=IH*(u(n)+u(r)),f=Math.max(Math.sin(e),LH),p=Math.round(Math.log2(1/f)),m=[],h=[],g=0;for(let n=o;g<d;n++){let r=s*2**n;if(r>=c)break;g+=a*r;let o=Math.max(i-n,0);m.push({intervals:[[Math.max(e-g,0),Math.min(e+g,Math.PI)]],step:r,level:o});let u=Math.min(g/f,Math.PI),d=Math.ceil(Math.log2(2*u/(4*a)/s)-1e-9),_=Math.max(n+p,d),v=s*2**_;v>=l||h.push({intervals:BH(t,u),step:v,level:Math.max(i-(_-p),0)})}return{rows:zH(Math.PI,m,c),columns:zH(2*Math.PI,h,l),stepLevel:o,innerRadius:a*s*2**o}}function WH(e,t,n,r,i=1){let a=t.length,o=n.length,s=new Float32Array(a*o*3),c=new Float32Array(a*o*3),l=new Float32Array(a*o*2),u=Float64Array.from(n,Math.sin),d=Float64Array.from(n,Math.cos);for(let f=0;f<a;f++){let a=t[f],p=Math.sin(a),m=Math.cos(a);for(let t=0;t<o;t++){let h=f*o+t,g=-d[t]*p,_=m,v=u[t]*p,y=e+(r?r[h]*i:0),b=h*3;s[b]=y*g,s[b+1]=y*_,s[b+2]=y*v,c[b]=g,c[b+1]=_,c[b+2]=v;let x=h*2;l[x]=n[t]/(2*Math.PI),l[x+1]=1-a/Math.PI}}let f=new Uint32Array((a-1)*(o-1)*6),p=0;for(let e=0;e<a-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<o-1;t++){let i=e*o+t+1,a=e*o+t,s=(e+1)*o+t,c=(e+1)*o+t+1;n||(f[p++]=i,f[p++]=a,f[p++]=c),r||(f[p++]=a,f[p++]=s,f[p++]=c)}}return{positions:s,normals:c,uvs:l,indices:f.subarray(0,p)}}var GH=256,KH=.25,qH=.32,JH=.35,YH=300,XH=4e5,ZH=16,QH=8,$H=new Y,eU=new J;function tU(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/128,a=[];for(let t=0;t<=128;t++){let n=t===128?e:t*i;(t===0||t===128||!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 nU(e){let t=new ns;return t.setAttribute(`position`,new Vo(e.positions,3)),t.setAttribute(`normal`,new Vo(e.normals,3)),t.setAttribute(`uv`,new Vo(e.uvs,2)),t.setIndex(new Vo(e.indices,1)),t}var rU=new WeakMap,iU=2;function aU(e){let t=e.displacementMeta?.tiles;return pD(t)&&!rU.get(e)?.dead?t:void 0}function oU(e,t,n,r){let i=mE(e.max_level,e.patches,n/(2*Math.PI),t/Math.PI);if(i===e.max_level)return i;let a=2**(Math.floor(Math.log2(r))-23),o=2*Math.PI*r/(QH*a);return Math.max(e.max_level,Math.min(i,Math.floor(Math.log2(o/RH))))}function sU(e){!e.mesh||!e.displacementMeta||jD(e.mesh.material,e.displacementMeta,e.radiusScene)}function cU(e){let t=rU.get(e);t?.abort?.abort(),t&&(t.abort=void 0),e.terrainWindow&&(e.terrainWindow.riseKm&&sU(e),e.terrainWindow=null,e.currentSegments=void 0)}function lU(e,t,n,r){let i=Math.sin(e)*Math.sin(n)*Math.cos(t-r)+Math.cos(e)*Math.cos(n);return Math.acos(Math.min(1,Math.max(-1,i)))}function uU(e,t,n,r,i,a,o){let s=e.terrainWindow?.riseKm?e.terrainWindow:void 0,c=t.material;s&&(c.displacementScale=0,c.displacementBias=0);let l=rU.get(e)??{failures:0,dead:!1};if(rU.set(e,l),l.abort)return!!s;let u=e.displacementMeta;if(!u)return!!s;let d=xn(e.body.data),f=oU(n,i,a,Q(d)),p=RH*2**f,m=CE().terrainBandCells,h=f>n.max_level?Math.min(m,ZH):m,g=s?.texWidth===p?s.stepLevel:void 0,_=HH(r,f,h,g);if(s){let e=lU(i,a,s.centerTheta,s.centerPhi);if(g===_&&e<JH*s.angRadius||performance.now()-s.builtAt<YH)return!0}let v=UH(i,a,r,.5*u.scale_km/d,f,h,_),y=v.rows.at,b=v.columns.at;if(y.length*b.length>XH)return console.warn(`terrain grid for ${e.body.data.id} would need ${y.length}×${b.length} vertices: left to the shader`),l.dead=!0,!!s;let x=new AbortController;l.abort=x;let S=performance.now();return JT({root:Jt(n),version:n.version,maxLevel:n.max_level,patches:(n.patches??[]).map(({max_level:e,x:t,y:n,version:r})=>({max_level:e,x:t,y:n,version:r})),tileSize:n.tile_size,scaleKm:n.scale_km??0,biasKm:(n.bias_km??0)-(u.absolute_radius?d:0),radius:Q(d),unitsPerKm:Q(1),rows:v.rows,columns:v.columns},x.signal).then(n=>{if(l.abort!==x||(l.abort=void 0,l.failures=0,e.mesh!==t||!e.displacementMap))return;let r=t.geometry;t.geometry=nU(n),r.dispose(),c.displacementScale=0,c.displacementBias=0,e.terrainWindow={thetas:y,phis:b,centerTheta:i,centerPhi:a,angRadius:v.innerRadius,stepLevel:_,texWidth:p,builtAt:performance.now(),riseKm:n.riseKm},e.currentSegments=128,console.debug(`terrain grid ${e.body.data.id}: ${y.length}×${b.length}, level ${_}, ${Math.round(performance.now()-S)} ms`),o()}).catch(()=>{l.abort===x&&(l.abort=void 0,++l.failures>=iU&&(l.dead=!0))}),!!s}function dU(e,t,n,r){let i=e.mesh,a=e.displacementMap;if(!n||!i||!a)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!i} tex=${!!a}`),cU(e),!1;i.updateMatrixWorld(),$H.copy(i.matrixWorld).invert(),eU.copy(t.position).applyMatrix4($H);let o=Q(xn(e.body.data)),s=eU.length(),c=Math.max(s/o-1,1e-6);if(c>(e.terrainWindow?qH:KH))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${c.toFixed(4)}`),cU(e),!1;let l=Math.acos(Math.min(1,Math.max(-1,eU.y/s))),u=Math.atan2(eU.z,-eU.x);u<0&&(u+=2*Math.PI);let d=aU(e);if(d)return uU(e,i,d,c,l,u,r);e.terrainWindow?.riseKm&&sU(e);let f=a.image?.width??2048,p=2*Math.PI/f,m=Math.acos(1/(1+c)),h=Math.max(p,2*m*IH/GH),g=Math.log2(h/p),_=Math.max(0,Math.ceil(g-1e-9)),v=e.terrainWindow;v&&v.texWidth===f&&g>v.stepLevel-.85&&g<v.stepLevel+.15&&(_=v.stepLevel);let y=p*2**_,b=y*GH/2;if(v&&v.texWidth===f&&(v.stepLevel===_&&lU(l,u,v.centerTheta,v.centerPhi)<JH*v.angRadius||performance.now()-v.builtAt<YH))return!0;let x=Math.max(0,l-b),S=Math.min(Math.PI,l+b),C=tU(Math.PI,[[x,S]],y),w=Math.min(Math.PI,b/Math.max(Math.sin(l),LH)),T=Math.max(_,Math.ceil(Math.log2(2*w/GH/p)-1e-9)),E=p*2**Math.max(0,T),D=u-w,O=u+w,k=w>=Math.PI?[[0,2*Math.PI]]:D<0?[[0,O],[D+2*Math.PI,2*Math.PI]]:O>2*Math.PI?[[0,O-2*Math.PI],[D,2*Math.PI]]:[[D,O]],A=tU(2*Math.PI,k,E);if(C.length*A.length>XH)return console.warn(`terrain window for ${e.body.data.id} would need ${C.length}×${A.length} vertices — keeping the uniform sphere`),cU(e),!1;let j=i.geometry;return i.geometry=nU(WH(o,C,A)),j.dispose(),console.debug(`terrain window ${e.body.data.id}: ${C.length}×${A.length} grid, level ${_} (tex ${f})`),e.terrainWindow={thetas:C,phis:A,centerTheta:l,centerPhi:u,angRadius:b,stepLevel:_,texWidth:f,builtAt:performance.now()},e.currentSegments=128,!0}var fU=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],pU=24;function mU(e,t,n,r){if(!n&&!t)return pU;let i=fU[fU.length-1].segs;for(let t of fU)if(e>=t.up){i=t.segs;break}if(i<r){let t=fU.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function hU(e,t,n,r,i,a){let o=t.fov*Math.PI/180,s=n.domElement.clientHeight/(2*Math.tan(o/2)),c=r.visibility.activeSystemId,l=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===G.STAR,o=n.body.data.id;if((o===l||n.terrainWindow)&&dU(n,t,o===l,a))continue;let u=mU(n.radiusScene/n.cachedDist*s,e,c?o===c||r.visibility.isInActiveSystem(n.body.data.parentId):o===i,n.currentSegments??64);if(u===n.currentSegments)continue;let d=Q(xn(n.body.data)),f=n.mesh.geometry;n.mesh.geometry=new _u(d,u,u),f.dispose(),n.currentSegments=u}}function gU(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(sP(n)>sP(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return sP(r)<sP(t)?r:t}function _U(e,t,n,r,i,a,o,s,c){s.apply(e,i);let l=t.fov*Math.PI/180,u=n.domElement.clientHeight/(2*Math.tan(l/2)),d=r.visibility.activeSystemId,f=ew(),p=f.showClouds,m=sP(vE());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=p);for(let s of e.values()){if(!s.mesh||!s.radiusScene||!s.group.visible||!s.availableTiers?.length||s.cachedDist<=0)continue;let e=s.body.data.id;if(d){if(e!==d&&!r.visibility.isInActiveSystem(s.body.data.parentId))continue}else if(e!==a)continue;let l=s.radiusScene/s.cachedDist*u,p=s.cachedDist/s.radiusScene,h;h=l<256&&p>10?`low`:l<1024&&p>2?`medium`:`high`;let g=sP(s.textureTier),_=iP(s)?Math.min(m,sP(`medium`)):m,v=Math.min(sP(h),_),y=uP(o,s.availableFrames),b=y!==s.textureFrame,x=v>g;if(f.showSurfaceTexture&&!s.textureLoading&&(x||b)){let e=x?cP(v,s.availableTiers):s.textureTier;e&&_P(s,e,y,i)}let S=u*n.getPixelRatio();aP(s,t,n,S,f.showSurfaceTexture&&!s.appearance?.surfaceOwned,c),_D(s,t,n,S,c);let C=s.displacementMeta?.tiers;if(s.displacementMap&&!s.displacementLoading&&RD(s,n))s.displacementTier!==`pyramid`&&zD(s,ID);else if(s.displacementMap&&C?.length&&!s.displacementLoading){let e=n.capabilities.maxTextureSize,t=e>=16383&&!hD(s)?2:+(e>=8192),r=s.displacementTier??`low`,i=cP(Math.min(sP(gU(p,r)),t,m),C);i&&i!==r&&zD(s,i)}if(s.clouds&&s.textureTier){let e=cP(sP(s.textureTier),s.clouds.availableTiers),t=YM(o,s.clouds.availableFrames,s.clouds.availableCoverage);e&&t&&QM(s.clouds,e,t)}}}var vU=LI.refMs,yU=new Y,bU=new J,xU=new J,SU=new Zi,CU=new Zi,wU=new J,TU=new J;function EU(e,t,n){return bU.set(e[0],e[1],e[2]),xU.set(t[0],t[1],t[2]),yU.lookAt(bU,xU,n),SU.setFromRotationMatrix(yU).clone()}function DU(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=Tv(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=Dv(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=Tv(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]),CU.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,CU,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=Tv(e.camOriginWorld,e.camTargetWorld,t)}let i=EU(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 OU(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=EU([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=Ev(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(II(o,zI),FI(s,BI))}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(),wU.set(0,0,-1).applyQuaternion(e.flyQ0),TU.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=FI(wU.angleTo(TU),LI);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 kU(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=Ev(n,r);wU.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),TU.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=wU.angleTo(TU);e.focusDurationMs=Math.max(II(a,zI),FI(o,BI)),i&&(e.focusDurationMs=0)}var AU={[G.STAR]:1e3,[G.PLANET]:100,[G.DWARF_PLANET]:10,[G.ASTEROID]:.1,[G.ASTEROID_INNER]:.1,[G.ASTEROID_MAIN_BELT]:.1,[G.ASTEROID_CENTAUR]:1,[G.ASTEROID_TROJAN]:1,[G.ASTEROID_TNO]:1,[G.COMET]:1,[G.MOON]:1},jU=5e-4,MU=new J,NU=new J;function PU(e){return AU[e.data.objectType]??xn(e.data)*.25}function FU(e,t){return Q((t??xn(e.data))+PU(e))}function IU(e,t,n,r){let i=t.data.radiusKm,a=t.position;if(!Number.isFinite(i)||i<=0||!a)return;let o=a[0]-n[0],s=a[1]-n[1],c=a[2]-n[2],l=Math.hypot(o,s,c),u=r?.centerOffsetScene,d=o+(u?u[0]:0),f=s+(u?u[1]:0),p=c+(u?u[2]:0),m=e.position.x-d,h=e.position.y-f,g=e.position.z-p,_=Math.hypot(m,h,g);if(r?.seated){if(_<1e-9){e.position.set(d,f+l+Q(jU),p);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]]){NU.set(a,o,s).applyQuaternion(e.quaternion);let t=m+NU.x,n=h+NU.y,c=g+NU.z,u=Math.hypot(t,n,c);if(u<1e-12)continue;MU.set(t/u,n/u,c/u).applyQuaternion(r.invQuat);let d=r.radialKm([MU.x,MU.y,MU.z]),f=(d===null?l:Q(d))+Q(jU);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/_;e.position.set(e.position.x+m*a,e.position.y+h*a,e.position.z+g*a);return}let v=PU(t);if(_>=Q((r?.outerRadiusKm??i)+v))return;let y=i;r&&_>1e-9&&(MU.set(m/_,h/_,g/_).applyQuaternion(r.invQuat),y=r.radialKm([MU.x,MU.y,MU.z])??i);let b=Q(y+v),x=l>0?Math.min(b,l):b;if(!(_>=x)){if(_<1e-9)m=0,h=x,g=0;else{let e=x/_;m*=e,h*=e,g*=e}e.position.set(d+m,f+h,p+g)}}function LU(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=BF([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=WF(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]=VF([0,0,0],s,c,l,n);r.set(u,d,f)}var RU=50,zU=20;function BU(e){return e<=0?`none`:e<zU?`full`:e<RU?`half`:`none`}function VU(e,t){return TV(e.data,t)}var HU=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),Oy().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 iv)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!==G.MOON||!this.isDefault(i.data.parentId))continue;let a=this.deps.ctx.getBody(i.data.parentId);!a||!Sn(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!==G.BARYCENTER&&e.data.objectType!==G.LAGRANGE_POINT?!0:iv.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,renderer:l}=this.deps;if(r.has(e.data.id))return!1;!e.orbitElements&&!e.data.pageOnly&&e.data.orbitalSource!==W.SPICE_PROBE&&(e.orbitElements=e.data,e.orbitCenterId=e.data.parentId),i.place(e,a.jd),CL([e],o,s,c,r,l.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let u=r.get(e.data.id);if(u&&!e.data.name&&hP(u),e.data.objectType===G.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(Sn(e.data.objectType)||e.data.objectType===G.COMET){let t=this.deps.ctx.bodies.findAsteroidZone(e.data.id);t&&i.bodies.dirtyAsteroidZones.add(t)}let d=e.data.id;return this.defaults.has(d)||(n?this.autoPromoted.add(d):(this.userPromoted.add(d),this.emitUserPromotedCount())),!0}finalizeBuilds(){pR(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(tv),t=this.currentMemberCount(e),n=BU(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)||VU(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 e=b_(r.data,r.data.validityStart),i=b_(r.data,r.data.validityEnd);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),VU(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&&!VU(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||hn(n)||n.data.objectType===G.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}if(e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),Hj(e),gP(e),DM(e),i.remove(e.root),e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),bL(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(),bL(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),bL(e.trail.material));let s=e.body.data.objectType;if(s===G.SPACECRAFT)c.add(e.body.data.parentId);else if(Sn(s)||s===G.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)}},UU=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r){this.deps=e,this.focusedBody=t,this.promotion=new HU({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer: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}place(e){return this.deps.ctx.place(e,this.deps.clock.jd)}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||Dj(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=GU(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&&(wL(t.body)?EL(t,n,r,i):Hj(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}wL(t)&&(TL(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(pR(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e,t){let n=this.place(e);if(!n)return;let{focus:r,camera:i}=this.deps,a=this.cameraTruePos(),o;if(t!==void 0){let e=this._tmpV3.set(a[0]-n[0],a[1]-n[1],a[2]-n[2]).normalize();o=[n[0]+e.x*t,n[1]+e.y*t,n[2]+e.z*t]}OU(r,[...n],i,a,o,ew().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,OU(n,[...e],r,a,o,ew().resolvedReducedMotion);let s=BF(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}this.setFocusTarget(e);let t=e.position;if(!t)return;let{latitude:n,longitude:r,distance:i}=BF(this.cameraTruePos(),t,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(n,r,i)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;hn(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=mM(u,r),f=mM(e,r),p=u&&(hn(u)?u.featureAnchor.hostId:u.data.id),m=hn(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&Hj(e)}if(d&&d!==f){let e=r.get(d);e&&DM(e)}e.data.id!==u?.data.id&&(this.pendingInitialView=null),this.focusedBody=e,hn(e)||(n.bodies.focusFeature=null),i.minDistance=FU(e,lM(r.get(e.data.id)));let g=hn(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),hn(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus();let _=this.place(e);_&&OU(o,[..._],s,this.cameraTruePos(),t,ew().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,focus:a,camera:o,callbacks:s,pointClouds:c}=this.deps,l=i.getBody(e);if(!l)return 0;let u=this.place(l);if(!u)return this.setFocusTarget(l),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=VF(u,n,r,t,this.focusedBodyQuat(l));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u[0]-e[0],u[1]-e[1],u[2]-e[2]).normalize().negate();d=[u[0]+n.x*t,u[1]+n.y*t,u[2]+n.z*t]}let f=BF(d??this.cameraTruePos(),u,this.focusedBodyQuat(l));return s.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?(this.pendingInitialView=null,this.focusedBody?.data.id===e&&Ev(a.focusTruePos,u)<FU(l)?(a.focusTruePos=[...u],this.deps.repositionAll(),c.rebuildBasis(),kU(a,o,this.cameraTruePos(),d,ew().resolvedReducedMotion)):(this.setFocusTarget(l,d),n!==void 0&&r!==void 0&&(a.orbitFly=!0))):this.setFocusTarget(l),a.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e),a=i&&this.place(i);!i||!a||(this.settleOnBodyInstant(i,a),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),l=i.getBody(t),u=c&&this.place(c),d=l&&this.place(l);if(!c||!u||!d)return;this.settleOnBodyInstant(c,u);let f=HF(u,d,n,r);a.position.set(f[0],f[1],f[2]),o.update();let p=BF(f,[0,0,0]);s.onCameraPosition?.(p.latitude,p.longitude,p.distance),this.pendingInitialView=null}settleOnBodyInstant(e,t){let{focus:n,pointClouds:r}=this.deps;this.setFocusTarget(e),n.focusTruePos=[...t],n.focusOriginWorld=[...t],n.focusTargetWorld=[...t],n.focusStartTime=-vU,n.camOriginWorld=null,n.camTargetWorld=null,n.flyQ0=null,n.orbitFly=!1,n.arcOrbit=!1,n.cameraStaysOnBody=!1,this.deps.repositionAll(),r.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!Dj(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=VF([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=BF(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),this.pendingInitialView=s&&WU(c)?{latitude:e,longitude:t,zoom:n}:null}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||WU(t)){this.pendingInitialView=null;return}let n=VF([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function WU(e){return e[0]===0&&e[1]===0&&e[2]===0&&e[3]===1}function GU(e,t){if(!e)return[];if(hn(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&wL(n)?[n]:[]}let n=[];if(wL(e)&&n.push(e),e.data.objectType===G.MOON||e.data.orbitalSource===W.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var KU=1e-6;function qU(e){return e.data.name??e.data.id}var JU=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}windowsOf(e){let t=this.coverage.get(e);if(t)return t;this.pending.has(e)||(this.pending.add(e),cS(e).catch(t=>(console.warn(`[coverage] ${e}: no coverage to arm the clock with:`,t),[])).then(t=>this.coverage.set(e,t)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.orbitalSource===W.SPICE_PROBE?e:void 0,r=n&&this.windowsOf(n.data.id)?.find(([e,n])=>t>e&&t<n);if(!n||!r){this.disarm();return}this.armedProbeId!==n.data.id&&(this.dismissNotice(),this.armedProbeId=n.data.id);let i=r[1]-KU,a=r[0]+KU;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:Number.isFinite(i)?i:null,backwardJd:Number.isFinite(a)?a:null,onHit:e=>this.onHit(n,e,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:qU(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)}},YU=class{group=new Ja;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()}},XU=Math.PI/180;function ZU(e){return`latitude`in e}function QU(e,t,n){let r=e*XU,i=t*XU,a=[Math.cos(r)*Math.cos(i),Math.sin(r),-Math.cos(r)*Math.sin(i)];return n&&$U(n,a,0,a,0),a}function $U(e,t,n,r,i){let a=t[n]*e.a,o=t[n+1]*e.c,s=t[n+2]*e.b,c=Math.hypot(a,o,s);r[i]=a/c,r[i+1]=o/c,r[i+2]=s/c}var eW=class{source=null;radii;out=new Float64Array;of(e,t){if(!t)return e;if(e!==this.source||t!==this.radii){this.out.length!==e.length&&(this.out=new Float64Array(e.length));for(let n=0;n<e.length;n+=3)$U(t,e,n,this.out,n);this.source=e,this.radii=t}return this.out}};function tW(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 nW(e,t,n){return t.place(e,n)}function rW(e,t,n,r){let[i,a,o]=n;if(ZU(e)){let n=Q(xn(t.data)+(e.altitudeKm??0)),[s,c,l]=QU(e.latitude,e.longitude,t.drawnRadii),u=t.orientation?SS(t.orientation,r,t.nutPrec):null;if(!u)return[i+s*n,a+c*n,o+l*n];let d=[0,0,0];return tW(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]=gB(s);return[i+c,a+l,o+u]}function iW(e,t,n){let r=t.getBody(e.body),i=r&&nW(r,t,n);return i?rW(e,r,i,n):null}function aW(e,t,n,r){let i=n.getBody(e.body),a=i&&nW(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 oW(e){let t=vg/10;return[e[0]*t,-e[2]*t,e[1]*t]}function sW(e,t,n){let r=iW(e.position,t,n),i=iW(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 cW=.02,lW=1e-4,uW=1e3/60;function dW(e){return e?.4:.05}function fW(e,t){return 1-(1-e)**(t/uW)}function pW(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=Dj(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){let r=n?.position;if(!n||!r)continue;let i=Q(xn(n.data));if(!(i>0))continue;let a=Math.hypot(e.position.x-(r[0]-t[0]),e.position.y-(r[1]-t[1]),e.position.z-(r[2]-t[2]));s=Math.min(s,a-i)}let c=o?Q(xn(o.data)):0,l=Math.tan(Xi.degToRad(e.getEffectiveFOV())/2);return{rotate:mW(c>0?(a-c)*l/(Math.PI*c):1,lW),translate:mW(s/a,cW)}}function mW(e,t){return Math.min(1,Math.max(t,e))}var hW=Math.PI/180;function gW(e,t){let n=e*hW,r=t*hW;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function _W(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new OT(i),[o,s,c]=gW(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function vW(e){e.parent?.remove(e),e.element.remove()}var yW=new J;function bW(e,t,n){if(!e)return;let r=t.get(tv);if(!r?.mesh)return;yW.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=yW.x,a=yW.y,o=yW.z,s=r.root.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 xW=-1,SW=1.2,CW=Q(1e6),wW=.02,TW=2,EW=2.3,DW=.9,OW=new J,kW=.25,AW=10,jW=4,MW=4,NW=28,PW=.02,FW=class e{renderer;composer;maxSceneSamples;atmoDepthPass;modelDepthPass=new LL;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=VL();pointClouds;systemData;positionDiagnostics=new VV;placer;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new YU;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;_tmpFwd=new J;_tmpSun=new J;_tmpLeak=new J;_occluders=[];_planeNormal=new J(0,0,1);_modelRaycaster=new Qd;_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:vU};lastUpdatedJd=NaN;get placedJd(){return this.lastUpdatedJd}lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;disposed=!1;lastDataVersion=-1;dateHolds=0;seenJumps=0;jumpJd=null;focusWasOutOfRange=!1;seekAwaitsData=!1;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 Zi;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=CE();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;orbitDampingFactor;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;halosShown=!0;textureLoader=new cd;appearances=new kL;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(ev)?.root.children.find(e=>e instanceof Td)}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.seenJumps=i.jumps,this.callbacks=o,this.outOfRange=new kV(o.notices),this.labelContainer=n;let s=wI(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.maxSceneSamples=s.maxSceneSamples,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new DL(c.x,c.y),this.modelScene=new no,this.modelScene.environment=ZS(this.renderer),this.modelScene.environmentIntensity=JS,this.modelCamera=new xd(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new kd(16777215,KS);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new Od(16777215,qS),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 Ws(new pu(40,40),new vu({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new _R(this.scene),this.skyDebugMarkers=new FR(this.scene),this.haloDebug=new WR(this.canvas),this.travelPath=new qB(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new QB(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),JP(this.scene,this.renderer,r,()=>this.disposed),this.placer=new BV(r,this.bodyObjects,this.positionDiagnostics,()=>this.dateHeld()),r.placer=this.placer;let u=[r.getBody(a.id),r.bodies.majorBodies.find(e=>e.data.id===GF),r.bodies.majorBodies.find(e=>e.data.id===ev)].find(e=>e&&this.placer.place(e,this.clock.jd)),d=u?.position??iV;this.focus.focusTruePos=[...d],this.focus.focusOriginWorld=[...d],this.focus.focusTargetWorld=[...d],this.focus.focusStartTime=-vU,this.pointClouds=new Cz(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(d),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new vF(this.camera,t),this.controls.enableDamping=!0,this.orbitDampingFactor=dW(ew().resolvedReducedMotion),this.controls.minDistance=u?FU(u):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 GI(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new hR(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new UU({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()},u,this.hoveredBodyIds,this.renderer),this.coverageWatch=new JU(i,o.notices);let f=u?.data.id===a.id?a:{latitude:45,longitude:0,zoom:15},p=VF([0,0,0],f.latitude,f.longitude,f.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(...p),this.focusController.setPendingInitialView({latitude:f.latitude,longitude:f.longitude,zoom:f.zoom}),u&&r.visibility.setFocused(u),r.visibility.updateCamera(f.zoom,this.clock.jd),o.onFocusChange(u),this.buildScene(),u&&this.focusController.promotion.ensureBodyObjects(u),u&&this.focusController.syncUpgradeTargets(u),this.repositionAll(),u&&this.maybeLoadTexture(u),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new NI(this.renderer,this.camera),this.pointerInteraction=new OI(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(){CL(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,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)))(()=>{pR(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.whereBody(t);if(!r)return;let i=this.focus.focusTruePos,a=r[0]-i[0]-this.camera.position.x,o=r[1]-i[1]-this.camera.position.y,s=r[2]-i[2]-this.camera.position.z,c=Math.hypot(a,o,s);c>n*1.35&&c<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.where(e),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.where(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.sceneJd),this.travelPath.reposition(t,this.focus.focusTruePos,e=>this.where(e)),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.where(e);if(!n)return;let[r,i,a]=gB(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=gB(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.where(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e);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.where(e.centerId),r=n?this.travelFocusWorld(n):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId),n=t&&this.whereBody(t);if(!t||!n)continue;let a=this.ctx.visibility.resolveSystemId(t);if(!a)continue;let o=this.ctx.visibility.systemReachAU(a);if(!(o>0))continue;let s=Ev(r,n)/10;!i&&s<=o?i=a:s<=o*2?this.systemData.prefetch(a):this.systemData.discardPrefetch(a)}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()}checkDrawnArePlaced(){for(let e of this.bodyObjects.values()){if(e.body.position)continue;let t=e.root.visible?`root`:e.trail?.visible?`trail`:e.model?.parent===this.modelScene?`model`:null;t&&this.positionDiagnostics.warnOnce(`drawn-unplaced`,e.body.data.id,()=>`[scene] ${e.body.data.id} has no place (${e.body.unplaced}) and its ${t} is drawn`)}}placeOf(e){return this.applyJdUpdate(),this.whereBody(e)}panCameraTo(e,t){return this.disarmLimits(),this.focusController.panCameraToBody(e,t),this.focus.focusDurationMs}where(e){return this.placer.at(e,this.sceneJd)}whereBody(e){return this.placer.place(e,this.sceneJd)}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let i=r.body.position;i&&r.root.position.set(i[0]-e,i[1]-t,i[2]-n)}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){Bz(i.body,a,o,e,this.sceneJd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;Vz(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.controls.dampingFactor=fW(this.orbitDampingFactor,n||16.666666666666668),this.holdingCamera||this.cameraUp.update(this.sceneJd),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.sceneJd,r);let i=this.holdingCamera?this.applyHeldCamera():DU(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=Sv(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||hn(a);t&&IU(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),oM(this.bodyObjects.get(a.data.id))&&IU(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(pW(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.sceneJd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.sceneJd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=nB(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(),tV(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),nH(this.bodyObjects,this.focus.focusTruePos,ew().realisticLighting,ew().overexposeRings,this.camera.position,this.pxPerRad());let s=MH(this.bodyObjects,this._occluders);NH(this.bodyObjects,s,this.focus.focusTruePos,this.camera.position.length(),ew().showAtmospheres),KV(this.bodyObjects,s,ew().realisticLighting,this.sunIntensityScale),s.length=0;let c=AH(this.bodyObjects,this.camera.position,ew().showAtmospheres,ew().realisticLighting,this.sunIntensityScale,ow(),this.sceneJd);_w(r,c.shellProminent),this.scene.backgroundIntensity=c.skyboxIntensity,this.applyLayerChrome();let l=this.bodyObjects.get(ev);l&&sL(l.corona,l.starPoint,c.sunTint);let u=ew().highAmbient?1:KS;if(!ew().highAmbient&&ew().realisticLighting){let e=this.bodyObjects.get(ev)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;u*=YS(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=u;bW(this.userLocationMarker,this.bodyObjects,this.camera);let d=mM(this.focusController.current,this.bodyObjects);_U(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,d,this.sceneJd,this.appearances,this.invalidate),hU(this.bodyObjects,this.camera,this.renderer,this.ctx,d,this.invalidate),FH(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,ew().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(c.sunRefraction),c.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.syncSceneSamples(c.insideShell),this.composer.readBuffer.resolveDepthBuffer=this.overlayActive,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)};syncSceneSamples(e){let t=this.composer.readBuffer,n=e?0:Math.min(this.tier.sceneSamples,this.maxSceneSamples);t.samples!==n&&(t.samples=n,t.dispose())}updateTightFar(e){if(bw())return;let t=this.focusController.current,n=t?mM(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e,o=r?.body.position;if(t&&o&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[r,i,s]=o,c=this.camera.position;a=Math.hypot(e+c.x-r,t+c.y-i,n+c.z-s)}let s=this.tightFar?EW:TW;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*s}updateDepthFar(){if(bw())return;let e=xI,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(ev);if(this.tightFar){let e=this.bodyObjects.get(t)?.body.position;if(e){let o=Math.hypot(e[0]-n,e[1]-r,e[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s?.body.position&&o(s.body.position);for(let e of this.bodyObjects.values()){let t=e.body.position;t&&this.ctx.visibility.hasFullRendering(e.body)&&o(t)}e=Math.min(xI,Math.max(CW,Math.sqrt(a)*SW))}Math.abs(e-this.camera.far)>this.camera.far*wW&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(ev),n=t?.body.position;if(!t||!n)return;let[r,i,a]=this.focus.focusTruePos,[o,s,c]=n,l=o-r,u=s-i,d=c-a;if(e){let t=this.camera.position,n=this._tmpV3.set(l-t.x,u-t.y,d-t.z),r=n.length();n.divideScalar(r);let i=OW.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),l=t.x+n.x*r,u=t.y+n.y*r,d=t.z+n.z*r)}let f=1;if(this.tightFar){let e=this.camera.far*DW,t=Math.hypot(l,u,d);t>e&&(f=e/t)}f===1&&this.sunProxyK===1&&!e||(this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.root.position.set(l*f,u*f,d*f),t.mesh?.scale.setScalar(this.sunBaseMeshScale*f),t.corona?.scale.set(this.sunBaseCoronaScale*f,this.sunBaseCoronaScale*f,1),this.sunProxyK=f)}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}tilesFailed(e){return!!this.bodyObjects.get(e)?.tileOverlay?.chain.dead}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=QU(t,n,r.drawnRadii);return hO(this.bodyObjects.get(e),e,xn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(oM(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:cM(n),centerOffsetScene:sM(n),radialKm:e=>aM(n,e)};if(!(!t||!e.orientation))return{invQuat:SS(e.orientation,this.sceneJd,e.nutPrec).invert(),seated:t,radialKm:t=>hO(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&Dj(t.body)&&vO(t)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model;if(!n)continue;let r=vO(t),i=t.modelRoot;if(!i){r&&n.parent!==this.modelScene?this.modelScene.add(n):!r&&n.parent&&n.removeFromParent();continue}if(e&&r)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==i){i.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=Fj(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(ev)?.body.position,a=e.body.position;if(!i||!a)return;this._tmpSun.set(i[0]-a[0],i[1]-a[1],i[2]-a[2]).normalize(),this.shadowLight.position.copy(e.root.position).addScaledVector(this._tmpSun,AW*n),this.shadowLight.target.position.copy(e.root.position);let o=this.shadowLight.shadow.camera;o.left=o.bottom=-jW*n,o.right=o.top=jW*n,o.near=MW*n,o.far=NW*n,o.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=PW*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.root.position);let n=this._tmpV3.length(),r=Fj(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||!vO(t))continue;let i=Fj(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.root.position,e.root.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(ev)?.body.position,s=e.body.position,c=1;if(o&&(this._tmpSun.set(o[0]-s[0],o[1]-s[1],o[2]-s[2]),ew().realisticLighting&&(c=YS(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)),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 l=Bw(this._tmpV3,this._tmpV3),u=Ww(this._tmpV3,this._tmpV3,this._tmpLeak);this.modelLight.color.setRGB(l+u.x,l+u.y,l+u.z),this.modelLight.intensity=qS*c*this.sunIntensityScale,this.modelScene.environmentIntensity=JS*l*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);let d=e.model.userData;this._tmpV3.copy(d.boxCenter).applyQuaternion(e.model.quaternion).add(e.model.position),this.modelCamera.getWorldDirection(this._tmpFwd);let f=this._tmpV3.sub(this.modelCamera.position).dot(this._tmpFwd)-d.halfExtents.length();this.renderer.autoClear=!1,this.renderer.clearDepth(),this.modelDepthPass.run(this.renderer,this.composer.readBuffer.depthTexture,this.camera,this.modelCamera,r,f),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=kW/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 BF([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?xW:Nn.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||LU(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,r=e?.position;return r?[n.x+t[0]-r[0],n.y+t[1]-r[1],n.z+t[2]-r[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&&sW(e,this.ctx,this.sceneJd);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&&(mP(t,this.textureLoader,this.sceneJd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(CS(t.mesh,e.orientation,this.sceneJd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}),zj(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=FU(t.body,lM(t))),!this.ctx.layers.skipped.has(`nomenclature`))return SM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&EM(t,this.selectedFeatureId)}))}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&(Hj(t),gP(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=mM(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&EM(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!==G.SPACECRAFT&&!hn(e))return null;let t=Sv(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`}|${nO()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;probeTargetRetries=new Ex(()=>{this.lastProbeTargetCheck=null,this.invalidate()});askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==W.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),rS(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)||this.probeTargetRetries.waiting(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Mg(this.clock.jd)).then(()=>this.probeTargetRetries.clear(r),e=>{console.warn(`[renderer] the body ${r} a craft is fit to did not load:`,e),this.requestedProbeTargets.delete(r),this.probeTargetRetries.fail(r)});return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}holdDate(){this.dateHolds++;let e=!0;return()=>{e&&this.dateHolds--,e=!1}}jumpLoads(){let{clock:e,ctx:t}=this;e.jumps!==this.seenJumps&&(this.seenJumps=e.jumps,this.jumpJd=e.jd,t.refreshTick(Mg(e.jd)),t.chebStore?.request(e.jd),t.probeStore?.request(e.jd));let n=this.jumpJd;return n===null?!1:!t.chebStore?.loadingAt(n)&&!t.probeStore?.loadingAt(n)?(this.jumpJd=null,!1):(this.invalidate(),!0)}dateHeld(){return!Number.isNaN(this.lastUpdatedJd)&&(this.dateHolds>0||this.jumpLoads())}get sceneJd(){return this.dateHeld()?this.lastUpdatedJd:this.clock.jd}applyJdUpdate(e=!1){if(this.dateHolds>0||this.jumpLoads())return;this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0,i=this.ctx.bodies.dataVersion+(this.ctx.chebStore?.version??0)+(this.ctx.refresher?.wakes??0);if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion&&i===this.lastDataVersion){this.clock.seeked=!1;return}let a=this.clock.seeked||this.seekAwaitsData;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.lastDataVersion=i,this.ctx.refreshTick(Mg(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let o=eV({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,placer:this.placer,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(),this.seekAwaitsData=a&&o.focusLoading;let s=o.focusUnplaced&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=o.focusUnplaced,e&&a&&s&&o.anchorId){let e=this.ctx.getBody(o.anchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.orbitDampingFactor=dW(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),o=a&&this.whereBody(a);if(!a||!o)return 0;this.focusController.clearPendingInitialView();let s=mM(this.focusController.current,this.bodyObjects)===e.hostId,c=qF(e,t);this.ctx.bodies.focusFeature=c;let l=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,l&&EM(l,e.featureId);let u=this.whereBody(c);if(!u)return 0;let d=this.focusController.focusedBodyQuat(c);if(r===`pan`){let e=BF(this.focusController.cameraTruePos(),u,d);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(c),this.focus.focusDurationMs}let f=u[0]-o[0],p=u[1]-o[1],m=u[2]-o[2],h=Math.hypot(f,p,m);h>1e-9?(f/=h,p/=h,m/=h):(f=0,p=1,m=0);let g=r===`snap`&&i?VF(u,i.latitude,i.longitude,i.zoom,d):[u[0]+f*n,u[1]+p*n,u[2]+m*n],_=BF(g,u,d);if(this.callbacks.onCameraPosition?.(_.latitude,_.longitude,_.distance),r===`snap`){this.focusController.setFocusTarget(c,g);let e=this.focus;return e.focusTruePos=[...u],e.focusOriginWorld=[...u],e.focusTargetWorld=[...u],e.focusStartTime=-vU,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(g[0]-u[0],g[1]-u[1],g[2]-u[2]),this.controls.update(),0}if(s){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(c),this.focus.focusTruePos=[...u],this.camera.position.set(e[0]-u[0],e[1]-u[1],e[2]-u[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),kU(this.focus,this.camera,e,g,ew().resolvedReducedMotion)}else this.focusController.setFocusTarget(c,g),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||!vO(e))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=e=>e?.model&&vO(e)?e:null,t=this.focusController.current;if(!t){let t=this.travelFocus?.centerId;return e(t?this.bodyObjects.get(t):void 0)}let n=hn(t)?t.featureAnchor.hostId:t.data.id,r=this.bodyObjects.get(n);return e(r)||(t.data.orbitalSource===W.SPICE_PROBE&&!r?.isLanded?e(this.bodyObjects.get(t.data.parentId)):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 YR({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:Dj(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 Ja,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new of(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 Ss(new cs({map:new qc(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=Yb(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&&fT(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(tv);n?.mesh&&(this.userLocationMarker&&vW(this.userLocationMarker),this.userLocationMarker=_W(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(vW(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(wE()),this.composer.setPixelRatio(wE()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),JP(this.scene,this.renderer,this.ctx,()=>this.disposed),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=CE();let e=wE();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),mI(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&&Hj(e);for(let e of this.bodyObjects.values())tP(e),gD(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),IW(this.scene.background),IW(this.scene.environment),IW(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.modelDepthPass.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))IW(t);e.dispose()}})}};function IW(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var LW=Qe({progress:null,bootPending:!1}),RW=6371;function zW(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 BW={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:zW(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},VW=1.6,HW=1.0005,UW=new J(.55,.25,.8).normalize(),WW=[`low`,`medium`,`high`,`ultra`],GW=4,KW=12,qW=10,JW=16,YW=5;function XW(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function ZW(e,t){let n=`low`;for(let r of e.tiers){let e=XW(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var QW=new Set([`WebKit WebGL`,`Mozilla`,``]);function $W(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!QW.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function eG(e,t){let n=e.getContext(),r=new no,i=new xd(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new Ou({color:7829367,roughness:1,metalness:0}),o=new Ws(new _u(1,64,64),a);o.renderOrder=1,r.add(o);let s=new Od(16777215,2);s.position.copy(UW),r.add(s);let c=BW,l=iT(c,1,RW),u=l.material.uniforms;u.uSunDir.value.copy(UW),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,HW,0),i.lookAt(1,HW+.1,0)):(i.position.set(0,0,VW),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}={})=>{dT(l,rw[e]),d(t);let i=0;for(let e=0;e<GW;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(JW,Math.max(1,Math.ceil(qW/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<KW;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=YW){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(),hT(l)}}}function tG(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 nG(e,t){let n=t.tiers??WW,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=eG(e,i),c=GW+KW,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`?GW: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`?KW:GW,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(rw[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 tG(e,n,f,p)}var rG=60,iG=100,aG=3e4,oG=25e4,sG=`v1`,cG=!1,lG=null,uG=Promise.resolve();function dG(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/oG);return`${$W(e)}|${n}|${sG}`}function fG(){cG||typeof window>`u`||(cG=!0,LW.bootPending=!0,uG=new Promise(e=>{let t=()=>{LW.bootPending=!1,e()};setTimeout(t,aG),setTimeout(()=>void mG(!1).finally(t),iG)}))}function pG(){return uG}function mG(e){return lG??=hG(e).finally(()=>lG=null),lG}async function hG(e){let t=ew();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new Th({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(JC()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=dG(n);if(!e&&t.atmosphereCalibration?.key===r)return;LW.progress=0;let i=await nG(n,{budgetMs:1e3/rG,startTier:iw(),onProgress:e=>LW.progress=e.fraction}),a={};for(let e of i.tiers){let t=XW(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=ZW(i,1e3/rG);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{LW.progress=null,n?.dispose(),n?.forceContextLoss()}}var gG=class{object=new Ja;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 OT(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,IT(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?iW(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=aW(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()}},_G=3,vG=new J,yG=new J,bG=new J;function xG(e){let[t,n=t]=(e??``).split(/[\s,]+/).filter(Boolean).map(Number);return t>0&&n>0?[t,n]:null}function SG(e,t){return vG.set(1,0,0).applyQuaternion(e.quaternion),yG.set(0,1,0).applyQuaternion(e.quaternion),bG.set(0,0,-1).applyQuaternion(e.quaternion),t/(2*Math.tan(e.getEffectiveFOV()*Math.PI/360))}function CG(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*vG.x+a*vG.y+o*vG.z,r[1]=i*yG.x+a*yG.y+o*yG.z,r[2]=i*bG.x+a*bG.y+o*bG.z}function wG(e,t,n){bG.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)*bG.x+(e[o*3+1]-i)*bG.y+(e[o*3+2]-a)*bG.z<n.near*2)return!0;return!1}function TG(e,t,n,r,i){let a=SG(n,r),o=[0,0,0],s=0,c=0,l=0,u=!1;for(let r=0;r<t;r++){if(CG(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 EG=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=SG(r,i),o=i*r.aspect*_G/2,s=i*_G/2,c=r.near*2,{a:l,b:u}=this,d=!1,f=0,p=0,m=0;n>0&&CG(e,0,r,l);for(let i=0;i+1<n;i++,[l,u]=[u,l]){CG(e,i+1,r,u);let n=0,h=1;for(let e=0;e<5&&n<=h;e++){let t=DG(e,l,a,o,s,c),r=DG(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 DG(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 OG=1e-9,kG=class{object=new Ja;anchor;color;widthPx;opacity;dash;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;seen=new EG;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=xG(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?iW(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])>OG||Math.abs(o[1]-this.lastOrigin[1])>OG||Math.abs(o[2]-this.lastOrigin[2])>OG;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||wG(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),$L(this.mesh.geometry,e.points,e.alphas,e.alphas,e.count),this.dash&&nR(this.mesh.geometry,e.lengths,e.count)}else s&&$L(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=rR(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 AG(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=jG(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,jG(n,a)]}function jG(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 MG(e,t={}){let[n,r]=AG(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 NG(e){if(e.length<3)return[];let[t,n]=AG(PG(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 uu.triangulateShape(r,[]).flat()}function PG(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 FG(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 IG([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 IG(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 LG(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]]:IG([n,r,i])}function RG(e,t){return new Eu({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
6366
+ `;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 WR(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 ns;c.setAttribute(`position`,new Wo(o,3));let l=new Rc(c,new Tc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function GR(){let e=new Ja;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of FR){HR(n.raDeg,n.decDeg,t).multiplyScalar(PR);let r=new RT(UR(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of VR){let n=WR(t.zero,t.pole,PR*.999,t.color,BR);n.name=t.name,e.add(n)}return e}function KR(e){e.traverse(e=>{e instanceof RT&&e.element.remove(),e instanceof Rc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var qR=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=GR(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(KR(this.group),null)}},JR=new J,YR=new J,XR=new J,ZR=[JR,YR,XR];function QR(e,t,n){return JR.set(1,0,0).applyQuaternion(e).transformDirection(t),YR.set(0,1,0).applyQuaternion(e).transformDirection(t),XR.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:ZR,a:n}}function $R(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 ez(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 tz(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,N=(-2*E*A+D*k)/j,P=-n/T;a.ox=M*P-e,a.oy=N*P-t}var nz=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Zi;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,l=o.body.position;if(!e||c<=0||!l)continue;let[u,d,b]=l;this.tmp.set(u-m,d-h,b-g).applyMatrix4(p);let x=this.tmp.x,S=this.tmp.y,C=this.tmp.z;if(C>=0||x*x+S*S+C*C<=c*c)continue;let w=DO(this.items,y++,rz),T=!!(o.semiAxesScene&&o.mesh);if(T){let e=QR(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);w.e0.copy(e.e[0]),w.e1.copy(e.e[1]),w.e2.copy(e.e[2]),w.sa[0]=e.a[0],w.sa[1]=e.a[1],w.sa[2]=e.a[2],ez(w.occ,x,S,C,e,f,_,v,o.body.data.id,o.cachedDist)}else w.e0.set(1,0,0),w.e1.set(0,1,0),w.e2.set(0,0,1),w.sa[0]=w.sa[1]=w.sa[2]=c,$R(w.occ,x,S,C,c,f,_,v,o.body.data.id,o.cachedDist);let E=C*C-c*c,D=E<=0,O=D?0:c*f/Math.sqrt(E),k=D||O>=16;this.tmp.set(u-m,d-h,b-g).project(t),w.cx=(this.tmp.x*.5+.5)*i,w.cy=(-this.tmp.y*.5+.5)*a,BO(o,t,n,i,a,this.labelRect),w.hx=this.labelRect.x,w.hy=this.labelRect.y,w.id=o.body.data.id,w.camX=x,w.camY=S,w.camZ=C,w.worldR=c,w.dist=o.cachedDist,w.isEllipsoid=T,w.degenerate=D,w.isOccluder=k,w.meshHidden=!s.visible,w.labelVisible=e.visible,w.maximized=o.labelMaximized!==!1,w.focused=o.body.data.id===r,w.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,RO(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(),oz(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)}}az(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,N=S*O-C*D,P=n.projectionMatrix.elements,ee=!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*N),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,_=P[3]*m+P[7]*h+P[11]*g+P[15];if(_<=1e-6){ee=!1;continue}let S=(P[0]*m+P[4]*h+P[8]*g+P[12])/_,C=(P[1]*m+P[5]*h+P[9]*g+P[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;ee?e.lineTo(w,T):(e.moveTo(w,T),ee=!0)}return!0}dispose(){this.setVisible(!1)}};function rz(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:MO(),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 iz=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function az(e,t){let n=t-8-(iz.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of iz)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 oz(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 sz(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 cz="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:P,mp:se}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,Y,X,le,ue,de,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),de=fe+2*.01675*Math.sin(fe),X=Math.sin(de),U=.5*X*X-.25,W=-.5*X*Math.cos(de);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*X,ge=p*U+m*W+ee*X,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),de=fe+2*.0549*Math.sin(fe),X=Math.sin(de),U=.5*X*X-.25,W=-.5*X*Math.cos(de);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*X,be=re*U+ie*W+x*X,xe=ae*U+S*W;return G=pe+_e,J=me+ve,Y=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,Y-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,P+=K,N+=q,se+=Y):(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),le=se+P+L*N,H=Y+K-J*N*R,le+=H,ue=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(ue-N)>a&&(N<ue?N+=o:N-=o),se+=Y,P=le-se-L*N)),{ep:oe,inclp:M,nodep:N,argpp:P,mp:se}}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,P,se,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,Y,X,le,ue,de,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,le=3*(l*l+u*u)+_e*$,ue=6*(l*d+u*f)+ve*$,de=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),le=le+le+ke*_e,ue=ue+ue+ke*ve,de=de+de+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,Y=v*y+_*b,X=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=Y,N=X,P=le,se=ue,F=de,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*se,$e=-2*A*(F-P),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*Y,st=2*W*X,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*ue,dt=-2*K*(de-le),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:Y,s7:X,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:P,sz2:se,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:le,z2:ue,z3:de,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:P,z33:se,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:Y,d4422:X,d5220:le,d5232:ue,d5421:de,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*(P+se-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,Y=qe*$*Be,X=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,le=qe*Ae*He,ue=qe*je*We,qe=2*Je*2.1765803e-9,de=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:Y,d4422:X,d5220:le,d5232:ue,d5421:de,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,P=5.7686396,se=.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-P)+r*Math.sin(D-P)+i*Math.sin(G+D-se)+a*Math.sin(-G+D-se)+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-P)+r*Math.cos(D-P)+i*Math.cos(G+D-se)+a*Math.cos(-G+D-se)+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,P=e.argpo+e.argpdot*e.t,se=e.nodeo+e.nodedot*e.t;g=P,D=N;let F=e.t*e.t;if(k=se+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=P-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 Y=L*(1-G),X=Math.sqrt(L)*K/Y,le=Math.sqrt(J)/Y,ue=Math.sqrt(1-q);S=K/(1+ue);let de=L/Y*(r-H-V*S),fe=L/Y*(n-V+H*S);v=Math.atan2(de,fe);let pe=(fe+fe)*de,me=1-2*de*de;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=Y*(1-1.5*ge*ue*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=X-O*he*e.x1mth2*pe/l,be=le+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,P,se,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,Y,X,le,ue,de,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}P=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,se=Math.abs(1-O),S=F*Z**4,C=S/se**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/se*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/($*se)*(-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*P*Q.no,he=.5*me*f*P,ge=-.46875*-165597e-11*P*P*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:Y,sz21:X,sz23:le,sz31:ue,sz33:de}=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:Y,sz21:X,sz23:le,sz31:ue,sz33:de,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=2451545,T=86400,E=[[2441317.5,10],[2441499.5,11],[2441683.5,12],[2442048.5,13],[2442413.5,14],[2442778.5,15],[2443144.5,16],[2443509.5,17],[2443874.5,18],[2444239.5,19],[2444786.5,20],[2445151.5,21],[2445516.5,22],[2446247.5,23],[2447161.5,24],[2447892.5,25],[2448257.5,26],[2448804.5,27],[2449169.5,28],[2449534.5,29],[2450083.5,30],[2450630.5,31],[2451179.5,32],[2453736.5,33],[2454832.5,34],[2456109.5,35],[2457204.5,36],[2457754.5,37]];function D(e){for(let t=E.length-1;t>=0;t--)if(e>=E[t][0])return E[t][1];return E[0][1]-1}function O(e){let t=6.239996+1.99096871e-7*(e-w)*T;return .001657*Math.sin(t+.01671*Math.sin(t))}function k(e){if(!Number.isFinite(e))return e;let t=e+(D(e)+32.184)/T;return t+O(t)/T}const A=Math.PI/180,j=A/3600,oe=1e-4*j,M=[[0,0,0,0,1,-171996,-174.2,92025,8.9],[0,0,2,-2,2,-13187,-1.6,5736,-3.1],[0,0,2,0,2,-2274,-.2,977,-.5],[0,0,0,0,2,2062,.2,-895,.5],[0,1,0,0,0,1426,-3.4,54,-.1],[1,0,0,0,0,712,.1,-7,0],[0,1,2,-2,2,-517,1.2,224,-.6],[0,0,2,0,1,-386,-.4,200,0],[1,0,2,0,2,-301,0,129,-.1],[0,-1,2,-2,2,217,-.5,-95,.3],[1,0,0,-2,0,-158,0,-1,0],[0,0,2,-2,1,129,.1,-70,0],[-1,0,2,0,2,123,0,-53,0],[1,0,0,0,1,63,.1,-33,0],[0,0,0,2,0,63,0,-2,0],[-1,0,2,2,2,-59,0,26,0],[-1,0,0,0,1,-58,-.1,32,0],[1,0,2,0,1,-51,0,27,0]];function N(e,t){let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[3*r+i]=e[3*r]*t[i]+e[3*r+1]*t[3+i]+e[3*r+2]*t[6+i];return n}function P(e){let t=Math.cos(e),n=Math.sin(e);return[1,0,0,0,t,n,0,-n,t]}function se(e){let t=Math.cos(e),n=Math.sin(e);return[t,0,-n,0,1,0,n,0,t]}function F(e){let t=Math.cos(e),n=Math.sin(e);return[t,n,0,-n,t,0,0,0,1]}function I(e){let t=(e-w)/36525,n=(2306.2181*t+.30188*t*t+.017998*t**3)*j,r=(2004.3109*t-.42665*t*t-.041833*t**3)*j,a=(2306.2181*t+1.09468*t*t+.018203*t**3)*j,o=134.96298139+477198.8673981*t+.0086972*t*t,s=357.52772333+35999.05034*t-1603e-7*t*t,c=93.27191028+483202.0175381*t-.0036825*t*t,l=297.85036306+445267.11148*t-.0019142*t*t,u=125.04452222-1934.1362608*t+.0020708*t*t,d=0,f=0;for(let[e,n,r,i,a,p,m,ee,te]of M){let h=(e*o+n*s+r*c+i*l+a*u)*A;d+=(p+m*t)*Math.sin(h),f+=(ee+te*t)*Math.cos(h)}d*=oe,f*=oe;let p=(84381.448-46.815*t-59e-5*t*t+.001813*t**3)*j,m=d*Math.cos(p),ee=N(N(N(N(F(n),se(-r)),F(a)),N(N(P(-p),F(d)),P(p+f))),F(-m));return N(P(i*A),ee)}let L=NaN,R=[1,0,0,0,1,0,0,0,1];function ce(e){return Math.abs(e-L)<=.01||(R=I(e),L=e),R}function z(e){return new Date((e-2440587.5)*864e5).toISOString()}function B(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:z(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 V=Math.PI/180;Math.cos(i*V),Math.sin(i*V);const H=Math.PI/180,U=Math.cos(i*H),W=Math.sin(i*H),G=10/r;function K(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 q(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:T,visibleFromDays:E}=r,D=p!==0&&r.applyFlagFilter,O=r.pickBase,A=d.length/3|0,j=i-w,oe=k(i),M=ce(i),N=0;for(let w=0;w<m&&!(N>=A);w++){let m=ee[w];if(m===0||E[w]>j||D&&(T[w]&p)!==p)continue;if(m===3){let e=C[w];if(!e){if(e=B({noradCatId:r.satnum[w],epochJd:re[w],meanMotion:b[w]/360,eccentricity:g[w],inclination:ne[w],raOfAscNode:_[w],argOfPericenter:v[w],meanAnomaly:y[w],bstar:r.bstar[w],meanMotionDot:r.ndot[w],meanMotionDdot:r.nddot[w],elementSetNo:0,revAtEpoch:0}),!e){ee[w]=0;continue}C[w]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x*G,m=n.position.y*G,te=n.position.z*G,h=M[0]*p+M[1]*m+M[2]*te,ie=M[3]*p+M[4]*m+M[5]*te,S=M[6]*p+M[7]*m+M[8]*te,T=-ie;if(!K(d,N,a+h-c,o+S-l,s+T-u))continue;if(f){let e=O+w,t=N*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}N++;continue}let k,A,P=g[w],se=ne[w],F=_[w],I=v[w];if(m===2){let e=n(ie[w],S[w],te[w]?i:oe);if(!e)continue;k=e.r*Math.cos(e.nu),A=e.r*Math.sin(e.nu)}else{let n=h[w];if(!isFinite(n)||!isFinite(P)||!isFinite(y[w])||!isFinite(b[w]))continue;let r=(te[w]?i:oe)-re[w],a=(y[w]+b[w]*r)*H,o,s;if(P<1||n>0){let t=Math.min(P,.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,P);if(!isFinite(e))continue;let r=P*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(P*P-1)*Math.sinh(e)/r,c=(P-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-P*Math.cosh(e))}k=s*Math.cos(o),A=s*Math.sin(o)}if(!isFinite(k)||!isFinite(A))continue;let L=Math.cos(I*H),R=Math.sin(I*H),ce=Math.cos(se*H),z=Math.sin(se*H),V=Math.cos(F*H),q=Math.sin(F*H),J=(V*L-q*R*ce)*k+(-V*R-q*L*ce)*A,Y=(q*L+V*R*ce)*k+(-q*R+V*L*ce)*A,X=R*z*k+L*z*A;if(te[w]){let e=Y*U+X*W,t=-Y*W+X*U;Y=e,X=t}let le=J*10,ue=X*10,de=-Y*10;if(K(d,N,a+le-c,o+ue-l,s+de-u)){if(f){let e=O+w,t=N*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}N++}}return N}const J=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)J.delete(e);for(let e of t.set)J.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=J.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=q(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-D2PB8gf5.js.map",lz=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,cz],{type:`text/javascript;charset=utf-8`});function uz(e){let t;try{if(t=lz&&(self.URL||self.webkitURL).createObjectURL(lz),!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(cz),{type:`module`,name:e?.name})}}var dz=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 uz;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 O_(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}]},A_(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()}},fz=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 jh(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},pz=.01,mz=[`asteroid`,`spacecraft`],hz=.0002959122082855911,gz=.75,_z=Q(8*86400);function vz(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(hz/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function yz(e){return e<0?0:e>1?1:e}function bz(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function xz(e){return e===null?{tBright:0,tSize:0}:{tBright:yz((Sz-e)/(Sz-Cz)),tSize:yz((wz-e)/(wz-Tz))}}var Sz=1e4,Cz=500,wz=Cz,Tz=50,Ez=4,Dz=.5,Oz=10,kz=1,Az=1,jz=3.5,Mz=2.5,Nz=2,Pz=jz,Fz=class{orbitPool=new dz;pickRegistry=new fz;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:Ez,dim:Dz,opacity:Az};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:Az};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 mz)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 mz)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)uv(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=xz(e);return{size:Ez+(Oz-Ez)*n,dim:Dz+(kz-Dz)*t,opacity:Az+(jz-Az)*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)bz(uv(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)bz(uv(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=xz(e);return{sizeMult:1+(Mz-1)*n,brightMult:1+(Nz-1)*t,opacity:Az+(Pz-Az)*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=Az,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=ER(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 mz)for(let[t,n]of this.workerPoints[e]){let r=uv(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of mz)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`?ev:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&bz(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=Nh(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,vz(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=nR(new Float32Array(l.cols.count*3),0,this.circleTexture,c,eR());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 lv(n,dy(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=>Mh(e.data.id)??Eh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:_z,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3);this.seedColors(f,l);let p=nR(new Float32Array(l.length*3),0,this.circleTexture,`#ffffff`,void 0,f);this.adoptCloud(`spacecraft`,i,c,p,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=uv(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)}seedColors(e,t){let n=new X,r=Math.min(t.length,e.length/3);for(let i=0;i<r;i++)n.set(av(t[i].data)),e[i*3]=n.r,e[i*3+1]=n.g,e[i*3+2]=n.b}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length!==n){if(e.setAttribute(`position`,new Vo(new Float32Array(n),3)),e.getAttribute(`color`)){let r=new Float32Array(n);this.seedColors(r,t),e.setAttribute(`color`,new Vo(r,3))}e.setDrawRange(0,0)}}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Vo(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 Vo(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 Vo(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of mz)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=pz*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(ev)?.position;for(let[i,a]of this.workerPoints.asteroid){if(!r)break;if(!this.ctx.visibility.isAsteroidGroupVisible(uv(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(uv(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;s[0]=o[0],s[1]=o[1],s[2]=o[2],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>=gz}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===G.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].position;s[r*3]=a?a[0]-e:NaN,s[r*3+1]=a?a[1]-t:NaN,s[r*3+2]=a?a[2]-n:NaN}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++){let r=n[t].position;i[t*3]=r?r[0]-e[0]:NaN,i[t*3+1]=r?r[1]-e[1]:NaN,i[t*3+2]=r?r[2]-e[2]:NaN}r.geometry.setAttribute(`position`,new Wo(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 mz)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()}},Iz=Math.PI/180,Lz=2451545,Rz=1.00000261,zz=.01671123,Bz=100.46457166*Iz,Vz=35999.37244981/36525*Iz,Hz=102.93768193*Iz,Uz=.32327364/36525*Iz;function Wz(e){let t=e-Lz,n=Hz+Uz*t,r=Bz+Vz*t-n,i=r+(2*zz-zz**3/4)*Math.sin(r)+1.25*zz*zz*Math.sin(2*r);return{lon:n+i,r:Rz*(1-zz*zz)/(1+zz*Math.cos(i))}}function Gz(e){let t=Wz(e).lon;return(e,n)=>{let r=t-Wz(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 Kz=.01,qz=1/100,Jz=1;function Yz(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 Xz(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 Zz(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=Yz(c,l,u)}function Qz(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position;if(!l)return;let 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(Xz(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=gR(t),b=e.lagrangeTrail?Gz(i):null,x=bR(e,n,_,c.x,c.y,c.z,r,b??void 0);_R(t,_,v,y,x,!0,s),Zz(o,g,u,d,f,p,m,h,_,x,a)}function $z(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=gR(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){dR(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function eB(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){Qz(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=cR(x_(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,p;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=oR(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=a=r),p=o.length-(r<a?2:1)}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*qz,Jz)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=cR(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)>Kz&&(o=cR(x_(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let m=e.trailAnchor??e.position;if(!m)return;let h=t.userData,g=u-n[0],_=d-n[1],v=f-n[2],y=m[0]-u,b=m[1]-d,x=m[2]-f;if(Xz(h,o,g,_,v,y,b,x,i))return;let S=Nb(e,o,s,u,d,f,p);if(S.length<2)return;let{posArr:C,trailArr:w,fullArr:T,capacity:E}=gR(t),D=u-n[0],O=d-n[1],k=f-n[2],A=Math.min(S.length,E);for(let e=0;e<A;e++)C[e*3]=S[e][0]+D,C[e*3+1]=S[e][1]+O,C[e*3+2]=S[e][2]+k;_R(t,C,w,T,A,s,c),h.trailLocalPositions=S,Zz(h,o,g,_,v,y,b,x,C,A,i)}function tB(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 nB(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 rB=4/2,iB=(.1*10)**2,aB=new J,oB=[],sB=oB;function cB(e){return DO(oB,e,MO)}var lB={x:0,y:0,left:0,right:0,h:0},uB=new Zi,dB={ox:0,oy:0},fB=new J,pB=new J;function mB(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()){let e=n.body.position;if(!e||n.carried){n.cachedDist=1/0;continue}if(n.cachedDist=Ev(C,e),n.isCrashed||n.noPhysical){let e=n.noPhysical===`model`,t=Sg(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()}CA(n,`missing`,r)}let r=n.label;if(!r)continue;n.labelAnchorOffscreen=!1;let i=n.noPhysical?0:n.radiusScene;if(!i){r.position.set(0,0,0);continue}let[o,s,c]=e;p.set(o-w[0],s-w[1],c-w[2]).applyMatrix4(T);let l=p.x,u=p.y,d=p.z,f=d*d,m=i*i;if(f<=m){r.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let h=i/n.cachedDist*S;if(h<1){r.position.set(0,0,0);continue}if(h>=16){let e=n.cachedDist,a=1/e,f=l*a,m=u*a,h=d*a,g=i*a,_=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*e-l,T*e-u,E*e-d).applyQuaternion(t.quaternion),r.position.copy(p),pB.set(o-w[0]+p.x,s-w[1]+p.y,c-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(pB.x)>1||Math.abs(pB.y)>1;continue}if(n.semiAxesScene&&n.mesh)tz(l,u,d,QR(n.mesh.getWorldQuaternion(uB),T,n.semiAxesScene),S,dB),p.set(dB.ox,dB.oy,0).applyQuaternion(t.quaternion);else{let e=m/(f-m);p.set(e*l,e*u,0).applyQuaternion(t.quaternion)}r.position.copy(p)}let E=oB,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene,n=t.body.position;if(!e||!n||t.carried)continue;let r=t.cachedDist,[i,a,o]=n,s=t.model?.userData.occluderSpheres;if(t.model&&s?.length){let e=Kj(t),n=t.model.position;for(let c of s){let s=c.r*e;if(fB.copy(c.center).applyQuaternion(t.model.quaternion).add(n).multiplyScalar(e),p.set(i-w[0]+fB.x,a-w[1]+fB.y,o-w[2]+fB.z).applyMatrix4(T),p.z>=s||p.lengthSq()<=s*s)continue;let l=p.z*p.z;(l<=s*s||s*S/Math.sqrt(l-s*s)>=16)&&$R(cB(k++),p.x,p.y,p.z,s,S,D,O,t.body.data.id,r)}continue}p.set(i-w[0],a-w[1],o-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z;if(u>=e)continue;let d=u*u;(d<=e*e||e*S/Math.sqrt(d-e*e)>=16)&&(t.semiAxesScene&&t.mesh?ez(cB(k++),c,l,u,QR(t.mesh.getWorldQuaternion(uB),T,t.semiAxesScene),S,D,O,t.body.data.id,r):$R(cB(k++),c,l,u,e,S,D,O,t.body.data.id,r))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=i?EM(n.getBody(i),e):void 0;for(let r of e.values()){let{body:a,group:s,trail:c}=r,l=r.cachedDist,u=kO(r);r.root.visible=u;let d,f,p=a.data.id===i,m=A!==null&&a.data.id===A;if(r.mesh===null&&!Cn(a.data.objectType)){let t=a.data.objectType;if(t===G.BARYCENTER||t===G.LAGRANGE_POINT){let t=!0,r=p?void 0:xv(a.data.id);if(r){let i=e.get(r)?.body??n.getBody(r);i?.position&&a.position&&Ev(a.position,i.position)/Ev(C,i.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),d=t,f=!1}else{let e=n.visibility.getPlanetVisibility(a,l)!==$.HIDE&&n.visibility.hasFullRendering(a);s.visible=e,c&&(c.visible=e),d=e,f=!1}}else{let e=a.data.objectType===G.MOON,t=e?n.visibility.getMoonVisibility(a):n.visibility.getPlanetVisibility(a,l),r=e?tB(t,o,p):nB(t,n.visibility.hasFullRendering(a),p||m);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),d=r.showLabel,f=r.isClose}u||(s.visible=!1,d=!1,f=!1),c&&(!u||a.orbitCenter===null)&&(c.visible=!1);let g=!1;if(r.starPoint&&u){let e=r.radiusScene/l*S/rB;g=e<1,r.starPoint.visible=g,g&&(r.starPoint.material.uniforms.uFlux.value=e*e),bL(r.corona,e),s.visible=!0,f=!g,d=!f}if(r.isMinor&&!p&&c&&!n.visibility.isPinned(a.data.id)&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(aB.set(w[0],w[1],w[2]))>iB&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:y}=r;if(!s.visible&&y&&y.parent===s?(s.remove(y),y.element.remove()):s.visible&&y&&y.parent!==s&&s.add(y),r.mesh&&r.radiusScene>0){let e=g||!p&&!m&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}LO(r,d,f,l,S,i)&&(j=!0);let T=r.radiusScene>0?r.radiusScene/l*S:0;JM(r,v&&a.data.id===M,T,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(uv(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(uv(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0){let n=i?xv(i):null;for(let r of e.values()){if(!r.label?.visible||!BO(r,t,w,b,x,lB))continue;let e=r.body.data.id;RO(lB.x,lB.y,r.cachedDist,e,E,e===i?n:null)&&(r.label.visible=!1)}}if((m||j||++d>=3)&&(d=0,$O(e,b,x,t,i,n,s,E,r)),ek(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 hB(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function gB(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function _B(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function vB(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 yB(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-bB(d):p,g=f?m+bB(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:xB(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:SB(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:xB(f,t),centerId:o.anchorId};if(l)return{r:SB(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}=vB(e,v);return{r:SB(y,b,t,x,S),centerId:e.centerId}}function bB(e){return e.jds[e.jds.length-1]-e.jds[0]}function xB(e,t){let n=bB(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return SB(e.points,e.jds,i)}function SB(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 hB(e[a-1],_B(gB(e[a],e[a-1]),s))}var CB=Math.PI/180,wB=Math.cos(yg*CB),TB=Math.sin(yg*CB);function EB(e,t,n,r){let i=Math.cos(e*CB),a=Math.sin(e*CB),o=Math.cos(t*CB),s=Math.sin(t*CB),c=Math.cos(n*CB),l=Math.sin(n*CB);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 DB(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*wB+a*TB,t=-i*TB+a*wB;i=e,a=t}return[r,i,a]}function OB(e){let t=10/vg;return[e[0]*t,e[2]*t,-e[1]*t]}function kB(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,u=y_(e,t),{om:d,w:f}=x_(e,t),p=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 t=d_(c,l,u);if(!t)return null;let r=n&&n>0?n:Vv,i=t.r*vg,a=2*c*vg;return AB(i,t.nu,a,1,r,f,e.i,d,p)}if(!isFinite(i)||!isFinite(a))return null;let m=r*vg,h=o*CB/Hv,g=n&&n>0?n:h*h*Math.abs(m)*Math.abs(m)*Math.abs(m);if(!isFinite(g)||g<=0)return null;let _=(a+o*(u-s))*CB,v,y;if(i<1||r>0){let e=Math.min(i,.9999999),t=c_(_,e),n=1-e*Math.cos(t);v=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),y=m*n}else{let e=u_(_,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;v=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),y=m*(1-i*Math.cosh(e))}if(!isFinite(y)||y<=0)return null;let b=m*(1-i*i);return!isFinite(b)||b<=0?null:AB(y,v,b,i,g,f,e.i,d,p)}function AB(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=EB(a,o,s,c),p=DB(e*l,e*u,f),m=DB(-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 jB={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};jB.cruise,jB.boost,jB.brake,jB.spiral,jB[`spiral-out`],jB[`spiral-in`];var MB={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},NB=3,PB=1,FB=2,IB=.6,LB=1.5,RB=.3,zB=1.5,BB=.85,VB=60,HB=.018,UB=.026,WB=`#ffffff`,GB=4,KB=1.5,qB=9,JB=1,YB={notice:GB-3,caution:GB-2,severe:GB-1},XB=[`notice`,`caution`,`severe`],ZB=.03,QB=.2;function $B(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 qc(t)}function eV(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 qc(t)}function tV(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 nV(e,t){let n=new Ss(new cs({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=GB,n}function rV(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&&(KT(c,i),TM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new RT(c);return p.center.set(0,.5),p}function iV(e,t){return e&&[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}var aV=class{group=new Ja;anchored=new Map;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?LB:FB,i?RB:IB,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)=>XB.indexOf(e.severity)-XB.indexOf(t.severity));for(let t of n){let n=MB[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine(tV(t,n.startJd,n.endJd,vB(e,r)),MB[n.severity],qB,JB,null,{renderOrder:YB[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=yB(e,t.startJd);if(!r)continue;let i=OB(r.r),a=r.centerId===e.centerId?null:r.centerId,o=nV(eV(n),ZB);this.parentOf(a).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 RT(s);c.center.set(0,.5),this.parentOf(a).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,NB,PB,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.parentOf(e.anchorId).add(e.sprite);this.craft={sprite:nV($B(WB),UB),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=yB(e,n.jd);if(!t)continue;let r=OB(t.r),i=t.centerId===e.centerId?null:t.centerId,a=nV($B(WB),HB);this.markers.push({sprite:a,local:r,anchorId:i});let o=rV(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.parentOf(i).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:OB(n.meeting.r),end:e.arrival,color:jB[a?.kind??`cruise`]}];o&&s.push({local:OB(o.r),end:e.departure,color:jB[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=rV(`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?PB:e.brightness),n.uniforms.uLineWidth.value=t?NB: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?vB(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),jB[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),jB.cruise,NB,PB,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),jB.cruise,NB,PB,null,{anchorId:n,renderOrder:KB}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),jB.cruise,NB,PB,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,jB.cruise,NB,PB,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),jB.cruise,zB,BB,null,{anchorId:n})}else this.addLine(t.approach,jB.cruise,NB,PB,null,{anchorId:n});let i=this.addLine(t.points,jB.cruise,zB,BB,null,{anchorId:n});if(!i)continue;let a=n===null?OB(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]=OB(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*QB));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=hR(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??GB,this.parentOf(a.anchorId??null).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=yB(this.path,e);t.sprite.visible=n!==null,n&&(t.local=OB(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],e[1]-t[1],e[2]-t[2]],i=new Map;for(let[e,r]of this.anchored){let a=n(e);i.set(e,iV(a,t)),r.visible=a!==null}let a=e=>e===null?r:i.get(e)??null;for(let e of this.arcs){let t=a(e.anchorId);if(!t)continue;let[n,r,i]=t;for(let t=0;t<e.count;t++)e.positions[t*3]=e.local[t*3]+n,e.positions[t*3+1]=e.local[t*3+1]+r,e.positions[t*3+2]=e.local[t*3+2]+i;dR(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let t=a(e.anchorId);if(!t)continue;let[n,r,i]=t;e.sprite.position.set(e.local[0]+n,e.local[1]+r,e.local[2]+i)}for(let e of this.labels){let t=a(e.anchorId);if(!t)continue;let[n,r,i]=t;e.object.position.set(e.local[0]+n,e.local[1]+r,e.local[2]+i)}if(this.craft){let{sprite:e,local:r,anchorId:i}=this.craft,o=i===null||this.anchored.has(i)?a(i):iV(n(i),t);o?e.position.set(r[0]+o[0],r[1]+o[1],r[2]+o[2]):e.visible=!1}for(let e of this.rings){let t=a(e.arc.anchorId);if(!t)continue;let[n,r,i]=t;e.world.set(e.local[0]+n,e.local[1]+r,e.local[2]+i)}}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*VB}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){ZO(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),!jw(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=RO(a,o,s,``,sB);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++}ZO(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))}parentOf(e){if(e===null)return this.group;let t=this.anchored.get(e);return t||(t=new Ja,this.anchored.set(e,t),this.group.add(t)),t}clear(){for(let e of this.arcs)e.line.removeFromParent(),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){e.sprite.removeFromParent();let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)e.object.removeFromParent(),e.object.element.remove();for(let e of this.anchored.values())this.group.remove(e);this.anchored.clear(),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)}},oV=2,sV=1,cV=4,lV=200,uV=class{group=new Ja;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,lV);for(let t=0;t<e.count;t++){let[r,i,a]=OB(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(lV*3),t=new Float32Array(lV).fill(1),n=hR(lV,e,t,t,0,jB.cruise,oV,sV);n.frustumCulled=!1,n.renderOrder=cV,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array(lV*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;dR(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)}},dV=new Set([`not-yet`,`no-data`,`parent`,`failed`]);function fV(e){let{jd:t,ctx:n,bodyObjects:r,focus:i,focusedBody:a,placer:o,trailView:s,frame:c,outOfRange:l}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let u=[];if(a){let e=new Set([a.data.id]),t=n.getBody(a.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),u.push({body:t,oldPos:t.position?[...t.position]:null}),t=n.getBody(t.data.parentId)}o.begin(t,a?.data.id,c);let d=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values())e.data.objectType===G.MOON&&e.data.parentId!==d&&e!==a||o.placeInPass(e);for(let e of r.values())o.placeInPass(e.body);let f=a?o.place(a,t):null,p=a?.unplaced;l.update({jd:t,satellites:n.refresher?.satelliteCoverage(t)??{kind:`covered`},majorBodies:o.noData,focusedOutOfRange:p!==void 0&&dV.has(p)});let m=null,h=performance.now()-i.focusStartTime<i.focusDurationMs;if(a&&!f)for(let e of u){let n=o.place(e.body,t);if(n){if(m=e.body.data.id,h){mV(i.focusTargetWorld,n);let e=i.camTargetOffset;e&&i.camTargetWorld&&hV(i.camTargetWorld,n,e)}else if(e.oldPos)for(let t=0;t<3;t++){let r=n[t]-e.oldPos[t];i.focusTruePos[t]+=r,i.focusTargetWorld[t]+=r}break}}else if(f){mV(i.focusTargetWorld,f);let e=i.camTargetOffset;e&&i.camTargetWorld&&hV(i.camTargetWorld,f,e);let t=i.camOriginOffset;t&&i.camOriginWorld&&hV(i.camOriginWorld,f,t),h||mV(i.focusTruePos,f)}let g=i.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}eB(e.body,n,g,t,s),n.userData.refreshDeferred=!1}}let _=!f&&p===`loading`;return{focusUnplaced:a!==void 0&&!f&&!_,focusLoading:_,anchorId:m}}function pV(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(eB(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}function mV(e,t){e[0]=t[0],e[1]=t[1],e[2]=t[2]}function hV(e,t,n){e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2]}var gV=Object.freeze([0,0,0]);function _V(e,t,n,r){if(!Number.isFinite(t+n+r))return vV(e,`failed`);let i=e,a=i.position??=[0,0,0];return a[0]=t,a[1]=n,a[2]=r,i.unplaced=void 0,a}function vV(e,t){let n=e;return n.position=null,n.orbitCenter=n.orbitCenterId===void 0?void 0:null,n.unplaced=t,null}function yV(e,t){let n=e;if(!t){n.orbitCenter=null;return}let r=n.orbitCenter??=[0,0,0];r[0]=t[0],r[1]=t[1],r[2]=t[2]}function bV(e,t){let n=e.trailAnchor??=[0,0,0];n[0]=t[0],n[1]=t[1],n[2]=t[2]}var xV=Math.PI/180,SV=120,CV=Q(.001)**2,wV=new WeakMap,TV=new J,EV=new J;function DV(e,t,n){e.distanceToSquared(t)<=CV?e.copy(t):e.lerp(t,n)}function OV(e,t,n,r,i){let a=e.featureAnchor;yV(e,n),EV.set(0,0,0);let o=r?.nomenclatureActiveIndex??-1,s=o>=0?r?.nomenclatureLabels?.[o]??null:null;if(s&&s.element.dataset.featureId===String(a.featureId)){let e=r?.nomenclatureAnchor;e?(TV.copy(s.position),EV.copy(e.position)):(TV.copy(s.position),r?.mesh&&TV.multiply(r.mesh.scale))}else{let e=t.data.radiusKm,n=a.lat*xV,i=a.lon*xV,o=t.orientation&&Number.isFinite(e)&&e>0?TO(r,t.data.id,e,n,i):null;if(o)TV.set(o.pointKm[0],o.pointKm[1],o.pointKm[2]);else{let t=Number.isFinite(e)&&e>0?e:0,[r,a,o]=iO(n,i);TV.set(t*r,t*a,t*o)}TV.multiplyScalar(Q(1))}let c=performance.now(),l=wV.get(e);if(!l)l={fixed:TV.clone(),addend:EV.clone(),t:c},wV.set(e,l);else{let e=1-Math.exp(-(c-l.t)/SV);l.t=c,DV(l.fixed,TV,e),DV(l.addend,EV,e)}return TV.copy(l.fixed),t.orientation&&TV.applyQuaternion(SS(t.orientation,i,t.nutPrec)),_V(e,n[0]+TV.x+l.addend.x,n[1]+TV.y+l.addend.y,n[2]+TV.z+l.addend.z)}var kV=30034e-10,AV=.45,jV=1.6,MV=.85,NV=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],PV=e=>Math.hypot(e[0],e[1],e[2]);function FV(e,t,n=kV){let r=PV(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=NV(e,t)/r,o=PV(e);if(Math.sqrt(Math.max(0,o*o-a*a))>MV*i)return null;let s=a/i;return s>=AV&&s<=jV?`EL1`:s<=-AV&&s>=-jV?`EL2`:null}function IV(e,t){return!(e.visibleFromDays!==void 0&&t-2451545<e.visibleFromDays)}function LV(e,t){let n=y_(e,t);return n>=e.validityStart&&n<=e.validityEnd}function RV(e){return e.a===0&&(e.objectType===G.BARYCENTER||e.objectType===G.LAGRANGE_POINT||Cn(e.objectType))}function zV(e,t){if(e.pageOnly)return`never`;if(!IV(e,t))return`not-yet`;if(!LV(e,t))return`no-data`;let n,r=e.satrec;return n=r?s_(r,t):e.omm?null:e.q==null?e.a===0?RV(e)?[0,0,0]:null:C_(e,t):w_(e,t),!n||!Number.isFinite(n[0]+n[1]+n[2])?`failed`:n}function BV(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var VV=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`?Ag(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})}}},HV=new Map,UV=new J,WV=new J;function GV(e,t,n,r,i,a,o){let s=lb(n,r,sb(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(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=TO(o.get(c),c,d,p,m);h&&HV.set(e.id,h);let g=h??HV.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=SS(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?UV.set(g.normal[0],g.normal[1],g.normal[2]).applyQuaternion(b):null,C=WV.set(-Math.sin(p)*Math.cos(m),Math.cos(p),Math.sin(p)*Math.sin(m)).applyQuaternion(b);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,north:C}}var KV=[0,0,0],qV=new Zi,JV=4,YV=0,XV=new Map;function ZV(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function QV(e,t,n){let r=XV.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 XV.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}var $V=class{focusedId;noData=BV();passJd=NaN;frame;settled=new Set;settling=new Set;ride=iS([],void 0,()=>void 0);rideJd=NaN;rideFocus;constructor(e,t,n,r=()=>!1){this.ctx=e,this.bodyObjects=t,this.diagnostics=n,this.held=r}begin(e,t,n){this.passJd=e,this.focusedId=t,this.frame=n,this.settled.clear(),this.noData=BV()}at(e,t){if(e===`naif-0`)return gV;let n=this.ctx.getBody(e)??this.bodyObjects.get(e)?.body;return n?this.place(n,t):null}placeInPass(e){let t=e.data,n=this.bodyObjects.get(t.id);n&&this.frame!==void 0&&t.id!==this.focusedId&&!n.root.visible&&!n.trail?.visible&&(t.orbitalSource===W.SPICE_PROBE||!Cn(t.objectType))&&(n.staggerSlot??=YV++%JV,this.frame%JV!==n.staggerSlot)||this.place(e,this.passJd)}place(e,t){t!==this.passJd&&this.held()&&(t=this.passJd);let n=e.data.id;if(t===this.passJd&&this.settled.has(n))return e.position;if(this.settling.has(n))return this.diagnostics.warnOnce(`parent-cycle`,n,()=>`place[${n}]: parent chain loops`),null;this.settling.add(n);let r=hn(e)?this.seatFeature(e,t):this.settle(e,t);return this.settling.delete(n),t===this.passJd&&this.settled.add(n),r}under(e){return(this.ctx.getBody(e)??this.bodyObjects.get(e)?.body)?.unplaced===`loading`?`loading`:`parent`}seatFeature(e,t){let n=e.featureAnchor.hostId,r=this.ctx.getBody(n),i=r&&this.place(r,t);return!r||!i?vV(e,this.under(n)):OV(e,r,i,this.bodyObjects.get(n),t)}rideAt(e){return(e!==this.rideJd||this.focusedId!==this.rideFocus)&&(this.rideJd=e,this.rideFocus=this.focusedId,this.ride=iS(this.ctx.probeStore?.ridesAt(e)??[],this.focusedId,e=>this.ctx.getBody(e)?.data.name)),this.ride}rowOffset(e,t,n){let r=this.ctx.bodies.elementRow(e),i=r&&this.at(r.parentId,n);if(!i)return null;let a=zV(r,n);return typeof a==`string`?null:[i[0]-t[0]+a[0],i[1]-t[1]+a[1],i[2]-t[2]+a[2]]}settle(e,t){let{ctx:n,diagnostics:r}=this,i=e.data,a=this.bodyObjects.get(i.id);if(i.pageOnly)return vV(e,`never`);if(i.orbitalSource===W.SPICE_PROBE)return this.settleProbe(e,a,t);let o=this.at(i.parentId,t);if(!o){let t=this.under(i.parentId);return t===`parent`&&r.warnOnce(`missing-parent`,i.id,()=>`place[${i.id}]: parent ${i.parentId} has no place`),vV(e,t)}r.clear(`missing-parent`,i.id);let s;return s=n.chebStore?.has(i.id)?IV(i,t)?n.chebStore.positionScene(i.id,t)??this.rowOffset(e,o,t)??this.chebMiss(i.id,t):`not-yet`:zV(i,t),typeof s==`string`?vV(e,s):this.finish(e,a,o[0]+s[0],o[1]+s[1],o[2]+s[2],o,t)}chebMiss(e,t){let n=this.ctx.chebStore;if(n.isAwaited(e,t))return`loading`;let r=n.zoneCoverage(e);return r!==null&&(t<r.start||t>r.end)&&t===this.passJd&&(this.noData.count++,r.start<this.noData.earliestStart&&(this.noData.earliestStart=r.start),r.end>this.noData.latestEnd&&(this.noData.latestEnd=r.end)),this.diagnostics.warnOnce(`cheb-null`,e,()=>{let n=r?`[${r.start.toFixed(1)},${r.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${e}] returned null at jd=${t.toFixed(3)} (coverage=${n})`}),`no-data`}finish(e,t,n,r,i,a,o){let s=e.data,c=_V(e,n,r,i);if(!c)return this.diagnostics.warnOnce(`non-finite`,s.id,()=>`place[${s.id}] non-finite: pos=[${n},${r},${i}] parentId=${s.parentId}`),null;let l=e.orbitCenterId;if(l!==void 0&&yV(e,l===s.parentId?a:this.at(l,o)),e.trailAnchorId!==void 0){let t=this.at(e.trailAnchorId,o);t&&bV(e,t)}if(!t)return c;if(t.trail&&e.orbitCenter){let n=t.trail.userData.orbitCenter;n&&n.set(e.orbitCenter[0],e.orbitCenter[1],e.orbitCenter[2])}if(e.orientation&&(t.mesh||t.model))t.mesh&&CS(t.mesh,e.orientation,o,e.nutPrec),t.model&&CS(t.model,e.orientation,o,e.nutPrec),t.nomenclatureAnchor&&CS(t.nomenclatureAnchor,e.orientation,o,e.nutPrec);else if(Rj(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(o,qV))t.mesh&&t.mesh.quaternion.copy(qV),t.model&&t.model.quaternion.copy(qV);else{let n=e.pointingOverride??e.pointing;if(n){let e=ZV(n)?QV(s.id,o,c):void 0,r={bodyPos:c,parentPos:a,sunPos:this.at(`naif-10`,o)??void 0,velocity:e};t.mesh&&ZS(t.mesh,n,r),t.model&&ZS(t.model,n,r)}else t.mesh&&ES(t.mesh,c,a),t.model&&ES(t.model,c,a)}}if(e.orientation)for(let n of t.rings)CS(n.mesh,e.orientation,o,e.nutPrec);return c}settleProbe(e,t,n){let{ctx:r,bodyObjects:i,diagnostics:o}=this,s=e.data,c=this.rideAt(n);if(t){t.carried=c.hidden.has(s.id);let e=c.credits.get(s.id);CA(t,`carrier`,e?a().messages.carried_by_scene_label({carrier:e}):null)}let l=r.visibility.activeSystemId,u=l?e=>r.bodies.isInSystem(`naif-${e}`,l):void 0,d=r.probeStore?.probeWithCenter(s.id,n,u)??null;if(!d)return r.probeStore?.awaitedAt(n)?vV(e,`loading`):(vV(e,`no-data`),o.warnOnce(`probe-unavailable`,s.id,()=>{let e=r.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${s.id} (${s.name??`unnamed`}): hidden — ${e}`}),null);let f=d.probe.landed;if(f&&cb(d.probe,n)){let a=s.parentId,c=GV(s,d.probe,f,n,e=>this.at(e,n),r,i);if(!c)return vV(e,this.under(`naif-${f.bodyNaifId}`));if(o.clear(`probe-unavailable`,s.id),a!==s.parentId&&e.trailBuffer?.clear(),t){let e=f.isDestroyed;t.isLanded||=(rP(t.labelHalo,`landed`),!0),t.isCrashed=e,t.model&&(t.model.visible=!e)}let l=_V(e,c.x,c.y,c.z);if(!l)return null;e.orbitCenterId=s.parentId,yV(e,c.parentPos);let u=c.up;if(t?.mesh&&(u?DS(t.mesh,u):ES(t.mesh,l,c.parentPos)),t?.model){u?DS(t.model,u):ES(t.model,l,c.parentPos);let r=OS(e.landedHeadings,n);r!==void 0&&LS(t.model,c.north,r)}return l}let p=yb(d.probe,n,d.fitCenterNaifId,r.chebStore??null,e=>this.at(e,n)!==null);if(!p){let t=d.probe.fitCenter?.id;return vV(e,t?this.under(t):`parent`),o.warnOnce(`probe-unavailable`,s.id,()=>`probe ${s.id} (${s.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`),null}let m=p.id,h=p.muKm3S2,g=ab(d.probe,n,h);if(!g)return vV(e,`no-data`),o.warnOnce(`probe-unavailable`,s.id,()=>`probe ${s.id} (${s.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`),null;o.clear(`probe-unavailable`,s.id),t?.isLanded&&(rP(t.labelHalo,`flying`),t.isLanded=!1,t.isCrashed&&(t.isCrashed=!1,t.model&&(t.model.visible=!0),t.noPhysical||CA(t,`missing`,null)));let _=this.at(tv,n),v=this.at(ev,n),y=m===`naif-399`&&_!==null&&v!==null&&FV([Q(g[0]),Q(g[2]),-Q(g[1])],[v[0]-_[0],v[1]-_[1],v[2]-_[2]])!==null,b=y!==(e.lagrangeTrail??!1);e.lagrangeTrail=y;let x=s.parentId!==m;if((x||b)&&e.trailBuffer&&r.probeStore){let t=e.trailBuffer;t.clear(),t.needsPopulate=!1;let i=Cb(gb(d.probe,n,h),s.validityEnd-s.validityStart,t.capacity,y);t.reconfigure(i.stepDays,i.epsilonScene,i.spanDays),kb(t,r.probeStore,r.chebStore??null,s.id,m,n)}x&&(s.parentId=m);let S=this.at(m,n);if(!S)return vV(e,this.under(m)),o.warnOnce(`probe-unavailable`,s.id,()=>`probe ${s.id} (${s.name??`unnamed`}): hidden — fit center ${m} has no position this frame`),null;let C=S,w=Q(g[0]),T=Q(g[2]),E=-Q(g[1]),D=C[0]+w,O=C[1]+T,k=C[2]+E,A=e.trailBuffer;if(A?.needsPopulate&&t?.trail?.visible&&r.probeStore&&(A.needsPopulate=!1,A.clear(),kb(A,r.probeStore,r.chebStore??null,s.id,m,n)),A){let e=A.newestJd,t=n-e,i=A.stepDays*A.capacity,a=isFinite(e)&&(t<0||t>i);if(a&&s.id===this.focusedId&&r.probeStore){A.clear();let e=Cb(gb(d.probe,n,h),s.validityEnd-s.validityStart,A.capacity,y);A.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),kb(A,r.probeStore,r.chebStore??null,s.id,m,n)}else a?(A.clear(),A.append(n,w,T,E)):isFinite(e)?isFinite(A.epsilonScene)?t>=A.stepDays*.00390625&&r.probeStore&&A.readNewestPos(KV)&&jb(A,Tb(r.probeStore,r.chebStore??null,s.id,m),e,[KV[0],KV[1],KV[2]],n):t>=A.stepDays&&A.append(n,w,T,E):A.append(n,w,T,E)}return e.orbitCenterId=s.parentId,this.finish(e,t,D,O,k,C,n)}},eH=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)}},tH=[],nH=new WeakMap;function rH(e,t){let{color:n,geometricAlbedo:r}=e.body.data,i=nH.get(e);return(!i||i.color!==n||i.geometricAlbedo!==r||i.map!==t)&&(i={color:n,geometricAlbedo:r,map:t,albedo:tj(e.body.data,t,new X)},nH.set(e,i)),i.albedo}function iH(e,t,n){let r=rH(e,t.map);if(r)return n.copy(r);n.copy(t.color);let i=t.map&&OA(t.map);return i?n.multiply(i):n}function aH(e,t,n,r){let i=e.get(ev)?.body.position,a=0;if(i)for(let e of t){if(!e.mesh)continue;let t=e.mesh.material,[o,s,c]=e.body.position,l=i[0]-o,u=i[1]-s,d=i[2]-c,f=Math.hypot(l,u,d),p=tH[a++]??={x:0,y:0,z:0,radius:0,sunX:0,sunY:0,sunZ:0,sunlight:0,albedo:new X};p.x=o,p.y=s,p.z=c,p.radius=e.radiusScene,p.sunX=l/f,p.sunY=u/f,p.sunZ=d/f,p.sunlight=rC*r*(n?aC(f):1),iH(e,t,p.albedo)}for(let t of e.values()){let e=t.planetshine,n=t.body.position;!e||!n||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4||FT(e,n[0],n[1],n[2],tH,a)}}var oH=Q(695700),sH=2,cH=1e-4,lH=2,uH=new J,dH=new J,fH=new J,pH=new Zi;function mH(e,t,n,r,i){uH.subVectors(e,t);let a=uH.dot(n),o=Math.sqrt(Math.max(uH.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 hH(e,t,n,r,i,a){let o=e.get(ev)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){let e=t.body.position;if(!t.rings.length||!e)continue;let[u,d,f]=e;for(let e of t.rings){let p=r||e.intensityScale>=.000980392156862745;e.mesh.visible=p;let m=r?1:p?e.intensityScale:0;e.material.uniforms.uIntensityScale.value=m;let h=e.material.uniforms.uSunDir.value;h.set(o[0]-u,o[1]-d,o[2]-f);let g=h.length(),_=oH/g;e.material.uniforms.uSunAngularRadius.value=_,e.material.uniforms.uLightScale.value=n?aC(g):1,h.normalize();let v=e.planetShadowOnRing;if(v.uPlanetCenter.value.set(u-s,d-c,f-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),e.layers){let{dist:t,sinToPole:n}=mH(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,e.innerScene,e.outerScene),r=e.thicknessScene*n/Math.max(t,1e-9)*a,o=Math.min(Math.max(Math.ceil(r*sH),1),48);e.layers.count!==o&&(e.layers.count=o,e.material.uniforms.uLayerCount.value=o,e.material.uniforms.uLayerAlphaExp.value=1/o)}let y=e.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))}gH(t,i,a)}}function gH(e,t,n){let r=e.rings.reduce((e,t)=>t.intensityScale>e.intensityScale?t:e),i=r.material.uniforms,a=i.uSunDir.value,o=r.planetShadowOnRing.uPlanetPoleDir.value,s=r.planetShadowOnRing.uPlanetCenter.value,c=Math.min(Math.max(a.dot(o),-1),1),l=r.light,u=r.outerScene/Math.max(t.distanceTo(s),1e-12)*n>=lH;u&&!(Math.abs(c-l.patchesSinB)<cH)&&(kC(l.patches,l.profile,c,l.planet),l.patchesSinB=c),dH.copy(a).addScaledVector(o,-c),dH.lengthSq()<1e-12&&dH.set(+(Math.abs(o.x)<.9),Math.abs(o.x)<.9?0:1,0).cross(o),dH.normalize(),r.ringshine&&VC(r.ringshine,l,dH,c,i.uLightScale.value),fH.copy(dH).applyQuaternion(pH.copy(r.mesh.quaternion).invert());for(let t of e.rings){if(!t.mesh.visible)continue;u&&t.light.planetLightSinB!==l.patchesSinB&&IC(t.light,l.patchesSinB,l);let n=t.material.uniforms;n.uSunAzimuth.value.set(fH.x,fH.z).normalize();let r=n.uPlanetAlbedo.value;e.mesh?iH(e,e.mesh.material,r):r.setRGB(0,0,0)}}var _H=Math.PI/180,vH=2451545;function yH(e){let t=e-vH,n=(19.3871+.52402073*t)*_H;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 bH(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 xH(e,t){let n=e.seasonal;if(!n)return e;let r=bH(n.lsDeg,n.dustTauFactor,t),i=bH(n.lsDeg,n.dustScaleHeightKm,t),a=bH(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 SH=new WeakMap,CH=.25;function wH(e,t){if(!e.seasonal)return e;let n=Math.round(yH(t)/CH),r=SH.get(e);if(r&&r.lsQ===n)return r.params;let i=xH(e,n*CH);return SH.set(e,{lsQ:n,params:i}),i}var TH=new J,EH=new J,DH=[.2126,.7152,.0722];function OH(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=FN(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+=DH[t]*Math.exp(-n)}return o}var kH=.4,AH=.05,jH=-.105,MH=.3,NH=.05;function PH(e,t,n){let r=OH(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/NH),a=Math.min(1,Math.max(0,(n-jH)/MH));return r*(1+(kH+(AH-kH)*a-1)*i)}function FH(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 IH=rC,LH=200,RH=new J,zH=new J,BH=new J,VH=new J;function HH(e,t,n,r){e.uOccluderCount.value=Jw(e.uOccluders.value,t,r,n)}function UH(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:RH.set(1,1,1),sunRefraction:null};DN(n&&a.sunTint);let c=e.get(ev);SL(c?.mesh?.material,Xb());let l=xL(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=LH,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere)continue;c.atmosphere.mesh.visible=n;let e=c.body.position;if(!n||!e)continue;xT(c.atmosphere,a);let f=Yb(c.body.data.id);if(f?.seasonal){let e=a.seasonal?wH(f,o):f;if(c.atmosphere.params!==e){ST(c.atmosphere,e);for(let t of c.sunTint??[])PN(t,e,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[p,m,h]=e,g=c.atmosphere.material.uniforms;g.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let _=g.uSunDir.value.set(d[0]-p,d[1]-m,d[2]-h),v=c.atmosphere.params,y=r?aC(_.length()):v.realisticSunAlways?Math.sqrt(aC(_.length())):1;g.uSunIntensity.value=v.sunIntensity*y*i,_.normalize(),c.mesh&&(TH.set(0,1,0).applyQuaternion(c.mesh.quaternion),g.uSpinAxis.value.copy(TH));let b=c.root.position,x=c.atmosphere.geometryRadiusScene*c.atmosphere.mesh.scale.x,S=t.distanceTo(b);x>S*.1&&(s.shellProminent=!0),a.eclipseShadows&&HH(g,b,_,x);let C=a.insideView&&S<x,w=c.atmosphere.planetRadiusKm,T=S*((w+v.topAltitudeKm)/x)-w,E=C&&vT(v,T),D=C?yT(v,T):0;hT(c.atmosphere,C,E,D),g.uDeepIrradiance.value=IH*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=IH*i,e.uAtmoTDeepBlend.value=D;if(C){s.insideShell=!0;let e=EH.copy(t).sub(b).divideScalar(S).dot(_),n=PH(v,T,e);if(s.skyboxIntensity*=n*(1-D),a.refraction&&v.refractivity&&!E){let t=FH(v.refractivity[1]*Math.exp(-Math.max(T,0)/v.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),v.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:VH.copy(EH)})}}let O=S/x;if(a.sunTint&&O<LH){let e=x/(1+v.topAltitudeKm/w)*(c.atmosphere.surfaceRadiusKm/w);BH.copy(t).sub(b);let n=g.uSpinAxis.value,r=g.uStretch.value;if(qN(v,BH,_,e,c.atmosphere.surfaceRadiusKm,zH,n,r)){let e=DH[0]*zH.x+DH[1]*zH.y+DH[2]*zH.z;e>1e-4&&s.sunTint.multiply(zH.divideScalar(e))}l&&O<u&&(u=O,HN(l,v,b,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var WH=new J;function GH(e,t){let n=0;for(let r of e.values()){if(r.body.data.objectType===G.STAR)continue;let e=r.body.data.radiusKm;!Number.isFinite(e)||e<=0||r.radiusScene<=0||!kO(r)||(t[n++]=r)}return t.length=n,t}function KH(e,t,n,r,i){let a=Uw(),o=Bw(),s=e.get(ev),c=s?.body.position;if(!s||!c){a.uSunAngularRadius.value=0,a.uOccluderCount.value=0,o.count=0;return}let[l,u,d]=n,f=c[0]-l,p=c[1]-u,m=c[2]-d,h=Math.hypot(f,p,m);h>0?(a.uSunDir.value.set(f/h,p/h,m/h),a.uSunAngularRadius.value=Math.asin(Math.min(s.radiusScene/h,1))):a.uSunAngularRadius.value=0;let g=t.length;for(;o.occluders.length<g;)o.occluders.push(new ga),o.leaks.push(new ga);for(let e=0;e<g;e++){let n=t[e],[r,a,s]=n.body.position;o.occluders[e].set(r-l,a-u,s-d,n.radiusScene),i&&n.atmosphere?Zw(n.atmosphere.params,n.atmosphere.planetRadiusKm,o.leaks[e]):o.leaks[e].set(0,0,0,0)}o.count=g;let _=a.uSunDir.value;a.uOccluderCount.value=Jw(a.uOccluders.value,WH,r,_,a.uOccluderLeak.value);for(let t of e.values()){let e=t.eclipseShadow,n=t.body.position;if(!e||!n||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[r,i,a]=n,o=e.uEclipseSelfPos.value.set(r-l,i-u,a-d);e.uOccluderCount.value=Jw(e.uOccluders.value,o,t.radiusScene,_,e.uOccluderLeak.value)}}var qH=10;function JH(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&oC(i,s,c);return}let u=e.get(ev)?.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(qH),r.target.position.set(0,0,0),r.intensity=rC*(s?aC(_):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=qH-b,x.far=qH+b,x.updateProjectionMatrix()}var YH=1.25,XH=.05,ZH=2048;function QH(e,t,n){let r=(e,t)=>!!e&&e.intervals.some(([e,n])=>t>e+1e-9&&t<n-1e-9),i=[],a=Math.round(e/n);for(let o=0;o<=a;o++){let s=o===a?e:o*n;(o===0||o===a||!r(t[t.length-1],s))&&i.push({p:s,level:0})}t.forEach((n,a)=>{for(let[o,s]of n.intervals){let c=Math.ceil(Math.max(o,0)/n.step-1e-9),l=Math.floor(Math.min(s,e)/n.step+1e-9);for(let e=c;e<=l;e++){let o=e*n.step;r(t[a-1],o)||i.push({p:o,level:n.level})}}}),i.sort((e,t)=>e.p-t.p||t.level-e.level);let o=(t[0]?.step??n)*.25,s=[];for(let e of i){let t=s[s.length-1];t&&e.p-t.p<o?t.level=Math.max(t.level,e.level):s.push(e)}return s[0].p=0,s[s.length-1].p=e,{at:Float64Array.from(s,e=>e.p),level:Int8Array.from(s,e=>e.level)}}function $H(e,t){let n=2*Math.PI;if(t>=Math.PI)return[[0,n]];let r=e-t,i=e+t;return r<0?[[0,i],[r+n,n]]:i>n?[[0,i-n],[r,n]]:[[r,i]]}function eU(e){return 2*Math.PI/(ZH*2**e)}function tU(e,t,n,r){let i=eU(t),a=Math.log2(Math.max(e/n,i)/i);return r!==void 0&&a>r-.85&&a<r+.15?r:Math.max(0,Math.ceil(a-1e-9))}function nU(e,t,n,r,i,a,o){let s=eU(i),c=Math.PI/128,l=2*Math.PI/128,u=e=>Math.acos(1/(1+Math.max(e,0))),d=YH*(u(n)+u(r)),f=Math.max(Math.sin(e),XH),p=Math.round(Math.log2(1/f)),m=[],h=[],g=0;for(let n=o;g<d;n++){let r=s*2**n;if(r>=c)break;g+=a*r;let o=Math.max(i-n,0);m.push({intervals:[[Math.max(e-g,0),Math.min(e+g,Math.PI)]],step:r,level:o});let u=Math.min(g/f,Math.PI),d=Math.ceil(Math.log2(2*u/(4*a)/s)-1e-9),_=Math.max(n+p,d),v=s*2**_;v>=l||h.push({intervals:$H(t,u),step:v,level:Math.max(i-(_-p),0)})}return{rows:QH(Math.PI,m,c),columns:QH(2*Math.PI,h,l),stepLevel:o,innerRadius:a*s*2**o}}function rU(e,t,n,r,i=1){let a=t.length,o=n.length,s=new Float32Array(a*o*3),c=new Float32Array(a*o*3),l=new Float32Array(a*o*2),u=Float64Array.from(n,Math.sin),d=Float64Array.from(n,Math.cos);for(let f=0;f<a;f++){let a=t[f],p=Math.sin(a),m=Math.cos(a);for(let t=0;t<o;t++){let h=f*o+t,g=-d[t]*p,_=m,v=u[t]*p,y=e+(r?r[h]*i:0),b=h*3;s[b]=y*g,s[b+1]=y*_,s[b+2]=y*v,c[b]=g,c[b+1]=_,c[b+2]=v;let x=h*2;l[x]=n[t]/(2*Math.PI),l[x+1]=1-a/Math.PI}}let f=new Uint32Array((a-1)*(o-1)*6),p=0;for(let e=0;e<a-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<o-1;t++){let i=e*o+t+1,a=e*o+t,s=(e+1)*o+t,c=(e+1)*o+t+1;n||(f[p++]=i,f[p++]=a,f[p++]=c),r||(f[p++]=a,f[p++]=s,f[p++]=c)}}return{positions:s,normals:c,uvs:l,indices:f.subarray(0,p)}}var iU=256,aU=.25,oU=.32,sU=.35,cU=300,lU=4e5,uU=16,dU=8,fU=new Y,pU=new J;function mU(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/128,a=[];for(let t=0;t<=128;t++){let n=t===128?e:t*i;(t===0||t===128||!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 hU(e){let t=new ns;return t.setAttribute(`position`,new Vo(e.positions,3)),t.setAttribute(`normal`,new Vo(e.normals,3)),t.setAttribute(`uv`,new Vo(e.uvs,2)),t.setIndex(new Vo(e.indices,1)),t}var gU=new WeakMap,_U=new WeakSet;function vU(e){return!gU.get(e)?.abort&&!_U.has(e)}var yU=2;function bU(e){let t=e.displacementMeta?.tiles;return wD(t)&&!gU.get(e)?.dead?t:void 0}function xU(e,t,n,r){let i=wE(e.max_level,e.patches,n/(2*Math.PI),t/Math.PI);if(i===e.max_level)return i;let a=2**(Math.floor(Math.log2(r))-23),o=2*Math.PI*r/(dU*a);return Math.max(e.max_level,Math.min(i,Math.floor(Math.log2(o/ZH))))}function SU(e){!e.mesh||!e.displacementMeta||HD(e.mesh.material,e.displacementMeta,e.radiusScene)}function CU(e){let t=gU.get(e);t?.abort?.abort(),t&&(t.abort=void 0),e.terrainWindow&&(e.terrainWindow.riseKm&&SU(e),e.terrainWindow=null,e.currentSegments=void 0)}function wU(e,t,n,r){let i=Math.sin(e)*Math.sin(n)*Math.cos(t-r)+Math.cos(e)*Math.cos(n);return Math.acos(Math.min(1,Math.max(-1,i)))}function TU(e,t,n,r,i,a,o){let s=e.terrainWindow?.riseKm?e.terrainWindow:void 0,c=t.material;s&&(c.displacementScale=0,c.displacementBias=0);let l=gU.get(e)??{failures:0,dead:!1};if(gU.set(e,l),l.abort)return!!s;let u=e.displacementMeta;if(!u)return!!s;let d=xn(e.body.data),f=xU(n,i,a,Q(d)),p=ZH*2**f,m=NE().terrainBandCells,h=f>n.max_level?Math.min(m,uU):m,g=s?.texWidth===p?s.stepLevel:void 0,_=tU(r,f,h,g);if(s){let t=wU(i,a,s.centerTheta,s.centerPhi);if(g===_&&t<sU*s.angRadius)return!0;if(performance.now()-s.builtAt<cU)return _U.add(e),!0}let v=nU(i,a,r,.5*u.scale_km/d,f,h,_),y=v.rows.at,b=v.columns.at;if(y.length*b.length>lU)return console.warn(`terrain grid for ${e.body.data.id} would need ${y.length}×${b.length} vertices: left to the shader`),l.dead=!0,!!s;let x=new AbortController;l.abort=x;let S=performance.now();return iE({root:Jt(n),version:n.version,maxLevel:n.max_level,patches:(n.patches??[]).map(({max_level:e,x:t,y:n,version:r})=>({max_level:e,x:t,y:n,version:r})),tileSize:n.tile_size,scaleKm:n.scale_km??0,biasKm:(n.bias_km??0)-(u.absolute_radius?d:0),radius:Q(d),unitsPerKm:Q(1),rows:v.rows,columns:v.columns},x.signal).then(n=>{if(l.abort!==x||(l.abort=void 0,l.failures=0,e.mesh!==t||!e.displacementMap))return;let r=t.geometry;t.geometry=hU(n),r.dispose(),c.displacementScale=0,c.displacementBias=0,e.terrainWindow={thetas:y,phis:b,centerTheta:i,centerPhi:a,angRadius:v.innerRadius,stepLevel:_,texWidth:p,builtAt:performance.now(),riseKm:n.riseKm},e.currentSegments=128,console.debug(`terrain grid ${e.body.data.id}: ${y.length}×${b.length}, level ${_}, ${Math.round(performance.now()-S)} ms`),o()}).catch(()=>{l.abort===x&&(l.abort=void 0,++l.failures>=yU&&(l.dead=!0))}),!!s}function EU(e,t,n,r){_U.delete(e);let i=e.mesh,a=e.displacementMap;if(!n||!i||!a)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!i} tex=${!!a}`),CU(e),!1;i.updateMatrixWorld(),fU.copy(i.matrixWorld).invert(),pU.copy(t.position).applyMatrix4(fU);let o=Q(xn(e.body.data)),s=pU.length(),c=Math.max(s/o-1,1e-6);if(c>(e.terrainWindow?oU:aU))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${c.toFixed(4)}`),CU(e),!1;let l=Math.acos(Math.min(1,Math.max(-1,pU.y/s))),u=Math.atan2(pU.z,-pU.x);u<0&&(u+=2*Math.PI);let d=bU(e);if(d)return TU(e,i,d,c,l,u,r);e.terrainWindow?.riseKm&&SU(e);let f=a.image?.width??2048,p=2*Math.PI/f,m=Math.acos(1/(1+c)),h=Math.max(p,2*m*YH/iU),g=Math.log2(h/p),_=Math.max(0,Math.ceil(g-1e-9)),v=e.terrainWindow;v&&v.texWidth===f&&g>v.stepLevel-.85&&g<v.stepLevel+.15&&(_=v.stepLevel);let y=p*2**_,b=y*iU/2;if(v&&v.texWidth===f){if(v.stepLevel===_&&wU(l,u,v.centerTheta,v.centerPhi)<sU*v.angRadius)return!0;if(performance.now()-v.builtAt<cU)return _U.add(e),!0}let x=Math.max(0,l-b),S=Math.min(Math.PI,l+b),C=mU(Math.PI,[[x,S]],y),w=Math.min(Math.PI,b/Math.max(Math.sin(l),XH)),T=Math.max(_,Math.ceil(Math.log2(2*w/iU/p)-1e-9)),E=p*2**Math.max(0,T),D=u-w,O=u+w,k=w>=Math.PI?[[0,2*Math.PI]]:D<0?[[0,O],[D+2*Math.PI,2*Math.PI]]:O>2*Math.PI?[[0,O-2*Math.PI],[D,2*Math.PI]]:[[D,O]],A=mU(2*Math.PI,k,E);if(C.length*A.length>lU)return console.warn(`terrain window for ${e.body.data.id} would need ${C.length}×${A.length} vertices — keeping the uniform sphere`),CU(e),!1;let j=i.geometry;return i.geometry=hU(rU(o,C,A)),j.dispose(),console.debug(`terrain window ${e.body.data.id}: ${C.length}×${A.length} grid, level ${_} (tex ${f})`),e.terrainWindow={thetas:C,phis:A,centerTheta:l,centerPhi:u,angRadius:b,stepLevel:_,texWidth:f,builtAt:performance.now()},e.currentSegments=128,!0}var DU=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],OU=24;function kU(e,t,n,r){if(!n&&!t)return OU;let i=DU[DU.length-1].segs;for(let t of DU)if(e>=t.up){i=t.segs;break}if(i<r){let t=DU.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function AU(e,t,n,r,i,a){let o=t.fov*Math.PI/180,s=n.domElement.clientHeight/(2*Math.tan(o/2)),c=r.visibility.activeSystemId,l=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===G.STAR,o=n.body.data.id;if((o===l||n.terrainWindow)&&EU(n,t,o===l,a))continue;let u=kU(n.radiusScene/n.cachedDist*s,e,c?o===c||r.visibility.isInActiveSystem(n.body.data.parentId):o===i,n.currentSegments??64);if(u===n.currentSegments)continue;let d=Q(xn(n.body.data)),f=n.mesh.geometry;n.mesh.geometry=new _u(d,u,u),f.dispose(),n.currentSegments=u}}function jU(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(yP(n)>yP(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return yP(r)<yP(t)?r:t}function MU(e){if(e.textureLoading||e.displacementLoading||e.clouds?.textureLoading||e.appearance?.loading||e.modelLoadPromise)return!0;let t=e.tileOverlay;if(t&&e.surfaceTiles&&!nD(t.chain,e.surfaceTiles))return!0;let n=e.reliefTiles;return n&&!nD(n.chain,n.tiles)?!0:!vU(e)}function NU(e,t,n,r,i,a,o,s,c){s.apply(e,i);let l=t.fov*Math.PI/180,u=n.domElement.clientHeight/(2*Math.tan(l/2)),d=r.visibility.activeSystemId,f=uw(),p=f.showClouds,m=yP(OE());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=p);for(let s of e.values()){if(!s.mesh||!s.radiusScene||!s.group.visible||!s.availableTiers?.length||s.cachedDist<=0)continue;let e=s.body.data.id;if(d){if(e!==d&&!r.visibility.isInActiveSystem(s.body.data.parentId))continue}else if(e!==a)continue;let l=s.radiusScene/s.cachedDist*u,p=s.cachedDist/s.radiusScene,h;h=l<256&&p>10?`low`:l<1024&&p>2?`medium`:`high`;let g=yP(s.textureTier),_=gP(s)?Math.min(m,yP(`medium`)):m,v=Math.min(yP(h),_),y=SP(o,s.availableFrames),b=y!==s.textureFrame,x=v>g;if(f.showSurfaceTexture&&!s.textureLoading&&(x||b)){let e=x?bP(v,s.availableTiers):s.textureTier;e&&kP(s,e,y,i)}let S=u*n.getPixelRatio();_P(s,t,n,S,f.showSurfaceTexture&&!s.appearance?.surfaceOwned,c),OD(s,t,n,S,c);let C=s.displacementMeta?.tiers;if(s.displacementMap&&!s.displacementLoading&&YD(s,n))s.displacementTier!==`pyramid`&&XD(s,qD);else if(s.displacementMap&&C?.length&&!s.displacementLoading){let e=n.capabilities.maxTextureSize,t=e>=16383&&!ED(s)?2:+(e>=8192),r=s.displacementTier??`low`,i=bP(Math.min(yP(jU(p,r)),t,m),C);i&&i!==r&&XD(s,i)}if(s.clouds&&s.textureTier){let e=bP(yP(s.textureTier),s.clouds.availableTiers),t=sN(o,s.clouds.availableFrames,s.clouds.availableCoverage);e&&t&&uN(s.clouds,e,t)}}}var PU=Qe({progress:null,bootPending:!1}),FU=YI.refMs,IU=new Y,LU=new J,RU=new J,zU=new Zi,BU=new Zi,VU=new J,HU=new J;function UU(e,t,n){return LU.set(e[0],e[1],e[2]),RU.set(t[0],t[1],t[2]),IU.lookAt(LU,RU,n),zU.setFromRotationMatrix(IU).clone()}function WU(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=Tv(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=Dv(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=Tv(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]),BU.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,BU,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=Tv(e.camOriginWorld,e.camTargetWorld,t)}let i=UU(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 GU(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=UU([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=Ev(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(JI(o,ZI),qI(s,QI))}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(),VU.set(0,0,-1).applyQuaternion(e.flyQ0),HU.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=qI(VU.angleTo(HU),YI);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 KU(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=Ev(n,r);VU.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),HU.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=VU.angleTo(HU);e.focusDurationMs=Math.max(JI(a,ZI),qI(o,QI)),i&&(e.focusDurationMs=0)}var qU={[G.STAR]:1e3,[G.PLANET]:100,[G.DWARF_PLANET]:10,[G.ASTEROID]:.1,[G.ASTEROID_INNER]:.1,[G.ASTEROID_MAIN_BELT]:.1,[G.ASTEROID_CENTAUR]:1,[G.ASTEROID_TROJAN]:1,[G.ASTEROID_TNO]:1,[G.COMET]:1,[G.MOON]:1},JU=5e-4,YU=new J,XU=new J;function ZU(e){return qU[e.data.objectType]??xn(e.data)*.25}function QU(e,t){return Q((t??xn(e.data))+ZU(e))}function $U(e,t,n,r){let i=t.data.radiusKm,a=t.position;if(!Number.isFinite(i)||i<=0||!a)return;let o=a[0]-n[0],s=a[1]-n[1],c=a[2]-n[2],l=Math.hypot(o,s,c),u=r?.centerOffsetScene,d=o+(u?u[0]:0),f=s+(u?u[1]:0),p=c+(u?u[2]:0),m=e.position.x-d,h=e.position.y-f,g=e.position.z-p,_=Math.hypot(m,h,g);if(r?.seated){if(_<1e-9){e.position.set(d,f+l+Q(JU),p);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]]){XU.set(a,o,s).applyQuaternion(e.quaternion);let t=m+XU.x,n=h+XU.y,c=g+XU.z,u=Math.hypot(t,n,c);if(u<1e-12)continue;YU.set(t/u,n/u,c/u).applyQuaternion(r.invQuat);let d=r.radialKm([YU.x,YU.y,YU.z]),f=(d===null?l:Q(d))+Q(JU);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/_;e.position.set(e.position.x+m*a,e.position.y+h*a,e.position.z+g*a);return}let v=ZU(t);if(_>=Q((r?.outerRadiusKm??i)+v))return;let y=i;r&&_>1e-9&&(YU.set(m/_,h/_,g/_).applyQuaternion(r.invQuat),y=r.radialKm([YU.x,YU.y,YU.z])??i);let b=Q(y+v),x=l>0?Math.min(b,l):b;if(!(_>=x)){if(_<1e-9)m=0,h=x,g=0;else{let e=x/_;m*=e,h*=e,g*=e}e.position.set(d+m,f+h,p+g)}}function eW(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=QF([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=nI(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]=$F([0,0,0],s,c,l,n);r.set(u,d,f)}var tW=50,nW=20;function rW(e){return e<=0?`none`:e<nW?`full`:e<tW?`half`:`none`}function iW(e,t){return LV(e.data,t)}var aW=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),Oy().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 iv)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!==G.MOON||!this.isDefault(i.data.parentId))continue;let a=this.deps.ctx.getBody(i.data.parentId);!a||!Sn(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!==G.BARYCENTER&&e.data.objectType!==G.LAGRANGE_POINT?!0:iv.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,renderer:l}=this.deps;if(r.has(e.data.id))return!1;!e.orbitElements&&!e.data.pageOnly&&e.data.orbitalSource!==W.SPICE_PROBE&&(e.orbitElements=e.data,e.orbitCenterId=e.data.parentId),i.place(e,a.jd),FL([e],o,s,c,r,l.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let u=r.get(e.data.id);if(u&&!e.data.name&&DP(u),e.data.objectType===G.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(Sn(e.data.objectType)||e.data.objectType===G.COMET){let t=this.deps.ctx.bodies.findAsteroidZone(e.data.id);t&&i.bodies.dirtyAsteroidZones.add(t)}let d=e.data.id;return this.defaults.has(d)||(n?this.autoPromoted.add(d):(this.userPromoted.add(d),this.emitUserPromotedCount())),!0}finalizeBuilds(){TR(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(tv),t=this.currentMemberCount(e),n=rW(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)||iW(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 e=b_(r.data,r.data.validityStart),i=b_(r.data,r.data.validityEnd);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),iW(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&&!iW(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||hn(n)||n.data.objectType===G.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}if(e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),$j(e),OP(e),zM(e),i.remove(e.root),e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),ML(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(),ML(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),ML(e.trail.material));let s=e.body.data.objectType;if(s===G.SPACECRAFT)c.add(e.body.data.parentId);else if(Sn(s)||s===G.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)}},oW=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r){this.deps=e,this.focusedBody=t,this.promotion=new aW({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer: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}place(e){return this.deps.ctx.place(e,this.deps.clock.jd)}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||Rj(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=cW(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&&(IL(t.body)?RL(t,n,r,i):$j(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}IL(t)&&(LL(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(TR(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e,t){let n=this.place(e);if(!n)return;let{focus:r,camera:i}=this.deps,a=this.cameraTruePos(),o;if(t!==void 0){let e=this._tmpV3.set(a[0]-n[0],a[1]-n[1],a[2]-n[2]).normalize();o=[n[0]+e.x*t,n[1]+e.y*t,n[2]+e.z*t]}GU(r,[...n],i,a,o,uw().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,GU(n,[...e],r,a,o,uw().resolvedReducedMotion);let s=QF(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}this.setFocusTarget(e);let t=e.position;if(!t)return;let{latitude:n,longitude:r,distance:i}=QF(this.cameraTruePos(),t,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(n,r,i)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;hn(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=EM(u,r),f=EM(e,r),p=u&&(hn(u)?u.featureAnchor.hostId:u.data.id),m=hn(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&$j(e)}if(d&&d!==f){let e=r.get(d);e&&zM(e)}e.data.id!==u?.data.id&&(this.pendingInitialView=null),this.focusedBody=e,hn(e)||(n.bodies.focusFeature=null),i.minDistance=QU(e,xM(r.get(e.data.id)));let g=hn(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),hn(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus();let _=this.place(e);_&&GU(o,[..._],s,this.cameraTruePos(),t,uw().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,focus:a,camera:o,callbacks:s,pointClouds:c}=this.deps,l=i.getBody(e);if(!l)return 0;let u=this.place(l);if(!u)return this.setFocusTarget(l),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=$F(u,n,r,t,this.focusedBodyQuat(l));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u[0]-e[0],u[1]-e[1],u[2]-e[2]).normalize().negate();d=[u[0]+n.x*t,u[1]+n.y*t,u[2]+n.z*t]}let f=QF(d??this.cameraTruePos(),u,this.focusedBodyQuat(l));return s.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?(this.pendingInitialView=null,this.focusedBody?.data.id===e&&Ev(a.focusTruePos,u)<QU(l)?(a.focusTruePos=[...u],this.deps.repositionAll(),c.rebuildBasis(),KU(a,o,this.cameraTruePos(),d,uw().resolvedReducedMotion)):(this.setFocusTarget(l,d),n!==void 0&&r!==void 0&&(a.orbitFly=!0))):this.setFocusTarget(l),a.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e),a=i&&this.place(i);!i||!a||(this.settleOnBodyInstant(i,a),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),l=i.getBody(t),u=c&&this.place(c),d=l&&this.place(l);if(!c||!u||!d)return;this.settleOnBodyInstant(c,u);let f=eI(u,d,n,r);a.position.set(f[0],f[1],f[2]),o.update();let p=QF(f,[0,0,0]);s.onCameraPosition?.(p.latitude,p.longitude,p.distance),this.pendingInitialView=null}settleOnBodyInstant(e,t){let{focus:n,pointClouds:r}=this.deps;this.setFocusTarget(e),n.focusTruePos=[...t],n.focusOriginWorld=[...t],n.focusTargetWorld=[...t],n.focusStartTime=-FU,n.camOriginWorld=null,n.camTargetWorld=null,n.flyQ0=null,n.orbitFly=!1,n.arcOrbit=!1,n.cameraStaysOnBody=!1,this.deps.repositionAll(),r.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!Rj(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=$F([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=QF(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),this.pendingInitialView=s&&sW(c)?{latitude:e,longitude:t,zoom:n}:null}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||sW(t)){this.pendingInitialView=null;return}let n=$F([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function sW(e){return e[0]===0&&e[1]===0&&e[2]===0&&e[3]===1}function cW(e,t){if(!e)return[];if(hn(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&IL(n)?[n]:[]}let n=[];if(IL(e)&&n.push(e),e.data.objectType===G.MOON||e.data.orbitalSource===W.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var lW=1e-6;function uW(e){return e.data.name??e.data.id}var dW=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}windowsOf(e){let t=this.coverage.get(e);if(t)return t;this.pending.has(e)||(this.pending.add(e),cS(e).catch(t=>(console.warn(`[coverage] ${e}: no coverage to arm the clock with:`,t),[])).then(t=>this.coverage.set(e,t)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.orbitalSource===W.SPICE_PROBE?e:void 0,r=n&&this.windowsOf(n.data.id)?.find(([e,n])=>t>e&&t<n);if(!n||!r){this.disarm();return}this.armedProbeId!==n.data.id&&(this.dismissNotice(),this.armedProbeId=n.data.id);let i=r[1]-lW,a=r[0]+lW;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:Number.isFinite(i)?i:null,backwardJd:Number.isFinite(a)?a:null,onHit:e=>this.onHit(n,e,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:uW(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)}},fW=class{group=new Ja;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()}},pW=Math.PI/180;function mW(e){return`latitude`in e}function hW(e,t,n){let r=e*pW,i=t*pW,a=[Math.cos(r)*Math.cos(i),Math.sin(r),-Math.cos(r)*Math.sin(i)];return n&&gW(n,a,0,a,0),a}function gW(e,t,n,r,i){let a=t[n]*e.a,o=t[n+1]*e.c,s=t[n+2]*e.b,c=Math.hypot(a,o,s);r[i]=a/c,r[i+1]=o/c,r[i+2]=s/c}var _W=class{source=null;radii;out=new Float64Array;of(e,t){if(!t)return e;if(e!==this.source||t!==this.radii){this.out.length!==e.length&&(this.out=new Float64Array(e.length));for(let n=0;n<e.length;n+=3)gW(t,e,n,this.out,n);this.source=e,this.radii=t}return this.out}};function vW(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 yW(e,t,n){return t.place(e,n)}function bW(e,t,n,r){let[i,a,o]=n;if(mW(e)){let n=Q(xn(t.data)+(e.altitudeKm??0)),[s,c,l]=hW(e.latitude,e.longitude,t.drawnRadii),u=t.orientation?SS(t.orientation,r,t.nutPrec):null;if(!u)return[i+s*n,a+c*n,o+l*n];let d=[0,0,0];return vW(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]=OB(s);return[i+c,a+l,o+u]}function xW(e,t,n){let r=t.getBody(e.body),i=r&&yW(r,t,n);return i?bW(e,r,i,n):null}function SW(e,t,n,r){let i=n.getBody(e.body),a=i&&yW(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 CW(e){let t=vg/10;return[e[0]*t,-e[2]*t,e[1]*t]}function wW(e,t,n){let r=xW(e.position,t,n),i=xW(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 TW=.02,EW=1e-4,DW=1e3/60;function OW(e){return e?.4:.05}function kW(e,t){return 1-(1-e)**(t/DW)}function AW(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=Rj(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){let r=n?.position;if(!n||!r)continue;let i=Q(xn(n.data));if(!(i>0))continue;let a=Math.hypot(e.position.x-(r[0]-t[0]),e.position.y-(r[1]-t[1]),e.position.z-(r[2]-t[2]));s=Math.min(s,a-i)}let c=o?Q(xn(o.data)):0,l=Math.tan(Xi.degToRad(e.getEffectiveFOV())/2);return{rotate:jW(c>0?(a-c)*l/(Math.PI*c):1,EW),translate:jW(s/a,TW)}}function jW(e,t){return Math.min(1,Math.max(t,e))}var MW=Math.PI/180;function NW(e,t){let n=e*MW,r=t*MW;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function PW(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new RT(i),[o,s,c]=NW(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function FW(e){e.parent?.remove(e),e.element.remove()}var IW=new J;function LW(e,t,n){if(!e)return;let r=t.get(tv);if(!r?.mesh)return;IW.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=IW.x,a=IW.y,o=IW.z,s=r.root.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 RW=-1,zW=1.2,BW=Q(1e6),VW=.02,HW=2,UW=2.3,WW=.9,GW=new J,KW=.25,qW=10,JW=4,YW=4,XW=28,ZW=.02,QW=class e{renderer;composer;maxSceneSamples;atmoDepthPass;modelDepthPass=new YL;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=$L();pointClouds;systemData;positionDiagnostics=new eH;placer;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new fW;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;_tmpFwd=new J;_tmpSun=new J;_tmpLeak=new J;_occluders=[];_planeNormal=new J(0,0,1);_modelRaycaster=new Qd;_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:FU};lastUpdatedJd=NaN;get placedJd(){return this.lastUpdatedJd}lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;disposed=!1;lastDataVersion=-1;dateHolds=0;seenJumps=0;jumpJd=null;focusWasOutOfRange=!1;seekAwaitsData=!1;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 Zi;restCamPos=new J(NaN,NaN,NaN);restCamQuat=new Zi;restFocusKey=``;atRest=!1;focusLoads=0;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=NE();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;orbitDampingFactor;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;halosShown=!0;textureLoader=new cd;appearances=new VL;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(ev)?.root.children.find(e=>e instanceof Td)}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.seenJumps=i.jumps,this.callbacks=o,this.outOfRange=new VV(o.notices),this.labelContainer=n;let s=II(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.maxSceneSamples=s.maxSceneSamples,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new zL(c.x,c.y),this.modelScene=new no,this.modelScene.environment=sC(this.renderer),this.modelScene.environmentIntensity=iC,this.modelCamera=new xd(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new kd(16777215,nC);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new Od(16777215,rC),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 Ws(new pu(40,40),new vu({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new kR(this.scene),this.skyDebugMarkers=new qR(this.scene),this.haloDebug=new nz(this.canvas),this.travelPath=new aV(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new uV(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),oF(this.scene,this.renderer,r,()=>this.disposed),this.placer=new $V(r,this.bodyObjects,this.positionDiagnostics,()=>this.dateHeld()),r.placer=this.placer;let u=[r.getBody(a.id),r.bodies.majorBodies.find(e=>e.data.id===rI),r.bodies.majorBodies.find(e=>e.data.id===ev)].find(e=>e&&this.placer.place(e,this.clock.jd)),d=u?.position??gV;this.focus.focusTruePos=[...d],this.focus.focusOriginWorld=[...d],this.focus.focusTargetWorld=[...d],this.focus.focusStartTime=-FU,this.pointClouds=new Fz(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(d),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new AF(this.camera,t),this.controls.enableDamping=!0,this.orbitDampingFactor=OW(uw().resolvedReducedMotion),this.controls.minDistance=u?QU(u):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 rL(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new DR(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new oW({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()},u,this.hoveredBodyIds,this.renderer),this.coverageWatch=new dW(i,o.notices);let f=u?.data.id===a.id?a:{latitude:45,longitude:0,zoom:15},p=$F([0,0,0],f.latitude,f.longitude,f.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(...p),this.focusController.setPendingInitialView({latitude:f.latitude,longitude:f.longitude,zoom:f.zoom}),u&&r.visibility.setFocused(u),r.visibility.updateCamera(f.zoom,this.clock.jd),o.onFocusChange(u),this.buildScene(),u&&this.focusController.promotion.ensureBodyObjects(u),u&&this.focusController.syncUpgradeTargets(u),this.repositionAll(),u&&this.maybeLoadTexture(u),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new GI(this.renderer,this.camera),this.pointerInteraction=new BI(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(){FL(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,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)))(()=>{TR(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.whereBody(t);if(!r)return;let i=this.focus.focusTruePos,a=r[0]-i[0]-this.camera.position.x,o=r[1]-i[1]-this.camera.position.y,s=r[2]-i[2]-this.camera.position.z,c=Math.hypot(a,o,s);c>n*1.35&&c<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.where(e),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.where(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.sceneJd),this.travelPath.reposition(t,this.focus.focusTruePos,e=>this.where(e)),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.where(e);if(!n)return;let[r,i,a]=OB(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=OB(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.where(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e);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.where(e.centerId),r=n?this.travelFocusWorld(n):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId),n=t&&this.whereBody(t);if(!t||!n)continue;let a=this.ctx.visibility.resolveSystemId(t);if(!a)continue;let o=this.ctx.visibility.systemReachAU(a);if(!(o>0))continue;let s=Ev(r,n)/10;!i&&s<=o?i=a:s<=o*2?this.systemData.prefetch(a):this.systemData.discardPrefetch(a)}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()}checkDrawnArePlaced(){for(let e of this.bodyObjects.values()){if(e.body.position)continue;let t=e.root.visible?`root`:e.trail?.visible?`trail`:e.model?.parent===this.modelScene?`model`:null;t&&this.positionDiagnostics.warnOnce(`drawn-unplaced`,e.body.data.id,()=>`[scene] ${e.body.data.id} has no place (${e.body.unplaced}) and its ${t} is drawn`)}}placeOf(e){return this.applyJdUpdate(),this.whereBody(e)}panCameraTo(e,t){return this.disarmLimits(),this.focusController.panCameraToBody(e,t),this.focus.focusDurationMs}where(e){return this.placer.at(e,this.sceneJd)}whereBody(e){return this.placer.place(e,this.sceneJd)}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let i=r.body.position;i&&r.root.position.set(i[0]-e,i[1]-t,i[2]-n)}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){Qz(i.body,a,o,e,this.sceneJd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;$z(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.controls.dampingFactor=kW(this.orbitDampingFactor,n||16.666666666666668),this.holdingCamera||this.cameraUp.update(this.sceneJd),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.dateHeld()&&!this.seekAwaitsData&&this.clock.placed(this.seenJumps),this.refreshTravelFocus(),this.callbacks.onFrame?.(this.sceneJd,r);let i=this.holdingCamera?this.applyHeldCamera():WU(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=Sv(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||hn(a);t&&$U(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),vM(this.bodyObjects.get(a.data.id))&&$U(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(AW(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.sceneJd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.sceneJd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=mB(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(),pV(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),hH(this.bodyObjects,this.focus.focusTruePos,uw().realisticLighting,uw().overexposeRings,this.camera.position,this.pxPerRad());let s=GH(this.bodyObjects,this._occluders);KH(this.bodyObjects,s,this.focus.focusTruePos,this.camera.position.length(),uw().showAtmospheres),aH(this.bodyObjects,s,uw().realisticLighting,this.sunIntensityScale),s.length=0;let c=UH(this.bodyObjects,this.camera.position,uw().showAtmospheres,uw().realisticLighting,this.sunIntensityScale,gw(),this.sceneJd);Dw(r,c.shellProminent),this.scene.backgroundIntensity=c.skyboxIntensity,this.applyLayerChrome();let l=this.bodyObjects.get(ev);l&&yL(l.corona,l.starPoint,c.sunTint);let u=uw().highAmbient?1:nC;if(!uw().highAmbient&&uw().realisticLighting){let e=this.bodyObjects.get(ev)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;u*=aC(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=u;LW(this.userLocationMarker,this.bodyObjects,this.camera);let d=EM(this.focusController.current,this.bodyObjects);NU(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,d,this.sceneJd,this.appearances,this.invalidate),AU(this.bodyObjects,this.camera,this.renderer,this.ctx,d,this.invalidate),JH(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,uw().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(c.sunRefraction),c.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.syncSceneSamples(c.insideShell),this.composer.readBuffer.resolveDepthBuffer=this.overlayActive,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),this.checkRest(t)};checkRest(e){let t=this.cameraMovedFrom(this.restCamPos,this.restCamQuat)||this.focusKey()!==this.restFocusKey;this.restCamPos.copy(this.camera.position),this.restCamQuat.copy(this.camera.quaternion),this.restFocusKey=this.focusKey(),t||this.settling(e)?this.atRest=!1:this.atRest||(this.atRest=!0,this.callbacks.onIdle?.())}settling(e){if(this.covered||this.ctx.loading||PU.bootPending||e-this.focus.focusStartTime<this.focus.focusDurationMs||this.jumpJd!==null||this.seekAwaitsData||this.focusLoads>0||this.systemData.isLoading())return!0;for(let e of this.bodyObjects.values())if(e.group.visible&&MU(e))return!0;return!1}syncSceneSamples(e){let t=this.composer.readBuffer,n=e?0:Math.min(this.tier.sceneSamples,this.maxSceneSamples);t.samples!==n&&(t.samples=n,t.dispose())}updateTightFar(e){if(Aw())return;let t=this.focusController.current,n=t?EM(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e,o=r?.body.position;if(t&&o&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[r,i,s]=o,c=this.camera.position;a=Math.hypot(e+c.x-r,t+c.y-i,n+c.z-s)}let s=this.tightFar?UW:HW;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*s}updateDepthFar(){if(Aw())return;let e=NI,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(ev);if(this.tightFar){let e=this.bodyObjects.get(t)?.body.position;if(e){let o=Math.hypot(e[0]-n,e[1]-r,e[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s?.body.position&&o(s.body.position);for(let e of this.bodyObjects.values()){let t=e.body.position;t&&this.ctx.visibility.hasFullRendering(e.body)&&o(t)}e=Math.min(NI,Math.max(BW,Math.sqrt(a)*zW))}Math.abs(e-this.camera.far)>this.camera.far*VW&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(ev),n=t?.body.position;if(!t||!n)return;let[r,i,a]=this.focus.focusTruePos,[o,s,c]=n,l=o-r,u=s-i,d=c-a;if(e){let t=this.camera.position,n=this._tmpV3.set(l-t.x,u-t.y,d-t.z),r=n.length();n.divideScalar(r);let i=GW.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),l=t.x+n.x*r,u=t.y+n.y*r,d=t.z+n.z*r)}let f=1;if(this.tightFar){let e=this.camera.far*WW,t=Math.hypot(l,u,d);t>e&&(f=e/t)}f===1&&this.sunProxyK===1&&!e||(this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.root.position.set(l*f,u*f,d*f),t.mesh?.scale.setScalar(this.sunBaseMeshScale*f),t.corona?.scale.set(this.sunBaseCoronaScale*f,this.sunBaseCoronaScale*f,1),this.sunProxyK=f)}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}tilesFailed(e){return!!this.bodyObjects.get(e)?.tileOverlay?.chain.dead}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=hW(t,n,r.drawnRadii);return EO(this.bodyObjects.get(e),e,xn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(vM(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:bM(n),centerOffsetScene:yM(n),radialKm:e=>_M(n,e)};if(!(!t||!e.orientation))return{invQuat:SS(e.orientation,this.sceneJd,e.nutPrec).invert(),seated:t,radialKm:t=>EO(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&Rj(t.body)&&kO(t)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model;if(!n)continue;let r=kO(t),i=t.modelRoot;if(!i){r&&n.parent!==this.modelScene?this.modelScene.add(n):!r&&n.parent&&n.removeFromParent();continue}if(e&&r)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==i){i.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=Kj(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(ev)?.body.position,a=e.body.position;if(!i||!a)return;this._tmpSun.set(i[0]-a[0],i[1]-a[1],i[2]-a[2]).normalize(),this.shadowLight.position.copy(e.root.position).addScaledVector(this._tmpSun,qW*n),this.shadowLight.target.position.copy(e.root.position);let o=this.shadowLight.shadow.camera;o.left=o.bottom=-JW*n,o.right=o.top=JW*n,o.near=YW*n,o.far=XW*n,o.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=ZW*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.root.position);let n=this._tmpV3.length(),r=Kj(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||!kO(t))continue;let i=Kj(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.root.position,e.root.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(ev)?.body.position,s=e.body.position,c=1;if(o&&(this._tmpSun.set(o[0]-s[0],o[1]-s[1],o[2]-s[2]),uw().realisticLighting&&(c=aC(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)),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 l=Xw(this._tmpV3,this._tmpV3),u=eT(this._tmpV3,this._tmpV3,this._tmpLeak);this.modelLight.color.setRGB(l+u.x,l+u.y,l+u.z),this.modelLight.intensity=rC*c*this.sunIntensityScale,this.modelScene.environmentIntensity=iC*l*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);let d=e.model.userData;this._tmpV3.copy(d.boxCenter).applyQuaternion(e.model.quaternion).add(e.model.position),this.modelCamera.getWorldDirection(this._tmpFwd);let f=this._tmpV3.sub(this.modelCamera.position).dot(this._tmpFwd)-d.halfExtents.length();this.renderer.autoClear=!1,this.renderer.clearDepth(),this.modelDepthPass.run(this.renderer,this.composer.readBuffer.depthTexture,this.camera,this.modelCamera,r,f),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=KW/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 QF([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?RW:Nn.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||eW(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,r=e?.position;return r?[n.x+t[0]-r[0],n.y+t[1]-r[1],n.z+t[2]-r[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&&wW(e,this.ctx,this.sceneJd);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){return this.holdingCamera||t-this.focus.focusStartTime<this.focus.focusDurationMs||this.focusKey()!==this.lastRenderedFocusKey||this.ctx.bodies.minorStreaming||this.pointClouds.hasPendingSceneAdds()||this.systemData.hasPendingUnloads()?!0:this.covered?!1:this.frameIndex-this.lastRenderedFrame>=e.IDLE_HEARTBEAT_FRAMES||this.cameraMovedFrom(this.lastRenderedCamPos,this.lastRenderedCamQuat)||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}cameraMovedFrom(e,t){let n=this.camera;return!(n.position.distanceToSquared(e)<=n.position.lengthSq()*1e-10&&8*(1-Math.abs(n.quaternion.dot(t)))<=1e-8)}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);if(!t)return;this.focusLoads+=2;let n=()=>this.focusLoads--;EP(t,this.textureLoader,this.sceneJd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(CS(t.mesh,e.orientation,this.sceneJd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}).finally(n),Xj(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=QU(t.body,xM(t))),!this.ctx.layers.skipped.has(`nomenclature`))return PM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&RM(t,this.selectedFeatureId)}).finally(n)}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&($j(t),OP(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=EM(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&RM(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!==G.SPACECRAFT&&!hn(e))return null;let t=Sv(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`}|${pO()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;probeTargetRetries=new Ex(()=>{this.lastProbeTargetCheck=null,this.invalidate()});askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==W.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),rS(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)||this.probeTargetRetries.waiting(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Mg(this.clock.jd)).then(()=>this.probeTargetRetries.clear(r),e=>{console.warn(`[renderer] the body ${r} a craft is fit to did not load:`,e),this.requestedProbeTargets.delete(r),this.probeTargetRetries.fail(r)});return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}holdDate(){this.dateHolds++;let e=!0;return()=>{e&&this.dateHolds--,e=!1}}jumpLoads(){let{clock:e,ctx:t}=this;e.jumps!==this.seenJumps&&(this.seenJumps=e.jumps,this.jumpJd=e.jd,t.refreshTick(Mg(e.jd)),t.chebStore?.request(e.jd),t.probeStore?.request(e.jd));let n=this.jumpJd;return n===null?!1:!t.chebStore?.loadingAt(n)&&!t.probeStore?.loadingAt(n)?(this.jumpJd=null,!1):(this.invalidate(),!0)}dateHeld(){return!Number.isNaN(this.lastUpdatedJd)&&(this.dateHolds>0||this.jumpLoads())}get sceneJd(){return this.dateHeld()?this.lastUpdatedJd:this.clock.jd}applyJdUpdate(e=!1){if(this.dateHolds>0||this.jumpLoads())return;this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0,i=this.ctx.bodies.dataVersion+(this.ctx.chebStore?.version??0)+(this.ctx.refresher?.wakes??0);if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion&&i===this.lastDataVersion){this.clock.seeked=!1;return}let a=this.clock.seeked||this.seekAwaitsData;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.lastDataVersion=i,this.ctx.refreshTick(Mg(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let o=fV({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,placer:this.placer,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(),this.seekAwaitsData=a&&o.focusLoading;let s=o.focusUnplaced&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=o.focusUnplaced,e&&a&&s&&o.anchorId){let e=this.ctx.getBody(o.anchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.orbitDampingFactor=OW(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),o=a&&this.whereBody(a);if(!a||!o)return 0;this.focusController.clearPendingInitialView();let s=EM(this.focusController.current,this.bodyObjects)===e.hostId,c=aI(e,t);this.ctx.bodies.focusFeature=c;let l=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,l&&RM(l,e.featureId);let u=this.whereBody(c);if(!u)return 0;let d=this.focusController.focusedBodyQuat(c);if(r===`pan`){let e=QF(this.focusController.cameraTruePos(),u,d);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(c),this.focus.focusDurationMs}let f=u[0]-o[0],p=u[1]-o[1],m=u[2]-o[2],h=Math.hypot(f,p,m);h>1e-9?(f/=h,p/=h,m/=h):(f=0,p=1,m=0);let g=r===`snap`&&i?$F(u,i.latitude,i.longitude,i.zoom,d):[u[0]+f*n,u[1]+p*n,u[2]+m*n],_=QF(g,u,d);if(this.callbacks.onCameraPosition?.(_.latitude,_.longitude,_.distance),r===`snap`){this.focusController.setFocusTarget(c,g);let e=this.focus;return e.focusTruePos=[...u],e.focusOriginWorld=[...u],e.focusTargetWorld=[...u],e.focusStartTime=-FU,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(g[0]-u[0],g[1]-u[1],g[2]-u[2]),this.controls.update(),0}if(s){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(c),this.focus.focusTruePos=[...u],this.camera.position.set(e[0]-u[0],e[1]-u[1],e[2]-u[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),KU(this.focus,this.camera,e,g,uw().resolvedReducedMotion)}else this.focusController.setFocusTarget(c,g),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||!kO(e))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=e=>e?.model&&kO(e)?e:null,t=this.focusController.current;if(!t){let t=this.travelFocus?.centerId;return e(t?this.bodyObjects.get(t):void 0)}let n=hn(t)?t.featureAnchor.hostId:t.data.id,r=this.bodyObjects.get(n);return e(r)||(t.data.orbitalSource===W.SPICE_PROBE&&!r?.isLanded?e(this.bodyObjects.get(t.data.parentId)):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 sz({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:Rj(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 Ja,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new of(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 Ss(new cs({map:new qc(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=Yb(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&&ST(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(tv);n?.mesh&&(this.userLocationMarker&&FW(this.userLocationMarker),this.userLocationMarker=PW(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(FW(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.atRest=!1:this.invalidate())}isContextLost(){return this.renderer.getContext().isContextLost()}handleContextRestored(){this.renderer.setPixelRatio(PE()),this.composer.setPixelRatio(PE()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),oF(this.scene,this.renderer,this.ctx,()=>this.disposed),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=NE();let e=PE();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),EI(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&&$j(e);for(let e of this.bodyObjects.values())pP(e),DD(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),$W(this.scene.background),$W(this.scene.environment),$W(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.modelDepthPass.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))$W(t);e.dispose()}})}};function $W(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var eG=6371;function tG(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 nG={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:tG(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},rG=1.6,iG=1.0005,aG=new J(.55,.25,.8).normalize(),oG=[`low`,`medium`,`high`,`ultra`],sG=4,cG=12,lG=10,uG=16,dG=5;function fG(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function pG(e,t){let n=`low`;for(let r of e.tiers){let e=fG(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var mG=new Set([`WebKit WebGL`,`Mozilla`,``]);function hG(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!mG.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function gG(e,t){let n=e.getContext(),r=new no,i=new xd(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new Ou({color:7829367,roughness:1,metalness:0}),o=new Ws(new _u(1,64,64),a);o.renderOrder=1,r.add(o);let s=new Od(16777215,2);s.position.copy(aG),r.add(s);let c=nG,l=mT(c,1,eG),u=l.material.uniforms;u.uSunDir.value.copy(aG),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,iG,0),i.lookAt(1,iG+.1,0)):(i.position.set(0,0,rG),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}={})=>{xT(l,pw[e]),d(t);let i=0;for(let e=0;e<sG;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(uG,Math.max(1,Math.ceil(lG/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<cG;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=dG){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(),TT(l)}}}function _G(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 vG(e,t){let n=t.tiers??oG,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=gG(e,i),c=sG+cG,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`?sG: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`?cG:sG,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(pw[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 _G(e,n,f,p)}var yG=60,bG=100,xG=3e4,SG=25e4,CG=`v1`,wG=!1,TG=null,EG=Promise.resolve();function DG(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/SG);return`${hG(e)}|${n}|${CG}`}function OG(){wG||typeof window>`u`||(wG=!0,PU.bootPending=!0,EG=new Promise(e=>{let t=()=>{PU.bootPending=!1,e()};setTimeout(t,xG),setTimeout(()=>void AG(!1).finally(t),bG)}))}function kG(){return EG}function AG(e){return TG??=jG(e).finally(()=>TG=null),TG}async function jG(e){let t=uw();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new Th({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(iw()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=DG(n);if(!e&&t.atmosphereCalibration?.key===r)return;PU.progress=0;let i=await vG(n,{budgetMs:1e3/yG,startTier:mw(),onProgress:e=>PU.progress=e.fraction}),a={};for(let e of i.tiers){let t=fG(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=pG(i,1e3/yG);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{PU.progress=null,n?.dispose(),n?.forceContextLoss()}}var MG=class{object=new Ja;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 RT(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,KT(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?xW(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=SW(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()}},NG=3,PG=new J,FG=new J,IG=new J;function LG(e){let[t,n=t]=(e??``).split(/[\s,]+/).filter(Boolean).map(Number);return t>0&&n>0?[t,n]:null}function RG(e,t){return PG.set(1,0,0).applyQuaternion(e.quaternion),FG.set(0,1,0).applyQuaternion(e.quaternion),IG.set(0,0,-1).applyQuaternion(e.quaternion),t/(2*Math.tan(e.getEffectiveFOV()*Math.PI/360))}function zG(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*PG.x+a*PG.y+o*PG.z,r[1]=i*FG.x+a*FG.y+o*FG.z,r[2]=i*IG.x+a*IG.y+o*IG.z}function BG(e,t,n){IG.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)*IG.x+(e[o*3+1]-i)*IG.y+(e[o*3+2]-a)*IG.z<n.near*2)return!0;return!1}function VG(e,t,n,r,i){let a=RG(n,r),o=[0,0,0],s=0,c=0,l=0,u=!1;for(let r=0;r<t;r++){if(zG(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 HG=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=RG(r,i),o=i*r.aspect*NG/2,s=i*NG/2,c=r.near*2,{a:l,b:u}=this,d=!1,f=0,p=0,m=0;n>0&&zG(e,0,r,l);for(let i=0;i+1<n;i++,[l,u]=[u,l]){zG(e,i+1,r,u);let n=0,h=1;for(let e=0;e<5&&n<=h;e++){let t=UG(e,l,a,o,s,c),r=UG(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 UG(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 WG=1e-9,GG=class{object=new Ja;anchor;color;widthPx;opacity;dash;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;seen=new HG;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=LG(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?xW(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])>WG||Math.abs(o[1]-this.lastOrigin[1])>WG||Math.abs(o[2]-this.lastOrigin[2])>WG;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||BG(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),dR(this.mesh.geometry,e.points,e.alphas,e.alphas,e.count),this.dash&&mR(this.mesh.geometry,e.lengths,e.count)}else s&&dR(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=hR(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 KG(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=qG(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,qG(n,a)]}function qG(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 JG(e,t={}){let[n,r]=KG(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 YG(e){if(e.length<3)return[];let[t,n]=KG(XG(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 uu.triangulateShape(r,[]).flat()}function XG(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 ZG(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 QG([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 QG(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 $G(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]]:QG([n,r,i])}function eK(e,t){return new Eu({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
6367
6367
  #include <common>
6368
6368
  #include <logdepthbuf_pars_vertex>
6369
6369
  uniform vec3 uCenterOffset;
@@ -6380,6 +6380,6 @@ void main() {
6380
6380
  gl_FragColor = vec4(uColor, uOpacity);
6381
6381
  #include <logdepthbuf_fragment>
6382
6382
  }
6383
- `})}var zG=.25,BG=1e-9,VG=3,HG=class{object=new Ja;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??zG,this.outline=t>0?new kG({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?iW(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])>BG||Math.abs(s[1]-this.lastOrigin[1])>BG||Math.abs(s[2]-this.lastOrigin[2])>BG){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=NG(e);if(!n.length)return;let r=new ns;r.setAttribute(`position`,new Wo(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new Ws(r,RG(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=VG,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()}},UG=class extends HG{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:MG(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(MG(e,{normal:this.normal,steps:this.steps}))}},WG=class extends gG{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}},GG=class extends gG{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}},KG=Math.PI/180,qG=180/Math.PI;function JG(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function YG(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[JG(n*i.lonPerX+t),i.lat]}}function XG(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function ZG(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 QG(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*qG,lonPerX:qG,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)=>[JG(e-t)*KG,n*KG],rowInverse:n,inverse:YG(n,t)}}var $G=1.340264,eK=-.081106,tK=893e-6,nK=.003796,rK=Math.sqrt(3),iK=e=>nK*e**9+tK*e**7+eK*e**3+$G*e,aK=e=>9*nK*e**8+7*tK*e**6+3*eK*e**2+$G;function oK(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(SK(rK/2*Math.sin(n*KG))),i=JG(e-t)*KG;return[2*rK*i*Math.cos(r)/(3*aK(r)),iK(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(iK(t)-e)/aK(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/rK*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*aK(t)/(2*rK*Math.cos(t))*qG;return{lat:Math.asin(n)*qG,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:ZG(n),forward:n,rowInverse:i,inverse:YG(i,t)}}var sK=Math.SQRT2;function cK(e){let t=e.centerLon??0,n=e=>{let t=e/sK;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*sK*i)*qG;return{lat:Math.asin(r)*qG,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*sK,minY:-sK,maxX:2*sK,maxY:sK},forward:(e,n)=>{let r=n*KG,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=JG(e-t)*KG;return[2*sK/Math.PI*a*Math.cos(i),sK*Math.sin(i)]},rowInverse:n,inverse:YG(n,t)}}function lK(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*qG,lonPerX:qG/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*KG;return[JG(e-t)*KG*Math.cos(r),r]},rowInverse:n,inverse:YG(n,t)}}var uK=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],dK=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],fK=.8487,pK=1.3523,mK=5;function hK(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 gK=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),_K=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function vK(e){let t=Math.min(Math.max(Math.floor(e),0),uK.length-2);return[t,e-t]}function yK(e){let[t,n]=vK(e);return fK*gK(hK(uK,t),n)*Math.PI}function bK(e){let t=0,n=dK.length-1;for(;n-t>1;){let r=t+n>>1;dK[r]<=e?t=r:n=r}let r=Math.min(t,dK.length-2),i=hK(dK,r),a=(e-dK[r])/(dK[r+1]-dK[r]);for(let t=0;t<8;t++){let t=_K(i,a);if(t===0)break;let n=(gK(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function xK(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/pK;if(t>1)return null;let n=bK(t),r=yK(n);return{lat:Math.sign(e)*n*mK,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-fK*Math.PI,minY:-pK,maxX:fK*Math.PI,maxY:pK},forward:(e,n)=>{let[r,i]=vK(Math.abs(n)/mK),a=gK(hK(uK,r),i),o=gK(hK(dK,r),i);return[fK*a*JG(e-t)*KG,pK*o*Math.sign(n)]},rowInverse:n,inverse:YG(n,t)}}function SK(e){return e<-1?-1:e>1?1:e}function CK(e,t,n,r,i,a,o){let s=Math.asin(SK(n*a+t*r*o));return[JG(i+Math.atan2(e*r,n*o-t*r*a)*qG),s*qG]}function wK(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function TK(e,t,n,r){let i=JG(e-n)*KG,a=t*KG;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function EK(e){let t=e.centerLon??0,n=(e.centerLat??0)*KG,r=Math.min(e.clipAngle??90,90)*KG,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:wK(a),forward:(e,r)=>{let a=JG(e-t)*KG,o=r*KG;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:TK(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:CK(e,n,Math.sqrt(1-r),1,t,o,s)}}}var DK=120;function OK(e){let t=e.centerLon??0,n=(e.centerLat??90)*KG,r=Math.min(e.clipAngle??DK,170)*KG,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:wK(a),forward:(e,r)=>{let a=JG(e-t)*KG,o=r*KG,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]=TK(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 CK(e,n,(4-r)*i*.25,i,t,o,s)}}}var kK={equirectangular:QG,equalEarth:oK,mollweide:cK,sinusoidal:lK,robinson:xK,orthographic:EK,stereographic:OK},AK=Object.keys(kK);function jK(e,t={}){let n=kK[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var MK=Math.PI/180,NK=2*Math.PI,PK=2*MK,FK=180/Math.PI,IK=512,LK=2;function RK(e,t){let n=e.lat*MK,r=t.lat*MK,i=r-n,a=JG(t.lon-e.lon)*MK,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)))*FK}function zK(e,t,n){let r=RK(e,t)*MK;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*MK,c=e.lon*MK,l=t.lat*MK,u=(e.lon+JG(t.lon-e.lon))*MK,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)*FK,lat:Math.atan2(p,Math.hypot(d,f))*FK}}function BK(e,t,n){return{lon:e.lon+JG(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function VK(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??LK,i=n===`geodesic`?zK:BK,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(IK,Math.max(1,Math.ceil(RK(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function HK(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=BK(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return BK(e,t,r)}function UK(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=HK(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=HK(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 WK(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 GK(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 KK=179.999999;function qK(e,t){let n=e=>e>KK?KK:e<-KK?-KK:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=JG(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=JG(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*KK,lat:e}),i.push(a),a=[{lon:-d*KK,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 JK(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?qK(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=UK(VK(e,n),t),a=!!n.closed&&i;return WK(r,t).map(e=>GK(e,a)).join(``)}).join(``)}function YK(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return JK(e,t,{...n,closed:!0});if(e.length<2)return``;let i=VK(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 GK(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=HK(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=HK(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=XK(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)%NK+NK)%NK;n<a&&(a=n,i=e)}let o=Math.ceil(a/PK);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=>GK(e.map(s),!0)).join(``)}function XK(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=JG(i.lon-r.lon)*MK*(2+Math.sin(r.lat*MK)+Math.sin(i.lat*MK))}let n=-t/2;return n>0?n<NK:n<-NK}function ZK(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?``:WK([i],e).map(e=>GK(e,!0)).join(``)}function QK(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 $K(e,t,n=128){let r=e.lat*MK,i=e.lon*MK,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*MK,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:JG(Math.atan2(l,s)*FK),lat:Math.atan2(p,Math.hypot(s,l))*FK})}return f}var eq=24;function tq(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<=eq;t++)e.push({lon:-n+2*n*t/eq,lat:r});t.push(e)}return t}var nq=.005,rq=1.5,iq=5,aq=24,oq=class{object=new Ja;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;groundDirs=new eW;groundFanDirs=new eW;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=xG(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=VK(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]=QU(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&&nW(a,i,e);if(this.line&&(this.line.visible=!!o),this.fill&&(this.fill.visible=!!o),!a||!o)return;let s=xn(a.data),c=Q(s+(this.altitudeKm??s*nq)),l=a.orientation?SS(a.orientation,e,a.nutPrec):null,u=[o[0]-t[0],o[1]-t[1],o[2]-t[2]];if(this.line){let e=this.groundDirs.of(this.dirs,a.drawnRadii);this.place(e,this.count,l,c,u,this.scratch),$L(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.dash&&(TG(this.scratch,this.count,n,r,this.lengths),nR(this.line.geometry,this.lengths,this.count)),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()}if(this.fill){let e=this.fill.geometry.getAttribute(`position`),t=this.groundFanDirs.of(this.fanDirs,a.drawnRadii);this.place(t,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?tW(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=rR(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1,this.dash??void 0);e.frustumCulled=!1,e.renderOrder=rq,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=LG(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(aq,Math.max(1,Math.ceil(t*180/Math.PI/iq))),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]=FG(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 ns;o.setAttribute(`position`,new Wo(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new Ws(o,RG(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=rq,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()}},sq=class{object=new Ja;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?cq(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 WG({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?iW(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 cq(e){let t=new vo().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var lq=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 sq(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 uq(e,t,n,r){let i=iW(e,n,r),a=iW(t,n,r);return!i||!a?null:oW([a[0]-i[0],a[1]-i[1],a[2]-i[2]])}function dq(e,t,n,r){let i=uq(e,t,n,r);return i&&Math.hypot(...i)}function fq(e,t,n,r){let i=e.orientation?SS(e.orientation,r,e.nutPrec).toArray():[0,0,0,1],{latitude:a,longitude:o,distance:s}=BF([n[0],n[1],n[2]],[t[0],t[1],t[2]],i);return s>0?{lon:o,lat:a}:null}function pq(e,t,n){let r=t.getBody(e),i=t.getBody(ev);if(!r||!i||r===i||!r.orientation&&!t.bodies.orientationRead.has(e))return null;let a=nW(r,t,n),o=nW(i,t,n);return a&&o&&fq(r,a,o,n)}var mq=1024,hq=Math.PI*(3-Math.sqrt(5));function gq(e,t,n){let r=Math.hypot(...t.centre),i=Math.asin(Math.min(t.radiusKm/r,1));if(!(i>0))return 1;let a=t.centre.map(e=>e/r),o=e=>e[0]*a[0]+e[1]*a[1]+e[2]*a[2],s=n.filter(({centre:t,radiusKm:n})=>{let r=o(t),a=Math.sqrt(Math.max(Math.hypot(...t)**2-r**2,0));return r>-(e+n)&&a<e+n+2*i*(r+e)});if(s.length===0)return 1;let[c,l]=AG(t.centre),u=0;for(let t=0;t<mq;t++){let n=Math.sqrt((t+.5)/mq),r=e*n*Math.cos(t*hq),d=e*n*Math.sin(t*hq),f=e*Math.sqrt(1-n*n),p=1;for(let{centre:e,radiusKm:t}of s){let n=[e[0]-r*c[0]-d*l[0]-f*a[0],e[1]-r*c[1]-d*l[1]-f*a[1],e[2]-r*c[2]-d*l[2]-f*a[2]],s=Math.hypot(...n),u=Math.acos(Math.max(-1,Math.min(1,o(n)/s)));if(p*=zw(i,Math.asin(Math.min(t/s,1)),u),p===0)break}u+=p}return u/mq}var _q=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 vq(e,t){return e??t??!0}var yq=1400,bq=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(xq()?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(),yq)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function xq(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var Sq={[G.BARYCENTER]:`barycenter`,[G.LAGRANGE_POINT]:`lagrange-point`,[G.STAR]:`star`,[G.PLANET]:`planet`,[G.DWARF_PLANET]:`dwarf-planet`,[G.MOON]:`moon`,[G.ASTEROID]:`asteroid`,[G.ASTEROID_INNER]:`asteroid`,[G.ASTEROID_MAIN_BELT]:`asteroid`,[G.ASTEROID_TROJAN]:`asteroid`,[G.ASTEROID_CENTAUR]:`asteroid`,[G.ASTEROID_TNO]:`asteroid`,[G.COMET]:`comet`,[G.SPACECRAFT]:`spacecraft`,[G.DEBRIS]:`debris`,[G.UNDOCUMENTED]:`unknown`,[G.SURFACE_FEATURE]:`surface-feature`},Cq={[G.ASTEROID_INNER]:`inner`,[G.ASTEROID_MAIN_BELT]:`main-belt`,[G.ASTEROID_TROJAN]:`trojan`,[G.ASTEROID_CENTAUR]:`centaur`,[G.ASTEROID_TNO]:`tno`};function wq(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a}=e.data,o={id:t,name:n,type:Sq[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:e.position!==null},s=Cq[r];return s&&(o.orbitClass=s),o}var Tq=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],Eq=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(...Tq.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},Dq=[(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()}],Oq=.05,kq=1.15,Aq=2e3,jq=4e3,Mq=new WeakMap,Nq=new WeakMap,Pq=class{ctx=new aF;clock;initialView;#e=Ke(null);get renderer(){return Ht(this.#e)}set renderer(e){qe(this.#e,e)}#t=Ke(!1);get webglError(){return Ht(this.#t)}set webglError(e){qe(this.#t,e,!0)}#n=Ke(!1);get contextLost(){return Ht(this.#n)}set contextLost(e){qe(this.#n,e,!0)}#r=Ke();get focusedBody(){return Ht(this.#r)}set focusedBody(e){qe(this.#r,e)}attribution=null;objects=new lq(()=>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;opening=null;navigation=0;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&&tw(e.settings),this.clock=new sF(jg(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??GF,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new _q(vq(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 _q(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new uy(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),fG()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};Nq.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)Nq.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&&wq(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=hn(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&wq(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 dq(e,t,this.ctx,this.placedJd)}offsetKm(e,t){return uq(e,t,this.ctx,this.placedJd)}getSubsolarPoint(e){return pq(e,this.ctx,this.placedJd)}tilesEnabled(){return nP()}async hasTiles(e){let t=(await nS(e,!1).catch(()=>null))?.global;return!t?.map_texture_available||KA(t)===null?!1:rP(s([t.texture&&{...t.texture,id:e},...t.alternates??[]])?.tiles)&&!this.renderer?.tilesFailed(e)}load(e=this.initialView.id){return this.ctx.load(Mg(this.clock.jd),e)}open(e=this.initialView.id){return this.opening??=this.openOnce(e)}async openOnce(e){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&!this.ctx.loading&&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`),Mq.set(e,(Mq.get(e)??0)+1),this.controls=new Eq(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 bq(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 FW(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=ct(()=>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=(Mq.get(e)??1)-1;Mq.set(e,n),n===0&&e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null}watch(e){ot(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=ew();for(let n of Dq)ot(()=>n(e,t));let n=this.clock;ot(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Mg(e),playing:t,timeScale:r,direction:i,live:a})}),ot(()=>{let e=this.ctx.loading,t=LW.bootPending;this.emit(`loading`,e||t)}),ot(()=>this.emit(`progress`,jv.value)),ot(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),ot(()=>{LW.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=ew();for(let n of Dq)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&&hn(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:Sg(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)*Oq,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=kq;break;case`-`:case`_`:i=1/kq;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`)},Aq)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(jq),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};async flyTo(e){let t=this.targetBody(e);if(e.feature)return this.toFeature(t,e.feature,`frame`);let n=await this.goTo(t,{clock:`keep`,view:()=>({distance:this.framing(e,t),latitude:e.lat,longitude:e.lon})});if(n.outcome===`failed`)throw n.error;return this.settled(n.flightMs)}async goTo(e,t={}){let n=++this.navigation,r=()=>n!==this.navigation,i={outcome:`superseded`,flightMs:0},a=()=>cS(e).catch(t=>(console.warn(`[map] goTo ${e}: no coverage to read, the clock stays:`,t),[])),o=this.cameraDistance(),s,c=null,l=()=>{};if(t.clock!==`keep`){if(c=await a(),r())return i;let e=this.clock.jd,t=lS(c,e);t!==null&&t!==e&&(l=this.renderer?.holdDate()??l,this.clock.jumpTo(t),s={from:e,to:t})}let u,d,f=e=>{d??=e},p=()=>(console.warn(`[map] goTo ${e}: its data did not load:`,d),{outcome:`failed`,error:d,clockMoved:s,flightMs:0});try{await this.open(e).catch(()=>{});let t=Mg(this.clock.jd);await this.ctx.ready(t).catch(f),await this.ctx.ensureBody(e,t).catch(f),u=await this.rendering()}finally{l()}if(r())return i;let m=this.ctx.getBody(e);if(!m||!u)return d===void 0?(console.warn(`[map] goTo ${e}: not an object of this map`),{outcome:`missing`,clockMoved:s,flightMs:0}):p();let h=u.placeOf(m)!==null;if(!h&&d!==void 0){if(c??=await a(),r())return i;if(lS(c,this.clock.jd)===this.clock.jd)return p()}if(t.commit?.(m),h){let n=t.view?.(m)??{},r=n.distance??(m.data.radiusKm>0?this.framing({},e):o),i=0;switch(t.camera??`fly`){case`fly`:i=u.focusOnBody(e,r,n.latitude,n.longitude);break;case`cut`:u.snapToBody(e,n.latitude??45,n.longitude??0,r);break;case`pan`:i=u.focusOnBody(e);break;case`none`:}return{outcome:`placed`,body:m,clockMoved:s,flightMs:i}}if(u.focusOnBody(e),c??=await a(),c.length>0)return t.clock!==`keep`&&console.error(`[map] goTo ${e}: no place at jd ${this.clock.jd} (${m.unplaced}), inside its coverage`),{outcome:`unplaced`,body:m,clockMoved:s,flightMs:0};let g=this.placedAncestor(m,u);if(!g)return{outcome:`nowhere`,body:m,clockMoved:s,flightMs:0};let _=u.panCameraTo(g,this.framing({},g.data.id));return{outcome:`host`,body:m,host:g,clockMoved:s,flightMs:_}}placedAncestor(e,t){let n=new Set([e.data.id]),r=this.ctx.getBody(e.data.parentId);for(;r&&!n.has(r.data.id);){if(t.placeOf(r))return r;n.add(r.data.id),r=this.ctx.getBody(r.data.parentId)}return null}rendering(){return new Promise(e=>{let t=()=>{this.renderer?e(this.renderer):this.webglError||this.ctx.error?e(null):document.hidden?setTimeout(t,100):requestAnimationFrame(t)};t()})}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:Sg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...ry]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,ry.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?FU(n)*5:this.cameraDistance()}cameraDistance(){return 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(xn(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:oW(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 gG(e,this.requireCanvas()))}addPolyline(e){return this.track(new kG(e))}addPolygon(e){return this.track(new HG({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new UG(e))}addLabel(e){return this.track(new WG(e,this.requireCanvas()))}addIcon(e){return this.track(new GG(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new oq(e))}addSurfacePolygon(e){return this.track(new oq({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:$K(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof sq)}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)}},Fq=`http://www.w3.org/2000/svg`;function Iq(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function Lq(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function Rq(e,t){let n=document.createElementNS(Fq,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function zq(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of tq(t)){let t=JK(r,e,{stepDeg:2});t&&n.append(Rq(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(Fq,`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=ZK(e);t&&n.append(Rq(t,`sm-flat__frame`))}}}}var Bq=120;function Vq(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 PT(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,Bq))},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(Fq,`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(Fq,`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 Hq(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 Uq(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var Wq=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(Fq,`g`),Hq(this.node,t),Uq(this.node,t),this.area=n?document.createElementNS(Fq,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(Fq,`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`,JK(this.points,e,t)),this.area?.setAttribute(`d`,YK(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)}},Gq=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)}},Kq=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 Wq(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new Wq(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 Wq(QK(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 Wq($K(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 Gq(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()}},qq=Math.PI/180,Jq=1.25,Yq=17,Xq=.15,Zq=.75;function Qq(e,t,n){if(e===0)return[(t+180)/360,(90-n)/180];let r=e===1?1:-1,i=.5*Math.tan((90-r*n)*qq/2)/QT;return[.5+i*Math.cos(t*qq),.5-r*i*Math.sin(t*qq)]}function $q(e,t){return Math.ceil(Math.log2(2*Math.PI/(e*Jq*2*t)))}function eJ(e,t){return 2*Math.PI/(2*t*2**e)}function tJ(e,t,n){let[r,i]=Qq(0,t,n),a=r-Math.floor(r),o=e.max_level;for(let t of e.patches??[]){if(t.max_level<=o)continue;let e=Math.floor(a*nE(0,t.max_level)),n=Math.floor(i*rE(0,t.max_level));dE([t],t.max_level,e,n)&&(o=t.max_level)}return o}function nJ(e,t,n,r){let[i]=Qq(0,r[0],r[1]),a={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(let[t,r]of n){let[n,o]=Qq(e,t,r);if(e!==0&&(n<0||n>1||o<0||o>1))return null;let s=e===0?n-Math.round(n-i):n;a.minX=Math.min(a.minX,s),a.maxX=Math.max(a.maxX,s),a.minY=Math.min(a.minY,o),a.maxY=Math.max(a.maxY,o)}let o=(a.maxX-a.minX)/(Yq-1),s=(a.maxY-a.minY)/(Yq-1);return a.minX-=o,a.maxX+=o,a.minY-=s,a.maxY+=s,e===0&&(t.north||t.south)&&(a.minX=i-.5,a.maxX=i+.5,t.north&&(a.minY=0),t.south&&(a.maxY=1)),a}function rJ(e,t,n,r,i){let a=nE(e,t)*n,o=rE(e,t)*n,s=t=>{let n=(r.maxX-r.minX)*t,i=(r.maxY-r.minY)*t,s=Math.floor((r.minX-n)*a),c=Math.ceil((r.maxX+n)*a);e===0?c-s>a&&(s=Math.round((r.minX+r.maxX)/2*a-a/2),c=s+a):(s=Math.max(s,0),c=Math.min(c,a));let l=Math.max(Math.floor((r.minY-i)*o),0),u=Math.min(Math.ceil((r.maxY+i)*o),o);return[s,l,c,u]},[c,l,u,d]=s(i),f=s(0);return{chart:e,level:t,x0:c,y0:l,width:Math.max(u-c,1),height:Math.max(d-l,1),inner:[f[0],f[1],f[2]-1,f[3]-1]}}function iJ(e,t,n,r,i){for(let a of[i,0]){let i=rJ(e,t,n,r,a);if(i.width*i.height<=8e6)return i}}function aJ(e,t){let n=nE(0,e.max_level),r=rE(0,e.max_level),i=(e.y[1]+1)/r;if(e.y[0]/r>t.maxY||i<t.minY)return!1;let a=e.x[0]/n;a-=Math.round(a-(t.minX+t.maxX)/2);let o=a+(e.x[1]+1-e.x[0])/n;return a<=t.maxX&&o>=t.minX}function oJ(e,t,n,r=!0){let i=r?Xq:0,a=t.place(.5,.5);if(!a||!(t.step>0))return[];let o=[];for(let e=0;e<Yq;e++)for(let n=0;n<Yq;n++){let r=t.place(n/(Yq-1),e/(Yq-1));r&&o.push(r)}let s=nJ(0,t,o,a),c=$q(t.step,e.tile_size),l=[],u=e.max_level;for(let t of e.patches??[])t.max_level>u&&aJ(t,s)&&(u=t.max_level);for(let t=Math.min(c,u);t>e.max_level;t--){let n=iJ(0,t,e.tile_size,s,i);if(n){l.push(n);break}}let d=a[1]>=0?1:2,f=nJ(d,t,o,a);for(let t=Math.min(c,e.max_level);t>=n;t--){let n=iJ(0,t,e.tile_size,s,i),r=f&&t>=1?iJ(d,t,e.tile_size,f,i):void 0,a=n?n.width*n.height:1/0,o=r&&r.width*r.height<=a*Zq?r:n??r;if(o){l.push(o);break}}return l}function sJ(e,t){let n=t.tile_size,r=nE(e.chart,e.level),i=rE(e.chart,e.level),a=[],o=Math.min(Math.floor((e.y0+e.height-1)/n),i-1),s=Math.floor((e.x0+e.width-1)/n);for(let i=Math.max(Math.floor(e.y0/n),0);i<=o;i++)for(let o=Math.floor(e.x0/n);o<=s;o++){if(e.chart!==0&&(o<0||o>=r))continue;let s=(o%r+r)%r,c=e.level>t.max_level?dE(t.patches,e.level,s,i):void 0;e.level>t.max_level&&!c||a.push({cap:YT[e.chart],level:e.level,x:s,y:i,dx:o*n-e.x0,dy:i*n-e.y0,patch:c})}let c=e.width/2-n/2,l=e.height/2-n/2,u=e=>Math.hypot(e.dx-c,e.dy-l);return a.sort((e,t)=>u(e)-u(t))}function cJ(e,t,n){if(e.chart!==t.chart||e.level!==t.level)return!1;let r=0;if(t.chart===0){let i=nE(0,t.level)*n;r=i*Math.round((t.inner[0]-e.x0)/i)}return e.x0+r<=t.inner[0]&&e.x0+r+e.width>t.inner[2]&&e.y0<=t.inner[1]&&e.y0+e.height>t.inner[3]}var lJ=8;function uJ(e){return nE(e.chart,e.level)*e.tileSize}function dJ(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 fJ(e,t){let[n,r]=dJ(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 pJ=class{width;height;refU;refV;u;v;inside;caps=new Map;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=i.inverse(e.view.centerX,e.view.centerY);[this.refU,this.refV]=a?Qq(0,a[0],a[1]):[.5,.5];let o=1/e.scale,s=e.view.centerX-e.width/2*o,c=e.view.centerY+e.height/2*o;for(let r=0;r<n;r++){let n=c-(r+.5)*o,a=r*t;i.rowInverse?this.fillRow(i,a,n,s,o,e):this.walkRow(i,a,n,s,o)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s,refU:c}=this,l=(90-o.lat)/180-this.refV,{minX:u,maxX:d}=e.extent,f=d-u,p=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(p)a=((a-u)%f+f)%f+u;else if(a<u||a>d)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360-c,m=t+n;this.u[m]=s-Math.round(s),this.v[m]=l,this.inside[m]=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,l=(s[0]+180)/360-this.refU;this.u[c]=l-Math.round(l),this.v[c]=(90-s[1])/180-this.refV,this.inside[c]=1}}offsets(e){if(e===0)return{refX:this.refU,refY:this.refV,x:this.u,y:this.v};let t=this.caps.get(e);return t||(t=this.capOffsets(e),this.caps.set(e,t)),t}capOffsets(e){let{u:t,v:n,inside:r,refU:i,refV:a,width:o,height:s}=this,c=e===1?1:-1,[l,u]=Qq(e,i*360-180,90-a*180),d=new Float32Array(t.length),f=new Float32Array(t.length),p=e=>{let r=c>0?a+n[e]:1-a-n[e],o=.5*Math.tan(r*Math.PI/2)/QT,s=(i+t[e])*2*Math.PI-Math.PI;d[e]=.5+o*Math.cos(s)-l,f[e]=.5-c*o*Math.sin(s)-u},m=mJ(o),h=mJ(s);if(m.length<2||h.length<2){for(let e=0;e<t.length;e++)r[e]&&p(e);return{refX:l,refY:u,x:d,y:f}}for(let e of h)for(let t of m)r[e*o+t]&&p(e*o+t);for(let e=0;e<h.length-1;e++){let t=h[e],n=h[e+1],i=e===h.length-2?n:n-1;for(let e=0;e<m.length-1;e++){let a=m[e],s=m[e+1],c=e===m.length-2?s:s-1,l=t*o+a,u=t*o+s,h=n*o+a,g=n*o+s;if(!(r[l]&&r[u]&&r[h]&&r[g])){for(let e=t;e<=i;e++)for(let t=e*o+a;t<=e*o+c;t++)r[t]&&p(t);continue}for(let e=t;e<=i;e++){let r=(e-t)/(n-t),i=d[l]+r*(d[h]-d[l]),p=f[l]+r*(f[h]-f[l]),m=(d[u]+r*(d[g]-d[u])-i)/(s-a),_=(f[u]+r*(f[g]-f[u])-p)/(s-a),v=e===t||e===n;for(let t=a;t<=c;t++)v&&(t===a||t===s)||(d[e*o+t]=i,f[e*o+t]=p),i+=m,p+=_}}}return{refX:l,refY:u,x:d,y:f}}};function mJ(e){let t=[];for(let n=0;n<e-1;n+=lJ)t.push(n);return t.push(e-1),t}function hJ(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c,refU:l,refV:u}=e,d=i*a;for(let n of t){let{image:t,opacity:i,blend:a}=n;if(i<=0)continue;let f=t.data,p=t.width,m=t.height,h=a===`add`,g=(n.detail??[]).map(t=>{let n=e.offsets(t.chart),r=uJ(t),i=t.chart===0?r/2:r,a=n.refX*r-t.x0;return t.chart===0&&(a-=r*Math.round((a-t.width/2)/r)),{xs:n.x,ys:n.y,left:a,top:n.refY*i-t.y0,across:r,down:i,width:t.width,height:t.height,data:t.data}});for(let e=0;e<d;e++){if(!c[e])continue;let t=f,n=-1;for(let r=0;r<g.length;r++){let i=g[r],a=i.left+i.xs[e]*i.across;if(!(a>=0&&a<i.width))continue;let o=i.top+i.ys[e]*i.down;if(!(o>=0&&o<i.height))continue;let s=((o|0)*i.width+(a|0))*4;if(i.data[s+3]!==0){t=i.data,n=s;break}}if(n<0){let t=l+o[e];t-=Math.floor(t);let r=Math.floor(t*p),i=Math.floor((u+s[e])*m);r=r<0?r+p:r>=p?r-p:r,i=i<0?0:i>=m?m-1:i,n=(i*p+r)*4}let a=t[n+3]/255*i;if(a<=0)continue;let d=e*4;if(h){r[d]=Math.min(255,r[d]+t[n]*a),r[d+1]=Math.min(255,r[d+1]+t[n+1]*a),r[d+2]=Math.min(255,r[d+2]+t[n+2]*a);continue}let _=r[d+3]/255,v=a+_*(1-a);if(!(v<=0)){if(a>=1)r[d]=t[n],r[d+1]=t[n+1],r[d+2]=t[n+2];else{let e=_*(1-a);r[d]=(t[n]*a+r[d]*e)/v,r[d+1]=(t[n+1]*a+r[d+1]*e)/v,r[d+2]=(t[n+2]*a+r[d+2]*e)/v}r[d+3]=v*255}}}}function gJ(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],m=(e,t,n)=>{let r=e.createPattern(t.image,`repeat-x`);if(!r)return;r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l);let i=t.detail??[];i.length&&(e.beginPath(),e.rect(f,l,p-f,d-l),e.clip());for(let t=i.length-1;t>=0;t--){let n=i[t],r=(u-c)/uJ(n),a=c+n.x0*r,o=a+n.width*r/2;a+=(u-c)*Math.round((e.canvas.width/2-o)/(u-c)),e.drawImage(n.canvas,a,l+n.y0*r,n.width*r,n.height*r)}e.restore()};e.save();for(let t of n){if(t.opacity<=0)continue;let n=dJ(t.image);if(!n)continue;e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`;let r=t.detail?.length&&(t.opacity<1||t.blend===`add`)?vJ(e.canvas.width,e.canvas.height):null;r?(m(r,t,n),e.drawImage(r.canvas,0,0)):m(e,t,n)}e.restore()}var _J=null;function vJ(e,t){return _J??=document.createElement(`canvas`).getContext(`2d`),_J?(_J.canvas.width!==e||_J.canvas.height!==t?(_J.canvas.width=e,_J.canvas.height=t):_J.clearRect(0,0,e,t),_J):null}var yJ=[`low`,`medium`,`high`];function bJ(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function xJ(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function SJ(e){let t=await Promise.all(yJ.map(t=>fetch($t(`/v1/textures/${e}/${t}.webp`,`textures`),{method:`HEAD`}).then(e=>e.ok).catch(()=>!1)));return yJ.filter((e,n)=>t[n])}async function CJ(e,t,n=SJ){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 wJ(e){return CJ(e,(await nS(e,!1).catch(()=>null))?.global)}async function TJ(e){let t=bJ(e);if(!t)return wJ(e);let n=(await xJ(`${Kt()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return wJ(e);let r=s([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return wJ(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 EJ={low:2048,medium:8192,high:16383};function DJ(e){return yJ.find(t=>EJ[t]>=e)??yJ[yJ.length-1]}function OJ(e,t){return yJ.indexOf(e)<=yJ.indexOf(t)?e:t}function kJ(e,t){let n=yJ.indexOf(t);for(let t=n<0?yJ.length-1:n;t>=0;t--)if(e.includes(yJ[t]))return yJ[t];return e[0]??`low`}function AJ(e,t,n){let r=e.id;if(e.frames?.length){let i=YM(n,e.frames,e.coverage);if(i)return $t(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=uP(n,e.monthlyFrames);return $t(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function jJ(e,t){return e*t*4}function MJ(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var NJ=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,t=!0){let n=this.entries.get(e);n&&(n.claims=Math.max(0,n.claims-1),!t&&!n.claims&&(this.entries.delete(e),this.free(n.value)),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=MJ();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()}},PJ=new NJ(e=>e.close()),FJ=new NJ(()=>{}),IJ=new Map;function LJ(e,t){return t?`${e}@${t}`:e}async function RJ(e,t){let n=LJ(e,t),r=PJ.claim(n);if(r)return{key:n,bitmap:r};let i=IJ.get(n);if(!i){i=zJ(e,t),IJ.set(n,i);let r=()=>IJ.delete(n);i.then(r,r)}let a=await i;return a?{key:n,bitmap:PJ.put(n,a,jJ(a.width,a.height))}:null}async function zJ(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 BJ(e,t=!0){PJ.release(e,t)}function VJ(e,t,n){let r=LJ(e,t),i=FJ.claim(r);if(i)return{key:r,raster:i};let a=fJ(n,t);return a?{key:r,raster:FJ.put(r,a,jJ(a.width,a.height))}:null}function HJ(e){FJ.release(e)}var UJ=4,WJ=2,GJ=null;function KJ(e,t,n,r){let i=Math.max(n,0),a=Math.max(r,0),o=Math.min(n+t.width,e.width)-i,s=Math.min(r+t.height,e.height)-a;if(o<=0||s<=0||(GJ??=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0}),!GJ))return;(GJ.canvas.width<t.width||GJ.canvas.height<t.height)&&(GJ.canvas.width=t.width,GJ.canvas.height=t.height),GJ.globalCompositeOperation=`copy`,GJ.drawImage(t,i-n,a-r,o,s,0,0,o,s);let c=GJ.getImageData(0,0,o,s).data,l=o*4;for(let t=0;t<s;t++)e.data.set(c.subarray(t*l,(t+1)*l),((a+t)*e.width+i)*4)}var qJ=class{windows=[];kind=`pixels`;failures=0;failed=new Set;dead=!1;constructor(e,t,n){this.block=e,this.changed=t,this.moves=n}plan(e,t,n){t!==this.kind&&(this.clear(),this.kind=t);for(let e of this.windows)e.wanted=!1;for(let t of this.dead?[]:e){let e=this.windows.find(e=>e.frame===n&&cJ(e,t,this.block.tile_size));e?e.wanted=!0:this.windows.push(this.open(t,n))}this.prune()}rasters(){return this.ordered().filter(e=>!!e.data)}canvases(){return this.ordered().flatMap(e=>e.ctx?[{...e,canvas:e.ctx.canvas}]:[])}clear(){for(let e of this.windows)this.drop(e);this.windows=[]}drop(e){e.dropped=!0,e.data=void 0,e.ctx&&(e.ctx.canvas.width=0)}ordered(){return[...this.windows].sort((e,t)=>t.level-e.level||Number(t.wanted)-Number(e.wanted))}open(e,t){let n={...e,tileSize:this.block.tile_size,frame:t,pending:0,wanted:!0,dropped:!1};if(this.kind===`canvas`){let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height,n.ctx=t.getContext(`2d`)??void 0}else n.data=new Uint8ClampedArray(e.width*e.height*4);for(let r of sJ(e,this.block)){let e=r.patch?.version??(r.cap===``?fE(this.block,r.level,r.x,r.y):this.block.version),i=Yt({id:this.block.id,version:e},r.cap,r.level,r.x,r.y,t);this.failed.has(i)||(n.pending++,this.load(n,i,r.dx,r.dy))}return n}async load(e,t,n,r){try{let i=await RJ(t,null);if(i)try{e.ctx&&!e.dropped?e.ctx.drawImage(i.bitmap,n,r):e.dropped||KJ(e,i.bitmap,n,r)}finally{BJ(i.key,this.moves())}this.failures=0}catch{this.failed.add(t),++this.failures>=UJ&&(this.dead=!0)}if(e.pending--,this.dead)this.clear();else if(e.dropped)return;else e.pending===0&&this.prune();this.changed()}prune(){let e=this.windows.some(e=>e.wanted&&e.pending>0),t=this.windows.filter(e=>!e.wanted),n=e?t.slice(-WJ):[];for(let e of t)n.includes(e)||this.drop(e);this.windows=this.windows.filter(e=>!e.dropped)}};function JJ(e,t,n){return[WF(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var YJ=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 XJ(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 XJ(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function ZJ(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=QJ(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:XJ(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 QJ(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]=JJ(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 $J=[[6,`high`],[2.5,`medium`]],eY=22e5,tY=4096,nY=11,rY=.4,iY=.8,aY=140,oY=`medium`,sY=250,cY=2,lY=`naif-399`,uY=[{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 dY(e){return e.kind===`raster`}var fY=new WeakMap,pY=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(Fq,`svg`);layerGroup=document.createElementNS(Fq,`g`);shapeGroup=document.createElementNS(Fq,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;ownMaxZoom;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;tiles=new Map;plannedAt=0;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??lY,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=jK(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.ownMaxZoom=e.limits?.maxZoom===void 0,this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??jg(new Date),this.dragPan=new _q(vq(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new _q(vq(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new _q(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 Kq(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 Eq(this,this.root),this.cooperative=new bq(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)dY(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.dropTiles(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await TJ(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.dropTiles(),this.missing.clear();for(let e of this.layerList)!dY(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=a(),t=[];this.dropTiles();for(let n of uY){let r=this.sources[n.kind];if(!r)continue;let i={kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:Lq(r),tiers:r.tiers,url:(e,t)=>AJ(r,t,e)};if(t.push(i),!r.tiles)continue;let a=new qJ(r.tiles,()=>{a.dead&&(this.loadVisible(),this.emit(`layerschange`,this.layers)),this.render()},()=>this.moves());this.tiles.set(i,a)}t.push(zq(e.layer_graticule())),t.push(Vq(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(Iq)}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=[],n=n=>{e.has(n.organisation)||(e.add(n.organisation),t.push(n))};for(let e of this.layerList){if(!e.visible||!e.credit)continue;n(e.credit);let t=this.tilesOf(e);if(!t)continue;let r={...e.credit,tiles:t.block},i=kn(r);i&&n(i);for(let e of An(r))n(e)}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||!dY(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 AK}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=jK(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=jK(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.ownMaxZoom=e.maxZoom===void 0,this.render(),this}getLimits(){return this.ownMaxZoom?{...this.limits,maxZoom:this.pictureMaxZoom()}:{...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)});fY.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)fY.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){let t=$J.find(([e])=>this.view.zoom>=e)?.[1]??`low`;return this.tilesOf(e)&&(t=OJ(t,oY)),kJ(e.tiers,OJ(t,DJ(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(tY,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),EJ[e]??tY)}picturesInUse(){return this.layerList.filter(e=>dY(e)&&e.visible).map(e=>{let t=this.tier(e);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!dY(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==LJ(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 RJ(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){BJ(r.key);return}this.hold(this.bitmaps,e,r,BJ),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)||(BJ(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(HJ(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===LJ(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=VJ(e,t,r);return i?(this.hold(this.rasters,e,i,HJ),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())BJ(e.key);for(let e of this.rasters.values())HJ(e.key);this.bitmaps.clear(),this.rasters.clear()}tilesOf(e){let t=this.tiles.get(e);if(!(!t||!dY(e)||t.dead||qt()===``)&&o(t.block.distribution))return Math.max(t.block.max_level,...(t.block.patches??[]).map(e=>e.max_level))>=this.firstTileLevel(e,t)?t:void 0}firstTileLevel(e,t){let n=EJ[kJ(e.tiers,oY)]??tY,r=this.projectionId===`equirectangular`?n:Math.min(n,tY);return Math.floor(Math.log2(r/(2*t.block.tile_size)))+1}frameSample(e,t){let{width:n,height:r,projection:i}=e,a=(t,n)=>e.unproject(t,n),o=a(n/2,r/2),s=a(n/2+1,r/2),c=a(n/2,r/2+1);if(!o||!s||!c)return;let l={lon:o[0],lat:o[1]},u=Math.min(RK(l,{lon:s[0],lat:s[1]}),RK(l,{lon:c[0],lat:c[1]})),d=t=>{let a=i.azimuthal?e.project(0,t):null;return!!a&&a[0]>=0&&a[0]<=n&&a[1]>=0&&a[1]<=r};return{place:(e,t)=>a(e*n,t*r),step:u*Math.PI/180/t,north:d(90),south:d(-90)}}planTiles(e,t){let n=this.projectionId===`equirectangular`?`canvas`:`pixels`,r;for(let[i,a]of this.tiles){let o=dY(i)&&i.visible&&i.opacity>0&&this.tilesOf(i);r??=o?this.frameSample(e,t):void 0;let s=o&&r?this.firstTileLevel(i,a):0,c=o&&r?oJ(a.block,r,s,this.moves()):[];a.plan(c,n,uP(this.jd,a.block.frames))}}moves(){return this.dragPan.isEnabled()||this.scrollZoom.isEnabled()}dropTiles(){for(let e of this.tiles.values())e.clear();this.tiles.clear()}pictureMaxZoom(){let e=16,{clientWidth:t,clientHeight:n}=this.root;if(!t||!n)return e;let r=new YJ(this.projection,t,n,this.view),i=this.frameSample(r,1),a=i?.place(.5,.5);if(!i||!a)return e;for(let t of this.layerList){let n=t.visible?this.tilesOf(t):void 0;if(!n)continue;let r=eJ(tJ(n.block,a[0],a[1]),n.block.tile_size)/cY;e=Math.max(e,this.view.zoom*i.step/r)}return e}heldLimits(){return this.ownMaxZoom&&this.layerList.some(e=>e.visible&&this.tilesOf(e))?{...this.limits,maxZoom:void 0}:this.limits}tileStepDeg(e,t){let n=this.layerList.find(e=>e.id===`surface`),r=n&&this.tilesOf(n);return r?eJ(tJ(r.block,e,t),r.block.tile_size)*180/Math.PI:null}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1,i=this.limitsArmed?this.heldLimits():{};return this.view=ZJ(this.view,this.projection,n,r,i),new YJ(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()},aY),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(eY/(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 YJ(this.projection,c,l,this.view),f=performance.now();(!this.moving||f-this.plannedAt>sY)&&(this.plannedAt=f,this.planTiles(u,i)),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(nY/this.msPerPixel/e);return t>iY?1:Math.max(rY,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=>dY(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)))?.bitmap,opacity:e.opacity,blend:e.blend,detail:this.tilesOf(e)?.canvases()})).filter(e=>!!e.image);t.length&&gJ(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e)),a),opacity:e.opacity,blend:e.blend,detail:this.tilesOf(e)?.rasters()})).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 pJ(e,t,n),this.lookupKey=s),hJ(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(dY(t)||!t.visible)continue;let n=document.createElementNS(Fq,`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]=JJ((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=jK(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=this.ownMaxZoom?Math.max(this.pictureMaxZoom(),this.view.zoom):this.limits.maxZoom??1/0,a=Math.min(i,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(a===this.view.zoom)return;this.view={...this.view,zoom:a};let o=this.viewport();if(!this.projection.azimuthal){let e=o.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 mY(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 hY(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function gY(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var _Y=Math.PI/180,vY=256,yY=128,bY=.05,xY=.25;function SY(e){try{let t=document.createElement(`canvas`);t.width=vY,t.height=yY;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,vY,yY);let{data:r}=n.getImageData(0,0,vY,yY),i=new Uint8Array(vY*yY);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:vY,height:yY,covered:i}}catch{return null}}function CY(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]*_Y);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*_Y),l+=t*Math.cos(o[n]*_Y),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<bY?t.heading:wY(Math.atan2(c,l)/_Y-n.northOffsetDeg),f=wY(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*xY||(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 wY(e){return(e%360+360)%360}Math.PI/180;function TY(e){return e.orientation!==`unknown`}function EY(e){return e.id}function DY(e){return`${e.time},${e.lat},${e.lon}`}function OY(e,t){return t?e.find(e=>EY(e)===t||DY(e)===t)??null:null}var kY=1;function AY(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=i=>{for(let a=r+i;a>=0&&a<e.length;a+=i){let r=e[a];if(r.mission!==t.mission)return null;let i=MY(t,r,n);if(i>=kY)return{entry:r,distanceM:i,bearingDeg:NY(t,r)}}return null};return{previous:i(-1),next:i(1)}}var jY=Math.PI/180;function MY(e,t,n){return RK(e,t)*jY*n*1e3}function NY(e,t){let n=e.lat*jY,r=t.lat*jY,i=(t.lon-e.lon)*jY,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)/jY%360+360)%360}var PY=Math.PI/180,FY=30,IY=110,LY=85,RY=75,zY=-22,BY=9,VY=6,HY=10,UY=1,WY=new Zi(-Math.SQRT1_2,0,0,Math.SQRT1_2),GY=new J(0,0,1);function KY(e){return(e%360+360)%360}function qY(e,[t,n]){let r=KY(n-t),i=KY(e-t);return i<=r?KY(e):i-r<360-i?KY(n):KY(t)}function JY(e,t,n){return Math.max(t,Math.min(n,e))}function YY(e,t,n=new J){let r=e*PY,i=t*PY;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function XY(){let e=new kl;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 ZY=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new no;camera=new xd(RY,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new Ja;arrowGeometry=new hu(XY());raycaster=new Qd;loader=new cd;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 Aa;gyroQuaternion=new Zi;gyroScreen=new Zi;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??RY},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 Ws(new _u(500,96,48).scale(-1,1,1),new Ms({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 Th({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 Eq(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 nS(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(tS),this.radiusKm=mY(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?AY(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&&TY(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture($t(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg,!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)??OY(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?qY(t,i.heading):KY(t),pitch:JY(n,i.pitch?.[0]??-LY,i.pitch?.[1]??LY),fov:JY(r,i.fov?.[0]??FY,i.fov?.[1]??IY)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[JY(e[0],t,n),JY(e[1],t,n)];this.limits={heading:e.heading&&[KY(e.heading[0]),KY(e.heading[1])],pitch:t(e.pitch,-LY,LY),fov:t(e.fov,FY,IY)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?hY()!==`available`||!await gY()||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*PY,e.alpha*PY,-e.gamma*PY,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(WY).multiply(this.gyroScreen.setFromAxisAngle(GY,-(screen.orientation?.angle??0)*PY)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/PY,n=Math.asin(JY(this.gyroDirection.y,-1,1))/PY;this.gyroOrigin===null&&(this.gyroOrigin=KY(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=SY(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*PY)*this.camera.aspect)/PY;this.setView(CY(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=ii,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*PY,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 Ws&&e.material.dispose()});for(let t of e){let e=new Ja;e.name=t.key;let n=new Ws(this.arrowGeometry,new Ms({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new Ws(this.arrowGeometry,new Ms({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(YY(t.bearingDeg,zY)).multiplyScalar(BY),e.rotation.y=-t.bearingDeg*PY,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(YY(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+=HY)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=HY)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+=HY){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+=HY){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+=UY){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 YY(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)<VY))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())}},QY=Gx(()=>`${Kt()}/v1/groups/__planetary_systems_map__.json.gz`,{error:e=>`Failed to fetch planetary systems map: ${e.status}`}),$Y=Gx(()=>`${Kt()}/v1/groups/__solar_system_map__.json.gz`,{error:e=>`Failed to fetch solar system map: ${e.status}`}),eX=new Map;function tX(e,t,n){return .2126*e+.7152*t+.0722*n}async function nX(e,t){let n=t.strip_rows;if(n.transparency===void 0||n.color===void 0)return console.warn(`Ring strip ${e}/${t.strip} has no transparency or color row, no profile drawn:`,n),null;let r=await fetch($t(`/v1/rings/${e}/${t.strip}`,`rings`));if(!r.ok)throw Error(`${r.status} ${r.statusText}`);let i=await createImageBitmap(await r.blob()),a=document.createElement(`canvas`);a.width=i.width,a.height=i.height;let o=a.getContext(`2d`,{willReadFrequently:!0});if(!o)return console.warn(`Ring strip ${e}/${t.strip}: no 2D context, no profile drawn`),null;o.drawImage(i,0,0);let s=i.width,c=o.getImageData(0,0,s,i.height).data;i.close();let l=t.intensity_scale||1,u=new Float32Array(s),d=new Uint8ClampedArray(s*3),f=n.backscattered??n.color,p=new Float32Array(s),m=0;for(let e=0;e<s;e++){let t=(n.transparency*s+e)*4,r=(f*s+e)*4,i=Math.min(1,(1-c[t]/255)*l);u[e]=i>=1?1/0:-Math.log(1-i),p[e]=tX(c[r],c[r+1],c[r+2])/255,p[e]>m&&(m=p[e])}let h=.35;for(let e=0;e<s;e++){let t=(n.color*s+e)*4,r=m>0?h+(1-h)*(p[e]/m):1;d[e*3]=c[t]*r,d[e*3+1]=c[t+1]*r,d[e*3+2]=c[t+2]*r}return{inner:t.inner_radius_km,outer:t.outer_radius_km,tau:u,rgb:d}}async function rX(e){let t=(await nS(e,!1)).global?.rings??[];t.length||console.warn(`Ring strips for ${e}: no ring bundles on the object`);let n=[];for(let r of t)try{let t=await nX(e,r);t&&n.push(t)}catch(t){console.warn(`Ring strip ${e}/${r.strip} unavailable:`,t)}return n}var iX=-Math.log1p(-.02);function aX(e){let t=1/0,n=-1/0;for(let r of e){let e=r.tau.length,i=(r.outer-r.inner)/(e-1);for(let a=0;a<e;a++){if(r.tau[a]<iX)continue;let e=r.inner+a*i;e<t&&(t=e),e>n&&(n=e)}}return n>=t?{inner:t,outer:n}:null}function oX(e){let t=eX.get(e);return t||(t=rX(e).catch(t=>(console.warn(`Ring strips for ${e} unavailable:`,t),eX.delete(e),[])),eX.set(e,t)),t}function sX({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 cX=2.2,lX=84,uX=40,dX=4,fX=3,pX=1e4,mX=34,hX=7,gX=.42,_X=30;function vX(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 yX(e){return e>90?180-e:e}function bX(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(cX,t.radiusKm*e.pxPerKm),o=120;if(t.tiltDeg>0){let r=Math.min(yX(t.tiltDeg)*e.pxPerDeg,lX),a=120-r,s=120+r;o=vX(n,a,i)>=vX(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*gX:0,r=t.cy-Math.max(t.r,n)-dX,i=[];for(let n of[...t.satellites].sort((e,t)=>t.radiusKm-e.radiusKm)){let a=Math.max(cX,n.radiusKm*e.pxPerKm);r-=a,i.push({...n,cx:t.cx,cy:r,r:a,hitY:0,hitHeight:0}),r-=a+fX}let o=Math.min(...i.map(e=>e.cy-e.r))-hX,s=Math.max(...i.map(e=>e.cy+e.r))+hX;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-mX/2,y:o,width:mX,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,_X);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(yX(t.tiltDeg),0)*e.pxPerDeg,lX),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:uX-c,xOf:r}}function xX(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function SX(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-pX:e-r.r;s>o||(a=r,o=s)}if(a)return a}return null}function CX(e,t,n){let r=SX(e,t,n,0);if(r)return{kind:`body`,id:r.id};for(let r of e.moonZones){if(!xX(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=SX(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 wX(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 TX=`http://www.w3.org/2000/svg`,EX=10,DX=-18,OX=1.2,kX=28,AX=6,jX=4,MX=18,NX=12,PX=190;function FX(e,t={},...n){let r=document.createElementNS(TX,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 IX(e,t){return JSON.stringify(e)===JSON.stringify(t)}function LX(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 RX=0,zX=class{root=document.createElement(`div`);svg=FX(`svg`);tip=document.createElement(`div`);tipTitle=document.createElement(`span`);tipSub=document.createElement(`span`);uid=`sm-system-map-${RX++}`;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=sX({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=bX(e);let n=LX(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)=>FX(`stop`,{offset:t,"stop-color":e.primary.color,"stop-opacity":n});i.append(FX(`defs`,{},FX(`radialGradient`,{id:`${this.uid}-primary`,gradientUnits:`userSpaceOnUse`,cx:t.primaryCx,cy:120,r:t.primaryR},a(`0%`,1),a(Math.max(0,1-EX/t.primaryR),.85),a(`100%`,.35)),FX(`pattern`,{id:`${this.uid}-band`,width:9,height:9,patternUnits:`userSpaceOnUse`},FX(`circle`,{cx:2,cy:2,r:.9,fill:`currentColor`,opacity:.55}),FX(`circle`,{cx:6.5,cy:6,r:.9,fill:`currentColor`,opacity:.55})))),r||this.drawAxis(e,t),t.cloudPath&&i.append(FX(`path`,{d:t.cloudPath,stroke:e.cloud?.color,"stroke-width":OX*2,"stroke-linecap":`round`,fill:`none`,opacity:.45,"pointer-events":`none`}));for(let e of t.bands){let t=FX(`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=FX(`text`,{x:e.x+e.width/2,y:232,"text-anchor":`middle`,"font-size":MX,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,FX(`rect`,{x:e.hitX,y:26,width:e.hitWidth,height:180,fill:`transparent`}),n))}let o=FX(`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(FX(`ellipse`,{cx:e.cx,cy:e.cy,rx:t,ry:t*gX,transform:`rotate(${DX} ${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=FX(`text`,{x:r,y:16,"text-anchor":`middle`,"font-size":16,fill:`currentColor`,opacity:.85});i.textContent=String(n),this.svg.append(FX(`line`,{x1:r,x2:r,y1:20,y2:212,stroke:`currentColor`,"stroke-width":.5,opacity:.12}),i)}let n=FX(`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?FX(`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`}):FX(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color});if(this.background)return!t||!e.grouped?n:FX(`g`,{},n,...this.moonDots(t));let r={kind:`body`,id:e.id},i=this.highlight(r,FX(`circle`,{cx:e.cx,cy:e.cy,r:e.r+3.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),a=FX(`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,FX(`circle`,{cx:n.cx,cy:n.cy,r:n.r+2.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),FX(`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=>FX(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color}))}zoneWash(e){return FX(`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 FX(`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?FX(`a`,{href:e.href,"aria-label":t}):i?FX(`g`,{role:`button`,tabindex:0,"aria-label":t,class:`sm-system-map__button`}):FX(`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`,()=>{IX(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(IX(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 CX(this.placed,r,i)}fitLabels(){for(let e of this.labels){let t=0;e.setAttribute(`font-size`,String(MX));try{t=e.getComputedTextLength()}catch{}if(!t)continue;if(t>PX){let n=Math.max(NX,MX*PX/t);e.setAttribute(`font-size`,String(n)),t*=n/MX}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+jX),Math.max(r,720-r-jX));e.setAttribute(`x`,String(i))}}placeTip(){let e=this.model&&this.placed&&!this.background?wX(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*AX)}px`;let r=this.tip.offsetWidth/2,i=Math.min(Math.max(e.cx*n,r+AX),Math.max(r,t-r-AX));this.tip.style.left=`${i}px`,this.tip.style.top=`${Math.max(4,e.cy*n-kX)}px`}};function BX(e,t){return{planetId:e.primary.id,planetName:t,planetRadiusKm:e.primary.radius_km,planetColor:W_[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:W_[e.id]??e.color??`#cccccc`})),rings:e.rings?{innerRp:e.rings.inner_rp,outerRp:e.rings.outer_rp}:null,moonCount:e.moon_count}}function VX(e,t){if(!e.rings||!t.length)return e.rings;let n=aX(t),r=e.planetRadiusKm;return n&&{innerRp:n.inner/r,outerRp:n.outer/r}}var HX=14,UX=1.001,WX=.62,GX=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,5e3],KX=`0 96 320 144`,qX=`0 96 720 144`,JX=[1,100];function YX(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)?JX:(r<=n&&(n/=2,r*=2),n=n<=UX?1:n,[n>1?10**(Math.log10(n)-.12):1,10**(Math.log10(r)+.12)])}function XX(e,t){let n=e.planetRadiusKm,r=YX(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:GX.filter(e=>e>=r[0]&&e<=r[1]),axisLabel:t.axisLabel,pxPerKm:HX/Math.max(...e.moons.map(e=>e.radiusKm).filter(e=>e>0),1),pxPerDeg:WX,text:t.text,backgroundView:t.wide?qX:KX,backgroundFit:t.wide?`fit`:`slice`}}var ZX=224e-6,QX=1.8,$X=[.3,50],eZ=[.3,1,3,10,30],tZ=`#ffdd44`;function nZ(e){let t=e.replace(/^\d+\s+/,``);return t===t.toUpperCase()&&/[A-Z]/.test(t)?t.charAt(0)+t.slice(1).toLowerCase():t}function rZ(e){return e.color||W_[e.id]||`#cccccc`}function iZ(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:rZ(i)}),e.tab||=!!i.link_parent,n.set(i.parent,e)}return n}function aZ(e,t){let n=e.objects.find(e=>e.kind===`star`);if(!n)return null;let r=iZ(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*vg,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:rZ(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:tZ,link:t.primaryLink},bodies:a,bands:e.belts.map(e=>({key:e.slug,innerKm:e.inner_au*vg,outerKm:e.outer_au*vg,tone:e.kind===`kuiper_belt`?`sky`:`muted`,...t.band(e)})),unitKm:vg,domain:$X,ticks:eZ,axisLabel:t.text.axisAu,pxPerKm:ZX,pxPerDeg:QX,text:t.text}}function oZ(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??W_[e.id]??`#cccccc`,parent:e.parent}}var sZ=4,cZ=10,lZ={inner:[.6,5.5],outer:[4.5,55]},uZ=[.1,.2,.3,.5,1,2,3,5,10,20,30,50,100,200,500,1e3],dZ=.9,fZ=.76;function pZ(e,t){return Math.log(e/t[0])/Math.log(t[1]/t[0])}var mZ=`naif-599`;function hZ(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 gZ(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:nZ(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:W_[e.id]??e.sbdb?.color??e.color??`#cccccc`,parent:e.orbit?.parent_id}}var _Z=.92;function vZ(e,t){return e<t*_Z?`inner`:`outer`}function yZ(e,t){return Object.values(e).find(e=>e.primary.id===t)}function bZ(e){return e.kind===`zone`?`zone:${e.zone}`:`${e.kind}:${e.id}`}var xZ=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?nZ(t):e)}named(e,t){return this.options.names[e]??t}link(e){return this.targets.set(bZ(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=(yZ(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:W_[e.id]??e.color??`#cccccc`}));if(n.length)return n.sort((e,t)=>t.radiusKm-e.radiusKm),{satellites:n.slice(0,sZ),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 SZ(e,t,n,r){let i=new xZ(e,t,r),a=e=>i.name(e.id,e.name),o=iZ(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=aZ(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 CZ(e,t,n,r,i,a){let o=yZ(e.systems,t);if(!o)throw Error(`spacemap: no planetary system around ${t}`);let s=new xZ(e,r,a),c=BX(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=e.ringProfiles?VX(c,e.ringProfiles):c.rings,d=u?[{key:`rings`,label:i.rings,innerKm:u.innerRp*l,outerKm:u.outerRp*l,tone:`amber`}]:[],f=XX(c,{text:i,axisLabel:i.axisRadii,bands:d,primaryLink:s.body(t,c.planetName),moonLink:e=>s.body(e.id,e.name)});return f.ticks=f.ticks.filter(e=>pZ(e,f.domain)<fZ),s.built(f,c.planetName)}function wZ(e,t,n,r,i){let a=new xZ(e,n,i),{solar:o,extras:s}=e,c=o.objects.find(e=>e.kind===`star`),l=o.objects.find(e=>e.id===mZ)?.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:rZ(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(vZ(e.aAu,l)!==t)continue;let n={...e,aKm:e.aAu*vg},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]=lZ[t],m=[Math.min(f,...d.map(e=>e.aKm/vg*.85)),Math.max(p,...d.map(e=>e.aKm/vg*1.15))],h=e=>e>=m[0]&&e<=m[1],g=cZ/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*vg,tiltDeg:0,radiusKm:0,color:rZ(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*ZX/g,color:tZ},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*vg,outerKm:e.outer_au*vg,tone:e.kind===`kuiper_belt`?`sky`:`muted`})),unitKm:vg,domain:m,ticks:uZ.filter(e=>h(e)&&pZ(e,m)<dZ),axisLabel:r.axisAu,pxPerKm:g,pxPerDeg:QX,text:r},_)}var TZ=new WeakMap,EZ=.01;function DZ(){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/vg;return t>0&&t<EZ?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 OZ=class{chart=new zX;listeners=new Map;view;bodies;names;grouping;zones;rings;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.rings=e.rings??`all`,this.places=(e.places??[]).map(oZ)}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([$Y(),QY()]),r={bodies:this.bodies,names:this.names,grouping:this.grouping,zones:this.zones},i=DZ(),a=e=>this.emit(`select`,e),o={solar:t,systems:n,extras:[]};switch(e.kind){case`solar-system`:return SZ(o,r,i,a);case`system`:{let t=this.rings===`visible`&&!!yZ(n,e.id)?.rings,[s,c]=await Promise.all([this.exportedNames(e.id,n),t?oX(e.id):void 0]);return CZ({...o,ringProfiles:c},e.id,s,r,i,a)}case`zone`:{let s=hZ(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=hZ(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 wZ({...o,extras:f},e.zone,r,i,a)}}}extra(e){let t=this.extras.get(e);return t||(t=nS(e,!1).then(t=>{if(!t.global)throw Error(`spacemap: no such body as ${e}`);return gZ(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,...(yZ(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 nS(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)});TZ.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)TZ.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}};function kZ(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 AZ(e){let t=e.credits,n=new Set;for(let r of En){if(!t.orbitSources.has(r))continue;let{archive:i,scoped:a}=Tn[r];if(!(a&&!kZ(e,r)))if(i)n.add(i);else for(let e of ln)e&&t.probeArchives.has(e)&&n.add(e)}return[...n]}function jZ(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function MZ(e,t=Dn){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(AZ(e).map(e=>t[e]))],i=new Set;for(let t of jZ(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 NZ=`https://spacemap.co`,PZ=`https://spacemap.co/credits`;function FZ(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function IZ(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function LZ(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 RZ=class{stop=null;onAdd(e){let t=FZ(),n=IZ(),r=IZ();return t.append(LZ(NZ,`spacemap`,`sm-attribution__home`),n,r,LZ(PZ,a().messages.credits_see_all())),this.stop=ct(()=>{ot(()=>{let t=MZ(e.ctx);zZ(n,a().messages.attribution_orbits(),t.orbits),zZ(r,a().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function zZ(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 BZ=class{off=null;onAdd(e){let t=FZ(),n=IZ();t.append(LZ(NZ,`spacemap`,`sm-attribution__home`),n,LZ(PZ,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 VZ(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 HZ=class{off=null;onAdd(e){let t=FZ(),n=IZ();t.append(LZ(NZ,`spacemap`,`sm-attribution__home`),n,LZ(PZ,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=VZ(t.credit_url),o=i?LZ(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`}};function UZ(e){return e}function WZ(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>qZ(t,e)}}function GZ(e){return{body:e.body??`naif-10`,offsetKm:t=>_B(e.elements,t)?.r??null}}function KZ(e,t){let n=gg(e,t);return n.error!==pg.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:tv,offsetKm:e=>{if(n.error!==pg.None)return null;let t=a_(n,e);return t&&t_(t[0],t[1],t[2],e)}}}function qZ(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=JZ(e,a-1,t),l=JZ(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function JZ(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 YZ(e){return e/vg}var XZ=null,ZZ=Promise.resolve();function QZ(e){let t=ZZ.then(e,e);return ZZ=t.catch(()=>{}),t}async function $Z(e){let t=jg(e),n=await _x();if(!XZ){let e=vx(n);e.size>0&&(XZ=new jx(e))}return await XZ?.load(t),{jd:t,metadata:n,chebyshev:XZ}}function eQ(e,t){return!(e!==void 0&&t-2451545<e)}async function tQ(e,{jd:t,metadata:n}){let r=n.position.zones.moons,i=r&&cx(r);if(!i)return null;let a=await Vb(`moons`,null,0,nx(i)?String(ix(i,t)):null);for(let t=0;t<a.rowCount;t++)if(Ih(a,t)===e)return H_(a,t,new Map,`naif`);return null}function nQ(e,t){return!eQ(e.visibleFromDays,t)||!TV(e,t)?null:e.satrec?s_(e.satrec,t):e.q==null?e.a===0?[0,0,0]:C_(e,t):w_(e,t)}async function rQ(e,t){let{jd:n}=t;if(t.chebyshev?.has(e)){let r=t.chebyshev.body(e,n);if(r&&!eQ(r.visibleFromDays,n))return null;let i=r&&Gy(r,n);if(i){let{radiusKm:e,objectType:t}=r;return{data:{radiusKm:e,objectType:t,orbitalSource:W.SPICE},parentId:`naif-${r.parentId}`,offset:i}}if(e.startsWith(`naif-`))return null}let r=(e.startsWith(`naif-`)?await tQ(e,t):null)??mS(e,await nS(e,!1)),i=r&&nQ(r,n);return i?{data:r,parentId:r.parentId,offset:i}:null}async function iQ(e,t,n=new Set){if(n.has(e))return null;let r=await rQ(e,t);if(!r)return null;if(r.parentId===`naif-0`)return{data:r.data,centre:r.offset,parents:[]};let i=await iQ(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]],parents:[r.parentId,...i.parents]}}function aQ(e,{parents:t},n){let r=new Set(t);for(let{body:e}of n.chebyshev?.bodiesAt(n.jd)??[])t.includes(`naif-${e.parentId}`)&&r.add(e.id);return r.delete(e),[...r]}async function oQ(e){let[t]=await Promise.all([nS(e,!1),Rv()]);return{orientation:t.global?.orientation,nutPrec:zv(e,t.global?.nut_prec)}}async function sQ(e,t){let n=await iQ(e.body,t);if(!n)return null;let r=`latitude`in e?await oQ(e.body):{};return rW(e,{data:n.data,...r},n.centre,t.jd)}function cQ(e,t,n){return QZ(async()=>{let r=await $Z(n),i=await sQ(e,r),a=i&&await sQ(t,r);return i&&a?oW([a[0]-i[0],a[1]-i[1],a[2]-i[2]]):null})}async function lQ(e,t,n){let r=await cQ(e,t,n);return r&&Math.hypot(...r)}function uQ(e,t){return QZ(async()=>{if(e===`naif-10`)return null;let n=await $Z(t),r=await iQ(e,n),i=r&&await iQ(`naif-10`,n);return!r||!i?null:fq({data:r.data,...await oQ(e)},r.centre,i.centre,n.jd)})}function dQ(e,t){return QZ(async()=>{if(e===`naif-10`)return null;let n=await $Z(t),r=await iQ(e,n),i=r&&await iQ(`naif-10`,n);if(!r||!i)return null;let a=({data:e,centre:t})=>({centre:oW([t[0]-r.centre[0],t[1]-r.centre[1],t[2]-r.centre[2]]),radiusKm:e.radiusKm}),o=[];for(let t of aQ(e,r,n)){let e=await iQ(t,n);e&&e.data.radiusKm>0&&o.push(a(e))}return gq(r.data.radiusKm>0?r.data.radiusKm:0,a(i),o)})}var fQ=null;function pQ(e=Pv){return fQ||(fQ=(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??[]})(),fQ.catch(()=>fQ=null),fQ)}async function mQ(e){return(await nS(e,!1)).global?.panoramas??[]}async function hQ(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,controls:l,events:u,...d}=e,f=yQ(t);bQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let p=new Pq(d);if(p.mount(f),p.webglError)throw p.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(u??{}))p.on(e,t);p.attribution=new RZ,p.addControl(p.attribution);for(let e of l??[])p.addControl(e);return await p.open(),p.applyInitialView(),await pG(),p}async function gQ(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,controls:l,events:u,...d}=e,f=yQ(t);bQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let p=new pY(d);p.mount(f);for(let[e,t]of Object.entries(u??{}))p.on(e,t);p.attribution=new BZ,p.addControl(p.attribution);for(let e of l??[])p.addControl(e);return await p.load(),p}async function _Q(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,controls:l,events:u,...d}=e,f=yQ(t);bQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let p=new ZY(d);p.mount(f);for(let[e,t]of Object.entries(u??{}))p.on(e,t);p.attribution=new HZ,p.addControl(p.attribution);for(let e of l??[])p.addControl(e);return await p.load(),p}async function vQ(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,events:l,...u}=e,d=yQ(t);bQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let f=new OZ(u);f.mount(d);for(let[e,t]of Object.entries(l??{}))f.on(e,t);try{await f.load()}catch(e){throw f.remove(),e}return f}function yQ(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 bQ(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.liveUrl!==void 0&&(t.liveUrl=e.liveUrl),e.tilesUrl!==void 0&&(t.tilesUrl=e.tilesUrl),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=RZ,e.FlatAttributionControl=BZ,e.FlatMap=pY,e.GestureHandler=_q,e.MAP_LAYERS=ry,e.PROJECTION_IDS=AK,e.PanoramaAttributionControl=HZ,e.PanoramaView=ZY,e.SpaceMap=Pq,e.SystemMap=OZ,e.Viewport=YJ,e.bearingDeg=NY,e.boxRing=QK,e.circlePoints=MG,e.configureHost=i,e.createFlatMap=gQ,e.createMap=hQ,e.createPanorama=_Q,e.createProjection=jK,e.createSystemMap=vQ,e.dateToJD=jg,e.defaultSceneSettings=QC,e.distanceKm=lQ,e.elements=GZ,e.fetchPanoramaIndex=pQ,e.fetchPanoramas=mQ,e.findPanorama=OY,e.fixed=UZ,e.graticule=tq,e.groundDistanceM=MY,e.isViewable=tS,e.jdToDate=Mg,e.kmToAu=YZ,e.neighboursOf=AY,e.offsetKm=cQ,e.panoramaAt=EY,e.pathFor=JK,e.planeBasis=AG,e.projectionAspect=XG,e.samples=WZ,e.smallCircle=$K,e.subsolarPoint=uQ,e.sunlight=dQ,e.tle=KZ,e})({});
6383
+ `})}var tK=.25,nK=1e-9,rK=3,iK=class{object=new Ja;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??tK,this.outline=t>0?new GG({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?xW(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])>nK||Math.abs(s[1]-this.lastOrigin[1])>nK||Math.abs(s[2]-this.lastOrigin[2])>nK){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=YG(e);if(!n.length)return;let r=new ns;r.setAttribute(`position`,new Wo(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new Ws(r,eK(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=rK,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()}},aK=class extends iK{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:JG(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(JG(e,{normal:this.normal,steps:this.steps}))}},oK=class extends MG{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}},sK=class extends MG{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}},cK=Math.PI/180,lK=180/Math.PI;function uK(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function dK(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[uK(n*i.lonPerX+t),i.lat]}}function fK(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function pK(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 mK(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*lK,lonPerX:lK,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)=>[uK(e-t)*cK,n*cK],rowInverse:n,inverse:dK(n,t)}}var hK=1.340264,gK=-.081106,_K=893e-6,vK=.003796,yK=Math.sqrt(3),bK=e=>vK*e**9+_K*e**7+gK*e**3+hK*e,xK=e=>9*vK*e**8+7*_K*e**6+3*gK*e**2+hK;function SK(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(RK(yK/2*Math.sin(n*cK))),i=uK(e-t)*cK;return[2*yK*i*Math.cos(r)/(3*xK(r)),bK(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(bK(t)-e)/xK(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/yK*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*xK(t)/(2*yK*Math.cos(t))*lK;return{lat:Math.asin(n)*lK,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:pK(n),forward:n,rowInverse:i,inverse:dK(i,t)}}var CK=Math.SQRT2;function wK(e){let t=e.centerLon??0,n=e=>{let t=e/CK;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*CK*i)*lK;return{lat:Math.asin(r)*lK,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*CK,minY:-CK,maxX:2*CK,maxY:CK},forward:(e,n)=>{let r=n*cK,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=uK(e-t)*cK;return[2*CK/Math.PI*a*Math.cos(i),CK*Math.sin(i)]},rowInverse:n,inverse:dK(n,t)}}function TK(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*lK,lonPerX:lK/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*cK;return[uK(e-t)*cK*Math.cos(r),r]},rowInverse:n,inverse:dK(n,t)}}var EK=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],DK=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],OK=.8487,kK=1.3523,AK=5;function jK(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 MK=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),NK=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function PK(e){let t=Math.min(Math.max(Math.floor(e),0),EK.length-2);return[t,e-t]}function FK(e){let[t,n]=PK(e);return OK*MK(jK(EK,t),n)*Math.PI}function IK(e){let t=0,n=DK.length-1;for(;n-t>1;){let r=t+n>>1;DK[r]<=e?t=r:n=r}let r=Math.min(t,DK.length-2),i=jK(DK,r),a=(e-DK[r])/(DK[r+1]-DK[r]);for(let t=0;t<8;t++){let t=NK(i,a);if(t===0)break;let n=(MK(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function LK(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/kK;if(t>1)return null;let n=IK(t),r=FK(n);return{lat:Math.sign(e)*n*AK,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-OK*Math.PI,minY:-kK,maxX:OK*Math.PI,maxY:kK},forward:(e,n)=>{let[r,i]=PK(Math.abs(n)/AK),a=MK(jK(EK,r),i),o=MK(jK(DK,r),i);return[OK*a*uK(e-t)*cK,kK*o*Math.sign(n)]},rowInverse:n,inverse:dK(n,t)}}function RK(e){return e<-1?-1:e>1?1:e}function zK(e,t,n,r,i,a,o){let s=Math.asin(RK(n*a+t*r*o));return[uK(i+Math.atan2(e*r,n*o-t*r*a)*lK),s*lK]}function BK(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function VK(e,t,n,r){let i=uK(e-n)*cK,a=t*cK;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function HK(e){let t=e.centerLon??0,n=(e.centerLat??0)*cK,r=Math.min(e.clipAngle??90,90)*cK,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:BK(a),forward:(e,r)=>{let a=uK(e-t)*cK,o=r*cK;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:VK(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:zK(e,n,Math.sqrt(1-r),1,t,o,s)}}}var UK=120;function WK(e){let t=e.centerLon??0,n=(e.centerLat??90)*cK,r=Math.min(e.clipAngle??UK,170)*cK,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:BK(a),forward:(e,r)=>{let a=uK(e-t)*cK,o=r*cK,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]=VK(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 zK(e,n,(4-r)*i*.25,i,t,o,s)}}}var GK={equirectangular:mK,equalEarth:SK,mollweide:wK,sinusoidal:TK,robinson:LK,orthographic:HK,stereographic:WK},KK=Object.keys(GK);function qK(e,t={}){let n=GK[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var JK=Math.PI/180,YK=2*Math.PI,XK=2*JK,ZK=180/Math.PI,QK=512,$K=2;function eq(e,t){let n=e.lat*JK,r=t.lat*JK,i=r-n,a=uK(t.lon-e.lon)*JK,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)))*ZK}function tq(e,t,n){let r=eq(e,t)*JK;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*JK,c=e.lon*JK,l=t.lat*JK,u=(e.lon+uK(t.lon-e.lon))*JK,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)*ZK,lat:Math.atan2(p,Math.hypot(d,f))*ZK}}function nq(e,t,n){return{lon:e.lon+uK(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function rq(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??$K,i=n===`geodesic`?tq:nq,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(QK,Math.max(1,Math.ceil(eq(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function iq(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=nq(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return nq(e,t,r)}function aq(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=iq(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=iq(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 oq(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 sq(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 cq=179.999999;function lq(e,t){let n=e=>e>cq?cq:e<-cq?-cq:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=uK(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=uK(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*cq,lat:e}),i.push(a),a=[{lon:-d*cq,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 uq(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?lq(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=aq(rq(e,n),t),a=!!n.closed&&i;return oq(r,t).map(e=>sq(e,a)).join(``)}).join(``)}function dq(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return uq(e,t,{...n,closed:!0});if(e.length<2)return``;let i=rq(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 sq(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=iq(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=iq(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=fq(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)%YK+YK)%YK;n<a&&(a=n,i=e)}let o=Math.ceil(a/XK);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=>sq(e.map(s),!0)).join(``)}function fq(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=uK(i.lon-r.lon)*JK*(2+Math.sin(r.lat*JK)+Math.sin(i.lat*JK))}let n=-t/2;return n>0?n<YK:n<-YK}function pq(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?``:oq([i],e).map(e=>sq(e,!0)).join(``)}function mq(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 hq(e,t,n=128){let r=e.lat*JK,i=e.lon*JK,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*JK,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:uK(Math.atan2(l,s)*ZK),lat:Math.atan2(p,Math.hypot(s,l))*ZK})}return f}var gq=24;function _q(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<=gq;t++)e.push({lon:-n+2*n*t/gq,lat:r});t.push(e)}return t}var vq=.005,yq=1.5,bq=5,xq=24,Sq=class{object=new Ja;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;groundDirs=new _W;groundFanDirs=new _W;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=LG(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=rq(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]=hW(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&&yW(a,i,e);if(this.line&&(this.line.visible=!!o),this.fill&&(this.fill.visible=!!o),!a||!o)return;let s=xn(a.data),c=Q(s+(this.altitudeKm??s*vq)),l=a.orientation?SS(a.orientation,e,a.nutPrec):null,u=[o[0]-t[0],o[1]-t[1],o[2]-t[2]];if(this.line){let e=this.groundDirs.of(this.dirs,a.drawnRadii);this.place(e,this.count,l,c,u,this.scratch),dR(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.dash&&(VG(this.scratch,this.count,n,r,this.lengths),mR(this.line.geometry,this.lengths,this.count)),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()}if(this.fill){let e=this.fill.geometry.getAttribute(`position`),t=this.groundFanDirs.of(this.fanDirs,a.drawnRadii);this.place(t,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?vW(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=hR(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1,this.dash??void 0);e.frustumCulled=!1,e.renderOrder=yq,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=$G(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(xq,Math.max(1,Math.ceil(t*180/Math.PI/bq))),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]=ZG(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 ns;o.setAttribute(`position`,new Wo(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new Ws(o,eK(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=yq,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()}},Cq=class{object=new Ja;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?wq(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 oK({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?xW(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 wq(e){let t=new vo().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var Tq=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 Cq(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 Eq(e,t,n,r){let i=xW(e,n,r),a=xW(t,n,r);return!i||!a?null:CW([a[0]-i[0],a[1]-i[1],a[2]-i[2]])}function Dq(e,t,n,r){let i=Eq(e,t,n,r);return i&&Math.hypot(...i)}function Oq(e,t,n,r){let i=e.orientation?SS(e.orientation,r,e.nutPrec).toArray():[0,0,0,1],{latitude:a,longitude:o,distance:s}=QF([n[0],n[1],n[2]],[t[0],t[1],t[2]],i);return s>0?{lon:o,lat:a}:null}function kq(e,t,n){let r=t.getBody(e),i=t.getBody(ev);if(!r||!i||r===i||!r.orientation&&!t.bodies.orientationRead.has(e))return null;let a=yW(r,t,n),o=yW(i,t,n);return a&&o&&Oq(r,a,o,n)}var Aq=1024,jq=Math.PI*(3-Math.sqrt(5));function Mq(e,t,n){let r=Math.hypot(...t.centre),i=Math.asin(Math.min(t.radiusKm/r,1));if(!(i>0))return 1;let a=t.centre.map(e=>e/r),o=e=>e[0]*a[0]+e[1]*a[1]+e[2]*a[2],s=n.filter(({centre:t,radiusKm:n})=>{let r=o(t),a=Math.sqrt(Math.max(Math.hypot(...t)**2-r**2,0));return r>-(e+n)&&a<e+n+2*i*(r+e)});if(s.length===0)return 1;let[c,l]=KG(t.centre),u=0;for(let t=0;t<Aq;t++){let n=Math.sqrt((t+.5)/Aq),r=e*n*Math.cos(t*jq),d=e*n*Math.sin(t*jq),f=e*Math.sqrt(1-n*n),p=1;for(let{centre:e,radiusKm:t}of s){let n=[e[0]-r*c[0]-d*l[0]-f*a[0],e[1]-r*c[1]-d*l[1]-f*a[1],e[2]-r*c[2]-d*l[2]-f*a[2]],s=Math.hypot(...n),u=Math.acos(Math.max(-1,Math.min(1,o(n)/s)));if(p*=Yw(i,Math.asin(Math.min(t/s,1)),u),p===0)break}u+=p}return u/Aq}var Nq=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 Pq(e,t){return e??t??!0}var Fq=1400,Iq=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(Lq()?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(),Fq)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function Lq(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var Rq={[G.BARYCENTER]:`barycenter`,[G.LAGRANGE_POINT]:`lagrange-point`,[G.STAR]:`star`,[G.PLANET]:`planet`,[G.DWARF_PLANET]:`dwarf-planet`,[G.MOON]:`moon`,[G.ASTEROID]:`asteroid`,[G.ASTEROID_INNER]:`asteroid`,[G.ASTEROID_MAIN_BELT]:`asteroid`,[G.ASTEROID_TROJAN]:`asteroid`,[G.ASTEROID_CENTAUR]:`asteroid`,[G.ASTEROID_TNO]:`asteroid`,[G.COMET]:`comet`,[G.SPACECRAFT]:`spacecraft`,[G.DEBRIS]:`debris`,[G.UNDOCUMENTED]:`unknown`,[G.SURFACE_FEATURE]:`surface-feature`},zq={[G.ASTEROID_INNER]:`inner`,[G.ASTEROID_MAIN_BELT]:`main-belt`,[G.ASTEROID_TROJAN]:`trojan`,[G.ASTEROID_CENTAUR]:`centaur`,[G.ASTEROID_TNO]:`tno`};function Bq(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a}=e.data,o={id:t,name:n,type:Rq[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:e.position!==null},s=zq[r];return s&&(o.orbitClass=s),o}var Vq=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],Hq=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(...Vq.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},Uq=[(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()}],Wq=.05,Gq=1.15,Kq=2e3,qq=4e3,Jq=new WeakMap,Yq=new WeakMap,Xq=class{ctx=new _F;clock;initialView;#e=Ke(null);get renderer(){return Ht(this.#e)}set renderer(e){qe(this.#e,e)}#t=Ke(!1);get webglError(){return Ht(this.#t)}set webglError(e){qe(this.#t,e,!0)}#n=Ke(!1);get contextLost(){return Ht(this.#n)}set contextLost(e){qe(this.#n,e,!0)}#r=Ke();get focusedBody(){return Ht(this.#r)}set focusedBody(e){qe(this.#r,e)}attribution=null;objects=new Tq(()=>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;opening=null;navigation=0;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,idle:new Set,error:new Set,datastale:new Set,notice:new Set,noticedismiss:new Set,layerschange:new Set,frame:new Set};constructor(e={}){e.settings&&dw(e.settings),this.clock=new yF(jg(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??rI,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new Nq(Pq(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 Nq(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new uy(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),OG()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};Yq.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)Yq.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&&Bq(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=hn(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&Bq(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 Dq(e,t,this.ctx,this.placedJd)}offsetKm(e,t){return Eq(e,t,this.ctx,this.placedJd)}getSubsolarPoint(e){return kq(e,this.ctx,this.placedJd)}tilesEnabled(){return mP()}async hasTiles(e){let t=(await nS(e,!1).catch(()=>null))?.global;return!t?.map_texture_available||rj(t)===null?!1:hP(s([t.texture&&{...t.texture,id:e},...t.alternates??[]])?.tiles)&&!this.renderer?.tilesFailed(e)}load(e=this.initialView.id){return this.ctx.load(Mg(this.clock.jd),e)}open(e=this.initialView.id){return this.opening??=this.openOnce(e)}async openOnce(e){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&!this.ctx.loading&&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`),Jq.set(e,(Jq.get(e)??0)+1),this.controls=new Hq(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 Iq(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 QW(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=ct(()=>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=(Jq.get(e)??1)-1;Jq.set(e,n),n===0&&e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null}watch(e){ot(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=uw();for(let n of Uq)ot(()=>n(e,t));let n=this.clock;ot(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Mg(e),playing:t,timeScale:r,direction:i,live:a})}),ot(()=>{let e=this.ctx.loading,t=PU.bootPending;this.emit(`loading`,e||t)}),ot(()=>this.emit(`progress`,jv.value)),ot(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),ot(()=>{PU.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=uw();for(let n of Uq)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&&hn(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})},onIdle:()=>this.emit(`idle`),onCameraPosition:(e,t,n)=>{let r=this.focusedBody?.data.id;r!==void 0&&this.emit(`camera`,{body:r,lat:e,lon:t,distanceKm:Sg(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)*Wq,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=Gq;break;case`-`:case`_`:i=1/Gq;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`)},Kq)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(qq),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};async flyTo(e){let t=this.targetBody(e);if(e.feature)return this.toFeature(t,e.feature,`frame`);let n=await this.goTo(t,{clock:`keep`,view:()=>({distance:this.framing(e,t),latitude:e.lat,longitude:e.lon})});if(n.outcome===`failed`)throw n.error;return this.settled(n.flightMs)}async goTo(e,t={}){let n=++this.navigation,r=()=>n!==this.navigation,i={outcome:`superseded`,flightMs:0},a=()=>cS(e).catch(t=>(console.warn(`[map] goTo ${e}: no coverage to read, the clock stays:`,t),[])),o=this.cameraDistance(),s,c=null,l=()=>{};if(t.clock!==`keep`){if(c=await a(),r())return i;let e=this.clock.jd,t=lS(c,e);t!==null&&t!==e&&(l=this.renderer?.holdDate()??l,this.clock.jumpTo(t),s={from:e,to:t})}let u,d,f=e=>{d??=e},p=()=>(console.warn(`[map] goTo ${e}: its data did not load:`,d),{outcome:`failed`,error:d,clockMoved:s,flightMs:0});try{await this.open(e).catch(()=>{});let t=Mg(this.clock.jd);await this.ctx.ready(t).catch(f),await this.ctx.ensureBody(e,t).catch(f),u=await this.rendering()}finally{l()}if(r())return i;let m=this.ctx.getBody(e);if(!m||!u)return d===void 0?(console.warn(`[map] goTo ${e}: not an object of this map`),{outcome:`missing`,clockMoved:s,flightMs:0}):p();let h=u.placeOf(m)!==null;if(!h&&d!==void 0){if(c??=await a(),r())return i;if(lS(c,this.clock.jd)===this.clock.jd)return p()}if(t.commit?.(m),h){let n=t.view?.(m)??{},r=n.distance??(m.data.radiusKm>0?this.framing({},e):o),i=0;switch(t.camera??`fly`){case`fly`:i=u.focusOnBody(e,r,n.latitude,n.longitude);break;case`cut`:u.snapToBody(e,n.latitude??45,n.longitude??0,r);break;case`pan`:i=u.focusOnBody(e);break;case`none`:}return{outcome:`placed`,body:m,clockMoved:s,flightMs:i}}if(u.focusOnBody(e),c??=await a(),c.length>0)return t.clock!==`keep`&&console.error(`[map] goTo ${e}: no place at jd ${this.clock.jd} (${m.unplaced}), inside its coverage`),{outcome:`unplaced`,body:m,clockMoved:s,flightMs:0};let g=this.placedAncestor(m,u);if(!g)return{outcome:`nowhere`,body:m,clockMoved:s,flightMs:0};let _=u.panCameraTo(g,this.framing({},g.data.id));return{outcome:`host`,body:m,host:g,clockMoved:s,flightMs:_}}placedAncestor(e,t){let n=new Set([e.data.id]),r=this.ctx.getBody(e.data.parentId);for(;r&&!n.has(r.data.id);){if(t.placeOf(r))return r;n.add(r.data.id),r=this.ctx.getBody(r.data.parentId)}return null}rendering(){return new Promise(e=>{let t=()=>{this.renderer?e(this.renderer):this.webglError||this.ctx.error?e(null):document.hidden?setTimeout(t,100):requestAnimationFrame(t)};t()})}panTo(e){return this.toFeature(this.targetBody(e),e.feature,`pan`)}async jumpTo(e){let t=this.targetBody(e);if(this.placedNow(t)&&e.facing===void 0||this.placedNow(e.facing))this.navigation++;else{let e=this.goTo(t,{clock:`keep`,camera:`none`}),n=this.navigation,r=await e;if(r.outcome===`failed`)throw r.error;if(r.outcome!==`placed`||n!==this.navigation)return}return this.snap(e,t),this.settled(0)}placedNow(e){let t=this.ctx.getBody(e);return!!t&&!!this.renderer?.placeOf(t)}snap(e,t){if(e.facing!==void 0){this.snapToBodyFacing(t,e.facing,e.elevationDeg??0,this.framing(e,t));return}if(e.feature){let{featureId:n,lat:r,lon:i,diameterM:a}=e.feature;this.focusOnFeature(t,n,r,i,a,null,`snap`);return}let n=this.getCamera();this.snapToBody(t,e.lat??n?.lat??45,e.lon??n?.lon??0,this.framing(e,t))}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:Sg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...ry]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,ry.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?QU(n)*5:this.cameraDistance()}cameraDistance(){return 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(xn(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:CW(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 MG(e,this.requireCanvas()))}addPolyline(e){return this.track(new GG(e))}addPolygon(e){return this.track(new iK({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new aK(e))}addLabel(e){return this.track(new oK(e,this.requireCanvas()))}addIcon(e){return this.track(new sK(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new Sq(e))}addSurfacePolygon(e){return this.track(new Sq({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:hq(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof Cq)}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)}},Zq=`http://www.w3.org/2000/svg`;function Qq(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function $q(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function eJ(e,t){let n=document.createElementNS(Zq,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function tJ(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of _q(t)){let t=uq(r,e,{stepDeg:2});t&&n.append(eJ(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(Zq,`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=pq(e);t&&n.append(eJ(t,`sm-flat__frame`))}}}}var nJ=120;function rJ(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 WT(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,nJ))},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(Zq,`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(Zq,`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 iJ(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 aJ(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var oJ=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(Zq,`g`),iJ(this.node,t),aJ(this.node,t),this.area=n?document.createElementNS(Zq,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(Zq,`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`,uq(this.points,e,t)),this.area?.setAttribute(`d`,dq(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)}},sJ=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)}},cJ=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 oJ(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new oJ(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 oJ(mq(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 oJ(hq(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 sJ(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()}},lJ=Math.PI/180,uJ=1.25,dJ=17,fJ=.15,pJ=.75;function mJ(e,t,n){if(e===0)return[(t+180)/360,(90-n)/180];let r=e===1?1:-1,i=.5*Math.tan((90-r*n)*lJ/2)/cE;return[.5+i*Math.cos(t*lJ),.5-r*i*Math.sin(t*lJ)]}function hJ(e,t){return Math.ceil(Math.log2(2*Math.PI/(e*uJ*2*t)))}function gJ(e,t){return 2*Math.PI/(2*t*2**e)}function _J(e,t,n){let[r,i]=mJ(0,t,n),a=r-Math.floor(r),o=e.max_level;for(let t of e.patches??[]){if(t.max_level<=o)continue;let e=Math.floor(a*fE(0,t.max_level)),n=Math.floor(i*pE(0,t.max_level));xE([t],t.max_level,e,n)&&(o=t.max_level)}return o}function vJ(e,t,n,r){let[i]=mJ(0,r[0],r[1]),a={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(let[t,r]of n){let[n,o]=mJ(e,t,r);if(e!==0&&(n<0||n>1||o<0||o>1))return null;let s=e===0?n-Math.round(n-i):n;a.minX=Math.min(a.minX,s),a.maxX=Math.max(a.maxX,s),a.minY=Math.min(a.minY,o),a.maxY=Math.max(a.maxY,o)}let o=(a.maxX-a.minX)/(dJ-1),s=(a.maxY-a.minY)/(dJ-1);return a.minX-=o,a.maxX+=o,a.minY-=s,a.maxY+=s,e===0&&(t.north||t.south)&&(a.minX=i-.5,a.maxX=i+.5,t.north&&(a.minY=0),t.south&&(a.maxY=1)),a}function yJ(e,t,n,r,i){let a=fE(e,t)*n,o=pE(e,t)*n,s=t=>{let n=(r.maxX-r.minX)*t,i=(r.maxY-r.minY)*t,s=Math.floor((r.minX-n)*a),c=Math.ceil((r.maxX+n)*a);e===0?c-s>a&&(s=Math.round((r.minX+r.maxX)/2*a-a/2),c=s+a):(s=Math.max(s,0),c=Math.min(c,a));let l=Math.max(Math.floor((r.minY-i)*o),0),u=Math.min(Math.ceil((r.maxY+i)*o),o);return[s,l,c,u]},[c,l,u,d]=s(i),f=s(0);return{chart:e,level:t,x0:c,y0:l,width:Math.max(u-c,1),height:Math.max(d-l,1),inner:[f[0],f[1],f[2]-1,f[3]-1]}}function bJ(e,t,n,r,i){for(let a of[i,0]){let i=yJ(e,t,n,r,a);if(i.width*i.height<=8e6)return i}}function xJ(e,t){let n=fE(0,e.max_level),r=pE(0,e.max_level),i=(e.y[1]+1)/r;if(e.y[0]/r>t.maxY||i<t.minY)return!1;let a=e.x[0]/n;a-=Math.round(a-(t.minX+t.maxX)/2);let o=a+(e.x[1]+1-e.x[0])/n;return a<=t.maxX&&o>=t.minX}function SJ(e,t,n,r=!0){let i=r?fJ:0,a=t.place(.5,.5);if(!a||!(t.step>0))return[];let o=[];for(let e=0;e<dJ;e++)for(let n=0;n<dJ;n++){let r=t.place(n/(dJ-1),e/(dJ-1));r&&o.push(r)}let s=vJ(0,t,o,a),c=hJ(t.step,e.tile_size),l=[],u=e.max_level;for(let t of e.patches??[])t.max_level>u&&xJ(t,s)&&(u=t.max_level);for(let t=Math.min(c,u);t>e.max_level;t--){let n=bJ(0,t,e.tile_size,s,i);if(n){l.push(n);break}}let d=a[1]>=0?1:2,f=vJ(d,t,o,a);for(let t=Math.min(c,e.max_level);t>=n;t--){let n=bJ(0,t,e.tile_size,s,i),r=f&&t>=1?bJ(d,t,e.tile_size,f,i):void 0,a=n?n.width*n.height:1/0,o=r&&r.width*r.height<=a*pJ?r:n??r;if(o){l.push(o);break}}return l}function CJ(e,t){let n=t.tile_size,r=fE(e.chart,e.level),i=pE(e.chart,e.level),a=[],o=Math.min(Math.floor((e.y0+e.height-1)/n),i-1),s=Math.floor((e.x0+e.width-1)/n);for(let i=Math.max(Math.floor(e.y0/n),0);i<=o;i++)for(let o=Math.floor(e.x0/n);o<=s;o++){if(e.chart!==0&&(o<0||o>=r))continue;let s=(o%r+r)%r,c=e.level>t.max_level?xE(t.patches,e.level,s,i):void 0;e.level>t.max_level&&!c||a.push({cap:aE[e.chart],level:e.level,x:s,y:i,dx:o*n-e.x0,dy:i*n-e.y0,patch:c})}let c=e.width/2-n/2,l=e.height/2-n/2,u=e=>Math.hypot(e.dx-c,e.dy-l);return a.sort((e,t)=>u(e)-u(t))}function wJ(e,t,n){if(e.chart!==t.chart||e.level!==t.level)return!1;let r=0;if(t.chart===0){let i=fE(0,t.level)*n;r=i*Math.round((t.inner[0]-e.x0)/i)}return e.x0+r<=t.inner[0]&&e.x0+r+e.width>t.inner[2]&&e.y0<=t.inner[1]&&e.y0+e.height>t.inner[3]}var TJ=8;function EJ(e){return fE(e.chart,e.level)*e.tileSize}function DJ(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 OJ(e,t){let[n,r]=DJ(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 kJ=class{width;height;refU;refV;u;v;inside;caps=new Map;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=i.inverse(e.view.centerX,e.view.centerY);[this.refU,this.refV]=a?mJ(0,a[0],a[1]):[.5,.5];let o=1/e.scale,s=e.view.centerX-e.width/2*o,c=e.view.centerY+e.height/2*o;for(let r=0;r<n;r++){let n=c-(r+.5)*o,a=r*t;i.rowInverse?this.fillRow(i,a,n,s,o,e):this.walkRow(i,a,n,s,o)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s,refU:c}=this,l=(90-o.lat)/180-this.refV,{minX:u,maxX:d}=e.extent,f=d-u,p=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(p)a=((a-u)%f+f)%f+u;else if(a<u||a>d)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360-c,m=t+n;this.u[m]=s-Math.round(s),this.v[m]=l,this.inside[m]=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,l=(s[0]+180)/360-this.refU;this.u[c]=l-Math.round(l),this.v[c]=(90-s[1])/180-this.refV,this.inside[c]=1}}offsets(e){if(e===0)return{refX:this.refU,refY:this.refV,x:this.u,y:this.v};let t=this.caps.get(e);return t||(t=this.capOffsets(e),this.caps.set(e,t)),t}capOffsets(e){let{u:t,v:n,inside:r,refU:i,refV:a,width:o,height:s}=this,c=e===1?1:-1,[l,u]=mJ(e,i*360-180,90-a*180),d=new Float32Array(t.length),f=new Float32Array(t.length),p=e=>{let r=c>0?a+n[e]:1-a-n[e],o=.5*Math.tan(r*Math.PI/2)/cE,s=(i+t[e])*2*Math.PI-Math.PI;d[e]=.5+o*Math.cos(s)-l,f[e]=.5-c*o*Math.sin(s)-u},m=AJ(o),h=AJ(s);if(m.length<2||h.length<2){for(let e=0;e<t.length;e++)r[e]&&p(e);return{refX:l,refY:u,x:d,y:f}}for(let e of h)for(let t of m)r[e*o+t]&&p(e*o+t);for(let e=0;e<h.length-1;e++){let t=h[e],n=h[e+1],i=e===h.length-2?n:n-1;for(let e=0;e<m.length-1;e++){let a=m[e],s=m[e+1],c=e===m.length-2?s:s-1,l=t*o+a,u=t*o+s,h=n*o+a,g=n*o+s;if(!(r[l]&&r[u]&&r[h]&&r[g])){for(let e=t;e<=i;e++)for(let t=e*o+a;t<=e*o+c;t++)r[t]&&p(t);continue}for(let e=t;e<=i;e++){let r=(e-t)/(n-t),i=d[l]+r*(d[h]-d[l]),p=f[l]+r*(f[h]-f[l]),m=(d[u]+r*(d[g]-d[u])-i)/(s-a),_=(f[u]+r*(f[g]-f[u])-p)/(s-a),v=e===t||e===n;for(let t=a;t<=c;t++)v&&(t===a||t===s)||(d[e*o+t]=i,f[e*o+t]=p),i+=m,p+=_}}}return{refX:l,refY:u,x:d,y:f}}};function AJ(e){let t=[];for(let n=0;n<e-1;n+=TJ)t.push(n);return t.push(e-1),t}function jJ(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c,refU:l,refV:u}=e,d=i*a;for(let n of t){let{image:t,opacity:i,blend:a}=n;if(i<=0)continue;let f=t.data,p=t.width,m=t.height,h=a===`add`,g=(n.detail??[]).map(t=>{let n=e.offsets(t.chart),r=EJ(t),i=t.chart===0?r/2:r,a=n.refX*r-t.x0;return t.chart===0&&(a-=r*Math.round((a-t.width/2)/r)),{xs:n.x,ys:n.y,left:a,top:n.refY*i-t.y0,across:r,down:i,width:t.width,height:t.height,data:t.data}});for(let e=0;e<d;e++){if(!c[e])continue;let t=f,n=-1;for(let r=0;r<g.length;r++){let i=g[r],a=i.left+i.xs[e]*i.across;if(!(a>=0&&a<i.width))continue;let o=i.top+i.ys[e]*i.down;if(!(o>=0&&o<i.height))continue;let s=((o|0)*i.width+(a|0))*4;if(i.data[s+3]!==0){t=i.data,n=s;break}}if(n<0){let t=l+o[e];t-=Math.floor(t);let r=Math.floor(t*p),i=Math.floor((u+s[e])*m);r=r<0?r+p:r>=p?r-p:r,i=i<0?0:i>=m?m-1:i,n=(i*p+r)*4}let a=t[n+3]/255*i;if(a<=0)continue;let d=e*4;if(h){r[d]=Math.min(255,r[d]+t[n]*a),r[d+1]=Math.min(255,r[d+1]+t[n+1]*a),r[d+2]=Math.min(255,r[d+2]+t[n+2]*a);continue}let _=r[d+3]/255,v=a+_*(1-a);if(!(v<=0)){if(a>=1)r[d]=t[n],r[d+1]=t[n+1],r[d+2]=t[n+2];else{let e=_*(1-a);r[d]=(t[n]*a+r[d]*e)/v,r[d+1]=(t[n+1]*a+r[d+1]*e)/v,r[d+2]=(t[n+2]*a+r[d+2]*e)/v}r[d+3]=v*255}}}}function MJ(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],m=(e,t,n)=>{let r=e.createPattern(t.image,`repeat-x`);if(!r)return;r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l);let i=t.detail??[];i.length&&(e.beginPath(),e.rect(f,l,p-f,d-l),e.clip());for(let t=i.length-1;t>=0;t--){let n=i[t],r=(u-c)/EJ(n),a=c+n.x0*r,o=a+n.width*r/2;a+=(u-c)*Math.round((e.canvas.width/2-o)/(u-c)),e.drawImage(n.canvas,a,l+n.y0*r,n.width*r,n.height*r)}e.restore()};e.save();for(let t of n){if(t.opacity<=0)continue;let n=DJ(t.image);if(!n)continue;e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`;let r=t.detail?.length&&(t.opacity<1||t.blend===`add`)?PJ(e.canvas.width,e.canvas.height):null;r?(m(r,t,n),e.drawImage(r.canvas,0,0)):m(e,t,n)}e.restore()}var NJ=null;function PJ(e,t){return NJ??=document.createElement(`canvas`).getContext(`2d`),NJ?(NJ.canvas.width!==e||NJ.canvas.height!==t?(NJ.canvas.width=e,NJ.canvas.height=t):NJ.clearRect(0,0,e,t),NJ):null}var FJ=[`low`,`medium`,`high`];function IJ(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function LJ(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function RJ(e){let t=await Promise.all(FJ.map(t=>fetch($t(`/v1/textures/${e}/${t}.webp`,`textures`),{method:`HEAD`}).then(e=>e.ok).catch(()=>!1)));return FJ.filter((e,n)=>t[n])}async function zJ(e,t,n=RJ){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 BJ(e){return zJ(e,(await nS(e,!1).catch(()=>null))?.global)}async function VJ(e){let t=IJ(e);if(!t)return BJ(e);let n=(await LJ(`${Kt()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return BJ(e);let r=s([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return BJ(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 HJ={low:2048,medium:8192,high:16383};function UJ(e){return FJ.find(t=>HJ[t]>=e)??FJ[FJ.length-1]}function WJ(e,t){return FJ.indexOf(e)<=FJ.indexOf(t)?e:t}function GJ(e,t){let n=FJ.indexOf(t);for(let t=n<0?FJ.length-1:n;t>=0;t--)if(e.includes(FJ[t]))return FJ[t];return e[0]??`low`}function KJ(e,t,n){let r=e.id;if(e.frames?.length){let i=sN(n,e.frames,e.coverage);if(i)return $t(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=SP(n,e.monthlyFrames);return $t(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function qJ(e,t){return e*t*4}function JJ(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var YJ=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,t=!0){let n=this.entries.get(e);n&&(n.claims=Math.max(0,n.claims-1),!t&&!n.claims&&(this.entries.delete(e),this.free(n.value)),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=JJ();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()}},XJ=new YJ(e=>e.close()),ZJ=new YJ(()=>{}),QJ=new Map;function $J(e,t){return t?`${e}@${t}`:e}async function eY(e,t){let n=$J(e,t),r=XJ.claim(n);if(r)return{key:n,bitmap:r};let i=QJ.get(n);if(!i){i=tY(e,t),QJ.set(n,i);let r=()=>QJ.delete(n);i.then(r,r)}let a=await i;return a?{key:n,bitmap:XJ.put(n,a,qJ(a.width,a.height))}:null}async function tY(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 nY(e,t=!0){XJ.release(e,t)}function rY(e,t,n){let r=$J(e,t),i=ZJ.claim(r);if(i)return{key:r,raster:i};let a=OJ(n,t);return a?{key:r,raster:ZJ.put(r,a,qJ(a.width,a.height))}:null}function iY(e){ZJ.release(e)}var aY=4,oY=2,sY=null;function cY(e,t,n,r){let i=Math.max(n,0),a=Math.max(r,0),o=Math.min(n+t.width,e.width)-i,s=Math.min(r+t.height,e.height)-a;if(o<=0||s<=0||(sY??=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0}),!sY))return;(sY.canvas.width<t.width||sY.canvas.height<t.height)&&(sY.canvas.width=t.width,sY.canvas.height=t.height),sY.globalCompositeOperation=`copy`,sY.drawImage(t,i-n,a-r,o,s,0,0,o,s);let c=sY.getImageData(0,0,o,s).data,l=o*4;for(let t=0;t<s;t++)e.data.set(c.subarray(t*l,(t+1)*l),((a+t)*e.width+i)*4)}var lY=class{windows=[];kind=`pixels`;failures=0;failed=new Set;dead=!1;constructor(e,t,n){this.block=e,this.changed=t,this.moves=n}plan(e,t,n){t!==this.kind&&(this.clear(),this.kind=t);for(let e of this.windows)e.wanted=!1;for(let t of this.dead?[]:e){let e=this.windows.find(e=>e.frame===n&&wJ(e,t,this.block.tile_size));e?e.wanted=!0:this.windows.push(this.open(t,n))}this.prune()}rasters(){return this.ordered().filter(e=>!!e.data)}canvases(){return this.ordered().flatMap(e=>e.ctx?[{...e,canvas:e.ctx.canvas}]:[])}clear(){for(let e of this.windows)this.drop(e);this.windows=[]}drop(e){e.dropped=!0,e.data=void 0,e.ctx&&(e.ctx.canvas.width=0)}ordered(){return[...this.windows].sort((e,t)=>t.level-e.level||Number(t.wanted)-Number(e.wanted))}open(e,t){let n={...e,tileSize:this.block.tile_size,frame:t,pending:0,wanted:!0,dropped:!1};if(this.kind===`canvas`){let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height,n.ctx=t.getContext(`2d`)??void 0}else n.data=new Uint8ClampedArray(e.width*e.height*4);for(let r of CJ(e,this.block)){let e=r.patch?.version??(r.cap===``?SE(this.block,r.level,r.x,r.y):this.block.version),i=Yt({id:this.block.id,version:e},r.cap,r.level,r.x,r.y,t);this.failed.has(i)||(n.pending++,this.load(n,i,r.dx,r.dy))}return n}async load(e,t,n,r){try{let i=await eY(t,null);if(i)try{e.ctx&&!e.dropped?e.ctx.drawImage(i.bitmap,n,r):e.dropped||cY(e,i.bitmap,n,r)}finally{nY(i.key,this.moves())}this.failures=0}catch{this.failed.add(t),++this.failures>=aY&&(this.dead=!0)}if(e.pending--,this.dead)this.clear();else if(e.dropped)return;else e.pending===0&&this.prune();this.changed()}prune(){let e=this.windows.some(e=>e.wanted&&e.pending>0),t=this.windows.filter(e=>!e.wanted),n=e?t.slice(-oY):[];for(let e of t)n.includes(e)||this.drop(e);this.windows=this.windows.filter(e=>!e.dropped)}};function uY(e,t,n){return[nI(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var dY=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 fY(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 fY(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function pY(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=mY(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:fY(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 mY(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]=uY(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 hY=[[6,`high`],[2.5,`medium`]],gY=22e5,_Y=4096,vY=11,yY=.4,bY=.8,xY=140,SY=`medium`,CY=250,wY=2,TY=`naif-399`,EY=[{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 DY(e){return e.kind===`raster`}var OY=new WeakMap,kY=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(Zq,`svg`);layerGroup=document.createElementNS(Zq,`g`);shapeGroup=document.createElementNS(Zq,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;ownMaxZoom;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;tiles=new Map;plannedAt=0;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??TY,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=qK(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.ownMaxZoom=e.limits?.maxZoom===void 0,this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??jg(new Date),this.dragPan=new Nq(Pq(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new Nq(Pq(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new Nq(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 cJ(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 Hq(this,this.root),this.cooperative=new Iq(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)DY(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.dropTiles(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await VJ(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.dropTiles(),this.missing.clear();for(let e of this.layerList)!DY(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=a(),t=[];this.dropTiles();for(let n of EY){let r=this.sources[n.kind];if(!r)continue;let i={kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:$q(r),tiers:r.tiers,url:(e,t)=>KJ(r,t,e)};if(t.push(i),!r.tiles)continue;let a=new lY(r.tiles,()=>{a.dead&&(this.loadVisible(),this.emit(`layerschange`,this.layers)),this.render()},()=>this.moves());this.tiles.set(i,a)}t.push(tJ(e.layer_graticule())),t.push(rJ(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(Qq)}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=[],n=n=>{e.has(n.organisation)||(e.add(n.organisation),t.push(n))};for(let e of this.layerList){if(!e.visible||!e.credit)continue;n(e.credit);let t=this.tilesOf(e);if(!t)continue;let r={...e.credit,tiles:t.block},i=kn(r);i&&n(i);for(let e of An(r))n(e)}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||!DY(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 KK}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=qK(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=qK(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.ownMaxZoom=e.maxZoom===void 0,this.render(),this}getLimits(){return this.ownMaxZoom?{...this.limits,maxZoom:this.pictureMaxZoom()}:{...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)});OY.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)OY.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){let t=hY.find(([e])=>this.view.zoom>=e)?.[1]??`low`;return this.tilesOf(e)&&(t=WJ(t,SY)),GJ(e.tiers,WJ(t,UJ(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(_Y,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),HJ[e]??_Y)}picturesInUse(){return this.layerList.filter(e=>DY(e)&&e.visible).map(e=>{let t=this.tier(e);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!DY(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==$J(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 eY(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){nY(r.key);return}this.hold(this.bitmaps,e,r,nY),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)||(nY(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(iY(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===$J(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=rY(e,t,r);return i?(this.hold(this.rasters,e,i,iY),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())nY(e.key);for(let e of this.rasters.values())iY(e.key);this.bitmaps.clear(),this.rasters.clear()}tilesOf(e){let t=this.tiles.get(e);if(!(!t||!DY(e)||t.dead||qt()===``)&&o(t.block.distribution))return Math.max(t.block.max_level,...(t.block.patches??[]).map(e=>e.max_level))>=this.firstTileLevel(e,t)?t:void 0}firstTileLevel(e,t){let n=HJ[GJ(e.tiers,SY)]??_Y,r=this.projectionId===`equirectangular`?n:Math.min(n,_Y);return Math.floor(Math.log2(r/(2*t.block.tile_size)))+1}frameSample(e,t){let{width:n,height:r,projection:i}=e,a=(t,n)=>e.unproject(t,n),o=a(n/2,r/2),s=a(n/2+1,r/2),c=a(n/2,r/2+1);if(!o||!s||!c)return;let l={lon:o[0],lat:o[1]},u=Math.min(eq(l,{lon:s[0],lat:s[1]}),eq(l,{lon:c[0],lat:c[1]})),d=t=>{let a=i.azimuthal?e.project(0,t):null;return!!a&&a[0]>=0&&a[0]<=n&&a[1]>=0&&a[1]<=r};return{place:(e,t)=>a(e*n,t*r),step:u*Math.PI/180/t,north:d(90),south:d(-90)}}planTiles(e,t){let n=this.projectionId===`equirectangular`?`canvas`:`pixels`,r;for(let[i,a]of this.tiles){let o=DY(i)&&i.visible&&i.opacity>0&&this.tilesOf(i);r??=o?this.frameSample(e,t):void 0;let s=o&&r?this.firstTileLevel(i,a):0,c=o&&r?SJ(a.block,r,s,this.moves()):[];a.plan(c,n,SP(this.jd,a.block.frames))}}moves(){return this.dragPan.isEnabled()||this.scrollZoom.isEnabled()}dropTiles(){for(let e of this.tiles.values())e.clear();this.tiles.clear()}pictureMaxZoom(){let e=16,{clientWidth:t,clientHeight:n}=this.root;if(!t||!n)return e;let r=new dY(this.projection,t,n,this.view),i=this.frameSample(r,1),a=i?.place(.5,.5);if(!i||!a)return e;for(let t of this.layerList){let n=t.visible?this.tilesOf(t):void 0;if(!n)continue;let r=gJ(_J(n.block,a[0],a[1]),n.block.tile_size)/wY;e=Math.max(e,this.view.zoom*i.step/r)}return e}heldLimits(){return this.ownMaxZoom&&this.layerList.some(e=>e.visible&&this.tilesOf(e))?{...this.limits,maxZoom:void 0}:this.limits}tileStepDeg(e,t){let n=this.layerList.find(e=>e.id===`surface`),r=n&&this.tilesOf(n);return r?gJ(_J(r.block,e,t),r.block.tile_size)*180/Math.PI:null}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1,i=this.limitsArmed?this.heldLimits():{};return this.view=pY(this.view,this.projection,n,r,i),new dY(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()},xY),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(gY/(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 dY(this.projection,c,l,this.view),f=performance.now();(!this.moving||f-this.plannedAt>CY)&&(this.plannedAt=f,this.planTiles(u,i)),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(vY/this.msPerPixel/e);return t>bY?1:Math.max(yY,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=>DY(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)))?.bitmap,opacity:e.opacity,blend:e.blend,detail:this.tilesOf(e)?.canvases()})).filter(e=>!!e.image);t.length&&MJ(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e)),a),opacity:e.opacity,blend:e.blend,detail:this.tilesOf(e)?.rasters()})).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 kJ(e,t,n),this.lookupKey=s),jJ(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(DY(t)||!t.visible)continue;let n=document.createElementNS(Zq,`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]=uY((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=qK(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=this.ownMaxZoom?Math.max(this.pictureMaxZoom(),this.view.zoom):this.limits.maxZoom??1/0,a=Math.min(i,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(a===this.view.zoom)return;this.view={...this.view,zoom:a};let o=this.viewport();if(!this.projection.azimuthal){let e=o.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 AY(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 jY(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function MY(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var NY=Math.PI/180,PY=256,FY=128,IY=.05,LY=.25;function RY(e){try{let t=document.createElement(`canvas`);t.width=PY,t.height=FY;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,PY,FY);let{data:r}=n.getImageData(0,0,PY,FY),i=new Uint8Array(PY*FY);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:PY,height:FY,covered:i}}catch{return null}}function zY(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]*NY);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*NY),l+=t*Math.cos(o[n]*NY),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<IY?t.heading:BY(Math.atan2(c,l)/NY-n.northOffsetDeg),f=BY(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*LY||(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 BY(e){return(e%360+360)%360}Math.PI/180;function VY(e){return e.orientation!==`unknown`}function HY(e){return e.id}function UY(e){return`${e.time},${e.lat},${e.lon}`}function WY(e,t){return t?e.find(e=>HY(e)===t||UY(e)===t)??null:null}var GY=1;function KY(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=i=>{for(let a=r+i;a>=0&&a<e.length;a+=i){let r=e[a];if(r.mission!==t.mission)return null;let i=JY(t,r,n);if(i>=GY)return{entry:r,distanceM:i,bearingDeg:YY(t,r)}}return null};return{previous:i(-1),next:i(1)}}var qY=Math.PI/180;function JY(e,t,n){return eq(e,t)*qY*n*1e3}function YY(e,t){let n=e.lat*qY,r=t.lat*qY,i=(t.lon-e.lon)*qY,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)/qY%360+360)%360}var XY=Math.PI/180,ZY=30,QY=110,$Y=85,eX=75,tX=-22,nX=9,rX=6,iX=10,aX=1,oX=new Zi(-Math.SQRT1_2,0,0,Math.SQRT1_2),sX=new J(0,0,1);function cX(e){return(e%360+360)%360}function lX(e,[t,n]){let r=cX(n-t),i=cX(e-t);return i<=r?cX(e):i-r<360-i?cX(n):cX(t)}function uX(e,t,n){return Math.max(t,Math.min(n,e))}function dX(e,t,n=new J){let r=e*XY,i=t*XY;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function fX(){let e=new kl;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 pX=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new no;camera=new xd(eX,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new Ja;arrowGeometry=new hu(fX());raycaster=new Qd;loader=new cd;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 Aa;gyroQuaternion=new Zi;gyroScreen=new Zi;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??eX},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 Ws(new _u(500,96,48).scale(-1,1,1),new Ms({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 Th({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 Hq(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 nS(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(tS),this.radiusKm=AY(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?KY(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&&VY(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture($t(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg,!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)??WY(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?lX(t,i.heading):cX(t),pitch:uX(n,i.pitch?.[0]??-$Y,i.pitch?.[1]??$Y),fov:uX(r,i.fov?.[0]??ZY,i.fov?.[1]??QY)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[uX(e[0],t,n),uX(e[1],t,n)];this.limits={heading:e.heading&&[cX(e.heading[0]),cX(e.heading[1])],pitch:t(e.pitch,-$Y,$Y),fov:t(e.fov,ZY,QY)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?jY()!==`available`||!await MY()||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*XY,e.alpha*XY,-e.gamma*XY,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(oX).multiply(this.gyroScreen.setFromAxisAngle(sX,-(screen.orientation?.angle??0)*XY)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/XY,n=Math.asin(uX(this.gyroDirection.y,-1,1))/XY;this.gyroOrigin===null&&(this.gyroOrigin=cX(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=RY(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*XY)*this.camera.aspect)/XY;this.setView(zY(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=ii,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*XY,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 Ws&&e.material.dispose()});for(let t of e){let e=new Ja;e.name=t.key;let n=new Ws(this.arrowGeometry,new Ms({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new Ws(this.arrowGeometry,new Ms({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(dX(t.bearingDeg,tX)).multiplyScalar(nX),e.rotation.y=-t.bearingDeg*XY,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(dX(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+=iX)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=iX)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+=iX){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+=iX){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+=aX){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 dX(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)<rX))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())}},mX=Gx(()=>`${Kt()}/v1/groups/__planetary_systems_map__.json.gz`,{error:e=>`Failed to fetch planetary systems map: ${e.status}`}),hX=Gx(()=>`${Kt()}/v1/groups/__solar_system_map__.json.gz`,{error:e=>`Failed to fetch solar system map: ${e.status}`}),gX=new Map;function _X(e,t,n){return .2126*e+.7152*t+.0722*n}async function vX(e,t){let n=t.strip_rows;if(n.transparency===void 0||n.color===void 0)return console.warn(`Ring strip ${e}/${t.strip} has no transparency or color row, no profile drawn:`,n),null;let r=await fetch($t(`/v1/rings/${e}/${t.strip}`,`rings`));if(!r.ok)throw Error(`${r.status} ${r.statusText}`);let i=await createImageBitmap(await r.blob()),a=document.createElement(`canvas`);a.width=i.width,a.height=i.height;let o=a.getContext(`2d`,{willReadFrequently:!0});if(!o)return console.warn(`Ring strip ${e}/${t.strip}: no 2D context, no profile drawn`),null;o.drawImage(i,0,0);let s=i.width,c=o.getImageData(0,0,s,i.height).data;i.close();let l=t.intensity_scale||1,u=new Float32Array(s),d=new Uint8ClampedArray(s*3),f=n.backscattered??n.color,p=new Float32Array(s),m=0;for(let e=0;e<s;e++){let t=(n.transparency*s+e)*4,r=(f*s+e)*4,i=Math.min(1,(1-c[t]/255)*l);u[e]=i>=1?1/0:-Math.log(1-i),p[e]=_X(c[r],c[r+1],c[r+2])/255,p[e]>m&&(m=p[e])}let h=.35;for(let e=0;e<s;e++){let t=(n.color*s+e)*4,r=m>0?h+(1-h)*(p[e]/m):1;d[e*3]=c[t]*r,d[e*3+1]=c[t+1]*r,d[e*3+2]=c[t+2]*r}return{inner:t.inner_radius_km,outer:t.outer_radius_km,tau:u,rgb:d}}async function yX(e){let t=(await nS(e,!1)).global?.rings??[];t.length||console.warn(`Ring strips for ${e}: no ring bundles on the object`);let n=[];for(let r of t)try{let t=await vX(e,r);t&&n.push(t)}catch(t){console.warn(`Ring strip ${e}/${r.strip} unavailable:`,t)}return n}var bX=-Math.log1p(-.02);function xX(e){let t=1/0,n=-1/0;for(let r of e){let e=r.tau.length,i=(r.outer-r.inner)/(e-1);for(let a=0;a<e;a++){if(r.tau[a]<bX)continue;let e=r.inner+a*i;e<t&&(t=e),e>n&&(n=e)}}return n>=t?{inner:t,outer:n}:null}function SX(e){let t=gX.get(e);return t||(t=yX(e).catch(t=>(console.warn(`Ring strips for ${e} unavailable:`,t),gX.delete(e),[])),gX.set(e,t)),t}function CX({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 wX=2.2,TX=84,EX=40,DX=4,OX=3,kX=1e4,AX=34,jX=7,MX=.42,NX=30;function PX(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 FX(e){return e>90?180-e:e}function IX(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(wX,t.radiusKm*e.pxPerKm),o=120;if(t.tiltDeg>0){let r=Math.min(FX(t.tiltDeg)*e.pxPerDeg,TX),a=120-r,s=120+r;o=PX(n,a,i)>=PX(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*MX:0,r=t.cy-Math.max(t.r,n)-DX,i=[];for(let n of[...t.satellites].sort((e,t)=>t.radiusKm-e.radiusKm)){let a=Math.max(wX,n.radiusKm*e.pxPerKm);r-=a,i.push({...n,cx:t.cx,cy:r,r:a,hitY:0,hitHeight:0}),r-=a+OX}let o=Math.min(...i.map(e=>e.cy-e.r))-jX,s=Math.max(...i.map(e=>e.cy+e.r))+jX;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-AX/2,y:o,width:AX,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,NX);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(FX(t.tiltDeg),0)*e.pxPerDeg,TX),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:EX-c,xOf:r}}function LX(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function RX(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-kX:e-r.r;s>o||(a=r,o=s)}if(a)return a}return null}function zX(e,t,n){let r=RX(e,t,n,0);if(r)return{kind:`body`,id:r.id};for(let r of e.moonZones){if(!LX(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=RX(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 BX(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 VX=`http://www.w3.org/2000/svg`,HX=10,UX=-18,WX=1.2,GX=28,KX=6,qX=4,JX=18,YX=12,XX=190;function ZX(e,t={},...n){let r=document.createElementNS(VX,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 QX(e,t){return JSON.stringify(e)===JSON.stringify(t)}function $X(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 eZ=0,tZ=class{root=document.createElement(`div`);svg=ZX(`svg`);tip=document.createElement(`div`);tipTitle=document.createElement(`span`);tipSub=document.createElement(`span`);uid=`sm-system-map-${eZ++}`;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=CX({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=IX(e);let n=$X(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)=>ZX(`stop`,{offset:t,"stop-color":e.primary.color,"stop-opacity":n});i.append(ZX(`defs`,{},ZX(`radialGradient`,{id:`${this.uid}-primary`,gradientUnits:`userSpaceOnUse`,cx:t.primaryCx,cy:120,r:t.primaryR},a(`0%`,1),a(Math.max(0,1-HX/t.primaryR),.85),a(`100%`,.35)),ZX(`pattern`,{id:`${this.uid}-band`,width:9,height:9,patternUnits:`userSpaceOnUse`},ZX(`circle`,{cx:2,cy:2,r:.9,fill:`currentColor`,opacity:.55}),ZX(`circle`,{cx:6.5,cy:6,r:.9,fill:`currentColor`,opacity:.55})))),r||this.drawAxis(e,t),t.cloudPath&&i.append(ZX(`path`,{d:t.cloudPath,stroke:e.cloud?.color,"stroke-width":WX*2,"stroke-linecap":`round`,fill:`none`,opacity:.45,"pointer-events":`none`}));for(let e of t.bands){let t=ZX(`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=ZX(`text`,{x:e.x+e.width/2,y:232,"text-anchor":`middle`,"font-size":JX,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,ZX(`rect`,{x:e.hitX,y:26,width:e.hitWidth,height:180,fill:`transparent`}),n))}let o=ZX(`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(ZX(`ellipse`,{cx:e.cx,cy:e.cy,rx:t,ry:t*MX,transform:`rotate(${UX} ${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=ZX(`text`,{x:r,y:16,"text-anchor":`middle`,"font-size":16,fill:`currentColor`,opacity:.85});i.textContent=String(n),this.svg.append(ZX(`line`,{x1:r,x2:r,y1:20,y2:212,stroke:`currentColor`,"stroke-width":.5,opacity:.12}),i)}let n=ZX(`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?ZX(`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`}):ZX(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color});if(this.background)return!t||!e.grouped?n:ZX(`g`,{},n,...this.moonDots(t));let r={kind:`body`,id:e.id},i=this.highlight(r,ZX(`circle`,{cx:e.cx,cy:e.cy,r:e.r+3.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),a=ZX(`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,ZX(`circle`,{cx:n.cx,cy:n.cy,r:n.r+2.5,fill:`none`,stroke:`currentColor`,"stroke-width":1,opacity:.8})),ZX(`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=>ZX(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:e.color}))}zoneWash(e){return ZX(`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 ZX(`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?ZX(`a`,{href:e.href,"aria-label":t}):i?ZX(`g`,{role:`button`,tabindex:0,"aria-label":t,class:`sm-system-map__button`}):ZX(`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`,()=>{QX(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(QX(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 zX(this.placed,r,i)}fitLabels(){for(let e of this.labels){let t=0;e.setAttribute(`font-size`,String(JX));try{t=e.getComputedTextLength()}catch{}if(!t)continue;if(t>XX){let n=Math.max(YX,JX*XX/t);e.setAttribute(`font-size`,String(n)),t*=n/JX}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+qX),Math.max(r,720-r-qX));e.setAttribute(`x`,String(i))}}placeTip(){let e=this.model&&this.placed&&!this.background?BX(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*KX)}px`;let r=this.tip.offsetWidth/2,i=Math.min(Math.max(e.cx*n,r+KX),Math.max(r,t-r-KX));this.tip.style.left=`${i}px`,this.tip.style.top=`${Math.max(4,e.cy*n-GX)}px`}};function nZ(e,t){return{planetId:e.primary.id,planetName:t,planetRadiusKm:e.primary.radius_km,planetColor:W_[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:W_[e.id]??e.color??`#cccccc`})),rings:e.rings?{innerRp:e.rings.inner_rp,outerRp:e.rings.outer_rp}:null,moonCount:e.moon_count}}function rZ(e,t){if(!e.rings||!t.length)return e.rings;let n=xX(t),r=e.planetRadiusKm;return n&&{innerRp:n.inner/r,outerRp:n.outer/r}}var iZ=14,aZ=1.001,oZ=.62,sZ=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,5e3],cZ=`0 96 320 144`,lZ=`0 96 720 144`,uZ=[1,100];function dZ(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)?uZ:(r<=n&&(n/=2,r*=2),n=n<=aZ?1:n,[n>1?10**(Math.log10(n)-.12):1,10**(Math.log10(r)+.12)])}function fZ(e,t){let n=e.planetRadiusKm,r=dZ(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:sZ.filter(e=>e>=r[0]&&e<=r[1]),axisLabel:t.axisLabel,pxPerKm:iZ/Math.max(...e.moons.map(e=>e.radiusKm).filter(e=>e>0),1),pxPerDeg:oZ,text:t.text,backgroundView:t.wide?lZ:cZ,backgroundFit:t.wide?`fit`:`slice`}}var pZ=224e-6,mZ=1.8,hZ=[.3,50],gZ=[.3,1,3,10,30],_Z=`#ffdd44`;function vZ(e){let t=e.replace(/^\d+\s+/,``);return t===t.toUpperCase()&&/[A-Z]/.test(t)?t.charAt(0)+t.slice(1).toLowerCase():t}function yZ(e){return e.color||W_[e.id]||`#cccccc`}function bZ(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:yZ(i)}),e.tab||=!!i.link_parent,n.set(i.parent,e)}return n}function xZ(e,t){let n=e.objects.find(e=>e.kind===`star`);if(!n)return null;let r=bZ(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*vg,tiltDeg:e.i,radiusKm:e.diameter_km/2,color:yZ(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:_Z,link:t.primaryLink},bodies:a,bands:e.belts.map(e=>({key:e.slug,innerKm:e.inner_au*vg,outerKm:e.outer_au*vg,tone:e.kind===`kuiper_belt`?`sky`:`muted`,...t.band(e)})),unitKm:vg,domain:hZ,ticks:gZ,axisLabel:t.text.axisAu,pxPerKm:pZ,pxPerDeg:mZ,text:t.text}}function SZ(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??W_[e.id]??`#cccccc`,parent:e.parent}}var CZ=4,wZ=10,TZ={inner:[.6,5.5],outer:[4.5,55]},EZ=[.1,.2,.3,.5,1,2,3,5,10,20,30,50,100,200,500,1e3],DZ=.9,OZ=.76;function kZ(e,t){return Math.log(e/t[0])/Math.log(t[1]/t[0])}var AZ=`naif-599`;function jZ(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 MZ(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:vZ(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:W_[e.id]??e.sbdb?.color??e.color??`#cccccc`,parent:e.orbit?.parent_id}}var NZ=.92;function PZ(e,t){return e<t*NZ?`inner`:`outer`}function FZ(e,t){return Object.values(e).find(e=>e.primary.id===t)}function IZ(e){return e.kind===`zone`?`zone:${e.zone}`:`${e.kind}:${e.id}`}var LZ=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?vZ(t):e)}named(e,t){return this.options.names[e]??t}link(e){return this.targets.set(IZ(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=(FZ(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:W_[e.id]??e.color??`#cccccc`}));if(n.length)return n.sort((e,t)=>t.radiusKm-e.radiusKm),{satellites:n.slice(0,CZ),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 RZ(e,t,n,r){let i=new LZ(e,t,r),a=e=>i.name(e.id,e.name),o=bZ(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=xZ(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 zZ(e,t,n,r,i,a){let o=FZ(e.systems,t);if(!o)throw Error(`spacemap: no planetary system around ${t}`);let s=new LZ(e,r,a),c=nZ(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=e.ringProfiles?rZ(c,e.ringProfiles):c.rings,d=u?[{key:`rings`,label:i.rings,innerKm:u.innerRp*l,outerKm:u.outerRp*l,tone:`amber`}]:[],f=fZ(c,{text:i,axisLabel:i.axisRadii,bands:d,primaryLink:s.body(t,c.planetName),moonLink:e=>s.body(e.id,e.name)});return f.ticks=f.ticks.filter(e=>kZ(e,f.domain)<OZ),s.built(f,c.planetName)}function BZ(e,t,n,r,i){let a=new LZ(e,n,i),{solar:o,extras:s}=e,c=o.objects.find(e=>e.kind===`star`),l=o.objects.find(e=>e.id===AZ)?.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:yZ(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(PZ(e.aAu,l)!==t)continue;let n={...e,aKm:e.aAu*vg},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]=TZ[t],m=[Math.min(f,...d.map(e=>e.aKm/vg*.85)),Math.max(p,...d.map(e=>e.aKm/vg*1.15))],h=e=>e>=m[0]&&e<=m[1],g=wZ/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*vg,tiltDeg:0,radiusKm:0,color:yZ(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*pZ/g,color:_Z},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*vg,outerKm:e.outer_au*vg,tone:e.kind===`kuiper_belt`?`sky`:`muted`})),unitKm:vg,domain:m,ticks:EZ.filter(e=>h(e)&&kZ(e,m)<DZ),axisLabel:r.axisAu,pxPerKm:g,pxPerDeg:mZ,text:r},_)}var VZ=new WeakMap,HZ=.01;function UZ(){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/vg;return t>0&&t<HZ?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 WZ=class{chart=new tZ;listeners=new Map;view;bodies;names;grouping;zones;rings;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.rings=e.rings??`all`,this.places=(e.places??[]).map(SZ)}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([hX(),mX()]),r={bodies:this.bodies,names:this.names,grouping:this.grouping,zones:this.zones},i=UZ(),a=e=>this.emit(`select`,e),o={solar:t,systems:n,extras:[]};switch(e.kind){case`solar-system`:return RZ(o,r,i,a);case`system`:{let t=this.rings===`visible`&&!!FZ(n,e.id)?.rings,[s,c]=await Promise.all([this.exportedNames(e.id,n),t?SX(e.id):void 0]);return zZ({...o,ringProfiles:c},e.id,s,r,i,a)}case`zone`:{let s=jZ(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=jZ(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 BZ({...o,extras:f},e.zone,r,i,a)}}}extra(e){let t=this.extras.get(e);return t||(t=nS(e,!1).then(t=>{if(!t.global)throw Error(`spacemap: no such body as ${e}`);return MZ(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,...(FZ(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 nS(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)});VZ.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)VZ.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}};function GZ(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 KZ(e){let t=e.credits,n=new Set;for(let r of En){if(!t.orbitSources.has(r))continue;let{archive:i,scoped:a}=Tn[r];if(!(a&&!GZ(e,r)))if(i)n.add(i);else for(let e of ln)e&&t.probeArchives.has(e)&&n.add(e)}return[...n]}function qZ(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function JZ(e,t=Dn){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(KZ(e).map(e=>t[e]))],i=new Set;for(let t of qZ(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 YZ=`https://spacemap.co`,XZ=`https://spacemap.co/credits`;function ZZ(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function QZ(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function $Z(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 eQ=class{stop=null;onAdd(e){let t=ZZ(),n=QZ(),r=QZ();return t.append($Z(YZ,`spacemap`,`sm-attribution__home`),n,r,$Z(XZ,a().messages.credits_see_all())),this.stop=ct(()=>{ot(()=>{let t=JZ(e.ctx);tQ(n,a().messages.attribution_orbits(),t.orbits),tQ(r,a().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function tQ(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 nQ=class{off=null;onAdd(e){let t=ZZ(),n=QZ();t.append($Z(YZ,`spacemap`,`sm-attribution__home`),n,$Z(XZ,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 rQ(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 iQ=class{off=null;onAdd(e){let t=ZZ(),n=QZ();t.append($Z(YZ,`spacemap`,`sm-attribution__home`),n,$Z(XZ,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=rQ(t.credit_url),o=i?$Z(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`}};function aQ(e){return e}function oQ(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>lQ(t,e)}}function sQ(e){return{body:e.body??`naif-10`,offsetKm:t=>kB(e.elements,t)?.r??null}}function cQ(e,t){let n=gg(e,t);return n.error!==pg.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:tv,offsetKm:e=>{if(n.error!==pg.None)return null;let t=a_(n,e);return t&&t_(t[0],t[1],t[2],e)}}}function lQ(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=uQ(e,a-1,t),l=uQ(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function uQ(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 dQ(e){return e/vg}var fQ=null,pQ=Promise.resolve();function mQ(e){let t=pQ.then(e,e);return pQ=t.catch(()=>{}),t}async function hQ(e){let t=jg(e),n=await _x();if(!fQ){let e=vx(n);e.size>0&&(fQ=new jx(e))}return await fQ?.load(t),{jd:t,metadata:n,chebyshev:fQ}}function gQ(e,t){return!(e!==void 0&&t-2451545<e)}async function _Q(e,{jd:t,metadata:n}){let r=n.position.zones.moons,i=r&&cx(r);if(!i)return null;let a=await Vb(`moons`,null,0,nx(i)?String(ix(i,t)):null);for(let t=0;t<a.rowCount;t++)if(Ih(a,t)===e)return H_(a,t,new Map,`naif`);return null}function vQ(e,t){return!gQ(e.visibleFromDays,t)||!LV(e,t)?null:e.satrec?s_(e.satrec,t):e.q==null?e.a===0?[0,0,0]:C_(e,t):w_(e,t)}async function yQ(e,t){let{jd:n}=t;if(t.chebyshev?.has(e)){let r=t.chebyshev.body(e,n);if(r&&!gQ(r.visibleFromDays,n))return null;let i=r&&Gy(r,n);if(i){let{radiusKm:e,objectType:t}=r;return{data:{radiusKm:e,objectType:t,orbitalSource:W.SPICE},parentId:`naif-${r.parentId}`,offset:i}}if(e.startsWith(`naif-`))return null}let r=(e.startsWith(`naif-`)?await _Q(e,t):null)??mS(e,await nS(e,!1)),i=r&&vQ(r,n);return i?{data:r,parentId:r.parentId,offset:i}:null}async function bQ(e,t,n=new Set){if(n.has(e))return null;let r=await yQ(e,t);if(!r)return null;if(r.parentId===`naif-0`)return{data:r.data,centre:r.offset,parents:[]};let i=await bQ(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]],parents:[r.parentId,...i.parents]}}function xQ(e,{parents:t},n){let r=new Set(t);for(let{body:e}of n.chebyshev?.bodiesAt(n.jd)??[])t.includes(`naif-${e.parentId}`)&&r.add(e.id);return r.delete(e),[...r]}async function SQ(e){let[t]=await Promise.all([nS(e,!1),Rv()]);return{orientation:t.global?.orientation,nutPrec:zv(e,t.global?.nut_prec)}}async function CQ(e,t){let n=await bQ(e.body,t);if(!n)return null;let r=`latitude`in e?await SQ(e.body):{};return bW(e,{data:n.data,...r},n.centre,t.jd)}function wQ(e,t,n){return mQ(async()=>{let r=await hQ(n),i=await CQ(e,r),a=i&&await CQ(t,r);return i&&a?CW([a[0]-i[0],a[1]-i[1],a[2]-i[2]]):null})}async function TQ(e,t,n){let r=await wQ(e,t,n);return r&&Math.hypot(...r)}function EQ(e,t){return mQ(async()=>{if(e===`naif-10`)return null;let n=await hQ(t),r=await bQ(e,n),i=r&&await bQ(`naif-10`,n);return!r||!i?null:Oq({data:r.data,...await SQ(e)},r.centre,i.centre,n.jd)})}function DQ(e,t){return mQ(async()=>{if(e===`naif-10`)return null;let n=await hQ(t),r=await bQ(e,n),i=r&&await bQ(`naif-10`,n);if(!r||!i)return null;let a=({data:e,centre:t})=>({centre:CW([t[0]-r.centre[0],t[1]-r.centre[1],t[2]-r.centre[2]]),radiusKm:e.radiusKm}),o=[];for(let t of xQ(e,r,n)){let e=await bQ(t,n);e&&e.data.radiusKm>0&&o.push(a(e))}return Mq(r.data.radiusKm>0?r.data.radiusKm:0,a(i),o)})}var OQ=null;function kQ(e=Pv){return OQ||(OQ=(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??[]})(),OQ.catch(()=>OQ=null),OQ)}async function AQ(e){return(await nS(e,!1)).global?.panoramas??[]}async function jQ(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,controls:l,events:u,...d}=e,f=FQ(t);IQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let p=new Xq(d);if(p.mount(f),p.webglError)throw p.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(u??{}))p.on(e,t);p.attribution=new eQ,p.addControl(p.attribution);for(let e of l??[])p.addControl(e);return await p.open(),p.applyInitialView(),await kG(),p}async function MQ(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,controls:l,events:u,...d}=e,f=FQ(t);IQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let p=new kY(d);p.mount(f);for(let[e,t]of Object.entries(u??{}))p.on(e,t);p.attribution=new nQ,p.addControl(p.attribution);for(let e of l??[])p.addControl(e);return await p.load(),p}async function NQ(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,controls:l,events:u,...d}=e,f=FQ(t);IQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let p=new pX(d);p.mount(f);for(let[e,t]of Object.entries(u??{}))p.on(e,t);p.attribution=new iQ,p.addControl(p.attribution);for(let e of l??[])p.addControl(e);return await p.load(),p}async function PQ(e){let{container:t,dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c,events:l,...u}=e,d=FQ(t);IQ({dataUrl:n,imagesUrl:r,liveUrl:i,tilesUrl:a,locale:o,messages:s,includeNonCommercial:c});let f=new WZ(u);f.mount(d);for(let[e,t]of Object.entries(l??{}))f.on(e,t);try{await f.load()}catch(e){throw f.remove(),e}return f}function FQ(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 IQ(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.liveUrl!==void 0&&(t.liveUrl=e.liveUrl),e.tilesUrl!==void 0&&(t.tilesUrl=e.tilesUrl),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=eQ,e.FlatAttributionControl=nQ,e.FlatMap=kY,e.GestureHandler=Nq,e.MAP_LAYERS=ry,e.PROJECTION_IDS=KK,e.PanoramaAttributionControl=iQ,e.PanoramaView=pX,e.SpaceMap=Xq,e.SystemMap=WZ,e.Viewport=dY,e.bearingDeg=YY,e.boxRing=mq,e.circlePoints=JG,e.configureHost=i,e.createFlatMap=MQ,e.createMap=jQ,e.createPanorama=NQ,e.createProjection=qK,e.createSystemMap=PQ,e.dateToJD=jg,e.defaultSceneSettings=cw,e.distanceKm=TQ,e.elements=sQ,e.fetchPanoramaIndex=kQ,e.fetchPanoramas=AQ,e.findPanorama=WY,e.fixed=aQ,e.graticule=_q,e.groundDistanceM=JY,e.isViewable=tS,e.jdToDate=Mg,e.kmToAu=dQ,e.neighboursOf=KY,e.offsetKm=wQ,e.panoramaAt=HY,e.pathFor=uq,e.planeBasis=KG,e.projectionAspect=fK,e.samples=oQ,e.smallCircle=hq,e.subsolarPoint=EQ,e.sunlight=DQ,e.tle=cQ,e})({});
6384
6384
  //# sourceMappingURL=spacemap.iife.js.map
6385
6385
  (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;box-sizing:border-box;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;box-sizing:border-box;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;box-sizing:border-box;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;box-sizing:border-box;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);})();