spacemap 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/spacemap.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*! spacemap SDK — https://spacemap.co — Mozilla Public License 2.0. Bundles MIT and ISC libraries: THIRD_PARTY_NOTICES.txt in the spacemap npm package. */
2
- var e=[`open`,`non-commercial`,`site-only`],t={dataUrl:`https://static.spacemap.co`,imagesUrl:`https://images.spacemap.co`,liveUrl:`https://live.spacemap.co`,locale:()=>`en`,messages:{body_note_no_model:()=>`no model available`,body_note_no_radius:()=>`no size data available`,carried_by_scene_label:({carrier:e})=>`Carried by ${e}`,scene_canvas_label:()=>`Interactive 3D map of the Solar System`,attribution_orbits:()=>`Orbits`,attribution_imagery:()=>`Imagery`,credits_see_all:()=>`See full credits`,layer_surface:()=>`Surface`,layer_clouds:()=>`Clouds`,layer_night:()=>`Night lights`,layer_graticule:()=>`Grid`,layer_nomenclature:()=>`Named features`,cooperative_wheel:()=>`Use ctrl + scroll to zoom the map`,cooperative_wheel_mac:()=>`Use ⌘ + scroll to zoom the map`,cooperative_touch:()=>`Use two fingers to move the map`},bodyHref:()=>``,textures:`open`},n=t;function r(e){let{messages:r,...i}=e;n={...t,...i},r&&(n.messages={...t.messages,...r}),n.dataUrl=n.dataUrl.replace(/\/$/,``),n.imagesUrl=n.imagesUrl.replace(/\/$/,``),n.liveUrl=n.liveUrl.replace(/\/$/,``)}function i(){return n}function a(t){if(t===void 0)return!0;let r=e.indexOf(t);return r<0?!1:r<=e.indexOf(n.textures)}function o(e){for(let t of e)if(t&&a(t.distribution))return t}function s(){return n.locale()}var c=Symbol(`uninitialized`),l=Array.isArray,u=Array.prototype.indexOf,d=Array.prototype.includes;Array.from;var f=Object.getOwnPropertyDescriptor,p=Object.prototype,m=Array.prototype,h=Object.getPrototypeOf,g=()=>{};function _(e){for(var t=0;t<e.length;t++)e[t]()}function v(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var y=1024,b=2048,x=4096,S=8192,C=16384,w=32768,T=1<<25,E=65536,D=1<<19,O=1<<20,k=65536,A=1<<21,j=1<<23,M=Symbol(`$state`),ee=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"};globalThis.document?.contentType;function N(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function te(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function ne(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function re(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function P(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ie(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function ae(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function F(){console.warn(`https://svelte.dev/e/derived_inert`)}function I(e){return e===this.v}var oe=!1,se=!1,ce=null;function le(e){ce=e}function ue(){return!se||ce!==null&&ce.l===null}var de=[];function fe(){var e=de;de=[],_(e)}function pe(e){if(de.length===0&&!xe){var t=de;queueMicrotask(()=>{t===de&&fe()})}de.push(e)}function me(e){var t=xt;if(t===null)return vt.f|=j,e;if(!(t.f&32768)&&!(t.f&4))throw e;he(e,t)}function he(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var L=~(b|x|y);function R(e,t){e.f=e.f&L|t}function z(e){e.f&512||e.deps===null?R(e,y):R(e,x)}function ge(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=k,ge(t.deps))}function B(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ge(e.deps),R(e,y)}var _e=!1,V=null,H=null,U=null,ve=null,ye=null,be=null,xe=!1,Se=!1,Ce=null,W=null,we=0,Te=1,Ee=class e{id=Te++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){H===null?V=H=this:(H.#n=this,this.#t=H),H=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)R(r,b),t(r);for(r of n.m)R(r,x),t(r)}this.#p.add(e)}#g(){this.#e=!0,we++>1e3&&(this.#S(),De());for(let e of this.#u)this.#d.delete(e),R(e,b),this.schedule(e);for(let e of this.#d)R(e,x),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Ce=[],r=[],i=W=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw Pe(e),this.#h()||this.discard(),t}if(U=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Ce=null,W=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)Ne(e,t);i.length>0&&U.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),ve=this,ke(r),ke(n),ve=null,this.#s?.resolve();var s=U;if(this.#a===0&&(this.#c.length===0||s!==null)&&(this.#S(),oe&&(this.#x(),U=s)),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=y;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=y:i&4?t.push(r):oe&&i&16777224?n.push(r):Pt(r)&&(i&16&&this.#d.add(r),zt(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),R(i,b),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),U=this,this.#g()}#b(e){for(var t=0;t<e.length;t+=1)B(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==c&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),ye?.set(e,t)),this.is_fork||(e.v=t)}activate(){U=this}deactivate(){U=null,ye=null}flush(){try{Se=!0,U=this,this.#g()}finally{we=0,be=null,Ce=null,W=null,Se=!1,U=null,ye=null,Ve.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#S(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}#x(){for(let l=V;l!==null;l=l.#n){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=l.async_deriveds.get(e);n&&t.promise.then(n.resolve).catch(n.reject)}if(l.#e){var r=[...l.current.keys()].filter(e=>!l.current.get(e)[1]&&!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#p)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#b([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Ae(o,r,i,a);a=new Map;var s=[...l.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(s.length>0)for(let e of this.#l)!(e.f&155648)&&je(e,s,a)&&(e.f&4194320?(R(e,b),l.schedule(e)):l.#u.add(e));if(l.#c.length>0&&!l.#m){l.apply();for(var c of l.#c)l.#_(c,[],[]);l.#c=[]}l.deactivate()}}}}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,pe(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=v()).promise}static ensure(){if(U===null){let t=U=new e;!Se&&!xe&&pe(()=>{t.#e||t.flush()})}return U}apply(){if(!oe||!this.is_fork&&this.#t===null&&this.#n===null){ye=null;return}ye=new Map;for(let[e,[t]]of this.current)ye.set(e,t);for(let t=V;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,r]]of t.current)if(!r&&this.current.has(n)){e=!0;break}}if(!e)for(let[e,n]of t.previous)ye.has(e)||ye.set(e,n)}}schedule(e){if(be=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Ce!==null&&t===xt&&(oe||(vt===null||!(vt.f&2))&&!_e))return;if(n&96){if(!(n&1024))return;t.f^=y}}this.#c.push(t)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null?V=t:e.#n=t,t===null?H=e:t.#t=e,this.linked=!1}}};function De(){try{re()}catch(e){he(e,be)}}var Oe=null;function ke(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Pt(r)&&(Oe=new Set,zt(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&ft(r),Oe?.size>0)){Ve.clear();for(let e of Oe){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Oe.has(n)&&(Oe.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||zt(n)}}Oe.clear()}}Oe=null}}function Ae(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Ae(i,t,n,r):e&4194320&&!(e&2048)&&je(i,t,r)&&(R(i,b),Me(i))}}function je(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(d.call(t,r))return!0;if(r.f&2&&je(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Me(e){U.schedule(e)}function Ne(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),R(e,y);for(var n=e.first;n!==null;)Ne(n,t),n=n.next}}function Pe(e){R(e,y);for(var t=e.first;t!==null;)Pe(t),t=t.next}E|D;function Fe(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)ut(t[n])}}function Ie(e){var t,n=xt,r=e.parent;if(!gt&&r!==null&&e.v!==c&&r.f&24576)return F(),e.v;St(r);try{e.f&=~k,Fe(e),t=It(e)}finally{St(n)}return t}function Le(e){var t=Ie(e);if(!e.equals(t)&&(e.wv=Nt(),(!U?.is_fork||e.deps===null)&&(U===null?e.v=t:(U.capture(e,t,!0),ve?.capture(e,t,!0)),e.deps===null))){R(e,y);return}gt||(ye===null?z(e):(rt()||U?.is_fork)&&ye.set(e,t))}function Re(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(ee),t.fn!==null&&(t.teardown=g),t.ac=null,Rt(t,0),ct(t))}function ze(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&zt(t)}var Be=new Set,Ve=new Map,He=!1;function Ue(e,t){return{f:0,v:e,reactions:null,equals:I,rv:0,wv:0}}function We(e,t){let n=Ue(e,t);return wt(n),n}function Ge(e,t,n=!1){return vt!==null&&(!yt||vt.f&131072)&&ue()&&vt.f&4325394&&(Ct===null||!Ct.has(e))&&ae(),Ke(e,n?Xe(t):t,W)}function Ke(e,t,n=null){if(!e.equals(t)){Ve.set(e,gt?t:e.v);var r=Ee.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Ie(t),ye===null&&z(t)}e.wv=Nt(),Ye(e,b,n),ue()&&xt!==null&&xt.f&1024&&!(xt.f&96)&&(Dt===null?Ot([e]):Dt.push(e)),!r.is_fork&&Be.size>0&&!He&&qe()}return t}function qe(){He=!1;for(let e of Be){e.f&1024&&R(e,x);let t;try{t=Pt(e)}catch{t=!0}t&&zt(e)}Be.clear()}function Je(e){Ge(e,e.v+1)}function Ye(e,t,n){var r=e.reactions;if(r!==null)for(var i=ue(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===xt)){var l=(c&b)===0;if(l&&R(s,t),c&131072)Be.add(s);else if(c&2){var u=s;ye?.delete(u),c&65536||(c&512&&(xt===null||!(xt.f&2097152))&&(s.f|=k),Ye(u,x,n))}else if(l){var d=s;c&16&&Oe!==null&&Oe.add(d),n===null?Me(d):n.push(d)}}}}function Xe(e){if(typeof e!=`object`||!e||M in e)return e;let t=h(e);if(t!==p&&t!==m)return e;var n=new Map,r=l(e),i=We(0),a=null,o=jt,s=e=>{if(jt===o)return e();var t=vt,n=jt;bt(null),Mt(o);var r=e();return bt(t),Mt(n),r};return r&&n.set(`length`,We(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&P();var i=n.get(t);return i===void 0?s(()=>{var e=We(r.value,a);return n.set(t,e),e}):Ge(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>We(c,a));n.set(t,e),Je(i)}}else Ge(r,c),Je(i);return!0},get(t,r,i){if(r===M)return e;var o=n.get(r),l=r in t;if(o===void 0&&(!l||f(t,r)?.writable)&&(o=s(()=>We(Xe(l?t[r]:c),a)),n.set(r,o)),o!==void 0){var u=Bt(o);return u===c?void 0:u}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=Bt(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==c)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===M)return!0;var r=n.get(t),i=r!==void 0&&r.v!==c||Reflect.has(e,t);return(r!==void 0||xt!==null&&(!i||f(e,t)?.writable))&&(r===void 0&&(r=s(()=>We(i?Xe(e[t]):c,a)),n.set(t,r)),Bt(r)===c)?!1:i},set(e,t,o,l){var u=n.get(t),d=t in e;if(r&&t===`length`)for(var p=o;p<u.v;p+=1){var m=n.get(p+``);m===void 0?p in e&&(m=s(()=>We(c,a)),n.set(p+``,m)):Ge(m,c)}if(u===void 0)(!d||f(e,t)?.writable)&&(u=s(()=>We(void 0,a)),Ge(u,Xe(o)),n.set(t,u));else{d=u.v!==c;var h=s(()=>Xe(o));Ge(u,h)}var g=Reflect.getOwnPropertyDescriptor(e,t);if(g?.set&&g.set.call(l,o),!d){if(r&&typeof t==`string`){var _=n.get(`length`),v=Number(t);Number.isInteger(v)&&v>=_.v&&Ge(_,v+1)}Je(i)}return!0},ownKeys(e){Bt(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==c});for(var[r,a]of n)a.v!==c&&!(r in e)&&t.push(r);return t},setPrototypeOf(){ie()}})}var Ze;function Qe(e){return Ze.call(e)}function $e(e){var t=vt,n=xt;bt(null),St(null);try{return e()}finally{bt(t),St(n)}}function et(e){xt===null&&(vt===null&&ne(e),te()),gt&&N(e)}function tt(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function nt(e,t){var n=xt;n!==null&&n.f&8192&&(e|=S);var r={ctx:ce,deps:null,nodes:null,f:e|b|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};U?.register_created_effect(r);var i=r;if(e&4)Ce===null?Ee.ensure().schedule(r):Ce.push(r);else if(t!==null){try{zt(r)}catch(e){throw ut(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=E))}if(i!==null&&(i.parent=n,n!==null&&tt(i,n),vt!==null&&vt.f&2&&!(e&64))){var a=vt;(a.effects??=[]).push(i)}return r}function rt(){return vt!==null&&!yt}function it(e){et(`$effect`);var t=xt.f;if(!vt&&t&32&&ce!==null&&!ce.i){var n=ce;(n.e??=[]).push(e)}else return at(e)}function at(e){return nt(4|O,e)}function ot(e){Ee.ensure();let t=nt(64|D,e);return()=>{ut(t)}}function st(e){var t=e.teardown;if(t!==null){let e=gt,n=vt;_t(!0),bt(null);try{t.call(null)}finally{_t(e),bt(n)}}}function ct(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&$e(()=>{e.abort(ee)});var r=n.next;n.f&64?n.parent=null:ut(n,t),n=r}}function lt(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||ut(t),t=n}}function ut(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(dt(e.nodes.start,e.nodes.end),n=!0),e.f|=T,ct(e,t&&!n),Rt(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();st(e),e.f^=T,e.f|=C;var i=e.parent;i!==null&&i.first!==null&&ft(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function dt(e,t){for(;e!==null;){var n=e===t?null:Qe(e);e.remove(),e=n}}function ft(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function pt(e,t,n){if(!(e.f&8192)){e.f^=S;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;pt(i,t,o?n:!1)}i=a}}}var mt=null,ht=!1,gt=!1;function _t(e){gt=e}var vt=null,yt=!1;function bt(e){vt=e}var xt=null;function St(e){xt=e}var Ct=null;function wt(e){vt!==null&&(!oe||vt.f&2)&&(Ct??=new Set).add(e)}var Tt=null,Et=0,Dt=null;function Ot(e){Dt=e}var kt=1,At=0,jt=At;function Mt(e){jt=e}function Nt(){return++kt}function Pt(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~k),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Pt(a)&&Le(a),a.wv>e.wv)return!0}t&512&&ye===null&&R(e,y)}return!1}function Ft(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!oe&&Ct!==null&&Ct.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Ft(a,t,!1):t===a&&(n?R(a,b):a.f&1024&&R(a,x),Me(a))}}function It(e){var t=Tt,n=Et,r=Dt,i=vt,a=Ct,o=ce,s=yt,c=jt,l=e.f;Tt=null,Et=0,Dt=null,vt=l&96?null:e,Ct=null,le(e.ctx),yt=!1,jt=++At,e.ac!==null&&($e(()=>{e.ac.abort(ee)}),e.ac=null);try{e.f|=A;var u=e.fn,d=u();e.f|=w;var f=e.deps,p=U?.is_fork;if(Tt!==null){var m;if(p||Rt(e,Et),f!==null&&Et>0)for(f.length=Et+Tt.length,m=0;m<Tt.length;m++)f[Et+m]=Tt[m];else e.deps=f=Tt;if(rt()&&e.f&512)for(m=Et;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&Et<f.length&&(Rt(e,Et),f.length=Et);if(ue()&&Dt!==null&&!yt&&f!==null&&!(e.f&6146))for(m=0;m<Dt.length;m++)Ft(Dt[m],e);if(i!==null&&i!==e){if(At++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=At;if(t!==null)for(let e of t)e.rv=At;Dt!==null&&(r===null?r=Dt:r.push(...Dt))}return e.f&8388608&&(e.f^=j),d}catch(e){return me(e)}finally{e.f^=A,Tt=t,Et=n,Dt=r,vt=i,Ct=a,le(o),yt=s,jt=c}}function Lt(e,t){let n=t.reactions;if(n!==null){var r=u.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(Tt===null||!d.call(Tt,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~k),a.v!==c&&z(a),Re(a),Rt(a,0)}}function Rt(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Lt(e,n[r])}function zt(e){var t=e.f;if(!(t&16384)){R(e,y);var n=xt,r=ht;xt=e,ht=!0;try{t&16777232?lt(e):ct(e),st(e);var i=It(e);e.teardown=typeof i==`function`?i:null,e.wv=kt}finally{ht=r,xt=n}}}function Bt(e){var t=(e.f&2)!=0;if(mt?.add(e),vt!==null&&!yt&&!(xt!==null&&xt.f&16384)&&(Ct===null||!Ct.has(e))){var n=vt.deps;if(vt.f&2097152)e.rv<At&&(e.rv=At,Tt===null&&n!==null&&n[Et]===e?Et++:Tt===null?Tt=[e]:Tt.push(e));else{vt.deps??=[],d.call(vt.deps,e)||vt.deps.push(e);var r=e.reactions;r===null?e.reactions=[vt]:d.call(r,vt)||r.push(vt)}}if(gt&&Ve.has(e))return Ve.get(e);if(t){var i=e;if(gt){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Ht(i))&&(a=Ie(i)),Ve.set(i,a),a}var o=(i.f&512)==0&&!yt&&vt!==null&&(ht||(vt.f&512)!=0),s=(i.f&w)===0;Pt(i)&&(o&&(i.f|=512),Le(i)),o&&!s&&(ze(i),Vt(i))}if(ye?.has(e))return ye.get(e);if(e.f&8388608)throw e.v;return e.v}function Vt(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(ze(t),Vt(t))}function Ht(e){if(e.v===c)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Ve.has(t)||t.f&2&&Ht(t))return!0;return!1}globalThis?.window?.trustedTypes,[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];function Ut(){return i().dataUrl}var Wt={};function Gt(e){Wt=e??{}}function Kt(e,t){return qt(Ut(),e,t)}function qt(e,t,n){let r=Wt[n];return r?`${e}${t}?v=${r}`:(console.error(`versionedUrl: missing '${n}' token for ${t}`),`${e}${t}`)}var Jt=32,Yt=e=>`${Ut()}/v1/labels/${e}.gz`;function Xt(e){return e===null?``:`${e}/`}function Zt(e,t,n){return Kt(`/v1/position/${e}/${Xt(t)}${n}.bin.gz`,`position`)}function Qt(e,t,n,r){return Kt(`/v1/position/${e}/${Xt(t)}${n}/${r}.bin.gz`,`position`)}function $t(e,t,n){return Kt(`/v1/position/${e}/${Xt(t)}${n}.bin.gz`,`position`)}var en=function(e){return e[e.PLANET=0]=`PLANET`,e[e.SYSTEM=1]=`SYSTEM`,e}({}),tn=function(e){return e[e.HORIZONS=0]=`HORIZONS`,e[e.SBDB=1]=`SBDB`,e[e.CELESTRAK=2]=`CELESTRAK`,e[e.SPICE=3]=`SPICE`,e[e.SBDB_MOON=4]=`SBDB_MOON`,e[e.SPICE_PROBE=5]=`SPICE_PROBE`,e[e.SPACETRACK=6]=`SPACETRACK`,e[e.ASTERSAT=7]=`ASTERSAT`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),nn=function(e){return e[e.NAIF=0]=`NAIF`,e[e.SPKID=1]=`SPKID`,e[e.NORAD_SATCAT=2]=`NORAD_SATCAT`,e[e.PROBE=4]=`PROBE`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),rn={[nn.NAIF]:`naif`,[nn.SPKID]:`spkid`,[nn.NORAD_SATCAT]:`norad_satcat`,[nn.PROBE]:`probe`},an=new Map(Object.entries(rn).map(([e,t])=>[t,Number(e)]));function on(e){return an.get(e)}function sn(e,t){let n=rn[e];return n?`${n}-${t}`:null}function cn(e){return e.data.objectType===G.SURFACE_FEATURE}var G=function(e){return e[e.BARYCENTER=0]=`BARYCENTER`,e[e.LAGRANGE_POINT=1]=`LAGRANGE_POINT`,e[e.STAR=2]=`STAR`,e[e.PLANET=3]=`PLANET`,e[e.DWARF_PLANET=4]=`DWARF_PLANET`,e[e.MOON=5]=`MOON`,e[e.ASTEROID=6]=`ASTEROID`,e[e.ASTEROID_INNER=7]=`ASTEROID_INNER`,e[e.ASTEROID_MAIN_BELT=8]=`ASTEROID_MAIN_BELT`,e[e.ASTEROID_TROJAN=9]=`ASTEROID_TROJAN`,e[e.ASTEROID_CENTAUR=10]=`ASTEROID_CENTAUR`,e[e.ASTEROID_TNO=11]=`ASTEROID_TNO`,e[e.COMET=12]=`COMET`,e[e.SPACECRAFT=13]=`SPACECRAFT`,e[e.DEBRIS=14]=`DEBRIS`,e[e.UNDOCUMENTED=15]=`UNDOCUMENTED`,e[e.SURFACE_FEATURE=16]=`SURFACE_FEATURE`,e}({}),ln={IEO:{minA:0,maxA:.983},ATE:{minA:.5,maxA:1},APO:{minA:1,maxA:3.2},AMO:{minA:1,maxA:3.2},MCA:{minA:1.3,maxA:3.2},IMB:{minA:1.666,maxA:2},MBA:{minA:2,maxA:3.2},OMB:{minA:3.2,maxA:4.6},ETc:{minA:0,maxA:5.5},JFC:{minA:0,maxA:15},TJN:{minA:4.6,maxA:5.5},CEN:{minA:5.5,maxA:30.1},TNO:{minA:30.1,maxA:1/0},earth:{minA:0,maxA:3e-4}};function un(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return null;let n=e*(1-t);return e*(1+t)<.983?`IEO`:e<1?`ATE`:n<1.017?`APO`:n<1.3?`AMO`:n<1.666&&e<3.2?`MCA`:e<2?`IMB`:e<3.2?`MBA`:e<4.6?`OMB`:e<5.5&&t<.3?`TJN`:e<30.1?`CEN`:`TNO`}var dn={[tn.SPICE_PROBE]:.005,[tn.SBDB_MOON]:.01,[tn.ASTERSAT]:.01},fn={[G.SPACECRAFT]:.005,[G.DEBRIS]:.005,[G.SURFACE_FEATURE]:.001},pn=.1;function mn(e){return Number.isFinite(e.radiusKm)&&e.radiusKm>0?e.radiusKm:dn[e.orbitalSource]??fn[e.objectType]??pn}function hn(e){return e>=G.ASTEROID&&e<=G.ASTEROID_TNO}function gn(e){return e===G.STAR||e===G.PLANET||e===G.DWARF_PLANET||e===G.MOON}function _n(e){return gn(e)||hn(e)||e===G.COMET}var vn={[tn.HORIZONS]:{archive:`horizons`,label:`NASA`},[tn.SBDB]:{archive:`sbdb`,label:`NASA`},[tn.SPICE]:{archive:`naif`,label:`NASA`},[tn.SBDB_MOON]:{archive:`sbdb`,label:`NASA`,scoped:!0},[tn.ASTERSAT]:{archive:`nsdb`,label:`Natural Satellites Data Base`,scoped:!0},[tn.SPICE_PROBE]:{archive:`naif`,label:`NASA`},[tn.CELESTRAK]:{archive:`celestrak`,label:`CelesTrak`,scoped:!0},[tn.SPACETRACK]:{archive:`spacetrack`,label:`Space-Track.org`,scoped:!0}},yn=[tn.HORIZONS,tn.SBDB,tn.SPICE,tn.SBDB_MOON,tn.ASTERSAT,tn.SPICE_PROBE,tn.CELESTRAK,tn.SPACETRACK];function bn(e){return vn[e]}var xn=class{imagery=new Map;#e=We(0);get imageryVersion(){return Bt(this.#e)}set imageryVersion(e){Ge(this.#e,e,!0)}model=new Map;#t=We(0);get modelVersion(){return Bt(this.#t)}set modelVersion(e){Ge(this.#t,e,!0)}orientation=new Map;#n=We(0);get orientationVersion(){return Bt(this.#n)}set orientationVersion(e){Ge(this.#n,e,!0)}#r=We(null);get skybox(){return Bt(this.#r)}set skybox(e){Ge(this.#r,e,!0)}#i=We(Xe(new Set));get orbitSources(){return Bt(this.#i)}set orbitSources(e){Ge(this.#i,e,!0)}#a=We(Xe(new Map));get orbitSourceParents(){return Bt(this.#a)}set orbitSourceParents(e){Ge(this.#a,e,!0)}registerImagery(e,t,n,r){let i=e===`rings`?`${e}${t}${r.source}`:`${e}${t}`;if(this.imagery.has(i))return;let{source:a,organisation:o,license:s,attribution:c,description:l}=r;this.imagery.set(i,{layer:e,bodyId:t,systemId:n,source:a,organisation:o,license:s,attribution:c,description:l}),this.imageryVersion++}imageryOf(e){return[...this.imagery.values()].filter(t=>t.layer===e)}registerOrientation(e){this.orientation.has(e.bodyId)||(this.orientation.set(e.bodyId,e),this.orientationVersion++)}registerModel(e){this.model.has(e.bodyId)||(this.model.set(e.bodyId,e),this.modelVersion++)}recordOrbitSources(e){let t=!1,n=!1;for(let r of e){let e=r.data.orbitalSource;if(e===tn.UNKNOWN||(this.orbitSources.has(e)||(this.orbitSources.add(e),t=!0),!bn(e)?.scoped))continue;let i=this.orbitSourceParents.get(e);i||(i=new Set,this.orbitSourceParents.set(e,i)),!i.has(r.data.parentId)&&(i.add(r.data.parentId),n=!0)}t&&(this.orbitSources=new Set(this.orbitSources)),n&&(this.orbitSourceParents=new Map(this.orbitSourceParents))}recordOrbitSource(e){e===tn.UNKNOWN||this.orbitSources.has(e)||(this.orbitSources.add(e),this.orbitSources=new Set(this.orbitSources))}},Sn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Cn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wn=`attached`,Tn=1e3,En=1001,Dn=1002,On=1003,kn=1004,An=1005,jn=1006,Mn=1007,Nn=1008,Pn=1009,Fn=1010,In=1011,Ln=1012,Rn=1013,zn=1014,Bn=1015,Vn=1016,Hn=1017,Un=1018,Wn=1020,Gn=35902,Kn=35899,qn=1021,Jn=1022,Yn=1023,Xn=1026,Zn=1027,Qn=1028,$n=1029,er=1030,tr=1031,nr=1033,rr=33776,ir=33777,ar=33778,or=33779,sr=35840,cr=35841,lr=35842,ur=35843,dr=36196,fr=37492,pr=37496,mr=37488,hr=37489,gr=37490,_r=37491,vr=37808,yr=37809,br=37810,xr=37811,Sr=37812,Cr=37813,wr=37814,Tr=37815,Er=37816,Dr=37817,Or=37818,kr=37819,Ar=37820,jr=37821,Mr=36492,Nr=36494,Pr=36495,Fr=36283,Ir=36284,Lr=36285,Rr=36286,zr=2300,Br=2301,Vr=2302,Hr=2303,Ur=2400,Wr=2401,Gr=2402,Kr=2500,qr=3200,Jr=`srgb`,Yr=`srgb-linear`,Xr=`linear`,Zr=`srgb`,Qr=7680,$r=35044,ei=2e3;function ti(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function ni(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ri(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function ii(){let e=ri(`canvas`);return e.style.display=`block`,e}var ai={},oi=null;function si(...e){let t=`THREE.`+e.shift();oi?oi(`log`,t,...e):console.log(t,...e)}function ci(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function K(...e){e=ci(e);let t=`THREE.`+e.shift();if(oi)oi(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function li(...e){e=ci(e);let t=`THREE.`+e.shift();if(oi)oi(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function ui(...e){let t=e.join(` `);t in ai||(ai[t]=!0,K(...e))}function di(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var fi={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},pi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},mi=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),hi=1234567,gi=Math.PI/180,_i=180/Math.PI;function vi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(mi[e&255]+mi[e>>8&255]+mi[e>>16&255]+mi[e>>24&255]+`-`+mi[t&255]+mi[t>>8&255]+`-`+mi[t>>16&15|64]+mi[t>>24&255]+`-`+mi[n&63|128]+mi[n>>8&255]+`-`+mi[n>>16&255]+mi[n>>24&255]+mi[r&255]+mi[r>>8&255]+mi[r>>16&255]+mi[r>>24&255]).toLowerCase()}function yi(e,t,n){return Math.max(t,Math.min(n,e))}function bi(e,t){return(e%t+t)%t}function xi(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Si(e,t,n){return e===t?0:(n-e)/(t-e)}function Ci(e,t,n){return(1-n)*e+n*t}function wi(e,t,n,r){return Ci(e,t,1-Math.exp(-n*r))}function Ti(e,t=1){return t-Math.abs(bi(e,t*2)-t)}function Ei(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Di(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Oi(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ki(e,t){return e+Math.random()*(t-e)}function Ai(e){return e*(.5-Math.random())}function ji(e){e!==void 0&&(hi=e);let t=hi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Mi(e){return e*gi}function Ni(e){return e*_i}function Pi(e){return(e&e-1)==0&&e!==0}function Fi(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Ii(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Li(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:K(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Ri(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function zi(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var Bi={DEG2RAD:gi,RAD2DEG:_i,generateUUID:vi,clamp:yi,euclideanModulo:bi,mapLinear:xi,inverseLerp:Si,lerp:Ci,damp:wi,pingpong:Ti,smoothstep:Ei,smootherstep:Di,randInt:Oi,randFloat:ki,randFloatSpread:Ai,seededRandom:ji,degToRad:Mi,radToDeg:Ni,isPowerOfTwo:Pi,ceilPowerOfTwo:Fi,floorPowerOfTwo:Ii,setQuaternionFromProperEuler:Li,normalize:zi,denormalize:Ri},q=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Vi=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:K(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yi(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},J=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ui.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ui.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Hi.copy(this).projectOnVector(e),this.sub(Hi)}reflect(e){return this.sub(Hi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Hi=new J,Ui=new Vi,Wi=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Gi.makeScale(e,t)),this}rotate(e){return this.premultiply(Gi.makeRotation(-e)),this}translate(e,t){return this.premultiply(Gi.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Gi=new Wi,Ki=new Wi().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),qi=new Wi().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ji(){let e={enabled:!0,workingColorSpace:Yr,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Xi(e.r),e.g=Xi(e.g),e.b=Xi(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Zi(e.r),e.g=Zi(e.g),e.b=Zi(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Xr:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return ui(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return ui(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Yr]:{primaries:t,whitePoint:r,transfer:Xr,toXYZ:Ki,fromXYZ:qi,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Jr},outputColorSpaceConfig:{drawingBufferColorSpace:Jr}},[Jr]:{primaries:t,whitePoint:r,transfer:Zr,toXYZ:Ki,fromXYZ:qi,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Jr}}}),e}var Yi=Ji();function Xi(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Zi(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Qi,$i=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Qi===void 0&&(Qi=ri(`canvas`)),Qi.width=e.width,Qi.height=e.height;let t=Qi.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Qi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=ri(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Xi(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Xi(t[e]/255)*255):t[e]=Xi(t[e]);return{data:t,width:e.width,height:e.height}}else return K(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},ea=0,ta=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:ea++}),this.uuid=vi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(na(r[t].image)):e.push(na(r[t]))}else e=na(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function na(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?$i.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(K(`Texture: Unable to serialize Texture.`),{})}var ra=0,ia=new J,aa=class e extends pi{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=En,i=En,a=jn,o=Nn,s=Yn,c=Pn,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:ra++}),this.uuid=vi(),this.name=``,this.source=new ta(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new q(0,0),this.repeat=new q(1,1),this.center=new q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Wi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ia).x}get height(){return this.source.getSize(ia).y}get depth(){return this.source.getSize(ia).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){K(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){K(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Tn:e.x-=Math.floor(e.x);break;case En:e.x=e.x<0?0:1;break;case Dn:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Tn:e.y-=Math.floor(e.y);break;case En:e.y=e.y<0?0:1;break;case Dn:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};aa.DEFAULT_IMAGE=null,aa.DEFAULT_MAPPING=300,aa.DEFAULT_ANISOTROPY=1;var oa=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this.w=yi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this.w=yi(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},sa=class extends pi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:jn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new oa(0,0,e,t),this.scissorTest=!1,this.viewport=new oa(0,0,e,t),this.textures=[];let r=new aa({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:jn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new ta(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},ca=class extends sa{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},la=class extends aa{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=On,this.minFilter=On,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ua=class extends aa{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=On,this.minFilter=On,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Y=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/da.setFromMatrixColumn(e,0).length(),i=1/da.setFromMatrixColumn(e,1).length(),a=1/da.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(pa,e,ma)}lookAt(e,t,n){let r=this.elements;return _a.subVectors(e,t),_a.lengthSq()===0&&(_a.z=1),_a.normalize(),ha.crossVectors(n,_a),ha.lengthSq()===0&&(Math.abs(n.z)===1?_a.x+=1e-4:_a.z+=1e-4,_a.normalize(),ha.crossVectors(n,_a)),ha.normalize(),ga.crossVectors(_a,ha),r[0]=ha.x,r[4]=ga.x,r[8]=_a.x,r[1]=ha.y,r[5]=ga.y,r[9]=_a.y,r[2]=ha.z,r[6]=ga.z,r[10]=_a.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],ee=r[3],N=r[7],te=r[11],ne=r[15];return i[0]=a*x+o*T+s*k+c*ee,i[4]=a*S+o*E+s*A+c*N,i[8]=a*C+o*D+s*j+c*te,i[12]=a*w+o*O+s*M+c*ne,i[1]=l*x+u*T+d*k+f*ee,i[5]=l*S+u*E+d*A+f*N,i[9]=l*C+u*D+d*j+f*te,i[13]=l*w+u*O+d*M+f*ne,i[2]=p*x+m*T+h*k+g*ee,i[6]=p*S+m*E+h*A+g*N,i[10]=p*C+m*D+h*j+g*te,i[14]=p*w+m*O+h*M+g*ne,i[3]=_*x+v*T+y*k+b*ee,i[7]=_*S+v*E+y*A+b*N,i[11]=_*C+v*D+y*j+b*te,i[15]=_*w+v*O+y*M+b*ne,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=da.set(r[0],r[1],r[2]).length(),o=da.set(r[4],r[5],r[6]).length(),s=da.set(r[8],r[9],r[10]).length();i<0&&(a=-a),fa.copy(this);let c=1/a,l=1/o,u=1/s;return fa.elements[0]*=c,fa.elements[1]*=c,fa.elements[2]*=c,fa.elements[4]*=l,fa.elements[5]*=l,fa.elements[6]*=l,fa.elements[8]*=u,fa.elements[9]*=u,fa.elements[10]*=u,t.setFromRotationMatrix(fa),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=ei,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=ei,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},da=new J,fa=new Y,pa=new J(0,0,0),ma=new J(1,1,1),ha=new J,ga=new J,_a=new J,va=new Y,ya=new Vi,ba=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(yi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-yi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(yi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-yi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(yi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-yi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:K(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return va.makeRotationFromQuaternion(e),this.setFromRotationMatrix(va,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ya.setFromEuler(this),this.setFromQuaternion(ya,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ba.DEFAULT_ORDER=`XYZ`;var xa=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},Sa=0,Ca=new J,wa=new Vi,Ta=new Y,Ea=new J,Da=new J,Oa=new J,ka=new Vi,Aa=new J(1,0,0),ja=new J(0,1,0),Ma=new J(0,0,1),Na={type:`added`},Pa={type:`removed`},Fa={type:`childadded`,child:null},Ia={type:`childremoved`,child:null},La=class e extends pi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:Sa++}),this.uuid=vi(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new J,n=new ba,r=new Vi,i=new J(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Y},normalMatrix:{value:new Wi}}),this.matrix=new Y,this.matrixWorld=new Y,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new xa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return wa.setFromAxisAngle(e,t),this.quaternion.multiply(wa),this}rotateOnWorldAxis(e,t){return wa.setFromAxisAngle(e,t),this.quaternion.premultiply(wa),this}rotateX(e){return this.rotateOnAxis(Aa,e)}rotateY(e){return this.rotateOnAxis(ja,e)}rotateZ(e){return this.rotateOnAxis(Ma,e)}translateOnAxis(e,t){return Ca.copy(e).applyQuaternion(this.quaternion),this.position.add(Ca.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Aa,e)}translateY(e){return this.translateOnAxis(ja,e)}translateZ(e){return this.translateOnAxis(Ma,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ta.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ea.copy(e):Ea.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Da.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ta.lookAt(Da,Ea,this.up):Ta.lookAt(Ea,Da,this.up),this.quaternion.setFromRotationMatrix(Ta),r&&(Ta.extractRotation(r.matrixWorld),wa.setFromRotationMatrix(Ta),this.quaternion.premultiply(wa.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(li(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Na),Fa.child=e,this.dispatchEvent(Fa),Fa.child=null):li(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Pa),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ta.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ta.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ta),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Na),Fa.child=e,this.dispatchEvent(Fa),Fa.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Da,e,Oa),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Da,ka,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};La.DEFAULT_UP=new J(0,1,0),La.DEFAULT_MATRIX_AUTO_UPDATE=!0,La.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Ra=class extends La{constructor(){super(),this.isGroup=!0,this.type=`Group`}},za={type:`move`},Ba=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ra,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ra,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new J,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new J),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ra,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new J,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new J),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position),s=.02,l=.005;c.inputState.pinching&&o>s+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(za)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Ra;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Va={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ha={h:0,s:0,l:0},Ua={h:0,s:0,l:0};function Wa(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var X=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Yi.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Yi.workingColorSpace){return this.r=e,this.g=t,this.b=n,Yi.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Yi.workingColorSpace){if(e=bi(e,1),t=yi(t,0,1),n=yi(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Wa(i,r,e+1/3),this.g=Wa(i,r,e),this.b=Wa(i,r,e-1/3)}return Yi.colorSpaceToWorking(this,r),this}setStyle(e,t=Jr){function n(t){t!==void 0&&parseFloat(t)<1&&K(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:K(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);K(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jr){let n=Va[e.toLowerCase()];return n===void 0?K(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Xi(e.r),this.g=Xi(e.g),this.b=Xi(e.b),this}copyLinearToSRGB(e){return this.r=Zi(e.r),this.g=Zi(e.g),this.b=Zi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jr){return Yi.workingToColorSpace(Ga.copy(this),e),Math.round(yi(Ga.r*255,0,255))*65536+Math.round(yi(Ga.g*255,0,255))*256+Math.round(yi(Ga.b*255,0,255))}getHexString(e=Jr){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Yi.workingColorSpace){Yi.workingToColorSpace(Ga.copy(this),t);let n=Ga.r,r=Ga.g,i=Ga.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Yi.workingColorSpace){return Yi.workingToColorSpace(Ga.copy(this),t),e.r=Ga.r,e.g=Ga.g,e.b=Ga.b,e}getStyle(e=Jr){Yi.workingToColorSpace(Ga.copy(this),e);let t=Ga.r,n=Ga.g,r=Ga.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Ha),this.setHSL(Ha.h+e,Ha.s+t,Ha.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ha),e.getHSL(Ua);let n=Ci(Ha.h,Ua.h,t),r=Ci(Ha.s,Ua.s,t),i=Ci(Ha.l,Ua.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Ga=new X;X.NAMES=Va;var Ka=class extends La{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ba,this.environmentIntensity=1,this.environmentRotation=new ba,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},qa=new J,Ja=new J,Ya=new J,Xa=new J,Za=new J,Qa=new J,$a=new J,eo=new J,to=new J,no=new J,ro=new oa,io=new oa,ao=new oa,oo=class e{constructor(e=new J,t=new J,n=new J){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),qa.subVectors(e,t),r.cross(qa);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){qa.subVectors(r,t),Ja.subVectors(n,t),Ya.subVectors(e,t);let a=qa.dot(qa),o=qa.dot(Ja),s=qa.dot(Ya),c=Ja.dot(Ja),l=Ja.dot(Ya),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Xa)===null?!1:Xa.x>=0&&Xa.y>=0&&Xa.x+Xa.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Xa)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Xa.x),s.addScaledVector(a,Xa.y),s.addScaledVector(o,Xa.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return ro.setScalar(0),io.setScalar(0),ao.setScalar(0),ro.fromBufferAttribute(e,t),io.fromBufferAttribute(e,n),ao.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ro,i.x),a.addScaledVector(io,i.y),a.addScaledVector(ao,i.z),a}static isFrontFacing(e,t,n,r){return qa.subVectors(n,t),Ja.subVectors(e,t),qa.cross(Ja).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qa.subVectors(this.c,this.b),Ja.subVectors(this.a,this.b),qa.cross(Ja).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Za.subVectors(r,n),Qa.subVectors(i,n),eo.subVectors(e,n);let s=Za.dot(eo),c=Qa.dot(eo);if(s<=0&&c<=0)return t.copy(n);to.subVectors(e,r);let l=Za.dot(to),u=Qa.dot(to);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Za,a);no.subVectors(e,i);let f=Za.dot(no),p=Qa.dot(no);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Qa,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return $a.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector($a,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Za,a).addScaledVector(Qa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},so=class{constructor(e=new J(1/0,1/0,1/0),t=new J(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(lo.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(lo.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=lo.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,lo):lo.fromBufferAttribute(r,t),lo.applyMatrix4(e.matrixWorld),this.expandByPoint(lo);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),uo.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),uo.copy(e.boundingBox)),uo.applyMatrix4(e.matrixWorld),this.union(uo)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,lo),lo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(vo),yo.subVectors(this.max,vo),fo.subVectors(e.a,vo),po.subVectors(e.b,vo),mo.subVectors(e.c,vo),ho.subVectors(po,fo),go.subVectors(mo,po),_o.subVectors(fo,mo);let t=[0,-ho.z,ho.y,0,-go.z,go.y,0,-_o.z,_o.y,ho.z,0,-ho.x,go.z,0,-go.x,_o.z,0,-_o.x,-ho.y,ho.x,0,-go.y,go.x,0,-_o.y,_o.x,0];return!So(t,fo,po,mo,yo)||(t=[1,0,0,0,1,0,0,0,1],!So(t,fo,po,mo,yo))?!1:(bo.crossVectors(ho,go),t=[bo.x,bo.y,bo.z],So(t,fo,po,mo,yo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,lo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(lo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(co[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),co[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),co[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),co[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),co[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),co[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),co[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),co[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(co),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},co=[new J,new J,new J,new J,new J,new J,new J,new J],lo=new J,uo=new so,fo=new J,po=new J,mo=new J,ho=new J,go=new J,_o=new J,vo=new J,yo=new J,bo=new J,xo=new J;function So(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){xo.fromArray(e,a);let o=i.x*Math.abs(xo.x)+i.y*Math.abs(xo.y)+i.z*Math.abs(xo.z),s=t.dot(xo),c=n.dot(xo),l=r.dot(xo);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Co=new J,wo=new q,To=0,Eo=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:To++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=$r,this.updateRanges=[],this.gpuType=Bn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyMatrix3(e),this.setXY(t,wo.x,wo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.applyMatrix3(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.applyMatrix4(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.applyNormalMatrix(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.transformDirection(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=zi(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ri(t,this.array)),t}setX(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ri(t,this.array)),t}setY(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ri(t,this.array)),t}setZ(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ri(t,this.array)),t}setW(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array),i=zi(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}},Do=class extends Eo{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Oo=class extends Eo{constructor(e,t,n){super(new Uint32Array(e),t,n)}},ko=class extends Eo{constructor(e,t,n){super(new Float32Array(e),t,n)}},Ao=new so,jo=new J,Mo=new J,No=class{constructor(e=new J,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Ao.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;jo.subVectors(e,this.center);let t=jo.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(jo,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Mo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(jo.copy(e.center).add(Mo)),this.expandByPoint(jo.copy(e.center).sub(Mo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Po=0,Fo=new Y,Io=new La,Lo=new J,Ro=new so,zo=new so,Bo=new J,Vo=class e extends pi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:Po++}),this.uuid=vi(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ti(e)?Oo:Do)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Wi().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fo.makeRotationFromQuaternion(e),this.applyMatrix4(Fo),this}rotateX(e){return Fo.makeRotationX(e),this.applyMatrix4(Fo),this}rotateY(e){return Fo.makeRotationY(e),this.applyMatrix4(Fo),this}rotateZ(e){return Fo.makeRotationZ(e),this.applyMatrix4(Fo),this}translate(e,t,n){return Fo.makeTranslation(e,t,n),this.applyMatrix4(Fo),this}scale(e,t,n){return Fo.makeScale(e,t,n),this.applyMatrix4(Fo),this}lookAt(e){return Io.lookAt(e),Io.updateMatrix(),this.applyMatrix4(Io.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lo).negate(),this.translate(Lo.x,Lo.y,Lo.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new ko(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&K(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new so);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){li(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new J(-1/0,-1/0,-1/0),new J(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ro.setFromBufferAttribute(n),this.morphTargetsRelative?(Bo.addVectors(this.boundingBox.min,Ro.min),this.boundingBox.expandByPoint(Bo),Bo.addVectors(this.boundingBox.max,Ro.max),this.boundingBox.expandByPoint(Bo)):(this.boundingBox.expandByPoint(Ro.min),this.boundingBox.expandByPoint(Ro.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&li(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new No);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){li(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new J,1/0);return}if(e){let n=this.boundingSphere.center;if(Ro.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];zo.setFromBufferAttribute(n),this.morphTargetsRelative?(Bo.addVectors(Ro.min,zo.min),Ro.expandByPoint(Bo),Bo.addVectors(Ro.max,zo.max),Ro.expandByPoint(Bo)):(Ro.expandByPoint(zo.min),Ro.expandByPoint(zo.max))}Ro.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Bo.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Bo));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Bo.fromBufferAttribute(a,t),o&&(Lo.fromBufferAttribute(e,t),Bo.add(Lo)),r=Math.max(r,n.distanceToSquared(Bo))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&li(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){li(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new Eo(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new J,s[e]=new J;let c=new J,l=new J,u=new J,d=new q,f=new q,p=new q,m=new J,h=new J;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new J,y=new J,b=new J,x=new J;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new Eo(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new J,i=new J,a=new J,o=new J,s=new J,c=new J,l=new J,u=new J;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Bo.fromBufferAttribute(e,t),Bo.normalize(),e.setXYZ(t,Bo.x,Bo.y,Bo.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Eo(a,r,i)}if(this.index===null)return K(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},Ho=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=$r,this.updateRanges=[],this.version=0,this.uuid=vi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Uo=new J,Wo=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Uo.fromBufferAttribute(this,t),Uo.applyMatrix4(e),this.setXYZ(t,Uo.x,Uo.y,Uo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Uo.fromBufferAttribute(this,t),Uo.applyNormalMatrix(e),this.setXYZ(t,Uo.x,Uo.y,Uo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Uo.fromBufferAttribute(this,t),Uo.transformDirection(e),this.setXYZ(t,Uo.x,Uo.y,Uo.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=zi(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ri(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ri(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ri(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ri(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array),i=zi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){si(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Eo(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){si(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Go=0,Ko=class extends pi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:Go++}),this.uuid=vi(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new X(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qr,this.stencilZFail=Qr,this.stencilZPass=Qr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){K(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){K(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},qo=class extends Ko{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Jo,Yo=new J,Xo=new J,Zo=new J,Qo=new q,$o=new q,es=new Y,ts=new J,ns=new J,rs=new J,is=new q,as=new q,os=new q,ss=class extends La{constructor(e=new qo){if(super(),this.isSprite=!0,this.type=`Sprite`,Jo===void 0){Jo=new Vo;let e=new Ho(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Jo.setIndex([0,1,2,0,2,3]),Jo.setAttribute(`position`,new Wo(e,3,0,!1)),Jo.setAttribute(`uv`,new Wo(e,2,3,!1))}this.geometry=Jo,this.material=e,this.center=new q(.5,.5),this.count=1}raycast(e,t){e.camera===null&&li(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Xo.setFromMatrixScale(this.matrixWorld),es.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Zo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Xo.multiplyScalar(-Zo.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;cs(ts.set(-.5,-.5,0),Zo,a,Xo,r,i),cs(ns.set(.5,-.5,0),Zo,a,Xo,r,i),cs(rs.set(.5,.5,0),Zo,a,Xo,r,i),is.set(0,0),as.set(1,0),os.set(1,1);let o=e.ray.intersectTriangle(ts,ns,rs,!1,Yo);if(o===null&&(cs(ns.set(-.5,.5,0),Zo,a,Xo,r,i),as.set(0,1),o=e.ray.intersectTriangle(ts,rs,ns,!1,Yo),o===null))return;let s=e.ray.origin.distanceTo(Yo);s<e.near||s>e.far||t.push({distance:s,point:Yo.clone(),uv:oo.getInterpolation(Yo,ts,ns,rs,is,as,os,new q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function cs(e,t,n,r,i,a){Qo.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?$o.copy(Qo):($o.x=a*Qo.x-i*Qo.y,$o.y=i*Qo.x+a*Qo.y),e.copy(t),e.x+=$o.x,e.y+=$o.y,e.applyMatrix4(es)}var ls=new J,us=new J,ds=new J,fs=new J,ps=new J,ms=new J,hs=new J,gs=class{constructor(e=new J,t=new J(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ls)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ls.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ls.copy(this.origin).addScaledVector(this.direction,t),ls.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){us.copy(e).add(t).multiplyScalar(.5),ds.copy(t).sub(e).normalize(),fs.copy(this.origin).sub(us);let i=e.distanceTo(t)*.5,a=-this.direction.dot(ds),o=fs.dot(this.direction),s=-fs.dot(ds),c=fs.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(us).addScaledVector(ds,d),f}intersectSphere(e,t){ls.subVectors(e.center,this.origin);let n=ls.dot(this.direction),r=ls.dot(ls)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ls)!==null}intersectTriangle(e,t,n,r,i){ps.subVectors(t,e),ms.subVectors(n,e),hs.crossVectors(ps,ms);let a=this.direction.dot(hs),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fs.subVectors(this.origin,e);let s=o*this.direction.dot(ms.crossVectors(fs,ms));if(s<0)return null;let c=o*this.direction.dot(ps.cross(fs));if(c<0||s+c>a)return null;let l=-o*fs.dot(hs);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},_s=class extends Ko{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ba,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},vs=new Y,ys=new gs,bs=new No,xs=new J,Ss=new J,Cs=new J,ws=new J,Ts=new J,Es=new J,Ds=new J,Os=new J,ks=class extends La{constructor(e=new Vo,t=new _s){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Es.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Ts.fromBufferAttribute(s,e),a?Es.addScaledVector(Ts,r):Es.addScaledVector(Ts.sub(t),r))}t.add(Es)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),bs.copy(n.boundingSphere),bs.applyMatrix4(i),ys.copy(e.ray).recast(e.near),!(bs.containsPoint(ys.origin)===!1&&(ys.intersectSphere(bs,xs)===null||ys.origin.distanceToSquared(xs)>(e.far-e.near)**2))&&(vs.copy(i).invert(),ys.copy(e.ray).applyMatrix4(vs),!(n.boundingBox!==null&&ys.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ys)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=js(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=js(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=js(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=js(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function As(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Os.copy(s),Os.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Os);return l<n.near||l>n.far?null:{distance:l,point:Os.clone(),object:e}}function js(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Ss),e.getVertexPosition(c,Cs),e.getVertexPosition(l,ws);let u=As(e,t,n,r,Ss,Cs,ws,Ds);if(u){let e=new J;oo.getBarycoord(Ds,Ss,Cs,ws,e),i&&(u.uv=oo.getInterpolatedAttribute(i,s,c,l,e,new q)),a&&(u.uv1=oo.getInterpolatedAttribute(a,s,c,l,e,new q)),o&&(u.normal=oo.getInterpolatedAttribute(o,s,c,l,e,new J),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new J,materialIndex:0};oo.getNormal(Ss,Cs,ws,t.normal),u.face=t,u.barycoord=e}return u}var Ms=new J,Ns=new oa,Ps=new oa,Fs=new J,Is=new Y,Ls=new J,Rs=new No,zs=new Y,Bs=new gs,Vs=class extends ks{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=wn,this.bindMatrix=new Y,this.bindMatrixInverse=new Y,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new so),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ls),this.boundingBox.expandByPoint(Ls)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new No),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ls),this.boundingSphere.expandByPoint(Ls)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Rs.copy(this.boundingSphere),Rs.applyMatrix4(r),e.ray.intersectsSphere(Rs)!==!1&&(zs.copy(r).invert(),Bs.copy(e.ray).applyMatrix4(zs),!(this.boundingBox!==null&&Bs.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Bs)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new oa,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():K(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Ns.fromBufferAttribute(r.attributes.skinIndex,e),Ps.fromBufferAttribute(r.attributes.skinWeight,e),Ms.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let r=Ps.getComponent(e);if(r!==0){let i=Ns.getComponent(e);Is.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Fs.copy(Ms).applyMatrix4(Is),r)}}return t.applyMatrix4(this.bindMatrixInverse)}},Hs=class extends La{constructor(){super(),this.isBone=!0,this.type=`Bone`}},Us=class extends aa{constructor(e=null,t=1,n=1,r,i,a,o,s,c=On,l=On,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Ws=new Y,Gs=new Y,Ks=class e{constructor(e=[],t=[]){this.uuid=vi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){K(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Y)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new Y;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:Gs;Ws.multiplyMatrices(i,t[r]),Ws.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Us(t,e,e,Yn,Bn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(K(`Skeleton: No bone found with UUID:`,r),i=new Hs),this.bones.push(i),this.boneInverses.push(new Y().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},qs=class extends Eo{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Js=new Y,Ys=new Y,Xs=[],Zs=new so,Qs=new Y,$s=new ks,ec=new No,tc=class extends ks{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qs(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,Qs)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new so),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Js),Zs.copy(e.boundingBox).applyMatrix4(Js),this.boundingBox.union(Zs)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new No),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Js),ec.copy(e.boundingSphere).applyMatrix4(Js),this.boundingSphere.union(ec)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if($s.geometry=this.geometry,$s.material=this.material,$s.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ec.copy(this.boundingSphere),ec.applyMatrix4(n),e.ray.intersectsSphere(ec)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,Js),Ys.multiplyMatrices(n,Js),$s.matrixWorld=Ys,$s.raycast(e,Xs);for(let e=0,n=Xs.length;e<n;e++){let n=Xs[e];n.instanceId=i,n.object=this,t.push(n)}Xs.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new qs(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Us(new Float32Array(r*this.count),r,this.count,Qn,Bn));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;i[s]=o,i.set(n,s+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:`dispose`}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},nc=new J,rc=new J,ic=new Wi,ac=class{constructor(e=new J(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=nc.subVectors(n,t).cross(rc.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(nc),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||ic.getNormalMatrix(e),r=this.coplanarPoint(nc).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},oc=new No,sc=new q(.5,.5),cc=new J,lc=class{constructor(e=new ac,t=new ac,n=new ac,r=new ac,i=new ac,a=new ac){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ei,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),oc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),oc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(oc)}intersectsSprite(e){return oc.center.set(0,0,0),oc.radius=.7071067811865476+sc.distanceTo(e.center),oc.applyMatrix4(e.matrixWorld),this.intersectsSphere(oc)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(cc.x=r.normal.x>0?e.max.x:e.min.x,cc.y=r.normal.y>0?e.max.y:e.min.y,cc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(cc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},uc=class extends Ko{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new X(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},dc=new J,fc=new J,pc=new Y,mc=new gs,hc=new No,gc=new J,_c=new J,vc=class extends La{constructor(e=new Vo,t=new uc){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)dc.fromBufferAttribute(t,e-1),fc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=dc.distanceTo(fc);e.setAttribute(`lineDistance`,new ko(n,1))}else K(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hc.copy(n.boundingSphere),hc.applyMatrix4(r),hc.radius+=i,e.ray.intersectsSphere(hc)===!1)return;pc.copy(r).invert(),mc.copy(e.ray).applyMatrix4(pc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=yc(this,e,mc,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=yc(this,e,mc,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=yc(this,e,mc,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=yc(this,e,mc,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function yc(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(dc.fromBufferAttribute(s,i),fc.fromBufferAttribute(s,a),n.distanceSqToSegment(dc,fc,gc,_c)>r)return;gc.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(gc);if(!(c<t.near||c>t.far))return{distance:c,point:_c.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var bc=new J,xc=new J,Sc=class extends vc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)bc.fromBufferAttribute(t,e),xc.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+bc.distanceTo(xc);e.setAttribute(`lineDistance`,new ko(n,1))}else K(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},Cc=class extends vc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},wc=class extends Ko{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Tc=new Y,Ec=new gs,Dc=new No,Oc=new J,kc=class extends La{constructor(e=new Vo,t=new wc){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Dc.copy(n.boundingSphere),Dc.applyMatrix4(r),Dc.radius+=i,e.ray.intersectsSphere(Dc)===!1)return;Tc.copy(r).invert(),Ec.copy(e.ray).applyMatrix4(Tc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Oc.fromBufferAttribute(l,n),Ac(Oc,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Oc.fromBufferAttribute(l,a),Ac(Oc,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Ac(e,t,n,r,i,a,o){let s=Ec.distanceSqToPoint(e);if(s<n){let n=new J;Ec.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var jc=class extends aa{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Mc=class extends aa{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Nc=class extends aa{constructor(e,t,n=zn,r,i,a,o=On,s=On,c,l=Xn,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ta(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Pc=class extends Nc{constructor(e,t=zn,n=301,r,i,a=On,o=On,s,c=Xn){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Fc=class extends aa{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Ic=class e extends Vo{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new ko(c,3)),this.setAttribute(`normal`,new ko(l,3)),this.setAttribute(`uv`,new ko(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new J;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Lc=class e extends Vo{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new ko(u,3)),this.setAttribute(`normal`,new ko(d,3)),this.setAttribute(`uv`,new ko(f,2));function _(){let a=new J,_=new J,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new q,m=new J,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Rc=class e extends Lc{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},zc=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){K(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new q:new J);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new J,r=[],i=[],a=[],o=new J,s=new Y;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new J)}i[0]=new J,a[0]=new J;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(yi(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(yi(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Bc=class extends zc{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new q){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Vc=class extends Bc{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Hc(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Uc=new J,Wc=new Hc,Gc=new Hc,Kc=new Hc,qc=class extends zc{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new J){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Uc.subVectors(r[0],r[1]).add(r[0]),c=Uc);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Uc.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Uc),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),Wc.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),Gc.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),Kc.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(Wc.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),Gc.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),Kc.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(Wc.calc(s),Gc.calc(s),Kc.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new J().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Jc(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Yc(e,t){let n=1-e;return n*n*t}function Xc(e,t){return 2*(1-e)*e*t}function Zc(e,t){return e*e*t}function Qc(e,t,n,r){return Yc(e,t)+Xc(e,n)+Zc(e,r)}function $c(e,t){let n=1-e;return n*n*n*t}function el(e,t){let n=1-e;return 3*n*n*e*t}function tl(e,t){return 3*(1-e)*e*e*t}function nl(e,t){return e*e*e*t}function rl(e,t,n,r,i){return $c(e,t)+el(e,n)+tl(e,r)+nl(e,i)}var il=class extends zc{constructor(e=new q,t=new q,n=new q,r=new q){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(rl(e,r.x,i.x,a.x,o.x),rl(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},al=class extends zc{constructor(e=new J,t=new J,n=new J,r=new J){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(rl(e,r.x,i.x,a.x,o.x),rl(e,r.y,i.y,a.y,o.y),rl(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ol=class extends zc{constructor(e=new q,t=new q){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new q){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},sl=class extends zc{constructor(e=new J,t=new J){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new J){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},cl=class extends zc{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Qc(e,r.x,i.x,a.x),Qc(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ll=class extends zc{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Qc(e,r.x,i.x,a.x),Qc(e,r.y,i.y,a.y),Qc(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ul=class extends zc{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new q){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Jc(o,s.x,c.x,l.x,u.x),Jc(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new q().fromArray(n))}return this}},dl=Object.freeze({__proto__:null,ArcCurve:Vc,CatmullRomCurve3:qc,CubicBezierCurve:il,CubicBezierCurve3:al,EllipseCurve:Bc,LineCurve:ol,LineCurve3:sl,QuadraticBezierCurve:cl,QuadraticBezierCurve3:ll,SplineCurve:ul}),fl=class extends zc{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new dl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new dl[n.type]().fromJSON(n))}return this}},pl=class extends fl{constructor(e){super(),this.type=`Path`,this.currentPoint=new q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new ol(this.currentPoint.clone(),new q(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new cl(this.currentPoint.clone(),new q(e,t),new q(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new il(this.currentPoint.clone(),new q(e,t),new q(n,r),new q(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=new ul([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new Bc(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ml=class extends pl{constructor(e){super(e),this.uuid=vi(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new pl().fromJSON(n))}return this}};function hl(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=gl(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=Cl(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return vl(a,o,n,s,c,l,0),o}function gl(e,t,n,r,i){let a;if(i===ql(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Wl(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Wl(i/r|0,e[i],e[i+1],a);return a&&Il(a,a.next)&&(Gl(a),a=a.next),a}function _l(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Il(n,n.next)||Fl(n.prev,n,n.next)===0)){if(Gl(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function vl(e,t,n,r,i,a,o){if(!e)return;!o&&a&&Ol(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?bl(e,r,i,a):yl(e)){t.push(c.i,e.i,l.i),Gl(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=xl(_l(e),t),vl(e,t,n,r,i,a,2)):o===2&&Sl(e,t,n,r,i,a):vl(_l(e),t,n,r,i,a,1);break}}}function yl(e){let t=e.prev,n=e,r=e.next;if(Fl(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Nl(i,s,a,c,o,l,m.x,m.y)&&Fl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function bl(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Fl(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Al(p,m,t,n,r),v=Al(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Nl(s,u,c,d,l,f,y.x,y.y)&&Fl(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Nl(s,u,c,d,l,f,b.x,b.y)&&Fl(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Nl(s,u,c,d,l,f,y.x,y.y)&&Fl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Nl(s,u,c,d,l,f,b.x,b.y)&&Fl(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function xl(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Il(r,i)&&Ll(r,n,n.next,i)&&Vl(r,i)&&Vl(i,r)&&(t.push(r.i,n.i,i.i),Gl(n),Gl(n.next),n=e=i),n=n.next}while(n!==e);return _l(n)}function Sl(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Pl(o,e)){let s=Ul(o,e);o=_l(o,o.next),s=_l(s,s.next),vl(o,t,n,r,i,a,0),vl(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Cl(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=gl(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(jl(o))}i.sort(wl);for(let e=0;e<i.length;e++)n=Tl(i[e],n);return n}function wl(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function Tl(e,t){let n=El(e,t);if(!n)return t;let r=Ul(n,e);return _l(r,r.next),_l(n,n.next)}function El(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Il(e,n))return n;do{if(Il(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&Ml(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);Vl(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&Dl(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Dl(e,t){return Fl(e.prev,e,t.prev)<0&&Fl(t.next,e,e.next)<0}function Ol(e,t,n,r){let i=e;do i.z===0&&(i.z=Al(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,kl(i)}function kl(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function Al(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function jl(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Ml(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Nl(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Ml(e,t,n,r,i,a,o,s)}function Pl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Bl(e,t)&&(Vl(e,t)&&Vl(t,e)&&Hl(e,t)&&(Fl(e.prev,e,t.prev)||Fl(e,t.prev,t))||Il(e,t)&&Fl(e.prev,e,e.next)>0&&Fl(t.prev,t,t.next)>0)}function Fl(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Il(e,t){return e.x===t.x&&e.y===t.y}function Ll(e,t,n,r){let i=zl(Fl(e,t,n)),a=zl(Fl(e,t,r)),o=zl(Fl(n,r,e)),s=zl(Fl(n,r,t));return!!(i!==a&&o!==s||i===0&&Rl(e,n,t)||a===0&&Rl(e,r,t)||o===0&&Rl(n,e,r)||s===0&&Rl(n,t,r))}function Rl(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function zl(e){return e>0?1:e<0?-1:0}function Bl(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ll(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Vl(e,t){return Fl(e.prev,e,e.next)<0?Fl(e,t,e.next)>=0&&Fl(e,e.prev,t)>=0:Fl(e,t,e.prev)<0||Fl(e,e.next,t)<0}function Hl(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Ul(e,t){let n=Kl(e.i,e.x,e.y),r=Kl(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Wl(e,t,n,r){let i=Kl(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Gl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Kl(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ql(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Jl=class{static triangulate(e,t,n=2){return hl(e,t,n)}},Yl=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];Xl(e),Zl(n,e);let a=e.length;t.forEach(Xl);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Zl(n,t[e]);let o=Jl.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}};function Xl(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Zl(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var Ql=class e extends Vo{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new ko(p,3)),this.setAttribute(`normal`,new ko(m,3)),this.setAttribute(`uv`,new ko(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},$l=class e extends Vo{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new J,p=new q;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new ko(s,3)),this.setAttribute(`normal`,new ko(c,3)),this.setAttribute(`uv`,new ko(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},eu=class e extends Vo{constructor(e=new ml([new q(0,.5),new q(-.5,-.5),new q(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new ko(r,3)),this.setAttribute(`normal`,new ko(i,3)),this.setAttribute(`uv`,new ko(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Yl.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Yl.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Yl.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return tu(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}};function tu(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}var nu=class e extends Vo{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new J,d=new J,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new ko(p,3)),this.setAttribute(`normal`,new ko(m,3)),this.setAttribute(`uv`,new ko(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},ru=class extends Ko{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new X(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}};function iu(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(K(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function au(e){let t={};for(let n=0;n<e.length;n++){let r=iu(e[n]);for(let e in r)t[e]=r[e]}return t}function ou(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function su(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Yi.workingColorSpace}var cu={clone:iu,merge:au},lu=`void main() {
2
+ var e=[`open`,`non-commercial`,`site-only`],t={dataUrl:`https://static.spacemap.co`,imagesUrl:`https://images.spacemap.co`,liveUrl:`https://live.spacemap.co`,locale:()=>`en`,messages:{body_note_no_model:()=>`no model available`,body_note_no_radius:()=>`no size data available`,body_note_crash_site:()=>`crash site, no wreckage model`,carried_by_scene_label:({carrier:e})=>`Carried by ${e}`,scene_canvas_label:()=>`Interactive 3D map of the Solar System`,attribution_orbits:()=>`Orbits`,attribution_imagery:()=>`Imagery`,credits_see_all:()=>`See full credits`,layer_surface:()=>`Surface`,layer_clouds:()=>`Clouds`,layer_night:()=>`Night lights`,layer_graticule:()=>`Grid`,layer_nomenclature:()=>`Named features`,cooperative_wheel:()=>`Use ctrl + scroll to zoom the map`,cooperative_wheel_mac:()=>`Use ⌘ + scroll to zoom the map`,cooperative_touch:()=>`Use two fingers to move the map`},bodyHref:()=>``,textures:`open`},n=t;function r(e){let{messages:r,...i}=e;n={...t,...i},r&&(n.messages={...t.messages,...r}),n.dataUrl=n.dataUrl.replace(/\/$/,``),n.imagesUrl=n.imagesUrl.replace(/\/$/,``),n.liveUrl=n.liveUrl.replace(/\/$/,``)}function i(){return n}function a(t){if(t===void 0)return!0;let r=e.indexOf(t);return r<0?!1:r<=e.indexOf(n.textures)}function o(e){for(let t of e)if(t&&a(t.distribution))return t}function s(){return n.locale()}var c=Symbol(`uninitialized`),l=Array.isArray,u=Array.prototype.indexOf,d=Array.prototype.includes;Array.from;var f=Object.getOwnPropertyDescriptor,p=Object.prototype,m=Array.prototype,h=Object.getPrototypeOf,g=()=>{};function _(e){for(var t=0;t<e.length;t++)e[t]()}function v(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var y=1024,b=2048,x=4096,S=8192,C=16384,w=32768,T=1<<25,E=65536,D=1<<19,O=1<<20,k=65536,A=1<<21,j=1<<23,M=Symbol(`$state`),ee=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"};globalThis.document?.contentType;function N(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function te(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function ne(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function re(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function P(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ie(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function ae(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function F(){console.warn(`https://svelte.dev/e/derived_inert`)}function I(e){return e===this.v}var oe=!1,se=!1,ce=null;function le(e){ce=e}function ue(){return!se||ce!==null&&ce.l===null}var de=[];function fe(){var e=de;de=[],_(e)}function pe(e){if(de.length===0&&!xe){var t=de;queueMicrotask(()=>{t===de&&fe()})}de.push(e)}function me(e){var t=xt;if(t===null)return vt.f|=j,e;if(!(t.f&32768)&&!(t.f&4))throw e;he(e,t)}function he(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var L=~(b|x|y);function R(e,t){e.f=e.f&L|t}function z(e){e.f&512||e.deps===null?R(e,y):R(e,x)}function ge(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=k,ge(t.deps))}function B(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ge(e.deps),R(e,y)}var _e=!1,V=null,H=null,U=null,ve=null,ye=null,be=null,xe=!1,Se=!1,Ce=null,W=null,we=0,Te=1,Ee=class e{id=Te++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){H===null?V=H=this:(H.#n=this,this.#t=H),H=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)R(r,b),t(r);for(r of n.m)R(r,x),t(r)}this.#p.add(e)}#g(){this.#e=!0,we++>1e3&&(this.#S(),De());for(let e of this.#u)this.#d.delete(e),R(e,b),this.schedule(e);for(let e of this.#d)R(e,x),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Ce=[],r=[],i=W=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw Pe(e),this.#h()||this.discard(),t}if(U=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Ce=null,W=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)Ne(e,t);i.length>0&&U.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),ve=this,ke(r),ke(n),ve=null,this.#s?.resolve();var s=U;if(this.#a===0&&(this.#c.length===0||s!==null)&&(this.#S(),oe&&(this.#x(),U=s)),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=y;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=y:i&4?t.push(r):oe&&i&16777224?n.push(r):Pt(r)&&(i&16&&this.#d.add(r),zt(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),R(i,b),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),U=this,this.#g()}#b(e){for(var t=0;t<e.length;t+=1)B(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==c&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),ye?.set(e,t)),this.is_fork||(e.v=t)}activate(){U=this}deactivate(){U=null,ye=null}flush(){try{Se=!0,U=this,this.#g()}finally{we=0,be=null,Ce=null,W=null,Se=!1,U=null,ye=null,Ve.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#S(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}#x(){for(let l=V;l!==null;l=l.#n){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=l.async_deriveds.get(e);n&&t.promise.then(n.resolve).catch(n.reject)}if(l.#e){var r=[...l.current.keys()].filter(e=>!l.current.get(e)[1]&&!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#p)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#b([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Ae(o,r,i,a);a=new Map;var s=[...l.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(s.length>0)for(let e of this.#l)!(e.f&155648)&&je(e,s,a)&&(e.f&4194320?(R(e,b),l.schedule(e)):l.#u.add(e));if(l.#c.length>0&&!l.#m){l.apply();for(var c of l.#c)l.#_(c,[],[]);l.#c=[]}l.deactivate()}}}}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,pe(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=v()).promise}static ensure(){if(U===null){let t=U=new e;!Se&&!xe&&pe(()=>{t.#e||t.flush()})}return U}apply(){if(!oe||!this.is_fork&&this.#t===null&&this.#n===null){ye=null;return}ye=new Map;for(let[e,[t]]of this.current)ye.set(e,t);for(let t=V;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,r]]of t.current)if(!r&&this.current.has(n)){e=!0;break}}if(!e)for(let[e,n]of t.previous)ye.has(e)||ye.set(e,n)}}schedule(e){if(be=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Ce!==null&&t===xt&&(oe||(vt===null||!(vt.f&2))&&!_e))return;if(n&96){if(!(n&1024))return;t.f^=y}}this.#c.push(t)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null?V=t:e.#n=t,t===null?H=e:t.#t=e,this.linked=!1}}};function De(){try{re()}catch(e){he(e,be)}}var Oe=null;function ke(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Pt(r)&&(Oe=new Set,zt(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&ft(r),Oe?.size>0)){Ve.clear();for(let e of Oe){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Oe.has(n)&&(Oe.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||zt(n)}}Oe.clear()}}Oe=null}}function Ae(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Ae(i,t,n,r):e&4194320&&!(e&2048)&&je(i,t,r)&&(R(i,b),Me(i))}}function je(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(d.call(t,r))return!0;if(r.f&2&&je(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Me(e){U.schedule(e)}function Ne(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),R(e,y);for(var n=e.first;n!==null;)Ne(n,t),n=n.next}}function Pe(e){R(e,y);for(var t=e.first;t!==null;)Pe(t),t=t.next}E|D;function Fe(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)ut(t[n])}}function Ie(e){var t,n=xt,r=e.parent;if(!gt&&r!==null&&e.v!==c&&r.f&24576)return F(),e.v;St(r);try{e.f&=~k,Fe(e),t=It(e)}finally{St(n)}return t}function Le(e){var t=Ie(e);if(!e.equals(t)&&(e.wv=Nt(),(!U?.is_fork||e.deps===null)&&(U===null?e.v=t:(U.capture(e,t,!0),ve?.capture(e,t,!0)),e.deps===null))){R(e,y);return}gt||(ye===null?z(e):(rt()||U?.is_fork)&&ye.set(e,t))}function Re(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(ee),t.fn!==null&&(t.teardown=g),t.ac=null,Rt(t,0),ct(t))}function ze(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&zt(t)}var Be=new Set,Ve=new Map,He=!1;function Ue(e,t){return{f:0,v:e,reactions:null,equals:I,rv:0,wv:0}}function We(e,t){let n=Ue(e,t);return wt(n),n}function Ge(e,t,n=!1){return vt!==null&&(!yt||vt.f&131072)&&ue()&&vt.f&4325394&&(Ct===null||!Ct.has(e))&&ae(),Ke(e,n?Xe(t):t,W)}function Ke(e,t,n=null){if(!e.equals(t)){Ve.set(e,gt?t:e.v);var r=Ee.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Ie(t),ye===null&&z(t)}e.wv=Nt(),Ye(e,b,n),ue()&&xt!==null&&xt.f&1024&&!(xt.f&96)&&(Dt===null?Ot([e]):Dt.push(e)),!r.is_fork&&Be.size>0&&!He&&qe()}return t}function qe(){He=!1;for(let e of Be){e.f&1024&&R(e,x);let t;try{t=Pt(e)}catch{t=!0}t&&zt(e)}Be.clear()}function Je(e){Ge(e,e.v+1)}function Ye(e,t,n){var r=e.reactions;if(r!==null)for(var i=ue(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===xt)){var l=(c&b)===0;if(l&&R(s,t),c&131072)Be.add(s);else if(c&2){var u=s;ye?.delete(u),c&65536||(c&512&&(xt===null||!(xt.f&2097152))&&(s.f|=k),Ye(u,x,n))}else if(l){var d=s;c&16&&Oe!==null&&Oe.add(d),n===null?Me(d):n.push(d)}}}}function Xe(e){if(typeof e!=`object`||!e||M in e)return e;let t=h(e);if(t!==p&&t!==m)return e;var n=new Map,r=l(e),i=We(0),a=null,o=jt,s=e=>{if(jt===o)return e();var t=vt,n=jt;bt(null),Mt(o);var r=e();return bt(t),Mt(n),r};return r&&n.set(`length`,We(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&P();var i=n.get(t);return i===void 0?s(()=>{var e=We(r.value,a);return n.set(t,e),e}):Ge(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>We(c,a));n.set(t,e),Je(i)}}else Ge(r,c),Je(i);return!0},get(t,r,i){if(r===M)return e;var o=n.get(r),l=r in t;if(o===void 0&&(!l||f(t,r)?.writable)&&(o=s(()=>We(Xe(l?t[r]:c),a)),n.set(r,o)),o!==void 0){var u=Bt(o);return u===c?void 0:u}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=Bt(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==c)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===M)return!0;var r=n.get(t),i=r!==void 0&&r.v!==c||Reflect.has(e,t);return(r!==void 0||xt!==null&&(!i||f(e,t)?.writable))&&(r===void 0&&(r=s(()=>We(i?Xe(e[t]):c,a)),n.set(t,r)),Bt(r)===c)?!1:i},set(e,t,o,l){var u=n.get(t),d=t in e;if(r&&t===`length`)for(var p=o;p<u.v;p+=1){var m=n.get(p+``);m===void 0?p in e&&(m=s(()=>We(c,a)),n.set(p+``,m)):Ge(m,c)}if(u===void 0)(!d||f(e,t)?.writable)&&(u=s(()=>We(void 0,a)),Ge(u,Xe(o)),n.set(t,u));else{d=u.v!==c;var h=s(()=>Xe(o));Ge(u,h)}var g=Reflect.getOwnPropertyDescriptor(e,t);if(g?.set&&g.set.call(l,o),!d){if(r&&typeof t==`string`){var _=n.get(`length`),v=Number(t);Number.isInteger(v)&&v>=_.v&&Ge(_,v+1)}Je(i)}return!0},ownKeys(e){Bt(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==c});for(var[r,a]of n)a.v!==c&&!(r in e)&&t.push(r);return t},setPrototypeOf(){ie()}})}var Ze;function Qe(e){return Ze.call(e)}function $e(e){var t=vt,n=xt;bt(null),St(null);try{return e()}finally{bt(t),St(n)}}function et(e){xt===null&&(vt===null&&ne(e),te()),gt&&N(e)}function tt(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function nt(e,t){var n=xt;n!==null&&n.f&8192&&(e|=S);var r={ctx:ce,deps:null,nodes:null,f:e|b|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};U?.register_created_effect(r);var i=r;if(e&4)Ce===null?Ee.ensure().schedule(r):Ce.push(r);else if(t!==null){try{zt(r)}catch(e){throw ut(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=E))}if(i!==null&&(i.parent=n,n!==null&&tt(i,n),vt!==null&&vt.f&2&&!(e&64))){var a=vt;(a.effects??=[]).push(i)}return r}function rt(){return vt!==null&&!yt}function it(e){et(`$effect`);var t=xt.f;if(!vt&&t&32&&ce!==null&&!ce.i){var n=ce;(n.e??=[]).push(e)}else return at(e)}function at(e){return nt(4|O,e)}function ot(e){Ee.ensure();let t=nt(64|D,e);return()=>{ut(t)}}function st(e){var t=e.teardown;if(t!==null){let e=gt,n=vt;_t(!0),bt(null);try{t.call(null)}finally{_t(e),bt(n)}}}function ct(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&$e(()=>{e.abort(ee)});var r=n.next;n.f&64?n.parent=null:ut(n,t),n=r}}function lt(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||ut(t),t=n}}function ut(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(dt(e.nodes.start,e.nodes.end),n=!0),e.f|=T,ct(e,t&&!n),Rt(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();st(e),e.f^=T,e.f|=C;var i=e.parent;i!==null&&i.first!==null&&ft(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function dt(e,t){for(;e!==null;){var n=e===t?null:Qe(e);e.remove(),e=n}}function ft(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function pt(e,t,n){if(!(e.f&8192)){e.f^=S;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;pt(i,t,o?n:!1)}i=a}}}var mt=null,ht=!1,gt=!1;function _t(e){gt=e}var vt=null,yt=!1;function bt(e){vt=e}var xt=null;function St(e){xt=e}var Ct=null;function wt(e){vt!==null&&(!oe||vt.f&2)&&(Ct??=new Set).add(e)}var Tt=null,Et=0,Dt=null;function Ot(e){Dt=e}var kt=1,At=0,jt=At;function Mt(e){jt=e}function Nt(){return++kt}function Pt(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~k),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Pt(a)&&Le(a),a.wv>e.wv)return!0}t&512&&ye===null&&R(e,y)}return!1}function Ft(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!oe&&Ct!==null&&Ct.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Ft(a,t,!1):t===a&&(n?R(a,b):a.f&1024&&R(a,x),Me(a))}}function It(e){var t=Tt,n=Et,r=Dt,i=vt,a=Ct,o=ce,s=yt,c=jt,l=e.f;Tt=null,Et=0,Dt=null,vt=l&96?null:e,Ct=null,le(e.ctx),yt=!1,jt=++At,e.ac!==null&&($e(()=>{e.ac.abort(ee)}),e.ac=null);try{e.f|=A;var u=e.fn,d=u();e.f|=w;var f=e.deps,p=U?.is_fork;if(Tt!==null){var m;if(p||Rt(e,Et),f!==null&&Et>0)for(f.length=Et+Tt.length,m=0;m<Tt.length;m++)f[Et+m]=Tt[m];else e.deps=f=Tt;if(rt()&&e.f&512)for(m=Et;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&Et<f.length&&(Rt(e,Et),f.length=Et);if(ue()&&Dt!==null&&!yt&&f!==null&&!(e.f&6146))for(m=0;m<Dt.length;m++)Ft(Dt[m],e);if(i!==null&&i!==e){if(At++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=At;if(t!==null)for(let e of t)e.rv=At;Dt!==null&&(r===null?r=Dt:r.push(...Dt))}return e.f&8388608&&(e.f^=j),d}catch(e){return me(e)}finally{e.f^=A,Tt=t,Et=n,Dt=r,vt=i,Ct=a,le(o),yt=s,jt=c}}function Lt(e,t){let n=t.reactions;if(n!==null){var r=u.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(Tt===null||!d.call(Tt,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~k),a.v!==c&&z(a),Re(a),Rt(a,0)}}function Rt(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Lt(e,n[r])}function zt(e){var t=e.f;if(!(t&16384)){R(e,y);var n=xt,r=ht;xt=e,ht=!0;try{t&16777232?lt(e):ct(e),st(e);var i=It(e);e.teardown=typeof i==`function`?i:null,e.wv=kt}finally{ht=r,xt=n}}}function Bt(e){var t=(e.f&2)!=0;if(mt?.add(e),vt!==null&&!yt&&!(xt!==null&&xt.f&16384)&&(Ct===null||!Ct.has(e))){var n=vt.deps;if(vt.f&2097152)e.rv<At&&(e.rv=At,Tt===null&&n!==null&&n[Et]===e?Et++:Tt===null?Tt=[e]:Tt.push(e));else{vt.deps??=[],d.call(vt.deps,e)||vt.deps.push(e);var r=e.reactions;r===null?e.reactions=[vt]:d.call(r,vt)||r.push(vt)}}if(gt&&Ve.has(e))return Ve.get(e);if(t){var i=e;if(gt){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Ht(i))&&(a=Ie(i)),Ve.set(i,a),a}var o=(i.f&512)==0&&!yt&&vt!==null&&(ht||(vt.f&512)!=0),s=(i.f&w)===0;Pt(i)&&(o&&(i.f|=512),Le(i)),o&&!s&&(ze(i),Vt(i))}if(ye?.has(e))return ye.get(e);if(e.f&8388608)throw e.v;return e.v}function Vt(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(ze(t),Vt(t))}function Ht(e){if(e.v===c)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Ve.has(t)||t.f&2&&Ht(t))return!0;return!1}globalThis?.window?.trustedTypes,[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];function Ut(){return i().dataUrl}var Wt={};function Gt(e){Wt=e??{}}function Kt(e,t){return qt(Ut(),e,t)}function qt(e,t,n){let r=Wt[n];return r?`${e}${t}?v=${r}`:(console.error(`versionedUrl: missing '${n}' token for ${t}`),`${e}${t}`)}var Jt=32,Yt=e=>`${Ut()}/v1/labels/${e}.gz`;function Xt(e){return e===null?``:`${e}/`}function Zt(e,t,n){return Kt(`/v1/position/${e}/${Xt(t)}${n}.bin.gz`,`position`)}function Qt(e,t,n,r){return Kt(`/v1/position/${e}/${Xt(t)}${n}/${r}.bin.gz`,`position`)}function $t(e,t,n){return Kt(`/v1/position/${e}/${Xt(t)}${n}.bin.gz`,`position`)}var en=function(e){return e[e.PLANET=0]=`PLANET`,e[e.SYSTEM=1]=`SYSTEM`,e}({}),tn=function(e){return e[e.HORIZONS=0]=`HORIZONS`,e[e.SBDB=1]=`SBDB`,e[e.CELESTRAK=2]=`CELESTRAK`,e[e.SPICE=3]=`SPICE`,e[e.SBDB_MOON=4]=`SBDB_MOON`,e[e.SPICE_PROBE=5]=`SPICE_PROBE`,e[e.SPACETRACK=6]=`SPACETRACK`,e[e.ASTERSAT=7]=`ASTERSAT`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),nn=function(e){return e[e.NAIF=0]=`NAIF`,e[e.SPKID=1]=`SPKID`,e[e.NORAD_SATCAT=2]=`NORAD_SATCAT`,e[e.PROBE=4]=`PROBE`,e[e.UNKNOWN=255]=`UNKNOWN`,e}({}),rn={[nn.NAIF]:`naif`,[nn.SPKID]:`spkid`,[nn.NORAD_SATCAT]:`norad_satcat`,[nn.PROBE]:`probe`},an=new Map(Object.entries(rn).map(([e,t])=>[t,Number(e)]));function on(e){return an.get(e)}function sn(e,t){let n=rn[e];return n?`${n}-${t}`:null}function cn(e){return e.data.objectType===G.SURFACE_FEATURE}var G=function(e){return e[e.BARYCENTER=0]=`BARYCENTER`,e[e.LAGRANGE_POINT=1]=`LAGRANGE_POINT`,e[e.STAR=2]=`STAR`,e[e.PLANET=3]=`PLANET`,e[e.DWARF_PLANET=4]=`DWARF_PLANET`,e[e.MOON=5]=`MOON`,e[e.ASTEROID=6]=`ASTEROID`,e[e.ASTEROID_INNER=7]=`ASTEROID_INNER`,e[e.ASTEROID_MAIN_BELT=8]=`ASTEROID_MAIN_BELT`,e[e.ASTEROID_TROJAN=9]=`ASTEROID_TROJAN`,e[e.ASTEROID_CENTAUR=10]=`ASTEROID_CENTAUR`,e[e.ASTEROID_TNO=11]=`ASTEROID_TNO`,e[e.COMET=12]=`COMET`,e[e.SPACECRAFT=13]=`SPACECRAFT`,e[e.DEBRIS=14]=`DEBRIS`,e[e.UNDOCUMENTED=15]=`UNDOCUMENTED`,e[e.SURFACE_FEATURE=16]=`SURFACE_FEATURE`,e}({}),ln={IEO:{minA:0,maxA:.983},ATE:{minA:.5,maxA:1},APO:{minA:1,maxA:3.2},AMO:{minA:1,maxA:3.2},MCA:{minA:1.3,maxA:3.2},IMB:{minA:1.666,maxA:2},MBA:{minA:2,maxA:3.2},OMB:{minA:3.2,maxA:4.6},ETc:{minA:0,maxA:5.5},JFC:{minA:0,maxA:15},TJN:{minA:4.6,maxA:5.5},CEN:{minA:5.5,maxA:30.1},TNO:{minA:30.1,maxA:1/0},earth:{minA:0,maxA:3e-4}};function un(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return null;let n=e*(1-t);return e*(1+t)<.983?`IEO`:e<1?`ATE`:n<1.017?`APO`:n<1.3?`AMO`:n<1.666&&e<3.2?`MCA`:e<2?`IMB`:e<3.2?`MBA`:e<4.6?`OMB`:e<5.5&&t<.3?`TJN`:e<30.1?`CEN`:`TNO`}var dn={[tn.SPICE_PROBE]:.005,[tn.SBDB_MOON]:.01,[tn.ASTERSAT]:.01},fn={[G.SPACECRAFT]:.005,[G.DEBRIS]:.005,[G.SURFACE_FEATURE]:.001},pn=.1;function mn(e){return Number.isFinite(e.radiusKm)&&e.radiusKm>0?e.radiusKm:dn[e.orbitalSource]??fn[e.objectType]??pn}function hn(e){return e>=G.ASTEROID&&e<=G.ASTEROID_TNO}function gn(e){return e===G.STAR||e===G.PLANET||e===G.DWARF_PLANET||e===G.MOON}function _n(e){return gn(e)||hn(e)||e===G.COMET}var vn={[tn.HORIZONS]:{archive:`horizons`,label:`NASA`},[tn.SBDB]:{archive:`sbdb`,label:`NASA`},[tn.SPICE]:{archive:`naif`,label:`NASA`},[tn.SBDB_MOON]:{archive:`sbdb`,label:`NASA`,scoped:!0},[tn.ASTERSAT]:{archive:`nsdb`,label:`Natural Satellites Data Base`,scoped:!0},[tn.SPICE_PROBE]:{archive:`naif`,label:`NASA`},[tn.CELESTRAK]:{archive:`celestrak`,label:`CelesTrak`,scoped:!0},[tn.SPACETRACK]:{archive:`spacetrack`,label:`Space-Track.org`,scoped:!0}},yn=[tn.HORIZONS,tn.SBDB,tn.SPICE,tn.SBDB_MOON,tn.ASTERSAT,tn.SPICE_PROBE,tn.CELESTRAK,tn.SPACETRACK];function bn(e){return vn[e]}var xn=class{imagery=new Map;#e=We(0);get imageryVersion(){return Bt(this.#e)}set imageryVersion(e){Ge(this.#e,e,!0)}model=new Map;#t=We(0);get modelVersion(){return Bt(this.#t)}set modelVersion(e){Ge(this.#t,e,!0)}orientation=new Map;#n=We(0);get orientationVersion(){return Bt(this.#n)}set orientationVersion(e){Ge(this.#n,e,!0)}#r=We(null);get skybox(){return Bt(this.#r)}set skybox(e){Ge(this.#r,e,!0)}#i=We(Xe(new Set));get orbitSources(){return Bt(this.#i)}set orbitSources(e){Ge(this.#i,e,!0)}#a=We(Xe(new Map));get orbitSourceParents(){return Bt(this.#a)}set orbitSourceParents(e){Ge(this.#a,e,!0)}registerImagery(e,t,n,r){let i=e===`rings`?`${e}${t}${r.source}`:`${e}${t}`;if(this.imagery.has(i))return;let{source:a,organisation:o,license:s,attribution:c,description:l}=r;this.imagery.set(i,{layer:e,bodyId:t,systemId:n,source:a,organisation:o,license:s,attribution:c,description:l}),this.imageryVersion++}imageryOf(e){return[...this.imagery.values()].filter(t=>t.layer===e)}registerOrientation(e){this.orientation.has(e.bodyId)||(this.orientation.set(e.bodyId,e),this.orientationVersion++)}registerModel(e){this.model.has(e.bodyId)||(this.model.set(e.bodyId,e),this.modelVersion++)}recordOrbitSources(e){let t=!1,n=!1;for(let r of e){let e=r.data.orbitalSource;if(e===tn.UNKNOWN||(this.orbitSources.has(e)||(this.orbitSources.add(e),t=!0),!bn(e)?.scoped))continue;let i=this.orbitSourceParents.get(e);i||(i=new Set,this.orbitSourceParents.set(e,i)),!i.has(r.data.parentId)&&(i.add(r.data.parentId),n=!0)}t&&(this.orbitSources=new Set(this.orbitSources)),n&&(this.orbitSourceParents=new Map(this.orbitSourceParents))}recordOrbitSource(e){e===tn.UNKNOWN||this.orbitSources.has(e)||(this.orbitSources.add(e),this.orbitSources=new Set(this.orbitSources))}},Sn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Cn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wn=`attached`,Tn=1e3,En=1001,Dn=1002,On=1003,kn=1004,An=1005,jn=1006,Mn=1007,Nn=1008,Pn=1009,Fn=1010,In=1011,Ln=1012,Rn=1013,zn=1014,Bn=1015,Vn=1016,Hn=1017,Un=1018,Wn=1020,Gn=35902,Kn=35899,qn=1021,Jn=1022,Yn=1023,Xn=1026,Zn=1027,Qn=1028,$n=1029,er=1030,tr=1031,nr=1033,rr=33776,ir=33777,ar=33778,or=33779,sr=35840,cr=35841,lr=35842,ur=35843,dr=36196,fr=37492,pr=37496,mr=37488,hr=37489,gr=37490,_r=37491,vr=37808,yr=37809,br=37810,xr=37811,Sr=37812,Cr=37813,wr=37814,Tr=37815,Er=37816,Dr=37817,Or=37818,kr=37819,Ar=37820,jr=37821,Mr=36492,Nr=36494,Pr=36495,Fr=36283,Ir=36284,Lr=36285,Rr=36286,zr=2300,Br=2301,Vr=2302,Hr=2303,Ur=2400,Wr=2401,Gr=2402,Kr=2500,qr=3200,Jr=`srgb`,Yr=`srgb-linear`,Xr=`linear`,Zr=`srgb`,Qr=7680,$r=35044,ei=2e3;function ti(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function ni(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ri(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function ii(){let e=ri(`canvas`);return e.style.display=`block`,e}var ai={},oi=null;function si(...e){let t=`THREE.`+e.shift();oi?oi(`log`,t,...e):console.log(t,...e)}function ci(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function K(...e){e=ci(e);let t=`THREE.`+e.shift();if(oi)oi(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function li(...e){e=ci(e);let t=`THREE.`+e.shift();if(oi)oi(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function ui(...e){let t=e.join(` `);t in ai||(ai[t]=!0,K(...e))}function di(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var fi={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},pi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},mi=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),hi=1234567,gi=Math.PI/180,_i=180/Math.PI;function vi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(mi[e&255]+mi[e>>8&255]+mi[e>>16&255]+mi[e>>24&255]+`-`+mi[t&255]+mi[t>>8&255]+`-`+mi[t>>16&15|64]+mi[t>>24&255]+`-`+mi[n&63|128]+mi[n>>8&255]+`-`+mi[n>>16&255]+mi[n>>24&255]+mi[r&255]+mi[r>>8&255]+mi[r>>16&255]+mi[r>>24&255]).toLowerCase()}function yi(e,t,n){return Math.max(t,Math.min(n,e))}function bi(e,t){return(e%t+t)%t}function xi(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function Si(e,t,n){return e===t?0:(n-e)/(t-e)}function Ci(e,t,n){return(1-n)*e+n*t}function wi(e,t,n,r){return Ci(e,t,1-Math.exp(-n*r))}function Ti(e,t=1){return t-Math.abs(bi(e,t*2)-t)}function Ei(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Di(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Oi(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ki(e,t){return e+Math.random()*(t-e)}function Ai(e){return e*(.5-Math.random())}function ji(e){e!==void 0&&(hi=e);let t=hi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Mi(e){return e*gi}function Ni(e){return e*_i}function Pi(e){return(e&e-1)==0&&e!==0}function Fi(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Ii(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Li(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:K(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Ri(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function zi(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var Bi={DEG2RAD:gi,RAD2DEG:_i,generateUUID:vi,clamp:yi,euclideanModulo:bi,mapLinear:xi,inverseLerp:Si,lerp:Ci,damp:wi,pingpong:Ti,smoothstep:Ei,smootherstep:Di,randInt:Oi,randFloat:ki,randFloatSpread:Ai,seededRandom:ji,degToRad:Mi,radToDeg:Ni,isPowerOfTwo:Pi,ceilPowerOfTwo:Fi,floorPowerOfTwo:Ii,setQuaternionFromProperEuler:Li,normalize:zi,denormalize:Ri},q=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Vi=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:K(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yi(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},J=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ui.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ui.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Hi.copy(this).projectOnVector(e),this.sub(Hi)}reflect(e){return this.sub(Hi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(yi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Hi=new J,Ui=new Vi,Wi=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Gi.makeScale(e,t)),this}rotate(e){return this.premultiply(Gi.makeRotation(-e)),this}translate(e,t){return this.premultiply(Gi.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Gi=new Wi,Ki=new Wi().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),qi=new Wi().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ji(){let e={enabled:!0,workingColorSpace:Yr,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Xi(e.r),e.g=Xi(e.g),e.b=Xi(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Zi(e.r),e.g=Zi(e.g),e.b=Zi(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Xr:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return ui(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return ui(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Yr]:{primaries:t,whitePoint:r,transfer:Xr,toXYZ:Ki,fromXYZ:qi,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Jr},outputColorSpaceConfig:{drawingBufferColorSpace:Jr}},[Jr]:{primaries:t,whitePoint:r,transfer:Zr,toXYZ:Ki,fromXYZ:qi,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Jr}}}),e}var Yi=Ji();function Xi(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Zi(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Qi,$i=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Qi===void 0&&(Qi=ri(`canvas`)),Qi.width=e.width,Qi.height=e.height;let t=Qi.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Qi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=ri(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Xi(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Xi(t[e]/255)*255):t[e]=Xi(t[e]);return{data:t,width:e.width,height:e.height}}else return K(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},ea=0,ta=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:ea++}),this.uuid=vi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(na(r[t].image)):e.push(na(r[t]))}else e=na(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function na(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?$i.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(K(`Texture: Unable to serialize Texture.`),{})}var ra=0,ia=new J,aa=class e extends pi{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=En,i=En,a=jn,o=Nn,s=Yn,c=Pn,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:ra++}),this.uuid=vi(),this.name=``,this.source=new ta(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new q(0,0),this.repeat=new q(1,1),this.center=new q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Wi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ia).x}get height(){return this.source.getSize(ia).y}get depth(){return this.source.getSize(ia).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){K(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){K(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Tn:e.x-=Math.floor(e.x);break;case En:e.x=e.x<0?0:1;break;case Dn:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Tn:e.y-=Math.floor(e.y);break;case En:e.y=e.y<0?0:1;break;case Dn:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};aa.DEFAULT_IMAGE=null,aa.DEFAULT_MAPPING=300,aa.DEFAULT_ANISOTROPY=1;var oa=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=yi(this.x,e.x,t.x),this.y=yi(this.y,e.y,t.y),this.z=yi(this.z,e.z,t.z),this.w=yi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=yi(this.x,e,t),this.y=yi(this.y,e,t),this.z=yi(this.z,e,t),this.w=yi(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yi(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},sa=class extends pi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:jn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new oa(0,0,e,t),this.scissorTest=!1,this.viewport=new oa(0,0,e,t),this.textures=[];let r=new aa({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:jn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new ta(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},ca=class extends sa{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},la=class extends aa{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=On,this.minFilter=On,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ua=class extends aa{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=On,this.minFilter=On,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Y=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/da.setFromMatrixColumn(e,0).length(),i=1/da.setFromMatrixColumn(e,1).length(),a=1/da.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(pa,e,ma)}lookAt(e,t,n){let r=this.elements;return _a.subVectors(e,t),_a.lengthSq()===0&&(_a.z=1),_a.normalize(),ha.crossVectors(n,_a),ha.lengthSq()===0&&(Math.abs(n.z)===1?_a.x+=1e-4:_a.z+=1e-4,_a.normalize(),ha.crossVectors(n,_a)),ha.normalize(),ga.crossVectors(_a,ha),r[0]=ha.x,r[4]=ga.x,r[8]=_a.x,r[1]=ha.y,r[5]=ga.y,r[9]=_a.y,r[2]=ha.z,r[6]=ga.z,r[10]=_a.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],ee=r[3],N=r[7],te=r[11],ne=r[15];return i[0]=a*x+o*T+s*k+c*ee,i[4]=a*S+o*E+s*A+c*N,i[8]=a*C+o*D+s*j+c*te,i[12]=a*w+o*O+s*M+c*ne,i[1]=l*x+u*T+d*k+f*ee,i[5]=l*S+u*E+d*A+f*N,i[9]=l*C+u*D+d*j+f*te,i[13]=l*w+u*O+d*M+f*ne,i[2]=p*x+m*T+h*k+g*ee,i[6]=p*S+m*E+h*A+g*N,i[10]=p*C+m*D+h*j+g*te,i[14]=p*w+m*O+h*M+g*ne,i[3]=_*x+v*T+y*k+b*ee,i[7]=_*S+v*E+y*A+b*N,i[11]=_*C+v*D+y*j+b*te,i[15]=_*w+v*O+y*M+b*ne,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=da.set(r[0],r[1],r[2]).length(),o=da.set(r[4],r[5],r[6]).length(),s=da.set(r[8],r[9],r[10]).length();i<0&&(a=-a),fa.copy(this);let c=1/a,l=1/o,u=1/s;return fa.elements[0]*=c,fa.elements[1]*=c,fa.elements[2]*=c,fa.elements[4]*=l,fa.elements[5]*=l,fa.elements[6]*=l,fa.elements[8]*=u,fa.elements[9]*=u,fa.elements[10]*=u,t.setFromRotationMatrix(fa),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=ei,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=ei,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},da=new J,fa=new Y,pa=new J(0,0,0),ma=new J(1,1,1),ha=new J,ga=new J,_a=new J,va=new Y,ya=new Vi,ba=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(yi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-yi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(yi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-yi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(yi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-yi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:K(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return va.makeRotationFromQuaternion(e),this.setFromRotationMatrix(va,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ya.setFromEuler(this),this.setFromQuaternion(ya,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ba.DEFAULT_ORDER=`XYZ`;var xa=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},Sa=0,Ca=new J,wa=new Vi,Ta=new Y,Ea=new J,Da=new J,Oa=new J,ka=new Vi,Aa=new J(1,0,0),ja=new J(0,1,0),Ma=new J(0,0,1),Na={type:`added`},Pa={type:`removed`},Fa={type:`childadded`,child:null},Ia={type:`childremoved`,child:null},La=class e extends pi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:Sa++}),this.uuid=vi(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new J,n=new ba,r=new Vi,i=new J(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Y},normalMatrix:{value:new Wi}}),this.matrix=new Y,this.matrixWorld=new Y,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new xa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return wa.setFromAxisAngle(e,t),this.quaternion.multiply(wa),this}rotateOnWorldAxis(e,t){return wa.setFromAxisAngle(e,t),this.quaternion.premultiply(wa),this}rotateX(e){return this.rotateOnAxis(Aa,e)}rotateY(e){return this.rotateOnAxis(ja,e)}rotateZ(e){return this.rotateOnAxis(Ma,e)}translateOnAxis(e,t){return Ca.copy(e).applyQuaternion(this.quaternion),this.position.add(Ca.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Aa,e)}translateY(e){return this.translateOnAxis(ja,e)}translateZ(e){return this.translateOnAxis(Ma,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ta.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ea.copy(e):Ea.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Da.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ta.lookAt(Da,Ea,this.up):Ta.lookAt(Ea,Da,this.up),this.quaternion.setFromRotationMatrix(Ta),r&&(Ta.extractRotation(r.matrixWorld),wa.setFromRotationMatrix(Ta),this.quaternion.premultiply(wa.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(li(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Na),Fa.child=e,this.dispatchEvent(Fa),Fa.child=null):li(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Pa),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ta.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ta.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ta),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Na),Fa.child=e,this.dispatchEvent(Fa),Fa.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Da,e,Oa),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Da,ka,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};La.DEFAULT_UP=new J(0,1,0),La.DEFAULT_MATRIX_AUTO_UPDATE=!0,La.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Ra=class extends La{constructor(){super(),this.isGroup=!0,this.type=`Group`}},za={type:`move`},Ba=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ra,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ra,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new J,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new J),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ra,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new J,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new J),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position),s=.02,l=.005;c.inputState.pinching&&o>s+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(za)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Ra;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Va={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ha={h:0,s:0,l:0},Ua={h:0,s:0,l:0};function Wa(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var X=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Yi.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Yi.workingColorSpace){return this.r=e,this.g=t,this.b=n,Yi.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Yi.workingColorSpace){if(e=bi(e,1),t=yi(t,0,1),n=yi(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Wa(i,r,e+1/3),this.g=Wa(i,r,e),this.b=Wa(i,r,e-1/3)}return Yi.colorSpaceToWorking(this,r),this}setStyle(e,t=Jr){function n(t){t!==void 0&&parseFloat(t)<1&&K(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:K(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);K(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jr){let n=Va[e.toLowerCase()];return n===void 0?K(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Xi(e.r),this.g=Xi(e.g),this.b=Xi(e.b),this}copyLinearToSRGB(e){return this.r=Zi(e.r),this.g=Zi(e.g),this.b=Zi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jr){return Yi.workingToColorSpace(Ga.copy(this),e),Math.round(yi(Ga.r*255,0,255))*65536+Math.round(yi(Ga.g*255,0,255))*256+Math.round(yi(Ga.b*255,0,255))}getHexString(e=Jr){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Yi.workingColorSpace){Yi.workingToColorSpace(Ga.copy(this),t);let n=Ga.r,r=Ga.g,i=Ga.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Yi.workingColorSpace){return Yi.workingToColorSpace(Ga.copy(this),t),e.r=Ga.r,e.g=Ga.g,e.b=Ga.b,e}getStyle(e=Jr){Yi.workingToColorSpace(Ga.copy(this),e);let t=Ga.r,n=Ga.g,r=Ga.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Ha),this.setHSL(Ha.h+e,Ha.s+t,Ha.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ha),e.getHSL(Ua);let n=Ci(Ha.h,Ua.h,t),r=Ci(Ha.s,Ua.s,t),i=Ci(Ha.l,Ua.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Ga=new X;X.NAMES=Va;var Ka=class extends La{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ba,this.environmentIntensity=1,this.environmentRotation=new ba,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},qa=new J,Ja=new J,Ya=new J,Xa=new J,Za=new J,Qa=new J,$a=new J,eo=new J,to=new J,no=new J,ro=new oa,io=new oa,ao=new oa,oo=class e{constructor(e=new J,t=new J,n=new J){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),qa.subVectors(e,t),r.cross(qa);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){qa.subVectors(r,t),Ja.subVectors(n,t),Ya.subVectors(e,t);let a=qa.dot(qa),o=qa.dot(Ja),s=qa.dot(Ya),c=Ja.dot(Ja),l=Ja.dot(Ya),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Xa)===null?!1:Xa.x>=0&&Xa.y>=0&&Xa.x+Xa.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Xa)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Xa.x),s.addScaledVector(a,Xa.y),s.addScaledVector(o,Xa.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return ro.setScalar(0),io.setScalar(0),ao.setScalar(0),ro.fromBufferAttribute(e,t),io.fromBufferAttribute(e,n),ao.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ro,i.x),a.addScaledVector(io,i.y),a.addScaledVector(ao,i.z),a}static isFrontFacing(e,t,n,r){return qa.subVectors(n,t),Ja.subVectors(e,t),qa.cross(Ja).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qa.subVectors(this.c,this.b),Ja.subVectors(this.a,this.b),qa.cross(Ja).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Za.subVectors(r,n),Qa.subVectors(i,n),eo.subVectors(e,n);let s=Za.dot(eo),c=Qa.dot(eo);if(s<=0&&c<=0)return t.copy(n);to.subVectors(e,r);let l=Za.dot(to),u=Qa.dot(to);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Za,a);no.subVectors(e,i);let f=Za.dot(no),p=Qa.dot(no);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Qa,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return $a.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector($a,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Za,a).addScaledVector(Qa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},so=class{constructor(e=new J(1/0,1/0,1/0),t=new J(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(lo.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(lo.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=lo.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,lo):lo.fromBufferAttribute(r,t),lo.applyMatrix4(e.matrixWorld),this.expandByPoint(lo);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),uo.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),uo.copy(e.boundingBox)),uo.applyMatrix4(e.matrixWorld),this.union(uo)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,lo),lo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(vo),yo.subVectors(this.max,vo),fo.subVectors(e.a,vo),po.subVectors(e.b,vo),mo.subVectors(e.c,vo),ho.subVectors(po,fo),go.subVectors(mo,po),_o.subVectors(fo,mo);let t=[0,-ho.z,ho.y,0,-go.z,go.y,0,-_o.z,_o.y,ho.z,0,-ho.x,go.z,0,-go.x,_o.z,0,-_o.x,-ho.y,ho.x,0,-go.y,go.x,0,-_o.y,_o.x,0];return!So(t,fo,po,mo,yo)||(t=[1,0,0,0,1,0,0,0,1],!So(t,fo,po,mo,yo))?!1:(bo.crossVectors(ho,go),t=[bo.x,bo.y,bo.z],So(t,fo,po,mo,yo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,lo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(lo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(co[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),co[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),co[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),co[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),co[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),co[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),co[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),co[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(co),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},co=[new J,new J,new J,new J,new J,new J,new J,new J],lo=new J,uo=new so,fo=new J,po=new J,mo=new J,ho=new J,go=new J,_o=new J,vo=new J,yo=new J,bo=new J,xo=new J;function So(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){xo.fromArray(e,a);let o=i.x*Math.abs(xo.x)+i.y*Math.abs(xo.y)+i.z*Math.abs(xo.z),s=t.dot(xo),c=n.dot(xo),l=r.dot(xo);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Co=new J,wo=new q,To=0,Eo=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:To++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=$r,this.updateRanges=[],this.gpuType=Bn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyMatrix3(e),this.setXY(t,wo.x,wo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.applyMatrix3(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.applyMatrix4(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.applyNormalMatrix(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Co.fromBufferAttribute(this,t),Co.transformDirection(e),this.setXYZ(t,Co.x,Co.y,Co.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=zi(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ri(t,this.array)),t}setX(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ri(t,this.array)),t}setY(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ri(t,this.array)),t}setZ(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ri(t,this.array)),t}setW(e,t){return this.normalized&&(t=zi(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array),i=zi(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}},Do=class extends Eo{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Oo=class extends Eo{constructor(e,t,n){super(new Uint32Array(e),t,n)}},ko=class extends Eo{constructor(e,t,n){super(new Float32Array(e),t,n)}},Ao=new so,jo=new J,Mo=new J,No=class{constructor(e=new J,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Ao.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;jo.subVectors(e,this.center);let t=jo.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(jo,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Mo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(jo.copy(e.center).add(Mo)),this.expandByPoint(jo.copy(e.center).sub(Mo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Po=0,Fo=new Y,Io=new La,Lo=new J,Ro=new so,zo=new so,Bo=new J,Vo=class e extends pi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:Po++}),this.uuid=vi(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ti(e)?Oo:Do)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Wi().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fo.makeRotationFromQuaternion(e),this.applyMatrix4(Fo),this}rotateX(e){return Fo.makeRotationX(e),this.applyMatrix4(Fo),this}rotateY(e){return Fo.makeRotationY(e),this.applyMatrix4(Fo),this}rotateZ(e){return Fo.makeRotationZ(e),this.applyMatrix4(Fo),this}translate(e,t,n){return Fo.makeTranslation(e,t,n),this.applyMatrix4(Fo),this}scale(e,t,n){return Fo.makeScale(e,t,n),this.applyMatrix4(Fo),this}lookAt(e){return Io.lookAt(e),Io.updateMatrix(),this.applyMatrix4(Io.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lo).negate(),this.translate(Lo.x,Lo.y,Lo.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new ko(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&K(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new so);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){li(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new J(-1/0,-1/0,-1/0),new J(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ro.setFromBufferAttribute(n),this.morphTargetsRelative?(Bo.addVectors(this.boundingBox.min,Ro.min),this.boundingBox.expandByPoint(Bo),Bo.addVectors(this.boundingBox.max,Ro.max),this.boundingBox.expandByPoint(Bo)):(this.boundingBox.expandByPoint(Ro.min),this.boundingBox.expandByPoint(Ro.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&li(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new No);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){li(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new J,1/0);return}if(e){let n=this.boundingSphere.center;if(Ro.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];zo.setFromBufferAttribute(n),this.morphTargetsRelative?(Bo.addVectors(Ro.min,zo.min),Ro.expandByPoint(Bo),Bo.addVectors(Ro.max,zo.max),Ro.expandByPoint(Bo)):(Ro.expandByPoint(zo.min),Ro.expandByPoint(zo.max))}Ro.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Bo.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Bo));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Bo.fromBufferAttribute(a,t),o&&(Lo.fromBufferAttribute(e,t),Bo.add(Lo)),r=Math.max(r,n.distanceToSquared(Bo))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&li(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){li(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new Eo(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new J,s[e]=new J;let c=new J,l=new J,u=new J,d=new q,f=new q,p=new q,m=new J,h=new J;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new J,y=new J,b=new J,x=new J;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new Eo(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new J,i=new J,a=new J,o=new J,s=new J,c=new J,l=new J,u=new J;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Bo.fromBufferAttribute(e,t),Bo.normalize(),e.setXYZ(t,Bo.x,Bo.y,Bo.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Eo(a,r,i)}if(this.index===null)return K(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},Ho=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=$r,this.updateRanges=[],this.version=0,this.uuid=vi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Uo=new J,Wo=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Uo.fromBufferAttribute(this,t),Uo.applyMatrix4(e),this.setXYZ(t,Uo.x,Uo.y,Uo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Uo.fromBufferAttribute(this,t),Uo.applyNormalMatrix(e),this.setXYZ(t,Uo.x,Uo.y,Uo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Uo.fromBufferAttribute(this,t),Uo.transformDirection(e),this.setXYZ(t,Uo.x,Uo.y,Uo.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=zi(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=zi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ri(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ri(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ri(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ri(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=zi(t,this.array),n=zi(n,this.array),r=zi(r,this.array),i=zi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){si(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Eo(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){si(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Go=0,Ko=class extends pi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:Go++}),this.uuid=vi(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new X(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qr,this.stencilZFail=Qr,this.stencilZPass=Qr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){K(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){K(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},qo=class extends Ko{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Jo,Yo=new J,Xo=new J,Zo=new J,Qo=new q,$o=new q,es=new Y,ts=new J,ns=new J,rs=new J,is=new q,as=new q,os=new q,ss=class extends La{constructor(e=new qo){if(super(),this.isSprite=!0,this.type=`Sprite`,Jo===void 0){Jo=new Vo;let e=new Ho(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Jo.setIndex([0,1,2,0,2,3]),Jo.setAttribute(`position`,new Wo(e,3,0,!1)),Jo.setAttribute(`uv`,new Wo(e,2,3,!1))}this.geometry=Jo,this.material=e,this.center=new q(.5,.5),this.count=1}raycast(e,t){e.camera===null&&li(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Xo.setFromMatrixScale(this.matrixWorld),es.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Zo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Xo.multiplyScalar(-Zo.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;cs(ts.set(-.5,-.5,0),Zo,a,Xo,r,i),cs(ns.set(.5,-.5,0),Zo,a,Xo,r,i),cs(rs.set(.5,.5,0),Zo,a,Xo,r,i),is.set(0,0),as.set(1,0),os.set(1,1);let o=e.ray.intersectTriangle(ts,ns,rs,!1,Yo);if(o===null&&(cs(ns.set(-.5,.5,0),Zo,a,Xo,r,i),as.set(0,1),o=e.ray.intersectTriangle(ts,rs,ns,!1,Yo),o===null))return;let s=e.ray.origin.distanceTo(Yo);s<e.near||s>e.far||t.push({distance:s,point:Yo.clone(),uv:oo.getInterpolation(Yo,ts,ns,rs,is,as,os,new q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function cs(e,t,n,r,i,a){Qo.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?$o.copy(Qo):($o.x=a*Qo.x-i*Qo.y,$o.y=i*Qo.x+a*Qo.y),e.copy(t),e.x+=$o.x,e.y+=$o.y,e.applyMatrix4(es)}var ls=new J,us=new J,ds=new J,fs=new J,ps=new J,ms=new J,hs=new J,gs=class{constructor(e=new J,t=new J(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ls)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ls.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ls.copy(this.origin).addScaledVector(this.direction,t),ls.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){us.copy(e).add(t).multiplyScalar(.5),ds.copy(t).sub(e).normalize(),fs.copy(this.origin).sub(us);let i=e.distanceTo(t)*.5,a=-this.direction.dot(ds),o=fs.dot(this.direction),s=-fs.dot(ds),c=fs.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(us).addScaledVector(ds,d),f}intersectSphere(e,t){ls.subVectors(e.center,this.origin);let n=ls.dot(this.direction),r=ls.dot(ls)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ls)!==null}intersectTriangle(e,t,n,r,i){ps.subVectors(t,e),ms.subVectors(n,e),hs.crossVectors(ps,ms);let a=this.direction.dot(hs),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fs.subVectors(this.origin,e);let s=o*this.direction.dot(ms.crossVectors(fs,ms));if(s<0)return null;let c=o*this.direction.dot(ps.cross(fs));if(c<0||s+c>a)return null;let l=-o*fs.dot(hs);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},_s=class extends Ko{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ba,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},vs=new Y,ys=new gs,bs=new No,xs=new J,Ss=new J,Cs=new J,ws=new J,Ts=new J,Es=new J,Ds=new J,Os=new J,ks=class extends La{constructor(e=new Vo,t=new _s){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Es.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Ts.fromBufferAttribute(s,e),a?Es.addScaledVector(Ts,r):Es.addScaledVector(Ts.sub(t),r))}t.add(Es)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),bs.copy(n.boundingSphere),bs.applyMatrix4(i),ys.copy(e.ray).recast(e.near),!(bs.containsPoint(ys.origin)===!1&&(ys.intersectSphere(bs,xs)===null||ys.origin.distanceToSquared(xs)>(e.far-e.near)**2))&&(vs.copy(i).invert(),ys.copy(e.ray).applyMatrix4(vs),!(n.boundingBox!==null&&ys.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ys)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=js(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=js(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=js(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=js(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function As(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Os.copy(s),Os.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Os);return l<n.near||l>n.far?null:{distance:l,point:Os.clone(),object:e}}function js(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Ss),e.getVertexPosition(c,Cs),e.getVertexPosition(l,ws);let u=As(e,t,n,r,Ss,Cs,ws,Ds);if(u){let e=new J;oo.getBarycoord(Ds,Ss,Cs,ws,e),i&&(u.uv=oo.getInterpolatedAttribute(i,s,c,l,e,new q)),a&&(u.uv1=oo.getInterpolatedAttribute(a,s,c,l,e,new q)),o&&(u.normal=oo.getInterpolatedAttribute(o,s,c,l,e,new J),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new J,materialIndex:0};oo.getNormal(Ss,Cs,ws,t.normal),u.face=t,u.barycoord=e}return u}var Ms=new J,Ns=new oa,Ps=new oa,Fs=new J,Is=new Y,Ls=new J,Rs=new No,zs=new Y,Bs=new gs,Vs=class extends ks{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=wn,this.bindMatrix=new Y,this.bindMatrixInverse=new Y,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new so),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ls),this.boundingBox.expandByPoint(Ls)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new No),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,Ls),this.boundingSphere.expandByPoint(Ls)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Rs.copy(this.boundingSphere),Rs.applyMatrix4(r),e.ray.intersectsSphere(Rs)!==!1&&(zs.copy(r).invert(),Bs.copy(e.ray).applyMatrix4(zs),!(this.boundingBox!==null&&Bs.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Bs)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new oa,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():K(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Ns.fromBufferAttribute(r.attributes.skinIndex,e),Ps.fromBufferAttribute(r.attributes.skinWeight,e),Ms.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let r=Ps.getComponent(e);if(r!==0){let i=Ns.getComponent(e);Is.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Fs.copy(Ms).applyMatrix4(Is),r)}}return t.applyMatrix4(this.bindMatrixInverse)}},Hs=class extends La{constructor(){super(),this.isBone=!0,this.type=`Bone`}},Us=class extends aa{constructor(e=null,t=1,n=1,r,i,a,o,s,c=On,l=On,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Ws=new Y,Gs=new Y,Ks=class e{constructor(e=[],t=[]){this.uuid=vi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){K(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Y)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new Y;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:Gs;Ws.multiplyMatrices(i,t[r]),Ws.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Us(t,e,e,Yn,Bn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(K(`Skeleton: No bone found with UUID:`,r),i=new Hs),this.bones.push(i),this.boneInverses.push(new Y().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},qs=class extends Eo{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Js=new Y,Ys=new Y,Xs=[],Zs=new so,Qs=new Y,$s=new ks,ec=new No,tc=class extends ks{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qs(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,Qs)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new so),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Js),Zs.copy(e.boundingBox).applyMatrix4(Js),this.boundingBox.union(Zs)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new No),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Js),ec.copy(e.boundingSphere).applyMatrix4(Js),this.boundingSphere.union(ec)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if($s.geometry=this.geometry,$s.material=this.material,$s.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ec.copy(this.boundingSphere),ec.applyMatrix4(n),e.ray.intersectsSphere(ec)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,Js),Ys.multiplyMatrices(n,Js),$s.matrixWorld=Ys,$s.raycast(e,Xs);for(let e=0,n=Xs.length;e<n;e++){let n=Xs[e];n.instanceId=i,n.object=this,t.push(n)}Xs.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new qs(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Us(new Float32Array(r*this.count),r,this.count,Qn,Bn));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;i[s]=o,i.set(n,s+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:`dispose`}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},nc=new J,rc=new J,ic=new Wi,ac=class{constructor(e=new J(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=nc.subVectors(n,t).cross(rc.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(nc),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||ic.getNormalMatrix(e),r=this.coplanarPoint(nc).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},oc=new No,sc=new q(.5,.5),cc=new J,lc=class{constructor(e=new ac,t=new ac,n=new ac,r=new ac,i=new ac,a=new ac){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ei,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),oc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),oc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(oc)}intersectsSprite(e){return oc.center.set(0,0,0),oc.radius=.7071067811865476+sc.distanceTo(e.center),oc.applyMatrix4(e.matrixWorld),this.intersectsSphere(oc)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(cc.x=r.normal.x>0?e.max.x:e.min.x,cc.y=r.normal.y>0?e.max.y:e.min.y,cc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(cc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},uc=class extends Ko{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new X(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},dc=new J,fc=new J,pc=new Y,mc=new gs,hc=new No,gc=new J,_c=new J,vc=class extends La{constructor(e=new Vo,t=new uc){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)dc.fromBufferAttribute(t,e-1),fc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=dc.distanceTo(fc);e.setAttribute(`lineDistance`,new ko(n,1))}else K(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hc.copy(n.boundingSphere),hc.applyMatrix4(r),hc.radius+=i,e.ray.intersectsSphere(hc)===!1)return;pc.copy(r).invert(),mc.copy(e.ray).applyMatrix4(pc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=yc(this,e,mc,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=yc(this,e,mc,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=yc(this,e,mc,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=yc(this,e,mc,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function yc(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(dc.fromBufferAttribute(s,i),fc.fromBufferAttribute(s,a),n.distanceSqToSegment(dc,fc,gc,_c)>r)return;gc.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(gc);if(!(c<t.near||c>t.far))return{distance:c,point:_c.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var bc=new J,xc=new J,Sc=class extends vc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)bc.fromBufferAttribute(t,e),xc.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+bc.distanceTo(xc);e.setAttribute(`lineDistance`,new ko(n,1))}else K(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},Cc=class extends vc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},wc=class extends Ko{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new X(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Tc=new Y,Ec=new gs,Dc=new No,Oc=new J,kc=class extends La{constructor(e=new Vo,t=new wc){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Dc.copy(n.boundingSphere),Dc.applyMatrix4(r),Dc.radius+=i,e.ray.intersectsSphere(Dc)===!1)return;Tc.copy(r).invert(),Ec.copy(e.ray).applyMatrix4(Tc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Oc.fromBufferAttribute(l,n),Ac(Oc,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Oc.fromBufferAttribute(l,a),Ac(Oc,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Ac(e,t,n,r,i,a,o){let s=Ec.distanceSqToPoint(e);if(s<n){let n=new J;Ec.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var jc=class extends aa{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Mc=class extends aa{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Nc=class extends aa{constructor(e,t,n=zn,r,i,a,o=On,s=On,c,l=Xn,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ta(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Pc=class extends Nc{constructor(e,t=zn,n=301,r,i,a=On,o=On,s,c=Xn){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Fc=class extends aa{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Ic=class e extends Vo{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new ko(c,3)),this.setAttribute(`normal`,new ko(l,3)),this.setAttribute(`uv`,new ko(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new J;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Lc=class e extends Vo{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new ko(u,3)),this.setAttribute(`normal`,new ko(d,3)),this.setAttribute(`uv`,new ko(f,2));function _(){let a=new J,_=new J,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new q,m=new J,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Rc=class e extends Lc{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},zc=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){K(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new q:new J);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new J,r=[],i=[],a=[],o=new J,s=new Y;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new J)}i[0]=new J,a[0]=new J;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(yi(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(yi(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Bc=class extends zc{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new q){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Vc=class extends Bc{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Hc(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Uc=new J,Wc=new Hc,Gc=new Hc,Kc=new Hc,qc=class extends zc{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new J){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Uc.subVectors(r[0],r[1]).add(r[0]),c=Uc);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(Uc.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=Uc),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),Wc.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),Gc.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),Kc.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(Wc.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),Gc.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),Kc.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(Wc.calc(s),Gc.calc(s),Kc.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new J().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Jc(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function Yc(e,t){let n=1-e;return n*n*t}function Xc(e,t){return 2*(1-e)*e*t}function Zc(e,t){return e*e*t}function Qc(e,t,n,r){return Yc(e,t)+Xc(e,n)+Zc(e,r)}function $c(e,t){let n=1-e;return n*n*n*t}function el(e,t){let n=1-e;return 3*n*n*e*t}function tl(e,t){return 3*(1-e)*e*e*t}function nl(e,t){return e*e*e*t}function rl(e,t,n,r,i){return $c(e,t)+el(e,n)+tl(e,r)+nl(e,i)}var il=class extends zc{constructor(e=new q,t=new q,n=new q,r=new q){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(rl(e,r.x,i.x,a.x,o.x),rl(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},al=class extends zc{constructor(e=new J,t=new J,n=new J,r=new J){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(rl(e,r.x,i.x,a.x,o.x),rl(e,r.y,i.y,a.y,o.y),rl(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ol=class extends zc{constructor(e=new q,t=new q){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new q){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},sl=class extends zc{constructor(e=new J,t=new J){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new J){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},cl=class extends zc{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Qc(e,r.x,i.x,a.x),Qc(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ll=class extends zc{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Qc(e,r.x,i.x,a.x),Qc(e,r.y,i.y,a.y),Qc(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ul=class extends zc{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new q){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Jc(o,s.x,c.x,l.x,u.x),Jc(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new q().fromArray(n))}return this}},dl=Object.freeze({__proto__:null,ArcCurve:Vc,CatmullRomCurve3:qc,CubicBezierCurve:il,CubicBezierCurve3:al,EllipseCurve:Bc,LineCurve:ol,LineCurve3:sl,QuadraticBezierCurve:cl,QuadraticBezierCurve3:ll,SplineCurve:ul}),fl=class extends zc{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new dl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new dl[n.type]().fromJSON(n))}return this}},pl=class extends fl{constructor(e){super(),this.type=`Path`,this.currentPoint=new q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new ol(this.currentPoint.clone(),new q(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new cl(this.currentPoint.clone(),new q(e,t),new q(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new il(this.currentPoint.clone(),new q(e,t),new q(n,r),new q(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=new ul([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new Bc(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ml=class extends pl{constructor(e){super(e),this.uuid=vi(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new pl().fromJSON(n))}return this}};function hl(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=gl(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=Cl(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return vl(a,o,n,s,c,l,0),o}function gl(e,t,n,r,i){let a;if(i===ql(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Wl(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Wl(i/r|0,e[i],e[i+1],a);return a&&Il(a,a.next)&&(Gl(a),a=a.next),a}function _l(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(Il(n,n.next)||Fl(n.prev,n,n.next)===0)){if(Gl(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function vl(e,t,n,r,i,a,o){if(!e)return;!o&&a&&Ol(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?bl(e,r,i,a):yl(e)){t.push(c.i,e.i,l.i),Gl(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=xl(_l(e),t),vl(e,t,n,r,i,a,2)):o===2&&Sl(e,t,n,r,i,a):vl(_l(e),t,n,r,i,a,1);break}}}function yl(e){let t=e.prev,n=e,r=e.next;if(Fl(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Nl(i,s,a,c,o,l,m.x,m.y)&&Fl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function bl(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Fl(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Al(p,m,t,n,r),v=Al(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Nl(s,u,c,d,l,f,y.x,y.y)&&Fl(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Nl(s,u,c,d,l,f,b.x,b.y)&&Fl(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Nl(s,u,c,d,l,f,y.x,y.y)&&Fl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Nl(s,u,c,d,l,f,b.x,b.y)&&Fl(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function xl(e,t){let n=e;do{let r=n.prev,i=n.next.next;!Il(r,i)&&Ll(r,n,n.next,i)&&Vl(r,i)&&Vl(i,r)&&(t.push(r.i,n.i,i.i),Gl(n),Gl(n.next),n=e=i),n=n.next}while(n!==e);return _l(n)}function Sl(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Pl(o,e)){let s=Ul(o,e);o=_l(o,o.next),s=_l(s,s.next),vl(o,t,n,r,i,a,0),vl(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Cl(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=gl(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(jl(o))}i.sort(wl);for(let e=0;e<i.length;e++)n=Tl(i[e],n);return n}function wl(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function Tl(e,t){let n=El(e,t);if(!n)return t;let r=Ul(n,e);return _l(r,r.next),_l(n,n.next)}function El(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Il(e,n))return n;do{if(Il(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&Ml(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);Vl(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&Dl(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Dl(e,t){return Fl(e.prev,e,t.prev)<0&&Fl(t.next,e,e.next)<0}function Ol(e,t,n,r){let i=e;do i.z===0&&(i.z=Al(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,kl(i)}function kl(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function Al(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function jl(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Ml(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Nl(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Ml(e,t,n,r,i,a,o,s)}function Pl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Bl(e,t)&&(Vl(e,t)&&Vl(t,e)&&Hl(e,t)&&(Fl(e.prev,e,t.prev)||Fl(e,t.prev,t))||Il(e,t)&&Fl(e.prev,e,e.next)>0&&Fl(t.prev,t,t.next)>0)}function Fl(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Il(e,t){return e.x===t.x&&e.y===t.y}function Ll(e,t,n,r){let i=zl(Fl(e,t,n)),a=zl(Fl(e,t,r)),o=zl(Fl(n,r,e)),s=zl(Fl(n,r,t));return!!(i!==a&&o!==s||i===0&&Rl(e,n,t)||a===0&&Rl(e,r,t)||o===0&&Rl(n,e,r)||s===0&&Rl(n,t,r))}function Rl(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function zl(e){return e>0?1:e<0?-1:0}function Bl(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ll(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Vl(e,t){return Fl(e.prev,e,e.next)<0?Fl(e,t,e.next)>=0&&Fl(e,e.prev,t)>=0:Fl(e,t,e.prev)<0||Fl(e,e.next,t)<0}function Hl(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Ul(e,t){let n=Kl(e.i,e.x,e.y),r=Kl(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Wl(e,t,n,r){let i=Kl(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Gl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Kl(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ql(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Jl=class{static triangulate(e,t,n=2){return hl(e,t,n)}},Yl=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];Xl(e),Zl(n,e);let a=e.length;t.forEach(Xl);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Zl(n,t[e]);let o=Jl.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}};function Xl(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Zl(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var Ql=class e extends Vo{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new ko(p,3)),this.setAttribute(`normal`,new ko(m,3)),this.setAttribute(`uv`,new ko(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},$l=class e extends Vo{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new J,p=new q;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new ko(s,3)),this.setAttribute(`normal`,new ko(c,3)),this.setAttribute(`uv`,new ko(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},eu=class e extends Vo{constructor(e=new ml([new q(0,.5),new q(-.5,-.5),new q(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new ko(r,3)),this.setAttribute(`normal`,new ko(i,3)),this.setAttribute(`uv`,new ko(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;Yl.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];Yl.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=Yl.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return tu(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}};function tu(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}var nu=class e extends Vo{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new J,d=new J,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new ko(p,3)),this.setAttribute(`normal`,new ko(m,3)),this.setAttribute(`uv`,new ko(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},ru=class extends Ko{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new X(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}};function iu(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(K(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function au(e){let t={};for(let n=0;n<e.length;n++){let r=iu(e[n]);for(let e in r)t[e]=r[e]}return t}function ou(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function su(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Yi.workingColorSpace}var cu={clone:iu,merge:au},lu=`void main() {
3
3
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
4
4
  }`,uu=`void main() {
5
5
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -4047,9 +4047,9 @@ void main() {
4047
4047
 
4048
4048
  }
4049
4049
 
4050
- }`,th=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Fc(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 du({vertexShader:$m,fragmentShader:eh,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ks(new Ql(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},nh=class extends pi{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 th,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new q,C=null,w=new od;w.viewport=new oa;let T=new od;T.viewport=new oa;let E=[w,T],D=new xd,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 Ba,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Ba,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Ba,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}O=null,k=null,h.reset();for(let e in g)delete g[e];e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,ae.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&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?Zn:Xn,a=_.stencil?Wn:zn);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 ca(d.textureWidth,d.textureHeight,{format:Yn,type:Pn,depthTexture:new Nc(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 ca(f.framebufferWidth,f.framebufferHeight,{format:Yn,type:Pn,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ae.setContext(r),ae.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function M(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let ee=new J,N=new J;function te(e,t,n){ee.setFromMatrixPosition(t.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);let r=ee.distanceTo(N),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ne(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;ne(D,i);for(let e=0;e<a.length;e++)ne(a[e],i);a.length===2?te(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),re(e,D,i)};function re(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=_i*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(D)},this.getCameraTexture=function(e){return g[e]};let P=null;function ie(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==D.cameras.length&&(D.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=E[n];o===void 0&&(o=new od,o.layers.enable(n),o.viewport=new oa,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 Fc,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}P&&P(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ae=new Jd;ae.setAnimationLoop(ie),this.setAnimationLoop=function(e){P=e},this.dispose=function(){}}},rh=new ba,ih=new Y;function ah(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,rh.copy(o),rh.x*=-1,rh.y*=-1,rh.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(rh.y*=-1,rh.z*=-1),e.envMapRotation.value.setFromMatrix4(ih.makeRotationFromEuler(rh)),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 oh(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 li(`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 lh(){return ch===null&&(ch=new Us(sh,16,16,er,Vn),ch.name=`DFG_LUT`,ch.minFilter=jn,ch.magFilter=jn,ch.wrapS=En,ch.wrapT=En,ch.generateMipmaps=!1,ch.needsUpdate=!0),ch}var uh=class{constructor(e={}){let{canvas:t=ii(),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=Pn}=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([nr,tr,$n]),g=new Set([Pn,zn,Ln,Wn,Hn,Un]),_=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=Jr;let E=0,D=0,O=null,k=-1,A=null,j=new oa,M=new oa,ee=null,N=new X(0),te=0,ne=t.width,re=t.height,P=1,ie=null,ae=null,F=new oa(0,0,ne,re),I=new oa(0,0,ne,re),oe=!1,se=new lc,ce=!1,le=!1,ue=new Y,de=new J,fe=new oa,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},me=!1;function he(){return O===null?P:1}let L=n;function R(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`,Fe,!1),t.addEventListener(`webglcontextrestored`,Ie,!1),t.addEventListener(`webglcontextcreationerror`,Le,!1),L===null){let t=`webgl2`;if(L=R(t,e),L===null)throw R(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw li(`WebGLRenderer: `+e.message),e}let z,ge,B,_e,V,H,U,ve,ye,be,xe,Se,Ce,W,we,Te,Ee,De,Oe,ke,Ae,je,Me;function Ne(){z=new kf(L),z.init(),Ae=new Qm(L,z),ge=new af(L,z,e,Ae),B=new Xm(L,z),ge.reversedDepthBuffer&&d&&B.buffers.depth.setReversed(!0),_e=new Mf(L),V=new Am,H=new Zm(L,z,B,V,ge,Ae,_e),U=new Of(w),ve=new Yd(L),je=new nf(L,ve),ye=new Af(L,ve,_e,je),be=new Pf(L,ye,ve,je,_e),De=new Nf(L,ge,H),we=new of(V),xe=new km(w,U,z,ge,je,we),Se=new ah(w,V),Ce=new Pm,W=new Vm(z),Ee=new tf(w,U,B,be,p,s),Te=new Ym(w,be,ge),Me=new oh(L,_e,ge,B),Oe=new rf(L,z,_e),ke=new jf(L,z,_e),_e.programs=xe.programs,w.capabilities=ge,w.extensions=z,w.properties=V,w.renderLists=Ce,w.shadowMap=Te,w.state=B,w.info=_e}Ne(),m!==1009&&(C=new If(m,t.width,t.height,r,i));let Pe=new nh(w,L);this.xr=Pe,this.getContext=function(){return L},this.getContextAttributes=function(){return L.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 P},this.setPixelRatio=function(e){e!==void 0&&(P=e,this.setSize(ne,re,!1))},this.getSize=function(e){return e.set(ne,re)},this.setSize=function(e,n,r=!0){if(Pe.isPresenting){K(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ne=e,re=n,t.width=Math.floor(e*P),t.height=Math.floor(n*P),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),C!==null&&C.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ne*P,re*P).floor()},this.setDrawingBufferSize=function(e,n,r){ne=e,re=n,P=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){console.error(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){console.warn(`THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}C.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(j)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,r){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,r),B.viewport(j.copy(F).multiplyScalar(P).round())},this.getScissor=function(e){return e.copy(I)},this.setScissor=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),B.scissor(M.copy(I).multiplyScalar(P).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){B.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Ee.getClearColor())},this.setClearColor=function(){Ee.setClearColor(...arguments)},this.getClearAlpha=function(){return Ee.getClearAlpha()},this.setClearAlpha=function(){Ee.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=Ee.getClearColor(),r=Ee.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,L.clearBufferuiv(L.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,L.clearBufferiv(L.COLOR,0,v))}else r|=L.COLOR_BUFFER_BIT}t&&(r|=L.DEPTH_BUFFER_BIT),n&&(r|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&L.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Fe,!1),t.removeEventListener(`webglcontextrestored`,Ie,!1),t.removeEventListener(`webglcontextcreationerror`,Le,!1),Ee.dispose(),Ce.dispose(),W.dispose(),V.dispose(),U.dispose(),be.dispose(),je.dispose(),Me.dispose(),xe.dispose(),Pe.dispose(),Pe.removeEventListener(`sessionstart`,We),Pe.removeEventListener(`sessionend`,Ge),Ke.stop()};function Fe(e){e.preventDefault(),si(`WebGLRenderer: Context Lost.`),T=!0}function Ie(){si(`WebGLRenderer: Context Restored.`),T=!1;let e=_e.autoReset,t=Te.enabled,n=Te.autoUpdate,r=Te.needsUpdate,i=Te.type;Ne(),_e.autoReset=e,Te.enabled=t,Te.autoUpdate=n,Te.needsUpdate=r,Te.type=i}function Le(e){li(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Re(e){let t=e.target;t.removeEventListener(`dispose`,Re),ze(t)}function ze(e){Be(e),V.remove(e)}function Be(e){let t=V.get(e).programs;t!==void 0&&(t.forEach(function(e){xe.releaseProgram(e)}),e.isShaderMaterial&&xe.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=pe);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=tt(e,t,n,r,i);B.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=ye.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;je.setup(i,r,s,n,c);let h,g=Oe;if(c!==null&&(h=ve.get(c),g=ke,g.setIndex(h)),i.isMesh)r.wireframe===!0?(B.setLineWidth(r.wireframeLinewidth*he()),g.setMode(L.LINES)):g.setMode(L.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),B.setLineWidth(e*he()),i.isLineSegments?g.setMode(L.LINES):i.isLineLoop?g.setMode(L.LINE_LOOP):g.setMode(L.LINE_STRIP)}else i.isPoints?g.setMode(L.POINTS):i.isSprite&&g.setMode(L.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)ui(`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?ve.get(c).bytesPerElement:1,o=V.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(L,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Ve(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,Qe(e,t,n),e.side=0,e.needsUpdate=!0,Qe(e,t,n),e.side=2):Qe(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),b=W.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];Ve(a,n,e),r.add(a)}else Ve(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 He=null;function Ue(e){He&&He(e)}function We(){Ke.stop()}function Ge(){Ke.start()}let Ke=new Jd;Ke.setAnimationLoop(Ue),typeof self<`u`&&Ke.setContext(self),this.setAnimationLoop=function(e){He=e,Pe.setAnimationLoop(e),e===null?Ke.stop():Ke.start()},Pe.addEventListener(`sessionstart`,We),Pe.addEventListener(`sessionend`,Ge),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){li(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(T===!0)return;let n=Pe.enabled===!0&&Pe.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(),Pe.enabled===!0&&Pe.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Pe.cameraAutoUpdate===!0&&Pe.updateCamera(t),t=Pe.getCamera()),e.isScene===!0&&e.onBeforeRender(w,e,t,O),b=W.get(e,S.length),b.init(t),S.push(b),ue.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromProjectionMatrix(ue,ei,t.reversedDepth),le=this.localClippingEnabled,ce=we.init(this.clippingPlanes,le),y=Ce.get(e,x.length),y.init(),x.push(y),Pe.enabled===!0&&Pe.isPresenting===!0){let e=w.xr.getDepthSensingMesh();e!==null&&qe(e,t,-1/0,w.sortObjects)}qe(e,t,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(ie,ae),me=Pe.enabled===!1||Pe.isPresenting===!1||Pe.hasDepthSensing()===!1,me&&Ee.addToRenderList(y,e),this.info.render.frame++,ce===!0&&we.beginShadows();let i=b.state.shadowsArray;if(Te.render(i,e,t),ce===!0&&we.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];Ye(n,r,e,a)}me&&Ee.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];Je(y,e,n,n.viewport)}}else r.length>0&&Ye(n,r,e,t),me&&Ee.render(e),Je(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),je.resetDefaultState(),k=-1,A=null,S.pop(),S.length>0?(b=S[S.length-1],ce===!0&&we.setGlobalState(w.clippingPlanes,b.state.camera)):b=null,x.pop(),y=x.length>0?x[x.length-1]:null};function qe(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)b.pushLight(e),e.castShadow&&b.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||se.intersectsSprite(e)){r&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ue);let t=be.update(e),i=e.material;i.visible&&y.push(e,t,i,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||se.intersectsObject(e))){let t=be.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),fe.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),fe.copy(e.boundingSphere.center)),fe.applyMatrix4(e.matrixWorld).applyMatrix4(ue)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&y.push(e,t,s,n,fe.z,o)}}else i.visible&&y.push(e,t,i,n,fe.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)qe(i[e],t,n,r)}function Je(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;b.setupLightsView(n),ce===!0&&we.setGlobalState(w.clippingPlanes,n),r&&B.viewport(j.copy(r)),i.length>0&&Xe(i,t,n),a.length>0&&Xe(a,t,n),o.length>0&&Xe(o,t,n),B.buffers.depth.setTest(!0),B.buffers.depth.setMask(!0),B.buffers.color.setMask(!0),B.setPolygonOffset(!1)}function Ye(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 ca(1,1,{generateMipmaps:!0,type:e?Vn:Pn,minFilter:Nn,samples:Math.max(4,ge.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Yi.workingColorSpace})}let a=b.state.transmissionRenderTarget[r.id],o=r.viewport||j;a.setSize(o.z*w.transmissionResolutionScale,o.w*w.transmissionResolutionScale);let s=w.getRenderTarget(),c=w.getActiveCubeFace(),l=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(N),te=w.getClearAlpha(),te<1&&w.setClearColor(16777215,.5),w.clear(),me&&Ee.render(n);let u=w.toneMapping;w.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),b.setupLightsView(r),ce===!0&&we.setGlobalState(w.clippingPlanes,r),Xe(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,Ze(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(N,te),d!==void 0&&(r.viewport=d),w.toneMapping=u}function Xe(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)&&Ze(o,t,n,s,l,c)}}function Ze(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 Qe(e,t,n){t.isScene!==!0&&(t=pe);let r=V.get(e),i=b.state.lights,a=b.state.shadowsArray,o=i.state.version,s=xe.getParameters(e,i.state,a,t,n),c=xe.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=U.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Re),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return et(e,s),d}else s.uniforms=xe.getUniforms(e),e.onBeforeCompile(s,w),d=xe.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=we.uniform),et(e,s),r.needsLights=rt(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 $e(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Up.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function et(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 tt(e,t,n,r,i){t.isScene!==!0&&(t=pe),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:Yr,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=U.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(ce===!0&&(le===!0||e!==A)){let t=e===A&&r.id===k;we.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!==we.numPlanes||v.numIntersection!==we.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=Qe(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(L,`projectionMatrix`,e.projectionMatrix),D.setValue(L,`viewMatrix`,e.matrixWorldInverse);let t=D.map.cameraPosition;t!==void 0&&t.setValue(L,de.setFromMatrixPosition(e.matrixWorld)),ge.logarithmicDepthBuffer&&D.setValue(L,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&D.setValue(L,`isOrthographic`,e.isOrthographicCamera===!0),A!==e&&(A=e,T=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&D.setValue(L,`directionalShadowMap`,y.state.directionalShadowMap,H),y.state.spotShadowMap.length>0&&D.setValue(L,`spotShadowMap`,y.state.spotShadowMap,H),y.state.pointShadowMap.length>0&&D.setValue(L,`pointShadowMap`,y.state.pointShadowMap,H)),i.isSkinnedMesh){D.setOptional(L,i,`bindMatrix`),D.setOptional(L,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),D.setValue(L,`boneTexture`,e.boneTexture,H))}i.isBatchedMesh&&(D.setOptional(L,i,`batchingTexture`),D.setValue(L,`batchingTexture`,i._matricesTexture,H),D.setOptional(L,i,`batchingIdTexture`),D.setValue(L,`batchingIdTexture`,i._indirectTexture,H),D.setOptional(L,i,`batchingColorTexture`),i._colorsTexture!==null&&D.setValue(L,`batchingColorTexture`,i._colorsTexture,H));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&De.update(i,n,S),(T||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,D.setValue(L,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=lh()),T&&(D.setValue(L,`toneMappingExposure`,w.toneMappingExposure),v.needsLights&&nt(j,E),a&&r.fog===!0&&Se.refreshFogUniforms(j,a),Se.refreshMaterialUniforms(j,r,P,re,b.state.transmissionRenderTarget[e.id]),Up.upload(L,$e(v),j,H)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Up.upload(L,$e(v),j,H),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&D.setValue(L,`center`,i.center),D.setValue(L,`modelViewMatrix`,i.modelViewMatrix),D.setValue(L,`normalMatrix`,i.normalMatrix),D.setValue(L,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Me.update(n,S),Me.bind(n,S)}}return S}function nt(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 rt(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 it=L.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){O=e,E=t,D=n;let r=null,i=!1,a=!1;if(e){let o=V.get(e);if(o.__useDefaultFramebuffer!==void 0){B.bindFramebuffer(L.FRAMEBUFFER,o.__webglFramebuffer),j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest,B.viewport(j),B.scissor(M),B.setScissorTest(ee),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),ee=e.scissorTest}else j.copy(F).multiplyScalar(P).floor(),M.copy(I).multiplyScalar(P).floor(),ee=oe;if(n!==0&&(r=it),B.bindFramebuffer(L.FRAMEBUFFER,r)&&B.drawBuffers(e,r),B.viewport(j),B.scissor(M),B.setScissorTest(ee),i){let r=V.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=V.get(e.textures[t]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=V.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,t.__webglTexture,n)}k=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){li(`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(L.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!ge.textureFormatReadable(c)){li(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!ge.textureTypeReadable(l)){li(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&L.readPixels(t,n,r,i,Ae.convert(c),Ae.convert(l),a)}finally{let e=O===null?null:V.get(O).__webglFramebuffer;B.bindFramebuffer(L.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=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(L.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!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=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.bufferData(L.PIXEL_PACK_BUFFER,a.byteLength,L.STREAM_READ),L.readPixels(t,n,r,i,Ae.convert(l),Ae.convert(u),0);let f=O===null?null:V.get(O).__webglFramebuffer;B.bindFramebuffer(L.FRAMEBUFFER,f);let p=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await di(L,p,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,a),L.deleteBuffer(d),L.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;H.setTexture2D(e,0),L.copyTexSubImage2D(L.TEXTURE_2D,n,0,0,o,s,i,a),B.unbindTexture()};let at=L.createFramebuffer(),ot=L.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Ae.convert(t.format),_=Ae.convert(t.type),v;t.isData3DTexture?(H.setTexture3D(t,0),v=L.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(H.setTexture2DArray(t,0),v=L.TEXTURE_2D_ARRAY):(H.setTexture2D(t,0),v=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,t.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,t.unpackAlignment);let y=L.getParameter(L.UNPACK_ROW_LENGTH),b=L.getParameter(L.UNPACK_IMAGE_HEIGHT),x=L.getParameter(L.UNPACK_SKIP_PIXELS),S=L.getParameter(L.UNPACK_SKIP_ROWS),C=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,h.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,h.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,l),L.pixelStorei(L.UNPACK_SKIP_ROWS,u),L.pixelStorei(L.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=V.get(e),r=V.get(t),h=V.get(n.__renderTarget),g=V.get(r.__renderTarget);B.bindFramebuffer(L.READ_FRAMEBUFFER,h.__webglFramebuffer),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,V.get(e).__webglTexture,i,d+n),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,V.get(t).__webglTexture,a,m+n)),L.blitFramebuffer(l,u,o,s,f,p,o,s,L.DEPTH_BUFFER_BIT,L.NEAREST);B.bindFramebuffer(L.READ_FRAMEBUFFER,null),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||V.has(e)){let n=V.get(e),r=V.get(t);B.bindFramebuffer(L.READ_FRAMEBUFFER,at),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,ot);for(let e=0;e<c;e++)w?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,n.__webglTexture,i),T?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,r.__webglTexture,a),i===0?T?L.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):L.copyTexSubImage2D(v,a,f,p,l,u,o,s):L.blitFramebuffer(l,u,o,s,f,p,o,s,L.COLOR_BUFFER_BIT,L.NEAREST);B.bindFramebuffer(L.READ_FRAMEBUFFER,null),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?L.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h);L.pixelStorei(L.UNPACK_ROW_LENGTH,y),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,b),L.pixelStorei(L.UNPACK_SKIP_PIXELS,x),L.pixelStorei(L.UNPACK_SKIP_ROWS,S),L.pixelStorei(L.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&L.generateMipmap(v),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(),je.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return ei}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Yi._getDrawingBufferColorSpace(e),t.unpackColorSpace=Yi._getUnpackColorSpace()}},dh=-(2**40),fh=8;function ph(e,t){return e<0||e>=fh?dh:t*fh+e}function mh(e){return(e%fh+fh)%fh}function hh(e){return(e-mh(e))/fh}function gh(e){return e===dh?null:sn(mh(e),hh(e))}function _h(e){let t=e.indexOf(`-`);if(t<=0)return null;let n=on(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=ph(n,r);return i===dh?null:i}function vh(e){let t=new Set;for(let n of e){let e=_h(n);e!==null&&t.add(e)}return t}function yh(e){return e+7&-8}function bh(e){return{subFormat:e.getUint16(24,!0),source:e.getUint8(26),idType:e.getUint8(27),rowCount:e.getUint32(28,!0)}}function xh(e,t){return sn(e.idType,e.id[t])}function Sh(e,t){return ph(e.idType,e.id[t])}function Ch(e,t){let n=Jt,r=new Int32Array(e,n,t);n+=yh(t*4);let i=new Uint8Array(e,n,t);n+=yh(t);let a=new Int32Array(e,n,t);n+=yh(t*4);let o=new Uint8Array(e,n,t);return n+=yh(t),{id:r,objectType:i,parentId:a,scale:o,offset:n}}function wh(e,t,n){let r=n,i=new Float64Array(e,r,t);r+=t*8;let a=new Float32Array(e,r,t);r+=yh(t*4);let o=new Float32Array(e,r,t);r+=yh(t*4);let s=new Float32Array(e,r,t);r+=yh(t*4);let c=new Float32Array(e,r,t);r+=yh(t*4);let l=new Float32Array(e,r,t);r+=yh(t*4);let u=new Float32Array(e,r,t);r+=yh(t*4);let d=new Float32Array(e,r,t);r+=yh(t*4);let f=new Float32Array(e,r,t);return r+=yh(t*4),{epochJd:i,a,e:o,i:s,om:c,w:l,ma:u,n:d,radiusKm:f,offset:r}}function Th(e,t,n){let{subFormat:r,rowCount:i,source:a,idType:o}=bh(new DataView(e));if(o===nn.UNKNOWN&&i>0&&console.warn(`elements payload has unknown id-type — ${i} row(s) will lack reconstructed IDs`),r===1)return Dh(e,i,t,n,a,o);if(r===2)return Eh(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}=Ch(e,i),f=wh(e,i,d),p=f.offset,m=new Float32Array(e,p,i);p+=yh(i*4);let h=new Float32Array(e,p,i);p+=yh(i*4);let g=new Uint8Array(e,p,i);p+=yh(i);let _=new Uint8Array(e,p,i);p+=yh(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 Eh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=Ch(e,t),d=wh(e,t,u),f=d.offset,p={validityStart:n,validityEnd:r,source:i,idType:a},m=new Float32Array(e,f,t);f+=yh(t*4);let h=new Float32Array(e,f,t);f+=yh(t*4);let g=new Float32Array(e,f,t);f+=yh(t*4);let _=new Int32Array(e,f,t);f+=yh(t*4);let v=new Int32Array(e,f,t);f+=yh(t*4);let y=new Uint8Array(e,f,t);f+=yh(t);let b=new Uint8Array(e,f,t);f+=yh(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 Dh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=Ch(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+=yh(t*4);let h=new Float32Array(e,d,t);d+=yh(t*4);let g=new Float32Array(e,d,t);d+=yh(t*4);let _=new Float32Array(e,d,t);d+=yh(t*4);let v=new Float32Array(e,d,t);d+=yh(t*4);let y=new Float64Array(e,d,t);d+=t*8;let b=new Float32Array(e,d,t);d+=yh(t*4);let x=new Uint8Array(e,d,t);d+=yh(t);let S=new Uint8Array(e,d,t);return d+=yh(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 Oh=Math.PI,kh=Oh*2,Ah=Oh/180;180/Oh;var jh=398600.8,Mh=6378.135,Nh=60/Math.sqrt(Mh*Mh*Mh/jh),Ph=Mh*Nh/60,Fh=1/Nh,Ih=.001082616,Lh=-253881e-11,Rh=-165597e-11,zh=Lh/Ih,Bh=2/3,Vh=1440/(2*Oh);function Hh(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 Uh(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 Wh(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return Uh(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return Uh(e,t,n,r,i,a,o)}function Gh(e,t){let{e3:n,ee2:r,peo:i,pgho:a,pho:o,pinco:s,plo:c,se2:l,se3:u,sgh2:d,sgh3:f,sgh4:p,sh2:m,sh3:h,si2:g,si3:_,sl2:v,sl3:y,sl4:b,t:x,xgh2:S,xgh3:C,xgh4:w,xh2:T,xh3:E,xi2:D,xi3:O,xl2:k,xl3:A,xl4:j,zmol:M,zmos:ee}=e,{init:N,opsmode:te}=t,{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}=t,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,R,z,ge,B,_e,V,H,U;U=ee+119459e-10*x,N===`y`&&(U=ee),H=U+2*.01675*Math.sin(U),B=Math.sin(H),pe=.5*B*B-.25,me=-.5*B*Math.cos(H);let ve=l*pe+u*me,ye=g*pe+_*me,be=v*pe+y*me+b*B,xe=d*pe+f*me+p*B,Se=m*pe+h*me;U=M+.00015835218*x,N===`y`&&(U=M),H=U+2*.0549*Math.sin(U),B=Math.sin(H),pe=.5*B*B-.25,me=-.5*B*Math.cos(H);let Ce=r*pe+n*me,W=D*pe+O*me,we=k*pe+A*me+j*B,Te=S*pe+C*me+w*B,Ee=T*pe+E*me;return he=ve+Ce,z=ye+W,ge=be+we,L=xe+Te,R=Se+Ee,N===`n`&&(he-=i,z-=s,ge-=c,L-=a,R-=o,re+=z,ne+=he,se=Math.sin(re),oe=Math.cos(re),re>=.2?(R/=se,L-=oe*R,ie+=L,P+=R,ae+=ge):(le=Math.sin(P),ce=Math.cos(P),F=se*le,I=se*ce,ue=R*ce+z*oe*le,de=-R*le+z*oe*ce,F+=ue,I+=de,P%=kh,P<0&&te===`a`&&(P+=kh),_e=ae+ie+oe*P,fe=ge+L-z*P*se,_e+=fe,V=P,P=Math.atan2(F,I),P<0&&te===`a`&&(P+=kh),Math.abs(V-P)>Oh&&(P<V?P+=kh:P-=kh),ae+=ge,ie=_e-ae-oe*P)),{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}}function Kh(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:o,np:s}=e,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,R,z,ge,B,_e,V,H,U,ve,ye,be,xe,Se,Ce,W,we,Te,Ee=.01675,De=.0549,Oe=s,ke=n,Ae=Math.sin(o),je=Math.cos(o),Me=Math.sin(r),Ne=Math.cos(r),Pe=Math.sin(a),Fe=Math.cos(a),Ie=ke*ke,Le=1-Ie,Re=Math.sqrt(Le),ze=t+18261.5+i/1440,Be=(4.523602-.00092422029*ze)%kh,Ve=Math.sin(Be),He=Math.cos(Be),Ue=.91375164-.03568096*He,We=Math.sqrt(1-Ue*Ue),Ge=.089683511*Ve/We,Ke=Math.sqrt(1-Ge*Ge),qe=5.8351514+.001944368*ze,Je=.39785416*Ve/We,Ye=Ke*He+.91744867*Ge*Ve;Je=Math.atan2(Je,Ye),Je+=qe-Be;let Xe=Math.cos(Je),Ze=Math.sin(Je);D=.1945905,O=-.98088458,j=.91744867,M=.39785416,k=je,A=Ae,v=29864797e-13;let Qe=1/Oe,$e=0;for(;$e<2;)$e+=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=Fe*m+Pe*h,d=Fe*g+Pe*_,f=-Pe*m+Fe*h,p=-Pe*g+Fe*_,y=c*Ne+l*Me,b=u*Ne+d*Me,x=-c*Me+l*Ne,S=-u*Me+d*Ne,C=f*Me,w=p*Me,T=f*Ne,E=p*Ne,W=12*y*y-3*x*x,we=24*y*b-6*x*S,Te=12*b*b-3*S*S,V=3*(c*c+l*l)+W*Ie,H=6*(c*u+l*d)+we*Ie,U=3*(u*u+d*d)+Te*Ie,ve=-6*c*f+Ie*(-24*y*T-6*x*C),ye=-6*(c*p+u*f)+Ie*(-24*(b*T+y*E)+-6*(x*w+S*C)),be=-6*u*p+Ie*(-24*b*E-6*S*w),xe=6*l*f+Ie*(24*y*C-6*x*T),Se=6*(d*f+l*p)+Ie*(24*(b*C+y*w)-6*(S*T+x*E)),Ce=6*d*p+Ie*(24*b*w-6*S*E),V=V+V+Le*W,H=H+H+Le*we,U=U+U+Le*Te,R=v*Qe,L=-.5*R/Re,z=R*Re,he=-15*ke*z,ge=y*x+b*S,B=b*x+y*S,_e=b*S-y*x,$e===1&&(ee=he,N=L,te=R,ne=z,re=ge,P=B,ie=_e,ae=V,F=H,I=U,oe=ve,se=ye,ce=be,le=xe,ue=Se,de=Ce,fe=W,pe=we,me=Te,D=Xe,O=Ze,j=Ue,M=We,k=Ke*je+Ge*Ae,A=Ae*Ke-je*Ge,v=4.7968065e-7);let et=(4.7199672+(.2299715*ze-qe))%kh,tt=(6.2565837+.017201977*ze)%kh,nt=2*ee*P,rt=2*ee*ie,it=2*N*se,at=2*N*(ce-oe),ot=-2*te*F,st=-2*te*(I-ae),ct=-2*te*(-21-9*Ie)*Ee,lt=2*ne*pe,ut=2*ne*(me-fe),dt=-18*ne*Ee,ft=-2*N*ue,pt=-2*N*(de-le),mt=2*he*B,ht=2*he*_e,gt=2*L*ye,_t=2*L*(be-ve),vt=-2*R*H,yt=-2*R*(U-V),bt=-2*R*(-21-9*Ie)*De,xt=2*z*we,St=2*z*(Te-W),Ct=-18*z*De,wt=-2*L*Se,Tt=-2*L*(Ce-xe);return{snodm:Ae,cnodm:je,sinim:Pe,cosim:Fe,sinomm:Me,cosomm:Ne,day:ze,e3:ht,ee2:mt,em:ke,emsq:Ie,gam:qe,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Re,se2:nt,se3:rt,sgh2:lt,sgh3:ut,sgh4:dt,sh2:ft,sh3:pt,si2:it,si3:at,sl2:ot,sl3:st,sl4:ct,s1:he,s2:L,s3:R,s4:z,s5:ge,s6:B,s7:_e,ss1:ee,ss2:N,ss3:te,ss4:ne,ss5:re,ss6:P,ss7:ie,sz1:ae,sz2:F,sz3:I,sz11:oe,sz12:se,sz13:ce,sz21:le,sz22:ue,sz23:de,sz31:fe,sz32:pe,sz33:me,xgh2:xt,xgh3:St,xgh4:Ct,xh2:wt,xh3:Tt,xi2:gt,xi3:_t,xl2:vt,xl3:yt,xl4:bt,nm:Oe,z1:V,z2:H,z3:U,z11:ve,z12:ye,z13:be,z21:xe,z22:Se,z23:Ce,z31:W,z32:we,z33:Te,zmol:et,zmos:tt}}function qh(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:a,s4:o,s5:s,sinim:c,ss1:l,ss2:u,ss3:d,ss4:f,ss5:p,sz1:m,sz3:h,sz11:g,sz13:_,sz21:v,sz23:y,sz31:b,sz33:x,t:S,tc:C,gsto:w,mo:T,mdot:E,no:D,nodeo:O,nodedot:k,xpidot:A,z1:j,z3:M,z11:ee,z13:N,z21:te,z23:ne,z31:re,z33:P,ecco:ie,eccsq:ae}=e,{emsq:F,em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:R,d4422:z,d5220:ge,d5232:B,d5421:_e,d5433:V,dedt:H,didt:U,dmdt:ve,dnodt:ye,domdt:be,del1:xe,del2:Se,del3:Ce,xfact:W,xlamo:we,xli:Te,xni:Ee}=e,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,tt,nt,rt,it,at=.0043752690880113,ot=.00015835218,st=119459e-10;de=0,le<.0052359877&&le>.0034906585&&(de=1),le>=.00826&&le<=.00924&&I>=.5&&(de=2);let ct=l*st*p,lt=u*st*(g+_),ut=-st*d*(m+h-14-6*F),dt=f*st*(b+x-6),ft=-st*u*(v+y);(se<.052359877||se>Oh-.052359877)&&(ft=0),c!==0&&(ft/=c);let pt=dt-t*ft;H=ct+r*ot*s,U=lt+i*ot*(ee+N),ve=ut-ot*a*(j+M-14-6*F);let mt=o*ot*(re+P-6),ht=-ot*i*(te+ne);(se<.052359877||se>Oh-.052359877)&&(ht=0),be=pt+mt,ye=ft,c!==0&&(be-=t/c*ht,ye+=ht/c);let gt=(w+C*at)%kh;if(I+=H*S,se+=U*S,oe+=be*S,ue+=ye*S,ce+=ve*S,de!==0){if(nt=(le/Nh)**Bh,de===2){rt=t*t;let e=I;I=ie;let n=F;F=ae,it=I*F,Be=-.306-(I-.64)*.44,I<=.65?(Ve=3.616-13.247*I+16.29*F,Ue=-19.302+117.39*I-228.419*F+156.591*it,We=-18.9068+109.7927*I-214.6334*F+146.5816*it,Ge=-41.122+242.694*I-471.094*F+313.953*it,Ke=-146.407+841.88*I-1629.014*F+1083.435*it,qe=-532.114+3017.977*I-5740.032*F+3708.276*it):(Ve=-72.099+331.819*I-508.738*F+266.724*it,Ue=-346.844+1582.851*I-2415.925*F+1246.113*it,We=-342.585+1554.908*I-2366.899*F+1215.972*it,Ge=-1052.797+4758.686*I-7193.992*F+3651.957*it,Ke=-3581.69+16178.11*I-24462.77*F+12422.52*it,qe=I>.715?-5149.66+29936.92*I-54087.36*F+31324.56*it:1464.74-4664.75*I+3763.64*F),I<.7?(Xe=-919.2277+4988.61*I-9064.77*F+5542.21*it,Je=-822.71072+4568.6173*I-8491.4146*F+5337.524*it,Ye=-853.666+4690.25*I-8624.77*F+5341.4*it):(Xe=-37995.78+161616.52*I-229838.2*F+109377.94*it,Je=-51752.104+218913.95*I-309468.16*F+146349.42*it,Ye=-40023.88+170470.89*I-242699.48*F+115605.82*it),Ze=c*c,De=.75*(1+2*t+rt),Oe=1.5*Ze,Ae=1.875*c*(1-2*t-3*rt),je=-1.875*c*(1+2*t-3*rt),Ne=35*Ze*De,Pe=39.375*Ze*Ze,Fe=9.84375*c*(Ze*(1-2*t-5*rt)+.33333333*(-2+4*t+6*rt)),Ie=c*(4.92187512*Ze*(-2-4*t+10*rt)+6.56250012*(1+2*t-3*rt)),Le=29.53125*c*(2-8*t+rt*(-12+8*t+10*rt)),Re=29.53125*c*(-2-8*t+rt*(12+8*t-10*rt)),et=le*le,tt=nt*nt,$e=3*et*tt,Qe=$e*17891679e-13,pe=Qe*De*Be,me=Qe*Oe*Ve,$e*=nt,Qe=$e*3.7393792e-7,he=Qe*Ae*Ue,L=Qe*je*We,$e*=nt,Qe=2*$e*7.3636953e-9,R=Qe*Ne*Ge,z=Qe*Pe*Ke,$e*=nt,Qe=$e*1.1428639e-7,ge=Qe*Fe*qe,B=Qe*Ie*Ye,Qe=2*$e*2.1765803e-9,_e=Qe*Le*Je,V=Qe*Re*Xe,we=(T+O+O-(gt+gt))%kh,W=E+ve+2*(k+ye-at)-D,I=e,F=n}de===1&&(ze=1+F*(-2.5+.8125*F),Ue=1+2*F,He=1+F*(-6+6.60937*F),De=.75*(1+t)*(1+t),ke=.9375*c*c*(1+3*t)-.75*(1+t),Me=1+t,Me*=1.875*Me*Me,xe=3*le*le*nt*nt,Se=2*xe*De*ze*17891679e-13,Ce=3*xe*Me*He*2.2123015e-7*nt,xe=xe*ke*Ue*21460748e-13*nt,we=(T+O+n-gt)%kh,W=E+A+ve+be+ye-(D+at)),Te=we,Ee=D,fe=0,le=D+0}return{em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:R,d4422:z,d5220:ge,d5232:B,d5421:_e,d5433:V,dedt:H,didt:U,dmdt:ve,dndt:0,dnodt:ye,domdt:be,del1:xe,del2:Se,del3:Ce,xfact:W,xlamo:we,xli:Te,xni:Ee}}function Jh(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*Ah/240%kh,n<0&&(n+=kh),n}function Yh(e,t,n,r,i,a,o){return e instanceof Date?Jh(Wh(e)):Jh(t===void 0?e:Wh(e,t,n,r,i,a,o))}function Xh(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=(Nh/a)**Bh,f=.75*Ih*(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=(Nh/a)**Bh,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+kh;C=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%kh,C<0&&(C+=kh)}else C=Yh(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 Zh(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:o,d4422:s,d5220:c,d5232:l,d5421:u,d5433:d,dedt:f,del1:p,del2:m,del3:h,didt:g,dmdt:_,dnodt:v,domdt:y,argpo:b,argpdot:x,t:S,tc:C,gsto:w,xfact:T,xlamo:E,no:D}=e,{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,nm:ne}=e,re=.13130908,P=2.8843198,ie=.37448087,ae=5.7686396,F=.95240898,I=1.8014998,oe=1.050833,se=4.4108898,ce=259200,le,ue,de,fe,pe,me,he,L,R=0,z=0,ge=(w+C*.0043752690880113)%kh;if(k+=f*S,j+=g*S,A+=y*S,te+=v*S,ee+=_*S,t!==0){(O===0||S*O<=0||Math.abs(S)<Math.abs(O))&&(O=0,N=D,M=E),le=S>0?720:-720;let e=381;for(;e===381;)t===2?(L=b+x*O,de=L+L,ue=M+M,he=n*Math.sin(de+M-ae)+r*Math.sin(M-ae)+i*Math.sin(L+M-F)+a*Math.sin(-L+M-F)+o*Math.sin(de+ue-I)+s*Math.sin(ue-I)+c*Math.sin(L+M-oe)+l*Math.sin(-L+M-oe)+u*Math.sin(L+ue-se)+d*Math.sin(-L+ue-se),pe=N+T,me=n*Math.cos(de+M-ae)+r*Math.cos(M-ae)+i*Math.cos(L+M-F)+a*Math.cos(-L+M-F)+c*Math.cos(L+M-oe)+l*Math.cos(-L+M-oe)+2*(o*Math.cos(de+ue-I)+s*Math.cos(ue-I)+u*Math.cos(L+ue-se)+d*Math.cos(-L+ue-se)),me*=pe):(he=p*Math.sin(M-re)+m*Math.sin(2*(M-P))+h*Math.sin(3*(M-ie)),pe=N+T,me=p*Math.cos(M-re)+2*m*Math.cos(2*(M-P))+3*h*Math.cos(3*(M-ie)),me*=pe),Math.abs(S-O)>=720?e=381:(z=S-O,e=0),e===381&&(M+=pe*le+he*ce,N+=he*le+me*ce,O+=le);ne=N+he*z+me*z*z*.5,fe=M+pe*z+he*z*z*.5,t===1?(ee=fe-te-A+ge,R=ne-D):(ee=fe-2*te+2*ge,R=ne-D),ne=D+R}return{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,dndt:R,nm:ne}}var Qh;(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`})(Qh||={});function $h(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=Qh.None;let k=e.mo+e.mdot*e.t,A=e.argpo+e.argpdot*e.t,j=e.nodeo+e.nodedot*e.t;u=A,S=k;let M=e.t*e.t;if(w=j+e.nodecf*M,v=1-e.cc1*e.t,y=e.bstar*e.cc4*e.t,b=e.t2cof*M,e.isimp!==1){c=e.omgcof*e.t;let t=1+e.eta*Math.cos(k);s=e.xmcof*(t*t*t-e.delmo),_=c+s,S=k+_,u=A-_,p=M*e.t,m=p*e.t,v=v-e.d2*M-e.d3*p-e.d4*m,y+=e.bstar*e.cc5*(Math.sin(S)-e.sinmao),b=b+e.t3cof*p+m*(e.t4cof+e.t*e.t5cof)}C=e.no;let ee=e.ecco;if(x=e.inclo,e.method===`d`){h=e.t;let t=Zh({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:h,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:ee,argpm:u,inclm:x,xli:e.xli,mm:S,xni:e.xni,nodem:w,nm:C});({em:ee,argpm:u,inclm:x,mm:S,nodem:w,nm:C}=t)}if(C<=0)return e.error=Qh.MeanMotionBelowZero,null;let N=(Nh/C)**Bh*v*v;if(C=Nh/N**1.5,ee-=y,ee>=1||ee<-.001)return e.error=Qh.MeanEccentricityOutOfRange,null;ee<1e-6&&(ee=1e-6),S+=e.no*b,E=S+u+w,w%=kh,u%=kh,E%=kh,S=(E-u-w)%kh;let te={am:N,em:ee,im:x,Om:w,om:u,mm:S,nm:C},ne=Math.sin(x),re=Math.cos(x),P=ee;if(T=x,d=u,O=w,D=S,a=ne,i=re,e.method===`d`){let t=Gh(e,{inclo:e.inclo,init:`n`,ep:P,inclp:T,nodep:O,argpp:d,mp:D,opsmode:e.operationmode});if({ep:P,nodep:O,argpp:d,mp:D}=t,T=t.inclp,T<0&&(T=-T,O+=Oh,d-=Oh),P<0||P>1)return e.error=Qh.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(a=Math.sin(T),i=Math.cos(T),e.aycof=-.5*zh*a,Math.abs(i+1)>15e-13?e.xlcof=-.25*zh*a*(3+5*i)/(1+i):e.xlcof=-.25*zh*a*(3+5*i)/15e-13);let ie=P*Math.cos(d);_=1/(N*(1-P*P));let ae=P*Math.sin(d)+_*e.aycof,F=(D+d+O+_*e.xlcof*ie-O)%kh;l=F,g=9999.9;let I=1;for(;Math.abs(g)>=1e-12&&I<=10;)r=Math.sin(l),n=Math.cos(l),g=1-n*ie-r*ae,g=(F-ae*n+ie*r-l)/g,Math.abs(g)>=.95&&(g=g>0?.95:-.95),l+=g,I+=1;let oe=ie*n+ae*r,se=ie*r-ae*n,ce=ie*ie+ae*ae,le=N*(1-ce);if(le<0)return e.error=Qh.SemiLatusRectumBelowZero,null;let ue=N*(1-oe),de=Math.sqrt(N)*se/ue,fe=Math.sqrt(le)/ue,pe=Math.sqrt(1-ce);_=se/(1+pe);let me=N/ue*(r-ae-ie*_),he=N/ue*(n-ie+ae*_);f=Math.atan2(me,he);let L=(he+he)*me,R=1-2*me*me;_=1/le;let z=.5*Ih*_,ge=z*_;e.method===`d`&&(o=i*i,e.con41=3*o-1,e.x1mth2=1-o,e.x7thm1=7*o-1);let B=ue*(1-1.5*ge*pe*e.con41)+.5*z*e.x1mth2*R;if(B<1)return e.error=Qh.Decayed,null;f-=.25*ge*e.x7thm1*L;let _e=O+1.5*ge*i*L,V=T+1.5*ge*i*a*R,H=de-C*z*e.x1mth2*L/Nh,U=fe+C*z*(e.x1mth2*R+1.5*e.con41)/Nh,ve=Math.sin(f),ye=Math.cos(f),be=Math.sin(_e),xe=Math.cos(_e),Se=Math.sin(V),Ce=Math.cos(V),W=-be*Ce,we=xe*Ce,Te=W*ve+xe*ye,Ee=we*ve+be*ye,De=Se*ve,Oe=W*ye-xe*ve,ke=we*ye-be*ve,Ae=Se*ye;return{position:{x:B*Te*Mh,y:B*Ee*Mh,z:B*De*Mh},velocity:{x:(H*Te+U*Oe)*Ph,y:(H*Ee+U*ke)*Ph,z:(H*De+U*Ae)*Ph},meanElements:te}}function eg(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:a,xecco:o,xargpo:s,xinclo:c,xmo:l,xno:u,xnodeo:d}=t,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,R,z,ge,B,_e,V,H,U,ve,ye,be,xe,Se,Ce,W=e;W.isimp=0,W.method=`n`,W.aycof=0,W.con41=0,W.cc1=0,W.cc4=0,W.cc5=0,W.d2=0,W.d3=0,W.d4=0,W.delmo=0,W.eta=0,W.argpdot=0,W.omgcof=0,W.sinmao=0,W.t=0,W.t2cof=0,W.t3cof=0,W.t4cof=0,W.t5cof=0,W.x1mth2=0,W.x7thm1=0,W.mdot=0,W.nodedot=0,W.xlcof=0,W.xmcof=0,W.nodecf=0,W.irez=0,W.d2201=0,W.d2211=0,W.d3210=0,W.d3222=0,W.d4410=0,W.d4422=0,W.d5220=0,W.d5232=0,W.d5421=0,W.d5433=0,W.dedt=0,W.del1=0,W.del2=0,W.del3=0,W.didt=0,W.dmdt=0,W.dnodt=0,W.domdt=0,W.e3=0,W.ee2=0,W.peo=0,W.pgho=0,W.pho=0,W.pinco=0,W.plo=0,W.se2=0,W.se3=0,W.sgh2=0,W.sgh3=0,W.sgh4=0,W.sh2=0,W.sh3=0,W.si2=0,W.si3=0,W.sl2=0,W.sl3=0,W.sl4=0,W.gsto=0,W.xfact=0,W.xgh2=0,W.xgh3=0,W.xgh4=0,W.xh2=0,W.xh3=0,W.xi2=0,W.xi3=0,W.xl2=0,W.xl3=0,W.xl4=0,W.xlamo=0,W.zmol=0,W.zmos=0,W.atime=0,W.xli=0,W.xni=0,W.bstar=a,W.ecco=o,W.argpo=s,W.inclo=c,W.mo=l,W.no=u,W.nodeo=d,W.operationmode=n;let we=78/Mh+1,Te=42/Mh,Ee=Te*Te*Te*Te;W.init=`y`,W.t=0;let De=Xh({satn:r,ecco:W.ecco,epoch:i,inclo:W.inclo,no:W.no,method:W.method,opsmode:W.operationmode}),{ao:Oe,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=De;if(W.no=De.no,W.con41=De.con41,W.gsto=De.gsto,W.a=(W.no*Fh)**(-2/3),W.alta=W.a*(1+W.ecco)-1,W.altp=W.a*(1-W.ecco)-1,W.error=0,Ne>=0||W.no>=0){if(W.isimp=0,Fe<1.034492841559484&&(W.isimp=1),P=we,M=Ee,k=(Fe-1)*Mh,k<156){P=k-78,k<98&&(P=20);let e=(120-P)/Mh;M=e*e*e*e,P=P/Mh+1}A=1/Pe,B=1/(Oe-P),W.eta=Oe*W.ecco*B,C=W.eta*W.eta,S=W.ecco*W.eta,j=Math.abs(1-C),_=M*B**4,v=_/j**3.5,h=v*W.no*(Oe*(1+1.5*C+S*(4+C))+.375*Ih*B/j*W.con41*(8+3*C*(8+C))),W.cc1=W.bstar*h,g=0,W.ecco>1e-4&&(g=-2*_*B*zh*W.no*Le/W.ecco),W.x1mth2=1-je,W.cc4=2*W.no*v*Oe*Ne*(W.eta*(2+.5*C)+W.ecco*(.5+2*C)-Ih*B/(Oe*j)*(-3*W.con41*(1-2*S+C*(1.5-.5*S))+.75*W.x1mth2*(2*C-S*(1+C))*Math.cos(2*W.argpo))),W.cc5=2*v*Oe*Ne*(1+2.75*(C+S)+S*C),y=je*je,R=1.5*Ih*A*W.no,z=.5*R*Ih*A,ge=-.46875*Rh*A*A*W.no,W.mdot=W.no+.5*R*Ie*W.con41+.0625*z*Ie*(13-78*je+137*y),W.argpdot=-.5*R*ke+.0625*z*(7-114*je+395*y)+ge*(3-36*je+49*y),V=-R*Ae,W.nodedot=V+(.5*z*(4-19*je)+2*ge*(3-7*je))*Ae,_e=W.argpdot+W.nodedot,W.omgcof=W.bstar*g*Math.cos(W.argpo),W.xmcof=0,W.ecco>1e-4&&(W.xmcof=-Bh*_*W.bstar/S),W.nodecf=3.5*Ne*V*W.cc1,W.t2cof=1.5*W.cc1,Math.abs(Ae+1)>15e-13?W.xlcof=-.25*zh*Le*(3+5*Ae)/(1+Ae):W.xlcof=-.25*zh*Le*(3+5*Ae)/15e-13,W.aycof=-.5*zh*Le;let e=1+W.eta*Math.cos(W.mo);if(W.delmo=e*e*e,W.sinmao=Math.sin(W.mo),W.x7thm1=7*je-1,2*Oh/W.no>=225){W.method=`d`,W.isimp=1,he=0,E=W.inclo;let e=Kh({epoch:i,ep:W.ecco,argpp:W.argpo,tc:he,inclp:W.inclo,nodep:W.nodeo,np:W.no,e3:W.e3,ee2:W.ee2,peo:W.peo,pgho:W.pgho,pho:W.pho,pinco:W.pinco,plo:W.plo,se2:W.se2,se3:W.se3,sgh2:W.sgh2,sgh3:W.sgh3,sgh4:W.sgh4,sh2:W.sh2,sh3:W.sh3,si2:W.si2,si3:W.si3,sl2:W.sl2,sl3:W.sl3,sl4:W.sl4,xgh2:W.xgh2,xgh3:W.xgh3,xgh4:W.xgh4,xh2:W.xh2,xh3:W.xh3,xi2:W.xi2,xi3:W.xi3,xl2:W.xl2,xl3:W.xl3,xl4:W.xl4,zmol:W.zmol,zmos:W.zmos});W.e3=e.e3,W.ee2=e.ee2,W.peo=e.peo,W.pgho=e.pgho,W.pho=e.pho,W.pinco=e.pinco,W.plo=e.plo,W.se2=e.se2,W.se3=e.se3,W.sgh2=e.sgh2,W.sgh3=e.sgh3,W.sgh4=e.sgh4,W.sh2=e.sh2,W.sh3=e.sh3,W.si2=e.si2,W.si3=e.si3,W.sl2=e.sl2,W.sl3=e.sl3,W.sl4=e.sl4,{sinim:p,cosim:f,em:b,emsq:x,s1:ee,s2:N,s3:te,s4:ne,s5:re,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me}=e,W.xgh2=e.xgh2,W.xgh3=e.xgh3,W.xgh4=e.xgh4,W.xh2=e.xh2,W.xh3=e.xh3,W.xi2=e.xi2,W.xi3=e.xi3,W.xl2=e.xl2,W.xl3=e.xl3,W.xl4=e.xl4,W.zmol=e.zmol,W.zmos=e.zmos,{nm:O,z1:H,z3:U,z11:ve,z13:ye,z21:be,z23:xe,z31:Se,z33:Ce}=e;let t=Gh(W,{inclo:E,init:W.init,ep:W.ecco,inclp:W.inclo,nodep:W.nodeo,argpp:W.argpo,mp:W.mo,opsmode:W.operationmode});W.ecco=t.ep,W.inclo=t.inclp,W.nodeo=t.nodep,W.argpo=t.argpp,W.mo=t.mp,w=0,T=0,D=0;let n=qh({cosim:f,emsq:x,argpo:W.argpo,s1:ee,s2:N,s3:te,s4:ne,s5:re,sinim:p,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me,t:W.t,tc:he,gsto:W.gsto,mo:W.mo,mdot:W.mdot,no:W.no,nodeo:W.nodeo,nodedot:W.nodedot,xpidot:_e,z1:H,z3:U,z11:ve,z13:ye,z21:be,z23:xe,z31:Se,z33:Ce,ecco:W.ecco,eccsq:Me,em:b,argpm:w,inclm:E,mm:D,nm:O,nodem:T,irez:W.irez,atime:W.atime,d2201:W.d2201,d2211:W.d2211,d3210:W.d3210,d3222:W.d3222,d4410:W.d4410,d4422:W.d4422,d5220:W.d5220,d5232:W.d5232,d5421:W.d5421,d5433:W.d5433,dedt:W.dedt,didt:W.didt,dmdt:W.dmdt,dnodt:W.dnodt,domdt:W.domdt,del1:W.del1,del2:W.del2,del3:W.del3,xfact:W.xfact,xlamo:W.xlamo,xli:W.xli,xni:W.xni});W.irez=n.irez,W.atime=n.atime,W.d2201=n.d2201,W.d2211=n.d2211,W.d3210=n.d3210,W.d3222=n.d3222,W.d4410=n.d4410,W.d4422=n.d4422,W.d5220=n.d5220,W.d5232=n.d5232,W.d5421=n.d5421,W.d5433=n.d5433,W.dedt=n.dedt,W.didt=n.didt,W.dmdt=n.dmdt,W.dnodt=n.dnodt,W.domdt=n.domdt,W.del1=n.del1,W.del2=n.del2,W.del3=n.del3,W.xfact=n.xfact,W.xlamo=n.xlamo,W.xli=n.xli,W.xni=n.xni}W.isimp!==1&&(m=W.cc1*W.cc1,W.d2=4*Oe*B*m,L=W.d2*B*W.cc1/3,W.d3=(17*Oe+P)*L,W.d4=.5*L*Oe*B*(221*Oe+31*P)*W.cc1,W.t3cof=W.d2+2*m,W.t4cof=.25*(3*W.d3+W.cc1*(12*W.d2+10*m)),W.t5cof=.2*(3*W.d4+12*W.cc1*W.d3+6*W.d2*W.d2+15*m*(2*W.d2+m)))}$h(W,0),W.init=`n`}function tg(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))*Ah,l=parseFloat(t.substring(17,25))*Ah,u=parseFloat(`.${t.substring(26,33).replace(/\s/g,`0`)}`),d=parseFloat(t.substring(34,42))*Ah,f=parseFloat(t.substring(43,51))*Ah,p=parseFloat(t.substring(52,63))/Vh;a/=Vh*1440,o/=Vh*1440*1440;let m=r<57?r+2e3:r+1900,{mon:h,day:g,hr:_,minute:v,sec:y}=Hh(m,i),b=Wh(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 eg(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 ng(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/=Vh*1440,c/=Vh*1440*1440;let l=Number(e.BSTAR),u=Number(e.INCLINATION)*Ah,d=Number(e.RA_OF_ASC_NODE)*Ah,f=Number(e.ECCENTRICITY),p=Number(e.ARG_OF_PERICENTER)*Ah,m=Number(e.MEAN_ANOMALY)*Ah,h=Number(e.MEAN_MOTION)/Vh,{mon:g,day:_,hr:v,minute:y,sec:b}=Hh(i,o),x=Wh(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 eg(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 rg=149597870.7,ig=23.4392911,ag=86400**2/rg**3,og=1/rg;function Q(e){return e/rg*10}function sg(e){return e/10*rg}var cg=Math.cos(Math.PI/180*ig),lg=Math.sin(Math.PI/180*ig);function ug(e,t,n,r){let i=r??{x:0,y:0,z:0};return i.x=e,i.y=-t*lg+n*cg,i.z=-(t*cg+n*lg),i}var dg=Math.PI/180,fg=Math.cos(ig*dg),pg=Math.sin(ig*dg),mg=2440587.5;function hg(e){return new Date((e-mg)*864e5).toISOString()}function gg(e,t){let n=ng({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:hg(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===Qh.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}function _g(e,t){let n=$h(e,(t-e.jdsatepoch)*1440);if(!n||e.error!==Qh.None)return null;let{x:r,y:i,z:a}=n.position;return[r,i,a]}function vg(e,t,n){let r=10/rg,i=e*r,a=t*r,o=n*r,s=a*fg+o*pg,c=-a*pg+o*fg;return a=s,o=c,[i,o,-a]}function yg(e,t){let n=_g(e,t);return n?vg(n[0],n[1],n[2]):null}function bg(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 xg=700;function Sg(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>xg)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 Cg(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 wg=null,Tg=null;function Eg(){if(!Tg){wg=[];let e=new MessageChannel;e.port1.onmessage=()=>wg.shift()?.(),Tg=e.port2}return new Promise(e=>{wg.push(e),Tg.postMessage(null)})}var Dg=2451545,Og=86400,kg=2440587.5,Ag=864e5;function jg(e){return e/Ag+kg}function Mg(e){return jg(e.getTime())}function Ng(e){return new Date((e-kg)*Ag)}function Pg(e){return(e-Dg)*Og}function Fg(e){return Dg+e/Og}var Ig=Math.PI/180;Math.cos(ig*Ig),Math.sin(ig*Ig),10/rg;function Lg(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 Rg(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 Lg(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 zg(e,t,n=!1){let r=e.length,i=Hg(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 Eg(),s=performance.now()),!Rg(i,n,e[n],t))continue;let r=e[n].data;r.validityStart<a&&(a=r.validityStart),r.validityEnd>o&&(o=r.validityEnd)}return i.validityStart=a===1/0?-1/0:a,i.validityEnd=o===-1/0?1/0:o,i}var Bg=[{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 Vg(e){let t=[];for(let n of Bg)n.transferable!==!1&&t.push(e[n.name].buffer);return t}function Hg(e){let t={count:e,applyFlagFilter:!1,validityStart:-1/0,validityEnd:1/0,pickBase:0};for(let n of Bg)t[n.name]=n.make(e);return t}function Ug(e,t){return e.get(t)?.name||null}function Wg(e,t){return e.get(t)?.isMinor??!1}function Gg(e,t){let n=e.get(t);return{name:n?.name||null,isMinor:n?.isMinor??!1}}function Kg(e,t,n,r){let i=e.scale[t]===en.PLANET,a=e.omDot[t],o=e.wDot[t],s=xh(e,t);if(s===null)return null;let{name:c,isMinor:l}=Gg(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]/rg: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 qg(e,t,n,r){let i=xh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Gg(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 Jg=new WeakMap,Yg=new WeakMap;function Xg(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 Zg={get omm(){let e=Yg.get(this);return e&&Xg(e[0],e[1])},get satrec(){let e=this,t=Jg.get(e);return t===void 0&&(t=gg(e.omm,e.name??void 0),Jg.set(e,t),t||(e.unplaceable=!0)),t??void 0}};function Qg(e,t,n,r){let i=xh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Gg(n,i),s=Object.assign(Object.create(Zg),{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]/rg,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 Yg.set(s,[e,t]),s}function $g(e,t,n,r){return e.kind===`parabolic`?qg(e,t,n,r):e.kind===`sgp4`?Qg(e,t,n,r):Kg(e,t,n,r)}function e_(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,Lg(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],Lg(n,r,e.a[t]/rg,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]===en.PLANET,s=o?e.a[t]/rg:e.a[t];return s!==0&&isFinite(s)?(n.kind[r]=1,Lg(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 t_={"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`},n_=`#cccccc`,r_=`#fcb493`,i_=`#c7ccda`,a_=`#ffe89e`,o_=`#ccb49a`,s_=`#d8ffe8`,c_=`#e8a85c`,l_=`#bed4ec`,u_=`#d5cfe7`,d_=`naif-10`,f_=`naif-399`,p_=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 m_(e){if(t_[e.id])return t_[e.id];let{objectType:t,parentId:n}=e;if(t===G.BARYCENTER){if(e.id===`naif-0`)return t_[`naif-10`];if(e.id===`naif-9`)return t_[`naif-999`];let t=`naif-${e.id.replace(`naif-`,``)}99`;if(t_[t])return t_[t]}if(t===G.STAR)return a_;if(t===G.PLANET||t===G.DWARF_PLANET)return r_;if(t===G.MOON)return i_;if(hn(t))return o_;if(t===G.COMET)return s_;if(t===G.DEBRIS)return c_;if(t===G.SPACECRAFT){if(n===`naif-399`)return l_;if(n===`naif-0`||n===`naif-10`)return u_}return n_}var h_=`#6b6b6b`;function g_(e){return e.color??h_}function __(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t>>>0}function v_(e,t){let n=Array.from({length:t},()=>[]);for(let r of e)n[__(r.data.id)%t].push(r);return n}function y_(e,t,n){return{buckets:v_(t,t.length>=n*600?n:1),baseWorker:__(e)%n}}async function b_(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 Eg(),a=performance.now());let n=t[e];i[__(n.data.id)%r].push(n)}return{buckets:i,baseWorker:__(e)%n}}function x_(e){let t=e.indexOf(`#`);return t<0?e:e.substring(0,t)}var S_=4096,C_=.75;function w_(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 T_=class{table=new Uint32Array(S_);mask=S_-1;count=0;constructor(e){this.keyOfRef=e}get size(){return this.count}slot(e){let t=w_(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*C_&&(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=w_(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)}},E_=2**20,D_=4096,O_=6;function k_(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 A_=class{chunks=[];rowOf=new T_(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>=E_)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%D_===D_-1&&performance.now()-o>O_&&(await Eg(),o=performance.now());let s=Sh(e,t);if(!(s===dh||n&&!n.has(s))&&(this.rowOf.set(s,r*E_+t,e=>Math.floor(e/E_)<=r)&&i++,a)){let n=xh(e,t),r=n===null?void 0:this.placeholders.get(n);if(r){let n=$g(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/E_);return Sh(this.chunks[t],e-t*E_)}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=_h(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=gh(e);return t!==null&&this.placeholders.has(t)}*ids(){for(let e of this.rowOf.keys()){let t=gh(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=_h(e);t!==null&&!this.rowOf.has(t)&&(yield t)}}get(e){let t=this.cache.get(e);if(t)return t;let n=_h(e),r=n===null?void 0:this.rowOf.get(n);if(r===void 0)return;let i=Math.floor(r/E_),a=$g(this.chunks[i],r-i*E_,this.labels,this.parentIdType);if(!a)return;let o={data:a,position:[0,0,0],positionUnknown:!0};return this.cache.set(e,o),o}getKey(e){let t=gh(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=$g(e,0,this.labels,this.parentIdType);return t?m_(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 Eg(),u=performance.now());let t=Math.floor(e/E_),n=a===1?0:k_(this.chunks[t].id[e-t*E_])%a;o[l]=e,s[l]=n,c[n]++,l++}let d=[];for(let e=0;e<a;e++){let t=Hg(c[e]);t.applyFlagFilter=!1,d.push({cols:t,colors:r?new Float32Array(c[e]*3):null,keys:new Float64Array(c[e]).fill(dh)})}let f=Array(a).fill(1/0),p=Array(a).fill(-1/0),m=Array(a).fill(0),h=r?new X:null;u=performance.now();for(let e=0;e<l;e++){(e&16383)==16383&&performance.now()-u>6&&(await Eg(),u=performance.now());let t=o[e],r=Math.floor(t/E_),i=t-r*E_,a=this.chunks[r],c=s[e],l=d[c],g=m[c]++,_=Sh(a,i);if(l.keys[g]=_,e_(a,i,l.cols,g,_,n)&&(a.validityStart<f[c]&&(f[c]=a.validityStart),a.validityEnd>p[c]&&(p[c]=a.validityEnd)),l.colors&&h){let e=$g(a,i,this.labels,this.parentIdType);h.set(e?m_(e):`#ffffff`),l.colors[g*3]=h.r,l.colors[g*3+1]=h.g,l.colors[g*3+2]=h.b}}for(let e=0;e<a;e++)d[e].cols.validityStart=f[e]===1/0?-1/0:f[e],d[e].cols.validityEnd=p[e]===-1/0?1/0:p[e];return{groups:d,baseWorker:__(e)%t}}};function j_(e){return e===`naif-0`||e===`naif-10`}function M_(e){let t=/^naif-([1-9])$/.exec(e);return t?`naif-${t[1]}99`:null}function N_(e){return e===`naif-0`?d_:M_(e)}function P_(e){if(!j_(e))return M_(e)??e}var F_=class{bodiesById=new Map;majorBodies=[];asteroidBodiesByZone=new Map;spacecraftByParent=new Map;focusFeature=null;dirtyAsteroidZones=new Set;dirtySpacecraftGroups=new Set;minorStreaming=!1;#e=We(0);get minorBodyVersion(){return Bt(this.#e)}set minorBodyVersion(e){Ge(this.#e,e,!0)}#t=We(0);get orientationVersion(){return Bt(this.#t)}set orientationVersion(e){Ge(this.#t,e,!0)}childrenByParent=new Map;moonMaxAByParent=new Map;addListeners=new Set;onBodiesAdded(e){return this.addListeners.add(e),()=>this.addListeners.delete(e)}notifyBodiesAdded(){for(let e of this.addListeners)e()}getBody(e,t){let n=this.bodiesById.get(e);if(n)return n;if(this.focusFeature?.data.id===e)return this.focusFeature;if(t!==void 0)return this.spacecraftByParent.get(t)?.get(e)??this.asteroidBodiesByZone.get(t)?.get(e);for(let t of this.spacecraftByParent.values()){let n=t.get(e);if(n)return n}for(let t of this.asteroidBodiesByZone.values()){let n=t.get(e);if(n)return n}}addBodies(e){let t=!1;for(let n of e){this.bodiesById.has(n.data.id)||(t=!0),this.bodiesById.set(n.data.id,n);let e=this.childrenByParent.get(n.data.parentId)??new Set;if(e.add(n.data.id),this.childrenByParent.set(n.data.parentId,e),n.data.objectType===G.MOON){let e=this.moonMaxAByParent.get(n.data.parentId)??0;n.data.a>e&&this.moonMaxAByParent.set(n.data.parentId,n.data.a)}}t&&this.notifyBodiesAdded()}asteroidBucket(e,t){let n=this.asteroidBodiesByZone.get(e);return n||this.asteroidBodiesByZone.set(e,n=new A_(t)),n}spacecraftBucket(e){let t=this.spacecraftByParent.get(e);return t||this.spacecraftByParent.set(e,t=new Map),t}flushMinor(e){this.asteroidBodiesByZone=new Map(this.asteroidBodiesByZone),this.spacecraftByParent=new Map(this.spacecraftByParent),this.minorBodyVersion++,e&&this.notifyBodiesAdded()}getChildren(e){return this.childrenByParent.get(e)}findAsteroidZone(e){for(let[t,n]of this.asteroidBodiesByZone)if(n.has(e))return t}maxMoonA(e){return this.moonMaxAByParent.get(e)}getSystemExtent(e){return this.moonMaxAByParent.get(e)??.01}isSystemBody(e){return j_(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())(hn(e.data.objectType)||e.data.objectType===G.COMET)&&i++;return{planets:e,moons:t,probes:n,earthSatellites:r,smallBodies:i}}};function I_(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 L_(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 R_(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 I_(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 I_(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 z_={metadata:.12,ephemeris:.55,majors:.8,labels:.92,done:1},B_=[`metadata`,`ephemeris`,`majors`,`labels`,`done`],V_=.9,H_=new class{#e=0;#t=z_.metadata;#n=0;#r=0;#i=!1;#a=We(0);get value(){return Bt(this.#a)}set value(e){Ge(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*V_;n>this.value&&(this.value=n)}reset(){this.#e=0,this.#t=z_.metadata,this.#n=0,this.#r=0,this.#i=!0,this.value=0}reach(e){if(!this.#i)return;let t=z_[e];if(t<=this.#e)return;this.#e=t,this.value<t&&(this.value=t);let n=B_[B_.indexOf(e)+1];this.#t=n?z_[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())}},U_=3e4;function W_(e){if(!H_.active||!e.body)return e;let t=Number(e.headers.get(`content-length`));if(!Number.isFinite(t)||t<=0)return e;H_.announce(t);let n=new TransformStream({transform(e,t){H_.addBytes(e.byteLength),t.enqueue(e)}});return new Response(e.body.pipeThrough(n),{status:e.status,statusText:e.statusText,headers:e.headers})}async function G_(e,t={},n=U_){let r=new AbortController,i=setTimeout(()=>r.abort(),n),a=()=>r.abort();t.signal?.addEventListener(`abort`,a,{once:!0});try{return W_(await fetch(e,{...t,signal:r.signal}))}catch(i){throw r.signal.aborted&&!t.signal?.aborted?Error(`Request timed out after ${n} ms: ${e}`,{cause:i}):i}finally{clearTimeout(i),t.signal?.removeEventListener(`abort`,a)}}var K_=new Map,q_=new Map,J_=null;function Y_(){if(J_)return J_;let e=(async()=>{let e=await G_(`${Ut()}/v1/systems/global.json`);if(!e.ok)return;let t=await e.json();if(t.gm)for(let[e,n]of Object.entries(t.gm))q_.set(parseInt(e,10),n);if(t.nut_prec_angles)for(let[e,n]of Object.entries(t.nut_prec_angles))K_.set(parseInt(e,10),n)})();return e.catch(()=>{J_===e&&(J_=null)}),J_=e,e}function X_(e){return e>=100?Math.trunc(e/100):e}function Z_(e){return K_.get(e)}function Q_(e){return q_.get(e)}var $_=132712440018,ev=86400;function tv(e){if(!j_(e.parentId))return;let t=Number(e.id.replace(/^naif-/,``));if(!Number.isFinite(t))return;let n=Q_(t>=1&&t<=9?t*100+99:t),r=e.a*rg;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*$_))/rg}var nv=`class-`,rv=`flag-`,iv=`cat-`;`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`;var av=`${iv}asteroids`,ov=`${iv}comets`,sv=`${iv}satellites`,cv=`${iv}debris`;`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`;var lv={neo:1,pha:2},uv=new Set([`ETc`,`JFc`,`JFC`,`CTc`,`HTC`,`PAR`,`HYP`,`COM`]);function dv(e){return uv.has(e)?`comet`:`asteroid`}function fv(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 pv=null;function mv(){if(pv)return pv;let e=G_(`${Ut()}/v1/groups/__index__.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch group index: ${e.status}`);return e.json()});return pv=e,e.catch(()=>{pv===e&&(pv=null)}),pv}var hv=[`planets`,`dwarfPlanets`,`moons`,`asteroids`,`comets`,`spacecraft`,`satellites`,`debris`,`orbits`,`labels`,`nomenclature`,`stars`],gv=new Set(hv),_v={[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`},vv=`small_bodies/`,yv=new Set([`COM`,`PAR`,`HYP`,`HYA`,`JFC`,`JFc`,`HTC`,`CTc`]);function bv(e){return e===`moons`||e.startsWith(`moons/`)||e===`small_body_moons`?`moons`:e.startsWith(`probes/`)?`spacecraft`:e.startsWith(vv)?yv.has(e.slice(13))?`comets`:`asteroids`:null}function xv(e,t){return e===G.SPACECRAFT?t===`naif-399`?`satellites`:`spacecraft`:_v[e]??null}var Sv=class{skipped;hiddenIds;onChange=null;constructor(e={}){let t=new Set;for(let n of hv)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 gv.has(e)}skipsZone(e){if(e===`earth`)return this.skipped.has(`satellites`)&&this.skipped.has(`debris`);let t=bv(e);return t!==null&&this.skipped.has(t)}hidesZone(e){let t=bv(e);return t!==null&&!this.isVisible(t)}hidesBody(e,t){let n=xv(e,t);return n!==null&&!this.isVisible(n)}hidesSpacecraftGroup(e){return e===`naif-399`?!this.isVisible(`satellites`)&&!this.isVisible(`debris`):!this.isVisible(`spacecraft`)}};function Cv(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 wv=`small_bodies/`;function Tv(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(!j_(r.data.parentId)){let t=e.bodiesById.get(r.data.parentId);t?.data.a&&(i=t.data.a,a=t.data.e)}return un(i,a)}function Ev(e,t,n){if(n.kind===`class`||n.kind===`category`){let r=Tv(e,t);return r===null?!1:n.kind===`class`?r===n.className:dv(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}({}),Dv=1503,Ov={[$.CLOSE]:.3,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},kv={[$.CLOSE]:.01,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},Av=1/3;function jv(e,t,n,r){return e<=t[$.CLOSE]?$.CLOSE:e<=t[$.FULL]*(r?n:1)?$.FULL:e<=t[$.FAR]?$.FAR:$.HIDE}var Mv=new Sv,Nv=3,Pv=4e6/rg;function Fv(e){return hn(e)||e===G.COMET||e===G.DWARF_PLANET}var Iv=class{#e=We(Xe(d_));get focusedBodyId(){return Bt(this.#e)}set focusedBodyId(e){Ge(this.#e,e,!0)}#t=We(null);get focusedSystemId(){return Bt(this.#t)}set focusedSystemId(e){Ge(this.#t,e,!0)}activeSystemId=null;isZoomedIn=!1;focusedBodyIdPlain=d_;focusedSystemIdPlain=null;travelSystemActive=!1;cameraDistThreeJS=0;lastRecomputeDist=-1;currentJd=0;hideThresholdAU=0;scaledPlanetary=Ov;scaledSystem=kv;fullMoonIds=new Set;moonVisibilityCache=new Map;constructor(e,t=()=>null,n=()=>null,r=()=>null,i=()=>Mv){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/Dv)**1.5,n=e=>({...e,[$.FULL]:e[$.FULL]*t,[$.FAR]:e[$.FAR]*t});this.scaledPlanetary=n(Ov),this.scaledSystem=n(kv)}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!==tn.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&&j_(e.data.parentId)&&!j_(e.data.id),n=e.data.objectType===G.STAR||!t&&j_(e.data.parentId);if(t)return e.data.id;if(n)return Fv(e.data.objectType)?e.data.id:null;let r=this.bodies.bodiesById.get(e.data.parentId);return r&&!j_(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&&hn(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=jv(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}getPlanetVisibility(e,t){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;if(e.data.orbitalSource===tn.SPICE_PROBE)return this.getProbeVisibility(e);let n=this.getEarthSatGroupFilter();if(n&&e.data.parentId===`naif-399`&&!n.has(e.data.id))return $.HIDE;let r=e.data.objectType;if((hn(r)||r===G.COMET||r===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 jv(t/10/n,this.scaledPlanetary,5,r)}let i=e.data.a;if(!j_(e.data.parentId)){let t=this.bodies.bodiesById.get(e.data.parentId);t?.data.a&&(i=t.data.a)}if(!i||i<0)return i===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 a=e.data.id===this.focusedBodyIdPlain,o=jv(t/10/i,this.scaledSystem,50,a);return o===$.CLOSE?$.FULL:o}getProbeVisibility(e){let t=this.getProbeStore();if((t?t.containingSystemAt(e.data.id,this.currentJd):null)===Nv&&this.getEarthSatGroupFilter())return $.HIDE;let n=e.data.id===this.focusedBodyIdPlain;if(!(t&&!t.hasHeliocentricFit(e.data.id,this.currentJd))){let t=this.bodies.bodiesById.get(d_),r=t?L_(e.position,t.position)/10:0;if(r===0)return $.FULL;let i=jv(this.cameraDistThreeJS/10/r,this.scaledSystem,50,n);return i===$.CLOSE?$.FULL:i}if(!this.isProbeInFocusedSystem(e))return $.HIDE;let r=this.bodies.bodiesById.get(e.data.parentId);if(!r)return $.FULL;let i=L_(e.position,r.position)/10;return i===0||this.cameraDistThreeJS/10/i<=this.scaledPlanetary[$.FULL]*(n?5:1)?$.FULL:$.HIDE}isProbeInFocusedSystem(e){let t=e.data.parentId;if(!j_(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.isInActiveSystem(j_(e.data.parentId)?e.data.id:e.data.parentId))return!0;if(e.data.orbitalSource!==tn.SPICE_PROBE)return!1;let t=this.getProbeStore();if(!t)return!1;let n=t.containingSystemAt(e.data.id,this.currentJd);return n!==null&&this.isInActiveSystem(`naif-${n}`)}isMoonGroupVisible(e){if(!this.getLayers().isVisible(`moons`)||!this.isInFocusedSystem(e))return!1;let t=this.bodies.maxMoonA(e);return t?this.cameraDistThreeJS/10/t<=this.scaledPlanetary[$.FAR]:!1}isSpacecraftGroupVisible(e){if(this.getLayers().hidesSpacecraftGroup(e))return!1;let t=this.activeSystemId;return j_(e)||this.bodies.bodiesById.get(e)?.data.objectType===G.STAR?!t:t?e===t?!0:this.bodies.getChildren(t)?.has(e)??!1:!1}isAsteroidGroupVisible(e){if(this.getLayers().hidesZone(e)||this.activeSystemId)return!1;let t=this.getSmallBodyFilter();if(t&&e.startsWith(`small_bodies/`)){let n=e.slice(wv.length);if(t.kind===`class`&&n!==t.className||t.kind===`category`&&dv(n)!==t.category)return!1}let n=ln[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:Ev(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(Fv(n.data.objectType))return Pv;let r=tv(n.data);return r?r*Av:0}},Lv=``;function Rv(e){let t=new Map;if(!e)return t;for(let n of e.split(`
4051
- `)){let e=n.indexOf(Lv);if(e===-1)continue;let r=n.slice(0,e),i=n.slice(e+1),a=i.indexOf(Lv),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 zv=new Map;async function Bv(e=s()){let t=zv.get(e);return t||(t=(async()=>{let t=Yt(e),n=await G_(t,{priority:`high`});if(!n.ok)throw Error(`Failed to fetch ${t}: ${n.status}`);let r=new DecompressionStream(`gzip`);return Rv(await new Response(n.body.pipeThrough(r)).text())})(),zv.set(e,t),t.catch(()=>{zv.get(e)===t&&zv.delete(e)})),t}var Vv=Math.PI/180,Hv=Math.cos(ig*Vv),Uv=Math.sin(ig*Vv);function Wv(e,t,n,r,i,a=!1){let o=Math.cos(n*Vv),s=Math.sin(n*Vv),c=Math.cos(r*Vv),l=Math.sin(r*Vv),u=Math.cos(i*Vv),d=Math.sin(i*Vv),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*Hv+m*Uv,t=-p*Uv+m*Hv;p=e,m=t}return[f*10,m*10,-p*10]}function Gv(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 Kv(e,t=new Date){return qv(e,Mg(t))}function qv(e,t){let{a:n,e:r,i,ma:a,n:o,epoch:s}=e;if(!isFinite(n)||!isFinite(r)||!isFinite(a)||!isFinite(o))return console.warn(`NaN in orbital elements: a=${n} e=${r} ma=${a} n=${o}`),null;let c=(a+o*(t-s))*Vv,{om:l,w:u}=Gv(e,t),d,f;if(r<1||n>0){let e=Math.min(r,.9999999),t=bg(c,e),i=Math.sqrt(1-e*e)*Math.sin(t)/(1-e*Math.cos(t)),a=(Math.cos(t)-e)/(1-e*Math.cos(t));d=Math.atan2(i,a),f=n*(1-e*Math.cos(t))}else{let e=Sg(c,r);if(!isFinite(e))return console.warn(`solveKeplerHyperbolic overflow: M=${c} e=${r}`),null;let t=r*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return console.warn(`Hyperbolic denom near zero: H=${e} e=${r} denom=${t}`),null;let i=Math.sqrt(r*r-1)*Math.sinh(e)/t,a=(r-Math.cosh(e))/t;d=Math.atan2(i,a),f=n*(1-r*Math.cosh(e))}let p=f*Math.cos(d),m=f*Math.sin(d);return!isFinite(p)||!isFinite(m)?(console.warn(`Non-finite orbital position: r=${f} nu=${d} xOrb=${p} yOrb=${m} a=${n} e=${r}`),null):Wv(p,m,u,i,l,e.equatorial)}function Jv(e,t=new Date){return Yv(e,Mg(t))}function Yv(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=Cg(n,r,t);if(!s)return null;let c=s.r*Math.cos(s.nu),l=s.r*Math.sin(s.nu);return!isFinite(c)||!isFinite(l)?null:Wv(c,l,o,i,a,e.equatorial)}var Xv=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 Zv(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=Jt;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 _=sn(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 Qv(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 $v(e,t,n,r){let i=Qv(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 ey=1e-7,ty=.001,ny=1,ry=16,iy=32;function ay(e,t,n){let r=new DataView(e,t,iy),i=r.getInt32(0,!0),a=r.getUint8(4),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=r.getInt32(16,!0)*ey,l=r.getInt32(20,!0)*ey,u=r.getInt32(24,!0)*ty,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+iy,d*ry);for(let e=0;e<d;e++){let t=e*ry;f[e]=n+r.getUint32(t,!0),p[e]=r.getInt32(t+4,!0)*ey,m[e]=r.getInt32(t+8,!0)*ey,h[e]=r.getInt32(t+12,!0)*ty}}return{bodyNaifId:i,isStatic:(a&ny)!==0,startEt:n+o,endEt:n+s,latRefDeg:c,lngRefDeg:l,altRefM:u,sampleEt:f,sampleLatDeg:p,sampleLngDeg:m,sampleAltM:h}}function oy(e,t,n,r){let i=n/(36*(r?8:4));return{method:3,coeffsPerAxis:12,nSeg:i,coeffs:Qv(e,t,i*3*12,r)}}function sy(e,t,n,r){let i=new DataView(e),a=i.getUint32(24,!0),o=i.getFloat32(28,!0),s=o*Og,c=Pg(t),l=[],u=Jt;for(let t=0;t<a;t++){let n=i.getInt32(u,!0),a=i.getUint8(u+4),o=i.getUint8(u+5),d=i.getUint8(u+6)===1,f=(i.getUint8(u+7)&1)!=0,p=i.getUint16(u+8,!0),m=i.getUint16(u+10,!0),h=i.getInt32(u+12,!0),g=i.getUint8(u+16),_=i.getUint8(u+17);u+=20;let v=sn(a,n)??``;v||console.warn(`probes payload: probe[${t}] (value=${n}) has unknown id-type ${a}; skipping`);let y=null;if(h!==-1&&g!==255){let e=sn(g,h);e?y={id:e,idType:g,idValue:h}:console.warn(`probes payload: probe[${t}] has unknown fit-center id-type ${g}; falling back to zone default`)}let b=Array(p),x=Array(p),S=Array(p);for(let n=0;n<p;n++){let a=i.getUint8(u),o=i.getUint32(u+4,!0),l=u+8,d=c+(m+n)*s;if(b[n]=d,x[n]=d+s,a===0)S[n]={method:0};else if(a===1||a===2)S[n]=$v(e,l,a,r);else if(a===3)S[n]=oy(e,l,o,r);else throw Error(`Unknown probe sub-chunk method ${a} at probe ${t} sub ${n}`);u=l+o}let C;if(f){let n=i.getUint8(u);if(n!==4)throw Error(`probe ${t}: PROBE_FLAG_HAS_LANDED_RECORD set but trailing record method = ${n}, expected 4`);let r=i.getUint32(u+4,!0),a=u+8;C=ay(e,a,c),u=a+r}let w=Array(_);for(let e=0;e<_;e++)w[e]={startEt:i.getFloat64(u,!0),endEt:i.getFloat64(u+8,!0),systemNaifId:i.getUint8(u+16)},u+=17;l.push({id:v,probeId:n,hasLocalized:d,objectType:o,fitCenter:y,subStartEt:b,subEndEt:x,subChunks:S,landed:C,systemIntervals:w})}return{startJd:t,endJd:n,subchunkDays:o,probes:l}}function cy(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:Th(e,o,s)};if(a===1)return{kind:`chebyshev`,chunk:Zv(e,o,s)};if(a===2)return{kind:`probes`,chunk:sy(e,o,s,t.probesFloat64??!1)};throw Error(`Unknown position-file format: ${a}`)}function ly(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 uy(e,t){let n=ly(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=e.coeffsPerAxis,s=e.coeffs,c=n*3*o,l=[0,0,0],u=2*a;for(let e=0;e<3;e++){let t=c+e*o;if(o===1){l[e]=s[t];continue}let n=0,r=0;for(let e=o-1;e>=1;e--){let i=s[t+e]+u*n-r;r=n,n=i}l[e]=s[t]+a*n-r}return l}function dy(e,t){let n=uy(e,t);return n===null?null:[Q(n[0]),Q(n[2]),-Q(n[1])]}function fy(e,t){let n=ly(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=2/(i-r),s=e.coeffsPerAxis,c=e.coeffs,l=n*3*s,u=[0,0,0],d=[0,0,0],f=2*a;for(let e=0;e<3;e++){let t=l+e*s;if(s===1){u[e]=c[t],d[e]=0;continue}let n=0,r=0;for(let e=s-1;e>=1;e--){let i=c[t+e]+f*n-r;r=n,n=i}u[e]=c[t]+a*n-r;let i=0,p=0;for(let e=s-2;e>=0;e--){let n=c[t+e+1]*(e+1)+f*i-p;p=i,i=n}d[e]=i*o}return{position:u,velocity:d}}function py(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 my(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 hy(e,t,n,r,i,a){if(t>=1)return null;let o=bg(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:my(f,p,r,n,i)}function gy(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 hy(e.aKm,e.e,e.iRad,e.om0,e.w0,o)}function _y(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 hy(e.aKm,e.e,e.iRad,i,a,o)}function vy(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 yy(e,t,n,r,i){switch(e.method){case 0:return null;case 1:return gy(e,t,r,i);case 2:return _y(e,t,r);case 3:return vy(e,t,n,r)}}function by(e,t,n){let r=Pg(t),i=py(e,r);return i<0?null:yy(e.subChunks[i],e.subStartEt[i],e.subEndEt[i],r,n)}function xy(e,t,n){let r=by(e,t,n);return r===null?null:[Q(r[0]),Q(r[2]),-Q(r[1])]}function Sy(e){if(!e.landed)return!1;let t=e.subEndEt.length;return t===0||e.subEndEt[t-1]<=e.landed.endEt}function Cy(e,t){if(!e.landed)return!1;let n=Pg(t);return n>=e.landed.startEt&&(n<e.landed.endEt||Sy(e))}function wy(e,t,n=!1){let r=Pg(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 Ty=30/Og;function Ey(e,t,n){let r=by(e,t,n);if(r===null)return null;let i=Ty,a=by(e,t+i,n),o=by(e,t-i,n),s,c,l;if(a!==null&&o!==null)s=a,c=o,l=1/(2*i);else if(a!==null)s=a,c=r,l=1/i;else if(o!==null)s=r,c=o,l=1/i;else return null;return{position:r,velocity:[(s[0]-c[0])*l,(s[1]-c[1])*l,(s[2]-c[2])*l]}}Math.PI/180;var Dy=180/Math.PI;rg/86400;var Oy=1e-9,ky=1e-9;function Ay(e,t,n){return e<t?t:e>n?n:e}function jy(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(Ay(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;_<ky||E===0?D=0:(D=Math.acos(Ay(w/E,-1,1)),T<0&&(D=2*Math.PI-D));let O;if(x<Oy)O=0;else if(_<ky||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(Ay(e,-1,1)),b<0&&(O=2*Math.PI-O)}let k,A=i*s+a*c+o*l;if(x<Oy&&(_<ky||E===0))k=Math.atan2(a,i),m<0&&(k=-k),k<0&&(k+=2*Math.PI);else if(x<Oy){let e=(w*i+T*a)/(E*u);k=Math.acos(Ay(e,-1,1)),o<0&&(k=2*Math.PI-k)}else{let e=(v*i+y*a+b*o)/(x*u);k=Math.acos(Ay(e,-1,1)),A<0&&(k=2*Math.PI-k)}let j;if(x<1){let e=2*Math.atan2(Math.sqrt(1-x)*Math.sin(k/2),Math.sqrt(1+x)*Math.cos(k/2));j=e-x*Math.sin(e)}else if(x>1){let e=2*Math.atanh(Math.sqrt((x-1)/(x+1))*Math.tan(k/2));if(!isFinite(e))return null;j=x*Math.sinh(e)-e}else return null;let M=Math.abs(C),ee=Math.sqrt(n/(M*M*M))*Dy;return{a:C,e:x,i:g*Dy,om:D*Dy,w:O*Dy,ma:j*Dy,n:ee,epoch:r,equatorial:!1}}var My=180/Math.PI;function Ny(e,t,n){if(n<=0)return null;let r=Math.sqrt(n/(e.aKm*e.aKm*e.aKm)),i=Fg(t+e.tAnchorOffsetS);return{a:e.aKm/rg,e:e.e,i:e.iRad*My,om:e.om0*My,w:e.w0*My,ma:e.m0*My,n:r*My*Og,epoch:i,equatorial:!1}}function Py(e,t){let n=Fg(t+e.tAnchorOffsetS);return{a:e.aKm/rg,e:e.e,i:e.iRad*My,om:e.om0*My,w:e.w0*My,ma:e.m0*My,n:e.nMeanRadS*My*Og,omDot:e.omDot*My*Og,wDot:e.wDot*My*Og,epoch:n,equatorial:!1}}function Fy(e,t,n){if(n<=0)return null;let r=Ey(e,t,n);if(!r)return null;let i=n*ag;return jy([r.position[0]/rg,r.position[1]/rg,r.position[2]/rg],[r.velocity[0]*og,r.velocity[1]*og,r.velocity[2]*og],i,t)}function Iy(e,t,n){let r=py(e,Pg(t));if(r<0)return null;let i=e.subChunks[r];switch(i.method){case 0:return null;case 1:return Ny(i,e.subStartEt[r],n);case 2:return Py(i,e.subStartEt[r]);case 3:return Fy(e,t,n)}}function Ly(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=fy(a,t),c=fy(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 Ry(e){let t=e-18e6;if(t>=2e6&&t<=2999999){let e=Q_(t);if(e!==void 0)return{naifId:t,muKm3S2:e}}return{naifId:e,muKm3S2:Q_(e)??0}}function zy(e,t,n,r,i){let a=`naif-${n}`,o=e.fitCenter;if(o&&o.id!==a){let n=Ly(e,t,a,r);return n?{id:n.id,naifId:n.naifId,muKm3S2:Q_(n.naifId)??0}:i?.(o.id)?o.idType===nn.SPKID?{id:o.id,...Ry(o.idValue)}:{id:o.id,naifId:o.idValue,muKm3S2:Q_(o.idValue)??0}:null}return{id:a,naifId:n,muKm3S2:Q_(n)??0}}var By=1/256,Vy=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}},Hy=200;function Uy(e,t,n,r=!1){if(r)return{stepDays:Hy/n,epsilonScene:1/0,spanDays:Hy};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 Wy(e){let t=Number(e.slice(5));return e=>e===t}function Gy(e,t,n,r){let i=Wy(r);return a=>{let o=e.probeWithCenter(n,a,i);if(!o)return null;let s=zy(o.probe,a,o.fitCenterNaifId,t,e=>e===r);return!s||s.id!==r?null:xy(o.probe,a,s.muKm3S2)}}function Ky(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 qy=.005;function Jy(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,qy*i)},c=t+o*a,l=e(c);if(l!==null&&s(Ky(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(Ky(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 Yy(e,t,n,r,i,a){Xy(e,Gy(t,n,r,i),a)}function Xy(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*By,o=n-e.spanDays;for(;i.length<e.capacity;){let n=i[i.length-1];if(n.jd<=o)break;let s=Jy(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 Zy(e,t,n,r,i){if(!isFinite(e.epsilonScene))return;let a=e.stepDays*16,o=e.stepDays*By,s=n,c=r;for(let n=0;n<e.capacity&&!(i-s<=o);n++){let n=Math.min(a,i-s),r=Jy(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 Qy(e,t,n,r,i,a){if(t.length===0)return[];let o=e.trailAnchor??e.position,s=[o[0]-r,o[1]-i,o[2]-a],c=0,l=1/0;for(let e=0;e<t.length;e++){let n=(t[e][0]-s[0])**2+(t[e][1]-s[1])**2+(t[e][2]-s[2])**2;n<l&&(l=n,c=e)}let u=Math.max(c-1,0),d=Math.min(c+1,t.length-1),f=(t[u][0]-s[0])**2+(t[u][1]-s[1])**2+(t[u][2]-s[2])**2<(t[d][0]-s[0])**2+(t[d][1]-s[1])**2+(t[d][2]-s[2])**2?u:c,p=[s];if(n)for(let e=0;e<511;e++){let n=Math.max(f-e,0);if(p.push(t[n]),n===0)break}else{for(let e=0;e<511;e++)p.push(t[((f-e)%512+512)%512]);p.push(s)}return p.filter(e=>e.every(Number.isFinite))}function $y(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 eb=new Map,tb=0,nb=10;function rb(e,t,n,r){let i=Q_(t);if(!i)return null;let a=fy(e,n);if(!a)return null;let o=r?fy(r,n):null;if(r&&!o)return null;let s=i*ag;return jy([(a.position[0]-(o?.position[0]??0))/rg,(a.position[1]-(o?.position[1]??0))/rg,(a.position[2]-(o?.position[2]??0))/rg],[(a.velocity[0]-(o?.velocity[0]??0))*og,(a.velocity[1]-(o?.velocity[1]??0))*og,(a.velocity[2]-(o?.velocity[2]??0))*og],s,n)}function ib(e,t,n){return!n||e.parentId!==tb||e.naifId===nb?null:rb(e,nb,t,n)}function ab(e,t,n,r){return r?Qt(e,t,r,n):Zt(e,t,n)}var ob=new Xv(8);async function sb(e,t,n,r,i){let a=`${e}:${t??``}:${n}:${r??``}`;return ob.getOrCompute(a,async()=>{let a=await G_(ab(e,t,n,r),{priority:i});if(!a.ok)throw Error(`Failed to fetch elements: ${a.status}`);let o=new DecompressionStream(`gzip`),s=cy(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 cb=class{static prefetch(e,t,n,r=null){fetch(ab(e,t,n,r))}positions=new Map;barycenters=new Map;neededParentKeys=new Set;probeBuffers=new Map;constructor(e){this.cheb=e,this.positions.set(`naif-0`,[0,0,0])}processChebyshev(e,t){if(!this.cheb)return[];let n=Mg(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-${nb}`,n);for(let{body:e,startJd:l,endJd:u}of o){let o=dy(e,n);if(!o)continue;a.set(e.naifId,e);let d=`naif-${e.parentId}`,f=this.positions.get(d);if(!f){console.warn(`processChebyshev: parent ${d} not in positions for ${e.id} — hiding`);continue}let p=[f[0]+o[0],f[1]+o[1],f[2]+o[2]],m=e.objectType,h=m===G.MOON&&e.parentId>=1&&e.parentId<=9?`naif-${e.parentId*100+99}`:null,g=h?this.positions.get(h):void 0,_=rb(e,e.parentId,n,h?s.body(h,n)??void 0:void 0),v=e.id,y=e=>{let t=s.body(v,e);return t?rb(t,t.parentId,e,h?s.body(h,e)??void 0:void 0):null},b=Math.hypot(o[0],o[1],o[2])/10,x={id:e.id,name:Ug(t,e.id),isMinor:Wg(t,e.id),hasLocalized:e.hasLocalized,objectType:m,parentId:`naif-${e.parentId}`,radiusKm:e.radiusKm,a:_?Math.abs(_.a):b,e:_?.e??0,i:_?.i??0,om:_?.om??0,w:_?.w??0,ma:_?.ma??0,n:_?.n??0,epoch:_?.epoch??0,equatorial:!1,helioElements:ib(e,n,c)??void 0,validityStart:l,validityEnd:u,orbitalSource:tn.SPICE,visibleFromDays:e.visibleFromDays};if(r&&this.positions.set(e.id,p),m===G.BARYCENTER||m===G.LAGRANGE_POINT){r&&_&&_.a>0&&_.e<1&&this.barycenters.set(e.id,_),i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y});continue}if(gn(m)){let t=m===G.MOON,n=this.barycenters.get(d),r=t?_:n??_,o=!t&&n!==void 0,c=a.get(e.parentId)?.id,l=o&&c?e=>{let t=s.body(c,e);return t?rb(t,t.parentId,e):null}:y;i.push({data:x,position:p,orbitElements:r??void 0,orbitCenter:o?void 0:g??f,trailAnchor:o?[f[0],f[1],f[2]]:void 0,rederiveElements:l})}else i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y})}return i}processProbes(e,t,n){let r=Mg(t),i=[],a=new Map,o=new Map,s=new Set,c=new Set;for(let{id:t,probe:l,zoneCenterNaifId:u,startJd:d,endJd:f}of e.probesAt(r)){if(!t)continue;u===void 0&&c.add(t);let p=`naif-${u}`,m=u===void 0?null:zy(l,r,u,this.cheb,e=>this.positions.has(e)),h=m?m.id:p,g=m?.muKm3S2??0,_=m===null,v=this.positions.get(h);if(!v){let e=a.get(h);e||a.set(h,e=new Set),e.add(t)}if(g===0){let e=o.get(h);e||o.set(h,e=new Set),e.add(t)}let y=by(l,r,g);y||s.add(t);let b=v??[0,0,0],x=y?[Q(y[0]),Q(y[2]),-Q(y[1])]:null,S=!x||!v||_,C=x&&!_?[b[0]+x[0],b[1]+x[1],b[2]+x[2]]:[b[0],b[1],b[2]],w={id:t,name:Ug(n,t),isMinor:Wg(n,t),hasLocalized:l.hasLocalized,objectType:l.objectType,parentId:h,loadParentId:h,radiusKm:NaN,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,equatorial:!1,validityStart:d,validityEnd:f,orbitalSource:tn.SPICE_PROBE},T=Iy(l,r,g),E=t,D=this.cheb,O=t=>{let n=e.probeWithCenter(E,t);if(!n)return null;let r=zy(n.probe,t,n.fitCenterNaifId,D,()=>!0);return r?Iy(n.probe,t,r.muKm3S2):null},k;{let{stepDays:e,epsilonScene:n,spanDays:r}=Uy(T,f-d,512),i=this.probeBuffers.get(t);i&&i.parentKey===h?(k=i.buffer,!isFinite(k.epsilonScene)&&isFinite(n)&&k.reconfigure(e,n,r)):(k=new Vy(512,e,n,r),k.needsPopulate=!0,this.probeBuffers.set(t,{buffer:k,parentKey:h}))}i.push({data:w,position:C,positionUnknown:S,orbitElements:T??void 0,orbitCenter:[b[0],b[1],b[2]],rederiveElements:O,trailBuffer:k})}c.size>0&&console.error(`processProbes: ${c.size} probe(s) have undefined fit_center_naif_id — metadata.json is stale (re-export to pick up fit_center_naif_id field). Affected probe ids: ${Array.from(c).slice(0,10).join(`, `)}`+(c.size>10?` (+${c.size-10} more)`:``));for(let[e,t]of a)console.warn(`processProbes: fit-center ${e} not in positions (unplaceable, kept hidden) — ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));for(let[e,t]of o)console.warn(`processProbes: GM unavailable for ${e} — kepler_pure sub-chunks will use mu=0 (static snapshot); affected ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));return s.size>0&&console.warn(`processProbes: ${s.size} probe(s) outside sub-chunk windows at load (will stay hidden until jd enters coverage): ${Array.from(s).slice(0,5).join(`, `)}`+(s.size>5?` (+${s.size-5} more)`:``)),i}async seedNeededParents(e,t,n,r,i){let a=await sb(e,t,n,r),o=on(i);if(o!==void 0)for(let e=0;e<a.rowCount;e++)this.neededParentKeys.add(ph(o,a.parentId[e]))}async fetchMinorColumns(e,t,n,r,i=null,a=`naif`,o){let s=await sb(e,t,n,i,o);return this.neededParentKeys.size>0&&await this.resolveNeededParents(s,r,a),s}async resolveNeededParents(e,t,n){let r=Mg(t),i=e.kind===`parabolic`,a=this.neededParentKeys,o=performance.now();for(let s=0;s<e.rowCount;s++){if((s&4095)==4095&&performance.now()-o>6&&(await Eg(),o=performance.now()),!a.has(Sh(e,s)))continue;let c=xh(e,s);if(c===null)continue;let l=this.positions.get(`${n}-${e.parentId[s]}`);if(!l)continue;let u=$g(e,s,eb,n);if(!u)continue;let d=r>=u.validityStart&&r<=u.validityEnd?u.satrec?yg(u.satrec,r):u.q==null?u.a===0&&!i?[0,0,0]:Kv(u,t):Jv(u,t):[0,0,0];d&&this.positions.set(c,[l[0]+d[0],l[1]+d[1],l[2]+d[2]])}}async process(e,t,n,r,i=null,a=`naif`,o,s){let c=this.barycenters.size===0,l=[],u=new Map,d=[],[f,p]=await Promise.all([sb(e,t,n,i,s),Bv()]),m=f.kind===`parabolic`,h=f.kind===`sgp4`,g=Mg(r),_=performance.now();for(let e=0;e<f.rowCount;e++){(e&255)==255&&performance.now()-_>6&&(await Eg(),_=performance.now());let t=f.objectType[e];if(!m&&f.a[e]===0&&t!==G.BARYCENTER&&t!==G.LAGRANGE_POINT&&!gn(t))continue;let n=`${a}-${f.parentId[e]}`,i=this.positions.get(n);if(!i){u.set(n,(u.get(n)??0)+1);continue}let s=m?qg(f,e,p,a):h?Qg(f,e,p,a):Kg(f,e,p,a);if(!s)continue;if(h&&s.name===null&&!o?.has(s.id)){l.push({data:s,position:[i[0],i[1],i[2]],positionUnknown:!0});continue}if(h&&!s.satrec)continue;let v=g>=s.validityStart&&g<=s.validityEnd,y=v?s.satrec?yg(s.satrec,g):s.a===0&&!m?[0,0,0]:s.q==null?Kv(s,r):Jv(s,r):[0,0,0];if(!y){d.push(s.id);continue}let b=[i[0]+y[0],i[1]+y[1],i[2]+y[2]],x=_h(s.id);if(x!==null&&this.neededParentKeys.has(x)&&this.positions.set(s.id,b),t===G.BARYCENTER||t===G.LAGRANGE_POINT){c&&(s.a>0&&s.e<1&&this.barycenters.set(s.id,s),this.positions.set(s.id,b)),l.push({data:s,position:b,positionUnknown:!v,orbitElements:s.a>0?s:void 0,orbitCenter:i});continue}if(c&&gn(t)&&this.positions.set(s.id,b),gn(t)){let e=t===G.MOON,r=this.barycenters.has(n);l.push({data:s,position:b,positionUnknown:!v,orbitElements:e?s:this.barycenters.get(n)??s,orbitCenter:e||!r?i:void 0})}else l.push({data:s,position:b,positionUnknown:!v})}if(d.length>0&&console.warn(`process(${e}/${t}/${n}): positioned ${l.length} body(ies), dropped ${d.length} the propagator refused — ${d.slice(0,5).join(`, `)}`+(d.length>5?` (+${d.length-5} more)`:``)),u.size>0){let r=Array.from(u.values()).reduce((e,t)=>e+t,0),i=Array.from(u.entries()).map(([e,t])=>`${e}×${t}`).join(`, `);console.warn(`process(${e}/${t}/${n}): hid ${r} body(ies) with unresolved parent — ${i}`)}return l}},lb=new Map,ub=null,db=null;function fb(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 pb(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 mb(){if(db)return db;let e=(async()=>{let e=await G_(`${Ut()}/v1/atmospheres.json`);if(!e.ok){console.warn(`atmospheres: fetch failed (${e.status}) — rendering without shells`);return}let t=await e.json();ub=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),lb.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:fb(n.seasonal),referenceAltitudeKm:n.reference_altitude_km,deepColumn:pb(e,n.deep_column,t.deep_n)})}})();return e.catch(()=>{db===e&&(db=null)}),db=e,e}function hb(e){return lb.get(e)}function gb(){return ub}var _b=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 vb(e,t){return e>>>t|e<<32-t}function yb(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=vb(i[e-15],7)^vb(i[e-15],18)^i[e-15]>>>3,n=vb(i[e-2],17)^vb(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=vb(c,6)^vb(c,11)^vb(c,25),a=c&l^~c&u,f=d+t+a+_b[e]+i[e]|0,p=(vb(n,2)^vb(n,13)^vb(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 bb(e){return e.shape===`parted`}function xb(e){return e.shape===`chunked-parted`&&e.label===`date`}function Sb(e){return e.shape===`chunked-parted`&&e.label===`index`}function Cb(e){return e.shape===`chunked`}function wb(e,t){let n=Math.floor((t-e.start_jd)/e.chunk_days);return Math.max(0,Math.min(e.chunks-1,n))}function Tb(e){return`shape`in e&&e.shape===`probes`}function Eb(e){return`zooms`in e}function Db(e){return Tb(e)?[]:Eb(e)?Object.entries(e.zooms).map(([e,t])=>({zoom:Number(e),data:t})):[{zoom:null,data:e}]}function Ob(e){return!Eb(e)&&!Tb(e)?e:void 0}var kb=new WeakMap;function Ab(e){let t=kb.get(e);return t||(t=Object.keys(e.parts_by_date).map(e=>Date.parse(`${e}T00:00:00Z`)).sort((e,t)=>e-t),kb.set(e,t)),t}function jb(e,t){let n=Ab(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 Mb=14;function Nb(e,t){let n=Ab(e),r=t.getTime(),i=Mb*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 Pb(e,t,n=0){let r=e.parts_by_date[t]??e.parts;return n>0?Math.min(r,n):r}var Fb=null;function Ib(){if(Fb)return Fb;let e=G_(`${Ut()}/v1/metadata.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch metadata: ${e.status}`);return e.json()}).then(e=>(Gt(e.versions),e));return Fb=e,e.catch(()=>{Fb===e&&(Fb=null)}),Fb}function Lb(e){let t=new Map;for(let[n,r]of Object.entries(e.position.zones)){if(Tb(r))continue;let e=Eb(r)?0:null,i=e===0?r.zooms[0]:r;!i||!Cb(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 Rb(e){let t=new Map,n=Object.entries(e.position.zones).filter(([,e])=>Tb(e)).sort(([e],[t])=>(e===`probes/interplanetary`)-+(t===`probes/interplanetary`)||e.localeCompare(t));for(let[e,r]of n)Tb(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 zb(e,t){let n=new TextEncoder().encode(e),r=crypto.subtle?await crypto.subtle.digest(`SHA-256`,n):yb(n).buffer;return new DataView(r).getUint32(0,!1)%t}async function Bb(e,t){let n=await G_(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 Vb(e,t,n,r){let i=cy(await Bb($t(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 Hb=1,Ub=Promise.resolve();function Wb(e,t){return`${e}:${t}`}var Gb=class{chunks=new Map;inflight=new Map;lastEnsuredJd=NaN;constructor(e){this.zoneParams=e}zones(){return Array.from(this.zoneParams.keys())}ensure(e){if(e===this.lastEnsuredJd)return{ready:this.allCurrentChunksLoaded(e),done:this.pendingCurrent(e)};this.lastEnsuredJd=e;let t=[],n=[],r=!0;for(let[i,a]of this.zoneParams){let o=wb(a,e);if(this.isLoadable(a,o)&&!this.isResident(i,o)){r=!1;let e=this.loadChunk(i,a,o,`high`);e&&t.push(e)}for(let e=-Hb;e<=Hb;e++){let t=o+e;e===0||t<0||t>=a.chunks||this.isLoadable(a,t)&&n.push([i,a,t])}this.evictOutsideWindow(i,o)}let i=t.length>0?Promise.all(t).then(()=>void 0):Ub;return i.catch(()=>{}).then(()=>{for(let[e,t,r]of n)this.loadChunk(e,t,r,`low`)?.catch(()=>{})}),{ready:r,done:i}}pendingCurrent(e){if(this.inflight.size===0)return Ub;let t=null;for(let[n,r]of this.zoneParams){let i=this.inflight.get(Wb(n,wb(r,e)));i&&(t??=[]).push(i)}return t?Promise.all(t).then(()=>void 0):Ub}allCurrentChunksLoaded(e){for(let[t,n]of this.zoneParams){let r=wb(n,e);if(this.isLoadable(n,r)&&!this.isResident(t,r))return!1}return!0}isResident(e,t){return this.chunks.get(e)?.has(t)??!1}evictOutsideWindow(e,t){let n=this.chunks.get(e);if(n)for(let e of n.keys())(e<t-Hb||e>t+Hb)&&n.delete(e)}loadChunk(e,t,n,r){if(this.isResident(e,n))return null;let i=Wb(e,n),a=this.inflight.get(i);if(a)return a;let o=this.fetchAndStore(e,t,n,r);return this.inflight.set(i,o),o.finally(()=>this.inflight.delete(i)),o}async fetchAndStore(e,t,n,r){let i=await this.fetchChunk(e,t,n,r),a=this.chunks.get(e);a||this.chunks.set(e,a=new Map),a.set(n,i),this.afterStore(e,i)}},Kb=class extends Gb{idToZone=new Map;isLoadable(){return!0}fetchChunk(e,t,n,r){return Vb(e,t.zoom,n,r)}afterStore(e,t){for(let n of t.byId.keys())this.idToZone.has(n)||this.idToZone.set(n,e)}has(e){return this.idToZone.has(e)}zoneCoverage(e){let t=this.idToZone.get(e);if(t===void 0)return null;let n=this.zoneParams.get(t);return n?{start:n.start_jd,end:n.end_jd}:null}resolve(e,t){let n=this.idToZone.get(e);if(n===void 0)return null;let r=this.zoneParams.get(n);if(!r)return null;let i=wb(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=wb(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?dy(n.body,t):null}};async function qb(e,t,n,r){let i=$t(e,null,t),a=await G_(i,{priority:r});if(!a.ok)throw Error(`Failed to fetch ${i}: ${a.status}`);let o=new DecompressionStream(`gzip`),s=cy(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 Jb=24;function Yb(e,t){for(let[n,r]of e){if(t<n)return!1;if(t<=r)return!0}return!1}var Xb=7,Zb=class extends Gb{fitCenterUsable=null;warmed=new Map;carried=new Map;_version=0;get version(){return this._version}zoneCenter(e){return this.zoneParams.get(e)?.fit_center_naif_id}isLoadable(e,t){return Yb(e.present,t)}fetchChunk(e,t,n,r){return qb(e,n,t.float64_coeffs,r)}afterStore(){this._version++}async warmAt(e){let t=[];for(let[n,r]of this.zoneParams){let i=wb(r,e);if(i<0||i>=r.chunks||!Yb(r.present,i)||this.isResident(n,i))continue;let a=Wb(n,i);if(this.warmed.has(a))continue;let o=this.inflight.get(a);if(o){t.push(o);continue}let s=this.fetchAndWarm(a,n,i,r);this.inflight.set(a,s),s.finally(()=>this.inflight.delete(a)),t.push(s)}await Promise.all(t)}async fetchAndWarm(e,t,n,r){let i=await qb(t,n,r.float64_coeffs,`low`);for(this.warmed.set(e,i);this.warmed.size>Jb;){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=wb(a,e),s=this.chunks.get(i)?.get(o)??this.warmed.get(Wb(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+Xb?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+Xb)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=Pg(t),i=null;for(let[a,o]of this.zoneParams){let s=wb(o,t),c=this.chunks.get(a)?.get(s)??this.warmed.get(Wb(a,s));if(c)for(let t of tx(c,e)){let e=c.probes[t];if(!this.fitCenterCovered(e))break;let s=py(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=Pg(t);for(let[r,i]of this.zoneParams){let a=wb(i,t),o=this.chunks.get(r)?.get(a)??this.warmed.get(Wb(r,a));if(o)for(let t of tx(o,e)){let e=o.probes[t];if(py(e,n)<0)break;return e.fitCenter?.id??null}}return null}probe(e,t,n){return this.resolve(e,t,n)?.probe??null}probeWithCenter(e,t,n){let r=this.resolve(e,t,n);return r?{probe:r.probe,fitCenterNaifId:r.params.fit_center_naif_id}:null}positionKm(e,t,n,r){let i=this.resolve(e,t,r);return i?by(i.probe,t,n):null}positionScene(e,t,n,r){let i=this.resolve(e,t,r);return i?xy(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=Pg(t),r=this.zoneParams.get(Qb);if(r){let i=wb(r,t),a=this.chunks.get(Qb)?.get(i);if(a)for(let t of tx(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===Qb||r.fit_center_naif_id===10)continue;let i=wb(r,t),a=this.chunks.get(n)?.get(i);if(a)for(let t of tx(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(Qb);if(!n)return!1;let r=wb(n,t),i=this.chunks.get(Qb)?.get(r);if(!i)return!1;let a=Pg(t);for(let t of tx(i,e))if(py(i.probes[t],a)>=0)return!0;return!1}},Qb=`probes/interplanetary`,$b=[],ex=new WeakMap;function tx(e,t){let n=ex.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])}ex.set(e,n)}return n.get(t)??$b}async function nx(e){let t=new DecompressionStream(`gzip`);return await new Response(e.body.pipeThrough(t)).json()}function rx(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 nx(a)})();return a=t,t.catch(()=>{a===t&&(a=null)}),t}}var ix=24,ax=new Map;function ox(e){let t=ax.get(e);if(t&&(ax.delete(e),ax.set(e,t)),!t){t=(async()=>{let t=await G_(e);if(!t.ok){if(t.status===404)return{};throw Error(`fetchGzipBundle: ${e} returned ${t.status} ${t.statusText}`)}return nx(t)})(),ax.set(e,t),t.catch(()=>{ax.get(e)===t&&ax.delete(e)});for(let e of ax.keys()){if(ax.size<=ix)break;ax.delete(e)}}return t}var sx={counts:`object_bundles`,globalPath:e=>`/v1/objects/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/objects/${e}/${t}.json.gz`,versionClass:`objects`},cx={counts:`group_bundles`,globalPath:e=>`/v1/groups/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/groups/${e}/${t}.json.gz`},lx=(e,t)=>ox(t?Kt(e,t):`${Ut()}${e}`);async function ux(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?zb(t,s):-1,c?zb(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 dx(e,t,n,r=!0){return ux(e,t,{meta:await Ib(),lang:n,localized:r,fetchBundle:lx})}function fx(e){return e.imagery!==`withheld`&&a(e.distribution)}function px(e,t=!0,n=s()){return dx(sx,e,n,t)}async function mx(e){if(e?.startsWith(`probe-`))try{let t=(await px(e,!1)).global,n=t?.coverage?.position_from;return n?{id:e,carriedFrom:n,carrierName:t?.carried_by?.name}:void 0}catch{return}}function hx(e,t,n){let r=new Set,i=new Map;for(let a of e){let e=t===a.passengerId;if(r.add(e?a.carrierId:a.passengerId),!e||!a.attached)continue;let o=n(a.carrierId)??a.carrierName;o&&i.set(a.passengerId,o)}return{hidden:r,credits:i}}function gx(e){return G[e.toUpperCase()]??G.UNDOCUMENTED}var _x={horizons:tn.HORIZONS,sbdb:tn.SBDB,celestrak:tn.CELESTRAK,spacetrack:tn.SPACETRACK,spice:tn.SPICE,sbdb_moons:tn.SBDB_MOON,astersat:tn.ASTERSAT};function vx(e){return e?_x[e]??tn.UNKNOWN:tn.UNKNOWN}var yx=14;function bx(e,t){let n=t.global;if(!n?.orbit)return null;let r=n.orbit,i=r.scale===`planet`,a=r.q!=null,o=n.cross_refs?.norad_cat_id,s=r.bstar!=null&&r.mean_motion_dot!=null&&r.mean_motion_ddot!=null&&r.n!=null&&o!=null,c=i&&s?gg({noradCatId:o,epochJd:r.epoch_jd,meanMotion:r.n,eccentricity:r.e,inclination:r.i,raOfAscNode:r.om,argOfPericenter:r.w,meanAnomaly:r.ma??0,bstar:r.bstar,meanMotionDot:r.mean_motion_dot,meanMotionDdot:r.mean_motion_ddot,elementSetNo:r.element_set_no??0,revAtEpoch:r.rev_at_epoch??0},n.name??void 0)??void 0:void 0;return{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:gx(n.type),parentId:r.parent_id,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,a:i?(r.a??0)/rg:r.a??0,e:r.e,i:r.i,om:r.om,w:r.w,ma:r.ma??0,n:i?(r.n??0)*360:r.n??0,epoch:r.epoch_jd,equatorial:i,validityStart:c?r.epoch_jd-yx:-1/0,validityEnd:c?r.epoch_jd+yx:1/0,orbitalSource:vx(r.source),...a?{q:r.q,tp:r.tp}:{},...c?{satrec:c}:{}}}function xx(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:gx(n.type),parentId:``,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,unplaceable:!0,a:NaN,e:NaN,i:NaN,om:NaN,w:NaN,ma:NaN,n:NaN,epoch:NaN,validityStart:-1/0,validityEnd:1/0,orbitalSource:tn.UNKNOWN}:null}async function Sx(e,t,n,r=new Set){if(r.has(e))return console.warn(`createPlaceholderBody: cycle detected at ${e} — hiding`),[];r.add(e);let i;try{i=await px(e)}catch{return console.warn(`createPlaceholderBody: failed to fetch global data for ${e} — hiding`),[]}let a=i.global;if(!a)return console.warn(`createPlaceholderBody: no catalogue record for ${e} — hiding`),[];let o=a.sbdb?.class??null,s=t=>{let n=t?{...t,unplaceable:!0}:xx(e,i);return n?[{body:{data:n,position:[0,0,0],positionUnknown:!0},zone:o}]:[]},c=bx(e,i);if(!c)return s();let l=c.satrec,u=c.q!=null,d=[],f=n.positions.get(c.parentId);if(!f){let e=await Sx(c.parentId,t,n,r),i=e[e.length-1];if(!i||i.body.positionUnknown)return[...e,...s(c)];f=i.body.position,n.positions.set(c.parentId,f),d.push(...e)}let p=l?yg(l,Mg(t)):u?Jv(c,t):Kv(c,t);if(!p)return console.warn(`Failed to compute position for ${e} (e=${c.e})`),[...d,...s(c)];let m=[f[0]+p[0],f[1]+p[1],f[2]+p[2]];return d.push({body:{data:c,position:m,orbitElements:c,orbitCenter:f},zone:o}),d}function Cx(e,t,n,r){let i=0;for(let a=0;a<t.length;a++){let{body:o,zone:s}=t[a];if(e.getBody(o.data.id))continue;let c=o.data.objectType;if(o.data.unplaceable)e.bodies.addBodies([o]),i++;else{let l=a>0?t[a-1]:null,u=c===G.MOON&&l&&hn(l.body.data.objectType)?`small_body_moons`:s;if(c===G.SPACECRAFT||c===G.DEBRIS){let t=o.data.parentId;e.bodies.spacecraftBucket(t).set(o.data.id,o),r?.onPlaceholder?.(o),e.bodies.dirtySpacecraftGroups.add(t),i++}else u?(e.bodies.asteroidBucket(u,n).addPlaceholder(o),e.bodies.dirtyAsteroidZones.add(u),i++):e.bodies.addBodies([o])}e.credits.recordOrbitSources([o])}return i}async function wx(e,t,n,r){if(e.getBody(t))return;let i=await Sx(t,n,r);if(i.length===0)return;let a=Cx(e,i,await Bv());e.bodies.flushMinor(a>0)}var Tx=`spacemap.atmosphere-calibration`;function Ex(){try{let e=localStorage.getItem(Tx);return e?JSON.parse(e):null}catch{return null}}function Dx(e){try{e?localStorage.setItem(Tx,JSON.stringify(e)):localStorage.removeItem(Tx)}catch{}}function Ox(){return Xe({resolvedReducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,viewMode:`map`,showClouds:!0,showAtmospheres:!0,atmosphereQuality:`auto`,atmosphereAutoTier:null,atmosphereCalibration:Ex(),atmoQualityOverrides:{},highAmbient:!1,realisticLighting:!1,overexposeRings:!1,showShapeMesh:!0,showSurfaceTexture:!0,showDisplacement:!0,showSelfShadow:!0,showHaloDebug:!1,maxPartsPerZone:0,setAtmosphereCalibration(e){this.atmosphereCalibration=e,Dx(e)},setAtmosphereAutoTier(e){this.atmosphereAutoTier=e}})}var kx=null;function Ax(){return kx??=Ox()}function jx(e){kx=e}var Mx=2e3,Nx=3,Px=class{zones=[];latestDate;failureStreak=0;staleNotified=!1;constructor(e,t,n,r){this.ctx=e,this.loader=n,this.latestDate=r;let i=Mg(r),a=Ax().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 Db(o)){if(s.shape===`chunked`||s.shape===`parted`)continue;let o=a>0?Math.min(s.parts,a):s.parts;if(xb(s)){let i={kind:`time`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentTime:jb(s,r),inFlight:null,lastLoadStartMs:-1/0,cap:a};this.zones.push(i),this.prefetchTimeNeighbors(i,r)}else if(Sb(s)){let a={kind:`chunk`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentIdx:wb(s,i),inFlight:null,preloads:new Map};this.zones.push(a),this.preloadChunkNeighbors(a,r)}}}}recordSuccess(){this.failureStreak=0}recordFailure(){this.failureStreak++,this.failureStreak>=Nx&&!this.staleNotified&&(this.staleNotified=!0,this.ctx.onDataStale?.())}invalidateZone(e){for(let t of this.zones)t.zone!==e||t.kind!==`time`||(t.currentTime=``,t.lastLoadStartMs=-1/0);this.tick(this.latestDate)}satelliteCoverage(e){let t=this.zones.find(e=>e.kind===`time`&&e.zone===`earth`);return t?Nb(t.zoomData,Ng(e)):{kind:`covered`}}tick(e){this.latestDate=e;let t=Mg(e);for(let n of this.zones)if(n.kind===`time`){if(n.inFlight)continue;let t=jb(n.zoomData,e);if(t===n.currentTime)continue;let r=performance.now();if(r-n.lastLoadStartMs<Mx)continue;n.lastLoadStartMs=r,n.inFlight=this.loadTime(n,t,e).finally(()=>{n.inFlight=null})}else{for(;;){let r=wb(n.zoomData,t);if(r===n.currentIdx)break;let i=n.preloads.get(r);if(i?.kind!==`ready`)break;let a=n.currentIdx;n.currentIdx=r,this.applyChunkSwap(n,a,r,i.bodies),this.preloadChunkNeighbors(n,e)}if(n.inFlight)continue;let r=wb(n.zoomData,t);if(r===n.currentIdx)continue;n.inFlight=this.loadChunk(n,r,e).finally(()=>{n.inFlight=null})}}async ensureBody(e,t){if(!this.ctx.getBody(e)){if(e.startsWith(`probe-`)){let n=this.ctx.probeStore;if(!n)return;let r=Mg(t),i=mx(e);await n.ensure(r).done;let a=await i;a&&n.registerCarried(a);let o=n.stampedFitCenterAt(e,r);if(o){this.ctx.getBody(o)||await wx(this.ctx,o,t,this.loader);let e=this.ctx.getBody(o);e&&!e.positionUnknown&&!this.loader.positions.has(o)&&this.loader.positions.set(o,e.position)}let s=await Bv(),c=this.loader.processProbes(n,t,s).find(t=>t.data.id===e);if(!c){await wx(this.ctx,e,t,this.loader);return}this.ctx.bodies.addBodies([c]),this.ctx.credits.recordOrbitSources([c]),this.ctx.bodies.notifyBodiesAdded();return}await wx(this.ctx,e,t,this.loader)}}async loadTime(e,t,n){let r=e.currentTime;try{let i=Pb(e.zoomData,t,e.cap),a=await Promise.all(Array.from({length:i},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,t,e.parentIdType))),o=e.zone===`earth`,s=o?this.ctx.earthSatFilter:null,c=o?this.ctx.earthTypeFilter:null,l=0,u=new Map;for(let t of a){this.ctx.credits.recordOrbitSources(t);for(let n of t){let t=n.data.objectType;if(t!==G.SPACECRAFT&&t!==G.DEBRIS){console.warn(`zone-refresher: unexpected non-spacecraft body in ${e.zone}: ${n.data.id} (type=${t})`);continue}if(s&&!s.has(n.data.id)){l++;continue}if(c&&!c.has(t)){l++;continue}let r=n.data.parentId,i=u.get(r);i||u.set(r,i=new Map),i.set(n.data.id,n)}}l>0&&console.log(`zone-refresher: ${e.zone}@${t}: filtered out ${l} non-member bodies`);let d=0,f=0,p=0;for(let[e,t]of u){let n=this.ctx.bodies.spacecraftBucket(e);for(let e of n.keys())t.has(e)||this.ctx.hasMeshBody?.(e)||(n.delete(e),p++);for(let[e,r]of t){let t=n.get(e);t?(t.data=r.data,t.position=r.position,r.orbitElements!==void 0&&(t.orbitElements=r.orbitElements),r.orbitCenter!==void 0&&(t.orbitCenter=r.orbitCenter),f++):(n.set(e,r),d++)}this.ctx.bodies.dirtySpacecraftGroups.add(e)}e.currentTime=t,this.ctx.bodies.minorBodyVersion++,d>0&&this.ctx.bodies.notifyBodiesAdded(),e.zone===`earth`&&this.ctx.notifyEarthSatRollover(),console.log(`zone-refresher: ${e.zone}@${r} → ${t} (+${d} ~${f} -${p})`),this.prefetchTimeNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: failed to refresh ${e.zone}@${t}:`,n),this.recordFailure()}}async loadChunk(e,t,n){let r=e.currentIdx;e.currentIdx=t;try{let i=e.preloads.get(t),a;a=i?.kind===`pending`?await i.promise:await Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,String(t),e.parentIdType))),this.applyChunkSwap(e,r,t,a),this.preloadChunkNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: ${e.zone} chunk reload failed (${r} → ${t}):`,n),e.currentIdx=r,this.recordFailure()}}applyChunkSwap(e,t,n,r){let i=0,a=0;for(let e of r){this.ctx.credits.recordOrbitSources(e);for(let t of e){let e=this.ctx.bodies.bodiesById.get(t.data.id);if(!e){this.ctx.bodies.addBodies([t]),this.ctx.bodies.majorBodies.push(t),a++;continue}e.data=t.data,e.position=t.position,t.orbitElements!==void 0&&(e.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(e.orbitCenter=t.orbitCenter),i++}}this.ctx.bodies.minorBodyVersion++,console.log(`zone-refresher: ${e.zone} chunk ${t} → ${n} (+${a} ~${i})`)}preloadChunkNeighbors(e,t){let n=Math.max(0,e.currentIdx-1),r=Math.min(e.zoomData.chunks-1,e.currentIdx+1);for(let i=n;i<=r;i++){if(e.preloads.has(i))continue;let n=String(i),r=Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,t,n,e.parentIdType)));e.preloads.set(i,{kind:`pending`,promise:r}),r.then(t=>{e.preloads.get(i)?.kind===`pending`&&e.preloads.set(i,{kind:`ready`,bodies:t})},t=>{console.warn(`zone-refresher: ${e.zone} chunk ${i} preload failed:`,t),e.preloads.get(i)?.kind===`pending`&&e.preloads.delete(i)})}for(let t of e.preloads.keys())(t<n||t>r)&&e.preloads.delete(t)}prefetchTimeNeighbors(e,t){let n=864e5,r=jb(e.zoomData,new Date(t.getTime()-n)),i=jb(e.zoomData,new Date(t.getTime()+n));for(let t of new Set([r,i])){if(t===e.currentTime)continue;let n=Pb(e.zoomData,t,e.cap);for(let r=0;r<n;r++)cb.prefetch(e.zone,e.zoom,r,t)}}},Fx,Ix=new Promise(e=>{Fx=e});function Lx(){Fx()}var Rx=4;function zx(){return typeof navigator>`u`?!1:navigator.connection?.saveData===!0}function Bx(){if(typeof navigator>`u`)return!1;if(zx())return!0;let e=navigator.deviceMemory;return typeof e==`number`&&e>0&&e<=Rx}var Vx;function Hx(){return Vx===void 0&&(Vx=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches),Vx}function Ux(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,2)}var Wx={low:{maxPixelRatio:1.25,shadowMapSize:1024,softShadows:!1,bloomScale:.5,pointBudget:4e5,maxTextureTier:`medium`,maxSkyboxFace:2048},medium:{maxPixelRatio:1.5,shadowMapSize:2048,softShadows:!0,bloomScale:.75,pointBudget:9e5,maxTextureTier:`medium`,maxSkyboxFace:2048},high:{maxPixelRatio:2,shadowMapSize:4096,softShadows:!0,bloomScale:1,pointBudget:1/0,maxTextureTier:`high`,maxSkyboxFace:1/0}};function Gx(){return Bx()?`low`:qx().maxTextureTier}function Kx(){let e=Ax().atmosphereCalibration?.tier;return e===`low`||e===`medium`?e:e===`high`||e===`ultra`?`high`:Hx()?Bx()?`low`:`medium`:Bx()?`medium`:`high`}function qx(){return Wx[Kx()]}function Jx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,qx().maxPixelRatio)}var Yx=Math.PI/180*ig,Xx=new Vi().setFromAxisAngle(new J(0,0,1),-Math.PI/2).premultiply(new Vi().setFromAxisAngle(new J(0,1,0),Math.PI/2-Yx)).premultiply(new Vi().setFromAxisAngle(new J(1,0,0),-Math.PI/2)),Zx=[`px`,`nx`,`py`,`ny`,`pz`,`nz`];function Qx(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 $x(e,t,n){return Kt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function eS(e,t,n){return Promise.all(Zx.map(async r=>{let i=await fetch($x(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 tS=new Map;function nS(e,t){return`${e}:${t}`}function rS(e,t,n){let r=nS(e,t),i=tS.get(r);return i||(i=eS(e,t,n),tS.set(r,i)),i}function iS(e,t,n){tS.delete(nS(e,t));for(let e of n)e.close()}function aS(e){let t=new jc(e);return t.colorSpace=Jr,t.needsUpdate=!0,t}function oS(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 sS(e){let t=oS(e);t&&rS(e.id,t).catch(()=>tS.delete(nS(e.id,t)))}var cS=12e3;async function lS(e,t,n){let r=Qx(n,Math.min(t.capabilities.maxTextureSize,qx().maxSkyboxFace));if(!r){console.warn(`Skybox ${n.id}: no tiers declared`);return}let i=oS(n),a={cube:null,bitmaps:null},o=!1;i&&i!==r&&rS(n.id,i).then(t=>{if(o){iS(n.id,i,t);return}a.cube=aS(t),a.bitmaps=t,e.background=a.cube,performance.mark(`sm-skybox-low`)}).catch(()=>{}),r!==i&&await Promise.race([Ix,new Promise(e=>setTimeout(e,cS))]);let s=await rS(n.id,r,r===i?void 0:`low`),c=aS(s);await new Promise(e=>`requestIdleCallback`in window?requestIdleCallback(()=>e(),{timeout:2e3}):setTimeout(e,500)),t.initTexture(c),o=!0;let l=e.background;e.background=c,performance.mark(`sm-skybox-high`),a.cube?.dispose(),l&&l!==a.cube&&l instanceof jc&&l.dispose(),iS(n.id,r,s),i&&i!==r&&a.bitmaps&&iS(n.id,i,a.bitmaps)}async function uS(e,t,n){if(!n?.layers.skipped.has(`stars`))try{let r=await Ib();if(!r.skybox)return;n&&(n.credits.skybox={source:r.skybox.source,organisation:r.skybox.organisation,license:r.skybox.license,attribution:r.skybox.attribution,description:r.skybox.description}),await lS(e,t,r.skybox)}catch(e){console.warn(`Failed to load skybox:`,e)}}var dS=13;function fS(e,t,n){let r=Ax().maxPartsPerZone,i=[],a=[];for(let[o,s]of Object.entries(e.position.zones)){if(o===`major`||o===`moons`||o===`spacecraft`||Tb(s)||n.skipsZone(o))continue;let e=s.parent_id_type??`naif`;for(let{zoom:n,data:c}of Db(s)){if(c.shape===`chunked`)continue;let s=xb(c)?jb(c,t):null,l=xb(c)&&s!==null?Pb(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>=dS?a.push(r):i.push(r)}}}return{eager:i,deferred:a}}async function pS(e,t,n){let r=Rb(e);for(let e of r.keys())n.skipsZone(e)&&r.delete(e);if(r.size===0)return null;console.log(`ProbeStore: ${r.size} zone(s) from metadata:\n`+Array.from(r).map(([e,t])=>` ${e}: chunks=${t.chunks} chunk_days=${t.chunk_days} fit_center=naif-${t.fit_center_naif_id} float64=${t.float64_coeffs}`).join(`
4052
- `));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 Zb(r);return await a.ensure(t).done,a}async function mS(e,t,n,r,i,a){let o=[],s=null;e.chebStore&&(s=await Bv(),o.push(...t.processChebyshev(r,s))),e.probeStore&&(s??=await Bv(),a&&e.probeStore.registerCarried(a),o.push(...t.processProbes(e.probeStore,r,s)));let c=n.position.zones.major;if(c&&Eb(c))for(let e of[1,2]){let n=c.zooms[String(e)];if(n&&bb(n))for(let i=0;i<n.parts;i++)o.push(...await t.process(`major`,e,i,r))}let l=e.layers.skipsZone(`moons`)?void 0:n.position.zones.moons,u=l?Ob(l):void 0,d=u&&Sb(u)?String(wb(u,i)):null;return u&&o.push(...await t.process(`moons`,null,0,r,d)),hS(o)}function hS(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 gS(e,t,n){performance.mark(`sm-load-start`),H_.reset(),Y_().catch(e=>console.warn(`scene-load: systems-global (GMs/nutation) failed to load:`,e));let r=mb().catch(e=>console.warn(`scene-load: atmospheres failed to load — rendering without shells:`,e)),i=Mg(t),a=Ib();Bv().catch(()=>{}),a.then(t=>{let n=t.position.zones.moons;if(!n||e.layers.skipsZone(`moons`))return;let r=Ob(n);r&&bb(r)&&cb.prefetch(`moons`,null,0,null)}),a.then(t=>{t.skybox&&!e.layers.skipped.has(`stars`)&&sS(t.skybox)});let o=a.then(n=>fS(n,t,e.layers)),s=a.then(async t=>{let n=Lb(t);for(let t of n.keys())e.layers.skipsZone(t)&&n.delete(t);if(n.size===0)return null;let r=new Kb(n);return await r.ensure(i).done,r}),c=a.then(t=>pS(t,i,e.layers)),l=mx(n),u=await a;H_.reach(`metadata`),e.chebStore=await s,e.probeStore=await c,H_.reach(`ephemeris`);let d=new cb(e.chebStore);e.probeStore&&(e.probeStore.fitCenterUsable=t=>(e.chebStore?.has(t)??!1)||(e.hasMeshBody?.(t)??!1)||d.positions.has(t));let f=await mS(e,d,u,t,i,await l);H_.reach(`majors`),await r,e.bodies.addBodies(f),e.credits.recordOrbitSources(f);let p=await Bv();H_.reach(`labels`);let m=new Map,h=!1,g=()=>{h=!0},_=()=>{let t=h;h=!1,e.bodies.flushMinor(t)};if(n&&!e.getBody(n)){let r=await Sx(n,t,d);Cx(e,r,p,{onPlaceholder:e=>m.set(e.data.id,e)})>0&&g(),r.length>0&&_()}e.bodies.majorBodies=f.filter(e=>e.data.objectType!==G.BARYCENTER&&e.data.objectType!==G.LAGRANGE_POINT&&e.data.orbitalSource!==tn.SPICE_PROBE),H_.reach(`done`),e.loading=!1,performance.mark(`sm-majors-done`);let{eager:v,deferred:y}=await o,b=v.filter(e=>e.zone===`small_body_moons`),x=v.filter(e=>e.zone!==`small_body_moons`);for(let e of b)try{await d.seedNeededParents(e.zone,e.zoom,e.part,e.time,e.parentIdType)}catch(t){console.warn(`scene-load: seedNeededParents failed for ${e.zone} part ${e.part}:`,t)}e.bodies.minorStreaming=!0;let S=setInterval(_,500),C=async(t,n,r)=>{e.credits.recordOrbitSource(n.source),n.rowCount!==0&&(await e.bodies.asteroidBucket(t,p).addChunk(n,r)>0&&g(),e.bodies.dirtyAsteroidZones.add(t))},w=(t,n)=>{e.credits.recordOrbitSources(n);let r=t===`earth`,i=r?e.earthSatFilter:null,a=r?e.earthTypeFilter:null;for(let t of n){if(i&&!i.has(t.data.id)||a&&!a.has(t.data.objectType))continue;let n=m.get(t.data.id);if(n){n.data=t.data,n.position=t.position,t.orbitElements!==void 0&&(n.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(n.orbitCenter=t.orbitCenter),m.delete(t.data.id),e.bodies.dirtySpacecraftGroups.add(t.data.parentId);continue}let r=t.data.parentId,o=e.bodies.spacecraftBucket(r);o.has(t.data.id)||g(),o.set(t.data.id,t),e.bodies.dirtySpacecraftGroups.add(r)}},T=(t,n)=>{e.credits.recordOrbitSources(n);let r=e.bodies.asteroidBucket(t,p);for(let e of n)r.addPlaceholder(e),g();e.bodies.dirtyAsteroidZones.add(t)},E=x.filter(e=>e.zone.startsWith(`small_bodies/`)),D=x.filter(e=>!e.zone.startsWith(`small_bodies/`)),O=new Set,k=(e,t)=>n=>{O.add(e),console.warn(`scene-load: ${e} part ${t} failed (skipped):`,n)};try{await Promise.all([...E.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a).then(t=>C(e,t,a)).catch(k(e,r))),...D.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a,new Set(m.keys()),`high`).then(t=>w(e,t)).catch(k(e,r)))]),await Promise.all(b.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a).then(t=>T(e,t)).catch(k(e,r))))}finally{clearInterval(S),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-minors-done`),Lx()}if(y.length>0&&Bx())console.info(`Low-end device: skipping ${y.length} deferred minor-belt parts to conserve memory`);else if(y.length>0){e.bodies.minorStreaming=!0;let n=setInterval(_,1e3);try{await Promise.all(y.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a,`low`).then(t=>C(e,t,a)).catch(k(e,r))))}finally{clearInterval(n),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-deferred-done`)}}try{e.refresher=new Px(e,await a,d,t);for(let t of O)e.refresher.invalidateZone(t)}catch(e){console.error(`scene-load: ZoneRefresher init failed; hot-reload disabled:`,e)}}var _S=rx(async()=>(await Ib(),Kt(`/v1/membership/earth.json.gz`,`membership`)),{onMissing:()=>({}),error:e=>`fetchEarthMembership: ${e.status} ${e.statusText}`});async function vS(e){let t=await _S();return new Set(t[e]??[])}function yS(e,t=s()){return dx(cx,e,t)}var bS={[sv]:new Set([G.SPACECRAFT]),[cv]:new Set([G.DEBRIS])},xS=class{bodies=new F_;credits=new xn;layers=new Sv;visibility=new Iv(this.bodies,()=>this.probeStore,()=>this.earthSatFilter,()=>this.smallBodyFilter,()=>this.layers);#e=We(!0);get loading(){return Bt(this.#e)}set loading(e){Ge(this.#e,e,!0)}#t=We(null);get error(){return Bt(this.#t)}set error(e){Ge(this.#t,e,!0)}onDataStale=null;constructor(){}chebStore=null;probeStore=null;refresher=null;hasMeshBody=null;earthSatFilter=null;earthSatFilterSlug=null;earthTypeFilter=null;smallBodyFilter=null;missionMemberIds=null;currentGroupSlug=null;groupFilterListeners=new Set;smallBodyFilterListeners=new Set;earthSatRolloverListeners=new Set;onGroupFilterChange(e){return this.groupFilterListeners.add(e),()=>this.groupFilterListeners.delete(e)}onSmallBodyFilterChange(e){return this.smallBodyFilterListeners.add(e),()=>this.smallBodyFilterListeners.delete(e)}onEarthSatRollover(e){return this.earthSatRolloverListeners.add(e),()=>this.earthSatRolloverListeners.delete(e)}notifyEarthSatRollover(){for(let e of this.earthSatRolloverListeners)e()}getBody(e,t){return this.bodies.getBody(e,t)}isMemberOfActiveGroup(e){if(this.missionMemberIds?.has(e)===!0||this.earthSatFilter?.has(e)===!0)return!0;let t=this.earthTypeFilter;if(t){let n=this.bodies.getBody(e)?.data.objectType;if(n!==void 0&&t.has(n))return!0}let n=this.smallBodyFilter;return n===null?!1:Ev(this.bodies,e,n)}async load(e,t){try{await gS(this,e,t)}catch(e){throw this.loading=!1,this.error=e instanceof Error?e.message:String(e),console.error(`[scene-load]`,e),e}}refreshTick(e){this.refresher?.tick(e)}async ensureBody(e,t){await this.refresher?.ensureBody(e,t)}async applyGroupFilter(e){if(e===this.currentGroupSlug)return;if(this.currentGroupSlug=e,e?.startsWith(`mission-`)){let t=await yS(e);if(e!==this.currentGroupSlug)return;this.missionMemberIds=new Set((t.global?.notable_members??[]).map(e=>e.id).filter(e=>!!e))}else this.missionMemberIds=null;let t=e?await this.resolveIndexEntry(e):null;if(e!==this.currentGroupSlug)return;let n=this.resolveSmallBodyFilter(e,t?.applies_to,t?.n),r=t?.applies_to===`earth_sat`?e:null,i=bS[e??``]??null;if(!fv(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 vS(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(f_),this.bodies.dirtySpacecraftGroups.add(f_),this.bodies.minorBodyVersion++,this.refresher?.invalidateZone(`earth`))}}resolveSmallBodyFilter(e,t,n){if(e===av)return{kind:`category`,category:`asteroid`};if(e===ov)return{kind:`category`,category:`comet`};if(e===null||t!==`small_body`)return null;if(e.startsWith(`class-`))return{kind:`class`,className:e.slice(nv.length)};if(e.startsWith(`flag-`)){let t=e.slice(rv.length),r=lv[t];return r===void 0?null:{kind:`flag`,flag:t,mask:r,n:n??0}}return null}async resolveIndexEntry(e){try{return(await mv())[e]??null}catch{return null}}},SS=400,CS=class{#e=We(0);get jd(){return Bt(this.#e)}set jd(e){Ge(this.#e,e,!0)}#t=We(1);get timeScale(){return Bt(this.#t)}set timeScale(e){Ge(this.#t,e,!0)}#n=We(1);get direction(){return Bt(this.#n)}set direction(e){Ge(this.#n,e,!0)}seeked=!1;#r=We(0);get jumps(){return Bt(this.#r)}set jumps(e){Ge(this.#r,e,!0)}#i=We(0);get settledJd(){return Bt(this.#i)}set settledJd(e){Ge(this.#i,e,!0)}#a=We(!1);get live(){return Bt(this.#a)}set live(e){Ge(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/Ag*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(),SS))}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(Mg(new Date)),this.live=this.timeScale===1}get playing(){return this.timeScale!==0}get date(){return Ng(this.jd)}setDate(e){this.jumpTo(Mg(e))}},wS={type:`change`},TS={type:`start`},ES={type:`end`},DS=new gs,OS=new ac,kS=Math.cos(70*Bi.DEG2RAD),AS=new J,jS=2*Math.PI,MS={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},NS=1e-6,PS=class extends Gd{constructor(e,t=null){super(e,t),this.state=MS.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:Sn.ROTATE,MIDDLE:Sn.DOLLY,RIGHT:Sn.PAN},this.touches={ONE:Cn.ROTATE,TWO:Cn.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 Vi,this._lastTargetPosition=new J,this._quat=new Vi().setFromUnitVectors(e.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Bd,this._sphericalDelta=new Bd,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=IS.bind(this),this._onPointerDown=FS.bind(this),this._onPointerUp=LS.bind(this),this._onContextMenu=WS.bind(this),this._onMouseWheel=BS.bind(this),this._onKeyDown=VS.bind(this),this._onTouchStart=HS.bind(this),this._onTouchMove=US.bind(this),this._onMouseDown=RS.bind(this),this._onMouseMove=zS.bind(this),this._interceptControlDown=GS.bind(this),this._interceptControlUp=KS.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(wS),this.update(),this.state=MS.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;AS.copy(t).sub(this.target),AS.applyQuaternion(this._quat),this._spherical.setFromVector3(AS),this.autoRotate&&this.state===MS.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+=jS:n>Math.PI&&(n-=jS),r<-Math.PI?r+=jS:r>Math.PI&&(r-=jS),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(AS.setFromSpherical(this._spherical),AS.applyQuaternion(this._quatInverse),t.copy(this.target).add(AS),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=AS.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=AS.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):(DS.origin.copy(this.object.position),DS.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(DS.direction))<kS?this.object.lookAt(this.target):(OS.setFromNormalAndCoplanarPoint(this.object.up,this.target),DS.intersectPlane(OS,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)>NS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>NS||this._lastTargetPosition.distanceToSquared(this.target)>NS?(this.dispatchEvent(wS),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?jS/60/60*this.autoRotateSpeed:jS/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){AS.setFromMatrixColumn(t,0),AS.multiplyScalar(-e),this._panOffset.add(AS)}_panUp(e,t){this.screenSpacePanning===!0?AS.setFromMatrixColumn(t,1):(AS.setFromMatrixColumn(t,0),AS.crossVectors(this.object.up,AS)),AS.multiplyScalar(e),this._panOffset.add(AS)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;AS.copy(r).sub(this.target);let i=AS.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(jS*this._rotateDelta.x/t.clientHeight),this._rotateUp(jS*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(jS*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(-jS*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(jS*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(-jS*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(jS*this._rotateDelta.x/t.clientHeight),this._rotateUp(jS*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 FS(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 IS(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function LS(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(ES),this.state=MS.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 RS(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 Sn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=MS.DOLLY;break;case Sn.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=MS.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=MS.ROTATE}break;case Sn.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=MS.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=MS.PAN}break;default:this.state=MS.NONE}this.state!==MS.NONE&&this.dispatchEvent(TS)}function zS(e){switch(this.state){case MS.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case MS.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case MS.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function BS(e){this.enabled===!1||this.enableZoom===!1||this.state!==MS.NONE||(e.preventDefault(),this.dispatchEvent(TS),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(ES))}function VS(e){this.enabled!==!1&&this._handleKeyDown(e)}function HS(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Cn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=MS.TOUCH_ROTATE;break;case Cn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=MS.TOUCH_PAN;break;default:this.state=MS.NONE}break;case 2:switch(this.touches.TWO){case Cn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=MS.TOUCH_DOLLY_PAN;break;case Cn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=MS.TOUCH_DOLLY_ROTATE;break;default:this.state=MS.NONE}break;default:this.state=MS.NONE}this.state!==MS.NONE&&this.dispatchEvent(TS)}function US(e){switch(this._trackPointer(e),this.state){case MS.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case MS.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case MS.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case MS.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=MS.NONE}}function WS(e){this.enabled!==!1&&e.preventDefault()}function GS(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function KS(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var{PI:qS,sin:JS,cos:YS,asin:XS,atan2:ZS,sqrt:QS}=Math,$S=180/qS,eC=qS/180;function tC(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 nC(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=QS(r*r+i*i+a*a);return n&&([r,i,a]=tC([r,i,a],n,!0)),{latitude:XS(i/o)*$S,longitude:n?ZS(-a,r)*$S:ZS(r,a)*$S,distance:o}}function rC(e,t,n,r,i){let a=t*eC,o=n*eC,s,c,l;if(i){let e=[r*YS(a)*YS(o),r*JS(a),-r*YS(a)*JS(o)];[s,c,l]=tC(e,i,!1)}else s=r*YS(a)*JS(o),c=r*JS(a),l=r*YS(a)*YS(o);return[e[0]+s,e[1]+c,e[2]+l]}function iC(e,t,n,r){let i=e[0]-t[0],a=e[2]-t[2],o=QS(i*i+a*a);o>0?(i/=o,a/=o):(i=0,a=1);let s=n*eC,c=YS(s);return[r*c*i,r*JS(s),r*c*a]}function aC(e){let t=(e+180)%360-180;return t<=-180?t+360:t}function oC(e,t,n){if(t===void 0&&n===void 0)return e;let r=t===void 0?-180:aC(t),i=r===180?-180:r,a=n===void 0?180:aC(n);if(i<=a?e>=i&&e<=a:e>=i||e<=a)return e;let o=(e,t)=>Math.abs(aC(e-t));return o(e,i)<=o(e,a)?i:a}var sC=f_,cC=Math.PI/180,lC=2451545,uC=36525;function dC(e,t,n){let r=t-lC,i=r/uC,a=e.pole_ra_0+e.pole_ra_1*i,o=e.pole_dec_0+e.pole_dec_1*i,s=e.w0+e.w1*r+e.w2*r*r;if(n){let{ra:e,dec:t,pm:r,angles:c}=n,l=Math.min(c.length>>1,Math.max(e.length,t.length,r.length));for(let n=0;n<l;n++){let l=(c[2*n]+c[2*n+1]*i)*cC,u=Math.sin(l);n<e.length&&(a+=e[n]*u),n<t.length&&(o+=t[n]*Math.cos(l)),n<r.length&&(s+=r[n]*u)}}let c=a*cC,l=o*cC,u=Math.cos(l),d=ug(u*Math.cos(c),u*Math.sin(c),Math.sin(l),new J).normalize(),f=ug(-Math.sin(c),Math.cos(c),0,new J).normalize(),p=new J().crossVectors(f,d).normalize(),m=new Vi().setFromRotationMatrix(new Y().makeBasis(f,d,p));return new Vi().setFromAxisAngle(d,s*cC).multiply(m)}function fC(e,t,n,r){e.quaternion.copy(dC(t,n,r))}var pC=new J(0,1,0),mC=new J;function hC(e,t,n){mC.set(t[0]-n[0],t[1]-n[1],t[2]-n[2]),!(mC.lengthSq()<1e-20)&&(mC.normalize(),e.quaternion.setFromUnitVectors(pC,mC))}function gC(e,t){e.quaternion.setFromUnitVectors(pC,t)}var _C={"+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 vC(e){let t=[];for(let[n,r]of Object.entries(e)){let e=_C[n],i=_C[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 Vi().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 Vi().setFromRotationMatrix(c.multiply(l))}var yC=new J,bC=new J,xC=new J,SC=new J,CC=new J,wC=new J,TC=new J,EC=new J,DC=new Y,OC=new Y;function kC(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 AC(e,t,n){if(!kC(t.primary.target,n,yC))return;let r=_C[t.primary.axis],i=t.secondary;if(!i||!kC(i.target,n,bC)){e.quaternion.setFromUnitVectors(r,yC);return}if(CC.crossVectors(r,_C[i.axis]),EC.crossVectors(yC,bC),CC.lengthSq()<1e-20||EC.lengthSq()<1e-20){e.quaternion.setFromUnitVectors(r,yC);return}CC.normalize(),EC.normalize(),xC.copy(r),wC.copy(yC),SC.crossVectors(CC,xC),TC.crossVectors(EC,wC),DC.makeBasis(wC,TC,EC),OC.makeBasis(xC,SC,CC).transpose(),DC.multiply(OC),e.quaternion.setFromRotationMatrix(DC)}function jC(e,t){let n=e,r=n.userData.shaderMods??=[];r.includes(t)||(r.push(t),e.customProgramCacheKey=()=>r.join(`|`))}function MC(e,t,n){let r=e.onBeforeCompile;e.onBeforeCompile=(e,t)=>{r?.(e,t),n(e,t)},jC(e,t),e.needsUpdate=!0}var NC={uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new oa)}},PC=`
4050
+ }`,th=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Fc(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 du({vertexShader:$m,fragmentShader:eh,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ks(new Ql(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},nh=class extends pi{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 th,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new q,C=null,w=new od;w.viewport=new oa;let T=new od;T.viewport=new oa;let E=[w,T],D=new xd,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 Ba,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Ba,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Ba,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}O=null,k=null,h.reset();for(let e in g)delete g[e];e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,ae.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&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?Zn:Xn,a=_.stencil?Wn:zn);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 ca(d.textureWidth,d.textureHeight,{format:Yn,type:Pn,depthTexture:new Nc(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 ca(f.framebufferWidth,f.framebufferHeight,{format:Yn,type:Pn,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ae.setContext(r),ae.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function M(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let ee=new J,N=new J;function te(e,t,n){ee.setFromMatrixPosition(t.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);let r=ee.distanceTo(N),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ne(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;ne(D,i);for(let e=0;e<a.length;e++)ne(a[e],i);a.length===2?te(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),re(e,D,i)};function re(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=_i*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(D)},this.getCameraTexture=function(e){return g[e]};let P=null;function ie(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==D.cameras.length&&(D.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=E[n];o===void 0&&(o=new od,o.layers.enable(n),o.viewport=new oa,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 Fc,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}P&&P(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ae=new Jd;ae.setAnimationLoop(ie),this.setAnimationLoop=function(e){P=e},this.dispose=function(){}}},rh=new ba,ih=new Y;function ah(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,rh.copy(o),rh.x*=-1,rh.y*=-1,rh.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(rh.y*=-1,rh.z*=-1),e.envMapRotation.value.setFromMatrix4(ih.makeRotationFromEuler(rh)),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 oh(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 li(`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 lh(){return ch===null&&(ch=new Us(sh,16,16,er,Vn),ch.name=`DFG_LUT`,ch.minFilter=jn,ch.magFilter=jn,ch.wrapS=En,ch.wrapT=En,ch.generateMipmaps=!1,ch.needsUpdate=!0),ch}var uh=class{constructor(e={}){let{canvas:t=ii(),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=Pn}=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([nr,tr,$n]),g=new Set([Pn,zn,Ln,Wn,Hn,Un]),_=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=Jr;let E=0,D=0,O=null,k=-1,A=null,j=new oa,M=new oa,ee=null,N=new X(0),te=0,ne=t.width,re=t.height,P=1,ie=null,ae=null,F=new oa(0,0,ne,re),I=new oa(0,0,ne,re),oe=!1,se=new lc,ce=!1,le=!1,ue=new Y,de=new J,fe=new oa,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},me=!1;function he(){return O===null?P:1}let L=n;function R(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`,Fe,!1),t.addEventListener(`webglcontextrestored`,Ie,!1),t.addEventListener(`webglcontextcreationerror`,Le,!1),L===null){let t=`webgl2`;if(L=R(t,e),L===null)throw R(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw li(`WebGLRenderer: `+e.message),e}let z,ge,B,_e,V,H,U,ve,ye,be,xe,Se,Ce,W,we,Te,Ee,De,Oe,ke,Ae,je,Me;function Ne(){z=new kf(L),z.init(),Ae=new Qm(L,z),ge=new af(L,z,e,Ae),B=new Xm(L,z),ge.reversedDepthBuffer&&d&&B.buffers.depth.setReversed(!0),_e=new Mf(L),V=new Am,H=new Zm(L,z,B,V,ge,Ae,_e),U=new Of(w),ve=new Yd(L),je=new nf(L,ve),ye=new Af(L,ve,_e,je),be=new Pf(L,ye,ve,je,_e),De=new Nf(L,ge,H),we=new of(V),xe=new km(w,U,z,ge,je,we),Se=new ah(w,V),Ce=new Pm,W=new Vm(z),Ee=new tf(w,U,B,be,p,s),Te=new Ym(w,be,ge),Me=new oh(L,_e,ge,B),Oe=new rf(L,z,_e),ke=new jf(L,z,_e),_e.programs=xe.programs,w.capabilities=ge,w.extensions=z,w.properties=V,w.renderLists=Ce,w.shadowMap=Te,w.state=B,w.info=_e}Ne(),m!==1009&&(C=new If(m,t.width,t.height,r,i));let Pe=new nh(w,L);this.xr=Pe,this.getContext=function(){return L},this.getContextAttributes=function(){return L.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 P},this.setPixelRatio=function(e){e!==void 0&&(P=e,this.setSize(ne,re,!1))},this.getSize=function(e){return e.set(ne,re)},this.setSize=function(e,n,r=!0){if(Pe.isPresenting){K(`WebGLRenderer: Can't change size while VR device is presenting.`);return}ne=e,re=n,t.width=Math.floor(e*P),t.height=Math.floor(n*P),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),C!==null&&C.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(ne*P,re*P).floor()},this.setDrawingBufferSize=function(e,n,r){ne=e,re=n,P=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){console.error(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){console.warn(`THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}C.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(j)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,r){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,r),B.viewport(j.copy(F).multiplyScalar(P).round())},this.getScissor=function(e){return e.copy(I)},this.setScissor=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),B.scissor(M.copy(I).multiplyScalar(P).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){B.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Ee.getClearColor())},this.setClearColor=function(){Ee.setClearColor(...arguments)},this.getClearAlpha=function(){return Ee.getClearAlpha()},this.setClearAlpha=function(){Ee.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=Ee.getClearColor(),r=Ee.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,L.clearBufferuiv(L.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,L.clearBufferiv(L.COLOR,0,v))}else r|=L.COLOR_BUFFER_BIT}t&&(r|=L.DEPTH_BUFFER_BIT),n&&(r|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&L.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Fe,!1),t.removeEventListener(`webglcontextrestored`,Ie,!1),t.removeEventListener(`webglcontextcreationerror`,Le,!1),Ee.dispose(),Ce.dispose(),W.dispose(),V.dispose(),U.dispose(),be.dispose(),je.dispose(),Me.dispose(),xe.dispose(),Pe.dispose(),Pe.removeEventListener(`sessionstart`,We),Pe.removeEventListener(`sessionend`,Ge),Ke.stop()};function Fe(e){e.preventDefault(),si(`WebGLRenderer: Context Lost.`),T=!0}function Ie(){si(`WebGLRenderer: Context Restored.`),T=!1;let e=_e.autoReset,t=Te.enabled,n=Te.autoUpdate,r=Te.needsUpdate,i=Te.type;Ne(),_e.autoReset=e,Te.enabled=t,Te.autoUpdate=n,Te.needsUpdate=r,Te.type=i}function Le(e){li(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Re(e){let t=e.target;t.removeEventListener(`dispose`,Re),ze(t)}function ze(e){Be(e),V.remove(e)}function Be(e){let t=V.get(e).programs;t!==void 0&&(t.forEach(function(e){xe.releaseProgram(e)}),e.isShaderMaterial&&xe.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=pe);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=tt(e,t,n,r,i);B.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=ye.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;je.setup(i,r,s,n,c);let h,g=Oe;if(c!==null&&(h=ve.get(c),g=ke,g.setIndex(h)),i.isMesh)r.wireframe===!0?(B.setLineWidth(r.wireframeLinewidth*he()),g.setMode(L.LINES)):g.setMode(L.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),B.setLineWidth(e*he()),i.isLineSegments?g.setMode(L.LINES):i.isLineLoop?g.setMode(L.LINE_LOOP):g.setMode(L.LINE_STRIP)}else i.isPoints?g.setMode(L.POINTS):i.isSprite&&g.setMode(L.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)ui(`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?ve.get(c).bytesPerElement:1,o=V.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(L,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Ve(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,Qe(e,t,n),e.side=0,e.needsUpdate=!0,Qe(e,t,n),e.side=2):Qe(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),b=W.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];Ve(a,n,e),r.add(a)}else Ve(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 He=null;function Ue(e){He&&He(e)}function We(){Ke.stop()}function Ge(){Ke.start()}let Ke=new Jd;Ke.setAnimationLoop(Ue),typeof self<`u`&&Ke.setContext(self),this.setAnimationLoop=function(e){He=e,Pe.setAnimationLoop(e),e===null?Ke.stop():Ke.start()},Pe.addEventListener(`sessionstart`,We),Pe.addEventListener(`sessionend`,Ge),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){li(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(T===!0)return;let n=Pe.enabled===!0&&Pe.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(),Pe.enabled===!0&&Pe.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Pe.cameraAutoUpdate===!0&&Pe.updateCamera(t),t=Pe.getCamera()),e.isScene===!0&&e.onBeforeRender(w,e,t,O),b=W.get(e,S.length),b.init(t),S.push(b),ue.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromProjectionMatrix(ue,ei,t.reversedDepth),le=this.localClippingEnabled,ce=we.init(this.clippingPlanes,le),y=Ce.get(e,x.length),y.init(),x.push(y),Pe.enabled===!0&&Pe.isPresenting===!0){let e=w.xr.getDepthSensingMesh();e!==null&&qe(e,t,-1/0,w.sortObjects)}qe(e,t,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(ie,ae),me=Pe.enabled===!1||Pe.isPresenting===!1||Pe.hasDepthSensing()===!1,me&&Ee.addToRenderList(y,e),this.info.render.frame++,ce===!0&&we.beginShadows();let i=b.state.shadowsArray;if(Te.render(i,e,t),ce===!0&&we.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];Ye(n,r,e,a)}me&&Ee.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];Je(y,e,n,n.viewport)}}else r.length>0&&Ye(n,r,e,t),me&&Ee.render(e),Je(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),je.resetDefaultState(),k=-1,A=null,S.pop(),S.length>0?(b=S[S.length-1],ce===!0&&we.setGlobalState(w.clippingPlanes,b.state.camera)):b=null,x.pop(),y=x.length>0?x[x.length-1]:null};function qe(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)b.pushLight(e),e.castShadow&&b.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||se.intersectsSprite(e)){r&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ue);let t=be.update(e),i=e.material;i.visible&&y.push(e,t,i,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||se.intersectsObject(e))){let t=be.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),fe.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),fe.copy(e.boundingSphere.center)),fe.applyMatrix4(e.matrixWorld).applyMatrix4(ue)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&y.push(e,t,s,n,fe.z,o)}}else i.visible&&y.push(e,t,i,n,fe.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)qe(i[e],t,n,r)}function Je(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;b.setupLightsView(n),ce===!0&&we.setGlobalState(w.clippingPlanes,n),r&&B.viewport(j.copy(r)),i.length>0&&Xe(i,t,n),a.length>0&&Xe(a,t,n),o.length>0&&Xe(o,t,n),B.buffers.depth.setTest(!0),B.buffers.depth.setMask(!0),B.buffers.color.setMask(!0),B.setPolygonOffset(!1)}function Ye(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 ca(1,1,{generateMipmaps:!0,type:e?Vn:Pn,minFilter:Nn,samples:Math.max(4,ge.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Yi.workingColorSpace})}let a=b.state.transmissionRenderTarget[r.id],o=r.viewport||j;a.setSize(o.z*w.transmissionResolutionScale,o.w*w.transmissionResolutionScale);let s=w.getRenderTarget(),c=w.getActiveCubeFace(),l=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(N),te=w.getClearAlpha(),te<1&&w.setClearColor(16777215,.5),w.clear(),me&&Ee.render(n);let u=w.toneMapping;w.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),b.setupLightsView(r),ce===!0&&we.setGlobalState(w.clippingPlanes,r),Xe(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,Ze(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(N,te),d!==void 0&&(r.viewport=d),w.toneMapping=u}function Xe(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)&&Ze(o,t,n,s,l,c)}}function Ze(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 Qe(e,t,n){t.isScene!==!0&&(t=pe);let r=V.get(e),i=b.state.lights,a=b.state.shadowsArray,o=i.state.version,s=xe.getParameters(e,i.state,a,t,n),c=xe.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=U.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Re),l=new Map,r.programs=l);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return et(e,s),d}else s.uniforms=xe.getUniforms(e),e.onBeforeCompile(s,w),d=xe.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=we.uniform),et(e,s),r.needsLights=rt(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 $e(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Up.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function et(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 tt(e,t,n,r,i){t.isScene!==!0&&(t=pe),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:Yr,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=U.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(ce===!0&&(le===!0||e!==A)){let t=e===A&&r.id===k;we.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!==we.numPlanes||v.numIntersection!==we.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=Qe(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(L,`projectionMatrix`,e.projectionMatrix),D.setValue(L,`viewMatrix`,e.matrixWorldInverse);let t=D.map.cameraPosition;t!==void 0&&t.setValue(L,de.setFromMatrixPosition(e.matrixWorld)),ge.logarithmicDepthBuffer&&D.setValue(L,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&D.setValue(L,`isOrthographic`,e.isOrthographicCamera===!0),A!==e&&(A=e,T=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&D.setValue(L,`directionalShadowMap`,y.state.directionalShadowMap,H),y.state.spotShadowMap.length>0&&D.setValue(L,`spotShadowMap`,y.state.spotShadowMap,H),y.state.pointShadowMap.length>0&&D.setValue(L,`pointShadowMap`,y.state.pointShadowMap,H)),i.isSkinnedMesh){D.setOptional(L,i,`bindMatrix`),D.setOptional(L,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),D.setValue(L,`boneTexture`,e.boneTexture,H))}i.isBatchedMesh&&(D.setOptional(L,i,`batchingTexture`),D.setValue(L,`batchingTexture`,i._matricesTexture,H),D.setOptional(L,i,`batchingIdTexture`),D.setValue(L,`batchingIdTexture`,i._indirectTexture,H),D.setOptional(L,i,`batchingColorTexture`),i._colorsTexture!==null&&D.setValue(L,`batchingColorTexture`,i._colorsTexture,H));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&De.update(i,n,S),(T||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,D.setValue(L,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=lh()),T&&(D.setValue(L,`toneMappingExposure`,w.toneMappingExposure),v.needsLights&&nt(j,E),a&&r.fog===!0&&Se.refreshFogUniforms(j,a),Se.refreshMaterialUniforms(j,r,P,re,b.state.transmissionRenderTarget[e.id]),Up.upload(L,$e(v),j,H)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Up.upload(L,$e(v),j,H),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&D.setValue(L,`center`,i.center),D.setValue(L,`modelViewMatrix`,i.modelViewMatrix),D.setValue(L,`normalMatrix`,i.normalMatrix),D.setValue(L,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Me.update(n,S),Me.bind(n,S)}}return S}function nt(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 rt(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 it=L.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){O=e,E=t,D=n;let r=null,i=!1,a=!1;if(e){let o=V.get(e);if(o.__useDefaultFramebuffer!==void 0){B.bindFramebuffer(L.FRAMEBUFFER,o.__webglFramebuffer),j.copy(e.viewport),M.copy(e.scissor),ee=e.scissorTest,B.viewport(j),B.scissor(M),B.setScissorTest(ee),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),ee=e.scissorTest}else j.copy(F).multiplyScalar(P).floor(),M.copy(I).multiplyScalar(P).floor(),ee=oe;if(n!==0&&(r=it),B.bindFramebuffer(L.FRAMEBUFFER,r)&&B.drawBuffers(e,r),B.viewport(j),B.scissor(M),B.setScissorTest(ee),i){let r=V.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=V.get(e.textures[t]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=V.get(e.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,t.__webglTexture,n)}k=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){li(`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(L.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!ge.textureFormatReadable(c)){li(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!ge.textureTypeReadable(l)){li(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&L.readPixels(t,n,r,i,Ae.convert(c),Ae.convert(l),a)}finally{let e=O===null?null:V.get(O).__webglFramebuffer;B.bindFramebuffer(L.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=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(L.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+s),!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=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.bufferData(L.PIXEL_PACK_BUFFER,a.byteLength,L.STREAM_READ),L.readPixels(t,n,r,i,Ae.convert(l),Ae.convert(u),0);let f=O===null?null:V.get(O).__webglFramebuffer;B.bindFramebuffer(L.FRAMEBUFFER,f);let p=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await di(L,p,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,d),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,a),L.deleteBuffer(d),L.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;H.setTexture2D(e,0),L.copyTexSubImage2D(L.TEXTURE_2D,n,0,0,o,s,i,a),B.unbindTexture()};let at=L.createFramebuffer(),ot=L.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Ae.convert(t.format),_=Ae.convert(t.type),v;t.isData3DTexture?(H.setTexture3D(t,0),v=L.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(H.setTexture2DArray(t,0),v=L.TEXTURE_2D_ARRAY):(H.setTexture2D(t,0),v=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,t.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,t.unpackAlignment);let y=L.getParameter(L.UNPACK_ROW_LENGTH),b=L.getParameter(L.UNPACK_IMAGE_HEIGHT),x=L.getParameter(L.UNPACK_SKIP_PIXELS),S=L.getParameter(L.UNPACK_SKIP_ROWS),C=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,h.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,h.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,l),L.pixelStorei(L.UNPACK_SKIP_ROWS,u),L.pixelStorei(L.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=V.get(e),r=V.get(t),h=V.get(n.__renderTarget),g=V.get(r.__renderTarget);B.bindFramebuffer(L.READ_FRAMEBUFFER,h.__webglFramebuffer),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,V.get(e).__webglTexture,i,d+n),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,V.get(t).__webglTexture,a,m+n)),L.blitFramebuffer(l,u,o,s,f,p,o,s,L.DEPTH_BUFFER_BIT,L.NEAREST);B.bindFramebuffer(L.READ_FRAMEBUFFER,null),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||V.has(e)){let n=V.get(e),r=V.get(t);B.bindFramebuffer(L.READ_FRAMEBUFFER,at),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,ot);for(let e=0;e<c;e++)w?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,n.__webglTexture,i),T?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,r.__webglTexture,a),i===0?T?L.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):L.copyTexSubImage2D(v,a,f,p,l,u,o,s):L.blitFramebuffer(l,u,o,s,f,p,o,s,L.COLOR_BUFFER_BIT,L.NEAREST);B.bindFramebuffer(L.READ_FRAMEBUFFER,null),B.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?L.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):L.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):L.texSubImage2D(L.TEXTURE_2D,a,f,p,o,s,g,_,h);L.pixelStorei(L.UNPACK_ROW_LENGTH,y),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,b),L.pixelStorei(L.UNPACK_SKIP_PIXELS,x),L.pixelStorei(L.UNPACK_SKIP_ROWS,S),L.pixelStorei(L.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&L.generateMipmap(v),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(),je.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return ei}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Yi._getDrawingBufferColorSpace(e),t.unpackColorSpace=Yi._getUnpackColorSpace()}},dh=-(2**40),fh=8;function ph(e,t){return e<0||e>=fh?dh:t*fh+e}function mh(e){return(e%fh+fh)%fh}function hh(e){return(e-mh(e))/fh}function gh(e){return e===dh?null:sn(mh(e),hh(e))}function _h(e){let t=e.indexOf(`-`);if(t<=0)return null;let n=on(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=ph(n,r);return i===dh?null:i}function vh(e){let t=new Set;for(let n of e){let e=_h(n);e!==null&&t.add(e)}return t}function yh(e){return e+7&-8}function bh(e){return{subFormat:e.getUint16(24,!0),source:e.getUint8(26),idType:e.getUint8(27),rowCount:e.getUint32(28,!0)}}function xh(e,t){return sn(e.idType,e.id[t])}function Sh(e,t){return ph(e.idType,e.id[t])}function Ch(e,t){let n=Jt,r=new Int32Array(e,n,t);n+=yh(t*4);let i=new Uint8Array(e,n,t);n+=yh(t);let a=new Int32Array(e,n,t);n+=yh(t*4);let o=new Uint8Array(e,n,t);return n+=yh(t),{id:r,objectType:i,parentId:a,scale:o,offset:n}}function wh(e,t,n){let r=n,i=new Float64Array(e,r,t);r+=t*8;let a=new Float32Array(e,r,t);r+=yh(t*4);let o=new Float32Array(e,r,t);r+=yh(t*4);let s=new Float32Array(e,r,t);r+=yh(t*4);let c=new Float32Array(e,r,t);r+=yh(t*4);let l=new Float32Array(e,r,t);r+=yh(t*4);let u=new Float32Array(e,r,t);r+=yh(t*4);let d=new Float32Array(e,r,t);r+=yh(t*4);let f=new Float32Array(e,r,t);return r+=yh(t*4),{epochJd:i,a,e:o,i:s,om:c,w:l,ma:u,n:d,radiusKm:f,offset:r}}function Th(e,t,n){let{subFormat:r,rowCount:i,source:a,idType:o}=bh(new DataView(e));if(o===nn.UNKNOWN&&i>0&&console.warn(`elements payload has unknown id-type — ${i} row(s) will lack reconstructed IDs`),r===1)return Dh(e,i,t,n,a,o);if(r===2)return Eh(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}=Ch(e,i),f=wh(e,i,d),p=f.offset,m=new Float32Array(e,p,i);p+=yh(i*4);let h=new Float32Array(e,p,i);p+=yh(i*4);let g=new Uint8Array(e,p,i);p+=yh(i);let _=new Uint8Array(e,p,i);p+=yh(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 Eh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=Ch(e,t),d=wh(e,t,u),f=d.offset,p={validityStart:n,validityEnd:r,source:i,idType:a},m=new Float32Array(e,f,t);f+=yh(t*4);let h=new Float32Array(e,f,t);f+=yh(t*4);let g=new Float32Array(e,f,t);f+=yh(t*4);let _=new Int32Array(e,f,t);f+=yh(t*4);let v=new Int32Array(e,f,t);f+=yh(t*4);let y=new Uint8Array(e,f,t);f+=yh(t);let b=new Uint8Array(e,f,t);f+=yh(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 Dh(e,t,n,r,i,a){let{id:o,objectType:s,parentId:c,scale:l,offset:u}=Ch(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+=yh(t*4);let h=new Float32Array(e,d,t);d+=yh(t*4);let g=new Float32Array(e,d,t);d+=yh(t*4);let _=new Float32Array(e,d,t);d+=yh(t*4);let v=new Float32Array(e,d,t);d+=yh(t*4);let y=new Float64Array(e,d,t);d+=t*8;let b=new Float32Array(e,d,t);d+=yh(t*4);let x=new Uint8Array(e,d,t);d+=yh(t);let S=new Uint8Array(e,d,t);return d+=yh(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 Oh=Math.PI,kh=Oh*2,Ah=Oh/180;180/Oh;var jh=398600.8,Mh=6378.135,Nh=60/Math.sqrt(Mh*Mh*Mh/jh),Ph=Mh*Nh/60,Fh=1/Nh,Ih=.001082616,Lh=-253881e-11,Rh=-165597e-11,zh=Lh/Ih,Bh=2/3,Vh=1440/(2*Oh);function Hh(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 Uh(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 Wh(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return Uh(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return Uh(e,t,n,r,i,a,o)}function Gh(e,t){let{e3:n,ee2:r,peo:i,pgho:a,pho:o,pinco:s,plo:c,se2:l,se3:u,sgh2:d,sgh3:f,sgh4:p,sh2:m,sh3:h,si2:g,si3:_,sl2:v,sl3:y,sl4:b,t:x,xgh2:S,xgh3:C,xgh4:w,xh2:T,xh3:E,xi2:D,xi3:O,xl2:k,xl3:A,xl4:j,zmol:M,zmos:ee}=e,{init:N,opsmode:te}=t,{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}=t,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,R,z,ge,B,_e,V,H,U;U=ee+119459e-10*x,N===`y`&&(U=ee),H=U+2*.01675*Math.sin(U),B=Math.sin(H),pe=.5*B*B-.25,me=-.5*B*Math.cos(H);let ve=l*pe+u*me,ye=g*pe+_*me,be=v*pe+y*me+b*B,xe=d*pe+f*me+p*B,Se=m*pe+h*me;U=M+.00015835218*x,N===`y`&&(U=M),H=U+2*.0549*Math.sin(U),B=Math.sin(H),pe=.5*B*B-.25,me=-.5*B*Math.cos(H);let Ce=r*pe+n*me,W=D*pe+O*me,we=k*pe+A*me+j*B,Te=S*pe+C*me+w*B,Ee=T*pe+E*me;return he=ve+Ce,z=ye+W,ge=be+we,L=xe+Te,R=Se+Ee,N===`n`&&(he-=i,z-=s,ge-=c,L-=a,R-=o,re+=z,ne+=he,se=Math.sin(re),oe=Math.cos(re),re>=.2?(R/=se,L-=oe*R,ie+=L,P+=R,ae+=ge):(le=Math.sin(P),ce=Math.cos(P),F=se*le,I=se*ce,ue=R*ce+z*oe*le,de=-R*le+z*oe*ce,F+=ue,I+=de,P%=kh,P<0&&te===`a`&&(P+=kh),_e=ae+ie+oe*P,fe=ge+L-z*P*se,_e+=fe,V=P,P=Math.atan2(F,I),P<0&&te===`a`&&(P+=kh),Math.abs(V-P)>Oh&&(P<V?P+=kh:P-=kh),ae+=ge,ie=_e-ae-oe*P)),{ep:ne,inclp:re,nodep:P,argpp:ie,mp:ae}}function Kh(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:o,np:s}=e,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,R,z,ge,B,_e,V,H,U,ve,ye,be,xe,Se,Ce,W,we,Te,Ee=.01675,De=.0549,Oe=s,ke=n,Ae=Math.sin(o),je=Math.cos(o),Me=Math.sin(r),Ne=Math.cos(r),Pe=Math.sin(a),Fe=Math.cos(a),Ie=ke*ke,Le=1-Ie,Re=Math.sqrt(Le),ze=t+18261.5+i/1440,Be=(4.523602-.00092422029*ze)%kh,Ve=Math.sin(Be),He=Math.cos(Be),Ue=.91375164-.03568096*He,We=Math.sqrt(1-Ue*Ue),Ge=.089683511*Ve/We,Ke=Math.sqrt(1-Ge*Ge),qe=5.8351514+.001944368*ze,Je=.39785416*Ve/We,Ye=Ke*He+.91744867*Ge*Ve;Je=Math.atan2(Je,Ye),Je+=qe-Be;let Xe=Math.cos(Je),Ze=Math.sin(Je);D=.1945905,O=-.98088458,j=.91744867,M=.39785416,k=je,A=Ae,v=29864797e-13;let Qe=1/Oe,$e=0;for(;$e<2;)$e+=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=Fe*m+Pe*h,d=Fe*g+Pe*_,f=-Pe*m+Fe*h,p=-Pe*g+Fe*_,y=c*Ne+l*Me,b=u*Ne+d*Me,x=-c*Me+l*Ne,S=-u*Me+d*Ne,C=f*Me,w=p*Me,T=f*Ne,E=p*Ne,W=12*y*y-3*x*x,we=24*y*b-6*x*S,Te=12*b*b-3*S*S,V=3*(c*c+l*l)+W*Ie,H=6*(c*u+l*d)+we*Ie,U=3*(u*u+d*d)+Te*Ie,ve=-6*c*f+Ie*(-24*y*T-6*x*C),ye=-6*(c*p+u*f)+Ie*(-24*(b*T+y*E)+-6*(x*w+S*C)),be=-6*u*p+Ie*(-24*b*E-6*S*w),xe=6*l*f+Ie*(24*y*C-6*x*T),Se=6*(d*f+l*p)+Ie*(24*(b*C+y*w)-6*(S*T+x*E)),Ce=6*d*p+Ie*(24*b*w-6*S*E),V=V+V+Le*W,H=H+H+Le*we,U=U+U+Le*Te,R=v*Qe,L=-.5*R/Re,z=R*Re,he=-15*ke*z,ge=y*x+b*S,B=b*x+y*S,_e=b*S-y*x,$e===1&&(ee=he,N=L,te=R,ne=z,re=ge,P=B,ie=_e,ae=V,F=H,I=U,oe=ve,se=ye,ce=be,le=xe,ue=Se,de=Ce,fe=W,pe=we,me=Te,D=Xe,O=Ze,j=Ue,M=We,k=Ke*je+Ge*Ae,A=Ae*Ke-je*Ge,v=4.7968065e-7);let et=(4.7199672+(.2299715*ze-qe))%kh,tt=(6.2565837+.017201977*ze)%kh,nt=2*ee*P,rt=2*ee*ie,it=2*N*se,at=2*N*(ce-oe),ot=-2*te*F,st=-2*te*(I-ae),ct=-2*te*(-21-9*Ie)*Ee,lt=2*ne*pe,ut=2*ne*(me-fe),dt=-18*ne*Ee,ft=-2*N*ue,pt=-2*N*(de-le),mt=2*he*B,ht=2*he*_e,gt=2*L*ye,_t=2*L*(be-ve),vt=-2*R*H,yt=-2*R*(U-V),bt=-2*R*(-21-9*Ie)*De,xt=2*z*we,St=2*z*(Te-W),Ct=-18*z*De,wt=-2*L*Se,Tt=-2*L*(Ce-xe);return{snodm:Ae,cnodm:je,sinim:Pe,cosim:Fe,sinomm:Me,cosomm:Ne,day:ze,e3:ht,ee2:mt,em:ke,emsq:Ie,gam:qe,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Re,se2:nt,se3:rt,sgh2:lt,sgh3:ut,sgh4:dt,sh2:ft,sh3:pt,si2:it,si3:at,sl2:ot,sl3:st,sl4:ct,s1:he,s2:L,s3:R,s4:z,s5:ge,s6:B,s7:_e,ss1:ee,ss2:N,ss3:te,ss4:ne,ss5:re,ss6:P,ss7:ie,sz1:ae,sz2:F,sz3:I,sz11:oe,sz12:se,sz13:ce,sz21:le,sz22:ue,sz23:de,sz31:fe,sz32:pe,sz33:me,xgh2:xt,xgh3:St,xgh4:Ct,xh2:wt,xh3:Tt,xi2:gt,xi3:_t,xl2:vt,xl3:yt,xl4:bt,nm:Oe,z1:V,z2:H,z3:U,z11:ve,z12:ye,z13:be,z21:xe,z22:Se,z23:Ce,z31:W,z32:we,z33:Te,zmol:et,zmos:tt}}function qh(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:a,s4:o,s5:s,sinim:c,ss1:l,ss2:u,ss3:d,ss4:f,ss5:p,sz1:m,sz3:h,sz11:g,sz13:_,sz21:v,sz23:y,sz31:b,sz33:x,t:S,tc:C,gsto:w,mo:T,mdot:E,no:D,nodeo:O,nodedot:k,xpidot:A,z1:j,z3:M,z11:ee,z13:N,z21:te,z23:ne,z31:re,z33:P,ecco:ie,eccsq:ae}=e,{emsq:F,em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:R,d4422:z,d5220:ge,d5232:B,d5421:_e,d5433:V,dedt:H,didt:U,dmdt:ve,dnodt:ye,domdt:be,del1:xe,del2:Se,del3:Ce,xfact:W,xlamo:we,xli:Te,xni:Ee}=e,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,tt,nt,rt,it,at=.0043752690880113,ot=.00015835218,st=119459e-10;de=0,le<.0052359877&&le>.0034906585&&(de=1),le>=.00826&&le<=.00924&&I>=.5&&(de=2);let ct=l*st*p,lt=u*st*(g+_),ut=-st*d*(m+h-14-6*F),dt=f*st*(b+x-6),ft=-st*u*(v+y);(se<.052359877||se>Oh-.052359877)&&(ft=0),c!==0&&(ft/=c);let pt=dt-t*ft;H=ct+r*ot*s,U=lt+i*ot*(ee+N),ve=ut-ot*a*(j+M-14-6*F);let mt=o*ot*(re+P-6),ht=-ot*i*(te+ne);(se<.052359877||se>Oh-.052359877)&&(ht=0),be=pt+mt,ye=ft,c!==0&&(be-=t/c*ht,ye+=ht/c);let gt=(w+C*at)%kh;if(I+=H*S,se+=U*S,oe+=be*S,ue+=ye*S,ce+=ve*S,de!==0){if(nt=(le/Nh)**Bh,de===2){rt=t*t;let e=I;I=ie;let n=F;F=ae,it=I*F,Be=-.306-(I-.64)*.44,I<=.65?(Ve=3.616-13.247*I+16.29*F,Ue=-19.302+117.39*I-228.419*F+156.591*it,We=-18.9068+109.7927*I-214.6334*F+146.5816*it,Ge=-41.122+242.694*I-471.094*F+313.953*it,Ke=-146.407+841.88*I-1629.014*F+1083.435*it,qe=-532.114+3017.977*I-5740.032*F+3708.276*it):(Ve=-72.099+331.819*I-508.738*F+266.724*it,Ue=-346.844+1582.851*I-2415.925*F+1246.113*it,We=-342.585+1554.908*I-2366.899*F+1215.972*it,Ge=-1052.797+4758.686*I-7193.992*F+3651.957*it,Ke=-3581.69+16178.11*I-24462.77*F+12422.52*it,qe=I>.715?-5149.66+29936.92*I-54087.36*F+31324.56*it:1464.74-4664.75*I+3763.64*F),I<.7?(Xe=-919.2277+4988.61*I-9064.77*F+5542.21*it,Je=-822.71072+4568.6173*I-8491.4146*F+5337.524*it,Ye=-853.666+4690.25*I-8624.77*F+5341.4*it):(Xe=-37995.78+161616.52*I-229838.2*F+109377.94*it,Je=-51752.104+218913.95*I-309468.16*F+146349.42*it,Ye=-40023.88+170470.89*I-242699.48*F+115605.82*it),Ze=c*c,De=.75*(1+2*t+rt),Oe=1.5*Ze,Ae=1.875*c*(1-2*t-3*rt),je=-1.875*c*(1+2*t-3*rt),Ne=35*Ze*De,Pe=39.375*Ze*Ze,Fe=9.84375*c*(Ze*(1-2*t-5*rt)+.33333333*(-2+4*t+6*rt)),Ie=c*(4.92187512*Ze*(-2-4*t+10*rt)+6.56250012*(1+2*t-3*rt)),Le=29.53125*c*(2-8*t+rt*(-12+8*t+10*rt)),Re=29.53125*c*(-2-8*t+rt*(12+8*t-10*rt)),et=le*le,tt=nt*nt,$e=3*et*tt,Qe=$e*17891679e-13,pe=Qe*De*Be,me=Qe*Oe*Ve,$e*=nt,Qe=$e*3.7393792e-7,he=Qe*Ae*Ue,L=Qe*je*We,$e*=nt,Qe=2*$e*7.3636953e-9,R=Qe*Ne*Ge,z=Qe*Pe*Ke,$e*=nt,Qe=$e*1.1428639e-7,ge=Qe*Fe*qe,B=Qe*Ie*Ye,Qe=2*$e*2.1765803e-9,_e=Qe*Le*Je,V=Qe*Re*Xe,we=(T+O+O-(gt+gt))%kh,W=E+ve+2*(k+ye-at)-D,I=e,F=n}de===1&&(ze=1+F*(-2.5+.8125*F),Ue=1+2*F,He=1+F*(-6+6.60937*F),De=.75*(1+t)*(1+t),ke=.9375*c*c*(1+3*t)-.75*(1+t),Me=1+t,Me*=1.875*Me*Me,xe=3*le*le*nt*nt,Se=2*xe*De*ze*17891679e-13,Ce=3*xe*Me*He*2.2123015e-7*nt,xe=xe*ke*Ue*21460748e-13*nt,we=(T+O+n-gt)%kh,W=E+A+ve+be+ye-(D+at)),Te=we,Ee=D,fe=0,le=D+0}return{em:I,argpm:oe,inclm:se,mm:ce,nm:le,nodem:ue,irez:de,atime:fe,d2201:pe,d2211:me,d3210:he,d3222:L,d4410:R,d4422:z,d5220:ge,d5232:B,d5421:_e,d5433:V,dedt:H,didt:U,dmdt:ve,dndt:0,dnodt:ye,domdt:be,del1:xe,del2:Se,del3:Ce,xfact:W,xlamo:we,xli:Te,xni:Ee}}function Jh(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*Ah/240%kh,n<0&&(n+=kh),n}function Yh(e,t,n,r,i,a,o){return e instanceof Date?Jh(Wh(e)):Jh(t===void 0?e:Wh(e,t,n,r,i,a,o))}function Xh(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=(Nh/a)**Bh,f=.75*Ih*(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=(Nh/a)**Bh,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+kh;C=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%kh,C<0&&(C+=kh)}else C=Yh(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 Zh(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:o,d4422:s,d5220:c,d5232:l,d5421:u,d5433:d,dedt:f,del1:p,del2:m,del3:h,didt:g,dmdt:_,dnodt:v,domdt:y,argpo:b,argpdot:x,t:S,tc:C,gsto:w,xfact:T,xlamo:E,no:D}=e,{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,nm:ne}=e,re=.13130908,P=2.8843198,ie=.37448087,ae=5.7686396,F=.95240898,I=1.8014998,oe=1.050833,se=4.4108898,ce=259200,le,ue,de,fe,pe,me,he,L,R=0,z=0,ge=(w+C*.0043752690880113)%kh;if(k+=f*S,j+=g*S,A+=y*S,te+=v*S,ee+=_*S,t!==0){(O===0||S*O<=0||Math.abs(S)<Math.abs(O))&&(O=0,N=D,M=E),le=S>0?720:-720;let e=381;for(;e===381;)t===2?(L=b+x*O,de=L+L,ue=M+M,he=n*Math.sin(de+M-ae)+r*Math.sin(M-ae)+i*Math.sin(L+M-F)+a*Math.sin(-L+M-F)+o*Math.sin(de+ue-I)+s*Math.sin(ue-I)+c*Math.sin(L+M-oe)+l*Math.sin(-L+M-oe)+u*Math.sin(L+ue-se)+d*Math.sin(-L+ue-se),pe=N+T,me=n*Math.cos(de+M-ae)+r*Math.cos(M-ae)+i*Math.cos(L+M-F)+a*Math.cos(-L+M-F)+c*Math.cos(L+M-oe)+l*Math.cos(-L+M-oe)+2*(o*Math.cos(de+ue-I)+s*Math.cos(ue-I)+u*Math.cos(L+ue-se)+d*Math.cos(-L+ue-se)),me*=pe):(he=p*Math.sin(M-re)+m*Math.sin(2*(M-P))+h*Math.sin(3*(M-ie)),pe=N+T,me=p*Math.cos(M-re)+2*m*Math.cos(2*(M-P))+3*h*Math.cos(3*(M-ie)),me*=pe),Math.abs(S-O)>=720?e=381:(z=S-O,e=0),e===381&&(M+=pe*le+he*ce,N+=he*le+me*ce,O+=le);ne=N+he*z+me*z*z*.5,fe=M+pe*z+he*z*z*.5,t===1?(ee=fe-te-A+ge,R=ne-D):(ee=fe-2*te+2*ge,R=ne-D),ne=D+R}return{atime:O,em:k,argpm:A,inclm:j,xli:M,mm:ee,xni:N,nodem:te,dndt:R,nm:ne}}var Qh;(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`})(Qh||={});function $h(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=Qh.None;let k=e.mo+e.mdot*e.t,A=e.argpo+e.argpdot*e.t,j=e.nodeo+e.nodedot*e.t;u=A,S=k;let M=e.t*e.t;if(w=j+e.nodecf*M,v=1-e.cc1*e.t,y=e.bstar*e.cc4*e.t,b=e.t2cof*M,e.isimp!==1){c=e.omgcof*e.t;let t=1+e.eta*Math.cos(k);s=e.xmcof*(t*t*t-e.delmo),_=c+s,S=k+_,u=A-_,p=M*e.t,m=p*e.t,v=v-e.d2*M-e.d3*p-e.d4*m,y+=e.bstar*e.cc5*(Math.sin(S)-e.sinmao),b=b+e.t3cof*p+m*(e.t4cof+e.t*e.t5cof)}C=e.no;let ee=e.ecco;if(x=e.inclo,e.method===`d`){h=e.t;let t=Zh({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:h,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:ee,argpm:u,inclm:x,xli:e.xli,mm:S,xni:e.xni,nodem:w,nm:C});({em:ee,argpm:u,inclm:x,mm:S,nodem:w,nm:C}=t)}if(C<=0)return e.error=Qh.MeanMotionBelowZero,null;let N=(Nh/C)**Bh*v*v;if(C=Nh/N**1.5,ee-=y,ee>=1||ee<-.001)return e.error=Qh.MeanEccentricityOutOfRange,null;ee<1e-6&&(ee=1e-6),S+=e.no*b,E=S+u+w,w%=kh,u%=kh,E%=kh,S=(E-u-w)%kh;let te={am:N,em:ee,im:x,Om:w,om:u,mm:S,nm:C},ne=Math.sin(x),re=Math.cos(x),P=ee;if(T=x,d=u,O=w,D=S,a=ne,i=re,e.method===`d`){let t=Gh(e,{inclo:e.inclo,init:`n`,ep:P,inclp:T,nodep:O,argpp:d,mp:D,opsmode:e.operationmode});if({ep:P,nodep:O,argpp:d,mp:D}=t,T=t.inclp,T<0&&(T=-T,O+=Oh,d-=Oh),P<0||P>1)return e.error=Qh.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(a=Math.sin(T),i=Math.cos(T),e.aycof=-.5*zh*a,Math.abs(i+1)>15e-13?e.xlcof=-.25*zh*a*(3+5*i)/(1+i):e.xlcof=-.25*zh*a*(3+5*i)/15e-13);let ie=P*Math.cos(d);_=1/(N*(1-P*P));let ae=P*Math.sin(d)+_*e.aycof,F=(D+d+O+_*e.xlcof*ie-O)%kh;l=F,g=9999.9;let I=1;for(;Math.abs(g)>=1e-12&&I<=10;)r=Math.sin(l),n=Math.cos(l),g=1-n*ie-r*ae,g=(F-ae*n+ie*r-l)/g,Math.abs(g)>=.95&&(g=g>0?.95:-.95),l+=g,I+=1;let oe=ie*n+ae*r,se=ie*r-ae*n,ce=ie*ie+ae*ae,le=N*(1-ce);if(le<0)return e.error=Qh.SemiLatusRectumBelowZero,null;let ue=N*(1-oe),de=Math.sqrt(N)*se/ue,fe=Math.sqrt(le)/ue,pe=Math.sqrt(1-ce);_=se/(1+pe);let me=N/ue*(r-ae-ie*_),he=N/ue*(n-ie+ae*_);f=Math.atan2(me,he);let L=(he+he)*me,R=1-2*me*me;_=1/le;let z=.5*Ih*_,ge=z*_;e.method===`d`&&(o=i*i,e.con41=3*o-1,e.x1mth2=1-o,e.x7thm1=7*o-1);let B=ue*(1-1.5*ge*pe*e.con41)+.5*z*e.x1mth2*R;if(B<1)return e.error=Qh.Decayed,null;f-=.25*ge*e.x7thm1*L;let _e=O+1.5*ge*i*L,V=T+1.5*ge*i*a*R,H=de-C*z*e.x1mth2*L/Nh,U=fe+C*z*(e.x1mth2*R+1.5*e.con41)/Nh,ve=Math.sin(f),ye=Math.cos(f),be=Math.sin(_e),xe=Math.cos(_e),Se=Math.sin(V),Ce=Math.cos(V),W=-be*Ce,we=xe*Ce,Te=W*ve+xe*ye,Ee=we*ve+be*ye,De=Se*ve,Oe=W*ye-xe*ve,ke=we*ye-be*ve,Ae=Se*ye;return{position:{x:B*Te*Mh,y:B*Ee*Mh,z:B*De*Mh},velocity:{x:(H*Te+U*Oe)*Ph,y:(H*Ee+U*ke)*Ph,z:(H*De+U*Ae)*Ph},meanElements:te}}function eg(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:a,xecco:o,xargpo:s,xinclo:c,xmo:l,xno:u,xnodeo:d}=t,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N,te,ne,re,P,ie,ae,F,I,oe,se,ce,le,ue,de,fe,pe,me,he,L,R,z,ge,B,_e,V,H,U,ve,ye,be,xe,Se,Ce,W=e;W.isimp=0,W.method=`n`,W.aycof=0,W.con41=0,W.cc1=0,W.cc4=0,W.cc5=0,W.d2=0,W.d3=0,W.d4=0,W.delmo=0,W.eta=0,W.argpdot=0,W.omgcof=0,W.sinmao=0,W.t=0,W.t2cof=0,W.t3cof=0,W.t4cof=0,W.t5cof=0,W.x1mth2=0,W.x7thm1=0,W.mdot=0,W.nodedot=0,W.xlcof=0,W.xmcof=0,W.nodecf=0,W.irez=0,W.d2201=0,W.d2211=0,W.d3210=0,W.d3222=0,W.d4410=0,W.d4422=0,W.d5220=0,W.d5232=0,W.d5421=0,W.d5433=0,W.dedt=0,W.del1=0,W.del2=0,W.del3=0,W.didt=0,W.dmdt=0,W.dnodt=0,W.domdt=0,W.e3=0,W.ee2=0,W.peo=0,W.pgho=0,W.pho=0,W.pinco=0,W.plo=0,W.se2=0,W.se3=0,W.sgh2=0,W.sgh3=0,W.sgh4=0,W.sh2=0,W.sh3=0,W.si2=0,W.si3=0,W.sl2=0,W.sl3=0,W.sl4=0,W.gsto=0,W.xfact=0,W.xgh2=0,W.xgh3=0,W.xgh4=0,W.xh2=0,W.xh3=0,W.xi2=0,W.xi3=0,W.xl2=0,W.xl3=0,W.xl4=0,W.xlamo=0,W.zmol=0,W.zmos=0,W.atime=0,W.xli=0,W.xni=0,W.bstar=a,W.ecco=o,W.argpo=s,W.inclo=c,W.mo=l,W.no=u,W.nodeo=d,W.operationmode=n;let we=78/Mh+1,Te=42/Mh,Ee=Te*Te*Te*Te;W.init=`y`,W.t=0;let De=Xh({satn:r,ecco:W.ecco,epoch:i,inclo:W.inclo,no:W.no,method:W.method,opsmode:W.operationmode}),{ao:Oe,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=De;if(W.no=De.no,W.con41=De.con41,W.gsto=De.gsto,W.a=(W.no*Fh)**(-2/3),W.alta=W.a*(1+W.ecco)-1,W.altp=W.a*(1-W.ecco)-1,W.error=0,Ne>=0||W.no>=0){if(W.isimp=0,Fe<1.034492841559484&&(W.isimp=1),P=we,M=Ee,k=(Fe-1)*Mh,k<156){P=k-78,k<98&&(P=20);let e=(120-P)/Mh;M=e*e*e*e,P=P/Mh+1}A=1/Pe,B=1/(Oe-P),W.eta=Oe*W.ecco*B,C=W.eta*W.eta,S=W.ecco*W.eta,j=Math.abs(1-C),_=M*B**4,v=_/j**3.5,h=v*W.no*(Oe*(1+1.5*C+S*(4+C))+.375*Ih*B/j*W.con41*(8+3*C*(8+C))),W.cc1=W.bstar*h,g=0,W.ecco>1e-4&&(g=-2*_*B*zh*W.no*Le/W.ecco),W.x1mth2=1-je,W.cc4=2*W.no*v*Oe*Ne*(W.eta*(2+.5*C)+W.ecco*(.5+2*C)-Ih*B/(Oe*j)*(-3*W.con41*(1-2*S+C*(1.5-.5*S))+.75*W.x1mth2*(2*C-S*(1+C))*Math.cos(2*W.argpo))),W.cc5=2*v*Oe*Ne*(1+2.75*(C+S)+S*C),y=je*je,R=1.5*Ih*A*W.no,z=.5*R*Ih*A,ge=-.46875*Rh*A*A*W.no,W.mdot=W.no+.5*R*Ie*W.con41+.0625*z*Ie*(13-78*je+137*y),W.argpdot=-.5*R*ke+.0625*z*(7-114*je+395*y)+ge*(3-36*je+49*y),V=-R*Ae,W.nodedot=V+(.5*z*(4-19*je)+2*ge*(3-7*je))*Ae,_e=W.argpdot+W.nodedot,W.omgcof=W.bstar*g*Math.cos(W.argpo),W.xmcof=0,W.ecco>1e-4&&(W.xmcof=-Bh*_*W.bstar/S),W.nodecf=3.5*Ne*V*W.cc1,W.t2cof=1.5*W.cc1,Math.abs(Ae+1)>15e-13?W.xlcof=-.25*zh*Le*(3+5*Ae)/(1+Ae):W.xlcof=-.25*zh*Le*(3+5*Ae)/15e-13,W.aycof=-.5*zh*Le;let e=1+W.eta*Math.cos(W.mo);if(W.delmo=e*e*e,W.sinmao=Math.sin(W.mo),W.x7thm1=7*je-1,2*Oh/W.no>=225){W.method=`d`,W.isimp=1,he=0,E=W.inclo;let e=Kh({epoch:i,ep:W.ecco,argpp:W.argpo,tc:he,inclp:W.inclo,nodep:W.nodeo,np:W.no,e3:W.e3,ee2:W.ee2,peo:W.peo,pgho:W.pgho,pho:W.pho,pinco:W.pinco,plo:W.plo,se2:W.se2,se3:W.se3,sgh2:W.sgh2,sgh3:W.sgh3,sgh4:W.sgh4,sh2:W.sh2,sh3:W.sh3,si2:W.si2,si3:W.si3,sl2:W.sl2,sl3:W.sl3,sl4:W.sl4,xgh2:W.xgh2,xgh3:W.xgh3,xgh4:W.xgh4,xh2:W.xh2,xh3:W.xh3,xi2:W.xi2,xi3:W.xi3,xl2:W.xl2,xl3:W.xl3,xl4:W.xl4,zmol:W.zmol,zmos:W.zmos});W.e3=e.e3,W.ee2=e.ee2,W.peo=e.peo,W.pgho=e.pgho,W.pho=e.pho,W.pinco=e.pinco,W.plo=e.plo,W.se2=e.se2,W.se3=e.se3,W.sgh2=e.sgh2,W.sgh3=e.sgh3,W.sgh4=e.sgh4,W.sh2=e.sh2,W.sh3=e.sh3,W.si2=e.si2,W.si3=e.si3,W.sl2=e.sl2,W.sl3=e.sl3,W.sl4=e.sl4,{sinim:p,cosim:f,em:b,emsq:x,s1:ee,s2:N,s3:te,s4:ne,s5:re,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me}=e,W.xgh2=e.xgh2,W.xgh3=e.xgh3,W.xgh4=e.xgh4,W.xh2=e.xh2,W.xh3=e.xh3,W.xi2=e.xi2,W.xi3=e.xi3,W.xl2=e.xl2,W.xl3=e.xl3,W.xl4=e.xl4,W.zmol=e.zmol,W.zmos=e.zmos,{nm:O,z1:H,z3:U,z11:ve,z13:ye,z21:be,z23:xe,z31:Se,z33:Ce}=e;let t=Gh(W,{inclo:E,init:W.init,ep:W.ecco,inclp:W.inclo,nodep:W.nodeo,argpp:W.argpo,mp:W.mo,opsmode:W.operationmode});W.ecco=t.ep,W.inclo=t.inclp,W.nodeo=t.nodep,W.argpo=t.argpp,W.mo=t.mp,w=0,T=0,D=0;let n=qh({cosim:f,emsq:x,argpo:W.argpo,s1:ee,s2:N,s3:te,s4:ne,s5:re,sinim:p,ss1:ie,ss2:ae,ss3:F,ss4:I,ss5:oe,sz1:se,sz3:ce,sz11:le,sz13:ue,sz21:de,sz23:fe,sz31:pe,sz33:me,t:W.t,tc:he,gsto:W.gsto,mo:W.mo,mdot:W.mdot,no:W.no,nodeo:W.nodeo,nodedot:W.nodedot,xpidot:_e,z1:H,z3:U,z11:ve,z13:ye,z21:be,z23:xe,z31:Se,z33:Ce,ecco:W.ecco,eccsq:Me,em:b,argpm:w,inclm:E,mm:D,nm:O,nodem:T,irez:W.irez,atime:W.atime,d2201:W.d2201,d2211:W.d2211,d3210:W.d3210,d3222:W.d3222,d4410:W.d4410,d4422:W.d4422,d5220:W.d5220,d5232:W.d5232,d5421:W.d5421,d5433:W.d5433,dedt:W.dedt,didt:W.didt,dmdt:W.dmdt,dnodt:W.dnodt,domdt:W.domdt,del1:W.del1,del2:W.del2,del3:W.del3,xfact:W.xfact,xlamo:W.xlamo,xli:W.xli,xni:W.xni});W.irez=n.irez,W.atime=n.atime,W.d2201=n.d2201,W.d2211=n.d2211,W.d3210=n.d3210,W.d3222=n.d3222,W.d4410=n.d4410,W.d4422=n.d4422,W.d5220=n.d5220,W.d5232=n.d5232,W.d5421=n.d5421,W.d5433=n.d5433,W.dedt=n.dedt,W.didt=n.didt,W.dmdt=n.dmdt,W.dnodt=n.dnodt,W.domdt=n.domdt,W.del1=n.del1,W.del2=n.del2,W.del3=n.del3,W.xfact=n.xfact,W.xlamo=n.xlamo,W.xli=n.xli,W.xni=n.xni}W.isimp!==1&&(m=W.cc1*W.cc1,W.d2=4*Oe*B*m,L=W.d2*B*W.cc1/3,W.d3=(17*Oe+P)*L,W.d4=.5*L*Oe*B*(221*Oe+31*P)*W.cc1,W.t3cof=W.d2+2*m,W.t4cof=.25*(3*W.d3+W.cc1*(12*W.d2+10*m)),W.t5cof=.2*(3*W.d4+12*W.cc1*W.d3+6*W.d2*W.d2+15*m*(2*W.d2+m)))}$h(W,0),W.init=`n`}function tg(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))*Ah,l=parseFloat(t.substring(17,25))*Ah,u=parseFloat(`.${t.substring(26,33).replace(/\s/g,`0`)}`),d=parseFloat(t.substring(34,42))*Ah,f=parseFloat(t.substring(43,51))*Ah,p=parseFloat(t.substring(52,63))/Vh;a/=Vh*1440,o/=Vh*1440*1440;let m=r<57?r+2e3:r+1900,{mon:h,day:g,hr:_,minute:v,sec:y}=Hh(m,i),b=Wh(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 eg(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 ng(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/=Vh*1440,c/=Vh*1440*1440;let l=Number(e.BSTAR),u=Number(e.INCLINATION)*Ah,d=Number(e.RA_OF_ASC_NODE)*Ah,f=Number(e.ECCENTRICITY),p=Number(e.ARG_OF_PERICENTER)*Ah,m=Number(e.MEAN_ANOMALY)*Ah,h=Number(e.MEAN_MOTION)/Vh,{mon:g,day:_,hr:v,minute:y,sec:b}=Hh(i,o),x=Wh(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 eg(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 rg=149597870.7,ig=23.4392911,ag=86400**2/rg**3,og=1/rg;function Q(e){return e/rg*10}function sg(e){return e/10*rg}var cg=Math.cos(Math.PI/180*ig),lg=Math.sin(Math.PI/180*ig);function ug(e,t,n,r){let i=r??{x:0,y:0,z:0};return i.x=e,i.y=-t*lg+n*cg,i.z=-(t*cg+n*lg),i}var dg=Math.PI/180,fg=Math.cos(ig*dg),pg=Math.sin(ig*dg),mg=2440587.5;function hg(e){return new Date((e-mg)*864e5).toISOString()}function gg(e,t){let n=ng({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:hg(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===Qh.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}function _g(e,t){let n=$h(e,(t-e.jdsatepoch)*1440);if(!n||e.error!==Qh.None)return null;let{x:r,y:i,z:a}=n.position;return[r,i,a]}function vg(e,t,n){let r=10/rg,i=e*r,a=t*r,o=n*r,s=a*fg+o*pg,c=-a*pg+o*fg;return a=s,o=c,[i,o,-a]}function yg(e,t){let n=_g(e,t);return n?vg(n[0],n[1],n[2]):null}function bg(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 xg=700;function Sg(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>xg)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 Cg(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 wg=null,Tg=null;function Eg(){if(!Tg){wg=[];let e=new MessageChannel;e.port1.onmessage=()=>wg.shift()?.(),Tg=e.port2}return new Promise(e=>{wg.push(e),Tg.postMessage(null)})}var Dg=2451545,Og=86400,kg=2440587.5,Ag=864e5;function jg(e){return e/Ag+kg}function Mg(e){return jg(e.getTime())}function Ng(e){return new Date((e-kg)*Ag)}function Pg(e){return(e-Dg)*Og}function Fg(e){return Dg+e/Og}var Ig=Math.PI/180;Math.cos(ig*Ig),Math.sin(ig*Ig),10/rg;function Lg(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 Rg(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 Lg(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 zg(e,t,n=!1){let r=e.length,i=Hg(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 Eg(),s=performance.now()),!Rg(i,n,e[n],t))continue;let r=e[n].data;r.validityStart<a&&(a=r.validityStart),r.validityEnd>o&&(o=r.validityEnd)}return i.validityStart=a===1/0?-1/0:a,i.validityEnd=o===-1/0?1/0:o,i}var Bg=[{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 Vg(e){let t=[];for(let n of Bg)n.transferable!==!1&&t.push(e[n.name].buffer);return t}function Hg(e){let t={count:e,applyFlagFilter:!1,validityStart:-1/0,validityEnd:1/0,pickBase:0};for(let n of Bg)t[n.name]=n.make(e);return t}function Ug(e,t){return e.get(t)?.name||null}function Wg(e,t){return e.get(t)?.isMinor??!1}function Gg(e,t){let n=e.get(t);return{name:n?.name||null,isMinor:n?.isMinor??!1}}function Kg(e,t,n,r){let i=e.scale[t]===en.PLANET,a=e.omDot[t],o=e.wDot[t],s=xh(e,t);if(s===null)return null;let{name:c,isMinor:l}=Gg(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]/rg: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 qg(e,t,n,r){let i=xh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Gg(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 Jg=new WeakMap,Yg=new WeakMap;function Xg(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 Zg={get omm(){let e=Yg.get(this);return e&&Xg(e[0],e[1])},get satrec(){let e=this,t=Jg.get(e);return t===void 0&&(t=gg(e.omm,e.name??void 0),Jg.set(e,t),t||(e.unplaceable=!0)),t??void 0}};function Qg(e,t,n,r){let i=xh(e,t);if(i===null)return null;let{name:a,isMinor:o}=Gg(n,i),s=Object.assign(Object.create(Zg),{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]/rg,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 Yg.set(s,[e,t]),s}function $g(e,t,n,r){return e.kind===`parabolic`?qg(e,t,n,r):e.kind===`sgp4`?Qg(e,t,n,r):Kg(e,t,n,r)}function e_(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,Lg(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],Lg(n,r,e.a[t]/rg,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]===en.PLANET,s=o?e.a[t]/rg:e.a[t];return s!==0&&isFinite(s)?(n.kind[r]=1,Lg(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 t_={"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`},n_=`#cccccc`,r_=`#fcb493`,i_=`#c7ccda`,a_=`#ffe89e`,o_=`#ccb49a`,s_=`#d8ffe8`,c_=`#e8a85c`,l_=`#bed4ec`,u_=`#d5cfe7`,d_=`naif-10`,f_=`naif-399`,p_=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 m_(e){if(t_[e.id])return t_[e.id];let{objectType:t,parentId:n}=e;if(t===G.BARYCENTER){if(e.id===`naif-0`)return t_[`naif-10`];if(e.id===`naif-9`)return t_[`naif-999`];let t=`naif-${e.id.replace(`naif-`,``)}99`;if(t_[t])return t_[t]}if(t===G.STAR)return a_;if(t===G.PLANET||t===G.DWARF_PLANET)return r_;if(t===G.MOON)return i_;if(hn(t))return o_;if(t===G.COMET)return s_;if(t===G.DEBRIS)return c_;if(t===G.SPACECRAFT){if(n===`naif-399`)return l_;if(n===`naif-0`||n===`naif-10`)return u_}return n_}var h_=`#6b6b6b`;function g_(e){return e.color??h_}function __(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t>>>0}function v_(e,t){let n=Array.from({length:t},()=>[]);for(let r of e)n[__(r.data.id)%t].push(r);return n}function y_(e,t,n){return{buckets:v_(t,t.length>=n*600?n:1),baseWorker:__(e)%n}}async function b_(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 Eg(),a=performance.now());let n=t[e];i[__(n.data.id)%r].push(n)}return{buckets:i,baseWorker:__(e)%n}}function x_(e){let t=e.indexOf(`#`);return t<0?e:e.substring(0,t)}var S_=4096,C_=.75;function w_(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 T_=class{table=new Uint32Array(S_);mask=S_-1;count=0;constructor(e){this.keyOfRef=e}get size(){return this.count}slot(e){let t=w_(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*C_&&(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=w_(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)}},E_=2**20,D_=4096,O_=6;function k_(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 A_=class{chunks=[];rowOf=new T_(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>=E_)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%D_===D_-1&&performance.now()-o>O_&&(await Eg(),o=performance.now());let s=Sh(e,t);if(!(s===dh||n&&!n.has(s))&&(this.rowOf.set(s,r*E_+t,e=>Math.floor(e/E_)<=r)&&i++,a)){let n=xh(e,t),r=n===null?void 0:this.placeholders.get(n);if(r){let n=$g(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/E_);return Sh(this.chunks[t],e-t*E_)}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=_h(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=gh(e);return t!==null&&this.placeholders.has(t)}*ids(){for(let e of this.rowOf.keys()){let t=gh(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=_h(e);t!==null&&!this.rowOf.has(t)&&(yield t)}}get(e){let t=this.cache.get(e);if(t)return t;let n=_h(e),r=n===null?void 0:this.rowOf.get(n);if(r===void 0)return;let i=Math.floor(r/E_),a=$g(this.chunks[i],r-i*E_,this.labels,this.parentIdType);if(!a)return;let o={data:a,position:[0,0,0],positionUnknown:!0};return this.cache.set(e,o),o}getKey(e){let t=gh(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=$g(e,0,this.labels,this.parentIdType);return t?m_(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 Eg(),u=performance.now());let t=Math.floor(e/E_),n=a===1?0:k_(this.chunks[t].id[e-t*E_])%a;o[l]=e,s[l]=n,c[n]++,l++}let d=[];for(let e=0;e<a;e++){let t=Hg(c[e]);t.applyFlagFilter=!1,d.push({cols:t,colors:r?new Float32Array(c[e]*3):null,keys:new Float64Array(c[e]).fill(dh)})}let f=Array(a).fill(1/0),p=Array(a).fill(-1/0),m=Array(a).fill(0),h=r?new X:null;u=performance.now();for(let e=0;e<l;e++){(e&16383)==16383&&performance.now()-u>6&&(await Eg(),u=performance.now());let t=o[e],r=Math.floor(t/E_),i=t-r*E_,a=this.chunks[r],c=s[e],l=d[c],g=m[c]++,_=Sh(a,i);if(l.keys[g]=_,e_(a,i,l.cols,g,_,n)&&(a.validityStart<f[c]&&(f[c]=a.validityStart),a.validityEnd>p[c]&&(p[c]=a.validityEnd)),l.colors&&h){let e=$g(a,i,this.labels,this.parentIdType);h.set(e?m_(e):`#ffffff`),l.colors[g*3]=h.r,l.colors[g*3+1]=h.g,l.colors[g*3+2]=h.b}}for(let e=0;e<a;e++)d[e].cols.validityStart=f[e]===1/0?-1/0:f[e],d[e].cols.validityEnd=p[e]===-1/0?1/0:p[e];return{groups:d,baseWorker:__(e)%t}}};function j_(e){return e===`naif-0`||e===`naif-10`}function M_(e){let t=/^naif-([1-9])$/.exec(e);return t?`naif-${t[1]}99`:null}function N_(e){return e===`naif-0`?d_:M_(e)}function P_(e){if(!j_(e))return M_(e)??e}var F_=class{bodiesById=new Map;majorBodies=[];asteroidBodiesByZone=new Map;spacecraftByParent=new Map;focusFeature=null;dirtyAsteroidZones=new Set;dirtySpacecraftGroups=new Set;minorStreaming=!1;#e=We(0);get minorBodyVersion(){return Bt(this.#e)}set minorBodyVersion(e){Ge(this.#e,e,!0)}#t=We(0);get orientationVersion(){return Bt(this.#t)}set orientationVersion(e){Ge(this.#t,e,!0)}childrenByParent=new Map;moonMaxAByParent=new Map;addListeners=new Set;onBodiesAdded(e){return this.addListeners.add(e),()=>this.addListeners.delete(e)}notifyBodiesAdded(){for(let e of this.addListeners)e()}getBody(e,t){let n=this.bodiesById.get(e);if(n)return n;if(this.focusFeature?.data.id===e)return this.focusFeature;if(t!==void 0)return this.spacecraftByParent.get(t)?.get(e)??this.asteroidBodiesByZone.get(t)?.get(e);for(let t of this.spacecraftByParent.values()){let n=t.get(e);if(n)return n}for(let t of this.asteroidBodiesByZone.values()){let n=t.get(e);if(n)return n}}addBodies(e){let t=!1;for(let n of e){this.bodiesById.has(n.data.id)||(t=!0),this.bodiesById.set(n.data.id,n);let e=this.childrenByParent.get(n.data.parentId)??new Set;if(e.add(n.data.id),this.childrenByParent.set(n.data.parentId,e),n.data.objectType===G.MOON){let e=this.moonMaxAByParent.get(n.data.parentId)??0;n.data.a>e&&this.moonMaxAByParent.set(n.data.parentId,n.data.a)}}t&&this.notifyBodiesAdded()}asteroidBucket(e,t){let n=this.asteroidBodiesByZone.get(e);return n||this.asteroidBodiesByZone.set(e,n=new A_(t)),n}spacecraftBucket(e){let t=this.spacecraftByParent.get(e);return t||this.spacecraftByParent.set(e,t=new Map),t}flushMinor(e){this.asteroidBodiesByZone=new Map(this.asteroidBodiesByZone),this.spacecraftByParent=new Map(this.spacecraftByParent),this.minorBodyVersion++,e&&this.notifyBodiesAdded()}getChildren(e){return this.childrenByParent.get(e)}findAsteroidZone(e){for(let[t,n]of this.asteroidBodiesByZone)if(n.has(e))return t}maxMoonA(e){return this.moonMaxAByParent.get(e)}getSystemExtent(e){return this.moonMaxAByParent.get(e)??.01}isSystemBody(e){return j_(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())(hn(e.data.objectType)||e.data.objectType===G.COMET)&&i++;return{planets:e,moons:t,probes:n,earthSatellites:r,smallBodies:i}}};function I_(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 L_(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 R_(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 I_(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 I_(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 z_={metadata:.12,ephemeris:.55,majors:.8,labels:.92,done:1},B_=[`metadata`,`ephemeris`,`majors`,`labels`,`done`],V_=.9,H_=new class{#e=0;#t=z_.metadata;#n=0;#r=0;#i=!1;#a=We(0);get value(){return Bt(this.#a)}set value(e){Ge(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*V_;n>this.value&&(this.value=n)}reset(){this.#e=0,this.#t=z_.metadata,this.#n=0,this.#r=0,this.#i=!0,this.value=0}reach(e){if(!this.#i)return;let t=z_[e];if(t<=this.#e)return;this.#e=t,this.value<t&&(this.value=t);let n=B_[B_.indexOf(e)+1];this.#t=n?z_[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())}},U_=3e4;function W_(e,t){if(t||!H_.active||!e.body)return e;let n=Number(e.headers.get(`content-length`));if(!Number.isFinite(n)||n<=0)return e;H_.announce(n);let r=new TransformStream({transform(e,t){H_.addBytes(e.byteLength),t.enqueue(e)}});return new Response(e.body.pipeThrough(r),{status:e.status,statusText:e.statusText,headers:e.headers})}async function G_(e,t={},n=U_){let r=new AbortController,i=setTimeout(()=>r.abort(),n),a=()=>r.abort();t.signal?.addEventListener(`abort`,a,{once:!0});try{return W_(await fetch(e,{...t,signal:r.signal}),t.priority===`low`)}catch(i){throw r.signal.aborted&&!t.signal?.aborted?Error(`Request timed out after ${n} ms: ${e}`,{cause:i}):i}finally{clearTimeout(i),t.signal?.removeEventListener(`abort`,a)}}var K_=new Map,q_=new Map,J_=null;function Y_(){if(J_)return J_;let e=(async()=>{let e=await G_(`${Ut()}/v1/systems/global.json`);if(!e.ok)return;let t=await e.json();if(t.gm)for(let[e,n]of Object.entries(t.gm))q_.set(parseInt(e,10),n);if(t.nut_prec_angles)for(let[e,n]of Object.entries(t.nut_prec_angles))K_.set(parseInt(e,10),n)})();return e.catch(()=>{J_===e&&(J_=null)}),J_=e,e}function X_(e){return e>=100?Math.trunc(e/100):e}function Z_(e){return K_.get(e)}function Q_(e){return q_.get(e)}var $_=132712440018,ev=86400;function tv(e){if(!j_(e.parentId))return;let t=Number(e.id.replace(/^naif-/,``));if(!Number.isFinite(t))return;let n=Q_(t>=1&&t<=9?t*100+99:t),r=e.a*rg;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*$_))/rg}var nv=`class-`,rv=`flag-`,iv=`cat-`;`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`;var av=`${iv}asteroids`,ov=`${iv}comets`,sv=`${iv}satellites`,cv=`${iv}debris`;`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`,`${iv}`;var lv={neo:1,pha:2},uv=new Set([`ETc`,`JFc`,`JFC`,`CTc`,`HTC`,`PAR`,`HYP`,`COM`]);function dv(e){return uv.has(e)?`comet`:`asteroid`}function fv(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 pv=null;function mv(){if(pv)return pv;let e=G_(`${Ut()}/v1/groups/__index__.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch group index: ${e.status}`);return e.json()});return pv=e,e.catch(()=>{pv===e&&(pv=null)}),pv}var hv=[`planets`,`dwarfPlanets`,`moons`,`asteroids`,`comets`,`spacecraft`,`satellites`,`debris`,`orbits`,`labels`,`nomenclature`,`stars`],gv=new Set(hv),_v={[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`},vv=`small_bodies/`,yv=new Set([`COM`,`PAR`,`HYP`,`HYA`,`JFC`,`JFc`,`HTC`,`CTc`]);function bv(e){return e===`moons`||e.startsWith(`moons/`)||e===`small_body_moons`?`moons`:e.startsWith(`probes/`)?`spacecraft`:e.startsWith(vv)?yv.has(e.slice(13))?`comets`:`asteroids`:null}function xv(e,t){return e===G.SPACECRAFT?t===`naif-399`?`satellites`:`spacecraft`:_v[e]??null}var Sv=class{skipped;hiddenIds;onChange=null;constructor(e={}){let t=new Set;for(let n of hv)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 gv.has(e)}skipsZone(e){if(e===`earth`)return this.skipped.has(`satellites`)&&this.skipped.has(`debris`);let t=bv(e);return t!==null&&this.skipped.has(t)}hidesZone(e){let t=bv(e);return t!==null&&!this.isVisible(t)}hidesBody(e,t){let n=xv(e,t);return n!==null&&!this.isVisible(n)}hidesSpacecraftGroup(e){return e===`naif-399`?!this.isVisible(`satellites`)&&!this.isVisible(`debris`):!this.isVisible(`spacecraft`)}};function Cv(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 wv=`small_bodies/`;function Tv(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(!j_(r.data.parentId)){let t=e.bodiesById.get(r.data.parentId);t?.data.a&&(i=t.data.a,a=t.data.e)}return un(i,a)}function Ev(e,t,n){if(n.kind===`class`||n.kind===`category`){let r=Tv(e,t);return r===null?!1:n.kind===`class`?r===n.className:dv(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}({}),Dv=1503,Ov={[$.CLOSE]:.3,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},kv={[$.CLOSE]:.01,[$.FULL]:20,[$.FAR]:100,[$.HIDE]:1/0},Av=1/3;function jv(e,t,n,r){return e<=t[$.CLOSE]?$.CLOSE:e<=t[$.FULL]*(r?n:1)?$.FULL:e<=t[$.FAR]?$.FAR:$.HIDE}var Mv=new Sv,Nv=3,Pv=4e6/rg;function Fv(e){return hn(e)||e===G.COMET||e===G.DWARF_PLANET}var Iv=class{#e=We(Xe(d_));get focusedBodyId(){return Bt(this.#e)}set focusedBodyId(e){Ge(this.#e,e,!0)}#t=We(null);get focusedSystemId(){return Bt(this.#t)}set focusedSystemId(e){Ge(this.#t,e,!0)}activeSystemId=null;isZoomedIn=!1;focusedBodyIdPlain=d_;focusedSystemIdPlain=null;travelSystemActive=!1;cameraDistThreeJS=0;lastRecomputeDist=-1;currentJd=0;hideThresholdAU=0;scaledPlanetary=Ov;scaledSystem=kv;fullMoonIds=new Set;moonVisibilityCache=new Map;constructor(e,t=()=>null,n=()=>null,r=()=>null,i=()=>Mv){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/Dv)**1.5,n=e=>({...e,[$.FULL]:e[$.FULL]*t,[$.FAR]:e[$.FAR]*t});this.scaledPlanetary=n(Ov),this.scaledSystem=n(kv)}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!==tn.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&&j_(e.data.parentId)&&!j_(e.data.id),n=e.data.objectType===G.STAR||!t&&j_(e.data.parentId);if(t)return e.data.id;if(n)return Fv(e.data.objectType)?e.data.id:null;let r=this.bodies.bodiesById.get(e.data.parentId);return r&&!j_(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&&hn(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=jv(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}getPlanetVisibility(e,t){if(this.getLayers().hidesBody(e.data.objectType,e.data.parentId))return $.HIDE;if(e.data.orbitalSource===tn.SPICE_PROBE)return this.getProbeVisibility(e);let n=this.getEarthSatGroupFilter();if(n&&e.data.parentId===`naif-399`&&!n.has(e.data.id))return $.HIDE;let r=e.data.objectType;if((hn(r)||r===G.COMET||r===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 jv(t/10/n,this.scaledPlanetary,5,r)}let i=e.data.a;if(!j_(e.data.parentId)){let t=this.bodies.bodiesById.get(e.data.parentId);t?.data.a&&(i=t.data.a)}if(!i||i<0)return i===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 a=e.data.id===this.focusedBodyIdPlain,o=jv(t/10/i,this.scaledSystem,50,a);return o===$.CLOSE?$.FULL:o}getProbeVisibility(e){let t=this.getProbeStore();if((t?t.containingSystemAt(e.data.id,this.currentJd):null)===Nv&&this.getEarthSatGroupFilter())return $.HIDE;let n=e.data.id===this.focusedBodyIdPlain;if(!(t&&!t.hasHeliocentricFit(e.data.id,this.currentJd))){let t=this.bodies.bodiesById.get(d_),r=t?L_(e.position,t.position)/10:0;if(r===0)return $.FULL;let i=jv(this.cameraDistThreeJS/10/r,this.scaledSystem,50,n);return i===$.CLOSE?$.FULL:i}if(!this.isProbeInFocusedSystem(e))return $.HIDE;let r=this.bodies.bodiesById.get(e.data.parentId);if(!r)return $.FULL;let i=L_(e.position,r.position)/10;return i===0||this.cameraDistThreeJS/10/i<=this.scaledPlanetary[$.FULL]*(n?5:1)?$.FULL:$.HIDE}isProbeInFocusedSystem(e){let t=e.data.parentId;if(!j_(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.isInActiveSystem(j_(e.data.parentId)?e.data.id:e.data.parentId))return!0;if(e.data.orbitalSource!==tn.SPICE_PROBE)return!1;let t=this.getProbeStore();if(!t)return!1;let n=t.containingSystemAt(e.data.id,this.currentJd);return n!==null&&this.isInActiveSystem(`naif-${n}`)}isMoonGroupVisible(e){if(!this.getLayers().isVisible(`moons`)||!this.isInFocusedSystem(e))return!1;let t=this.bodies.maxMoonA(e);return t?this.cameraDistThreeJS/10/t<=this.scaledPlanetary[$.FAR]:!1}isSpacecraftGroupVisible(e){if(this.getLayers().hidesSpacecraftGroup(e))return!1;let t=this.activeSystemId;return j_(e)||this.bodies.bodiesById.get(e)?.data.objectType===G.STAR?!t:t?e===t?!0:this.bodies.getChildren(t)?.has(e)??!1:!1}isAsteroidGroupVisible(e){if(this.getLayers().hidesZone(e)||this.activeSystemId)return!1;let t=this.getSmallBodyFilter();if(t&&e.startsWith(`small_bodies/`)){let n=e.slice(wv.length);if(t.kind===`class`&&n!==t.className||t.kind===`category`&&dv(n)!==t.category)return!1}let n=ln[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:Ev(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(Fv(n.data.objectType))return Pv;let r=tv(n.data);return r?r*Av:0}},Lv=``;function Rv(e){let t=new Map;if(!e)return t;for(let n of e.split(`
4051
+ `)){let e=n.indexOf(Lv);if(e===-1)continue;let r=n.slice(0,e),i=n.slice(e+1),a=i.indexOf(Lv),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 zv=new Map;async function Bv(e=s()){let t=zv.get(e);return t||(t=(async()=>{let t=Yt(e),n=await G_(t,{priority:`high`});if(!n.ok)throw Error(`Failed to fetch ${t}: ${n.status}`);let r=new DecompressionStream(`gzip`);return Rv(await new Response(n.body.pipeThrough(r)).text())})(),zv.set(e,t),t.catch(()=>{zv.get(e)===t&&zv.delete(e)})),t}var Vv=Math.PI/180,Hv=Math.cos(ig*Vv),Uv=Math.sin(ig*Vv);function Wv(e,t,n,r,i,a=!1){let o=Math.cos(n*Vv),s=Math.sin(n*Vv),c=Math.cos(r*Vv),l=Math.sin(r*Vv),u=Math.cos(i*Vv),d=Math.sin(i*Vv),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*Hv+m*Uv,t=-p*Uv+m*Hv;p=e,m=t}return[f*10,m*10,-p*10]}function Gv(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 Kv(e,t=new Date){return qv(e,Mg(t))}function qv(e,t){let{a:n,e:r,i,ma:a,n:o,epoch:s}=e;if(!isFinite(n)||!isFinite(r)||!isFinite(a)||!isFinite(o))return console.warn(`NaN in orbital elements: a=${n} e=${r} ma=${a} n=${o}`),null;let c=(a+o*(t-s))*Vv,{om:l,w:u}=Gv(e,t),d,f;if(r<1||n>0){let e=Math.min(r,.9999999),t=bg(c,e),i=Math.sqrt(1-e*e)*Math.sin(t)/(1-e*Math.cos(t)),a=(Math.cos(t)-e)/(1-e*Math.cos(t));d=Math.atan2(i,a),f=n*(1-e*Math.cos(t))}else{let e=Sg(c,r);if(!isFinite(e))return console.warn(`solveKeplerHyperbolic overflow: M=${c} e=${r}`),null;let t=r*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return console.warn(`Hyperbolic denom near zero: H=${e} e=${r} denom=${t}`),null;let i=Math.sqrt(r*r-1)*Math.sinh(e)/t,a=(r-Math.cosh(e))/t;d=Math.atan2(i,a),f=n*(1-r*Math.cosh(e))}let p=f*Math.cos(d),m=f*Math.sin(d);return!isFinite(p)||!isFinite(m)?(console.warn(`Non-finite orbital position: r=${f} nu=${d} xOrb=${p} yOrb=${m} a=${n} e=${r}`),null):Wv(p,m,u,i,l,e.equatorial)}function Jv(e,t=new Date){return Yv(e,Mg(t))}function Yv(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=Cg(n,r,t);if(!s)return null;let c=s.r*Math.cos(s.nu),l=s.r*Math.sin(s.nu);return!isFinite(c)||!isFinite(l)?null:Wv(c,l,o,i,a,e.equatorial)}var Xv=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 Zv(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=Jt;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 _=sn(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 Qv(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 $v(e,t,n,r){let i=Qv(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 ey=1e-7,ty=.001,ny=1,ry=2,iy=16,ay=32;function oy(e,t,n){let r=new DataView(e,t,ay),i=r.getInt32(0,!0),a=r.getUint8(4),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=r.getInt32(16,!0)*ey,l=r.getInt32(20,!0)*ey,u=r.getInt32(24,!0)*ty,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+ay,d*iy);for(let e=0;e<d;e++){let t=e*iy;f[e]=n+r.getUint32(t,!0),p[e]=r.getInt32(t+4,!0)*ey,m[e]=r.getInt32(t+8,!0)*ey,h[e]=r.getInt32(t+12,!0)*ty}}return{bodyNaifId:i,isStatic:(a&ny)!==0,isDestroyed:(a&ry)!==0,startEt:n+o,endEt:n+s,latRefDeg:c,lngRefDeg:l,altRefM:u,sampleEt:f,sampleLatDeg:p,sampleLngDeg:m,sampleAltM:h}}function sy(e,t,n,r){let i=n/(36*(r?8:4));return{method:3,coeffsPerAxis:12,nSeg:i,coeffs:Qv(e,t,i*3*12,r)}}function cy(e,t,n,r){let i=new DataView(e),a=i.getUint32(24,!0),o=i.getFloat32(28,!0),s=o*Og,c=Pg(t),l=[],u=Jt;for(let t=0;t<a;t++){let n=i.getInt32(u,!0),a=i.getUint8(u+4),o=i.getUint8(u+5),d=i.getUint8(u+6)===1,f=(i.getUint8(u+7)&1)!=0,p=i.getUint16(u+8,!0),m=i.getUint16(u+10,!0),h=i.getInt32(u+12,!0),g=i.getUint8(u+16),_=i.getUint8(u+17);u+=20;let v=sn(a,n)??``;v||console.warn(`probes payload: probe[${t}] (value=${n}) has unknown id-type ${a}; skipping`);let y=null;if(h!==-1&&g!==255){let e=sn(g,h);e?y={id:e,idType:g,idValue:h}:console.warn(`probes payload: probe[${t}] has unknown fit-center id-type ${g}; falling back to zone default`)}let b=Array(p),x=Array(p),S=Array(p);for(let n=0;n<p;n++){let a=i.getUint8(u),o=i.getUint32(u+4,!0),l=u+8,d=c+(m+n)*s;if(b[n]=d,x[n]=d+s,a===0)S[n]={method:0};else if(a===1||a===2)S[n]=$v(e,l,a,r);else if(a===3)S[n]=sy(e,l,o,r);else throw Error(`Unknown probe sub-chunk method ${a} at probe ${t} sub ${n}`);u=l+o}let C;if(f){let n=i.getUint8(u);if(n!==4)throw Error(`probe ${t}: PROBE_FLAG_HAS_LANDED_RECORD set but trailing record method = ${n}, expected 4`);let r=i.getUint32(u+4,!0),a=u+8;C=oy(e,a,c),u=a+r}let w=Array(_);for(let e=0;e<_;e++)w[e]={startEt:i.getFloat64(u,!0),endEt:i.getFloat64(u+8,!0),systemNaifId:i.getUint8(u+16)},u+=17;l.push({id:v,probeId:n,hasLocalized:d,objectType:o,fitCenter:y,subStartEt:b,subEndEt:x,subChunks:S,landed:C,systemIntervals:w})}return{startJd:t,endJd:n,subchunkDays:o,probes:l}}function ly(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:Th(e,o,s)};if(a===1)return{kind:`chebyshev`,chunk:Zv(e,o,s)};if(a===2)return{kind:`probes`,chunk:cy(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 dy(e,t){let n=uy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=e.coeffsPerAxis,s=e.coeffs,c=n*3*o,l=[0,0,0],u=2*a;for(let e=0;e<3;e++){let t=c+e*o;if(o===1){l[e]=s[t];continue}let n=0,r=0;for(let e=o-1;e>=1;e--){let i=s[t+e]+u*n-r;r=n,n=i}l[e]=s[t]+a*n-r}return l}function fy(e,t){let n=dy(e,t);return n===null?null:[Q(n[0]),Q(n[2]),-Q(n[1])]}function py(e,t){let n=uy(e.startJds,e.endJds,t);if(n<0)return null;let r=e.startJds[n],i=e.endJds[n],a=2*(t-r)/(i-r)-1,o=2/(i-r),s=e.coeffsPerAxis,c=e.coeffs,l=n*3*s,u=[0,0,0],d=[0,0,0],f=2*a;for(let e=0;e<3;e++){let t=l+e*s;if(s===1){u[e]=c[t],d[e]=0;continue}let n=0,r=0;for(let e=s-1;e>=1;e--){let i=c[t+e]+f*n-r;r=n,n=i}u[e]=c[t]+a*n-r;let i=0,p=0;for(let e=s-2;e>=0;e--){let n=c[t+e+1]*(e+1)+f*i-p;p=i,i=n}d[e]=i*o}return{position:u,velocity:d}}function my(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 hy(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 gy(e,t,n,r,i,a){if(t>=1)return null;let o=bg(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:hy(f,p,r,n,i)}function _y(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 gy(e.aKm,e.e,e.iRad,e.om0,e.w0,o)}function vy(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 gy(e.aKm,e.e,e.iRad,i,a,o)}function yy(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 by(e,t,n,r,i){switch(e.method){case 0:return null;case 1:return _y(e,t,r,i);case 2:return vy(e,t,r);case 3:return yy(e,t,n,r)}}function xy(e,t,n){let r=Pg(t),i=my(e,r);return i<0?null:by(e.subChunks[i],e.subStartEt[i],e.subEndEt[i],r,n)}function Sy(e,t,n){let r=xy(e,t,n);return r===null?null:[Q(r[0]),Q(r[2]),-Q(r[1])]}function Cy(e){if(!e.landed)return!1;let t=e.subEndEt.length;return t===0||e.subEndEt[t-1]<=e.landed.endEt}function wy(e,t){if(!e.landed)return!1;let n=Pg(t);return n>=e.landed.startEt&&(n<e.landed.endEt||Cy(e))}function Ty(e,t,n=!1){let r=Pg(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 Ey=30/Og;function Dy(e,t,n){let r=xy(e,t,n);if(r===null)return null;let i=Ey,a=xy(e,t+i,n),o=xy(e,t-i,n),s,c,l;if(a!==null&&o!==null)s=a,c=o,l=1/(2*i);else if(a!==null)s=a,c=r,l=1/i;else if(o!==null)s=r,c=o,l=1/i;else return null;return{position:r,velocity:[(s[0]-c[0])*l,(s[1]-c[1])*l,(s[2]-c[2])*l]}}Math.PI/180;var Oy=180/Math.PI;rg/86400;var ky=1e-9,Ay=1e-9;function jy(e,t,n){return e<t?t:e>n?n:e}function My(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(jy(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;_<Ay||E===0?D=0:(D=Math.acos(jy(w/E,-1,1)),T<0&&(D=2*Math.PI-D));let O;if(x<ky)O=0;else if(_<Ay||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(jy(e,-1,1)),b<0&&(O=2*Math.PI-O)}let k,A=i*s+a*c+o*l;if(x<ky&&(_<Ay||E===0))k=Math.atan2(a,i),m<0&&(k=-k),k<0&&(k+=2*Math.PI);else if(x<ky){let e=(w*i+T*a)/(E*u);k=Math.acos(jy(e,-1,1)),o<0&&(k=2*Math.PI-k)}else{let e=(v*i+y*a+b*o)/(x*u);k=Math.acos(jy(e,-1,1)),A<0&&(k=2*Math.PI-k)}let j;if(x<1){let e=2*Math.atan2(Math.sqrt(1-x)*Math.sin(k/2),Math.sqrt(1+x)*Math.cos(k/2));j=e-x*Math.sin(e)}else if(x>1){let e=2*Math.atanh(Math.sqrt((x-1)/(x+1))*Math.tan(k/2));if(!isFinite(e))return null;j=x*Math.sinh(e)-e}else return null;let M=Math.abs(C),ee=Math.sqrt(n/(M*M*M))*Oy;return{a:C,e:x,i:g*Oy,om:D*Oy,w:O*Oy,ma:j*Oy,n:ee,epoch:r,equatorial:!1}}var Ny=180/Math.PI;function Py(e,t,n){if(n<=0)return null;let r=Math.sqrt(n/(e.aKm*e.aKm*e.aKm)),i=Fg(t+e.tAnchorOffsetS);return{a:e.aKm/rg,e:e.e,i:e.iRad*Ny,om:e.om0*Ny,w:e.w0*Ny,ma:e.m0*Ny,n:r*Ny*Og,epoch:i,equatorial:!1}}function Fy(e,t){let n=Fg(t+e.tAnchorOffsetS);return{a:e.aKm/rg,e:e.e,i:e.iRad*Ny,om:e.om0*Ny,w:e.w0*Ny,ma:e.m0*Ny,n:e.nMeanRadS*Ny*Og,omDot:e.omDot*Ny*Og,wDot:e.wDot*Ny*Og,epoch:n,equatorial:!1}}function Iy(e,t,n){if(n<=0)return null;let r=Dy(e,t,n);if(!r)return null;let i=n*ag;return My([r.position[0]/rg,r.position[1]/rg,r.position[2]/rg],[r.velocity[0]*og,r.velocity[1]*og,r.velocity[2]*og],i,t)}function Ly(e,t,n){let r=my(e,Pg(t));if(r<0)return null;let i=e.subChunks[r];switch(i.method){case 0:return null;case 1:return Py(i,e.subStartEt[r],n);case 2:return Fy(i,e.subStartEt[r]);case 3:return Iy(e,t,n)}}function Ry(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=py(a,t),c=py(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 zy(e){let t=e-18e6;if(t>=2e6&&t<=2999999){let e=Q_(t);if(e!==void 0)return{naifId:t,muKm3S2:e}}return{naifId:e,muKm3S2:Q_(e)??0}}function By(e,t,n,r,i){let a=`naif-${n}`,o=e.fitCenter;if(o&&o.id!==a){let n=Ry(e,t,a,r);return n?{id:n.id,naifId:n.naifId,muKm3S2:Q_(n.naifId)??0}:i?.(o.id)?o.idType===nn.SPKID?{id:o.id,...zy(o.idValue)}:{id:o.id,naifId:o.idValue,muKm3S2:Q_(o.idValue)??0}:null}return{id:a,naifId:n,muKm3S2:Q_(n)??0}}var Vy=1/256,Hy=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}},Uy=200;function Wy(e,t,n,r=!1){if(r)return{stepDays:Uy/n,epsilonScene:1/0,spanDays:Uy};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 Gy(e){let t=Number(e.slice(5));return e=>e===t}function Ky(e,t,n,r){let i=Gy(r);return a=>{let o=e.probeWithCenter(n,a,i);if(!o)return null;let s=By(o.probe,a,o.fitCenterNaifId,t,e=>e===r);return!s||s.id!==r?null:Sy(o.probe,a,s.muKm3S2)}}function qy(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 Jy=.005;function Yy(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,Jy*i)},c=t+o*a,l=e(c);if(l!==null&&s(qy(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(qy(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 Xy(e,t,n,r,i,a){Zy(e,Ky(t,n,r,i),a)}function Zy(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*Vy,o=n-e.spanDays;for(;i.length<e.capacity;){let n=i[i.length-1];if(n.jd<=o)break;let s=Yy(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 Qy(e,t,n,r,i){if(!isFinite(e.epsilonScene))return;let a=e.stepDays*16,o=e.stepDays*Vy,s=n,c=r;for(let n=0;n<e.capacity&&!(i-s<=o);n++){let n=Math.min(a,i-s),r=Yy(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 $y(e,t,n,r,i,a){if(t.length===0)return[];let o=e.trailAnchor??e.position,s=[o[0]-r,o[1]-i,o[2]-a],c=0,l=1/0;for(let e=0;e<t.length;e++){let n=(t[e][0]-s[0])**2+(t[e][1]-s[1])**2+(t[e][2]-s[2])**2;n<l&&(l=n,c=e)}let u=Math.max(c-1,0),d=Math.min(c+1,t.length-1),f=(t[u][0]-s[0])**2+(t[u][1]-s[1])**2+(t[u][2]-s[2])**2<(t[d][0]-s[0])**2+(t[d][1]-s[1])**2+(t[d][2]-s[2])**2?u:c,p=[s];if(n)for(let e=0;e<511;e++){let n=Math.max(f-e,0);if(p.push(t[n]),n===0)break}else{for(let e=0;e<511;e++)p.push(t[((f-e)%512+512)%512]);p.push(s)}return p.filter(e=>e.every(Number.isFinite))}function eb(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 tb=new Map,nb=0,rb=10;function ib(e,t,n,r){let i=Q_(t);if(!i)return null;let a=py(e,n);if(!a)return null;let o=r?py(r,n):null;if(r&&!o)return null;let s=i*ag;return My([(a.position[0]-(o?.position[0]??0))/rg,(a.position[1]-(o?.position[1]??0))/rg,(a.position[2]-(o?.position[2]??0))/rg],[(a.velocity[0]-(o?.velocity[0]??0))*og,(a.velocity[1]-(o?.velocity[1]??0))*og,(a.velocity[2]-(o?.velocity[2]??0))*og],s,n)}function ab(e,t,n){return!n||e.parentId!==nb||e.naifId===rb?null:ib(e,rb,t,n)}function ob(e,t,n,r){return r?Qt(e,t,r,n):Zt(e,t,n)}var sb=new Xv(8);async function cb(e,t,n,r,i){let a=`${e}:${t??``}:${n}:${r??``}`;return sb.getOrCompute(a,async()=>{let a=await G_(ob(e,t,n,r),{priority:i});if(!a.ok)throw Error(`Failed to fetch elements: ${a.status}`);let o=new DecompressionStream(`gzip`),s=ly(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 lb=class{static prefetch(e,t,n,r=null){fetch(ob(e,t,n,r))}positions=new Map;barycenters=new Map;neededParentKeys=new Set;probeBuffers=new Map;constructor(e){this.cheb=e,this.positions.set(`naif-0`,[0,0,0])}processChebyshev(e,t){if(!this.cheb)return[];let n=Mg(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-${rb}`,n);for(let{body:e,startJd:l,endJd:u}of o){let o=fy(e,n);if(!o)continue;a.set(e.naifId,e);let d=`naif-${e.parentId}`,f=this.positions.get(d);if(!f){console.warn(`processChebyshev: parent ${d} not in positions for ${e.id} — hiding`);continue}let p=[f[0]+o[0],f[1]+o[1],f[2]+o[2]],m=e.objectType,h=m===G.MOON&&e.parentId>=1&&e.parentId<=9?`naif-${e.parentId*100+99}`:null,g=h?this.positions.get(h):void 0,_=ib(e,e.parentId,n,h?s.body(h,n)??void 0:void 0),v=e.id,y=e=>{let t=s.body(v,e);return t?ib(t,t.parentId,e,h?s.body(h,e)??void 0:void 0):null},b=Math.hypot(o[0],o[1],o[2])/10,x={id:e.id,name:Ug(t,e.id),isMinor:Wg(t,e.id),hasLocalized:e.hasLocalized,objectType:m,parentId:`naif-${e.parentId}`,radiusKm:e.radiusKm,a:_?Math.abs(_.a):b,e:_?.e??0,i:_?.i??0,om:_?.om??0,w:_?.w??0,ma:_?.ma??0,n:_?.n??0,epoch:_?.epoch??0,equatorial:!1,helioElements:ab(e,n,c)??void 0,validityStart:l,validityEnd:u,orbitalSource:tn.SPICE,visibleFromDays:e.visibleFromDays};if(r&&this.positions.set(e.id,p),m===G.BARYCENTER||m===G.LAGRANGE_POINT){r&&_&&_.a>0&&_.e<1&&this.barycenters.set(e.id,_),i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y});continue}if(gn(m)){let t=m===G.MOON,n=this.barycenters.get(d),r=t?_:n??_,o=!t&&n!==void 0,c=a.get(e.parentId)?.id,l=o&&c?e=>{let t=s.body(c,e);return t?ib(t,t.parentId,e):null}:y;i.push({data:x,position:p,orbitElements:r??void 0,orbitCenter:o?void 0:g??f,trailAnchor:o?[f[0],f[1],f[2]]:void 0,rederiveElements:l})}else i.push({data:x,position:p,orbitElements:_??void 0,orbitCenter:f,rederiveElements:y})}return i}processProbes(e,t,n){let r=Mg(t),i=[],a=new Map,o=new Map,s=new Set,c=new Set;for(let{id:t,probe:l,zoneCenterNaifId:u,startJd:d,endJd:f}of e.probesAt(r)){if(!t)continue;u===void 0&&c.add(t);let p=`naif-${u}`,m=u===void 0?null:By(l,r,u,this.cheb,e=>this.positions.has(e)),h=m?m.id:p,g=m?.muKm3S2??0,_=m===null,v=this.positions.get(h);if(!v){let e=a.get(h);e||a.set(h,e=new Set),e.add(t)}if(g===0){let e=o.get(h);e||o.set(h,e=new Set),e.add(t)}let y=xy(l,r,g);y||s.add(t);let b=v??[0,0,0],x=y?[Q(y[0]),Q(y[2]),-Q(y[1])]:null,S=!x||!v||_,C=x&&!_?[b[0]+x[0],b[1]+x[1],b[2]+x[2]]:[b[0],b[1],b[2]],w={id:t,name:Ug(n,t),isMinor:Wg(n,t),hasLocalized:l.hasLocalized,objectType:l.objectType,parentId:h,loadParentId:h,radiusKm:NaN,a:0,e:0,i:0,om:0,w:0,ma:0,n:0,epoch:0,equatorial:!1,validityStart:d,validityEnd:f,orbitalSource:tn.SPICE_PROBE},T=Ly(l,r,g),E=t,D=this.cheb,O=t=>{let n=e.probeWithCenter(E,t);if(!n)return null;let r=By(n.probe,t,n.fitCenterNaifId,D,()=>!0);return r?Ly(n.probe,t,r.muKm3S2):null},k;{let{stepDays:e,epsilonScene:n,spanDays:r}=Wy(T,f-d,512),i=this.probeBuffers.get(t);i&&i.parentKey===h?(k=i.buffer,!isFinite(k.epsilonScene)&&isFinite(n)&&k.reconfigure(e,n,r)):(k=new Hy(512,e,n,r),k.needsPopulate=!0,this.probeBuffers.set(t,{buffer:k,parentKey:h}))}i.push({data:w,position:C,positionUnknown:S,orbitElements:T??void 0,orbitCenter:[b[0],b[1],b[2]],rederiveElements:O,trailBuffer:k})}c.size>0&&console.error(`processProbes: ${c.size} probe(s) have undefined fit_center_naif_id — metadata.json is stale (re-export to pick up fit_center_naif_id field). Affected probe ids: ${Array.from(c).slice(0,10).join(`, `)}`+(c.size>10?` (+${c.size-10} more)`:``));for(let[e,t]of a)console.warn(`processProbes: fit-center ${e} not in positions (unplaceable, kept hidden) — ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));for(let[e,t]of o)console.warn(`processProbes: GM unavailable for ${e} — kepler_pure sub-chunks will use mu=0 (static snapshot); affected ${t.size} probe(s): ${Array.from(t).slice(0,5).join(`, `)}`+(t.size>5?` (+${t.size-5} more)`:``));return s.size>0&&console.warn(`processProbes: ${s.size} probe(s) outside sub-chunk windows at load (will stay hidden until jd enters coverage): ${Array.from(s).slice(0,5).join(`, `)}`+(s.size>5?` (+${s.size-5} more)`:``)),i}async seedNeededParents(e,t,n,r,i){let a=await cb(e,t,n,r),o=on(i);if(o!==void 0)for(let e=0;e<a.rowCount;e++)this.neededParentKeys.add(ph(o,a.parentId[e]))}async fetchMinorColumns(e,t,n,r,i=null,a=`naif`,o){let s=await cb(e,t,n,i,o);return this.neededParentKeys.size>0&&await this.resolveNeededParents(s,r,a),s}async resolveNeededParents(e,t,n){let r=Mg(t),i=e.kind===`parabolic`,a=this.neededParentKeys,o=performance.now();for(let s=0;s<e.rowCount;s++){if((s&4095)==4095&&performance.now()-o>6&&(await Eg(),o=performance.now()),!a.has(Sh(e,s)))continue;let c=xh(e,s);if(c===null)continue;let l=this.positions.get(`${n}-${e.parentId[s]}`);if(!l)continue;let u=$g(e,s,tb,n);if(!u)continue;let d=r>=u.validityStart&&r<=u.validityEnd?u.satrec?yg(u.satrec,r):u.q==null?u.a===0&&!i?[0,0,0]:Kv(u,t):Jv(u,t):[0,0,0];d&&this.positions.set(c,[l[0]+d[0],l[1]+d[1],l[2]+d[2]])}}async process(e,t,n,r,i=null,a=`naif`,o,s){let c=this.barycenters.size===0,l=[],u=new Map,d=[],[f,p]=await Promise.all([cb(e,t,n,i,s),Bv()]),m=f.kind===`parabolic`,h=f.kind===`sgp4`,g=Mg(r),_=performance.now();for(let e=0;e<f.rowCount;e++){(e&255)==255&&performance.now()-_>6&&(await Eg(),_=performance.now());let t=f.objectType[e];if(!m&&f.a[e]===0&&t!==G.BARYCENTER&&t!==G.LAGRANGE_POINT&&!gn(t))continue;let n=`${a}-${f.parentId[e]}`,i=this.positions.get(n);if(!i){u.set(n,(u.get(n)??0)+1);continue}let s=m?qg(f,e,p,a):h?Qg(f,e,p,a):Kg(f,e,p,a);if(!s)continue;if(h&&s.name===null&&!o?.has(s.id)){l.push({data:s,position:[i[0],i[1],i[2]],positionUnknown:!0});continue}if(h&&!s.satrec)continue;let v=g>=s.validityStart&&g<=s.validityEnd,y=v?s.satrec?yg(s.satrec,g):s.a===0&&!m?[0,0,0]:s.q==null?Kv(s,r):Jv(s,r):[0,0,0];if(!y){d.push(s.id);continue}let b=[i[0]+y[0],i[1]+y[1],i[2]+y[2]],x=_h(s.id);if(x!==null&&this.neededParentKeys.has(x)&&this.positions.set(s.id,b),t===G.BARYCENTER||t===G.LAGRANGE_POINT){c&&(s.a>0&&s.e<1&&this.barycenters.set(s.id,s),this.positions.set(s.id,b)),l.push({data:s,position:b,positionUnknown:!v,orbitElements:s.a>0?s:void 0,orbitCenter:i});continue}if(c&&gn(t)&&this.positions.set(s.id,b),gn(t)){let e=t===G.MOON,r=this.barycenters.has(n);l.push({data:s,position:b,positionUnknown:!v,orbitElements:e?s:this.barycenters.get(n)??s,orbitCenter:e||!r?i:void 0})}else l.push({data:s,position:b,positionUnknown:!v})}if(d.length>0&&console.warn(`process(${e}/${t}/${n}): positioned ${l.length} body(ies), dropped ${d.length} the propagator refused — ${d.slice(0,5).join(`, `)}`+(d.length>5?` (+${d.length-5} more)`:``)),u.size>0){let r=Array.from(u.values()).reduce((e,t)=>e+t,0),i=Array.from(u.entries()).map(([e,t])=>`${e}×${t}`).join(`, `);console.warn(`process(${e}/${t}/${n}): hid ${r} body(ies) with unresolved parent — ${i}`)}return l}},ub=new Map,db=null,fb=null;function pb(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 mb(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 hb(){if(fb)return fb;let e=(async()=>{let e=await G_(`${Ut()}/v1/atmospheres.json`);if(!e.ok){console.warn(`atmospheres: fetch failed (${e.status}) — rendering without shells`);return}let t=await e.json();db=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:pb(n.seasonal),referenceAltitudeKm:n.reference_altitude_km,deepColumn:mb(e,n.deep_column,t.deep_n)})}})();return e.catch(()=>{fb===e&&(fb=null)}),fb=e,e}function gb(e){return ub.get(e)}function _b(){return db}var vb=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 yb(e,t){return e>>>t|e<<32-t}function bb(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=yb(i[e-15],7)^yb(i[e-15],18)^i[e-15]>>>3,n=yb(i[e-2],17)^yb(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=yb(c,6)^yb(c,11)^yb(c,25),a=c&l^~c&u,f=d+t+a+vb[e]+i[e]|0,p=(yb(n,2)^yb(n,13)^yb(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 xb(e){return e.shape===`parted`}function Sb(e){return e.shape===`chunked-parted`&&e.label===`date`}function Cb(e){return e.shape===`chunked-parted`&&e.label===`index`}function wb(e){return e.shape===`chunked`}function Tb(e,t){let n=Math.floor((t-e.start_jd)/e.chunk_days);return Math.max(0,Math.min(e.chunks-1,n))}function Eb(e){return`shape`in e&&e.shape===`probes`}function Db(e){return`zooms`in e}function Ob(e){return Eb(e)?[]:Db(e)?Object.entries(e.zooms).map(([e,t])=>({zoom:Number(e),data:t})):[{zoom:null,data:e}]}function kb(e){return!Db(e)&&!Eb(e)?e:void 0}var Ab=new WeakMap;function jb(e){let t=Ab.get(e);return t||(t=Object.keys(e.parts_by_date).map(e=>Date.parse(`${e}T00:00:00Z`)).sort((e,t)=>e-t),Ab.set(e,t)),t}function Mb(e,t){let n=jb(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 Nb=14;function Pb(e,t){let n=jb(e),r=t.getTime(),i=Nb*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 Fb(e,t,n=0){let r=e.parts_by_date[t]??e.parts;return n>0?Math.min(r,n):r}var Ib=null;function Lb(){if(Ib)return Ib;let e=G_(`${Ut()}/v1/metadata.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch metadata: ${e.status}`);return e.json()}).then(e=>(Gt(e.versions),e));return Ib=e,e.catch(()=>{Ib===e&&(Ib=null)}),Ib}function Rb(e){let t=new Map;for(let[n,r]of Object.entries(e.position.zones)){if(Eb(r))continue;let e=Db(r)?0:null,i=e===0?r.zooms[0]:r;!i||!wb(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 zb(e){let t=new Map,n=Object.entries(e.position.zones).filter(([,e])=>Eb(e)).sort(([e],[t])=>(e===`probes/interplanetary`)-+(t===`probes/interplanetary`)||e.localeCompare(t));for(let[e,r]of n)Eb(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 Bb(e,t){let n=new TextEncoder().encode(e),r=crypto.subtle?await crypto.subtle.digest(`SHA-256`,n):bb(n).buffer;return new DataView(r).getUint32(0,!1)%t}async function Vb(e,t){let n=await G_(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 Hb(e,t,n,r){let i=ly(await Vb($t(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 Ub=1,Wb=Promise.resolve();function Gb(e,t){return`${e}:${t}`}var Kb=class{chunks=new Map;inflight=new Map;lastEnsuredJd=NaN;constructor(e){this.zoneParams=e}zones(){return Array.from(this.zoneParams.keys())}ensure(e){if(e===this.lastEnsuredJd)return{ready:this.allCurrentChunksLoaded(e),done:this.pendingCurrent(e)};this.lastEnsuredJd=e;let t=[],n=[],r=!0;for(let[i,a]of this.zoneParams){let o=Tb(a,e);if(this.isLoadable(a,o)&&!this.isResident(i,o)){r=!1;let e=this.loadChunk(i,a,o,`high`);e&&t.push(e)}for(let e=-Ub;e<=Ub;e++){let t=o+e;e===0||t<0||t>=a.chunks||this.isLoadable(a,t)&&n.push([i,a,t])}this.evictOutsideWindow(i,o)}let i=t.length>0?Promise.all(t).then(()=>void 0):Wb;return i.catch(()=>{}).then(()=>{for(let[e,t,r]of n)this.loadChunk(e,t,r,`low`)?.catch(()=>{})}),{ready:r,done:i}}pendingCurrent(e){if(this.inflight.size===0)return Wb;let t=null;for(let[n,r]of this.zoneParams){let i=this.inflight.get(Gb(n,Tb(r,e)));i&&(t??=[]).push(i)}return t?Promise.all(t).then(()=>void 0):Wb}allCurrentChunksLoaded(e){for(let[t,n]of this.zoneParams){let r=Tb(n,e);if(this.isLoadable(n,r)&&!this.isResident(t,r))return!1}return!0}isResident(e,t){return this.chunks.get(e)?.has(t)??!1}evictOutsideWindow(e,t){let n=this.chunks.get(e);if(n)for(let e of n.keys())(e<t-Ub||e>t+Ub)&&n.delete(e)}loadChunk(e,t,n,r){if(this.isResident(e,n))return null;let i=Gb(e,n),a=this.inflight.get(i);if(a)return a;let o=this.fetchAndStore(e,t,n,r);return this.inflight.set(i,o),o.finally(()=>this.inflight.delete(i)),o}async fetchAndStore(e,t,n,r){let i=await this.fetchChunk(e,t,n,r),a=this.chunks.get(e);a||this.chunks.set(e,a=new Map),a.set(n,i),this.afterStore(e,i)}},qb=class extends Kb{idToZone=new Map;isLoadable(){return!0}fetchChunk(e,t,n,r){return Hb(e,t.zoom,n,r)}afterStore(e,t){for(let n of t.byId.keys())this.idToZone.has(n)||this.idToZone.set(n,e)}has(e){return this.idToZone.has(e)}zoneCoverage(e){let t=this.idToZone.get(e);if(t===void 0)return null;let n=this.zoneParams.get(t);return n?{start:n.start_jd,end:n.end_jd}:null}resolve(e,t){let n=this.idToZone.get(e);if(n===void 0)return null;let r=this.zoneParams.get(n);if(!r)return null;let i=Tb(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=Tb(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?fy(n.body,t):null}};async function Jb(e,t,n,r){let i=$t(e,null,t),a=await G_(i,{priority:r});if(!a.ok)throw Error(`Failed to fetch ${i}: ${a.status}`);let o=new DecompressionStream(`gzip`),s=ly(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 Yb=24;function Xb(e,t){for(let[n,r]of e){if(t<n)return!1;if(t<=r)return!0}return!1}var Zb=7,Qb=class extends Kb{fitCenterUsable=null;warmed=new Map;carried=new Map;_version=0;get version(){return this._version}zoneCenter(e){return this.zoneParams.get(e)?.fit_center_naif_id}isLoadable(e,t){return Xb(e.present,t)}fetchChunk(e,t,n,r){return Jb(e,n,t.float64_coeffs,r)}afterStore(){this._version++}async warmAt(e){let t=[];for(let[n,r]of this.zoneParams){let i=Tb(r,e);if(i<0||i>=r.chunks||!Xb(r.present,i)||this.isResident(n,i))continue;let a=Gb(n,i);if(this.warmed.has(a))continue;let o=this.inflight.get(a);if(o){t.push(o);continue}let s=this.fetchAndWarm(a,n,i,r);this.inflight.set(a,s),s.finally(()=>this.inflight.delete(a)),t.push(s)}await Promise.all(t)}async fetchAndWarm(e,t,n,r){let i=await Jb(t,n,r.float64_coeffs,`low`);for(this.warmed.set(e,i);this.warmed.size>Yb;){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=Tb(a,e),s=this.chunks.get(i)?.get(o)??this.warmed.get(Gb(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+Zb?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+Zb)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=Pg(t),i=null;for(let[a,o]of this.zoneParams){let s=Tb(o,t),c=this.chunks.get(a)?.get(s)??this.warmed.get(Gb(a,s));if(c)for(let t of nx(c,e)){let e=c.probes[t];if(!this.fitCenterCovered(e))break;let s=my(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=Pg(t);for(let[r,i]of this.zoneParams){let a=Tb(i,t),o=this.chunks.get(r)?.get(a)??this.warmed.get(Gb(r,a));if(o)for(let t of nx(o,e)){let e=o.probes[t];if(my(e,n)<0)break;return e.fitCenter?.id??null}}return null}probe(e,t,n){return this.resolve(e,t,n)?.probe??null}probeWithCenter(e,t,n){let r=this.resolve(e,t,n);return r?{probe:r.probe,fitCenterNaifId:r.params.fit_center_naif_id}:null}positionKm(e,t,n,r){let i=this.resolve(e,t,r);return i?xy(i.probe,t,n):null}positionScene(e,t,n,r){let i=this.resolve(e,t,r);return i?Sy(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=Pg(t),r=this.zoneParams.get($b);if(r){let i=Tb(r,t),a=this.chunks.get($b)?.get(i);if(a)for(let t of nx(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===$b||r.fit_center_naif_id===10)continue;let i=Tb(r,t),a=this.chunks.get(n)?.get(i);if(a)for(let t of nx(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($b);if(!n)return!1;let r=Tb(n,t),i=this.chunks.get($b)?.get(r);if(!i)return!1;let a=Pg(t);for(let t of nx(i,e))if(my(i.probes[t],a)>=0)return!0;return!1}},$b=`probes/interplanetary`,ex=[],tx=new WeakMap;function nx(e,t){let n=tx.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])}tx.set(e,n)}return n.get(t)??ex}async function rx(e){let t=new DecompressionStream(`gzip`);return await new Response(e.body.pipeThrough(t)).json()}function ix(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 rx(a)})();return a=t,t.catch(()=>{a===t&&(a=null)}),t}}var ax=24,ox=new Map;function sx(e,t){let n=ox.get(e);if(n&&(ox.delete(e),ox.set(e,n)),!n){n=(async()=>{let n=await G_(e,t);if(!n.ok){if(n.status===404)return{};throw Error(`fetchGzipBundle: ${e} returned ${n.status} ${n.statusText}`)}return rx(n)})(),ox.set(e,n),n.catch(()=>{ox.get(e)===n&&ox.delete(e)});for(let e of ox.keys()){if(ox.size<=ax)break;ox.delete(e)}}return n}var cx={counts:`object_bundles`,globalPath:e=>`/v1/objects/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/objects/${e}/${t}.json.gz`,versionClass:`objects`},lx={counts:`group_bundles`,globalPath:e=>`/v1/groups/__global__/${e}.json.gz`,localizedPath:(e,t)=>`/v1/groups/${e}/${t}.json.gz`},ux=(e,t)=>sx(t?Kt(e,t):`${Ut()}${e}`);async function dx(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?Bb(t,s):-1,c?Bb(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 fx(e,t,n,r=!0){return dx(e,t,{meta:await Lb(),lang:n,localized:r,fetchBundle:ux})}function px(e){return e.imagery!==`withheld`&&a(e.distribution)}function mx(e,t=!0,n=s()){return fx(cx,e,n,t)}async function hx(e){if(e?.startsWith(`probe-`))try{let t=(await mx(e,!1)).global,n=t?.coverage?.position_from;return n?{id:e,carriedFrom:n,carrierName:t?.carried_by?.name}:void 0}catch{return}}function gx(e,t,n){let r=new Set,i=new Map;for(let a of e){let e=t===a.passengerId;if(r.add(e?a.carrierId:a.passengerId),!e||!a.attached)continue;let o=n(a.carrierId)??a.carrierName;o&&i.set(a.passengerId,o)}return{hidden:r,credits:i}}function _x(e){return G[e.toUpperCase()]??G.UNDOCUMENTED}var vx={horizons:tn.HORIZONS,sbdb:tn.SBDB,celestrak:tn.CELESTRAK,spacetrack:tn.SPACETRACK,spice:tn.SPICE,sbdb_moons:tn.SBDB_MOON,astersat:tn.ASTERSAT};function yx(e){return e?vx[e]??tn.UNKNOWN:tn.UNKNOWN}var bx=14;function xx(e,t){let n=t.global;if(!n?.orbit)return null;let r=n.orbit,i=r.scale===`planet`,a=r.q!=null,o=n.cross_refs?.norad_cat_id,s=r.bstar!=null&&r.mean_motion_dot!=null&&r.mean_motion_ddot!=null&&r.n!=null&&o!=null,c=i&&s?gg({noradCatId:o,epochJd:r.epoch_jd,meanMotion:r.n,eccentricity:r.e,inclination:r.i,raOfAscNode:r.om,argOfPericenter:r.w,meanAnomaly:r.ma??0,bstar:r.bstar,meanMotionDot:r.mean_motion_dot,meanMotionDdot:r.mean_motion_ddot,elementSetNo:r.element_set_no??0,revAtEpoch:r.rev_at_epoch??0},n.name??void 0)??void 0:void 0;return{id:e,name:t.localized?.name??n.name??n.sbdb_primary_designation??n.provisional_designation??null,objectType:_x(n.type),parentId:r.parent_id,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,a:i?(r.a??0)/rg:r.a??0,e:r.e,i:r.i,om:r.om,w:r.w,ma:r.ma??0,n:i?(r.n??0)*360:r.n??0,epoch:r.epoch_jd,equatorial:i,validityStart:c?r.epoch_jd-bx:-1/0,validityEnd:c?r.epoch_jd+bx:1/0,orbitalSource:yx(r.source),...a?{q:r.q,tp:r.tp}:{},...c?{satrec:c}:{}}}function Sx(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:_x(n.type),parentId:``,radiusKm:n.sbdb?.diameter?n.sbdb.diameter/2:NaN,hasLocalized:t.localized!=null,unplaceable:!0,a:NaN,e:NaN,i:NaN,om:NaN,w:NaN,ma:NaN,n:NaN,epoch:NaN,validityStart:-1/0,validityEnd:1/0,orbitalSource:tn.UNKNOWN}:null}async function Cx(e,t,n,r=new Set){if(r.has(e))return console.warn(`createPlaceholderBody: cycle detected at ${e} — hiding`),[];r.add(e);let i;try{i=await mx(e)}catch{return console.warn(`createPlaceholderBody: failed to fetch global data for ${e} — hiding`),[]}let a=i.global;if(!a)return console.warn(`createPlaceholderBody: no catalogue record for ${e} — hiding`),[];let o=a.sbdb?.class??null,s=t=>{let n=t?{...t,unplaceable:!0}:Sx(e,i);return n?[{body:{data:n,position:[0,0,0],positionUnknown:!0},zone:o}]:[]},c=xx(e,i);if(!c)return s();let l=c.satrec,u=c.q!=null,d=[],f=n.positions.get(c.parentId);if(!f){let e=await Cx(c.parentId,t,n,r),i=e[e.length-1];if(!i||i.body.positionUnknown)return[...e,...s(c)];f=i.body.position,n.positions.set(c.parentId,f),d.push(...e)}let p=l?yg(l,Mg(t)):u?Jv(c,t):Kv(c,t);if(!p)return console.warn(`Failed to compute position for ${e} (e=${c.e})`),[...d,...s(c)];let m=[f[0]+p[0],f[1]+p[1],f[2]+p[2]];return d.push({body:{data:c,position:m,orbitElements:c,orbitCenter:f},zone:o}),d}function wx(e,t,n,r){let i=0;for(let a=0;a<t.length;a++){let{body:o,zone:s}=t[a];if(e.getBody(o.data.id))continue;let c=o.data.objectType;if(o.data.unplaceable)e.bodies.addBodies([o]),i++;else{let l=a>0?t[a-1]:null,u=c===G.MOON&&l&&hn(l.body.data.objectType)?`small_body_moons`:s;if(c===G.SPACECRAFT||c===G.DEBRIS){let t=o.data.parentId;e.bodies.spacecraftBucket(t).set(o.data.id,o),r?.onPlaceholder?.(o),e.bodies.dirtySpacecraftGroups.add(t),i++}else u?(e.bodies.asteroidBucket(u,n).addPlaceholder(o),e.bodies.dirtyAsteroidZones.add(u),i++):e.bodies.addBodies([o])}e.credits.recordOrbitSources([o])}return i}async function Tx(e,t,n,r){if(e.getBody(t))return;let i=await Cx(t,n,r);if(i.length===0)return;let a=wx(e,i,await Bv());e.bodies.flushMinor(a>0)}var Ex=`spacemap.atmosphere-calibration`;function Dx(){try{let e=localStorage.getItem(Ex);return e?JSON.parse(e):null}catch{return null}}function Ox(e){try{e?localStorage.setItem(Ex,JSON.stringify(e)):localStorage.removeItem(Ex)}catch{}}function kx(){return Xe({resolvedReducedMotion:typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,viewMode:`map`,showClouds:!0,showAtmospheres:!0,atmosphereQuality:`auto`,atmosphereAutoTier:null,atmosphereCalibration:Dx(),atmoQualityOverrides:{},highAmbient:!1,realisticLighting:!1,overexposeRings:!1,showShapeMesh:!0,showSurfaceTexture:!0,showDisplacement:!0,showSelfShadow:!0,showHaloDebug:!1,maxPartsPerZone:0,setAtmosphereCalibration(e){this.atmosphereCalibration=e,Ox(e)},setAtmosphereAutoTier(e){this.atmosphereAutoTier=e}})}var Ax=null;function jx(){return Ax??=kx()}function Mx(e){Ax=e}var Nx=2e3,Px=3,Fx=class{zones=[];latestDate;failureStreak=0;staleNotified=!1;constructor(e,t,n,r){this.ctx=e,this.loader=n,this.latestDate=r;let i=Mg(r),a=jx().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 Ob(o)){if(s.shape===`chunked`||s.shape===`parted`)continue;let o=a>0?Math.min(s.parts,a):s.parts;if(Sb(s)){let i={kind:`time`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentTime:Mb(s,r),inFlight:null,lastLoadStartMs:-1/0,cap:a};this.zones.push(i),this.prefetchTimeNeighbors(i,r)}else if(Cb(s)){let a={kind:`chunk`,zone:n,zoom:e,parts:o,parentIdType:t,zoomData:s,currentIdx:Tb(s,i),inFlight:null,preloads:new Map};this.zones.push(a),this.preloadChunkNeighbors(a,r)}}}}recordSuccess(){this.failureStreak=0}recordFailure(){this.failureStreak++,this.failureStreak>=Px&&!this.staleNotified&&(this.staleNotified=!0,this.ctx.onDataStale?.())}invalidateZone(e){for(let t of this.zones)t.zone!==e||t.kind!==`time`||(t.currentTime=``,t.lastLoadStartMs=-1/0);this.tick(this.latestDate)}satelliteCoverage(e){let t=this.zones.find(e=>e.kind===`time`&&e.zone===`earth`);return t?Pb(t.zoomData,Ng(e)):{kind:`covered`}}tick(e){this.latestDate=e;let t=Mg(e);for(let n of this.zones)if(n.kind===`time`){if(n.inFlight)continue;let t=Mb(n.zoomData,e);if(t===n.currentTime)continue;let r=performance.now();if(r-n.lastLoadStartMs<Nx)continue;n.lastLoadStartMs=r,n.inFlight=this.loadTime(n,t,e).finally(()=>{n.inFlight=null})}else{for(;;){let r=Tb(n.zoomData,t);if(r===n.currentIdx)break;let i=n.preloads.get(r);if(i?.kind!==`ready`)break;let a=n.currentIdx;n.currentIdx=r,this.applyChunkSwap(n,a,r,i.bodies),this.preloadChunkNeighbors(n,e)}if(n.inFlight)continue;let r=Tb(n.zoomData,t);if(r===n.currentIdx)continue;n.inFlight=this.loadChunk(n,r,e).finally(()=>{n.inFlight=null})}}async ensureBody(e,t){if(!this.ctx.getBody(e)){if(e.startsWith(`probe-`)){let n=this.ctx.probeStore;if(!n)return;let r=Mg(t),i=hx(e);await n.ensure(r).done;let a=await i;a&&n.registerCarried(a);let o=n.stampedFitCenterAt(e,r);if(o){this.ctx.getBody(o)||await Tx(this.ctx,o,t,this.loader);let e=this.ctx.getBody(o);e&&!e.positionUnknown&&!this.loader.positions.has(o)&&this.loader.positions.set(o,e.position)}let s=await Bv(),c=this.loader.processProbes(n,t,s).find(t=>t.data.id===e);if(!c){await Tx(this.ctx,e,t,this.loader);return}this.ctx.bodies.addBodies([c]),this.ctx.credits.recordOrbitSources([c]),this.ctx.bodies.notifyBodiesAdded();return}await Tx(this.ctx,e,t,this.loader)}}async loadTime(e,t,n){let r=e.currentTime;try{let i=Fb(e.zoomData,t,e.cap),a=await Promise.all(Array.from({length:i},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,t,e.parentIdType))),o=e.zone===`earth`,s=o?this.ctx.earthSatFilter:null,c=o?this.ctx.earthTypeFilter:null,l=0,u=new Map;for(let t of a){this.ctx.credits.recordOrbitSources(t);for(let n of t){let t=n.data.objectType;if(t!==G.SPACECRAFT&&t!==G.DEBRIS){console.warn(`zone-refresher: unexpected non-spacecraft body in ${e.zone}: ${n.data.id} (type=${t})`);continue}if(s&&!s.has(n.data.id)){l++;continue}if(c&&!c.has(t)){l++;continue}let r=n.data.parentId,i=u.get(r);i||u.set(r,i=new Map),i.set(n.data.id,n)}}l>0&&console.log(`zone-refresher: ${e.zone}@${t}: filtered out ${l} non-member bodies`);let d=0,f=0,p=0;for(let[e,t]of u){let n=this.ctx.bodies.spacecraftBucket(e);for(let e of n.keys())t.has(e)||this.ctx.hasMeshBody?.(e)||(n.delete(e),p++);for(let[e,r]of t){let t=n.get(e);t?(t.data=r.data,t.position=r.position,r.orbitElements!==void 0&&(t.orbitElements=r.orbitElements),r.orbitCenter!==void 0&&(t.orbitCenter=r.orbitCenter),f++):(n.set(e,r),d++)}this.ctx.bodies.dirtySpacecraftGroups.add(e)}e.currentTime=t,this.ctx.bodies.minorBodyVersion++,d>0&&this.ctx.bodies.notifyBodiesAdded(),e.zone===`earth`&&this.ctx.notifyEarthSatRollover(),console.log(`zone-refresher: ${e.zone}@${r} → ${t} (+${d} ~${f} -${p})`),this.prefetchTimeNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: failed to refresh ${e.zone}@${t}:`,n),this.recordFailure()}}async loadChunk(e,t,n){let r=e.currentIdx;e.currentIdx=t;try{let i=e.preloads.get(t),a;a=i?.kind===`pending`?await i.promise:await Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,n,String(t),e.parentIdType))),this.applyChunkSwap(e,r,t,a),this.preloadChunkNeighbors(e,n),this.recordSuccess()}catch(n){console.warn(`zone-refresher: ${e.zone} chunk reload failed (${r} → ${t}):`,n),e.currentIdx=r,this.recordFailure()}}applyChunkSwap(e,t,n,r){let i=0,a=0;for(let e of r){this.ctx.credits.recordOrbitSources(e);for(let t of e){let e=this.ctx.bodies.bodiesById.get(t.data.id);if(!e){this.ctx.bodies.addBodies([t]),this.ctx.bodies.majorBodies.push(t),a++;continue}e.data=t.data,e.position=t.position,t.orbitElements!==void 0&&(e.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(e.orbitCenter=t.orbitCenter),i++}}this.ctx.bodies.minorBodyVersion++,console.log(`zone-refresher: ${e.zone} chunk ${t} → ${n} (+${a} ~${i})`)}preloadChunkNeighbors(e,t){let n=Math.max(0,e.currentIdx-1),r=Math.min(e.zoomData.chunks-1,e.currentIdx+1);for(let i=n;i<=r;i++){if(e.preloads.has(i))continue;let n=String(i),r=Promise.all(Array.from({length:e.parts},(r,i)=>this.loader.process(e.zone,e.zoom,i,t,n,e.parentIdType)));e.preloads.set(i,{kind:`pending`,promise:r}),r.then(t=>{e.preloads.get(i)?.kind===`pending`&&e.preloads.set(i,{kind:`ready`,bodies:t})},t=>{console.warn(`zone-refresher: ${e.zone} chunk ${i} preload failed:`,t),e.preloads.get(i)?.kind===`pending`&&e.preloads.delete(i)})}for(let t of e.preloads.keys())(t<n||t>r)&&e.preloads.delete(t)}prefetchTimeNeighbors(e,t){let n=864e5,r=Mb(e.zoomData,new Date(t.getTime()-n)),i=Mb(e.zoomData,new Date(t.getTime()+n));for(let t of new Set([r,i])){if(t===e.currentTime)continue;let n=Fb(e.zoomData,t,e.cap);for(let r=0;r<n;r++)lb.prefetch(e.zone,e.zoom,r,t)}}},Ix,Lx=new Promise(e=>{Ix=e});function Rx(){Ix()}var zx=4;function Bx(){return typeof navigator>`u`?!1:navigator.connection?.saveData===!0}function Vx(){if(typeof navigator>`u`)return!1;if(Bx())return!0;let e=navigator.deviceMemory;return typeof e==`number`&&e>0&&e<=zx}var Hx;function Ux(){return Hx===void 0&&(Hx=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches),Hx}function Wx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,2)}var Gx={low:{maxPixelRatio:1.25,shadowMapSize:1024,softShadows:!1,bloomScale:.5,pointBudget:4e5,maxTextureTier:`medium`,maxSkyboxFace:2048},medium:{maxPixelRatio:1.5,shadowMapSize:2048,softShadows:!0,bloomScale:.75,pointBudget:9e5,maxTextureTier:`medium`,maxSkyboxFace:2048},high:{maxPixelRatio:2,shadowMapSize:4096,softShadows:!0,bloomScale:1,pointBudget:1/0,maxTextureTier:`high`,maxSkyboxFace:1/0}};function Kx(){return Vx()?`low`:Jx().maxTextureTier}function qx(){let e=jx().atmosphereCalibration?.tier;return e===`low`||e===`medium`?e:e===`high`||e===`ultra`?`high`:Ux()?Vx()?`low`:`medium`:Vx()?`medium`:`high`}function Jx(){return Gx[qx()]}function Yx(){return typeof window>`u`?1:Math.min(window.devicePixelRatio,Jx().maxPixelRatio)}var Xx=Math.PI/180*ig,Zx=new Vi().setFromAxisAngle(new J(0,0,1),-Math.PI/2).premultiply(new Vi().setFromAxisAngle(new J(0,1,0),Math.PI/2-Xx)).premultiply(new Vi().setFromAxisAngle(new J(1,0,0),-Math.PI/2)),Qx=[`px`,`nx`,`py`,`ny`,`pz`,`nz`];function $x(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 eS(e,t,n){return Kt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function tS(e,t,n){return Promise.all(Qx.map(async r=>{let i=await fetch(eS(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 nS=new Map;function rS(e,t){return`${e}:${t}`}function iS(e,t,n){let r=rS(e,t),i=nS.get(r);return i||(i=tS(e,t,n),nS.set(r,i)),i}function aS(e,t,n){nS.delete(rS(e,t));for(let e of n)e.close()}function oS(e){let t=new jc(e);return t.colorSpace=Jr,t.needsUpdate=!0,t}function sS(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 cS(e){let t=sS(e);t&&iS(e.id,t).catch(()=>nS.delete(rS(e.id,t)))}var lS=12e3;async function uS(e,t,n){let r=$x(n,Math.min(t.capabilities.maxTextureSize,Jx().maxSkyboxFace));if(!r){console.warn(`Skybox ${n.id}: no tiers declared`);return}let i=sS(n),a={cube:null,bitmaps:null},o=!1;i&&i!==r&&iS(n.id,i).then(t=>{if(o){aS(n.id,i,t);return}a.cube=oS(t),a.bitmaps=t,e.background=a.cube,performance.mark(`sm-skybox-low`)}).catch(()=>{}),r!==i&&await Promise.race([Lx,new Promise(e=>setTimeout(e,lS))]);let s=await iS(n.id,r,r===i?void 0:`low`),c=oS(s);await new Promise(e=>`requestIdleCallback`in window?requestIdleCallback(()=>e(),{timeout:2e3}):setTimeout(e,500)),t.initTexture(c),o=!0;let l=e.background;e.background=c,performance.mark(`sm-skybox-high`),a.cube?.dispose(),l&&l!==a.cube&&l instanceof jc&&l.dispose(),aS(n.id,r,s),i&&i!==r&&a.bitmaps&&aS(n.id,i,a.bitmaps)}async function dS(e,t,n){if(!n?.layers.skipped.has(`stars`))try{let r=await Lb();if(!r.skybox)return;n&&(n.credits.skybox={source:r.skybox.source,organisation:r.skybox.organisation,license:r.skybox.license,attribution:r.skybox.attribution,description:r.skybox.description}),await uS(e,t,r.skybox)}catch(e){console.warn(`Failed to load skybox:`,e)}}var fS=13;function pS(e,t,n){let r=jx().maxPartsPerZone,i=[],a=[];for(let[o,s]of Object.entries(e.position.zones)){if(o===`major`||o===`moons`||o===`spacecraft`||Eb(s)||n.skipsZone(o))continue;let e=s.parent_id_type??`naif`;for(let{zoom:n,data:c}of Ob(s)){if(c.shape===`chunked`)continue;let s=Sb(c)?Mb(c,t):null,l=Sb(c)&&s!==null?Fb(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>=fS?a.push(r):i.push(r)}}}return{eager:i,deferred:a}}async function mS(e,t,n){let r=zb(e);for(let e of r.keys())n.skipsZone(e)&&r.delete(e);if(r.size===0)return null;console.log(`ProbeStore: ${r.size} zone(s) from metadata:\n`+Array.from(r).map(([e,t])=>` ${e}: chunks=${t.chunks} chunk_days=${t.chunk_days} fit_center=naif-${t.fit_center_naif_id} float64=${t.float64_coeffs}`).join(`
4052
+ `));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 Qb(r);return await a.ensure(t).done,a}async function hS(e,t,n,r,i,a){let o=[],s=null;e.chebStore&&(s=await Bv(),o.push(...t.processChebyshev(r,s))),e.probeStore&&(s??=await Bv(),a&&e.probeStore.registerCarried(a),o.push(...t.processProbes(e.probeStore,r,s)));let c=n.position.zones.major;if(c&&Db(c))for(let e of[1,2]){let n=c.zooms[String(e)];if(n&&xb(n))for(let i=0;i<n.parts;i++)o.push(...await t.process(`major`,e,i,r))}let l=e.layers.skipsZone(`moons`)?void 0:n.position.zones.moons,u=l?kb(l):void 0,d=u&&Cb(u)?String(Tb(u,i)):null;return u&&o.push(...await t.process(`moons`,null,0,r,d)),gS(o)}function gS(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 _S(e,t,n){performance.mark(`sm-load-start`),H_.reset(),Y_().catch(e=>console.warn(`scene-load: systems-global (GMs/nutation) failed to load:`,e));let r=hb().catch(e=>console.warn(`scene-load: atmospheres failed to load — rendering without shells:`,e)),i=Mg(t),a=Lb();Bv().catch(()=>{}),a.then(t=>{let n=t.position.zones.moons;if(!n||e.layers.skipsZone(`moons`))return;let r=kb(n);r&&xb(r)&&lb.prefetch(`moons`,null,0,null)}),a.then(t=>{t.skybox&&!e.layers.skipped.has(`stars`)&&cS(t.skybox)});let o=a.then(n=>pS(n,t,e.layers)),s=a.then(async t=>{let n=Rb(t);for(let t of n.keys())e.layers.skipsZone(t)&&n.delete(t);if(n.size===0)return null;let r=new qb(n);return await r.ensure(i).done,r}),c=a.then(t=>mS(t,i,e.layers)),l=hx(n),u=await a;H_.reach(`metadata`),e.chebStore=await s,e.probeStore=await c,H_.reach(`ephemeris`);let d=new lb(e.chebStore);e.probeStore&&(e.probeStore.fitCenterUsable=t=>(e.chebStore?.has(t)??!1)||(e.hasMeshBody?.(t)??!1)||d.positions.has(t));let f=await hS(e,d,u,t,i,await l);H_.reach(`majors`),await r,e.bodies.addBodies(f),e.credits.recordOrbitSources(f);let p=await Bv();H_.reach(`labels`);let m=new Map,h=!1,g=()=>{h=!0},_=()=>{let t=h;h=!1,e.bodies.flushMinor(t)};if(n&&!e.getBody(n)){let r=await Cx(n,t,d);wx(e,r,p,{onPlaceholder:e=>m.set(e.data.id,e)})>0&&g(),r.length>0&&_()}e.bodies.majorBodies=f.filter(e=>e.data.objectType!==G.BARYCENTER&&e.data.objectType!==G.LAGRANGE_POINT&&e.data.orbitalSource!==tn.SPICE_PROBE),H_.reach(`done`),e.loading=!1,performance.mark(`sm-majors-done`);let{eager:v,deferred:y}=await o,b=v.filter(e=>e.zone===`small_body_moons`),x=v.filter(e=>e.zone!==`small_body_moons`);for(let e of b)try{await d.seedNeededParents(e.zone,e.zoom,e.part,e.time,e.parentIdType)}catch(t){console.warn(`scene-load: seedNeededParents failed for ${e.zone} part ${e.part}:`,t)}e.bodies.minorStreaming=!0;let S=setInterval(_,500),C=async(t,n,r)=>{e.credits.recordOrbitSource(n.source),n.rowCount!==0&&(await e.bodies.asteroidBucket(t,p).addChunk(n,r)>0&&g(),e.bodies.dirtyAsteroidZones.add(t))},w=(t,n)=>{e.credits.recordOrbitSources(n);let r=t===`earth`,i=r?e.earthSatFilter:null,a=r?e.earthTypeFilter:null;for(let t of n){if(i&&!i.has(t.data.id)||a&&!a.has(t.data.objectType))continue;let n=m.get(t.data.id);if(n){n.data=t.data,n.position=t.position,t.orbitElements!==void 0&&(n.orbitElements=t.orbitElements),t.orbitCenter!==void 0&&(n.orbitCenter=t.orbitCenter),m.delete(t.data.id),e.bodies.dirtySpacecraftGroups.add(t.data.parentId);continue}let r=t.data.parentId,o=e.bodies.spacecraftBucket(r);o.has(t.data.id)||g(),o.set(t.data.id,t),e.bodies.dirtySpacecraftGroups.add(r)}},T=(t,n)=>{e.credits.recordOrbitSources(n);let r=e.bodies.asteroidBucket(t,p);for(let e of n)r.addPlaceholder(e),g();e.bodies.dirtyAsteroidZones.add(t)},E=x.filter(e=>e.zone.startsWith(`small_bodies/`)),D=x.filter(e=>!e.zone.startsWith(`small_bodies/`)),O=new Set,k=(e,t)=>n=>{O.add(e),console.warn(`scene-load: ${e} part ${t} failed (skipped):`,n)};try{await Promise.all([...E.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a).then(t=>C(e,t,a)).catch(k(e,r))),...D.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a,new Set(m.keys()),`high`).then(t=>w(e,t)).catch(k(e,r)))]),await Promise.all(b.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.process(e,n,r,t,i,a).then(t=>T(e,t)).catch(k(e,r))))}finally{clearInterval(S),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-minors-done`),Rx()}if(y.length>0&&Vx())console.info(`Low-end device: skipping ${y.length} deferred minor-belt parts to conserve memory`);else if(y.length>0){e.bodies.minorStreaming=!0;let n=setInterval(_,1e3);try{await Promise.all(y.map(({zone:e,zoom:n,part:r,time:i,parentIdType:a})=>d.fetchMinorColumns(e,n,r,t,i,a,`low`).then(t=>C(e,t,a)).catch(k(e,r))))}finally{clearInterval(n),e.bodies.minorStreaming=!1,_(),performance.mark(`sm-deferred-done`)}}try{e.refresher=new Fx(e,await a,d,t);for(let t of O)e.refresher.invalidateZone(t)}catch(e){console.error(`scene-load: ZoneRefresher init failed; hot-reload disabled:`,e)}}var vS=ix(async()=>(await Lb(),Kt(`/v1/membership/earth.json.gz`,`membership`)),{onMissing:()=>({}),error:e=>`fetchEarthMembership: ${e.status} ${e.statusText}`});async function yS(e){let t=await vS();return new Set(t[e]??[])}function bS(e,t=s()){return fx(lx,e,t)}var xS={[sv]:new Set([G.SPACECRAFT]),[cv]:new Set([G.DEBRIS])},SS=class{bodies=new F_;credits=new xn;layers=new Sv;visibility=new Iv(this.bodies,()=>this.probeStore,()=>this.earthSatFilter,()=>this.smallBodyFilter,()=>this.layers);#e=We(!0);get loading(){return Bt(this.#e)}set loading(e){Ge(this.#e,e,!0)}#t=We(null);get error(){return Bt(this.#t)}set error(e){Ge(this.#t,e,!0)}onDataStale=null;constructor(){}chebStore=null;probeStore=null;refresher=null;hasMeshBody=null;earthSatFilter=null;earthSatFilterSlug=null;earthTypeFilter=null;smallBodyFilter=null;missionMemberIds=null;currentGroupSlug=null;groupFilterListeners=new Set;smallBodyFilterListeners=new Set;earthSatRolloverListeners=new Set;onGroupFilterChange(e){return this.groupFilterListeners.add(e),()=>this.groupFilterListeners.delete(e)}onSmallBodyFilterChange(e){return this.smallBodyFilterListeners.add(e),()=>this.smallBodyFilterListeners.delete(e)}onEarthSatRollover(e){return this.earthSatRolloverListeners.add(e),()=>this.earthSatRolloverListeners.delete(e)}notifyEarthSatRollover(){for(let e of this.earthSatRolloverListeners)e()}getBody(e,t){return this.bodies.getBody(e,t)}isMemberOfActiveGroup(e){if(this.missionMemberIds?.has(e)===!0||this.earthSatFilter?.has(e)===!0)return!0;let t=this.earthTypeFilter;if(t){let n=this.bodies.getBody(e)?.data.objectType;if(n!==void 0&&t.has(n))return!0}let n=this.smallBodyFilter;return n===null?!1:Ev(this.bodies,e,n)}async load(e,t){try{await _S(this,e,t)}catch(e){throw this.loading=!1,this.error=e instanceof Error?e.message:String(e),console.error(`[scene-load]`,e),e}}refreshTick(e){this.refresher?.tick(e)}async ensureBody(e,t){await this.refresher?.ensureBody(e,t)}async applyGroupFilter(e){if(e===this.currentGroupSlug)return;if(this.currentGroupSlug=e,e?.startsWith(`mission-`)){let t=await bS(e);if(e!==this.currentGroupSlug)return;this.missionMemberIds=new Set((t.global?.notable_members??[]).map(e=>e.id).filter(e=>!!e))}else this.missionMemberIds=null;let t=e?await this.resolveIndexEntry(e):null;if(e!==this.currentGroupSlug)return;let n=this.resolveSmallBodyFilter(e,t?.applies_to,t?.n),r=t?.applies_to===`earth_sat`?e:null,i=xS[e??``]??null;if(!fv(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 yS(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(f_),this.bodies.dirtySpacecraftGroups.add(f_),this.bodies.minorBodyVersion++,this.refresher?.invalidateZone(`earth`))}}resolveSmallBodyFilter(e,t,n){if(e===av)return{kind:`category`,category:`asteroid`};if(e===ov)return{kind:`category`,category:`comet`};if(e===null||t!==`small_body`)return null;if(e.startsWith(`class-`))return{kind:`class`,className:e.slice(nv.length)};if(e.startsWith(`flag-`)){let t=e.slice(rv.length),r=lv[t];return r===void 0?null:{kind:`flag`,flag:t,mask:r,n:n??0}}return null}async resolveIndexEntry(e){try{return(await mv())[e]??null}catch{return null}}},CS=400,wS=class{#e=We(0);get jd(){return Bt(this.#e)}set jd(e){Ge(this.#e,e,!0)}#t=We(1);get timeScale(){return Bt(this.#t)}set timeScale(e){Ge(this.#t,e,!0)}#n=We(1);get direction(){return Bt(this.#n)}set direction(e){Ge(this.#n,e,!0)}seeked=!1;#r=We(0);get jumps(){return Bt(this.#r)}set jumps(e){Ge(this.#r,e,!0)}#i=We(0);get settledJd(){return Bt(this.#i)}set settledJd(e){Ge(this.#i,e,!0)}#a=We(!1);get live(){return Bt(this.#a)}set live(e){Ge(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/Ag*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(),CS))}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(Mg(new Date)),this.live=this.timeScale===1}get playing(){return this.timeScale!==0}get date(){return Ng(this.jd)}setDate(e){this.jumpTo(Mg(e))}},TS={type:`change`},ES={type:`start`},DS={type:`end`},OS=new gs,kS=new ac,AS=Math.cos(70*Bi.DEG2RAD),jS=new J,MS=2*Math.PI,NS={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},PS=1e-6,FS=class extends Gd{constructor(e,t=null){super(e,t),this.state=NS.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:Sn.ROTATE,MIDDLE:Sn.DOLLY,RIGHT:Sn.PAN},this.touches={ONE:Cn.ROTATE,TWO:Cn.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 Vi,this._lastTargetPosition=new J,this._quat=new Vi().setFromUnitVectors(e.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Bd,this._sphericalDelta=new Bd,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=LS.bind(this),this._onPointerDown=IS.bind(this),this._onPointerUp=RS.bind(this),this._onContextMenu=GS.bind(this),this._onMouseWheel=VS.bind(this),this._onKeyDown=HS.bind(this),this._onTouchStart=US.bind(this),this._onTouchMove=WS.bind(this),this._onMouseDown=zS.bind(this),this._onMouseMove=BS.bind(this),this._interceptControlDown=KS.bind(this),this._interceptControlUp=qS.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(TS),this.update(),this.state=NS.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;jS.copy(t).sub(this.target),jS.applyQuaternion(this._quat),this._spherical.setFromVector3(jS),this.autoRotate&&this.state===NS.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+=MS:n>Math.PI&&(n-=MS),r<-Math.PI?r+=MS:r>Math.PI&&(r-=MS),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(jS.setFromSpherical(this._spherical),jS.applyQuaternion(this._quatInverse),t.copy(this.target).add(jS),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=jS.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=jS.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):(OS.origin.copy(this.object.position),OS.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(OS.direction))<AS?this.object.lookAt(this.target):(kS.setFromNormalAndCoplanarPoint(this.object.up,this.target),OS.intersectPlane(kS,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)>PS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>PS||this._lastTargetPosition.distanceToSquared(this.target)>PS?(this.dispatchEvent(TS),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?MS/60/60*this.autoRotateSpeed:MS/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){jS.setFromMatrixColumn(t,0),jS.multiplyScalar(-e),this._panOffset.add(jS)}_panUp(e,t){this.screenSpacePanning===!0?jS.setFromMatrixColumn(t,1):(jS.setFromMatrixColumn(t,0),jS.crossVectors(this.object.up,jS)),jS.multiplyScalar(e),this._panOffset.add(jS)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;jS.copy(r).sub(this.target);let i=jS.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(MS*this._rotateDelta.x/t.clientHeight),this._rotateUp(MS*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(MS*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(-MS*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(MS*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(-MS*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(MS*this._rotateDelta.x/t.clientHeight),this._rotateUp(MS*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 IS(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 LS(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function RS(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(DS),this.state=NS.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 zS(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 Sn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=NS.DOLLY;break;case Sn.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=NS.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=NS.ROTATE}break;case Sn.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=NS.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=NS.PAN}break;default:this.state=NS.NONE}this.state!==NS.NONE&&this.dispatchEvent(ES)}function BS(e){switch(this.state){case NS.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case NS.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case NS.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function VS(e){this.enabled===!1||this.enableZoom===!1||this.state!==NS.NONE||(e.preventDefault(),this.dispatchEvent(ES),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(DS))}function HS(e){this.enabled!==!1&&this._handleKeyDown(e)}function US(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Cn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=NS.TOUCH_ROTATE;break;case Cn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=NS.TOUCH_PAN;break;default:this.state=NS.NONE}break;case 2:switch(this.touches.TWO){case Cn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=NS.TOUCH_DOLLY_PAN;break;case Cn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=NS.TOUCH_DOLLY_ROTATE;break;default:this.state=NS.NONE}break;default:this.state=NS.NONE}this.state!==NS.NONE&&this.dispatchEvent(ES)}function WS(e){switch(this._trackPointer(e),this.state){case NS.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case NS.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case NS.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case NS.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=NS.NONE}}function GS(e){this.enabled!==!1&&e.preventDefault()}function KS(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function qS(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var{PI:JS,sin:YS,cos:XS,asin:ZS,atan2:QS,sqrt:$S}=Math,eC=180/JS,tC=JS/180;function nC(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 rC(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=$S(r*r+i*i+a*a);return n&&([r,i,a]=nC([r,i,a],n,!0)),{latitude:ZS(i/o)*eC,longitude:n?QS(-a,r)*eC:QS(r,a)*eC,distance:o}}function iC(e,t,n,r,i){let a=t*tC,o=n*tC,s,c,l;if(i){let e=[r*XS(a)*XS(o),r*YS(a),-r*XS(a)*YS(o)];[s,c,l]=nC(e,i,!1)}else s=r*XS(a)*YS(o),c=r*YS(a),l=r*XS(a)*XS(o);return[e[0]+s,e[1]+c,e[2]+l]}function aC(e,t,n,r){let i=e[0]-t[0],a=e[2]-t[2],o=$S(i*i+a*a);o>0?(i/=o,a/=o):(i=0,a=1);let s=n*tC,c=XS(s);return[r*c*i,r*YS(s),r*c*a]}function oC(e){let t=(e+180)%360-180;return t<=-180?t+360:t}function sC(e,t,n){if(t===void 0&&n===void 0)return e;let r=t===void 0?-180:oC(t),i=r===180?-180:r,a=n===void 0?180:oC(n);if(i<=a?e>=i&&e<=a:e>=i||e<=a)return e;let o=(e,t)=>Math.abs(oC(e-t));return o(e,i)<=o(e,a)?i:a}var cC=f_,lC=Math.PI/180,uC=2451545,dC=36525;function fC(e,t,n){let r=t-uC,i=r/dC,a=e.pole_ra_0+e.pole_ra_1*i,o=e.pole_dec_0+e.pole_dec_1*i,s=e.w0+e.w1*r+e.w2*r*r;if(n){let{ra:e,dec:t,pm:r,angles:c}=n,l=Math.min(c.length>>1,Math.max(e.length,t.length,r.length));for(let n=0;n<l;n++){let l=(c[2*n]+c[2*n+1]*i)*lC,u=Math.sin(l);n<e.length&&(a+=e[n]*u),n<t.length&&(o+=t[n]*Math.cos(l)),n<r.length&&(s+=r[n]*u)}}let c=a*lC,l=o*lC,u=Math.cos(l),d=ug(u*Math.cos(c),u*Math.sin(c),Math.sin(l),new J).normalize(),f=ug(-Math.sin(c),Math.cos(c),0,new J).normalize(),p=new J().crossVectors(f,d).normalize(),m=new Vi().setFromRotationMatrix(new Y().makeBasis(f,d,p));return new Vi().setFromAxisAngle(d,s*lC).multiply(m)}function pC(e,t,n,r){e.quaternion.copy(fC(t,n,r))}var mC=new J(0,1,0),hC=new J;function gC(e,t,n){hC.set(t[0]-n[0],t[1]-n[1],t[2]-n[2]),!(hC.lengthSq()<1e-20)&&(hC.normalize(),e.quaternion.setFromUnitVectors(mC,hC))}function _C(e,t){e.quaternion.setFromUnitVectors(mC,t)}var vC={"+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 yC(e){let t=[];for(let[n,r]of Object.entries(e)){let e=vC[n],i=vC[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 Vi().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 Vi().setFromRotationMatrix(c.multiply(l))}var bC=new J,xC=new J,SC=new J,CC=new J,wC=new J,TC=new J,EC=new J,DC=new J,OC=new Y,kC=new Y;function AC(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 jC(e,t,n){if(!AC(t.primary.target,n,bC))return;let r=vC[t.primary.axis],i=t.secondary;if(!i||!AC(i.target,n,xC)){e.quaternion.setFromUnitVectors(r,bC);return}if(wC.crossVectors(r,vC[i.axis]),DC.crossVectors(bC,xC),wC.lengthSq()<1e-20||DC.lengthSq()<1e-20){e.quaternion.setFromUnitVectors(r,bC);return}wC.normalize(),DC.normalize(),SC.copy(r),TC.copy(bC),CC.crossVectors(wC,SC),EC.crossVectors(DC,TC),OC.makeBasis(TC,EC,DC),kC.makeBasis(SC,CC,wC).transpose(),OC.multiply(kC),e.quaternion.setFromRotationMatrix(OC)}function MC(e,t){let n=e,r=n.userData.shaderMods??=[];r.includes(t)||(r.push(t),e.customProgramCacheKey=()=>r.join(`|`))}function NC(e,t,n){let r=e.onBeforeCompile;e.onBeforeCompile=(e,t)=>{r?.(e,t),n(e,t)},MC(e,t),e.needsUpdate=!0}var PC={uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new oa)}},FC=`
4053
4053
  #define ECLIPSE_MAX_OCCLUDERS 32
4054
4054
  uniform float uSunAngularRadius;
4055
4055
  uniform int uOccluderCount;
@@ -4101,20 +4101,20 @@ void main() {
4101
4101
  }
4102
4102
  return result;
4103
4103
  }
4104
- `;function FC(){return NC}function IC(){return{uEclipseSelfPos:{value:new J},uOccluders:{value:Array.from({length:32},()=>new oa)},uOccluderCount:{value:0}}}function LC(e,t,n,r){let i=NC.uSunAngularRadius.value,a=NC.uOccluders.value,o=NC.uOccluderCount.value,s=0;for(let c=0;c<o;c++){let o=a[c],l=o.x-t.x,u=o.y-t.y,d=o.z-t.z,f=l*l+u*u+d*d;if(f<o.w*o.w*.25)continue;let p=l*r.x+u*r.y+d*r.z;if(p<-(n+o.w))continue;let m=n+o.w+i*(p+n)*1.5;f-p*p>m*m||e[s++].copy(o)}return s}function RC(e,t){let n=NC.uSunAngularRadius.value;if(n<=0)return 1;let r=NC.uSunDir.value,i=NC.uOccluderCount.value,a=NC.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)),v=Math.acos(_);if(g>10*n){let e=(g-v)/n;if(e>=1)return 0;if(e<=-1)continue;let t=(Math.acos(-e)+e*Math.sqrt(Math.max(1-e*e,0)))/Math.PI;o*=1-t;continue}if(v>=n+g)continue;if(v+n<=g)return 0;if(v+g<=n){o*=1-g*g/(n*n);continue}let y=n,b=g,x=v,S=(x*x+y*y-b*b)/(2*x),C=Math.sqrt(Math.max(y*y-S*S,0)),w=y*y*Math.acos(Math.max(-1,Math.min(1,S/y)))+b*b*Math.acos(Math.max(-1,Math.min(1,(x-S)/b)))-x*C;o*=1-w/(Math.PI*y*y)}return o}function zC(e,t){let n=t??IC();return MC(e,`eclipse`,e=>{Object.assign(e.uniforms,NC,n),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4104
+ `;function IC(){return PC}function LC(){return{uEclipseSelfPos:{value:new J},uOccluders:{value:Array.from({length:32},()=>new oa)},uOccluderCount:{value:0}}}function RC(e,t,n,r){let i=PC.uSunAngularRadius.value,a=PC.uOccluders.value,o=PC.uOccluderCount.value,s=0;for(let c=0;c<o;c++){let o=a[c],l=o.x-t.x,u=o.y-t.y,d=o.z-t.z,f=l*l+u*u+d*d;if(f<o.w*o.w*.25)continue;let p=l*r.x+u*r.y+d*r.z;if(p<-(n+o.w))continue;let m=n+o.w+i*(p+n)*1.5;f-p*p>m*m||e[s++].copy(o)}return s}function zC(e,t){let n=PC.uSunAngularRadius.value;if(n<=0)return 1;let r=PC.uSunDir.value,i=PC.uOccluderCount.value,a=PC.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)),v=Math.acos(_);if(g>10*n){let e=(g-v)/n;if(e>=1)return 0;if(e<=-1)continue;let t=(Math.acos(-e)+e*Math.sqrt(Math.max(1-e*e,0)))/Math.PI;o*=1-t;continue}if(v>=n+g)continue;if(v+n<=g)return 0;if(v+g<=n){o*=1-g*g/(n*n);continue}let y=n,b=g,x=v,S=(x*x+y*y-b*b)/(2*x),C=Math.sqrt(Math.max(y*y-S*S,0)),w=y*y*Math.acos(Math.max(-1,Math.min(1,S/y)))+b*b*Math.acos(Math.max(-1,Math.min(1,(x-S)/b)))-x*C;o*=1-w/(Math.PI*y*y)}return o}function BC(e,t){let n=t??LC();return NC(e,`eclipse`,e=>{Object.assign(e.uniforms,PC,n),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4105
4105
  varying vec3 vEclipseWorldPos;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
4106
4106
  vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
4107
4107
  uniform vec3 uSunDir;
4108
4108
  uniform vec3 uEclipseSelfPos;
4109
4109
  varying vec3 vEclipseWorldPos;
4110
- ${PC}
4110
+ ${FC}
4111
4111
  float eclipseFactor() {
4112
4112
  return eclipseFactorAt(vEclipseWorldPos, uEclipseSelfPos, uSunDir);
4113
4113
  }
4114
4114
  `).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
4115
4115
  float eclipseShadow = eclipseFactor();
4116
4116
  reflectedLight.directDiffuse *= eclipseShadow;
4117
- reflectedLight.directSpecular *= eclipseShadow;`)}),n}var BC=32,VC=1,HC=2,UC=1.5,WC=4,GC=.04,KC=.02,qC=-.08,JC=.18;function YC(e,t,n,r){let i=t.image,a=new q(1/(i?.width??4096),1/(i?.height??2048)),o=e.userData.selfShadow;if(o)return o.uSelfHeightMap.value=t,o.uSelfScale.value=n,o.uSelfTexel.value.copy(a),o;let s={uSelfHeightMap:{value:t},uSelfScale:{value:n},uSelfTexel:{value:a}};e.userData.selfShadow=s;let c=r??FC().uSunDir;return MC(e,`selfShadow`,e=>{Object.assign(e.uniforms,s,{uSelfSunDir:c}),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4117
+ reflectedLight.directSpecular *= eclipseShadow;`)}),n}var VC=32,HC=1,UC=2,WC=1.5,GC=4,KC=.04,qC=.02,JC=-.08,YC=.18;function XC(e,t,n,r){let i=t.image,a=new q(1/(i?.width??4096),1/(i?.height??2048)),o=e.userData.selfShadow;if(o)return o.uSelfHeightMap.value=t,o.uSelfScale.value=n,o.uSelfTexel.value.copy(a),o;let s={uSelfHeightMap:{value:t},uSelfScale:{value:n},uSelfTexel:{value:a}};e.userData.selfShadow=s;let c=r??IC().uSunDir;return NC(e,`selfShadow`,e=>{Object.assign(e.uniforms,s,{uSelfSunDir:c}),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4118
4118
  varying vec3 vSelfWorldNormal;
4119
4119
  varying vec2 vSelfUv;
4120
4120
  varying vec3 vSelfEastW;
@@ -4133,7 +4133,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4133
4133
  vSelfNorthW = normalize(mat3(modelMatrix) * cross(nObj, eastObj));
4134
4134
  vSelfRadiusW = length(mat3(modelMatrix) * position);
4135
4135
  vSelfCosLat = cl;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
4136
- #define SELF_STEPS ${BC}
4136
+ #define SELF_STEPS ${VC}
4137
4137
  uniform sampler2D uSelfHeightMap;
4138
4138
  uniform float uSelfScale;
4139
4139
  uniform vec2 uSelfTexel;
@@ -4167,18 +4167,18 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4167
4167
  // Wider-than-one-texel stencil averages out 8-bit terracing, floored
4168
4168
  // at the low tier's texel so a higher-res map keeps the same
4169
4169
  // physical smoothing width instead of flattening the relief.
4170
- vec2 d = max(uSelfTexel, vec2(1.0 / 2048.0, 1.0 / 1024.0)) * ${HC.toFixed(3)};
4170
+ vec2 d = max(uSelfTexel, vec2(1.0 / 2048.0, 1.0 / 1024.0)) * ${UC.toFixed(3)};
4171
4171
  float hu = selfHeight(vSelfUv + vec2(d.x, 0.0))
4172
4172
  - selfHeight(vSelfUv - vec2(d.x, 0.0));
4173
4173
  float hv = selfHeight(vSelfUv + vec2(0.0, d.y))
4174
4174
  - selfHeight(vSelfUv - vec2(0.0, d.y));
4175
4175
  // Slope = Δheight / Δworld-distance along each axis.
4176
- float su = ${VC.toFixed(3)} * hu / (2.0 * d.x * lenTu);
4177
- float sv = ${VC.toFixed(3)} * hv / (2.0 * d.y * lenTv);
4176
+ float su = ${HC.toFixed(3)} * hu / (2.0 * d.x * lenTu);
4177
+ float sv = ${HC.toFixed(3)} * hv / (2.0 * d.y * lenTv);
4178
4178
  // |Tu|/|Tv|=2·cos(lat): fade relief at the poles, where |Tu|→0 blows up east-west slope into a starburst.
4179
4179
  float poleFade = smoothstep(0.0, 0.12, lenTu / (2.0 * lenTv));
4180
- su = clamp(su * poleFade, -${UC.toFixed(3)}, ${UC.toFixed(3)});
4181
- sv = clamp(sv * poleFade, -${UC.toFixed(3)}, ${UC.toFixed(3)});
4180
+ su = clamp(su * poleFade, -${WC.toFixed(3)}, ${WC.toFixed(3)});
4181
+ sv = clamp(sv * poleFade, -${WC.toFixed(3)}, ${WC.toFixed(3)});
4182
4182
  vec3 reliefN = cross(Tu / lenTu + Nw * su, Tv / lenTv + Nw * sv);
4183
4183
  float rl = length(reliefN);
4184
4184
  if (rl > 1e-12) {
@@ -4195,7 +4195,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4195
4195
  // Gate on the GEOMETRIC normal: the relief normal can tilt sunward
4196
4196
  // past the terminator and light the night side. Fading direct light
4197
4197
  // by geometric N·L keeps the night dark regardless.
4198
- float shadow = smoothstep(${qC.toFixed(3)}, ${KC.toFixed(3)}, gN);
4198
+ float shadow = smoothstep(${JC.toFixed(3)}, ${qC.toFixed(3)}, gN);
4199
4199
  vec3 Tu, Tv;
4200
4200
  selfTangents(Tu, Tv);
4201
4201
  float lenTu = length(Tu);
@@ -4207,7 +4207,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4207
4207
  float lv = dot(L, Tv / lenTv);
4208
4208
  float lh = sqrt(lu * lu + lv * lv);
4209
4209
  if (lh > 1e-4) {
4210
- float ds = ${WC.toFixed(3)} * uSelfScale / float(SELF_STEPS);
4210
+ float ds = ${GC.toFixed(3)} * uSelfScale / float(SELF_STEPS);
4211
4211
  // World step → uv step via the per-axis metric (|Tu|, |Tv|).
4212
4212
  vec2 stepUv = ds * vec2((lu / lh) / lenTu, (lv / lh) / lenTv);
4213
4213
  float h0 = selfHeight(vSelfUv);
@@ -4220,13 +4220,13 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4220
4220
  }
4221
4221
  // Fade the march out at grazing angles: a near-horizontal ray
4222
4222
  // occludes every away-facing slope, banding the terminator.
4223
- float marchFade = smoothstep(0.0, ${JC.toFixed(3)}, gN);
4224
- shadow *= 1.0 - marchFade * clamp(block / (${GC.toFixed(3)} * uSelfScale), 0.0, 1.0);
4223
+ float marchFade = smoothstep(0.0, ${YC.toFixed(3)}, gN);
4224
+ shadow *= 1.0 - marchFade * clamp(block / (${KC.toFixed(3)} * uSelfScale), 0.0, 1.0);
4225
4225
  }
4226
4226
  }
4227
4227
  reflectedLight.directDiffuse *= shadow;
4228
4228
  reflectedLight.directSpecular *= shadow;
4229
- }`)}),s}function XC(e){e&&(e.uSelfHeightMap.value=null,e.uSelfScale.value=0)}async function ZC(e,t,n,r,i,a=Q(1)){let o=QC(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,e.displacementScale=t.scale_km*a,e.displacementBias=t.bias_km*a-(t.absolute_radius?i:0),e.needsUpdate=!0,s}function QC(e,t){return Kt(`/v1/textures/${e.id}/${t}.webp`,`textures`)}async function $C(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 ew=4e6;async function tw(e,t,n){let r=e.width,i=Math.max(1,Math.floor(ew/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}async function nw(e,t){let n=e.displacementMeta;if(!(!n||!e.mesh||e.displacementLoading||e.displacementTier===t)){e.displacementLoading=!0;try{let r=await $C(QC(n,t));if(!r)return;let i=r.width,a=r.height,o=await tw(r,0,a-1);if(r.close(),!o||!e.mesh||!e.displacementMap)return;let s=new Uint8Array(i);for(let e=0;e<a>>1;e++){let t=o.subarray(e*i,(e+1)*i),n=o.subarray((a-1-e)*i,(a-e)*i);s.set(t),t.set(n),n.set(s)}let c=new Us(o,i,a,Qn,Pn);c.colorSpace=``,c.magFilter=jn,c.minFilter=jn,c.generateMipmaps=!1,c.unpackAlignment=1,c.needsUpdate=!0;let l=e.mesh.material,u=l.displacementMap;l.displacementMap=c,e.displacementMap=c,e.displacementTier=t,e.selfShadow&&YC(l,c,Q(n.scale_km)),u&&u!==c&&u.dispose()}finally{e.displacementLoading=!1}}}function rw(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;return(h*(1-c)+g*c)/255}function iw(e){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.needsUpdate=!0)}function aw(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 ow(e,t){let n=Math.cos(e);return[n*Math.cos(t),Math.sin(e),-n*Math.sin(t)]}function sw(e,t,n,r,i,a,o){let s=(r+n)/r,[c,l,u]=ow(e,t);return[s*i*c,s*o*l,s*a*u]}function cw(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}=e,a=Math.PI/2-t,o=(n-Math.PI)%(2*Math.PI);o<0&&(o+=2*Math.PI);let s=aw(r,a),c=aw(i,o),l=Math.min(Math.max((a-r[s])/(r[s+1]-r[s]),0),1),u=Math.min(Math.max((o-i[c])/(i[c+1]-i[c]),0),1);return{corners:[[s,c],[s,c+1],[s+1,c],[s+1,c+1]].map(([e,t])=>({latRad:Math.PI/2-r[e],lonRad:i[t]+Math.PI})),tx:u,ty:l}}function lw(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 uw(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 dw(e,t,n){let{p0:r,n:i}=uw(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 fw=new Map,pw=new Map,mw=0;function hw(){return mw}var gw=6;function _w(){let e=0;for(let t of fw.values())t!==`failed`&&e++;for(let[t,n]of fw){if(e<=gw)break;n!==`failed`&&(fw.delete(t),e--)}}function vw(e,t){let n=pw.get(e);return n||(n=(async()=>{let n=await $C(QC(t,`low`)),r=n&&await tw(n,0,n.height-1);if(!n||!r)return n?.close(),fw.set(e,`failed`),null;let i={data:r,width:n.width,height:n.height,bottomUp:!1};return n.close(),fw.set(e,i),_w(),mw++,i})(),n.finally(()=>pw.delete(e)),pw.set(e,n),n)}function yw(e,t){let n=e.displacementMap?.image;if(!n)return null;if(n.data instanceof Uint8Array&&n.width&&n.height)return{data:n.data,width:n.width,height:n.height,bottomUp:!0};let r=fw.get(t);if(r&&r!==`failed`)return fw.delete(t),fw.set(t,r),r;let i=e.displacementMeta;return!r&&i&&vw(t,i),null}function bw(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 rw(e.data,e.width,e.height,a,o)}async function xw(e,t,n,r,i){let a=(e&&yw(e,t))??await vw(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]=bw(a,i[e].latRad,i[e].lonRad)*n.scale_km+o;return s}var Sw=new Map,Cw=new Set;function ww(e,t){return Sw.get(e)||(Cw.has(e)||(Cw.add(e),(async()=>{try{let n=(await px(e,!1)).global;Sw.set(e,n?.radii??{a:t,b:t,c:t})}catch(n){console.warn(`Failed to load radii for ${e}:`,n),Sw.set(e,{a:t,b:t,c:t})}finally{Cw.delete(e),mw++}})()),null)}function Tw(e){let t=e?.terrainWindow;return t?{kind:`window`,thetas:t.thetas,phis:t.phis}:{kind:`uniform`,segs:e?.currentSegments??128}}function Ew(e,t,n,r,i){let a=ww(t,n);if(!a)return null;let o=null,s=0,c=0,l=e?.displacementMeta;if(l&&e?.displacementMap){if(o=yw(e,t),!o)return null;s=l.scale_km,c=l.bias_km-(l.absolute_radius?n:0)}let{corners:u,tx:d,ty:f}=cw(Tw(e),r,i);return{pts:u.map(e=>{let t=o?bw(o,e.latRad,e.lonRad)*s+c:0;return sw(e.latRad,e.lonRad,t,n,a.a,a.b,a.c)}),tx:d,ty:f}}function Dw(e,t,n,r,i){let a=Ew(e,t,n,r,i);return a?{pointKm:lw(a.pts,a.tx,a.ty),normal:dw(a.pts,a.tx,a.ty)}:null}function Ow(e,t,n,r){let i=ww(t,n);if(!i)return null;let a=Ew(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}=uw(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}var kw=Math.PI/180;function Aw(e,t){return`feature:${e}:${t}`}function jw(e,t){return{data:{id:Aw(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:tn.UNKNOWN},position:[0,0,0],orbitCenter:[0,0,0],featureAnchor:e}}var Mw=120,Nw=Q(.001)**2,Pw=new WeakMap,Fw=new J,Iw=new J;function Lw(e,t,n){e.distanceToSquared(t)<=Nw?e.copy(t):e.lerp(t,n)}function Rw(e,t,n,r){let i=e.featureAnchor,a=t.position;e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),Iw.set(0,0,0);let o=n?.nomenclatureActiveIndex??-1,s=o>=0?n?.nomenclatureLabels?.[o]??null:null;if(s&&s.element.dataset.featureId===String(i.featureId)){let e=n?.nomenclatureAnchor;e?(Fw.copy(s.position),Iw.copy(e.position)):(Fw.copy(s.position),n?.mesh&&Fw.multiply(n.mesh.scale))}else{let e=t.data.radiusKm,r=i.lat*kw,a=i.lon*kw,o=t.orientation&&Number.isFinite(e)&&e>0?Dw(n,t.data.id,e,r,a):null;if(o)Fw.set(o.pointKm[0],o.pointKm[1],o.pointKm[2]);else{let t=Number.isFinite(e)&&e>0?e:0,[n,i,o]=ow(r,a);Fw.set(t*n,t*i,t*o)}Fw.multiplyScalar(Q(1))}let c=performance.now(),l=Pw.get(e);if(!l)l={fixed:Fw.clone(),addend:Iw.clone(),t:c},Pw.set(e,l);else{let e=1-Math.exp(-(c-l.t)/Mw);l.t=c,Lw(l.fixed,Fw,e),Lw(l.addend,Iw,e)}Fw.copy(l.fixed),t.orientation&&Fw.applyQuaternion(dC(t.orientation,r,t.nutPrec)),e.position[0]=a[0]+Fw.x+l.addend.x,e.position[1]=a[1]+Fw.y+l.addend.y,e.position[2]=a[2]+Fw.z+l.addend.z}var zw={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
4229
+ }`)}),s}function ZC(e){e&&(e.uSelfHeightMap.value=null,e.uSelfScale.value=0)}async function QC(e,t,n,r,i,a=Q(1)){let o=$C(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,e.displacementScale=t.scale_km*a,e.displacementBias=t.bias_km*a-(t.absolute_radius?i:0),e.needsUpdate=!0,s}function $C(e,t){return Kt(`/v1/textures/${e.id}/${t}.webp`,`textures`)}async function ew(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 tw=4e6;async function nw(e,t,n){let r=e.width,i=Math.max(1,Math.floor(tw/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}async function rw(e,t){let n=e.displacementMeta;if(!(!n||!e.mesh||e.displacementLoading||e.displacementTier===t)){e.displacementLoading=!0;try{let r=await ew($C(n,t));if(!r)return;let i=r.width,a=r.height,o=await nw(r,0,a-1);if(r.close(),!o||!e.mesh||!e.displacementMap)return;let s=new Uint8Array(i);for(let e=0;e<a>>1;e++){let t=o.subarray(e*i,(e+1)*i),n=o.subarray((a-1-e)*i,(a-e)*i);s.set(t),t.set(n),n.set(s)}let c=new Us(o,i,a,Qn,Pn);c.colorSpace=``,c.magFilter=jn,c.minFilter=jn,c.generateMipmaps=!1,c.unpackAlignment=1,c.needsUpdate=!0;let l=e.mesh.material,u=l.displacementMap;l.displacementMap=c,e.displacementMap=c,e.displacementTier=t,e.selfShadow&&XC(l,c,Q(n.scale_km)),u&&u!==c&&u.dispose()}finally{e.displacementLoading=!1}}}function iw(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;return(h*(1-c)+g*c)/255}function aw(e){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.needsUpdate=!0)}function ow(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 sw(e,t){let n=Math.cos(e);return[n*Math.cos(t),Math.sin(e),-n*Math.sin(t)]}function cw(e,t,n,r,i,a,o){let s=(r+n)/r,[c,l,u]=sw(e,t);return[s*i*c,s*o*l,s*a*u]}function lw(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}=e,a=Math.PI/2-t,o=(n-Math.PI)%(2*Math.PI);o<0&&(o+=2*Math.PI);let s=ow(r,a),c=ow(i,o),l=Math.min(Math.max((a-r[s])/(r[s+1]-r[s]),0),1),u=Math.min(Math.max((o-i[c])/(i[c+1]-i[c]),0),1);return{corners:[[s,c],[s,c+1],[s+1,c],[s+1,c+1]].map(([e,t])=>({latRad:Math.PI/2-r[e],lonRad:i[t]+Math.PI})),tx:u,ty:l}}function uw(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 dw(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 fw(e,t,n){let{p0:r,n:i}=dw(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 pw=new Map,mw=new Map,hw=0;function gw(){return hw}var _w=6;function vw(){let e=0;for(let t of pw.values())t!==`failed`&&e++;for(let[t,n]of pw){if(e<=_w)break;n!==`failed`&&(pw.delete(t),e--)}}function yw(e,t){let n=mw.get(e);return n||(n=(async()=>{let n=await ew($C(t,`low`)),r=n&&await nw(n,0,n.height-1);if(!n||!r)return n?.close(),pw.set(e,`failed`),null;let i={data:r,width:n.width,height:n.height,bottomUp:!1};return n.close(),pw.set(e,i),vw(),hw++,i})(),n.finally(()=>mw.delete(e)),mw.set(e,n),n)}function bw(e,t){let n=e.displacementMap?.image;if(!n)return null;if(n.data instanceof Uint8Array&&n.width&&n.height)return{data:n.data,width:n.width,height:n.height,bottomUp:!0};let r=pw.get(t);if(r&&r!==`failed`)return pw.delete(t),pw.set(t,r),r;let i=e.displacementMeta;return!r&&i&&yw(t,i),null}function xw(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 iw(e.data,e.width,e.height,a,o)}async function Sw(e,t,n,r,i){let a=(e&&bw(e,t))??await yw(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]=xw(a,i[e].latRad,i[e].lonRad)*n.scale_km+o;return s}var Cw=new Map,ww=new Set;function Tw(e,t){return Cw.get(e)||(ww.has(e)||(ww.add(e),(async()=>{try{let n=(await mx(e,!1)).global;Cw.set(e,n?.radii??{a:t,b:t,c:t})}catch(n){console.warn(`Failed to load radii for ${e}:`,n),Cw.set(e,{a:t,b:t,c:t})}finally{ww.delete(e),hw++}})()),null)}function Ew(e){let t=e?.terrainWindow;return t?{kind:`window`,thetas:t.thetas,phis:t.phis}:{kind:`uniform`,segs:e?.currentSegments??128}}function Dw(e,t,n,r,i){let a=Tw(t,n);if(!a)return null;let o=null,s=0,c=0,l=e?.displacementMeta;if(l&&e?.displacementMap){if(o=bw(e,t),!o)return null;s=l.scale_km,c=l.bias_km-(l.absolute_radius?n:0)}let{corners:u,tx:d,ty:f}=lw(Ew(e),r,i);return{pts:u.map(e=>{let t=o?xw(o,e.latRad,e.lonRad)*s+c:0;return cw(e.latRad,e.lonRad,t,n,a.a,a.b,a.c)}),tx:d,ty:f}}function Ow(e,t,n,r,i){let a=Dw(e,t,n,r,i);return a?{pointKm:uw(a.pts,a.tx,a.ty),normal:fw(a.pts,a.tx,a.ty)}:null}function kw(e,t,n,r){let i=Tw(t,n);if(!i)return null;let a=Dw(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}=dw(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}var Aw=Math.PI/180;function jw(e,t){return`feature:${e}:${t}`}function Mw(e,t){return{data:{id:jw(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:tn.UNKNOWN},position:[0,0,0],orbitCenter:[0,0,0],featureAnchor:e}}var Nw=120,Pw=Q(.001)**2,Fw=new WeakMap,Iw=new J,Lw=new J;function Rw(e,t,n){e.distanceToSquared(t)<=Pw?e.copy(t):e.lerp(t,n)}function zw(e,t,n,r){let i=e.featureAnchor,a=t.position;e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),Lw.set(0,0,0);let o=n?.nomenclatureActiveIndex??-1,s=o>=0?n?.nomenclatureLabels?.[o]??null:null;if(s&&s.element.dataset.featureId===String(i.featureId)){let e=n?.nomenclatureAnchor;e?(Iw.copy(s.position),Lw.copy(e.position)):(Iw.copy(s.position),n?.mesh&&Iw.multiply(n.mesh.scale))}else{let e=t.data.radiusKm,r=i.lat*Aw,a=i.lon*Aw,o=t.orientation&&Number.isFinite(e)&&e>0?Ow(n,t.data.id,e,r,a):null;if(o)Iw.set(o.pointKm[0],o.pointKm[1],o.pointKm[2]);else{let t=Number.isFinite(e)&&e>0?e:0,[n,i,o]=sw(r,a);Iw.set(t*n,t*i,t*o)}Iw.multiplyScalar(Q(1))}let c=performance.now(),l=Fw.get(e);if(!l)l={fixed:Iw.clone(),addend:Lw.clone(),t:c},Fw.set(e,l);else{let e=1-Math.exp(-(c-l.t)/Nw);l.t=c,Rw(l.fixed,Iw,e),Rw(l.addend,Lw,e)}Iw.copy(l.fixed),t.orientation&&Iw.applyQuaternion(fC(t.orientation,r,t.nutPrec)),e.position[0]=a[0]+Iw.x+l.addend.x,e.position[1]=a[1]+Iw.y+l.addend.y,e.position[2]=a[2]+Iw.z+l.addend.z}var Bw={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
4230
4230
 
4231
4231
  varying vec2 vUv;
4232
4232
 
@@ -4249,7 +4249,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4249
4249
  gl_FragColor = opacity * texel;
4250
4250
 
4251
4251
 
4252
- }`},Bw=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(){}},Vw=new dd(-1,1,1,-1,0,1),Hw=new class extends Vo{constructor(){super(),this.setAttribute(`position`,new ko([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new ko([0,2,0,0,2,0],2))}},Uw=class{constructor(e){this._mesh=new ks(Hw,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Vw)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},Ww=class extends Bw{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof du?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=cu.clone(e.uniforms),this.material=new du({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 Uw(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()}},Gw=class extends Bw{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)}},Kw=class extends Bw{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},qw=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 ca(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Vn}),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 Ww(zw),this.copyPass.material.blending=0,this.timer=new Sd}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()}Gw!==void 0&&(r instanceof Gw?n=!0:r instanceof Kw&&(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()}},Jw=class extends Bw{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}},Yw={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new X(0)},defaultOpacity:{value:0}},vertexShader:`
4252
+ }`},Vw=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(){}},Hw=new dd(-1,1,1,-1,0,1),Uw=new class extends Vo{constructor(){super(),this.setAttribute(`position`,new ko([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new ko([0,2,0,0,2,0],2))}},Ww=class{constructor(e){this._mesh=new ks(Uw,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Hw)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},Gw=class extends Vw{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof du?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=cu.clone(e.uniforms),this.material=new du({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 Ww(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()}},Kw=class extends Vw{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)}},qw=class extends Vw{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},Jw=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 ca(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Vn}),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 Gw(Bw),this.copyPass.material.blending=0,this.timer=new Sd}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()}Kw!==void 0&&(r instanceof Kw?n=!0:r instanceof qw&&(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()}},Yw=class extends Vw{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}},Xw={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new X(0)},defaultOpacity:{value:0}},vertexShader:`
4253
4253
 
4254
4254
  varying vec2 vUv;
4255
4255
 
@@ -4281,7 +4281,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4281
4281
 
4282
4282
  gl_FragColor = mix( outputColor, texel, alpha );
4283
4283
 
4284
- }`},Xw=class e extends Bw{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 ca(i,a,{type:Vn}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new ca(i,a,{type:Vn});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let n=new ca(i,a,{type:Vn});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=Yw;this.highPassUniforms=cu.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new du({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(zw.uniforms),this.blendMaterial=new du({uniforms:this.copyUniforms,vertexShader:zw.vertexShader,fragmentShader:zw.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new X,this._oldClearAlpha=1,this._basic=new _s,this._fsQuad=new Uw(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 du({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new q(.5,.5)},direction:{value:new q(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
4284
+ }`},Zw=class e extends Vw{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 ca(i,a,{type:Vn}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new ca(i,a,{type:Vn});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let n=new ca(i,a,{type:Vn});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=Xw;this.highPassUniforms=cu.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new du({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(Bw.uniforms),this.blendMaterial=new du({uniforms:this.copyUniforms,vertexShader:Bw.vertexShader,fragmentShader:Bw.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new X,this._oldClearAlpha=1,this._basic=new _s,this._fsQuad=new Ww(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 du({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new q(.5,.5)},direction:{value:new q(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
4285
4285
 
4286
4286
  varying vec2 vUv;
4287
4287
 
@@ -4363,7 +4363,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4363
4363
  float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
4364
4364
  gl_FragColor = vec4( bloom, bloomAlpha );
4365
4365
 
4366
- }`})}};Xw.BlurDirectionX=new q(1,0),Xw.BlurDirectionY=new q(0,1);var Zw={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
4366
+ }`})}};Zw.BlurDirectionX=new q(1,0),Zw.BlurDirectionY=new q(0,1);var Qw={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
4367
4367
  precision highp float;
4368
4368
 
4369
4369
  uniform mat4 modelViewMatrix;
@@ -4434,7 +4434,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4434
4434
 
4435
4435
  #endif
4436
4436
 
4437
- }`},Qw=class extends Bw{constructor(){super(),this.isOutputPass=!0,this.uniforms=cu.clone(Zw.uniforms),this.material=new fu({name:Zw.name,uniforms:this.uniforms,vertexShader:Zw.vertexShader,fragmentShader:Zw.fragmentShader}),this._fsQuad=new Uw(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={},Yi.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()}},$w=!1;function eT(e){$w=e}function tT(){return $w}function nT(e){return $w?e>=0&&e<=1:e>=-1&&e<=1}function rT(e){return e.isCSS2DObject===!0}var iT=NaN,aT=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),rT(e)){let n=e.element;this._vector.setFromMatrixPosition(e.matrixWorld),this._vector.applyMatrix4(this._viewProjectionMatrix);let r=this._vector.z,i=nT(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:iT,ty:iT,cx:iT,cy:iT,display:`__init__`,zIndex:iT,dist2:0},this._cache.set(e,t)),t}hideObject(e){if(rT(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)}}},oT=.5;function sT(e,t){return new X(e).multiplyScalar(t)}var cT=new q(1,1);function lT(e,t){cT.set(e,t)}function uT(e,t=oT){return new du({transparent:!0,depthWrite:!1,uniforms:{uColor:{value:sT(e,t)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0}},vertexShader:`
4437
+ }`},$w=class extends Vw{constructor(){super(),this.isOutputPass=!0,this.uniforms=cu.clone(Qw.uniforms),this.material=new fu({name:Qw.name,uniforms:this.uniforms,vertexShader:Qw.vertexShader,fragmentShader:Qw.fragmentShader}),this._fsQuad=new Ww(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={},Yi.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()}},eT=!1;function tT(e){eT=e}function nT(){return eT}function rT(e){return eT?e>=0&&e<=1:e>=-1&&e<=1}function iT(e){return e.isCSS2DObject===!0}var aT=NaN,oT=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),iT(e)){let n=e.element;this._vector.setFromMatrixPosition(e.matrixWorld),this._vector.applyMatrix4(this._viewProjectionMatrix);let r=this._vector.z,i=rT(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:aT,ty:aT,cx:aT,cy:aT,display:`__init__`,zIndex:aT,dist2:0},this._cache.set(e,t)),t}hideObject(e){if(iT(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)}}},sT=.5;function cT(e,t){return new X(e).multiplyScalar(t)}var lT=new q(1,1);function uT(e,t){lT.set(e,t)}function dT(e,t=sT){return new du({transparent:!0,depthWrite:!1,uniforms:{uColor:{value:cT(e,t)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0}},vertexShader:`
4438
4438
  #include <common>
4439
4439
  #include <logdepthbuf_pars_vertex>
4440
4440
  uniform vec3 uCenterOffset;
@@ -4458,7 +4458,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4458
4458
  gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
4459
4459
  #include <logdepthbuf_fragment>
4460
4460
  }
4461
- `})}function dT(e,t,n=oT){return new du({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:sT(e,n)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0},uLineWidth:{value:t},uResolution:{value:cT}},vertexShader:`
4461
+ `})}function fT(e,t,n=sT){return new du({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:cT(e,n)},uCenterOffset:{value:new J},uAlphaMultiplier:{value:1},uAlphaMin:{value:0},uShowFull:{value:0},uLineWidth:{value:t},uResolution:{value:lT}},vertexShader:`
4462
4462
  #include <common>
4463
4463
  #include <logdepthbuf_pars_vertex>
4464
4464
  uniform vec3 uCenterOffset;
@@ -4498,7 +4498,7 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4498
4498
  gl_FragColor = vec4(uColor, clamp(max(vAlpha * uAlphaMultiplier, uAlphaMin), 0.0, 1.0));
4499
4499
  #include <logdepthbuf_fragment>
4500
4500
  }
4501
- `})}var fT=class extends Ka{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Ic;e.deleteAttribute(`uv`);let t=new pu({side:1}),n=new pu,r=new ud(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new ks(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new tc(e,n,6),o=new La;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 ks(e,pT(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new ks(e,pT(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new ks(e,pT(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new ks(e,pT(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new ks(e,pT(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new ks(e,pT(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 pT(e){return new hu({color:0,emissive:16777215,emissiveIntensity:e})}var mT=.01,hT=3.5,gT=.04;function _T(e){let t=Math.max(e/10,.01);return 1/(t*t)}function vT(e,t,n=1){e.decay=t?2:0,e.intensity=(t?hT*10*10:hT)*n}function yT(e){let t=new vf(e),n=t.fromScene(new fT).texture;return t.dispose(),n}var bT=1e5;function xT(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var ST=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function CT(e,t,n){let r,i=xT();try{r=new uh(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new ST(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),eT(r.capabilities.reversedDepthBuffer);let a=qx();r.setPixelRatio(Jx()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,lT(e.clientWidth,e.clientHeight);let o=new aT({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new Ka,c=new md(16777215,mT);s.add(c);let l=new pd(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 od(60,e.clientWidth/e.clientHeight,Q(.001),bT),d=r.capabilities.reversedDepthBuffer?new ca(e.clientWidth,e.clientHeight,{type:Vn,depthTexture:new Nc(e.clientWidth,e.clientHeight,Bn)}):void 0,f=new qw(r,d);f.setPixelRatio(Jx()),f.setSize(e.clientWidth,e.clientHeight),f.addPass(new Jw(s,u));let p=new Xw(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);return f.addPass(p),f.addPass(new Qw),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:f,bloomPass:p,ambientLight:c,shadowLight:l}}function wT(e,t,n){let r=e.data,i=r.q!=null,a;if(r.parentId===`naif-0`)a=[0,0,0];else{let t=n.getBody(r.parentId)?.position;if(!t){e.positionUnknown=!0;return}a=t}if(t<r.validityStart||t>r.validityEnd){e.positionUnknown=!0;return}let o=r.a===0&&!i&&!r.satrec?[0,0,0]:r.satrec?yg(r.satrec,t):i?Yv(r,t):qv(r,t);if(!o){e.positionUnknown=!0;return}e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1}function TT(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 ET(e){let t=new Map,n=new Map,r=e.clone();return DT(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 DT(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)DT(e.children[r],t.children[r],n)}var OT=class extends Vu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new FT(e)}),this.register(function(e){return new IT(e)}),this.register(function(e){return new GT(e)}),this.register(function(e){return new KT(e)}),this.register(function(e){return new qT(e)}),this.register(function(e){return new RT(e)}),this.register(function(e){return new zT(e)}),this.register(function(e){return new BT(e)}),this.register(function(e){return new VT(e)}),this.register(function(e){return new PT(e)}),this.register(function(e){return new HT(e)}),this.register(function(e){return new LT(e)}),this.register(function(e){return new WT(e)}),this.register(function(e){return new UT(e)}),this.register(function(e){return new MT(e)}),this.register(function(e){return new JT(e,jT.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new JT(e,jT.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new YT(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=hd.extractUrlBase(e);a=hd.resolveURL(t,this.path)}else a=hd.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 Wu(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))===XT){try{a[jT.KHR_BINARY_GLTF]=new $T(e)}catch(e){r&&r(e);return}i=JSON.parse(a[jT.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 TE(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 jT.KHR_MATERIALS_UNLIT:a[t]=new NT;break;case jT.KHR_DRACO_MESH_COMPRESSION:a[t]=new eE(i,this.dracoLoader);break;case jT.KHR_TEXTURE_TRANSFORM:a[t]=new tE;break;case jT.KHR_MESH_QUANTIZATION:a[t]=new nE;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 kT(){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 AT(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var jT={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`},MT=class{constructor(e){this.parser=e,this.name=jT.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],Yr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new pd(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new ud(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),_E(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)})}},NT=class{constructor(){this.name=jT.KHR_MATERIALS_UNLIT}getMaterialType(){return _s}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],Yr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Jr))}return Promise.all(r)}},PT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=AT(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},FT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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)}},IT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_DISPERSION}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},LT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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)}},RT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_SHEEN}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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],Yr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Jr)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},zT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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)}},BT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_VOLUME}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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],Yr),Promise.all(r)}},VT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_IOR}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},HT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_SPECULAR}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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],Yr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Jr)),Promise.all(r)}},UT=class{constructor(e){this.parser=e,this.name=jT.EXT_MATERIALS_BUMP}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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)}},WT=class{constructor(e){this.parser=e,this.name=jT.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return AT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=AT(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)}},GT=class{constructor(e){this.parser=e,this.name=jT.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)}},KT=class{constructor(e){this.parser=e,this.name=jT.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},qT=class{constructor(e){this.parser=e,this.name=jT.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)}},JT=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}},YT=class{constructor(e){this.name=jT.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!==oE.TRIANGLES&&e.mode!==oE.TRIANGLE_STRIP&&e.mode!==oE.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 Vi,s=new J(1,1,1),c=new tc(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 qs(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);La.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},XT=`glTF`,ZT=12,QT={JSON:1313821514,BIN:5130562},$T=class{constructor(e){this.name=jT.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,ZT),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!==XT)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-ZT,i=new DataView(e,ZT),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===QT.JSON){let r=new Uint8Array(e,ZT+a,t);this.content=n.decode(r)}else if(r===QT.BIN){let n=ZT+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},eE=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=jT.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=dE[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=dE[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=sE[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,Yr,n)})})}},tE=class{constructor(){this.name=jT.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)}},nE=class{constructor(){this.name=jT.KHR_MESH_QUANTIZATION}},rE=class extends Su{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}},iE=new Vi,aE=class extends rE{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return iE.fromArray(i).normalize().toArray(i),i}},oE={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},sE={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},cE={9728:On,9729:jn,9984:kn,9985:Mn,9986:An,9987:Nn},lE={33071:En,33648:Dn,10497:Tn},uE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},dE={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`},fE={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},pE={CUBICSPLINE:void 0,LINEAR:Br,STEP:zr},mE={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function hE(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new pu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function gE(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 _E(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 vE(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 yE(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 bE(e){let t,n=e.extensions&&e.extensions[jT.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+xE(n.attributes):e.indices+`:`+xE(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+xE(e.targets[n]);return t}function xE(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 SE(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 CE(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 wE=new Y,TE=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new kT,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 qu(this.options.manager):this.textureLoader=new _d(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Wu(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 gE(i,a,r),_E(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[jT.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(hd.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=uE[r.type],t=sE[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Eo(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=uE[r.type],o=sE[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 Ho(f,u/s),t.cache.add(n,c)),p=new Wo(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Eo(f,a,d);if(r.sparse!==void 0){let t=uE.SCALAR,n=sE[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 Eo(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=cE[n.magFilter]||1006,t.minFilter=cE[n.minFilter]||1008,t.wrapS=lE[n.wrapS]||1e3,t.wrapT=lE[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 aa(e);t.needsUpdate=!0,n(t)}),t.load(hd.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),_E(e,a),e.userData.mimeType=a.mimeType||CE(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[jT.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[jT.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[jT.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 wc,Ko.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 uc,Ko.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 pu}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[jT.KHR_MATERIALS_UNLIT]){let e=r[jT.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],Yr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Jr)),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||mE.OPAQUE;if(l===mE.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===mE.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==_s&&(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!==_s&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==_s){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],Yr)}return i.emissiveTexture!==void 0&&a!==_s&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Jr)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),_E(n,i),t.associations.set(n,{materials:e}),i.extensions&&gE(r,n,i),n})}createUniqueName(e){let t=Fd.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[jT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return DE(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=bE(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[jT.KHR_DRACO_MESH_COMPRESSION]?i(o):DE(new Vo,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?hE(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===oE.TRIANGLES||u.mode===oE.TRIANGLE_STRIP||u.mode===oE.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Vs(l,f):new ks(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===oE.TRIANGLE_STRIP?d.geometry=TT(d.geometry,1):u.mode===oE.TRIANGLE_FAN&&(d.geometry=TT(d.geometry,2));else if(u.mode===oE.LINES)d=new Sc(l,f);else if(u.mode===oE.LINE_STRIP)d=new vc(l,f);else if(u.mode===oE.LINE_LOOP)d=new Cc(l,f);else if(u.mode===oE.POINTS)d=new kc(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&yE(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),_E(d,i),u.extensions&&gE(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&&gE(r,c[0],i),c[0];let l=new Ra;i.extensions&&gE(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 od(Bi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new dd(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),_E(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 Ks(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 Fu(i,void 0,l);return _E(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,wE)});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 Hs:t.length>1?new Ra:t.length===1?t[0]:new La,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),_E(o,i),i.extensions&&gE(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 Ra;n.name&&(i.name=r.createUniqueName(n.name)),_E(i,n),n.extensions&&gE(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(ET(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof Ko||e instanceof aa)&&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=[];fE[i.path]===fE.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(fE[i.path]){case fE.weights:c=Au;break;case fE.rotation:c=Mu;break;case fE.translation:case fE.scale:c=Pu;break;default:switch(n.itemSize){case 1:c=Au;break;default:c=Pu;break}break}let l=r.interpolation===void 0?Br:pE[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+fE[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=SE(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 Mu?aE:rE)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function EE(e,t,n){let r=t.attributes,i=new so;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=SE(sE[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=SE(sE[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 No;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function DE(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=dE[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 Yi.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Yi.workingColorSpace}" not supported.`),_E(e,t),EE(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:vE(e,t.targets,n)})}var OE=(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})}}})(),kE=1230263361,AE=2,jE=16,ME=11,NE=32767,PE=86400;function FE(e){let t=new DataView(e);if(t.getUint32(0,!0)!==kE)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==AE)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-jE)/ME),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=jE+e*ME;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/PE;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/NE,l=t.getInt16(n+7,!0)/NE,u=t.getInt16(n+9,!0)/NE,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 IE=86400,LE=new Vi().setFromRotationMatrix(new Y().makeBasis(ug(1,0,0,new J),ug(0,1,0,new J),ug(0,0,1,new J))),RE=new Vi,zE=new Vi,BE=new Vi,VE=new J;function HE(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var UE=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;failed=new Set;constructor(e,t){this.probeId=e,this.startJd=t.files.length?t.files[0].start_jd:0,this.endJd=t.files.length?t.files[t.files.length-1].end_jd:0,this.baselines=t.baselines,this.files=t.files}covers(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){if(!this.covers(e))return!1;let n=this.fileIndexFor(e),r=this.ensure(n);if(!r)return!1;this.ensure(n-1),this.ensure(n+1),this.sampleChunk(e,n,r);let i=this.baselines?.[this.files[n].baseline_index??0];if(i){let{axis:t,rate_rad_s:n,anchor:r,anchor_jd:a}=i,o=(e-a)*IE;VE.set(t[0],t[1],t[2]),BE.setFromAxisAngle(VE,n*o),zE.set(r[1],r[2],r[3],r[0]),BE.multiply(zE),RE.copy(BE.multiply(RE))}return RE.conjugate(),t.copy(LE).multiply(RE),!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]){HE(i,0,RE);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);HE(i,a-1,RE),HE(n.quats,0,zE),RE.slerpQuaternions(RE,zE,o)}else HE(i,a-1,RE);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;HE(i,o,RE),HE(i,s,zE),RE.slerpQuaternions(RE,zE,l)}ensure(e){if(e<0||e>=this.files.length)return;let t=this.chunks.get(e);if(t)return t;this.inflight.has(e)||this.failed.has(e)||(this.inflight.add(e),this.load(e))}async load(e){let t=this.files[e];try{let n=await fetch(`${Ut()}/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,FE(i))}catch(n){this.failed.add(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function WE(e,t){return new UE(e,t)}var GE=[`carrier`,`missing`],KE=`scene-label__annotation--visible`;function qE(e,t,n){let r=e.labelAnnotations?.[t];if(!r){if(!n||!e.label)return;r=document.createElement(`span`),r.className=`scene-label__annotation`,r.dir=`auto`,r.textContent=n,XE(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(KE))return}else if(r.textContent===n&&r.classList.contains(KE))return;else r.textContent=n;r.classList.toggle(KE,n!==null),JE(e)}function JE(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 GE){let r=e.labelAnnotations?.[t];r?.classList.contains(KE)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function YE(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 XE(e,t,n){for(let r of GE.slice(GE.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}YE(e).appendChild(t)}function ZE(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=nD(e,t);return n.tintBase=i,n.tintKey=r,i}var QE=32,$E=16,eD=.01,tD=.001;function nD(e,t){let n=new X(16777215);if(!t)return n;let r=rD(e);if(r===null||r>eD)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<tD?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function rD(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=QE,n.height=$E;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,QE,$E);let i;try{i=r.getImageData(0,0,QE,$E).data}catch{return null}let a=0,o=i.length/4;for(let e=0;e<i.length;e+=4){let t=i[e]/255,n=i[e+1]/255,r=i[e+2]/255;a+=Math.max(t,n,r)-Math.min(t,n,r)}return a/o}var iD=`
4501
+ `})}var pT=class extends Ka{constructor(){super(),this.name=`RoomEnvironment`,this.position.y=-3.5;let e=new Ic;e.deleteAttribute(`uv`);let t=new pu({side:1}),n=new pu,r=new ud(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let i=new ks(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new tc(e,n,6),o=new La;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 ks(e,mT(50));s.position.set(-16.116,14.37,8.208),s.scale.set(.1,2.428,2.739),this.add(s);let c=new ks(e,mT(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let l=new ks(e,mT(17));l.position.set(14.904,12.198,-1.832),l.scale.set(.15,4.265,6.331),this.add(l);let u=new ks(e,mT(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new ks(e,mT(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new ks(e,mT(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 mT(e){return new hu({color:0,emissive:16777215,emissiveIntensity:e})}var hT=.01,gT=3.5,_T=.04;function vT(e){let t=Math.max(e/10,.01);return 1/(t*t)}function yT(e,t,n=1){e.decay=t?2:0,e.intensity=(t?gT*10*10:gT)*n}function bT(e){let t=new vf(e),n=t.fromScene(new pT).texture;return t.dispose(),n}var xT=1e5;function ST(){try{return!!document.createElement(`canvas`).getContext(`webgl2`)?.getExtension(`EXT_clip_control`)}catch{return!1}}var CT=class extends Error{constructor(e){super(`WebGL is unavailable on this device.`,{cause:e}),this.name=`WebGLUnavailableError`}};function wT(e,t,n){let r,i=ST();try{r=new uh(i?{canvas:e,reversedDepthBuffer:!0,antialias:!0}:{canvas:e,logarithmicDepthBuffer:!0,antialias:!0})}catch(e){throw new CT(e)}i&&!r.capabilities.reversedDepthBuffer&&console.warn(`EXT_clip_control probe mismatch: reversed depth unavailable on main context`),tT(r.capabilities.reversedDepthBuffer);let a=Jx();r.setPixelRatio(Yx()),r.setSize(e.clientWidth,e.clientHeight,!1),r.shadowMap.enabled=!0,r.shadowMap.type=a.softShadows?2:1,r.toneMapping=4,r.toneMappingExposure=1,uT(e.clientWidth,e.clientHeight);let o=new oT({element:t});o.setSize(e.clientWidth,e.clientHeight),n.visibility.updateViewport(e.clientHeight);let s=new Ka,c=new md(16777215,hT);s.add(c);let l=new pd(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 od(60,e.clientWidth/e.clientHeight,Q(.001),xT),d=r.capabilities.reversedDepthBuffer?new ca(e.clientWidth,e.clientHeight,{type:Vn,depthTexture:new Nc(e.clientWidth,e.clientHeight,Bn)}):void 0,f=new Jw(r,d);f.setPixelRatio(Yx()),f.setSize(e.clientWidth,e.clientHeight),f.addPass(new Yw(s,u));let p=new Zw(new q(e.clientWidth*a.bloomScale,e.clientHeight*a.bloomScale),.3,.5,1);return f.addPass(p),f.addPass(new $w),{renderer:r,labelRenderer:o,scene:s,camera:u,composer:f,bloomPass:p,ambientLight:c,shadowLight:l}}function TT(e,t,n){let r=e.data,i=r.q!=null,a;if(r.parentId===`naif-0`)a=[0,0,0];else{let t=n.getBody(r.parentId)?.position;if(!t){e.positionUnknown=!0;return}a=t}if(t<r.validityStart||t>r.validityEnd){e.positionUnknown=!0;return}let o=r.a===0&&!i&&!r.satrec?[0,0,0]:r.satrec?yg(r.satrec,t):i?Yv(r,t):qv(r,t);if(!o){e.positionUnknown=!0;return}e.position[0]=a[0]+o[0],e.position[1]=a[1]+o[1],e.position[2]=a[2]+o[2],e.orbitCenter&&(e.orbitCenter[0]=a[0],e.orbitCenter[1]=a[1],e.orbitCenter[2]=a[2]),e.positionUnknown=!1}function ET(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 DT(e){let t=new Map,n=new Map,r=e.clone();return OT(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 OT(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)OT(e.children[r],t.children[r],n)}var kT=class extends Vu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new IT(e)}),this.register(function(e){return new LT(e)}),this.register(function(e){return new KT(e)}),this.register(function(e){return new qT(e)}),this.register(function(e){return new JT(e)}),this.register(function(e){return new zT(e)}),this.register(function(e){return new BT(e)}),this.register(function(e){return new VT(e)}),this.register(function(e){return new HT(e)}),this.register(function(e){return new FT(e)}),this.register(function(e){return new UT(e)}),this.register(function(e){return new RT(e)}),this.register(function(e){return new GT(e)}),this.register(function(e){return new WT(e)}),this.register(function(e){return new NT(e)}),this.register(function(e){return new YT(e,MT.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new YT(e,MT.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new XT(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=hd.extractUrlBase(e);a=hd.resolveURL(t,this.path)}else a=hd.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 Wu(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))===ZT){try{a[MT.KHR_BINARY_GLTF]=new eE(e)}catch(e){r&&r(e);return}i=JSON.parse(a[MT.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 EE(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 MT.KHR_MATERIALS_UNLIT:a[t]=new PT;break;case MT.KHR_DRACO_MESH_COMPRESSION:a[t]=new tE(i,this.dracoLoader);break;case MT.KHR_TEXTURE_TRANSFORM:a[t]=new nE;break;case MT.KHR_MESH_QUANTIZATION:a[t]=new rE;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 AT(){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 jT(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var MT={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`},NT=class{constructor(e){this.parser=e,this.name=MT.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],Yr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new pd(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new ud(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),vE(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)})}},PT=class{constructor(){this.name=MT.KHR_MATERIALS_UNLIT}getMaterialType(){return _s}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],Yr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Jr))}return Promise.all(r)}},FT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},IT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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)}},LT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_DISPERSION}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},RT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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)}},zT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_SHEEN}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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],Yr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Jr)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},BT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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)}},VT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_VOLUME}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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],Yr),Promise.all(r)}},HT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_IOR}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior),Promise.resolve()}},UT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_SPECULAR}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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],Yr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Jr)),Promise.all(r)}},WT=class{constructor(e){this.parser=e,this.name=MT.EXT_MATERIALS_BUMP}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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)}},GT=class{constructor(e){this.parser=e,this.name=MT.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return jT(this.parser,e,this.name)===null?null:mu}extendMaterialParams(e,t){let n=jT(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)}},KT=class{constructor(e){this.parser=e,this.name=MT.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)}},qT=class{constructor(e){this.parser=e,this.name=MT.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)}},JT=class{constructor(e){this.parser=e,this.name=MT.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)}},YT=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}},XT=class{constructor(e){this.name=MT.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!==sE.TRIANGLES&&e.mode!==sE.TRIANGLE_STRIP&&e.mode!==sE.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 Vi,s=new J(1,1,1),c=new tc(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 qs(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);La.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},ZT=`glTF`,QT=12,$T={JSON:1313821514,BIN:5130562},eE=class{constructor(e){this.name=MT.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,QT),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!==ZT)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-QT,i=new DataView(e,QT),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===$T.JSON){let r=new Uint8Array(e,QT+a,t);this.content=n.decode(r)}else if(r===$T.BIN){let n=QT+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},tE=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=MT.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=fE[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=fE[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=cE[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,Yr,n)})})}},nE=class{constructor(){this.name=MT.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)}},rE=class{constructor(){this.name=MT.KHR_MESH_QUANTIZATION}},iE=class extends Su{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}},aE=new Vi,oE=class extends iE{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return aE.fromArray(i).normalize().toArray(i),i}},sE={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},cE={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},lE={9728:On,9729:jn,9984:kn,9985:Mn,9986:An,9987:Nn},uE={33071:En,33648:Dn,10497:Tn},dE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fE={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`},pE={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},mE={CUBICSPLINE:void 0,LINEAR:Br,STEP:zr},hE={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function gE(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new pu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function _E(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 vE(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 yE(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 bE(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 xE(e){let t,n=e.extensions&&e.extensions[MT.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+SE(n.attributes):e.indices+`:`+SE(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+SE(e.targets[n]);return t}function SE(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 CE(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 wE(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 TE=new Y,EE=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new AT,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 qu(this.options.manager):this.textureLoader=new _d(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Wu(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 _E(i,a,r),vE(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[MT.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(hd.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=dE[r.type],t=cE[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new Eo(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=dE[r.type],o=cE[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 Ho(f,u/s),t.cache.add(n,c)),p=new Wo(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new Eo(f,a,d);if(r.sparse!==void 0){let t=dE.SCALAR,n=cE[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 Eo(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=lE[n.magFilter]||1006,t.minFilter=lE[n.minFilter]||1008,t.wrapS=uE[n.wrapS]||1e3,t.wrapT=uE[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 aa(e);t.needsUpdate=!0,n(t)}),t.load(hd.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),vE(e,a),e.userData.mimeType=a.mimeType||wE(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[MT.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[MT.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[MT.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 wc,Ko.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 uc,Ko.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 pu}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[MT.KHR_MATERIALS_UNLIT]){let e=r[MT.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],Yr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Jr)),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||hE.OPAQUE;if(l===hE.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===hE.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==_s&&(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!==_s&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==_s){let e=i.emissiveFactor;o.emissive=new X().setRGB(e[0],e[1],e[2],Yr)}return i.emissiveTexture!==void 0&&a!==_s&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Jr)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),vE(n,i),t.associations.set(n,{materials:e}),i.extensions&&_E(r,n,i),n})}createUniqueName(e){let t=Fd.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[MT.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return OE(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=xE(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[MT.KHR_DRACO_MESH_COMPRESSION]?i(o):OE(new Vo,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?gE(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===sE.TRIANGLES||u.mode===sE.TRIANGLE_STRIP||u.mode===sE.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Vs(l,f):new ks(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===sE.TRIANGLE_STRIP?d.geometry=ET(d.geometry,1):u.mode===sE.TRIANGLE_FAN&&(d.geometry=ET(d.geometry,2));else if(u.mode===sE.LINES)d=new Sc(l,f);else if(u.mode===sE.LINE_STRIP)d=new vc(l,f);else if(u.mode===sE.LINE_LOOP)d=new Cc(l,f);else if(u.mode===sE.POINTS)d=new kc(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&bE(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),vE(d,i),u.extensions&&_E(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&&_E(r,c[0],i),c[0];let l=new Ra;i.extensions&&_E(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 od(Bi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new dd(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),vE(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 Ks(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 Fu(i,void 0,l);return vE(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,TE)});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 Hs:t.length>1?new Ra:t.length===1?t[0]:new La,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),vE(o,i),i.extensions&&_E(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 Ra;n.name&&(i.name=r.createUniqueName(n.name)),vE(i,n),n.extensions&&_E(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(DT(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof Ko||e instanceof aa)&&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=[];pE[i.path]===pE.weights?e.traverse(function(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}):s.push(o);let c;switch(pE[i.path]){case pE.weights:c=Au;break;case pE.rotation:c=Mu;break;case pE.translation:case pE.scale:c=Pu;break;default:switch(n.itemSize){case 1:c=Au;break;default:c=Pu;break}break}let l=r.interpolation===void 0?Br:mE[r.interpolation],u=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new c(s[e]+`.`+pE[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=CE(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 Mu?oE:iE)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function DE(e,t,n){let r=t.attributes,i=new so;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=CE(cE[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=CE(cE[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 No;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function OE(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=fE[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 Yi.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Yi.workingColorSpace}" not supported.`),vE(e,t),DE(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:yE(e,t.targets,n)})}var kE=(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})}}})(),AE=1230263361,jE=2,ME=16,NE=11,PE=32767,FE=86400;function IE(e){let t=new DataView(e);if(t.getUint32(0,!0)!==AE)throw Error(`attitude: bad file magic (expected ATTI)`);let n=t.getUint16(4,!0);if(n!==jE)throw Error(`attitude: unsupported version ${n}`);let r=t.getFloat64(8,!0),i=Math.floor((e.byteLength-ME)/NE),a=new Float64Array(i),o=new Float32Array(i*4),s=0;for(let e=0;e<i;e++){let n=ME+e*NE;e>0&&(s+=t.getFloat32(n,!0)),a[e]=r+s/FE;let i=t.getUint8(n+4),c=t.getInt16(n+5,!0)/PE,l=t.getInt16(n+7,!0)/PE,u=t.getInt16(n+9,!0)/PE,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 LE=86400,RE=new Vi().setFromRotationMatrix(new Y().makeBasis(ug(1,0,0,new J),ug(0,1,0,new J),ug(0,0,1,new J))),zE=new Vi,BE=new Vi,VE=new Vi,HE=new J;function UE(e,t,n){let r=t*4;return n.set(e[r+1],e[r+2],e[r+3],e[r])}var WE=class{startJd;endJd;baselines;files;chunks=new Map;inflight=new Set;failed=new Set;constructor(e,t){this.probeId=e,this.startJd=t.files.length?t.files[0].start_jd:0,this.endJd=t.files.length?t.files[t.files.length-1].end_jd:0,this.baselines=t.baselines,this.files=t.files}covers(e){return e>=this.startJd&&e<=this.endJd&&this.files.length>0}orientationAt(e,t){if(!this.covers(e))return!1;let n=this.fileIndexFor(e),r=this.ensure(n);if(!r)return!1;this.ensure(n-1),this.ensure(n+1),this.sampleChunk(e,n,r);let i=this.baselines?.[this.files[n].baseline_index??0];if(i){let{axis:t,rate_rad_s:n,anchor:r,anchor_jd:a}=i,o=(e-a)*LE;HE.set(t[0],t[1],t[2]),VE.setFromAxisAngle(HE,n*o),BE.set(r[1],r[2],r[3],r[0]),VE.multiply(BE),zE.copy(VE.multiply(zE))}return zE.conjugate(),t.copy(RE).multiply(zE),!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]){UE(i,0,zE);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);UE(i,a-1,zE),UE(n.quats,0,BE),zE.slerpQuaternions(zE,BE,o)}else UE(i,a-1,zE);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;UE(i,o,zE),UE(i,s,BE),zE.slerpQuaternions(zE,BE,l)}ensure(e){if(e<0||e>=this.files.length)return;let t=this.chunks.get(e);if(t)return t;this.inflight.has(e)||this.failed.has(e)||(this.inflight.add(e),this.load(e))}async load(e){let t=this.files[e];try{let n=await fetch(`${Ut()}/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,IE(i))}catch(n){this.failed.add(e),console.warn(`attitude: chunk ${this.probeId}/${t.name} failed to load:`,n)}finally{this.inflight.delete(e)}}};function GE(e,t){return new WE(e,t)}var KE=[`carrier`,`missing`],qE=`scene-label__annotation--visible`;function JE(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,ZE(e,r,t),(e.labelAnnotations??={})[t]=r}else if(n===null){if(!r.classList.contains(qE))return}else if(r.textContent===n&&r.classList.contains(qE))return;else r.textContent=n;r.classList.toggle(qE,n!==null),YE(e)}function YE(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 KE){let r=e.labelAnnotations?.[t];r?.classList.contains(qE)&&n.push(r.textContent)}let r=n.filter(Boolean).join(`, `);r?t.setAttribute(`aria-label`,r):t.removeAttribute(`aria-label`)}function XE(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 ZE(e,t,n){for(let r of KE.slice(KE.indexOf(n)+1)){let n=e.labelAnnotations?.[r];if(n){n.parentElement.insertBefore(t,n);return}}XE(e).appendChild(t)}function QE(e,t){let n=e.userData,r=t??``;if(n.tintBase&&n.tintKey===r)return n.tintBase;let i=rD(e,t);return n.tintBase=i,n.tintKey=r,i}var $E=32,eD=16,tD=.01,nD=.001;function rD(e,t){let n=new X(16777215);if(!t)return n;let r=iD(e);if(r===null||r>tD)return n;let i=new X(t),a=.2126*i.r+.7152*i.g+.0722*i.b;return a<nD?n:new X().setRGB(i.r/a,i.g/a,i.b/a)}function iD(e){let t=e.image;if(!t||!t.width||!t.height)return null;let n=document.createElement(`canvas`);n.width=$E,n.height=eD;let r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return null;r.drawImage(t,0,0,$E,eD);let i;try{i=r.getImageData(0,0,$E,eD).data}catch{return null}let a=0,o=i.length/4;for(let e=0;e<i.length;e+=4){let t=i[e]/255,n=i[e+1]/255,r=i[e+2]/255;a+=Math.max(t,n,r)-Math.min(t,n,r)}return a/o}var aD=`
4502
4502
  #ifdef USE_MAP
4503
4503
  vec3 bodyDir = normalize( vBodyDir );
4504
4504
  float lon = atan( -bodyDir.z, bodyDir.x );
@@ -4510,14 +4510,14 @@ vEclipseWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e
4510
4510
  vec4 sampledDiffuseColor = textureGrad( map, euv, seam ? dxB : dxA, seam ? dyB : dyA );
4511
4511
  diffuseColor *= sampledDiffuseColor;
4512
4512
  #endif
4513
- `;function aD(e){let t=new pu({color:e,roughness:1,metalness:0});return t.onBeforeCompile=e=>{e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4513
+ `;function oD(e){let t=new pu({color:e,roughness:1,metalness:0});return t.onBeforeCompile=e=>{e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
4514
4514
  varying vec3 vBodyDir;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
4515
4515
  vBodyDir = position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
4516
- varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,iD).replace(`#include <envmap_physical_pars_fragment>`,`
4516
+ varying vec3 vBodyDir;`).replace(`#include <map_fragment>`,aD).replace(`#include <envmap_physical_pars_fragment>`,`
4517
4517
  #ifdef USE_ENVMAP
4518
4518
  vec3 getIBLIrradiance( const in vec3 normal ) { return vec3( 0.0 ); }
4519
4519
  vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { return vec3( 0.0 ); }
4520
- #endif`)},jC(t,`shapeModel`),t}function oD(e,t){e.traverse(e=>{if(!(e instanceof ks))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function sD(e,t,n,r){e.traverse(e=>{!(e instanceof ks)||!(e.material instanceof pu)||(e.material.map=t,t?e.material.color.copy(ZE(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function cD(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=Jr,e.map=t,e.color.copy(ZE(t,n)),e.needsUpdate=!0}var lD=new Set([]);function uD(e){return e?.model_name?Bx()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!lD.has(e.id)?`dem-preferred`:null:`no-bundle`}function dD(e,t,n,r){e.body.orientation=t,n?.credits.registerOrientation({bodyId:e.body.data.id,systemId:r??e.body.data.id,source:t.source,reference:t.reference})}var fD=48,pD=96,mD=fD*pD,hD=1<<24,gD=Math.PI*2;function _D(e){let t=Math.floor((e+1)/2*fD);return Math.min(fD-1,Math.max(0,t))}function vD(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/gD*pD)%pD+pD)%pD}var yD=new J;function bD(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)yD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=yD.x,r[i*3+1]=yD.y,r[i*3+2]=yD.z,n[i]=_D(yD.y)*pD+vD(yD.x,yD.z);return{cells:n,dirs:r}}function xD(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++)yD.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=yD.x,i[e*3+1]=yD.y,i[e*3+2]=yD.z;return i}var SD=new J,CD=new J,wD=new J,TD=new J,ED=new J,DD=new J;function OD(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function kD(e,t,n,r){return DD.crossVectors(e,n).dot(r)>=0&&DD.crossVectors(n,t).dot(r)>=0}function AD(e,t,n){TD.crossVectors(e,t);let r=TD.lengthSq();r<1e-18||(ED.set(0,1,0).addScaledVector(TD,-TD.y/r).normalize(),kD(e,t,ED,TD)&&(n.hi=Math.max(n.hi,_D(ED.y))),ED.negate(),kD(e,t,ED,TD)&&(n.lo=Math.min(n.lo,_D(ED.y))))}function jD(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 MD(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/pD|0,p=u/pD|0,m=d/pD|0,h=l%pD,g=u%pD,_=d%pD,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+pD-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+pD):x-S>C&&(w=x,T=S+pD),(y-v>1||T-w>1)&&(OD(s,t,SD),OD(s,r,CD),OD(s,i,wD),jD(SD,CD,wD,1)?(y=fD-1,w=0,T=pD-1):jD(SD,CD,wD,-1)?(v=0,w=0,T=pD-1):(n.lo=v,n.hi=y,AD(SD,CD,n),AD(CD,wD,n),AD(wD,SD,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 ND(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*hD+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*pD+a%pD,i)}}}function PD(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 ks))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>=hD||n.push({verts:xD(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=MD(n,n.map(bD)),i=new Int32Array(mD+1);ND(r,e=>i[e+1]++);for(let e=0;e<mD;e++)i[e+1]+=i[e];let a=new Int32Array(i[mD]),o=i.slice(0,mD);return ND(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var FD=new J,ID=new J,LD=new J,RD=new J,zD=new J,BD=new J,VD=new J;function HD(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;FD.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),ID.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),LD.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),RD.subVectors(ID,FD),zD.subVectors(LD,FD),BD.crossVectors(n,zD);let o=RD.dot(BD);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-FD.dot(BD)*s;if(c<0||c>1)return 0;VD.crossVectors(FD,RD).negate();let l=n.dot(VD)*s;if(l<0||c+l>1)return 0;let u=zD.dot(VD)*s;return u>0?u:0}function UD(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=HD(o[t/hD|0],t%hD,n);i>r&&(r=i)}return r}function WD(e,t){let n=_D(t.y),r=vD(t.x,t.z),i=UD(e,n*pD+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=fD))for(let n=-1;n<=1;n++)i=UD(e,o*pD+(r+n+pD)%pD,t,i)}if(i===0&&(n===0||n===fD-1)){let r=n===0?0:fD-2;for(let n=r;n<r+2;n++)for(let r=0;r<pD;r++)i=UD(e,n*pD+r,t,i)}return i>0?i:null}function GD(e){let t=e.data.objectType;return t===G.SPACECRAFT||t===G.DEBRIS||e.data.orbitalSource===tn.SPICE_PROBE}var KD=new OT;KD.setMeshoptDecoder(OE);var qD=KD,JD=new Map;function YD(e){let t=JD.get(e);return t||(t=fetch(Kt(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),JD.set(e,t)),t}function XD(e){return e.credit??e.exports.high.credit}function ZD(e){return e.modelUnitOverride??e.radiusScene}var QD=new Set;function $D(e,t){let n=new Ra;n.scale.setScalar(ZD(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,QD.add(n)}function eO(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof ks))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof pu)||n.has(t)||(n.add(t),e.eclipseShadow=zC(t,e.eclipseShadow??void 0))})}function tO(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=(GD(e.body)?nO(e,t,n):rO(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function nO(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await px(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=WE(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),aO(e,!0);let s=YD(o),c=await qD.loadAsync(Kt(`/v1/models/${o}/high.glb`,`models`)),l=null;try{l=await s}catch(e){console.warn(`Failed to load model metadata for ${o}:`,e)}if((e.modelLoadEpoch??0)!==r||!e.mesh){DO(c.scene);return}let u=l?.frame_map?vC(l.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=oO(c.scene,u),f=l?.model_anchor?new J(...l.model_anchor):null;if(sO(d,f&&u?f.applyQuaternion(u):f),EO(d),t.add(d),e.model=d,e.modelName=o,aO(e,!1),l){if(l.scale_meters){let t=l.scale_meters/2e3;e.body.data.radiusKm=t*(l.body_span_ratio??1),e.radiusScene=Q(mn(e.body.data)),e.modelUnitOverride=l.body_span_ratio?Q(t):void 0}n?.credits.registerModel({bodyId:e.body.data.id,source:l.exports.high.credit.url,organisation:l.exports.high.credit.name,license:l.exports.high.credit.license})}}finally{e.model||aO(e,!1)}}async function rO(e,t){if(!Ax().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await px(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=uD(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&&dD(e,r.global.orientation,t);let o=YD(i),s=await qD.loadAsync(Kt(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){DO(s.scene);return}let c;try{c=await o}catch(e){DO(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){DO(s.scene);return}let l=s.scene;sO(l),l.userData.radialIndex=PD(l),oD(l,aD(e.body.data.color??g_(e.body.data)));let u=e.mesh?e.mesh.material.map:null;u&&sD(l,u,g_(e.body.data),e.body.data.color),EO(l),eO(e,l),c.true_scale&&(e.radiusScene=Q(c.true_scale.max_extent_km/2),Number.isFinite(e.body.data.radiusKm)&&e.body.data.radiusKm>0||(e.body.data.radiusKm=c.true_scale.max_extent_km/2),e.noPhysical&&(e.noPhysical=void 0,qE(e,`missing`,null))),$D(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let d=XD(c),f=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:d.url,organisation:d.name,license:d.license,provenance:f?.provenance,technique:f?.technique,archive:f?.archive,archiveUrl:f?.archive_url,mission:f?.mission&&{name:f.mission.name,id:f.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function iO(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,aO(e,!1);let t=!GD(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=(QD.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),DO(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 aO(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 oO(e,t){if(!t)return e;let n=new Ra;return e.quaternion.copy(t),n.add(e),n}function sO(e,t=null){e.updateMatrixWorld(!0);let n=new so().setFromObject(e,!0),r=n.getSize(new J),i=n.getCenter(new J),a=Math.max(r.x,r.y,r.z);if(a<=0)return;let o=2/a;t&&i.addScaledVector(t,a/2),e.scale.multiplyScalar(o),e.userData.fitScale=e.scale.x,e.position.copy(i).multiplyScalar(-o),e.userData.centerOffset=i.clone().multiplyScalar(o),e.userData.feetOffset=new J(i.x,n.min.y,i.z).multiplyScalar(o),e.userData.halfExtents=r.clone().multiplyScalar(o*.5);let s=uO(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c}var cO=8,lO=4096;function uO(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 ks&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/lO)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof ks))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:cO},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(cO-1,Math.max(0,Math.floor(t*cO)))].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 dO=4,fO=.05,pO=new J,mO=new J,hO=new J,gO=new J,_O=new Vi,vO=new J,yO=new Ld;function bO(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(gO).x;if(!(a>0))return null;let o=Math.cos(t);pO.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),mO.copy(pO).applyQuaternion(e.quaternion),hO.copy(e.position).addScaledVector(mO,dO),i.localToWorld(hO),yO.set(hO,mO.negate());let s=yO.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(_O.copy(e.quaternion).invert()),Math.max(dO-s.distance/a,fO)):null}function xO(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=WD(n,vO.set(t[0],t[1],t[2]));return r===null?null:sg(r*ZD(e))}function SO(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function CO(e){if(!SO(e))return;let t=e.model.position,n=ZD(e);return[t.x*n,t.y*n,t.z*n]}function wO(e){if(SO(e))return sg(e.model.userData.maxRadius*ZD(e))}function TO(e){if(SO(e))return sg(e.model.userData.minRadius*ZD(e))}function EO(e){e.traverse(e=>{e instanceof ks&&(e.castShadow=!0,e.receiveShadow=!0)})}function DO(e){e.traverse(e=>{if(!(e instanceof ks))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 aa&&t.dispose();e.dispose()}})}function OO(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=>{wT(e,s,n),p.set(e.position[0]-m,e.position[1]-h,e.position[2]-g);let r=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!nT(p.z))return;let o=(p.x+1)*.5*i,c=(1-p.y)*.5*a,u=Math.hypot(o-d,c-f);(u<y||u===y&&r<b)&&(l&&!l(p.x,p.y,r)||(y=u,b=r,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===G.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var kO=9,AO=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Ld;_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>kO)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,...QD]))?.body,o=OO(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;wT(n,r,this.ctx);let i=this.worldDistOf(n);if(this.isDotVisible(e.ndcX,e.ndcY,i))return{body:n,distance:i,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e.position[0]-t-i.x,e.position[1]-n-i.y,e.position[2]-r-i.z)}resolveMeshHit(e){for(let t of e){let e=t.object;for(;e;){let n=this.meshToBody.get(e)??e.userData.pickBody;if(n)return{body:n,distance:t.distance};e=e.parent}}}isDotVisible=(e,t,n)=>{if(this.modelPick(e,t))return!1;if(this.clickables.length===0&&QD.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);if(QD.size>0&&r.push(...this.raycaster.intersectObjects([...QD],!0)),r.length===0)return!0;let i=1/0;for(let e of r)e.distance<i&&(i=e.distance);return i>=n*.999}},jO=4,MO=16,NO=`
4520
+ #endif`)},MC(t,`shapeModel`),t}function sD(e,t){e.traverse(e=>{if(!(e instanceof ks))return;let n=e.material;e.material=t;let r=Array.isArray(n)?n:[n];for(let e of r)e?.dispose()})}function cD(e,t,n,r){e.traverse(e=>{!(e instanceof ks)||!(e.material instanceof pu)||(e.material.map=t,t?e.material.color.copy(QE(t,r)):e.material.color.set(n),e.material.needsUpdate=!0)})}function lD(e,t,n){e.map&&e.map!==t&&e.map.dispose(),t.colorSpace=Jr,e.map=t,e.color.copy(QE(t,n)),e.needsUpdate=!0}var uD=new Set([]);function dD(e){return e?.model_name?Vx()&&e.render_quality!==`high`?`low-end-device`:e.displacement&&!uD.has(e.id)?`dem-preferred`:null:`no-bundle`}function fD(e,t,n,r){e.body.orientation=t,n?.credits.registerOrientation({bodyId:e.body.data.id,systemId:r??e.body.data.id,source:t.source,reference:t.reference})}var pD=48,mD=96,hD=pD*mD,gD=1<<24,_D=Math.PI*2;function vD(e){let t=Math.floor((e+1)/2*pD);return Math.min(pD-1,Math.max(0,t))}function yD(e,t){let n=Math.atan2(-t,e);return(Math.floor((n+Math.PI)/_D*mD)%mD+mD)%mD}var bD=new J;function xD(e){let t=e.verts.length/3,n=new Int32Array(t),r=new Float32Array(t*3);for(let i=0;i<t;i++)bD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]).normalize(),r[i*3]=bD.x,r[i*3+1]=bD.y,r[i*3+2]=bD.z,n[i]=vD(bD.y)*mD+yD(bD.x,bD.z);return{cells:n,dirs:r}}function SD(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++)bD.set(n.getX(e),n.getY(e),n.getZ(e)).applyMatrix4(r),i[e*3]=bD.x,i[e*3+1]=bD.y,i[e*3+2]=bD.z;return i}var CD=new J,wD=new J,TD=new J,ED=new J,DD=new J,OD=new J;function kD(e,t,n){return n.set(e[t*3],e[t*3+1],e[t*3+2])}function AD(e,t,n,r){return OD.crossVectors(e,n).dot(r)>=0&&OD.crossVectors(n,t).dot(r)>=0}function jD(e,t,n){ED.crossVectors(e,t);let r=ED.lengthSq();r<1e-18||(DD.set(0,1,0).addScaledVector(ED,-ED.y/r).normalize(),AD(e,t,DD,ED)&&(n.hi=Math.max(n.hi,vD(DD.y))),DD.negate(),AD(e,t,DD,ED)&&(n.lo=Math.min(n.lo,vD(DD.y))))}function MD(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 ND(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/mD|0,p=u/mD|0,m=d/mD|0,h=l%mD,g=u%mD,_=d%mD,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+mD-x,w=b,T=x;S-b>=x-S&&S-b>C?(w=S,T=b+mD):x-S>C&&(w=x,T=S+mD),(y-v>1||T-w>1)&&(kD(s,t,CD),kD(s,r,wD),kD(s,i,TD),MD(CD,wD,TD,1)?(y=pD-1,w=0,T=mD-1):MD(CD,wD,TD,-1)?(v=0,w=0,T=mD-1):(n.lo=v,n.hi=y,jD(CD,wD,n),jD(wD,TD,n),jD(TD,CD,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 PD(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*gD+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*mD+a%mD,i)}}}function FD(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 ks))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>=gD||n.push({verts:SD(e,t),idx:i?i.array:null,faces:Math.floor(a)})}),!n.length)return null;let r=ND(n,n.map(xD)),i=new Int32Array(hD+1);PD(r,e=>i[e+1]++);for(let e=0;e<hD;e++)i[e+1]+=i[e];let a=new Int32Array(i[hD]),o=i.slice(0,hD);return PD(r,(e,t)=>{a[o[e]++]=t}),{meshes:n,start:i,slots:a}}var ID=new J,LD=new J,RD=new J,zD=new J,BD=new J,VD=new J,HD=new J;function UD(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;ID.set(e.verts[r*3],e.verts[r*3+1],e.verts[r*3+2]),LD.set(e.verts[i*3],e.verts[i*3+1],e.verts[i*3+2]),RD.set(e.verts[a*3],e.verts[a*3+1],e.verts[a*3+2]),zD.subVectors(LD,ID),BD.subVectors(RD,ID),VD.crossVectors(n,BD);let o=zD.dot(VD);if(Math.abs(o)<1e-12)return 0;let s=1/o,c=-ID.dot(VD)*s;if(c<0||c>1)return 0;HD.crossVectors(ID,zD).negate();let l=n.dot(HD)*s;if(l<0||c+l>1)return 0;let u=BD.dot(HD)*s;return u>0?u:0}function WD(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=UD(o[t/gD|0],t%gD,n);i>r&&(r=i)}return r}function GD(e,t){let n=vD(t.y),r=yD(t.x,t.z),i=WD(e,n*mD+r,t,0);if(i>0)return i;for(let a=-1;a<=1;a++){let o=n+a;if(!(o<0||o>=pD))for(let n=-1;n<=1;n++)i=WD(e,o*mD+(r+n+mD)%mD,t,i)}if(i===0&&(n===0||n===pD-1)){let r=n===0?0:pD-2;for(let n=r;n<r+2;n++)for(let r=0;r<mD;r++)i=WD(e,n*mD+r,t,i)}return i>0?i:null}function KD(e){let t=e.data.objectType;return t===G.SPACECRAFT||t===G.DEBRIS||e.data.orbitalSource===tn.SPICE_PROBE}var qD=new kT;qD.setMeshoptDecoder(kE);var JD=qD,YD=new Map;function XD(e){let t=YD.get(e);return t||(t=fetch(Kt(`/v1/models/${e}/metadata.json`,`models`)).then(e=>e.json()),YD.set(e,t)),t}function ZD(e){return e.credit??e.exports.high.credit}function QD(e){return e.modelUnitOverride??e.radiusScene}var $D=new Set;function eO(e,t){let n=new Ra;n.scale.setScalar(QD(e)),n.userData.pickBody=e.body,n.add(t),e.group.add(n),e.modelRoot=n,e.model=t,$D.add(n)}function tO(e,t){let n=new Set;t.traverse(t=>{if(!(t instanceof ks))return;let r=Array.isArray(t.material)?t.material:[t.material];for(let t of r)!(t instanceof pu)||n.has(t)||(n.add(t),e.eclipseShadow=BC(t,e.eclipseShadow??void 0))})}function nO(e,t,n){if(e.model)return Promise.resolve();if(e.modelLoadPromise)return e.modelLoadPromise;let r=(KD(e.body)?rO(e,t,n):iO(e,n)).finally(()=>{e.modelLoadPromise===r&&(e.modelLoadPromise=void 0)});return e.modelLoadPromise=r,r}async function rO(e,t,n){let r=e.modelLoadEpoch??0;e.mesh&&(e.mesh.visible=!1);try{let i=await mx(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=GE(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),oO(e,!0);let s=XD(o),c=await JD.loadAsync(Kt(`/v1/models/${o}/high.glb`,`models`)),l=null;try{l=await s}catch(e){console.warn(`Failed to load model metadata for ${o}:`,e)}if((e.modelLoadEpoch??0)!==r||!e.mesh){OO(c.scene);return}let u=l?.frame_map?yC(l.frame_map):null;e.body.modelBaseFrame=u??void 0;let d=sO(c.scene,u),f=l?.model_anchor?new J(...l.model_anchor):null;if(cO(d,f&&u?f.applyQuaternion(u):f),DO(d),t.add(d),d.visible=!e.isCrashed,e.model=d,e.modelName=o,oO(e,!1),l){if(l.scale_meters){let t=l.scale_meters/2e3;e.body.data.radiusKm=t*(l.body_span_ratio??1),e.radiusScene=Q(mn(e.body.data)),e.modelUnitOverride=l.body_span_ratio?Q(t):void 0}n?.credits.registerModel({bodyId:e.body.data.id,source:l.exports.high.credit.url,organisation:l.exports.high.credit.name,license:l.exports.high.credit.license})}}finally{e.model||oO(e,!1)}}async function iO(e,t){if(!jx().showShapeMesh)return;let n=e.modelLoadEpoch??0;try{let r=await mx(e.body.data.id,!1),i=r.global?.model_name;if(!i)return;let a=dD(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&&fD(e,r.global.orientation,t);let o=XD(i),s=await JD.loadAsync(Kt(`/v1/models/${i}/high.glb`,`models`));if((e.modelLoadEpoch??0)!==n){OO(s.scene);return}let c;try{c=await o}catch(e){OO(s.scene),console.warn(`Failed to load shape-model metadata for ${i}:`,e);return}if(c.kind!==`shape_model`){OO(s.scene);return}let l=s.scene;cO(l),l.userData.radialIndex=FD(l),sD(l,oD(e.body.data.color??g_(e.body.data)));let u=e.mesh?e.mesh.material.map:null;u&&cD(l,u,g_(e.body.data),e.body.data.color),DO(l),tO(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,JE(e,`missing`,null))),eO(e,l),e.modelName=i,e.mesh&&(e.mesh.visible=!1);let d=ZD(c),f=r.global?.model_source;t?.credits.registerModel({bodyId:e.body.data.id,source:d.url,organisation:d.name,license:d.license,provenance:f?.provenance,technique:f?.technique,archive:f?.archive,archiveUrl:f?.archive_url,mission:f?.mission&&{name:f.mission.name,id:f.mission.primary_id}})}finally{!e.model&&e.mesh&&(e.mesh.visible=!0)}}function aO(e){e.modelLoadEpoch=(e.modelLoadEpoch??0)+1,e.modelLoadPromise=void 0,oO(e,!1);let t=!KD(e.body),n=e.model;if(!n){e.mesh&&t&&(e.mesh.visible=!0);return}e.modelRoot&&=($D.delete(e.modelRoot),e.modelRoot.removeFromParent(),null),n.parent?.remove(n),OO(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 oO(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 sO(e,t){if(!t)return e;let n=new Ra;return e.quaternion.copy(t),n.add(e),n}function cO(e,t=null){e.updateMatrixWorld(!0);let n=new so().setFromObject(e,!0),r=n.getSize(new J),i=n.getCenter(new J),a=Math.max(r.x,r.y,r.z);if(a<=0)return;let o=2/a;t&&i.addScaledVector(t,a/2),e.scale.multiplyScalar(o),e.userData.fitScale=e.scale.x,e.position.copy(i).multiplyScalar(-o),e.userData.centerOffset=i.clone().multiplyScalar(o),e.userData.feetOffset=new J(i.x,n.min.y,i.z).multiplyScalar(o),e.userData.halfExtents=r.clone().multiplyScalar(o*.5);let s=dO(e,r,o,e.userData.centerOffset);e.userData.occluderSpheres=s.spheres;let c=e.userData.centerOffset.length();e.userData.minRadius=Math.max(0,s.minRadius-c),e.userData.maxRadius=e.userData.halfExtents.length()+c}var lO=8,uO=4096;function dO(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 ks&&(a+=e.geometry.attributes.position?.count??0)}),!a)return{spheres:[],minRadius:0};let o=Math.max(1,Math.floor(a/uO)),s=[],c=new J;e.traverse(t=>{if(!(t instanceof ks))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:lO},()=>[]);for(let e of s){let t=(e.getComponent(i)+l)/(2*l);u[Math.min(lO-1,Math.max(0,Math.floor(t*lO)))].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 fO=4,pO=.05,mO=new J,hO=new J,gO=new J,_O=new J,vO=new Vi,yO=new J,bO=new Ld;function xO(e,t,n,r){let i=e.parent;if(!i)return null;i.updateMatrixWorld(!0);let a=i.getWorldScale(_O).x;if(!(a>0))return null;let o=Math.cos(t);mO.set(o*Math.cos(n),Math.sin(t),-o*Math.sin(n)),hO.copy(mO).applyQuaternion(e.quaternion),gO.copy(e.position).addScaledVector(hO,fO),i.localToWorld(gO),bO.set(gO,hO.negate());let s=bO.intersectObject(e,!0)[0];return s?(r&&s.face&&r.copy(s.face.normal).transformDirection(s.object.matrixWorld).applyQuaternion(vO.copy(e.quaternion).invert()),Math.max(fO-s.distance/a,pO)):null}function SO(e,t){let n=e?.model?.userData.radialIndex;if(!n)return null;let r=GD(n,yO.set(t[0],t[1],t[2]));return r===null?null:sg(r*QD(e))}function CO(e){return!!e?.model?.userData.radialIndex&&e.model.parent===e.modelRoot}function wO(e){if(!CO(e))return;let t=e.model.position,n=QD(e);return[t.x*n,t.y*n,t.z*n]}function TO(e){if(CO(e))return sg(e.model.userData.maxRadius*QD(e))}function EO(e){if(CO(e))return sg(e.model.userData.minRadius*QD(e))}function DO(e){e.traverse(e=>{e instanceof ks&&(e.castShadow=!0,e.receiveShadow=!0)})}function OO(e){e.traverse(e=>{if(!(e instanceof ks))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 aa&&t.dispose();e.dispose()}})}function kO(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=>{TT(e,s,n),p.set(e.position[0]-m,e.position[1]-h,e.position[2]-g);let r=Math.hypot(p.x-_.x,p.y-_.y,p.z-_.z);if(p.project(t),!rT(p.z))return;let o=(p.x+1)*.5*i,c=(1-p.y)*.5*a,u=Math.hypot(o-d,c-f);(u<y||u===y&&r<b)&&(l&&!l(p.x,p.y,r)||(y=u,b=r,v=e))};for(let e of n.bodies.majorBodies)e.data.objectType===G.MOON&&n.visibility.isMoonGroupVisible(e.data.parentId)&&x(e);return v?{body:v,distance:b,screenDist:y}:null}var AO=9,jO=class{downPos=new q;pointer=new q;_tmpPointer=new q;raycaster=new Ld;_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>AO)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,...$D]))?.body,o=kO(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;TT(n,r,this.ctx);let i=this.worldDistOf(n);if(this.isDotVisible(e.ndcX,e.ndcY,i))return{body:n,distance:i,screenDist:e.pixelDist}}return null}worldDistOf(e){let[t,n,r]=this.focus.focusTruePos,i=this.camera.position;return Math.hypot(e.position[0]-t-i.x,e.position[1]-n-i.y,e.position[2]-r-i.z)}resolveMeshHit(e){for(let t of e){let e=t.object;for(;e;){let n=this.meshToBody.get(e)??e.userData.pickBody;if(n)return{body:n,distance:t.distance};e=e.parent}}}isDotVisible=(e,t,n)=>{if(this.modelPick(e,t))return!1;if(this.clickables.length===0&&$D.size===0)return!0;this._tmpPointer.set(e,t),this.raycaster.setFromCamera(this._tmpPointer,this.camera);let r=this.raycaster.intersectObjects(this.clickables,!1);if($D.size>0&&r.push(...this.raycaster.intersectObjects([...$D],!0)),r.length===0)return!0;let i=1/0;for(let e of r)e.distance<i&&(i=e.distance);return i>=n*.999}},MO=4,NO=16,PO=`
4521
4521
  uniform mat4 modelViewMatrix;
4522
4522
  uniform mat4 projectionMatrix;
4523
4523
  uniform float uPointSize;
@@ -4529,13 +4529,13 @@ void main() {
4529
4529
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
4530
4530
  gl_PointSize = uPointSize;
4531
4531
  }
4532
- `,PO=`
4532
+ `,FO=`
4533
4533
  precision highp float;
4534
4534
  varying vec4 vPick;
4535
4535
  void main() {
4536
4536
  gl_FragColor = vPick;
4537
4537
  }
4538
- `,FO=class{target;material;scene=new Ka;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new ca(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=Yr,this.target.texture.generateMipmaps=!1,this.material=new fu({vertexShader:NO,fragmentShader:PO,uniforms:{uPointSize:{value:jO}},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 kc(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,MO)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function IO(e,t,n){return Math.min(Math.max(e,t),n)}function LO(e,t){let n=Math.max(e,0);return IO(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function RO(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return IO(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var zO={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},BO={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},VO={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},HO={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},UO=new J(0,1,0),WO=(()=>{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=ig*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 GO(e){return(e??new J).copy(WO)}function KO(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&(i.set(e.position[0]-e.orbitCenter[0],e.position[1]-e.orbitCenter[1],e.position[2]-e.orbitCenter[2]),i.lengthSq()>1e-20)?i.normalize():(i.copy(UO),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=dC(e.orientation,t,e.nutPrec);return i.copy(UO).applyQuaternion(a).normalize()}var qO=class{refId=null;startVec=new J(0,1,0);targetVec=new J(0,1,0);currentVec=new J(0,1,0);animStartTime=-1/0;animDurationMs=BO.refMs;needsDurationCalc=!1;_quatA=new Vi;_quatB=new Vi;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`)GO(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);KO(t,e,this.targetVec,n)}else this.targetVec.copy(UO)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=LO(e,BO)}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(UO,this.startVec),this._quatB.setFromUnitVectors(UO,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy(UO).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,UO),n._quatInverse.copy(n._quat).invert()}},JO=class extends La{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 YO(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}function XO(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function ZO(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}}var QO=new J,$O=22;function ek(){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 tk=new WeakMap;function nk(e){tk.delete(e)}function rk(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(tk.get(e)===t)return;tk.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 ik(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(tk.get(e)===t)return;tk.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 ak(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 ok(e,t,n,r,i){for(let a of i){if(a.id===r)continue;let i=e-a.cx0,o=a.cy0-t,s=-a.f,c=i*a.gxx+o*a.gxy+s*a.gxz,l=i*a.gyx+o*a.gyy+s*a.gyz,u=i*a.gzx+o*a.gzy+s*a.gzz,d=c*a.cpx+l*a.cpy+u*a.cpz;if(!(d<=0)&&!(d*d<=a.K*(c*c+l*l+u*u))&&i*a.ccx+o*a.ccy+s*a.ccz<=n*Math.hypot(i,o,s))return!0}return!1}function sk(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function ck(e,t,n,r,i,a){let o=e.label,[s,c,l]=e.body.position,u=o.position;QO.set(s-n[0]+u.x,c-n[1]+u.y,l-n[2]+u.z),QO.project(t),a.x=(QO.x*.5+.5)*r,a.y=(-QO.y*.5+.5)*i;let d=a.x-o.center.x*32;return a.left=d,a.right=d+40+(e.labelTextWidth||50),a.h=$O,nT(QO.z)}var lk=[],uk=0,dk=[],fk=0,pk=[],mk=0,hk={rects:dk,get count(){return fk}};function gk(){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 _k(){return{left:0,right:0,y:0,h:0}}var vk={x:0,left:0,right:0,y:0,h:0};function yk(e,t){for(let n=0;n<t;n++)sk(XO(pk,n,_k),e[n]);mk=t}function bk(){for(let e=0;e<mk;e++)sk(XO(dk,e,_k),pk[e]);return mk}function xk(e,t,n,r,i,a,o,s,c=[0,0,0]){uk=0,fk=bk();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(!ck(s,r,c,t,n,vk))continue;let d=e.data.id===i,f=o.has(e.data.id),p=XO(lk,uk++,gk);sk(p.rect,vk),p.rect.x=vk.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,p.dist=s.cachedDist}lk.length=uk,lk.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=ZO(e.body.data.objectType),i=ZO(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<uk;e++){let t=lk[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){rk(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&ok(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<fk;n++){let r=dk[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<$O){e=!0;break}}rk(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<fk;e++){let n=dk[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<$O){i=!0;break}}i?(rk(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(sk(XO(dk,fk++,_k),t.rect),ik(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<uk;e++){let t=lk[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function Sk(e,t,n,r,i){fk=bk();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&ck(a,r,i,t,n,vk)&&sk(XO(dk,fk++,_k),vk)}var Ck=`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`,wk=`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 Tk(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,t?wk:Ck)}function Ek(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 Dk(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:Ek(i,t,n,r),JE(e)}function Ok(e){let t=e.data.objectType;return gn(t)||t===G.STAR||hn(t)||t===G.COMET||t===G.BARYCENTER||t===G.LAGRANGE_POINT?`major`:t===G.SPACECRAFT?`spacecraft`:t===G.DEBRIS?`debris`:`none`}function kk(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`:Ck),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(),YO(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&Ek(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)`:``,nk(l),document.body.style.cursor=``,o?.(!1)});let p=new JO(c);return p.visible=!1,p}var Ak=3;function jk(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>Ak*Ak&&(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 Mk=[`low`,`medium`,`high`,`ultra`],Nk={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 Pk(){return Hx()?Bx()?`low`:`medium`:Bx()?`high`:`ultra`}function Fk(e){if(e!==`auto`)return e;let t=Ax();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??Pk()}function Ik(){let e=Ax();return{...Nk[Fk(e.atmosphereQuality)],...e.atmoQualityOverrides}}function Lk(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var Rk=30,zk=45,Bk=3e3,Vk=2500,Hk=250,Uk=60,Wk=0,Gk=Vk,Kk=``;function qk(e,t){let n=Ax();if(n.atmosphereQuality!==`auto`||e<=0||e>Hk)return;let r=Lk(Ik());if(r!==Kk&&(Kk=r,Gk=Vk,Wk=0,Uk=60),Uk+=(1e3/e-Uk)*Math.min(1,e/500),Gk>0){Gk-=e;return}if(!t||Uk>zk){Wk=Math.max(0,Wk-e);return}if(Uk>=Rk||(Wk+=e,Wk<Bk))return;Wk=0;let i=Mk[Mk.indexOf(Fk(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var Jk=256,Yk=96;async function Xk(e,t,n){let r=await fetch(e);if(!r.ok)throw Error(`Failed to load ${e}: ${r.status} ${r.statusText}`);let i=await r.blob(),a=await createImageBitmap(i),o=Math.min(a.width,n);o<a.width&&console.info(`Ring strip ${e}: downscaling ${a.width}px → ${o}px to fit GL MAX_TEXTURE_SIZE.`);let s=Zk(a,e,n),c={};for(let[n,r]of Object.entries(t)){let t=document.createElement(`canvas`);t.width=o,t.height=2;let i=t.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);let l=Qk(s,a.width,r,o);i.putImageData(l,0,0),i.putImageData(l,0,1);let u=new Mc(t);n===`color`&&(u.colorSpace=Jr),u.minFilter=Nn,u.magFilter=jn,u.generateMipmaps=!0,u.anisotropy=16,u.needsUpdate=!0,c[n]=u}return a.close(),c}function Zk(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 Qk(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 $k=`
4538
+ `,IO=class{target;material;scene=new Ka;pickCamera;size=0;buffer=new Uint8Array;prevClear=new X;proxies=[];constructor(e,t){this.renderer=e,this.target=new ca(1,1,{depthBuffer:!0}),this.target.texture.colorSpace=Yr,this.target.texture.generateMipmaps=!1,this.material=new fu({vertexShader:PO,fragmentShader:FO,uniforms:{uPointSize:{value:MO}},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 kc(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,NO)}dispose(){this.target.dispose(),this.material.dispose(),this.proxies.length=0}};function LO(e,t,n){return Math.min(Math.max(e,t),n)}function RO(e,t){let n=Math.max(e,0);return LO(t.refMs*n/t.refAngleRad,t.minMs,t.maxMs)}function zO(e,t){if(!(e>0))return t.minMs;let n=Math.log10(e/t.refDist);return LO(t.refMs+n*t.msPerDecade,t.minMs,t.maxMs)}var BO={refMs:350,refAngleRad:Math.PI/3,minMs:200,maxMs:700},VO={refMs:400,refAngleRad:Math.PI/2,minMs:200,maxMs:800},HO={refMs:1600,refDist:2,msPerDecade:400,minMs:600,maxMs:2500},UO={refMs:1600,refAngleRad:Math.PI/2,minMs:600,maxMs:2500},WO=new J(0,1,0),GO=(()=>{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=ig*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 KO(e){return(e??new J).copy(GO)}function qO(e,t,n,r=!1){let i=n??new J;if(!e.orientation)return r&&e.orbitCenter&&(i.set(e.position[0]-e.orbitCenter[0],e.position[1]-e.orbitCenter[1],e.position[2]-e.orbitCenter[2]),i.lengthSq()>1e-20)?i.normalize():(i.copy(WO),e.modelBaseFrame&&i.applyQuaternion(e.modelBaseFrame).normalize(),i);let a=fC(e.orientation,t,e.nutPrec);return i.copy(WO).applyQuaternion(a).normalize()}var JO=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=VO.refMs;needsDurationCalc=!1;_quatA=new Vi;_quatB=new Vi;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`)KO(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);qO(t,e,this.targetVec,n)}else this.targetVec.copy(WO)}if(this.needsDurationCalc){this.needsDurationCalc=!1;let e=this.startVec.angleTo(this.targetVec);this.animDurationMs=RO(e,VO)}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(WO,this.startVec),this._quatB.setFromUnitVectors(WO,this.targetVec),this._quatA.slerp(this._quatB,n),this.currentVec.copy(WO).applyQuaternion(this._quatA)}this.camera.up.copy(this.currentVec);let n=this.controls;n._quat.setFromUnitVectors(this.currentVec,WO),n._quatInverse.copy(n._quat).invert()}},YO=class extends La{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 XO(e){return e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey}function ZO(e,t,n){let r=e[t];return r||(r=n(),e[t]=r),r}function QO(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}}var $O=new J,ek=22;function tk(){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 nk=new WeakMap;function rk(e){nk.delete(e)}function ik(e,t,n,r=.3,i=null){if(e){let t=`d${r}${+!!n}`;if(nk.get(e)===t)return;nk.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 ak(e,t,n,r,i=null){if(e){let t=`r${+!!n}${+!!r}`;if(nk.get(e)===t)return;nk.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 ok(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 sk(e,t,n,r,i){for(let a of i){if(a.id===r)continue;let i=e-a.cx0,o=a.cy0-t,s=-a.f,c=i*a.gxx+o*a.gxy+s*a.gxz,l=i*a.gyx+o*a.gyy+s*a.gyz,u=i*a.gzx+o*a.gzy+s*a.gzz,d=c*a.cpx+l*a.cpy+u*a.cpz;if(!(d<=0)&&!(d*d<=a.K*(c*c+l*l+u*u))&&i*a.ccx+o*a.ccy+s*a.ccz<=n*Math.hypot(i,o,s))return!0}return!1}function ck(e,t){e.left=t.left,e.right=t.right,e.y=t.y,e.h=t.h}function lk(e,t,n,r,i,a){let o=e.label,[s,c,l]=e.body.position,u=o.position;$O.set(s-n[0]+u.x,c-n[1]+u.y,l-n[2]+u.z),$O.project(t),a.x=($O.x*.5+.5)*r,a.y=(-$O.y*.5+.5)*i;let d=a.x-o.center.x*32;return a.left=d,a.right=d+40+(e.labelTextWidth||50),a.h=ek,rT($O.z)}var uk=[],dk=0,fk=[],pk=0,mk=[],hk=0,gk={rects:fk,get count(){return pk}};function _k(){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 vk(){return{left:0,right:0,y:0,h:0}}var yk={x:0,left:0,right:0,y:0,h:0};function bk(e,t){for(let n=0;n<t;n++)ck(ZO(mk,n,vk),e[n]);hk=t}function xk(){for(let e=0;e<hk;e++)ck(ZO(fk,e,vk),mk[e]);return hk}function Sk(e,t,n,r,i,a,o,s,c=[0,0,0]){dk=0,pk=xk();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(!lk(s,r,c,t,n,yk))continue;let d=e.data.id===i,f=o.has(e.data.id),p=ZO(uk,dk++,_k);ck(p.rect,yk),p.rect.x=yk.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,p.dist=s.cachedDist}uk.length=dk,uk.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=QO(e.body.data.objectType),i=QO(t.body.data.objectType);return r===i?e.dist-t.dist:r-i});for(let e=0;e<dk;e++){let t=uk[e],n=t.labelHalo,r=n?.nextElementSibling;if(t.isCapped&&!t.isSelected){ik(n,r,!0,.3,t.bo.labelStack),t.bo.labelMaximized=!1;continue}if(!t.isSelected&&sk(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<pk;n++){let r=fk[n];if(t.rect.x-8<r.right&&t.rect.x+8>r.left&&Math.abs(t.rect.y-r.y)<ek){e=!0;break}}ik(n,r,!e,e?.3:.5,t.bo.labelStack),t.bo.labelMaximized=!1;continue}let i=!1;for(let e=0;e<pk;e++){let n=fk[e];if(t.rect.left<n.right&&t.rect.right>n.left&&Math.abs(t.rect.y-n.y)<ek){i=!0;break}}i?(ik(n,r,!1,.3,t.bo.labelStack),t.bo.labelMaximized=!1):(ck(ZO(fk,pk++,vk),t.rect),ak(n,r,o.has(t.bodyId),t.isFocused,t.bo.labelStack),t.bo.labelMaximized=!0)}for(let e=0;e<dk;e++){let t=uk[e];t.bo=null,t.body=null,t.label=null,t.labelHalo=null}}function Ck(e,t,n,r,i){pk=xk();for(let a of e.values())a.label?.visible&&a.labelMaximized!==!1&&lk(a,r,i,t,n,yk)&&ck(ZO(fk,pk++,vk),yk)}var wk=`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`,Tk=`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`,Ek={flying:wk,landed:Tk,crashed:Tk+`M15 9l-6 6M9 9l6 6`};function Dk(e,t){if(!e)return;let n=e.querySelector(`path`);n&&n.setAttribute(`d`,Ek[t])}function Ok(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 kk(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:Ok(i,t,n,r),YE(e)}function Ak(e){let t=e.data.objectType;return gn(t)||t===G.STAR||hn(t)||t===G.COMET||t===G.BARYCENTER||t===G.LAGRANGE_POINT?`major`:t===G.SPACECRAFT?`spacecraft`:t===G.DEBRIS?`debris`:`none`}function jk(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`:wk),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(),XO(e))return;e.preventDefault();let t=e.clientX-u,n=e.clientY-d;t*t+n*n<=9&&i()};t&&Ok(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)`:``,rk(l),document.body.style.cursor=``,o?.(!1)});let p=new YO(c);return p.visible=!1,p}var Mk=3;function Nk(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>Mk*Mk&&(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 Pk=[`low`,`medium`,`high`,`ultra`],Fk={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 Ik(){return Ux()?Vx()?`low`:`medium`:Vx()?`high`:`ultra`}function Lk(e){if(e!==`auto`)return e;let t=jx();return t.atmosphereAutoTier??t.atmosphereCalibration?.tier??Ik()}function Rk(){let e=jx();return{...Fk[Lk(e.atmosphereQuality)],...e.atmoQualityOverrides}}function zk(e){return`${e.primarySteps}|${e.lightSteps}|${+e.eclipseShadows}|${+e.ringShadows}|${+e.insideView}|${+e.layeredDensity}`}var Bk=30,Vk=45,Hk=3e3,Uk=2500,Wk=250,Gk=60,Kk=0,qk=Uk,Jk=``;function Yk(e,t){let n=jx();if(n.atmosphereQuality!==`auto`||e<=0||e>Wk)return;let r=zk(Rk());if(r!==Jk&&(Jk=r,qk=Uk,Kk=0,Gk=60),Gk+=(1e3/e-Gk)*Math.min(1,e/500),qk>0){qk-=e;return}if(!t||Gk>Vk){Kk=Math.max(0,Kk-e);return}if(Gk>=Bk||(Kk+=e,Kk<Hk))return;Kk=0;let i=Pk[Pk.indexOf(Lk(`auto`))-1];i&&n.setAtmosphereAutoTier(i)}var Xk=256,Zk=96;async function Qk(e,t,n){let r=await fetch(e);if(!r.ok)throw Error(`Failed to load ${e}: ${r.status} ${r.statusText}`);let i=await r.blob(),a=await createImageBitmap(i),o=Math.min(a.width,n);o<a.width&&console.info(`Ring strip ${e}: downscaling ${a.width}px → ${o}px to fit GL MAX_TEXTURE_SIZE.`);let s=$k(a,e,n),c={};for(let[n,r]of Object.entries(t)){let t=document.createElement(`canvas`);t.width=o,t.height=2;let i=t.getContext(`2d`);if(!i)throw Error(`Failed to acquire 2D context for ring strip ${e}`);let l=eA(s,a.width,r,o);i.putImageData(l,0,0),i.putImageData(l,0,1);let u=new Mc(t);n===`color`&&(u.colorSpace=Jr),u.minFilter=Nn,u.magFilter=jn,u.generateMipmaps=!0,u.anisotropy=16,u.needsUpdate=!0,c[n]=u}return a.close(),c}function $k(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 eA(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 tA=`
4539
4539
  #include <common>
4540
4540
  #include <logdepthbuf_pars_vertex>
4541
4541
 
@@ -4570,7 +4570,7 @@ void main() {
4570
4570
  gl_Position = projectionMatrix * viewMatrix * worldPosition;
4571
4571
  #include <logdepthbuf_vertex>
4572
4572
  }
4573
- `,eA=`
4573
+ `,nA=`
4574
4574
  #include <common>
4575
4575
  #include <logdepthbuf_pars_fragment>
4576
4576
 
@@ -4686,7 +4686,7 @@ void main() {
4686
4686
  gl_FragColor = vec4(finalAlbedo * uIntensityScale * shadow * uLightScale, alpha);
4687
4687
  #include <logdepthbuf_fragment>
4688
4688
  }
4689
- `,tA=`
4689
+ `,rA=`
4690
4690
  uniform sampler2D uRingShadowTransparency;
4691
4691
  uniform float uRingShadowInnerScene;
4692
4692
  uniform float uRingShadowOuterScene; // 0 = no rings
@@ -4739,14 +4739,14 @@ void main() {
4739
4739
  // to avoid blow-up near grazing incidence.
4740
4740
  return pow(max(trans, 1e-4), 1.0 / max(abs(denom), 0.02));
4741
4741
  }
4742
- `;function nA(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>
4742
+ `;function iA(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>
4743
4743
  varying vec3 vRingShadowWorldPos;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
4744
4744
  vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
4745
4745
  varying vec3 vRingShadowWorldPos;
4746
- ${tA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
4746
+ ${rA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
4747
4747
  float ringShadow = ringShadowAt(vRingShadowWorldPos);
4748
4748
  reflectedLight.directDiffuse *= ringShadow;
4749
- reflectedLight.directSpecular *= ringShadow;`)},jC(e,`ringShadow`),e.needsUpdate=!0,a.ringShadow=c,c}async function rA(e,t,n){let r=Q(t.inner_radius_km),i=Q(t.outer_radius_km),a=t.intensity_scale??1,o;try{o=await Xk(Kt(`/v1/rings/${e}/${t.strip}`,`rings`),t.strip_rows,n)}catch(t){return console.warn(`Failed to load ring strip for ${e}:`,t),null}let s=t.thickness_scale_km&&o.thickness?Q(t.thickness_scale_km):0,c=s>0?48:1,l=new du({uniforms:{uBackscattered:{value:o.backscattered},uForwardscattered:{value:o.forwardscattered},uUnlitside:{value:o.unlitside},uTransparency:{value:o.transparency},uColor:{value:o.color},uThickness:{value:o.thickness??o.transparency},uThicknessScene:{value:s},uLayerCount:{value:1},uLayerAlphaExp:{value:1},uInnerScene:{value:r},uOuterScene:{value:i},uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uPlanetCenter:{value:new J},uPlanetPoleDir:{value:new J(0,1,0)},uPlanetEquatorialScene:{value:0},uPlanetPolarScene:{value:0},uLightScale:{value:1},uIntensityScale:{value:a}},vertexShader:$k,fragmentShader:eA,transparent:!0,depthWrite:!1,blending:1,side:2}),u=new $l(r,i*(1/Math.cos(Math.PI/Jk)),Jk,c>1?Yk:1);u.rotateX(-Math.PI/2);let d;if(c>1){u.setAttribute(`aLayerIndex`,new qs(Float32Array.from({length:c},(e,t)=>t),1));let e=new tc(u,l,c);e.count=1,d=e}else d=new ks(u,l);d.frustumCulled=!1,d.renderOrder=3,d.userData.isRingMesh=!0;let f={uPlanetCenter:l.uniforms.uPlanetCenter,uPlanetPoleDir:l.uniforms.uPlanetPoleDir,uPlanetEquatorialScene:l.uniforms.uPlanetEquatorialScene,uPlanetPolarScene:l.uniforms.uPlanetPolarScene};return{mesh:d,material:l,layers:d instanceof tc?d:null,thicknessScene:s,transparency:o.transparency,intensityScale:a,innerScene:r,outerScene:i,planetShadow:null,planetShadowOnRing:f}}function iA(e){e.mesh.geometry.dispose();let t=e.material.uniforms;for(let e of[`uBackscattered`,`uForwardscattered`,`uUnlitside`,`uTransparency`,`uColor`,`uThickness`])(t[e]?.value)?.dispose();e.mesh.material.dispose()}var aA=null;function oA(){return aA||(aA=new Us(new Uint8Array([255,255,255,255]),1,1),aA.needsUpdate=!0),aA}function sA(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 Us(t,e.length,1,Yn,Bn);return n.needsUpdate=!0,n}function cA(e,t,n){if(t===n)return;let r=e.uniforms;r.uMieProfileTex.value!==aA&&r.uMieProfileTex.value.dispose(),r.uMieProfileTex.value=n?sA(n):oA(),r.uMieProfileOn.value=+!!n,r.uMieProfileN.value=n?.length??1}function lA(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 Us(t,128,1,Yn,Bn);return n.needsUpdate=!0,n}var uA=new WeakMap;function dA(e){let t=uA.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 Us(r,n,3,Yn,Bn),t.needsUpdate=!0,uA.set(e,t),t}function fA(e,t,n){if(t===n)return;let r=e.uniforms;r.uDeepTex.value=n?dA(n):oA(),r.uDeepN.value=n?.n??1}function pA(e,t){return t+(e.referenceAltitudeKm??0)}var mA=`
4749
+ reflectedLight.directSpecular *= ringShadow;`)},MC(e,`ringShadow`),e.needsUpdate=!0,a.ringShadow=c,c}async function aA(e,t,n){let r=Q(t.inner_radius_km),i=Q(t.outer_radius_km),a=t.intensity_scale??1,o;try{o=await Qk(Kt(`/v1/rings/${e}/${t.strip}`,`rings`),t.strip_rows,n)}catch(t){return console.warn(`Failed to load ring strip for ${e}:`,t),null}let s=t.thickness_scale_km&&o.thickness?Q(t.thickness_scale_km):0,c=s>0?48:1,l=new du({uniforms:{uBackscattered:{value:o.backscattered},uForwardscattered:{value:o.forwardscattered},uUnlitside:{value:o.unlitside},uTransparency:{value:o.transparency},uColor:{value:o.color},uThickness:{value:o.thickness??o.transparency},uThicknessScene:{value:s},uLayerCount:{value:1},uLayerAlphaExp:{value:1},uInnerScene:{value:r},uOuterScene:{value:i},uSunDir:{value:new J(1,0,0)},uSunAngularRadius:{value:0},uPlanetCenter:{value:new J},uPlanetPoleDir:{value:new J(0,1,0)},uPlanetEquatorialScene:{value:0},uPlanetPolarScene:{value:0},uLightScale:{value:1},uIntensityScale:{value:a}},vertexShader:tA,fragmentShader:nA,transparent:!0,depthWrite:!1,blending:1,side:2}),u=new $l(r,i*(1/Math.cos(Math.PI/Xk)),Xk,c>1?Zk:1);u.rotateX(-Math.PI/2);let d;if(c>1){u.setAttribute(`aLayerIndex`,new qs(Float32Array.from({length:c},(e,t)=>t),1));let e=new tc(u,l,c);e.count=1,d=e}else d=new ks(u,l);d.frustumCulled=!1,d.renderOrder=3,d.userData.isRingMesh=!0;let f={uPlanetCenter:l.uniforms.uPlanetCenter,uPlanetPoleDir:l.uniforms.uPlanetPoleDir,uPlanetEquatorialScene:l.uniforms.uPlanetEquatorialScene,uPlanetPolarScene:l.uniforms.uPlanetPolarScene};return{mesh:d,material:l,layers:d instanceof tc?d:null,thicknessScene:s,transparency:o.transparency,intensityScale:a,innerScene:r,outerScene:i,planetShadow:null,planetShadowOnRing:f}}function oA(e){e.mesh.geometry.dispose();let t=e.material.uniforms;for(let e of[`uBackscattered`,`uForwardscattered`,`uUnlitside`,`uTransparency`,`uColor`,`uThickness`])(t[e]?.value)?.dispose();e.mesh.material.dispose()}var sA=null;function cA(){return sA||(sA=new Us(new Uint8Array([255,255,255,255]),1,1),sA.needsUpdate=!0),sA}function lA(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 Us(t,e.length,1,Yn,Bn);return n.needsUpdate=!0,n}function uA(e,t,n){if(t===n)return;let r=e.uniforms;r.uMieProfileTex.value!==sA&&r.uMieProfileTex.value.dispose(),r.uMieProfileTex.value=n?lA(n):cA(),r.uMieProfileOn.value=+!!n,r.uMieProfileN.value=n?.length??1}function dA(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 Us(t,128,1,Yn,Bn);return n.needsUpdate=!0,n}var fA=new WeakMap;function pA(e){let t=fA.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 Us(r,n,3,Yn,Bn),t.needsUpdate=!0,fA.set(e,t),t}function mA(e,t,n){if(t===n)return;let r=e.uniforms;r.uDeepTex.value=n?pA(n):cA(),r.uDeepN.value=n?.n??1}function hA(e,t){return t+(e.referenceAltitudeKm??0)}var gA=`
4750
4750
  #include <common>
4751
4751
  #include <logdepthbuf_pars_vertex>
4752
4752
 
@@ -4763,7 +4763,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
4763
4763
  gl_Position = projectionMatrix * viewMatrix * worldPos;
4764
4764
  #include <logdepthbuf_vertex>
4765
4765
  }
4766
- `,hA=`
4766
+ `,_A=`
4767
4767
  #include <common>
4768
4768
  #include <logdepthbuf_pars_fragment>
4769
4769
 
@@ -4830,11 +4830,11 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
4830
4830
  varying vec3 vWorldPos;
4831
4831
  varying vec3 vPlanetCenter;
4832
4832
 
4833
- ${PC}
4833
+ ${FC}
4834
4834
 
4835
4835
  // Ring shadow on the air column: the same uniforms the planet surface
4836
4836
  // marches, shared by value-ref once rings load.
4837
- ${tA}
4837
+ ${rA}
4838
4838
 
4839
4839
  // PRIMARY_STEPS / LIGHT_STEPS and the ATMO_ECLIPSE / ATMO_RING_SHADOW /
4840
4840
  // ATMO_INSIDE feature flags come from material.defines — quality tiers
@@ -5244,7 +5244,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5244
5244
  gl_FragColor = vec4(color, alpha);
5245
5245
  #include <logdepthbuf_fragment>
5246
5246
  }
5247
- `;function gA(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 _A(e,t,n){let r=pA(e,n),i=t*r/n,a=e.sunColor,o=FC(),s=Ik(),c=new du({defines:CA(s),uniforms:{uSunAngularRadius:o.uSunAngularRadius,uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new oa)},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:oA()},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:lA(e.miePhase)},uMieProfileTex:{value:e.mieProfile?sA(e.mieProfile):oA()},uMieProfileOn:{value:+!!e.mieProfile},uMieProfileN:{value:e.mieProfile?.length??1},uDeepTex:{value:e.deepColumn?dA(e.deepColumn):oA()},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:oA()},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:mA,fragmentShader:hA,transparent:!0,depthWrite:!0,blending:5,blendSrc:201,blendDst:205,side:0});gA(c,e,i,r);let l=i*(1+e.topAltitudeKm/r),u=new ks(new nu(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:Lk(s)}}function vA(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 yA=2;function bA(e){return(e.deepColumn?.topKm??0)-(e.referenceAltitudeKm??0)}function xA(e,t){return!!e.deepColumn&&t<bA(e)}function SA(e,t){if(!e.deepColumn)return 0;let n=yA*e.mieScaleHeightKm,r=Math.min(1,Math.max(0,(t-bA(e))/n));return 1-r*r*(3-2*r)}function CA(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 wA(e,t){let n=Lk(t);n!==e.qualityKey&&(e.qualityKey=n,e.material.defines=CA(t),e.material.needsUpdate=!0)}function TA(e,t){cA(e.material,e.params.mieProfile,t.mieProfile),fA(e.material,e.params.deepColumn,t.deepColumn),e.params=t;let n=e.material.uniforms;n.uGroundAlbedo.value=t.groundAlbedo??0,e.planetRadiusKm=pA(t,e.surfaceRadiusKm);let r=e.surfaceRadiusScene*e.planetRadiusKm/e.surfaceRadiusKm;gA(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 EA(e,t,n,r){e.surfaceRadiusKm=t,e.surfaceRadiusScene=r,e.planetRadiusKm=pA(e.params,t);let i=r*e.planetRadiusKm/t;gA(e.material,e.params,i,e.planetRadiusKm),e.material.uniforms.uStretch.value=e.planetRadiusKm/pA(e.params,n);let a=i*(1+e.params.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function DA(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 OA(e){e.mesh.geometry.dispose(),e.material.uniforms.uMiePhaseTex.value.dispose();let t=e.material.uniforms.uMieProfileTex.value;t!==aA&&t.dispose(),e.mesh.material.dispose()}var kA=6,AA=16,jA={uAtmoTEnable:{value:1}};function MA(e){jA.uAtmoTEnable.value=+!!e}var NA=`
5247
+ `;function vA(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 yA(e,t,n){let r=hA(e,n),i=t*r/n,a=e.sunColor,o=IC(),s=Rk(),c=new du({defines:TA(s),uniforms:{uSunAngularRadius:o.uSunAngularRadius,uOccluderCount:{value:0},uOccluders:{value:Array.from({length:32},()=>new oa)},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:cA()},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:dA(e.miePhase)},uMieProfileTex:{value:e.mieProfile?lA(e.mieProfile):cA()},uMieProfileOn:{value:+!!e.mieProfile},uMieProfileN:{value:e.mieProfile?.length??1},uDeepTex:{value:e.deepColumn?pA(e.deepColumn):cA()},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:cA()},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:gA,fragmentShader:_A,transparent:!0,depthWrite:!0,blending:5,blendSrc:201,blendDst:205,side:0});vA(c,e,i,r);let l=i*(1+e.topAltitudeKm/r),u=new ks(new nu(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:zk(s)}}function bA(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 xA=2;function SA(e){return(e.deepColumn?.topKm??0)-(e.referenceAltitudeKm??0)}function CA(e,t){return!!e.deepColumn&&t<SA(e)}function wA(e,t){if(!e.deepColumn)return 0;let n=xA*e.mieScaleHeightKm,r=Math.min(1,Math.max(0,(t-SA(e))/n));return 1-r*r*(3-2*r)}function TA(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 EA(e,t){let n=zk(t);n!==e.qualityKey&&(e.qualityKey=n,e.material.defines=TA(t),e.material.needsUpdate=!0)}function DA(e,t){uA(e.material,e.params.mieProfile,t.mieProfile),mA(e.material,e.params.deepColumn,t.deepColumn),e.params=t;let n=e.material.uniforms;n.uGroundAlbedo.value=t.groundAlbedo??0,e.planetRadiusKm=hA(t,e.surfaceRadiusKm);let r=e.surfaceRadiusScene*e.planetRadiusKm/e.surfaceRadiusKm;vA(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 OA(e,t,n,r){e.surfaceRadiusKm=t,e.surfaceRadiusScene=r,e.planetRadiusKm=hA(e.params,t);let i=r*e.planetRadiusKm/t;vA(e.material,e.params,i,e.planetRadiusKm),e.material.uniforms.uStretch.value=e.planetRadiusKm/hA(e.params,n);let a=i*(1+e.params.topAltitudeKm/e.planetRadiusKm);e.mesh.scale.setScalar(a/e.geometryRadiusScene)}function kA(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 AA(e){e.mesh.geometry.dispose(),e.material.uniforms.uMiePhaseTex.value.dispose();let t=e.material.uniforms.uMieProfileTex.value;t!==sA&&t.dispose(),e.mesh.material.dispose()}var jA=6,MA=16,NA={uAtmoTEnable:{value:1}};function PA(e){NA.uAtmoTEnable.value=+!!e}var FA=`
5248
5248
  uniform vec3 uAtmoTBetaR; // Rayleigh β, per planet radius, (R,G,B)
5249
5249
  uniform vec3 uAtmoTBetaMExt; // Mie extinction β, per planet radius
5250
5250
  uniform vec3 uAtmoTBetaA; // absorber band β, per planet radius
@@ -5294,11 +5294,11 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5294
5294
  vec3 atmoTSquash(vec3 v) {
5295
5295
  return v + (uAtmoTStretch - 1.0) * dot(v, uAtmoTSpinAxis) * uAtmoTSpinAxis;
5296
5296
  }
5297
- `,PA=`
5297
+ `,IA=`
5298
5298
  // Eclipse's uSunDir/uEclipseSelfPos are declared after this chunk's
5299
5299
  // insertion point — same value refs re-bound under own names.
5300
5300
  uniform vec3 uAtmoTSunDir;
5301
- ${NA}
5301
+ ${FA}
5302
5302
 
5303
5303
  // Column (∫density above h) of the linear-tent absorber, in radii of
5304
5304
  // surface-density-equivalent path — mirrors tentColumnAboveKm.
@@ -5348,9 +5348,9 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5348
5348
  float tFar = -b + sqrt(d);
5349
5349
  if (tFar <= 0.0) return vec3(1.0);
5350
5350
  // Fragment sits inside the shell → the segment starts at the fragment.
5351
- float dt = tFar / ${kA.toFixed(1)};
5351
+ float dt = tFar / ${jA.toFixed(1)};
5352
5352
  vec3 od = vec3(0.0);
5353
- for (int i = 0; i < ${kA}; i++) {
5353
+ for (int i = 0; i < ${jA}; i++) {
5354
5354
  float h = max(length(p + sd * (dt * (float(i) + 0.5))) - 1.0, 0.0);
5355
5355
  od += vec3(
5356
5356
  exp(-h / uAtmoTRayleighH),
@@ -5390,8 +5390,8 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5390
5390
  float w = 0.5 + 0.5 * dot(worldNormal, up);
5391
5391
  return mix(down * atmoTDeepTap(1.0, zf), down, w) * uAtmoTDeepBlend;
5392
5392
  }
5393
- `,FA=`
5394
- ${NA}
5393
+ `,LA=`
5394
+ ${FA}
5395
5395
 
5396
5396
  vec3 atmoViewTint(vec3 worldPos) {
5397
5397
  if (uAtmoTEnable < 0.5) return vec3(1.0);
@@ -5409,9 +5409,9 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5409
5409
  float t1 = -b + s;
5410
5410
  if (t1 <= 0.0) return vec3(1.0);
5411
5411
  float t0 = max(-b - s, 0.0);
5412
- float dt = (t1 - t0) / ${kA.toFixed(1)};
5412
+ float dt = (t1 - t0) / ${jA.toFixed(1)};
5413
5413
  vec3 od = vec3(0.0);
5414
- for (int i = 0; i < ${kA}; i++) {
5414
+ for (int i = 0; i < ${jA}; i++) {
5415
5415
  float h = max(length(p + rd * (t0 + dt * (float(i) + 0.5))) - 1.0, 0.0);
5416
5416
  od += vec3(
5417
5417
  exp(-h / uAtmoTRayleighH),
@@ -5424,13 +5424,13 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5424
5424
  float lum = dot(t, vec3(0.2126, 0.7152, 0.0722));
5425
5425
  return t / max(lum, 1e-4);
5426
5426
  }
5427
- `;function IA(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:RA()},uAtmoTDeepN:{value:1},uAtmoTDeepBaseR:{value:1},uAtmoTDeepSpanR:{value:0},uAtmoTDeepKmPerRadius:{value:1},uAtmoTDeepIrradiance:{value:0},uAtmoTDeepBlend:{value:0}}}var LA=null;function RA(){return LA||(LA=new Us(new Uint8Array([255,255,255,255]),1,1),LA.needsUpdate=!0),LA}function zA(e,t,n,r){let i=r;r=pA(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?dA(u):RA(),e.uAtmoTDeepN.value=u?.n??1,e.uAtmoTDeepBaseR.value=i/r,e.uAtmoTDeepSpanR.value=u?u.topKm/r:0,e.uAtmoTDeepKmPerRadius.value=r}function BA(){return{...IA({value:0}),uAtmoTCenter:{value:new J}}}function VA(e,t,n,r,i,a,o=1){zA(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 HA(e,t,n,r,i,a,o=1){let s={...IA(jA.uAtmoTEnable),uAtmoTSunDir:FC().uSunDir,uAtmoTCenter:i.uEclipseSelfPos};return s.uAtmoTMeshR.value=o*r/pA(t,r),a&&(s.uAtmoTSpinAxis=a.material.uniforms.uSpinAxis,s.uAtmoTStretch=a.material.uniforms.uStretch),zA(s,t,n,r),MC(e,`sunTint`,e=>{Object.assign(e.uniforms,s),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${PA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
5427
+ `;function RA(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:BA()},uAtmoTDeepN:{value:1},uAtmoTDeepBaseR:{value:1},uAtmoTDeepSpanR:{value:0},uAtmoTDeepKmPerRadius:{value:1},uAtmoTDeepIrradiance:{value:0},uAtmoTDeepBlend:{value:0}}}var zA=null;function BA(){return zA||(zA=new Us(new Uint8Array([255,255,255,255]),1,1),zA.needsUpdate=!0),zA}function VA(e,t,n,r){let i=r;r=hA(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?pA(u):BA(),e.uAtmoTDeepN.value=u?.n??1,e.uAtmoTDeepBaseR.value=i/r,e.uAtmoTDeepSpanR.value=u?u.topKm/r:0,e.uAtmoTDeepKmPerRadius.value=r}function HA(){return{...RA({value:0}),uAtmoTCenter:{value:new J}}}function UA(e,t,n,r,i,a,o=1){VA(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 WA(e,t,n,r,i,a,o=1){let s={...RA(NA.uAtmoTEnable),uAtmoTSunDir:IC().uSunDir,uAtmoTCenter:i.uEclipseSelfPos};return s.uAtmoTMeshR.value=o*r/hA(t,r),a&&(s.uAtmoTSpinAxis=a.material.uniforms.uSpinAxis,s.uAtmoTStretch=a.material.uniforms.uStretch),VA(s,t,n,r),NC(e,`sunTint`,e=>{Object.assign(e.uniforms,s),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${IA}`).replace(`#include <lights_fragment_end>`,`#include <lights_fragment_end>
5428
5428
  vec3 atmoTint = atmoSunTint(vEclipseWorldPos);
5429
5429
  reflectedLight.directDiffuse *= atmoTint;
5430
5430
  reflectedLight.directSpecular *= atmoTint;
5431
5431
  reflectedLight.indirectDiffuse +=
5432
5432
  atmoDeepSkyLight(vEclipseWorldPos, inverseTransformDirection(normal, viewMatrix)) *
5433
- BRDF_Lambert(diffuseColor.rgb);`)}),s}var UA=new J,WA=new J;function GA(e,t,n){return!t||n===1?e:e.addScaledVector(t,(n-1)*e.dot(t))}function KA(e,t,n,r,i,a,o,s=1){let c=i;i=pA(e,c),r=r*i/c;let l=GA(UA.copy(t).divideScalar(r),o,s),u=GA(WA.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)/AA,x=b*i/d,S=0,C=0,w=0;for(let t=0;t<AA;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 qA=6*.8/.3;function JA(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,XA(e,1)),a.addColorStop(.15,XA(e,1)),a.addColorStop(.4,XA(e,.3)),a.addColorStop(1,XA(e,0)),r.fillStyle=a,r.fillRect(0,0,t,t),new Mc(n)}function YA(e){return`rgb(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)})`}function XA(e,t){return e.replace(`)`,`, ${t})`).replace(`rgb(`,`rgba(`)}var ZA=`#fff5eb`,QA=`#ffd9a8`;function $A(){let e=new X(ZA),t=new X(QA);return new du({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)},...BA()},vertexShader:`
5433
+ BRDF_Lambert(diffuseColor.rgb);`)}),s}var GA=new J,KA=new J;function qA(e,t,n){return!t||n===1?e:e.addScaledVector(t,(n-1)*e.dot(t))}function JA(e,t,n,r,i,a,o,s=1){let c=i;i=hA(e,c),r=r*i/c;let l=qA(GA.copy(t).divideScalar(r),o,s),u=qA(KA.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)/MA,x=b*i/d,S=0,C=0,w=0;for(let t=0;t<MA;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 YA=6*.8/.3;function XA(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,QA(e,1)),a.addColorStop(.15,QA(e,1)),a.addColorStop(.4,QA(e,.3)),a.addColorStop(1,QA(e,0)),r.fillStyle=a,r.fillRect(0,0,t,t),new Mc(n)}function ZA(e){return`rgb(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)})`}function QA(e,t){return e.replace(`)`,`, ${t})`).replace(`rgb(`,`rgba(`)}var $A=`#fff5eb`,ej=`#ffd9a8`;function tj(){let e=new X($A),t=new X(ej);return new du({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)},...HA()},vertexShader:`
5434
5434
  #include <common>
5435
5435
  #include <logdepthbuf_pars_vertex>
5436
5436
  varying vec3 vNormalView;
@@ -5453,7 +5453,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5453
5453
  varying vec3 vNormalView;
5454
5454
  varying vec3 vViewDir;
5455
5455
  varying vec3 vWorldPos;
5456
- ${FA}
5456
+ ${LA}
5457
5457
  void main() {
5458
5458
  #include <logdepthbuf_fragment>
5459
5459
  float mu = max(dot(normalize(vNormalView), normalize(vViewDir)), 0.0);
@@ -5468,7 +5468,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5468
5468
  vec3 hdr = tint * darkening * ${6 .toFixed(1)};
5469
5469
  gl_FragColor = vec4(atmoViewTint(vWorldPos) * hdr, 1.0);
5470
5470
  }
5471
- `})}function ej(e,t){let n=new ss(new qo({map:JA(t.startsWith(`#`)?YA(t):t),blending:2,transparent:!0,opacity:.6,depthWrite:!1,depthTest:!0})),r=e*6;return n.scale.set(r,r,1),n}function tj(e,t){let n=new Vo;n.setAttribute(`position`,new ko(new Float32Array(3),3));let r=new X(e),i=new kc(n,new du({uniforms:{uColor:{value:new J(r.r,r.g,r.b)},uIntensity:{value:qA},uTint:{value:new J(1,1,1)},uMap:{value:t}},vertexShader:`
5471
+ `})}function nj(e,t){let n=new ss(new qo({map:XA(t.startsWith(`#`)?ZA(t):t),blending:2,transparent:!0,opacity:.6,depthWrite:!1,depthTest:!0})),r=e*6;return n.scale.set(r,r,1),n}function rj(e,t){let n=new Vo;n.setAttribute(`position`,new ko(new Float32Array(3),3));let r=new X(e),i=new kc(n,new du({uniforms:{uColor:{value:new J(r.r,r.g,r.b)},uIntensity:{value:YA},uTint:{value:new J(1,1,1)},uMap:{value:t}},vertexShader:`
5472
5472
  #include <common>
5473
5473
  #include <logdepthbuf_pars_vertex>
5474
5474
  void main() {
@@ -5489,7 +5489,7 @@ vRingShadowWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;`),e.fragmentShade
5489
5489
  if (texel.a < 0.01) discard;
5490
5490
  gl_FragColor = vec4(uTint * uColor * uIntensity, texel.a);
5491
5491
  }
5492
- `,transparent:!0,depthTest:!0,depthWrite:!1}));return i.frustumCulled=!1,i}function nj(e,t,n,r){let i=new ud(16777215,hT,0,0);e.add(i);let a=ej(t,n);e.add(a);let o=tj(n,r);return e.add(o),{light:i,corona:a,starPoint:o}}function rj(e,t,n){e&&e.material.color.setRGB(n.x,n.y,n.z),t&&t.material.uniforms.uTint.value.copy(n)}function ij(e){let t=e?.uniforms;return t?.uAtmoTEnable?t:null}function aj(e,t){let n=e?.uniforms;t&&n?.uLimbAlpha&&n.uLimbAlpha.value.set(t[0],t[1],t[2])}function oj(e){if(Array.isArray(e))for(let t of e)t.dispose();else e.dispose()}var sj=96,cj=24;function lj(e,t,n,r,a,o,s,c,l,u){for(let d of e){let e=d.data.id,f=u?.has(e)??!1,p=d.data.objectType,m=f||p===G.BARYCENTER||p===G.LAGRANGE_POINT||p===G.COMET||hn(p)||d.data.orbitalSource===tn.SPICE_PROBE,h=m_(d.data),g=Q(mn(d.data)),_=p===G.STAR,v=GD(d),y=Number.isFinite(d.data.radiusKm)&&d.data.radiusKm>0,b=!v&&_n(p)&&!y?`radius`:void 0,x=new Ra;x.position.set(0,0,0);let S=null,C=null,w=null,T=null,E,D=[];if(!m&&!b){_&&(C=nj(t,g,h,o),D.push(C.light,C.corona,C.starPoint));let i=_?sj:cj,a=new nu(g,i,i),s=_?$A():new pu({color:g_(d.data)});S=new ks(a,s),v&&(S.visible=!1),_||(w=zC(s)),t.add(S),D.push(S),n.push(S),r.set(S,d);let c=_?void 0:hb(e);c&&(T=_A(c,g,mn(d.data)),t.add(T.mesh),D.push(T.mesh),w&&(E=[HA(s,c,g,mn(d.data),w,T)]))}let O=Ok(d),k=_||p===G.PLANET,A=f||p_.has(e)||d.data.isMinor===!0,j=kk(h,d.data.name??``,O,i().bodyHref(e,d.data.name??``),()=>c(d),k,l?t=>l(e,t):void 0,A);j&&(jk(j.element,s),x.add(j)),t.add(x);let M=j?j.element.firstElementChild:null;M&&(M.dataset.origBorder=M.style.border),a.set(e,{body:d,group:x,mesh:S,label:j,labelHalo:M,labelStack:null,loadingEl:null,extraObjects:D,corona:C?.corona??null,starPoint:C?.starPoint??null,trail:null,radiusScene:g,cachedDist:0,currentSegments:m||b?void 0:_?sj:cj,isMinor:A,noPhysical:b,rings:[],clouds:null,atmosphere:T,sunTint:E,specularMap:null,emissiveMap:null,displacementMap:null,selfShadow:null,eclipseShadow:w,nomenclatureLabels:null,model:null})}}function uj(e){let t=e.data.objectType;return t===G.COMET||hn(t)||e.data.orbitalSource===tn.SPICE_PROBE}function dj(e,t,n,r){if(e.mesh!==null)return;let{body:i,radiusScene:a}=e;e.focusUpgraded=!0;let o=GD(i);if(!o&&!(Number.isFinite(i.data.radiusKm)&&i.data.radiusKm>0)){e.noPhysical=`radius`;return}let s=g_(i.data),c=cj,l=new nu(a,c,c),u=new pu({color:s}),d=new ks(l,u);o&&(d.visible=!1),t.add(d),e.mesh=d,e.extraObjects.push(d),n.push(d),r.set(d,i),e.eclipseShadow=zC(u),e.currentSegments=c;let f=hb(i.data.id);f&&(e.atmosphere=_A(f,a,mn(i.data)),t.add(e.atmosphere.mesh),e.extraObjects.push(e.atmosphere.mesh),e.sunTint=[HA(u,f,a,mn(i.data),e.eclipseShadow,e.atmosphere)])}function fj(e,t,n,r){e.focusUpgraded=!1,iO(e);let i=e.mesh;if(i){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementTier=void 0,XC(e.selfShadow),e.selfShadow=null),e.terrainWindow=null,t.remove(i),i.geometry.dispose(),oj(i.material);let a=n.indexOf(i);a>=0&&n.splice(a,1),r.delete(i);let o=e.extraObjects.indexOf(i);o>=0&&e.extraObjects.splice(o,1),e.mesh=null,e.currentSegments=void 0,e.eclipseShadow=null,e.sunTint=void 0,e.radiiApplied=!1,e.semiAxesScene=void 0}if(e.atmosphere){let n=e.atmosphere.mesh;t.remove(n);let r=e.extraObjects.indexOf(n);r>=0&&e.extraObjects.splice(r,1),n.geometry.dispose(),oj(n.material),e.atmosphere=null}let a=e.body.data.orbitalSource===tn.SPICE_PROBE;e.trail&&!a&&(t.remove(e.trail),e.trail.geometry.dispose(),oj(e.trail.material),e.trail=null)}var pj=class{#e;#t=new J;#n=new q;#r=new WeakMap;#i=[];constructor(e,t){this.#e=mj(e,t)}setSize(e,t){this.#e.dispose(),this.#e.depthTexture?.dispose(),this.#e=mj(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=+!!tT(),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 gu,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 mj(e,t){let n=new ca(e,t);return n.depthTexture=new Nc(e,t,Bn),n}function hj(e,t,n,r,i,a,o,s){if(!n.length||i.rings.length)return[];let c=n.reduce((e,t)=>t.intensity_scale>e.intensity_scale?t:e),l=[];for(let u of n){if(s)for(let n of u.sources)s.credits.registerImagery(`rings`,e,t,{...n,description:u.description});l.push(rA(e,u,o).then(e=>{if(e){if(i.rings.some(e=>e.mesh.userData.ringBundle===u.bundle)){e.mesh.geometry.dispose(),e.mesh.material.dispose();return}e.mesh.userData.ringBundle=u.bundle,i.rings.push(e),a.add(e.mesh),i.extraObjects.push(e.mesh),i.mesh&&u===c&&(e.planetShadow=nA(i.mesh.material,e.innerScene,e.outerScene,e.transparency,e.intensityScale),i.atmosphere&&DA(i.atmosphere,e.planetShadow,e.transparency,e.innerScene,e.outerScene)),r&&(e.planetShadowOnRing.uPlanetEquatorialScene.value=Q((r.a+r.b)/2),e.planetShadowOnRing.uPlanetPolarScene.value=Q(r.c))}}))}return l}var gj=1.002,_j=1e3;function vj(e,t,n){return Kt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function yj(e,t,n){try{let r=await fetch(vj(e,t,n));if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=new aa(await createImageBitmap(i,{imageOrientation:`flipY`}));return a.flipY=!1,a.colorSpace=Jr,a.needsUpdate=!0,a}catch(r){return console.warn(`Failed to load ${t} cloud texture for ${e} @ ${n}:`,r),null}}function bj(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 xj=10800*1e3;function Sj(e,t,n){return n?n.some(([t,n])=>e>=bj(t)&&e<bj(n)+xj):e>=bj(t[0])&&e<=bj(t[t.length-1])}function Cj(e,t,n){if(t.length===0)return;let r=Ng(e).getTime(),i=bj(t[0]);if(Sj(r,t,n)){let e=0,n=t.length;for(;e<n;){let i=e+n>>>1;bj(t[i])<=r?e=i+1:n=i}return t[Math.max(0,e-1)]}let a=Ng(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 wj(e,t,n,r,i=gj){let a=await yj(n.id,`low`,r);if(!a)return null;let o=Tj(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 Tj(e,t,n,r=gj){let i=new pu({map:n,transparent:!0,depthWrite:!1}),a=new ks(new nu(t,64,64),i);return a.scale.setScalar(r),a.renderOrder=1,e.add(a),{mesh:a,material:i,id:``,availableTiers:[],availableFrames:[]}}async function Ej(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<_j)){e.lastSwapMs=r,e.textureLoading=!0;try{let r=await yj(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 Dj(e){e.mesh.geometry.dispose(),e.material.map?.dispose(),e.material.dispose(),e.mesh.parent?.remove(e.mesh)}var Oj=.2,kj=-.125,Aj=.1,jj=Symbol(`night-lights-hook`);async function Mj(e,t,n,r){let i=Kt(`/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=Jr,Nj(e,a),a}function Nj(e,t){e.emissiveMap=t,e.emissive=new X(16777215);let n=e;if(!n[jj]){n[jj]=!0;let t=FC();MC(e,`nightLights`,e=>{e.uniforms.uSunDir=t.uSunDir,e.uniforms.uNightIntensity={value:Oj},e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5492
+ `,transparent:!0,depthTest:!0,depthWrite:!1}));return i.frustumCulled=!1,i}function ij(e,t,n,r){let i=new ud(16777215,gT,0,0);e.add(i);let a=nj(t,n);e.add(a);let o=rj(n,r);return e.add(o),{light:i,corona:a,starPoint:o}}function aj(e,t,n){e&&e.material.color.setRGB(n.x,n.y,n.z),t&&t.material.uniforms.uTint.value.copy(n)}function oj(e){let t=e?.uniforms;return t?.uAtmoTEnable?t:null}function sj(e,t){let n=e?.uniforms;t&&n?.uLimbAlpha&&n.uLimbAlpha.value.set(t[0],t[1],t[2])}function cj(e){if(Array.isArray(e))for(let t of e)t.dispose();else e.dispose()}var lj=96,uj=24;function dj(e,t,n,r,a,o,s,c,l,u){for(let d of e){let e=d.data.id,f=u?.has(e)??!1,p=d.data.objectType,m=f||p===G.BARYCENTER||p===G.LAGRANGE_POINT||p===G.COMET||hn(p)||d.data.orbitalSource===tn.SPICE_PROBE,h=m_(d.data),g=Q(mn(d.data)),_=p===G.STAR,v=KD(d),y=Number.isFinite(d.data.radiusKm)&&d.data.radiusKm>0,b=!v&&_n(p)&&!y?`radius`:void 0,x=new Ra;x.position.set(0,0,0);let S=null,C=null,w=null,T=null,E,D=[];if(!m&&!b){_&&(C=ij(t,g,h,o),D.push(C.light,C.corona,C.starPoint));let i=_?lj:uj,a=new nu(g,i,i),s=_?tj():new pu({color:g_(d.data)});S=new ks(a,s),v&&(S.visible=!1),_||(w=BC(s)),t.add(S),D.push(S),n.push(S),r.set(S,d);let c=_?void 0:gb(e);c&&(T=yA(c,g,mn(d.data)),t.add(T.mesh),D.push(T.mesh),w&&(E=[WA(s,c,g,mn(d.data),w,T)]))}let O=Ak(d),k=_||p===G.PLANET,A=f||p_.has(e)||d.data.isMinor===!0,j=jk(h,d.data.name??``,O,i().bodyHref(e,d.data.name??``),()=>c(d),k,l?t=>l(e,t):void 0,A);j&&(Nk(j.element,s),x.add(j)),t.add(x);let M=j?j.element.firstElementChild:null;M&&(M.dataset.origBorder=M.style.border),a.set(e,{body:d,group:x,mesh:S,label:j,labelHalo:M,labelStack:null,loadingEl:null,extraObjects:D,corona:C?.corona??null,starPoint:C?.starPoint??null,trail:null,radiusScene:g,cachedDist:0,currentSegments:m||b?void 0:_?lj:uj,isMinor:A,noPhysical:b,rings:[],clouds:null,atmosphere:T,sunTint:E,specularMap:null,emissiveMap:null,displacementMap:null,selfShadow:null,eclipseShadow:w,nomenclatureLabels:null,model:null})}}function fj(e){let t=e.data.objectType;return t===G.COMET||hn(t)||e.data.orbitalSource===tn.SPICE_PROBE}function pj(e,t,n,r){if(e.mesh!==null)return;let{body:i,radiusScene:a}=e;e.focusUpgraded=!0;let o=KD(i);if(!o&&!(Number.isFinite(i.data.radiusKm)&&i.data.radiusKm>0)){e.noPhysical=`radius`;return}let s=g_(i.data),c=uj,l=new nu(a,c,c),u=new pu({color:s}),d=new ks(l,u);o&&(d.visible=!1),t.add(d),e.mesh=d,e.extraObjects.push(d),n.push(d),r.set(d,i),e.eclipseShadow=BC(u),e.currentSegments=c;let f=gb(i.data.id);f&&(e.atmosphere=yA(f,a,mn(i.data)),t.add(e.atmosphere.mesh),e.extraObjects.push(e.atmosphere.mesh),e.sunTint=[WA(u,f,a,mn(i.data),e.eclipseShadow,e.atmosphere)])}function mj(e,t,n,r){e.focusUpgraded=!1,aO(e);let i=e.mesh;if(i){e.displacementMap&&(e.displacementMap.dispose(),e.displacementMap=null,e.displacementTier=void 0,ZC(e.selfShadow),e.selfShadow=null),e.terrainWindow=null,t.remove(i),i.geometry.dispose(),cj(i.material);let a=n.indexOf(i);a>=0&&n.splice(a,1),r.delete(i);let o=e.extraObjects.indexOf(i);o>=0&&e.extraObjects.splice(o,1),e.mesh=null,e.currentSegments=void 0,e.eclipseShadow=null,e.sunTint=void 0,e.radiiApplied=!1,e.semiAxesScene=void 0}if(e.atmosphere){let n=e.atmosphere.mesh;t.remove(n);let r=e.extraObjects.indexOf(n);r>=0&&e.extraObjects.splice(r,1),n.geometry.dispose(),cj(n.material),e.atmosphere=null}let a=e.body.data.orbitalSource===tn.SPICE_PROBE;e.trail&&!a&&(t.remove(e.trail),e.trail.geometry.dispose(),cj(e.trail.material),e.trail=null)}var hj=class{#e;#t=new J;#n=new q;#r=new WeakMap;#i=[];constructor(e,t){this.#e=gj(e,t)}setSize(e,t){this.#e.dispose(),this.#e.depthTexture?.dispose(),this.#e=gj(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=+!!nT(),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 gu,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 gj(e,t){let n=new ca(e,t);return n.depthTexture=new Nc(e,t,Bn),n}function _j(e,t,n,r,i,a,o,s){if(!n.length||i.rings.length)return[];let c=n.reduce((e,t)=>t.intensity_scale>e.intensity_scale?t:e),l=[];for(let u of n){if(s)for(let n of u.sources)s.credits.registerImagery(`rings`,e,t,{...n,description:u.description});l.push(aA(e,u,o).then(e=>{if(!e)return;if(i.rings.some(e=>e.mesh.userData.ringBundle===u.bundle)){e.mesh.geometry.dispose(),e.mesh.material.dispose();return}e.mesh.userData.ringBundle=u.bundle;let t=i.mesh??i.model;t&&e.mesh.quaternion.copy(t.quaternion),i.rings.push(e),a.add(e.mesh),i.extraObjects.push(e.mesh),i.mesh&&u===c&&(e.planetShadow=iA(i.mesh.material,e.innerScene,e.outerScene,e.transparency,e.intensityScale),i.atmosphere&&kA(i.atmosphere,e.planetShadow,e.transparency,e.innerScene,e.outerScene)),r&&(e.planetShadowOnRing.uPlanetEquatorialScene.value=Q((r.a+r.b)/2),e.planetShadowOnRing.uPlanetPolarScene.value=Q(r.c))}))}return l}var vj=1.002,yj=1e3;function bj(e,t,n){return Kt(`/v1/textures/${e}/${t}_${n}.webp`,`textures`)}async function xj(e,t,n){try{let r=await fetch(bj(e,t,n));if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=new aa(await createImageBitmap(i,{imageOrientation:`flipY`}));return a.flipY=!1,a.colorSpace=Jr,a.needsUpdate=!0,a}catch(r){return console.warn(`Failed to load ${t} cloud texture for ${e} @ ${n}:`,r),null}}function Sj(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 Cj=10800*1e3;function wj(e,t,n){return n?n.some(([t,n])=>e>=Sj(t)&&e<Sj(n)+Cj):e>=Sj(t[0])&&e<=Sj(t[t.length-1])}function Tj(e,t,n){if(t.length===0)return;let r=Ng(e).getTime(),i=Sj(t[0]);if(wj(r,t,n)){let e=0,n=t.length;for(;e<n;){let i=e+n>>>1;Sj(t[i])<=r?e=i+1:n=i}return t[Math.max(0,e-1)]}let a=Ng(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 Ej(e,t,n,r,i=vj){let a=await xj(n.id,`low`,r);if(!a)return null;let o=Dj(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 Dj(e,t,n,r=vj){let i=new pu({map:n,transparent:!0,depthWrite:!1}),a=new ks(new nu(t,64,64),i);return a.scale.setScalar(r),a.renderOrder=1,e.add(a),{mesh:a,material:i,id:``,availableTiers:[],availableFrames:[]}}async function Oj(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<yj)){e.lastSwapMs=r,e.textureLoading=!0;try{let r=await xj(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 kj(e){e.mesh.geometry.dispose(),e.material.map?.dispose(),e.material.dispose(),e.mesh.parent?.remove(e.mesh)}var Aj=.2,jj=-.125,Mj=.1,Nj=Symbol(`night-lights-hook`);async function Pj(e,t,n,r){let i=Kt(`/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=Jr,Fj(e,a),a}function Fj(e,t){e.emissiveMap=t,e.emissive=new X(16777215);let n=e;if(!n[Nj]){n[Nj]=!0;let t=IC();NC(e,`nightLights`,e=>{e.uniforms.uSunDir=t.uSunDir,e.uniforms.uNightIntensity={value:Aj},e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
5493
5493
  varying vec3 vNightOutwardWorld;`).replace(`#include <begin_vertex>`,`#include <begin_vertex>
5494
5494
  vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5495
5495
  uniform float uNightIntensity;
@@ -5498,9 +5498,9 @@ vNightOutwardWorld = mat3(modelMatrix) * position;`),e.fragmentShader=e.fragment
5498
5498
  // Modulate by unlit-side factor: 1 night, 0 day.
5499
5499
  vec3 nightOutward = normalize(vNightOutwardWorld);
5500
5500
  float nightDot = dot(nightOutward, uSunDir);
5501
- float nightFactor = 1.0 - smoothstep(${kj.toFixed(2)}, ${Aj.toFixed(2)}, nightDot);
5501
+ float nightFactor = 1.0 - smoothstep(${jj.toFixed(2)}, ${Mj.toFixed(2)}, nightDot);
5502
5502
  totalEmissiveRadiance *= nightFactor * uNightIntensity;
5503
- #endif`)})}e.needsUpdate=!0}function Pj(e){e.emissiveMap&&(e.emissiveMap.dispose(),e.emissiveMap=null,e.emissive.setRGB(0,0,0),e.needsUpdate=!0)}var Fj=.55,Ij=Symbol(`specular-hook`);async function Lj(e,t,n,r){let i=Kt(`/v1/textures/${t.id}/${n}.webp`,`textures`),a;try{a=await new Promise((e,t)=>{r.load(i,e,void 0,t)})}catch(e){return console.warn(`Failed to load specular map ${i}:`,e),null}e.roughnessMap=a;let o=e;return o[Ij]||(o[Ij]=!0,MC(e,`specular`,e=>{e.uniforms.uOceanRoughness={value:Fj},e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5503
+ #endif`)})}e.needsUpdate=!0}function Ij(e){e.emissiveMap&&(e.emissiveMap.dispose(),e.emissiveMap=null,e.emissive.setRGB(0,0,0),e.needsUpdate=!0)}var Lj=.55,Rj=Symbol(`specular-hook`);async function zj(e,t,n,r){let i=Kt(`/v1/textures/${t.id}/${n}.webp`,`textures`),a;try{a=await new Promise((e,t)=>{r.load(i,e,void 0,t)})}catch(e){return console.warn(`Failed to load specular map ${i}:`,e),null}e.roughnessMap=a;let o=e;return o[Rj]||(o[Rj]=!0,NC(e,`specular`,e=>{e.uniforms.uOceanRoughness={value:Lj},e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
5504
5504
  uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`float roughnessFactor = roughness;
5505
5505
  #ifdef USE_ROUGHNESSMAP
5506
5506
  // Mask carries the fraction of the texel under water, so a
@@ -5509,14 +5509,14 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5509
5509
  // roughnessmap sample.
5510
5510
  vec4 texelRoughness = texture2D(roughnessMap, vRoughnessMapUv);
5511
5511
  roughnessFactor = mix(roughness, uOceanRoughness, texelRoughness.g);
5512
- #endif`)})),e.needsUpdate=!0,a}function Rj(e){e.roughnessMap&&(e.roughnessMap.dispose(),e.roughnessMap=null,e.needsUpdate=!0)}var zj={specular:{meta:e=>e.specular,loaded:e=>e.specularMap!==null,async load(e,t,n,r){let i=await Lj(n.material,t,`low`,r.textureLoader);if(i){if(e.specularMap){i.dispose();return}e.specularMap=i}},unload(e,t){t&&(Rj(t.material),e.specularMap=null)}},night:{meta:e=>e.night,loaded:e=>e.emissiveMap!==null,async load(e,t,n,r){let i=await Mj(n.material,t,`low`,r.textureLoader);if(i){if(e.emissiveMap){i.dispose();return}e.emissiveMap=i}},unload(e,t){t&&(Pj(t.material),e.emissiveMap=null)}},topography:{meta:e=>e.displacement,loaded:e=>e.displacementMap!==null,enabled(e){return Bx()?(console.info(`Low-end device: skipping DEM relief for ${e}`),!1):Ax().showDisplacement},async load(e,t,n,r){let i=n.material,a=await ZC(i,t,`low`,r.textureLoader,e.radiusScene);if(a){if(e.displacementMap){a.dispose();return}e.displacementMap=a,e.displacementMeta=t,e.displacementTier=`low`,e.selfShadow=Ax().showSelfShadow?YC(i,a,Q(t.scale_km)):null}},unload(e,t){t&&(iw(t.material),e.displacementMap=null,e.displacementTier=void 0,XC(e.selfShadow),e.selfShadow=null)}},clouds:{meta:e=>e.clouds,loaded:e=>e.clouds!==null,async load(e,t,n,r){let i=Cj(r.currentJd,t.frames,t.coverage);if(!i)return;let a=e.atmosphere?e.atmosphere.planetRadiusKm/e.atmosphere.surfaceRadiusKm:1,o=a>1?a:gj,s=await wj(n,e.radiusScene,t,i,o);if(s){if(e.clouds){Dj(s);return}e.eclipseShadow&&(zC(s.material,e.eclipseShadow),e.atmosphere&&(e.sunTint??=[]).push(HA(s.material,e.atmosphere.params,e.radiusScene,e.atmosphere.surfaceRadiusKm,e.eclipseShadow,e.atmosphere,gj*a))),e.clouds=s}},unload(e){e.clouds&&=(Dj(e.clouds),null)}}},Bj=Object.keys(zj);function Vj(e,t,n,r,i,a){let o=zj[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 Hj(e,t,n,r,i){let a=[];for(let o of Bj){let s=Vj(o,e,t,n,r,i);s&&a.push(s)}return a}function Uj(e,t){let n=zj[e];n.loaded(t)&&n.unload(t,t.mesh)}function Wj(e){for(let t of Bj)Uj(t,e)}var Gj=[`low`,`medium`,`high`];function Kj(e){return e===void 0?-1:Gj.indexOf(e)}function qj(e,t){for(let n=e;n>=0;n--){let e=Gj[n];if(t.includes(e))return e}}function Jj(e,t,n){return Kt(n===void 0?`/v1/textures/${e}/${t}.webp`:`/v1/textures/${e}/${t}_${String(n).padStart(2,`0`)}.webp`,`textures`)}function Yj(e,t){if(!(!t||t<2))return t===12?Ng(e).getUTCMonth()+1:1}async function Xj(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(Jj(i,t,n),e,void 0,a)});if(!e.mesh||e.textureLoadGen!==a){o.dispose();return}let s=e.mesh.material;cD(s,o,e.body.data.color),e.model&&sD(e.model,o,g_(e.body.data),e.body.data.color),e.textureTier=t,e.textureFrame=n}catch(e){console.warn(`Failed to load ${t} texture for ${i}:`,e)}finally{e.textureLoading=!1}}function Zj(e,t){if(!e.mesh)return;let{a:n,b:r,c:i}=t,a=Q(1)/e.radiusScene;if(e.mesh.scale.set(n*a,i*a,r*a),e.radiusScene=Q(Math.max(n,r,i)),e.semiAxesScene=[Q(n),Q(i),Q(r)],e.atmosphere){let t=Math.max(n,r);EA(e.atmosphere,t,i,Q(t));for(let n of e.sunTint??[])zA(n,e.atmosphere.params,Q(t),t)}e.radiiApplied=!0}async function Qj(e,t,n,r,i,a){if(e.textureTier||e.textureLoading)return;let s=await px(e.body.data.id,!1);if(!s.global)return;s.global.orientation&&!e.body.orientation&&dD(e,s.global.orientation,a),s.global.radii&&e.radiusScene>0&&!e.radiiApplied&&!s.global.displacement?.absolute_radius&&Zj(e,s.global.radii),s.global.rings?.length&&await Promise.allSettled(hj(e.body.data.id,e.body.data.id,s.global.rings,s.global.radii,e,r,i,a));let c=s.global.sbdb?.color??s.global.color;if(c&&(e.body.data.color=c,e.mesh&&!e.textureTier&&e.mesh.material.color.set(c)),!s.global.map_texture_available)return;let l=e.body.data.id,u=o([s.global.texture&&{...s.global.texture,id:l,tiers:void 0},...s.global.alternates??[]]);a&&u&&a.credits.registerImagery(`surface`,l,l,u),await Vj(`topography`,l,l,s.global,e,{textureLoader:t,currentJd:n,ctx:a}),!(e.textureTier||e.textureLoading)&&Ax().showSurfaceTexture&&u&&(e.textureBundleId=u.id===l?void 0:u.id,e.availableTiers??=u.tiers??[...Gj],e.availableFrames=u.frames,await Xj(e,`low`,Yj(n,e.availableFrames),t))}async function $j(e){if(!e.label)return;let t=e.body.data;if(t.name)return;let n=await px(t.id,t.hasLocalized),r=n.localized?.name??n.global?.name;r&&(t.name??=r,Dk(e,r,Ok(e.body),t.objectType===G.STAR||t.objectType===G.PLANET))}function eM(e){if(!e.mesh)return;e.textureLoadGen=(e.textureLoadGen??0)+1;let t=e.mesh.material;Uj(`topography`,e),t.map&&(t.map.dispose(),t.map=null,t.color.set(g_(e.body.data)),t.needsUpdate=!0,e.model&&sD(e.model,null,g_(e.body.data)),e.textureTier=void 0)}async function tM(e,t,n,r){e.textureLoading||e.availableTiers?.includes(t)&&(e.textureTier===t&&e.textureFrame===n||await Xj(e,t,n,r))}var nM=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&&rM(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),iM(i,r,t,()=>this.wanted.get(n)))}}}};function rM(e,t){let n=e.appearance;if(!n||!e.mesh)return;let r=e.mesh.material;if(n.surfaceOwned&&t?.surface===void 0&&(n.surfaceMap?.dispose(),r.map=null,r.color.set(g_(e.body.data)),r.needsUpdate=!0,e.model&&sD(e.model,null,g_(e.body.data)),n.surfaceOwned=void 0,n.surfaceUrl=void 0,n.surfaceMap=void 0,e.textureTier=void 0),n.nightUrl!==void 0&&t?.night===void 0){let e=n.displacedNight;n.nightMap?.dispose(),e?Nj(r,e):Pj(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 iM(e,t,n,r){let i=e.appearance??={};if(i.loading)return;let a=oM(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 sM(t.surface,n);if(r()!==t)return void a?.dispose();let o=oM(e);a&&o&&(cD(o,a),e.model&&sD(e.model,a,g_(e.body.data)),i.surfaceUrl=t.surface,i.surfaceMap=a)}if(s){let a=await sM(t.night,n);if(r()!==t)return void a?.dispose();let o=oM(e);a&&o&&(i.displacedNight??=o.emissiveMap,Nj(o,a),i.nightUrl=t.night,i.nightMap=a)}if(c){let a=await sM(t.clouds,n);if(r()!==t)return void a?.dispose();a&&e.mesh&&aM(e,i,a,t.clouds)}}finally{i.loading=!1}}}function aM(e,t,n,r){let i=e.clouds;if(i)t.ownCloudNode||(t.displacedClouds??=i.material.map,t.displacedCloudTiers??=i.availableTiers,t.displacedCloudFrames??=i.availableFrames),i.material.map=n,i.material.needsUpdate=!0;else{if(!e.mesh)return;i=Tj(e.mesh,e.radiusScene,n),e.clouds=i,t.ownCloudNode=!0}i.availableTiers=[],i.availableFrames=[],t.cloudsUrl=r,t.cloudsMap=n}function oM(e){return e.mesh?e.mesh.material:null}async function sM(e,t){try{let n=await new Promise((n,r)=>{t.load(e,n,void 0,r)});return n.colorSpace=Jr,n}catch(t){return console.warn(`spacemap: could not load the picture at ${e}:`,t),null}}function cM(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 lM=new Map;async function uM(e){let t=Kt(`/v1/nomenclature/positions/${e}.bin.gz`,`nomenclature`),n=await fetch(t);if(!n.ok){if(n.status===404)return[];throw Error(`fetchPositions: ${t} returned ${n.status} ${n.statusText}`)}let r=new DecompressionStream(`gzip`);return cM(await new Response(n.body.pipeThrough(r)).arrayBuffer())}async function dM(e,t){let n=Kt(`/v1/nomenclature/labels/${t}/${e}.txt.gz`,`nomenclature`),r=await fetch(n);if(!r.ok){if(r.status===404)return[];throw Error(`fetchNomenclatureLabels: ${n} returned ${r.status} ${r.statusText}`)}let i=new DecompressionStream(`gzip`),a=await new Response(r.body.pipeThrough(i)).text();return a===``?[]:a.split(`
5513
- `)}function fM(e,t=s()){let n=`${e}:${t}`,r=lM.get(n);return r||(r=(async()=>{let[n,r]=await Promise.all([uM(e),dM(e,t)]);return n.map((e,t)=>({...e,name:r[t]??`Feature ${e.featureId}`}))})(),lM.set(n,r),r.catch(()=>{lM.get(n)===r&&lM.delete(n)})),r}var pM=3;function mM(e,t,n=pM){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 hM(e,t){if(e)return cn(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var gM=Math.PI/180,_M=.9,vM=24,yM=.2,bM=100,xM=16,SM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function CM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await px(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await fM(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!SM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:bM;return(t.diameterM>0?t.diameterM:bM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await EM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=ZD(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new Ra,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 xw(e,e.body.data.id,r.global.displacement,mn(e.body.data),a.map(e=>({latRad:e.lat*gM,lonRad:e.lon*gM}))),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:bM;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),jk(o,t),n&&mM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=ow(r.lat*gM,r.lon*gM),m=c[e],g=new JO(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 ${bM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var wM=8,TM=new J;async function EM(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%wM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*gM,s=t[o].lon*gM,c=bO(e,n,s,TM);if(c!==null)r[o]=c;else{let[e,t,i]=ow(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),TM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=TM.x,i[o*3+1]=TM.y,i[o*3+2]=TM.z}return{radii:r,normals:i}}function DM(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 OM(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 kM=new J,AM=new J,jM=new J,MM=new J,NM=new J,PM=new Vi,FM=new J,IM=.12;function LM(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/(mn(e.body.data)*1e3),m=yM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<vM)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(kM),r.getWorldPosition(AM);let h=AM.x-kM.x,g=AM.y-kM.y,_=AM.z-kM.z;MM.copy(kM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(_M*(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(PM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<vM||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(jM);let v=jM.x-kM.x,y=jM.y-kM.y,w=jM.z-kM.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){FM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(PM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(FM.x*n+FM.y*r+FM.z*i<IM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}NM.copy(jM).project(r);let T=(NM.x-MM.x)*x,E=(NM.y-MM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(NM.x*.5+.5)*i,l[e]=(-NM.y*.5+.5)*a}}var RM=[];function zM(e){let t=RM[e];return t||(t={left:0,right:0,y:0,h:0},RM[e]=t),t}function BM(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=RM[e],n=(t.h+xM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=zM(r);return f.left=u,f.right=d,f.y=o,f.h=xM,r+1}function VM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=hk,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=zM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=BM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=BM(e,i,!1,r))}var HM=34028235e31,UM=3;function WM(e){return new X(e).multiplyScalar(.5)}function GM(){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 Mc(e)}function KM(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function qM(e,t,n,r=[0,0,0],i=4,a=null){let o=e.filter(e=>{let[t,n,r]=e.position;return isFinite(t)&&Math.abs(t)<=HM&&isFinite(n)&&Math.abs(n)<=HM&&isFinite(r)&&Math.abs(r)<=HM?!0:(console.warn(`Skipping body with non-finite position: id=${e.data.id} name=${e.data.name}`,e.position),!1)}),s=new Float32Array(o.length*3),c=a?new Float32Array(o.length*3):null,l=c?new X:null;for(let e=0;e<o.length;e++){let t=o[e];s[e*3]=t.position[0]-r[0],s[e*3+1]=t.position[1]-r[1],s[e*3+2]=t.position[2]-r[2],c&&l&&a&&(l.set(a(t)),c[e*3]=l.r,c[e*3+1]=l.g,c[e*3+2]=l.b)}let u=new Vo;u.setAttribute(`position`,new ko(s,3)),c&&u.setAttribute(`color`,new ko(c,3));let d=new kc(u,new wc({map:t,color:c?new X(.5,.5,.5):WM(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=UM,d}function JM(e,t,n,r,i=4,a=null){let o=new Vo;o.setAttribute(`position`,new Eo(e,3)),a&&o.setAttribute(`color`,new Eo(a,3)),o.setDrawRange(0,t);let s=new kc(o,new wc({map:n,color:a?new X(.5,.5,.5):WM(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=UM,s}function YM(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(Wv(c,l,e.w,e.i,e.om,e.equatorial))}return o}function XM(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(Wv(b,x,a,r,i,e.equatorial))}return l}function ZM(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(Wv(d,f,e.w,e.i,e.om,e.equatorial))}return o}function QM(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=yg(e,t-i+i*n/r);o&&a.push(o)}return a}function $M(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function eN(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:YM(e,t),isOpen:!0}:!n&&e.e>=1?{points:ZM(e,t),isOpen:!0}:{points:XM(e,t),isOpen:!1}}var tN=3;function nN(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 Vo;return c.setAttribute(`position`,new ko(n,3)),c.setAttribute(`nextPosition`,new ko(r,3)),c.setAttribute(`side`,new ko(i,1)),c.setAttribute(`trailAlpha`,new ko(a,1)),c.setAttribute(`fullAlpha`,new ko(o,1)),c.setIndex(new Do(s,1)),c}function rN(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 iN(){let e=new Vo;e.setAttribute(`position`,new ko(new Float32Array(6),3));let t=new vc(e,new du({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=tN,t}function aN(e,t,n,r,i){let a=new Vo;a.setAttribute(`position`,new ko(e,3)),a.setAttribute(`trailAlpha`,new ko(t,1)),a.setAttribute(`fullAlpha`,new ko(n,1)),a.setDrawRange(0,r);let o=new vc(a,uT(i));return o.matrixAutoUpdate=!1,o.renderOrder=tN,o}function oN(e,t,n,r,i,a,o,s){let c=nN(e);rN(c,t,n,r,i);let l=new ks(c,dT(a,o,s));return l.matrixAutoUpdate=!1,l.renderOrder=tN,l}function sN(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 cN(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($y(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){rN(e.geometry,t,n,r,i);return}e.geometry.setDrawRange(0,i),e.geometry.getAttribute(`position`).needsUpdate=!0,e.geometry.getAttribute(`trailAlpha`).needsUpdate=!0,e.geometry.getAttribute(`fullAlpha`).needsUpdate=!0}function lN(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;n[0]=c[0]-o[0],n[1]=c[1]-o[1],n[2]=c[2]-o[2];let l=r-o[0],u=i-o[1],d=a-o[2];return 1+t.writeVertices(n.subarray(3),l,u,d,s)}function uN(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||hn(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=lN(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&$y(m.subarray(0,p),h.subarray(0,p),!0,u);let g=i>1,_=g?oN(d,f,h,m,p,n,i):aN(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 dN(e,t,n=[0,0,0],r=Mg(new Date),i=1){if(e.trailBuffer)return uN(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l;if(s.satrec)c=QM(s.satrec,r,s.n/360,512),l=!0;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=$M(a)}let u=o?.[0]??0,d=o?.[1]??0,f=o?.[2]??0,p=l||s.objectType===G.DWARF_PLANET||s.objectType===G.MOON||s.objectType===G.SPACECRAFT||s.objectType===G.COMET||hn(s.objectType),m=c?Qy(e,c,l,u,d,f):[];if(c&&m.length<2)return iN();let h=c?Math.max(m.length,c.length):513,g=new Float32Array(h),_=new Float32Array(h);$y(g.subarray(0,m.length),_.subarray(0,m.length),l,p);let v=u-n[0],y=d-n[1],b=f-n[2],x=new Float32Array(h*3);for(let e=0;e<m.length;e++)x[e*3]=m[e][0]+v,x[e*3+1]=m[e][1]+y,x[e*3+2]=m[e][2]+b;let S=i>1,C=S?oN(h,x,_,g,m.length,t,i):aN(x,_,g,m.length,t);return C.frustumCulled=!1,C.visible=!1,C.userData.orbitCenter=new J(u,d,f),C.userData.trailLocalPositions=c?m:void 0,C.userData.sourceCurve=c??void 0,C.userData.curvePending=c===null,C.userData.isOpenCurve=l,C.userData.useTrail=p,C.userData.curveJd=r,C.userData.elementsJd=a?.epoch??r,S&&(C.userData.isFatLine=!0,C.userData.thinPositions=x,C.userData.thinTrailAlphas=_,C.userData.thinFullAlphas=g),C}function fN(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 pN(e){return e.data.objectType===G.PLANET?4:(e.data.objectType===G.MOON||e.data.objectType===G.DWARF_PLANET)&&t_[e.data.id]?3:1}function mN(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===tn.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&uj(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=dN(e,m_(e.data),n,r,pN(e));t.add(a),i.trail=a}}function hN(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=KM();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=fN(c.values(),i);if(e.length===0)continue;let u=m_(e[0].data),{buckets:d}=y_(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=qM(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=Cv(e.layers,o,fN(c.values(),i));if(l.length===0)continue;let{buckets:u}=y_(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=qM(i,n,`#ffffff`,r,void 0,e=>m_(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=qM(i,n,m_(i[0].data),r),o=a.material;o.transparent=!1,o.alphaTest=.5,o.depthTest=!0,o.depthWrite=!0,a.visible=!1,c.set(e,a),t.add(a)}return{asteroidPoints:o,spacecraftPoints:s,moonPoints:c}}async function gN(e,t,n,r,i,a,s){let c;try{let t=await fetch(`${Ut()}/v1/systems/${e}.json`);if(!t.ok)return;c=await t.json()}catch{return}let l=[];for(let[u,d]of Object.entries(c)){let c=o([d.texture&&{...d.texture,id:u,tiers:d.tiers},...d.alternates??[]]);c&&s?.credits.registerImagery(`surface`,u,e,c);let f=t.get(u);if(f?.mesh){if(d.orientation){if(dD(f,d.orientation,s,e),d.nut_prec){let e=u.match(/^naif-(-?\d+)$/),t=e?parseInt(e[1],10):null,n=t===null?void 0:Z_(X_(t));n&&(f.body.nutPrec={...d.nut_prec,angles:n})}fC(f.mesh,d.orientation,i,f.body.nutPrec)}if(d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&Zj(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,!f.textureTier)){let e=Yj(i,f.availableFrames);l.push(tM(f,`low`,e,r))}l.push(...Hj(u,e,d,f,{textureLoader:r,currentJd:i,ctx:s})),d.rings?.length&&l.push(...hj(u,e,d.rings,d.radii,f,n,a,s))}}await Promise.allSettled(l)}function _N(e,t,n,r){for(let i of t.values())if(r.visibility.isBodyInSystem(i.body,e)){if(eM(i),Wj(i),i.terrainWindow&&i.mesh){i.terrainWindow=null;let e=Q(mn(i.body.data)),t=i.mesh.geometry;i.mesh.geometry=new nu(e,24,24),t.dispose(),i.currentSegments=24}for(let e of i.rings){e.planetShadow?.disable(),n.remove(e.mesh);let t=i.extraObjects.indexOf(e.mesh);t>=0&&i.extraObjects.splice(t,1),iA(e)}i.rings=[],OM(i)}}var vN=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 j_(n)?null:n}load(e){gN(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)_N(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},yN=Math.PI/180,bN=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Vi;_adjustQ=new Vi;_tmpQ=new Vi;_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*yN).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*yN)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*yN)),this._q.copy(Xx).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},xN=Math.PI/180,SN=ig*xN,CN=Math.cos(SN),wN=Math.sin(SN),TN=5e3,EN=[{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`}],DN=192.85948,ON=27.12825,kN=266.40499,AN=-28.93617,jN=256,MN=[{name:`galactic-plane`,zero:NN(kN,AN,new J).normalize(),pole:NN(DN,ON,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:NN(0,0,new J).normalize(),pole:NN(0,90,new J).normalize(),color:10325247}];function NN(e,t,n){let r=e*xN,i=t*xN,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*CN+c*wN,d=-s*wN+c*CN;return n.set(l,d,-u)}function PN(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=`
5512
+ #endif`)})),e.needsUpdate=!0,a}function Bj(e){e.roughnessMap&&(e.roughnessMap.dispose(),e.roughnessMap=null,e.needsUpdate=!0)}var Vj={specular:{meta:e=>e.specular,loaded:e=>e.specularMap!==null,async load(e,t,n,r){let i=await zj(n.material,t,`low`,r.textureLoader);if(i){if(e.specularMap){i.dispose();return}e.specularMap=i}},unload(e,t){t&&(Bj(t.material),e.specularMap=null)}},night:{meta:e=>e.night,loaded:e=>e.emissiveMap!==null,async load(e,t,n,r){let i=await Pj(n.material,t,`low`,r.textureLoader);if(i){if(e.emissiveMap){i.dispose();return}e.emissiveMap=i}},unload(e,t){t&&(Ij(t.material),e.emissiveMap=null)}},topography:{meta:e=>e.displacement,loaded:e=>e.displacementMap!==null,enabled(e){return Vx()?(console.info(`Low-end device: skipping DEM relief for ${e}`),!1):jx().showDisplacement},async load(e,t,n,r){let i=n.material,a=await QC(i,t,`low`,r.textureLoader,e.radiusScene);if(a){if(e.displacementMap){a.dispose();return}e.displacementMap=a,e.displacementMeta=t,e.displacementTier=`low`,e.selfShadow=jx().showSelfShadow?XC(i,a,Q(t.scale_km)):null}},unload(e,t){t&&(aw(t.material),e.displacementMap=null,e.displacementTier=void 0,ZC(e.selfShadow),e.selfShadow=null)}},clouds:{meta:e=>e.clouds,loaded:e=>e.clouds!==null,async load(e,t,n,r){let i=Tj(r.currentJd,t.frames,t.coverage);if(!i)return;let a=e.atmosphere?e.atmosphere.planetRadiusKm/e.atmosphere.surfaceRadiusKm:1,o=a>1?a:vj,s=await Ej(n,e.radiusScene,t,i,o);if(s){if(e.clouds){kj(s);return}e.eclipseShadow&&(BC(s.material,e.eclipseShadow),e.atmosphere&&(e.sunTint??=[]).push(WA(s.material,e.atmosphere.params,e.radiusScene,e.atmosphere.surfaceRadiusKm,e.eclipseShadow,e.atmosphere,vj*a))),e.clouds=s}},unload(e){e.clouds&&=(kj(e.clouds),null)}}},Hj=Object.keys(Vj);function Uj(e,t,n,r,i,a){let o=Vj[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 Wj(e,t,n,r,i){let a=[];for(let o of Hj){let s=Uj(o,e,t,n,r,i);s&&a.push(s)}return a}function Gj(e,t){let n=Vj[e];n.loaded(t)&&n.unload(t,t.mesh)}function Kj(e){for(let t of Hj)Gj(t,e)}var qj=[`low`,`medium`,`high`];function Jj(e){return e===void 0?-1:qj.indexOf(e)}function Yj(e,t){for(let n=e;n>=0;n--){let e=qj[n];if(t.includes(e))return e}}function Xj(e,t,n){return Kt(n===void 0?`/v1/textures/${e}/${t}.webp`:`/v1/textures/${e}/${t}_${String(n).padStart(2,`0`)}.webp`,`textures`)}function Zj(e,t){if(!(!t||t<2))return t===12?Ng(e).getUTCMonth()+1:1}async function Qj(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(Xj(i,t,n),e,void 0,a)});if(!e.mesh||e.textureLoadGen!==a){o.dispose();return}let s=e.mesh.material;lD(s,o,e.body.data.color),e.model&&cD(e.model,o,g_(e.body.data),e.body.data.color),e.textureTier=t,e.textureFrame=n}catch(e){console.warn(`Failed to load ${t} texture for ${i}:`,e)}finally{e.textureLoading=!1}}function $j(e,t){if(!e.mesh)return;let{a:n,b:r,c:i}=t,a=Q(1)/e.radiusScene;if(e.mesh.scale.set(n*a,i*a,r*a),e.radiusScene=Q(Math.max(n,r,i)),e.semiAxesScene=[Q(n),Q(i),Q(r)],e.atmosphere){let t=Math.max(n,r);OA(e.atmosphere,t,i,Q(t));for(let n of e.sunTint??[])VA(n,e.atmosphere.params,Q(t),t)}e.radiiApplied=!0}async function eM(e,t,n,r,i,a){if(e.textureTier||e.textureLoading)return;let s=await mx(e.body.data.id,!1);if(!s.global)return;s.global.orientation&&!e.body.orientation&&fD(e,s.global.orientation,a),s.global.radii&&e.radiusScene>0&&!e.radiiApplied&&!s.global.displacement?.absolute_radius&&$j(e,s.global.radii),s.global.rings?.length&&await Promise.allSettled(_j(e.body.data.id,e.body.data.id,s.global.rings,s.global.radii,e,r,i,a));let c=s.global.sbdb?.color??s.global.color;if(c&&(e.body.data.color=c,e.mesh&&!e.textureTier&&e.mesh.material.color.set(c)),!s.global.map_texture_available)return;let l=e.body.data.id,u=o([s.global.texture&&{...s.global.texture,id:l,tiers:void 0},...s.global.alternates??[]]);a&&u&&a.credits.registerImagery(`surface`,l,l,u),await Uj(`topography`,l,l,s.global,e,{textureLoader:t,currentJd:n,ctx:a}),!(e.textureTier||e.textureLoading)&&jx().showSurfaceTexture&&u&&(e.textureBundleId=u.id===l?void 0:u.id,e.availableTiers??=u.tiers??[...qj],e.availableFrames=u.frames,await Qj(e,`low`,Zj(n,e.availableFrames),t))}async function tM(e){if(!e.label)return;let t=e.body.data;if(t.name)return;let n=await mx(t.id,t.hasLocalized),r=n.localized?.name??n.global?.name;r&&(t.name??=r,kk(e,r,Ak(e.body),t.objectType===G.STAR||t.objectType===G.PLANET))}function nM(e){if(!e.mesh)return;e.textureLoadGen=(e.textureLoadGen??0)+1;let t=e.mesh.material;Gj(`topography`,e),t.map&&(t.map.dispose(),t.map=null,t.color.set(g_(e.body.data)),t.needsUpdate=!0,e.model&&cD(e.model,null,g_(e.body.data)),e.textureTier=void 0)}async function rM(e,t,n,r){e.textureLoading||e.availableTiers?.includes(t)&&(e.textureTier===t&&e.textureFrame===n||await Qj(e,t,n,r))}var iM=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&&aM(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),oM(i,r,t,()=>this.wanted.get(n)))}}}};function aM(e,t){let n=e.appearance;if(!n||!e.mesh)return;let r=e.mesh.material;if(n.surfaceOwned&&t?.surface===void 0&&(n.surfaceMap?.dispose(),r.map=null,r.color.set(g_(e.body.data)),r.needsUpdate=!0,e.model&&cD(e.model,null,g_(e.body.data)),n.surfaceOwned=void 0,n.surfaceUrl=void 0,n.surfaceMap=void 0,e.textureTier=void 0),n.nightUrl!==void 0&&t?.night===void 0){let e=n.displacedNight;n.nightMap?.dispose(),e?Fj(r,e):Ij(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 oM(e,t,n,r){let i=e.appearance??={};if(i.loading)return;let a=cM(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 lM(t.surface,n);if(r()!==t)return void a?.dispose();let o=cM(e);a&&o&&(lD(o,a),e.model&&cD(e.model,a,g_(e.body.data)),i.surfaceUrl=t.surface,i.surfaceMap=a)}if(s){let a=await lM(t.night,n);if(r()!==t)return void a?.dispose();let o=cM(e);a&&o&&(i.displacedNight??=o.emissiveMap,Fj(o,a),i.nightUrl=t.night,i.nightMap=a)}if(c){let a=await lM(t.clouds,n);if(r()!==t)return void a?.dispose();a&&e.mesh&&sM(e,i,a,t.clouds)}}finally{i.loading=!1}}}function sM(e,t,n,r){let i=e.clouds;if(i)t.ownCloudNode||(t.displacedClouds??=i.material.map,t.displacedCloudTiers??=i.availableTiers,t.displacedCloudFrames??=i.availableFrames),i.material.map=n,i.material.needsUpdate=!0;else{if(!e.mesh)return;i=Dj(e.mesh,e.radiusScene,n),e.clouds=i,t.ownCloudNode=!0}i.availableTiers=[],i.availableFrames=[],t.cloudsUrl=r,t.cloudsMap=n}function cM(e){return e.mesh?e.mesh.material:null}async function lM(e,t){try{let n=await new Promise((n,r)=>{t.load(e,n,void 0,r)});return n.colorSpace=Jr,n}catch(t){return console.warn(`spacemap: could not load the picture at ${e}:`,t),null}}function uM(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 dM=new Map;async function fM(e){let t=Kt(`/v1/nomenclature/positions/${e}.bin.gz`,`nomenclature`),n=await fetch(t);if(!n.ok){if(n.status===404)return[];throw Error(`fetchPositions: ${t} returned ${n.status} ${n.statusText}`)}let r=new DecompressionStream(`gzip`);return uM(await new Response(n.body.pipeThrough(r)).arrayBuffer())}async function pM(e,t){let n=Kt(`/v1/nomenclature/labels/${t}/${e}.txt.gz`,`nomenclature`),r=await fetch(n);if(!r.ok){if(r.status===404)return[];throw Error(`fetchNomenclatureLabels: ${n} returned ${r.status} ${r.statusText}`)}let i=new DecompressionStream(`gzip`),a=await new Response(r.body.pipeThrough(i)).text();return a===``?[]:a.split(`
5513
+ `)}function mM(e,t=s()){let n=`${e}:${t}`,r=dM.get(n);return r||(r=(async()=>{let[n,r]=await Promise.all([fM(e),pM(e,t)]);return n.map((e,t)=>({...e,name:r[t]??`Feature ${e.featureId}`}))})(),dM.set(n,r),r.catch(()=>{dM.get(n)===r&&dM.delete(n)})),r}var hM=3;function gM(e,t,n=hM){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 _M(e,t){if(e)return cn(e)?e.featureAnchor.hostId:t.get(e.data.id)?.isLanded?e.data.parentId:e.data.id}var vM=Math.PI/180,yM=.9,bM=24,xM=.2,SM=100,CM=16,wM=new Set([`CA`,`CH`,`DO`,`FL`,`FO`,`LI`,`RI`,`RU`,`VA`]);async function TM(e,t,n){if(e.nomenclatureLabels||!e.mesh&&!e.model)return;let r=await mx(e.body.data.id,!1);if(!r.global?.has_nomenclature||e.nomenclatureLabels)return;let i=await mM(e.body.data.id);if(e.nomenclatureLabels)return;let a=i.filter(e=>!wM.has(e.typeCode));a.sort((e,t)=>{let n=e.diameterM>0?e.diameterM:SM;return(t.diameterM>0?t.diameterM:SM)-n});let o=a.length,s=e.model,c=new Float32Array(o),l;if(s){let t=await OM(s,a);if(e.nomenclatureLabels||e.model!==s)return;let n=QD(e);for(let e=0;e<o;e++)c[e]=t.radii[e]*n;e.nomenclatureNormals=t.normals;let r=new Ra,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 Sw(e,e.body.data.id,r.global.displacement,mn(e.body.data),a.map(e=>({latRad:e.lat*vM,lonRad:e.lon*vM}))),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:SM;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),Nk(o,t),n&&gM(o,()=>n(r.featureId,r.lat,r.lon,i));let[s,f,p]=sw(r.lat*vM,r.lon*vM),m=c[e],g=new YO(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 ${SM}m fallback`),e.nomenclatureLabels=u,e.nomenclatureDiamsM=d,e.nomenclatureWidths=f,e.nomenclatureSX=p,e.nomenclatureSY=m,e.nomenclatureActiveIndex=-1}var EM=8,DM=new J;async function OM(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%EM===0&&await new Promise(e=>setTimeout(e));let n=t[o].lat*vM,s=t[o].lon*vM,c=xO(e,n,s,DM);if(c!==null)r[o]=c;else{let[e,t,i]=sw(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),DM.set(e/(c*c),t/(l*l),i/(u*u)).normalize()}i[o*3]=DM.x,i[o*3+1]=DM.y,i[o*3+2]=DM.z}return{radii:r,normals:i}}function kM(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 AM(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 jM=new J,MM=new J,NM=new J,PM=new J,FM=new J,IM=new Vi,LM=new J,RM=.12;function zM(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/(mn(e.body.data)*1e3),m=xM*Math.min(i,a);if(u<0&&(d===0||f||s[0]*p<bM)){for(let e of o)e.visible=!1;return}e.group.getWorldPosition(jM),r.getWorldPosition(MM);let h=MM.x-jM.x,g=MM.y-jM.y,_=MM.z-jM.z;PM.copy(jM).project(r);let v=h*h+g*g+_*_,y=e.radiusScene*e.radiusScene,b=(yM*(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(IM);for(let e=0;e<d;e++){let t=o[e],n=e===u,d=s[e]*p;if(f&&!n||!n&&(d<bM||d>m)){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.getWorldPosition(NM);let v=NM.x-jM.x,y=NM.y-jM.y,w=NM.z-jM.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){LM.set(C[e*3],C[e*3+1],C[e*3+2]).applyQuaternion(IM);let n=h-v,r=g-y,i=_-w,a=Math.sqrt(n*n+r*r+i*i);if(LM.x*n+LM.y*r+LM.z*i<RM*a){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}}FM.copy(NM).project(r);let T=(FM.x-PM.x)*x,E=(FM.y-PM.y)*S;if(!n&&T*T+E*E>=b){t.visible=!1,c[e]=NaN,l[e]=NaN;continue}t.visible=!0,c[e]=(FM.x*.5+.5)*i,l[e]=(-FM.y*.5+.5)*a}}var BM=[];function VM(e){let t=BM[e];return t||(t={left:0,right:0,y:0,h:0},BM[e]=t),t}function HM(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=BM[e],n=(t.h+CM)*.5;if(u<t.right&&d>t.left&&Math.abs(o-t.y)<n)return i.visible=!1,r}let f=VM(r);return f.left=u,f.right=d,f.y=o,f.h=CM,r+1}function UM(e){let t=e.nomenclatureLabels;if(!t)return;let n=e.nomenclatureActiveIndex??-1,r=0,i=gk,a=i.count;for(let e=0;e<a;e++){let t=i.rects[e],n=VM(r++);n.left=t.left,n.right=t.right,n.y=t.y,n.h=t.h}n>=0&&(r=HM(e,n,!0,r));for(let i=0;i<t.length;i++)i!==n&&(r=HM(e,i,!1,r))}var WM=34028235e31,GM=3;function KM(e){return new X(e).multiplyScalar(.5)}function qM(){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 Mc(e)}function JM(){return typeof window>`u`?3:window.matchMedia(`(max-width: 768px)`).matches?2:3}function YM(e,t,n,r=[0,0,0],i=4,a=null){let o=e.filter(e=>{let[t,n,r]=e.position;return isFinite(t)&&Math.abs(t)<=WM&&isFinite(n)&&Math.abs(n)<=WM&&isFinite(r)&&Math.abs(r)<=WM?!0:(console.warn(`Skipping body with non-finite position: id=${e.data.id} name=${e.data.name}`,e.position),!1)}),s=new Float32Array(o.length*3),c=a?new Float32Array(o.length*3):null,l=c?new X:null;for(let e=0;e<o.length;e++){let t=o[e];s[e*3]=t.position[0]-r[0],s[e*3+1]=t.position[1]-r[1],s[e*3+2]=t.position[2]-r[2],c&&l&&a&&(l.set(a(t)),c[e*3]=l.r,c[e*3+1]=l.g,c[e*3+2]=l.b)}let u=new Vo;u.setAttribute(`position`,new ko(s,3)),c&&u.setAttribute(`color`,new ko(c,3));let d=new kc(u,new wc({map:t,color:c?new X(.5,.5,.5):KM(n),vertexColors:!!c,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return d.frustumCulled=!1,d.renderOrder=GM,d}function XM(e,t,n,r,i=4,a=null){let o=new Vo;o.setAttribute(`position`,new Eo(e,3)),a&&o.setAttribute(`color`,new Eo(a,3)),o.setDrawRange(0,t);let s=new kc(o,new wc({map:n,color:a?new X(.5,.5,.5):KM(r),vertexColors:!!a,transparent:!0,size:i,sizeAttenuation:!1,depthTest:!0,depthWrite:!1}));return s.frustumCulled=!1,s.renderOrder=GM,s}function ZM(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(Wv(c,l,e.w,e.i,e.om,e.equatorial))}return o}function QM(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(Wv(b,x,a,r,i,e.equatorial))}return l}function $M(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(Wv(d,f,e.w,e.i,e.om,e.equatorial))}return o}function eN(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=yg(e,t-i+i*n/r);o&&a.push(o)}return a}function tN(e){return!(isFinite(e.a)&&e.a>0)&&(e.q!=null||e.e>=1)}function nN(e,t=512){let n=isFinite(e.a)&&e.a>0;return!n&&e.q!=null?{points:ZM(e,t),isOpen:!0}:!n&&e.e>=1?{points:$M(e,t),isOpen:!0}:{points:QM(e,t),isOpen:!1}}var rN=3;function iN(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 Vo;return c.setAttribute(`position`,new ko(n,3)),c.setAttribute(`nextPosition`,new ko(r,3)),c.setAttribute(`side`,new ko(i,1)),c.setAttribute(`trailAlpha`,new ko(a,1)),c.setAttribute(`fullAlpha`,new ko(o,1)),c.setIndex(new Do(s,1)),c}function aN(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 oN(){let e=new Vo;e.setAttribute(`position`,new ko(new Float32Array(6),3));let t=new vc(e,new du({transparent:!0}));return t.matrixAutoUpdate=!1,t.visible=!1,t.renderOrder=rN,t}function sN(e,t,n,r,i){let a=new Vo;a.setAttribute(`position`,new ko(e,3)),a.setAttribute(`trailAlpha`,new ko(t,1)),a.setAttribute(`fullAlpha`,new ko(n,1)),a.setDrawRange(0,r);let o=new vc(a,dT(i));return o.matrixAutoUpdate=!1,o.renderOrder=rN,o}function cN(e,t,n,r,i,a,o,s){let c=iN(e);aN(c,t,n,r,i);let l=new ks(c,fT(a,o,s));return l.matrixAutoUpdate=!1,l.renderOrder=rN,l}function lN(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 uN(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(eb(r.subarray(0,i),n.subarray(0,i),a,o),e.userData.isFatLine){aN(e.geometry,t,n,r,i);return}e.geometry.setDrawRange(0,i),e.geometry.getAttribute(`position`).needsUpdate=!0,e.geometry.getAttribute(`trailAlpha`).needsUpdate=!0,e.geometry.getAttribute(`fullAlpha`).needsUpdate=!0}function dN(e,t,n,r,i,a,o,s){let c=e.trailAnchor??e.position;n[0]=c[0]-o[0],n[1]=c[1]-o[1],n[2]=c[2]-o[2];let l=r-o[0],u=i-o[1],d=a-o[2];return 1+t.writeVertices(n.subarray(3),l,u,d,s)}function fN(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||hn(o.objectType),d=t.capacity+1,f=new Float32Array(d*3),p=dN(e,t,f,s,c,l,r),m=new Float32Array(d),h=new Float32Array(d);p>0&&eb(m.subarray(0,p),h.subarray(0,p),!0,u);let g=i>1,_=g?cN(d,f,h,m,p,n,i):sN(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 pN(e,t,n=[0,0,0],r=Mg(new Date),i=1){if(e.trailBuffer)return fN(e,e.trailBuffer,t,n,i);let{orbitElements:a,orbitCenter:o,data:s}=e,c,l;if(s.satrec)c=eN(s.satrec,r,s.n/360,512),l=!0;else{if(!a)throw Error(`makeTrail called without orbitElements`);c=null,l=tN(a)}let u=o?.[0]??0,d=o?.[1]??0,f=o?.[2]??0,p=l||s.objectType===G.DWARF_PLANET||s.objectType===G.MOON||s.objectType===G.SPACECRAFT||s.objectType===G.COMET||hn(s.objectType),m=c?$y(e,c,l,u,d,f):[];if(c&&m.length<2)return oN();let h=c?Math.max(m.length,c.length):513,g=new Float32Array(h),_=new Float32Array(h);eb(g.subarray(0,m.length),_.subarray(0,m.length),l,p);let v=u-n[0],y=d-n[1],b=f-n[2],x=new Float32Array(h*3);for(let e=0;e<m.length;e++)x[e*3]=m[e][0]+v,x[e*3+1]=m[e][1]+y,x[e*3+2]=m[e][2]+b;let S=i>1,C=S?cN(h,x,_,g,m.length,t,i):sN(x,_,g,m.length,t);return C.frustumCulled=!1,C.visible=!1,C.userData.orbitCenter=new J(u,d,f),C.userData.trailLocalPositions=c?m:void 0,C.userData.sourceCurve=c??void 0,C.userData.curvePending=c===null,C.userData.isOpenCurve=l,C.userData.useTrail=p,C.userData.curveJd=r,C.userData.elementsJd=a?.epoch??r,S&&(C.userData.isFatLine=!0,C.userData.thinPositions=x,C.userData.thinTrailAlphas=_,C.userData.thinFullAlphas=g),C}function mN(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 hN(e){return e.data.objectType===G.PLANET?4:(e.data.objectType===G.MOON||e.data.objectType===G.DWARF_PLANET)&&t_[e.data.id]?3:1}function gN(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===tn.SPICE_PROBE){if(i.isMinor&&!i.mesh)continue}else if(!i.mesh&&!i.focusUpgraded&&fj(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=pN(e,m_(e.data),n,r,hN(e));t.add(a),i.trail=a}}function _N(e,t,n,r=[0,0,0],i,a){let o=new Map,s=new Map,c=new Map,l=JM();for(let[s,c]of e.bodies.asteroidBodiesByZone){let e=mN(c.values(),i);if(e.length===0)continue;let u=m_(e[0].data),{buckets:d}=y_(s,e,a);for(let e=0;e<d.length;e++){let i=d[e];if(i.length===0)continue;let a=YM(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=Cv(e.layers,o,mN(c.values(),i));if(l.length===0)continue;let{buckets:u}=y_(o,l,a);for(let e=0;e<u.length;e++){let i=u[e];if(i.length===0)continue;let a=YM(i,n,`#ffffff`,r,void 0,e=>m_(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=YM(i,n,m_(i[0].data),r),o=a.material;o.transparent=!1,o.alphaTest=.5,o.depthTest=!0,o.depthWrite=!0,a.visible=!1,c.set(e,a),t.add(a)}return{asteroidPoints:o,spacecraftPoints:s,moonPoints:c}}async function vN(e,t,n,r,i,a,s){let c;try{let t=await fetch(`${Ut()}/v1/systems/${e}.json`);if(!t.ok)return;c=await t.json()}catch{return}let l=[];for(let[u,d]of Object.entries(c)){let c=o([d.texture&&{...d.texture,id:u,tiers:d.tiers},...d.alternates??[]]);c&&s?.credits.registerImagery(`surface`,u,e,c);let f=t.get(u);if(f?.mesh){if(d.orientation){if(fD(f,d.orientation,s,e),d.nut_prec){let e=u.match(/^naif-(-?\d+)$/),t=e?parseInt(e[1],10):null,n=t===null?void 0:Z_(X_(t));n&&(f.body.nutPrec={...d.nut_prec,angles:n})}pC(f.mesh,d.orientation,i,f.body.nutPrec)}if(d.radii&&f.radiusScene>0&&!f.radiiApplied&&!d.displacement?.absolute_radius&&$j(f,d.radii),c?.tiers?.length&&(f.availableTiers=c.tiers,f.availableFrames=c.frames,f.textureBundleId=c.id===u?void 0:c.id,!f.textureTier)){let e=Zj(i,f.availableFrames);l.push(rM(f,`low`,e,r))}l.push(...Wj(u,e,d,f,{textureLoader:r,currentJd:i,ctx:s})),d.rings?.length&&l.push(..._j(u,e,d.rings,d.radii,f,n,a,s))}}await Promise.allSettled(l)}function yN(e,t,n,r){for(let i of t.values())if(r.visibility.isBodyInSystem(i.body,e)){if(nM(i),Kj(i),i.terrainWindow&&i.mesh){i.terrainWindow=null;let e=Q(mn(i.body.data)),t=i.mesh.geometry;i.mesh.geometry=new nu(e,24,24),t.dispose(),i.currentSegments=24}for(let e of i.rings){e.planetShadow?.disable(),n.remove(e.mesh);let t=i.extraObjects.indexOf(e.mesh);t>=0&&i.extraObjects.splice(t,1),oA(e)}i.rings=[],AM(i)}}var bN=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 j_(n)?null:n}load(e){vN(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)yN(e,this.bodyObjects,this.scene,this.ctx);this.pendingUnloads.clear()}}hasPendingUnloads(){return this.pendingUnloads.size>0}},xN=Math.PI/180,SN=class{adjust={rxDeg:0,ryDeg:0,rzDeg:0};_q=new Vi;_adjustQ=new Vi;_tmpQ=new Vi;_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*xN).premultiply(this._tmpQ.setFromAxisAngle(this._axisY,t*xN)).premultiply(this._tmpQ.setFromAxisAngle(this._axisZ,n*xN)),this._q.copy(Zx).multiply(this._adjustQ),this.scene.backgroundRotation.setFromQuaternion(this._q)}},CN=Math.PI/180,wN=ig*CN,TN=Math.cos(wN),EN=Math.sin(wN),DN=5e3,ON=[{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`}],kN=192.85948,AN=27.12825,jN=266.40499,MN=-28.93617,NN=256,PN=[{name:`galactic-plane`,zero:FN(jN,MN,new J).normalize(),pole:FN(kN,AN,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:FN(0,0,new J).normalize(),pole:FN(0,90,new J).normalize(),color:10325247}];function FN(e,t,n){let r=e*CN,i=t*CN,a=Math.cos(i),o=a*Math.cos(r),s=a*Math.sin(r),c=Math.sin(i),l=o,u=s*TN+c*EN,d=-s*EN+c*TN;return n.set(l,d,-u)}function IN(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=`
5514
5514
  <circle cx="0" cy="0" r="14" fill="none" stroke="${r}" stroke-width="1.6"/>
5515
5515
  <line x1="-23" y1="0" x2="-10" y2="0" stroke="${r}" stroke-width="1.6"/>
5516
5516
  <line x1="10" y1="0" x2="23" y2="0" stroke="${r}" stroke-width="1.6"/>
5517
5517
  <line x1="0" y1="-23" x2="0" y2="-10" stroke="${r}" stroke-width="1.6"/>
5518
5518
  <line x1="0" y1="10" x2="0" y2="23" stroke="${r}" stroke-width="1.6"/>
5519
- `;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 FN(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 Vo;c.setAttribute(`position`,new ko(o,3));let l=new Cc(c,new uc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function IN(){let e=new Ra;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of EN){NN(n.raDeg,n.decDeg,t).multiplyScalar(TN);let r=new JO(PN(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of MN){let n=FN(t.zero,t.pole,TN*.999,t.color,jN);n.name=t.name,e.add(n)}return e}function LN(e){e.traverse(e=>{e instanceof JO&&e.element.remove(),e instanceof Cc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var RN=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=IN(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(LN(this.group),null)}},zN=new J,BN=new J,VN=new J,HN=[zN,BN,VN];function UN(e,t,n){return zN.set(1,0,0).applyQuaternion(e).transformDirection(t),BN.set(0,1,0).applyQuaternion(e).transformDirection(t),VN.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:HN,a:n}}function WN(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 GN(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 KN(e,t,n,r,i,a){let[o,s,c]=r.e,[l,u,d]=r.a,f=1/(l*l),p=1/(u*u),m=1/(d*d),h=f*o.x*o.x+p*s.x*s.x+m*c.x*c.x,g=f*o.x*o.y+p*s.x*s.y+m*c.x*c.y,_=f*o.x*o.z+p*s.x*s.z+m*c.x*c.z,v=f*o.y*o.y+p*s.y*s.y+m*c.y*c.y,y=f*o.y*o.z+p*s.y*s.z+m*c.y*c.z,b=f*o.z*o.z+p*s.z*s.z+m*c.z*c.z,x=h*e+g*t+_*n,S=g*e+v*t+y*n,C=_*e+y*t+b*n,w=e*x+t*S+n*C-1,T=i,E=w*h-x*x,D=2*(w*g-x*S),O=w*v-S*S,k=-2*T*(w*_-x*C),A=-2*T*(w*y-S*C),j=4*E*O-D*D,M=(-2*O*k+D*A)/j,ee=(-2*E*A+D*k)/j,N=-n/T;a.ox=M*N-e,a.oy=ee*N-t}var qN=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Vi;items=[];one=[];labelRect={x:0,left:0,right:0,y:0,h:0};constructor(e){this.anchor=e}get active(){return this.canvas!==null}setVisible(e){if(e){if(this.canvas)return;let e=document.createElement(`canvas`);e.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:5`,this.anchor.parentElement?.appendChild(e),this.canvas=e,this.gfx=e.getContext(`2d`)}else this.canvas&&(this.canvas.remove(),this.canvas=null,this.gfx=null)}draw(e,t,n,r,i,a){let o=this.gfx,s=this.canvas;if(!o||!s)return;let c=window.devicePixelRatio||1,l=Math.round(i*c),u=Math.round(a*c);(s.width!==l||s.height!==u)&&(s.width=l,s.height=u),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,i,a),o.font=`10px monospace`,o.textBaseline=`middle`;let d=t.fov*Math.PI/180,f=a/(2*Math.tan(d/2)),p=t.matrixWorldInverse,[m,h,g]=n,_=i*.5,v=a*.5,y=0;for(let o of e.values()){let{label:e,group:s,radiusScene:c}=o;if(!e||c<=0)continue;let[l,u,d]=o.body.position;this.tmp.set(l-m,u-h,d-g).applyMatrix4(p);let b=this.tmp.x,x=this.tmp.y,S=this.tmp.z;if(S>=0||b*b+x*x+S*S<=c*c)continue;let C=XO(this.items,y++,JN),w=!!(o.semiAxesScene&&o.mesh);if(w){let e=UN(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);C.e0.copy(e.e[0]),C.e1.copy(e.e[1]),C.e2.copy(e.e[2]),C.sa[0]=e.a[0],C.sa[1]=e.a[1],C.sa[2]=e.a[2],GN(C.occ,b,x,S,e,f,_,v,o.body.data.id,o.cachedDist)}else C.e0.set(1,0,0),C.e1.set(0,1,0),C.e2.set(0,0,1),C.sa[0]=C.sa[1]=C.sa[2]=c,WN(C.occ,b,x,S,c,f,_,v,o.body.data.id,o.cachedDist);let T=S*S-c*c,E=T<=0,D=E?0:c*f/Math.sqrt(T),O=E||D>=16;this.tmp.set(l-m,u-h,d-g).project(t),C.cx=(this.tmp.x*.5+.5)*i,C.cy=(-this.tmp.y*.5+.5)*a,ck(o,t,n,i,a,this.labelRect),C.hx=this.labelRect.x,C.hy=this.labelRect.y,C.id=o.body.data.id,C.camX=b,C.camY=x,C.camZ=S,C.worldR=c,C.dist=o.cachedDist,C.isEllipsoid=w,C.degenerate=E,C.isOccluder=O,C.meshHidden=!s.visible,C.labelVisible=e.visible,C.maximized=o.labelMaximized!==!1,C.focused=o.body.data.id===r,C.occludedBy=-1}for(let e=0;e<y;e++){let t=this.items[e];for(let e=0;e<y;e++){let n=this.items[e];if(!(!n.isOccluder||n.id===t.id)&&(this.one[0]=n.occ,this.one.length=1,ok(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(),ZN(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)}}XN(o,a)}strokeLimb(e,t,n,r,i){let{camX:a,camY:o,camZ:s,e0:c,e1:l,e2:u,sa:d}=t,f=(a*c.x+o*c.y+s*c.z)/d[0],p=(a*l.x+o*l.y+s*l.z)/d[1],m=(a*u.x+o*u.y+s*u.z)/d[2],h=f*f+p*p+m*m;if(h<=1)return!1;let g=Math.sqrt(h),_=(h-1)/h,v=Math.sqrt(h-1)/g,y=f*_,b=p*_,x=m*_,S=f/g,C=p/g,w=m/g,T=0,E=1;Math.abs(w)>.9&&(T=1,E=0);let D=C*E-w*0,O=w*T-S*E,k=S*0-C*T,A=Math.hypot(D,O,k)||1;D/=A,O/=A,k/=A;let j=C*k-w*O,M=w*D-S*k,ee=S*O-C*D,N=n.projectionMatrix.elements,te=!1;for(let t=0;t<=72;t++){let n=t/72*Math.PI*2,a=Math.cos(n),o=Math.sin(n),s=y+v*(a*D+o*j),f=b+v*(a*O+o*M),p=x+v*(a*k+o*ee),m=d[0]*s*c.x+d[1]*f*l.x+d[2]*p*u.x,h=d[0]*s*c.y+d[1]*f*l.y+d[2]*p*u.y,g=d[0]*s*c.z+d[1]*f*l.z+d[2]*p*u.z,_=N[3]*m+N[7]*h+N[11]*g+N[15];if(_<=1e-6){te=!1;continue}let S=(N[0]*m+N[4]*h+N[8]*g+N[12])/_,C=(N[1]*m+N[5]*h+N[9]*g+N[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;te?e.lineTo(w,T):(e.moveTo(w,T),te=!0)}return!0}dispose(){this.setVisible(!1)}};function JN(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:ek(),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 YN=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function XN(e,t){let n=t-8-(YN.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of YN)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 ZN(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 QN(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 $N="function e(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}function t(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>700)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function n(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}const r=149597870.7,i=23.4392911;86400**2/r**3,1/r,Math.cos(Math.PI/180*i),Math.sin(Math.PI/180*i);const a=Math.PI,o=a*2,s=a/180;180/a;const c=6378.135,l=60/Math.sqrt(c*c*c/398600.8),u=c*l/60,d=1/l,f=.001082616,p=-253881e-11/f,m=2/3,ee=1440/(2*a);function te(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function h(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function g(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return h(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return h(e,t,n,r,i,a,o)}function ne(e,t){let{e3:n,ee2:r,peo:i,pgho:s,pho:c,pinco:l,plo:u,se2:d,se3:f,sgh2:p,sgh3:m,sgh4:ee,sh2:te,sh3:h,si2:g,si3:ne,sl2:_,sl3:v,sl4:y,t:b,xgh2:re,xgh3:ie,xgh4:x,xh2:ae,xh3:S,xi2:C,xi3:w,xl2:T,xl3:E,xl4:D,zmol:O,zmos:k}=e,{init:A,opsmode:j}=t,{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),X=fe+2*.01675*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*Y,ge=p*U+m*W+ee*Y,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),X=fe+2*.0549*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*Y,be=re*U+ie*W+x*Y,xe=ae*U+S*W;return G=pe+_e,J=me+ve,le=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,le-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,se+=K,N+=q,P+=le):(z=Math.sin(N),ce=Math.cos(N),F=R*z,I=R*ce,B=q*ce+J*L*z,V=-q*z+J*L*ce,F+=B,I+=V,N%=o,N<0&&j===`a`&&(N+=o),ue=P+se+L*N,H=le+K-J*N*R,ue+=H,de=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(de-N)>a&&(N<de?N+=o:N-=o),P+=le,se=ue-P-L*N)),{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}}function _(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:s,np:c}=e,l,u,d,f,p,m,ee,te,h,g,ne,_,v,y,b,re,ie,x,ae,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be=.01675,xe=.0549,Se=c,Ce=n,we=Math.sin(s),Te=Math.cos(s),Ee=Math.sin(r),Q=Math.cos(r),De=Math.sin(a),Oe=Math.cos(a),$=Ce*Ce,ke=1-$,Ae=Math.sqrt(ke),je=t+18261.5+i/1440,Me=(4.523602-.00092422029*je)%o,Ne=Math.sin(Me),Pe=Math.cos(Me),Fe=.91375164-.03568096*Pe,Ie=Math.sqrt(1-Fe*Fe),Le=.089683511*Ne/Ie,Re=Math.sqrt(1-Le*Le),ze=5.8351514+.001944368*je,Be=.39785416*Ne/Ie,Ve=Re*Pe+.91744867*Le*Ne;Be=Math.atan2(Be,Ve),Be+=ze-Me;let He=Math.cos(Be),Ue=Math.sin(Be);S=.1945905,C=-.98088458,E=.91744867,D=.39785416,w=Te,T=we,ne=29864797e-13;let We=1/Se,Ge=0;for(;Ge<2;)Ge+=1,l=S*w+C*E*T,d=-C*w+S*E*T,ee=-S*T+C*E*w,te=C*D,h=C*T+S*E*w,g=S*D,u=Oe*ee+De*te,f=Oe*h+De*g,p=-De*ee+Oe*te,m=-De*h+Oe*g,_=l*Q+u*Ee,v=d*Q+f*Ee,y=-l*Ee+u*Q,b=-d*Ee+f*Q,re=p*Ee,ie=m*Ee,x=p*Q,ae=m*Q,_e=12*_*_-3*y*y,ve=24*_*v-6*y*b,ye=12*v*v-3*b*b,ue=3*(l*l+u*u)+_e*$,de=6*(l*d+u*f)+ve*$,X=3*(d*d+f*f)+ye*$,fe=-6*l*p+$*(-24*_*x-6*y*re),pe=-6*(l*m+d*p)+$*(-24*(v*x+_*ae)+-6*(y*ie+b*re)),me=-6*d*m+$*(-24*v*ae-6*b*ie),he=6*u*p+$*(24*_*re-6*y*x),ge=6*(f*p+u*m)+$*(24*(v*re+_*ie)-6*(b*x+y*ae)),Z=6*f*m+$*(24*v*ie-6*b*ae),ue=ue+ue+ke*_e,de=de+de+ke*ve,X=X+X+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,le=v*y+_*b,Y=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=le,N=Y,se=ue,P=de,F=X,I=fe,L=pe,R=me,ce=he,z=ge,B=Z,V=_e,H=ve,U=ye,S=He,C=Ue,E=Fe,D=Ie,w=Re*Te+Le*we,T=we*Re-Te*Le,ne=4.7968065e-7);let Ke=(4.7199672+(.2299715*je-ze))%o,qe=(6.2565837+.017201977*je)%o,Je=2*O*M,Ye=2*O*N,Xe=2*k*L,Ze=2*k*(R-I),Qe=-2*A*P,$e=-2*A*(F-se),et=-2*A*(-21-9*$)*be,tt=2*j*H,nt=2*j*(U-V),rt=-18*j*be,it=-2*k*z,at=-2*k*(B-ce),ot=2*W*le,st=2*W*Y,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*de,dt=-2*K*(X-ue),ft=-2*K*(-21-9*$)*xe,pt=2*q*ve,mt=2*q*(ye-_e),ht=-18*q*xe,gt=-2*G*ge,_t=-2*G*(Z-he);return{snodm:we,cnodm:Te,sinim:De,cosim:Oe,sinomm:Ee,cosomm:Q,day:je,e3:st,ee2:ot,em:Ce,emsq:$,gam:ze,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Ae,se2:Je,se3:Ye,sgh2:tt,sgh3:nt,sgh4:rt,sh2:it,sh3:at,si2:Xe,si3:Ze,sl2:Qe,sl3:$e,sl4:et,s1:W,s2:G,s3:K,s4:q,s5:J,s6:le,s7:Y,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:se,sz2:P,sz3:F,sz11:I,sz12:L,sz13:R,sz21:ce,sz22:z,sz23:B,sz31:V,sz32:H,sz33:U,xgh2:pt,xgh3:mt,xgh4:ht,xh2:gt,xh3:_t,xi2:ct,xi3:lt,xl2:ut,xl3:dt,xl4:ft,nm:Se,z1:ue,z2:de,z3:X,z11:fe,z12:pe,z13:me,z21:he,z22:ge,z23:Z,z31:_e,z32:ve,z33:ye,zmol:Ke,zmos:qe}}function v(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:s,s4:c,s5:u,sinim:d,ss1:f,ss2:p,ss3:ee,ss4:te,ss5:h,sz1:g,sz3:ne,sz11:_,sz13:v,sz21:y,sz23:b,sz31:re,sz33:ie,t:x,tc:ae,gsto:S,mo:C,mdot:w,no:T,nodeo:E,nodedot:D,xpidot:O,z1:k,z3:A,z11:j,z13:oe,z21:M,z23:N,z31:se,z33:P,ecco:F,eccsq:I}=e,{emsq:L,em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}=e,we,Te,Ee,Q,De,Oe,$,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et=.0043752690880113,tt=.00015835218,nt=119459e-10;U=0,V<.0052359877&&V>.0034906585&&(U=1),V>=.00826&&V<=.00924&&R>=.5&&(U=2);let rt=f*nt*h,it=p*nt*(_+v),at=-nt*ee*(g+ne-14-6*L),ot=te*nt*(re+ie-6),st=-nt*p*(y+b);(z<.052359877||z>a-.052359877)&&(st=0),d!==0&&(st/=d);let ct=ot-t*st;pe=rt+r*tt*u,me=it+i*tt*(j+oe),he=at-tt*s*(k+A-14-6*L);let lt=c*tt*(se+P-6),ut=-tt*i*(M+N);(z<.052359877||z>a-.052359877)&&(ut=0),Z=ct+lt,ge=st,d!==0&&(Z-=t/d*ut,ge+=ut/d);let dt=(S+ae*et)%o;if(R+=pe*x,z+=me*x,ce+=Z*x,H+=ge*x,B+=he*x,U!==0){if(Ze=(V/l)**m,U===2){Qe=t*t;let e=R;R=F;let n=L;L=I,$e=R*L,Fe=-.306-(R-.64)*.44,R<=.65?(Ie=3.616-13.247*R+16.29*L,Re=-19.302+117.39*R-228.419*L+156.591*$e,ze=-18.9068+109.7927*R-214.6334*L+146.5816*$e,Be=-41.122+242.694*R-471.094*L+313.953*$e,Ve=-146.407+841.88*R-1629.014*L+1083.435*$e,He=-532.114+3017.977*R-5740.032*L+3708.276*$e):(Ie=-72.099+331.819*R-508.738*L+266.724*$e,Re=-346.844+1582.851*R-2415.925*L+1246.113*$e,ze=-342.585+1554.908*R-2366.899*L+1215.972*$e,Be=-1052.797+4758.686*R-7193.992*L+3651.957*$e,Ve=-3581.69+16178.11*R-24462.77*L+12422.52*$e,He=R>.715?-5149.66+29936.92*R-54087.36*L+31324.56*$e:1464.74-4664.75*R+3763.64*L),R<.7?(Ge=-919.2277+4988.61*R-9064.77*L+5542.21*$e,Ue=-822.71072+4568.6173*R-8491.4146*L+5337.524*$e,We=-853.666+4690.25*R-8624.77*L+5341.4*$e):(Ge=-37995.78+161616.52*R-229838.2*L+109377.94*$e,Ue=-51752.104+218913.95*R-309468.16*L+146349.42*$e,We=-40023.88+170470.89*R-242699.48*L+115605.82*$e),Ke=d*d,we=.75*(1+2*t+Qe),Te=1.5*Ke,Q=1.875*d*(1-2*t-3*Qe),De=-1.875*d*(1+2*t-3*Qe),$=35*Ke*we,ke=39.375*Ke*Ke,Ae=9.84375*d*(Ke*(1-2*t-5*Qe)+.33333333*(-2+4*t+6*Qe)),je=d*(4.92187512*Ke*(-2-4*t+10*Qe)+6.56250012*(1+2*t-3*Qe)),Me=29.53125*d*(2-8*t+Qe*(-12+8*t+10*Qe)),Ne=29.53125*d*(-2-8*t+Qe*(12+8*t-10*Qe)),Ye=V*V,Xe=Ze*Ze,Je=3*Ye*Xe,qe=Je*17891679e-13,G=qe*we*Fe,K=qe*Te*Ie,Je*=Ze,qe=Je*3.7393792e-7,q=qe*Q*Re,J=qe*De*ze,Je*=Ze,qe=2*Je*7.3636953e-9,le=qe*$*Be,Y=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,ue=qe*Ae*He,de=qe*je*We,qe=2*Je*2.1765803e-9,X=qe*Me*Ue,fe=qe*Ne*Ge,xe=(C+E+E-(dt+dt))%o,be=w+he+2*(D+ge-et)-T,R=e,L=n}U===1&&(Pe=1+L*(-2.5+.8125*L),Re=1+2*L,Le=1+L*(-6+6.60937*L),we=.75*(1+t)*(1+t),Ee=.9375*d*d*(1+3*t)-.75*(1+t),Oe=1+t,Oe*=1.875*Oe*Oe,_e=3*V*V*Ze*Ze,ve=2*_e*we*Pe*17891679e-13,ye=3*_e*Oe*Le*2.2123015e-7*Ze,_e=_e*Ee*Re*21460748e-13*Ze,xe=(C+E+n-dt)%o,be=w+O+he+Z+ge-(T+et)),Se=xe,Ce=T,W=0,V=T+0}return{em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dndt:0,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}}function y(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*s/240%o,n<0&&(n+=o),n}function b(e,t,n,r,i,a,o){return e instanceof Date?y(g(e)):y(t===void 0?e:g(e,t,n,r,i,a,o))}function re(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,s=t*t,c=1-s,u=Math.sqrt(c),d=Math.cos(r),p=d*d,ee=(l/a)**m,te=.75*f*(3*p-1)/(u*c),h=te/(ee*ee),g=ee*(1-h*h-h*(1/3+134*h*h/81));h=te/(g*g),a/=1+h;let ne=(l/a)**m,_=Math.sin(r),v=ne*c,y=1-5*p,re=-y-p-p,ie=1/ne,x=v*v,ae=ne*(1-t),S;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+o;S=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%o,S<0&&(S+=o)}else S=b(n+2433281.5);return{no:a,method:`n`,ainv:ie,ao:ne,con41:re,con42:y,cosio:d,cosio2:p,eccsq:s,omeosq:c,posq:x,rp:ae,rteosq:u,sinio:_,gsto:S}}function ie(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:s,d4422:c,d5220:l,d5232:u,d5421:d,d5433:f,dedt:p,del1:m,del2:ee,del3:te,didt:h,dmdt:g,dnodt:ne,domdt:_,argpo:v,argpdot:y,t:b,tc:re,gsto:ie,xfact:x,xlamo:ae,no:S}=e,{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,nm:j}=e,oe=.13130908,M=2.8843198,N=.37448087,se=5.7686396,P=.95240898,F=1.8014998,I=1.050833,L=4.4108898,R=259200,ce,z,B,V,H,U,W,G,K=0,q=0,J=(ie+re*.0043752690880113)%o;if(w+=p*b,E+=h*b,T+=_*b,A+=ne*b,O+=g*b,t!==0){(C===0||b*C<=0||Math.abs(b)<Math.abs(C))&&(C=0,k=S,D=ae),ce=b>0?720:-720;let e=381;for(;e===381;)t===2?(G=v+y*C,B=G+G,z=D+D,W=n*Math.sin(B+D-se)+r*Math.sin(D-se)+i*Math.sin(G+D-P)+a*Math.sin(-G+D-P)+s*Math.sin(B+z-F)+c*Math.sin(z-F)+l*Math.sin(G+D-I)+u*Math.sin(-G+D-I)+d*Math.sin(G+z-L)+f*Math.sin(-G+z-L),H=k+x,U=n*Math.cos(B+D-se)+r*Math.cos(D-se)+i*Math.cos(G+D-P)+a*Math.cos(-G+D-P)+l*Math.cos(G+D-I)+u*Math.cos(-G+D-I)+2*(s*Math.cos(B+z-F)+c*Math.cos(z-F)+d*Math.cos(G+z-L)+f*Math.cos(-G+z-L)),U*=H):(W=m*Math.sin(D-oe)+ee*Math.sin(2*(D-M))+te*Math.sin(3*(D-N)),H=k+x,U=m*Math.cos(D-oe)+2*ee*Math.cos(2*(D-M))+3*te*Math.cos(3*(D-N)),U*=H),Math.abs(b-C)>=720?e=381:(q=b-C,e=0),e===381&&(D+=H*ce+W*R,k+=W*ce+U*R,C+=ce);j=k+W*q+U*q*q*.5,V=D+H*q+W*q*q*.5,t===1?(O=V-A-T+J,K=j-S):(O=V-2*A+2*J,K=j-S),j=S+K}return{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,dndt:K,nm:j}}var x;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})(x||={});function ae(e,t){let n,r,i,s,d,ee,te,h,g,_,v,y,b,re,ae,S,C,w,T,E,D,O,k,A,j,oe,M;e.t=t,e.error=x.None;let N=e.mo+e.mdot*e.t,se=e.argpo+e.argpdot*e.t,P=e.nodeo+e.nodedot*e.t;g=se,D=N;let F=e.t*e.t;if(k=P+e.nodecf*F,C=1-e.cc1*e.t,w=e.bstar*e.cc4*e.t,T=e.t2cof*F,e.isimp!==1){te=e.omgcof*e.t;let t=1+e.eta*Math.cos(N);ee=e.xmcof*(t*t*t-e.delmo),S=te+ee,D=N+S,g=se-S,y=F*e.t,b=y*e.t,C=C-e.d2*F-e.d3*y-e.d4*b,w+=e.bstar*e.cc5*(Math.sin(D)-e.sinmao),T=T+e.t3cof*y+b*(e.t4cof+e.t*e.t5cof)}O=e.no;let I=e.ecco;if(E=e.inclo,e.method===`d`){re=e.t;let t=ie({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:re,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:I,argpm:g,inclm:E,xli:e.xli,mm:D,xni:e.xni,nodem:k,nm:O});({em:I,argpm:g,inclm:E,mm:D,nodem:k,nm:O}=t)}if(O<=0)return e.error=x.MeanMotionBelowZero,null;let L=(l/O)**m*C*C;if(O=l/L**1.5,I-=w,I>=1||I<-.001)return e.error=x.MeanEccentricityOutOfRange,null;I<1e-6&&(I=1e-6),D+=e.no*T,j=D+g+k,k%=o,g%=o,j%=o,D=(j-g-k)%o;let R={am:L,em:I,im:E,Om:k,om:g,mm:D,nm:O},ce=Math.sin(E),z=Math.cos(E),B=I;if(A=E,_=g,M=k,oe=D,s=ce,i=z,e.method===`d`){let t=ne(e,{inclo:e.inclo,init:`n`,ep:B,inclp:A,nodep:M,argpp:_,mp:oe,opsmode:e.operationmode});if({ep:B,nodep:M,argpp:_,mp:oe}=t,A=t.inclp,A<0&&(A=-A,M+=a,_-=a),B<0||B>1)return e.error=x.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(s=Math.sin(A),i=Math.cos(A),e.aycof=-.5*p*s,Math.abs(i+1)>15e-13?e.xlcof=-.25*p*s*(3+5*i)/(1+i):e.xlcof=-.25*p*s*(3+5*i)/15e-13);let V=B*Math.cos(_);S=1/(L*(1-B*B));let H=B*Math.sin(_)+S*e.aycof,U=(oe+_+M+S*e.xlcof*V-M)%o;h=U,ae=9999.9;let W=1;for(;Math.abs(ae)>=1e-12&&W<=10;)r=Math.sin(h),n=Math.cos(h),ae=1-n*V-r*H,ae=(U-H*n+V*r-h)/ae,Math.abs(ae)>=.95&&(ae=ae>0?.95:-.95),h+=ae,W+=1;let G=V*n+H*r,K=V*r-H*n,q=V*V+H*H,J=L*(1-q);if(J<0)return e.error=x.SemiLatusRectumBelowZero,null;let le=L*(1-G),Y=Math.sqrt(L)*K/le,ue=Math.sqrt(J)/le,de=Math.sqrt(1-q);S=K/(1+de);let X=L/le*(r-H-V*S),fe=L/le*(n-V+H*S);v=Math.atan2(X,fe);let pe=(fe+fe)*X,me=1-2*X*X;S=1/J;let he=.5*f*S,ge=he*S;e.method===`d`&&(d=i*i,e.con41=3*d-1,e.x1mth2=1-d,e.x7thm1=7*d-1);let Z=le*(1-1.5*ge*de*e.con41)+.5*he*e.x1mth2*me;if(Z<1)return e.error=x.Decayed,null;v-=.25*ge*e.x7thm1*pe;let _e=M+1.5*ge*i*pe,ve=A+1.5*ge*i*s*me,ye=Y-O*he*e.x1mth2*pe/l,be=ue+O*he*(e.x1mth2*me+1.5*e.con41)/l,xe=Math.sin(v),Se=Math.cos(v),Ce=Math.sin(_e),we=Math.cos(_e),Te=Math.sin(ve),Ee=Math.cos(ve),Q=-Ce*Ee,De=we*Ee,Oe=Q*xe+we*Se,$=De*xe+Ce*Se,ke=Te*xe,Ae=Q*Se-we*xe,je=De*Se-Ce*xe,Me=Te*Se;return{position:{x:Z*Oe*c,y:Z*$*c,z:Z*ke*c},velocity:{x:(ye*Oe+be*Ae)*u,y:(ye*$+be*je)*u,z:(ye*ke+be*Me)*u},meanElements:R}}function S(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:o,xecco:s,xargpo:l,xinclo:u,xmo:ee,xno:te,xnodeo:h}=t,g,y,b,ie,x,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,Q=e;Q.isimp=0,Q.method=`n`,Q.aycof=0,Q.con41=0,Q.cc1=0,Q.cc4=0,Q.cc5=0,Q.d2=0,Q.d3=0,Q.d4=0,Q.delmo=0,Q.eta=0,Q.argpdot=0,Q.omgcof=0,Q.sinmao=0,Q.t=0,Q.t2cof=0,Q.t3cof=0,Q.t4cof=0,Q.t5cof=0,Q.x1mth2=0,Q.x7thm1=0,Q.mdot=0,Q.nodedot=0,Q.xlcof=0,Q.xmcof=0,Q.nodecf=0,Q.irez=0,Q.d2201=0,Q.d2211=0,Q.d3210=0,Q.d3222=0,Q.d4410=0,Q.d4422=0,Q.d5220=0,Q.d5232=0,Q.d5421=0,Q.d5433=0,Q.dedt=0,Q.del1=0,Q.del2=0,Q.del3=0,Q.didt=0,Q.dmdt=0,Q.dnodt=0,Q.domdt=0,Q.e3=0,Q.ee2=0,Q.peo=0,Q.pgho=0,Q.pho=0,Q.pinco=0,Q.plo=0,Q.se2=0,Q.se3=0,Q.sgh2=0,Q.sgh3=0,Q.sgh4=0,Q.sh2=0,Q.sh3=0,Q.si2=0,Q.si3=0,Q.sl2=0,Q.sl3=0,Q.sl4=0,Q.gsto=0,Q.xfact=0,Q.xgh2=0,Q.xgh3=0,Q.xgh4=0,Q.xh2=0,Q.xh3=0,Q.xi2=0,Q.xi3=0,Q.xl2=0,Q.xl3=0,Q.xl4=0,Q.xlamo=0,Q.zmol=0,Q.zmos=0,Q.atime=0,Q.xli=0,Q.xni=0,Q.bstar=o,Q.ecco=s,Q.argpo=l,Q.inclo=u,Q.mo=ee,Q.no=te,Q.nodeo=h,Q.operationmode=n,78/c+1;let De=42/c;De*De*De*De,Q.init=`y`,Q.t=0;let Oe=re({satn:r,ecco:Q.ecco,epoch:i,inclo:Q.inclo,no:Q.no,method:Q.method,opsmode:Q.operationmode}),{ao:$,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=Oe;if(Q.no=Oe.no,Q.con41=Oe.con41,Q.gsto=Oe.gsto,Q.a=(Q.no*d)**(-2/3),Q.alta=Q.a*(1+Q.ecco)-1,Q.altp=Q.a*(1-Q.ecco)-1,Q.error=0,Ne>=0||Q.no>=0){if(Q.isimp=0,Fe<1.034492841559484&&(Q.isimp=1),B=1.0122292801892716,F=1.880279159015271e-9,N=(Fe-1)*c,N<156){B=N-78,N<98&&(B=20);let e=(120-B)/c;F=e*e*e*e,B=B/c+1}se=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,P=Math.abs(1-O),S=F*Z**4,C=S/P**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/P*Q.con41*(8+3*O*(8+O))),Q.cc1=Q.bstar*ie,x=0,Q.ecco>1e-4&&(x=-2*S*Z*p*Q.no*Le/Q.ecco),Q.x1mth2=1-je,Q.cc4=2*Q.no*C*$*Ne*(Q.eta*(2+.5*O)+Q.ecco*(.5+2*O)-f*Z/($*P)*(-3*Q.con41*(1-2*D+O*(1.5-.5*D))+.75*Q.x1mth2*(2*O-D*(1+O))*Math.cos(2*Q.argpo))),Q.cc5=2*C*$*Ne*(1+2.75*(O+D)+D*O),w=je*je,me=1.5*f*se*Q.no,he=.5*me*f*se,ge=-.46875*-165597e-11*se*se*Q.no,Q.mdot=Q.no+.5*me*Ie*Q.con41+.0625*he*Ie*(13-78*je+137*w),Q.argpdot=-.5*me*ke+.0625*he*(7-114*je+395*w)+ge*(3-36*je+49*w),ve=-me*Ae,Q.nodedot=ve+(.5*he*(4-19*je)+2*ge*(3-7*je))*Ae,_e=Q.argpdot+Q.nodedot,Q.omgcof=Q.bstar*x*Math.cos(Q.argpo),Q.xmcof=0,Q.ecco>1e-4&&(Q.xmcof=-m*S*Q.bstar/D),Q.nodecf=3.5*Ne*ve*Q.cc1,Q.t2cof=1.5*Q.cc1,Math.abs(Ae+1)>15e-13?Q.xlcof=-.25*p*Le*(3+5*Ae)/(1+Ae):Q.xlcof=-.25*p*Le*(3+5*Ae)/15e-13,Q.aycof=-.5*p*Le;let e=1+Q.eta*Math.cos(Q.mo);if(Q.delmo=e*e*e,Q.sinmao=Math.sin(Q.mo),Q.x7thm1=7*je-1,2*a/Q.no>=225){Q.method=`d`,Q.isimp=1,fe=0,j=Q.inclo;let e=_({epoch:i,ep:Q.ecco,argpp:Q.argpo,tc:fe,inclp:Q.inclo,nodep:Q.nodeo,np:Q.no,e3:Q.e3,ee2:Q.ee2,peo:Q.peo,pgho:Q.pgho,pho:Q.pho,pinco:Q.pinco,plo:Q.plo,se2:Q.se2,se3:Q.se3,sgh2:Q.sgh2,sgh3:Q.sgh3,sgh4:Q.sgh4,sh2:Q.sh2,sh3:Q.sh3,si2:Q.si2,si3:Q.si3,sl2:Q.sl2,sl3:Q.sl3,sl4:Q.sl4,xgh2:Q.xgh2,xgh3:Q.xgh3,xgh4:Q.xgh4,xh2:Q.xh2,xh3:Q.xh3,xi2:Q.xi2,xi3:Q.xi3,xl2:Q.xl2,xl3:Q.xl3,xl4:Q.xl4,zmol:Q.zmol,zmos:Q.zmos});Q.e3=e.e3,Q.ee2=e.ee2,Q.peo=e.peo,Q.pgho=e.pgho,Q.pho=e.pho,Q.pinco=e.pinco,Q.plo=e.plo,Q.se2=e.se2,Q.se3=e.se3,Q.sgh2=e.sgh2,Q.sgh3=e.sgh3,Q.sgh4=e.sgh4,Q.sh2=e.sh2,Q.sh3=e.sh3,Q.si2=e.si2,Q.si3=e.si3,Q.sl2=e.sl2,Q.sl3=e.sl3,Q.sl4=e.sl4,{sinim:y,cosim:g,em:T,emsq:E,s1:I,s2:L,s3:R,s4:ce,s5:z,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X}=e,Q.xgh2=e.xgh2,Q.xgh3=e.xgh3,Q.xgh4=e.xgh4,Q.xh2=e.xh2,Q.xh3=e.xh3,Q.xi2=e.xi2,Q.xi3=e.xi3,Q.xl2=e.xl2,Q.xl3=e.xl3,Q.xl4=e.xl4,Q.zmol=e.zmol,Q.zmos=e.zmos,{nm:M,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee}=e;let t=ne(Q,{inclo:j,init:Q.init,ep:Q.ecco,inclp:Q.inclo,nodep:Q.nodeo,argpp:Q.argpo,mp:Q.mo,opsmode:Q.operationmode});Q.ecco=t.ep,Q.inclo=t.inclp,Q.nodeo=t.nodep,Q.argpo=t.argpp,Q.mo=t.mp,k=0,A=0,oe=0;let n=v({cosim:g,emsq:E,argpo:Q.argpo,s1:I,s2:L,s3:R,s4:ce,s5:z,sinim:y,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X,t:Q.t,tc:fe,gsto:Q.gsto,mo:Q.mo,mdot:Q.mdot,no:Q.no,nodeo:Q.nodeo,nodedot:Q.nodedot,xpidot:_e,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee,ecco:Q.ecco,eccsq:Me,em:T,argpm:k,inclm:j,mm:oe,nm:M,nodem:A,irez:Q.irez,atime:Q.atime,d2201:Q.d2201,d2211:Q.d2211,d3210:Q.d3210,d3222:Q.d3222,d4410:Q.d4410,d4422:Q.d4422,d5220:Q.d5220,d5232:Q.d5232,d5421:Q.d5421,d5433:Q.d5433,dedt:Q.dedt,didt:Q.didt,dmdt:Q.dmdt,dnodt:Q.dnodt,domdt:Q.domdt,del1:Q.del1,del2:Q.del2,del3:Q.del3,xfact:Q.xfact,xlamo:Q.xlamo,xli:Q.xli,xni:Q.xni});Q.irez=n.irez,Q.atime=n.atime,Q.d2201=n.d2201,Q.d2211=n.d2211,Q.d3210=n.d3210,Q.d3222=n.d3222,Q.d4410=n.d4410,Q.d4422=n.d4422,Q.d5220=n.d5220,Q.d5232=n.d5232,Q.d5421=n.d5421,Q.d5433=n.d5433,Q.dedt=n.dedt,Q.didt=n.didt,Q.dmdt=n.dmdt,Q.dnodt=n.dnodt,Q.domdt=n.domdt,Q.del1=n.del1,Q.del2=n.del2,Q.del3=n.del3,Q.xfact=n.xfact,Q.xlamo=n.xlamo,Q.xli=n.xli,Q.xni=n.xni}Q.isimp!==1&&(b=Q.cc1*Q.cc1,Q.d2=4*$*Z*b,pe=Q.d2*Z*Q.cc1/3,Q.d3=(17*$+B)*pe,Q.d4=.5*pe*$*Z*(221*$+31*B)*Q.cc1,Q.t3cof=Q.d2+2*b,Q.t4cof=.25*(3*Q.d3+Q.cc1*(12*Q.d2+10*b)),Q.t5cof=.2*(3*Q.d4+12*Q.cc1*Q.d3+6*Q.d2*Q.d2+15*b*(2*Q.d2+b)))}ae(Q,0),Q.init=`n`}function C(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,c=Number(e.MEAN_MOTION_DOT),l=Number(e.MEAN_MOTION_DDOT);c/=ee*1440,l/=ee*1440*1440;let u=Number(e.BSTAR),d=Number(e.INCLINATION)*s,f=Number(e.RA_OF_ASC_NODE)*s,p=Number(e.ECCENTRICITY),m=Number(e.ARG_OF_PERICENTER)*s,h=Number(e.MEAN_ANOMALY)*s,ne=Number(e.MEAN_MOTION)/ee,{mon:_,day:v,hr:y,minute:b,sec:re}=te(i,o),ie=g(i,_,v,y,b,re),x={error:0,satnum:n,epochyr:a,epochdays:o,ndot:c,nddot:l,bstar:u,inclo:d,nodeo:f,ecco:p,argpo:m,mo:h,no:ne,jdsatepoch:ie};return S(x,{opsmode:t,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}3*Float64Array.BYTES_PER_ELEMENT;const w=Math.PI/180;Math.cos(i*w),Math.sin(i*w);function T(e){return new Date((e-2440587.5)*864e5).toISOString()}function E(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:T(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===x.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}const D=Math.PI/180,O=Math.cos(i*D),k=Math.sin(i*D),A=10/r;function j(e,t,n,r,i){return!isFinite(Math.fround(n))||!isFinite(Math.fround(r))||!isFinite(Math.fround(i))?!1:(e[t*3]=n,e[t*3+1]=r,e[t*3+2]=i,!0)}function oe(r,i,a,o,s,c,l,u,d,f=null,p=0){if(i<r.validityStart||i>r.validityEnd)return 0;let{count:m,kind:ee,equatorial:te,a:h,e:g,i:ne,om:_,w:v,ma:y,n:b,epoch:re,q:ie,tp:S,satrec:C,flags:w,visibleFromDays:T}=r,oe=p!==0&&r.applyFlagFilter,M=r.pickBase,N=d.length/3|0,se=i-2451545,P=0;for(let F=0;F<m&&!(P>=N);F++){let m=ee[F];if(m===0||T[F]>se||oe&&(w[F]&p)!==p)continue;if(m===3){let e=C[F];if(!e){if(e=E({noradCatId:r.satnum[F],epochJd:re[F],meanMotion:b[F]/360,eccentricity:g[F],inclination:ne[F],raOfAscNode:_[F],argOfPericenter:v[F],meanAnomaly:y[F],bstar:r.bstar[F],meanMotionDot:r.ndot[F],meanMotionDdot:r.nddot[F],elementSetNo:0,revAtEpoch:0}),!e){ee[F]=0;continue}C[F]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x,m=n.position.y,te=n.position.z,h=p*A,ie=m*A,S=te*A,w=ie*O+S*k,T=-ie*k+S*O,D=h,oe=T,N=-w;if(!j(d,P,a+D-c,o+oe-l,s+N-u))continue;if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++;continue}let N,I,L=g[F],R=ne[F],ce=_[F],z=v[F];if(m===2){let e=n(ie[F],S[F],i);if(!e)continue;N=e.r*Math.cos(e.nu),I=e.r*Math.sin(e.nu)}else{let n=h[F];if(!isFinite(n)||!isFinite(L)||!isFinite(y[F])||!isFinite(b[F]))continue;let r=i-re[F],a=(y[F]+b[F]*r)*D,o,s;if(L<1||n>0){let t=Math.min(L,.9999999),r=e(a,t),i=Math.sqrt(1-t*t)*Math.sin(r)/(1-t*Math.cos(r)),c=(Math.cos(r)-t)/(1-t*Math.cos(r));o=Math.atan2(i,c),s=n*(1-t*Math.cos(r))}else{let e=t(a,L);if(!isFinite(e))continue;let r=L*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(L*L-1)*Math.sinh(e)/r,c=(L-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-L*Math.cosh(e))}N=s*Math.cos(o),I=s*Math.sin(o)}if(!isFinite(N)||!isFinite(I))continue;let B=Math.cos(z*D),V=Math.sin(z*D),H=Math.cos(R*D),U=Math.sin(R*D),W=Math.cos(ce*D),G=Math.sin(ce*D),K=(W*B-G*V*H)*N+(-W*V-G*B*H)*I,q=(G*B+W*V*H)*N+(-G*V+W*B*H)*I,J=V*U*N+B*U*I;if(te[F]){let e=q*O+J*k,t=-q*k+J*O;q=e,J=t}let le=K*10,Y=J*10,ue=-q*10;if(j(d,P,a+le-c,o+Y-l,s+ue-u)){if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++}}return P}const M=new Map;self.onmessage=e=>{let t=e.data;if(t.type===`ping`){self.postMessage({type:`pong`});return}if(t.type===`rewireDelta`){if(t.remove)for(let e of t.remove)M.delete(e);for(let e of t.set)M.set(e.id,e.cols);return}if(t.type===`tick`){let e=[],n=[],[r,i,a]=t.basis;for(let o of t.groups){let s=M.get(o.id);if(!s){e.push({id:o.id,count:0,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer);continue}let c=oe(s,t.jd,o.parent[0],o.parent[1],o.parent[2],r,i,a,o.out,o.outIds,t.requiredFlags??0);e.push({id:o.id,count:c,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer)}self.postMessage({type:`tickResult`,groups:e},n);return}};\n//# sourceMappingURL=worker-CK5Z1yOu.js.map",eP=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,$N],{type:`text/javascript;charset=utf-8`});function tP(e){let t;try{if(t=eP&&(self.URL||self.webkitURL).createObjectURL(eP),!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($N),{type:`module`,name:e?.name})}}var nP=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 tP;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 zg(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}]},Vg(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()}},rP=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 gh(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},iP=.01,aP=[`asteroid`,`spacecraft`],oP=.0002959122082855911,sP=.75,cP=Q(8*86400);function lP(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(oP/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function uP(e){return e<0?0:e>1?1:e}function dP(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function fP(e){return e===null?{tBright:0,tSize:0}:{tBright:uP((pP-e)/(pP-mP)),tSize:uP((hP-e)/(hP-gP))}}var pP=1e4,mP=500,hP=mP,gP=50,_P=4,vP=.5,yP=10,bP=1,xP=1,SP=3.5,CP=2.5,wP=2,TP=SP,EP=class{orbitPool=new nP;pickRegistry=new rP;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:_P,dim:vP,opacity:xP};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:xP};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 aP)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 aP)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)x_(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=fP(e);return{size:_P+(yP-_P)*n,dim:vP+(bP-vP)*t,opacity:xP+(SP-xP)*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)dP(x_(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)dP(x_(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=fP(e);return{sizeMult:1+(CP-1)*n,brightMult:1+(wP-1)*t,opacity:xP+(TP-xP)*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=xP,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=hN(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 aP)for(let[t,n]of this.workerPoints[e]){let r=x_(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of aP)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`?d_:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&dP(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.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=vh(this.bodyObjects.keys()),{groups:o,baseWorker:s}=i?await i.buildWorkerGroups(n,t,a,!1):{groups:[],baseWorker:0},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,lP(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=JM(new Float32Array(l.cols.count*3),0,this.circleTexture,c,KM());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 b_(n,Cv(this.ctx.layers,n,r?Array.from(r.values()):[]),t),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=>_h(e.data.id)??dh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:cP,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3),p=new Float32Array(l.length*3);this.seedGeometryArray(f,l,p);let m=JM(f,l.length,this.circleTexture,`#ffffff`,void 0,p);this.adoptCloud(`spacecraft`,i,c,m,e)}}if(this.orbitPool.poolGeneration!==n){for(let e of r)this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of i)this.ctx.bodies.dirtySpacecraftGroups.add(e);this.lastPackedSize.clear(),this.rebuildQueued=!0}}unwireGroup(e,t,n){this.orbitPool.unwireOne(n),this.forgetGroupGate(n),this.pickRegistry.release(n);let r=this.workerPoints[e].get(t);r&&(this.scene.remove(r),this.workerPoints[e].delete(t))}armGroupGate(e,t){this.groupKinematics.set(e,t),this.lastSolvedJd.delete(e)}adoptCloud(e,t,n,r,i){let a=x_(t);r.userData.frontBasis=i,r.userData.groupId=n,r.userData.parentBodyId=this.cloudParentId(e,a),r.userData.parentVec=[0,0,0],this.emphasiseNewCloud(e,a,r),this.workerPoints[e].set(t,r),this.pendingSceneAdds.push(r)}deferPackWhileStreaming(e,t){if(!this.ctx.bodies.minorStreaming)return this.lastPackedSize.set(e,t),!1;let n=this.lastPackedSize.get(e);return n!==void 0&&t>n&&t<n*2?!0:(this.lastPackedSize.set(e,t),!1)}seedGeometryArray(e,t,n=null){let[r,i,a]=this.basisPos,o=Math.min(t.length,e.length/3),s=n?new X:null;for(let c=0;c<o;c++){let o=t[c],l=o.position;e[c*3]=l[0]-r,e[c*3+1]=l[1]-i,e[c*3+2]=l[2]-a,n&&s&&(s.set(m_(o.data)),n[c*3]=s.r,n[c*3+1]=s.g,n[c*3+2]=s.b)}}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length===n){e.setDrawRange(0,t.length);return}let r=!!e.getAttribute(`color`),i=new Float32Array(n),a=r?new Float32Array(n):null;this.seedGeometryArray(i,t,a),e.setAttribute(`position`,new Eo(i,3)),a&&e.setAttribute(`color`,new Eo(a,3)),e.setDrawRange(0,t.length)}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Eo(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 Eo(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 Eo(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of aP)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=iP*10;l>u*u&&this.rebuildBasis()}rebuildBasis(){this.basisPos=[...this.focus.focusTruePos],this.rebuildMoons(),this.onBasisRebuilt(),this.reposition()}updateForJd(e,t){this.writeMoons();let n=this._parentsScratch;n.clear();let r=this.ctx.getBody(`naif-10`)?.position??[0,0,0];for(let[i,a]of this.workerPoints.asteroid){if(!this.ctx.visibility.isAsteroidGroupVisible(x_(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(x_(r)))continue;let a=i.userData.groupId,o=this.ctx.getBody(i.userData.parentBodyId)?.position;if(o&&!this.shouldSolveGroup(a,o,e,t))continue;let s=i.userData.parentVec;o?(s[0]=o[0],s[1]=o[1],s[2]=o[2]):(s[0]=0,s[1]=0,s[2]=0),n.set(a,s)}this.orbitPool.tick(e,this.basisPos,n,this.ctx.visibility.getRequiredFlags())}shouldSolveGroup(e,t,n,r){let i=this.groupKinematics.get(e);if(!i||i.alwaysSolve)return!0;let a=this.lastSolvedJd.get(e);if(a===void 0||!isFinite(a))return!0;let[o,s,c]=this.focus.focusTruePos,l=r.camPos[0]-(t[0]-o),u=r.camPos[1]-(t[1]-s),d=r.camPos[2]-(t[2]-c),f=Math.max(1e-6,Math.sqrt(l*l+u*u+d*d)),p=Math.abs(n-a);return i.maxSpeedScene*p/f*r.pxPerRad>=sP}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];if(this.bodyObjects.get(a.data.id)?.outOfRange){s[r*3]=s[r*3+1]=s[r*3+2]=NaN;continue}s[r*3]=a.position[0]-e,s[r*3+1]=a.position[1]-t,s[r*3+2]=a.position[2]-n}o.needsUpdate=!0}}rebuildMoons(){let e=this.basisPos;for(let[t,n]of this.moonsByParent()){let r=this.moonPoints.get(t);if(!r)continue;let i=new Float32Array(n.length*3);for(let t=0;t<n.length;t++)i[t*3]=n[t].position[0]-e[0],i[t*3+1]=n[t].position[1]-e[1],i[t*3+2]=n[t].position[2]-e[2];r.geometry.setAttribute(`position`,new ko(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.orbitPool.destroy(),this.pickRegistry.clear();for(let e of aP)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()}},DP=Math.PI/180,OP=2451545,kP=1.00000261,AP=.01671123,jP=100.46457166*DP,MP=35999.37244981/36525*DP,NP=102.93768193*DP,PP=.32327364/36525*DP;function FP(e){let t=e-OP,n=NP+PP*t,r=jP+MP*t-n,i=r+(2*AP-AP**3/4)*Math.sin(r)+1.25*AP*AP*Math.sin(2*r);return{lon:n+i,r:kP*(1-AP*AP)/(1+AP*Math.cos(i))}}function IP(e){let t=FP(e).lon;return(e,n)=>{let r=t-FP(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 LP=.01,RP=1/100,zP=1;function BP(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 VP(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 HP(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=BP(c,l,u)}function UP(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position,u=c.x-r[0],d=c.y-r[1],f=c.z-r[2],p=l[0]-c.x,m=l[1]-c.y,h=l[2]-c.z,g=e.lagrangeTrail?NaN:n.newestJd+n.count*1e-9;if(VP(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=sN(t),b=e.lagrangeTrail?IP(i):null,x=lN(e,n,_,c.x,c.y,c.z,r,b??void 0);cN(t,_,v,y,x,!0,s),HP(o,g,u,d,f,p,m,h,_,x,a)}function WP(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=sN(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){rN(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function GP(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){UP(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=eN(Gv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.curvePending=!1}let s=t.userData.isOpenCurve,c=t.userData.useTrail,l=t.userData.orbitCenter,u=l.x,d=l.y,f=l.z;if(e.data.satrec){let n=e.data.n/360,i=n>0?1/n/512:0,a=t.userData.curveJd;(o.length===0||a===void 0||Math.abs(r-a)>=i)&&(o=QM(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=r)}else if(e.orbitElements){if(e.rederiveElements){let n=t.userData.elementsJd??r,i=e.orbitElements.n,a=i>0?360/i:1/0;if(Math.abs(r-n)>Math.min(a*RP,zP)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=eN(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)>LP&&(o=eN(Gv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let p=e.trailAnchor??e.position,m=t.userData,h=u-n[0],g=d-n[1],_=f-n[2],v=p[0]-u,y=p[1]-d,b=p[2]-f;if(VP(m,o,h,g,_,v,y,b,i))return;let x=Qy(e,o,s,u,d,f);if(x.length<2)return;let{posArr:S,trailArr:C,fullArr:w,capacity:T}=sN(t),E=u-n[0],D=d-n[1],O=f-n[2],k=Math.min(x.length,T);for(let e=0;e<k;e++)S[e*3]=x[e][0]+E,S[e*3+1]=x[e][1]+D,S[e*3+2]=x[e][2]+O;cN(t,S,C,w,k,s,c),m.trailLocalPositions=x,HP(m,o,h,g,_,v,y,b,S,k,i)}function KP(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 qP(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 JP=4/2,YP=(.1*10)**2,XP=new J,ZP=[],QP=ZP;function $P(e){return XO(ZP,e,ek)}var eF={x:0,y:0,left:0,right:0,h:0},tF=new Vi,nF={ox:0,oy:0},rF=new J,iF=new J;function aF(e,t,n,r,a,o,s,c,l,u,d,f,p,m,h){let g=n.layers,_=!g.isVisible(`orbits`),v=g.isVisible(`nomenclature`),y=t.fov*Math.PI/180,b=f.domElement.clientWidth,x=f.domElement.clientHeight,S=x/(2*Math.tan(y/2)),C=[r[0]+t.position.x,r[1]+t.position.y,r[2]+t.position.z],w=r,T=t.matrixWorldInverse;for(let n of e.values()){if(n.cachedDist=L_(C,n.body.position),n.noPhysical){let e=n.noPhysical===`model`;qE(n,`missing`,sg(n.cachedDist)<(e?.1:1)?e?i().messages.body_note_no_model():i().messages.body_note_no_radius():null)}let e=n.label;if(!e)continue;n.labelAnchorOffscreen=!1;let r=n.noPhysical?0:n.radiusScene;if(!r){e.position.set(0,0,0);continue}let[a,o,s]=n.body.position;p.set(a-w[0],o-w[1],s-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z,d=u*u,f=r*r;if(d<=f){e.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let m=r/n.cachedDist*S;if(m<1){e.position.set(0,0,0);continue}if(m>=16){let i=n.cachedDist,d=1/i,f=c*d,m=l*d,h=u*d,g=r*d,_=Math.sqrt(Math.max(1-g*g,0)),v=1-f*f,y=-f*m,b=-f*h,x=Math.hypot(v,y,b);x<1e-4&&(v=-m*f,y=1-m*m,b=-m*h,x=Math.hypot(v,y,b));let S=g/x,C=f*_+v*S,T=m*_+y*S,E=h*_+b*S;p.set(C*i-c,T*i-l,E*i-u).applyQuaternion(t.quaternion),e.position.copy(p),iF.set(a-w[0]+p.x,o-w[1]+p.y,s-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(iF.x)>1||Math.abs(iF.y)>1;continue}if(n.semiAxesScene&&n.mesh)KN(c,l,u,UN(n.mesh.getWorldQuaternion(tF),T,n.semiAxesScene),S,nF),p.set(nF.ox,nF.oy,0).applyQuaternion(t.quaternion);else{let e=f/(d-f);p.set(e*c,e*l,0).applyQuaternion(t.quaternion)}e.position.copy(p)}let E=ZP,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene;if(!e)continue;let n=t.cachedDist,[r,i,a]=t.body.position,o=t.model?.userData.occluderSpheres;if(t.model&&o?.length){let e=ZD(t),s=t.model.position;for(let c of o){let o=c.r*e;if(rF.copy(c.center).applyQuaternion(t.model.quaternion).add(s).multiplyScalar(e),p.set(r-w[0]+rF.x,i-w[1]+rF.y,a-w[2]+rF.z).applyMatrix4(T),p.z>=o||p.lengthSq()<=o*o)continue;let l=p.z*p.z;(l<=o*o||o*S/Math.sqrt(l-o*o)>=16)&&WN($P(k++),p.x,p.y,p.z,o,S,D,O,t.body.data.id,n)}continue}p.set(r-w[0],i-w[1],a-w[2]).applyMatrix4(T);let s=p.x,c=p.y,l=p.z;if(l>=e)continue;let u=l*l;(u<=e*e||e*S/Math.sqrt(u-e*e)>=16)&&(t.semiAxesScene&&t.mesh?GN($P(k++),s,c,l,UN(t.mesh.getWorldQuaternion(tF),T,t.semiAxesScene),S,D,O,t.body.data.id,n):WN($P(k++),s,c,l,e,S,D,O,t.body.data.id,n))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=a?hM(n.getBody(a),e):void 0;for(let r of e.values()){let{body:i,group:s,trail:c}=r,l=r.cachedDist,u,d,f=i.data.id===a,p=A!==null&&i.data.id===A;if(r.mesh===null&&!gn(i.data.objectType)){let t=i.data.objectType;if(t===G.BARYCENTER||t===G.LAGRANGE_POINT){let t=!0,r=f?void 0:N_(i.data.id);if(r){let a=e.get(r)?.body??n.getBody(r);a&&L_(i.position,a.position)/L_(C,a.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),u=t,d=!1}else{let e=n.visibility.getPlanetVisibility(i,l)!==$.HIDE&&n.visibility.hasFullRendering(i);s.visible=e,c&&(c.visible=e),u=e,d=!1}}else{let e=i.data.objectType===G.MOON,t=e?n.visibility.getMoonVisibility(i):n.visibility.getPlanetVisibility(i,l),r=e?KP(t,o,f):qP(t,n.visibility.hasFullRendering(i),f||p);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),u=r.showLabel,d=r.isClose}if(r.outOfRange&&(s.visible=!1,c&&(c.visible=!1),u=!1),r.starPoint){let e=r.radiusScene/l*S,t=e<JP;if(r.starPoint.visible=t,t){let t=r.starPoint.material,n=e/JP,i=Math.max(qA*n*n,3);t.uniforms.uIntensity.value=i}s.visible=!0,d=!t,u=!d}if(r.isMinor&&!f&&c&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(XP.set(w[0],w[1],w[2]))>YP&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:m}=r;if(!s.visible&&m&&m.parent===s?(s.remove(m),m.element.remove()):s.visible&&m&&m.parent!==s&&s.add(m),r.mesh&&r.radiusScene>0){let e=!f&&!p&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}ak(r,u,d,l,S,a)&&(j=!0);let g=r.radiusScene>0?r.radiusScene/l*S:0;LM(r,v&&i.data.id===M,g,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(x_(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(x_(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0)for(let n of e.values())n.label?.visible&&ck(n,t,w,b,x,eF)&&ok(eF.x,eF.y,n.cachedDist,n.body.data.id,E)&&(n.label.visible=!1);if((m||j||++d>=3)&&(d=0,xk(e,b,x,t,a,n,s,E,r)),Sk(e,b,x,t,r),M){let t=e.get(M);t&&VM(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 i=n.body.data.id===a,o=s.has(n.body.data.id);r.uniforms.uAlphaMultiplier.value=o?2:i?1.75:1;let c=e.userData.isOpenCurve===!1;r.uniforms.uAlphaMin.value=i&&c?.15:0,r.uniforms.uShowFull.value=+!!i}return d}function oF(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function sF(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function cF(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function lF(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 uF(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-dF(d):p,g=f?m+dF(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:fF(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:pF(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:fF(f,t),centerId:o.anchorId};if(l)return{r:pF(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}=lF(e,v);return{r:pF(y,b,t,x,S),centerId:e.centerId}}function dF(e){return e.jds[e.jds.length-1]-e.jds[0]}function fF(e,t){let n=dF(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return pF(e.points,e.jds,i)}function pF(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 oF(e[a-1],cF(sF(e[a],e[a-1]),s))}var mF=Math.PI/180,hF=Math.cos(ig*mF),gF=Math.sin(ig*mF);function _F(e,t,n,r){let i=Math.cos(e*mF),a=Math.sin(e*mF),o=Math.cos(t*mF),s=Math.sin(t*mF),c=Math.cos(n*mF),l=Math.sin(n*mF);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 vF(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*hF+a*gF,t=-i*gF+a*hF;i=e,a=t}return[r,i,a]}function yF(e){let t=10/rg;return[e[0]*t,e[2]*t,-e[1]*t]}function bF(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,{om:u,w:d}=Gv(e,t),f=e.equatorial??!1;if(!isFinite(r)||r===0||!isFinite(o)||o<=0){if(c==null||l==null||!isFinite(c)||!isFinite(l)||c<=0)return null;let r=Cg(c,l,t);if(!r)return null;let i=n&&n>0?n:$_,a=r.r*rg,o=2*c*rg;return xF(a,r.nu,o,1,i,d,e.i,u,f)}if(!isFinite(i)||!isFinite(a))return null;let p=r*rg,m=o*mF/ev,h=n&&n>0?n:m*m*Math.abs(p)*Math.abs(p)*Math.abs(p);if(!isFinite(h)||h<=0)return null;let g=(a+o*(t-s))*mF,_,v;if(i<1||r>0){let e=Math.min(i,.9999999),t=bg(g,e),n=1-e*Math.cos(t);_=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),v=p*n}else{let e=Sg(g,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;_=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),v=p*(1-i*Math.cosh(e))}if(!isFinite(v)||v<=0)return null;let y=p*(1-i*i);return!isFinite(y)||y<=0?null:xF(v,_,y,i,h,d,e.i,u,f)}function xF(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=_F(a,o,s,c),p=vF(e*l,e*u,f),m=vF(-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 SF={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};SF.cruise,SF.boost,SF.brake,SF.spiral,SF[`spiral-out`],SF[`spiral-in`];var CF={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},wF=3,TF=1,EF=2,DF=.6,OF=1.5,kF=.3,AF=1.5,jF=.85,MF=60,NF=.018,PF=.026,FF=`#ffffff`,IF=4,LF=1.5,RF=9,zF=1,BF={notice:IF-3,caution:IF-2,severe:IF-1},VF=[`notice`,`caution`,`severe`],HF=.03,UF=.2;function WF(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 Mc(t)}function GF(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 Mc(t)}function KF(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 qF(e,t){let n=new ss(new qo({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=IF,n}function JF(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&&(jk(c,i),mM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new JO(c);return p.center.set(0,.5),p}var YF=class{group=new Ra;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?OF:EF,i?kF:DF,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)=>VF.indexOf(e.severity)-VF.indexOf(t.severity));for(let t of n){let n=CF[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine(KF(t,n.startJd,n.endJd,lF(e,r)),CF[n.severity],RF,zF,null,{renderOrder:BF[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=uF(e,t.startJd);if(!r)continue;let i=yF(r.r),a=r.centerId===e.centerId?null:r.centerId,o=qF(GF(n),HF);this.group.add(o),this.markers.push({sprite:o,local:i,anchorId:a});let s=document.createElement(`div`);s.className=`scene-hazard-label`,s.style.color=n,s.textContent=t.label;let c=new JO(s);c.center.set(0,.5),this.group.add(c),this.labels.push({object:c,local:i,anchorId:a,owner:null,width:0,height:0,dimmed:!1,faint:!0})}}mergeIntoStep(e,t){let n=e.kind===`aeroassist`?`aero-pass`:e.kind===`belt-crossing`?`assist`:null;if(!n)return!1;let r=null,i=1/0;for(let{step:t,label:a}of this.drawnSteps){if(t.kind!==n||e.bodyId&&t.bodyId!==e.bodyId)continue;let o=Math.abs(t.jd-e.peakJd);o<i&&(i=o,r=a)}if(!r)return!1;let a=r.object.element,o=document.createElement(`span`);return o.className=`scene-path-label__hazard`,o.style.color=t,o.dir=`auto`,o.textContent=e.label,a.querySelector(`.scene-path-label__text`)?.append(o),a.setAttribute(`aria-label`,`${a.getAttribute(`aria-label`)} — ${e.label}`),!0}addPlan(e,t){let n=e.path;this.addArcs(n,wF,TF,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.group.add(e.sprite);this.craft={sprite:qF(WF(FF),PF),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=uF(e,n.jd);if(!t)continue;let r=yF(t.r),i=t.centerId===e.centerId?null:t.centerId,a=qF(WF(FF),NF);this.markers.push({sprite:a,local:r,anchorId:i});let o=JF(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.group.add(o),this.labels.push({object:o,local:r,anchorId:i,owner:null,width:0,height:0,dimmed:!1,faint:!1,step:!0,sprite:a}),this.drawnSteps.push({step:n,label:this.labels[this.labels.length-1]})}}addEndLabels(e,t=!1){let{path:n,onSelect:r}=e,i=n.arcs[0],a=n.arcs[n.arcs.length-1],o=n.stops.find(e=>e.kind===`departure`),s=[{local:yF(n.meeting.r),end:e.arrival,color:SF[a?.kind??`cruise`]}];o&&s.push({local:yF(o.r),end:e.departure,color:SF[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=JF(`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?TF:e.brightness),n.uniforms.uLineWidth.value=t?wF: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?lF(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),SF[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),SF.cruise,wF,TF,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),SF.cruise,wF,TF,null,{anchorId:n,renderOrder:LF}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),SF.cruise,wF,TF,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,SF.cruise,wF,TF,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),SF.cruise,AF,jF,null,{anchorId:n})}else this.addLine(t.approach,SF.cruise,wF,TF,null,{anchorId:n});let i=this.addLine(t.points,SF.cruise,AF,jF,null,{anchorId:n});if(!i)continue;let a=n===null?yF(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]=yF(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*UF));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=oN(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??IF,this.group.add(d);let f={line:d,owner:i,anchorId:a.anchorId??null,color:t,brightness:r,width:n,local:s,positions:c,alphas:l,count:o};return this.arcs.push(f),f}setClock(e){let t=this.craft;if(!t||!this.path)return;let n=uF(this.path,e);t.sprite.visible=n!==null,n&&(t.local=yF(n.r),t.anchorId=n.centerId===this.path.centerId?null:n.centerId)}reposition(e,t,n){if(this.center===null)return;let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=new Map,s=e=>{if(e===null)return[r,i,a];let s=o.get(e);if(s)return s;let c=n(e),l=c?[c[0]-t[0],c[1]-t[1],c[2]-t[2]]:[r,i,a];return o.set(e,l),l};for(let e of this.arcs){let[t,n,r]=s(e.anchorId);for(let i=0;i<e.count;i++)e.positions[i*3]=e.local[i*3]+t,e.positions[i*3+1]=e.local[i*3+1]+n,e.positions[i*3+2]=e.local[i*3+2]+r;rN(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let[t,n,r]=s(e.anchorId);e.sprite.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}for(let e of this.labels){let[t,n,r]=s(e.anchorId);e.object.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}if(this.craft){let{sprite:e,local:t,anchorId:n}=this.craft,[r,i,a]=s(n);e.position.set(t[0]+r,t[1]+i,t[2]+a)}for(let e of this.rings){let[t,n,r]=s(e.arc.anchorId);e.world.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}}updateCameraOffset(e){if(this.arcs.length!==0){this.offset.set(-e.x,-e.y,-e.z);for(let e of this.arcs)e.line.material.uniforms.uCenterOffset.value.copy(this.offset);for(let t of this.rings){let n=t.world.distanceTo(e);t.arc.line.visible=n<t.radius*MF}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){yk(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),!nT(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=ok(a,o,s,``,QP);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++}yk(this.rects,r)}setStepVisible(e,t){e.object.visible=t,e.sprite&&(e.sprite.visible=t)}setLabelDimmed(e,t){e.dimmed!==t&&(e.dimmed=t,e.object.element.classList.toggle(`scene-path-label--dim`,t))}clear(){for(let e of this.arcs)this.group.remove(e.line),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){this.group.remove(e.sprite);let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)this.group.remove(e.object),e.object.element.remove();this.arcs=[],this.rings=[],this.markers=[],this.labels=[],this.drawnSteps=[],this.craft=null,this.path=null,this.center=null}dispose(){this.clear(),this.scene.remove(this.group)}},XF=2,ZF=1,QF=4,$F=200,eI=class{group=new Ra;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,$F);for(let t=0;t<e.count;t++){let[r,i,a]=yF(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($F*3),t=new Float32Array($F).fill(1),n=oN($F,e,t,t,0,SF.cruise,XF,ZF);n.frustumCulled=!1,n.renderOrder=QF,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array($F*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;rN(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)}},tI=30034e-10,nI=.45,rI=1.6,iI=.85,aI=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],oI=e=>Math.hypot(e[0],e[1],e[2]);function sI(e,t,n=tI){let r=oI(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=aI(e,t)/r,o=oI(e);if(Math.sqrt(Math.max(0,o*o-a*a))>iI*i)return null;let s=a/i;return s>=nI&&s<=rI?`EL1`:s<=-nI&&s>=-rI?`EL2`:null}function cI(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var lI=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`?jg(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})}}},uI=new Map,dI=new J;function fI(e,t,n,r,i,a,o){let s=wy(n,r,Sy(t));if(!s)return null;let c=`naif-${n.bodyNaifId}`,l=a.bodies.bodiesById.get(c);if(!l||!l.orientation)return null;let u=i.get(c);if(!u)return null;let d=l.data.radiusKm;if(!Number.isFinite(d)||d<=0)return null;let f=Math.PI/180,p=s.latDeg*f,m=s.lngDeg*f,h=Dw(o.get(c),c,d,p,m);h&&uI.set(e.id,h);let g=h??uI.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=dC(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?dI.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 pI=[0,0,0],mI=new Vi,hI=4,gI=0,_I=new Map;function vI(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function yI(e,t,n){let r=_I.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 _I.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}function bI(e){let{jd:t,ctx:n,bodyObjects:r,focus:a,focusedBody:o,positionMap:s,diagnostics:c,trailView:l,frame:u,outOfRange:d}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let f=n.visibility.activeSystemId,p=f?e=>n.bodies.isInSystem(`naif-${e}`,f):void 0,m={jd:t,satellites:{kind:`covered`},majorBodies:cI(),focusedOutOfRange:!1},h=o?.data.id,g=hx(n.probeStore?.ridesAt(t)??[],h,e=>n.getBody(e)?.data.name),_=[];if(o){let e=new Set([o.data.id]),t=n.getBody(o.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),_.push({id:t.data.id,oldPos:[t.position[0],t.position[1],t.position[2]],bo:r.get(t.data.id)}),t=n.getBody(t.data.parentId)}s.clear(),s.set(`naif-0`,[0,0,0]);for(let e of n.bodies.bodiesById.values())s.set(e.data.id,e.position);for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||s.set(e.body.data.id,e.body.position);let v=new Set,y=e=>{if(v.has(e.data.id))return;v.add(e.data.id);let a=e.data,o=r.get(a.id);if(o&&u!==void 0&&a.id!==h&&!o.group.visible&&!o.trail?.visible&&(a.orbitalSource===tn.SPICE_PROBE||!gn(a.objectType))&&(o.staggerSlot??=gI++%hI,u%hI!==o.staggerSlot))return;let l=(t=!1)=>{o&&(o.outOfRange=!0),e.positionUnknown=!0,!t&&a.id===h&&(m.focusedOutOfRange=!0)};if(a.unplaceable){l(!0);return}let d=n.chebStore?.has(a.id)??!1,f=a.orbitalSource===tn.SPICE_PROBE;if(f){if(g.hidden.has(a.id)){l(!0);return}if(o){let e=g.credits.get(a.id);qE(o,`carrier`,e?i().messages.carried_by_scene_label({carrier:e}):null)}}if(a.visibleFromDays!==void 0&&t-2451545<a.visibleFromDays){l();return}let _;if(f)_=s.get(a.parentId)??[0,0,0];else{let e=s.get(a.parentId);if(!e){l(),c.warnOnce(`missing-parent`,a.id,()=>`computePosition[${a.id}]: parent ${a.parentId} not in positionMap — hiding`);return}_=e,c.clear(`missing-parent`,a.id)}let b=a.q!=null;if(!d&&!f&&(t<a.validityStart||t>a.validityEnd)){l(!a.satrec);return}let x,S,C;if(d){let e=n.chebStore.positionScene(a.id,t);if(!e){l(!0);let e=n.chebStore.zoneCoverage(a.id);e&&(t<e.start||t>e.end)&&(m.majorBodies.count++,e.start<m.majorBodies.earliestStart&&(m.majorBodies.earliestStart=e.start),e.end>m.majorBodies.latestEnd&&(m.majorBodies.latestEnd=e.end),a.id===h&&(m.focusedOutOfRange=!0)),c.warnOnce(`cheb-null`,a.id,()=>{let n=e?t>=e.start&&t<=e.end:void 0,r=e?`[${e.start.toFixed(1)},${e.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${a.id}] returned null at jd=${t.toFixed(3)} (coverage=${r}, insideCoverage=${n}) — children of this body will read stale positionMap entry (pre-seeded) instead of falling to SSB`});return}x=_[0]+e[0],S=_[1]+e[1],C=_[2]+e[2]}else if(f){let i=n.probeStore?.probeWithCenter(a.id,t,p)??null;if(!i){l(),c.warnOnce(`probe-unavailable`,a.id,()=>{let e=n.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${a.id} (${a.name??`unnamed`}): hidden — ${e}`});return}let u=i.probe.landed;if(u&&Cy(i.probe,t)){let d=a.parentId,f=fI(a,i.probe,u,t,s,n,r);if(!f){l();return}c.clear(`probe-unavailable`,a.id),e.positionUnknown=!1,d!==a.parentId&&e.trailBuffer?.clear(),o&&(o.outOfRange=!1,o.isLanded||=(Tk(o.labelHalo,!0),!0)),e.position[0]=f.x,e.position[1]=f.y,e.position[2]=f.z,e.orbitCenter&&(e.orbitCenter[0]=f.parentPos[0],e.orbitCenter[1]=f.parentPos[1],e.orbitCenter[2]=f.parentPos[2]),e.trailAnchor&&(e.trailAnchor[0]=f.parentPos[0],e.trailAnchor[1]=f.parentPos[1],e.trailAnchor[2]=f.parentPos[2]),s.set(a.id,e.position);let p=f.up;o?.mesh&&(p?gC(o.mesh,p):hC(o.mesh,e.position,f.parentPos)),o?.model&&(p?gC(o.model,p):hC(o.model,e.position,f.parentPos));return}let d=zy(i.probe,t,i.fitCenterNaifId,n.chebStore??null,e=>s.has(e));if(!d){l(),c.warnOnce(`probe-unavailable`,a.id,()=>`probe ${a.id} (${a.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`);return}let f=d.id,m=d.muKm3S2,g=by(i.probe,t,m);if(!g){l(),c.warnOnce(`probe-unavailable`,a.id,()=>`probe ${a.id} (${a.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`);return}c.clear(`probe-unavailable`,a.id),o?.isLanded&&(Tk(o.labelHalo,!1),o.isLanded=!1);let b=s.get(f_),w=s.get(d_),T=f===`naif-399`&&b!==void 0&&w!==void 0&&sI([Q(g[0]),Q(g[2]),-Q(g[1])],[w[0]-b[0],w[1]-b[1],w[2]-b[2]])!==null,E=T!==(e.lagrangeTrail??!1);e.lagrangeTrail=T;let D=a.parentId!==f;if((D||E)&&e.trailBuffer&&n.probeStore){let r=e.trailBuffer;r.clear(),r.needsPopulate=!1;let o=Uy(Iy(i.probe,t,m),a.validityEnd-a.validityStart,r.capacity,T);r.reconfigure(o.stepDays,o.epsilonScene,o.spanDays),Yy(r,n.probeStore,n.chebStore??null,a.id,f,t)}if(D&&(a.parentId=f),!v.has(f)){let e=n.bodies.bodiesById.get(f)??r.get(f)?.body;e&&y(e)}let O=s.get(f);if(!O){l(),c.warnOnce(`probe-unavailable`,a.id,()=>`probe ${a.id} (${a.name??`unnamed`}): hidden — fit center ${f} has no position this frame`);return}_=O;let k=Q(g[0]),A=Q(g[2]),j=-Q(g[1]);x=_[0]+k,S=_[1]+A,C=_[2]+j;let M=e.trailBuffer;if(M?.needsPopulate&&o?.trail?.visible&&n.probeStore&&(M.needsPopulate=!1,M.clear(),Yy(M,n.probeStore,n.chebStore??null,a.id,f,t)),M){let e=M.newestJd,r=t-e,o=M.stepDays*M.capacity,s=isFinite(e)&&(r<0||r>o);if(s&&a.id===h&&n.probeStore){M.clear();let e=Uy(Iy(i.probe,t,m),a.validityEnd-a.validityStart,M.capacity,T);M.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),Yy(M,n.probeStore,n.chebStore??null,a.id,f,t)}else s?(M.clear(),M.append(t,k,A,j)):isFinite(e)?isFinite(M.epsilonScene)?r>=M.stepDays*.00390625&&n.probeStore&&M.readNewestPos(pI)&&Zy(M,Gy(n.probeStore,n.chebStore??null,a.id,f),e,[pI[0],pI[1],pI[2]],t):r>=M.stepDays&&M.append(t,k,A,j):M.append(t,k,A,j)}}else if(a.a===0&&!b&&!a.satrec)[x,S,C]=_;else{let e=a.satrec?yg(a.satrec,t):b?Yv(a,t):qv(a,t);if(!e){l();return}x=_[0]+e[0],S=_[1]+e[1],C=_[2]+e[2]}if(o&&(o.outOfRange=!1),e.positionUnknown=!1,e.position[0]=x,e.position[1]=S,e.position[2]=C,(!Number.isFinite(x)||!Number.isFinite(S)||!Number.isFinite(C))&&c.warnOnce(`non-finite`,a.id,()=>{let e=s.has(a.parentId);return`computePosition[${a.id}] non-finite: pos=[${x},${S},${C}] parentId=${a.parentId} parentInPositionMap=${e} parentPos=[${_[0]},${_[1]},${_[2]}] isChebTracked=${d} isProbe=${f} objectType=${a.objectType}`}),e.orbitCenter&&(e.orbitCenter[0]=_[0],e.orbitCenter[1]=_[1],e.orbitCenter[2]=_[2]),e.trailAnchor&&(e.trailAnchor[0]=_[0],e.trailAnchor[1]=_[1],e.trailAnchor[2]=_[2]),s.set(a.id,e.position),o){if(o.trail&&e.orbitCenter){let e=o.trail.userData.orbitCenter;e&&e.set(_[0],_[1],_[2])}if(e.orientation&&(o.mesh||o.model))o.mesh&&fC(o.mesh,e.orientation,t,e.nutPrec),o.model&&fC(o.model,e.orientation,t,e.nutPrec),o.nomenclatureAnchor&&fC(o.nomenclatureAnchor,e.orientation,t,e.nutPrec);else if(GD(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(t,mI))o.mesh&&o.mesh.quaternion.copy(mI),o.model&&o.model.quaternion.copy(mI);else{let n=e.pointingOverride??e.pointing;if(n){let r=vI(n)?yI(a.id,t,e.position):void 0,i={bodyPos:e.position,parentPos:_,sunPos:s.get(d_),velocity:r};o.mesh&&AC(o.mesh,n,i),o.model&&AC(o.model,n,i)}else o.mesh&&hC(o.mesh,e.position,_),o.model&&hC(o.model,e.position,_)}}if(e.orientation)for(let n of o.rings)fC(n.mesh,e.orientation,t,e.nutPrec)}},b=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values()){if(e.data.objectType===G.MOON&&!(b!==null&&e.data.parentId===b)&&e.data.id!==h){s.set(e.data.id,e.position);continue}y(e)}for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||y(e.body);if(m.satellites=n.refresher?.satelliteCoverage(t)??{kind:`covered`},d.update(m),o&&cn(o)){let e=n.getBody(o.featureAnchor.hostId);e&&s.has(e.data.id)?Rw(o,e,r.get(e.data.id),t):m.focusedOutOfRange=!0}let x=null;if(o&&m.focusedOutOfRange){let e=_.find(e=>e.bo&&!e.bo.outOfRange);if(e){x=e.id;let t=s.get(e.id)??e.oldPos;if(performance.now()-a.focusStartTime<a.focusDurationMs){a.focusTargetWorld[0]=t[0],a.focusTargetWorld[1]=t[1],a.focusTargetWorld[2]=t[2];let e=a.camTargetOffset;e&&a.camTargetWorld&&(a.camTargetWorld[0]=t[0]+e[0],a.camTargetWorld[1]=t[1]+e[1],a.camTargetWorld[2]=t[2]+e[2])}else{let n=t[0]-e.oldPos[0],r=t[1]-e.oldPos[1],i=t[2]-e.oldPos[2];a.focusTruePos[0]+=n,a.focusTruePos[1]+=r,a.focusTruePos[2]+=i,a.focusTargetWorld[0]=a.focusTruePos[0],a.focusTargetWorld[1]=a.focusTruePos[1],a.focusTargetWorld[2]=a.focusTruePos[2]}}}else if(o){let e=o.position,t=performance.now()-a.focusStartTime<a.focusDurationMs;a.focusTargetWorld[0]=e[0],a.focusTargetWorld[1]=e[1],a.focusTargetWorld[2]=e[2];let n=a.camTargetOffset;n&&a.camTargetWorld&&(a.camTargetWorld[0]=e[0]+n[0],a.camTargetWorld[1]=e[1]+n[1],a.camTargetWorld[2]=e[2]+n[2]);let r=a.camOriginOffset;r&&a.camOriginWorld&&(a.camOriginWorld[0]=e[0]+r[0],a.camOriginWorld[1]=e[1]+r[1],a.camOriginWorld[2]=e[2]+r[2]),t||(a.focusTruePos[0]=e[0],a.focusTruePos[1]=e[1],a.focusTruePos[2]=e[2])}let S=a.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}GP(e.body,n,S,t,l),n.userData.refreshDeferred=!1}}return{focusedOutOfRange:m.focusedOutOfRange,reanchorId:x}}function xI(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(GP(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}var SI=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)}},CI=Q(695700),wI=2,TI=new J;function EI(e,t,n,r,i){TI.subVectors(e,t);let a=TI.dot(n),o=Math.sqrt(Math.max(TI.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 DI(e,t,n,r,i,a){let o=e.get(d_)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){if(!t.rings.length)continue;let[e,u,d]=t.body.position;for(let f of t.rings){let p=r||f.intensityScale>=.000980392156862745;f.mesh.visible=p;let m=r?1:p?f.intensityScale:0;f.material.uniforms.uIntensityScale.value=m;let h=f.material.uniforms.uSunDir.value;h.set(o[0]-e,o[1]-u,o[2]-d);let g=h.length(),_=CI/g;f.material.uniforms.uSunAngularRadius.value=_,f.material.uniforms.uLightScale.value=n?_T(g):1,h.normalize();let v=f.planetShadowOnRing;if(v.uPlanetCenter.value.set(e-s,u-c,d-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),f.layers){let{dist:e,sinToPole:t}=EI(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,f.innerScene,f.outerScene),n=f.thicknessScene*t/Math.max(e,1e-9)*a,r=Math.min(Math.max(Math.ceil(n*wI),1),48);f.layers.count!==r&&(f.layers.count=r,f.material.uniforms.uLayerCount.value=r,f.material.uniforms.uLayerAlphaExp.value=1/r)}let y=f.planetShadow;y&&(y.uRingShadowIntensity.value=m,y.uRingShadowSunAngularRadius.value=_,y.uRingShadowSunDir.value.copy(h),y.uRingShadowPoleDir.value.copy(v.uPlanetPoleDir.value),y.uRingShadowCenter.value.copy(v.uPlanetCenter.value))}}}var OI=Math.PI/180,kI=2451545;function AI(e){let t=e-kI,n=(19.3871+.52402073*t)*OI;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 jI(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 MI(e,t){let n=e.seasonal;if(!n)return e;let r=jI(n.lsDeg,n.dustTauFactor,t),i=jI(n.lsDeg,n.dustScaleHeightKm,t),a=jI(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 NI=new WeakMap,PI=.25;function FI(e,t){if(!e.seasonal)return e;let n=Math.round(AI(t)/PI),r=NI.get(e);if(r&&r.lsQ===n)return r.params;let i=MI(e,n*PI);return NI.set(e,{lsQ:n,params:i}),i}var II=new J,LI=new J,RI=[.2126,.7152,.0722];function zI(e,t,n){return n<=0?0:e<=t-n?n:e>=t+n?0:e<=t?n-(e-(t-n))**2/(2*n):(t+n-e)**2/(2*n)}function BI(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=zI(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+=RI[t]*Math.exp(-n)}return o}var VI=.4,HI=.05,UI=-.105,WI=.3,GI=.05;function KI(e,t,n){let r=BI(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/GI),a=Math.min(1,Math.max(0,(n-UI)/WI));return r*(1+(VI+(HI-VI)*a-1)*i)}function qI(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 JI=hT,YI=200,XI=new J,ZI=new J,QI=new J,$I=new J;function eL(e,t,n,r){e.uOccluderCount.value=LC(e.uOccluders.value,t,r,n)}function tL(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:XI.set(1,1,1),sunRefraction:null};MA(n&&a.sunTint);let c=e.get(d_);aj(c?.mesh?.material,gb());let l=ij(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=YI,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere||(c.atmosphere.mesh.visible=n,!n))continue;wA(c.atmosphere,a);let e=hb(c.body.data.id);if(e?.seasonal){let t=a.seasonal?FI(e,o):e;if(c.atmosphere.params!==t){TA(c.atmosphere,t);for(let e of c.sunTint??[])zA(e,t,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[f,p,m]=c.body.position,h=c.atmosphere.material.uniforms;h.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let g=h.uSunDir.value.set(d[0]-f,d[1]-p,d[2]-m),_=c.atmosphere.params,v=r?_T(g.length()):_.realisticSunAlways?Math.sqrt(_T(g.length())):1;h.uSunIntensity.value=_.sunIntensity*v*i,g.normalize(),c.mesh&&(II.set(0,1,0).applyQuaternion(c.mesh.quaternion),h.uSpinAxis.value.copy(II));let y=c.atmosphere.mesh,b=c.atmosphere.geometryRadiusScene*y.scale.x,x=t.distanceTo(y.position);b>x*.1&&(s.shellProminent=!0),a.eclipseShadows&&eL(h,y.position,g,b);let S=a.insideView&&x<b,C=c.atmosphere.planetRadiusKm,w=x*((C+_.topAltitudeKm)/b)-C,T=S&&xA(_,w),E=S?SA(_,w):0;vA(c.atmosphere,S,T,E),h.uDeepIrradiance.value=JI*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=JI*i,e.uAtmoTDeepBlend.value=E;if(S){s.insideShell=!0;let e=LI.copy(t).sub(y.position).divideScalar(x).dot(g),n=KI(_,w,e);if(s.skyboxIntensity*=n*(1-E),a.refraction&&_.refractivity&&!T){let t=qI(_.refractivity[1]*Math.exp(-Math.max(w,0)/_.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),_.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:$I.copy(LI)})}}let D=x/b;if(a.sunTint&&D<YI){let e=b/(1+_.topAltitudeKm/C)*(c.atmosphere.surfaceRadiusKm/C);QI.copy(t).sub(y.position);let n=h.uSpinAxis.value,r=h.uStretch.value;if(KA(_,QI,g,e,c.atmosphere.surfaceRadiusKm,ZI,n,r)){let e=RI[0]*ZI.x+RI[1]*ZI.y+RI[2]*ZI.z;e>1e-4&&s.sunTint.multiply(ZI.divideScalar(e))}l&&D<u&&(u=D,VA(l,_,y.position,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var nL=[];function rL(e,t){let n=FC(),r=e.get(d_);if(!r){n.uSunAngularRadius.value=0,n.uOccluderCount.value=0;return}let[i,a,o]=t,s=r.body.position,c=s[0]-i,l=s[1]-a,u=s[2]-o,d=Math.hypot(c,l,u);d>0?(n.uSunDir.value.set(c/d,l/d,u/d),n.uSunAngularRadius.value=Math.asin(Math.min(r.radiusScene/d,1))):n.uSunAngularRadius.value=0;let f=nL,p=0;for(let t of e.values()){if(t.body.data.objectType===G.STAR)continue;let e=t.body.data.radiusKm;!Number.isFinite(e)||e<=0||t.radiusScene<=0||(f[p++]=t)}f.length=p,p>32&&(f.sort((e,t)=>t.radiusScene-e.radiusScene),f.length=32,p=32);let m=n.uOccluders.value;for(let e=0;e<p;e++){let t=f[e],[n,r,s]=t.body.position;m[e].set(n-i,r-a,s-o,t.radiusScene)}n.uOccluderCount.value=p;for(let e=0;e<p;e++)f[e]=void 0;f.length=0;let h=n.uSunDir.value;for(let t of e.values()){let e=t.eclipseShadow;if(!e||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[n,r,s]=t.body.position,c=e.uEclipseSelfPos.value.set(n-i,r-a,s-o);e.uOccluderCount.value=LC(e.uOccluders.value,c,t.radiusScene,h)}}var iL=10;function aL(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&vT(i,s,c);return}let u=e.get(d_)?.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(iL),r.target.position.set(0,0,0),r.intensity=hT*(s?_T(_):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=iL-b,x.far=iL+b,x.updateProjectionMatrix()}var oL=128,sL=256,cL=.25,lL=.32,uL=.35,dL=300,fL=1.25,pL=.05,mL=4e5,hL=new Y,gL=new J;function _L(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/oL,a=[];for(let t=0;t<=oL;t++){let n=t===oL?e:t*i;(t===0||t===oL||!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 vL(e,t,n){let r=t.length,i=n.length,a=new Float32Array(r*i*3),o=new Float32Array(r*i*3),s=new Float32Array(r*i*2);for(let c=0;c<r;c++){let r=t[c],l=Math.sin(r),u=Math.cos(r);for(let t=0;t<i;t++){let d=n[t],f=-Math.cos(d)*l,p=u,m=Math.sin(d)*l,h=(c*i+t)*3;a[h]=e*f,a[h+1]=e*p,a[h+2]=e*m,o[h]=f,o[h+1]=p,o[h+2]=m;let g=(c*i+t)*2;s[g]=d/(2*Math.PI),s[g+1]=1-r/Math.PI}}let c=new Uint32Array((r-1)*(i-1)*6),l=0;for(let e=0;e<r-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<i-1;t++){let a=e*i+t+1,o=e*i+t,s=(e+1)*i+t,u=(e+1)*i+t+1;n||(c[l++]=a,c[l++]=o,c[l++]=u),r||(c[l++]=o,c[l++]=s,c[l++]=u)}}let u=new Vo;return u.setAttribute(`position`,new Eo(a,3)),u.setAttribute(`normal`,new Eo(o,3)),u.setAttribute(`uv`,new Eo(s,2)),u.setIndex(new Eo(c.subarray(0,l),1)),u}function yL(e){e.terrainWindow&&(e.terrainWindow=null,e.currentSegments=void 0)}function bL(e,t,n){let r=e.mesh,i=e.displacementMap;if(!n||!r||!i)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!r} tex=${!!i}`),yL(e),!1;r.updateMatrixWorld(),hL.copy(r.matrixWorld).invert(),gL.copy(t.position).applyMatrix4(hL);let a=Q(mn(e.body.data)),o=gL.length(),s=Math.max(o/a-1,1e-6);if(s>(e.terrainWindow?lL:cL))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${s.toFixed(4)}`),yL(e),!1;let c=i.image?.width??2048,l=2*Math.PI/c,u=Math.acos(1/(1+s)),d=Math.max(l,2*u*fL/sL),f=Math.log2(d/l),p=Math.max(0,Math.ceil(f-1e-9)),m=e.terrainWindow;m&&m.texWidth===c&&f>m.stepLevel-.85&&f<m.stepLevel+.15&&(p=m.stepLevel);let h=l*2**p,g=h*sL/2,_=Math.acos(Math.min(1,Math.max(-1,gL.y/o))),v=Math.atan2(gL.z,-gL.x);if(v<0&&(v+=2*Math.PI),m&&m.texWidth===c){if(m.stepLevel===p){let e=Math.sin(_)*Math.sin(m.centerTheta)*Math.cos(v-m.centerPhi)+Math.cos(_)*Math.cos(m.centerTheta);if(Math.acos(Math.min(1,Math.max(-1,e)))<uL*m.angRadius)return!0}if(performance.now()-m.builtAt<dL)return!0}let y=Math.max(0,_-g),b=Math.min(Math.PI,_+g),x=_L(Math.PI,[[y,b]],h),S=Math.min(Math.PI,g/Math.max(Math.sin(_),pL)),C=Math.max(p,Math.ceil(Math.log2(2*S/sL/l)-1e-9)),w=l*2**Math.max(0,C),T=v-S,E=v+S,D=S>=Math.PI?[[0,2*Math.PI]]:T<0?[[0,E],[T+2*Math.PI,2*Math.PI]]:E>2*Math.PI?[[0,E-2*Math.PI],[T,2*Math.PI]]:[[T,E]],O=_L(2*Math.PI,D,w);if(x.length*O.length>mL)return console.warn(`terrain window for ${e.body.data.id} would need ${x.length}×${O.length} vertices — keeping the uniform sphere`),yL(e),!1;let k=r.geometry;return r.geometry=vL(a,x,O),k.dispose(),console.debug(`terrain window ${e.body.data.id}: ${x.length}×${O.length} grid, level ${p} (tex ${c})`),e.terrainWindow={thetas:x,phis:O,centerTheta:_,centerPhi:v,angRadius:g,stepLevel:p,texWidth:c,builtAt:performance.now()},e.currentSegments=oL,!0}var xL=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],SL=24;function CL(e,t,n,r){if(!n&&!t)return SL;let i=xL[xL.length-1].segs;for(let t of xL)if(e>=t.up){i=t.segs;break}if(i<r){let t=xL.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function wL(e,t,n,r,i){let a=t.fov*Math.PI/180,o=n.domElement.clientHeight/(2*Math.tan(a/2)),s=r.visibility.activeSystemId,c=i;for(let n of e.values()){if(!n.mesh||!n.radiusScene||!n.group.visible||n.cachedDist<=0)continue;let e=n.body.data.objectType===G.STAR,a=n.body.data.id;if((a===c||n.terrainWindow)&&bL(n,t,a===c))continue;let l=CL(n.radiusScene/n.cachedDist*o,e,s?a===s||r.visibility.isInActiveSystem(n.body.data.parentId):a===i,n.currentSegments??64);if(l===n.currentSegments)continue;let u=Q(mn(n.body.data)),d=n.mesh.geometry;n.mesh.geometry=new nu(u,l,l),d.dispose(),n.currentSegments=l}}function TL(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(Kj(n)>Kj(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return Kj(r)<Kj(t)?r:t}function EL(e,t,n,r,i,a,o,s){s.apply(e,i);let c=t.fov*Math.PI/180,l=n.domElement.clientHeight/(2*Math.tan(c/2)),u=r.visibility.activeSystemId,d=Ax(),f=d.showClouds,p=Kj(Gx());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=f);for(let t of e.values()){if(!t.mesh||!t.radiusScene||!t.group.visible||!t.availableTiers?.length||t.cachedDist<=0)continue;let e=t.body.data.id;if(u){if(e!==u&&!r.visibility.isInActiveSystem(t.body.data.parentId))continue}else if(e!==a)continue;let s=t.radiusScene/t.cachedDist*l,c=t.cachedDist/t.radiusScene,f;f=s<256&&c>10?`low`:s<1024&&c>2?`medium`:`high`;let m=Kj(t.textureTier),h=Math.min(Kj(f),p),g=Yj(o,t.availableFrames),_=g!==t.textureFrame,v=h>m;if(d.showSurfaceTexture&&!t.textureLoading&&(v||_)){let e=v?qj(h,t.availableTiers):t.textureTier;e&&tM(t,e,g,i)}let y=t.displacementMeta?.tiers;if(t.displacementMap&&y?.length&&!t.displacementLoading){let e=n.capabilities.maxTextureSize,r=e>=16383?2:+(e>=8192),i=t.displacementTier??`low`,a=qj(Math.min(Kj(TL(c,i)),r,p),y);a&&a!==i&&nw(t,a)}if(t.clouds&&t.textureTier){let e=qj(Kj(t.textureTier),t.clouds.availableTiers),n=Cj(o,t.clouds.availableFrames,t.clouds.availableCoverage);e&&n&&Ej(t.clouds,e,n)}}}var DL=zO.refMs,OL=new Y,kL=new J,AL=new J,jL=new Vi,ML=new Vi,NL=new J,PL=new J;function FL(e,t,n){return kL.set(e[0],e[1],e[2]),AL.set(t[0],t[1],t[2]),OL.lookAt(kL,AL,n),jL.setFromRotationMatrix(OL).clone()}function IL(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=I_(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=R_(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=I_(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]),ML.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,ML,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=I_(e.camOriginWorld,e.camTargetWorld,t)}let i=FL(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 LL(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=FL([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=L_(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(RO(o,VO),LO(s,HO))}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(),NL.set(0,0,-1).applyQuaternion(e.flyQ0),PL.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=LO(NL.angleTo(PL),zO);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 RL(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=L_(n,r);NL.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),PL.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=NL.angleTo(PL);e.focusDurationMs=Math.max(RO(a,VO),LO(o,HO)),i&&(e.focusDurationMs=0)}var zL={[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},BL=5e-4,VL=new J,HL=new J;function UL(e){return zL[e.data.objectType]??mn(e.data)*.25}function WL(e,t){return Q((t??mn(e.data))+UL(e))}function GL(e,t,n,r){let i=t.data.radiusKm;if(!Number.isFinite(i)||i<=0)return;let a=t.position[0]-n[0],o=t.position[1]-n[1],s=t.position[2]-n[2],c=Math.hypot(a,o,s),l=r?.centerOffsetScene,u=a+(l?l[0]:0),d=o+(l?l[1]:0),f=s+(l?l[2]:0),p=e.position.x-u,m=e.position.y-d,h=e.position.z-f,g=Math.hypot(p,m,h);if(r?.seated){if(g<1e-9){e.position.set(u,d+c+Q(BL),f);return}let t=Math.tan(e.fov*Math.PI/360)*e.near,n=t*e.aspect,i=0;for(let[a,o,s]of[[0,0,0],[-n,-t,-e.near],[n,-t,-e.near],[-n,t,-e.near],[n,t,-e.near]]){HL.set(a,o,s).applyQuaternion(e.quaternion);let t=p+HL.x,n=m+HL.y,l=h+HL.z,u=Math.hypot(t,n,l);if(u<1e-12)continue;VL.set(t/u,n/u,l/u).applyQuaternion(r.invQuat);let d=r.radialKm([VL.x,VL.y,VL.z]),f=(d===null?c:Q(d))+Q(BL);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/g;e.position.set(e.position.x+p*a,e.position.y+m*a,e.position.z+h*a);return}let _=UL(t);if(g>=Q((r?.outerRadiusKm??i)+_))return;let v=i;r&&g>1e-9&&(VL.set(p/g,m/g,h/g).applyQuaternion(r.invQuat),v=r.radialKm([VL.x,VL.y,VL.z])??i);let y=Q(v+_),b=c>0?Math.min(y,c):y;if(!(g>=b)){if(g<1e-9)p=0,m=b,h=0;else{let e=b/g;p*=e,m*=e,h*=e}e.position.set(u+p,d+m,f+h)}}function KL(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=nC([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=oC(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]=rC([0,0,0],s,c,l,n);r.set(u,d,f)}var qL=50,JL=20;function YL(e){return e<=0?`none`:e<JL?`full`:e<qL?`half`:`none`}function XL(e,t){return e.data.validityStart<=t&&t<=e.data.validityEnd}var ZL=class{pendingDefaults=new Set;defaults=new Set;userPromoted=new Set;autoPromoted=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.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),Bv().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 p_)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||!hn(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:p_.has(t)}isDefault(e){return this.defaults.has(e)}ensureBodyObjects(e){this.buildBodyInstance(e)&&this.finalizeBuilds()}buildBodyInstance(e,t,n=!1){let{bodyObjects:r,ctx:i,clock:a,scene:o,clickables:s,meshToBody:c,circleTexture:l,renderer:u}=this.deps;if(r.has(e.data.id))return!1;if(wT(e,a.jd,i),!e.orbitElements&&!e.data.unplaceable&&e.data.orbitalSource!==tn.SPICE_PROBE){e.orbitElements=e.data;let t=r.get(e.data.parentId);t&&(e.orbitCenter=[...t.body.position])}lj([e],o,s,c,r,l,u.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let d=r.get(e.data.id);if(d&&!e.data.name&&$j(d),e.data.objectType===G.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(hn(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 f=e.data.id;return this.defaults.has(f)||(n?this.autoPromoted.add(f):(this.userPromoted.add(f),this.emitUserPromotedCount())),!0}finalizeBuilds(){mN(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(f_),t=this.currentMemberCount(e),n=YL(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)||XL(t,i)&&(this.deps.bodyObjects.has(t.data.id)||a.push(t));if(a.length===0)return;let o=n===`half`?new Set(a.map(e=>e.data.id)):void 0;this.buildBatch(a,o,!0)}currentMemberCount(e){if(this.countStableLo=-1/0,this.countStableHi=1/0,!e)return 0;let t=this.deps.clock.jd,n=0;for(let r of e.values()){if(this.groupTargets&&!this.groupTargets.has(r.data.id))continue;let{validityStart:e,validityEnd:i}=r.data;e<=t?e>this.countStableLo&&(this.countStableLo=e):e<this.countStableHi&&(this.countStableHi=e),i<t?i>this.countStableLo&&(this.countStableLo=i):i<this.countStableHi&&(this.countStableHi=i),XL(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&&!XL(a,n)&&r.push(i)}r.length!==0&&this.tearDownBodies(r,this.autoPromoted)}clearUserPromoted(){let e=this.deps.getFocusedId(),t=[...this.userPromoted].filter(t=>t!==e);this.tearDownBodies(t,this.userPromoted),this.emitUserPromotedCount()}tearDownBodies(e,t){if(e.length===0)return;let{bodyObjects:n,ctx:r,scene:i,clickables:a,meshToBody:o,pointClouds:s}=this.deps,c=new Set,l=new Set;for(let r of e){let e=n.get(r);if(!e){t.delete(r);continue}e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),iO(e),eM(e),OM(e),i.remove(e.group);for(let t of e.extraObjects)i.remove(t);if(e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),oj(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(),oj(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),oj(e.trail.material));let s=e.body.data.objectType;if(s===G.SPACECRAFT)c.add(e.body.data.parentId);else if(hn(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)}},QL=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r,i){this.deps=e,this.focusedBody=t,this.promotion=new ZL({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer:i,circleTexture:r,clickables:e.clickables,meshToBody:e.meshToBody,hoveredBodyIds:n,pointClouds:e.pointClouds,onBodyClick:e=>this.handleFocus(e),assignMapLayerToTrails:e.assignMapLayerToTrails,repositionAll:e.repositionAll,getFocusedId:()=>this.focusedBody?.data.id,onUserPromotedChange:e.callbacks.onUserPromotedChange})}get current(){return this.focusedBody}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||GD(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=$L(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&&(uj(t.body)?fj(t,n,r,i):iO(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}uj(t)&&(dj(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(mN(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e){if(e.positionUnknown)return;let{focus:t,camera:n}=this.deps;LL(t,[...e.position],n,this.cameraTruePos(),void 0,Ax().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,LL(n,[...e],r,a,o,Ax().resolvedReducedMotion);let s=nC(o??a,e,void 0);i.onCameraPosition?.(s.latitude,s.longitude,s.distance)}handleFocus(e){if(this.readerFocusFilter&&!this.readerFocusFilter(e))return;if(this.focusedBody?.data.id===e.data.id){this.deps.callbacks.onFocusChange(e);return}if(this.setFocusTarget(e),e.positionUnknown)return;let{latitude:t,longitude:n,distance:r}=nC(this.cameraTruePos(),e.position,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(t,n,r)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;cn(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=hM(u,r),f=hM(e,r),p=u&&(cn(u)?u.featureAnchor.hostId:u.data.id),m=cn(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&iO(e)}if(d&&d!==f){let e=r.get(d);e&&OM(e)}this.focusedBody=e,cn(e)||(n.bodies.focusFeature=null),i.minDistance=WL(e,TO(r.get(e.data.id)));let g=cn(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),cn(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus(),e.positionUnknown||LL(o,[...e.position],s,this.cameraTruePos(),t,Ax().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,clock:a,focus:o,camera:s,callbacks:c,pointClouds:l}=this.deps,u=i.getBody(e);if(!u)return 0;if(i.bodies.bodiesById.has(e)||wT(u,a.jd,i),u.positionUnknown)return this.setFocusTarget(u),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=rC(u.position,n,r,t,this.focusedBodyQuat(u));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u.position[0]-e[0],u.position[1]-e[1],u.position[2]-e[2]).normalize().negate();d=[u.position[0]+n.x*t,u.position[1]+n.y*t,u.position[2]+n.z*t]}let f=nC(d??this.cameraTruePos(),u.position,this.focusedBodyQuat(u));return c.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?this.focusedBody?.data.id===e&&L_(o.focusTruePos,u.position)<WL(u)?(o.focusTruePos=[...u.position],this.deps.repositionAll(),l.rebuildBasis(),RL(o,s,this.cameraTruePos(),d,Ax().resolvedReducedMotion)):(this.setFocusTarget(u,d),n!==void 0&&r!==void 0&&(o.orbitFly=!0)):this.setFocusTarget(u),o.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e);!i||i.positionUnknown||(this.settleOnBodyInstant(i),this.snapToBodyFrame(t,n,r))}snapToBodyFacing(e,t,n,r){let{ctx:i,camera:a,controls:o,callbacks:s}=this.deps,c=i.getBody(e);if(!c||c.positionUnknown)return;this.settleOnBodyInstant(c);let l=i.getBody(t)?.position??[0,0,0],u=iC(c.position,l,n,r);a.position.set(u[0],u[1],u[2]),o.update();let d=nC(u,[0,0,0]);s.onCameraPosition?.(d.latitude,d.longitude,d.distance),this.pendingInitialView=null}settleOnBodyInstant(e){let{focus:t,pointClouds:n}=this.deps;this.setFocusTarget(e),t.focusTruePos=[...e.position],t.focusOriginWorld=[...e.position],t.focusTargetWorld=[...e.position],t.focusStartTime=-DL,t.camOriginWorld=null,t.camTargetWorld=null,t.flyQ0=null,t.orbitFly=!1,t.arcOrbit=!1,t.cameraStaysOnBody=!1,this.deps.repositionAll(),n.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!GD(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=rC([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=nC(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),s&&c[0]===0&&c[1]===0&&c[2]===0&&c[3]===1&&(this.pendingInitialView={latitude:e,longitude:t,zoom:n})}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===1){this.pendingInitialView=null;return}let n=rC([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function $L(e,t){if(!e)return[];if(cn(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&uj(n)?[n]:[]}let n=[];if(uj(e)&&n.push(e),e.data.objectType===G.MOON||e.data.orbitalSource===tn.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var eR=1e-6;function tR(e){return e.data.name??e.data.id}var nR=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}coverageFor(e){let t=this.coverage.get(e);if(t!==void 0)return t??void 0;this.pending.has(e)||(this.pending.add(e),px(e,!1).then(t=>this.coverage.set(e,t.global?.coverage??null)).catch(()=>this.coverage.set(e,null)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.id??null,r=n===null?void 0:this.coverageFor(n);if(!e||!r){this.disarm();return}this.armedProbeId!==n&&(this.dismissNotice(),this.armedProbeId=n);let i=r.end_jd-eR,a=r.start_jd+eR;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:i,backwardJd:a,onHit:t=>this.onHit(e,t,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:tR(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)}},rR=class{group=new Ra;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()}},iR=Math.PI/180;function aR(e){return`latitude`in e}function oR(e,t){let n=e*iR,r=t*iR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function sR(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 cR(e,t,n){let r=t.getBody(e.body);if(!r)return null;let[i,a,o]=r.position;if(aR(e)){let t=Q(mn(r.data)+(e.altitudeKm??0)),[s,c,l]=oR(e.latitude,e.longitude),u=r.orientation?dC(r.orientation,n,r.nutPrec):null;if(!u)return[i+s*t,a+c*t,o+l*t];let d=[0,0,0];return sR(u,s,c,l,d,0),[i+d[0]*t,a+d[1]*t,o+d[2]*t]}let s=typeof e.offsetKm==`function`?e.offsetKm(n):e.offsetKm;if(s===null)return null;if(s===void 0)return[i,a,o];let[c,l,u]=yF(s);return[i+c,a+l,o+u]}function lR(e,t,n){let r=n.getBody(e.body);if(!r)return null;let i=t[0]-r.position[0],a=t[1]-r.position[1],o=t[2]-r.position[2],s=Math.hypot(i,a,o);return s===0?null:[i/s,a/s,o/s]}function uR(e){let t=rg/10;return[e[0]*t,-e[2]*t,e[1]*t]}function dR(e,t,n){let r=cR(e.position,t,n),i=cR(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 fR=.02,pR=1e-4;function mR(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=GD(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){if(!n)continue;let r=Q(mn(n.data));if(!(r>0))continue;let i=Math.hypot(e.position.x-(n.position[0]-t[0]),e.position.y-(n.position[1]-t[1]),e.position.z-(n.position[2]-t[2]));s=Math.min(s,i-r)}let c=o?Q(mn(o.data)):0,l=Math.tan(Bi.degToRad(e.getEffectiveFOV())/2);return{rotate:hR(c>0?(a-c)*l/(Math.PI*c):1,pR),translate:hR(s/a,fR)}}function hR(e,t){return Math.min(1,Math.max(t,e))}var gR=Math.PI/180;function _R(e,t){let n=e*gR,r=t*gR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function vR(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new JO(i),[o,s,c]=_R(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function yR(e){e.parent?.remove(e),e.element.remove()}var bR=new J;function xR(e,t,n){if(!e)return;let r=t.get(f_);if(!r?.mesh)return;bR.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=bR.x,a=bR.y,o=bR.z,s=r.mesh.position,c=n.position.x-s.x,l=n.position.y-s.y,u=n.position.z-s.z,d=r.radiusScene,f=d*d;e.visible=c*c+l*l+u*u<=f||i*c+a*l+o*u>f}var SR=-1,CR=.05,wR=.4,TR=1.2,ER=Q(1e6),DR=.02,OR=2,kR=2.3,AR=.9,jR=new J,MR=.25,NR=10,PR=4,FR=4,IR=28,LR=.02,RR=class e{renderer;composer;atmoDepthPass;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=GM();pointClouds;systemData;positionDiagnostics=new SI;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new rR;cameraHold=null;holdingCamera=!1;_tmpV3=new J;cameraBand=null;focusableBodies=null;limitsArmed=!1;bodySelectEnabled=!0;featureSelectEnabled=!0;modelScene;modelCamera;modelLight;overlayActive=!1;modelShadowPlane=null;_tmpUp=new J;_tmpSun=new J;_planeNormal=new J(0,0,1);_modelRaycaster=new Ld;_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:DL};lastUpdatedJd=NaN;lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;focusWasOutOfRange=!1;_positionMapScratch=new Map;frameIndex=0;static WAKE_FRAMES=30;static IDLE_HEARTBEAT_FRAMES=10;static REALTIME_FRAME_MS=30;wakeUntilFrame=e.WAKE_FRAMES;lastRenderedFrame=0;lastRenderMs=0;lastRenderedJd=NaN;lastRenderedFocusKey=``;lastRenderedCamPos=new J(NaN,NaN,NaN);lastRenderedCamQuat=new Vi;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=qx();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;textureLoader=new qu;appearances=new nM;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(d_)?.extraObjects.find(e=>e instanceof ud)}tightFar=!1;sunProxyK=1;sunBaseMeshScale=1;sunBaseCoronaScale=0;userLocationMarker=null;labelContainer;static MAP_LAYER=1;static ATMO_DEPTH_LAYER=2;constructor(t,n,r,i,a,o){this.canvas=t,this.ctx=r,r.hasMeshBody=e=>this.bodyObjects.has(e),this.clock=i,this.callbacks=o,this.outOfRange=new lI(o.notices),this.labelContainer=n;let s=CT(t,n,r);this.viewportH=t.clientHeight||1,this.renderer=s.renderer,this.labelRenderer=s.labelRenderer,this.scene=s.scene,this.scene.add(this.extensions.group),this.camera=s.camera,this.composer=s.composer,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new pj(c.x,c.y),this.modelScene=new Ka,this.modelScene.environment=yT(this.renderer),this.modelScene.environmentIntensity=gT,this.modelCamera=new od(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new md(16777215,mT);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new pd(16777215,hT),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 ks(new Ql(40,40),new ru({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new bN(this.scene),this.skyDebugMarkers=new RN(this.scene),this.haloDebug=new qN(this.canvas),this.travelPath=new YF(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new eI(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),uS(this.scene,this.renderer,r);let u=r.bodies.majorBodies.find(e=>e.data.id===d_),d=r.getBody(a.id),f=d&&!d.positionUnknown?d:void 0,p=r.bodies.majorBodies.find(e=>e.data.id===sC)||u,m=f??p,h=m?.position??[0,0,0];this.focus.focusTruePos=[...h],this.focus.focusOriginWorld=[...h],this.focus.focusTargetWorld=[...h],this.focus.focusStartTime=-DL,this.pointClouds=new EP(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(h),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new PS(this.camera,t),this.controls.enableDamping=!0,this.controls.dampingFactor=Ax().resolvedReducedMotion?wR:CR,this.controls.minDistance=m?WL(m):Q(.01),this.controls.maxDistance=31620.5*10,this.controls.target.set(0,0,0),this.controls.update(),this.controls.addEventListener(`end`,this.onControlsEnd),this.controls.addEventListener(`start`,this.invalidate),this.controls.addEventListener(`start`,this.armLimits),this.controls.addEventListener(`end`,this.invalidate);for(let n of e.INPUT_EVENTS)t.addEventListener(n,this.invalidate,{passive:!0});window.addEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded=r.bodies.onBodiesAdded(this.invalidate),this.cameraUp=new qO(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new vN(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new QL({ctx:r,clock:i,camera:this.camera,controls:this.controls,scene:this.scene,bodyObjects:this.bodyObjects,clickables:this.clickables,meshToBody:this.meshToBody,callbacks:o,focus:this.focus,pointClouds:this.pointClouds,systemData:this.systemData,loadTexture:e=>this.maybeLoadTexture(e),repositionAll:()=>this.repositionAll(),assignMapLayerToTrails:()=>this.assignMapLayerToTrails()},m,this.hoveredBodyIds,this.circleTexture,this.renderer),this.coverageWatch=new nR(i,o.notices);let g=f?a:{latitude:45,longitude:0,zoom:15},_=rC([0,0,0],g.latitude,g.longitude,g.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(..._),this.focusController.setPendingInitialView({latitude:g.latitude,longitude:g.longitude,zoom:g.zoom}),m&&r.visibility.setFocused(m),r.visibility.updateCamera(g.zoom,this.clock.jd),o.onFocusChange(m),this.buildScene(),m&&this.focusController.promotion.ensureBodyObjects(m),m&&this.focusController.syncUpgradeTargets(m),this.repositionAll(),m&&this.maybeLoadTexture(m),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new FO(this.renderer,this.camera),this.pointerInteraction=new AO(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(){lj(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,this.circleTexture,this.renderer.domElement,e=>this.focusController.handleFocus(e),(e,t)=>{t?this.hoveredBodyIds.add(e):this.hoveredBodyIds.delete(e),this.invalidate()}),this.pointClouds.buildInitial(new Set(this.bodyObjects.keys()));let e=this.pointClouds.basis();(globalThis.requestIdleCallback??(e=>setTimeout(e,0)))(()=>{mN(this.bodyObjects,this.scene,e,this.clock.jd),this.assignMapLayerToTrails()})}setTravelPath(e,t=[],n=[],r=[]){this.travelPath.set(e,t,n,r),this.refreshTravelPath()}setTravelHover(e){this.travelPath.setHovered(e)}setOrbitPreview(e,t=null){this.orbitPreview.set(e),this.refreshOrbitPreview(),t&&this.frameOrbitPreview(t)}frameOrbitPreview(e){let t=this.ctx.getBody(e.bodyId);if(!t)return;let n=Q(e.radiusKm);if(!(n>0)||performance.now()-this.focus.focusStartTime<this.focus.focusDurationMs&&this.previewFlyBodyId===e.bodyId)return;let r=this.focus.focusTruePos,i=t.position[0]-r[0]-this.camera.position.x,a=t.position[1]-r[1]-this.camera.position.y,o=t.position[2]-r[2]-this.camera.position.z,s=Math.hypot(i,a,o);s>n*1.35&&s<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.ctx.getBody(e)?.position??null,this.focus.focusTruePos),this.orbitPreview.updateCameraOffset(this.camera.position))}refreshTravelPath(){if(this.travelPath.isEmpty){this.reserveTravelLabelSpace();return}let e=this.travelPath.centerId,t=e?this.ctx.getBody(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.clock.jd),this.travelPath.reposition(t.position,this.focus.focusTruePos,e=>this.ctx.getBody(e)?.position??null),this.travelPath.updateCameraOffset(this.camera.position),this.reserveTravelLabelSpace()}reserveTravelLabelSpace(){this.travelPath.reserveLabelSpace(this.camera,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)}focusOnPathPoint(e,t){this.disarmLimits();let n=this.ctx.getBody(e);if(!n)return;let[r,i,a]=yF(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n.position);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=yF(t);this.travelFocus={centerId:e,local:[n,r,i]}}travelFocusWorld(e){let t=this.travelFocus;return t?[e[0]+t.local[0],e[1]+t.local[1],e[2]+t.local[2]]:null}refreshTravelFocus(){if(!this.travelFocus)return;if(this.focusController.current){this.travelFocus=null;return}let e=this.ctx.getBody(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e.position);if(!t)return;let n=this.focus;n.focusTargetWorld=t;let r=n.camTargetOffset;r&&n.camTargetWorld&&(n.camTargetWorld=[t[0]+r[0],t[1]+r[1],t[2]+r[2]]),performance.now()-n.focusStartTime>=n.focusDurationMs&&(n.focusTruePos=[...t])}updateTravelCraftSystem(){let e=this.travelFocus,t=this.travelPath.plan;if(!e||!t){this.ctx.visibility.clearTravelSystem();return}let n=this.ctx.getBody(e.centerId),r=n?this.travelFocusWorld(n.position):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId);if(!t)continue;let n=this.ctx.visibility.resolveSystemId(t);if(!n)continue;let a=this.ctx.visibility.systemReachAU(n);if(!(a>0))continue;let o=L_(r,t.position)/10;!i&&o<=a?i=n:o<=a*2?this.systemData.prefetch(n):this.systemData.discardPrefetch(n)}this.ctx.visibility.setTravelSystem(i)}assignMapLayerToTrails(){for(let t of this.bodyObjects.values())t.trail&&t.trail.layers.set(e.MAP_LAYER)}setImmersive(t){t?(this.camera.layers.disable(e.MAP_LAYER),this.labelContainer.style.display=`none`):(this.camera.layers.enable(e.MAP_LAYER),this.labelContainer.style.display=``)}rebuildMinorPointClouds(){this.pointClouds.rebuildMinor()}repositionAll(){this.repositionBodies(),this.rebuildTrailBasis()}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let[i,a,o]=r.body.position,s=i-e,c=a-t,l=o-n;r.group.position.set(s,c,l);for(let e of r.extraObjects)e.position.set(s,c,l)}this.pointClouds.reposition()}rebuildTrailBasis(){let e=this.focus.focusTruePos,[t,n,r]=e;for(let i of this.bodyObjects.values()){let a=i.trail;if(!a)continue;let o=a.userData.trailBuffer;if(o){UP(i.body,a,o,e,this.clock.jd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;WP(a,s,c.x-t,c.y-n,c.z-r)}}tick=()=>{this.rafId=requestAnimationFrame(this.tick),this.frameIndex++;let t=performance.now(),n=this.lastTickMs?t-this.lastTickMs:0;if(this.lastTickMs=t,this.holdingCamera||this.cameraUp.update(this.clock.jd),this.firstFrame&&(this.firstFrame=!1,this.controls.target.set(0,0,0),this.controls.update()),this.coverageWatch?.sync(this.focusController.current,this.clock.jd),this.clock.tick(performance.now()),!this.shouldRender(t)){this.controls.update(),this.applyReaderLimits(t);return}this.fpsSamples.length<e.FPS_SAMPLE_FRAMES?this.fpsSamples.push(t):(this.fpsSamples[this.fpsSampleHead]=t,this.fpsSampleHead=(this.fpsSampleHead+1)%e.FPS_SAMPLE_FRAMES);let r=this.lastRenderedFrame===this.frameIndex-1?n:0;this.lastRenderedFrame=this.frameIndex,this.lastRenderMs=t,this.lastRenderedJd=this.clock.jd,this.lastRenderedFocusKey=this.focusKey(),this.lastRenderedCamPos.copy(this.camera.position),this.lastRenderedCamQuat.copy(this.camera.quaternion),this.applyJdUpdate(!0),this.refreshTravelFocus(),this.callbacks.onFrame?.(this.clock.jd,r);let i=this.holdingCamera?this.applyHeldCamera():IL(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=P_(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||cn(a);t&&GL(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),SO(this.bodyObjects.get(a.data.id))&&GL(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(mR(this.camera,this.focus.focusTruePos,a,t,n))}else this.setMotionScale({rotate:1,translate:1});if(this.pendingUrlWrite&&i){this.pendingUrlWrite=!1;let{latitude:e,longitude:t,distance:n}=this.getCameraState();this.callbacks.onCameraPosition?.(e,t,n)}this.systemData.hasPendingUnloads()&&performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&this.systemData.drainPendingUnloads();let{distance:o}=this.getCameraState();this.updateTravelCraftSystem(),this.ctx.visibility.updateCamera(o,this.clock.jd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.clock.jd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=aF(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(),xI(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),DI(this.bodyObjects,this.focus.focusTruePos,Ax().realisticLighting,Ax().overexposeRings,this.camera.position,this.pxPerRad()),rL(this.bodyObjects,this.focus.focusTruePos);let s=tL(this.bodyObjects,this.camera.position,Ax().showAtmospheres,Ax().realisticLighting,this.sunIntensityScale,Ik(),this.clock.jd);qk(r,s.shellProminent),this.scene.backgroundIntensity=s.skyboxIntensity,this.applyLayerChrome();let c=this.bodyObjects.get(d_);c&&rj(c.corona,c.starPoint,s.sunTint);let l=Ax().highAmbient?1:mT;if(!Ax().highAmbient&&Ax().realisticLighting){let e=this.bodyObjects.get(d_)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;l*=_T(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=l;xR(this.userLocationMarker,this.bodyObjects,this.camera);let u=hM(this.focusController.current,this.bodyObjects);EL(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,u,this.clock.jd,this.appearances),wL(this.bodyObjects,this.camera,this.renderer,this.ctx,u),aL(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,Ax().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(s.sunRefraction),s.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.composer.render(),this.renderModelOverlay(),this.labelRenderer.render(this.scene,this.camera),this.haloDebug.active&&this.haloDebug.draw(this.bodyObjects,this.camera,this.focus.focusTruePos,this.focusController.current?.data.id,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)};updateTightFar(e){if(tT())return;let t=this.focusController.current,n=t?hM(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e;if(t&&r&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[i,o,s]=r.body.position,c=this.camera.position;a=Math.hypot(e+c.x-i,t+c.y-o,n+c.z-s)}let o=this.tightFar?kR:OR;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*o}updateDepthFar(){if(tT())return;let e=bT,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(d_);if(this.tightFar){let e=this.bodyObjects.get(t)?.body;if(e){let o=Math.hypot(e.position[0]-n,e.position[1]-r,e.position[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s&&o(s.body.position);for(let e of this.bodyObjects.values())this.ctx.visibility.hasFullRendering(e.body)&&o(e.body.position);e=Math.min(bT,Math.max(ER,Math.sqrt(a)*TR))}Math.abs(e-this.camera.far)>this.camera.far*DR&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(d_);if(!t)return;let[n,r,i]=this.focus.focusTruePos,[a,o,s]=t.body.position,c=a-n,l=o-r,u=s-i;if(e){let t=this.camera.position,n=this._tmpV3.set(c-t.x,l-t.y,u-t.z),r=n.length();n.divideScalar(r);let i=jR.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),c=t.x+n.x*r,l=t.y+n.y*r,u=t.z+n.z*r)}let d=1;if(this.tightFar){let e=this.camera.far*AR,t=Math.hypot(c,l,u);t>e&&(d=e/t)}if(!(d===1&&this.sunProxyK===1&&!e)){this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.group.position.set(c*d,l*d,u*d);for(let e of t.extraObjects)e.position.set(c*d,l*d,u*d);t.mesh?.scale.setScalar(this.sunBaseMeshScale*d),t.corona?.scale.set(this.sunBaseCoronaScale*d,this.sunBaseCoronaScale*d,1),this.sunProxyK=d}}setMotionScale(e){this.motionScale=e,this.controls.rotateSpeed=e.rotate,this.controls.panSpeed=e.translate,this.controls.zoomSpeed=e.translate}isLanded(e){return!!this.bodyObjects.get(e)?.isLanded}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=ow(t*Math.PI/180,n*Math.PI/180);return Ow(this.bodyObjects.get(e),e,mn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(SO(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:wO(n),centerOffsetScene:CO(n),radialKm:e=>xO(n,e)};if(!(!t||!e.orientation))return{invQuat:dC(e.orientation,this.clock.jd,e.nutPrec).invert(),seated:t,radialKm:t=>Ow(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&GD(t.body)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model,r=t.modelRoot;if(!(!n||!r)){if(e)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==r){r.add(n);let e=n.userData;n.scale.setScalar(e.fitScale??1),n.position.set(0,0,0),e.centerOffset&&n.position.addScaledVector(e.centerOffset,-1)}}}if(e){this.shadowLight.castShadow=!1;return}this.updateFocusedMountedModel()}updateFocusedMountedModel(){let e=this.overlayModelBo(),t=e?.model&&e.model.parent===e.modelRoot?e.modelRoot:null;if(!e||!t){this.shadowLight.castShadow=!1;return}let n=ZD(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(d_)?.body;if(!i)return;let[a,o,s]=i.position,[c,l,u]=e.body.position;this._tmpSun.set(a-c,o-l,s-u).normalize(),this.shadowLight.position.copy(e.group.position).addScaledVector(this._tmpSun,NR*n),this.shadowLight.target.position.copy(e.group.position);let d=this.shadowLight.shadow.camera;d.left=d.bottom=-PR*n,d.right=d.top=PR*n,d.near=FR*n,d.far=IR*n,d.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=LR*n}renderModelOverlay(){if(!this.overlayActive)return;let e=this.overlayModelBo();if(!e?.model)return;let t=e.model.userData;e.model.scale.setScalar(t.fitScale??1),e.model.position.set(0,0,0),e.isLanded&&t.feetOffset?e.model.position.copy(t.feetOffset).applyQuaternion(e.model.quaternion).multiplyScalar(-1):t.centerOffset&&e.model.position.copy(t.centerOffset).multiplyScalar(-1),this._tmpV3.copy(this.camera.position).sub(e.group.position);let n=this._tmpV3.length(),r=ZD(e),i=n/r;this.modelCamera.position.copy(this._tmpV3).normalize().multiplyScalar(i),this.modelCamera.quaternion.copy(this.camera.quaternion),this.modelCamera.aspect=this.camera.aspect;let a=0;for(let t of this.bodyObjects.values()){let n=t.model;if(!n||t===e)continue;let i=ZD(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.group.position,e.group.position).divideScalar(r);let s=n.userData;s.centerOffset&&n.position.addScaledVector(s.centerOffset,-i);let c=n.position.length()+i;c>a&&(a=c)}this.modelCamera.near=Math.max(.01,i-5-a),this.modelCamera.far=i+50+a,this.modelCamera.updateProjectionMatrix();let o=this.bodyObjects.get(d_)?.body,s=1;if(o){let[t,n,r]=o.position,[i,a,c]=e.body.position;this._tmpSun.set(t-i,n-a,r-c),Ax().realisticLighting&&(s=_T(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)}if(this.modelShadowPlane){this._tmpUp.set(0,1,0).applyQuaternion(e.model.quaternion);let t=this._tmpSun.dot(this._tmpUp)>.03;this.modelShadowPlane.visible=!!e.isLanded&&t,this.modelShadowPlane.visible&&this.modelShadowPlane.quaternion.setFromUnitVectors(this._planeNormal,this._tmpUp)}this._tmpV3.set(0,0,0);let c=RC(this._tmpV3,this._tmpV3)*s;this.modelLight.intensity=hT*c*this.sunIntensityScale,this.modelScene.environmentIntensity=gT*c,this.showPointingAxes?(this.pointingAxes||(this.pointingAxes=this.buildPointingAxes(),this.modelScene.add(this.pointingAxes)),this.pointingAxes.quaternion.copy(e.model.quaternion),this.pointingAxes.scale.setScalar(Math.min(.8,.45*i)),this.pointingAxes.visible=!0):this.pointingAxes&&(this.pointingAxes.visible=!1),this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.render(this.modelScene,this.modelCamera),this.renderer.autoClear=!0}pxPerRad(){return this.viewportH/2/Math.tan(this.camera.fov*Math.PI/360)}trailView(){let e=this._trailView,t=this.camera.position;return e.camX=t.x,e.camY=t.y,e.camZ=t.z,e.tolAngle=MR/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 nC([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?SR:Cn.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||KL(this.camera,this.cameraBand,this.focusController.focusedBodyQuat())}static INPUT_EVENTS=[`pointerdown`,`pointermove`,`pointerup`,`wheel`];invalidate=()=>{this.wakeUntilFrame=this.frameIndex+e.WAKE_FRAMES};focusKey(){let e=this.ctx.visibility;return`${this.focusController.current?.data.id??``}|${e.focusedSystemId??``}|${e.activeSystemId??``}`}cameraOffsetFromFocus(){let e=this.focusController.current,t=this.focus.focusTruePos,n=this.camera.position;return e?[n.x+t[0]-e.position[0],n.y+t[1]-e.position[1],n.z+t[2]-e.position[2]]:[n.x,n.y,n.z]}holdCamera(){this.holdingCamera||(this.disarmLimits(),this.holdingCamera=!0,this.controls.enabled=!1,this.focus.camOriginWorld=null,this.focus.camTargetWorld=null,this.focus.camTargetOffset=null,this.focus.camOriginOffset=null,this.focus.flyQ0=null,this.focus.orbitFly=!1,this.focus.arcOrbit=!1,this.focus.cameraStaysOnBody=!1)}setHeldPose(e){this.cameraHold=e}releaseCamera(){this.holdingCamera&&(this.holdingCamera=!1,this.cameraHold=null,this.controls.enabled=!0,this.controls.target.set(0,0,0),this.controls.enableDamping=!1,this.controls.update(),this.controls.enableDamping=!0,this.invalidate())}applyHeldCamera(){let e=this.cameraHold,t=e&&dR(e,this.ctx,this.clock.jd);if(!t)return!0;let n=this.focus.focusTruePos;return this.camera.up.set(t.up[0],t.up[1],t.up[2]).normalize(),this.camera.position.set(t.position[0]-n[0],t.position[1]-n[1],t.position[2]-n[2]),this.camera.lookAt(t.target[0]-n[0],t.target[1]-n[1],t.target[2]-n[2]),!0}shouldRender(t){if(this.holdingCamera||t-this.focus.focusStartTime<this.focus.focusDurationMs||this.focusKey()!==this.lastRenderedFocusKey||this.ctx.bodies.minorStreaming||this.pointClouds.hasPendingSceneAdds()||this.systemData.hasPendingUnloads())return!0;if(this.covered)return!1;if(this.frameIndex-this.lastRenderedFrame>=e.IDLE_HEARTBEAT_FRAMES)return!0;let n=this.camera;return n.position.distanceToSquared(this.lastRenderedCamPos)>n.position.lengthSq()*1e-10||8*(1-Math.abs(n.quaternion.dot(this.lastRenderedCamQuat)))>1e-8||this.frameIndex<this.wakeUntilFrame||this.haloDebug.active?!0:this.clock.jd===this.lastRenderedJd?!1:Math.abs(this.clock.timeScale)>1||t-this.lastRenderMs>=e.REALTIME_FRAME_MS}onControlsEnd=()=>{this.pendingUrlWrite=!0,this.focusController.clearPendingInitialView()};nudgeCamera(e,t,n){this.armLimits();let{rotate:r,translate:i}=this.motionScale;e!==0&&this.controls.rotateLeft(e*r),t!==0&&this.controls.rotateUp(t*r),n!==1&&this.controls.dollyIn(1/n**+i),this.onControlsEnd()}maybeLoadTexture(e){let t=this.bodyObjects.get(e.data.id);t&&(Qj(t,this.textureLoader,this.clock.jd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(fC(t.mesh,e.orientation,this.clock.jd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}),tO(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=WL(t.body,TO(t))),!this.ctx.layers.skipped.has(`nomenclature`))return CM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&DM(t,this.selectedFeatureId)}))}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&(iO(t),eM(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=hM(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&DM(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&&!cn(e))return null;let t=P_(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`}|${hw()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==tn.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),mx(e.data.id).then(e=>e&&t.registerCarried(e)));let n=`${e.data.id}@${this.clock.jd}`;if(n===this.lastProbeTargetCheck)return;this.lastProbeTargetCheck=n;let r=t.stampedFitCenterAt(e.data.id,this.clock.jd);if(!r)return;let i=this.ctx.getBody(r);if(!i){if(this.requestedProbeTargets.has(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Ng(this.clock.jd));return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}applyJdUpdate(e=!1){this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0;if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion){this.clock.seeked=!1;return}let i=this.clock.seeked;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.ctx.refreshTick(Ng(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let a=bI({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,positionMap:this._positionMapScratch,diagnostics:this.positionDiagnostics,trailView:this.trailView(),frame:this.frameIndex,outOfRange:this.outOfRange});this.pointClouds.updateForJd(this.clock.jd,this.cloudViewInfo()),this.refreshTravelFocus(),performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&(this.repositionBodies(),this.pointClouds.maybeRebase()),this.syncLandedNomenclature();let o=a.focusedOutOfRange&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=a.focusedOutOfRange,e&&i&&o&&a.reanchorId){let e=this.ctx.getBody(a.reanchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.controls.dampingFactor=e?wR:CR}focusOnBody(e,t,n,r){return this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.focusOnBody(e,t,n,r)}focusOnFeature(e,t,n,r=`frame`,i){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1;let a=this.ctx.getBody(e.hostId);if(!a)return 0;this.focusController.clearPendingInitialView();let o=hM(this.focusController.current,this.bodyObjects)===e.hostId,s=jw(e,t);this.ctx.bodies.focusFeature=s;let c=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,c&&DM(c,e.featureId),Rw(s,a,c,this.clock.jd);let l=s.position,u=this.focusController.focusedBodyQuat(s);if(r===`pan`){let e=nC(this.focusController.cameraTruePos(),l,u);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(s),this.focus.focusDurationMs}let d=l[0]-a.position[0],f=l[1]-a.position[1],p=l[2]-a.position[2],m=Math.hypot(d,f,p);m>1e-9?(d/=m,f/=m,p/=m):(d=0,f=1,p=0);let h=r===`snap`&&i?rC(l,i.latitude,i.longitude,i.zoom,u):[l[0]+d*n,l[1]+f*n,l[2]+p*n],g=nC(h,l,u);if(this.callbacks.onCameraPosition?.(g.latitude,g.longitude,g.distance),r===`snap`){this.focusController.setFocusTarget(s,h);let e=this.focus;return e.focusTruePos=[...l],e.focusOriginWorld=[...l],e.focusTargetWorld=[...l],e.focusStartTime=-DL,e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1,this.repositionAll(),this.pointClouds.rebuildBasis(),this.camera.position.set(h[0]-l[0],h[1]-l[1],h[2]-l[2]),this.controls.update(),0}if(o){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(s),this.focus.focusTruePos=[...l],this.camera.position.set(e[0]-l[0],e[1]-l[1],e[2]-l[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),RL(this.focus,this.camera,e,h,Ax().resolvedReducedMotion)}else this.focusController.setFocusTarget(s,h),this.focus.orbitFly=!0;return this.focus.focusDurationMs}pickFocusedModel(e,t){if(!this.overlayActive||!this.overlayModelBo()?.model)return null;this._pickNdc.set(e,t),this._modelRaycaster.setFromCamera(this._pickNdc,this.modelCamera);let n=null,r=1/0;for(let e of this.bodyObjects.values()){if(!e.model)continue;let t=this._modelRaycaster.intersectObject(e.model,!0);t.length>0&&t[0].distance<r&&(r=t[0].distance,n=e.body)}return n}overlayModelBo(){let e=this.focusController.current;if(!e){let e=this.travelFocus?.centerId,t=e?this.bodyObjects.get(e):void 0;return t?.model?t:null}let t=cn(e)?e.featureAnchor.hostId:e.data.id,n=this.bodyObjects.get(t);if(n?.model)return n;if(e.data.orbitalSource===tn.SPICE_PROBE&&!n?.isLanded){let t=this.bodyObjects.get(e.data.parentId);if(t?.model)return t}return null}snapToBodyFacing(e,t,n,r){this.disarmLimits(),this.focusController.snapToBodyFacing(e,t,n,r)}snapToBody(e,t,n,r){this.disarmLimits(),this.focusController.snapToBody(e,t,n,r)}setFocusTarget(e,t){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.setFocusTarget(e,t)}getFocusedBody(){return this.focusController.current}getDebugStats(){let t=this.fpsSamples,n=0;if(t.length>=2){let r=t.length<e.FPS_SAMPLE_FRAMES?0:this.fpsSampleHead,i=t[r],a=(t[(r-1+t.length)%t.length]-i)/1e3;a>0&&(n=(t.length-1)/a)}return QN({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)}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:GD(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 Ra,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new Wd(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 qo({map:new Mc(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=hb(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&&TA(n,e)}getSkyboxAdjust(){return this.skyboxAdjuster.get()}setSkyboxAdjust(e,t,n){this.skyboxAdjuster.set(e,t,n)}setSkyDebugMarkersVisible(e){this.skyDebugMarkers.setVisible(e)}applyLayerChrome(){this.ctx.layers.isVisible(`stars`)?this.stashedSky&&=(this.scene.background=this.stashedSky,null):this.scene.background&&(this.stashedSky=this.scene.background,this.scene.background=null);let e=this.ctx.layers.isVisible(`labels`);e!==this.namesShown&&(this.namesShown=e,this.labelContainer.classList.toggle(`scene-overlay--no-names`,!e))}setHaloDebugVisible(e){this.haloDebug.setVisible(e)}setUserLocation(e,t){let n=this.bodyObjects.get(f_);n?.mesh&&(this.userLocationMarker&&yR(this.userLocationMarker),this.userLocationMarker=vR(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(yR(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(Jx()),this.composer.setPixelRatio(Jx()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),uS(this.scene,this.renderer,this.ctx),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=qx();let e=Jx();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),lT(e,t)}dispose(){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&&iO(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),zR(this.scene.background),zR(this.scene.environment),zR(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.renderer.dispose()}disposeScene(e){let t=new Set;e.traverse(e=>{let n=e;n.geometry?.dispose();let r=n.material,i=Array.isArray(r)?r:r?[r]:[];for(let e of i)if(!t.has(e)){t.add(e);for(let t of Object.values(e))zR(t);e.dispose()}})}};function zR(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var BR=Xe({progress:null,bootPending:!1}),VR=6371;function HR(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 UR={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:HR(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},WR=1.6,GR=1.0005,KR=new J(.55,.25,.8).normalize(),qR=[`low`,`medium`,`high`,`ultra`],JR=4,YR=12,XR=10,ZR=16,QR=5;function $R(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function ez(e,t){let n=`low`;for(let r of e.tiers){let e=$R(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var tz=new Set([`WebKit WebGL`,`Mozilla`,``]);function nz(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!tz.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function rz(e,t){let n=e.getContext(),r=new Ka,i=new od(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new pu({color:7829367,roughness:1,metalness:0}),o=new ks(new nu(1,64,64),a);o.renderOrder=1,r.add(o);let s=new pd(16777215,2);s.position.copy(KR),r.add(s);let c=UR,l=_A(c,1,VR),u=l.material.uniforms;u.uSunDir.value.copy(KR),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,GR,0),i.lookAt(1,GR+.1,0)):(i.position.set(0,0,WR),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}={})=>{wA(l,Nk[e]),d(t);let i=0;for(let e=0;e<JR;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(ZR,Math.max(1,Math.ceil(XR/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<YR;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=QR){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(),OA(l)}}}function iz(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 az(e,t){let n=t.tiers??qR,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=rz(e,i),c=JR+YR,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`?JR: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`?YR:JR,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(Nk[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 iz(e,n,f,p)}var oz=60,sz=100,cz=3e4,lz=25e4,uz=`v1`,dz=!1,fz=null,pz=Promise.resolve();function mz(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/lz);return`${nz(e)}|${n}|${uz}`}function hz(){dz||typeof window>`u`||(dz=!0,BR.bootPending=!0,pz=new Promise(e=>{let t=()=>{BR.bootPending=!1,e()};setTimeout(t,cz),setTimeout(()=>void _z(!1).finally(t),sz)}))}function gz(){return pz}function _z(e){return fz??=vz(e).finally(()=>fz=null),fz}async function vz(e){let t=Ax();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new uh({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(Ux()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=mz(n);if(!e&&t.atmosphereCalibration?.key===r)return;BR.progress=0;let i=await az(n,{budgetMs:1e3/oz,startTier:Pk(),onProgress:e=>BR.progress=e.fraction}),a={};for(let e of i.tiers){let t=$R(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=ez(i,1e3/oz);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{BR.progress=null,n?.dispose(),n?.forceContextLoss()}}var yz=class{object=new Ra;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 JO(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,jk(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?cR(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}){let r=lR(this.anchor,e,n);if(!r)return!0;let{position:i}=this.label,a=t.position.x-i.x,o=t.position.y-i.y,s=t.position.z-i.z;return r[0]*a+r[1]*o+r[2]*s>0}dispose(){this.label.removeFromParent(),this.element.remove()}},bz=1e-9,xz=class{object=new Ra;anchor;color;widthPx;opacity;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;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.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,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,ctx:r}){let i=this.mesh;if(!i)return;let a=this.wanted&&this.count>=2?cR(this.anchor,r,e):null;if(i.visible=a!==null,!a)return;let o=[a[0]-t[0],a[1]-t[1],a[2]-t[2]];(this.dirty||Math.abs(o[0]-this.lastOrigin[0])>bz||Math.abs(o[1]-this.lastOrigin[1])>bz||Math.abs(o[2]-this.lastOrigin[2])>bz)&&(this.writeVertices(i,o),this.lastOrigin=o,this.dirty=!1),i.material.uniforms.uCenterOffset.value.copy(n.position).negate()}writeVertices(e,t){for(let e=0;e<this.count;e++)this.scratch[e*3]=this.local[e*3]+t[0],this.scratch[e*3+1]=this.local[e*3+1]+t[1],this.scratch[e*3+2]=this.local[e*3+2]+t[2];rN(e.geometry,this.scratch,this.alphas,this.alphas,this.count)}rebuild(e){this.disposeMesh(),this.dirty=!0,this.scratch=new Float32Array(e*3),this.alphas=new Float32Array(e);let t=oN(e,this.scratch,this.alphas,this.alphas,e,this.color,this.widthPx,1);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 Sz(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=Cz(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,Cz(n,a)]}function Cz(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 wz(e,t={}){let[n,r]=Sz(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 Tz(e){if(e.length<3)return[];let[t,n]=Sz(Ez(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 Yl.triangulateShape(r,[]).flat()}function Ez(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 Dz(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 Oz([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 Oz(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 kz(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]]:Oz([n,r,i])}function Az(e,t){return new du({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
5519
+ `;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 LN(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 Vo;c.setAttribute(`position`,new ko(o,3));let l=new Cc(c,new uc({color:r,transparent:!0,opacity:.55}));return l.frustumCulled=!1,l}function RN(){let e=new Ra;e.name=`sky-debug-markers`,e.visible=!1;let t=new J;for(let n of ON){FN(n.raDeg,n.decDeg,t).multiplyScalar(DN);let r=new YO(IN(n));r.center.set(0,.5),r.position.copy(t),e.add(r)}for(let t of PN){let n=LN(t.zero,t.pole,DN*.999,t.color,NN);n.name=t.name,e.add(n)}return e}function zN(e){e.traverse(e=>{e instanceof YO&&e.element.remove(),e instanceof Cc&&(e.geometry.dispose(),e.material.dispose())}),e.parent?.remove(e)}var BN=class{group=null;constructor(e){this.scene=e}setVisible(e){e?(this.group||(this.group=RN(),this.scene.add(this.group)),this.group.visible=!0):this.group&&=(zN(this.group),null)}},VN=new J,HN=new J,UN=new J,WN=[VN,HN,UN];function GN(e,t,n){return VN.set(1,0,0).applyQuaternion(e).transformDirection(t),HN.set(0,1,0).applyQuaternion(e).transformDirection(t),UN.set(0,0,1).applyQuaternion(e).transformDirection(t),{e:WN,a:n}}function KN(e,t,n,r,i,a,o,s,c,l){let u=1/i;e.gxx=u,e.gxy=0,e.gxz=0,e.gyx=0,e.gyy=u,e.gyz=0,e.gzx=0,e.gzy=0,e.gzz=u,e.cpx=t*u,e.cpy=n*u,e.cpz=r*u,e.K=(t*t+n*n+r*r)*u*u-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function qN(e,t,n,r,i,a,o,s,c,l){let[u,d,f]=i.e,[p,m,h]=i.a;e.gxx=u.x/p,e.gxy=u.y/p,e.gxz=u.z/p,e.gyx=d.x/m,e.gyy=d.y/m,e.gyz=d.z/m,e.gzx=f.x/h,e.gzy=f.y/h,e.gzz=f.z/h;let g=(t*u.x+n*u.y+r*u.z)/p,_=(t*d.x+n*d.y+r*d.z)/m,v=(t*f.x+n*f.y+r*f.z)/h;e.cpx=g,e.cpy=_,e.cpz=v,e.K=g*g+_*_+v*v-1,e.cx0=o,e.cy0=s,e.f=a,e.id=c,e.dist=l,e.ccx=t,e.ccy=n,e.ccz=r}function JN(e,t,n,r,i,a){let[o,s,c]=r.e,[l,u,d]=r.a,f=1/(l*l),p=1/(u*u),m=1/(d*d),h=f*o.x*o.x+p*s.x*s.x+m*c.x*c.x,g=f*o.x*o.y+p*s.x*s.y+m*c.x*c.y,_=f*o.x*o.z+p*s.x*s.z+m*c.x*c.z,v=f*o.y*o.y+p*s.y*s.y+m*c.y*c.y,y=f*o.y*o.z+p*s.y*s.z+m*c.y*c.z,b=f*o.z*o.z+p*s.z*s.z+m*c.z*c.z,x=h*e+g*t+_*n,S=g*e+v*t+y*n,C=_*e+y*t+b*n,w=e*x+t*S+n*C-1,T=i,E=w*h-x*x,D=2*(w*g-x*S),O=w*v-S*S,k=-2*T*(w*_-x*C),A=-2*T*(w*y-S*C),j=4*E*O-D*D,M=(-2*O*k+D*A)/j,ee=(-2*E*A+D*k)/j,N=-n/T;a.ox=M*N-e,a.oy=ee*N-t}var YN=class{canvas=null;gfx=null;tmp=new J;tmpQ=new Vi;items=[];one=[];labelRect={x:0,left:0,right:0,y:0,h:0};constructor(e){this.anchor=e}get active(){return this.canvas!==null}setVisible(e){if(e){if(this.canvas)return;let e=document.createElement(`canvas`);e.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:5`,this.anchor.parentElement?.appendChild(e),this.canvas=e,this.gfx=e.getContext(`2d`)}else this.canvas&&(this.canvas.remove(),this.canvas=null,this.gfx=null)}draw(e,t,n,r,i,a){let o=this.gfx,s=this.canvas;if(!o||!s)return;let c=window.devicePixelRatio||1,l=Math.round(i*c),u=Math.round(a*c);(s.width!==l||s.height!==u)&&(s.width=l,s.height=u),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,i,a),o.font=`10px monospace`,o.textBaseline=`middle`;let d=t.fov*Math.PI/180,f=a/(2*Math.tan(d/2)),p=t.matrixWorldInverse,[m,h,g]=n,_=i*.5,v=a*.5,y=0;for(let o of e.values()){let{label:e,group:s,radiusScene:c}=o;if(!e||c<=0)continue;let[l,u,d]=o.body.position;this.tmp.set(l-m,u-h,d-g).applyMatrix4(p);let b=this.tmp.x,x=this.tmp.y,S=this.tmp.z;if(S>=0||b*b+x*x+S*S<=c*c)continue;let C=ZO(this.items,y++,XN),w=!!(o.semiAxesScene&&o.mesh);if(w){let e=GN(o.mesh.getWorldQuaternion(this.tmpQ),p,o.semiAxesScene);C.e0.copy(e.e[0]),C.e1.copy(e.e[1]),C.e2.copy(e.e[2]),C.sa[0]=e.a[0],C.sa[1]=e.a[1],C.sa[2]=e.a[2],qN(C.occ,b,x,S,e,f,_,v,o.body.data.id,o.cachedDist)}else C.e0.set(1,0,0),C.e1.set(0,1,0),C.e2.set(0,0,1),C.sa[0]=C.sa[1]=C.sa[2]=c,KN(C.occ,b,x,S,c,f,_,v,o.body.data.id,o.cachedDist);let T=S*S-c*c,E=T<=0,D=E?0:c*f/Math.sqrt(T),O=E||D>=16;this.tmp.set(l-m,u-h,d-g).project(t),C.cx=(this.tmp.x*.5+.5)*i,C.cy=(-this.tmp.y*.5+.5)*a,lk(o,t,n,i,a,this.labelRect),C.hx=this.labelRect.x,C.hy=this.labelRect.y,C.id=o.body.data.id,C.camX=b,C.camY=x,C.camZ=S,C.worldR=c,C.dist=o.cachedDist,C.isEllipsoid=w,C.degenerate=E,C.isOccluder=O,C.meshHidden=!s.visible,C.labelVisible=e.visible,C.maximized=o.labelMaximized!==!1,C.focused=o.body.data.id===r,C.occludedBy=-1}for(let e=0;e<y;e++){let t=this.items[e];for(let e=0;e<y;e++){let n=this.items[e];if(!(!n.isOccluder||n.id===t.id)&&(this.one[0]=n.occ,this.one.length=1,sk(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(),$N(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)}}QN(o,a)}strokeLimb(e,t,n,r,i){let{camX:a,camY:o,camZ:s,e0:c,e1:l,e2:u,sa:d}=t,f=(a*c.x+o*c.y+s*c.z)/d[0],p=(a*l.x+o*l.y+s*l.z)/d[1],m=(a*u.x+o*u.y+s*u.z)/d[2],h=f*f+p*p+m*m;if(h<=1)return!1;let g=Math.sqrt(h),_=(h-1)/h,v=Math.sqrt(h-1)/g,y=f*_,b=p*_,x=m*_,S=f/g,C=p/g,w=m/g,T=0,E=1;Math.abs(w)>.9&&(T=1,E=0);let D=C*E-w*0,O=w*T-S*E,k=S*0-C*T,A=Math.hypot(D,O,k)||1;D/=A,O/=A,k/=A;let j=C*k-w*O,M=w*D-S*k,ee=S*O-C*D,N=n.projectionMatrix.elements,te=!1;for(let t=0;t<=72;t++){let n=t/72*Math.PI*2,a=Math.cos(n),o=Math.sin(n),s=y+v*(a*D+o*j),f=b+v*(a*O+o*M),p=x+v*(a*k+o*ee),m=d[0]*s*c.x+d[1]*f*l.x+d[2]*p*u.x,h=d[0]*s*c.y+d[1]*f*l.y+d[2]*p*u.y,g=d[0]*s*c.z+d[1]*f*l.z+d[2]*p*u.z,_=N[3]*m+N[7]*h+N[11]*g+N[15];if(_<=1e-6){te=!1;continue}let S=(N[0]*m+N[4]*h+N[8]*g+N[12])/_,C=(N[1]*m+N[5]*h+N[9]*g+N[13])/_,w=(S*.5+.5)*r,T=(-C*.5+.5)*i;te?e.lineTo(w,T):(e.moveTo(w,T),te=!0)}return!0}dispose(){this.setVisible(!1)}};function XN(){return{id:``,camX:0,camY:0,camZ:0,worldR:0,e0:new J,e1:new J,e2:new J,sa:[0,0,0],occ:tk(),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 ZN=[[`#1ae5ff`,`label shown`],[`#ffe11a`,`dimmed`],[`#ff3b3b`,`hidden`],[`#ff8c1a`,`occluder silhouette`],[`#7dff7d`,`focused`]];function QN(e,t){let n=t-8-(ZN.length-1)*13;e.font=`10px monospace`,e.textBaseline=`middle`;for(let[t,r]of ZN)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 $N(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 eP(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 tP="function e(e,t,n=1e-10,r=50){let i=e;for(let a=0;a<r;a++){let r=(i-t*Math.sin(i)-e)/(1-t*Math.cos(i));if(i-=Math.max(-1,Math.min(1,r)),Math.abs(r)<n)break}return i}function t(e,t,n=1e-10,r=50){if(e===0)return 0;let i=e<0?-1:1,a=Math.abs(e),o=0,s=1;for(;t*Math.sinh(s)-s<a;)if(s*=2,s>700)return NaN;let c=.5*(o+s);for(let e=0;e<r;e++){let e=t*Math.sinh(c)-c-a;e>0?s=c:o=c;let r=c-e/(t*Math.cosh(c)-1);r>o&&r<s||(r=.5*(o+s));let i=Math.abs(r-c);if(c=r,i<n)break}return i*c}function n(e,t,n){let r=.01720209895*(n-t)/(Math.sqrt(2)*e**1.5),i=Math.cbrt(3*r+Math.sqrt(1+9*r*r)),a=i-1/i,o=2*Math.atan(a),s=e*(1+a*a);return!isFinite(o)||!isFinite(s)||s<=0?null:{nu:o,r:s}}const r=149597870.7,i=23.4392911;86400**2/r**3,1/r,Math.cos(Math.PI/180*i),Math.sin(Math.PI/180*i);const a=Math.PI,o=a*2,s=a/180;180/a;const c=6378.135,l=60/Math.sqrt(c*c*c/398600.8),u=c*l/60,d=1/l,f=.001082616,p=-253881e-11/f,m=2/3,ee=1440/(2*a);function te(e,t){let n=[31,e%4==0?29:28,31,30,31,30,31,31,30,31,30,31],r=Math.floor(t),i=1,a=0;for(;r>a+n[i-1]&&i<12;)a+=n[i-1],i+=1;let o=i,s=r-a,c=(t-r)*24,l=Math.floor(c);c=(c-l)*60;let u=Math.floor(c);return{mon:o,day:s,hr:l,minute:u,sec:(c-u)*60}}function h(e,t,n,r,i,a,o=0){return 367*e-Math.floor(7*(e+Math.floor((t+9)/12))*.25)+Math.floor(275*t/9)+n+1721013.5+((o/6e4+a/60+i)/60+r)/24}function g(e,t,n,r,i,a,o=0){if(e instanceof Date){let t=e;return h(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}return h(e,t,n,r,i,a,o)}function ne(e,t){let{e3:n,ee2:r,peo:i,pgho:s,pho:c,pinco:l,plo:u,se2:d,se3:f,sgh2:p,sgh3:m,sgh4:ee,sh2:te,sh3:h,si2:g,si3:ne,sl2:_,sl3:v,sl4:y,t:b,xgh2:re,xgh3:ie,xgh4:x,xh2:ae,xh3:S,xi2:C,xi3:w,xl2:T,xl3:E,xl4:D,zmol:O,zmos:k}=e,{init:A,opsmode:j}=t,{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}=t,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe;fe=k+119459e-10*b,A===`y`&&(fe=k),X=fe+2*.01675*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let pe=d*U+f*W,me=g*U+ne*W,he=_*U+v*W+y*Y,ge=p*U+m*W+ee*Y,Z=te*U+h*W;fe=O+.00015835218*b,A===`y`&&(fe=O),X=fe+2*.0549*Math.sin(fe),Y=Math.sin(X),U=.5*Y*Y-.25,W=-.5*Y*Math.cos(X);let _e=r*U+n*W,ve=C*U+w*W,ye=T*U+E*W+D*Y,be=re*U+ie*W+x*Y,xe=ae*U+S*W;return G=pe+_e,J=me+ve,le=he+ye,K=ge+be,q=Z+xe,A===`n`&&(G-=i,J-=l,le-=u,K-=s,q-=c,M+=J,oe+=G,R=Math.sin(M),L=Math.cos(M),M>=.2?(q/=R,K-=L*q,se+=K,N+=q,P+=le):(z=Math.sin(N),ce=Math.cos(N),F=R*z,I=R*ce,B=q*ce+J*L*z,V=-q*z+J*L*ce,F+=B,I+=V,N%=o,N<0&&j===`a`&&(N+=o),ue=P+se+L*N,H=le+K-J*N*R,ue+=H,de=N,N=Math.atan2(F,I),N<0&&j===`a`&&(N+=o),Math.abs(de-N)>a&&(N<de?N+=o:N-=o),P+=le,se=ue-P-L*N)),{ep:oe,inclp:M,nodep:N,argpp:se,mp:P}}function _(e){let{epoch:t,ep:n,argpp:r,tc:i,inclp:a,nodep:s,np:c}=e,l,u,d,f,p,m,ee,te,h,g,ne,_,v,y,b,re,ie,x,ae,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be=.01675,xe=.0549,Se=c,Ce=n,we=Math.sin(s),Te=Math.cos(s),Ee=Math.sin(r),Q=Math.cos(r),De=Math.sin(a),Oe=Math.cos(a),$=Ce*Ce,ke=1-$,Ae=Math.sqrt(ke),je=t+18261.5+i/1440,Me=(4.523602-.00092422029*je)%o,Ne=Math.sin(Me),Pe=Math.cos(Me),Fe=.91375164-.03568096*Pe,Ie=Math.sqrt(1-Fe*Fe),Le=.089683511*Ne/Ie,Re=Math.sqrt(1-Le*Le),ze=5.8351514+.001944368*je,Be=.39785416*Ne/Ie,Ve=Re*Pe+.91744867*Le*Ne;Be=Math.atan2(Be,Ve),Be+=ze-Me;let He=Math.cos(Be),Ue=Math.sin(Be);S=.1945905,C=-.98088458,E=.91744867,D=.39785416,w=Te,T=we,ne=29864797e-13;let We=1/Se,Ge=0;for(;Ge<2;)Ge+=1,l=S*w+C*E*T,d=-C*w+S*E*T,ee=-S*T+C*E*w,te=C*D,h=C*T+S*E*w,g=S*D,u=Oe*ee+De*te,f=Oe*h+De*g,p=-De*ee+Oe*te,m=-De*h+Oe*g,_=l*Q+u*Ee,v=d*Q+f*Ee,y=-l*Ee+u*Q,b=-d*Ee+f*Q,re=p*Ee,ie=m*Ee,x=p*Q,ae=m*Q,_e=12*_*_-3*y*y,ve=24*_*v-6*y*b,ye=12*v*v-3*b*b,ue=3*(l*l+u*u)+_e*$,de=6*(l*d+u*f)+ve*$,X=3*(d*d+f*f)+ye*$,fe=-6*l*p+$*(-24*_*x-6*y*re),pe=-6*(l*m+d*p)+$*(-24*(v*x+_*ae)+-6*(y*ie+b*re)),me=-6*d*m+$*(-24*v*ae-6*b*ie),he=6*u*p+$*(24*_*re-6*y*x),ge=6*(f*p+u*m)+$*(24*(v*re+_*ie)-6*(b*x+y*ae)),Z=6*f*m+$*(24*v*ie-6*b*ae),ue=ue+ue+ke*_e,de=de+de+ke*ve,X=X+X+ke*ye,K=ne*We,G=-.5*K/Ae,q=K*Ae,W=-15*Ce*q,J=_*y+v*b,le=v*y+_*b,Y=v*b-_*y,Ge===1&&(O=W,k=G,A=K,j=q,oe=J,M=le,N=Y,se=ue,P=de,F=X,I=fe,L=pe,R=me,ce=he,z=ge,B=Z,V=_e,H=ve,U=ye,S=He,C=Ue,E=Fe,D=Ie,w=Re*Te+Le*we,T=we*Re-Te*Le,ne=4.7968065e-7);let Ke=(4.7199672+(.2299715*je-ze))%o,qe=(6.2565837+.017201977*je)%o,Je=2*O*M,Ye=2*O*N,Xe=2*k*L,Ze=2*k*(R-I),Qe=-2*A*P,$e=-2*A*(F-se),et=-2*A*(-21-9*$)*be,tt=2*j*H,nt=2*j*(U-V),rt=-18*j*be,it=-2*k*z,at=-2*k*(B-ce),ot=2*W*le,st=2*W*Y,ct=2*G*pe,lt=2*G*(me-fe),ut=-2*K*de,dt=-2*K*(X-ue),ft=-2*K*(-21-9*$)*xe,pt=2*q*ve,mt=2*q*(ye-_e),ht=-18*q*xe,gt=-2*G*ge,_t=-2*G*(Z-he);return{snodm:we,cnodm:Te,sinim:De,cosim:Oe,sinomm:Ee,cosomm:Q,day:je,e3:st,ee2:ot,em:Ce,emsq:$,gam:ze,peo:0,pgho:0,pho:0,pinco:0,plo:0,rtemsq:Ae,se2:Je,se3:Ye,sgh2:tt,sgh3:nt,sgh4:rt,sh2:it,sh3:at,si2:Xe,si3:Ze,sl2:Qe,sl3:$e,sl4:et,s1:W,s2:G,s3:K,s4:q,s5:J,s6:le,s7:Y,ss1:O,ss2:k,ss3:A,ss4:j,ss5:oe,ss6:M,ss7:N,sz1:se,sz2:P,sz3:F,sz11:I,sz12:L,sz13:R,sz21:ce,sz22:z,sz23:B,sz31:V,sz32:H,sz33:U,xgh2:pt,xgh3:mt,xgh4:ht,xh2:gt,xh3:_t,xi2:ct,xi3:lt,xl2:ut,xl3:dt,xl4:ft,nm:Se,z1:ue,z2:de,z3:X,z11:fe,z12:pe,z13:me,z21:he,z22:ge,z23:Z,z31:_e,z32:ve,z33:ye,zmol:Ke,zmos:qe}}function v(e){let{cosim:t,argpo:n,s1:r,s2:i,s3:s,s4:c,s5:u,sinim:d,ss1:f,ss2:p,ss3:ee,ss4:te,ss5:h,sz1:g,sz3:ne,sz11:_,sz13:v,sz21:y,sz23:b,sz31:re,sz33:ie,t:x,tc:ae,gsto:S,mo:C,mdot:w,no:T,nodeo:E,nodedot:D,xpidot:O,z1:k,z3:A,z11:j,z13:oe,z21:M,z23:N,z31:se,z33:P,ecco:F,eccsq:I}=e,{emsq:L,em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}=e,we,Te,Ee,Q,De,Oe,$,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et=.0043752690880113,tt=.00015835218,nt=119459e-10;U=0,V<.0052359877&&V>.0034906585&&(U=1),V>=.00826&&V<=.00924&&R>=.5&&(U=2);let rt=f*nt*h,it=p*nt*(_+v),at=-nt*ee*(g+ne-14-6*L),ot=te*nt*(re+ie-6),st=-nt*p*(y+b);(z<.052359877||z>a-.052359877)&&(st=0),d!==0&&(st/=d);let ct=ot-t*st;pe=rt+r*tt*u,me=it+i*tt*(j+oe),he=at-tt*s*(k+A-14-6*L);let lt=c*tt*(se+P-6),ut=-tt*i*(M+N);(z<.052359877||z>a-.052359877)&&(ut=0),Z=ct+lt,ge=st,d!==0&&(Z-=t/d*ut,ge+=ut/d);let dt=(S+ae*et)%o;if(R+=pe*x,z+=me*x,ce+=Z*x,H+=ge*x,B+=he*x,U!==0){if(Ze=(V/l)**m,U===2){Qe=t*t;let e=R;R=F;let n=L;L=I,$e=R*L,Fe=-.306-(R-.64)*.44,R<=.65?(Ie=3.616-13.247*R+16.29*L,Re=-19.302+117.39*R-228.419*L+156.591*$e,ze=-18.9068+109.7927*R-214.6334*L+146.5816*$e,Be=-41.122+242.694*R-471.094*L+313.953*$e,Ve=-146.407+841.88*R-1629.014*L+1083.435*$e,He=-532.114+3017.977*R-5740.032*L+3708.276*$e):(Ie=-72.099+331.819*R-508.738*L+266.724*$e,Re=-346.844+1582.851*R-2415.925*L+1246.113*$e,ze=-342.585+1554.908*R-2366.899*L+1215.972*$e,Be=-1052.797+4758.686*R-7193.992*L+3651.957*$e,Ve=-3581.69+16178.11*R-24462.77*L+12422.52*$e,He=R>.715?-5149.66+29936.92*R-54087.36*L+31324.56*$e:1464.74-4664.75*R+3763.64*L),R<.7?(Ge=-919.2277+4988.61*R-9064.77*L+5542.21*$e,Ue=-822.71072+4568.6173*R-8491.4146*L+5337.524*$e,We=-853.666+4690.25*R-8624.77*L+5341.4*$e):(Ge=-37995.78+161616.52*R-229838.2*L+109377.94*$e,Ue=-51752.104+218913.95*R-309468.16*L+146349.42*$e,We=-40023.88+170470.89*R-242699.48*L+115605.82*$e),Ke=d*d,we=.75*(1+2*t+Qe),Te=1.5*Ke,Q=1.875*d*(1-2*t-3*Qe),De=-1.875*d*(1+2*t-3*Qe),$=35*Ke*we,ke=39.375*Ke*Ke,Ae=9.84375*d*(Ke*(1-2*t-5*Qe)+.33333333*(-2+4*t+6*Qe)),je=d*(4.92187512*Ke*(-2-4*t+10*Qe)+6.56250012*(1+2*t-3*Qe)),Me=29.53125*d*(2-8*t+Qe*(-12+8*t+10*Qe)),Ne=29.53125*d*(-2-8*t+Qe*(12+8*t-10*Qe)),Ye=V*V,Xe=Ze*Ze,Je=3*Ye*Xe,qe=Je*17891679e-13,G=qe*we*Fe,K=qe*Te*Ie,Je*=Ze,qe=Je*3.7393792e-7,q=qe*Q*Re,J=qe*De*ze,Je*=Ze,qe=2*Je*7.3636953e-9,le=qe*$*Be,Y=qe*ke*Ve,Je*=Ze,qe=Je*1.1428639e-7,ue=qe*Ae*He,de=qe*je*We,qe=2*Je*2.1765803e-9,X=qe*Me*Ue,fe=qe*Ne*Ge,xe=(C+E+E-(dt+dt))%o,be=w+he+2*(D+ge-et)-T,R=e,L=n}U===1&&(Pe=1+L*(-2.5+.8125*L),Re=1+2*L,Le=1+L*(-6+6.60937*L),we=.75*(1+t)*(1+t),Ee=.9375*d*d*(1+3*t)-.75*(1+t),Oe=1+t,Oe*=1.875*Oe*Oe,_e=3*V*V*Ze*Ze,ve=2*_e*we*Pe*17891679e-13,ye=3*_e*Oe*Le*2.2123015e-7*Ze,_e=_e*Ee*Re*21460748e-13*Ze,xe=(C+E+n-dt)%o,be=w+O+he+Z+ge-(T+et)),Se=xe,Ce=T,W=0,V=T+0}return{em:R,argpm:ce,inclm:z,mm:B,nm:V,nodem:H,irez:U,atime:W,d2201:G,d2211:K,d3210:q,d3222:J,d4410:le,d4422:Y,d5220:ue,d5232:de,d5421:X,d5433:fe,dedt:pe,didt:me,dmdt:he,dndt:0,dnodt:ge,domdt:Z,del1:_e,del2:ve,del3:ye,xfact:be,xlamo:xe,xli:Se,xni:Ce}}function y(e){let t=(e-2451545)/36525,n=-62e-7*t*t*t+.093104*t*t+3164400184.812866*t+67310.54841;return n=n*s/240%o,n<0&&(n+=o),n}function b(e,t,n,r,i,a,o){return e instanceof Date?y(g(e)):y(t===void 0?e:g(e,t,n,r,i,a,o))}function re(e){let{ecco:t,epoch:n,inclo:r,opsmode:i}=e,{no:a}=e,s=t*t,c=1-s,u=Math.sqrt(c),d=Math.cos(r),p=d*d,ee=(l/a)**m,te=.75*f*(3*p-1)/(u*c),h=te/(ee*ee),g=ee*(1-h*h-h*(1/3+134*h*h/81));h=te/(g*g),a/=1+h;let ne=(l/a)**m,_=Math.sin(r),v=ne*c,y=1-5*p,re=-y-p-p,ie=1/ne,x=v*v,ae=ne*(1-t),S;if(i===`a`){let e=n-7305,t=Math.floor(e+1e-8),r=e-t,i=.017202791694070362,a=i+o;S=(1.7321343856509375+i*t+a*r+e*e*5075514194322695e-30)%o,S<0&&(S+=o)}else S=b(n+2433281.5);return{no:a,method:`n`,ainv:ie,ao:ne,con41:re,con42:y,cosio:d,cosio2:p,eccsq:s,omeosq:c,posq:x,rp:ae,rteosq:u,sinio:_,gsto:S}}function ie(e){let{irez:t,d2201:n,d2211:r,d3210:i,d3222:a,d4410:s,d4422:c,d5220:l,d5232:u,d5421:d,d5433:f,dedt:p,del1:m,del2:ee,del3:te,didt:h,dmdt:g,dnodt:ne,domdt:_,argpo:v,argpdot:y,t:b,tc:re,gsto:ie,xfact:x,xlamo:ae,no:S}=e,{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,nm:j}=e,oe=.13130908,M=2.8843198,N=.37448087,se=5.7686396,P=.95240898,F=1.8014998,I=1.050833,L=4.4108898,R=259200,ce,z,B,V,H,U,W,G,K=0,q=0,J=(ie+re*.0043752690880113)%o;if(w+=p*b,E+=h*b,T+=_*b,A+=ne*b,O+=g*b,t!==0){(C===0||b*C<=0||Math.abs(b)<Math.abs(C))&&(C=0,k=S,D=ae),ce=b>0?720:-720;let e=381;for(;e===381;)t===2?(G=v+y*C,B=G+G,z=D+D,W=n*Math.sin(B+D-se)+r*Math.sin(D-se)+i*Math.sin(G+D-P)+a*Math.sin(-G+D-P)+s*Math.sin(B+z-F)+c*Math.sin(z-F)+l*Math.sin(G+D-I)+u*Math.sin(-G+D-I)+d*Math.sin(G+z-L)+f*Math.sin(-G+z-L),H=k+x,U=n*Math.cos(B+D-se)+r*Math.cos(D-se)+i*Math.cos(G+D-P)+a*Math.cos(-G+D-P)+l*Math.cos(G+D-I)+u*Math.cos(-G+D-I)+2*(s*Math.cos(B+z-F)+c*Math.cos(z-F)+d*Math.cos(G+z-L)+f*Math.cos(-G+z-L)),U*=H):(W=m*Math.sin(D-oe)+ee*Math.sin(2*(D-M))+te*Math.sin(3*(D-N)),H=k+x,U=m*Math.cos(D-oe)+2*ee*Math.cos(2*(D-M))+3*te*Math.cos(3*(D-N)),U*=H),Math.abs(b-C)>=720?e=381:(q=b-C,e=0),e===381&&(D+=H*ce+W*R,k+=W*ce+U*R,C+=ce);j=k+W*q+U*q*q*.5,V=D+H*q+W*q*q*.5,t===1?(O=V-A-T+J,K=j-S):(O=V-2*A+2*J,K=j-S),j=S+K}return{atime:C,em:w,argpm:T,inclm:E,xli:D,mm:O,xni:k,nodem:A,dndt:K,nm:j}}var x;(function(e){e[e.None=0]=`None`,e[e.MeanEccentricityOutOfRange=1]=`MeanEccentricityOutOfRange`,e[e.MeanMotionBelowZero=2]=`MeanMotionBelowZero`,e[e.PerturbedEccentricityOutOfRange=3]=`PerturbedEccentricityOutOfRange`,e[e.SemiLatusRectumBelowZero=4]=`SemiLatusRectumBelowZero`,e[e.Decayed=6]=`Decayed`})(x||={});function ae(e,t){let n,r,i,s,d,ee,te,h,g,_,v,y,b,re,ae,S,C,w,T,E,D,O,k,A,j,oe,M;e.t=t,e.error=x.None;let N=e.mo+e.mdot*e.t,se=e.argpo+e.argpdot*e.t,P=e.nodeo+e.nodedot*e.t;g=se,D=N;let F=e.t*e.t;if(k=P+e.nodecf*F,C=1-e.cc1*e.t,w=e.bstar*e.cc4*e.t,T=e.t2cof*F,e.isimp!==1){te=e.omgcof*e.t;let t=1+e.eta*Math.cos(N);ee=e.xmcof*(t*t*t-e.delmo),S=te+ee,D=N+S,g=se-S,y=F*e.t,b=y*e.t,C=C-e.d2*F-e.d3*y-e.d4*b,w+=e.bstar*e.cc5*(Math.sin(D)-e.sinmao),T=T+e.t3cof*y+b*(e.t4cof+e.t*e.t5cof)}O=e.no;let I=e.ecco;if(E=e.inclo,e.method===`d`){re=e.t;let t=ie({irez:e.irez,d2201:e.d2201,d2211:e.d2211,d3210:e.d3210,d3222:e.d3222,d4410:e.d4410,d4422:e.d4422,d5220:e.d5220,d5232:e.d5232,d5421:e.d5421,d5433:e.d5433,dedt:e.dedt,del1:e.del1,del2:e.del2,del3:e.del3,didt:e.didt,dmdt:e.dmdt,dnodt:e.dnodt,domdt:e.domdt,argpo:e.argpo,argpdot:e.argpdot,t:e.t,tc:re,gsto:e.gsto,xfact:e.xfact,xlamo:e.xlamo,no:e.no,atime:e.atime,em:I,argpm:g,inclm:E,xli:e.xli,mm:D,xni:e.xni,nodem:k,nm:O});({em:I,argpm:g,inclm:E,mm:D,nodem:k,nm:O}=t)}if(O<=0)return e.error=x.MeanMotionBelowZero,null;let L=(l/O)**m*C*C;if(O=l/L**1.5,I-=w,I>=1||I<-.001)return e.error=x.MeanEccentricityOutOfRange,null;I<1e-6&&(I=1e-6),D+=e.no*T,j=D+g+k,k%=o,g%=o,j%=o,D=(j-g-k)%o;let R={am:L,em:I,im:E,Om:k,om:g,mm:D,nm:O},ce=Math.sin(E),z=Math.cos(E),B=I;if(A=E,_=g,M=k,oe=D,s=ce,i=z,e.method===`d`){let t=ne(e,{inclo:e.inclo,init:`n`,ep:B,inclp:A,nodep:M,argpp:_,mp:oe,opsmode:e.operationmode});if({ep:B,nodep:M,argpp:_,mp:oe}=t,A=t.inclp,A<0&&(A=-A,M+=a,_-=a),B<0||B>1)return e.error=x.PerturbedEccentricityOutOfRange,null}e.method===`d`&&(s=Math.sin(A),i=Math.cos(A),e.aycof=-.5*p*s,Math.abs(i+1)>15e-13?e.xlcof=-.25*p*s*(3+5*i)/(1+i):e.xlcof=-.25*p*s*(3+5*i)/15e-13);let V=B*Math.cos(_);S=1/(L*(1-B*B));let H=B*Math.sin(_)+S*e.aycof,U=(oe+_+M+S*e.xlcof*V-M)%o;h=U,ae=9999.9;let W=1;for(;Math.abs(ae)>=1e-12&&W<=10;)r=Math.sin(h),n=Math.cos(h),ae=1-n*V-r*H,ae=(U-H*n+V*r-h)/ae,Math.abs(ae)>=.95&&(ae=ae>0?.95:-.95),h+=ae,W+=1;let G=V*n+H*r,K=V*r-H*n,q=V*V+H*H,J=L*(1-q);if(J<0)return e.error=x.SemiLatusRectumBelowZero,null;let le=L*(1-G),Y=Math.sqrt(L)*K/le,ue=Math.sqrt(J)/le,de=Math.sqrt(1-q);S=K/(1+de);let X=L/le*(r-H-V*S),fe=L/le*(n-V+H*S);v=Math.atan2(X,fe);let pe=(fe+fe)*X,me=1-2*X*X;S=1/J;let he=.5*f*S,ge=he*S;e.method===`d`&&(d=i*i,e.con41=3*d-1,e.x1mth2=1-d,e.x7thm1=7*d-1);let Z=le*(1-1.5*ge*de*e.con41)+.5*he*e.x1mth2*me;if(Z<1)return e.error=x.Decayed,null;v-=.25*ge*e.x7thm1*pe;let _e=M+1.5*ge*i*pe,ve=A+1.5*ge*i*s*me,ye=Y-O*he*e.x1mth2*pe/l,be=ue+O*he*(e.x1mth2*me+1.5*e.con41)/l,xe=Math.sin(v),Se=Math.cos(v),Ce=Math.sin(_e),we=Math.cos(_e),Te=Math.sin(ve),Ee=Math.cos(ve),Q=-Ce*Ee,De=we*Ee,Oe=Q*xe+we*Se,$=De*xe+Ce*Se,ke=Te*xe,Ae=Q*Se-we*xe,je=De*Se-Ce*xe,Me=Te*Se;return{position:{x:Z*Oe*c,y:Z*$*c,z:Z*ke*c},velocity:{x:(ye*Oe+be*Ae)*u,y:(ye*$+be*je)*u,z:(ye*ke+be*Me)*u},meanElements:R}}function S(e,t){let{opsmode:n,satn:r,epoch:i,xbstar:o,xecco:s,xargpo:l,xinclo:u,xmo:ee,xno:te,xnodeo:h}=t,g,y,b,ie,x,S,C,w,T,E,D,O,k,A,j,oe,M,N,se,P,F,I,L,R,ce,z,B,V,H,U,W,G,K,q,J,le,Y,ue,de,X,fe,pe,me,he,ge,Z,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,Q=e;Q.isimp=0,Q.method=`n`,Q.aycof=0,Q.con41=0,Q.cc1=0,Q.cc4=0,Q.cc5=0,Q.d2=0,Q.d3=0,Q.d4=0,Q.delmo=0,Q.eta=0,Q.argpdot=0,Q.omgcof=0,Q.sinmao=0,Q.t=0,Q.t2cof=0,Q.t3cof=0,Q.t4cof=0,Q.t5cof=0,Q.x1mth2=0,Q.x7thm1=0,Q.mdot=0,Q.nodedot=0,Q.xlcof=0,Q.xmcof=0,Q.nodecf=0,Q.irez=0,Q.d2201=0,Q.d2211=0,Q.d3210=0,Q.d3222=0,Q.d4410=0,Q.d4422=0,Q.d5220=0,Q.d5232=0,Q.d5421=0,Q.d5433=0,Q.dedt=0,Q.del1=0,Q.del2=0,Q.del3=0,Q.didt=0,Q.dmdt=0,Q.dnodt=0,Q.domdt=0,Q.e3=0,Q.ee2=0,Q.peo=0,Q.pgho=0,Q.pho=0,Q.pinco=0,Q.plo=0,Q.se2=0,Q.se3=0,Q.sgh2=0,Q.sgh3=0,Q.sgh4=0,Q.sh2=0,Q.sh3=0,Q.si2=0,Q.si3=0,Q.sl2=0,Q.sl3=0,Q.sl4=0,Q.gsto=0,Q.xfact=0,Q.xgh2=0,Q.xgh3=0,Q.xgh4=0,Q.xh2=0,Q.xh3=0,Q.xi2=0,Q.xi3=0,Q.xl2=0,Q.xl3=0,Q.xl4=0,Q.xlamo=0,Q.zmol=0,Q.zmos=0,Q.atime=0,Q.xli=0,Q.xni=0,Q.bstar=o,Q.ecco=s,Q.argpo=l,Q.inclo=u,Q.mo=ee,Q.no=te,Q.nodeo=h,Q.operationmode=n,78/c+1;let De=42/c;De*De*De*De,Q.init=`y`,Q.t=0;let Oe=re({satn:r,ecco:Q.ecco,epoch:i,inclo:Q.inclo,no:Q.no,method:Q.method,opsmode:Q.operationmode}),{ao:$,con42:ke,cosio:Ae,cosio2:je,eccsq:Me,omeosq:Ne,posq:Pe,rp:Fe,rteosq:Ie,sinio:Le}=Oe;if(Q.no=Oe.no,Q.con41=Oe.con41,Q.gsto=Oe.gsto,Q.a=(Q.no*d)**(-2/3),Q.alta=Q.a*(1+Q.ecco)-1,Q.altp=Q.a*(1-Q.ecco)-1,Q.error=0,Ne>=0||Q.no>=0){if(Q.isimp=0,Fe<1.034492841559484&&(Q.isimp=1),B=1.0122292801892716,F=1.880279159015271e-9,N=(Fe-1)*c,N<156){B=N-78,N<98&&(B=20);let e=(120-B)/c;F=e*e*e*e,B=B/c+1}se=1/Pe,Z=1/($-B),Q.eta=$*Q.ecco*Z,O=Q.eta*Q.eta,D=Q.ecco*Q.eta,P=Math.abs(1-O),S=F*Z**4,C=S/P**3.5,ie=C*Q.no*($*(1+1.5*O+D*(4+O))+.375*f*Z/P*Q.con41*(8+3*O*(8+O))),Q.cc1=Q.bstar*ie,x=0,Q.ecco>1e-4&&(x=-2*S*Z*p*Q.no*Le/Q.ecco),Q.x1mth2=1-je,Q.cc4=2*Q.no*C*$*Ne*(Q.eta*(2+.5*O)+Q.ecco*(.5+2*O)-f*Z/($*P)*(-3*Q.con41*(1-2*D+O*(1.5-.5*D))+.75*Q.x1mth2*(2*O-D*(1+O))*Math.cos(2*Q.argpo))),Q.cc5=2*C*$*Ne*(1+2.75*(O+D)+D*O),w=je*je,me=1.5*f*se*Q.no,he=.5*me*f*se,ge=-.46875*-165597e-11*se*se*Q.no,Q.mdot=Q.no+.5*me*Ie*Q.con41+.0625*he*Ie*(13-78*je+137*w),Q.argpdot=-.5*me*ke+.0625*he*(7-114*je+395*w)+ge*(3-36*je+49*w),ve=-me*Ae,Q.nodedot=ve+(.5*he*(4-19*je)+2*ge*(3-7*je))*Ae,_e=Q.argpdot+Q.nodedot,Q.omgcof=Q.bstar*x*Math.cos(Q.argpo),Q.xmcof=0,Q.ecco>1e-4&&(Q.xmcof=-m*S*Q.bstar/D),Q.nodecf=3.5*Ne*ve*Q.cc1,Q.t2cof=1.5*Q.cc1,Math.abs(Ae+1)>15e-13?Q.xlcof=-.25*p*Le*(3+5*Ae)/(1+Ae):Q.xlcof=-.25*p*Le*(3+5*Ae)/15e-13,Q.aycof=-.5*p*Le;let e=1+Q.eta*Math.cos(Q.mo);if(Q.delmo=e*e*e,Q.sinmao=Math.sin(Q.mo),Q.x7thm1=7*je-1,2*a/Q.no>=225){Q.method=`d`,Q.isimp=1,fe=0,j=Q.inclo;let e=_({epoch:i,ep:Q.ecco,argpp:Q.argpo,tc:fe,inclp:Q.inclo,nodep:Q.nodeo,np:Q.no,e3:Q.e3,ee2:Q.ee2,peo:Q.peo,pgho:Q.pgho,pho:Q.pho,pinco:Q.pinco,plo:Q.plo,se2:Q.se2,se3:Q.se3,sgh2:Q.sgh2,sgh3:Q.sgh3,sgh4:Q.sgh4,sh2:Q.sh2,sh3:Q.sh3,si2:Q.si2,si3:Q.si3,sl2:Q.sl2,sl3:Q.sl3,sl4:Q.sl4,xgh2:Q.xgh2,xgh3:Q.xgh3,xgh4:Q.xgh4,xh2:Q.xh2,xh3:Q.xh3,xi2:Q.xi2,xi3:Q.xi3,xl2:Q.xl2,xl3:Q.xl3,xl4:Q.xl4,zmol:Q.zmol,zmos:Q.zmos});Q.e3=e.e3,Q.ee2=e.ee2,Q.peo=e.peo,Q.pgho=e.pgho,Q.pho=e.pho,Q.pinco=e.pinco,Q.plo=e.plo,Q.se2=e.se2,Q.se3=e.se3,Q.sgh2=e.sgh2,Q.sgh3=e.sgh3,Q.sgh4=e.sgh4,Q.sh2=e.sh2,Q.sh3=e.sh3,Q.si2=e.si2,Q.si3=e.si3,Q.sl2=e.sl2,Q.sl3=e.sl3,Q.sl4=e.sl4,{sinim:y,cosim:g,em:T,emsq:E,s1:I,s2:L,s3:R,s4:ce,s5:z,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X}=e,Q.xgh2=e.xgh2,Q.xgh3=e.xgh3,Q.xgh4=e.xgh4,Q.xh2=e.xh2,Q.xh3=e.xh3,Q.xi2=e.xi2,Q.xi3=e.xi3,Q.xl2=e.xl2,Q.xl3=e.xl3,Q.xl4=e.xl4,Q.zmol=e.zmol,Q.zmos=e.zmos,{nm:M,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee}=e;let t=ne(Q,{inclo:j,init:Q.init,ep:Q.ecco,inclp:Q.inclo,nodep:Q.nodeo,argpp:Q.argpo,mp:Q.mo,opsmode:Q.operationmode});Q.ecco=t.ep,Q.inclo=t.inclp,Q.nodeo=t.nodep,Q.argpo=t.argpp,Q.mo=t.mp,k=0,A=0,oe=0;let n=v({cosim:g,emsq:E,argpo:Q.argpo,s1:I,s2:L,s3:R,s4:ce,s5:z,sinim:y,ss1:V,ss2:H,ss3:U,ss4:W,ss5:G,sz1:K,sz3:q,sz11:J,sz13:le,sz21:Y,sz23:ue,sz31:de,sz33:X,t:Q.t,tc:fe,gsto:Q.gsto,mo:Q.mo,mdot:Q.mdot,no:Q.no,nodeo:Q.nodeo,nodedot:Q.nodedot,xpidot:_e,z1:ye,z3:be,z11:xe,z13:Se,z21:Ce,z23:we,z31:Te,z33:Ee,ecco:Q.ecco,eccsq:Me,em:T,argpm:k,inclm:j,mm:oe,nm:M,nodem:A,irez:Q.irez,atime:Q.atime,d2201:Q.d2201,d2211:Q.d2211,d3210:Q.d3210,d3222:Q.d3222,d4410:Q.d4410,d4422:Q.d4422,d5220:Q.d5220,d5232:Q.d5232,d5421:Q.d5421,d5433:Q.d5433,dedt:Q.dedt,didt:Q.didt,dmdt:Q.dmdt,dnodt:Q.dnodt,domdt:Q.domdt,del1:Q.del1,del2:Q.del2,del3:Q.del3,xfact:Q.xfact,xlamo:Q.xlamo,xli:Q.xli,xni:Q.xni});Q.irez=n.irez,Q.atime=n.atime,Q.d2201=n.d2201,Q.d2211=n.d2211,Q.d3210=n.d3210,Q.d3222=n.d3222,Q.d4410=n.d4410,Q.d4422=n.d4422,Q.d5220=n.d5220,Q.d5232=n.d5232,Q.d5421=n.d5421,Q.d5433=n.d5433,Q.dedt=n.dedt,Q.didt=n.didt,Q.dmdt=n.dmdt,Q.dnodt=n.dnodt,Q.domdt=n.domdt,Q.del1=n.del1,Q.del2=n.del2,Q.del3=n.del3,Q.xfact=n.xfact,Q.xlamo=n.xlamo,Q.xli=n.xli,Q.xni=n.xni}Q.isimp!==1&&(b=Q.cc1*Q.cc1,Q.d2=4*$*Z*b,pe=Q.d2*Z*Q.cc1/3,Q.d3=(17*$+B)*pe,Q.d4=.5*pe*$*Z*(221*$+31*B)*Q.cc1,Q.t3cof=Q.d2+2*b,Q.t4cof=.25*(3*Q.d3+Q.cc1*(12*Q.d2+10*b)),Q.t5cof=.2*(3*Q.d4+12*Q.cc1*Q.d3+6*Q.d2*Q.d2+15*b*(2*Q.d2+b)))}ae(Q,0),Q.init=`n`}function C(e,t=`i`){let n=e.NORAD_CAT_ID.toString(),r=new Date(e.EPOCH.endsWith(`Z`)?e.EPOCH:`${e.EPOCH}Z`),i=r.getUTCFullYear(),a=Number(i.toString().slice(-2)),o=(r.valueOf()-new Date(Date.UTC(i,0,1,0,0,0)).valueOf())/(86400*1e3)+1,c=Number(e.MEAN_MOTION_DOT),l=Number(e.MEAN_MOTION_DDOT);c/=ee*1440,l/=ee*1440*1440;let u=Number(e.BSTAR),d=Number(e.INCLINATION)*s,f=Number(e.RA_OF_ASC_NODE)*s,p=Number(e.ECCENTRICITY),m=Number(e.ARG_OF_PERICENTER)*s,h=Number(e.MEAN_ANOMALY)*s,ne=Number(e.MEAN_MOTION)/ee,{mon:_,day:v,hr:y,minute:b,sec:re}=te(i,o),ie=g(i,_,v,y,b,re),x={error:0,satnum:n,epochyr:a,epochdays:o,ndot:c,nddot:l,bstar:u,inclo:d,nodeo:f,ecco:p,argpo:m,mo:h,no:ne,jdsatepoch:ie};return S(x,{opsmode:t,satn:x.satnum,epoch:x.jdsatepoch-2433281.5,xbstar:x.bstar,xecco:x.ecco,xargpo:x.argpo,xinclo:x.inclo,xmo:x.mo,xno:x.no,xnodeo:x.nodeo}),x}3*Float64Array.BYTES_PER_ELEMENT;const w=Math.PI/180;Math.cos(i*w),Math.sin(i*w);function T(e){return new Date((e-2440587.5)*864e5).toISOString()}function E(e,t){let n=C({OBJECT_NAME:t??String(e.noradCatId),OBJECT_ID:String(e.noradCatId),EPOCH:T(e.epochJd),MEAN_MOTION:e.meanMotion,ECCENTRICITY:e.eccentricity,INCLINATION:e.inclination,RA_OF_ASC_NODE:e.raOfAscNode,ARG_OF_PERICENTER:e.argOfPericenter,MEAN_ANOMALY:e.meanAnomaly,EPHEMERIS_TYPE:0,CLASSIFICATION_TYPE:`U`,NORAD_CAT_ID:e.noradCatId,ELEMENT_SET_NO:e.elementSetNo,REV_AT_EPOCH:e.revAtEpoch,BSTAR:e.bstar,MEAN_MOTION_DOT:e.meanMotionDot,MEAN_MOTION_DDOT:e.meanMotionDdot});return n.error===x.None?n:(console.warn(`buildSatrec: SGP4 init failed for NORAD ${e.noradCatId} (error=${n.error})`),null)}const D=Math.PI/180,O=Math.cos(i*D),k=Math.sin(i*D),A=10/r;function j(e,t,n,r,i){return!isFinite(Math.fround(n))||!isFinite(Math.fround(r))||!isFinite(Math.fround(i))?!1:(e[t*3]=n,e[t*3+1]=r,e[t*3+2]=i,!0)}function oe(r,i,a,o,s,c,l,u,d,f=null,p=0){if(i<r.validityStart||i>r.validityEnd)return 0;let{count:m,kind:ee,equatorial:te,a:h,e:g,i:ne,om:_,w:v,ma:y,n:b,epoch:re,q:ie,tp:S,satrec:C,flags:w,visibleFromDays:T}=r,oe=p!==0&&r.applyFlagFilter,M=r.pickBase,N=d.length/3|0,se=i-2451545,P=0;for(let F=0;F<m&&!(P>=N);F++){let m=ee[F];if(m===0||T[F]>se||oe&&(w[F]&p)!==p)continue;if(m===3){let e=C[F];if(!e){if(e=E({noradCatId:r.satnum[F],epochJd:re[F],meanMotion:b[F]/360,eccentricity:g[F],inclination:ne[F],raOfAscNode:_[F],argOfPericenter:v[F],meanAnomaly:y[F],bstar:r.bstar[F],meanMotionDot:r.ndot[F],meanMotionDdot:r.nddot[F],elementSetNo:0,revAtEpoch:0}),!e){ee[F]=0;continue}C[F]=e}let t=(i-e.jdsatepoch)*1440,n=ae(e,t);if(!n||e.error!==x.None)continue;let p=n.position.x,m=n.position.y,te=n.position.z,h=p*A,ie=m*A,S=te*A,w=ie*O+S*k,T=-ie*k+S*O,D=h,oe=T,N=-w;if(!j(d,P,a+D-c,o+oe-l,s+N-u))continue;if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++;continue}let N,I,L=g[F],R=ne[F],ce=_[F],z=v[F];if(m===2){let e=n(ie[F],S[F],i);if(!e)continue;N=e.r*Math.cos(e.nu),I=e.r*Math.sin(e.nu)}else{let n=h[F];if(!isFinite(n)||!isFinite(L)||!isFinite(y[F])||!isFinite(b[F]))continue;let r=i-re[F],a=(y[F]+b[F]*r)*D,o,s;if(L<1||n>0){let t=Math.min(L,.9999999),r=e(a,t),i=Math.sqrt(1-t*t)*Math.sin(r)/(1-t*Math.cos(r)),c=(Math.cos(r)-t)/(1-t*Math.cos(r));o=Math.atan2(i,c),s=n*(1-t*Math.cos(r))}else{let e=t(a,L);if(!isFinite(e))continue;let r=L*Math.cosh(e)-1;if(Math.abs(r)<1e-15)continue;let i=Math.sqrt(L*L-1)*Math.sinh(e)/r,c=(L-Math.cosh(e))/r;o=Math.atan2(i,c),s=n*(1-L*Math.cosh(e))}N=s*Math.cos(o),I=s*Math.sin(o)}if(!isFinite(N)||!isFinite(I))continue;let B=Math.cos(z*D),V=Math.sin(z*D),H=Math.cos(R*D),U=Math.sin(R*D),W=Math.cos(ce*D),G=Math.sin(ce*D),K=(W*B-G*V*H)*N+(-W*V-G*B*H)*I,q=(G*B+W*V*H)*N+(-G*V+W*B*H)*I,J=V*U*N+B*U*I;if(te[F]){let e=q*O+J*k,t=-q*k+J*O;q=e,J=t}let le=K*10,Y=J*10,ue=-q*10;if(j(d,P,a+le-c,o+Y-l,s+ue-u)){if(f){let e=M+F,t=P*4;f[t]=e&255,f[t+1]=e>>>8&255,f[t+2]=e>>>16&255,f[t+3]=e>>>24&255}P++}}return P}const M=new Map;self.onmessage=e=>{let t=e.data;if(t.type===`ping`){self.postMessage({type:`pong`});return}if(t.type===`rewireDelta`){if(t.remove)for(let e of t.remove)M.delete(e);for(let e of t.set)M.set(e.id,e.cols);return}if(t.type===`tick`){let e=[],n=[],[r,i,a]=t.basis;for(let o of t.groups){let s=M.get(o.id);if(!s){e.push({id:o.id,count:0,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer);continue}let c=oe(s,t.jd,o.parent[0],o.parent[1],o.parent[2],r,i,a,o.out,o.outIds,t.requiredFlags??0);e.push({id:o.id,count:c,buf:o.out.buffer,idbuf:o.outIds.buffer}),n.push(o.out.buffer,o.outIds.buffer)}self.postMessage({type:`tickResult`,groups:e},n);return}};\n//# sourceMappingURL=worker-CK5Z1yOu.js.map",nP=typeof self<`u`&&self.Blob&&new Blob([`URL.revokeObjectURL(import.meta.url);`,tP],{type:`text/javascript;charset=utf-8`});function rP(e){let t;try{if(t=nP&&(self.URL||self.webkitURL).createObjectURL(nP),!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(tP),{type:`module`,name:e?.name})}}var iP=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 rP;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 zg(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}]},Vg(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()}},aP=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 gh(n[e-t]);return null}clear(){this.#t.clear(),this.#e=1}},oP=.01,sP=[`asteroid`,`spacecraft`],cP=.0002959122082855911,lP=.75,uP=Q(8*86400);function dP(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(cP/i*((1+o)/(1-o)));s>t&&(t=s)}return{maxSpeedScene:t*10,alwaysSolve:n}}function fP(e){return e<0?0:e>1?1:e}function pP(e,t){return t===`*`?e.startsWith(`small_bodies/`):e===t}function mP(e){return e===null?{tBright:0,tSize:0}:{tBright:fP((hP-e)/(hP-gP)),tSize:fP((_P-e)/(_P-vP))}}var hP=1e4,gP=500,_P=gP,vP=50,yP=4,bP=.5,xP=10,SP=1,CP=1,wP=3.5,TP=2.5,EP=2,DP=wP,OP=class{orbitPool=new iP;pickRegistry=new aP;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:yP,dim:bP,opacity:CP};emphasizedSmallBodyZone=null;smallBodyEmphasis={sizeMult:1,brightMult:1,opacity:CP};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 sP)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 sP)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)x_(e)===`naif-399`&&this.applyEarthSatEmphasis(t)}computeEarthSatEmphasis(e){let{tBright:t,tSize:n}=mP(e);return{size:yP+(xP-yP)*n,dim:bP+(SP-bP)*t,opacity:CP+(wP-CP)*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)pP(x_(e),n)&&this.resetSmallBodyEmphasis(t);if(e!==null)for(let[t,n]of this.workerPoints.asteroid)pP(x_(t),e)&&this.applySmallBodyEmphasis(n)}computeSmallBodyEmphasis(e){let{tBright:t,tSize:n}=mP(e);return{sizeMult:1+(TP-1)*n,brightMult:1+(EP-1)*t,opacity:CP+(DP-CP)*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=CP,e.userData.smallBodyBaseSize=void 0,e.userData.smallBodyBaseColor=void 0}seedBasis(e){this.basisPos=[...e]}buildInitial(e){let t=_N(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 sP)for(let[t,n]of this.workerPoints[e]){let r=x_(t);n.userData.parentBodyId=this.cloudParentId(e,r),this.emphasiseNewCloud(e,r,n)}this.assignMapLayer()}assignMapLayer(){for(let e of sP)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`?d_:t}emphasiseNewCloud(e,t,n){if(e===`spacecraft`){t===`naif-399`&&this.applyEarthSatEmphasis(n);return}let r=this.emphasizedSmallBodyZone;r!==null&&pP(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.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=vh(this.bodyObjects.keys()),{groups:o,baseWorker:s}=i?await i.buildWorkerGroups(n,t,a,!1):{groups:[],baseWorker:0},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,dP(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=XM(new Float32Array(l.cols.count*3),0,this.circleTexture,c,JM());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 b_(n,Cv(this.ctx.layers,n,r?Array.from(r.values()):[]),t),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=>_h(e.data.id)??dh));await this.orbitPool.rewireOne(c,l,s,(o+r)%t,!1,u),this.armGroupGate(c,{maxSpeedScene:uP,alwaysSolve:!1});let d=this.workerPoints.spacecraft.get(i);if(d){this.resizeGeometryIfNeeded(d.geometry,l);continue}let f=new Float32Array(l.length*3),p=new Float32Array(l.length*3);this.seedGeometryArray(f,l,p);let m=XM(f,l.length,this.circleTexture,`#ffffff`,void 0,p);this.adoptCloud(`spacecraft`,i,c,m,e)}}if(this.orbitPool.poolGeneration!==n){for(let e of r)this.ctx.bodies.dirtyAsteroidZones.add(e);for(let e of i)this.ctx.bodies.dirtySpacecraftGroups.add(e);this.lastPackedSize.clear(),this.rebuildQueued=!0}}unwireGroup(e,t,n){this.orbitPool.unwireOne(n),this.forgetGroupGate(n),this.pickRegistry.release(n);let r=this.workerPoints[e].get(t);r&&(this.scene.remove(r),this.workerPoints[e].delete(t))}armGroupGate(e,t){this.groupKinematics.set(e,t),this.lastSolvedJd.delete(e)}adoptCloud(e,t,n,r,i){let a=x_(t);r.userData.frontBasis=i,r.userData.groupId=n,r.userData.parentBodyId=this.cloudParentId(e,a),r.userData.parentVec=[0,0,0],this.emphasiseNewCloud(e,a,r),this.workerPoints[e].set(t,r),this.pendingSceneAdds.push(r)}deferPackWhileStreaming(e,t){if(!this.ctx.bodies.minorStreaming)return this.lastPackedSize.set(e,t),!1;let n=this.lastPackedSize.get(e);return n!==void 0&&t>n&&t<n*2?!0:(this.lastPackedSize.set(e,t),!1)}seedGeometryArray(e,t,n=null){let[r,i,a]=this.basisPos,o=Math.min(t.length,e.length/3),s=n?new X:null;for(let c=0;c<o;c++){let o=t[c],l=o.position;e[c*3]=l[0]-r,e[c*3+1]=l[1]-i,e[c*3+2]=l[2]-a,n&&s&&(s.set(m_(o.data)),n[c*3]=s.r,n[c*3+1]=s.g,n[c*3+2]=s.b)}}resizeGeometryIfNeeded(e,t){let n=t.length*3;if(e.getAttribute(`position`).array.length===n){e.setDrawRange(0,t.length);return}let r=!!e.getAttribute(`color`),i=new Float32Array(n),a=r?new Float32Array(n):null;this.seedGeometryArray(i,t,a),e.setAttribute(`position`,new Eo(i,3)),a&&e.setAttribute(`color`,new Eo(a,3)),e.setDrawRange(0,t.length)}resizeGeometryToCount(e,t,n){let r=t*3,i=e.getAttribute(`position`).array;if(n&&e.setAttribute(`color`,new Eo(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 Eo(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 Eo(t.slice(),4,!0))}reposition(){let[e,t,n]=this.focus.focusTruePos,r=this.basisPos;for(let i of sP)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=oP*10;l>u*u&&this.rebuildBasis()}rebuildBasis(){this.basisPos=[...this.focus.focusTruePos],this.rebuildMoons(),this.onBasisRebuilt(),this.reposition()}updateForJd(e,t){this.writeMoons();let n=this._parentsScratch;n.clear();let r=this.ctx.getBody(`naif-10`)?.position??[0,0,0];for(let[i,a]of this.workerPoints.asteroid){if(!this.ctx.visibility.isAsteroidGroupVisible(x_(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(x_(r)))continue;let a=i.userData.groupId,o=this.ctx.getBody(i.userData.parentBodyId)?.position;if(o&&!this.shouldSolveGroup(a,o,e,t))continue;let s=i.userData.parentVec;o?(s[0]=o[0],s[1]=o[1],s[2]=o[2]):(s[0]=0,s[1]=0,s[2]=0),n.set(a,s)}this.orbitPool.tick(e,this.basisPos,n,this.ctx.visibility.getRequiredFlags())}shouldSolveGroup(e,t,n,r){let i=this.groupKinematics.get(e);if(!i||i.alwaysSolve)return!0;let a=this.lastSolvedJd.get(e);if(a===void 0||!isFinite(a))return!0;let[o,s,c]=this.focus.focusTruePos,l=r.camPos[0]-(t[0]-o),u=r.camPos[1]-(t[1]-s),d=r.camPos[2]-(t[2]-c),f=Math.max(1e-6,Math.sqrt(l*l+u*u+d*d)),p=Math.abs(n-a);return i.maxSpeedScene*p/f*r.pxPerRad>=lP}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];if(this.bodyObjects.get(a.data.id)?.outOfRange){s[r*3]=s[r*3+1]=s[r*3+2]=NaN;continue}s[r*3]=a.position[0]-e,s[r*3+1]=a.position[1]-t,s[r*3+2]=a.position[2]-n}o.needsUpdate=!0}}rebuildMoons(){let e=this.basisPos;for(let[t,n]of this.moonsByParent()){let r=this.moonPoints.get(t);if(!r)continue;let i=new Float32Array(n.length*3);for(let t=0;t<n.length;t++)i[t*3]=n[t].position[0]-e[0],i[t*3+1]=n[t].position[1]-e[1],i[t*3+2]=n[t].position[2]-e[2];r.geometry.setAttribute(`position`,new ko(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.orbitPool.destroy(),this.pickRegistry.clear();for(let e of sP)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()}},kP=Math.PI/180,AP=2451545,jP=1.00000261,MP=.01671123,NP=100.46457166*kP,PP=35999.37244981/36525*kP,FP=102.93768193*kP,IP=.32327364/36525*kP;function LP(e){let t=e-AP,n=FP+IP*t,r=NP+PP*t-n,i=r+(2*MP-MP**3/4)*Math.sin(r)+1.25*MP*MP*Math.sin(2*r);return{lon:n+i,r:jP*(1-MP*MP)/(1+MP*Math.cos(i))}}function RP(e){let t=LP(e).lon;return(e,n)=>{let r=t-LP(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 zP=.01,BP=1/100,VP=1;function HP(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 UP(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 WP(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=HP(c,l,u)}function GP(e,t,n,r,i,a){let o=t.userData,s=o.useTrail,c=o.orbitCenter,l=e.trailAnchor??e.position,u=c.x-r[0],d=c.y-r[1],f=c.z-r[2],p=l[0]-c.x,m=l[1]-c.y,h=l[2]-c.z,g=e.lagrangeTrail?NaN:n.newestJd+n.count*1e-9;if(UP(o,g,u,d,f,p,m,h,a))return;let{posArr:_,trailArr:v,fullArr:y}=lN(t),b=e.lagrangeTrail?RP(i):null,x=dN(e,n,_,c.x,c.y,c.z,r,b??void 0);uN(t,_,v,y,x,!0,s),WP(o,g,u,d,f,p,m,h,_,x,a)}function KP(e,t,n,r,i){let{posArr:a,trailArr:o,fullArr:s,capacity:c}=lN(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){aN(e.geometry,a,o,s,l);return}e.geometry.getAttribute(`position`).needsUpdate=!0}function qP(e,t,n,r,i){let a=t.userData.trailBuffer;if(a){GP(e,t,a,n,r,i);return}let o=t.userData.sourceCurve;if(!o){if(!t.userData.curvePending||!e.orbitElements)return;o=nN(Gv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r,t.userData.curvePending=!1}let s=t.userData.isOpenCurve,c=t.userData.useTrail,l=t.userData.orbitCenter,u=l.x,d=l.y,f=l.z;if(e.data.satrec){let n=e.data.n/360,i=n>0?1/n/512:0,a=t.userData.curveJd;(o.length===0||a===void 0||Math.abs(r-a)>=i)&&(o=eN(e.data.satrec,r,n,512),t.userData.sourceCurve=o,t.userData.curveJd=r)}else if(e.orbitElements){if(e.rederiveElements){let n=t.userData.elementsJd??r,i=e.orbitElements.n,a=i>0?360/i:1/0;if(Math.abs(r-n)>Math.min(a*BP,VP)){let n=e.rederiveElements(r);n&&(Object.assign(e.orbitElements,n),o=nN(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)>zP&&(o=nN(Gv(e.orbitElements,r),512).points,t.userData.sourceCurve=o,t.userData.curveJd=r)}}let p=e.trailAnchor??e.position,m=t.userData,h=u-n[0],g=d-n[1],_=f-n[2],v=p[0]-u,y=p[1]-d,b=p[2]-f;if(UP(m,o,h,g,_,v,y,b,i))return;let x=$y(e,o,s,u,d,f);if(x.length<2)return;let{posArr:S,trailArr:C,fullArr:w,capacity:T}=lN(t),E=u-n[0],D=d-n[1],O=f-n[2],k=Math.min(x.length,T);for(let e=0;e<k;e++)S[e*3]=x[e][0]+E,S[e*3+1]=x[e][1]+D,S[e*3+2]=x[e][2]+O;uN(t,S,C,w,k,s,c),m.trailLocalPositions=x,WP(m,o,h,g,_,v,y,b,S,k,i)}function JP(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 YP(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 XP=4/2,ZP=(.1*10)**2,QP=new J,$P=[],eF=$P;function tF(e){return ZO($P,e,tk)}var nF={x:0,y:0,left:0,right:0,h:0},rF=new Vi,iF={ox:0,oy:0},aF=new J,oF=new J;function sF(e,t,n,r,a,o,s,c,l,u,d,f,p,m,h){let g=n.layers,_=!g.isVisible(`orbits`),v=g.isVisible(`nomenclature`),y=t.fov*Math.PI/180,b=f.domElement.clientWidth,x=f.domElement.clientHeight,S=x/(2*Math.tan(y/2)),C=[r[0]+t.position.x,r[1]+t.position.y,r[2]+t.position.z],w=r,T=t.matrixWorldInverse;for(let n of e.values()){if(n.cachedDist=L_(C,n.body.position),n.isCrashed||n.noPhysical){let e=n.noPhysical===`model`,t=sg(n.cachedDist)<(n.isCrashed||e?.1:1),r=null;if(t){let t=i().messages;r=n.isCrashed?t.body_note_crash_site():e?t.body_note_no_model():t.body_note_no_radius()}JE(n,`missing`,r)}let e=n.label;if(!e)continue;n.labelAnchorOffscreen=!1;let r=n.noPhysical?0:n.radiusScene;if(!r){e.position.set(0,0,0);continue}let[a,o,s]=n.body.position;p.set(a-w[0],o-w[1],s-w[2]).applyMatrix4(T);let c=p.x,l=p.y,u=p.z,d=u*u,f=r*r;if(d<=f){e.position.set(0,0,0),n.labelAnchorOffscreen=!0;continue}let m=r/n.cachedDist*S;if(m<1){e.position.set(0,0,0);continue}if(m>=16){let i=n.cachedDist,d=1/i,f=c*d,m=l*d,h=u*d,g=r*d,_=Math.sqrt(Math.max(1-g*g,0)),v=1-f*f,y=-f*m,b=-f*h,x=Math.hypot(v,y,b);x<1e-4&&(v=-m*f,y=1-m*m,b=-m*h,x=Math.hypot(v,y,b));let S=g/x,C=f*_+v*S,T=m*_+y*S,E=h*_+b*S;p.set(C*i-c,T*i-l,E*i-u).applyQuaternion(t.quaternion),e.position.copy(p),oF.set(a-w[0]+p.x,o-w[1]+p.y,s-w[2]+p.z).project(t),n.labelAnchorOffscreen=Math.abs(oF.x)>1||Math.abs(oF.y)>1;continue}if(n.semiAxesScene&&n.mesh)JN(c,l,u,GN(n.mesh.getWorldQuaternion(rF),T,n.semiAxesScene),S,iF),p.set(iF.ox,iF.oy,0).applyQuaternion(t.quaternion);else{let e=f/(d-f);p.set(e*c,e*l,0).applyQuaternion(t.quaternion)}e.position.copy(p)}let E=$P,D=b*.5,O=x*.5,k=0;for(let t of e.values()){let e=t.noPhysical?0:t.radiusScene;if(!e)continue;let n=t.cachedDist,[r,i,a]=t.body.position,o=t.model?.userData.occluderSpheres;if(t.model&&o?.length){let e=QD(t),s=t.model.position;for(let c of o){let o=c.r*e;if(aF.copy(c.center).applyQuaternion(t.model.quaternion).add(s).multiplyScalar(e),p.set(r-w[0]+aF.x,i-w[1]+aF.y,a-w[2]+aF.z).applyMatrix4(T),p.z>=o||p.lengthSq()<=o*o)continue;let l=p.z*p.z;(l<=o*o||o*S/Math.sqrt(l-o*o)>=16)&&KN(tF(k++),p.x,p.y,p.z,o,S,D,O,t.body.data.id,n)}continue}p.set(r-w[0],i-w[1],a-w[2]).applyMatrix4(T);let s=p.x,c=p.y,l=p.z;if(l>=e)continue;let u=l*l;(u<=e*e||e*S/Math.sqrt(u-e*e)>=16)&&(t.semiAxesScene&&t.mesh?qN(tF(k++),s,c,l,GN(t.mesh.getWorldQuaternion(rF),T,t.semiAxesScene),S,D,O,t.body.data.id,n):KN(tF(k++),s,c,l,e,S,D,O,t.body.data.id,n))}E.length=k;let A=n.visibility.focusedSystemId,j=!1,M=a?_M(n.getBody(a),e):void 0;for(let r of e.values()){let{body:i,group:s,trail:c}=r,l=r.cachedDist,u,d,f=i.data.id===a,p=A!==null&&i.data.id===A;if(r.mesh===null&&!gn(i.data.objectType)){let t=i.data.objectType;if(t===G.BARYCENTER||t===G.LAGRANGE_POINT){let t=!0,r=f?void 0:N_(i.data.id);if(r){let a=e.get(r)?.body??n.getBody(r);a&&L_(i.position,a.position)/L_(C,a.position)*S<16&&(t=!1)}s.visible=t,c&&(c.visible=t),u=t,d=!1}else{let e=n.visibility.getPlanetVisibility(i,l)!==$.HIDE&&n.visibility.hasFullRendering(i);s.visible=e,c&&(c.visible=e),u=e,d=!1}}else{let e=i.data.objectType===G.MOON,t=e?n.visibility.getMoonVisibility(i):n.visibility.getPlanetVisibility(i,l),r=e?JP(t,o,f):YP(t,n.visibility.hasFullRendering(i),f||p);s.visible=r.groupVisible,c&&(c.visible=r.orbitVisible),u=r.showLabel,d=r.isClose}if(r.outOfRange&&(s.visible=!1,c&&(c.visible=!1),u=!1),r.starPoint){let e=r.radiusScene/l*S,t=e<XP;if(r.starPoint.visible=t,t){let t=r.starPoint.material,n=e/XP,i=Math.max(YA*n*n,3);t.uniforms.uIntensity.value=i}s.visible=!0,d=!t,u=!d}if(r.isMinor&&!f&&c&&(c.visible=!1),h&&c?.visible){let e=c.userData.orbitCenter;e&&e.distanceToSquared(QP.set(w[0],w[1],w[2]))>ZP&&(c.visible=!1)}_&&c&&(c.visible=!1),s.matrixWorldAutoUpdate=s.visible;let{label:m}=r;if(!s.visible&&m&&m.parent===s?(s.remove(m),m.element.remove()):s.visible&&m&&m.parent!==s&&s.add(m),r.mesh&&r.radiusScene>0){let e=!f&&!p&&r.radiusScene/l*S<.5;e!==r.meshSubPixel&&(r.meshSubPixel=e,e?r.mesh.layers.disable(0):r.mesh.layers.enable(0))}ok(r,u,d,l,S,a)&&(j=!0);let g=r.radiusScene>0?r.radiusScene/l*S:0;zM(r,v&&i.data.id===M,g,t,b,x)}for(let[e,t]of c)t.visible=n.visibility.isAsteroidGroupVisible(x_(e));for(let[e,t]of l)t.visible=n.visibility.isSpacecraftGroupVisible(x_(e));for(let[e,t]of u)t.visible=n.visibility.isMoonGroupVisible(e);if(E.length>0)for(let n of e.values())n.label?.visible&&lk(n,t,w,b,x,nF)&&sk(nF.x,nF.y,n.cachedDist,n.body.data.id,E)&&(n.label.visible=!1);if((m||j||++d>=3)&&(d=0,Sk(e,b,x,t,a,n,s,E,r)),Ck(e,b,x,t,r),M){let t=e.get(M);t&&UM(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 i=n.body.data.id===a,o=s.has(n.body.data.id);r.uniforms.uAlphaMultiplier.value=o?2:i?1.75:1;let c=e.userData.isOpenCurve===!1;r.uniforms.uAlphaMin.value=i&&c?.15:0,r.uniforms.uShowFull.value=+!!i}return d}function cF(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function lF(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function uF(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function dF(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 fF(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-pF(d):p,g=f?m+pF(f):m;if(t<h||t>g)return null;if(a&&d&&t<(c?.jds[0]??n.startJd))return{r:mF(d,t),centerId:a.anchorId};if(c&&t<=c.jds[c.jds.length-1])return{r:hF(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:mF(f,t),centerId:o.anchorId};if(l)return{r:hF(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}=dF(e,v);return{r:hF(y,b,t,x,S),centerId:e.centerId}}function pF(e){return e.jds[e.jds.length-1]-e.jds[0]}function mF(e,t){let n=pF(e),r=e.jds[0],i=n>0?r+((t-r)%n+n)%n:t;return hF(e.points,e.jds,i)}function hF(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 cF(e[a-1],uF(lF(e[a],e[a-1]),s))}var gF=Math.PI/180,_F=Math.cos(ig*gF),vF=Math.sin(ig*gF);function yF(e,t,n,r){let i=Math.cos(e*gF),a=Math.sin(e*gF),o=Math.cos(t*gF),s=Math.sin(t*gF),c=Math.cos(n*gF),l=Math.sin(n*gF);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 bF(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*_F+a*vF,t=-i*vF+a*_F;i=e,a=t}return[r,i,a]}function xF(e){let t=10/rg;return[e[0]*t,e[2]*t,-e[1]*t]}function SF(e,t,n){let{a:r,e:i,ma:a,n:o,epoch:s,q:c,tp:l}=e,{om:u,w:d}=Gv(e,t),f=e.equatorial??!1;if(!isFinite(r)||r===0||!isFinite(o)||o<=0){if(c==null||l==null||!isFinite(c)||!isFinite(l)||c<=0)return null;let r=Cg(c,l,t);if(!r)return null;let i=n&&n>0?n:$_,a=r.r*rg,o=2*c*rg;return CF(a,r.nu,o,1,i,d,e.i,u,f)}if(!isFinite(i)||!isFinite(a))return null;let p=r*rg,m=o*gF/ev,h=n&&n>0?n:m*m*Math.abs(p)*Math.abs(p)*Math.abs(p);if(!isFinite(h)||h<=0)return null;let g=(a+o*(t-s))*gF,_,v;if(i<1||r>0){let e=Math.min(i,.9999999),t=bg(g,e),n=1-e*Math.cos(t);_=Math.atan2(Math.sqrt(1-e*e)*Math.sin(t),Math.cos(t)-e),v=p*n}else{let e=Sg(g,i);if(!isFinite(e))return null;let t=i*Math.cosh(e)-1;if(Math.abs(t)<1e-15)return null;_=Math.atan2(Math.sqrt(i*i-1)*Math.sinh(e)/t,(i-Math.cosh(e))/t),v=p*(1-i*Math.cosh(e))}if(!isFinite(v)||v<=0)return null;let y=p*(1-i*i);return!isFinite(y)||y<=0?null:CF(v,_,y,i,h,d,e.i,u,f)}function CF(e,t,n,r,i,a,o,s,c){let l=Math.cos(t),u=Math.sin(t),d=Math.sqrt(i/n),f=yF(a,o,s,c),p=bF(e*l,e*u,f),m=bF(-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 wF={cruise:`#7fdbff`,boost:`#ffb454`,brake:`#ff8c69`,spiral:`#c9a0ff`,"spiral-out":`#9b7fd4`,"spiral-in":`#9b7fd4`};wF.cruise,wF.boost,wF.brake,wF.spiral,wF[`spiral-out`],wF[`spiral-in`];var TF={notice:`#8ab4f8`,caution:`#f2b23e`,severe:`#ff6b5a`},EF=3,DF=1,OF=2,kF=.6,AF=1.5,jF=.3,MF=1.5,NF=.85,PF=60,FF=.018,IF=.026,LF=`#ffffff`,RF=4,zF=1.5,BF=9,VF=1,HF={notice:RF-3,caution:RF-2,severe:RF-1},UF=[`notice`,`caution`,`severe`],WF=.03,GF=.2;function KF(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 Mc(t)}function qF(e){let t=document.createElement(`canvas`);t.width=t.height=64;let n=t.getContext(`2d`);return n.beginPath(),n.moveTo(64/2,8),n.lineTo(56,56),n.lineTo(8,56),n.closePath(),n.fillStyle=e,n.fill(),n.lineWidth=6,n.lineJoin=`round`,n.strokeStyle=`rgba(0,0,0,0.65)`,n.stroke(),new Mc(t)}function JF(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 YF(e,t){let n=new ss(new qo({map:e,transparent:!0,sizeAttenuation:!1,depthTest:!1}));return n.scale.setScalar(t),n.renderOrder=RF,n}function XF(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&&(Nk(c,i),gM(c,o)),s&&(c.addEventListener(`mouseenter`,()=>s(!0)),c.addEventListener(`mouseleave`,()=>s(!1)));let p=new YO(c);return p.center.set(0,.5),p}var ZF=class{group=new Ra;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?AF:OF,i?jF:kF,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)=>UF.indexOf(e.severity)-UF.indexOf(t.severity));for(let t of n){let n=TF[t.severity];for(let n of t.bands)e.arcs.forEach((t,r)=>{this.addLine(JF(t,n.startJd,n.endJd,dF(e,r)),TF[n.severity],BF,VF,null,{renderOrder:HF[n.severity]})});if(this.mergeIntoStep(t,n))continue;let r=fF(e,t.startJd);if(!r)continue;let i=xF(r.r),a=r.centerId===e.centerId?null:r.centerId,o=YF(qF(n),WF);this.group.add(o),this.markers.push({sprite:o,local:i,anchorId:a});let s=document.createElement(`div`);s.className=`scene-hazard-label`,s.style.color=n,s.textContent=t.label;let c=new YO(s);c.center.set(0,.5),this.group.add(c),this.labels.push({object:c,local:i,anchorId:a,owner:null,width:0,height:0,dimmed:!1,faint:!0})}}mergeIntoStep(e,t){let n=e.kind===`aeroassist`?`aero-pass`:e.kind===`belt-crossing`?`assist`:null;if(!n)return!1;let r=null,i=1/0;for(let{step:t,label:a}of this.drawnSteps){if(t.kind!==n||e.bodyId&&t.bodyId!==e.bodyId)continue;let o=Math.abs(t.jd-e.peakJd);o<i&&(i=o,r=a)}if(!r)return!1;let a=r.object.element,o=document.createElement(`span`);return o.className=`scene-path-label__hazard`,o.style.color=t,o.dir=`auto`,o.textContent=e.label,a.querySelector(`.scene-path-label__text`)?.append(o),a.setAttribute(`aria-label`,`${a.getAttribute(`aria-label`)} — ${e.label}`),!0}addPlan(e,t){let n=e.path;this.addArcs(n,EF,DF,null,!0),this.addEndOrbits(n),this.addSteps(n,t);for(let e of this.markers)this.group.add(e.sprite);this.craft={sprite:YF(KF(LF),IF),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=fF(e,n.jd);if(!t)continue;let r=xF(t.r),i=t.centerId===e.centerId?null:t.centerId,a=YF(KF(LF),FF);this.markers.push({sprite:a,local:r,anchorId:i});let o=XF(`step`,n.name,n.when,{canvas:this.canvas,onSelect:n.onPick});this.group.add(o),this.labels.push({object:o,local:r,anchorId:i,owner:null,width:0,height:0,dimmed:!1,faint:!1,step:!0,sprite:a}),this.drawnSteps.push({step:n,label:this.labels[this.labels.length-1]})}}addEndLabels(e,t=!1){let{path:n,onSelect:r}=e,i=n.arcs[0],a=n.arcs[n.arcs.length-1],o=n.stops.find(e=>e.kind===`departure`),s=[{local:xF(n.meeting.r),end:e.arrival,color:wF[a?.kind??`cruise`]}];o&&s.push({local:xF(o.r),end:e.departure,color:wF[i?.kind??`cruise`]});for(let{local:n,end:i,color:a}of s){if(!i.name)continue;let o=XF(`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?DF:e.brightness),n.uniforms.uLineWidth.value=t?EF: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?dF(e,s):{from:0,to:a.points.length};this.addLine(a.points.slice(c,l),wF[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),wF.cruise,EF,DF,null,{anchorId:n}),this.addLine(t.approach.slice(i.from,i.to),wF.cruise,EF,DF,null,{anchorId:n,renderOrder:zF}),e=i.to;e<t.approach.length&&this.addLine(t.approach.slice(Math.max(0,e-1)),wF.cruise,EF,DF,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,wF.cruise,EF,DF,null,{anchorId:n});this.addLine(t.approach.slice(e>0?e-1:0,r),wF.cruise,MF,NF,null,{anchorId:n})}else this.addLine(t.approach,wF.cruise,EF,DF,null,{anchorId:n});let i=this.addLine(t.points,wF.cruise,MF,NF,null,{anchorId:n});if(!i)continue;let a=n===null?xF(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]=xF(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*GF));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=cN(o,c,l,l,o,t,n,r);d.frustumCulled=!1,d.renderOrder=a.renderOrder??RF,this.group.add(d);let f={line:d,owner:i,anchorId:a.anchorId??null,color:t,brightness:r,width:n,local:s,positions:c,alphas:l,count:o};return this.arcs.push(f),f}setClock(e){let t=this.craft;if(!t||!this.path)return;let n=fF(this.path,e);t.sprite.visible=n!==null,n&&(t.local=xF(n.r),t.anchorId=n.centerId===this.path.centerId?null:n.centerId)}reposition(e,t,n){if(this.center===null)return;let r=e[0]-t[0],i=e[1]-t[1],a=e[2]-t[2],o=new Map,s=e=>{if(e===null)return[r,i,a];let s=o.get(e);if(s)return s;let c=n(e),l=c?[c[0]-t[0],c[1]-t[1],c[2]-t[2]]:[r,i,a];return o.set(e,l),l};for(let e of this.arcs){let[t,n,r]=s(e.anchorId);for(let i=0;i<e.count;i++)e.positions[i*3]=e.local[i*3]+t,e.positions[i*3+1]=e.local[i*3+1]+n,e.positions[i*3+2]=e.local[i*3+2]+r;aN(e.line.geometry,e.positions,e.alphas,e.alphas,e.count)}for(let e of this.markers){let[t,n,r]=s(e.anchorId);e.sprite.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}for(let e of this.labels){let[t,n,r]=s(e.anchorId);e.object.position.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}if(this.craft){let{sprite:e,local:t,anchorId:n}=this.craft,[r,i,a]=s(n);e.position.set(t[0]+r,t[1]+i,t[2]+a)}for(let e of this.rings){let[t,n,r]=s(e.arc.anchorId);e.world.set(e.local[0]+t,e.local[1]+n,e.local[2]+r)}}updateCameraOffset(e){if(this.arcs.length!==0){this.offset.set(-e.x,-e.y,-e.z);for(let e of this.arcs)e.line.material.uniforms.uCenterOffset.value.copy(this.offset);for(let t of this.rings){let n=t.world.distanceTo(e);t.arc.line.visible=n<t.radius*PF}}}setVisible(e){this.group.visible=e}reserveLabelSpace(e,t,n){if(!this.group.visible||this.labels.length===0){bk(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),!rT(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=sk(a,o,s,``,eF);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++}bk(this.rects,r)}setStepVisible(e,t){e.object.visible=t,e.sprite&&(e.sprite.visible=t)}setLabelDimmed(e,t){e.dimmed!==t&&(e.dimmed=t,e.object.element.classList.toggle(`scene-path-label--dim`,t))}clear(){for(let e of this.arcs)this.group.remove(e.line),e.line.geometry.dispose(),e.line.material.dispose();for(let e of[...this.markers,...this.craft?[this.craft]:[]]){this.group.remove(e.sprite);let t=e.sprite.material;t.map?.dispose(),t.dispose()}for(let e of this.labels)this.group.remove(e.object),e.object.element.remove();this.arcs=[],this.rings=[],this.markers=[],this.labels=[],this.drawnSteps=[],this.craft=null,this.path=null,this.center=null}dispose(){this.clear(),this.scene.remove(this.group)}},QF=2,$F=1,eI=4,tI=200,nI=class{group=new Ra;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,tI);for(let t=0;t<e.count;t++){let[r,i,a]=xF(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(tI*3),t=new Float32Array(tI).fill(1),n=cN(tI,e,t,t,0,wF.cruise,QF,$F);n.frustumCulled=!1,n.renderOrder=eI,this.layer!==null&&n.layers.set(this.layer),this.group.add(n),this.slots.push({line:n,bodyId:``,local:new Float64Array(tI*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;aN(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)}},rI=30034e-10,iI=.45,aI=1.6,oI=.85,sI=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],cI=e=>Math.hypot(e[0],e[1],e[2]);function lI(e,t,n=rI){let r=cI(t);if(!(r>0))return null;let i=r*Math.cbrt(n/3),a=sI(e,t)/r,o=cI(e);if(Math.sqrt(Math.max(0,o*o-a*a))>oI*i)return null;let s=a/i;return s>=iI&&s<=aI?`EL1`:s<=-iI&&s>=-aI?`EL2`:null}function uI(){return{count:0,earliestStart:1/0,latestEnd:-1/0}}var dI=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`?jg(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})}}},fI=new Map,pI=new J;function mI(e,t,n,r,i,a,o){let s=Ty(n,r,Cy(t));if(!s)return null;let c=`naif-${n.bodyNaifId}`,l=a.bodies.bodiesById.get(c);if(!l||!l.orientation)return null;let u=i.get(c);if(!u)return null;let d=l.data.radiusKm;if(!Number.isFinite(d)||d<=0)return null;let f=Math.PI/180,p=s.latDeg*f,m=s.lngDeg*f,h=Ow(o.get(c),c,d,p,m);h&&fI.set(e.id,h);let g=h??fI.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=fC(l.orientation,r,l.nutPrec),x=new J(_,v,y).applyQuaternion(b),S=g?pI.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 hI=[0,0,0],gI=new Vi,_I=4,vI=0,yI=new Map;function bI(e){return e.primary.target===`velocity`||e.secondary?.target===`velocity`}function xI(e,t,n){let r=yI.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 yI.set(e,{jd:t,pos:[n[0],n[1],n[2]],dir:i}),i??void 0}function SI(e){let{jd:t,ctx:n,bodyObjects:r,focus:a,focusedBody:o,positionMap:s,diagnostics:c,trailView:l,frame:u,outOfRange:d}=e;n.chebStore?.ensure(t),n.probeStore?.ensure(t);let f=n.visibility.activeSystemId,p=f?e=>n.bodies.isInSystem(`naif-${e}`,f):void 0,m={jd:t,satellites:{kind:`covered`},majorBodies:uI(),focusedOutOfRange:!1},h=o?.data.id,g=gx(n.probeStore?.ridesAt(t)??[],h,e=>n.getBody(e)?.data.name),_=[];if(o){let e=new Set([o.data.id]),t=n.getBody(o.data.parentId);for(;t&&!e.has(t.data.id);)e.add(t.data.id),_.push({id:t.data.id,oldPos:[t.position[0],t.position[1],t.position[2]],bo:r.get(t.data.id)}),t=n.getBody(t.data.parentId)}s.clear(),s.set(`naif-0`,[0,0,0]);for(let e of n.bodies.bodiesById.values())s.set(e.data.id,e.position);for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||s.set(e.body.data.id,e.body.position);let v=new Set,y=e=>{if(v.has(e.data.id))return;v.add(e.data.id);let a=e.data,o=r.get(a.id);if(o&&u!==void 0&&a.id!==h&&!o.group.visible&&!o.trail?.visible&&(a.orbitalSource===tn.SPICE_PROBE||!gn(a.objectType))&&(o.staggerSlot??=vI++%_I,u%_I!==o.staggerSlot))return;let l=(t=!1)=>{o&&(o.outOfRange=!0),e.positionUnknown=!0,!t&&a.id===h&&(m.focusedOutOfRange=!0)};if(a.unplaceable){l(!0);return}let d=n.chebStore?.has(a.id)??!1,f=a.orbitalSource===tn.SPICE_PROBE;if(f){if(g.hidden.has(a.id)){l(!0);return}if(o){let e=g.credits.get(a.id);JE(o,`carrier`,e?i().messages.carried_by_scene_label({carrier:e}):null)}}if(a.visibleFromDays!==void 0&&t-2451545<a.visibleFromDays){l();return}let _;if(f)_=s.get(a.parentId)??[0,0,0];else{let e=s.get(a.parentId);if(!e){l(),c.warnOnce(`missing-parent`,a.id,()=>`computePosition[${a.id}]: parent ${a.parentId} not in positionMap — hiding`);return}_=e,c.clear(`missing-parent`,a.id)}let b=a.q!=null;if(!d&&!f&&(t<a.validityStart||t>a.validityEnd)){l(!a.satrec);return}let x,S,C;if(d){let e=n.chebStore.positionScene(a.id,t);if(!e){l(!0);let e=n.chebStore.zoneCoverage(a.id);e&&(t<e.start||t>e.end)&&(m.majorBodies.count++,e.start<m.majorBodies.earliestStart&&(m.majorBodies.earliestStart=e.start),e.end>m.majorBodies.latestEnd&&(m.majorBodies.latestEnd=e.end),a.id===h&&(m.focusedOutOfRange=!0)),c.warnOnce(`cheb-null`,a.id,()=>{let n=e?t>=e.start&&t<=e.end:void 0,r=e?`[${e.start.toFixed(1)},${e.end.toFixed(1)}]`:`unknown`;return`chebStore.positionScene[${a.id}] returned null at jd=${t.toFixed(3)} (coverage=${r}, insideCoverage=${n}) — children of this body will read stale positionMap entry (pre-seeded) instead of falling to SSB`});return}x=_[0]+e[0],S=_[1]+e[1],C=_[2]+e[2]}else if(f){let i=n.probeStore?.probeWithCenter(a.id,t,p)??null;if(!i){l(),c.warnOnce(`probe-unavailable`,a.id,()=>{let e=n.probeStore?`no zone has both a loaded chunk and a sub-chunk covering this jd`:`no ProbeStore`;return`probe ${a.id} (${a.name??`unnamed`}): hidden — ${e}`});return}let u=i.probe.landed;if(u&&wy(i.probe,t)){let d=a.parentId,f=mI(a,i.probe,u,t,s,n,r);if(!f){l();return}if(c.clear(`probe-unavailable`,a.id),e.positionUnknown=!1,d!==a.parentId&&e.trailBuffer?.clear(),o){o.outOfRange=!1;let e=u.isDestroyed;(!o.isLanded||o.isCrashed!==e)&&(Dk(o.labelHalo,e?`crashed`:`landed`),o.isLanded=!0,o.isCrashed=e),o.model&&(o.model.visible=!e)}e.position[0]=f.x,e.position[1]=f.y,e.position[2]=f.z,e.orbitCenter&&(e.orbitCenter[0]=f.parentPos[0],e.orbitCenter[1]=f.parentPos[1],e.orbitCenter[2]=f.parentPos[2]),e.trailAnchor&&(e.trailAnchor[0]=f.parentPos[0],e.trailAnchor[1]=f.parentPos[1],e.trailAnchor[2]=f.parentPos[2]),s.set(a.id,e.position);let p=f.up;o?.mesh&&(p?_C(o.mesh,p):gC(o.mesh,e.position,f.parentPos)),o?.model&&(p?_C(o.model,p):gC(o.model,e.position,f.parentPos));return}let d=By(i.probe,t,i.fitCenterNaifId,n.chebStore??null,e=>s.has(e));if(!d){l(),c.warnOnce(`probe-unavailable`,a.id,()=>`probe ${a.id} (${a.name??`unnamed`}): hidden — stamped fit center is not placeable this frame`);return}let f=d.id,m=d.muKm3S2,g=xy(i.probe,t,m);if(!g){l(),c.warnOnce(`probe-unavailable`,a.id,()=>`probe ${a.id} (${a.name??`unnamed`}): hidden — sub-chunk evaluation returned null (uncoverable, non-finite fit, or missing mu for kepler_pure)`);return}c.clear(`probe-unavailable`,a.id),o?.isLanded&&(Dk(o.labelHalo,`flying`),o.isLanded=!1,o.isCrashed&&(o.isCrashed=!1,o.model&&(o.model.visible=!0),o.noPhysical||JE(o,`missing`,null)));let b=s.get(f_),w=s.get(d_),T=f===`naif-399`&&b!==void 0&&w!==void 0&&lI([Q(g[0]),Q(g[2]),-Q(g[1])],[w[0]-b[0],w[1]-b[1],w[2]-b[2]])!==null,E=T!==(e.lagrangeTrail??!1);e.lagrangeTrail=T;let D=a.parentId!==f;if((D||E)&&e.trailBuffer&&n.probeStore){let r=e.trailBuffer;r.clear(),r.needsPopulate=!1;let o=Wy(Ly(i.probe,t,m),a.validityEnd-a.validityStart,r.capacity,T);r.reconfigure(o.stepDays,o.epsilonScene,o.spanDays),Xy(r,n.probeStore,n.chebStore??null,a.id,f,t)}if(D&&(a.parentId=f),!v.has(f)){let e=n.bodies.bodiesById.get(f)??r.get(f)?.body;e&&y(e)}let O=s.get(f);if(!O){l(),c.warnOnce(`probe-unavailable`,a.id,()=>`probe ${a.id} (${a.name??`unnamed`}): hidden — fit center ${f} has no position this frame`);return}_=O;let k=Q(g[0]),A=Q(g[2]),j=-Q(g[1]);x=_[0]+k,S=_[1]+A,C=_[2]+j;let M=e.trailBuffer;if(M?.needsPopulate&&o?.trail?.visible&&n.probeStore&&(M.needsPopulate=!1,M.clear(),Xy(M,n.probeStore,n.chebStore??null,a.id,f,t)),M){let e=M.newestJd,r=t-e,o=M.stepDays*M.capacity,s=isFinite(e)&&(r<0||r>o);if(s&&a.id===h&&n.probeStore){M.clear();let e=Wy(Ly(i.probe,t,m),a.validityEnd-a.validityStart,M.capacity,T);M.reconfigure(e.stepDays,e.epsilonScene,e.spanDays),Xy(M,n.probeStore,n.chebStore??null,a.id,f,t)}else s?(M.clear(),M.append(t,k,A,j)):isFinite(e)?isFinite(M.epsilonScene)?r>=M.stepDays*.00390625&&n.probeStore&&M.readNewestPos(hI)&&Qy(M,Ky(n.probeStore,n.chebStore??null,a.id,f),e,[hI[0],hI[1],hI[2]],t):r>=M.stepDays&&M.append(t,k,A,j):M.append(t,k,A,j)}}else if(a.a===0&&!b&&!a.satrec)[x,S,C]=_;else{let e=a.satrec?yg(a.satrec,t):b?Yv(a,t):qv(a,t);if(!e){l();return}x=_[0]+e[0],S=_[1]+e[1],C=_[2]+e[2]}if(o&&(o.outOfRange=!1),e.positionUnknown=!1,e.position[0]=x,e.position[1]=S,e.position[2]=C,(!Number.isFinite(x)||!Number.isFinite(S)||!Number.isFinite(C))&&c.warnOnce(`non-finite`,a.id,()=>{let e=s.has(a.parentId);return`computePosition[${a.id}] non-finite: pos=[${x},${S},${C}] parentId=${a.parentId} parentInPositionMap=${e} parentPos=[${_[0]},${_[1]},${_[2]}] isChebTracked=${d} isProbe=${f} objectType=${a.objectType}`}),e.orbitCenter&&(e.orbitCenter[0]=_[0],e.orbitCenter[1]=_[1],e.orbitCenter[2]=_[2]),e.trailAnchor&&(e.trailAnchor[0]=_[0],e.trailAnchor[1]=_[1],e.trailAnchor[2]=_[2]),s.set(a.id,e.position),o){if(o.trail&&e.orbitCenter){let e=o.trail.userData.orbitCenter;e&&e.set(_[0],_[1],_[2])}if(e.orientation&&(o.mesh||o.model))o.mesh&&pC(o.mesh,e.orientation,t,e.nutPrec),o.model&&pC(o.model,e.orientation,t,e.nutPrec),o.nomenclatureAnchor&&pC(o.nomenclatureAnchor,e.orientation,t,e.nutPrec);else if(KD(e)){let n=e.attitudeTrack;if(!e.pointingOverride&&n&&n.orientationAt(t,gI))o.mesh&&o.mesh.quaternion.copy(gI),o.model&&o.model.quaternion.copy(gI);else{let n=e.pointingOverride??e.pointing;if(n){let r=bI(n)?xI(a.id,t,e.position):void 0,i={bodyPos:e.position,parentPos:_,sunPos:s.get(d_),velocity:r};o.mesh&&jC(o.mesh,n,i),o.model&&jC(o.model,n,i)}else o.mesh&&gC(o.mesh,e.position,_),o.model&&gC(o.model,e.position,_)}}if(e.orientation)for(let n of o.rings)pC(n.mesh,e.orientation,t,e.nutPrec)}},b=n.visibility.focusedSystemId;for(let e of n.bodies.bodiesById.values()){if(e.data.objectType===G.MOON&&!(b!==null&&e.data.parentId===b)&&e.data.id!==h){s.set(e.data.id,e.position);continue}y(e)}for(let e of r.values())n.bodies.bodiesById.has(e.body.data.id)||y(e.body);if(m.satellites=n.refresher?.satelliteCoverage(t)??{kind:`covered`},d.update(m),o&&cn(o)){let e=n.getBody(o.featureAnchor.hostId);e&&s.has(e.data.id)?zw(o,e,r.get(e.data.id),t):m.focusedOutOfRange=!0}let x=null;if(o&&m.focusedOutOfRange){let e=_.find(e=>e.bo&&!e.bo.outOfRange);if(e){x=e.id;let t=s.get(e.id)??e.oldPos;if(performance.now()-a.focusStartTime<a.focusDurationMs){a.focusTargetWorld[0]=t[0],a.focusTargetWorld[1]=t[1],a.focusTargetWorld[2]=t[2];let e=a.camTargetOffset;e&&a.camTargetWorld&&(a.camTargetWorld[0]=t[0]+e[0],a.camTargetWorld[1]=t[1]+e[1],a.camTargetWorld[2]=t[2]+e[2])}else{let n=t[0]-e.oldPos[0],r=t[1]-e.oldPos[1],i=t[2]-e.oldPos[2];a.focusTruePos[0]+=n,a.focusTruePos[1]+=r,a.focusTruePos[2]+=i,a.focusTargetWorld[0]=a.focusTruePos[0],a.focusTargetWorld[1]=a.focusTruePos[1],a.focusTargetWorld[2]=a.focusTruePos[2]}}}else if(o){let e=o.position,t=performance.now()-a.focusStartTime<a.focusDurationMs;a.focusTargetWorld[0]=e[0],a.focusTargetWorld[1]=e[1],a.focusTargetWorld[2]=e[2];let n=a.camTargetOffset;n&&a.camTargetWorld&&(a.camTargetWorld[0]=e[0]+n[0],a.camTargetWorld[1]=e[1]+n[1],a.camTargetWorld[2]=e[2]+n[2]);let r=a.camOriginOffset;r&&a.camOriginWorld&&(a.camOriginWorld[0]=e[0]+r[0],a.camOriginWorld[1]=e[1]+r[1],a.camOriginWorld[2]=e[2]+r[2]),t||(a.focusTruePos[0]=e[0],a.focusTruePos[1]=e[1],a.focusTruePos[2]=e[2])}let S=a.focusTruePos;for(let e of r.values()){let n=e.trail;if(n){if(!n.visible){n.userData.refreshDeferred=!0;continue}qP(e.body,n,S,t,l),n.userData.refreshDeferred=!1}}return{focusedOutOfRange:m.focusedOutOfRange,reanchorId:x}}function CI(e,t,n,r){let i=t.focusTruePos;for(let t of e.values()){let e=t.trail;!e||!e.visible||!e.userData.refreshDeferred||(qP(t.body,e,i,n,r),e.userData.refreshDeferred=!1)}}var wI=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)}},TI=Q(695700),EI=2,DI=new J;function OI(e,t,n,r,i){DI.subVectors(e,t);let a=DI.dot(n),o=Math.sqrt(Math.max(DI.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 kI(e,t,n,r,i,a){let o=e.get(d_)?.body.position;if(!o)return;let[s,c,l]=t;for(let t of e.values()){if(!t.rings.length)continue;let[e,u,d]=t.body.position;for(let f of t.rings){let p=r||f.intensityScale>=.000980392156862745;f.mesh.visible=p;let m=r?1:p?f.intensityScale:0;f.material.uniforms.uIntensityScale.value=m;let h=f.material.uniforms.uSunDir.value;h.set(o[0]-e,o[1]-u,o[2]-d);let g=h.length(),_=TI/g;f.material.uniforms.uSunAngularRadius.value=_,f.material.uniforms.uLightScale.value=n?vT(g):1,h.normalize();let v=f.planetShadowOnRing;if(v.uPlanetCenter.value.set(e-s,u-c,d-l),t.mesh&&v.uPlanetPoleDir.value.set(0,1,0).applyQuaternion(t.mesh.quaternion),f.layers){let{dist:e,sinToPole:t}=OI(i,v.uPlanetCenter.value,v.uPlanetPoleDir.value,f.innerScene,f.outerScene),n=f.thicknessScene*t/Math.max(e,1e-9)*a,r=Math.min(Math.max(Math.ceil(n*EI),1),48);f.layers.count!==r&&(f.layers.count=r,f.material.uniforms.uLayerCount.value=r,f.material.uniforms.uLayerAlphaExp.value=1/r)}let y=f.planetShadow;y&&(y.uRingShadowIntensity.value=m,y.uRingShadowSunAngularRadius.value=_,y.uRingShadowSunDir.value.copy(h),y.uRingShadowPoleDir.value.copy(v.uPlanetPoleDir.value),y.uRingShadowCenter.value.copy(v.uPlanetCenter.value))}}}var AI=Math.PI/180,jI=2451545;function MI(e){let t=e-jI,n=(19.3871+.52402073*t)*AI;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 NI(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 PI(e,t){let n=e.seasonal;if(!n)return e;let r=NI(n.lsDeg,n.dustTauFactor,t),i=NI(n.lsDeg,n.dustScaleHeightKm,t),a=NI(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 FI=new WeakMap,II=.25;function LI(e,t){if(!e.seasonal)return e;let n=Math.round(MI(t)/II),r=FI.get(e);if(r&&r.lsQ===n)return r.params;let i=PI(e,n*II);return FI.set(e,{lsQ:n,params:i}),i}var RI=new J,zI=new J,BI=[.2126,.7152,.0722];function VI(e,t,n){return n<=0?0:e<=t-n?n:e>=t+n?0:e<=t?n-(e-(t-n))**2/(2*n):(t+n-e)**2/(2*n)}function HI(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=VI(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+=BI[t]*Math.exp(-n)}return o}var UI=.4,WI=.05,GI=-.105,KI=.3,qI=.05;function JI(e,t,n){let r=HI(e,t),i=Math.min(1,-Math.log(Math.max(r,.001))/qI),a=Math.min(1,Math.max(0,(n-GI)/KI));return r*(1+(UI+(WI-UI)*a-1)*i)}function YI(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 XI=gT,ZI=200,QI=new J,$I=new J,eL=new J,tL=new J;function nL(e,t,n,r){e.uOccluderCount.value=RC(e.uOccluders.value,t,r,n)}function rL(e,t,n,r,i,a,o){let s={insideShell:!1,shellProminent:!1,skyboxIntensity:1,sunTint:QI.set(1,1,1),sunRefraction:null};PA(n&&a.sunTint);let c=e.get(d_);sj(c?.mesh?.material,_b());let l=oj(c?.mesh?.material);l&&(l.uAtmoTEnable.value=0);let u=ZI,d=c?.body.position;if(!d)return s;for(let c of e.values()){if(!c.atmosphere||(c.atmosphere.mesh.visible=n,!n))continue;EA(c.atmosphere,a);let e=gb(c.body.data.id);if(e?.seasonal){let t=a.seasonal?LI(e,o):e;if(c.atmosphere.params!==t){DA(c.atmosphere,t);for(let e of c.sunTint??[])VA(e,t,c.atmosphere.surfaceRadiusScene,c.atmosphere.surfaceRadiusKm)}}let[f,p,m]=c.body.position,h=c.atmosphere.material.uniforms;h.uGroundAlbedo.value=a.groundAlbedo?c.atmosphere.params.groundAlbedo??0:0;let g=h.uSunDir.value.set(d[0]-f,d[1]-p,d[2]-m),_=c.atmosphere.params,v=r?vT(g.length()):_.realisticSunAlways?Math.sqrt(vT(g.length())):1;h.uSunIntensity.value=_.sunIntensity*v*i,g.normalize(),c.mesh&&(RI.set(0,1,0).applyQuaternion(c.mesh.quaternion),h.uSpinAxis.value.copy(RI));let y=c.atmosphere.mesh,b=c.atmosphere.geometryRadiusScene*y.scale.x,x=t.distanceTo(y.position);b>x*.1&&(s.shellProminent=!0),a.eclipseShadows&&nL(h,y.position,g,b);let S=a.insideView&&x<b,C=c.atmosphere.planetRadiusKm,w=x*((C+_.topAltitudeKm)/b)-C,T=S&&CA(_,w),E=S?wA(_,w):0;bA(c.atmosphere,S,T,E),h.uDeepIrradiance.value=XI*i;for(let e of c.sunTint??[])e.uAtmoTDeepIrradiance.value=XI*i,e.uAtmoTDeepBlend.value=E;if(S){s.insideShell=!0;let e=zI.copy(t).sub(y.position).divideScalar(x).dot(g),n=JI(_,w,e);if(s.skyboxIntensity*=n*(1-E),a.refraction&&_.refractivity&&!T){let t=YI(_.refractivity[1]*Math.exp(-Math.max(w,0)/_.rayleighScaleHeightKm),Math.asin(Math.min(1,Math.max(-1,e))),_.rayleighScaleHeightKm,c.atmosphere.planetRadiusKm);t>5e-6&&(s.sunRefraction={angleRad:t,up:tL.copy(zI)})}}let D=x/b;if(a.sunTint&&D<ZI){let e=b/(1+_.topAltitudeKm/C)*(c.atmosphere.surfaceRadiusKm/C);eL.copy(t).sub(y.position);let n=h.uSpinAxis.value,r=h.uStretch.value;if(JA(_,eL,g,e,c.atmosphere.surfaceRadiusKm,$I,n,r)){let e=BI[0]*$I.x+BI[1]*$I.y+BI[2]*$I.z;e>1e-4&&s.sunTint.multiply($I.divideScalar(e))}l&&D<u&&(u=D,UA(l,_,y.position,e,c.atmosphere.surfaceRadiusKm,n,r))}}return s}var iL=[];function aL(e,t){let n=IC(),r=e.get(d_);if(!r){n.uSunAngularRadius.value=0,n.uOccluderCount.value=0;return}let[i,a,o]=t,s=r.body.position,c=s[0]-i,l=s[1]-a,u=s[2]-o,d=Math.hypot(c,l,u);d>0?(n.uSunDir.value.set(c/d,l/d,u/d),n.uSunAngularRadius.value=Math.asin(Math.min(r.radiusScene/d,1))):n.uSunAngularRadius.value=0;let f=iL,p=0;for(let t of e.values()){if(t.body.data.objectType===G.STAR)continue;let e=t.body.data.radiusKm;!Number.isFinite(e)||e<=0||t.radiusScene<=0||(f[p++]=t)}f.length=p,p>32&&(f.sort((e,t)=>t.radiusScene-e.radiusScene),f.length=32,p=32);let m=n.uOccluders.value;for(let e=0;e<p;e++){let t=f[e],[n,r,s]=t.body.position;m[e].set(n-i,r-a,s-o,t.radiusScene)}n.uOccluderCount.value=p;for(let e=0;e<p;e++)f[e]=void 0;f.length=0;let h=n.uSunDir.value;for(let t of e.values()){let e=t.eclipseShadow;if(!e||t.cachedDist>0&&t.radiusScene<t.cachedDist*1e-4)continue;let[n,r,s]=t.body.position,c=e.uEclipseSelfPos.value.set(n-i,r-a,s-o);e.uOccluderCount.value=RC(e.uOccluders.value,c,t.radiusScene,h)}}var oL=10;function sL(e,t,n,r,i,a,o,s,c){let l=n.visibility.activeSystemId;if(!l){r.intensity=0,i&&yT(i,s,c);return}let u=e.get(d_)?.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(oL),r.target.position.set(0,0,0),r.intensity=gT*(s?vT(_):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=oL-b,x.far=oL+b,x.updateProjectionMatrix()}var cL=128,lL=256,uL=.25,dL=.32,fL=.35,pL=300,mL=1.25,hL=.05,gL=4e5,_L=new Y,vL=new J;function yL(e,t,n){let r=e=>t.some(([t,n])=>e>t+1e-9&&e<n-1e-9),i=e/cL,a=[];for(let t=0;t<=cL;t++){let n=t===cL?e:t*i;(t===0||t===cL||!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 bL(e,t,n){let r=t.length,i=n.length,a=new Float32Array(r*i*3),o=new Float32Array(r*i*3),s=new Float32Array(r*i*2);for(let c=0;c<r;c++){let r=t[c],l=Math.sin(r),u=Math.cos(r);for(let t=0;t<i;t++){let d=n[t],f=-Math.cos(d)*l,p=u,m=Math.sin(d)*l,h=(c*i+t)*3;a[h]=e*f,a[h+1]=e*p,a[h+2]=e*m,o[h]=f,o[h+1]=p,o[h+2]=m;let g=(c*i+t)*2;s[g]=d/(2*Math.PI),s[g+1]=1-r/Math.PI}}let c=new Uint32Array((r-1)*(i-1)*6),l=0;for(let e=0;e<r-1;e++){let n=t[e]<=0,r=t[e+1]>=Math.PI;for(let t=0;t<i-1;t++){let a=e*i+t+1,o=e*i+t,s=(e+1)*i+t,u=(e+1)*i+t+1;n||(c[l++]=a,c[l++]=o,c[l++]=u),r||(c[l++]=o,c[l++]=s,c[l++]=u)}}let u=new Vo;return u.setAttribute(`position`,new Eo(a,3)),u.setAttribute(`normal`,new Eo(o,3)),u.setAttribute(`uv`,new Eo(s,2)),u.setIndex(new Eo(c.subarray(0,l),1)),u}function xL(e){e.terrainWindow&&(e.terrainWindow=null,e.currentSegments=void 0)}function SL(e,t,n){let r=e.mesh,i=e.displacementMap;if(!n||!r||!i)return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: eligible=${n} mesh=${!!r} tex=${!!i}`),xL(e),!1;r.updateMatrixWorld(),_L.copy(r.matrixWorld).invert(),vL.copy(t.position).applyMatrix4(_L);let a=Q(mn(e.body.data)),o=vL.length(),s=Math.max(o/a-1,1e-6);if(s>(e.terrainWindow?dL:uL))return e.terrainWindow&&console.debug(`terrain window exit ${e.body.data.id}: alt=${s.toFixed(4)}`),xL(e),!1;let c=i.image?.width??2048,l=2*Math.PI/c,u=Math.acos(1/(1+s)),d=Math.max(l,2*u*mL/lL),f=Math.log2(d/l),p=Math.max(0,Math.ceil(f-1e-9)),m=e.terrainWindow;m&&m.texWidth===c&&f>m.stepLevel-.85&&f<m.stepLevel+.15&&(p=m.stepLevel);let h=l*2**p,g=h*lL/2,_=Math.acos(Math.min(1,Math.max(-1,vL.y/o))),v=Math.atan2(vL.z,-vL.x);if(v<0&&(v+=2*Math.PI),m&&m.texWidth===c){if(m.stepLevel===p){let e=Math.sin(_)*Math.sin(m.centerTheta)*Math.cos(v-m.centerPhi)+Math.cos(_)*Math.cos(m.centerTheta);if(Math.acos(Math.min(1,Math.max(-1,e)))<fL*m.angRadius)return!0}if(performance.now()-m.builtAt<pL)return!0}let y=Math.max(0,_-g),b=Math.min(Math.PI,_+g),x=yL(Math.PI,[[y,b]],h),S=Math.min(Math.PI,g/Math.max(Math.sin(_),hL)),C=Math.max(p,Math.ceil(Math.log2(2*S/lL/l)-1e-9)),w=l*2**Math.max(0,C),T=v-S,E=v+S,D=S>=Math.PI?[[0,2*Math.PI]]:T<0?[[0,E],[T+2*Math.PI,2*Math.PI]]:E>2*Math.PI?[[0,E-2*Math.PI],[T,2*Math.PI]]:[[T,E]],O=yL(2*Math.PI,D,w);if(x.length*O.length>gL)return console.warn(`terrain window for ${e.body.data.id} would need ${x.length}×${O.length} vertices — keeping the uniform sphere`),xL(e),!1;let k=r.geometry;return r.geometry=bL(a,x,O),k.dispose(),console.debug(`terrain window ${e.body.data.id}: ${x.length}×${O.length} grid, level ${p} (tex ${c})`),e.terrainWindow={thetas:x,phis:O,centerTheta:_,centerPhi:v,angRadius:g,stepLevel:p,texWidth:c,builtAt:performance.now()},e.currentSegments=cL,!0}var CL=[{up:150,segs:128},{up:40,segs:64},{up:0,segs:32}],wL=24;function TL(e,t,n,r){if(!n&&!t)return wL;let i=CL[CL.length-1].segs;for(let t of CL)if(e>=t.up){i=t.segs;break}if(i<r){let t=CL.find(e=>e.segs===r);if(t&&e>=t.up*.85)return r}return i}function EL(e,t,n,r,i){let a=t.fov*Math.PI/180,o=n.domElement.clientHeight/(2*Math.tan(a/2)),s=r.visibility.activeSystemId,c=i;for(let n of e.values()){if(!n.mesh||!n.radiusScene||!n.group.visible||n.cachedDist<=0)continue;let e=n.body.data.objectType===G.STAR,a=n.body.data.id;if((a===c||n.terrainWindow)&&SL(n,t,a===c))continue;let l=TL(n.radiusScene/n.cachedDist*o,e,s?a===s||r.visibility.isInActiveSystem(n.body.data.parentId):a===i,n.currentSegments??64);if(l===n.currentSegments)continue;let u=Q(mn(n.body.data)),d=n.mesh.geometry;n.mesh.geometry=new nu(u,l,l),d.dispose(),n.currentSegments=l}}function DL(e,t){let n=e<1.05?`high`:e<4?`medium`:`low`;if(Jj(n)>Jj(t))return n;let r=e>7?`low`:e>1.15?`medium`:`high`;return Jj(r)<Jj(t)?r:t}function OL(e,t,n,r,i,a,o,s){s.apply(e,i);let c=t.fov*Math.PI/180,l=n.domElement.clientHeight/(2*Math.tan(c/2)),u=r.visibility.activeSystemId,d=jx(),f=d.showClouds,p=Jj(Kx());for(let t of e.values())t.clouds&&(t.clouds.mesh.visible=f);for(let t of e.values()){if(!t.mesh||!t.radiusScene||!t.group.visible||!t.availableTiers?.length||t.cachedDist<=0)continue;let e=t.body.data.id;if(u){if(e!==u&&!r.visibility.isInActiveSystem(t.body.data.parentId))continue}else if(e!==a)continue;let s=t.radiusScene/t.cachedDist*l,c=t.cachedDist/t.radiusScene,f;f=s<256&&c>10?`low`:s<1024&&c>2?`medium`:`high`;let m=Jj(t.textureTier),h=Math.min(Jj(f),p),g=Zj(o,t.availableFrames),_=g!==t.textureFrame,v=h>m;if(d.showSurfaceTexture&&!t.textureLoading&&(v||_)){let e=v?Yj(h,t.availableTiers):t.textureTier;e&&rM(t,e,g,i)}let y=t.displacementMeta?.tiers;if(t.displacementMap&&y?.length&&!t.displacementLoading){let e=n.capabilities.maxTextureSize,r=e>=16383?2:+(e>=8192),i=t.displacementTier??`low`,a=Yj(Math.min(Jj(DL(c,i)),r,p),y);a&&a!==i&&rw(t,a)}if(t.clouds&&t.textureTier){let e=Yj(Jj(t.textureTier),t.clouds.availableTiers),n=Tj(o,t.clouds.availableFrames,t.clouds.availableCoverage);e&&n&&Oj(t.clouds,e,n)}}}var kL=BO.refMs,AL=new Y,jL=new J,ML=new J,NL=new Vi,PL=new Vi,FL=new J,IL=new J;function LL(e,t,n){return jL.set(e[0],e[1],e[2]),ML.set(t[0],t[1],t[2]),AL.lookAt(jL,ML,n),NL.setFromRotationMatrix(AL).clone()}function RL(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=I_(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=R_(e.camOriginWorld,e.camTargetWorld,e.focusTargetWorld,n);else{let t=r?o*o*o:n;i=I_(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]),PL.copy(t.quaternion),t.quaternion.slerpQuaternions(e.flyQ0,PL,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=I_(e.camOriginWorld,e.camTargetWorld,t)}let i=LL(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 zL(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=LL([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=L_(r,i),s=e.flyQ0.angleTo(a);e.focusDurationMs=Math.max(zO(o,HO),RO(s,UO))}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(),FL.set(0,0,-1).applyQuaternion(e.flyQ0),IL.set(t[0]-r[0],t[1]-r[1],t[2]-r[2]).normalize(),e.focusDurationMs=RO(FL.angleTo(IL),BO);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 BL(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=L_(n,r);FL.set(e.focusTruePos[0]-n[0],e.focusTruePos[1]-n[1],e.focusTruePos[2]-n[2]).normalize(),IL.set(e.focusTruePos[0]-r[0],e.focusTruePos[1]-r[1],e.focusTruePos[2]-r[2]).normalize();let o=FL.angleTo(IL);e.focusDurationMs=Math.max(zO(a,HO),RO(o,UO)),i&&(e.focusDurationMs=0)}var VL={[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},HL=5e-4,UL=new J,WL=new J;function GL(e){return VL[e.data.objectType]??mn(e.data)*.25}function KL(e,t){return Q((t??mn(e.data))+GL(e))}function qL(e,t,n,r){let i=t.data.radiusKm;if(!Number.isFinite(i)||i<=0)return;let a=t.position[0]-n[0],o=t.position[1]-n[1],s=t.position[2]-n[2],c=Math.hypot(a,o,s),l=r?.centerOffsetScene,u=a+(l?l[0]:0),d=o+(l?l[1]:0),f=s+(l?l[2]:0),p=e.position.x-u,m=e.position.y-d,h=e.position.z-f,g=Math.hypot(p,m,h);if(r?.seated){if(g<1e-9){e.position.set(u,d+c+Q(HL),f);return}let t=Math.tan(e.fov*Math.PI/360)*e.near,n=t*e.aspect,i=0;for(let[a,o,s]of[[0,0,0],[-n,-t,-e.near],[n,-t,-e.near],[-n,t,-e.near],[n,t,-e.near]]){WL.set(a,o,s).applyQuaternion(e.quaternion);let t=p+WL.x,n=m+WL.y,l=h+WL.z,u=Math.hypot(t,n,l);if(u<1e-12)continue;UL.set(t/u,n/u,l/u).applyQuaternion(r.invQuat);let d=r.radialKm([UL.x,UL.y,UL.z]),f=(d===null?c:Q(d))+Q(HL);f-u>i&&(i=f-u)}if(i<=0)return;let a=i/g;e.position.set(e.position.x+p*a,e.position.y+m*a,e.position.z+h*a);return}let _=GL(t);if(g>=Q((r?.outerRadiusKm??i)+_))return;let v=i;r&&g>1e-9&&(UL.set(p/g,m/g,h/g).applyQuaternion(r.invQuat),v=r.radialKm([UL.x,UL.y,UL.z])??i);let y=Q(v+_),b=c>0?Math.min(y,c):y;if(!(g>=b)){if(g<1e-9)p=0,m=b,h=0;else{let e=b/g;p*=e,m*=e,h*=e}e.position.set(u+p,d+m,f+h)}}function JL(e,t,n){let r=e.position,{latitude:i,longitude:a,distance:o}=rC([r.x,r.y,r.z],[0,0,0],n),s=Math.min(Math.max(i,t.minLat??-90),t.maxLat??90),c=sC(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]=iC([0,0,0],s,c,l,n);r.set(u,d,f)}var YL=50,XL=20;function ZL(e){return e<=0?`none`:e<XL?`full`:e<YL?`half`:`none`}function QL(e,t){return e.data.validityStart<=t&&t<=e.data.validityEnd}var $L=class{pendingDefaults=new Set;defaults=new Set;userPromoted=new Set;autoPromoted=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.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),Bv().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 p_)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||!hn(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:p_.has(t)}isDefault(e){return this.defaults.has(e)}ensureBodyObjects(e){this.buildBodyInstance(e)&&this.finalizeBuilds()}buildBodyInstance(e,t,n=!1){let{bodyObjects:r,ctx:i,clock:a,scene:o,clickables:s,meshToBody:c,circleTexture:l,renderer:u}=this.deps;if(r.has(e.data.id))return!1;if(TT(e,a.jd,i),!e.orbitElements&&!e.data.unplaceable&&e.data.orbitalSource!==tn.SPICE_PROBE){e.orbitElements=e.data;let t=r.get(e.data.parentId);t&&(e.orbitCenter=[...t.body.position])}dj([e],o,s,c,r,l,u.domElement,this.deps.onBodyClick,(e,t)=>t?this.deps.hoveredBodyIds.add(e):this.deps.hoveredBodyIds.delete(e),t);let d=r.get(e.data.id);if(d&&!e.data.name&&tM(d),e.data.objectType===G.SPACECRAFT)i.bodies.dirtySpacecraftGroups.add(e.data.parentId);else if(hn(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 f=e.data.id;return this.defaults.has(f)||(n?this.autoPromoted.add(f):(this.userPromoted.add(f),this.emitUserPromotedCount())),!0}finalizeBuilds(){gN(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(f_),t=this.currentMemberCount(e),n=ZL(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)||QL(t,i)&&(this.deps.bodyObjects.has(t.data.id)||a.push(t));if(a.length===0)return;let o=n===`half`?new Set(a.map(e=>e.data.id)):void 0;this.buildBatch(a,o,!0)}currentMemberCount(e){if(this.countStableLo=-1/0,this.countStableHi=1/0,!e)return 0;let t=this.deps.clock.jd,n=0;for(let r of e.values()){if(this.groupTargets&&!this.groupTargets.has(r.data.id))continue;let{validityStart:e,validityEnd:i}=r.data;e<=t?e>this.countStableLo&&(this.countStableLo=e):e<this.countStableHi&&(this.countStableHi=e),i<t?i>this.countStableLo&&(this.countStableLo=i):i<this.countStableHi&&(this.countStableHi=i),QL(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&&!QL(a,n)&&r.push(i)}r.length!==0&&this.tearDownBodies(r,this.autoPromoted)}clearUserPromoted(){let e=this.deps.getFocusedId(),t=[...this.userPromoted].filter(t=>t!==e);this.tearDownBodies(t,this.userPromoted),this.emitUserPromotedCount()}tearDownBodies(e,t){if(e.length===0)return;let{bodyObjects:n,ctx:r,scene:i,clickables:a,meshToBody:o,pointClouds:s}=this.deps,c=new Set,l=new Set;for(let r of e){let e=n.get(r);if(!e){t.delete(r);continue}e.label&&(e.label.element.remove(),e.label.removeFromParent()),e.loadingEl?.remove(),aO(e),nM(e),AM(e),i.remove(e.group);for(let t of e.extraObjects)i.remove(t);if(e.trail&&i.remove(e.trail),e.mesh){e.mesh.geometry.dispose(),cj(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(),cj(e.atmosphere.mesh.material),null),e.trail&&(e.trail.geometry.dispose(),cj(e.trail.material));let s=e.body.data.objectType;if(s===G.SPACECRAFT)c.add(e.body.data.parentId);else if(hn(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)}},eR=class{promotion;readerFocusFilter=null;focusedBody;_tmpV3=new J;pendingInitialView=null;upgradeTargetIds=new Set;constructor(e,t,n,r,i){this.deps=e,this.focusedBody=t,this.promotion=new $L({scene:e.scene,bodyObjects:e.bodyObjects,ctx:e.ctx,clock:e.clock,renderer:i,circleTexture:r,clickables:e.clickables,meshToBody:e.meshToBody,hoveredBodyIds:n,pointClouds:e.pointClouds,onBodyClick:e=>this.handleFocus(e),assignMapLayerToTrails:e.assignMapLayerToTrails,repositionAll:e.repositionAll,getFocusedId:()=>this.focusedBody?.data.id,onUserPromotedChange:e.callbacks.onUserPromotedChange})}get current(){return this.focusedBody}setPendingInitialView(e){this.pendingInitialView=e}clearPendingInitialView(){this.pendingInitialView=null}focusedBodyQuat(e){let t=e??this.focusedBody;if(!t||KD(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=tR(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&&(fj(t.body)?mj(t,n,r,i):aO(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}fj(t)&&(pj(o,n,r,i),f=!0),t.data.id!==e?.data.id&&c(t)}return f&&(gN(a,n,o.basis(),s.jd),l()),this.upgradeTargetIds=d,d}panCameraToBody(e){if(e.positionUnknown)return;let{focus:t,camera:n}=this.deps;zL(t,[...e.position],n,this.cameraTruePos(),void 0,jx().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,zL(n,[...e],r,a,o,jx().resolvedReducedMotion);let s=rC(o??a,e,void 0);i.onCameraPosition?.(s.latitude,s.longitude,s.distance)}handleFocus(e){if(this.readerFocusFilter&&!this.readerFocusFilter(e))return;if(this.focusedBody?.data.id===e.data.id){this.deps.callbacks.onFocusChange(e);return}if(this.setFocusTarget(e),e.positionUnknown)return;let{latitude:t,longitude:n,distance:r}=rC(this.cameraTruePos(),e.position,this.focusedBodyQuat(e));this.deps.callbacks.onCameraPosition?.(t,n,r)}setFocusTarget(e,t){let{ctx:n,bodyObjects:r,controls:i,callbacks:a,focus:o,camera:s,systemData:c,loadTexture:l}=this.deps;cn(e)||this.promotion.ensureBodyObjects(e);let u=this.focusedBody,d=_M(u,r),f=_M(e,r),p=u&&(cn(u)?u.featureAnchor.hostId:u.data.id),m=cn(e)?e.featureAnchor.hostId:e.data.id,h=this.syncUpgradeTargets(e);if(p&&p!==m&&!h.has(p)){let e=r.get(p);e&&aO(e)}if(d&&d!==f){let e=r.get(d);e&&AM(e)}this.focusedBody=e,cn(e)||(n.bodies.focusFeature=null),i.minDistance=KL(e,EO(r.get(e.data.id)));let g=cn(e)?n.getBody(e.featureAnchor.hostId):void 0;if(n.visibility.setFocused(g??e),a.onFocusChange(e),cn(e)||l(e),f&&f!==e.data.id){let e=n.getBody(f);e&&l(e)}c.syncToFocus(),e.positionUnknown||zL(o,[...e.position],s,this.cameraTruePos(),t,jx().resolvedReducedMotion),this.promotion.emitUserPromotedCount()}focusOnBody(e,t,n,r){let{ctx:i,clock:a,focus:o,camera:s,callbacks:c,pointClouds:l}=this.deps,u=i.getBody(e);if(!u)return 0;if(i.bodies.bodiesById.has(e)||TT(u,a.jd,i),u.positionUnknown)return this.setFocusTarget(u),0;let d;if(t!==void 0)if(n!==void 0&&r!==void 0)d=iC(u.position,n,r,t,this.focusedBodyQuat(u));else{let e=this.cameraTruePos(),n=this._tmpV3.set(u.position[0]-e[0],u.position[1]-e[1],u.position[2]-e[2]).normalize().negate();d=[u.position[0]+n.x*t,u.position[1]+n.y*t,u.position[2]+n.z*t]}let f=rC(d??this.cameraTruePos(),u.position,this.focusedBodyQuat(u));return c.onCameraPosition?.(f.latitude,f.longitude,f.distance),t!==void 0&&d?this.focusedBody?.data.id===e&&L_(o.focusTruePos,u.position)<KL(u)?(o.focusTruePos=[...u.position],this.deps.repositionAll(),l.rebuildBasis(),BL(o,s,this.cameraTruePos(),d,jx().resolvedReducedMotion)):(this.setFocusTarget(u,d),n!==void 0&&r!==void 0&&(o.orbitFly=!0)):this.setFocusTarget(u),o.focusDurationMs}snapToBody(e,t,n,r){let i=this.deps.ctx.getBody(e);!i||i.positionUnknown||(this.settleOnBodyInstant(i),this.snapToBodyFrame(t,n,r))}snapToBodyFacing(e,t,n,r){let{ctx:i,camera:a,controls:o,callbacks:s}=this.deps,c=i.getBody(e);if(!c||c.positionUnknown)return;this.settleOnBodyInstant(c);let l=i.getBody(t)?.position??[0,0,0],u=aC(c.position,l,n,r);a.position.set(u[0],u[1],u[2]),o.update();let d=rC(u,[0,0,0]);s.onCameraPosition?.(d.latitude,d.longitude,d.distance),this.pendingInitialView=null}settleOnBodyInstant(e){let{focus:t,pointClouds:n}=this.deps;this.setFocusTarget(e),t.focusTruePos=[...e.position],t.focusOriginWorld=[...e.position],t.focusTargetWorld=[...e.position],t.focusStartTime=-kL,t.camOriginWorld=null,t.camTargetWorld=null,t.flyQ0=null,t.orbitFly=!1,t.arcOrbit=!1,t.cameraStaysOnBody=!1,this.deps.repositionAll(),n.rebuildBasis()}snapToBodyFrame(e,t,n){let r=this.focusedBody;if(!r)return;let{camera:i,controls:a,callbacks:o}=this.deps,s=!KD(r),c=s?this.focusedBodyQuat(r)??[0,0,0,1]:void 0,l=iC([0,0,0],e,t,n,c);i.position.set(l[0],l[1],l[2]),a.update();let u=rC(l,[0,0,0],c);o.onCameraPosition?.(u.latitude,u.longitude,u.distance),s&&c[0]===0&&c[1]===0&&c[2]===0&&c[3]===1&&(this.pendingInitialView={latitude:e,longitude:t,zoom:n})}reapplyInitialViewIfPending(){let e=this.pendingInitialView;if(!e)return;let t=this.focusedBodyQuat();if(!t||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===1){this.pendingInitialView=null;return}let n=iC([0,0,0],e.latitude,e.longitude,e.zoom,t);this.deps.camera.position.set(...n),this.deps.controls.update(),this.pendingInitialView=null}};function tR(e,t){if(!e)return[];if(cn(e)){let n=t.getBody(e.featureAnchor.hostId);return n&&fj(n)?[n]:[]}let n=[];if(fj(e)&&n.push(e),e.data.objectType===G.MOON||e.data.orbitalSource===tn.SPICE_PROBE){let r=t.getBody(e.data.parentId);r&&n.push(r)}return n}var nR=1e-6;function rR(e){return e.data.name??e.data.id}var iR=class{armedProbeId=null;noticeShown=!1;coverage=new Map;pending=new Set;constructor(e,t){this.clock=e,this.notices=t}coverageFor(e){let t=this.coverage.get(e);if(t!==void 0)return t??void 0;this.pending.has(e)||(this.pending.add(e),mx(e,!1).then(t=>this.coverage.set(e,t.global?.coverage??null)).catch(()=>this.coverage.set(e,null)).finally(()=>this.pending.delete(e)))}sync(e,t){let n=e?.data.id??null,r=n===null?void 0:this.coverageFor(n);if(!e||!r){this.disarm();return}this.armedProbeId!==n&&(this.dismissNotice(),this.armedProbeId=n);let i=r.end_jd-nR,a=r.start_jd+nR;this.noticeShown&&t>a&&t<i&&this.dismissNotice(),this.clock.setBoundaryStops({forwardJd:i,backwardJd:a,onHit:t=>this.onHit(e,t,i)})}onHit(e,t,n){this.notices.notify({topic:`coverage-pause`,name:rR(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)}},aR=class{group=new Ra;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()}},oR=Math.PI/180;function sR(e){return`latitude`in e}function cR(e,t){let n=e*oR,r=t*oR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function lR(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 uR(e,t,n){let r=t.getBody(e.body);if(!r)return null;let[i,a,o]=r.position;if(sR(e)){let t=Q(mn(r.data)+(e.altitudeKm??0)),[s,c,l]=cR(e.latitude,e.longitude),u=r.orientation?fC(r.orientation,n,r.nutPrec):null;if(!u)return[i+s*t,a+c*t,o+l*t];let d=[0,0,0];return lR(u,s,c,l,d,0),[i+d[0]*t,a+d[1]*t,o+d[2]*t]}let s=typeof e.offsetKm==`function`?e.offsetKm(n):e.offsetKm;if(s===null)return null;if(s===void 0)return[i,a,o];let[c,l,u]=xF(s);return[i+c,a+l,o+u]}function dR(e,t,n){let r=n.getBody(e.body);if(!r)return null;let i=t[0]-r.position[0],a=t[1]-r.position[1],o=t[2]-r.position[2],s=Math.hypot(i,a,o);return s===0?null:[i/s,a/s,o/s]}function fR(e){let t=rg/10;return[e[0]*t,-e[2]*t,e[1]*t]}function pR(e,t,n){let r=uR(e.position,t,n),i=uR(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 mR=.02,hR=1e-4;function gR(e){return e?.4:.05}function _R(e,t,n,r,i){let a=e.position.length();if(!(a>0))return{rotate:1,translate:1};let o=KD(n)?void 0:n,s=a;for(let n of[o,i?void 0:r]){if(!n)continue;let r=Q(mn(n.data));if(!(r>0))continue;let i=Math.hypot(e.position.x-(n.position[0]-t[0]),e.position.y-(n.position[1]-t[1]),e.position.z-(n.position[2]-t[2]));s=Math.min(s,i-r)}let c=o?Q(mn(o.data)):0,l=Math.tan(Bi.degToRad(e.getEffectiveFOV())/2);return{rotate:vR(c>0?(a-c)*l/(Math.PI*c):1,hR),translate:vR(s/a,mR)}}function vR(e,t){return Math.min(1,Math.max(t,e))}var yR=Math.PI/180;function bR(e,t){let n=e*yR,r=t*yR;return[Math.cos(n)*Math.cos(r),Math.sin(n),-Math.cos(n)*Math.sin(r)]}function xR(e,t,n,r){let i=document.createElement(`div`);i.className=`user-location-marker`;let a=new YO(i),[o,s,c]=bR(n,r);return a.position.set(o*t,s*t,c*t),e.add(a),a}function SR(e){e.parent?.remove(e),e.element.remove()}var CR=new J;function wR(e,t,n){if(!e)return;let r=t.get(f_);if(!r?.mesh)return;CR.copy(e.position).applyQuaternion(r.mesh.quaternion);let i=CR.x,a=CR.y,o=CR.z,s=r.mesh.position,c=n.position.x-s.x,l=n.position.y-s.y,u=n.position.z-s.z,d=r.radiusScene,f=d*d;e.visible=c*c+l*l+u*u<=f||i*c+a*l+o*u>f}var TR=-1,ER=1.2,DR=Q(1e6),OR=.02,kR=2,AR=2.3,jR=.9,MR=new J,NR=.25,PR=10,FR=4,IR=4,LR=28,RR=.02,zR=class e{renderer;composer;atmoDepthPass;bloomPass;labelRenderer;scene;camera;controls;motionScale={rotate:1,translate:1};pointerInteraction;gpuPick;canvas;ctx;clock;callbacks;selectedFeatureId=null;bodyObjects=new Map;circleTexture=qM();pointClouds;systemData;positionDiagnostics=new wI;clickables=[];meshToBody=new Map;hoveredBodyIds=new Set;cullFrameCounter=0;hideCappedMoonLabels=!1;focusController;coverageWatch=null;outOfRange;extensions=new aR;cameraHold=null;holdingCamera=!1;_tmpV3=new J;cameraBand=null;focusableBodies=null;limitsArmed=!1;bodySelectEnabled=!0;featureSelectEnabled=!0;modelScene;modelCamera;modelLight;overlayActive=!1;modelShadowPlane=null;_tmpUp=new J;_tmpSun=new J;_planeNormal=new J(0,0,1);_modelRaycaster=new Ld;_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:kL};lastUpdatedJd=NaN;lastUpdatedSystemId=null;lastSeatConfigKey=null;lastProbeVersion=0;focusWasOutOfRange=!1;_positionMapScratch=new Map;frameIndex=0;static WAKE_FRAMES=30;static IDLE_HEARTBEAT_FRAMES=10;static REALTIME_FRAME_MS=30;wakeUntilFrame=e.WAKE_FRAMES;lastRenderedFrame=0;lastRenderMs=0;lastRenderedJd=NaN;lastRenderedFocusKey=``;lastRenderedCamPos=new J(NaN,NaN,NaN);lastRenderedCamQuat=new Vi;unsubscribeBodiesAdded=null;_trailView={camX:0,camY:0,camZ:0,tolAngle:0};viewportH=1;tier=Jx();landedNomBodyId=null;rafId=0;paused=!1;covered=!1;firstFrame=!0;pendingUrlWrite=!1;lastTickMs=0;static FPS_SAMPLE_FRAMES=30;fpsSamples=[];fpsSampleHead=0;stashedSky=null;namesShown=!0;textureLoader=new qu;appearances=new iM;shadowLight;ambientLights;get sunPointLight(){return this.bodyObjects.get(d_)?.extraObjects.find(e=>e instanceof ud)}tightFar=!1;sunProxyK=1;sunBaseMeshScale=1;sunBaseCoronaScale=0;userLocationMarker=null;labelContainer;static MAP_LAYER=1;static ATMO_DEPTH_LAYER=2;constructor(t,n,r,i,a,o){this.canvas=t,this.ctx=r,r.hasMeshBody=e=>this.bodyObjects.has(e),this.clock=i,this.callbacks=o,this.outOfRange=new dI(o.notices),this.labelContainer=n;let s=wT(t,n,r);this.viewportH=t.clientHeight||1,this.renderer=s.renderer,this.labelRenderer=s.labelRenderer,this.scene=s.scene,this.scene.add(this.extensions.group),this.camera=s.camera,this.composer=s.composer,this.bloomPass=s.bloomPass,this.shadowLight=s.shadowLight;let c=this.renderer.getDrawingBufferSize(new q);this.atmoDepthPass=new hj(c.x,c.y),this.modelScene=new Ka,this.modelScene.environment=bT(this.renderer),this.modelScene.environmentIntensity=_T,this.modelCamera=new od(60,1,.01,1e3),this.modelScene.add(this.modelCamera);let l=new md(16777215,hT);this.modelScene.add(l),this.ambientLights=[s.ambientLight,l],this.modelLight=new pd(16777215,gT),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 ks(new Ql(40,40),new ru({opacity:.55})),this.modelShadowPlane.receiveShadow=!0,this.modelShadowPlane.visible=!1,this.modelScene.add(this.modelShadowPlane),this.skyboxAdjuster=new SN(this.scene),this.skyDebugMarkers=new BN(this.scene),this.haloDebug=new YN(this.canvas),this.travelPath=new ZF(this.scene,this.canvas),this.travelPath.setLayer(e.MAP_LAYER),this.orbitPreview=new nI(this.scene),this.orbitPreview.setLayer(e.MAP_LAYER),this.skyboxAdjuster.set(0,0,0),dS(this.scene,this.renderer,r);let u=r.bodies.majorBodies.find(e=>e.data.id===d_),d=r.getBody(a.id),f=d&&!d.positionUnknown?d:void 0,p=r.bodies.majorBodies.find(e=>e.data.id===cC)||u,m=f??p,h=m?.position??[0,0,0];this.focus.focusTruePos=[...h],this.focus.focusOriginWorld=[...h],this.focus.focusTargetWorld=[...h],this.focus.focusStartTime=-kL,this.pointClouds=new OP(r,this.scene,this.bodyObjects,this.circleTexture,this.focus,e.MAP_LAYER,()=>this.rebuildTrailBasis()),this.pointClouds.seedBasis(h),this.pointClouds.setPointBudget(this.tier.pointBudget),this.controls=new FS(this.camera,t),this.controls.enableDamping=!0,this.controls.dampingFactor=gR(jx().resolvedReducedMotion),this.controls.minDistance=m?KL(m):Q(.01),this.controls.maxDistance=31620.5*10,this.controls.target.set(0,0,0),this.controls.update(),this.controls.addEventListener(`end`,this.onControlsEnd),this.controls.addEventListener(`start`,this.invalidate),this.controls.addEventListener(`start`,this.armLimits),this.controls.addEventListener(`end`,this.invalidate);for(let n of e.INPUT_EVENTS)t.addEventListener(n,this.invalidate,{passive:!0});window.addEventListener(`keydown`,this.invalidate),this.unsubscribeBodiesAdded=r.bodies.onBodiesAdded(this.invalidate),this.cameraUp=new JO(this.camera,this.controls,r,e=>this.isLanded(e)),this.systemData=new bN(this.scene,r,this.renderer,this.textureLoader,this.bodyObjects,i,()=>this.focusController.reapplyInitialViewIfPending()),this.focusController=new eR({ctx:r,clock:i,camera:this.camera,controls:this.controls,scene:this.scene,bodyObjects:this.bodyObjects,clickables:this.clickables,meshToBody:this.meshToBody,callbacks:o,focus:this.focus,pointClouds:this.pointClouds,systemData:this.systemData,loadTexture:e=>this.maybeLoadTexture(e),repositionAll:()=>this.repositionAll(),assignMapLayerToTrails:()=>this.assignMapLayerToTrails()},m,this.hoveredBodyIds,this.circleTexture,this.renderer),this.coverageWatch=new iR(i,o.notices);let g=f?a:{latitude:45,longitude:0,zoom:15},_=iC([0,0,0],g.latitude,g.longitude,g.zoom,this.focusController.focusedBodyQuat());this.camera.position.set(..._),this.focusController.setPendingInitialView({latitude:g.latitude,longitude:g.longitude,zoom:g.zoom}),m&&r.visibility.setFocused(m),r.visibility.updateCamera(g.zoom,this.clock.jd),o.onFocusChange(m),this.buildScene(),m&&this.focusController.promotion.ensureBodyObjects(m),m&&this.focusController.syncUpgradeTargets(m),this.repositionAll(),m&&this.maybeLoadTexture(m),this.systemData.syncToFocus(),this.focusController.readerFocusFilter=this.readerMayFocus,this.gpuPick=new IO(this.renderer,this.camera),this.pointerInteraction=new jO(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(){dj(this.ctx.bodies.majorBodies,this.scene,this.clickables,this.meshToBody,this.bodyObjects,this.circleTexture,this.renderer.domElement,e=>this.focusController.handleFocus(e),(e,t)=>{t?this.hoveredBodyIds.add(e):this.hoveredBodyIds.delete(e),this.invalidate()}),this.pointClouds.buildInitial(new Set(this.bodyObjects.keys()));let e=this.pointClouds.basis();(globalThis.requestIdleCallback??(e=>setTimeout(e,0)))(()=>{gN(this.bodyObjects,this.scene,e,this.clock.jd),this.assignMapLayerToTrails()})}setTravelPath(e,t=[],n=[],r=[]){this.travelPath.set(e,t,n,r),this.refreshTravelPath()}setTravelHover(e){this.travelPath.setHovered(e)}setOrbitPreview(e,t=null){this.orbitPreview.set(e),this.refreshOrbitPreview(),t&&this.frameOrbitPreview(t)}frameOrbitPreview(e){let t=this.ctx.getBody(e.bodyId);if(!t)return;let n=Q(e.radiusKm);if(!(n>0)||performance.now()-this.focus.focusStartTime<this.focus.focusDurationMs&&this.previewFlyBodyId===e.bodyId)return;let r=this.focus.focusTruePos,i=t.position[0]-r[0]-this.camera.position.x,a=t.position[1]-r[1]-this.camera.position.y,o=t.position[2]-r[2]-this.camera.position.z,s=Math.hypot(i,a,o);s>n*1.35&&s<n*45||(this.previewFlyBodyId=e.bodyId,this.focusController.focusOnBody(e.bodyId,n*4))}refreshOrbitPreview(){this.orbitPreview.isEmpty||(this.orbitPreview.reposition(e=>this.ctx.getBody(e)?.position??null,this.focus.focusTruePos),this.orbitPreview.updateCameraOffset(this.camera.position))}refreshTravelPath(){if(this.travelPath.isEmpty){this.reserveTravelLabelSpace();return}let e=this.travelPath.centerId,t=e?this.ctx.getBody(e):null;if(!t){this.travelPath.setVisible(!1),this.reserveTravelLabelSpace();return}this.travelPath.setVisible(!0),this.travelPath.setClock(this.clock.jd),this.travelPath.reposition(t.position,this.focus.focusTruePos,e=>this.ctx.getBody(e)?.position??null),this.travelPath.updateCameraOffset(this.camera.position),this.reserveTravelLabelSpace()}reserveTravelLabelSpace(){this.travelPath.reserveLabelSpace(this.camera,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)}focusOnPathPoint(e,t){this.disarmLimits();let n=this.ctx.getBody(e);if(!n)return;let[r,i,a]=xF(t);this.travelFocus={centerId:e,local:[r,i,a]};let o=this.travelFocusWorld(n.position);o&&this.focusController.focusOnPoint(o)}trackPathPoint(e,t){if(!this.travelFocus){this.focusOnPathPoint(e,t);return}let[n,r,i]=xF(t);this.travelFocus={centerId:e,local:[n,r,i]}}travelFocusWorld(e){let t=this.travelFocus;return t?[e[0]+t.local[0],e[1]+t.local[1],e[2]+t.local[2]]:null}refreshTravelFocus(){if(!this.travelFocus)return;if(this.focusController.current){this.travelFocus=null;return}let e=this.ctx.getBody(this.travelFocus.centerId);if(!e)return;let t=this.travelFocusWorld(e.position);if(!t)return;let n=this.focus;n.focusTargetWorld=t;let r=n.camTargetOffset;r&&n.camTargetWorld&&(n.camTargetWorld=[t[0]+r[0],t[1]+r[1],t[2]+r[2]]),performance.now()-n.focusStartTime>=n.focusDurationMs&&(n.focusTruePos=[...t])}updateTravelCraftSystem(){let e=this.travelFocus,t=this.travelPath.plan;if(!e||!t){this.ctx.visibility.clearTravelSystem();return}let n=this.ctx.getBody(e.centerId),r=n?this.travelFocusWorld(n.position):null;if(!r)return;let i=null;for(let e of t.stops){let t=this.ctx.getBody(e.bodyId);if(!t)continue;let n=this.ctx.visibility.resolveSystemId(t);if(!n)continue;let a=this.ctx.visibility.systemReachAU(n);if(!(a>0))continue;let o=L_(r,t.position)/10;!i&&o<=a?i=n:o<=a*2?this.systemData.prefetch(n):this.systemData.discardPrefetch(n)}this.ctx.visibility.setTravelSystem(i)}assignMapLayerToTrails(){for(let t of this.bodyObjects.values())t.trail&&t.trail.layers.set(e.MAP_LAYER)}setImmersive(t){t?(this.camera.layers.disable(e.MAP_LAYER),this.labelContainer.style.display=`none`):(this.camera.layers.enable(e.MAP_LAYER),this.labelContainer.style.display=``)}rebuildMinorPointClouds(){this.pointClouds.rebuildMinor()}repositionAll(){this.repositionBodies(),this.rebuildTrailBasis()}repositionBodies(){let[e,t,n]=this.focus.focusTruePos;for(let r of this.bodyObjects.values()){let[i,a,o]=r.body.position,s=i-e,c=a-t,l=o-n;r.group.position.set(s,c,l);for(let e of r.extraObjects)e.position.set(s,c,l)}this.pointClouds.reposition()}rebuildTrailBasis(){let e=this.focus.focusTruePos,[t,n,r]=e;for(let i of this.bodyObjects.values()){let a=i.trail;if(!a)continue;let o=a.userData.trailBuffer;if(o){GP(i.body,a,o,e,this.clock.jd);continue}let s=a.userData.trailLocalPositions;if(!s)continue;let c=a.userData.orbitCenter;KP(a,s,c.x-t,c.y-n,c.z-r)}}tick=()=>{this.rafId=requestAnimationFrame(this.tick),this.frameIndex++;let t=performance.now(),n=this.lastTickMs?t-this.lastTickMs:0;if(this.lastTickMs=t,this.holdingCamera||this.cameraUp.update(this.clock.jd),this.firstFrame&&(this.firstFrame=!1,this.controls.target.set(0,0,0),this.controls.update()),this.coverageWatch?.sync(this.focusController.current,this.clock.jd),this.clock.tick(performance.now()),!this.shouldRender(t)){this.controls.update(),this.applyReaderLimits(t);return}this.fpsSamples.length<e.FPS_SAMPLE_FRAMES?this.fpsSamples.push(t):(this.fpsSamples[this.fpsSampleHead]=t,this.fpsSampleHead=(this.fpsSampleHead+1)%e.FPS_SAMPLE_FRAMES);let r=this.lastRenderedFrame===this.frameIndex-1?n:0;this.lastRenderedFrame=this.frameIndex,this.lastRenderMs=t,this.lastRenderedJd=this.clock.jd,this.lastRenderedFocusKey=this.focusKey(),this.lastRenderedCamPos.copy(this.camera.position),this.lastRenderedCamQuat.copy(this.camera.quaternion),this.applyJdUpdate(!0),this.refreshTravelFocus(),this.callbacks.onFrame?.(this.clock.jd,r);let i=this.holdingCamera?this.applyHeldCamera():RL(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=P_(a.data.parentId),t=e?this.ctx.getBody(e):void 0,n=!!this.bodyObjects.get(a.data.id)?.isLanded||cn(a);t&&qL(this.camera,t,this.focus.focusTruePos,this.surfaceClamp(t,n)),CO(this.bodyObjects.get(a.data.id))&&qL(this.camera,a,this.focus.focusTruePos,this.surfaceClamp(a,!1)),this.setMotionScale(_R(this.camera,this.focus.focusTruePos,a,t,n))}else this.setMotionScale({rotate:1,translate:1});if(this.pendingUrlWrite&&i){this.pendingUrlWrite=!1;let{latitude:e,longitude:t,distance:n}=this.getCameraState();this.callbacks.onCameraPosition?.(e,t,n)}this.systemData.hasPendingUnloads()&&performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&this.systemData.drainPendingUnloads();let{distance:o}=this.getCameraState();this.updateTravelCraftSystem(),this.ctx.visibility.updateCamera(o,this.clock.jd),this.updateTightFar(o),this.systemData.syncToFocus(),this.refreshTravelPath(),this.refreshOrbitPreview(),this.extensions.update({jd:this.clock.jd,basis:this.focus.focusTruePos,camera:this.camera,viewportPx:this.viewportH,ctx:this.ctx}),this.cullFrameCounter=sF(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(),CI(this.bodyObjects,this.focus,this.lastUpdatedJd,this.trailView()),kI(this.bodyObjects,this.focus.focusTruePos,jx().realisticLighting,jx().overexposeRings,this.camera.position,this.pxPerRad()),aL(this.bodyObjects,this.focus.focusTruePos);let s=rL(this.bodyObjects,this.camera.position,jx().showAtmospheres,jx().realisticLighting,this.sunIntensityScale,Rk(),this.clock.jd);Yk(r,s.shellProminent),this.scene.backgroundIntensity=s.skyboxIntensity,this.applyLayerChrome();let c=this.bodyObjects.get(d_);c&&aj(c.corona,c.starPoint,s.sunTint);let l=jx().highAmbient?1:hT;if(!jx().highAmbient&&jx().realisticLighting){let e=this.bodyObjects.get(d_)?.body.position;if(e&&this.ctx.visibility.activeSystemId){let[t,n,r]=this.focus.focusTruePos;l*=vT(Math.hypot(e[0]-t,e[1]-n,e[2]-r))}}for(let e of this.ambientLights)e.intensity=l;wR(this.userLocationMarker,this.bodyObjects,this.camera);let u=_M(this.focusController.current,this.bodyObjects);OL(this.bodyObjects,this.camera,this.renderer,this.ctx,this.textureLoader,u,this.clock.jd,this.appearances),EL(this.bodyObjects,this.camera,this.renderer,this.ctx,u),sL(this.bodyObjects,this.focus.focusTruePos,this.ctx,this.shadowLight,this.sunPointLight,o,this._tmpV3,jx().realisticLighting,this.sunIntensityScale),this.updateModelMounts(),this.pointClouds.drainOnePendingSceneAdd(),this.updateDepthFar(),this.updateSunProxy(s.sunRefraction),s.insideShell&&this.atmoDepthPass.run(this.renderer,this.scene,this.camera,this.bodyObjects,e.ATMO_DEPTH_LAYER),this.composer.render(),this.renderModelOverlay(),this.labelRenderer.render(this.scene,this.camera),this.haloDebug.active&&this.haloDebug.draw(this.bodyObjects,this.camera,this.focus.focusTruePos,this.focusController.current?.data.id,this.renderer.domElement.clientWidth,this.renderer.domElement.clientHeight)};updateTightFar(e){if(nT())return;let t=this.focusController.current,n=t?_M(t,this.bodyObjects):void 0,r=n?this.bodyObjects.get(n):void 0,i=r?.radiusScene??0,a=e;if(t&&r&&n!==t.data.id){let[e,t,n]=this.focus.focusTruePos,[i,o,s]=r.body.position,c=this.camera.position;a=Math.hypot(e+c.x-i,t+c.y-o,n+c.z-s)}let o=this.tightFar?AR:kR;this.tightFar=i>0&&this.ctx.visibility.activeSystemId!==null&&a<i*o}updateDepthFar(){if(nT())return;let e=xT,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(d_);if(this.tightFar){let e=this.bodyObjects.get(t)?.body;if(e){let o=Math.hypot(e.position[0]-n,e.position[1]-r,e.position[2]-i)+this.ctx.bodies.getSystemExtent(t)*10*2;a=Math.max(a,o*o)}}else s&&o(s.body.position);for(let e of this.bodyObjects.values())this.ctx.visibility.hasFullRendering(e.body)&&o(e.body.position);e=Math.min(xT,Math.max(DR,Math.sqrt(a)*ER))}Math.abs(e-this.camera.far)>this.camera.far*OR&&(this.camera.far=e,this.camera.updateProjectionMatrix())}updateSunProxy(e){let t=this.bodyObjects.get(d_);if(!t)return;let[n,r,i]=this.focus.focusTruePos,[a,o,s]=t.body.position,c=a-n,l=o-r,u=s-i;if(e){let t=this.camera.position,n=this._tmpV3.set(c-t.x,l-t.y,u-t.z),r=n.length();n.divideScalar(r);let i=MR.copy(e.up).addScaledVector(n,-e.up.dot(n));i.lengthSq()>1e-12&&(n.addScaledVector(i.normalize(),e.angleRad).normalize(),c=t.x+n.x*r,l=t.y+n.y*r,u=t.z+n.z*r)}let d=1;if(this.tightFar){let e=this.camera.far*jR,t=Math.hypot(c,l,u);t>e&&(d=e/t)}if(!(d===1&&this.sunProxyK===1&&!e)){this.sunProxyK===1&&(this.sunBaseMeshScale=t.mesh?.scale.x??1,this.sunBaseCoronaScale=t.corona?.scale.x??0),t.group.position.set(c*d,l*d,u*d);for(let e of t.extraObjects)e.position.set(c*d,l*d,u*d);t.mesh?.scale.setScalar(this.sunBaseMeshScale*d),t.corona?.scale.set(this.sunBaseCoronaScale*d,this.sunBaseCoronaScale*d,1),this.sunProxyK=d}}setMotionScale(e){this.motionScale=e,this.controls.rotateSpeed=e.rotate,this.controls.panSpeed=e.translate,this.controls.zoomSpeed=e.translate}isLanded(e){return!!this.bodyObjects.get(e)?.isLanded}surfaceRadialKm(e,t,n){let r=this.ctx.getBody(e);if(!r)return null;let i=sw(t*Math.PI/180,n*Math.PI/180);return kw(this.bodyObjects.get(e),e,mn(r.data),i)}surfaceClamp(e,t){let n=this.bodyObjects.get(e.data.id);if(CO(n))return{invQuat:n.model.quaternion.clone().invert(),seated:t,outerRadiusKm:TO(n),centerOffsetScene:wO(n),radialKm:e=>SO(n,e)};if(!(!t||!e.orientation))return{invQuat:fC(e.orientation,this.clock.jd,e.nutPrec).invert(),seated:t,radialKm:t=>kw(n,e.data.id,e.data.radiusKm,t)}}updateModelMounts(){let e=!1;for(let t of this.bodyObjects.values())if(t.model&&KD(t.body)){e=!0;break}this.overlayActive=e;for(let t of this.bodyObjects.values()){let n=t.model,r=t.modelRoot;if(!(!n||!r)){if(e)n.parent!==this.modelScene&&this.modelScene.add(n);else if(n.parent!==r){r.add(n);let e=n.userData;n.scale.setScalar(e.fitScale??1),n.position.set(0,0,0),e.centerOffset&&n.position.addScaledVector(e.centerOffset,-1)}}}if(e){this.shadowLight.castShadow=!1;return}this.updateFocusedMountedModel()}updateFocusedMountedModel(){let e=this.overlayModelBo(),t=e?.model&&e.model.parent===e.modelRoot?e.modelRoot:null;if(!e||!t){this.shadowLight.castShadow=!1;return}let n=QD(e);t.scale.setScalar(n);let r=this.shadowLight.intensity>0;if(this.shadowLight.castShadow=r,!r)return;let i=this.bodyObjects.get(d_)?.body;if(!i)return;let[a,o,s]=i.position,[c,l,u]=e.body.position;this._tmpSun.set(a-c,o-l,s-u).normalize(),this.shadowLight.position.copy(e.group.position).addScaledVector(this._tmpSun,PR*n),this.shadowLight.target.position.copy(e.group.position);let d=this.shadowLight.shadow.camera;d.left=d.bottom=-FR*n,d.right=d.top=FR*n,d.near=IR*n,d.far=LR*n,d.updateProjectionMatrix(),this.shadowLight.shadow.normalBias=RR*n}renderModelOverlay(){if(!this.overlayActive)return;let e=this.overlayModelBo();if(!e?.model)return;let t=e.model.userData;e.model.scale.setScalar(t.fitScale??1),e.model.position.set(0,0,0),e.isLanded&&t.feetOffset?e.model.position.copy(t.feetOffset).applyQuaternion(e.model.quaternion).multiplyScalar(-1):t.centerOffset&&e.model.position.copy(t.centerOffset).multiplyScalar(-1),this._tmpV3.copy(this.camera.position).sub(e.group.position);let n=this._tmpV3.length(),r=QD(e),i=n/r;this.modelCamera.position.copy(this._tmpV3).normalize().multiplyScalar(i),this.modelCamera.quaternion.copy(this.camera.quaternion),this.modelCamera.aspect=this.camera.aspect;let a=0;for(let t of this.bodyObjects.values()){let n=t.model;if(!n||t===e)continue;let i=QD(t)/r,o=n.userData.fitScale??1;n.scale.setScalar(o*i),n.position.subVectors(t.group.position,e.group.position).divideScalar(r);let s=n.userData;s.centerOffset&&n.position.addScaledVector(s.centerOffset,-i);let c=n.position.length()+i;c>a&&(a=c)}this.modelCamera.near=Math.max(.01,i-5-a),this.modelCamera.far=i+50+a,this.modelCamera.updateProjectionMatrix();let o=this.bodyObjects.get(d_)?.body,s=1;if(o){let[t,n,r]=o.position,[i,a,c]=e.body.position;this._tmpSun.set(t-i,n-a,r-c),jx().realisticLighting&&(s=vT(this._tmpSun.length())),this._tmpSun.normalize(),this.modelLight.position.copy(this._tmpSun).multiplyScalar(10)}if(this.modelShadowPlane){this._tmpUp.set(0,1,0).applyQuaternion(e.model.quaternion);let t=this._tmpSun.dot(this._tmpUp)>.03;this.modelShadowPlane.visible=!!e.isLanded&&!e.isCrashed&&t,this.modelShadowPlane.visible&&this.modelShadowPlane.quaternion.setFromUnitVectors(this._planeNormal,this._tmpUp)}this._tmpV3.set(0,0,0);let c=zC(this._tmpV3,this._tmpV3)*s;this.modelLight.intensity=gT*c*this.sunIntensityScale,this.modelScene.environmentIntensity=_T*c,this.showPointingAxes?(this.pointingAxes||(this.pointingAxes=this.buildPointingAxes(),this.modelScene.add(this.pointingAxes)),this.pointingAxes.quaternion.copy(e.model.quaternion),this.pointingAxes.scale.setScalar(Math.min(.8,.45*i)),this.pointingAxes.visible=!0):this.pointingAxes&&(this.pointingAxes.visible=!1),this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.render(this.modelScene,this.modelCamera),this.renderer.autoClear=!0}pxPerRad(){return this.viewportH/2/Math.tan(this.camera.fov*Math.PI/360)}trailView(){let e=this._trailView,t=this.camera.position;return e.camX=t.x,e.camY=t.y,e.camZ=t.z,e.tolAngle=NR/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 rC([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?TR:Cn.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||JL(this.camera,this.cameraBand,this.focusController.focusedBodyQuat())}static INPUT_EVENTS=[`pointerdown`,`pointermove`,`pointerup`,`wheel`];invalidate=()=>{this.wakeUntilFrame=this.frameIndex+e.WAKE_FRAMES};focusKey(){let e=this.ctx.visibility;return`${this.focusController.current?.data.id??``}|${e.focusedSystemId??``}|${e.activeSystemId??``}`}cameraOffsetFromFocus(){let e=this.focusController.current,t=this.focus.focusTruePos,n=this.camera.position;return e?[n.x+t[0]-e.position[0],n.y+t[1]-e.position[1],n.z+t[2]-e.position[2]]:[n.x,n.y,n.z]}holdCamera(){this.holdingCamera||(this.disarmLimits(),this.holdingCamera=!0,this.controls.enabled=!1,this.focus.camOriginWorld=null,this.focus.camTargetWorld=null,this.focus.camTargetOffset=null,this.focus.camOriginOffset=null,this.focus.flyQ0=null,this.focus.orbitFly=!1,this.focus.arcOrbit=!1,this.focus.cameraStaysOnBody=!1)}setHeldPose(e){this.cameraHold=e}releaseCamera(){this.holdingCamera&&(this.holdingCamera=!1,this.cameraHold=null,this.controls.enabled=!0,this.controls.target.set(0,0,0),this.controls.enableDamping=!1,this.controls.update(),this.controls.enableDamping=!0,this.invalidate())}applyHeldCamera(){let e=this.cameraHold,t=e&&pR(e,this.ctx,this.clock.jd);if(!t)return!0;let n=this.focus.focusTruePos;return this.camera.up.set(t.up[0],t.up[1],t.up[2]).normalize(),this.camera.position.set(t.position[0]-n[0],t.position[1]-n[1],t.position[2]-n[2]),this.camera.lookAt(t.target[0]-n[0],t.target[1]-n[1],t.target[2]-n[2]),!0}shouldRender(t){if(this.holdingCamera||t-this.focus.focusStartTime<this.focus.focusDurationMs||this.focusKey()!==this.lastRenderedFocusKey||this.ctx.bodies.minorStreaming||this.pointClouds.hasPendingSceneAdds()||this.systemData.hasPendingUnloads())return!0;if(this.covered)return!1;if(this.frameIndex-this.lastRenderedFrame>=e.IDLE_HEARTBEAT_FRAMES)return!0;let n=this.camera;return n.position.distanceToSquared(this.lastRenderedCamPos)>n.position.lengthSq()*1e-10||8*(1-Math.abs(n.quaternion.dot(this.lastRenderedCamQuat)))>1e-8||this.frameIndex<this.wakeUntilFrame||this.haloDebug.active?!0:this.clock.jd===this.lastRenderedJd?!1:Math.abs(this.clock.timeScale)>1||t-this.lastRenderMs>=e.REALTIME_FRAME_MS}onControlsEnd=()=>{this.pendingUrlWrite=!0,this.focusController.clearPendingInitialView()};nudgeCamera(e,t,n){this.armLimits();let{rotate:r,translate:i}=this.motionScale;e!==0&&this.controls.rotateLeft(e*r),t!==0&&this.controls.rotateUp(t*r),n!==1&&this.controls.dollyIn(1/n**+i),this.onControlsEnd()}maybeLoadTexture(e){let t=this.bodyObjects.get(e.data.id);t&&(eM(t,this.textureLoader,this.clock.jd,this.scene,this.renderer.capabilities.maxTextureSize,this.ctx).then(()=>{this.focusController.current?.data.id===e.data.id&&e.orientation&&t.mesh&&(pC(t.mesh,e.orientation,this.clock.jd,e.nutPrec),this.focusController.reapplyInitialViewIfPending())}),nO(t,this.modelScene,this.ctx).then(()=>{if(this.focusController.current?.data.id===t.body.data.id&&(this.controls.minDistance=KL(t.body,EO(t))),!this.ctx.layers.skipped.has(`nomenclature`))return TM(t,this.canvas,(e,n,r,i)=>{this.featureSelectEnabled&&this.callbacks.onFeatureSelect?.(t.body.data.id,e,n,r,i)})}).then(()=>{this.selectedFeatureId!==null&&kM(t,this.selectedFeatureId)}))}reapplyBodyLayers(){let e=this.focusController.current;if(!e)return;let t=this.bodyObjects.get(e.data.id);t&&(aO(t),nM(t),this.maybeLoadTexture(e))}setSelectedFeature(e){this.selectedFeatureId=e;let t=_M(this.focusController.current,this.bodyObjects),n=t?this.bodyObjects.get(t):void 0;n&&kM(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&&!cn(e))return null;let t=P_(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`}|${gw()}`}lastProbeTargetCheck=null;requestedProbeTargets=new Set;askedProbeRides=new Set;ensureFocusedProbeTarget(){let e=this.focusController.current,t=this.ctx.probeStore;if(!e||!t?.fitCenterUsable||e.data.orbitalSource!==tn.SPICE_PROBE)return;this.askedProbeRides.has(e.data.id)||(this.askedProbeRides.add(e.data.id),hx(e.data.id).then(e=>e&&t.registerCarried(e)));let n=`${e.data.id}@${this.clock.jd}`;if(n===this.lastProbeTargetCheck)return;this.lastProbeTargetCheck=n;let r=t.stampedFitCenterAt(e.data.id,this.clock.jd);if(!r)return;let i=this.ctx.getBody(r);if(!i){if(this.requestedProbeTargets.has(r))return;this.requestedProbeTargets.add(r),this.ctx.ensureBody(r,Ng(this.clock.jd));return}this.focusController.promotion.ensureBodyObjects(i),this.focusController.syncUpgradeTargets(e)}applyJdUpdate(e=!1){this.ensureFocusedProbeTarget();let t=this.ctx.visibility.focusedSystemId,n=this.focusedSeatConfigKey(),r=this.ctx.probeStore?.version??0;if(this.clock.jd===this.lastUpdatedJd&&t===this.lastUpdatedSystemId&&n===this.lastSeatConfigKey&&r===this.lastProbeVersion){this.clock.seeked=!1;return}let i=this.clock.seeked;this.clock.seeked=!1,this.lastUpdatedJd=this.clock.jd,this.lastUpdatedSystemId=t,this.lastSeatConfigKey=n,this.lastProbeVersion=r,this.ctx.refreshTick(Ng(this.clock.jd)),this.focusController.promotion.onSimTimeChanged();let a=SI({jd:this.clock.jd,ctx:this.ctx,bodyObjects:this.bodyObjects,focus:this.focus,focusedBody:this.focusController.current,positionMap:this._positionMapScratch,diagnostics:this.positionDiagnostics,trailView:this.trailView(),frame:this.frameIndex,outOfRange:this.outOfRange});this.pointClouds.updateForJd(this.clock.jd,this.cloudViewInfo()),this.refreshTravelFocus(),performance.now()-this.focus.focusStartTime>=this.focus.focusDurationMs&&(this.repositionBodies(),this.pointClouds.maybeRebase()),this.syncLandedNomenclature();let o=a.focusedOutOfRange&&!this.focusWasOutOfRange;if(this.focusWasOutOfRange=a.focusedOutOfRange,e&&i&&o&&a.reanchorId){let e=this.ctx.getBody(a.reanchorId);e&&this.focusController.panCameraToBody(e)}}setReducedMotion(e){this.controls.dampingFactor=gR(e)}focusOnBody(e,t,n,r){return this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.focusOnBody(e,t,n,r)}focusOnFeature(e,t,n,r=`frame`,i){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1;let a=this.ctx.getBody(e.hostId);if(!a)return 0;this.focusController.clearPendingInitialView();let o=_M(this.focusController.current,this.bodyObjects)===e.hostId,s=Mw(e,t);this.ctx.bodies.focusFeature=s;let c=this.bodyObjects.get(a.data.id);this.selectedFeatureId=e.featureId,c&&kM(c,e.featureId),zw(s,a,c,this.clock.jd);let l=s.position,u=this.focusController.focusedBodyQuat(s);if(r===`pan`){let e=rC(this.focusController.cameraTruePos(),l,u);return this.callbacks.onCameraPosition?.(e.latitude,e.longitude,e.distance),this.focusController.setFocusTarget(s),this.focus.focusDurationMs}let d=l[0]-a.position[0],f=l[1]-a.position[1],p=l[2]-a.position[2],m=Math.hypot(d,f,p);m>1e-9?(d/=m,f/=m,p/=m):(d=0,f=1,p=0);let h=r===`snap`&&i?iC(l,i.latitude,i.longitude,i.zoom,u):[l[0]+d*n,l[1]+f*n,l[2]+p*n],g=rC(h,l,u);if(this.callbacks.onCameraPosition?.(g.latitude,g.longitude,g.distance),r===`snap`){this.focusController.setFocusTarget(s,h);let e=this.focus;return e.focusTruePos=[...l],e.focusOriginWorld=[...l],e.focusTargetWorld=[...l],e.focusStartTime=-kL,e.camOriginWorld=null,e.camTargetWorld=null,e.camTargetOffset=null,e.camOriginOffset=null,e.flyQ0=null,e.orbitFly=!1,e.arcOrbit=!1,e.cameraStaysOnBody=!1,this.repositionAll(),this.pointClouds.rebuildBasis(),this.camera.position.set(h[0]-l[0],h[1]-l[1],h[2]-l[2]),this.controls.update(),0}if(o){let e=this.focusController.cameraTruePos();this.focusController.setFocusTarget(s),this.focus.focusTruePos=[...l],this.camera.position.set(e[0]-l[0],e[1]-l[1],e[2]-l[2]),this.repositionAll(),this.pointClouds.rebuildBasis(),BL(this.focus,this.camera,e,h,jx().resolvedReducedMotion)}else this.focusController.setFocusTarget(s,h),this.focus.orbitFly=!0;return this.focus.focusDurationMs}pickFocusedModel(e,t){if(!this.overlayActive||!this.overlayModelBo()?.model)return null;this._pickNdc.set(e,t),this._modelRaycaster.setFromCamera(this._pickNdc,this.modelCamera);let n=null,r=1/0;for(let e of this.bodyObjects.values()){if(!e.model)continue;let t=this._modelRaycaster.intersectObject(e.model,!0);t.length>0&&t[0].distance<r&&(r=t[0].distance,n=e.body)}return n}overlayModelBo(){let e=this.focusController.current;if(!e){let e=this.travelFocus?.centerId,t=e?this.bodyObjects.get(e):void 0;return t?.model?t:null}let t=cn(e)?e.featureAnchor.hostId:e.data.id,n=this.bodyObjects.get(t);if(n?.model)return n;if(e.data.orbitalSource===tn.SPICE_PROBE&&!n?.isLanded){let t=this.bodyObjects.get(e.data.parentId);if(t?.model)return t}return null}snapToBodyFacing(e,t,n,r){this.disarmLimits(),this.focusController.snapToBodyFacing(e,t,n,r)}snapToBody(e,t,n,r){this.disarmLimits(),this.focusController.snapToBody(e,t,n,r)}setFocusTarget(e,t){this.disarmLimits(),this.applyJdUpdate(),this.focusWasOutOfRange=!1,this.focusController.setFocusTarget(e,t)}getFocusedBody(){return this.focusController.current}getDebugStats(){let t=this.fpsSamples,n=0;if(t.length>=2){let r=t.length<e.FPS_SAMPLE_FRAMES?0:this.fpsSampleHead,i=t[r],a=(t[(r-1+t.length)%t.length]-i)/1e3;a>0&&(n=(t.length-1)/a)}return eP({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)}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:KD(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 Ra,t=new J(0,0,0),n=(n,r,i,a)=>{let o=new Wd(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 qo({map:new Mc(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=gb(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&&DA(n,e)}getSkyboxAdjust(){return this.skyboxAdjuster.get()}setSkyboxAdjust(e,t,n){this.skyboxAdjuster.set(e,t,n)}setSkyDebugMarkersVisible(e){this.skyDebugMarkers.setVisible(e)}applyLayerChrome(){this.ctx.layers.isVisible(`stars`)?this.stashedSky&&=(this.scene.background=this.stashedSky,null):this.scene.background&&(this.stashedSky=this.scene.background,this.scene.background=null);let e=this.ctx.layers.isVisible(`labels`);e!==this.namesShown&&(this.namesShown=e,this.labelContainer.classList.toggle(`scene-overlay--no-names`,!e))}setHaloDebugVisible(e){this.haloDebug.setVisible(e)}setUserLocation(e,t){let n=this.bodyObjects.get(f_);n?.mesh&&(this.userLocationMarker&&SR(this.userLocationMarker),this.userLocationMarker=xR(n.mesh,n.radiusScene,e,t))}clearUserLocation(){this.userLocationMarker&&=(SR(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(Yx()),this.composer.setPixelRatio(Yx()),this.resize(this.canvas.clientWidth,this.canvas.clientHeight),dS(this.scene,this.renderer,this.ctx),this.resume()}recoverWorkersIfDead(e){return this.pointClouds.recoverWorkersIfDead(e)}applyRenderTier(){this.tier=Jx();let e=Yx();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),uT(e,t)}dispose(){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&&aO(e);this.pointClouds.dispose(),this.disposeScene(this.scene),this.disposeScene(this.modelScene),BR(this.scene.background),BR(this.scene.environment),BR(this.modelScene.environment),this.circleTexture.dispose(),this.bodyObjects.clear(),this.composer.dispose(),this.atmoDepthPass.dispose(),this.renderer.dispose()}disposeScene(e){let t=new Set;e.traverse(e=>{let n=e;n.geometry?.dispose();let r=n.material,i=Array.isArray(r)?r:r?[r]:[];for(let e of i)if(!t.has(e)){t.add(e);for(let t of Object.values(e))BR(t);e.dispose()}})}};function BR(e){e&&typeof e==`object`&&e.isTexture&&e.dispose()}var VR=Xe({progress:null,bootPending:!1}),HR=6371;function UR(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 WR={topAltitudeKm:67,rayleighScatterPerKm:[.0058,.0136,.0331],rayleighScaleHeightKm:8.4,mieScatterPerKm:[.004,.004,.004],mieAbsorptionPerKm:[4e-4,4e-4,4e-4],mieScaleHeightKm:1.2,miePhase:UR(.75),absorptionPerKm:[65e-5,.001881,85e-6],absorptionCenterKm:25,absorptionWidthKm:15,bakedCompensation:1,multiScatterGain:.3,sunIntensity:5,sunColor:[1,1,1]},GR=1.6,KR=1.0005,qR=new J(.55,.25,.8).normalize(),JR=[`low`,`medium`,`high`,`ultra`],YR=4,XR=12,ZR=10,QR=16,$R=5;function ez(e){return!e.limb&&!e.sky?NaN:Math.max(e.limb?.medianMs??0,e.sky?.medianMs??0)}function tz(e,t){let n=`low`;for(let r of e.tiers){let e=ez(r);!Number.isNaN(e)&&e<=t&&(n=r.tier)}return n}var nz=new Set([`WebKit WebGL`,`Mozilla`,``]);function rz(e){let t=e.getContext(),n=String(t.getParameter(t.RENDERER)??``);if(!nz.has(n))return n;let r=t.getExtension(`WEBGL_debug_renderer_info`);return r?String(t.getParameter(r.UNMASKED_RENDERER_WEBGL)):n}function iz(e,t){let n=e.getContext(),r=new Ka,i=new od(50,n.drawingBufferWidth/Math.max(n.drawingBufferHeight,1),.005,100),a=new pu({color:7829367,roughness:1,metalness:0}),o=new ks(new nu(1,64,64),a);o.renderOrder=1,r.add(o);let s=new pd(16777215,2);s.position.copy(qR),r.add(s);let c=WR,l=yA(c,1,HR),u=l.material.uniforms;u.uSunDir.value.copy(qR),u.uSunIntensity.value=c.sunIntensity,r.add(l.mesh);let d=e=>{let t=e===`sky`;t?(i.position.set(0,KR,0),i.lookAt(1,KR+.1,0)):(i.position.set(0,0,GR),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}={})=>{EA(l,Fk[e]),d(t);let i=0;for(let e=0;e<YR;e++)r?.(`warmup`,e+1),await p(),i=m(1);let a=Math.min(QR,Math.max(1,Math.ceil(ZR/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<XR;e++)if(r?.(`measure`,e+1),await p(),o.push(m(a)),n!==void 0&&o.length>=$R){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(),AA(l)}}}function az(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 oz(e,t){let n=t.tiers??JR,{budgetMs:r,signal:i,onProgress:a}=t,o=Math.max(0,n.indexOf(t.startTier??n[n.length-1])),s=iz(e,i),c=YR+XR,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`?YR: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`?XR:YR,fraction:u})}}),f=new Map,p=new Map,m=async e=>{let t=n[e];if(Fk[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 az(e,n,f,p)}var sz=60,cz=100,lz=3e4,uz=25e4,dz=`v1`,fz=!1,pz=null,mz=Promise.resolve();function hz(e){let t=e.getContext(),n=Math.round(t.drawingBufferWidth*t.drawingBufferHeight/uz);return`${rz(e)}|${n}|${dz}`}function gz(){fz||typeof window>`u`||(fz=!0,VR.bootPending=!0,mz=new Promise(e=>{let t=()=>{VR.bootPending=!1,e()};setTimeout(t,lz),setTimeout(()=>void vz(!1).finally(t),cz)}))}function _z(){return mz}function vz(e){return pz??=yz(e).finally(()=>pz=null),pz}async function yz(e){let t=jx();if(!e&&(t.atmosphereQuality!==`auto`||!t.showAtmospheres))return;let n=null;try{n=new uh({canvas:document.createElement(`canvas`),antialias:!0}),n.setPixelRatio(Wx()),n.setSize(window.innerWidth,window.innerHeight,!1);let r=hz(n);if(!e&&t.atmosphereCalibration?.key===r)return;VR.progress=0;let i=await oz(n,{budgetMs:1e3/sz,startTier:Ik(),onProgress:e=>VR.progress=e.fraction}),a={};for(let e of i.tiers){let t=ez(e);Number.isNaN(t)||(a[e.tier]=Math.round(t*100)/100)}let o=tz(i,1e3/sz);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{VR.progress=null,n?.dispose(),n?.forceContextLoss()}}var bz=class{object=new Ra;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 YO(e.element);let[n,r]=e.align??[.5,.5];this.label.center.set(n,r),this.object.add(this.label),this.object.matrixAutoUpdate=!1,Nk(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?uR(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}){let r=dR(this.anchor,e,n);if(!r)return!0;let{position:i}=this.label,a=t.position.x-i.x,o=t.position.y-i.y,s=t.position.z-i.z;return r[0]*a+r[1]*o+r[2]*s>0}dispose(){this.label.removeFromParent(),this.element.remove()}},xz=1e-9,Sz=class{object=new Ra;anchor;color;widthPx;opacity;fade;closed;local;count=0;mesh=null;scratch=new Float32Array;alphas=new Float32Array;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.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,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,ctx:r}){let i=this.mesh;if(!i)return;let a=this.wanted&&this.count>=2?uR(this.anchor,r,e):null;if(i.visible=a!==null,!a)return;let o=[a[0]-t[0],a[1]-t[1],a[2]-t[2]];(this.dirty||Math.abs(o[0]-this.lastOrigin[0])>xz||Math.abs(o[1]-this.lastOrigin[1])>xz||Math.abs(o[2]-this.lastOrigin[2])>xz)&&(this.writeVertices(i,o),this.lastOrigin=o,this.dirty=!1),i.material.uniforms.uCenterOffset.value.copy(n.position).negate()}writeVertices(e,t){for(let e=0;e<this.count;e++)this.scratch[e*3]=this.local[e*3]+t[0],this.scratch[e*3+1]=this.local[e*3+1]+t[1],this.scratch[e*3+2]=this.local[e*3+2]+t[2];aN(e.geometry,this.scratch,this.alphas,this.alphas,this.count)}rebuild(e){this.disposeMesh(),this.dirty=!0,this.scratch=new Float32Array(e*3),this.alphas=new Float32Array(e);let t=cN(e,this.scratch,this.alphas,this.alphas,e,this.color,this.widthPx,1);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 Cz(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=wz(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,wz(n,a)]}function wz(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 Tz(e,t={}){let[n,r]=Cz(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 Ez(e){if(e.length<3)return[];let[t,n]=Cz(Dz(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 Yl.triangulateShape(r,[]).flat()}function Dz(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 Oz(e,t,n){let r=Math.min(1,Math.max(-1,e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),i=Math.acos(r);if(i<1e-9||Math.PI-i<1e-9)return kz([e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]);let a=Math.sin(i),o=Math.sin((1-n)*i)/a,s=Math.sin(n*i)/a;return[e[0]*o+t[0]*s,e[1]*o+t[1]*s,e[2]*o+t[2]*s]}function kz(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?[e[0]/t,e[1]/t,e[2]/t]:[0,0,1]}function Az(e,t){let n=0,r=0,i=0;for(let a=0;a<t;a++)n+=e[a*3],r+=e[a*3+1],i+=e[a*3+2];return Math.hypot(n,r,i)<1e-9?[e[0],e[1],e[2]]:kz([n,r,i])}function jz(e,t){return new du({transparent:!0,depthWrite:!1,side:2,uniforms:{uColor:{value:new X(e)},uOpacity:{value:t},uCenterOffset:{value:new J}},vertexShader:`
5520
5520
  #include <common>
5521
5521
  #include <logdepthbuf_pars_vertex>
5522
5522
  uniform vec3 uCenterOffset;
@@ -5533,6 +5533,6 @@ uniform float uOceanRoughness;`).replace(`#include <roughnessmap_fragment>`,`flo
5533
5533
  gl_FragColor = vec4(uColor, uOpacity);
5534
5534
  #include <logdepthbuf_fragment>
5535
5535
  }
5536
- `})}var jz=.25,Mz=1e-9,Nz=3,Pz=class{object=new Ra;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??jz,this.outline=t>0?new xz({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?cR(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])>Mz||Math.abs(s[1]-this.lastOrigin[1])>Mz||Math.abs(s[2]-this.lastOrigin[2])>Mz){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=Tz(e);if(!n.length)return;let r=new Vo;r.setAttribute(`position`,new ko(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new ks(r,Az(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=Nz,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()}},Fz=class extends Pz{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:wz(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(wz(e,{normal:this.normal,steps:this.steps}))}},Iz=class extends yz{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}},Lz=class extends yz{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}},Rz=Math.PI/180,zz=180/Math.PI;function Bz(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function Vz(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[Bz(n*i.lonPerX+t),i.lat]}}function Hz(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function Uz(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 Wz(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*zz,lonPerX:zz,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)=>[Bz(e-t)*Rz,n*Rz],rowInverse:n,inverse:Vz(n,t)}}var Gz=1.340264,Kz=-.081106,qz=893e-6,Jz=.003796,Yz=Math.sqrt(3),Xz=e=>Jz*e**9+qz*e**7+Kz*e**3+Gz*e,Zz=e=>9*Jz*e**8+7*qz*e**6+3*Kz*e**2+Gz;function Qz(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(mB(Yz/2*Math.sin(n*Rz))),i=Bz(e-t)*Rz;return[2*Yz*i*Math.cos(r)/(3*Zz(r)),Xz(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(Xz(t)-e)/Zz(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/Yz*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*Zz(t)/(2*Yz*Math.cos(t))*zz;return{lat:Math.asin(n)*zz,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:Uz(n),forward:n,rowInverse:i,inverse:Vz(i,t)}}var $z=Math.SQRT2;function eB(e){let t=e.centerLon??0,n=e=>{let t=e/$z;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*$z*i)*zz;return{lat:Math.asin(r)*zz,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*$z,minY:-$z,maxX:2*$z,maxY:$z},forward:(e,n)=>{let r=n*Rz,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=Bz(e-t)*Rz;return[2*$z/Math.PI*a*Math.cos(i),$z*Math.sin(i)]},rowInverse:n,inverse:Vz(n,t)}}function tB(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*zz,lonPerX:zz/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*Rz;return[Bz(e-t)*Rz*Math.cos(r),r]},rowInverse:n,inverse:Vz(n,t)}}var nB=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],rB=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],iB=.8487,aB=1.3523,oB=5;function sB(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 cB=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),lB=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function uB(e){let t=Math.min(Math.max(Math.floor(e),0),nB.length-2);return[t,e-t]}function dB(e){let[t,n]=uB(e);return iB*cB(sB(nB,t),n)*Math.PI}function fB(e){let t=0,n=rB.length-1;for(;n-t>1;){let r=t+n>>1;rB[r]<=e?t=r:n=r}let r=Math.min(t,rB.length-2),i=sB(rB,r),a=(e-rB[r])/(rB[r+1]-rB[r]);for(let t=0;t<8;t++){let t=lB(i,a);if(t===0)break;let n=(cB(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function pB(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/aB;if(t>1)return null;let n=fB(t),r=dB(n);return{lat:Math.sign(e)*n*oB,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-iB*Math.PI,minY:-aB,maxX:iB*Math.PI,maxY:aB},forward:(e,n)=>{let[r,i]=uB(Math.abs(n)/oB),a=cB(sB(nB,r),i),o=cB(sB(rB,r),i);return[iB*a*Bz(e-t)*Rz,aB*o*Math.sign(n)]},rowInverse:n,inverse:Vz(n,t)}}function mB(e){return e<-1?-1:e>1?1:e}function hB(e,t,n,r,i,a,o){let s=Math.asin(mB(n*a+t*r*o));return[Bz(i+Math.atan2(e*r,n*o-t*r*a)*zz),s*zz]}function gB(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function _B(e,t,n,r){let i=Bz(e-n)*Rz,a=t*Rz;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function vB(e){let t=e.centerLon??0,n=(e.centerLat??0)*Rz,r=Math.min(e.clipAngle??90,90)*Rz,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:gB(a),forward:(e,r)=>{let a=Bz(e-t)*Rz,o=r*Rz;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:_B(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:hB(e,n,Math.sqrt(1-r),1,t,o,s)}}}var yB=120;function bB(e){let t=e.centerLon??0,n=(e.centerLat??90)*Rz,r=Math.min(e.clipAngle??yB,170)*Rz,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:gB(a),forward:(e,r)=>{let a=Bz(e-t)*Rz,o=r*Rz,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]=_B(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 hB(e,n,(4-r)*i*.25,i,t,o,s)}}}var xB={equirectangular:Wz,equalEarth:Qz,mollweide:eB,sinusoidal:tB,robinson:pB,orthographic:vB,stereographic:bB},SB=Object.keys(xB);function CB(e,t={}){let n=xB[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var wB=Math.PI/180,TB=2*Math.PI,EB=2*wB,DB=180/Math.PI,OB=512,kB=2;function AB(e,t){let n=e.lat*wB,r=t.lat*wB,i=r-n,a=Bz(t.lon-e.lon)*wB,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)))*DB}function jB(e,t,n){let r=AB(e,t)*wB;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*wB,c=e.lon*wB,l=t.lat*wB,u=(e.lon+Bz(t.lon-e.lon))*wB,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)*DB,lat:Math.atan2(p,Math.hypot(d,f))*DB}}function MB(e,t,n){return{lon:e.lon+Bz(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function NB(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??kB,i=n===`geodesic`?jB:MB,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(OB,Math.max(1,Math.ceil(AB(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function PB(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=MB(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return MB(e,t,r)}function FB(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=PB(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=PB(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 IB(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 LB(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 RB=179.999999;function zB(e,t){let n=e=>e>RB?RB:e<-RB?-RB:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=Bz(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=Bz(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*RB,lat:e}),i.push(a),a=[{lon:-d*RB,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 BB(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?zB(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=FB(NB(e,n),t),a=!!n.closed&&i;return IB(r,t).map(e=>LB(e,a)).join(``)}).join(``)}function VB(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return BB(e,t,{...n,closed:!0});if(e.length<2)return``;let i=NB(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 LB(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=PB(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=PB(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=HB(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)%TB+TB)%TB;n<a&&(a=n,i=e)}let o=Math.ceil(a/EB);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=>LB(e.map(s),!0)).join(``)}function HB(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=Bz(i.lon-r.lon)*wB*(2+Math.sin(r.lat*wB)+Math.sin(i.lat*wB))}let n=-t/2;return n>0?n<TB:n<-TB}function UB(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?``:IB([i],e).map(e=>LB(e,!0)).join(``)}function WB(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 GB(e,t,n=128){let r=e.lat*wB,i=e.lon*wB,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*wB,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:Bz(Math.atan2(l,s)*DB),lat:Math.atan2(p,Math.hypot(s,l))*DB})}return f}var KB=24;function qB(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<=KB;t++)e.push({lon:-n+2*n*t/KB,lat:r});t.push(e)}return t}var JB=.005,YB=1.5,XB=5,ZB=24,QB=class{object=new Ra;body;altitudeKm;closed;interpolate;stepDeg;color;widthPx;opacity;fillColor;fillOpacity;dirs=new Float64Array;count=0;line=null;scratch=new Float32Array;alphas=new Float32Array;fanDirs=new Float64Array;fill=null;fillScratch=new Float32Array;turned=[0,0,0];wanted=!0;removeSelf=null;constructor(e){this.body=e.body,this.altitudeKm=e.altitudeKm??null,this.closed=e.closed??!1,this.interpolate=e.interpolate??`linear`,this.stepDeg=e.stepDeg,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.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=NB(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]=oR(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,ctx:r}){let i=this.wanted&&this.count>=2?r.getBody(this.body):void 0;if(this.line&&(this.line.visible=i!==void 0),this.fill&&(this.fill.visible=i!==void 0),!i)return;let a=mn(i.data),o=Q(a+(this.altitudeKm??a*JB)),s=i.orientation?dC(i.orientation,e,i.nutPrec):null,c=[i.position[0]-t[0],i.position[1]-t[1],i.position[2]-t[2]];if(this.line&&(this.place(this.dirs,this.count,s,o,c,this.scratch),rN(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()),this.fill){let e=this.fill.geometry.getAttribute(`position`);this.place(this.fanDirs,this.fillScratch.length/3,s,o,c,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?sR(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);let e=oN(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1);e.frustumCulled=!1,e.renderOrder=YB,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=kz(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(ZB,Math.max(1,Math.ceil(t*180/Math.PI/XB))),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]=Dz(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 Vo;o.setAttribute(`position`,new ko(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new ks(o,Az(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=YB,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()}},$B=class{object=new Ra;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?eV(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 Iz({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?cR(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 eV(e){let t=new so().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var tV=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 $B(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()}},nV=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 rV(e,t){return e??t??!0}var iV=1400,aV=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}=i().messages;return this.show(oV()?n():t()),!1}allowsTouchDrag(e){return!this.enabled||e>1?!0:(this.show(i().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(),iV)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function oV(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var sV={[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`},cV={[G.ASTEROID_INNER]:`inner`,[G.ASTEROID_MAIN_BELT]:`main-belt`,[G.ASTEROID_TROJAN]:`trojan`,[G.ASTEROID_CENTAUR]:`centaur`,[G.ASTEROID_TNO]:`tno`};function lV(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a,unplaceable:o}=e.data,s={id:t,name:n,type:sV[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:o!==!0&&e.positionUnknown!==!0},c=cV[r];return c&&(s.orbitClass=c),s}var uV=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],dV=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(...uV.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},fV=[(e,t)=>e.setReducedMotion(t.resolvedReducedMotion),(e,t)=>e.setImmersive(t.viewMode===`immersive`),(e,t)=>e.setHaloDebugVisible(t.showHaloDebug),(e,t)=>{t.atmosphereCalibration,e.applyRenderTier()}],pV=.05,mV=1.15,hV=2e3,gV=4e3,_V=new WeakMap,vV=class{ctx=new xS;clock;initialView;#e=We(null);get renderer(){return Bt(this.#e)}set renderer(e){Ge(this.#e,e)}#t=We(!1);get webglError(){return Bt(this.#t)}set webglError(e){Ge(this.#t,e,!0)}#n=We(!1);get contextLost(){return Bt(this.#n)}set contextLost(e){Ge(this.#n,e,!0)}#r=We();get focusedBody(){return Bt(this.#r)}set focusedBody(e){Ge(this.#r,e)}attribution=null;objects=new tV(()=>this.requireRenderer().extensions,()=>this.requireCanvas());dragRotate;scrollZoom;keyboard;bodySelect;featureSelect;cooperativeGestures;container=null;canvas=null;labelLayer=null;stopWatching=null;controls=null;lostPanelTimer;cooperative=null;limits={};initialFocusPending=!0;pendingFocusId=null;retireCameraHold=null;listeners={focuschange:new Set,camera:new Set,featureselect:new Set,userpromoted:new Set,contextlost:new Set,contextrestored:new Set,clock:new Set,loading:new Set,progress:new Set,error:new Set,datastale:new Set,notice:new Set,noticedismiss:new Set,layerschange:new Set,frame:new Set};constructor(e={}){e.settings&&jx(e.settings),this.clock=new CS(Mg(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??sC,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new nV(rV(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 nV(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new Sv(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),hz()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};_V.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)_V.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&&lV(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=cn(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&lV(t)}getChildren(e){return[...this.ctx.bodies.getChildren(e)??[]]}load(e=this.initialView.id){return this.ctx.load(Ng(this.clock.jd),e)}async open(e=this.initialView.id){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&this.ctx.getBody(e)?t():document.hidden?setTimeout(r,100):requestAnimationFrame(r))};r()});try{await Promise.race([t,r])}finally{n=!1}}applyInitialView(){let{id:e,latitude:t,longitude:n,zoom:r}=this.initialView;this.focusedBody||!this.ctx.getBody(e)||this.renderer?.snapToBody(e,t,n,r)}mount(e){if(this.container)throw Error(`SpaceMap is already mounted`);this.container=e,e.classList.add(`sm-map`),this.controls=new dV(this,e);let t=document.createElement(`canvas`);t.className=`sm-map__canvas`,t.tabIndex=0,t.setAttribute(`role`,`application`),t.setAttribute(`aria-label`,i().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 aV(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 RR(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 a=new ResizeObserver(()=>r.resize(t.clientWidth,t.clientHeight));a.observe(t);let o=ot(()=>this.watch(r));this.stopWatching=()=>{a.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;!e||!t||(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(),e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null)}watch(e){it(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=Ax();for(let n of fV)it(()=>n(e,t));let n=this.clock;it(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Ng(e),playing:t,timeScale:r,direction:i,live:a})}),it(()=>{let e=this.ctx.loading,t=BR.bootPending;this.emit(`loading`,e||t)}),it(()=>this.emit(`progress`,H_.value)),it(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),it(()=>{BR.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=Ax();for(let n of fV)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&&cn(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)*pV,n=0,r=0,i=1;switch(e.key){case`ArrowLeft`:n=t;break;case`ArrowRight`:n=-t;break;case`ArrowUp`:r=t;break;case`ArrowDown`:r=-t;break;case`+`:case`=`:i=mV;break;case`-`:case`_`:i=1/mV;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`)},hV)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(gV),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};flyTo(e){let t=this.targetBody(e);return e.feature?this.toFeature(t,e.feature,`frame`):this.settled(this.focusOnBody(t,this.framing(e,t),e.lat,e.lon))}panTo(e){return this.toFeature(this.targetBody(e),e.feature,`pan`)}jumpTo(e){let t=this.targetBody(e);if(e.facing!==void 0)return this.snapToBodyFacing(t,e.facing,e.elevationDeg??0,this.framing(e,t)),this;if(e.feature){let{featureId:n,lat:r,lon:i,diameterM:a}=e.feature;return this.focusOnFeature(t,n,r,i,a,null,`snap`),this}let n=this.getCamera();return this.snapToBody(t,e.lat??n?.lat??45,e.lon??n?.lon??0,this.framing(e,t)),this}getCamera(){let e=this.renderer,t=this.focusedBody?.data.id;if(!e||t===void 0)return null;let{latitude:n,longitude:r,distance:i}=e.getCameraState();return{body:t,lat:n,lon:r,distanceKm:sg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...hv]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,hv.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?WL(n)*5:this.renderer?.getCameraState().distance??15}focusOnBody(e,t,n,r){return this.renderer?this.renderer.focusOnBody(e,t,n,r):(this.pendingFocusId=e,0)}snapToBody(e,t,n,r){this.renderer?.snapToBody(e,t,n,r)}snapToBodyFacing(e,t,n,r){this.renderer?.snapToBodyFacing(e,t,n,r)}focusOnFeature(e,t,n,r,i,a,o=`frame`,s=null){let c=this.ctx.getBody(e);if(!c)return 0;let l=Q(i*4/1e3),u=Q(.02),d=Q(mn(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:uR(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 yz(e,this.requireCanvas()))}addPolyline(e){return this.track(new xz(e))}addPolygon(e){return this.track(new Pz({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new Fz(e))}addLabel(e){return this.track(new Iz(e,this.requireCanvas()))}addIcon(e){return this.track(new Lz(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new QB(e))}addSurfacePolygon(e){return this.track(new QB({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:GB(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof $B)}setBodyAppearance(e,t){return this.requireRenderer().setBodyAppearance(e,t),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)}},yV=`http://www.w3.org/2000/svg`;function bV(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function xV(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function SV(e,t){let n=document.createElementNS(yV,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function CV(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of qB(t)){let t=BB(r,e,{stepDeg:2});t&&n.append(SV(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(yV,`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=UB(e);t&&n.append(SV(t,`sm-flat__frame`))}}}}var wV=120;function TV(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 fM(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,wV))},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(yV,`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(yV,`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 EV(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 DV(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var OV=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(yV,`g`),EV(this.node,t),DV(this.node,t),this.area=n?document.createElementNS(yV,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(yV,`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`,BB(this.points,e,t)),this.area?.setAttribute(`d`,VB(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)}},kV=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)}},AV=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 OV(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new OV(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 OV(WB(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 OV(GB(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 kV(e,this.drop,this.onChange);return this.track(t,t.element)}redraw(e){for(let t of this.drawings)t.redraw(e)}clear(){for(let e of this.drawings)e.detach();this.drawings.clear()}};function jV(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 MV(e,t){let[n,r]=jV(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 NV=class{width;height;u;v;inside;constructor(e,t,n){this.width=t,this.height=n;let r=t*n;this.u=new Float32Array(r),this.v=new Float32Array(r),this.inside=new Uint8Array(r);let{projection:i}=e,a=1/e.scale,o=e.view.centerX-e.width/2*a,s=e.view.centerY+e.height/2*a;for(let r=0;r<n;r++){let n=s-(r+.5)*a,c=r*t;i.rowInverse?this.fillRow(i,c,n,o,a,e):this.walkRow(i,c,n,o,a)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s}=this,c=(90-o.lat)/180,{minX:l,maxX:u}=e.extent,d=u-l,f=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(f)a=((a-l)%d+d)%d+l;else if(a<l||a>u)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360,p=t+n;this.u[p]=s-Math.floor(s),this.v[p]=c,this.inside[p]=1}}walkRow(e,t,n,r,i){let{width:a}=this,o=0,s=a-1;if(e.azimuthal){let t=e.extent.maxX;if(Math.abs(n)>t)return;let c=Math.sqrt(t*t-n*n);o=Math.max(0,Math.ceil((-c-r)/i-.5)),s=Math.min(a-1,Math.floor((c-r)/i-.5))}for(let a=o;a<=s;a++){let o=r+(a+.5)*i,s=e.inverse(o,n);if(!s)continue;let c=t+a;this.u[c]=(s[0]+180)/360,this.v[c]=(90-s[1])/180,this.inside[c]=1}}};function PV(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c}=e,l=i*a;for(let e of t){let{image:t,opacity:n,blend:i}=e;if(n<=0)continue;let a=t.data,u=t.width,d=t.height,f=i===`add`;for(let e=0;e<l;e++){if(!c[e])continue;let t=Math.floor(o[e]*u),i=Math.floor(s[e]*d);t=t<0?t+u:t>=u?t-u:t,i=i<0?0:i>=d?d-1:i;let l=(i*u+t)*4,p=a[l+3]/255*n;if(p<=0)continue;let m=e*4;if(f){r[m]=Math.min(255,r[m]+a[l]*p),r[m+1]=Math.min(255,r[m+1]+a[l+1]*p),r[m+2]=Math.min(255,r[m+2]+a[l+2]*p);continue}let h=r[m+3]/255,g=p+h*(1-p);if(!(g<=0)){if(p>=1)r[m]=a[l],r[m+1]=a[l+1],r[m+2]=a[l+2];else{let e=h*(1-p);r[m]=(a[l]*p+r[m]*e)/g,r[m+1]=(a[l+1]*p+r[m+1]*e)/g,r[m+2]=(a[l+2]*p+r[m+2]*e)/g}r[m+3]=g*255}}}}function FV(e,t,n){let{minX:r,maxX:i,minY:a,maxY:o}=t.projection.extent,s=t.projection.centerLon*Math.PI/180,[c,l]=t.toScreen(r-s,o),[u,d]=t.toScreen(i-s,a),f=t.repeatsHorizontally?0:t.toScreen(r,o)[0],p=t.repeatsHorizontally?e.canvas.width:t.toScreen(i,o)[0];e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`;for(let t of n){if(t.opacity<=0)continue;let n=jV(t.image),r=n&&e.createPattern(t.image,`repeat-x`);r&&(r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l))}e.restore()}var IV=[`low`,`medium`,`high`];function LV(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function RV(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function zV(e){let t=await RV(Kt(`/v1/textures/${e}/metadata.json`,`textures`));if(!t||!a(t.distribution))return{};let n=Object.keys(t.exports??{}).filter(e=>[`low`,`medium`,`high`].includes(e));return n.length===0?{}:{surface:{id:e,tiers:n,source:String(t.source??``),organisation:String(t.organisation??``),type:String(t.type??`cylindrical`),attribution:t.attribution,description:t.description,license:t.license,distribution:t.distribution}}}async function BV(e){let t=LV(e);if(!t)return zV(e);let n=(await RV(`${Ut()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return zV(e);let r=o([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return zV(e);let{frames:i,...a}=r,s=n.radii;return{surface:{...a,monthlyFrames:i},clouds:n.clouds,night:n.night,radiusKm:s?(s.a+s.b+s.c)/3:void 0}}var VV={low:2048,medium:8192,high:16383};function HV(e){return IV.find(t=>VV[t]>=e)??IV[IV.length-1]}function UV(e,t){return IV.indexOf(e)<=IV.indexOf(t)?e:t}function WV(e,t){let n=IV.indexOf(t);for(let t=n<0?IV.length-1:n;t>=0;t--)if(e.includes(IV[t]))return IV[t];return e[0]??`low`}function GV(e,t,n){let r=e.id;if(e.frames?.length){let i=Cj(n,e.frames,e.coverage);if(i)return Kt(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=Yj(n,e.monthlyFrames);return Kt(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function KV(e,t){return e*t*4}function qV(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var JV=class{entries=new Map;clock=0;constructor(e){this.free=e}claim(e){let t=this.entries.get(e);return t?(t.claims++,t.used=++this.clock,t.value):null}put(e,t,n){let r=this.entries.get(e);return r?(r.value!==t&&this.free(t),r.claims++,r.used=++this.clock,r.value):(this.entries.set(e,{value:t,bytes:n,claims:1,used:++this.clock}),this.evict(),t)}release(e){let t=this.entries.get(e);t&&(t.claims=Math.max(0,t.claims-1),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=qV();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()}},YV=new JV(e=>e.close()),XV=new JV(()=>{}),ZV=new Map;function QV(e,t){return t?`${e}@${t}`:e}async function $V(e,t){let n=QV(e,t),r=YV.claim(n);if(r)return{key:n,bitmap:r};let i=ZV.get(n);i||(i=eH(e,t),ZV.set(n,i),i.finally(()=>ZV.delete(n)));let a=await i;return a?{key:n,bitmap:YV.put(n,a,KV(a.width,a.height))}:null}async function eH(e,t){let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob();if(!t)return createImageBitmap(r);try{return await createImageBitmap(r,{resizeWidth:t,resizeQuality:`high`})}catch{return createImageBitmap(r)}}function tH(e){YV.release(e)}function nH(e,t,n){let r=QV(e,t),i=XV.claim(r);if(i)return{key:r,raster:i};let a=MV(n,t);return a?{key:r,raster:XV.put(r,a,KV(a.width,a.height))}:null}function rH(e){XV.release(e)}function iH(e,t,n){return[oC(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var aH=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 oH(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 oH(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function sH(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=cH(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:oH(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 cH(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]=iH(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 lH=[[6,`high`],[2.5,`medium`]],uH=22e5,dH=4096,fH=11,pH=.4,mH=.8,hH=140,gH=`naif-399`,_H=[{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 vH(e){return e.kind===`raster`}var yH=new WeakMap,bH=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(yV,`svg`);layerGroup=document.createElementNS(yV,`g`);shapeGroup=document.createElementNS(yV,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;generation=0;controls=null;attribution=null;dragPan;scrollZoom;cooperativeGestures;lookup=null;lookupKey=``;buffer=null;frame=0;resizeObserver=null;listeners=new Map;announcedReady=!1;disposed=!1;moving=!1;sharpWidth=0;msPerPixel=0;settleTimer=0;chosenVisibility=new Map;customLayers=[];constructor(e={}){this.bodyId=e.body??gH,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=CB(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??Mg(new Date),this.dragPan=new nV(rV(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new nV(rV(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new nV(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 AV(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 dV(this,this.root),this.cooperative=new aV(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)vH(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await BV(e);if(!this.disposed){if(!t.surface){let t=Error(`spacemap: no map texture for ${e}`);throw this.emit(`error`,t),t}e!==this.bodyId&&this.release(),this.bodyId=e,this.sources=t,this.bodyRadiusKm=t.radiusKm??null,this.overlay.setBodyRadiusKm(this.bodyRadiusKm),this.buildLayers(),await this.loadVisible(),!this.disposed&&this.render()}}release(){this.generation++,this.dropTextures(),this.missing.clear();for(let e of this.layerList)!vH(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=i(),t=[];for(let n of _H){let r=this.sources[n.kind];r&&t.push({kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:xV(r),tiers:r.tiers,url:(e,t)=>GV(r,t,e)})}t.push(CV(e.layer_graticule())),t.push(TV(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(bV)}getLayers(){return this.layerList.map(e=>e.id)}isLayerVisible(e){return this.layerList.find(t=>t.id===e)?.visible??!1}get credits(){let e=new Set,t=[];for(let n of this.layerList)!n.visible||!n.credit||e.has(n.credit.organisation)||(e.add(n.credit.organisation),t.push(n.credit));return t}setLayerVisible(e,t){this.chosenVisibility.set(e,t);let n=this.layerList.find(t=>t.id===e);!n||n.visible===t||(n.visible=t,this.emit(`layerschange`,this.layers),this.loadVisible(),this.render())}setLayerOpacity(e,t){let n=this.layerList.find(t=>t.id===e);!n||!vH(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 SB}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=CB(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=CB(this.projectionId,this.projectionOptions);else{let e=this.projection.forward(n,r);e&&(this.view={...this.view,centerX:e[0],centerY:e[1]})}}this.loadVisible(),this.render(),this.emit(`viewchange`,this.viewState)}setLimits(e){return this.limits={maxZoom:16,...e},this.render(),this}getLimits(){return{...this.limits}}setTime(e){this.jd=e,this.loadVisible(),this.render()}async setBody(e){e!==this.bodyId&&(this.limitsArmed=!1,await this.adopt(e))}project(e,t){return this.viewport().project(e,t)}unproject(e,t){let n=this.viewport().unproject(e,t);return n?{lon:n[0],lat:n[1]}:null}addPolyline(e){let t=this.overlay.addPolyline(e);return this.render(),t}addPolygon(e){let t=this.overlay.addPolygon(e);return this.render(),t}addBox(e){let t=this.overlay.addBox(e);return this.render(),t}addCircle(e){let t=this.overlay.addCircle(e);return this.render(),t}addMarker(e){let t=this.overlay.addMarker(e);return this.render(),t}clearDrawings(){this.overlay.clear(),this.render()}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});yH.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)yH.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}tier(e){return WV(e,UV(lH.find(([e])=>this.view.zoom>=e)?.[1]??`low`,HV(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(dH,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),VV[e]??dH)}picturesInUse(){return this.layerList.filter(e=>vH(e)&&e.visible).map(e=>{let t=this.tier(e.tiers);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!vH(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==QV(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 $V(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){tH(r.key);return}this.hold(this.bitmaps,e,r,tH),this.render()}catch(t){if(n!==this.generation)return;this.missing.add(e),this.emit(`error`,Error(`spacemap: could not load ${e}`,{cause:t}))}finally{this.pending.delete(e)}});await Promise.all([...t,...n]),this.dropUnused(new Set(this.picturesInUse().map(({url:e})=>e)))}dropUnused(e){for(let[t,n]of this.bitmaps)e.has(t)||(tH(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(rH(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===QV(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=nH(e,t,r);return i?(this.hold(this.rasters,e,i,rH),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())tH(e.key);for(let e of this.rasters.values())rH(e.key);this.bitmaps.clear(),this.rasters.clear()}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1;return this.view=sH(this.view,this.projection,n,r,this.limitsArmed?this.limits:{}),new aH(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()},hH),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(uH/(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 aH(this.projection,c,l,this.view);this.clipToDisc(u),this.drawRaster(d,c,l),this.drawVector(u),!this.announcedReady&&this.bitmaps.size>0&&(this.announcedReady=!0,this.emit(`ready`))}record(e,t){if(t<=0)return;let n=e/t;this.msPerPixel=this.msPerPixel===0?n:this.msPerPixel*.7+n*.3}interactionScale(e){if(this.msPerPixel<=0||e<=0)return 1;let t=Math.sqrt(fH/this.msPerPixel/e);return t>mH?1:Math.max(pH,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=>vH(e)&&e.visible);if(i.length===0)return;if(this.projectionId===`equirectangular`){let t=i.map(e=>({image:this.bitmaps.get(e.url(this.jd,this.tier(e.tiers)))?.bitmap,opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);t.length&&FV(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e.tiers)),a),opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);if(o.length===0)return;(!this.buffer||this.buffer.width!==t||this.buffer.height!==n)&&(this.buffer=r.createImageData(t,n));let s=`${this.projectionId}|${JSON.stringify(this.projectionOptions)}|${this.view.zoom}|${this.view.centerX}|${this.view.centerY}|${t}x${n}`,c=!this.lookup||this.lookupKey!==s,l=performance.now();c&&(this.lookup=new NV(e,t,n),this.lookupKey=s),PV(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(vH(t)||!t.visible)continue;let n=document.createElementNS(yV,`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]=iH((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=CB(this.projectionId,this.projectionOptions)}else this.view={...this.view,centerX:this.view.centerX-e/n.scale,centerY:this.view.centerY+t/n.scale};this.renderMoving(),this.emit(`viewchange`,this.viewState)}zoomBy(e,t,n){this.limitsArmed=!0;let r=this.viewport().fromScreen(t,n),i=Math.min(this.limits.maxZoom??1/0,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(i===this.view.zoom)return;this.view={...this.view,zoom:i};let a=this.viewport();if(!this.projection.azimuthal){let e=a.fromScreen(t,n);this.view={...this.view,centerX:this.view.centerX+r[0]-e[0],centerY:this.view.centerY+r[1]-e[1]}}this.loadVisible(),this.renderMoving(),this.emit(`viewchange`,this.viewState)}};function xH(e){let t=e?.radii;if(t)return(t.a+t.b+t.c)/3;let n=e?.wikidata?.radius;if(n)return n.unit===`kilometre`?n.value:n.unit===`metre`?n.value/1e3:null;let r=e?.sbdb?.diameter;return r?r/2:null}function SH(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function CH(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var wH=Math.PI/180,TH=256,EH=128,DH=.05,OH=.25;function kH(e){try{let t=document.createElement(`canvas`);t.width=TH,t.height=EH;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,TH,EH);let{data:r}=n.getImageData(0,0,TH,EH),i=new Uint8Array(TH*EH);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:TH,height:EH,covered:i}}catch{return null}}function AH(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]*wH);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*wH),l+=t*Math.cos(o[n]*wH),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<DH?t.heading:jH(Math.atan2(c,l)/wH-n.northOffsetDeg),f=jH(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*OH||(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 jH(e){return(e%360+360)%360}Math.PI/180;function MH(e){return e.orientation!==`unknown`&&e.north_offset_deg!==void 0}function NH(e){return e.id}function PH(e){return`${e.time},${e.lat},${e.lon}`}function FH(e,t){return t?e.find(e=>NH(e)===t||PH(e)===t)??null:null}function IH(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=e=>e&&e.mission===t.mission,a=e=>i(e)?{entry:e,distanceM:RH(t,e,n),bearingDeg:zH(t,e)}:null;return{previous:a(e[r-1]),next:a(e[r+1])}}var LH=Math.PI/180;function RH(e,t,n){return AB(e,t)*LH*n*1e3}function zH(e,t){let n=e.lat*LH,r=t.lat*LH,i=(t.lon-e.lon)*LH,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)/LH%360+360)%360}var BH=Math.PI/180,VH=30,HH=110,UH=85,WH=75,GH=-22,KH=9,qH=6,JH=10,YH=1,XH=1,ZH=new Vi(-Math.SQRT1_2,0,0,Math.SQRT1_2),QH=new J(0,0,1);function $H(e){return(e%360+360)%360}function eU(e,[t,n]){let r=$H(n-t),i=$H(e-t);return i<=r?$H(e):i-r<360-i?$H(n):$H(t)}function tU(e,t,n){return Math.max(t,Math.min(n,e))}function nU(e,t,n=new J){let r=e*BH,i=t*BH;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function rU(){let e=new ml;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 iU=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new Ka;camera=new od(WH,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new Ra;arrowGeometry=new eu(rU());raycaster=new Ld;loader=new qu;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 ba;gyroQuaternion=new Vi;gyroScreen=new Vi;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??WH},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 ks(new nu(500,96,48).scale(-1,1,1),new _s({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 uh({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 dV(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 px(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(fx),this.radiusKm=xH(e.global)??0,this.emit(`ready`);let t=this.openAt?this.byKey(this.openAt):this.entries[0]??null;if(!t){let e=Error(this.openAt?`spacemap: no panorama ${this.openAt} on ${this.bodyId}`:`spacemap: no panoramas on ${this.bodyId}`);throw this.emit(`error`,e),e}await this.open(t)}addControl(e,t){return this.controls?.add(e,t),this}removeControl(e){if(e===this.attribution)throw Error(`spacemap: the attribution control cannot be removed`);return this.controls?.remove(e),this}remove(){this.disposed=!0,this.setGyroEnabled(!1),this.loadToken++,cancelAnimationFrame(this.frame),this.frame=0,this.controls?.clear(),this.resizeObserver?.disconnect();let e=this.renderer?.domElement;e&&(e.removeEventListener(`pointerdown`,this.onPointerDown),e.removeEventListener(`pointermove`,this.onPointerMove),e.removeEventListener(`pointerup`,this.onPointerUp),e.removeEventListener(`pointercancel`,this.onPointerCancel),e.removeEventListener(`wheel`,this.onWheel),e.removeEventListener(`keydown`,this.onKeyDown)),this.setArrowTargets([]),this.texture?.dispose(),this.sphere.geometry.dispose(),this.sphere.material.dispose(),this.arrowGeometry.dispose(),this.renderer?.dispose(),this.renderer=null,this.root.remove(),this.container=null}getPanoramas(){return this.entries}getCurrent(){return this.current}getNeighbours(){return this.neighbours}async open(e){let t=typeof e==`string`?this.byKey(e):e;if(!t){let t=Error(`spacemap: no panorama ${String(e)} on ${this.bodyId}`);throw this.emit(`error`,t),t}this.current=t,this.neighbours=this.radiusKm?IH(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&&MH(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n&&e.n.distanceM>=XH).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture(Kt(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg??0,!n),this.current===t&&this.emit(`load`,t)}async step(e){let t=this.neighbours?.[e];t&&await this.open(t.entry)}byKey(e){return this.entries.find(t=>t.id===e)??FH(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?eU(t,i.heading):$H(t),pitch:tU(n,i.pitch?.[0]??-UH,i.pitch?.[1]??UH),fov:tU(r,i.fov?.[0]??VH,i.fov?.[1]??HH)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[tU(e[0],t,n),tU(e[1],t,n)];this.limits={heading:e.heading&&[$H(e.heading[0]),$H(e.heading[1])],pitch:t(e.pitch,-UH,UH),fov:t(e.fov,VH,HH)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?SH()!==`available`||!await CH()||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*BH,e.alpha*BH,-e.gamma*BH,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(ZH).multiply(this.gyroScreen.setFromAxisAngle(QH,-(screen.orientation?.angle??0)*BH)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/BH,n=Math.asin(tU(this.gyroDirection.y,-1,1))/BH;this.gyroOrigin===null&&(this.gyroOrigin=$H(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=kH(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*BH)*this.camera.aspect)/BH;this.setView(AH(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=Jr,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*BH,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 ks&&e.material.dispose()});for(let t of e){let e=new Ra;e.name=t.key;let n=new ks(this.arrowGeometry,new _s({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new ks(this.arrowGeometry,new _s({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(nU(t.bearingDeg,GH)).multiplyScalar(KH),e.rotation.y=-t.bearingDeg*BH,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(nU(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+=JH)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=JH)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+=JH){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+=JH){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+=YH){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 nU(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)<qH))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())}},aU=Object.fromEntries(yn.map(e=>[e,vn[e].label]));function oU(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 sU(e){return yn.filter(t=>e.credits.orbitSources.has(t)).filter(t=>!vn[t].scoped||oU(e,t)).map(e=>({source:e,info:vn[e]}))}function cU(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function lU(e,t=aU){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(sU(e).map(({source:e})=>t[e]))],i=new Set;for(let t of cU(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 uU=`https://spacemap.co`,dU=`https://spacemap.co/credits`;function fU(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function pU(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function mU(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 hU=class{stop=null;onAdd(e){let t=fU(),n=pU(),r=pU();return t.append(mU(uU,`spacemap`,`sm-attribution__home`),n,r,mU(dU,i().messages.credits_see_all())),this.stop=ot(()=>{it(()=>{let t=lU(e.ctx);gU(n,i().messages.attribution_orbits(),t.orbits),gU(r,i().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function gU(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 _U=class{off=null;onAdd(e){let t=fU(),n=pU();t.append(mU(uU,`spacemap`,`sm-attribution__home`),n,mU(dU,i().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=`${i().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 vU(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 yU=class{off=null;onAdd(e){let t=fU(),n=pU();t.append(mU(uU,`spacemap`,`sm-attribution__home`),n,mU(dU,i().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=`${i().messages.attribution_imagery()}:`;let a=vU(t.credit_url),o=a?mU(a,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`}},bU=Math.PI/180,xU=Math.cos(ig*bU),SU=Math.sin(ig*bU);function CU(e){return e}function wU(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>OU(t,e)}}function TU(e){return{body:e.body??`naif-10`,offsetKm:t=>bF(e.elements,t)?.r??null}}function EU(e,t){let n=tg(e,t);return n.error!==Qh.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:f_,offsetKm:e=>{if(n.error!==Qh.None)return null;let t=_g(n,e);return t&&DU(t[0],t[1],t[2])}}}function DU(e,t,n){return[e,t*xU+n*SU,-t*SU+n*xU]}function OU(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=kU(e,a-1,t),l=kU(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function kU(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 AU(e){return e/rg}async function jU(e=G_){let t=await e(`${Ut()}/v1/panoramas.json`);if(!t.ok)throw Error(`Failed to load panoramas.json: ${t.status}`);return(await t.json()).bodies??[]}async function MU(e){return(await px(e,!1)).global?.panoramas??[]}async function NU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=IU(t);LU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new vV(l);if(d.mount(u),d.webglError)throw d.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new hU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.open(),d.applyInitialView(),await gz(),d}async function PU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=IU(t);LU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new bH(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new _U,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function FU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=IU(t);LU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new iU(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new yU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}function IU(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 LU(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.locale!==void 0&&(t.locale=()=>e.locale),e.messages!==void 0&&(t.messages=e.messages),e.includeNonCommercial&&(t.textures=`non-commercial`),r(t)}export{hU as AttributionControl,_U as FlatAttributionControl,bH as FlatMap,nV as GestureHandler,hv as MAP_LAYERS,SB as PROJECTION_IDS,yU as PanoramaAttributionControl,iU as PanoramaView,vV as SpaceMap,aH as Viewport,zH as bearingDeg,WB as boxRing,wz as circlePoints,r as configureHost,PU as createFlatMap,NU as createMap,FU as createPanorama,CB as createProjection,Mg as dateToJD,Ox as defaultSceneSettings,TU as elements,jU as fetchPanoramaIndex,MU as fetchPanoramas,FH as findPanorama,CU as fixed,qB as graticule,RH as groundDistanceM,Ng as jdToDate,AU as kmToAu,IH as neighboursOf,NH as panoramaAt,BB as pathFor,Sz as planeBasis,Hz as projectionAspect,wU as samples,GB as smallCircle,EU as tle};
5536
+ `})}var Mz=.25,Nz=1e-9,Pz=3,Fz=class{object=new Ra;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??Mz,this.outline=t>0?new Sz({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?uR(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])>Nz||Math.abs(s[1]-this.lastOrigin[1])>Nz||Math.abs(s[2]-this.lastOrigin[2])>Nz){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=Ez(e);if(!n.length)return;let r=new Vo;r.setAttribute(`position`,new ko(new Float32Array(e.length*3),3)),r.setIndex(n),this.scratch=r.getAttribute(`position`).array;let i=new ks(r,jz(t,this.fillOpacity));i.matrixAutoUpdate=!1,i.renderOrder=Pz,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()}},Iz=class extends Fz{normal;steps;constructor(e){let{radiusKm:t,normal:n,steps:r,...i}=e;super({...i,points:Tz(t,{normal:n,steps:r})}),this.normal=n,this.steps=r}setRadiusKm(e){this.setPoints(Tz(e,{normal:this.normal,steps:this.steps}))}},Lz=class extends bz{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}},Rz=class extends bz{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}},zz=Math.PI/180,Bz=180/Math.PI;function Vz(e){return e>=-180&&e<180?e:((e+180)%360+360)%360-180}function Hz(e,t){return(n,r)=>{let i=e(r);return!i||Math.abs(n)>i.maxAbsX+1e-9?null:[Vz(n*i.lonPerX+t),i.lat]}}function Uz(e){let{minX:t,maxX:n,minY:r,maxY:i}=e.extent;return(n-t)/(i-r)}function Wz(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 Gz(e){let t=e.centerLon??0,n=e=>Math.abs(e)>Math.PI/2?null:{lat:e*Bz,lonPerX:Bz,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)=>[Vz(e-t)*zz,n*zz],rowInverse:n,inverse:Hz(n,t)}}var Kz=1.340264,qz=-.081106,Jz=893e-6,Yz=.003796,Xz=Math.sqrt(3),Zz=e=>Yz*e**9+Jz*e**7+qz*e**3+Kz*e,Qz=e=>9*Yz*e**8+7*Jz*e**6+3*qz*e**2+Kz;function $z(e){let t=e.centerLon??0,n=(e,n)=>{let r=Math.asin(hB(Xz/2*Math.sin(n*zz))),i=Vz(e-t)*zz;return[2*Xz*i*Math.cos(r)/(3*Qz(r)),Zz(r)]},r=e=>{let t=e;for(let n=0;n<12;n++){let n=(Zz(t)-e)/Qz(t);if(t-=n,Math.abs(n)<1e-12)break}return t},i=e=>{let t=r(e),n=2/Xz*Math.sin(t);if(Math.abs(n)>1)return null;let i=3*Qz(t)/(2*Xz*Math.cos(t))*Bz;return{lat:Math.asin(n)*Bz,lonPerX:i,maxAbsX:180/i}};return{id:`equalEarth`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:Wz(n),forward:n,rowInverse:i,inverse:Hz(i,t)}}var eB=Math.SQRT2;function tB(e){let t=e.centerLon??0,n=e=>{let t=e/eB;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*eB*i)*Bz;return{lat:Math.asin(r)*Bz,lonPerX:a,maxAbsX:180/a}};return{id:`mollweide`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-2*eB,minY:-eB,maxX:2*eB,maxY:eB},forward:(e,n)=>{let r=n*zz,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=Vz(e-t)*zz;return[2*eB/Math.PI*a*Math.cos(i),eB*Math.sin(i)]},rowInverse:n,inverse:Hz(n,t)}}function nB(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*Bz,lonPerX:Bz/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*zz;return[Vz(e-t)*zz*Math.cos(r),r]},rowInverse:n,inverse:Hz(n,t)}}var rB=[1,.9986,.9954,.99,.9822,.973,.96,.9427,.9216,.8962,.8679,.835,.7986,.7597,.7186,.6732,.6213,.5722,.5322],iB=[0,.062,.124,.186,.248,.31,.372,.434,.4958,.5571,.6176,.6769,.7346,.7903,.8435,.8936,.9394,.9761,1],aB=.8487,oB=1.3523,sB=5;function cB(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 lB=(e,t)=>e[0]+t*(e[1]+t*(e[2]+t*e[3])),uB=(e,t)=>e[1]+t*(2*e[2]+3*e[3]*t);function dB(e){let t=Math.min(Math.max(Math.floor(e),0),rB.length-2);return[t,e-t]}function fB(e){let[t,n]=dB(e);return aB*lB(cB(rB,t),n)*Math.PI}function pB(e){let t=0,n=iB.length-1;for(;n-t>1;){let r=t+n>>1;iB[r]<=e?t=r:n=r}let r=Math.min(t,iB.length-2),i=cB(iB,r),a=(e-iB[r])/(iB[r+1]-iB[r]);for(let t=0;t<8;t++){let t=uB(i,a);if(t===0)break;let n=(lB(i,a)-e)/t;if(a-=n,Math.abs(n)<1e-14)break}return r+Math.min(Math.max(a,0),1)}function mB(e){let t=e.centerLon??0,n=e=>{let t=Math.abs(e)/oB;if(t>1)return null;let n=pB(t),r=fB(n);return{lat:Math.sign(e)*n*sB,lonPerX:180/r,maxAbsX:r}};return{id:`robinson`,centerLon:t,cyclic:!0,rectangular:!1,azimuthal:!1,extent:{minX:-aB*Math.PI,minY:-oB,maxX:aB*Math.PI,maxY:oB},forward:(e,n)=>{let[r,i]=dB(Math.abs(n)/sB),a=lB(cB(rB,r),i),o=lB(cB(iB,r),i);return[aB*a*Vz(e-t)*zz,oB*o*Math.sign(n)]},rowInverse:n,inverse:Hz(n,t)}}function hB(e){return e<-1?-1:e>1?1:e}function gB(e,t,n,r,i,a,o){let s=Math.asin(hB(n*a+t*r*o));return[Vz(i+Math.atan2(e*r,n*o-t*r*a)*Bz),s*Bz]}function _B(e){return{minX:-e,minY:-e,maxX:e,maxY:e}}function vB(e,t,n,r){let i=Vz(e-n)*zz,a=t*zz;return[Math.cos(a)*Math.sin(i),Math.cos(r)*Math.sin(a)-Math.sin(r)*Math.cos(a)*Math.cos(i)]}function yB(e){let t=e.centerLon??0,n=(e.centerLat??0)*zz,r=Math.min(e.clipAngle??90,90)*zz,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:_B(a),forward:(e,r)=>{let a=Vz(e-t)*zz,o=r*zz;return Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos(a)<i?null:vB(e,r,t,n)},inverse:(e,n)=>{let r=e*e+n*n;return r>a*a?null:gB(e,n,Math.sqrt(1-r),1,t,o,s)}}}var bB=120;function xB(e){let t=e.centerLon??0,n=(e.centerLat??90)*zz,r=Math.min(e.clipAngle??bB,170)*zz,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:_B(a),forward:(e,r)=>{let a=Vz(e-t)*zz,o=r*zz,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]=vB(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 gB(e,n,(4-r)*i*.25,i,t,o,s)}}}var SB={equirectangular:Gz,equalEarth:$z,mollweide:tB,sinusoidal:nB,robinson:mB,orthographic:yB,stereographic:xB},CB=Object.keys(SB);function wB(e,t={}){let n=SB[e];if(!n)throw Error(`spacemap: unknown projection "${e}"`);return n(t)}var TB=Math.PI/180,EB=2*Math.PI,DB=2*TB,OB=180/Math.PI,kB=512,AB=2;function jB(e,t){let n=e.lat*TB,r=t.lat*TB,i=r-n,a=Vz(t.lon-e.lon)*TB,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)))*OB}function MB(e,t,n){let r=jB(e,t)*TB;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*TB,c=e.lon*TB,l=t.lat*TB,u=(e.lon+Vz(t.lon-e.lon))*TB,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)*OB,lat:Math.atan2(p,Math.hypot(d,f))*OB}}function NB(e,t,n){return{lon:e.lon+Vz(t.lon-e.lon)*n,lat:e.lat+(t.lat-e.lat)*n}}function PB(e,t={}){let n=t.interpolate??`linear`,r=t.stepDeg??AB,i=n===`geodesic`?MB:NB,a=t.closed&&e.length>2?[...e,e[0]]:e;if(a.length<2)return[...a];let o=[a[0]];for(let e=1;e<a.length;e++){let t=a[e-1],n=a[e],s=Math.min(kB,Math.max(1,Math.ceil(jB(t,n)/r)));for(let e=1;e<=s;e++)o.push(e===s?n:i(t,n,e/s))}return o}function FB(e,t,n){let r=0,i=1;for(let a=0;a<20;a++){let a=(r+i)/2,o=NB(e,t,a);n.forward(o.lon,o.lat)?r=a:i=a}return NB(e,t,r)}function IB(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=FB(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=FB(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 LB(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 RB(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 zB=179.999999;function BB(e,t){let n=e=>e>zB?zB:e<-zB?-zB:e,r=e.length;if(r<3)return[e];let i=[],a=[],o=Vz(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=Vz(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*zB,lat:e}),i.push(a),a=[{lon:-d*zB,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 VB(e,t,n={}){if(e.length<2)return``;let{projection:r}=t;return(n.closed&&r.cyclic?BB(e,r.centerLon):[e]).map(e=>{let{runs:r,whole:i}=IB(PB(e,n),t),a=!!n.closed&&i;return LB(r,t).map(e=>RB(e,a)).join(``)}).join(``)}function HB(e,t,n={}){let{projection:r}=t;if(!r.azimuthal)return VB(e,t,{...n,closed:!0});if(e.length<2)return``;let i=PB(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 RB(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=FB(a[t],a[n],r);f=[r.forward(e.lon,e.lat)]}f.push(i)}else if(f){let e=FB(a[n],a[t],r);f.push(r.forward(e.lon,e.lat)),d.push(f),f=null}}let p=UB(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)%EB+EB)%EB;n<a&&(a=n,i=e)}let o=Math.ceil(a/DB);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=>RB(e.map(s),!0)).join(``)}function UB(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n],i=e[(n+1)%e.length];t+=Vz(i.lon-r.lon)*TB*(2+Math.sin(r.lat*TB)+Math.sin(i.lat*TB))}let n=-t/2;return n>0?n<EB:n<-EB}function WB(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?``:LB([i],e).map(e=>RB(e,!0)).join(``)}function GB(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 KB(e,t,n=128){let r=e.lat*TB,i=e.lon*TB,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*TB,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:Vz(Math.atan2(l,s)*OB),lat:Math.atan2(p,Math.hypot(s,l))*OB})}return f}var qB=24;function JB(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<=qB;t++)e.push({lon:-n+2*n*t/qB,lat:r});t.push(e)}return t}var YB=.005,XB=1.5,ZB=5,QB=24,$B=class{object=new Ra;body;altitudeKm;closed;interpolate;stepDeg;color;widthPx;opacity;fillColor;fillOpacity;dirs=new Float64Array;count=0;line=null;scratch=new Float32Array;alphas=new Float32Array;fanDirs=new Float64Array;fill=null;fillScratch=new Float32Array;turned=[0,0,0];wanted=!0;removeSelf=null;constructor(e){this.body=e.body,this.altitudeKm=e.altitudeKm??null,this.closed=e.closed??!1,this.interpolate=e.interpolate??`linear`,this.stepDeg=e.stepDeg,this.color=e.color??`#ffffff`,this.widthPx=e.widthPx??2,this.opacity=e.opacity??1,this.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=PB(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]=cR(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,ctx:r}){let i=this.wanted&&this.count>=2?r.getBody(this.body):void 0;if(this.line&&(this.line.visible=i!==void 0),this.fill&&(this.fill.visible=i!==void 0),!i)return;let a=mn(i.data),o=Q(a+(this.altitudeKm??a*YB)),s=i.orientation?fC(i.orientation,e,i.nutPrec):null,c=[i.position[0]-t[0],i.position[1]-t[1],i.position[2]-t[2]];if(this.line&&(this.place(this.dirs,this.count,s,o,c,this.scratch),aN(this.line.geometry,this.scratch,this.alphas,this.alphas,this.count),this.line.material.uniforms.uCenterOffset.value.copy(n.position).negate()),this.fill){let e=this.fill.geometry.getAttribute(`position`);this.place(this.fanDirs,this.fillScratch.length/3,s,o,c,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?lR(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);let e=cN(this.count,this.scratch,this.alphas,this.alphas,this.count,this.color,this.widthPx,1);e.frustumCulled=!1,e.renderOrder=XB,this.object.add(e),this.line=e}buildFill(){if(this.disposeFill(),!this.fillColor||this.count<3)return;let e=Az(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(QB,Math.max(1,Math.ceil(t*180/Math.PI/ZB))),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]=Oz(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 Vo;o.setAttribute(`position`,new ko(new Float32Array(r*3),3)),o.setIndex(i),this.fillScratch=o.getAttribute(`position`).array;let s=new ks(o,jz(this.fillColor,this.fillOpacity));s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.renderOrder=XB,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()}},eV=class{object=new Ra;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?tV(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 Lz({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?uR(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 tV(e){let t=new so().setFromObject(e).getSize(new J);return Math.max(t.x,t.y,t.z)}var nV=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 eV(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()}},rV=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 iV(e,t){return e??t??!0}var aV=1400,oV=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}=i().messages;return this.show(sV()?n():t()),!1}allowsTouchDrag(e){return!this.enabled||e>1?!0:(this.show(i().messages.cooperative_touch()),!1)}dispose(){clearTimeout(this.timer),this.element.remove()}show(e){this.element.textContent=e,this.element.classList.add(`sm-cooperative-hint--shown`),clearTimeout(this.timer),this.timer=setTimeout(()=>this.hide(),aV)}hide(){clearTimeout(this.timer),this.element.classList.remove(`sm-cooperative-hint--shown`)}};function sV(){return/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}var cV={[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`},lV={[G.ASTEROID_INNER]:`inner`,[G.ASTEROID_MAIN_BELT]:`main-belt`,[G.ASTEROID_TROJAN]:`trojan`,[G.ASTEROID_CENTAUR]:`centaur`,[G.ASTEROID_TNO]:`tno`};function uV(e){let{id:t,name:n,objectType:r,parentId:i,radiusKm:a,unplaceable:o}=e.data,s={id:t,name:n,type:cV[r],parentId:i,radiusKm:Number.isFinite(a)&&a>0?a:null,placed:o!==!0&&e.positionUnknown!==!0},c=lV[r];return c&&(s.orbitClass=c),s}var dV=[`top-left`,`top-right`,`bottom-left`,`bottom-right`],fV=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(...dV.map(e=>this.corners.get(e)).filter(e=>e!==void 0)),t)}},pV=[(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()}],mV=.05,hV=1.15,gV=2e3,_V=4e3,vV=new WeakMap,yV=class{ctx=new SS;clock;initialView;#e=We(null);get renderer(){return Bt(this.#e)}set renderer(e){Ge(this.#e,e)}#t=We(!1);get webglError(){return Bt(this.#t)}set webglError(e){Ge(this.#t,e,!0)}#n=We(!1);get contextLost(){return Bt(this.#n)}set contextLost(e){Ge(this.#n,e,!0)}#r=We();get focusedBody(){return Bt(this.#r)}set focusedBody(e){Ge(this.#r,e)}attribution=null;objects=new nV(()=>this.requireRenderer().extensions,()=>this.requireCanvas());dragRotate;scrollZoom;keyboard;bodySelect;featureSelect;cooperativeGestures;container=null;canvas=null;labelLayer=null;stopWatching=null;controls=null;lostPanelTimer;cooperative=null;limits={};initialFocusPending=!0;pendingFocusId=null;retireCameraHold=null;listeners={focuschange:new Set,camera:new Set,featureselect:new Set,userpromoted:new Set,contextlost:new Set,contextrestored:new Set,clock:new Set,loading:new Set,progress:new Set,error:new Set,datastale:new Set,notice:new Set,noticedismiss:new Set,layerschange:new Set,frame:new Set};constructor(e={}){e.settings&&Mx(e.settings),this.clock=new wS(Mg(e.date??new Date),e.live??e.date===void 0);let t=e.view??{};this.initialView={id:t.body??cC,latitude:t.lat??45,longitude:t.lon??0,zoom:t.distanceKm===void 0?15:Q(t.distanceKm)};let n=t=>new rV(iV(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 rV(e.cooperativeGestures??!1,()=>this.applyGestures()),e.limits&&(this.limits={...e.limits}),this.ctx.layers=new Sv(e.layers),this.ctx.layers.onChange=()=>this.onLayerChange(),this.ctx.onDataStale=()=>this.emit(`datastale`),gz()}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}once(e,t){let n=(...e)=>{r(),t(...e)};vV.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)vV.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&&uV(t)}getFocusedBody(){let e=this.focusedBody;if(!e)return;let t=cn(e)?this.ctx.getBody(e.featureAnchor.hostId):e;return t&&uV(t)}getChildren(e){return[...this.ctx.bodies.getChildren(e)??[]]}load(e=this.initialView.id){return this.ctx.load(Ng(this.clock.jd),e)}async open(e=this.initialView.id){let t=this.load(e);t.catch(()=>{});let n=!0,r=new Promise(t=>{let r=()=>{n&&(this.renderer&&this.ctx.getBody(e)?t():document.hidden?setTimeout(r,100):requestAnimationFrame(r))};r()});try{await Promise.race([t,r])}finally{n=!1}}applyInitialView(){let{id:e,latitude:t,longitude:n,zoom:r}=this.initialView;this.focusedBody||!this.ctx.getBody(e)||this.renderer?.snapToBody(e,t,n,r)}mount(e){if(this.container)throw Error(`SpaceMap is already mounted`);this.container=e,e.classList.add(`sm-map`),this.controls=new fV(this,e);let t=document.createElement(`canvas`);t.className=`sm-map__canvas`,t.tabIndex=0,t.setAttribute(`role`,`application`),t.setAttribute(`aria-label`,i().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 oV(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 zR(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 a=new ResizeObserver(()=>r.resize(t.clientWidth,t.clientHeight));a.observe(t);let o=ot(()=>this.watch(r));this.stopWatching=()=>{a.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;!e||!t||(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(),e.classList.remove(`sm-map`),this.container=this.canvas=this.labelLayer=null)}watch(e){it(()=>{this.ctx.bodies.minorBodyVersion,e.rebuildMinorPointClouds()});let t=jx();for(let n of pV)it(()=>n(e,t));let n=this.clock;it(()=>{let{jd:e,playing:t,timeScale:r,direction:i,live:a}=n;this.listeners.clock.size!==0&&this.emit(`clock`,{jd:e,date:Ng(e),playing:t,timeScale:r,direction:i,live:a})}),it(()=>{let e=this.ctx.loading,t=VR.bootPending;this.emit(`loading`,e||t)}),it(()=>this.emit(`progress`,H_.value)),it(()=>{let e=this.ctx.error;e!==null&&this.emit(`error`,e)}),it(()=>{VR.progress===null?e.isContextLost()||e.resume():e.pause()})}applySettings(){let e=this.renderer;if(!e)return;let t=jx();for(let n of pV)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&&cn(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)*mV,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=hV;break;case`-`:case`_`:i=1/hV;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`)},gV)};onContextRestored=()=>{console.warn(`[scene] WebGL context restored`),clearTimeout(this.lostPanelTimer),this.contextLost=!1,this.renderer?.handleContextRestored(),this.renderer?.recoverWorkersIfDead(_V),this.emit(`contextrestored`)};onVisibility=()=>{document.visibilityState===`visible`&&(this.renderer?.isContextLost()||this.renderer?.recoverWorkersIfDead())};flyTo(e){let t=this.targetBody(e);return e.feature?this.toFeature(t,e.feature,`frame`):this.settled(this.focusOnBody(t,this.framing(e,t),e.lat,e.lon))}panTo(e){return this.toFeature(this.targetBody(e),e.feature,`pan`)}jumpTo(e){let t=this.targetBody(e);if(e.facing!==void 0)return this.snapToBodyFacing(t,e.facing,e.elevationDeg??0,this.framing(e,t)),this;if(e.feature){let{featureId:n,lat:r,lon:i,diameterM:a}=e.feature;return this.focusOnFeature(t,n,r,i,a,null,`snap`),this}let n=this.getCamera();return this.snapToBody(t,e.lat??n?.lat??45,e.lon??n?.lon??0,this.framing(e,t)),this}getCamera(){let e=this.renderer,t=this.focusedBody?.data.id;if(!e||t===void 0)return null;let{latitude:n,longitude:r,distance:i}=e.getCameraState();return{body:t,lat:n,lon:r,distanceKm:sg(i)}}setLayerVisible(e,t){return this.ctx.layers.setVisible(e,t),this}isLayerVisible(e){return this.ctx.layers.isVisible(e)}getLayers(){return[...hv]}onLayerChange(){for(let e of this.ctx.bodies.spacecraftByParent.keys())this.ctx.bodies.dirtySpacecraftGroups.add(e);this.ctx.bodies.minorBodyVersion++,this.emit(`layerschange`,hv.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?KL(n)*5:this.renderer?.getCameraState().distance??15}focusOnBody(e,t,n,r){return this.renderer?this.renderer.focusOnBody(e,t,n,r):(this.pendingFocusId=e,0)}snapToBody(e,t,n,r){this.renderer?.snapToBody(e,t,n,r)}snapToBodyFacing(e,t,n,r){this.renderer?.snapToBodyFacing(e,t,n,r)}focusOnFeature(e,t,n,r,i,a,o=`frame`,s=null){let c=this.ctx.getBody(e);if(!c)return 0;let l=Q(i*4/1e3),u=Q(.02),d=Q(mn(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:fR(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 bz(e,this.requireCanvas()))}addPolyline(e){return this.track(new Sz(e))}addPolygon(e){return this.track(new Fz({fill:e.color??`#ffffff`,...e}))}addCircle(e){return this.track(new Iz(e))}addLabel(e){return this.track(new Lz(e,this.requireCanvas()))}addIcon(e){return this.track(new Rz(e,this.requireCanvas()))}addSurfacePolyline(e){return this.track(new $B(e))}addSurfacePolygon(e){return this.track(new $B({fill:e.color??`#ffffff`,...e,closed:!0}))}addSurfaceCircle(e){return this.addSurfacePolygon({...e,points:KB(e.center,this.capRadiusDeg(e),e.steps)})}clearDrawings(){this.renderer?.extensions.clear(e=>e instanceof eV)}setBodyAppearance(e,t){return this.requireRenderer().setBodyAppearance(e,t),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)}},bV=`http://www.w3.org/2000/svg`;function xV(e){return{id:e.id,label:e.label,kind:e.kind,visible:e.visible,credit:e.credit}}function SV(e){return{organisation:e.organisation,source:e.source,attribution:e.attribution}}function CV(e,t){let n=document.createElementNS(bV,`path`);return n.setAttribute(`d`,e),n.setAttribute(`class`,t),n}function wV(e,t=30){return{kind:`vector`,id:`graticule`,label:e,visible:!1,render(e,n){for(let r of JB(t)){let t=VB(r,e,{stepDeg:2});t&&n.append(CV(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(bV,`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=WB(e);t&&n.append(CV(t,`sm-flat__frame`))}}}}var TV=120;function EV(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 mM(e)].sort((e,t)=>t.diameterM-e.diameterM).slice(0,TV))},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(bV,`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(bV,`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 DV(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 OV(e,t){t.onclick&&e.addEventListener(`click`,t.onclick),t.onpointerenter&&e.addEventListener(`pointerenter`,t.onpointerenter),t.onpointerleave&&e.addEventListener(`pointerleave`,t.onpointerleave)}var kV=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(bV,`g`),DV(this.node,t),OV(this.node,t),this.area=n?document.createElementNS(bV,`path`):null,this.area?.setAttribute(`stroke`,`none`),this.edge=document.createElementNS(bV,`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`,VB(this.points,e,t)),this.area?.setAttribute(`d`,HB(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)}},AV=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)}},jV=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 kV(e.points,e,e.closed??!1,e.interpolate??`linear`,this.drop,this.onChange);return this.track(t,t.node)}addPolygon(e){let t=new kV(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 kV(GB(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 kV(KB(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 AV(e,this.drop,this.onChange);return this.track(t,t.element)}redraw(e){for(let t of this.drawings)t.redraw(e)}clear(){for(let e of this.drawings)e.detach();this.drawings.clear()}};function MV(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 NV(e,t){let[n,r]=MV(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 PV=class{width;height;u;v;inside;constructor(e,t,n){this.width=t,this.height=n;let r=t*n;this.u=new Float32Array(r),this.v=new Float32Array(r),this.inside=new Uint8Array(r);let{projection:i}=e,a=1/e.scale,o=e.view.centerX-e.width/2*a,s=e.view.centerY+e.height/2*a;for(let r=0;r<n;r++){let n=s-(r+.5)*a,c=r*t;i.rowInverse?this.fillRow(i,c,n,o,a,e):this.walkRow(i,c,n,o,a)}}fillRow(e,t,n,r,i,a){let o=e.rowInverse(n);if(!o)return;let{width:s}=this,c=(90-o.lat)/180,{minX:l,maxX:u}=e.extent,d=u-l,f=a.repeatsHorizontally;for(let n=0;n<s;n++){let a=r+(n+.5)*i;if(f)a=((a-l)%d+d)%d+l;else if(a<l||a>u)continue;if(a<-o.maxAbsX||a>o.maxAbsX)continue;let s=(a*o.lonPerX+e.centerLon+180)/360,p=t+n;this.u[p]=s-Math.floor(s),this.v[p]=c,this.inside[p]=1}}walkRow(e,t,n,r,i){let{width:a}=this,o=0,s=a-1;if(e.azimuthal){let t=e.extent.maxX;if(Math.abs(n)>t)return;let c=Math.sqrt(t*t-n*n);o=Math.max(0,Math.ceil((-c-r)/i-.5)),s=Math.min(a-1,Math.floor((c-r)/i-.5))}for(let a=o;a<=s;a++){let o=r+(a+.5)*i,s=e.inverse(o,n);if(!s)continue;let c=t+a;this.u[c]=(s[0]+180)/360,this.v[c]=(90-s[1])/180,this.inside[c]=1}}};function FV(e,t,n){let r=n.data;r.fill(0);let{width:i,height:a,u:o,v:s,inside:c}=e,l=i*a;for(let e of t){let{image:t,opacity:n,blend:i}=e;if(n<=0)continue;let a=t.data,u=t.width,d=t.height,f=i===`add`;for(let e=0;e<l;e++){if(!c[e])continue;let t=Math.floor(o[e]*u),i=Math.floor(s[e]*d);t=t<0?t+u:t>=u?t-u:t,i=i<0?0:i>=d?d-1:i;let l=(i*u+t)*4,p=a[l+3]/255*n;if(p<=0)continue;let m=e*4;if(f){r[m]=Math.min(255,r[m]+a[l]*p),r[m+1]=Math.min(255,r[m+1]+a[l+1]*p),r[m+2]=Math.min(255,r[m+2]+a[l+2]*p);continue}let h=r[m+3]/255,g=p+h*(1-p);if(!(g<=0)){if(p>=1)r[m]=a[l],r[m+1]=a[l+1],r[m+2]=a[l+2];else{let e=h*(1-p);r[m]=(a[l]*p+r[m]*e)/g,r[m+1]=(a[l+1]*p+r[m+1]*e)/g,r[m+2]=(a[l+2]*p+r[m+2]*e)/g}r[m+3]=g*255}}}}function IV(e,t,n){let{minX:r,maxX:i,minY:a,maxY:o}=t.projection.extent,s=t.projection.centerLon*Math.PI/180,[c,l]=t.toScreen(r-s,o),[u,d]=t.toScreen(i-s,a),f=t.repeatsHorizontally?0:t.toScreen(r,o)[0],p=t.repeatsHorizontally?e.canvas.width:t.toScreen(i,o)[0];e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`;for(let t of n){if(t.opacity<=0)continue;let n=MV(t.image),r=n&&e.createPattern(t.image,`repeat-x`);r&&(r.setTransform(new DOMMatrix().translateSelf(c,l).scaleSelf((u-c)/n[0],(d-l)/n[1])),e.globalAlpha=t.opacity,e.globalCompositeOperation=t.blend===`add`?`lighter`:`source-over`,e.fillStyle=r,e.fillRect(f,l,p-f,d-l))}e.restore()}var LV=[`low`,`medium`,`high`];function RV(e){let t=/^naif-(\d)\d\d$/.exec(e);return t?`naif-${t[1]}`:null}async function zV(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function BV(e){let t=await zV(Kt(`/v1/textures/${e}/metadata.json`,`textures`));if(!t||!a(t.distribution))return{};let n=Object.keys(t.exports??{}).filter(e=>[`low`,`medium`,`high`].includes(e));return n.length===0?{}:{surface:{id:e,tiers:n,source:String(t.source??``),organisation:String(t.organisation??``),type:String(t.type??`cylindrical`),attribution:t.attribution,description:t.description,license:t.license,distribution:t.distribution}}}async function VV(e){let t=RV(e);if(!t)return BV(e);let n=(await zV(`${Ut()}/v1/systems/${t}.json`))?.[e];if(!n?.texture||!n.tiers?.length)return BV(e);let r=o([{...n.texture,id:e,tiers:n.tiers},...n.alternates??[]]);if(!r)return BV(e);let{frames:i,...a}=r,s=n.radii;return{surface:{...a,monthlyFrames:i},clouds:n.clouds,night:n.night,radiusKm:s?(s.a+s.b+s.c)/3:void 0}}var HV={low:2048,medium:8192,high:16383};function UV(e){return LV.find(t=>HV[t]>=e)??LV[LV.length-1]}function WV(e,t){return LV.indexOf(e)<=LV.indexOf(t)?e:t}function GV(e,t){let n=LV.indexOf(t);for(let t=n<0?LV.length-1:n;t>=0;t--)if(e.includes(LV[t]))return LV[t];return e[0]??`low`}function KV(e,t,n){let r=e.id;if(e.frames?.length){let i=Tj(n,e.frames,e.coverage);if(i)return Kt(`/v1/textures/${r}/${t}_${i}.webp`,`textures`)}let i=Zj(n,e.monthlyFrames);return Kt(i===void 0?`/v1/textures/${r}/${t}.webp`:`/v1/textures/${r}/${t}_${String(i).padStart(2,`0`)}.webp`,`textures`)}function qV(e,t){return e*t*4}function JV(){let e=navigator.deviceMemory??4;return Math.max(1,Math.min(e,8))*24*1024*1024}var YV=class{entries=new Map;clock=0;constructor(e){this.free=e}claim(e){let t=this.entries.get(e);return t?(t.claims++,t.used=++this.clock,t.value):null}put(e,t,n){let r=this.entries.get(e);return r?(r.value!==t&&this.free(t),r.claims++,r.used=++this.clock,r.value):(this.entries.set(e,{value:t,bytes:n,claims:1,used:++this.clock}),this.evict(),t)}release(e){let t=this.entries.get(e);t&&(t.claims=Math.max(0,t.claims-1),this.evict())}evict(){let e=0;for(let t of this.entries.values())t.claims||(e+=t.bytes);let t=JV();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()}},XV=new YV(e=>e.close()),ZV=new YV(()=>{}),QV=new Map;function $V(e,t){return t?`${e}@${t}`:e}async function eH(e,t){let n=$V(e,t),r=XV.claim(n);if(r)return{key:n,bitmap:r};let i=QV.get(n);i||(i=tH(e,t),QV.set(n,i),i.finally(()=>QV.delete(n)));let a=await i;return a?{key:n,bitmap:XV.put(n,a,qV(a.width,a.height))}:null}async function tH(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 nH(e){XV.release(e)}function rH(e,t,n){let r=$V(e,t),i=ZV.claim(r);if(i)return{key:r,raster:i};let a=NV(n,t);return a?{key:r,raster:ZV.put(r,a,qV(a.width,a.height))}:null}function iH(e){ZV.release(e)}function aH(e,t,n){return[sC(e,n.minLon,n.maxLon),Math.min(Math.max(t,n.minLat??-90),n.maxLat??90)]}var oH=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 sH(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 sH(e,t,n){return e.cyclic&&e.rectangular&&t>=n-.5}function cH(e,t,n,r,i){let a=Math.min(Math.max(e.zoom,1,i.minZoom??1),i.maxZoom??1/0),o=lH(e,t,i),s=t.extent,c=s.maxX-s.minX,l=s.maxY-s.minY,u=Math.min(n/c,r/l)*a,d=n/2/u,f=r/2/u,p=(s.minX+s.maxX)/2,m=(s.minY+s.maxY)/2,h=(e,t,n,r)=>n>=r/2?t:Math.min(t+r/2-n,Math.max(t-r/2+n,e));return{zoom:a,centerX:sH(t,c*u,n)?((o.centerX-s.minX)%c+c)%c+s.minX:h(o.centerX,p,d,c),centerY:h(o.centerY,m,f,l)}}function lH(e,t,n){if(!(n.minLon!==void 0||n.maxLon!==void 0||n.minLat!==void 0||n.maxLat!==void 0)||t.azimuthal)return e;let r=t.inverse(e.centerX,e.centerY);if(!r)return e;let[i,a]=aH(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 uH=[[6,`high`],[2.5,`medium`]],dH=22e5,fH=4096,pH=11,mH=.4,hH=.8,gH=140,_H=`naif-399`,vH=[{kind:`surface`,label:e=>e.layer_surface(),visible:!0,opacity:1,blend:`normal`},{kind:`clouds`,label:e=>e.layer_clouds(),visible:!0,opacity:1,blend:`normal`},{kind:`night`,label:e=>e.layer_night(),visible:!1,opacity:.85,blend:`add`}];function yH(e){return e.kind===`raster`}var bH=new WeakMap,xH=class{container=null;root=document.createElement(`div`);canvas=document.createElement(`canvas`);svg=document.createElementNS(bV,`svg`);layerGroup=document.createElementNS(bV,`g`);shapeGroup=document.createElementNS(bV,`g`);markerLayer=document.createElement(`div`);ctx;overlay;bodyId;sources={};layerList=[];projection;projectionId;projectionOptions;view;limits;limitsArmed=!1;jd;cooperative=null;bodyRadiusKm=null;bitmaps=new Map;rasters=new Map;pending=new Set;missing=new Set;generation=0;controls=null;attribution=null;dragPan;scrollZoom;cooperativeGestures;lookup=null;lookupKey=``;buffer=null;frame=0;resizeObserver=null;listeners=new Map;announcedReady=!1;disposed=!1;moving=!1;sharpWidth=0;msPerPixel=0;settleTimer=0;chosenVisibility=new Map;customLayers=[];constructor(e={}){this.bodyId=e.body??_H,this.projectionId=e.projection??`equirectangular`,this.projectionOptions={centerLon:e.centerLon??0,centerLat:e.centerLat,clipAngle:e.clipAngle},this.projection=wB(this.projectionId,this.projectionOptions),this.limits={maxZoom:16,...e.limits},this.view={zoom:e.zoom??1,centerX:0,centerY:0},this.jd=e.jd??Mg(new Date),this.dragPan=new rV(iV(e.interactions?.dragPan,e.interactive),e=>this.root.classList.toggle(`sm-flat--interactive`,e)),this.scrollZoom=new rV(iV(e.interactions?.scrollZoom,e.interactive)),this.cooperativeGestures=new rV(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 jV(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 fV(this,this.root),this.cooperative=new oV(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)yH(e)||e.dispose?.();this.overlay.clear(),this.dropTextures(),this.root.remove(),this.container=null}async load(){await this.adopt(this.bodyId)}async adopt(e){let t=await VV(e);if(!this.disposed){if(!t.surface){let t=Error(`spacemap: no map texture for ${e}`);throw this.emit(`error`,t),t}e!==this.bodyId&&this.release(),this.bodyId=e,this.sources=t,this.bodyRadiusKm=t.radiusKm??null,this.overlay.setBodyRadiusKm(this.bodyRadiusKm),this.buildLayers(),await this.loadVisible(),!this.disposed&&this.render()}}release(){this.generation++,this.dropTextures(),this.missing.clear();for(let e of this.layerList)!yH(e)&&!this.customLayers.includes(e)&&e.dispose?.()}buildLayers(){let{messages:e}=i(),t=[];for(let n of vH){let r=this.sources[n.kind];r&&t.push({kind:`raster`,id:n.kind,label:n.label(e),visible:n.visible,opacity:n.opacity,blend:n.blend,credit:SV(r),tiers:r.tiers,url:(e,t)=>KV(r,t,e)})}t.push(wV(e.layer_graticule())),t.push(EV(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(xV)}getLayers(){return this.layerList.map(e=>e.id)}isLayerVisible(e){return this.layerList.find(t=>t.id===e)?.visible??!1}get credits(){let e=new Set,t=[];for(let n of this.layerList)!n.visible||!n.credit||e.has(n.credit.organisation)||(e.add(n.credit.organisation),t.push(n.credit));return t}setLayerVisible(e,t){this.chosenVisibility.set(e,t);let n=this.layerList.find(t=>t.id===e);!n||n.visible===t||(n.visible=t,this.emit(`layerschange`,this.layers),this.loadVisible(),this.render())}setLayerOpacity(e,t){let n=this.layerList.find(t=>t.id===e);!n||!yH(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 CB}setProjection(e,t={}){this.limitsArmed=!1,this.projectionId=e,this.projectionOptions={...this.projectionOptions,...t},this.projection=wB(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=wB(this.projectionId,this.projectionOptions);else{let e=this.projection.forward(n,r);e&&(this.view={...this.view,centerX:e[0],centerY:e[1]})}}this.loadVisible(),this.render(),this.emit(`viewchange`,this.viewState)}setLimits(e){return this.limits={maxZoom:16,...e},this.render(),this}getLimits(){return{...this.limits}}setTime(e){this.jd=e,this.loadVisible(),this.render()}async setBody(e){e!==this.bodyId&&(this.limitsArmed=!1,await this.adopt(e))}project(e,t){return this.viewport().project(e,t)}unproject(e,t){let n=this.viewport().unproject(e,t);return n?{lon:n[0],lat:n[1]}:null}addPolyline(e){let t=this.overlay.addPolyline(e);return this.render(),t}addPolygon(e){let t=this.overlay.addPolygon(e);return this.render(),t}addBox(e){let t=this.overlay.addBox(e);return this.render(),t}addCircle(e){let t=this.overlay.addCircle(e);return this.render(),t}addMarker(e){let t=this.overlay.addMarker(e);return this.render(),t}clearDrawings(){this.overlay.clear(),this.render()}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),()=>n.delete(t)}once(e,t){let n=((...e)=>{r(),t(...e)});bH.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)bH.get(e)===t&&n.delete(e)}}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of[...n])e(...t)}tier(e){return GV(e,WV(uH.find(([e])=>this.view.zoom>=e)?.[1]??`low`,UV(this.usableSourceWidth())))}usableSourceWidth(){return this.projectionId===`equirectangular`?this.deviceWidth()*this.view.zoom:this.workingWidth()}deviceWidth(){return this.sharpWidth||Math.max(1,this.root.clientWidth)}workingWidth(){let e=this.deviceWidth()*2*this.view.zoom;return Math.min(fH,2**Math.ceil(Math.log2(Math.max(256,e))))}decodeWidth(e){return this.projectionId===`equirectangular`?null:Math.min(this.workingWidth(),HV[e]??fH)}picturesInUse(){return this.layerList.filter(e=>yH(e)&&e.visible).map(e=>{let t=this.tier(e.tiers);return{url:e.url(this.jd,t),tier:t}})}async loadVisible(){let e=this.picturesInUse(),t=this.layerList.filter(e=>!yH(e)&&e.visible&&!!e.prepare).map(e=>e.prepare().then(()=>this.render(),()=>{})),n=e.filter(({url:e,tier:t})=>this.bitmaps.get(e)?.key!==$V(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 eH(e,this.decodeWidth(t));if(!r)return;if(this.disposed||n!==this.generation){nH(r.key);return}this.hold(this.bitmaps,e,r,nH),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)||(nH(n.key),this.bitmaps.delete(t));for(let[t,n]of this.rasters)e.has(t)||(iH(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===$V(e,t))return n.raster;let r=this.bitmaps.get(e)?.bitmap;if(!r)return null;let i=rH(e,t,r);return i?(this.hold(this.rasters,e,i,iH),i.raster):null}dropTextures(){for(let e of this.bitmaps.values())nH(e.key);for(let e of this.rasters.values())iH(e.key);this.bitmaps.clear(),this.rasters.clear()}viewport(e,t){let n=e??this.root.clientWidth??1,r=t??this.root.clientHeight??1;return this.view=cH(this.view,this.projection,n,r,this.limitsArmed?this.limits:{}),new oH(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()},gH),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(dH/(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 oH(this.projection,c,l,this.view);this.clipToDisc(u),this.drawRaster(d,c,l),this.drawVector(u),!this.announcedReady&&this.bitmaps.size>0&&(this.announcedReady=!0,this.emit(`ready`))}record(e,t){if(t<=0)return;let n=e/t;this.msPerPixel=this.msPerPixel===0?n:this.msPerPixel*.7+n*.3}interactionScale(e){if(this.msPerPixel<=0||e<=0)return 1;let t=Math.sqrt(pH/this.msPerPixel/e);return t>hH?1:Math.max(mH,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=>yH(e)&&e.visible);if(i.length===0)return;if(this.projectionId===`equirectangular`){let t=i.map(e=>({image:this.bitmaps.get(e.url(this.jd,this.tier(e.tiers)))?.bitmap,opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);t.length&&IV(r,e,t);return}let a=this.workingWidth(),o=i.map(e=>({image:this.rasterFor(e.url(this.jd,this.tier(e.tiers)),a),opacity:e.opacity,blend:e.blend})).filter(e=>!!e.image);if(o.length===0)return;(!this.buffer||this.buffer.width!==t||this.buffer.height!==n)&&(this.buffer=r.createImageData(t,n));let s=`${this.projectionId}|${JSON.stringify(this.projectionOptions)}|${this.view.zoom}|${this.view.centerX}|${this.view.centerY}|${t}x${n}`,c=!this.lookup||this.lookupKey!==s,l=performance.now();c&&(this.lookup=new PV(e,t,n),this.lookupKey=s),FV(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(yH(t)||!t.visible)continue;let n=document.createElementNS(bV,`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]=aH((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=wB(this.projectionId,this.projectionOptions)}else this.view={...this.view,centerX:this.view.centerX-e/n.scale,centerY:this.view.centerY+t/n.scale};this.renderMoving(),this.emit(`viewchange`,this.viewState)}zoomBy(e,t,n){this.limitsArmed=!0;let r=this.viewport().fromScreen(t,n),i=Math.min(this.limits.maxZoom??1/0,Math.max(1,this.limits.minZoom??1,this.view.zoom*e));if(i===this.view.zoom)return;this.view={...this.view,zoom:i};let a=this.viewport();if(!this.projection.azimuthal){let e=a.fromScreen(t,n);this.view={...this.view,centerX:this.view.centerX+r[0]-e[0],centerY:this.view.centerY+r[1]-e[1]}}this.loadVisible(),this.renderMoving(),this.emit(`viewchange`,this.viewState)}};function SH(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 CH(){return typeof window>`u`?`unsupported`:window.isSecureContext?`DeviceOrientationEvent`in window&&window.matchMedia(`(pointer: coarse)`).matches?`available`:`unsupported`:`insecure`}async function wH(){let e=DeviceOrientationEvent.requestPermission;if(typeof e!=`function`)return!0;try{return await e.call(DeviceOrientationEvent)===`granted`}catch{return!1}}var TH=Math.PI/180,EH=256,DH=128,OH=.05,kH=.25;function AH(e){try{let t=document.createElement(`canvas`);t.width=EH,t.height=DH;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.drawImage(e,0,0,EH,DH);let{data:r}=n.getImageData(0,0,EH,DH),i=new Uint8Array(EH*DH);for(let e=0;e<i.length;e++)i[e]=+(r[e*4+3]>127);return{width:EH,height:DH,covered:i}}catch{return null}}function jH(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]*TH);for(let n=0;n<r;n++)a[e*r+n]&&(c+=t*Math.sin(o[n]*TH),l+=t*Math.cos(o[n]*TH),u+=t)}if(u===0)return t;let d=Math.hypot(c,l)/u<OH?t.heading:MH(Math.atan2(c,l)/TH-n.northOffsetDeg),f=MH(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*kH||(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 MH(e){return(e%360+360)%360}Math.PI/180;function NH(e){return e.orientation!==`unknown`&&e.north_offset_deg!==void 0}function PH(e){return e.id}function FH(e){return`${e.time},${e.lat},${e.lon}`}function IH(e,t){return t?e.find(e=>PH(e)===t||FH(e)===t)??null:null}function LH(e,t,n){let r=e.findIndex(e=>e.id===t.id),i=e=>e&&e.mission===t.mission,a=e=>i(e)?{entry:e,distanceM:zH(t,e,n),bearingDeg:BH(t,e)}:null;return{previous:a(e[r-1]),next:a(e[r+1])}}var RH=Math.PI/180;function zH(e,t,n){return jB(e,t)*RH*n*1e3}function BH(e,t){let n=e.lat*RH,r=t.lat*RH,i=(t.lon-e.lon)*RH,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)/RH%360+360)%360}var VH=Math.PI/180,HH=30,UH=110,WH=85,GH=75,KH=-22,qH=9,JH=6,YH=10,XH=1,ZH=1,QH=new Vi(-Math.SQRT1_2,0,0,Math.SQRT1_2),$H=new J(0,0,1);function eU(e){return(e%360+360)%360}function tU(e,[t,n]){let r=eU(n-t),i=eU(e-t);return i<=r?eU(e):i-r<360-i?eU(n):eU(t)}function nU(e,t,n){return Math.max(t,Math.min(n,e))}function rU(e,t,n=new J){let r=e*VH,i=t*VH;return n.set(Math.sin(r)*Math.cos(i),Math.sin(i),-Math.cos(r)*Math.cos(i))}function iU(){let e=new ml;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 aU=class{bodyId;openAt;openingView;interactive;followArrows;limits={};attribution=null;container=null;root=document.createElement(`div`);renderer=null;controls=null;resizeObserver=null;scene=new Ka;camera=new od(GH,1,.1,1e3);sphere;angleCanvas=document.createElement(`canvas`);angleContext=this.angleCanvas.getContext(`2d`);angleGridVisible=!1;arrows=new Ra;arrowGeometry=new eu(iU());raycaster=new Ld;loader=new qu;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 ba;gyroQuaternion=new Vi;gyroScreen=new Vi;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??GH},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 ks(new nu(500,96,48).scale(-1,1,1),new _s({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 uh({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 fV(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 mx(this.bodyId,!1);if(this.disposed)return;this.entries=(e.global?.panoramas??[]).filter(px),this.radiusKm=SH(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?LH(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&&NH(t)?[`previous`,`next`].map(e=>({key:e,n:this.neighbours?.[e]??null})).filter(e=>e.n&&e.n.distanceM>=ZH).map(e=>({key:e.key,bearingDeg:e.n.bearingDeg})):[]),await this.loadTexture(Kt(`/v1/panoramas/${t.id}.webp`,`panoramas`),t.north_offset_deg??0,!n),this.current===t&&this.emit(`load`,t)}async step(e){let t=this.neighbours?.[e];t&&await this.open(t.entry)}byKey(e){return this.entries.find(t=>t.id===e)??IH(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?tU(t,i.heading):eU(t),pitch:nU(n,i.pitch?.[0]??-WH,i.pitch?.[1]??WH),fov:nU(r,i.fov?.[0]??HH,i.fov?.[1]??UH)},this.invalidate(),this.emit(`viewchange`,this.getView())}getLimits(){return structuredClone(this.limits)}setLimits(e){let t=(e,t,n)=>e&&[nU(e[0],t,n),nU(e[1],t,n)];this.limits={heading:e.heading&&[eU(e.heading[0]),eU(e.heading[1])],pitch:t(e.pitch,-WH,WH),fov:t(e.fov,HH,UH)},this.setView({})}async setGyroEnabled(e){return e===this.gyroEnabled?this.gyroEnabled:e?CH()!==`available`||!await wH()||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*VH,e.alpha*VH,-e.gamma*VH,`YXZ`),this.gyroQuaternion.setFromEuler(this.gyroEuler).multiply(QH).multiply(this.gyroScreen.setFromAxisAngle($H,-(screen.orientation?.angle??0)*VH)),this.gyroDirection.set(0,0,-1).applyQuaternion(this.gyroQuaternion);let t=Math.atan2(this.gyroDirection.x,-this.gyroDirection.z)/VH,n=Math.asin(nU(this.gyroDirection.y,-1,1))/VH;this.gyroOrigin===null&&(this.gyroOrigin=eU(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=AH(e);if(!n)return;let r=this.view.fov,i=2*Math.atan(Math.tan(r/2*VH)*this.camera.aspect)/VH;this.setView(jH(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=Jr,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*VH,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 ks&&e.material.dispose()});for(let t of e){let e=new Ra;e.name=t.key;let n=new ks(this.arrowGeometry,new _s({color:`#000000`,transparent:!0,opacity:.45,side:2,depthWrite:!1}));n.scale.setScalar(1.3);let r=new ks(this.arrowGeometry,new _s({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(rU(t.bearingDeg,KH)).multiplyScalar(qH),e.rotation.y=-t.bearingDeg*VH,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(rU(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+=YH)this.traceAngleLine(n,e,t,r,!0);for(let r=-80;r<=80;r+=YH)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+=YH){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+=YH){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+=XH){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 rU(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)<JH))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())}},oU=Object.fromEntries(yn.map(e=>[e,vn[e].label]));function sU(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 cU(e){return yn.filter(t=>e.credits.orbitSources.has(t)).filter(t=>!vn[t].scoped||sU(e,t)).map(e=>({source:e,info:vn[e]}))}function lU(e,t){let n=e.visibility.focusedSystemId,r=e.visibility.focusedBodyId;return[...t].filter(e=>e.bodyId===r||n&&e.systemId===n)}function uU(e,t=oU){let n=e.credits;n.imageryVersion,n.modelVersion;let r=[...new Set(cU(e).map(({source:e})=>t[e]))],i=new Set;for(let t of lU(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 dU=`https://spacemap.co`,fU=`https://spacemap.co/credits`;function pU(){let e=document.createElement(`div`);return e.className=`sm-attribution`,e}function mU(){let e=document.createElement(`span`);return e.className=`sm-attribution__group`,e}function hU(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 gU=class{stop=null;onAdd(e){let t=pU(),n=mU(),r=mU();return t.append(hU(dU,`spacemap`,`sm-attribution__home`),n,r,hU(fU,i().messages.credits_see_all())),this.stop=ot(()=>{it(()=>{let t=uU(e.ctx);_U(n,i().messages.attribution_orbits(),t.orbits),_U(r,i().messages.attribution_imagery(),t.imagery)})}),t}onRemove(){this.stop?.(),this.stop=null}getDefaultPosition(){return`bottom-right`}};function _U(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 vU=class{off=null;onAdd(e){let t=pU(),n=mU();t.append(hU(dU,`spacemap`,`sm-attribution__home`),n,hU(fU,i().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=`${i().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 yU(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 bU=class{off=null;onAdd(e){let t=pU(),n=mU();t.append(hU(dU,`spacemap`,`sm-attribution__home`),n,hU(fU,i().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=`${i().messages.attribution_imagery()}:`;let a=yU(t.credit_url),o=a?hU(a,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`}},xU=Math.PI/180,SU=Math.cos(ig*xU),CU=Math.sin(ig*xU);function wU(e){return e}function TU(e){let t=[...e.samples].sort((e,t)=>e.jd-t.jd);return{body:e.body??`naif-10`,offsetKm:e=>kU(t,e)}}function EU(e){return{body:e.body??`naif-10`,offsetKm:t=>SF(e.elements,t)?.r??null}}function DU(e,t){let n=tg(e,t);return n.error!==Qh.None&&console.warn(`spacemap: SGP4 will not take this element set (error=${n.error})`),{body:f_,offsetKm:e=>{if(n.error!==Qh.None)return null;let t=_g(n,e);return t&&OU(t[0],t[1],t[2])}}}function OU(e,t,n){return[e,t*SU+n*CU,-t*CU+n*SU]}function kU(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=AU(e,a-1,t),l=AU(e,a,t);g[t]=f*n+p*c*i+m*r+h*c*l}return g}function AU(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 jU(e){return e/rg}var MU=null;function NU(e=G_){return MU||(MU=(async()=>{let t=await e(`${Ut()}/v1/panoramas.json`);if(!t.ok)throw Error(`Failed to load panoramas.json: ${t.status}`);return(await t.json()).bodies??[]})(),MU.catch(()=>MU=null),MU)}async function PU(e){return(await mx(e,!1)).global?.panoramas??[]}async function FU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=RU(t);zU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new yV(l);if(d.mount(u),d.webglError)throw d.unmount(),Error(`spacemap: WebGL is not available`);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new gU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.open(),d.applyInitialView(),await _z(),d}async function IU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=RU(t);zU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new xH(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new vU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}async function LU(e){let{container:t,dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o,controls:s,events:c,...l}=e,u=RU(t);zU({dataUrl:n,imagesUrl:r,locale:i,messages:a,includeNonCommercial:o});let d=new aU(l);d.mount(u);for(let[e,t]of Object.entries(c??{}))d.on(e,t);d.attribution=new bU,d.addControl(d.attribution);for(let e of s??[])d.addControl(e);return await d.load(),d}function RU(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 zU(e){let t={};e.dataUrl!==void 0&&(t.dataUrl=e.dataUrl),e.imagesUrl!==void 0&&(t.imagesUrl=e.imagesUrl),e.locale!==void 0&&(t.locale=()=>e.locale),e.messages!==void 0&&(t.messages=e.messages),e.includeNonCommercial&&(t.textures=`non-commercial`),r(t)}export{gU as AttributionControl,vU as FlatAttributionControl,xH as FlatMap,rV as GestureHandler,hv as MAP_LAYERS,CB as PROJECTION_IDS,bU as PanoramaAttributionControl,aU as PanoramaView,yV as SpaceMap,oH as Viewport,BH as bearingDeg,GB as boxRing,Tz as circlePoints,r as configureHost,IU as createFlatMap,FU as createMap,LU as createPanorama,wB as createProjection,Mg as dateToJD,kx as defaultSceneSettings,EU as elements,NU as fetchPanoramaIndex,PU as fetchPanoramas,IH as findPanorama,wU as fixed,JB as graticule,zH as groundDistanceM,Ng as jdToDate,jU as kmToAu,LH as neighboursOf,PH as panoramaAt,VB as pathFor,Cz as planeBasis,Uz as projectionAspect,TU as samples,KB as smallCircle,DU as tle};
5537
5537
  //# sourceMappingURL=spacemap.js.map
5538
5538
  (function(){if(typeof document==='undefined')return;var s=document.createElement('style');s.textContent=".scene-label{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;touch-action:none;z-index:1;width:32px;height:32px;text-decoration:none;display:block;position:relative;left:0}.scene-label__halo{border-radius:50%;width:100%;height:100%;transition:transform .1s}.scene-label__halo--spacecraft,.scene-label__halo--debris{overflow:visible}.scene-label__loader{box-sizing:border-box;pointer-events:none;border:2px solid #fff;border-color:#fff #fff #fff3 #fff3;border-radius:50%;width:32px;height:32px;margin:auto;animation:.9s linear infinite scene-label-loader-spin;position:fixed;inset:0}@keyframes scene-label-loader-spin{to{transform:rotate(360deg)}}.reduce-motion .scene-label__loader{animation-duration:.9s!important;animation-iteration-count:infinite!important}.scene-label__name{white-space:nowrap;pointer-events:auto;cursor:pointer;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;padding-left:8px;font-size:14px;font-weight:700;text-decoration:none;position:absolute;top:50%;left:32px;transform:translateY(-50%)}.scene-label__name--large{font-size:16px}.scene-label__annotations{top:28px;pointer-events:none;flex-direction:column;padding-inline-start:8px;display:flex;position:absolute;inset-inline-start:32px}.scene-label__annotation{opacity:0;white-space:nowrap;color:#fff9;text-shadow:0 0 3px #000,0 0 3px #000;transition:opacity .15s, display .15s allow-discrete;font-size:11px;line-height:1.3;display:none}.scene-label__annotation--visible{opacity:1;display:block}@starting-style{.scene-label__annotation--visible{opacity:0}}.scene-feature-label{color:#ffffffb3;white-space:nowrap;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;text-shadow:0 0 2px #000,0 0 2px #000;z-index:0;font-size:12px;transition:color .1s;left:0}.scene-feature-label:hover{color:#fff;text-shadow:0 0 3px #000,0 0 3px #000}.scene-feature-label--active{color:#fff;font-size:14px;font-weight:600}.scene-path-label{color:#fff;font:inherit;white-space:nowrap;text-align:start;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;z-index:2;background:0 0;border:0;align-items:center;gap:8px;padding:0;line-height:1.15;display:flex;left:0}.scene-path-label--static{pointer-events:none;cursor:default}.scene-path-label__halo{border-radius:50%;flex-shrink:0;width:32px;height:32px;margin-inline-start:-16px;transition:transform .1s}.scene-path-label:hover .scene-path-label__halo{transform:scale(1.15)}.scene-path-label__text{flex-direction:column;gap:1px;display:flex}.scene-path-label__name{font-size:14px;font-weight:700}.scene-path-label__when{opacity:.8;font-variant-numeric:tabular-nums;font-size:12px}.scene-path-label--dim .scene-path-label__text{display:none}.scene-path-label--dim .scene-path-label__halo{transform:scale(.55)}.scene-path-label--dim:hover .scene-path-label__halo{transform:scale(.75)}.scene-path-label--step .scene-path-label__halo{background:0 0;border:0}.scene-path-label--step:hover .scene-path-label__halo{background:#ffffff1f}.scene-path-label--step .scene-path-label__name{font-size:12px;font-weight:600}.scene-path-label--step .scene-path-label__when{font-size:11px}.scene-path-label__hazard{font-size:11px;font-weight:700}.scene-path-label--lit{color:#fff}.scene-path-label--lit .scene-path-label__halo{transform:scale(1.15)}.scene-path-label--lit.scene-path-label--dim .scene-path-label__halo{transform:scale(.75)}.scene-path-label--faint .scene-path-label__text{display:none}.scene-path-label--faint .scene-path-label__halo{opacity:.45;transform:scale(.5)}.scene-path-label--faint:hover .scene-path-label__halo{opacity:1;transform:scale(.75)}.scene-overlay--no-names .scene-label__name,.scene-overlay--no-names .scene-label__annotations{display:none}.scene-hazard-label{white-space:nowrap;pointer-events:none;-webkit-user-select:none;user-select:none;text-shadow:0 0 4px #000,0 0 4px #000;margin-inline-start:16px;font-size:12px;font-weight:700;position:relative;left:0}.user-location-marker{pointer-events:none;background:#1a73e8;border:2px solid #fff;border-radius:50%;width:16px;height:16px;box-shadow:0 0 6px #0006}.sm-drawing-label{white-space:nowrap;color:#fff;text-shadow:0 0 4px #000,0 0 4px #000;-webkit-user-select:none;user-select:none;pointer-events:none;font:700 14px/1.2 system-ui,sans-serif}.sm-drawing-icon{-webkit-user-select:none;user-select:none;pointer-events:none;display:block}.sm-drawing--interactive{pointer-events:auto;cursor:pointer;touch-action:none}.sm-cooperative-hint{z-index:4;color:#fff;text-align:center;pointer-events:none;opacity:0;background:#0000008c;place-content:center;padding:16px;font:15px/1.4 system-ui,sans-serif;transition:opacity .2s;display:grid;position:absolute;inset:0}.sm-cooperative-hint--shown{opacity:1}@media (prefers-reduced-motion:reduce){.sm-cooperative-hint{transition:none}}.sm-ctrl{z-index:2;pointer-events:none;flex-direction:column;gap:6px;max-width:100%;padding:6px;display:flex;position:absolute}.sm-ctrl>*{pointer-events:auto}.sm-ctrl--top-left{align-items:flex-start;top:0;left:0}.sm-ctrl--top-right{align-items:flex-end;top:0;right:0}.sm-ctrl--bottom-left{align-items:flex-start;bottom:0;left:0}.sm-ctrl--bottom-right{align-items:flex-end;bottom:0;right:0}.sm-map{-webkit-user-select:none;user-select:none;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-ctrl:has(>.sm-attribution:only-child){padding:0}.sm-ctrl--top-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 var(--sm-attribution-radius) 0}.sm-ctrl--top-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 0 0 var(--sm-attribution-radius)}.sm-ctrl--bottom-left:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:0 var(--sm-attribution-radius) 0 0}.sm-ctrl--bottom-right:has(>.sm-attribution:only-child)>.sm-attribution{border-radius:var(--sm-attribution-radius) 0 0 0}.sm-attribution{--sm-attribution-radius:3px;border-radius:var(--sm-attribution-radius);color:#ffffffbf;white-space:nowrap;background:#0006;align-items:center;gap:.5em;max-width:100%;padding:1px 6px;font:11px/1.45 system-ui,sans-serif;display:flex}.sm-attribution a{color:inherit;text-decoration:none}.sm-attribution a:hover{color:#fff;text-decoration:underline}.sm-attribution__home{font-weight:600}.sm-attribution__group{text-overflow:ellipsis;overflow:hidden}.sm-attribution__label{color:#ffffff80}\n/*$vite$:1*/";document.head.appendChild(s);})();