From 4215d13410dbbc35c4b64054fe8b1c5f3278fa1e Mon Sep 17 00:00:00 2001
From: ajmas <ajmas@users.noreply.github.com>
Date: Mon, 8 Jan 2024 21:39:44 +0000
Subject: [PATCH] deploy: 9f6152a1383d7b778d82faa5ac384b9c0f107f1c

---
 appinfo.json                                    | 4 ++--
 assets/{index-PO5TO8ie.js => index-RkkUHyHQ.js} | 6 +++---
 index.html                                      | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
 rename assets/{index-PO5TO8ie.js => index-RkkUHyHQ.js} (91%)

diff --git a/appinfo.json b/appinfo.json
index be168b1..62b0bb9 100644
--- a/appinfo.json
+++ b/appinfo.json
@@ -1,7 +1,7 @@
 {
-    "buildDate": "2024-01-08T21:38:54Z",
+    "buildDate": "2024-01-08T21:39:09Z",
     "version": "",
-    "gitHash": "46d7f6d1e253a0e6209fec120700a8acdc797fd6",
+    "gitHash": "9f6152a1383d7b778d82faa5ac384b9c0f107f1c",
     "gitBranch": "master"
     "mode": "cmd"
 }
diff --git a/assets/index-PO5TO8ie.js b/assets/index-RkkUHyHQ.js
similarity index 91%
rename from assets/index-PO5TO8ie.js
rename to assets/index-RkkUHyHQ.js
index 079ddd1..3d01b78 100644
--- a/assets/index-PO5TO8ie.js
+++ b/assets/index-RkkUHyHQ.js
@@ -1,6 +1,6 @@
 var re=Object.defineProperty;var oe=(a,e,t)=>e in a?re(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var o=(a,e,t)=>(oe(a,typeof e!="symbol"?e+"":e,t),t);import{T as W,S as D,M as z,a as E,U as ae,b as V,B as ne,A as le,G as $,C as B,D as he,P as ce,F as g,c as _,d as de,e as ue,O as fe,f as ge,L as pe,g as me,h as Se,i as j,j as we,k as ye,W as be,l as ve,R as xe,V as Le,m as De}from"./vendor-tzzAqV-x.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const n of r.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&s(n)}).observe(document,{childList:!0,subtree:!0});function t(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=t(i);fetch(i.href,r)}})();class Ee{constructor(){o(this,"baseUrl","");o(this,"basePath","/StuffInSpace/images");o(this,"radiusInKm",6371);o(this,"pxToRadius",3185.5);o(this,"addAtmosphere",!1);o(this,"addClouds",!0);o(this,"sphere");o(this,"group")}async loadTexture(e){const t=new W;return new Promise((s,i)=>{t.load(e,r=>s(r),void 0,r=>i(r))})}async initClouds(e,t){const s=await this.loadTexture(`${this.basePath}/Earth_Cloud.jpg`),i=e.km2pixels(this.radiusInKm+.02),r=new D(i,32,32),n=new z({map:s,opacity:.3,transparent:!0}),l=new E(r,n),h=1.01;l.scale.set(h,h,h),t.add(l)}initAtmosphere(e,t){const s=["varying vec3 vNormal;","varying vec3 vPosition;","void main() {","vNormal = normalize( normalMatrix * normal );","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vPosition = gl_Position.xyz;","}"].join(`
 `),i=["varying vec3 vNormal;","varying vec3 vPosition;","void main() {","  float intensity = pow( 0.8 + dot( vNormal, vec3( 0, 0, 1.0 ) ), 12.0 );","  intensity = min(intensity, 1.7);","  gl_FragColor = vec4( 0.37, 0.71, 0.93, 0.6 ) * intensity;","}"].join(`
-`),r=ae.clone({}),n=new V({uniforms:r,vertexShader:s,fragmentShader:i,side:ne,blending:le,transparent:!0}),l=e.km2pixels(this.radiusInKm+.1),h=new D(l,32,32),c=new E(h,n),d=1.019;c.scale.set(d,d,d),t.add(c)}async init(e,t){t.config&&(this.baseUrl=t.config.baseUrl),this.group=new $;const s=`${this.baseUrl}images`,i=await this.loadTexture(`${s}/earth-blue-marble.jpg`),r=await this.loadTexture(`${s}/nightearth-4096.png`),n=await this.loadTexture(`${s}/8081_earthbump4k.jpg`),l=await this.loadTexture(`${s}/earth-water.png`),h=new z({map:i,bumpMap:n,emissiveMap:r,emissive:new B(8947848),emissiveIntensity:5,specularMap:l,specular:1,shininess:15,bumpScale:1}),c=e.km2pixels(this.radiusInKm),d=new D(c,32,32);this.sphere=new E(d,h),this.group.add(this.sphere),this.addClouds&&this.initClouds(e,this.group),this.addAtmosphere&&this.initAtmosphere(e,this.group),e.add(this.group),this.sphere.geometry.computeBoundingBox(),this.sphere.geometry.computeBoundingSphere()}update(){}getMesh(){return this.sphere}}const A=class A{constructor(){o(this,"fastTime",!1);o(this,"showGeometry",!1);o(this,"lightSouce");o(this,"lightSourceGeometery");o(this,"hour",0);o(this,"objectGroup");o(this,"scene");o(this,"visible",!0)}degreesToReadians(e){return e*A.deg2RadMult}calculateSunLoc(){let t=this.hour;(t===void 0||t===-1)&&(t=he.utc().hour);const s=t/24*360+180;return{x:25*Math.cos(this.degreesToReadians(s)),z:25*Math.sin(this.degreesToReadians(s))}}init(e){this.fastTime?setInterval(()=>{this.hour+=.05},100):this.hour=-1,this.calculateSunLoc();const t=this.calculateSunLoc(),s={x:t.x,y:0,z:t.z};if(this.scene=e,this.objectGroup=new $,this.lightSouce=new ce(16777215,2e3),this.lightSouce.position.set(s.x,s.y,s.z),this.objectGroup.add(this.lightSouce),this.showGeometry){const i=new D(.1,32,32);this.lightSourceGeometery=new E(i),this.lightSourceGeometery.position.set(s.x,s.y,s.z),this.objectGroup.add(this.lightSourceGeometery)}e.add(this.objectGroup)}update(){}setVisible(e){var t,s;e?this.visible||(t=this.scene)==null||t.add(this.objectGroup):this.visible&&((s=this.scene)==null||s.remove(this.objectGroup)),this.visible=e}};o(A,"deg2RadMult",Math.PI/180);let I=A;class Te{init(e,t){const s=t.config.baseUrl,i=new W().load(`${s}textures/example_render.jpg`);e.background=i}update(){}}function Ae(a){return new Worker("/StuffInSpace/assets/SatCruncherWorker-BkJiidUT.js",{name:a==null?void 0:a.name})}const Ge="debug",v=["error","warn","info","debug"];let y={},x=new Proxy({logLevel:Ge,enabledOutputs:{},error:y.error,warn:y.warn,info:y.info,debug:y.debug,setLogLevel:J},{});function L(a,e,t,...s){a.enabledOutputs[e]&&t(e.toUpperCase(),...s)}function J(a){const e=v.indexOf(a.toLowerCase());if(e<0)throw new Error("Unknown log level");for(let t=0;t<v.length;t++)x.enabledOutputs[v[t]]=t<=e}function Ce(){return x}function Oe(){const a=x,e=a.enabledOutputs;for(let t=0;t<v.length;t++)e[v[t]]=!0;y={error:L.bind(a,{enabledOutputs:e},"error",console.error),warn:L.bind(a,{enabledOutputs:e},"warn",console.warn),info:L.bind(a,{enabledOutputs:e},"info",console.info),debug:L.bind(a,{enabledOutputs:e},"debug",console.debug)},x=new Proxy({...x,...y},{})}Oe();const f=Ce();class Z{constructor(e,t){o(this,"name");o(this,"colorizer");this.name=e,this.colorizer=t}getSatelliteColor(e,t){return this.colorizer(e,t)}}class U extends Z{constructor(){super("Default color scheme",e=>{let t=[1,1,0,1],s=!1;return e&&(s=!0,e.OBJECT_TYPE==="PAYLOAD"?t=[1,.2,0,1]:e.OBJECT_TYPE==="ROCKET BODY"?t=[.2,.5,1,.85]:e.OBJECT_TYPE==="DEBRIS"&&(t=[.5,.5,.5,.85])),{color:t,pickable:s}})}}class Ie extends Z{constructor(){super("Group color scheme",(e,t)=>e&&t&&t.hasSat(e.id)?{color:[1,.2,0,1],pickable:!0}:{color:[1,1,1,.2],pickable:!0})}}class Me{constructor(){o(this,"baseUrl","");o(this,"worker");o(this,"currentColorScheme",new U);o(this,"numSats",1);o(this,"maxSize",0);o(this,"satPos",new Float32Array);o(this,"satVel",new Float32Array);o(this,"satAlt",new Float32Array);o(this,"satelliteColors",[]);o(this,"cruncherReady",!1);o(this,"scene");o(this,"particles");o(this,"geometry");o(this,"satelliteStore");o(this,"shaderStore");o(this,"selectedSatelliteIndexes",[]);o(this,"satelliteGroup");o(this,"hoverSatelliteIdx",-1)}setColorScheme(e){this.currentColorScheme=e}debugRaycastSelection(){if(this.satelliteStore&&(this.satelliteColors.length===0&&this.satelliteStore.satData.length>0&&(this.satelliteColors=new Array(this.satelliteStore.satData.length*4),this.satelliteColors.fill(1,0,this.satelliteColors.length),this.geometry&&this.geometry.setAttribute("color",new g(this.satelliteColors,4))),this.selectedSatelliteIndexes.length>0&&this.geometry)){for(let e=0;e<this.selectedSatelliteIndexes.length;e++){const t=this.selectedSatelliteIndexes[e]*4;this.satelliteColors[t]=0,this.satelliteColors[t+1]=1,this.satelliteColors[t+2]=0,this.satelliteColors[t+3]=1}this.geometry.setAttribute("color",new g(this.satelliteColors,4))}}updateSatellites(){var e;if(this.satelliteStore){if(this.satPos&&this.satPos.length>0&&(e=this.geometry)!=null&&e.attributes){const t=this.satelliteStore.satData,s=t.length;this.updateSatellitesGeometry(),this.updateSatellitesMaterial(s,t)}this.debugRaycastSelection()}}updateSatellitesMaterial(e,t){var s,i,r;if((s=this.geometry)!=null&&s.attributes.color&&this.currentColorScheme&&this.satelliteStore){(this.satelliteColors.length===0||e*4!==this.satelliteColors.length)&&(this.satelliteColors=new Array(this.satelliteStore.satData.length*4),this.satelliteColors.fill(1,0,this.satelliteColors.length));for(let n=0;n<t.length;n++){let l=(r=(i=this.currentColorScheme)==null?void 0:i.getSatelliteColor(t[n],this.satelliteGroup))==null?void 0:r.color;l||(l=[0,0,0]);const h=n*4;this.satelliteColors[h]=l[0],this.satelliteColors[h+1]=l[1],this.satelliteColors[h+2]=l[2],this.satelliteColors[h+3]=l[3]}this.geometry.setAttribute("color",new g(this.satelliteColors,4))}}updateSatellitesGeometry(){var e;if((e=this.geometry)!=null&&e.attributes.position&&this.satelliteStore){const t=new Float32Array;t.fill(0,0,this.satelliteStore.satData.length*3),this.geometry.setAttribute("position",new g(t,3));for(let s=0;s<this.satPos.length;s++)isNaN(this.satPos[s])&&(this.satPos[s]=0);this.geometry.setAttribute("position",new g(this.satPos,3)),this.geometry.computeBoundingBox(),this.geometry.computeBoundingSphere()}}onMessage(e){var r;if(!this.satelliteStore)return;const t=this.satelliteStore.getSatData();if(!t)return;const s=t.length;let i;try{if(!this.satelliteStore.gotExtraData){const n=performance.now();if(e.data.extraData){if(i=JSON.parse(e.data.extraData),!i)return;for(let l=0;l<s;l++)t[l].inclination=i[l].inclination,t[l].eccentricity=i[l].eccentricity,t[l].raan=i[l].raan,t[l].argPe=i[l].argPe,t[l].meanMotion=i[l].meanMotion,t[l].semiMajorAxis=i[l].semiMajorAxis,t[l].semiMinorAxis=i[l].semiMinorAxis,t[l].apogee=i[l].apogee,t[l].perigee=i[l].perigee,t[l].period=i[l].period;f.debug(`sat.js copied extra data in ${performance.now()-n} ms`),this.satelliteStore.setSatelliteData(t,!0);return}}this.satPos=new Float32Array(e.data.satPos),this.satVel=new Float32Array(e.data.satVel),this.satAlt=new Float32Array(e.data.satAlt),this.satelliteStore.setPositionalData(this.satVel,this.satPos,this.satAlt),this.cruncherReady||((r=document.querySelector("#load-cover"))==null||r.classList.add("hidden"),this.cruncherReady=!0),this.updateSatellites()}catch(n){f.debug("Error in worker response",n),f.debug("worker message",e)}}onSatDataLoaded(){if(this.satelliteStore)if(this.worker){const e=JSON.stringify(this.satelliteStore.satData);f.debug("Sending data to sat cruncher worker, to perform work"),this.worker.postMessage(e)}else f.error("worker is not available")}setSatelliteGroup(e){this.satelliteGroup=e,this.satelliteGroup?this.currentColorScheme=new Ie:this.currentColorScheme=new U}getSatellitegroup(){return this.satelliteGroup}setSelectedSatellites(e){f.debug("Updated selected satellites",e),this.selectedSatelliteIndexes=e,this.updateSatellites()}setSelectedSatellite(e){this.setSelectedSatellites([e])}setHoverSatellite(e){this.hoverSatelliteIdx=e,this.updateSatellites()}initGeometry(){if(!this.satelliteStore)throw new Error("satelliteStore is not available");if(!this.shaderStore)throw new Error("sahderStore is not available");const e=(this.satelliteStore.satData||[]).length,t=new _,s=new Float32Array,i=new Float32Array,r=new Array(e*4);s.fill(0,0,e*3),r.fill(0,0,e*3),i.fill(10,0,e),t.setAttribute("position",new g(s,3)),t.setAttribute("color",new g(r,4)),t.setAttribute("size",new g(i,2));const n=new W().load(`${this.baseUrl}/images/circle.png`),l=this.shaderStore.getShader("dot2"),h=new V({uniforms:{color:{value:new B(16777215)},pointTexture:{value:n}},clipping:!1,vertexShader:l.vertex,fragmentShader:l.fragment,blending:de,blendSrcAlpha:ue,blendDstAlpha:fe,transparent:!0,alphaTest:.5,depthTest:!0,depthWrite:!1});t.center(),this.geometry=t,this.particles=new ge(t,h),this.scene&&this.scene.add(this.particles),window.addEventListener("visibilitychange",()=>{var c;(c=this.worker)==null||c.postMessage(JSON.stringify({state:{running:document.visibilityState==="visible"}}))})}getObject3D(){return this.particles}initSatWorker(e={}){f.info("Kicking off sat-cruncher-worker"),this.worker=new Ae,this.worker.onmessage=this.onMessage.bind(this),this.worker.postMessage(JSON.stringify({config:e}))}async init(e,t){this.satelliteStore=t.satelliteStore,this.shaderStore=t.shaderStore,this.scene=e;const s=t.config||{};let i={};s.satWorker&&(i={...s.satWorker,logLevel:s.logLevel}),this.initSatWorker(i),t!=null&&t.config&&(this.baseUrl=t.config.baseUrl),this.satelliteStore&&(this.satelliteStore.addEventListener("satdataloaded",this.onSatDataLoaded.bind(this)),await this.satelliteStore.loadSatelliteData(),this.initGeometry(),this.satelliteStore.gotExtraData&&this.updateSatellites())}update(){}}function ke(a){return new Worker("/StuffInSpace/assets/OrbitCalculationWorker-_Yyn1p1l.js",{name:a==null?void 0:a.name})}class Pe{constructor(){o(this,"config",{});o(this,"segmentCount",255);o(this,"orbitWorker");o(this,"selectedSatellites",[]);o(this,"hoverSatelliteIdx",-1);o(this,"satelliteGroups");o(this,"satelliteGroup");o(this,"inProgress",[]);o(this,"scene");o(this,"selectColor",[0,1,0,1]);o(this,"hoverColor",[1,.92,.23,1]);o(this,"groupColor",[.3,.5,1,.4]);o(this,"orbitTracks",[]);o(this,"satelliteStore");o(this,"satelliteOrbitGroup")}calculateOrbits(e){e=e.filter(t=>!this.inProgress[t]),this.orbitWorker?this.orbitWorker.postMessage(JSON.stringify({isInit:!1,satId:e})):f.error("Orbit worker is undefined"),e.forEach(t=>this.inProgress[t]=!0)}onSatellitesLoaded(){this.satelliteStore&&(this.inProgress=new Array(this.satelliteStore.size()),this.orbitTracks=new Array(this.satelliteStore.size()),this.orbitWorker&&this.orbitWorker.postMessage(JSON.stringify({isInit:!0,satData:this.satelliteStore.satData,numSegs:this.segmentCount})))}isTrackVisible(e){return this.selectedSatellites.indexOf(e)>-1||e===this.hoverSatelliteIdx||this.satelliteGroup&&this.satelliteGroup.hasSat(e)}getTrackColor(e){let t=[1,1,0];return e===this.hoverSatelliteIdx?t=this.hoverColor:this.selectedSatellites.indexOf(e)>-1?t=this.selectColor:this.satelliteGroup&&this.satelliteGroup.hasSat(e)&&(t=this.groupColor),new B(t[0],t[1],t[2])}addOrbitTrack(e,t){const s=this.getTrackColor(e),i=new pe({color:s,linewidth:10}),r=new _;r.setAttribute("position",new g(t,3));const n=new me(r,i);n.name=`${e}`,this.satelliteOrbitGroup&&this.satelliteOrbitGroup.add(n),this.orbitTracks[e]=n}updateOrbitTrack(e,t){const s=this.orbitTracks[e];if(s){const i=s.material;i.color=this.getTrackColor(e),i.needsUpdate=!0,t&&(s.geometry.setAttribute("position",new g(t,3)),s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere())}}removeOrbitTrack(e){var t;if(this.orbitTracks[e]){const s=this.orbitTracks[e];(t=this.satelliteOrbitGroup)==null||t.remove(s),s.geometry&&s.geometry.dispose(),this.orbitTracks[e]=void 0}}onMessage(e){const{satId:t}=e.data;this.scene&&(this.orbitTracks[t]?this.updateOrbitTrack(t,e.data.pointsOut):this.isTrackVisible(t)&&this.addOrbitTrack(t,e.data.pointsOut)),this.inProgress[t]=!1}isHoverSatellite(e){return this.hoverSatelliteIdx!==void 0&&e!==-1&&this.hoverSatelliteIdx===e}isSelectedSatellite(e){return this.selectedSatellites.length>0?this.selectedSatellites.indexOf(e)>-1:!1}refreshOrbits(){if(this.satelliteGroup){const e=this.satelliteGroup.sats;for(let t=0;t<e.length;t++)this.updateOrbitTrack(e[t].satId)}}setSelectedSatellites(e){if(this.selectedSatellites.length>0)for(let t=0;t<this.selectedSatellites.length;t++){const s=this.selectedSatellites[t];this.orbitTracks[s]&&(!this.satelliteGroup||!this.satelliteGroup.hasSat(s)?this.removeOrbitTrack(s):this.updateOrbitTrack(s))}this.selectedSatellites=e,this.calculateOrbits(e),this.refreshOrbits()}setSelectedSatellite(e){this.setSelectedSatellites([e])}setHoverSatellite(e){let t=!1;const s=this.hoverSatelliteIdx||-1;this.hoverSatelliteIdx&&this.hoverSatelliteIdx>-1&&(t=this.selectedSatellites.indexOf(this.hoverSatelliteIdx)<0,t=t&&(!this.satelliteGroup||!this.satelliteGroup.hasSat(this.hoverSatelliteIdx))),this.hoverSatelliteIdx=e,t?this.removeOrbitTrack(s):this.updateOrbitTrack(s),this.calculateOrbits([e]),this.refreshOrbits()}setSatelliteGroup(e){if(this.satelliteGroup){this.setSelectedSatellites([]),this.setHoverSatellite(-1);for(let t=0;t<this.orbitTracks.length;t++)this.orbitTracks[t]&&this.removeOrbitTrack(t)}if(this.satelliteGroup=e,this.satelliteGroup){const s=this.satelliteGroup.sats.map(i=>i.satId);this.calculateOrbits(s)}}init(e,t){this.config=t.config,this.scene=e,this.orbitWorker=new ke,this.orbitWorker.onmessage=this.onMessage.bind(this),this.satelliteStore=t.satelliteStore,this.orbitWorker.postMessage(JSON.stringify({config:{logLevel:this.config.logLevel}})),this.satelliteStore&&(this.satelliteStore.addEventListener("satdataloaded",this.onSatellitesLoaded.bind(this)),this.satelliteStore.size()>0&&(this.inProgress=new Array(this.satelliteStore.size()),this.onSatellitesLoaded())),t.satelliteGroups&&(this.satelliteGroups=t.satelliteGroups),this.satelliteOrbitGroup=new $,this.scene.add(this.satelliteOrbitGroup)}update(){}}const G=class G extends Se{constructor(){super();o(this,"pxToRadius",3185.5)}setPixels2Radius(t){this.pxToRadius=t}getPixels2Radius(){return this.pxToRadius}km2pixels(t){return t/this.pxToRadius}alitudeToPixels(t){return(G.earthRadiusInKm+t)/this.pxToRadius}};o(G,"earthRadiusInKm",6371);let M=G;class Y{constructor(e,t,s,i,r){o(this,"sats",[]);o(this,"id");o(this,"name");o(this,"groupType");o(this,"data");o(this,"satelliteStore");if(this.id=e,this.name=t,this.groupType=s,this.data=i,this.satelliteStore=r,!this.satelliteStore)throw new Error("satelliteStore is required")}reload(){switch(this.sats=[],this.groupType){case"intlDes":this.searchIntlDes();break;case"nameRegex":this.searchNameRegex();break;case"idList":this.searchIdList();break;case"objectType":this.searchObjectType();break;default:throw new Error("Invalid groupType")}}searchObjectType(){if(typeof this.data!="string")throw new Error("objectType must be a string");const t=this.satelliteStore.search({["OBJECT_TYPE"]:this.data});for(const s of t)this.sats.push({satId:s.id,isIntlDes:!1,strIndex:0})}searchIdList(){if(typeof this.data=="string")throw new Error("idList must be an array");for(const e of this.data)this.sats.push({satId:e,isIntlDes:!1,strIndex:0})}searchNameRegex(){if(typeof this.data!="string")throw new Error("nameRegex must be a string");const e=new RegExp(this.data),t=this.satelliteStore.searchNameRegex(e);for(const s of t)this.sats.push({satId:s,isIntlDes:!1,strIndex:0})}searchIntlDes(){if(typeof this.data=="string")throw new Error("intlDes must be an array");for(const e of this.data)this.sats.push({satId:this.satelliteStore.getIdFromIntlDes(e),isIntlDes:!0,strIndex:0})}getSat(e){return this.satelliteStore.satData.find(t=>t.id===e)}hasSat(e){for(const t of this.sats)if(t.satId===e)return!0;return!1}}class Re{constructor(e,t){o(this,"groups",{});o(this,"selectedGroup");o(this,"sats",[]);o(this,"satelliteStore");if(!t)throw new Error("satelliteStore is required");this.satelliteStore=t,this.resetConfig(e),this.satelliteStore.addEventListener("satdataloaded",this.onSatDataLoaded.bind(this))}asArray(){return Object.values(this.groups)}selectGroup(e){if(this.selectedGroup=e,!e){this.clearSelect();return}}forEach(e){for(let t=0;t<this.sats.length;t++)e(this.sats[t].satId)}clearSelect(){this.selectedGroup=void 0}getGroupById(e){if(e)return e=e.toLowerCase(),this.groups[e]}getSelectedGroup(){return this.selectedGroup}reloadGroups(){const e=Object.keys(this.groups);for(let t=0;t<e.length;t++)this.groups[e[t]].reload()}resetConfig(e){const t=e;for(let s=0;s<t.length;s++)f.debug(`registering satellite group ${t[s].name} (id: ${t[s].id})`),this.groups[t[s].id.toLowerCase()]=new Y(t[s].id.toLowerCase(),t[s].name,t[s].groupType,t[s].data,this.satelliteStore)}onSatDataLoaded(){this.reloadGroups()}}class K{constructor(e){o(this,"listeners",{});o(this,"supportedEvents");this.supportedEvents=e}addEventListener(e,t){if(!e)throw new Error("eventName must not be undefined");if(this.supportedEvents&&this.supportedEvents.indexOf(e)<0)throw new Error(`unsupported event ${e}`);if(e=e.toLowerCase(),this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e])this.listeners[e].add(t);else throw new Error("unknown event")}fireEvent(e,t){if(!e)throw new Error("undefined eventName");e=e.toLowerCase(),this.listeners[e]&&this.listeners[e].forEach(i=>{i(t)})}}const We={baseUrl:"/StuffInSpace/"};class $e{constructor(e={}){o(this,"tleUrl",`${We.baseUrl}/data/attributed-TLE.json`);o(this,"eventManager");o(this,"satData",[]);o(this,"attribution");o(this,"updateDate");o(this,"satelliteVelocities",new Float32Array);o(this,"satellitePositions",new Float32Array);o(this,"satelliteAltitudes",new Float32Array);o(this,"gotExtraData",!1);o(this,"gotPositionalData",!1);o(this,"loaded",!1);this.eventManager=new K,e.tleUrl&&(this.tleUrl=e.tleUrl)}async loadSatelliteData(){try{const e=await j.get(this.tleUrl,{params:{t:Date.now()}});if(e.data){Array.isArray(e.data)?this.satData=e.data:(this.satData=e.data.data,this.attribution=e.data.source,this.updateDate=e.data.date);for(let t=0;t<this.satData.length;t++){if(this.satData[t].INTLDES){const s=Number(this.satData[t].INTLDES.substring(0,2)),r=(s>50?"19":"20")+s.toString(),n=this.satData[t].INTLDES.substring(2);this.satData[t].intlDes=`${r}-${n}`}else this.satData[t].intlDes="unknown";this.satData[t].id=t}}this.eventManager.fireEvent("satdataloaded",this.satData),this.loaded=!0}catch(e){f.error("error loading TLE data",e)}}getAttribution(){return this.attribution}getUpdatedDate(){return this.updateDate}setSatelliteData(e,t=!1){this.satData=e,this.gotExtraData=t,t&&this.eventManager.fireEvent("satextradataloaded",this.satData)}setPositionalData(e,t,s){this.satelliteVelocities=e,this.satellitePositions=t,this.satelliteAltitudes=s,this.gotPositionalData=!0}getSatellitePosition(e){const t=e*3;if(this.satellitePositions&&t<this.satellitePositions.length)return[this.satellitePositions[t],this.satellitePositions[t+1],this.satellitePositions[t+3]]}getSatData(){return this.satData||[]}getPositions(){return this.satellitePositions}getAltitudes(){return this.satelliteAltitudes}getVelocitities(){return this.satelliteVelocities}size(){return this.satData.length}searchNameRegex(e){const t=[];for(let s=0;s<this.satData.length;s++)e.test(this.satData[s].OBJECT_NAME)&&t.push(s);return t}search(e){const t=Object.keys(e);let s=Object.assign([],this.satData);for(const i of t)s=s.filter(r=>r[i]===e[i]);return s}searchName(e){const t=[];for(let s=0;s<this.satData.length;s++)this.satData[s].OBJECT_NAME===e&&t.push(s);return t}getIdFromIntlDes(e){for(let t=0;t<this.satData.length;t++)if(this.satData[t].INTLDES===e||this.satData[t].intlDes===e)return t;return null}getSatellite(e){if(e===-1||e===void 0||!this.satData)return;const t=new Proxy(this.satData[e],{});if(t)return this.gotPositionalData&&(t.altitude=this.satelliteAltitudes[e],t.velocity=Math.sqrt(this.satelliteVelocities[e*3]*this.satelliteVelocities[e*3]+this.satelliteVelocities[e*3+1]*this.satelliteVelocities[e*3+1]+this.satelliteVelocities[e*3+2]*this.satelliteVelocities[e*3+2]),t.position={x:this.satellitePositions[e*3],y:this.satellitePositions[e*3+1],z:this.satellitePositions[e*3+2]}),t}addEventListener(e,t){this.eventManager.addEventListener(e,t)}}class Be{constructor(e=""){o(this,"basePath","shaders/");o(this,"baseUrl",`./${this.basePath}`);o(this,"shaders",["earth-fragment","earth-vertex","dot-fragment","dot-vertex","dot2-fragment","dot2-vertex","pick-fragment","pick-vertex","path-fragment","path-vertex"]);o(this,"shaderData",{});this.baseUrl=`${e}${this.basePath}`}async loadShader(e){const t=`${this.baseUrl}${e}.glsl`;f.debug(`loading shader from ${t}`);const s=await j.get(t);if(s.data)return s.data;throw new Error("no data received")}async load(){try{for(let e=0;e<this.shaders.length;e++){const t=await this.loadShader(this.shaders[e]);this.shaderData[this.shaders[e]]=t}}catch(e){f.error("Errors while loading shaders",e)}}addShader(e,t,s){this.shaderData[`${e}-fragment`]=t,this.shaderData[`${e}-vertex`]=s}getFragmentShader(e){return this.shaderData[`${e}-fragment`]}getVertexShader(e){return this.shaderData[`${e}-vertex`]}getShader(e){return{vertex:this.getVertexShader(e),fragment:this.getFragmentShader(e)}}}class je{constructor(e){o(this,"config",{canvasSelector:".viewer"});o(this,"sceneComponents",[]);o(this,"sceneComponentsByName",{});o(this,"scene");o(this,"camera");o(this,"controls");o(this,"renderer");o(this,"context",{});o(this,"satelliteGroups");o(this,"satelliteStore");o(this,"shaderStore");o(this,"selectedSatelliteIdx",-1);o(this,"eventManager",new K);o(this,"ready",!1);o(this,"raycaster");o(this,"showRaycastArrow",!1);o(this,"raycastArrow");o(this,"satellites");o(this,"orbits");o(this,"earth");o(this,"mouseMoved",!1);o(this,"targetZoom",5);o(this,"minZoomLevel",1);o(this,"maxZoomLevel",10);this.config={...this.config,...e}}async registerSceneComponent(e,t){f.debug(`Registering scene component ${e}`),this.sceneComponents.push(t),this.sceneComponentsByName[e]=t,await t.init(this.scene,this.context)}getCenterPoint(e){if(e){const t=e.geometry;t.computeBoundingBox();const s=new Le;if(t.boundingBox)return t.boundingBox.getCenter(s),e.localToWorld(s),s}}onWindowResize(){this.camera&&(this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix()),this.renderer&&this.renderer.setSize(window.innerWidth,window.innerHeight)}onSatDataLoaded(e){this.eventManager.fireEvent("satdataloaded",e),this.ready=!0}findSatellitesAtMouse(e){var n;const t=(n=this.renderer)==null?void 0:n.domElement;if(!this.raycaster||!this.scene||!this.camera||!t)return[];this.raycaster.params.Points.threshold=.05;const s=t.getBoundingClientRect(),i=new De;i.x=(e.x-s.left)/t.clientWidth*2-1,i.y=-((e.y-s.top)/t.clientHeight*2)+1,this.raycaster.setFromCamera(i,this.camera),this.showRaycastArrow&&(this.raycastArrow&&(this.scene.remove(this.raycastArrow),this.raycastArrow.dispose(),this.raycastArrow=void 0),this.raycastArrow=new we(this.raycaster.ray.direction,this.raycaster.ray.origin,300,16776960,void 0,1),this.scene.add(this.raycastArrow));const r=this.raycaster.intersectObjects(this.scene.children,!0);if(r.length>0){r.sort((h,c)=>h.object.type==="Line"&&c.object.type==="Points"?1:h.object.type==="Points"&&c.object.type==="Line"?-1:0);let l=r.map(h=>h.object.type==="Points"?h.index:h.object.type==="Line"?parseInt(h.object.name):-1).filter(h=>h!==-1);if(l.length>0){const h=[];for(const c of l)this.isValidTarget(c)&&h.push(c);l=h}return l}return[]}isValidTarget(e){var s;const t=(s=this.satellites)==null?void 0:s.getSatellitegroup();return t?t.hasSat(e):!0}onClick(e){var n,l,h,c;const t=(n=this.renderer)==null?void 0:n.domElement;if(!this.raycaster||!this.scene||!this.camera||!t)return;const s=this.findSatellitesAtMouse({x:e.clientX,y:e.clientY});let i=-1,r;s&&s.length>0&&(i=s[0],r=(l=this.satelliteStore)==null?void 0:l.getSatellite(i)),this.selectedSatelliteIdx=i,(h=this.satellites)==null||h.setSelectedSatellite(i),(c=this.orbits)==null||c.setSelectedSatellite(i),this.eventManager.fireEvent("selectedSatChange",r)}onMouseMove(){this.mouseMoved=!0}onMouseDown(){this.mouseMoved=!1,this.controls&&(this.controls.autoRotate=!1),window.addEventListener("mousemove",this.onMouseMove.bind(this))}onMouseUp(e){this.mouseMoved||this.onClick(e),this.mouseMoved=!1,window.removeEventListener("mousemove",this.onMouseMove.bind(this))}onHover(e){var n,l,h,c;const t=(n=this.renderer)==null?void 0:n.domElement;if(!this.raycaster||!this.scene||!this.camera||!t)return;const s=this.findSatellitesAtMouse({x:e.clientX,y:e.clientY});let i=-1,r;s&&s.length>0&&(i=s[0],r=(l=this.satelliteStore)==null?void 0:l.getSatellite(i)),(h=this.satellites)==null||h.setHoverSatellite(i),(c=this.orbits)==null||c.setHoverSatellite(i),this.eventManager.fireEvent("sathoverChange",r),this.mouseMoved=!0}async init(){var e;try{this.scene=new M,this.camera=new ye(45,window.innerWidth/window.innerHeight,.1,1e3),this.camera.position.z=15,this.camera.zoom=1,this.renderer=new be({antialias:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),(e=document.querySelector(this.config.canvasSelector))==null||e.appendChild(this.renderer.domElement),f.debug(`Using WebGL 2: ${this.renderer.capabilities.isWebGL2}`),this.controls=new ve(this.camera,this.renderer.domElement),this.controls.rotateSpeed=.33,this.controls.enablePan=!1,this.controls.enableZoom=!0,this.controls.enableDamping=!0,this.controls.dampingFactor=.05,this.controls.zoomSpeed=3,this.controls.maxZoom=10,this.controls.minZoom=3,this.controls.autoRotate=!0,this.controls.autoRotateSpeed=.5,this.controls.maxDistance=50,this.controls.minDistance=3,this.controls.update(),this.raycaster=new xe,this.satelliteStore=new $e(this.config),this.satelliteGroups=new Re(this.config.satelliteGroups,this.satelliteStore),this.shaderStore=new Be(this.config.baseUrl),f.debug("loading shaders"),await this.shaderStore.load(),this.context.satelliteGroups=this.satelliteGroups,this.context.config=this.config,this.context.satelliteStore=this.satelliteStore,this.context.shaderStore=this.shaderStore,this.satelliteStore.addEventListener("satdataloaded",this.onSatDataLoaded.bind(this)),this.earth=new Ee,await this.registerSceneComponent("earth",this.earth),await this.registerSceneComponent("sun",new I),await this.registerSceneComponent("universe",new Te),this.satellites=new Me,await this.registerSceneComponent("satellites",this.satellites),this.orbits=new Pe,await this.registerSceneComponent("orbits",this.orbits);const t=this.getCenterPoint(this.earth.getMesh());t&&(this.controls.target=t),this.camera.updateProjectionMatrix(),window.addEventListener("resize",this.onWindowResize.bind(this));const s=this.renderer.domElement;s.addEventListener("mousedown",this.onMouseDown.bind(this)),s.addEventListener("mouseup",this.onMouseUp.bind(this)),s.addEventListener("mousemove",this.onHover.bind(this))}catch(t){f.error("Error while initialising scene",t)}}animate(){requestAnimationFrame(this.animate.bind(this));for(const e of this.sceneComponents)e.update(this.scene);this.controls&&this.controls.update(),this.renderer&&this.renderer.render(this.scene,this.camera)}getSatelliteStore(){return this.satelliteStore}getSatelliteGroups(){return this.satelliteGroups}zoomToSatellite(e){var t;(t=this.satelliteStore)==null||t.getSatellitePosition(e)}clampZoom(){this.camera&&(this.targetZoom>this.camera.zoom*5?this.targetZoom=this.camera.zoom*5:this.targetZoom<this.camera.zoom/5&&(this.targetZoom=this.camera.zoom/5),this.camera.zoom=Math.min(Math.max(this.camera.zoom,this.minZoomLevel),this.maxZoomLevel),this.targetZoom=Math.min(Math.max(this.targetZoom,this.minZoomLevel),this.maxZoomLevel))}zoomIn(){this.camera&&(this.targetZoom+=this.camera.zoom/4,this.clampZoom())}zoomOut(){this.camera&&(this.targetZoom-=this.camera.zoom/6,this.clampZoom())}setHoverSatellite(e){var t,s;(t=this.satellites)==null||t.setHoverSatellite(e),(s=this.orbits)==null||s.setHoverSatellite(e)}setSelectedSatellite(e){var t,s;(t=this.satellites)==null||t.setSelectedSatellite(e),(s=this.orbits)==null||s.setSelectedSatellite(e)}setSelectedSatelliteGroup(e){var t,s,i;this.setSelectedSatellite(-1),(t=this.satelliteGroups)==null||t.selectGroup(e),(s=this.orbits)==null||s.setSatelliteGroup(e),(i=this.satellites)==null||i.setSatelliteGroup(e)}getSelectedSatellite(){if(this.satelliteStore)return this.satelliteStore.getSatellite(this.selectedSatelliteIdx)}getSelectedSatelliteIdx(){return this.selectedSatelliteIdx}addEventListener(e,t){this.eventManager.addEventListener(e,t)}}function ze(a){return new je(a)}const Ue="/StuffInSpace/",N={appName:"Stuff in Space",baseUrl:Ue,propergateInterval:1e3,pushHistory:!1,logLevel:"debug",satWorker:{runOnce:!0},satelliteGroups:[{id:"GPSGroup",name:"GPS",groupType:"intlDes",data:["90103A","93068A","96041A","97035A","99055A","00025A","00040A","00071A","01004A","03005A","03010A","03058A","04009A","04023A","04045A","05038A","06042A","06052A","07047A","07062A","08012A","09043A","10022A","11036A","12053A","13023A","14008A","14026A","14045A","14068A","15013A"]},{id:"IridiumGroup",name:"Iridium Debris",groupType:"nameRegex",data:/IRIDIUM(?!.*DEB)/},{id:"Iridium33DebrisGroup",name:"Iridium 33 Debris",groupType:"nameRegex",data:/(COSMOS 2251|IRIDIUM 33) DEB/},{id:"GlonassGroup",name:"Glonass",groupType:"nameRegex",data:/GLONASS/},{id:"GalileoGroup",name:"Galileo",groupType:"nameRegex",data:/GALILEO/},{id:"FunGroup",name:"Fun",groupType:"nameRegex",data:/SYLDA/},{id:"WestfordNeedlesGroup",name:"Westford Needles",groupType:"nameRegex",data:/WESTFORD NEEDLES/},{id:"SpaceXGroup",name:"Space X",groupType:"nameRegex",data:/FALCON [19]/},{id:"DebrisGroup",name:"Debris",groupType:"objectType",data:"DEBRIS"},{id:"Starlink",name:"Starlink",groupType:"nameRegex",data:/STARLINK/},{id:"Unknown",name:"Unknown Objects",groupType:"objectType",data:"UNKNOWN"}]},Ne=80/Math.PI,T={satMovementChange:"satMovementChange",selectedSatChange:"selectedSatChange",satHover:"sathoverChange",satDataLoaded:"satdataloaded",closeWindow:"closeWindow",cruncherReady:"cruncherReady"};class Fe{constructor(e,t={}){o(this,"element");o(this,"id");o(this,"options");o(this,"listeners",{});o(this,"firstOpen",!0);o(this,"windowManager");this.element=document.querySelector(`#${e}`),this.id=e,this.options=t,this.listeners={},this.firstOpen=!0,this.initEvents()}setWindowManager(e){this.windowManager=e}open(){this.element&&(this.firstOpen=!1,this.element.classList.add("active"),this.element.classList.add("visible"),this.element.classList.remove("hidden"),this.windowManager.bringWindowToFront(this),this.fireEvent("open",{}))}close(){this.element&&(this.element.classList.remove("active"),this.element.classList.remove("visible"),this.element.classList.add("hidden"),this.fireEvent("close",{}))}isOpen(){return this.element?this.element.classList.contains("visible"):!1}initEvents(){if(!this.element)return;const e=this.element.querySelector(".window-close");e&&e.addEventListener("click",()=>{this.close()})}moveTo(e,t){this.element&&(this.element.style.top=`${t}px`,this.element.style.left=`${e}px`)}getLocation(){if(!this.element)return{x:0,y:0};const e=this.element.style;return e.x?{x:e.x,y:e.y}:{x:this.element.offsetLeft,y:this.element.offsetTop}}addEventListener(e,t){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e])this.listeners[e].add(t);else throw new Error("unknown event")}fireEvent(e,t){this.listeners[e]&&this.listeners[e].forEach(i=>{i(t)})}}const qe=100;class He{constructor(){o(this,"windows",[]);o(this,"windowsById",{});o(this,"initialOpen",!1)}bringWindowToFront(e){const t=e.element;let s=-1;for(let i=0;i<this.windows.length;i++)if(this.windows[i].id===(t==null?void 0:t.id)){s=i;break}s>-1&&(this.windows.splice(s,1),this.windows.push(e));for(let i=0;i<this.windows.length;i++){const r=this.windows[i];r&&r.element&&r.element.style&&(r.element.style.zIndex=qe+i+1)}}getWindow(e){return this.windowsById[e]}registerWindow(e,t={}){const s=new Fe(e,t);s.setWindowManager(this),this.windows.push(s),this.windowsById[e]=s,this.makeDraggable(s)}getTopWindow(){for(let e=this.windows.length-1;e>=0;e--)if(this.windows[e].isOpen())return this.windows[e]}openWindow(e){const s={x:100,y:100},i=this.windowsById[e],r=this.getTopWindow();let n=!1;if(i){let{x:l,y:h}=i.getLocation();if(r||(l=s.x,h=s.y,this.initialOpen=!1),n=i.firstOpen,n&&r){const c=r.getLocation();c&&(c.x>window.innerWidth/2?l=c.x-42-300:l=c.x+42,c.y>window.innerHeight/2?h=c.y-42-300:h=c.y+42)}if(i.open(),!this.initialOpen&&!n){const c=i.getLocation();c&&(l=c.x,h=c.y)}(l>window.innerWidth||l<0)&&(l=s.x),(h>window.innerHeight||h<0)&&(h=s.y),this.bringWindowToFront(i),i.moveTo(l,h),this.initialOpen=!1}}closeWindow(e){const t=this.windowsById[e];t&&t.close()}makeDraggable(e){let t=0,s=0,i=0,r=0;const n=e.element;if(!n)return;const l=n.querySelector(".drag-zone")||n;function h(c){const d=`${t-(r-c.clientY)}px`,b=`${s-(i-c.clientX)}px`;n&&n.style&&(n.style.top=d,n.style.left=b)}n.classList.add("draggable"),n.addEventListener("click",()=>{this.bringWindowToFront(e)}),l.addEventListener("mousedown",c=>{c.preventDefault(),s=n.offsetLeft,t=n.offsetTop,i=c.clientX,r=c.clientY,this.bringWindowToFront(e),n.style.right="unset",n.style.bottom="unset",n.style.left=`${s}px`,n.style.top=`${t}px`,n.classList.add("dragging"),l.addEventListener("mousemove",h)}),n.addEventListener("mouseup",c=>{c.preventDefault(),l.removeEventListener("mousemove",h),n.classList.remove("dragging")}),n.addEventListener("mouseout",c=>{c.preventDefault(),l.removeEventListener("mousemove",h),n.classList.remove("dragging")})}}const F=200;let m,k,X=!1,P=-1,C=!1,Q;function ee(){return C}function Ve(){return Q}function _e(){return C?document.querySelector("#search").value:null}function Je(){return X}function Ze(){return P}function Ye(){X=!1,P=-1,m.setHoverSatellite(P)}function O(a){const e=document.querySelector("#search-results");e&&(a?e.style.display="block":e.style.display="none",C=a)}function Ke(){O(!ee())}function Xe(){O(!0)}function te(){O(!1);const a=m.getSatelliteGroups();a&&a.clearSelect()}function se(a,e){const t=document.querySelector("#search-results"),s=m.getSatelliteStore();if(!s)return;let i="";for(const r of a){if(r.satId===void 0)continue;const n=s.getSatellite(r.satId);if(!n){f.warn("satellite not found",r.satId);continue}i+=`<div class="search-result" data-sat-id="${n.id}">`,r.type!=="name"?i+=n.OBJECT_NAME:i+=`
+`),r=ae.clone({}),n=new V({uniforms:r,vertexShader:s,fragmentShader:i,side:ne,blending:le,transparent:!0}),l=e.km2pixels(this.radiusInKm+.1),h=new D(l,32,32),c=new E(h,n),d=1.019;c.scale.set(d,d,d),t.add(c)}async init(e,t){t.config&&(this.baseUrl=t.config.baseUrl),this.group=new $;const s=`${this.baseUrl}images`,i=await this.loadTexture(`${s}/earth-blue-marble.jpg`),r=await this.loadTexture(`${s}/nightearth-4096.png`),n=await this.loadTexture(`${s}/8081_earthbump4k.jpg`),l=await this.loadTexture(`${s}/earth-water.png`),h=new z({map:i,bumpMap:n,emissiveMap:r,emissive:new B(8947848),emissiveIntensity:5,specularMap:l,specular:1,shininess:15,bumpScale:1}),c=e.km2pixels(this.radiusInKm),d=new D(c,32,32);this.sphere=new E(d,h),this.group.add(this.sphere),this.addClouds&&this.initClouds(e,this.group),this.addAtmosphere&&this.initAtmosphere(e,this.group),e.add(this.group),this.sphere.geometry.computeBoundingBox(),this.sphere.geometry.computeBoundingSphere()}update(){}getMesh(){return this.sphere}}const A=class A{constructor(){o(this,"fastTime",!1);o(this,"showGeometry",!1);o(this,"lightSouce");o(this,"lightSourceGeometery");o(this,"hour",0);o(this,"objectGroup");o(this,"scene");o(this,"visible",!0)}degreesToReadians(e){return e*A.deg2RadMult}calculateSunLoc(){let t=this.hour;(t===void 0||t===-1)&&(t=he.utc().hour);const s=t/24*360+180;return{x:25*Math.cos(this.degreesToReadians(s)),z:25*Math.sin(this.degreesToReadians(s))}}init(e){this.fastTime?setInterval(()=>{this.hour+=.05},100):this.hour=-1,this.calculateSunLoc();const t=this.calculateSunLoc(),s={x:t.x,y:0,z:t.z};if(this.scene=e,this.objectGroup=new $,this.lightSouce=new ce(16777215,2e3),this.lightSouce.position.set(s.x,s.y,s.z),this.objectGroup.add(this.lightSouce),this.showGeometry){const i=new D(.1,32,32);this.lightSourceGeometery=new E(i),this.lightSourceGeometery.position.set(s.x,s.y,s.z),this.objectGroup.add(this.lightSourceGeometery)}e.add(this.objectGroup)}update(){}setVisible(e){var t,s;e?this.visible||(t=this.scene)==null||t.add(this.objectGroup):this.visible&&((s=this.scene)==null||s.remove(this.objectGroup)),this.visible=e}};o(A,"deg2RadMult",Math.PI/180);let I=A;class Te{init(e,t){const s=t.config.baseUrl,i=new W().load(`${s}textures/example_render.jpg`);e.background=i}update(){}}function Ae(a){return new Worker("/StuffInSpace/assets/SatCruncherWorker-BkJiidUT.js",{name:a==null?void 0:a.name})}const Ce="debug",v=["error","warn","info","debug"];let y={},x=new Proxy({logLevel:Ce,enabledOutputs:{},error:y.error,warn:y.warn,info:y.info,debug:y.debug,setLogLevel:J},{});function L(a,e,t,...s){a.enabledOutputs[e]&&t(e.toUpperCase(),...s)}function J(a){const e=v.indexOf(a.toLowerCase());if(e<0)throw new Error("Unknown log level");for(let t=0;t<v.length;t++)x.enabledOutputs[v[t]]=t<=e}function Ge(){return x}function Oe(){const a=x,e=a.enabledOutputs;for(let t=0;t<v.length;t++)e[v[t]]=!0;y={error:L.bind(a,{enabledOutputs:e},"error",console.error),warn:L.bind(a,{enabledOutputs:e},"warn",console.warn),info:L.bind(a,{enabledOutputs:e},"info",console.info),debug:L.bind(a,{enabledOutputs:e},"debug",console.debug)},x=new Proxy({...x,...y},{})}Oe();const u=Ge();class Z{constructor(e,t){o(this,"name");o(this,"colorizer");this.name=e,this.colorizer=t}getSatelliteColor(e,t){return this.colorizer(e,t)}}class U extends Z{constructor(){super("Default color scheme",e=>{let t=[1,1,0,1],s=!1;return e&&(s=!0,e.OBJECT_TYPE==="PAYLOAD"?t=[1,.2,0,1]:e.OBJECT_TYPE==="ROCKET BODY"?t=[.2,.5,1,.85]:e.OBJECT_TYPE==="DEBRIS"&&(t=[.5,.5,.5,.85])),{color:t,pickable:s}})}}class Ie extends Z{constructor(){super("Group color scheme",(e,t)=>e&&t&&t.hasSat(e.id)?{color:[1,.2,0,1],pickable:!0}:{color:[1,1,1,.2],pickable:!0})}}class Me{constructor(){o(this,"baseUrl","");o(this,"worker");o(this,"currentColorScheme",new U);o(this,"numSats",1);o(this,"maxSize",0);o(this,"satPos",new Float32Array);o(this,"satVel",new Float32Array);o(this,"satAlt",new Float32Array);o(this,"satelliteColors",[]);o(this,"cruncherReady",!1);o(this,"scene");o(this,"particles");o(this,"geometry");o(this,"satelliteStore");o(this,"shaderStore");o(this,"selectedSatelliteIndexes",[]);o(this,"satelliteGroup");o(this,"hoverSatelliteIdx",-1)}setColorScheme(e){this.currentColorScheme=e}debugRaycastSelection(){if(this.satelliteStore&&(this.satelliteColors.length===0&&this.satelliteStore.satData.length>0&&(this.satelliteColors=new Array(this.satelliteStore.satData.length*4),this.satelliteColors.fill(1,0,this.satelliteColors.length),this.geometry&&this.geometry.setAttribute("color",new g(this.satelliteColors,4))),this.selectedSatelliteIndexes.length>0&&this.geometry)){for(let e=0;e<this.selectedSatelliteIndexes.length;e++){const t=this.selectedSatelliteIndexes[e]*4;this.satelliteColors[t]=0,this.satelliteColors[t+1]=1,this.satelliteColors[t+2]=0,this.satelliteColors[t+3]=1}this.geometry.setAttribute("color",new g(this.satelliteColors,4))}}updateSatellites(){var e;if(this.satelliteStore){if(this.satPos&&this.satPos.length>0&&(e=this.geometry)!=null&&e.attributes){const t=this.satelliteStore.satData,s=t.length;this.updateSatellitesGeometry(),this.updateSatellitesMaterial(s,t)}this.debugRaycastSelection()}}updateSatellitesMaterial(e,t){var s,i,r;if((s=this.geometry)!=null&&s.attributes.color&&this.currentColorScheme&&this.satelliteStore){(this.satelliteColors.length===0||e*4!==this.satelliteColors.length)&&(this.satelliteColors=new Array(this.satelliteStore.satData.length*4),this.satelliteColors.fill(1,0,this.satelliteColors.length));for(let n=0;n<t.length;n++){let l=(r=(i=this.currentColorScheme)==null?void 0:i.getSatelliteColor(t[n],this.satelliteGroup))==null?void 0:r.color;l||(l=[0,0,0]);const h=n*4;this.satelliteColors[h]=l[0],this.satelliteColors[h+1]=l[1],this.satelliteColors[h+2]=l[2],this.satelliteColors[h+3]=l[3]}this.geometry.setAttribute("color",new g(this.satelliteColors,4))}}updateSatellitesGeometry(){var e;if((e=this.geometry)!=null&&e.attributes.position&&this.satelliteStore){const t=new Float32Array;t.fill(0,0,this.satelliteStore.satData.length*3),this.geometry.setAttribute("position",new g(t,3));for(let s=0;s<this.satPos.length;s++)isNaN(this.satPos[s])&&(this.satPos[s]=0);this.geometry.setAttribute("position",new g(this.satPos,3)),this.geometry.computeBoundingBox(),this.geometry.computeBoundingSphere()}}onMessage(e){var r;if(!this.satelliteStore)return;const t=this.satelliteStore.getSatData();if(!t)return;const s=t.length;let i;try{if(!this.satelliteStore.gotExtraData){const n=performance.now();if(e.data.extraData){if(i=JSON.parse(e.data.extraData),!i)return;for(let l=0;l<s;l++)t[l].inclination=i[l].inclination,t[l].eccentricity=i[l].eccentricity,t[l].raan=i[l].raan,t[l].argPe=i[l].argPe,t[l].meanMotion=i[l].meanMotion,t[l].semiMajorAxis=i[l].semiMajorAxis,t[l].semiMinorAxis=i[l].semiMinorAxis,t[l].apogee=i[l].apogee,t[l].perigee=i[l].perigee,t[l].period=i[l].period;u.debug(`sat.js copied extra data in ${performance.now()-n} ms`),this.satelliteStore.setSatelliteData(t,!0);return}}this.satPos=new Float32Array(e.data.satPos),this.satVel=new Float32Array(e.data.satVel),this.satAlt=new Float32Array(e.data.satAlt),this.satelliteStore.setPositionalData(this.satVel,this.satPos,this.satAlt),this.cruncherReady||((r=document.querySelector("#load-cover"))==null||r.classList.add("hidden"),this.cruncherReady=!0),this.updateSatellites()}catch(n){u.debug("Error in worker response",n),u.debug("worker message",e)}}onSatDataLoaded(){if(this.satelliteStore)if(this.worker){const e=JSON.stringify(this.satelliteStore.satData);u.debug("Sending data to sat cruncher worker, to perform work"),this.worker.postMessage(e)}else u.error("worker is not available")}setSatelliteGroup(e){this.satelliteGroup=e,this.satelliteGroup?this.currentColorScheme=new Ie:this.currentColorScheme=new U}getSatellitegroup(){return this.satelliteGroup}setSelectedSatellites(e){u.debug("Updated selected satellites",e),this.selectedSatelliteIndexes=e,this.updateSatellites()}setSelectedSatellite(e){this.setSelectedSatellites([e])}setHoverSatellite(e){this.hoverSatelliteIdx=e,this.updateSatellites()}initGeometry(){if(!this.satelliteStore)throw new Error("satelliteStore is not available");if(!this.shaderStore)throw new Error("sahderStore is not available");const e=(this.satelliteStore.satData||[]).length,t=new _,s=new Float32Array,i=new Float32Array,r=new Array(e*4);s.fill(0,0,e*3),r.fill(0,0,e*3),i.fill(10,0,e),t.setAttribute("position",new g(s,3)),t.setAttribute("color",new g(r,4)),t.setAttribute("size",new g(i,2));const n=new W().load(`${this.baseUrl}/images/circle.png`),l=this.shaderStore.getShader("dot2"),h=new V({uniforms:{color:{value:new B(16777215)},pointTexture:{value:n}},clipping:!1,vertexShader:l.vertex,fragmentShader:l.fragment,blending:de,blendSrcAlpha:ue,blendDstAlpha:fe,transparent:!0,alphaTest:.5,depthTest:!0,depthWrite:!1});t.center(),this.geometry=t,this.particles=new ge(t,h),this.scene&&this.scene.add(this.particles),window.addEventListener("visibilitychange",()=>{var c;(c=this.worker)==null||c.postMessage(JSON.stringify({state:{running:document.visibilityState==="visible"}}))})}getObject3D(){return this.particles}initSatWorker(e={}){u.info("Kicking off sat-cruncher-worker"),this.worker=new Ae,this.worker.onmessage=this.onMessage.bind(this),this.worker.postMessage(JSON.stringify({config:e}))}async init(e,t){this.satelliteStore=t.satelliteStore,this.shaderStore=t.shaderStore,this.scene=e;const s=t.config||{};let i={};s.satWorker&&(i={...s.satWorker,logLevel:s.logLevel}),this.initSatWorker(i),t!=null&&t.config&&(this.baseUrl=t.config.baseUrl),this.satelliteStore&&(this.satelliteStore.addEventListener("satdataloaded",this.onSatDataLoaded.bind(this)),await this.satelliteStore.loadSatelliteData(),this.initGeometry(),this.satelliteStore.gotExtraData&&this.updateSatellites())}update(){}}function ke(a){return new Worker("/StuffInSpace/assets/OrbitCalculationWorker-_Yyn1p1l.js",{name:a==null?void 0:a.name})}class Pe{constructor(){o(this,"config",{});o(this,"segmentCount",255);o(this,"orbitWorker");o(this,"selectedSatellites",[]);o(this,"hoverSatelliteIdx",-1);o(this,"satelliteGroups");o(this,"satelliteGroup");o(this,"inProgress",[]);o(this,"scene");o(this,"selectColor",[0,1,0,1]);o(this,"hoverColor",[1,.92,.23,1]);o(this,"groupColor",[.3,.5,1,.4]);o(this,"orbitTracks",[]);o(this,"satelliteStore");o(this,"satelliteOrbitGroup")}calculateOrbits(e){e=e.filter(t=>!this.inProgress[t]),this.orbitWorker?this.orbitWorker.postMessage(JSON.stringify({isInit:!1,satId:e})):u.error("Orbit worker is undefined"),e.forEach(t=>this.inProgress[t]=!0)}onSatellitesLoaded(){this.satelliteStore&&(this.inProgress=new Array(this.satelliteStore.size()),this.orbitTracks=new Array(this.satelliteStore.size()),this.orbitWorker&&this.orbitWorker.postMessage(JSON.stringify({isInit:!0,satData:this.satelliteStore.satData,numSegs:this.segmentCount})))}isTrackVisible(e){return this.selectedSatellites.indexOf(e)>-1||e===this.hoverSatelliteIdx||this.satelliteGroup&&this.satelliteGroup.hasSat(e)}getTrackColor(e){let t=[1,1,0];return e===this.hoverSatelliteIdx?t=this.hoverColor:this.selectedSatellites.indexOf(e)>-1?t=this.selectColor:this.satelliteGroup&&this.satelliteGroup.hasSat(e)&&(t=this.groupColor),new B(t[0],t[1],t[2])}addOrbitTrack(e,t){const s=this.getTrackColor(e),i=new pe({color:s,linewidth:10}),r=new _;r.setAttribute("position",new g(t,3));const n=new me(r,i);n.name=`${e}`,this.satelliteOrbitGroup&&this.satelliteOrbitGroup.add(n),this.orbitTracks[e]=n}updateOrbitTrack(e,t){const s=this.orbitTracks[e];if(s){const i=s.material;i.color=this.getTrackColor(e),i.needsUpdate=!0,t&&(s.geometry.setAttribute("position",new g(t,3)),s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere())}}removeOrbitTrack(e){var t;if(this.orbitTracks[e]){const s=this.orbitTracks[e];(t=this.satelliteOrbitGroup)==null||t.remove(s),s.geometry&&s.geometry.dispose(),this.orbitTracks[e]=void 0}}onMessage(e){const{satId:t}=e.data;this.scene&&(this.orbitTracks[t]?this.updateOrbitTrack(t,e.data.pointsOut):this.isTrackVisible(t)&&this.addOrbitTrack(t,e.data.pointsOut)),this.inProgress[t]=!1}isHoverSatellite(e){return this.hoverSatelliteIdx!==void 0&&e!==-1&&this.hoverSatelliteIdx===e}isSelectedSatellite(e){return this.selectedSatellites.length>0?this.selectedSatellites.indexOf(e)>-1:!1}refreshOrbits(){if(this.satelliteGroup){const e=this.satelliteGroup.sats;for(let t=0;t<e.length;t++)this.updateOrbitTrack(e[t].satId)}}setSelectedSatellites(e){if(this.selectedSatellites.length>0)for(let t=0;t<this.selectedSatellites.length;t++){const s=this.selectedSatellites[t];this.orbitTracks[s]&&(!this.satelliteGroup||!this.satelliteGroup.hasSat(s)?this.removeOrbitTrack(s):this.updateOrbitTrack(s))}this.selectedSatellites=e,this.calculateOrbits(e),this.refreshOrbits()}setSelectedSatellite(e){this.setSelectedSatellites([e])}setHoverSatellite(e){let t=!1;const s=this.hoverSatelliteIdx||-1;this.hoverSatelliteIdx&&this.hoverSatelliteIdx>-1&&(t=this.selectedSatellites.indexOf(this.hoverSatelliteIdx)<0,t=t&&(!this.satelliteGroup||!this.satelliteGroup.hasSat(this.hoverSatelliteIdx))),this.hoverSatelliteIdx=e,t?this.removeOrbitTrack(s):this.updateOrbitTrack(s),this.calculateOrbits([e]),this.refreshOrbits()}setSatelliteGroup(e){if(this.satelliteGroup){this.setSelectedSatellites([]),this.setHoverSatellite(-1);for(let t=0;t<this.orbitTracks.length;t++)this.orbitTracks[t]&&this.removeOrbitTrack(t)}if(this.satelliteGroup=e,this.satelliteGroup){const s=this.satelliteGroup.sats.map(i=>i.satId);this.calculateOrbits(s)}}init(e,t){this.config=t.config,this.scene=e,this.orbitWorker=new ke,this.orbitWorker.onmessage=this.onMessage.bind(this),this.satelliteStore=t.satelliteStore,this.orbitWorker.postMessage(JSON.stringify({config:{logLevel:this.config.logLevel}})),this.satelliteStore&&(this.satelliteStore.addEventListener("satdataloaded",this.onSatellitesLoaded.bind(this)),this.satelliteStore.size()>0&&(this.inProgress=new Array(this.satelliteStore.size()),this.onSatellitesLoaded())),t.satelliteGroups&&(this.satelliteGroups=t.satelliteGroups),this.satelliteOrbitGroup=new $,this.scene.add(this.satelliteOrbitGroup)}update(){}}const C=class C extends Se{constructor(){super();o(this,"pxToRadius",3185.5)}setPixels2Radius(t){this.pxToRadius=t}getPixels2Radius(){return this.pxToRadius}km2pixels(t){return t/this.pxToRadius}alitudeToPixels(t){return(C.earthRadiusInKm+t)/this.pxToRadius}};o(C,"earthRadiusInKm",6371);let M=C;class Y{constructor(e,t,s,i,r){o(this,"sats",[]);o(this,"id");o(this,"name");o(this,"groupType");o(this,"data");o(this,"satelliteStore");if(this.id=e,this.name=t,this.groupType=s,this.data=i,this.satelliteStore=r,!this.satelliteStore)throw new Error("satelliteStore is required")}reload(){switch(this.sats=[],this.groupType){case"intlDes":this.searchIntlDes();break;case"nameRegex":this.searchNameRegex();break;case"idList":this.searchIdList();break;case"objectType":this.searchObjectType();break;default:throw new Error("Invalid groupType")}}searchObjectType(){if(typeof this.data!="string")throw new Error("objectType must be a string");const t=this.satelliteStore.search({["OBJECT_TYPE"]:this.data});for(const s of t)this.sats.push({satId:s.id,isIntlDes:!1,strIndex:0})}searchIdList(){if(typeof this.data=="string")throw new Error("idList must be an array");for(const e of this.data)this.sats.push({satId:e,isIntlDes:!1,strIndex:0})}searchNameRegex(){if(typeof this.data!="string")throw new Error("nameRegex must be a string");const e=new RegExp(this.data),t=this.satelliteStore.searchNameRegex(e);for(const s of t)this.sats.push({satId:s,isIntlDes:!1,strIndex:0})}searchIntlDes(){if(typeof this.data=="string")throw new Error("intlDes must be an array");for(const e of this.data)this.sats.push({satId:this.satelliteStore.getIdFromIntlDes(e),isIntlDes:!0,strIndex:0})}getSat(e){return this.satelliteStore.satData.find(t=>t.id===e)}hasSat(e){for(const t of this.sats)if(t.satId===e)return!0;return!1}}class Re{constructor(e,t){o(this,"groups",{});o(this,"selectedGroup");o(this,"sats",[]);o(this,"satelliteStore");if(!t)throw new Error("satelliteStore is required");this.satelliteStore=t,this.resetConfig(e),this.satelliteStore.addEventListener("satdataloaded",this.onSatDataLoaded.bind(this))}asArray(){return Object.values(this.groups)}selectGroup(e){if(this.selectedGroup=e,!e){this.clearSelect();return}}forEach(e){for(let t=0;t<this.sats.length;t++)e(this.sats[t].satId)}clearSelect(){this.selectedGroup=void 0}getGroupById(e){if(e)return e=e.toLowerCase(),this.groups[e]}getSelectedGroup(){return this.selectedGroup}reloadGroups(){const e=Object.keys(this.groups);for(let t=0;t<e.length;t++)this.groups[e[t]].reload()}resetConfig(e){const t=e;for(let s=0;s<t.length;s++)u.debug(`registering satellite group ${t[s].name} (id: ${t[s].id})`),this.groups[t[s].id.toLowerCase()]=new Y(t[s].id.toLowerCase(),t[s].name,t[s].groupType,t[s].data,this.satelliteStore)}onSatDataLoaded(){this.reloadGroups()}}class K{constructor(e){o(this,"listeners",{});o(this,"supportedEvents");this.supportedEvents=e}addEventListener(e,t){if(!e)throw new Error("eventName must not be undefined");if(this.supportedEvents&&this.supportedEvents.indexOf(e)<0)throw new Error(`unsupported event ${e}`);if(e=e.toLowerCase(),this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e])this.listeners[e].add(t);else throw new Error("unknown event")}fireEvent(e,t){if(!e)throw new Error("undefined eventName");e=e.toLowerCase(),this.listeners[e]&&this.listeners[e].forEach(i=>{i(t)})}}const We={baseUrl:"/StuffInSpace/"};class $e{constructor(e={}){o(this,"tleUrl",`${We.baseUrl}/data/attributed-TLE.json`);o(this,"eventManager");o(this,"satData",[]);o(this,"attribution");o(this,"updateDate");o(this,"satelliteVelocities",new Float32Array);o(this,"satellitePositions",new Float32Array);o(this,"satelliteAltitudes",new Float32Array);o(this,"gotExtraData",!1);o(this,"gotPositionalData",!1);o(this,"loaded",!1);this.eventManager=new K,e.tleUrl&&(this.tleUrl=e.tleUrl)}async loadSatelliteData(){try{const e=await j.get(this.tleUrl,{params:{t:Date.now()}});if(e.data){Array.isArray(e.data)?this.satData=e.data:(this.satData=e.data.data,this.attribution=e.data.source,this.updateDate=e.data.date);for(let t=0;t<this.satData.length;t++){if(this.satData[t].INTLDES){const s=Number(this.satData[t].INTLDES.substring(0,2)),r=(s>50?"19":"20")+s.toString(),n=this.satData[t].INTLDES.substring(2);this.satData[t].intlDes=`${r}-${n}`}else this.satData[t].intlDes="unknown";this.satData[t].id=t}}this.eventManager.fireEvent("satdataloaded",this.satData),this.loaded=!0}catch(e){u.error("error loading TLE data",e)}}getAttribution(){return this.attribution}getUpdatedDate(){return this.updateDate}setSatelliteData(e,t=!1){this.satData=e,this.gotExtraData=t,t&&this.eventManager.fireEvent("satextradataloaded",this.satData)}setPositionalData(e,t,s){this.satelliteVelocities=e,this.satellitePositions=t,this.satelliteAltitudes=s,this.gotPositionalData=!0}getSatellitePosition(e){const t=e*3;if(this.satellitePositions&&t<this.satellitePositions.length)return[this.satellitePositions[t],this.satellitePositions[t+1],this.satellitePositions[t+3]]}getSatData(){return this.satData||[]}getPositions(){return this.satellitePositions}getAltitudes(){return this.satelliteAltitudes}getVelocitities(){return this.satelliteVelocities}size(){return this.satData.length}searchNameRegex(e){const t=[];for(let s=0;s<this.satData.length;s++)e.test(this.satData[s].OBJECT_NAME)&&t.push(s);return t}search(e){const t=Object.keys(e);let s=Object.assign([],this.satData);for(const i of t)s=s.filter(r=>r[i]===e[i]);return s}searchName(e){const t=[];for(let s=0;s<this.satData.length;s++)this.satData[s].OBJECT_NAME===e&&t.push(s);return t}getIdFromIntlDes(e){for(let t=0;t<this.satData.length;t++)if(this.satData[t].INTLDES===e||this.satData[t].intlDes===e)return t;return null}getSatellite(e){if(e===-1||e===void 0||!this.satData)return;const t=new Proxy(this.satData[e],{});if(t)return this.gotPositionalData&&(t.altitude=this.satelliteAltitudes[e],t.velocity=Math.sqrt(this.satelliteVelocities[e*3]*this.satelliteVelocities[e*3]+this.satelliteVelocities[e*3+1]*this.satelliteVelocities[e*3+1]+this.satelliteVelocities[e*3+2]*this.satelliteVelocities[e*3+2]),t.position={x:this.satellitePositions[e*3],y:this.satellitePositions[e*3+1],z:this.satellitePositions[e*3+2]}),t}addEventListener(e,t){this.eventManager.addEventListener(e,t)}}class Be{constructor(e=""){o(this,"basePath","shaders/");o(this,"baseUrl",`./${this.basePath}`);o(this,"shaders",["earth-fragment","earth-vertex","dot-fragment","dot-vertex","dot2-fragment","dot2-vertex","pick-fragment","pick-vertex","path-fragment","path-vertex"]);o(this,"shaderData",{});this.baseUrl=`${e}${this.basePath}`}async loadShader(e){const t=`${this.baseUrl}${e}.glsl`;u.debug(`loading shader from ${t}`);const s=await j.get(t);if(s.data)return s.data;throw new Error("no data received")}async load(){try{for(let e=0;e<this.shaders.length;e++){const t=await this.loadShader(this.shaders[e]);this.shaderData[this.shaders[e]]=t}}catch(e){u.error("Errors while loading shaders",e)}}addShader(e,t,s){this.shaderData[`${e}-fragment`]=t,this.shaderData[`${e}-vertex`]=s}getFragmentShader(e){return this.shaderData[`${e}-fragment`]}getVertexShader(e){return this.shaderData[`${e}-vertex`]}getShader(e){return{vertex:this.getVertexShader(e),fragment:this.getFragmentShader(e)}}}class je{constructor(e){o(this,"config",{canvasSelector:".viewer"});o(this,"sceneComponents",[]);o(this,"sceneComponentsByName",{});o(this,"scene");o(this,"camera");o(this,"controls");o(this,"renderer");o(this,"context",{});o(this,"satelliteGroups");o(this,"satelliteStore");o(this,"shaderStore");o(this,"selectedSatelliteIdx",-1);o(this,"eventManager",new K);o(this,"ready",!1);o(this,"raycaster");o(this,"showRaycastArrow",!1);o(this,"raycastArrow");o(this,"satellites");o(this,"orbits");o(this,"earth");o(this,"mouseMoved",!1);o(this,"targetZoom",5);o(this,"minZoomLevel",1);o(this,"maxZoomLevel",10);this.config={...this.config,...e}}async registerSceneComponent(e,t){u.debug(`Registering scene component ${e}`),this.sceneComponents.push(t),this.sceneComponentsByName[e]=t,await t.init(this.scene,this.context)}getCenterPoint(e){if(e){const t=e.geometry;t.computeBoundingBox();const s=new Le;if(t.boundingBox)return t.boundingBox.getCenter(s),e.localToWorld(s),s}}onWindowResize(){this.camera&&(this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix()),this.renderer&&this.renderer.setSize(window.innerWidth,window.innerHeight)}onSatDataLoaded(e){this.eventManager.fireEvent("satdataloaded",e),this.ready=!0}findSatellitesAtMouse(e){var n;const t=(n=this.renderer)==null?void 0:n.domElement;if(!this.raycaster||!this.scene||!this.camera||!t)return[];this.raycaster.params.Points.threshold=.05;const s=t.getBoundingClientRect(),i=new De;i.x=(e.x-s.left)/t.clientWidth*2-1,i.y=-((e.y-s.top)/t.clientHeight*2)+1,this.raycaster.setFromCamera(i,this.camera),this.showRaycastArrow&&(this.raycastArrow&&(this.scene.remove(this.raycastArrow),this.raycastArrow.dispose(),this.raycastArrow=void 0),this.raycastArrow=new we(this.raycaster.ray.direction,this.raycaster.ray.origin,300,16776960,void 0,1),this.scene.add(this.raycastArrow));const r=this.raycaster.intersectObjects(this.scene.children,!0);if(r.length>0){r.sort((h,c)=>h.object.type==="Line"&&c.object.type==="Points"?1:h.object.type==="Points"&&c.object.type==="Line"?-1:0);let l=r.map(h=>h.object.type==="Points"?h.index:h.object.type==="Line"?parseInt(h.object.name):-1).filter(h=>h!==-1);if(l.length>0){const h=[];for(const c of l)this.isValidTarget(c)&&h.push(c);l=h}return l}return[]}isValidTarget(e){var s;const t=(s=this.satellites)==null?void 0:s.getSatellitegroup();return t?t.hasSat(e):!0}onClick(e){var n,l,h,c;const t=(n=this.renderer)==null?void 0:n.domElement;if(!this.raycaster||!this.scene||!this.camera||!t)return;const s=this.findSatellitesAtMouse({x:e.clientX,y:e.clientY});let i=-1,r;s&&s.length>0&&(i=s[0],r=(l=this.satelliteStore)==null?void 0:l.getSatellite(i)),this.selectedSatelliteIdx=i,(h=this.satellites)==null||h.setSelectedSatellite(i),(c=this.orbits)==null||c.setSelectedSatellite(i),this.eventManager.fireEvent("selectedSatChange",r)}onMouseMove(){this.mouseMoved=!0}onMouseDown(){this.mouseMoved=!1,this.controls&&(this.controls.autoRotate=!1),window.addEventListener("mousemove",this.onMouseMove.bind(this))}onMouseUp(e){this.mouseMoved||this.onClick(e),this.mouseMoved=!1,window.removeEventListener("mousemove",this.onMouseMove.bind(this))}onHover(e){var n,l,h,c;const t=(n=this.renderer)==null?void 0:n.domElement;if(!this.raycaster||!this.scene||!this.camera||!t)return;const s=this.findSatellitesAtMouse({x:e.clientX,y:e.clientY});let i=-1,r;s&&s.length>0&&(i=s[0],r=(l=this.satelliteStore)==null?void 0:l.getSatellite(i)),(h=this.satellites)==null||h.setHoverSatellite(i),(c=this.orbits)==null||c.setHoverSatellite(i),this.eventManager.fireEvent("sathoverChange",r),this.mouseMoved=!0}async init(){var e;try{this.scene=new M,this.camera=new ye(45,window.innerWidth/window.innerHeight,.1,1e3),this.camera.position.z=15,this.camera.zoom=1,this.renderer=new be({antialias:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),(e=document.querySelector(this.config.canvasSelector))==null||e.appendChild(this.renderer.domElement),u.debug(`Using WebGL 2: ${this.renderer.capabilities.isWebGL2}`),this.controls=new ve(this.camera,this.renderer.domElement),this.controls.rotateSpeed=.33,this.controls.enablePan=!1,this.controls.enableZoom=!0,this.controls.enableDamping=!0,this.controls.dampingFactor=.05,this.controls.zoomSpeed=3,this.controls.maxZoom=10,this.controls.minZoom=3,this.controls.autoRotate=!0,this.controls.autoRotateSpeed=.5,this.controls.maxDistance=50,this.controls.minDistance=3,this.controls.update(),this.raycaster=new xe,this.satelliteStore=new $e(this.config),this.satelliteGroups=new Re(this.config.satelliteGroups,this.satelliteStore),this.shaderStore=new Be(this.config.baseUrl),u.debug("loading shaders"),await this.shaderStore.load(),this.context.satelliteGroups=this.satelliteGroups,this.context.config=this.config,this.context.satelliteStore=this.satelliteStore,this.context.shaderStore=this.shaderStore,this.satelliteStore.addEventListener("satdataloaded",this.onSatDataLoaded.bind(this)),this.earth=new Ee,await this.registerSceneComponent("earth",this.earth),await this.registerSceneComponent("sun",new I),await this.registerSceneComponent("universe",new Te),this.satellites=new Me,await this.registerSceneComponent("satellites",this.satellites),this.orbits=new Pe,await this.registerSceneComponent("orbits",this.orbits);const t=this.getCenterPoint(this.earth.getMesh());t&&(this.controls.target=t),this.camera.updateProjectionMatrix(),window.addEventListener("resize",this.onWindowResize.bind(this));const s=this.renderer.domElement;s.addEventListener("mousedown",this.onMouseDown.bind(this)),s.addEventListener("mouseup",this.onMouseUp.bind(this)),s.addEventListener("mousemove",this.onHover.bind(this))}catch(t){u.error("Error while initialising scene",t)}}animate(){requestAnimationFrame(this.animate.bind(this));for(const e of this.sceneComponents)e.update(this.scene);this.controls&&this.controls.update(),this.renderer&&this.renderer.render(this.scene,this.camera)}getSatelliteStore(){return this.satelliteStore}getSatelliteGroups(){return this.satelliteGroups}zoomToSatellite(e){var t;(t=this.satelliteStore)==null||t.getSatellitePosition(e)}clampZoom(){this.camera&&(this.targetZoom>this.camera.zoom*5?this.targetZoom=this.camera.zoom*5:this.targetZoom<this.camera.zoom/5&&(this.targetZoom=this.camera.zoom/5),this.camera.zoom=Math.min(Math.max(this.camera.zoom,this.minZoomLevel),this.maxZoomLevel),this.targetZoom=Math.min(Math.max(this.targetZoom,this.minZoomLevel),this.maxZoomLevel))}zoomIn(){this.camera&&(this.targetZoom+=this.camera.zoom/4,this.clampZoom())}zoomOut(){this.camera&&(this.targetZoom-=this.camera.zoom/6,this.clampZoom())}setHoverSatellite(e){var t,s;(t=this.satellites)==null||t.setHoverSatellite(e),(s=this.orbits)==null||s.setHoverSatellite(e)}setSelectedSatellite(e){var t,s;(t=this.satellites)==null||t.setSelectedSatellite(e),(s=this.orbits)==null||s.setSelectedSatellite(e)}setSelectedSatelliteGroup(e){var t,s,i;this.setSelectedSatellite(-1),(t=this.satelliteGroups)==null||t.selectGroup(e),(s=this.orbits)==null||s.setSatelliteGroup(e),(i=this.satellites)==null||i.setSatelliteGroup(e)}getSelectedSatellite(){if(this.satelliteStore)return this.satelliteStore.getSatellite(this.selectedSatelliteIdx)}getSelectedSatelliteIdx(){return this.selectedSatelliteIdx}addEventListener(e,t){this.eventManager.addEventListener(e,t)}}function ze(a){return new je(a)}const Ue="/StuffInSpace/",N={appName:"Stuff in Space",baseUrl:Ue,propergateInterval:1e3,pushHistory:!1,logLevel:"debug",satWorker:{runOnce:!0},satelliteGroups:[{id:"GPSGroup",name:"GPS",groupType:"intlDes",data:["90103A","93068A","96041A","97035A","99055A","00025A","00040A","00071A","01004A","03005A","03010A","03058A","04009A","04023A","04045A","05038A","06042A","06052A","07047A","07062A","08012A","09043A","10022A","11036A","12053A","13023A","14008A","14026A","14045A","14068A","15013A"]},{id:"IridiumGroup",name:"Iridium Debris",groupType:"nameRegex",data:/IRIDIUM(?!.*DEB)/},{id:"Iridium33DebrisGroup",name:"Iridium 33 Debris",groupType:"nameRegex",data:/(COSMOS 2251|IRIDIUM 33) DEB/},{id:"GlonassGroup",name:"Glonass",groupType:"nameRegex",data:/GLONASS/},{id:"GalileoGroup",name:"Galileo",groupType:"nameRegex",data:/GALILEO/},{id:"FunGroup",name:"Fun",groupType:"nameRegex",data:/SYLDA/},{id:"WestfordNeedlesGroup",name:"Westford Needles",groupType:"nameRegex",data:/WESTFORD NEEDLES/},{id:"SpaceXGroup",name:"Space X",groupType:"nameRegex",data:/FALCON [19]/},{id:"DebrisGroup",name:"Debris",groupType:"objectType",data:"DEBRIS"},{id:"Starlink",name:"Starlink",groupType:"nameRegex",data:/STARLINK/},{id:"Unknown",name:"Unknown Objects",groupType:"objectType",data:"UNKNOWN"}]},Ne=80/Math.PI,T={satMovementChange:"satMovementChange",selectedSatChange:"selectedSatChange",satHover:"sathoverChange",satDataLoaded:"satdataloaded",closeWindow:"closeWindow",cruncherReady:"cruncherReady"};class Fe{constructor(e,t={}){o(this,"element");o(this,"id");o(this,"options");o(this,"listeners",{});o(this,"firstOpen",!0);o(this,"windowManager");this.element=document.querySelector(`#${e}`),this.id=e,this.options=t,this.listeners={},this.firstOpen=!0,this.initEvents()}setWindowManager(e){this.windowManager=e}open(){this.element&&(this.firstOpen=!1,this.element.classList.add("active"),this.element.classList.add("visible"),this.element.classList.remove("hidden"),this.windowManager.bringWindowToFront(this),this.fireEvent("open",{}))}close(){this.element&&(this.element.classList.remove("active"),this.element.classList.remove("visible"),this.element.classList.add("hidden"),this.fireEvent("close",{}))}isOpen(){return this.element?this.element.classList.contains("visible"):!1}initEvents(){if(!this.element)return;const e=this.element.querySelector(".window-close");e&&e.addEventListener("click",()=>{this.close()})}moveTo(e,t){this.element&&(this.element.style.top=`${t}px`,this.element.style.left=`${e}px`)}getLocation(){if(!this.element)return{x:0,y:0};const e=this.element.style;return e.x?{x:e.x,y:e.y}:{x:this.element.offsetLeft,y:this.element.offsetTop}}addEventListener(e,t){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e])this.listeners[e].add(t);else throw new Error("unknown event")}fireEvent(e,t){this.listeners[e]&&this.listeners[e].forEach(i=>{i(t)})}}const He=100;class qe{constructor(){o(this,"windows",[]);o(this,"windowsById",{});o(this,"initialOpen",!1)}bringWindowToFront(e){const t=e.element;let s=-1;for(let i=0;i<this.windows.length;i++)if(this.windows[i].id===(t==null?void 0:t.id)){s=i;break}s>-1&&(this.windows.splice(s,1),this.windows.push(e));for(let i=0;i<this.windows.length;i++){const r=this.windows[i];r&&r.element&&r.element.style&&(r.element.style.zIndex=He+i+1)}}getWindow(e){return this.windowsById[e]}registerWindow(e,t={}){const s=new Fe(e,t);s.setWindowManager(this),this.windows.push(s),this.windowsById[e]=s,this.makeDraggable(s)}getTopWindow(){for(let e=this.windows.length-1;e>=0;e--)if(this.windows[e].isOpen())return this.windows[e]}openWindow(e){const s={x:100,y:100},i=this.windowsById[e],r=this.getTopWindow();let n=!1;if(i){let{x:l,y:h}=i.getLocation();if(r||(l=s.x,h=s.y,this.initialOpen=!1),n=i.firstOpen,n&&r){const c=r.getLocation();c&&(c.x>window.innerWidth/2?l=c.x-42-300:l=c.x+42,c.y>window.innerHeight/2?h=c.y-42-300:h=c.y+42)}if(i.open(),!this.initialOpen&&!n){const c=i.getLocation();c&&(l=c.x,h=c.y)}(l>window.innerWidth||l<0)&&(l=s.x),(h>window.innerHeight||h<0)&&(h=s.y),this.bringWindowToFront(i),i.moveTo(l,h),this.initialOpen=!1}}closeWindow(e){const t=this.windowsById[e];t&&t.close()}makeDraggable(e){let t=0,s=0,i=0,r=0;const n=e.element;if(!n)return;const l=n.querySelector(".drag-zone")||n;function h(c){const d=`${t-(r-c.clientY)}px`,b=`${s-(i-c.clientX)}px`;n&&n.style&&(n.style.top=d,n.style.left=b)}n.classList.add("draggable"),n.addEventListener("click",()=>{this.bringWindowToFront(e)}),l.addEventListener("mousedown",c=>{c.preventDefault(),s=n.offsetLeft,t=n.offsetTop,i=c.clientX,r=c.clientY,this.bringWindowToFront(e),n.style.right="unset",n.style.bottom="unset",n.style.left=`${s}px`,n.style.top=`${t}px`,n.classList.add("dragging"),l.addEventListener("mousemove",h)}),n.addEventListener("mouseup",c=>{c.preventDefault(),l.removeEventListener("mousemove",h),n.classList.remove("dragging")}),n.addEventListener("mouseout",c=>{c.preventDefault(),l.removeEventListener("mousemove",h),n.classList.remove("dragging")})}}const F=200;let m,k,X=!1,P=-1,G=!1,Q;function ee(){return G}function Ve(){return Q}function _e(){return G?document.querySelector("#search").value:null}function Je(){return X}function Ze(){return P}function Ye(){X=!1,P=-1,m.setHoverSatellite(P)}function O(a){const e=document.querySelector("#search-results");e&&(a?e.style.display="block":e.style.display="none",G=a)}function Ke(){O(!ee())}function Xe(){O(!0)}function te(){O(!1);const a=m.getSatelliteGroups();a&&a.clearSelect()}function se(a,e){const t=document.querySelector("#search-results"),s=m.getSatelliteStore();if(!s)return;let i="";for(const r of a){if(r.satId===void 0)continue;const n=s.getSatellite(r.satId);if(!n){u.warn("satellite not found",r.satId);continue}i+=`<div class="search-result" data-sat-id="${n.id}">`,r.type!=="name"?i+=n.OBJECT_NAME:i+=`
       ${n.OBJECT_NAME.substring(0,r.strIndex)}
       <span class="search-hilight">
         ${n.OBJECT_NAME.substring(r.strIndex,r.strIndex+e.length)}
@@ -15,5 +15,5 @@ var re=Object.defineProperty;var oe=(a,e,t)=>e in a?re(a,e,{enumerable:!0,config
       <span class="search-hilight">
         ${n.NORAD_CAT_ID.substring(r.strIndex,r.strIndex+e.length)}
       </span>
-      ${n.NORAD_CAT_ID.substring(r.strIndex+e.length)}`:i+=n.intlDes,i+="</div></div>"}t.innerHTML=i,t.style.display="block",C=!0}function Qe(){const a=document.querySelector("#search-results");a&&(a.innerHTML="")}function R(a){var l,h,c;const e=m.getSatelliteStore();if(!e)return;const t=e.getSatData();if(m.setSelectedSatellite(-1),a.length===0){te();return}a=a.toUpperCase();const s=[];for(let d=0;d<t.length;d++)((h=(l=t[d])==null?void 0:l.NORAD_CAT_ID)==null?void 0:h.indexOf(a))!==-1&&s.push({type:"noradId",strIndex:t[d].NORAD_CAT_ID.indexOf(a),satId:d}),((c=t[d])==null?void 0:c.OBJECT_NAME.indexOf(a))!==-1&&s.push({type:"name",strIndex:t[d].OBJECT_NAME.indexOf(a),satId:d}),t[d].intlDes&&t[d].intlDes.indexOf(a)!==-1&&s.push({type:"intlDes",strIndex:t[d].intlDes.indexOf(a),satId:d});s.length>F&&(s.length=F);const i=[];for(const d of s)i.push(d.satId);const r=new Y("search-results","Search Results","idList",i,e);r.reload(),Q=r;const n=m.getSatelliteGroups();n&&(n.selectGroup(r),m.setSelectedSatelliteGroup(r)),se(s,a)}function et(){var e,t;const a=document.querySelector("#search-results");a&&(a.addEventListener("click",s=>{let i=s.target;if(i.className!=="search-result"&&(i=i.closest(".search-result")),!i)return;const r=i==null?void 0:i.dataset.satId;Ye(),m.setSelectedSatellite(parseInt(r))}),(e=document.querySelector("#search"))==null||e.addEventListener("input",()=>{var i;const s=(i=document.querySelector("#search"))==null?void 0:i.value;R(s)}),(t=document.querySelector("#all-objects-link"))==null||t.addEventListener("click",()=>{const s=m.getSelectedSatellite();if(s){const r=s.intlDes.slice(0,8);R(r),document.querySelector("#search").value=r,k&&k.openWindow("search-window")}}))}function tt(a,e){m=a,k=e,et()}const w={init:tt,clearResults:Qe,getHoverSat:Ze,isHovering:Je,showResults:Xe,hideResults:te,doSearch:R,getCurrentSearch:_e,getLastResultGroup:Ve,fillResultBox:se,isResultBoxOpen:ee,setResultsVisible:O,toggleResultsVisible:Ke},st=[],S=new He,it=[];let q=!1,u;function rt(a){var t;let e=document.querySelector(".attribution");if(e||(e=document.createElement("div"),e.className="attribution",(t=document.querySelector("body"))==null||t.appendChild(e)),e)if(a){const s=u.getSatelliteStore();if(s&&s.getAttribution()){const i=s.getAttribution()||{},r=s.getUpdatedDate();e.innerHTML=`Orbital object data from <a href="${i.url}">${i.name}</a> <span class="updated">(updated ${r})</span>`}e.classList.remove("hidden")}else e.classList.add("hidden")}function ie(a){var e,t;a?(e=document.querySelector("body"))==null||e.classList.add("loading"):(t=document.querySelector("body"))==null||t.classList.remove("loading")}function ot(){const a=document.querySelector("#groups-display"),e=u.getSatelliteGroups();let t=[];e&&(t=e.asArray().sort((i,r)=>i.name.localeCompare(r.name)));let s="";for(let i=0;i<t.length;i++)s+=`<li data-group="${t[i].id}" id="satgroup-${t[i].id}" class="clickable">${t[i].name}</li>
-`;a.innerHTML=s}function p(a,e){const t=document.querySelector(a);t&&(t.innerHTML=e)}function at(a){var e,t,s,i,r;a?((e=document.querySelector("#sat-infobox"))==null||e.classList.add("visible"),p("#sat-info-title",a.OBJECT_NAME),p("#sat-intl-des",a.intlDes),p("#sat-type",a.OBJECT_TYPE),p("#sat-apogee",`${(t=a.apogee)==null?void 0:t.toFixed(0)} km`),p("#sat-perigee",`${(s=a.perigee)==null?void 0:s.toFixed(0)} km`),p("#sat-inclination",`${(a.inclination*Ne).toFixed(2)}°`),p("#sat-period",`${(i=a.period)==null?void 0:i.toFixed(2)} min`)):(r=document.querySelector("#sat-infobox"))==null||r.classList.remove("visible")}function nt(a){const{satId:e,satX:t,satY:s,satellite:i}=a||{};if(!e||e===-1){p("#sat-hoverbox","(none)");let r=document.querySelector("#sat-hoverbox");r&&(r.style.display="none"),r=document.querySelector("#canvas"),r&&(r.style.cursor="default")}else{const r=document.querySelector("#sat-hoverbox");r&&(r.innerHTML=i.OBJECT_NAME,r.style.display="block",r.style.position="absolute",r.style.left=`${t+20}px`,r.style.top=`${s-10}px`);const n=document.querySelector("#canvas");n&&(n.style.cursor="pointer")}}function lt(){var e;(e=document.querySelector("#groups-display"))==null||e.addEventListener("mouseout",()=>{if(!q){const t=u.getSatelliteGroups();t&&(w.isResultBoxOpen()?t.selectGroup(w.getLastResultGroup()):t.clearSelect())}});const a=document.querySelectorAll("#groups-display>li");for(let t=0;t<a.length;t++){const s=a[t];s.addEventListener("mouseover",i=>{const n=i.currentTarget.dataset.group,l=u.getSatelliteGroups();l&&l.selectGroup(l.getGroupById(n))}),s.addEventListener("mouseout",()=>{const i=u.getSatelliteGroups();if(i){const r=document.querySelector("#groups-display>li.selected");r?i.selectGroup(i.getGroupById(r.dataset.group)):i.selectGroup(void 0)}}),s.addEventListener("click",i=>{i.preventDefault();const r=i.currentTarget;q=!0;const n=document.querySelector("#groups-display>li.selected");let l;n&&(l=n.dataset.group);for(let b=0;b<a.length;b++)a[b].classList.remove("selected");const h=u.getSatelliteGroups(),c=r.dataset.group;let d;c===l?(h&&h.clearSelect(),w.clearResults(),w.hideResults()):(i.preventDefault(),i.stopPropagation(),h&&(u.setSelectedSatellite(-1),h&&(d=h.getGroupById(c)),d&&(r.classList.add("selected"),w.fillResultBox(d.sats,""),S.openWindow("search-window"),d.reload()))),h&&(h.selectGroup(d),u.setSelectedSatelliteGroup(d))})}}function ht(){var e,t;const a=u.getSatelliteGroups();a==null||a.reloadGroups(),u.addEventListener(T.selectedSatChange,at),u.addEventListener(T.satHover,nt),(e=document.querySelector("#zoom-in"))==null||e.addEventListener("click",s=>{s.preventDefault(),u.zoomIn()}),(t=document.querySelector("#zoom-out"))==null||t.addEventListener("click",s=>{s.preventDefault(),u.zoomOut()}),window.addEventListener("resize",()=>{it.forEach(s=>{window.visualViewport&&(s.offsetLeft+s.offsetWidth>window.visualViewport.width&&(s.style.right="unset",s.style.left=`${window.visualViewport.width-s.offsetWidth}px`),s.offsetTop+s.offsetHeight>window.visualViewport.height&&(s.style.bottom="unset",s.style.offsetTop=`${window.visualViewport.height-s.offsetHeight}px`))})}),ie(!1)}function ct(a){a.satId&&(p("#sat-altitude",`${a.altitude.toFixed(2)} km`),p("#sat-velocity",`${a.velocity.toFixed(2)} km/s`))}function H(){ht(),ot(),setTimeout(()=>lt(),0);const a=document.querySelector("#load-cover");a&&a.classList.add("hidden"),rt(!0)}function dt(){return st}function ut(){const a=document.querySelectorAll(".menu-item");for(let e=0;e<a.length;e++){const t=a[e];t.addEventListener("click",()=>{const s=t.dataset.action;if(s&&s.startsWith("open:")){const i=s.split(":");S.openWindow(i[1])}})}}function ft(){return w.getCurrentSearch()}function gt(a){var e;u=a,S.registerWindow("sat-infobox"),S.registerWindow("about-window"),S.registerWindow("help-window"),S.registerWindow("groups-window"),S.registerWindow("search-window"),(e=S.getWindow("search-window"))==null||e.addEventListener("close",()=>{var s;(s=u.getSatelliteGroups())==null||s.clearSelect(),u.setSelectedSatelliteGroup();const t=document.querySelectorAll("#groups-display>li");for(const i of t)i.classList.remove("selected")}),w.init(u,S),ut(),u.addEventListener(T.satMovementChange,ct),u.ready?H():u.addEventListener(T.satDataLoaded,H)}const pt={setLoading:ie,init:gt,getSupportedEvents:dt,getCurrentSearch:ft};async function mt(){const e=await j.get("./config.json");let t=N;return e.data&&(t={...N,...e.data}),f.info(`.... ${t.baseUrl}`),t}async function St(){const a=await mt();J(a.logLevel);const e=ze(a);await e.init(),e.animate(),pt.init(e)}document.addEventListener("DOMContentLoaded",()=>{St().catch(a=>console.error(a))});
+      ${n.NORAD_CAT_ID.substring(r.strIndex+e.length)}`:i+=n.intlDes,i+="</div></div>"}t.innerHTML=i,t.style.display="block",G=!0}function Qe(){const a=document.querySelector("#search-results");a&&(a.innerHTML="")}function R(a){var l,h,c;const e=m.getSatelliteStore();if(!e)return;const t=e.getSatData();if(m.setSelectedSatellite(-1),a.length===0){te();return}a=a.toUpperCase();const s=[];for(let d=0;d<t.length;d++)((h=(l=t[d])==null?void 0:l.NORAD_CAT_ID)==null?void 0:h.indexOf(a))!==-1&&s.push({type:"noradId",strIndex:t[d].NORAD_CAT_ID.indexOf(a),satId:d}),((c=t[d])==null?void 0:c.OBJECT_NAME.indexOf(a))!==-1&&s.push({type:"name",strIndex:t[d].OBJECT_NAME.indexOf(a),satId:d}),t[d].intlDes&&t[d].intlDes.indexOf(a)!==-1&&s.push({type:"intlDes",strIndex:t[d].intlDes.indexOf(a),satId:d});s.length>F&&(s.length=F);const i=[];for(const d of s)i.push(d.satId);const r=new Y("search-results","Search Results","idList",i,e);r.reload(),Q=r;const n=m.getSatelliteGroups();n&&(n.selectGroup(r),m.setSelectedSatelliteGroup(r)),se(s,a)}function et(){var e,t;const a=document.querySelector("#search-results");a&&(a.addEventListener("click",s=>{let i=s.target;if(i.className!=="search-result"&&(i=i.closest(".search-result")),!i)return;const r=i==null?void 0:i.dataset.satId;Ye(),m.setSelectedSatellite(parseInt(r))}),(e=document.querySelector("#search"))==null||e.addEventListener("input",()=>{var i;const s=(i=document.querySelector("#search"))==null?void 0:i.value;R(s)}),(t=document.querySelector("#all-objects-link"))==null||t.addEventListener("click",()=>{const s=m.getSelectedSatellite();if(s){const r=s.intlDes.slice(0,8);R(r),document.querySelector("#search").value=r,k&&k.openWindow("search-window")}}))}function tt(a,e){m=a,k=e,et()}const w={init:tt,clearResults:Qe,getHoverSat:Ze,isHovering:Je,showResults:Xe,hideResults:te,doSearch:R,getCurrentSearch:_e,getLastResultGroup:Ve,fillResultBox:se,isResultBoxOpen:ee,setResultsVisible:O,toggleResultsVisible:Ke},st=[],S=new qe,it=[];let H=!1,f;function rt(a){var t;let e=document.querySelector(".attribution");if(e||(e=document.createElement("div"),e.className="attribution",(t=document.querySelector("body"))==null||t.appendChild(e)),e)if(a){const s=f.getSatelliteStore();if(s&&s.getAttribution()){const i=s.getAttribution()||{},r=s.getUpdatedDate();e.innerHTML=`Orbital object data from <a href="${i.url}">${i.name}</a> <span class="updated">(updated ${r})</span>`}e.classList.remove("hidden")}else e.classList.add("hidden")}function ie(a){var e,t;a?(e=document.querySelector("body"))==null||e.classList.add("loading"):(t=document.querySelector("body"))==null||t.classList.remove("loading")}function ot(){const a=document.querySelector("#groups-display"),e=f.getSatelliteGroups();let t=[];e&&(t=e.asArray().sort((i,r)=>i.name.localeCompare(r.name)));let s="";for(let i=0;i<t.length;i++)s+=`<li data-group="${t[i].id}" id="satgroup-${t[i].id}" class="clickable">${t[i].name}</li>
+`;a.innerHTML=s}function p(a,e){const t=document.querySelector(a);t&&(t.innerHTML=e)}function at(a){var e,t,s,i,r;a?((e=document.querySelector("#sat-infobox"))==null||e.classList.add("visible"),p("#sat-info-title",a.OBJECT_NAME),p("#sat-intl-des",a.intlDes),p("#sat-type",a.OBJECT_TYPE),p("#sat-apogee",`${(t=a.apogee)==null?void 0:t.toFixed(0)} km`),p("#sat-perigee",`${(s=a.perigee)==null?void 0:s.toFixed(0)} km`),p("#sat-inclination",`${(a.inclination*Ne).toFixed(2)}°`),p("#sat-period",`${(i=a.period)==null?void 0:i.toFixed(2)} min`)):(r=document.querySelector("#sat-infobox"))==null||r.classList.remove("visible")}function nt(a){const{satId:e,satX:t,satY:s,satellite:i}=a||{};if(!e||e===-1){p("#sat-hoverbox","(none)");let r=document.querySelector("#sat-hoverbox");r&&(r.style.display="none"),r=document.querySelector("#canvas"),r&&(r.style.cursor="default")}else{const r=document.querySelector("#sat-hoverbox");r&&(r.innerHTML=i.OBJECT_NAME,r.style.display="block",r.style.position="absolute",r.style.left=`${t+20}px`,r.style.top=`${s-10}px`);const n=document.querySelector("#canvas");n&&(n.style.cursor="pointer")}}function lt(){var e;(e=document.querySelector("#groups-display"))==null||e.addEventListener("mouseout",()=>{if(!H){const t=f.getSatelliteGroups();t&&(w.isResultBoxOpen()?t.selectGroup(w.getLastResultGroup()):t.clearSelect())}});const a=document.querySelectorAll("#groups-display>li");for(let t=0;t<a.length;t++){const s=a[t];s.addEventListener("mouseover",i=>{const n=i.currentTarget.dataset.group,l=f.getSatelliteGroups();l&&l.selectGroup(l.getGroupById(n))}),s.addEventListener("mouseout",()=>{const i=f.getSatelliteGroups();if(i){const r=document.querySelector("#groups-display>li.selected");r?i.selectGroup(i.getGroupById(r.dataset.group)):i.selectGroup(void 0)}}),s.addEventListener("click",i=>{i.preventDefault();const r=i.currentTarget;H=!0;const n=document.querySelector("#groups-display>li.selected");let l;n&&(l=n.dataset.group);for(let b=0;b<a.length;b++)a[b].classList.remove("selected");const h=f.getSatelliteGroups(),c=r.dataset.group;let d;c===l?(h&&h.clearSelect(),w.clearResults(),w.hideResults()):(i.preventDefault(),i.stopPropagation(),h&&(f.setSelectedSatellite(-1),h&&(d=h.getGroupById(c)),d&&(r.classList.add("selected"),w.fillResultBox(d.sats,""),S.openWindow("search-window"),d.reload()))),h&&(h.selectGroup(d),f.setSelectedSatelliteGroup(d))})}}function ht(){var e,t;const a=f.getSatelliteGroups();a==null||a.reloadGroups(),f.addEventListener(T.selectedSatChange,at),f.addEventListener(T.satHover,nt),(e=document.querySelector("#zoom-in"))==null||e.addEventListener("click",s=>{s.preventDefault(),f.zoomIn()}),(t=document.querySelector("#zoom-out"))==null||t.addEventListener("click",s=>{s.preventDefault(),f.zoomOut()}),window.addEventListener("resize",()=>{it.forEach(s=>{window.visualViewport&&(s.offsetLeft+s.offsetWidth>window.visualViewport.width&&(s.style.right="unset",s.style.left=`${window.visualViewport.width-s.offsetWidth}px`),s.offsetTop+s.offsetHeight>window.visualViewport.height&&(s.style.bottom="unset",s.style.offsetTop=`${window.visualViewport.height-s.offsetHeight}px`))})}),ie(!1)}function ct(a){a.satId&&(p("#sat-altitude",`${a.altitude.toFixed(2)} km`),p("#sat-velocity",`${a.velocity.toFixed(2)} km/s`))}function q(){ht(),ot(),setTimeout(()=>lt(),0);const a=document.querySelector("#load-cover");a&&a.classList.add("hidden"),rt(!0)}function dt(){return st}function ut(){const a=document.querySelectorAll(".menu-item");for(let e=0;e<a.length;e++){const t=a[e];t.addEventListener("click",()=>{const s=t.dataset.action;if(s&&s.startsWith("open:")){const i=s.split(":");S.openWindow(i[1])}})}}function ft(){return w.getCurrentSearch()}function gt(a){f=a,S.registerWindow("sat-infobox"),S.registerWindow("about-window"),S.registerWindow("help-window"),S.registerWindow("groups-window"),S.registerWindow("search-window"),w.init(f,S),ut(),f.addEventListener(T.satMovementChange,ct),f.ready?q():f.addEventListener(T.satDataLoaded,q)}const pt={setLoading:ie,init:gt,getSupportedEvents:dt,getCurrentSearch:ft};async function mt(){const e=await j.get("./config.json");let t=N;return e.data&&(t={...N,...e.data}),u.info(`.... ${t.baseUrl}`),t}async function St(){const a=await mt();J(a.logLevel);const e=ze(a);await e.init(),e.animate(),pt.init(e)}document.addEventListener("DOMContentLoaded",()=>{St().catch(a=>console.error(a))});
diff --git a/index.html b/index.html
index 7167be4..e43d366 100644
--- a/index.html
+++ b/index.html
@@ -27,7 +27,7 @@
 
 
     <title>Stuff in Space</title>
-    <script type="module" crossorigin src="/StuffInSpace/assets/index-PO5TO8ie.js"></script>
+    <script type="module" crossorigin src="/StuffInSpace/assets/index-RkkUHyHQ.js"></script>
     <link rel="modulepreload" crossorigin href="/StuffInSpace/assets/vendor-tzzAqV-x.js">
   </head>
   <body class="loading">